Load old ObjectData correctly (#553)

* Load old ObjectData correctly

ITS changed ObjectDataStructs::OBJECT_BOMBS_AND_OTHER::ubBombOwner data size from 1 byte to 2 bytes, and it was not taken into account when loading ObjectData
This commit is contained in:
Asdow
2025-11-11 20:14:46 +02:00
committed by GitHub
parent 9ce1492651
commit 264105071a
3 changed files with 99 additions and 6 deletions
+28
View File
@@ -1179,6 +1179,34 @@ ObjectData& ObjectData::operator =(const ObjectData& src)
return *this;
}
ObjectData& ObjectData::operator =(const ObjectData_PRE_ITS& src)
{
if ((void*)this != (void*)&src)
{
//copy over the data
this->bTrap = src.bTrap;
this->fUsed = src.fUsed;
this->ubImprintID = src.ubImprintID;
this->bTemperature = src.bTemperature;
this->ubDirection = src.ubDirection;
this->ubWireNetworkFlag = src.ubWireNetworkFlag;
this->bDefuseFrequency = src.bDefuseFrequency;
this->sRepairThreshold = src.sRepairThreshold;
this->sObjectFlag = src.sObjectFlag;
//copy over the union
this->misc.bBombStatus = src.misc.bBombStatus;
this->misc.bDetonatorType = src.misc.bDetonatorType;
this->misc.usBombItem = src.misc.usBombItem;
this->misc.bDelay = src.misc.bDelay;
this->misc.ubBombOwner = static_cast<UINT16>(src.misc.ubBombOwner);
this->misc.bActionValue = src.misc.bActionValue;
this->misc.ubTolerance = src.misc.ubTolerance;
}
return *this;
}
ObjectData::~ObjectData()
{
DeleteLBE();
+53 -1
View File
@@ -390,6 +390,7 @@ public:
UINT8 fUsed; // flags for whether the item is used or not
};
namespace ObjectDataStructs {
struct OBJECT_GUN
{
@@ -439,8 +440,57 @@ namespace ObjectDataStructs {
INT8 bLBE; // Marks item as LBENODE
int uniqueID; // how the LBENODE is accessed
};
// Used to maintain compatibility with major map versions older than 8.0
struct OBJECT_BOMBS_AND_OTHER_PRE_ITS
{
INT16 bBombStatus;
INT8 bDetonatorType;
UINT16 usBombItem;
union
{
INT8 bDelay;
INT8 bFrequency;
};
UINT8 ubBombOwner; //<-- Data size changed
UINT8 bActionValue;
union
{
UINT8 ubTolerance;
UINT8 ubLocationID;
};
};
};
struct ObjectData_PRE_ITS
{
union {
INT16 objectStatus;//holds the same value as bStatus[0]
UINT16 ubShotsLeft;//holds the same value as ubShotsLeft[0]
ObjectDataStructs::OBJECT_GUN gun;
ObjectDataStructs::OBJECT_MONEY money;
ObjectDataStructs::OBJECT_BOMBS_AND_OTHER_PRE_ITS misc;
ObjectDataStructs::OBJECT_KEY key;
ObjectDataStructs::OBJECT_OWNER owner;
ObjectDataStructs::OBJECT_LBE lbe;
};
INT8 bTrap; // 1-10 exp_lvl to detect
UINT8 fUsed; // flags for whether the item is used or not
UINT8 ubImprintID; // ID of merc that item is imprinted on
char endOfPOD; // For WF maps
FLOAT bTemperature; // Flugente FTW 1.2: temperature of gun
UINT8 ubDirection; // direction the bomb faces (for directional explosives)
UINT32 ubWireNetworkFlag; // flags for the tripwire network
INT8 bDefuseFrequency; // frequency for defusing, >=0 values used only
INT16 sRepairThreshold; // repair only possible up to this value
FLOAT bFiller; // unused for now
UINT64 sObjectFlag; // used to notify of various states that apply to this object, but not the item in general
};
// Flugente: needed for reading WF maps
#define SIZEOF_OBJECTDATA_POD_PRE_ITS (offsetof(ObjectData_PRE_ITS, endOfPOD))
class ObjectData
{
public:
@@ -451,6 +501,8 @@ public:
ObjectData(const ObjectData&);
// Assignment operator
ObjectData& operator=(const ObjectData&);
// Conversion operator
ObjectData& operator=(const ObjectData_PRE_ITS&);
void initialize() {memset(this, 0, sizeof(ObjectData));};
@@ -474,7 +526,7 @@ public:
UINT8 fUsed; // flags for whether the item is used or not
UINT8 ubImprintID; // ID of merc that item is imprinted on
// Flugente: due do inconsistencies with WF maps, where data from a map is laoded differently, I had to add this marker.
// Flugente: due do inconsistencies with WF maps, where data from a map is loaded differently, I had to add this marker.
// New values, like bTemperature, have to come after this. And please, don't destroy ObjectData's POD-ness.
char endOfPOD;