Fix: crash when placing vehicles with to long name (by asm-debacle)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7897 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2015-06-28 20:34:33 +00:00
parent 4d9140da57
commit 9cae4bde9a
2 changed files with 14 additions and 14 deletions
+1
View File
@@ -2696,6 +2696,7 @@ void CreateDetailedPlacementGivenStaticDetailedPlacementAndBasicPlacementInfo(
pp->bOrders = bp->bOrders; pp->bOrders = bp->bOrders;
pp->bAttitude = bp->bAttitude; pp->bAttitude = bp->bAttitude;
pp->ubDirection = bp->ubDirection; pp->ubDirection = bp->ubDirection;
pp->bBodyType = bp->bBodyType;
pp->bPatrolCnt = bp->bPatrolCnt; pp->bPatrolCnt = bp->bPatrolCnt;
memcpy( pp->sPatrolGrid, bp->sPatrolGrid, sizeof( INT32 ) * MAXPATROLGRIDS ); memcpy( pp->sPatrolGrid, bp->sPatrolGrid, sizeof( INT32 ) * MAXPATROLGRIDS );
pp->fHasKeys = bp->fHasKeys; pp->fHasKeys = bp->fHasKeys;
+13 -14
View File
@@ -201,7 +201,8 @@ BOOLEAN LoadNewVehiclesToSaveGameFile( HWFILE hFile )
return( TRUE ); return( TRUE );
} }
void InitAVehicle(int index, int x, int y) { void InitAVehicle(int index, int x, int y)
{
gubVehicleMovementGroups[ index ] = CreateNewVehicleGroupDepartingFromSector( x, y, index ); gubVehicleMovementGroups[ index ] = CreateNewVehicleGroupDepartingFromSector( x, y, index );
// Set persistent.... // Set persistent....
@@ -212,17 +213,19 @@ void InitAVehicle(int index, int x, int y) {
// Loop through and create a few soldier squad ID's for vehicles // Loop through and create a few soldier squad ID's for vehicles
void InitAllVehicles( ) { void InitAllVehicles( )
for( int cnt = 0; cnt < MAX_VEHICLES; cnt++ ) {
for( int cnt = 0; cnt < MAX_VEHICLES; ++cnt )
InitAVehicle(cnt, 1, 1); InitAVehicle(cnt, 1, 1);
} }
void SetVehicleValuesIntoSoldierType( SOLDIERTYPE *pVehicle ) void SetVehicleValuesIntoSoldierType( SOLDIERTYPE *pVehicle )
{ {
// wcscpy( pVehicle->name, zVehicleName[ pVehicleList[ pVehicle->bVehicleID ].ubVehicleType ] ); //wcscpy( pVehicle->name, zVehicleName[ pVehicleList[ pVehicle->bVehicleID ].ubVehicleType ] );
wcscpy( pVehicle->name, gNewVehicle[ pVehicleList[ pVehicle->bVehicleID ].ubVehicleType ].NewVehicleName ); //wcscpy( pVehicle->name, gNewVehicle[ pVehicleList[ pVehicle->bVehicleID ].ubVehicleType ].NewVehicleName );
wcsncpy( pVehicle->name, gNewVehicle[pVehicleList[pVehicle->bVehicleID].ubVehicleType].NewVehicleName, (sizeof(pVehicle->name) / sizeof(pVehicle->name[0]) - 1) );
pVehicle->ubProfile = pVehicleList[ pVehicle->bVehicleID ].ubProfileID; pVehicle->ubProfile = pVehicleList[ pVehicle->bVehicleID ].ubProfileID;
// Init fuel! // Init fuel!
@@ -242,11 +245,10 @@ INT32 AddVehicleToList( INT16 sMapX, INT16 sMapY, INT32 sGridNo, UINT8 ubType )
BOOLEAN fFoundEmpty = FALSE; BOOLEAN fFoundEmpty = FALSE;
GROUP *pGroup; GROUP *pGroup;
if( pVehicleList != NULL ) if( pVehicleList != NULL )
{ {
// not the first, add to list // not the first, add to list
for( iCounter = 0; iCounter < ubNumberOfVehicles ; iCounter++ ) for( iCounter = 0; iCounter < ubNumberOfVehicles ; ++iCounter )
{ {
// might have an empty slot // might have an empty slot
if( pVehicleList[ iCounter ].fValid == FALSE ) if( pVehicleList[ iCounter ].fValid == FALSE )
@@ -254,7 +256,7 @@ INT32 AddVehicleToList( INT16 sMapX, INT16 sMapY, INT32 sGridNo, UINT8 ubType )
iCount = iCounter; iCount = iCounter;
iCounter = ubNumberOfVehicles; iCounter = ubNumberOfVehicles;
fFoundEmpty = TRUE; fFoundEmpty = TRUE;
iVehicleIdValue = iCount; iVehicleIdValue = iCount;
} }
} }
} }
@@ -274,8 +276,7 @@ INT32 AddVehicleToList( INT16 sMapX, INT16 sMapY, INT32 sGridNo, UINT8 ubType )
ubNumberOfVehicles = 1; ubNumberOfVehicles = 1;
iVehicleIdValue = 0; iVehicleIdValue = 0;
} }
if( ( iVehicleIdValue == -1 ) && ( iCount != 0 ) && ( fFoundEmpty == FALSE ) ) if( ( iVehicleIdValue == -1 ) && ( iCount != 0 ) && ( fFoundEmpty == FALSE ) )
{ {
@@ -300,9 +301,7 @@ INT32 AddVehicleToList( INT16 sMapX, INT16 sMapY, INT32 sGridNo, UINT8 ubType )
// now get the index value // now get the index value
iVehicleIdValue = ubNumberOfVehicles; iVehicleIdValue = ubNumberOfVehicles;
ubNumberOfVehicles++; ++ubNumberOfVehicles;
} }
// found a slot // found a slot