forked from Daizee/spitfireii
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCity.h
More file actions
206 lines (158 loc) · 5.02 KB
/
City.h
File metadata and controls
206 lines (158 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//
// City.h
// Project Spitfire
//
// Copyright (c) 2013 Daizee (rensiadz at gmail dot com)
//
// This file is part of Spitfire.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "funcs.h"
#include "structs.h"
class Client;
char * GetBuildingName(int id);
class City
{
public:
City();
~City(void);
bool SetBuilding(int16_t type, int16_t level, int16_t position, int16_t status = 0, double starttime = 0, double endtime = 0);
void SetResources(int64_t gold, int64_t food, int64_t wood, int64_t stone, int64_t iron);
void SetForts(int32_t traps, int32_t abatis, int32_t towers, int32_t logs, int32_t trebs);
int32_t GetForts(int32_t type);
string m_cityname;
int8_t m_status;
int32_t m_tileid;
int8_t m_type;
int8_t m_level;
int8_t m_loyalty;
int8_t m_grievance;
stResources m_resources;
stResources m_maxresources;
stForts m_forts;
stBuilding m_innerbuildings[35]; // 735 bytes
stBuilding m_outerbuildings[41]; // 840 bytes
//
// public bool m_npc = true;
// public Client m_client = null;
// public int m_herocount = 0;
// public ArrayList m_heroes = new ArrayList();
// public bool m_allowAlliance = false;
// //public ArrayList m_buildings = new ArrayList();
// public Building[] m_buildings;
};
class NpcCity: public City
{
public:
NpcCity();
~NpcCity(void);
void Initialize(bool resources, bool troops);
void SetTroops(int32_t warrior, int32_t pike, int32_t sword, int32_t archer, int32_t cavalry);
void SetupBuildings();
void CalculateStats(bool resources, bool troops);
struct stTroops
{
int32_t warrior;
int32_t pike;
int32_t sword;
int32_t archer;
int32_t cavalry;
} m_troops, m_maxtroops;
stForts m_maxforts;
Hero * m_temphero;
uint64_t m_calculatestuff;
int32_t m_ownerid;
};
class PlayerCity: public City
{
public:
PlayerCity();
~PlayerCity(void);
Client * m_client;
uint32_t m_castleid;
uint64_t m_castleinternalid;
int64_t m_accountid;
string m_logurl;
int32_t m_population;
uint32_t m_availablepopulation;
uint32_t m_maxpopulation;
bool m_allowalliance;
bool m_gooutforbattle;
bool m_hasenemy;
double m_creation;
bool m_researching;
double m_lastcomfort;
double m_lastlevy;
stTroops m_troops, m_injuredtroops; // size 44 bytes
stResources m_production;
stResources m_workpopulation;
stResources m_workrate;
stResources m_storepercent;
double m_productionefficiency;
int32_t m_resourcebaseproduction;
double m_resourcemanagement;
int32_t m_resourcetech;
int32_t m_resourcevalley;
double m_troopconsume;
struct stTimers
{
double updateresources;
} m_timers;
Hero * m_heroes[10]; // 75 bytes * 10
Hero * m_innheroes[10]; // 75 bytes * 10
Hero * m_mayor;
amf3object ToObject();
amf3array Buildings();
amf3object Troops();
amf3object InjuredTroops();
amf3object Resources();
amf3array HeroArray();
amf3object Fortifications();
void SetTroops(int8_t type, int64_t amount);
void SetForts(int32_t type, int32_t count);
int64_t GetTroops(int8_t type);
bool HasTroops(stTroops & troops);
void SetMaxResources(int64_t food, int64_t wood, int64_t stone, int64_t iron);
void ParseBuildings(string str);
void ParseTroops(string str);
void ParseFortifications(string str);
void ParseMisc(string str);
bool CheckBuildingPrereqs(int16_t type, int16_t level);
void CalculateStats();
void CalculateResources();
void RecalculateCityStats();
void CalculateResourceStats();
void CastleUpdate();
void ResourceUpdate();
void HeroUpdate(Hero * hero, int16_t updatetype);
void TroopUpdate();
void FortUpdate();
int16_t GetReliefMultiplier();
amf3array ResourceProduceData();
vector<stTroopQueue> m_troopqueue;
vector<stArmyMovement*> armymovement;
int16_t HeroCount();
Hero * GetHero(uint64_t id);
stTroopQueue * GetBarracksQueue(int16_t position);
int8_t AddToBarracksQueue(int8_t position, int16_t troopid, int32_t count, bool isshare, bool isidle);
int16_t GetBuildingLevel(int16_t id);
stBuilding * GetBuilding(int16_t position);
int16_t GetTechLevel(int16_t id);
int16_t GetBuildingCount(int16_t id);
}; // 3,448 + base