- fixed a bug that caused bad pointers when accessing the sector inventory and then entering it

- fixed: reinforcements can happen in turnbased again
- codechange: stacks of ammo item scan now be used to feed a gun from the inventory

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5458 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-08-11 17:07:28 +00:00
parent 7e8b51ad34
commit 333633b782
9 changed files with 68 additions and 25 deletions
@@ -5073,8 +5073,11 @@ void SectorInventoryCooldownFunctions( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
HandleSectorCooldownFunctions( sMapX, sMapY, (INT8)sMapZ, pTotalSectorList, uiTotalNumberOfRealItems, TRUE );
//Save the Items to the the file
SaveWorldItemsToTempItemFile( sMapX, sMapY, (INT8)sMapZ, uiTotalNumberOfRealItems, pTotalSectorList );
if ( sMapX != gWorldSectorX || sMapY != gWorldSectorY || sMapZ != gbWorldSectorZ )
{
//Save the Items to the the file
SaveWorldItemsToTempItemFile( sMapX, sMapY, (INT8)sMapZ, uiTotalNumberOfRealItems, pTotalSectorList );
}
}
// Flugente: handle various cooldwon functions over an array of items in a specific sector.
@@ -5117,7 +5120,7 @@ void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, WORLDI
{
OBJECTTYPE* pObj = &(pWorldItem[ uiCount ].object); // ... get pointer for this item ...
if ( pObj != NULL ) // ... if pointer is not obviously useless ...
if ( pObj != NULL && pObj->exists() ) // ... if pointer is not obviously useless ...
{
// ... if we use overheating and item is a gun, a launcher or a barrel ...
if ( gGameOptions.fWeaponOverheating && ( Item[pWorldItem[ uiCount ].object.usItem].usItemClass & (IC_GUN|IC_LAUNCHER) || Item[pWorldItem[ uiCount ].object.usItem].barrel == TRUE ) )
+4 -1
View File
@@ -1830,8 +1830,11 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
}
// HEADROCK HAM 3.2: enemy reinforcements arrive with 0 APs.
if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 1 || gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 2)
{
{
pSoldier->bActionPoints = 0;
// Flugente: due to a fix, also note here that the reinforcements get no APs.
pSoldier->bSoldierFlagMask |= SOLDIER_NO_AP;
}
}
+7 -1
View File
@@ -4146,7 +4146,13 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec
SetFontForeground ( AmmoTypes[usAmmoAmmoType].fontColour );
swprintf( pStr, L"%d", (*pObject)[iter]->data.ubShotsLeft );
// count the total ammo left
UINT16 totalammo = 0;
int i;
for (i=0; i < pObject->ubNumberOfObjects; ++i)
totalammo += (*pObject)[i]->data.ubShotsLeft;
swprintf( pStr, L"%d", totalammo );
// Get length of string
uiStringLength=StringPixLength(pStr, ITEM_FONT );
+20 -6
View File
@@ -14112,7 +14112,7 @@ OBJECTTYPE* GetExternalFeedingObject(SOLDIERTYPE* pSoldier, OBJECTTYPE * pObject
if ( !pObject || !(pObject->exists()) || !pSoldier || !pSoldier->bActive || !pSoldier->bInSector || pSoldier->stats.bLife < OKLIFE )
// how did we even get here?
return false;
return ( pObjExtMag );
UINT16 usItem = pObject->usItem;
@@ -14182,13 +14182,27 @@ BOOLEAN DeductBulletViaExternalFeeding(SOLDIERTYPE* pSoldier, OBJECTTYPE * pObje
OBJECTTYPE* pObjExtMag = GetExternalFeedingObject(pSoldier, pObject);
if ( pObjExtMag && (*pObjExtMag)[0]->data.ubShotsLeft != 0 )
{
(*pObjExtMag)[0]->data.ubShotsLeft--;
if ( !pObjExtMag || pObjExtMag->ubNumberOfObjects == 0)
return false;
if ( (*pObjExtMag)[0]->data.ubShotsLeft == 0 )
UINT8 lastobjinstack = pObjExtMag->ubNumberOfObjects - 1;
if ( (*pObjExtMag)[lastobjinstack]->data.ubShotsLeft != 0 )
{
(*pObjExtMag)[lastobjinstack]->data.ubShotsLeft--;
if ( (*pObjExtMag)[lastobjinstack]->data.ubShotsLeft == 0 )
{
DeleteObj( pObjExtMag );
pObjExtMag->ubNumberOfObjects--;
if ( !pObjExtMag->exists() )
{
// Delete object
DeleteObj( pObjExtMag );
// dirty interface panel
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
}
}
return( TRUE );
+13 -5
View File
@@ -2247,6 +2247,15 @@ void SOLDIERTYPE::CalcNewActionPoints( void )
}
this->bInitialActionPoints = this->bActionPoints;
// Flugente: due to changes and bugs with enemy reinforcements, we now set a flag if a soldier should start with no APs, and act here accordingly
if ( this->bSoldierFlagMask & SOLDIER_NO_AP )
{
this->bSoldierFlagMask &= ~SOLDIER_NO_AP;
this->bInitialActionPoints = 0;
this->bActionPoints = 0;
}
}
@@ -13916,21 +13925,20 @@ BOOLEAN SOLDIERTYPE::IsFeedingExternal(UINT8* pubId1, UINT16* pGunSlot1, UINT16
if ( pAmmoObj != NULL ) // ... if pointer is not obviously useless ...
{
if ( pAmmoObj->ubNumberOfObjects == 1 )
//if ( pAmmoObj->ubNumberOfObjects == 1 )
{
usAmmoItem = pAmmoObj->usItem;
if ( Item [ usAmmoItem ].usItemClass == IC_AMMO && HasItemFlag( usAmmoItem, AMMO_BELT ) )
{
// remember the caliber, magsize (TODO: really?) and type of ammo. They all have to fit
// remember the caliber and type of ammo. They all have to fit
usMagIndex = Item[usAmmoItem].ubClassIndex;
usAmmoCalibre = Magazine[usMagIndex].ubCalibre;
//usAmmoMagSize = Magazine[usMagIndex].ubMagSize;
usAmmoAmmoType = Magazine[usMagIndex].ubAmmoType;
if ( usGunCalibre == usAmmoCalibre && /*usGunMagSize == usAmmoMagSize &&*/ usGunAmmoType == usAmmoAmmoType )
if ( usGunCalibre == usAmmoCalibre && usGunAmmoType == usAmmoAmmoType )
{
// same calibre, same magsize, same ammotype. We can serve this guy
// same calibre, same ammotype. We can serve this guy
if ( !firstgunfound )
{
firstgunfound = TRUE;
+2 -2
View File
@@ -334,8 +334,8 @@ enum
// -------- added by Flugente: various flags for soldiers --------
// easier than adding 32 differently named variables. DO NOT CHANGE THEM, UNLESS YOU KNOW WHAT YOU ARE DOING!!!
#define SOLDIER_DRUGGED 0x00000001 //1 // Soldier is on drugs
/*#define unused 0x00000002 //2 // Soldier is on a kill streak
#define WH40K_BOLTER 0x00000004 //4
#define SOLDIER_NO_AP 0x00000002 //2 // Soldier has no APs this turn (fix for reinforcement bug)
/*#define WH40K_BOLTER 0x00000004 //4
#define WH40K_FLAMER 0x00000008 //8
#define WH40K_POWER_ARMOR 0x00000010 //16
+3
View File
@@ -2670,6 +2670,9 @@ void AddSoldierInitListMilitiaOnEdge( UINT8 ubStrategicInsertionCode, UINT8 ubNu
if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 1 || gGameExternalOptions.ubReinforcementsFirstTurnFreeze == 3)
{
pSoldier->bActionPoints = 0;
// Flugente: due to a fix, also note here that the reinforcements get no APs.
pSoldier->bSoldierFlagMask |= SOLDIER_NO_AP;
}
}
}
+6 -2
View File
@@ -329,12 +329,16 @@ void EndTurn( UINT8 ubNextTeam )
}
else
{
// Flugente: I'm not really sure why we check here for gGameExternalOptions.ubReinforcementsFirstTurnFreeze, shouldn't that be a check for ALLOW_REINFORCEMENTS?
// as this inhibits reinforcements during turnbased-mode, I'll check for that instead
// HEADROCK HAM 3.2: Experimental fix to force reinforcements enter battle with 0 APs.
if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 1 && gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 2)
//if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 1 && gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 2)
if ( gGameExternalOptions.gfAllowReinforcements )
{
AddPossiblePendingEnemiesToBattle();
}
if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 1 && gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 3)
//if (gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 1 && gGameExternalOptions.ubReinforcementsFirstTurnFreeze != 3)
if ( gGameExternalOptions.gfAllowReinforcements )
{
AddPossiblePendingMilitiaToBattle();
}
+7 -5
View File
@@ -4461,19 +4461,21 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
}
else if ( fAlt )
{
/*
// Flugente: spawn items while debugging
/*// Flugente: spawn items while debugging
if ( gusSelectedSoldier != NOBODY )
{
static UINT16 usitem = 1560;
static UINT16 usitem = 1075;
static INT16 status = 100;
static FLOAT temperature = 50000.0;
static FLOAT temperature = 00000.0;
OBJECTTYPE newobj;
CreateItem( usitem, status, &newobj );
(newobj)[0]->data.bTemperature = temperature;
AddItemToPool( MercPtrs[ gusSelectedSoldier ]->sGridNo, &newobj, 1, 0, 0, -1 );
CreateItem( usitem, status, &newobj );
(newobj)[0]->data.bTemperature = temperature;
AddItemToPool( MercPtrs[ gusSelectedSoldier ]->sGridNo, &newobj, 1, 0, 0, -1 );
}*/
}