14 #include "../clib/cfgelem.h" 15 #include "../clib/cfgfile.h" 16 #include "../clib/fileutil.h" 17 #include "../clib/logfacility.h" 18 #include "../clib/rawtypes.h" 19 #include "../clib/strutil.h" 20 #include "../clib/timer.h" 21 #include "../plib/systemstate.h" 52 while ( cf.
read( elem ) )
55 if ( elem.
type_is(
"Modified" ) )
60 std::string
name, value;
63 pol_serial_t serial = strtoul( name.c_str(),
nullptr, 0 );
74 return ( *itr ).second;
83 std::string filename =
87 slurp( filename.c_str(),
"CHARACTER NPC ITEM GLOBALPROPERTIES SYSTEM MULTI STORAGEAREA" );
100 unsigned index = ( *citr ).second;
101 if ( index == UINT_MAX )
122 int num_until_dot = 1000;
123 unsigned int nobjects = 0;
131 if ( --num_until_dot == 0 )
134 num_until_dot = 1000;
138 UObject* obj = ( *itr ).second;
144 if ( chr !=
nullptr )
151 "Item 0x{:X} is supposed to be on Character 0x{:X}, but that character cannot be " 153 << item->
serial << container_serial;
158 throw std::runtime_error(
"Data file integrity error" );
161 ERROR_PRINT <<
"Ignore load errors enabled. Removing object.\n";
170 if ( cont_item !=
nullptr )
177 <<
" is supposed to be in container 0x" << fmt::hexu( container_serial )
178 <<
", but that container cannot be found.\n";
183 throw std::runtime_error(
"Data file integrity error" );
186 ERROR_PRINT <<
"Ignore load errors enabled. Removing object.\n";
215 <<
" is supposed to be equipped on Character " << fmt::hexu( chr->
serial )
216 <<
", but is not 'equippable' on that character.\n";
221 bool canadd = bp->
can_add( *item );
224 if ( canadd && add_to_slot && item->
slot_index( slotIndex ) )
229 ERROR_PRINT <<
"I'm so cool, I put it in the character's backpack!\n";
235 ERROR_PRINT <<
"Tried to put it in the character's backpack, " 236 <<
"but it wouldn't fit.\n";
241 ERROR_PRINT <<
"Tried to put it in the character's backpack, " 242 <<
"but there isn't one. That's naughty...\n";
244 throw std::runtime_error(
"Data file integrity error" );
269 u8 spellslot = spellnum & 7;
270 if ( spellslot == 0 )
278 bool canadd = cont->
can_add( *item );
283 ERROR_PRINT <<
"Can't add Item 0x" << fmt::hexu( item->
serial ) <<
" to container 0x" 284 << fmt::hexu( cont->
serial ) <<
"\n";
285 throw std::runtime_error(
"Data file error" );
288 if ( !add_to_slot || !item->
slot_index( slotIndex ) )
290 ERROR_PRINT <<
"Can't add Item 0x" << fmt::hexu( item->
serial ) <<
" to container 0x" 291 << fmt::hexu( cont->
serial ) <<
" at slot 0x" << fmt::hexu( slotIndex ) <<
"\n";
292 throw std::runtime_error(
"Data file error" );
308 <<
" contains items, but is not a container class\n";
309 throw std::runtime_error(
"Config file error" );
bool remove_first_prop(std::string *propname, std::string *value)
bool can_add_to_slot(u8 &slotIndex)
DeferList deferred_insertions
virtual bool can_add(const Items::Item &item) const
void add_loaded_item(Items::Item *cont_item, Items::Item *item)
std::string world_data_path
unsigned char tilelayer(unsigned short tilenum)
std::string decint(unsigned short v)
void insert_deferred_items()
unsigned current_incremental_save
void RegisterCleanDeletedSerial(u32 serial)
void load_incremental_indexes()
virtual void add(Items::Item *item)
virtual bool script_isa(unsigned isatype) const POL_OVERRIDE
void read_incremental_saves()
bool check_equip_script(Mobile::Character *chr, bool startup)
unsigned incremental_save_count
void add_at_random_location(Items::Item *item)
void equip_loaded_item(Mobile::Character *chr, Items::Item *item)
void equip(Items::Item *item)
SerialIndexMap incremental_serial_index
const unsigned POLCLASS_SPELLBOOK
StateManager stateManager
Mobile::Character * system_find_mobile(u32 serial)
bool IsCharacter(u32 serial)
Items::Item * system_find_item(u32 serial)
Core::UContainer * backpack() const
bool type_is(const char *name) const
ObjectStorageManager objStorageManager
bool gflag_enforce_container_limits
bool isa(UOBJ_CLASS uobj_class) const
bool check_equiptest_scripts(Mobile::Character *chr, bool startup=false)
void defer_item_insertion(Items::Item *item, pol_serial_t container_serial)
bool FileExists(const char *filename)
bool read(ConfigElem &elem)
bool equippable(const Items::Item *item) const
void slurp(const char *filename, const char *tags, int sysfind_flags=0)
unsigned get_save_index(pol_serial_t serial)
void register_deleted_serials()