diff --git a/src/droid.h b/src/droid.h index b18e4b54d..ae74e4b12 100644 --- a/src/droid.h +++ b/src/droid.h @@ -520,6 +520,7 @@ do { \ assert(droid->numWeaps <= DROID_MAXWEAPS); \ assert(droid->listSize <= ORDER_LIST_MAX); \ assert(droid->player < MAX_PLAYERS); \ + assert(worldOnMap(droid->sMove.fx, droid->sMove.fy)); \ \ for (i = 0; i < DROID_MAXWEAPS; ++i) \ assert(droid->turretRotation[i] <= 360); \ diff --git a/src/game.c b/src/game.c index 09e38e342..010df9263 100644 --- a/src/game.c +++ b/src/game.c @@ -5674,11 +5674,11 @@ static void SaveDroidMoveControl(SAVE_DROID * const psSaveDroid, DROID const * c psSaveDroid->sMove.targetY = PHYSFS_swapSLE32(psDroid->sMove.targetY); // Little endian floats - psSaveDroid->sMove.fx = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psDroid->sMove.fx); - psSaveDroid->sMove.fy = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psDroid->sMove.fy); - psSaveDroid->sMove.speed = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psDroid->sMove.speed); - psSaveDroid->sMove.moveDir = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psDroid->sMove.moveDir); - psSaveDroid->sMove.fz = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psDroid->sMove.fz); + psSaveDroid->sMove.fx = PHYSFS_swapSLE32(psDroid->sMove.fx); + psSaveDroid->sMove.fy = PHYSFS_swapSLE32(psDroid->sMove.fy); + psSaveDroid->sMove.speed = PHYSFS_swapSLE32(psDroid->sMove.speed); + psSaveDroid->sMove.moveDir = PHYSFS_swapSLE32(psDroid->sMove.moveDir); + psSaveDroid->sMove.fz = PHYSFS_swapSLE32(psDroid->sMove.fz); // Little endian SWORDs psSaveDroid->sMove.boundX = PHYSFS_swapSLE16(psDroid->sMove.boundX); @@ -5742,11 +5742,12 @@ static void LoadDroidMoveControl(DROID * const psDroid, SAVE_DROID const * const psDroid->sMove.targetY = PHYSFS_swapSLE32(psSaveDroid->sMove.targetY); // Little endian floats - psDroid->sMove.fx = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psSaveDroid->sMove.fx); - psDroid->sMove.fy = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psSaveDroid->sMove.fy); - psDroid->sMove.speed = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psSaveDroid->sMove.speed); - psDroid->sMove.moveDir = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psSaveDroid->sMove.moveDir); - psDroid->sMove.fz = PHYSFS_swapSLE32(*(uint32_t*)(void*)&psSaveDroid->sMove.fz); + psDroid->sMove.fx = PHYSFS_swapSLE32(psSaveDroid->sMove.fx); + psDroid->sMove.fy = PHYSFS_swapSLE32(psSaveDroid->sMove.fy); + psDroid->sMove.speed = PHYSFS_swapSLE32(psSaveDroid->sMove.speed); + psDroid->sMove.moveDir = PHYSFS_swapSLE32(psSaveDroid->sMove.moveDir); + psDroid->sMove.fz = PHYSFS_swapSLE32(psSaveDroid->sMove.fz); + assert(worldOnMap(psDroid->sMove.fx, psDroid->sMove.fy)); // Little endian SWORDs psDroid->sMove.boundX = PHYSFS_swapSLE16(psSaveDroid->sMove.boundX); diff --git a/src/move.c b/src/move.c index 34b6470e0..9293506ec 100644 --- a/src/move.c +++ b/src/move.c @@ -2332,15 +2332,11 @@ static void moveUpdateDroidPos( DROID *psDroid, float dx, float dy ) /* impact if about to go off map else update coordinates */ if ( worldOnMap( iX, iY ) == FALSE ) { - if ( psDroid->droidType == DROID_TRANSPORTER ) - { - /* transporter going off-world - trigger next map */ - - } - else + /* transporter going off-world will trigger next map, and is ok */ + ASSERT(psDroid->droidType == DROID_TRANSPORTER, "droid trying to move off the map!") + if (psDroid->droidType != DROID_TRANSPORTER) { /* dreadful last-ditch crash-avoiding hack - sort this! - GJ */ - debug(LOG_ERROR, "**** droid about to go off map - destroying it ****"); destroyDroid( psDroid ); return; }