Add hack to fix droidOnMap asserts when loading some savegames. Reported by
Dale Gill in bug #11298. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4142 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
51d5b30e3e
commit
342a673d08
|
@ -5554,7 +5554,7 @@ BOOL cyborgDroid(DROID *psDroid)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL droidOnMap(DROID *psDroid)
|
||||
BOOL droidOnMap(const DROID *psDroid)
|
||||
{
|
||||
if (psDroid->died == NOT_CURRENT_LIST || psDroid->droidType == DROID_TRANSPORTER
|
||||
|| psDroid->sMove.fx == INVALID_XY || psDroid->pos.x == INVALID_XY || missionIsOffworld())
|
||||
|
|
|
@ -404,7 +404,7 @@ extern BOOL cyborgDroid(DROID *psDroid);
|
|||
BOOL droidCheckReferences(DROID *psVictimDroid);
|
||||
|
||||
/** Check if droid is in a legal world position and is not on its way to drive off the map. */
|
||||
BOOL droidOnMap(DROID *psDroid);
|
||||
BOOL droidOnMap(const DROID *psDroid);
|
||||
|
||||
#define droidSensorRange(_psDroid) objSensorRange((BASE_OBJECT *)_psDroid)
|
||||
#define droidSensorPower(_psDroid) objSensorPower((BASE_OBJECT *)_psDroid)
|
||||
|
|
13
src/game.c
13
src/game.c
|
@ -5599,13 +5599,14 @@ static void SaveDroidMoveControl(SAVE_DROID * const psSaveDroid, DROID const * c
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
ASSERT(droidOnMap(psDroid), "saved droid standing or moving off the map");
|
||||
|
||||
// Copy over the endian neutral stuff (all UBYTE)
|
||||
psSaveDroid->sMove.Status = psDroid->sMove.Status;
|
||||
psSaveDroid->sMove.Position = psDroid->sMove.Position;
|
||||
psSaveDroid->sMove.numPoints = psDroid->sMove.numPoints;
|
||||
memcpy(&psSaveDroid->sMove.asPath, &psDroid->sMove.asPath, sizeof(psSaveDroid->sMove.asPath));
|
||||
|
||||
|
||||
// Little endian SDWORDs
|
||||
psSaveDroid->sMove.DestinationX = PHYSFS_swapSLE32(psDroid->sMove.DestinationX);
|
||||
psSaveDroid->sMove.DestinationY = PHYSFS_swapSLE32(psDroid->sMove.DestinationY);
|
||||
|
@ -5673,7 +5674,6 @@ static void LoadDroidMoveControl(DROID * const psDroid, SAVE_DROID const * const
|
|||
psDroid->sMove.numPoints = psSaveDroid->sMove.numPoints;
|
||||
memcpy(&psDroid->sMove.asPath, &psSaveDroid->sMove.asPath, sizeof(psSaveDroid->sMove.asPath));
|
||||
|
||||
|
||||
// Little endian SDWORDs
|
||||
psDroid->sMove.DestinationX = PHYSFS_swapSLE32(psSaveDroid->sMove.DestinationX);
|
||||
psDroid->sMove.DestinationY = PHYSFS_swapSLE32(psSaveDroid->sMove.DestinationY);
|
||||
|
@ -5688,6 +5688,15 @@ static void LoadDroidMoveControl(DROID * const psDroid, SAVE_DROID const * const
|
|||
psDroid->sMove.speed = PHYSFS_swapSLE32(psSaveDroid->sMove.speed);
|
||||
psDroid->sMove.moveDir = PHYSFS_swapSLE32(psSaveDroid->sMove.moveDir);
|
||||
psDroid->sMove.fz = PHYSFS_swapSLE32(psSaveDroid->sMove.fz);
|
||||
|
||||
// Hack to fix bad droids in savegames
|
||||
if (!droidOnMap(psDroid))
|
||||
{
|
||||
psDroid->sMove.fx = 0;
|
||||
psDroid->sMove.fy = 0;
|
||||
psDroid->sMove.fz = 0;
|
||||
debug(LOG_ERROR, "%s had bad movement coordinates - fixed!", psDroid->aName);
|
||||
}
|
||||
ASSERT(droidOnMap(psDroid), "loaded droid standing or moving off the map");
|
||||
|
||||
// Little endian SWORDs
|
||||
|
|
Loading…
Reference in New Issue