From 2eb729ab31333a9fc8797ce0df5ef15658b74e82 Mon Sep 17 00:00:00 2001 From: ChrisL Date: Tue, 28 Oct 2008 18:41:22 +0000 Subject: [PATCH] Headrock found a bug in the CTH calculation with regards to autofire penalties. Think I've fixed a glich where mercs who were already in a sector (but not active) could not be placed on the tactical placement screen (either because of an assertion error or simply being told the placement wasn't valid). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2385 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 8 ++++---- Tactical/Weapons.cpp | 2 +- TileEngine/Map Edgepoints.cpp | 10 +++++++--- TileEngine/Map Edgepoints.h | 5 +++-- TileEngine/Tactical Placement GUI.cpp | 9 +++++++-- ja2_2005Express.vcproj | 8 ++++---- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index 2e688975..172fdd42 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -13,12 +13,12 @@ #ifdef JA2EDITOR //MAP EDITOR BUILD VERSION -CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.2377" }; +CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.2385" }; #elif defined JA2BETAVERSION //BETA/TEST BUILD VERSION -CHAR16 zVersionLabel[256] = { L"Debug v1.13.2377" }; +CHAR16 zVersionLabel[256] = { L"Debug v1.13.2385" }; #elif defined CRIPPLED_VERSION @@ -28,11 +28,11 @@ CHAR16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - CHAR16 zVersionLabel[256] = { L"Release v1.13.2375" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.2385" }; #endif -CHAR8 czVersionNumber[16] = { "Build 08.10.15" }; //YY.MM.DD +CHAR8 czVersionNumber[16] = { "Build 08.10.28" }; //YY.MM.DD CHAR16 zTrackingNumber[16] = { L"Z" }; diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index d49719fe..47b5526b 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -3732,7 +3732,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubAimTime, { // Snap: bipod may reduce auto penalty iPenalty = GetAutoPenalty(pInHand, gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_PRONE) - * (pSoldier->bDoBurst - 1); + * (pSoldier->bDoAutofire - 1); // halve the penalty for people with the autofire trait if ( HAS_SKILL_TRAIT( pSoldier, AUTO_WEAPS ) ) diff --git a/TileEngine/Map Edgepoints.cpp b/TileEngine/Map Edgepoints.cpp index b1066e96..a9f5b898 100644 --- a/TileEngine/Map Edgepoints.cpp +++ b/TileEngine/Map Edgepoints.cpp @@ -1040,7 +1040,7 @@ BOOLEAN LoadMapEdgepoints( INT8 **hBuffer ) return TRUE; } -UINT16 ChooseMapEdgepoint( UINT8 ubStrategicInsertionCode ) +UINT16 ChooseMapEdgepoint( UINT8 *ubStrategicInsertionCode, UINT8 lastValidICode ) { INT16 *psArray=NULL; UINT16 usArraySize=0; @@ -1048,7 +1048,9 @@ UINT16 ChooseMapEdgepoint( UINT8 ubStrategicInsertionCode ) //First validate and get access to the correct array based on strategic direction. //We will use the selected array to choose insertion gridno's. - switch( ubStrategicInsertionCode ) + if( *ubStrategicInsertionCode == INSERTION_CODE_GRIDNO) + *ubStrategicInsertionCode = lastValidICode; + switch( *ubStrategicInsertionCode ) { case INSERTION_CODE_NORTH: psArray = gps1stNorthEdgepointArray; @@ -1251,7 +1253,7 @@ void EndMapEdgepointSearch() //THIS CODE ISN'T RECOMMENDED FOR TIME CRITICAL AREAS. -INT16 SearchForClosestPrimaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode ) +INT16 SearchForClosestPrimaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode, UINT8 defaultICode, UINT8 *storedICode ) { INT32 i, iDirectionLoop; INT16 *psArray=NULL; @@ -1263,6 +1265,8 @@ INT16 SearchForClosestPrimaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode { //Everything is reserved. AssertMsg( 0, "All closest map edgepoints have been reserved. We should only have 20 soldiers maximum..."); } + if( ubInsertionCode == INSERTION_CODE_GRIDNO ) + *storedICode = ubInsertionCode = defaultICode; switch( ubInsertionCode ) { case INSERTION_CODE_NORTH: diff --git a/TileEngine/Map Edgepoints.h b/TileEngine/Map Edgepoints.h index e365a784..008c3741 100644 --- a/TileEngine/Map Edgepoints.h +++ b/TileEngine/Map Edgepoints.h @@ -3,6 +3,7 @@ #include "types.h" #include "Fileman.h" +#include "strategic.h" typedef struct MAPEDGEPOINTINFO { @@ -11,7 +12,7 @@ typedef struct MAPEDGEPOINTINFO INT16 sGridNo[ 32 ]; }MAPEDGEPOINTINFO; -UINT16 ChooseMapEdgepoint( UINT8 ubStrategicInsertionCode ); +UINT16 ChooseMapEdgepoint( UINT8 *ubStrategicInsertionCode, UINT8 lastValidICode ); void ChooseMapEdgepoints( MAPEDGEPOINTINFO *pMapEdgepointInfo, UINT8 ubStrategicInsertionCode, UINT8 ubNumDesiredPoints ); void GenerateMapEdgepoints(); void SaveMapEdgepoints( HWFILE fp ); @@ -62,7 +63,7 @@ extern UINT16 gus2ndWestEdgepointMiddleIndex; //code shouldn't be used for enemies or anybody else. void BeginMapEdgepointSearch(); void EndMapEdgepointSearch(); -INT16 SearchForClosestPrimaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode ); +INT16 SearchForClosestPrimaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode, UINT8 defaultICode = INSERTION_CODE_GRIDNO, UINT8 *storedICode = NULL ); INT16 SearchForClosestSecondaryMapEdgepoint( INT16 sGridNo, UINT8 ubInsertionCode ); //There are two classes of edgepoints. diff --git a/TileEngine/Tactical Placement GUI.cpp b/TileEngine/Tactical Placement GUI.cpp index 69208e8e..1e0f68dd 100644 --- a/TileEngine/Tactical Placement GUI.cpp +++ b/TileEngine/Tactical Placement GUI.cpp @@ -907,14 +907,16 @@ void KillTacticalPlacementGUI() void ChooseRandomEdgepoints() { INT32 i; + UINT8 lastValidICode = INSERTION_CODE_GRIDNO; for( i = 0; i < giPlacements; i++ ) { if ( !( gMercPlacement[ i ].pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) ) { - gMercPlacement[ i ].pSoldier->usStrategicInsertionData = ChooseMapEdgepoint( gMercPlacement[ i ].ubStrategicInsertionCode ); + gMercPlacement[ i ].pSoldier->usStrategicInsertionData = ChooseMapEdgepoint( &gMercPlacement[ i ].ubStrategicInsertionCode, lastValidICode ); if( gMercPlacement[ i ].pSoldier->usStrategicInsertionData != NOWHERE ) { gMercPlacement[ i ].pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + lastValidICode = gMercPlacement[ i ].ubStrategicInsertionCode; } else { @@ -1109,6 +1111,7 @@ void HandleTacticalPlacementClicksInOverheadMap( MOUSE_REGION *reg, INT32 reason INT32 i; INT16 sGridNo; BOOLEAN fInvalidArea = FALSE; + UINT8 lastValidICode = INSERTION_CODE_GRIDNO; if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { //if we have a selected merc, move him to the new closest map edgepoint of his side. if( gfValidCursor ) @@ -1127,12 +1130,14 @@ void HandleTacticalPlacementClicksInOverheadMap( MOUSE_REGION *reg, INT32 reason //the problem. If everything's okay, we will place them all. if( gMercPlacement[ i ].pSoldier->ubGroupID == gubSelectedGroupID ) { - gMercPlacement[ i ].pSoldier->usStrategicInsertionData = SearchForClosestPrimaryMapEdgepoint( sGridNo, gMercPlacement[ i ].ubStrategicInsertionCode ); + gMercPlacement[ i ].pSoldier->usStrategicInsertionData = SearchForClosestPrimaryMapEdgepoint( sGridNo, gMercPlacement[ i ].ubStrategicInsertionCode, lastValidICode, &gMercPlacement[ i ].ubStrategicInsertionCode ); if( gMercPlacement[ i ].pSoldier->usStrategicInsertionData == NOWHERE ) { fInvalidArea = TRUE; break; } + else + lastValidICode = gMercPlacement[ i ].ubStrategicInsertionCode; } } if( !fInvalidArea ) diff --git a/ja2_2005Express.vcproj b/ja2_2005Express.vcproj index 1498b115..41a21aba 100644 --- a/ja2_2005Express.vcproj +++ b/ja2_2005Express.vcproj @@ -66,7 +66,7 @@