Pol  Revision:4b29d2b
uvars.h
Go to the documentation of this file.
1 
7 #ifndef __UVARS_H
8 #define __UVARS_H
9 
10 #include <array>
11 #include <boost/noncopyable.hpp>
12 #include <map>
13 #include <queue>
14 #include <set>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 #include "../../clib/maputil.h"
20 #include "../../clib/rawtypes.h"
21 #include "../../clib/refptr.h"
22 #include "../../clib/threadhelp.h"
23 #include "../action.h"
24 #include "../clidata.h"
25 #include "../cmdlevel.h"
26 #include "../layers.h"
27 #include "../menu.h"
28 #include "../reftypes.h"
29 #include "../region.h"
30 #include "../schedule.h"
31 #include "../storage.h"
32 #include "../syshook.h"
33 #include "../target.h"
34 #include "../tasks.h"
35 #include "../textcmd.h"
36 #include "../uoskills.h"
37 
38 
39 namespace Pol
40 {
41 namespace Realms
42 {
43 class Realm;
44 }
45 namespace Items
46 {
47 class Equipment;
48 class Item;
49 class ItemDesc;
50 class UWeapon;
51 }
52 namespace Mobile
53 {
54 class Attribute;
55 }
56 namespace Network
57 {
58 class Client;
59 }
60 namespace Multi
61 {
62 struct BoatShape;
63 }
64 namespace Core
65 {
66 class ConsoleCommand;
67 class Guild;
68 class JusticeRegion;
69 class LightRegion;
70 class ListenPoint;
71 class MusicRegion;
72 class NoCastRegion;
73 class NpcTemplate;
74 class NpcTemplateElem;
75 class Party;
76 class PropertyList;
77 class ResourceDef;
78 class SpellCircle;
79 class StartingLocation;
80 class UOExecutor;
81 class USpell;
82 class Vital;
83 class WeatherDef;
84 
85 typedef std::vector<Core::CmdLevel> CmdLevels;
86 
87 typedef std::vector<AccountRef> AccountsVector;
88 class ItemsVector : public std::vector<Items::Item*>
89 {
90 };
91 
92 typedef std::vector<StartingLocation*> StartingLocations;
97 
98 typedef std::map<std::string, NpcTemplateElem, Clib::ci_cmp_pred> NpcTemplatesElems;
99 typedef std::map<std::string, NpcTemplate*> NpcTemplates;
100 
102 typedef std::vector<PartyRef> Parties;
104 typedef std::map<unsigned int, GuildRef> Guilds;
105 
106 typedef std::map<std::string, Mobile::Attribute*, Clib::ci_cmp_pred> AttributesByName;
107 
108 typedef std::vector<ArmorZone> ArmorZones;
109 typedef std::map<std::string, Vital*, Clib::ci_cmp_pred> VitalsByName;
110 typedef std::map<unsigned int, unsigned int> OldObjtypeConversions;
111 typedef std::map<std::string, u32, Clib::ci_cmp_pred> ObjtypeByNameMap;
112 typedef std::map<std::string, ResourceDef*> ResourceDefs;
113 typedef std::pair<std::string /* name */, u8 /* layer */> NameAndLayer;
114 typedef std::map<NameAndLayer, Items::Equipment*> IntrinsicEquipments;
115 typedef std::map<u16 /* graphic */, Multi::BoatShape*> BoatShapes;
116 typedef std::map<UOExecutor*, ListenPoint*> ListenPoints;
117 typedef std::priority_queue<ScheduledTask*, std::vector<ScheduledTask*>, SchComparer> TaskQueue;
118 typedef std::set<std::string> PropSet;
119 
120 typedef void ( *TextCmdFunc )( Network::Client* );
121 typedef std::map<std::string, TextCmdFunc, Clib::ci_cmp_pred> TextCmds;
122 typedef void ( *ParamTextCmdFunc )( Network::Client*, const char* );
123 typedef std::map<std::string, ParamTextCmdFunc, wordicmp> ParamTextCmds;
124 
125 
126 class GameState : boost::noncopyable
127 {
128 public:
129  GameState();
130  ~GameState();
131 
132  void deinitialize();
133  struct Memory;
134 
135  Memory estimateSize() const;
136 
137  CmdLevels cmdlevels;
138 
139  NpcTemplates npc_templates;
140  NpcTemplatesElems npc_template_elems;
141 
142  std::unique_ptr<Core::PropertyList> global_properties;
143 
144  AccountsVector accounts;
145  StartingLocations startlocations;
147 
148  JusticeDef* justicedef;
149  NoCastDef* nocastdef;
150  LightDef* lightdef;
152  MusicDef* musicdef;
153 
154  std::vector<Menu> menus;
155 
157 
158  Parties parties;
159  Guilds guilds;
160  unsigned int nextguildid;
161 
163  std::vector<Realms::Realm*> Realms;
164  std::map<int, Realms::Realm*> shadowrealms_by_id;
165  unsigned int baserealm_count;
166  unsigned int shadowrealm_count;
167 
168  std::unique_ptr<PeriodicTask> update_rpm_task;
169  std::unique_ptr<PeriodicTask> regen_stats_task;
170  std::unique_ptr<PeriodicTask> regen_resources_task;
171  std::unique_ptr<PeriodicTask> reload_accounts_task;
172  std::unique_ptr<PeriodicTask> write_account_task;
173  std::unique_ptr<PeriodicTask> update_sysload_task;
174  std::unique_ptr<PeriodicTask> reload_pol_cfg_task;
175 
176  std::vector<Mobile::Attribute*> attributes;
177  unsigned numAttributes;
178  AttributesByName attributes_byname;
184 
185  std::array<std::array<u32, 2>, 8> spell_scroll_objtype_limits;
186  std::vector<USpell*> spells;
187  std::vector<SpellCircle*> spellcircles;
188 
189  std::vector<ExportScript*> export_scripts;
191 
192  std::vector<std::string> tipfilenames;
193 
194  ArmorZones armorzones;
196 
197  std::vector<Vital*> vitals;
198  unsigned numVitals;
202  VitalsByName vitals_byname;
203 
204  std::map<u32, Items::ItemDesc*> desctable;
205  OldObjtypeConversions old_objtype_conversions;
206  std::vector<Items::ItemDesc*> dynamic_item_descriptors;
207  ObjtypeByNameMap objtype_byname;
208  std::unique_ptr<Items::ItemDesc> empty_itemdesc;
209  std::unique_ptr<Items::ItemDesc> temp_itemdesc;
210 
211  ResourceDefs resourcedefs;
212 
213  IntrinsicEquipments intrinsic_equipments;
214 
215  BoatShapes boatshapes;
216 
217  UACTION mount_action_xlate[ACTION__HIGHEST + 1];
218  std::map<std::string, MobileTranslate> animation_translates;
219 
220  std::vector<ConsoleCommand> console_commands;
221 
222  std::array<LandTile, LANDTILE_COUNT> landtiles;
224 
225  ListenPoints listen_points;
226 
228  std::map<std::string, std::string> mime_types;
229 
230  TaskQueue task_queue;
231 
233 
235 
236  TextCmds textcmds;
237  ParamTextCmds paramtextcmds;
238 
239  std::vector<UOSkill> uo_skills;
240 
241  struct Memory
242  {
243  size_t account_size;
245  size_t realm_size;
246  size_t misc;
247  };
249 private:
250  void cleanup_vars();
251  void cleanup_scripts();
252  void clear_listen_points();
253  void unload_intrinsic_weapons();
254  void unload_intrinsic_templates();
255  void unload_npc_templates();
256 };
257 extern GameState gamestate;
258 }
259 }
260 #endif
unsigned char u8
Definition: rawtypes.h:25
NpcTemplates npc_templates
Definition: uvars.h:139
std::map< std::string, ParamTextCmdFunc, wordicmp > ParamTextCmds
Definition: uvars.h:123
AccountsVector accounts
Definition: uvars.h:144
PropSet Global_Ignore_CProps
Definition: uvars.h:232
TaskQueue task_queue
Definition: uvars.h:230
std::map< std::string, std::string > mime_types
Definition: uvars.h:228
std::vector< Items::ItemDesc * > dynamic_item_descriptors
Definition: uvars.h:206
IntrinsicEquipments intrinsic_equipments
Definition: uvars.h:213
std::vector< StartingLocation * > StartingLocations
Definition: uvars.h:92
Cursors target_cursors
Definition: uvars.h:234
threadhelp::TaskThreadPool task_thread_pool
Definition: uvars.h:248
const Vital * pVitalLife
Definition: uvars.h:199
std::unique_ptr< PeriodicTask > update_rpm_task
Definition: uvars.h:168
const Mobile::Attribute * pAttrParry
Definition: uvars.h:182
SystemHooks system_hooks
Definition: uvars.h:190
MusicDef * musicdef
Definition: uvars.h:152
std::vector< UOSkill > uo_skills
Definition: uvars.h:239
std::map< NameAndLayer, Items::Equipment * > IntrinsicEquipments
Definition: uvars.h:114
void(* TextCmdFunc)(Network::Client *)
Definition: uvars.h:120
ResourceDefs resourcedefs
Definition: uvars.h:211
RegionGroup< MusicRegion > MusicDef
Definition: uvars.h:96
TextCmds textcmds
Definition: uvars.h:236
AttributesByName attributes_byname
Definition: uvars.h:178
std::map< std::string, NpcTemplateElem, Clib::ci_cmp_pred > NpcTemplatesElems
Definition: uvars.h:98
std::unique_ptr< Core::PropertyList > global_properties
Definition: uvars.h:142
CmdLevels cmdlevels
Definition: uvars.h:137
std::map< std::string, Vital *, Clib::ci_cmp_pred > VitalsByName
Definition: uvars.h:109
VitalsByName vitals_byname
Definition: uvars.h:202
LightDef * lightdef
Definition: uvars.h:150
std::map< u16, Multi::BoatShape * > BoatShapes
Definition: uvars.h:115
const Mobile::Attribute * pAttrTactics
Definition: uvars.h:183
std::vector< PartyRef > Parties
Definition: uvars.h:102
ListenPoints listen_points
Definition: uvars.h:225
std::unique_ptr< Items::ItemDesc > temp_itemdesc
Definition: uvars.h:209
unsigned int nextguildid
Definition: uvars.h:160
std::unique_ptr< Items::ItemDesc > empty_itemdesc
Definition: uvars.h:208
unsigned short u16
Definition: rawtypes.h:26
std::map< std::string, u32, Clib::ci_cmp_pred > ObjtypeByNameMap
Definition: uvars.h:111
std::map< std::string, ResourceDef * > ResourceDefs
Definition: uvars.h:112
std::vector< Menu > menus
Definition: uvars.h:154
std::vector< Core::CmdLevel > CmdLevels
Definition: uvars.h:83
std::map< std::string, MobileTranslate > animation_translates
Definition: uvars.h:218
std::vector< ConsoleCommand > console_commands
Definition: uvars.h:220
void(* ParamTextCmdFunc)(Network::Client *, const char *)
Definition: uvars.h:122
std::vector< std::string > tipfilenames
Definition: uvars.h:192
Plib::Package * wwwroot_pkg
Definition: uvars.h:227
const Mobile::Attribute * pAttrStrength
Definition: uvars.h:179
Definition: refptr.h:65
std::vector< Realms::Realm * > Realms
Definition: uvars.h:163
unsigned int shadowrealm_count
Definition: uvars.h:166
NpcTemplatesElems npc_template_elems
Definition: uvars.h:140
std::map< unsigned int, GuildRef > Guilds
Definition: uvars.h:104
bool landtiles_loaded
Definition: uvars.h:223
JusticeDef * justicedef
Definition: uvars.h:148
Parties parties
Definition: uvars.h:158
ParamTextCmds paramtextcmds
Definition: uvars.h:237
std::array< LandTile, LANDTILE_COUNT > landtiles
Definition: uvars.h:222
std::vector< Mobile::Attribute * > attributes
Definition: uvars.h:176
std::map< unsigned int, unsigned int > OldObjtypeConversions
Definition: uvars.h:110
std::array< std::array< u32, 2 >, 8 > spell_scroll_objtype_limits
Definition: uvars.h:185
NoCastDef * nocastdef
Definition: uvars.h:149
std::map< std::string, TextCmdFunc, Clib::ci_cmp_pred > TextCmds
Definition: uvars.h:121
const Vital * pVitalStamina
Definition: uvars.h:200
GameState gamestate
Definition: uvars.cpp:74
const Vital * pVitalMana
Definition: uvars.h:201
std::vector< USpell * > spells
Definition: uvars.h:186
std::unique_ptr< PeriodicTask > regen_resources_task
Definition: uvars.h:170
unsigned numVitals
Definition: uvars.h:198
std::vector< ArmorZone > ArmorZones
Definition: uvars.h:108
void clear_listen_points()
RegionGroup< JusticeRegion > JusticeDef
Definition: uvars.h:93
std::unique_ptr< PeriodicTask > update_sysload_task
Definition: uvars.h:173
std::unique_ptr< PeriodicTask > regen_stats_task
Definition: uvars.h:169
ArmorZones armorzones
Definition: uvars.h:194
const Mobile::Attribute * pAttrIntelligence
Definition: uvars.h:180
std::set< std::string > PropSet
Definition: uvars.h:118
ObjtypeByNameMap objtype_byname
Definition: uvars.h:207
RegionGroup< LightRegion > LightDef
Definition: uvars.h:95
std::pair< std::string, u8 > NameAndLayer
Definition: uvars.h:113
OldObjtypeConversions old_objtype_conversions
Definition: uvars.h:205
std::vector< AccountRef > AccountsVector
Definition: uvars.h:87
std::vector< ExportScript * > export_scripts
Definition: uvars.h:189
unsigned numAttributes
Definition: uvars.h:177
RegionGroup< NoCastRegion > NoCastDef
Definition: uvars.h:94
std::map< u32, Items::ItemDesc * > desctable
Definition: uvars.h:204
WeatherDef * weatherdef
Definition: uvars.h:151
double armor_zone_chance_sum
Definition: uvars.h:195
const Mobile::Attribute * pAttrDexterity
Definition: uvars.h:181
StartingLocations startlocations
Definition: uvars.h:145
BoatShapes boatshapes
Definition: uvars.h:215
std::priority_queue< ScheduledTask *, std::vector< ScheduledTask * >, SchComparer > TaskQueue
Definition: uvars.h:117
Items::UWeapon * wrestling_weapon
Definition: uvars.h:146
ref_ptr< Party > PartyRef
Definition: uvars.h:101
std::map< int, Realms::Realm * > shadowrealms_by_id
Definition: uvars.h:164
unsigned int baserealm_count
Definition: uvars.h:165
std::vector< SpellCircle * > spellcircles
Definition: uvars.h:187
std::map< std::string, NpcTemplate * > NpcTemplates
Definition: uvars.h:99
Realms::Realm * main_realm
Definition: uvars.h:162
Storage storage
Definition: uvars.h:156
Definition: berror.cpp:12
std::unique_ptr< PeriodicTask > reload_pol_cfg_task
Definition: uvars.h:174
std::map< std::string, Mobile::Attribute *, Clib::ci_cmp_pred > AttributesByName
Definition: uvars.h:106
ref_ptr< Guild > GuildRef
Definition: uvars.h:103
std::vector< Vital * > vitals
Definition: uvars.h:197
std::unique_ptr< PeriodicTask > write_account_task
Definition: uvars.h:172
std::unique_ptr< PeriodicTask > reload_accounts_task
Definition: uvars.h:171
std::map< UOExecutor *, ListenPoint * > ListenPoints
Definition: uvars.h:116