Add more syncDebug when objects are damaged.
Also, added syncDebugObject function for tracing objects of unspecified type.master
parent
e0617af5e6
commit
4fec447170
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue