19 #include "../clib/clib_endian.h" 20 #include "../clib/logfacility.h" 21 #include "../clib/passert.h" 38 zone.
items.push_back( item );
44 if ( item->
container ==
nullptr && !item->has_gotten_by() )
48 if ( multi !=
nullptr )
54 ZoneItems::iterator itr = std::find( zone.
items.begin(), zone.
items.end(), item );
55 if ( itr == zone.
items.end() )
58 "remove_item_from_world: item 0x{:X} at {},{} does not exist in world zone ( Old Serial: " 66 zone.
items.erase( itr );
72 zone.
multis.push_back( multi );
79 ZoneMultis::iterator itr = std::find( zone.
multis.begin(), zone.
multis.end(), multi );
93 if ( &oldzone != &newzone )
95 ZoneMultis::iterator itr = std::find( oldzone.
multis.begin(), oldzone.
multis.end(), multi );
98 oldzone.
multis.erase( itr );
99 newzone.
multis.push_back( multi );
102 if ( multi->
realm != oldrealm )
113 count += realm->toplevel_item_count();
121 count += realm->mobile_count();
133 passert( std::find(
set.begin(),
set.end(), chr ) ==
set.end() );
134 set.push_back( chr );
138 set_pos( zone.
npcs );
154 auto itr = std::find(
set.begin(),
set.end(), chr );
155 if ( itr ==
set.end() )
168 clear_pos( zone.
npcs );
175 if ( oldrealm ==
nullptr )
176 oldrealm = chr->
realm;
185 if ( &oldzone != &newzone )
188 auto oldset_itr = std::find( oldset.begin(), oldset.end(), chr );
191 passert( oldset_itr != oldset.end() );
193 passert( std::find( newset.begin(), newset.end(), chr ) == newset.end() );
195 oldset.erase( oldset_itr );
196 newset.push_back( chr );
202 move_pos( oldzone.
npcs, newzone.
npcs );
207 if ( chr->
realm != oldrealm )
217 if ( oldrealm ==
nullptr )
218 oldrealm = item->
realm;
223 if ( &oldzone != &newzone )
225 ZoneItems::iterator itr = std::find( oldzone.
items.begin(), oldzone.
items.end(), item );
227 if ( itr == oldzone.
items.end() )
230 "MoveItemWorldPosition: item 0x{:X} at old-x/y({},{} - {}) new-x/y({},{} - {}) does not " 231 "exist in world zone. \n" )
232 << item->
serial << oldx << oldy << oldrealm->
name() << item->
x << item->
y 238 oldzone.
items.erase( itr );
241 newzone.
items.push_back( item );
244 if ( oldrealm != item->
realm )
259 std::string msgreason =
"unknown reason";
263 msgreason =
"Client Exit";
266 msgreason =
"NPC death";
273 "ClrCharacterWorldPosition({}): mob (0x{:X},0x{:X}) supposedly at ({},{}) isn't in correct " 278 for (
unsigned zonex = 0; zonex < wgridx; ++zonex )
280 for (
unsigned zoney = 0; zoney < wgridy; ++zoney )
286 found = std::find( _z.begin(), _z.end(), chr ) != _z.end();
291 found = std::find( _z.begin(), _z.end(), chr ) != _z.end();
294 POLLOG_ERROR.Format(
"ClrCharacterWorldPosition: Found mob in zone ({},{})\n" )
307 for (
const auto& item : witem )
309 unsigned short wx, wy;
311 if ( wx != x || wy != y )
313 POLLOG_ERROR.Format(
"Item 0x{:X} in zone ({},{}) but location is ({},{}) (zone {},{})\n" )
314 << item->serial << x << y << item->x << item->y << wx << wy;
321 POLLOG_ERROR.Format(
"item integ problem at zone ({},{})\n" ) << x << y;
333 unsigned int gridwidth = realm->grid_width();
334 unsigned int gridheight = realm->grid_height();
336 for (
unsigned x = 0; x < gridwidth; ++x )
338 for (
unsigned y = 0; y < gridheight; ++y )
364 unsigned int gridwidth = realm->grid_width();
365 unsigned int gridheight = realm->grid_height();
368 unsigned short wx, wy;
370 if ( wx != x || wy != y )
371 INFO_PRINT <<
"Character 0x" << fmt::hexu( chr->
serial ) <<
" in a zone, but elsewhere\n";
374 for (
unsigned x = 0; x < gridwidth; ++x )
376 for (
unsigned y = 0; y < gridheight; ++y )
378 for (
const auto& chr : realm->zone[x][y].characters )
379 check_zone( chr, y, x );
380 for (
const auto& chr : realm->zone[x][y].npcs )
381 check_zone( chr, y, x );
392 unsigned int gridwidth = realm->grid_width();
393 unsigned int gridheight = realm->grid_height();
395 for (
unsigned x = 0; x < gridwidth; ++x )
397 for (
unsigned y = 0; y < gridheight; ++y )
399 realm->zone[x][y].characters.shrink_to_fit();
400 realm->zone[x][y].npcs.shrink_to_fit();
401 realm->zone[x][y].items.shrink_to_fit();
402 realm->zone[x][y].multis.shrink_to_fit();
bool check_single_zone_item_integrity(int, int, Realms::Realm *)
void remove_multi(const Multi::UMulti &multi)
int get_toplevel_item_count()
void remove_toplevel_item(const Items::Item &item)
void add_item_to_world(Items::Item *item)
void check_character_integrity()
void SetCharacterWorldPosition(Mobile::Character *chr, Realms::WorldChangeReason reason)
const std::string name() const
void remove_item_from_world(Items::Item *item)
void add_multi_to_world(Multi::UMulti *multi)
ZoneCharacters characters
std::vector< Items::Item * > ZoneItems
std::vector< Realms::Realm * > Realms
void add_toplevel_item(const Items::Item &item)
unsigned short grid_width() const
void add_multi(const Multi::UMulti &multi)
unsigned short grid_height() const
void remove_mobile(const Mobile::Character &chr, WorldChangeReason reason)
Core::UContainer * container
void ClrCharacterWorldPosition(Mobile::Character *chr, Realms::WorldChangeReason reason)
Zone & getzone(unsigned short x, unsigned short y, Realms::Realm *realm)
void add_mobile(const Mobile::Character &chr, WorldChangeReason reason)
std::vector< Mobile::Character * > ZoneCharacters
void MoveCharacterWorldPosition(unsigned short oldx, unsigned short oldy, unsigned short newx, unsigned short newy, Mobile::Character *chr, Realms::Realm *oldrealm)
void zone_convert(unsigned short x, unsigned short y, unsigned short *wx, unsigned short *wy, const Realms::Realm *realm)
void move_multi_in_world(unsigned short oldx, unsigned short oldy, unsigned short newx, unsigned short newy, Multi::UMulti *multi, Realms::Realm *oldrealm)
bool isa(UOBJ_CLASS uobj_class) const
void remove_multi_from_world(Multi::UMulti *multi)
Multi::UMulti * find_supporting_multi(unsigned short x, unsigned short y, short z) const
virtual void unregister_object(UObject *obj)
void MoveItemWorldPosition(unsigned short oldx, unsigned short oldy, Items::Item *item, Realms::Realm *oldrealm)
static void find_missing_char_in_zone(Mobile::Character *chr, Realms::WorldChangeReason reason)
bool check_item_integrity()