diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index bbbf4e14..a6bb7b35 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -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 ) ) diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index f59441ae..88dd94a7 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -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; } } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index e63ca41c..fec21784 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -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 ); diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 68f50677..a6db2cad 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -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 ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 93a8ac09..a9027ec9 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -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; diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 51322b46..c1a4862b 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -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 diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp index 795db8e0..3acc968f 100644 --- a/Tactical/Soldier Init List.cpp +++ b/Tactical/Soldier Init List.cpp @@ -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; } } } diff --git a/Tactical/TeamTurns.cpp b/Tactical/TeamTurns.cpp index 28cc2ce5..5aef8323 100644 --- a/Tactical/TeamTurns.cpp +++ b/Tactical/TeamTurns.cpp @@ -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(); } diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 4149e25d..9e9b9d1a 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -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 ); }*/ }