diff --git a/src/baseobject.cpp b/src/baseobject.cpp index 9eed9706b..75d1ef37f 100644 --- a/src/baseobject.cpp +++ b/src/baseobject.cpp @@ -19,12 +19,15 @@ */ #include "lib/framework/frame.h" +#include "lib/netplay/netplay.h" #include "lib/sound/audio.h" #include "baseobject.h" #include "droid.h" #include "projectile.h" #include "structure.h" +#include "feature.h" + static inline uint16_t interpolateAngle(uint16_t v1, uint16_t v2, uint32_t t1, uint32_t t2, uint32_t t) { @@ -141,3 +144,17 @@ void checkObject(const BASE_OBJECT* psObject, const char * const location_descri || psObject->player < MAX_PLAYERS, location_description, function, "CHECK_OBJECT: Out of bound owning player number (%u)", (unsigned int)psObject->player); } + +void _syncDebugObject(const char *function, SIMPLE_OBJECT const *psObject, char ch) +{ + switch (psObject->type) + { + case OBJ_DROID: _syncDebugDroid (function, (const DROID *) psObject, ch); break; + case OBJ_STRUCTURE: _syncDebugStructure (function, (const STRUCTURE *) psObject, ch); break; + case OBJ_FEATURE: _syncDebugFeature (function, (const FEATURE *) psObject, ch); break; + case OBJ_PROJECTILE: _syncDebugProjectile(function, (const PROJECTILE *)psObject, ch); break; + default: _syncDebug (function, "%c unidentified_object%d = p%d;objectType%d", ch, psObject->id, psObject->player, psObject->type); + ASSERT_HELPER(!"invalid object type", "_syncDebugObject", function, "syncDebug: Invalid object type (type num %u)", (unsigned int)psObject->type); + break; + } +} diff --git a/src/baseobject.h b/src/baseobject.h index c7993c9d9..4eb3cc32d 100644 --- a/src/baseobject.h +++ b/src/baseobject.h @@ -38,4 +38,7 @@ void checkObject(const BASE_OBJECT* psObject, const char * const location_descri /* assert if object is bad */ #define CHECK_OBJECT(object) checkObject((object), AT_MACRO, __FUNCTION__, max_check_object_recursion) +#define syncDebugObject(psObject, ch) _syncDebugObject(__FUNCTION__, psObject, ch) +void _syncDebugObject(const char *function, SIMPLE_OBJECT const *psObject, char ch); + #endif // __INCLUDED_BASEOBJECT_H__ diff --git a/src/combat.cpp b/src/combat.cpp index 3fda26139..55aaab838 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -496,6 +496,7 @@ int32_t objDamage(BASE_OBJECT *psObj, UDWORD damage, UDWORD originalhp, WEAPON_C actualDamage = MAX(actualDamage, MIN_WEAPON_DAMAGE); objTrace(psObj->id, "objDamage: Penetrated %d", actualDamage); + syncDebug("damage%u dam%u,o%u,wc%d.%d,is%d,ar%d,lev%d,aDam%d", psObj->id, damage, originalhp, weaponClass, weaponSubClass, impactSide, armour, level, actualDamage); // for some odd reason, we have 0 hitpoints. if (!originalhp) @@ -513,6 +514,8 @@ int32_t objDamage(BASE_OBJECT *psObj, UDWORD damage, UDWORD originalhp, WEAPON_C // Subtract the dealt damage from the droid's remaining body points psObj->body -= actualDamage; + syncDebugObject(psObj, 'D'); + return (int64_t)65536 * actualDamage / originalhp; } diff --git a/src/droid.cpp b/src/droid.cpp index 91ea026b2..e141f199b 100644 --- a/src/droid.cpp +++ b/src/droid.cpp @@ -697,7 +697,7 @@ void droidBurn(DROID *psDroid) orderDroid(psDroid, DORDER_RUNBURN, ModeImmediate); } -void _syncDebugDroid(const char *function, DROID *psDroid, char ch) +void _syncDebugDroid(const char *function, DROID const *psDroid, char ch) { char actTar[DROID_MAXWEAPS*15]; unsigned actTarLen = 0; diff --git a/src/droid.h b/src/droid.h index 9d0b524ec..fd0cb53ff 100644 --- a/src/droid.h +++ b/src/droid.h @@ -548,7 +548,7 @@ void templateSetParts(const DROID *psDroid, DROID_TEMPLATE *psTemplate); void cancelBuild(DROID *psDroid); #define syncDebugDroid(psDroid, ch) _syncDebugDroid(__FUNCTION__, psDroid, ch) -void _syncDebugDroid(const char *function, DROID *psDroid, char ch); +void _syncDebugDroid(const char *function, DROID const *psDroid, char ch); // True iff object is a droid. diff --git a/src/feature.cpp b/src/feature.cpp index 1b9f0be4e..92627126d 100644 --- a/src/feature.cpp +++ b/src/feature.cpp @@ -370,7 +370,7 @@ FEATURE::~FEATURE() { } -void _syncDebugFeature(const char *function, FEATURE *psFeature, char ch) +void _syncDebugFeature(const char *function, FEATURE const *psFeature, char ch) { _syncDebug(function, "%c feature%d = p%d;pos(%d,%d,%d),subtype%d,dam%d,bp%d", ch, psFeature->id, diff --git a/src/feature.h b/src/feature.h index 43d84b7c6..abca2e8ba 100644 --- a/src/feature.h +++ b/src/feature.h @@ -63,7 +63,7 @@ int32_t featureDamage(FEATURE *psFeature, UDWORD damage, WEAPON_CLASS weaponClas extern void featureInitVars(void); #define syncDebugFeature(psFeature, ch) _syncDebugFeature(__FUNCTION__, psFeature, ch) -void _syncDebugFeature(const char *function, FEATURE *psFeature, char ch); +void _syncDebugFeature(const char *function, FEATURE const *psFeature, char ch); // True iff object is a feature. diff --git a/src/projectile.cpp b/src/projectile.cpp index 862298b31..86af58955 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -311,7 +311,7 @@ static void proj_UpdateKills(PROJECTILE *psObj, int32_t experienceInc) /***************************************************************************/ -void _syncDebugProjectile(const char *function, PROJECTILE *psProj, char ch) +void _syncDebugProjectile(const char *function, PROJECTILE const *psProj, char ch) { _syncDebug(function, "%c projectile = p%d;pos(%d,%d,%d),rot(%d,%d,%d),state%d,edc%d,nd%lu", ch, psProj->player, diff --git a/src/projectile.h b/src/projectile.h index 05c1e99be..07eff520e 100644 --- a/src/projectile.h +++ b/src/projectile.h @@ -111,6 +111,6 @@ void checkProjectile(const PROJECTILE* psProjectile, const char * const location #define CHECK_PROJECTILE(object) checkProjectile((object), AT_MACRO, __FUNCTION__, max_check_object_recursion) #define syncDebugProjectile(psProj, ch) _syncDebugProjectile(__FUNCTION__, psProj, ch) -void _syncDebugProjectile(const char *function, PROJECTILE *psProj, char ch); +void _syncDebugProjectile(const char *function, PROJECTILE const *psProj, char ch); #endif // __INCLUDED_SRC_PROJECTILE_H__ diff --git a/src/structure.cpp b/src/structure.cpp index 89bf25249..7c143b672 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -3567,7 +3567,7 @@ static float CalcStructureSmokeInterval(float damage) return (((1. - damage) + 0.1) * 10) * STRUCTURE_DAMAGE_SCALING; } -void _syncDebugStructure(const char *function, STRUCTURE *psStruct, char ch) +void _syncDebugStructure(const char *function, STRUCTURE const *psStruct, char ch) { int ref = 0; char const *refStr = ""; diff --git a/src/structure.h b/src/structure.h index 659d77ed6..fa06836ad 100644 --- a/src/structure.h +++ b/src/structure.h @@ -455,7 +455,7 @@ void checkStructure(const STRUCTURE* psStructure, const char * const location_de extern void structureInitVars(void); #define syncDebugStructure(psStruct, ch) _syncDebugStructure(__FUNCTION__, psStruct, ch) -void _syncDebugStructure(const char *function, STRUCTURE *psStruct, char ch); +void _syncDebugStructure(const char *function, STRUCTURE const *psStruct, char ch); // True iff object is a structure.