Pol  Revision:cb584c9
cgdata.cpp
Go to the documentation of this file.
1 
8 #include "cgdata.h"
9 
10 #include <cstddef>
11 
12 #include "../containr.h"
13 #include "../fnsearch.h"
14 #include "../mobile/npc.h"
15 #include "../module/osmod.h"
16 #include "../module/unimod.h"
17 #include "../module/uomod.h"
18 #include "../multi/customhouses.h"
19 #include "../multi/house.h"
20 #include "../multi/multi.h"
21 #include "../uoexec.h"
22 
23 namespace Pol
24 {
25 namespace Network
26 {
28  : vendor( nullptr ),
29  gumpmods(),
30  textentry_uoemod( nullptr ),
31  target_cursor_uoemod( nullptr ),
32  menu_selection_uoemod( nullptr ),
33  popup_menu_selection_uoemod( nullptr ),
34  prompt_uoemod( nullptr ),
35  resurrect_uoemod( nullptr ),
36  selcolor_uoemod( nullptr ),
37  prompt_uniemod( nullptr ),
38  justice_region( nullptr ),
39  lightlevel( 0 ),
40  // light_region(nullptr),
41  music_region( nullptr ),
42  weather_region( nullptr ),
43  custom_house_serial( 0 )
44 {
45 }
46 
48 {
49  clear();
50 }
51 
53 {
54  while ( !gumpmods.empty() )
55  {
56  GumpMods::iterator it = gumpmods.begin();
57  Module::UOExecutorModule* uoemod = it->second;
58  uoemod->uoexec.os_module->revive();
59  uoemod->gump_chr = nullptr;
60  gumpmods.erase( it );
61  }
62 
63  if ( textentry_uoemod != nullptr )
64  {
67  textentry_uoemod = nullptr;
68  }
69 
70  if ( menu_selection_uoemod != nullptr )
71  {
74  menu_selection_uoemod = nullptr;
75  }
76 
77  if ( popup_menu_selection_uoemod != nullptr )
78  {
83  }
84 
85  if ( prompt_uoemod != nullptr )
86  {
88  prompt_uoemod->prompt_chr = nullptr;
89  prompt_uoemod = nullptr;
90  }
91 
92  if ( resurrect_uoemod != nullptr )
93  {
96  resurrect_uoemod = nullptr;
97  }
98 
99  if ( selcolor_uoemod != nullptr )
100  {
102  selcolor_uoemod->selcolor_chr = nullptr;
103  selcolor_uoemod = nullptr;
104  }
105 
106  if ( target_cursor_uoemod != nullptr )
107  {
110  target_cursor_uoemod = nullptr;
111  }
112 
113  if ( prompt_uniemod != nullptr )
114  {
116  prompt_uniemod->prompt_chr = nullptr;
117  prompt_uniemod = nullptr;
118  }
119  if ( custom_house_serial != 0 )
120  {
122  if ( multi != nullptr )
123  {
124  Multi::UHouse* house = multi->as_house();
125  if ( house != nullptr )
126  {
127  house->CurrentDesign.FillComponents( house );
128  house->WorkingDesign.FillComponents( house, false ); // keep in sync
129  house->revision++;
130  std::vector<u8> newvec;
131  house->WorkingCompressed.swap( newvec );
132 
133  std::vector<u8> newvec2;
134  house->CurrentCompressed.swap( newvec2 );
135  house->editing = false;
136  }
137  }
139  }
140 }
141 
144 {
145  gumpmods[gumpid] = uoemod;
146 }
147 
150 {
151  GumpMods::iterator it = gumpmods.find( gumpid );
152  if ( it == gumpmods.end() )
153  return nullptr;
154  return it->second;
155 }
156 
159 {
160  for ( GumpMods::const_iterator it = gumpmods.cbegin(); it != gumpmods.cend(); /* no inc here */ )
161  if ( it->second == uoemod )
162  gumpmods.erase( it++ );
163  else
164  ++it;
165 }
166 
168 {
169  size_t size = sizeof( ClientGameData );
170  size += 3 * sizeof( void* ) +
171  gumpmods.size() * ( sizeof( Module::UOExecutorModule* ) + 3 * sizeof( void* ) );
172  return size;
173 }
174 }
175 }
Module::UOExecutorModule * popup_menu_selection_uoemod
Definition: cgdata.h:63
CustomHouseDesign WorkingDesign
Definition: house.h:79
Mobile::Character * gump_chr
Definition: uomod.h:304
Mobile::Character * prompt_chr
Definition: uomod.h:303
Core::UOExecutor & uoexec
Definition: unimod.h:52
Module::UOExecutorModule * textentry_uoemod
Definition: cgdata.h:53
Core::UOExecutor & uoexec
Definition: uomod.h:291
Mobile::Character * resurrect_chr
Definition: uomod.h:306
CustomHouseDesign CurrentDesign
Definition: house.h:78
std::vector< u8 > CurrentCompressed
Definition: house.h:81
int lightlevel(unsigned short x, unsigned short y)
Module::UOExecutorModule * find_gumpmod(u32 gumpid)
Given a gumpid, finds the module that registered it, returns nullptr if not found.
Definition: cgdata.cpp:149
unsigned int u32
Definition: rawtypes.h:27
Multi::UMulti * system_find_multi(u32 serial)
Definition: fnsearch.cpp:50
virtual class UHouse * as_house()
Definition: multis.cpp:55
size_t estimatedSize() const
Definition: cgdata.cpp:167
Mobile::Character * target_cursor_chr
Definition: uomod.h:299
Module::UOExecutorModule * prompt_uoemod
Definition: cgdata.h:64
Module::UOExecutorModule * selcolor_uoemod
Definition: cgdata.h:66
Module::UOExecutorModule * resurrect_uoemod
Definition: cgdata.h:65
Module::UnicodeExecutorModule * prompt_uniemod
Definition: cgdata.h:68
Core::UObject * popup_menu_selection_above
Definition: uomod.h:302
void FillComponents(UHouse *house, bool add_as_component=true)
Mobile::Character * popup_menu_selection_chr
Definition: uomod.h:301
void add_gumpmod(Module::UOExecutorModule *, u32 gumpid)
Registers a gumpid for the given module.
Definition: cgdata.cpp:143
Mobile::Character * menu_selection_chr
Definition: uomod.h:300
Module::UOExecutorModule * target_cursor_uoemod
Definition: cgdata.h:61
std::vector< u8 > WorkingCompressed
Definition: house.h:82
Mobile::Character * selcolor_chr
Definition: uomod.h:307
Module::UOExecutorModule * menu_selection_uoemod
Definition: cgdata.h:62
void remove_gumpmods(Module::UOExecutorModule *)
Removes all the registered gumpids for a given module.
Definition: cgdata.cpp:158
Mobile::Character * prompt_chr
Definition: unimod.h:63
Definition: berror.cpp:12
Module::OSExecutorModule * os_module
Definition: uoexec.h:37
Mobile::Character * textentry_chr
Definition: uomod.h:305