2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
* - 2009/08/25 Shinigami: STLport-5.2.1 fix: init order changed of realm and saveonexit_
|
|
|
|
|
* - 2009/09/14 MuadDib: UObject::setgraphic added error printing.
|
|
|
|
|
* - 2009/12/02 Turley: added config.max_tile_id - Tomi
|
|
|
|
|
*/
|
2014-08-30 12:25:08 +02:00
|
|
|
|
|
|
|
|
|
2014-10-31 20:43:58 +01:00
|
|
|
#include "uobject.h"
|
2014-08-30 12:25:08 +02:00
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include <atomic>
|
|
|
|
|
#include <iosfwd>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <string>
|
2021-09-10 20:17:25 +02:00
|
|
|
#include <utility>
|
2018-01-29 21:55:48 +01:00
|
|
|
|
2014-08-30 12:25:08 +02:00
|
|
|
#include "../clib/cfgelem.h"
|
|
|
|
|
#include "../clib/logfacility.h"
|
|
|
|
|
#include "../clib/passert.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../clib/rawtypes.h"
|
|
|
|
|
#include "../clib/refptr.h"
|
2014-08-30 12:25:08 +02:00
|
|
|
#include "../clib/streamsaver.h"
|
2018-12-21 20:27:05 +01:00
|
|
|
#include "../plib/clidata.h"
|
2024-11-03 14:37:38 +01:00
|
|
|
#include "../plib/objtype.h"
|
2014-12-30 14:14:41 +01:00
|
|
|
#include "../plib/systemstate.h"
|
2018-12-21 20:27:05 +01:00
|
|
|
#include "../plib/uconst.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "baseobject.h"
|
|
|
|
|
#include "dynproperties.h"
|
2015-01-02 14:46:44 +01:00
|
|
|
#include "globals/state.h"
|
2018-10-13 00:03:40 +02:00
|
|
|
#include "globals/uvars.h"
|
2014-08-30 12:25:08 +02:00
|
|
|
#include "item/itemdesc.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "proplist.h"
|
2015-09-18 19:11:46 +02:00
|
|
|
#include "realms/realm.h"
|
2021-09-10 20:17:25 +02:00
|
|
|
#include "realms/realms.h"
|
2018-10-13 00:03:40 +02:00
|
|
|
#include "syshookscript.h"
|
2014-08-30 12:25:08 +02:00
|
|
|
#include "tooltips.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "uobjcnt.h"
|
2014-11-01 15:31:44 +01:00
|
|
|
|
2026-01-17 10:30:21 +01:00
|
|
|
|
|
|
|
|
namespace Pol::Core
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
std::set<UObject*> unreaped_orphan_instances;
|
|
|
|
|
|
|
|
|
|
void display_unreaped_orphan_instances()
|
|
|
|
|
{
|
2025-02-06 20:41:12 +01:00
|
|
|
Clib::StreamWriter sw{ "orphans.txt" };
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
for ( auto& obj : unreaped_orphan_instances )
|
|
|
|
|
{
|
2025-02-06 20:41:12 +01:00
|
|
|
sw.comment( "{}, {}", obj->name(), obj->ref_counted_count() );
|
|
|
|
|
obj->printOnDebug( sw );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2025-02-06 20:41:12 +01:00
|
|
|
if ( !unreaped_orphan_instances.empty() )
|
|
|
|
|
INFO_PRINT( "orphans detected, check orphans.txt" );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-12 22:21:59 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
std::atomic<unsigned int> UObject::dirty_writes;
|
|
|
|
|
std::atomic<unsigned int> UObject::clean_writes;
|
|
|
|
|
|
|
|
|
|
UObject::UObject( u32 objtype, UOBJ_CLASS i_uobj_class )
|
2016-12-12 22:21:59 +01:00
|
|
|
: ref_counted(),
|
|
|
|
|
ULWObject( i_uobj_class ),
|
|
|
|
|
DynamicPropsHolder(),
|
2016-02-19 19:26:35 +01:00
|
|
|
serial_ext( 0 ),
|
|
|
|
|
objtype_( objtype ),
|
|
|
|
|
color( 0 ),
|
2021-09-11 22:38:43 +02:00
|
|
|
facing( Core::FACING_N ),
|
2016-02-19 19:26:35 +01:00
|
|
|
_rev( 0 ),
|
|
|
|
|
name_( "" ),
|
2016-12-07 23:34:16 +01:00
|
|
|
flags_(),
|
2016-12-12 22:21:59 +01:00
|
|
|
proplist_( CPropProfiler::class_to_type( i_uobj_class ) )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
graphic = Items::getgraphic( objtype );
|
2016-12-07 23:34:16 +01:00
|
|
|
flags_.set( OBJ_FLAGS::DIRTY );
|
|
|
|
|
flags_.set( OBJ_FLAGS::SAVE_ON_EXIT );
|
2018-12-22 00:32:47 +01:00
|
|
|
height = Plib::tileheight( graphic );
|
2016-02-19 19:26:35 +01:00
|
|
|
++stateManager.uobjcount.uobject_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UObject::~UObject()
|
|
|
|
|
{
|
|
|
|
|
if ( ref_counted::count() != 0 )
|
|
|
|
|
{
|
2024-01-16 17:55:42 +01:00
|
|
|
POLLOG_INFOLN( "Ouch! UObject::~UObject() with count()=={}", ref_counted::count() );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
passert( ref_counted::count() == 0 );
|
|
|
|
|
if ( serial == 0 )
|
|
|
|
|
{
|
|
|
|
|
--stateManager.uobjcount.unreaped_orphans;
|
|
|
|
|
}
|
|
|
|
|
--stateManager.uobjcount.uobject_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t UObject::estimatedSize() const
|
|
|
|
|
{
|
|
|
|
|
size_t size = sizeof( UObject ) + proplist_.estimatedSize();
|
|
|
|
|
size += estimateSizeDynProps();
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Every UObject is registered with the objecthash after creation.
|
|
|
|
|
// (This can't happen in the ctor since the object isn't fully created yet)
|
|
|
|
|
//
|
|
|
|
|
// Scripts may still reference any object, so rather than outright delete,
|
|
|
|
|
// we set its serial to 0 (marking it "orphan", though "zombie" would probably be a better term).
|
|
|
|
|
// Later, when all _other_ references to the object have been deleted,
|
|
|
|
|
// objecthash.Reap() will remove its reference to this object, deleting it.
|
|
|
|
|
//
|
|
|
|
|
void UObject::destroy()
|
|
|
|
|
{
|
|
|
|
|
if ( serial != 0 )
|
|
|
|
|
{
|
|
|
|
|
if ( ref_counted::count() < 1 )
|
2014-08-30 12:25:08 +02:00
|
|
|
{
|
2024-01-16 17:55:42 +01:00
|
|
|
POLLOG_INFOLN( "Ouch! UObject::destroy() with count()=={}", ref_counted::count() );
|
2014-08-30 12:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
set_dirty(); // we will have to write a 'object deleted' directive once
|
|
|
|
|
|
|
|
|
|
serial =
|
|
|
|
|
0; // used to set serial_ext to 0. This way, if debugging, one can find out the old serial
|
|
|
|
|
passert( ref_counted::count() >= 1 );
|
|
|
|
|
|
|
|
|
|
++stateManager.uobjcount.unreaped_orphans;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UObject::dirty() const
|
|
|
|
|
{
|
2016-12-07 23:34:16 +01:00
|
|
|
return flags_.get( OBJ_FLAGS::DIRTY );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::clear_dirty() const
|
|
|
|
|
{
|
2016-12-07 23:34:16 +01:00
|
|
|
if ( dirty() )
|
2016-02-19 19:26:35 +01:00
|
|
|
++dirty_writes;
|
|
|
|
|
else
|
|
|
|
|
++clean_writes;
|
2016-12-07 23:34:16 +01:00
|
|
|
flags_.remove( OBJ_FLAGS::DIRTY );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UObject::getprop( const std::string& propname, std::string& propval ) const
|
|
|
|
|
{
|
|
|
|
|
return proplist_.getprop( propname, propval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::setprop( const std::string& propname, const std::string& propvalue )
|
|
|
|
|
{
|
|
|
|
|
if ( propname[0] != '#' )
|
|
|
|
|
set_dirty();
|
|
|
|
|
proplist_.setprop( propname, propvalue ); // VOID_RETURN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::eraseprop( const std::string& propname )
|
|
|
|
|
{
|
|
|
|
|
if ( propname[0] != '#' )
|
|
|
|
|
set_dirty();
|
|
|
|
|
proplist_.eraseprop( propname ); // VOID_RETURN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::copyprops( const UObject& from )
|
|
|
|
|
{
|
|
|
|
|
set_dirty();
|
|
|
|
|
proplist_.copyprops( from.proplist_ );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::copyprops( const PropertyList& proplist )
|
|
|
|
|
{
|
|
|
|
|
set_dirty();
|
|
|
|
|
proplist_.copyprops( proplist );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::getpropnames( std::vector<std::string>& propnames ) const
|
|
|
|
|
{
|
|
|
|
|
proplist_.getpropnames( propnames );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PropertyList& UObject::getprops() const
|
|
|
|
|
{
|
|
|
|
|
return proplist_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string UObject::name() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string UObject::description() const
|
|
|
|
|
{
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::setname( const std::string& newname )
|
|
|
|
|
{
|
|
|
|
|
set_dirty();
|
|
|
|
|
increv();
|
|
|
|
|
send_object_cache_to_inrange( this );
|
|
|
|
|
name_ = newname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UObject* UObject::owner()
|
|
|
|
|
{
|
2018-07-31 14:30:29 +02:00
|
|
|
return nullptr;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UObject* UObject::owner() const
|
|
|
|
|
{
|
2018-07-31 14:30:29 +02:00
|
|
|
return nullptr;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UObject* UObject::self_as_owner()
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UObject* UObject::self_as_owner() const
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UObject* UObject::toplevel_owner()
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UObject* UObject::toplevel_owner() const
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-10 20:17:25 +02:00
|
|
|
void UObject::setposition( Pos4d newpos )
|
|
|
|
|
{
|
2023-01-05 00:10:51 +01:00
|
|
|
set_dirty();
|
2021-09-10 20:17:25 +02:00
|
|
|
pos( std::move( newpos ) );
|
|
|
|
|
}
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2021-09-11 22:38:43 +02:00
|
|
|
UFACING UObject::direction_toward( UObject* other ) const
|
|
|
|
|
{
|
|
|
|
|
return pos2d().direction_toward( other->toplevel_owner()->pos2d() );
|
|
|
|
|
}
|
|
|
|
|
UFACING UObject::direction_toward( const Pos2d& other ) const
|
|
|
|
|
{
|
|
|
|
|
return pos2d().direction_toward( other );
|
|
|
|
|
}
|
|
|
|
|
UFACING UObject::direction_away( UObject* other ) const
|
|
|
|
|
{
|
|
|
|
|
return pos2d().direction_away( other->toplevel_owner()->pos2d() );
|
|
|
|
|
}
|
|
|
|
|
UFACING UObject::direction_away( const Pos2d& other ) const
|
|
|
|
|
{
|
|
|
|
|
return pos2d().direction_away( other );
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
void UObject::printProperties( Clib::StreamWriter& sw ) const
|
|
|
|
|
{
|
|
|
|
|
using namespace fmt;
|
|
|
|
|
|
|
|
|
|
if ( !name_.get().empty() )
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "Name", name_.get() );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2025-01-29 06:48:05 +01:00
|
|
|
sw.add( "Serial", Clib::hexintv( serial ) );
|
|
|
|
|
sw.add( "ObjType", Clib::hexintv( objtype_ ) );
|
|
|
|
|
sw.add( "Graphic", Clib::hexintv( graphic ) );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
if ( color != 0 )
|
2025-01-29 06:48:05 +01:00
|
|
|
sw.add( "Color", Clib::hexintv( color ) );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "X", x() );
|
|
|
|
|
sw.add( "Y", y() );
|
|
|
|
|
sw.add( "Z", (int)z() );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
if ( facing )
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "Facing", static_cast<int>( facing ) );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "Revision", rev() );
|
2021-09-10 20:17:25 +02:00
|
|
|
if ( realm() == nullptr )
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "Realm", "britannia" );
|
2016-02-19 19:26:35 +01:00
|
|
|
else
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.add( "Realm", realm()->name() );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2025-03-04 20:27:03 +01:00
|
|
|
|
|
|
|
|
if ( has_fire_resist() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = fire_resist().mod; value )
|
|
|
|
|
sw.add( "FireResistMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_cold_resist() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = cold_resist().mod; value )
|
|
|
|
|
sw.add( "ColdResistMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_energy_resist() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = energy_resist().mod; value )
|
|
|
|
|
sw.add( "EnergyResistMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_poison_resist() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = poison_resist().mod; value )
|
|
|
|
|
sw.add( "PoisonResistMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_physical_resist() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = physical_resist().mod; value )
|
|
|
|
|
sw.add( "PhysicalResistMod", value );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( has_fire_damage() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = fire_damage().mod; value )
|
|
|
|
|
sw.add( "FireDamageMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_cold_damage() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = cold_damage().mod; value )
|
|
|
|
|
sw.add( "ColdDamageMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_energy_damage() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = energy_damage().mod; value )
|
|
|
|
|
sw.add( "EnergyDamageMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_poison_damage() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = poison_damage().mod; value )
|
|
|
|
|
sw.add( "PoisonDamageMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_physical_damage() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = physical_damage().mod; value )
|
|
|
|
|
sw.add( "PhysicalDamageMod", value );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( has_lower_reagent_cost() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = lower_reagent_cost().mod; value )
|
|
|
|
|
sw.add( "LowerReagentCostMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_defence_increase() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = defence_increase().mod; value )
|
|
|
|
|
sw.add( "DefenceIncreaseMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_defence_increase_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = defence_increase_cap().mod; value )
|
|
|
|
|
sw.add( "DefenceIncreaseCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_lower_mana_cost() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = lower_mana_cost().mod; value )
|
|
|
|
|
sw.add( "LowerManaCostMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_hit_chance() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = hit_chance().mod; value )
|
|
|
|
|
sw.add( "HitChanceMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_fire_resist_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = fire_resist_cap().mod; value )
|
|
|
|
|
sw.add( "FireResistCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_cold_resist_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = cold_resist_cap().mod; value )
|
|
|
|
|
sw.add( "ColdResistCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_energy_resist_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = energy_resist_cap().mod; value )
|
|
|
|
|
sw.add( "EnergyResistCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_physical_resist_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = physical_resist_cap().mod; value )
|
|
|
|
|
sw.add( "PhysicalResistCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_poison_resist_cap() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = poison_resist_cap().mod; value )
|
|
|
|
|
sw.add( "PoisonResistCapMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_spell_damage_increase() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = spell_damage_increase().mod; value )
|
|
|
|
|
sw.add( "SpellDamageIncreaseMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_faster_casting() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = faster_casting().mod; value )
|
|
|
|
|
sw.add( "FasterCastingMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_faster_cast_recovery() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = faster_cast_recovery().mod; value )
|
|
|
|
|
sw.add( "FasterCastRecoveryMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_luck() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = luck().mod; value )
|
|
|
|
|
sw.add( "LuckMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_swing_speed_increase() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = swing_speed_increase().mod; value )
|
|
|
|
|
sw.add( "SwingSpeedIncreaseMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_min_attack_range_increase() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = min_attack_range_increase().mod; value )
|
|
|
|
|
sw.add( "MinAttackRangeIncreaseMod", value );
|
|
|
|
|
}
|
|
|
|
|
if ( has_max_attack_range_increase() )
|
|
|
|
|
{
|
|
|
|
|
if ( s16 value = max_attack_range_increase().mod; value )
|
|
|
|
|
sw.add( "MaxAttackRangeIncreaseMod", value );
|
|
|
|
|
}
|
2019-06-17 18:58:58 +08:00
|
|
|
|
|
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
proplist_.printProperties( sw );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::printDebugProperties( Clib::StreamWriter& sw ) const
|
|
|
|
|
{
|
2024-11-14 06:58:18 +01:00
|
|
|
sw.comment( "uobj_class: {}", (int)uobj_class() );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Fixes invalid graphic, moving here to allow it to be overridden in subclass (see Multi)
|
|
|
|
|
void UObject::fixInvalidGraphic()
|
|
|
|
|
{
|
|
|
|
|
if ( graphic > ( Plib::systemstate.config.max_tile_id ) )
|
|
|
|
|
graphic = GRAPHIC_NODRAW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::readProperties( Clib::ConfigElem& elem )
|
|
|
|
|
{
|
|
|
|
|
name_ = elem.remove_string( "NAME", "" );
|
|
|
|
|
|
|
|
|
|
// serial, objtype extracted by caller
|
|
|
|
|
graphic = elem.remove_ushort( "GRAPHIC", static_cast<u16>( objtype_ ) );
|
|
|
|
|
fixInvalidGraphic();
|
|
|
|
|
|
2018-12-22 00:32:47 +01:00
|
|
|
height = Plib::tileheight( graphic );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
color = elem.remove_ushort( "COLOR", 0 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string realmstr = elem.remove_string( "Realm", "britannia" );
|
2021-09-10 20:17:25 +02:00
|
|
|
auto* realm_tmp = find_realm( realmstr );
|
|
|
|
|
if ( !realm_tmp )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2024-05-05 09:13:12 +02:00
|
|
|
ERROR_PRINTLN( "{} '{}' ({:#x}): has an invalid realm property '{}'.", classname(), name(),
|
2024-01-12 06:51:44 +01:00
|
|
|
serial, realmstr );
|
2016-02-19 19:26:35 +01:00
|
|
|
throw std::runtime_error( "Data integrity error" );
|
2014-08-30 12:25:08 +02:00
|
|
|
}
|
2021-09-10 20:17:25 +02:00
|
|
|
setposition( Pos4d( elem.remove_ushort( "X" ), elem.remove_ushort( "Y" ),
|
|
|
|
|
static_cast<s8>( elem.remove_int( "Z" ) ), realm_tmp ) );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
unsigned short tmp = elem.remove_ushort( "FACING", 0 );
|
|
|
|
|
setfacing( static_cast<unsigned char>( tmp ) );
|
|
|
|
|
|
|
|
|
|
_rev = elem.remove_ulong( "Revision", 0 );
|
|
|
|
|
|
2019-06-17 18:58:58 +08:00
|
|
|
s16 mod_value = static_cast<s16>( elem.remove_int( "FIRERESISTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
fire_resist( fire_resist().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "COLDRESISTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
cold_resist( cold_resist().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "ENERGYRESISTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
energy_resist( energy_resist().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "POISONRESISTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
poison_resist( poison_resist().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "PHYSICALRESISTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
physical_resist( physical_resist().setAsMod( mod_value ) );
|
|
|
|
|
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "FIREDAMAGEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
fire_damage( fire_damage().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "COLDDAMAGEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
cold_damage( cold_damage().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "ENERGYDAMAGEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
energy_damage( energy_damage().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "POISONDAMAGEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
poison_damage( poison_damage().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "PHYSICALDAMAGEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
physical_damage( physical_damage().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "DEFENCEINCREASEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
defence_increase( defence_increase().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "DEFENCEINCREASECAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
defence_increase_cap( defence_increase_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "LOWERMANACOSTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
lower_mana_cost( lower_mana_cost().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "HITCHANCEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
hit_chance( hit_chance().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "FIRERESISTCAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
fire_resist_cap( fire_resist_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "COLDRESISTCAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
cold_resist_cap( cold_resist_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "ENERGYRESISTCAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
energy_resist_cap( energy_resist_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "POISONRESISTCAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
poison_resist_cap( poison_resist_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "PHYSICALRESISTCAPMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
physical_resist_cap( physical_resist_cap().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "LOWERREAGENTCOSTMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
lower_reagent_cost( lower_reagent_cost().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "SPELLDAMAGEINCREASEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
spell_damage_increase( spell_damage_increase().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "FASTERCASTINGMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
faster_casting( faster_casting().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "FASTERCASTRECOVERYMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
faster_cast_recovery( faster_cast_recovery().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "LUCKMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
luck( luck().setAsMod( mod_value ) );
|
2020-05-18 21:55:24 +08:00
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "SWINGSPEEDINCREASEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
swing_speed_increase( swing_speed_increase().setAsMod( mod_value ) );
|
2024-11-02 22:46:50 +08:00
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "MINATTACKRANGEINCREASEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
min_attack_range_increase( min_attack_range_increase().setAsMod( mod_value ) );
|
|
|
|
|
mod_value = static_cast<s16>( elem.remove_int( "MAXATTACKRANGEINCREASEMOD", 0 ) );
|
|
|
|
|
if ( mod_value != 0 )
|
|
|
|
|
max_attack_range_increase( max_attack_range_increase().setAsMod( mod_value ) );
|
2019-06-17 18:58:58 +08:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
proplist_.readProperties( elem );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::printSelfOn( Clib::StreamWriter& sw ) const
|
|
|
|
|
{
|
|
|
|
|
printOn( sw );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::printOn( Clib::StreamWriter& sw ) const
|
|
|
|
|
{
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.begin( classname() );
|
2016-02-19 19:26:35 +01:00
|
|
|
printProperties( sw );
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.end();
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::printOnDebug( Clib::StreamWriter& sw ) const
|
|
|
|
|
{
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.begin( classname() );
|
2016-02-19 19:26:35 +01:00
|
|
|
printProperties( sw );
|
|
|
|
|
printDebugProperties( sw );
|
Savefile rewrite (#601)
* rewrite of saving, replaced operator way with a generic add method, thus
not everywhere the formating of the savefiles is hardcoded.
since its the last spot which uses the old formating lib, remobed the
lib
* removed cmake of old format lib
* testscripts for load/save of UObject,Item,Armor,Weapon
* fixed: member faster_cast_recovery and faster_cast_recovery_mod getter returned
a wrong value
* wrong/missing docs
* test containers, lockable, map, spellbooks
fixed save bug in map and spellbook
removed ancient savestrategy experiments
* added corpse test
splitted testfiles
* fixed loading (ancient bug) and saving (PR bug) of Reportables
added tests for houses, boats, accounts and chars
* fixed include
* fix shutdown leak
* added npc tests
upload complete coretest folder also on failure
* do not write and load RegisteredHouse for NPCs two times
readded extra newline between accounts
* tests for guild, party, realm
added resource cfgs, but a test is not really possible since nothing of
interest is stored
* added datafile, storage test
* activated resource loading, 25year old bug, but since the stored values
are senseless it makes no real difference.
added a few wtf comments
catch all exceptions during formatting of log lines
* replaced .write with explixit .begin, .end and .comment.
for leftovers.txt the StreamSaver was also used, since the format is
different use directly ofstream
* added corechanges
2024-01-24 18:49:06 +01:00
|
|
|
sw.end();
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UObject::setgraphic( u16 /*newgraphic*/ )
|
|
|
|
|
{
|
2024-01-12 06:51:44 +01:00
|
|
|
ERROR_PRINTLN(
|
2024-05-05 09:13:12 +02:00
|
|
|
"UOBject::SetGraphic used, object class does not have a graphic member! Object Serial: {:#x}",
|
2024-01-12 06:51:44 +01:00
|
|
|
serial );
|
2016-02-19 19:26:35 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UObject::setcolor( u16 newcolor )
|
|
|
|
|
{
|
|
|
|
|
set_dirty();
|
|
|
|
|
|
|
|
|
|
if ( color != newcolor )
|
|
|
|
|
{
|
|
|
|
|
color = newcolor;
|
|
|
|
|
on_color_changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
void UObject::on_color_changed() {}
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
void UObject::on_facing_changed() {}
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
bool UObject::saveonexit() const
|
|
|
|
|
{
|
2016-12-07 23:34:16 +01:00
|
|
|
return flags_.get( OBJ_FLAGS::SAVE_ON_EXIT );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UObject::saveonexit( bool newvalue )
|
|
|
|
|
{
|
2016-12-07 23:34:16 +01:00
|
|
|
flags_.change( OBJ_FLAGS::SAVE_ON_EXIT, newvalue );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* UObject::target_tag() const
|
|
|
|
|
{
|
|
|
|
|
return "object";
|
|
|
|
|
}
|
2018-10-13 00:03:40 +02:00
|
|
|
|
|
|
|
|
bool UObject::get_method_hook( const char* methodname, Bscript::Executor* ex, ExportScript** hook,
|
|
|
|
|
unsigned int* PC ) const
|
|
|
|
|
{
|
|
|
|
|
return gamestate.system_hooks.get_method_hook( gamestate.system_hooks.uobject_method_script.get(),
|
|
|
|
|
methodname, ex, hook, PC );
|
|
|
|
|
}
|
2026-01-17 10:30:21 +01:00
|
|
|
} // namespace Pol::Core
|