Merc arrival location fix (#263)

* User center insertion point for merc arrival

instead of initial arrival gridno that is meant only for the very first helidrop arrival at the start of a game.

* Prevent possible nullptr dereference
This commit is contained in:
Asdow
2024-01-24 00:35:39 +02:00
committed by GitHub
parent 57bf3d9fa7
commit c7bd75b60d
4 changed files with 46 additions and 38 deletions
+7
View File
@@ -628,7 +628,14 @@ UINT32 MainGameScreenHandle(void)
InternalLocateGridNo( gGameUBOptions.LOCATEGRIDNO, TRUE ); InternalLocateGridNo( gGameUBOptions.LOCATEGRIDNO, TRUE );
} }
#else #else
if (gfFirstHeliRun)
{
InternalLocateGridNo( gGameExternalOptions.iInitialMercArrivalLocation, TRUE ); InternalLocateGridNo( gGameExternalOptions.iInitialMercArrivalLocation, TRUE );
}
else
{
InternalLocateGridNo(gMapInformation.sCenterGridNo, TRUE);
}
#endif #endif
// Flugente: we might have reloaded the game, so we are currently not dropping mercs out of a helicopter // Flugente: we might have reloaded the game, so we are currently not dropping mercs out of a helicopter
gfIngagedInDrop = FALSE; gfIngagedInDrop = FALSE;
+11 -16
View File
@@ -3382,27 +3382,22 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY,
break; break;
case INSERTION_CODE_ARRIVING_GAME: case INSERTION_CODE_ARRIVING_GAME:
// Are we in Omerta! #ifdef JA2UB
if ( sSectorX == gWorldSectorX && gWorldSectorX == 9 && sSectorY == gWorldSectorY && gWorldSectorY == 1 && bSectorZ == gbWorldSectorZ && gbWorldSectorZ == 0 ) pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->sInsertionGridNo = gGameUBOptions.LOCATEGRIDNO;
#else
extern BOOLEAN gfFirstHeliRun;
if (gfFirstHeliRun)
{ {
// TODO.WANNE: Hardcoded grid number pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
// Try another location and walk into map pSoldier->sInsertionGridNo = gGameExternalOptions.iInitialMercArrivalLocation;
pSoldier->sInsertionGridNo = 4379;//dnl!!!
} }
else else
{ {
#ifdef JA2UB pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CENTER;
//pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; pSoldier->sInsertionGridNo = gMapInformation.sCenterGridNo;
//pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo;
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->sInsertionGridNo = gGameUBOptions.LOCATEGRIDNO;
#else
//pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH;
//pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo;
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->sInsertionGridNo = gGameExternalOptions.iInitialMercArrivalLocation;
#endif
} }
#endif
break; break;
case INSERTION_CODE_CHOPPER: case INSERTION_CODE_CHOPPER:
// Try another location and walk into map // Try another location and walk into map
+15 -14
View File
@@ -1038,27 +1038,28 @@ UINT8 SpawnAirDropElite( INT32 sGridNo )
// Flugente hack // Flugente hack
pSoldier = TacticalCreateEliteEnemy( ); pSoldier = TacticalCreateEliteEnemy( );
if ( pSoldier == nullptr)
{
return NOBODY;
}
//Add soldier strategic info, so it doesn't break the counters! //Add soldier strategic info, so it doesn't break the counters!
if ( pSoldier ) if ( !gbWorldSectorZ )
{ {
if ( !gbWorldSectorZ ) SECTORINFO *pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )];
switch ( pSoldier->ubSoldierClass )
{ {
SECTORINFO *pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )]; case SOLDIER_CLASS_ADMINISTRATOR: pSector->ubNumAdmins++; pSector->ubAdminsInBattle++; break;
switch ( pSoldier->ubSoldierClass ) case SOLDIER_CLASS_ARMY: pSector->ubNumTroops++; pSector->ubTroopsInBattle++; break;
{ case SOLDIER_CLASS_ELITE: pSector->ubNumElites++; pSector->ubElitesInBattle++; break;
case SOLDIER_CLASS_ADMINISTRATOR: pSector->ubNumAdmins++; pSector->ubAdminsInBattle++; break;
case SOLDIER_CLASS_ARMY: pSector->ubNumTroops++; pSector->ubTroopsInBattle++; break;
case SOLDIER_CLASS_ELITE: pSector->ubNumElites++; pSector->ubElitesInBattle++; break;
}
} }
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CHOPPER;
pSoldier->usStrategicInsertionData = sGridNo; // required, otherwise soldiers will spawn in map before jumping out of the heli
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
//AllTeamsLookForAll( NO_INTERRUPTS );
} }
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CHOPPER;
pSoldier->usStrategicInsertionData = sGridNo; // required, otherwise soldiers will spawn in map before jumping out of the heli
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
//AllTeamsLookForAll( NO_INTERRUPTS );
return pSoldier->ubID; return pSoldier->ubID;
} }
+13 -8
View File
@@ -50,6 +50,7 @@
#include "DynamicDialogue.h"// added by Flugente #include "DynamicDialogue.h"// added by Flugente
#include "Dialogue Control.h" // added by Flugente #include "Dialogue Control.h" // added by Flugente
#include "connect.h" #include "connect.h"
#include "Map Information.h"
#ifdef JA2UB #ifdef JA2UB
#include "Soldier Control.h" #include "Soldier Control.h"
@@ -534,16 +535,23 @@ void MercArrivesCallback( UINT8 ubSoldierID )
#ifdef JA2UB #ifdef JA2UB
if ( pSoldier->ubStrategicInsertionCode != INSERTION_CODE_CHOPPER && pSoldier->sSectorX == gGameExternalOptions.ubDefaultArrivalSectorX && pSoldier->sSectorY == gGameExternalOptions.ubDefaultArrivalSectorY && gGameUBOptions.InGameHeli == TRUE ) if ( pSoldier->ubStrategicInsertionCode != INSERTION_CODE_CHOPPER && pSoldier->sSectorX == gGameExternalOptions.ubDefaultArrivalSectorX && pSoldier->sSectorY == gGameExternalOptions.ubDefaultArrivalSectorY && gGameUBOptions.InGameHeli == TRUE )
#else #else
if ( pSoldier->ubStrategicInsertionCode != INSERTION_CODE_CHOPPER && pSoldier->sSectorX == gGameExternalOptions.ubDefaultArrivalSectorX && pSoldier->sSectorY == gGameExternalOptions.ubDefaultArrivalSectorY ) if (pSoldier->ubStrategicInsertionCode != INSERTION_CODE_CHOPPER )
#endif #endif
{ {
gfTacticalDoHeliRun = TRUE; gfTacticalDoHeliRun = TRUE;
SetHelicopterDroppoint(gGameExternalOptions.iInitialMercArrivalLocation); if (gfFirstHeliRun)
{
SetHelicopterDroppoint(gGameExternalOptions.iInitialMercArrivalLocation);
}
else
{
SetHelicopterDroppoint(gMapInformation.sCenterGridNo);
}
// OK, If we are in mapscreen, get out... // OK, If we are in mapscreen, get out...
if ( guiCurrentScreen == MAP_SCREEN ) if ( guiCurrentScreen == MAP_SCREEN )
{ {
// ATE: Make sure the current one is selected! // ATE: Make sure the current one is selected!
ChangeSelectedMapSector( gWorldSectorX, gWorldSectorY, 0 ); ChangeSelectedMapSector( gWorldSectorX, gWorldSectorY, 0 );
RequestTriggerExitFromMapscreen( MAP_EXIT_TO_TACTICAL ); RequestTriggerExitFromMapscreen( MAP_EXIT_TO_TACTICAL );
@@ -554,17 +562,14 @@ void MercArrivesCallback( UINT8 ubSoldierID )
UpdateMercInSector( pSoldier, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ); UpdateMercInSector( pSoldier, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );
} }
// Strategic map arrival to a sector that's not loaded
else else
{ {
// OK, otherwise, set them in north area, so once we load again, they are here.
#ifdef JA2UB #ifdef JA2UB
//pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH;
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->usStrategicInsertionData = gGameUBOptions.LOCATEGRIDNO; pSoldier->usStrategicInsertionData = gGameUBOptions.LOCATEGRIDNO;
#else #else
//pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CENTER;
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->usStrategicInsertionData = gGameExternalOptions.iInitialMercArrivalLocation;
#endif #endif
} }