HAM5.5b2 merged in!

Notes:
-There may still be bugs!! (In fact, I almost guarantee it -- there's
-Ammo box code added to HR's crate code
-Splitting a crate/box also automatically refills half empty magazines
-new pathing arrows for map screen not included
-code for scouts to know where enemies are going doesn't appear to work... but i'm not sure it was completed.
-lots of gobledy gook (chinese?) comments turned back to english
-also added Bob's popups
-other languages besides english still need to have there language.cpp files updated with array changes
-AI enhancements by Warmsteel (reloading, suppression, roaming, avoiding gas, and other fixes)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5181 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2012-04-10 23:45:46 +00:00
parent ab3412e5ed
commit c845f9f117
72 changed files with 10737 additions and 2362 deletions
+3 -1
View File
@@ -68,6 +68,7 @@
// #include "Strategic AI.h"
#include "interface Dialogue.h"
#include "AIInternals.h" // added by SANDRO
#include "Bullets.h" // HEADROCK HAM 5, for use with Bullet Impact.
#endif
#include "Reinforcement.h"
@@ -4414,7 +4415,8 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget )
else
ubLocation = AIM_SHOT_TORSO;
ubAccuracy = (UINT8)((usAttack - usDefence + PreRandom( usDefence - pTarget->usDefence ) )/10);
iImpact = BulletImpact( pAttacker->pSoldier, pTarget->pSoldier, ubLocation, ubImpact, ubAccuracy, NULL );
// HEADROCK HAM 5: Added argument
iImpact = BulletImpact( pAttacker->pSoldier, NULL, pTarget->pSoldier, ubLocation, ubImpact, ubAccuracy, NULL );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SANDRO - increased mercs' offense/deffense rating
if (pAttacker->uiFlags & CELL_MERC && gGameExternalOptions.sMercsAutoresolveOffenseBonus != 0)
+27 -4
View File
@@ -28,8 +28,12 @@
// Also include Town Militia for checks regarding Mobile Militia Restrictions
#include "Town Militia.h"
// Also include Quests, for checking whether a fact is true.
#include "Quests.h"
#include "Quests.h"
// HEADROCK HAM 5: Required for inventory filter popup
#include "popup_callback.h"
#include "popup_class.h"
#endif
#include "connect.h"
#ifdef JA2UB
@@ -91,6 +95,13 @@ BOOLEAN fZoomFlag = FALSE;
//BOOLEAN fCursorIsOnMapScrollButtons = FALSE;
//BOOLEAN fDisabledMapBorder = FALSE;
// HEADROCK HAM 5: Externed here to be able to forgo redrawing the map inventory.
extern POPUP* gMapInventoryFilterPopup;
extern BOOLEAN gfMapInventoryFilterPopupVisible;
extern BOOLEAN gfQueueRecreateMapInventoryFilterMenu;
extern UINT32 guiMapInvenFilterButton[ 9 ];
extern void CreateMapInventoryFilterMenu( );
// buttons & button images
// HEADROCK HAM 4: Increase both arrays by one to accomodate new Mobile Restrictions button
@@ -210,17 +221,29 @@ void RenderMapBorder( void )
}
*/
// HEADROCK HAM 5: Do not redraw if the filter menu is open.
if( fShowMapInventoryPool )
{
// render background, then leave
BlitInventoryPoolGraphic( );
if (gfMapInventoryFilterPopupVisible)
{
if (gfQueueRecreateMapInventoryFilterMenu)
{
ButtonList[guiMapInvenFilterButton[ 0 ]]->uiFlags |= (BUTTON_CLICKED_ON);
CreateMapInventoryFilterMenu();
}
gMapInventoryFilterPopup->show();
}
else
{
// render background, then leave
BlitInventoryPoolGraphic( );
}
return;
}
// get and blt border
GetVideoObject(&hHandle, guiMapBorder );
// HEADROCK HAM 4: Load different map border depending on whether we want to display the mobile militia button or not.
if (gGameExternalOptions.gfAllowMilitiaGroups)
{
BltVideoObject( guiSAVEBUFFER , hHandle, 1, xResOffset + MAP_BORDER_X, MAP_BORDER_Y, VO_BLT_SRCTRANSPARENCY,NULL );
File diff suppressed because it is too large Load Diff
@@ -12,6 +12,9 @@
// whether we are showing the inventory pool graphic
extern BOOLEAN fShowMapInventoryPool;
// HEADROCK HAM 5: Flag telling us whether we've already redrawn the screen to show
// sector inventory sale prices.
extern UINT8 gubRenderedMapInventorySalePrices;
// load inventory pool graphic
BOOLEAN LoadInventoryPoolGraphic( void );
@@ -21,6 +24,8 @@ void RemoveInventoryPoolGraphic( void );
// blit the inventory graphic
void BlitInventoryPoolGraphic( void );
// HEADROCK HAM 5: Blit map inventory slots
void BlitInventoryPoolSlotGraphics( void );
// which buttons in map invneotyr panel?
void HandleButtonStatesWhileMapInventoryActive( void );
@@ -52,6 +57,8 @@ extern INT32 sObjectSourceGridNo;
extern INT32 iCurrentInventoryPoolPage;
extern INT32 iLastInventoryPoolPage;
extern BOOLEAN fMapInventoryItemCompatable[ ];
// HEADROCK HAM 5: Same idea as above, this flags items as being candidates for appearing in Zoomed mode.
extern BOOLEAN gfMapInventoryItemToZoom[ ];
extern INT32 MAP_INVENTORY_POOL_SLOT_COUNT;
BOOLEAN IsMapScreenWorldItemInvisibleInMapInventory( WORLDITEM *pWorldItem );
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -98,6 +98,7 @@ void RestoreClipRegionToFullScreenForRectangle( UINT32 uiDestPitchBYTES );
// show the icons for people in motion
void ShowPeopleInMotion( INT16 sX, INT16 sY );
void ShowEnemyGroupsInMotion( INT16 sX, INT16 sY);
// last sector in helicopter's path
INT16 GetLastSectorOfHelicoptersPath( void );
@@ -159,7 +160,9 @@ enum {
enum {
KNOWS_NOTHING = 0,
KNOWS_THEYRE_THERE,
KNOWS_THEYRE_THERE_AND_WHERE_GOING,
KNOWS_HOW_MANY,
KNOWS_HOW_MANY_AND_WHERE_GOING,
};
@@ -273,7 +276,8 @@ extern UINT32 guiBULLSEYE;
// character between sector icons
extern UINT32 guiCHARBETWEENSECTORICONS;
extern UINT32 guiCHARBETWEENSECTORICONSCLOSE;
// HEADROCK HAM 5: Enemies Between Sectors icons
extern UINT32 guiENEMYBETWEENSECTORICONS;
// the viewable map bound region
extern SGPRect MapScreenRect;
@@ -296,6 +300,9 @@ extern INT8 bSelectedContractChar;
// map arrows graphical index value
extern UINT32 guiMAPCURSORS;
// HEADROCK HAM 5: New pathing arrows may replace the above eventually, but for now a separate variable will do.
extern UINT32 guiMapPathingArrows;
// has temp path for character path or helicopter been already drawn
extern BOOLEAN fTempPathAlreadyDrawn;
+170 -59
View File
@@ -59,6 +59,8 @@ UINT16 sTotalButtonWidth = 0;
extern BOOLEAN fMapScreenBottomDirty;
//extern UINT8 gubMonsterMineInfestation[];
// HEADROCK HAM 5: Must be externed here for correct sector name display
extern CHAR16 gzSectorNames[256][4][MAX_SECTOR_NAME_LENGTH];
// create the town/mine info box
void CreateTownInfoBox( void );
@@ -294,43 +296,96 @@ void AddTextToTownBox( void )
usTownSectorIndex = SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY );
switch( usTownSectorIndex )
AssertGE(usTownSectorIndex, 0);
AssertLT(usTownSectorIndex,256);
////////////////////////////////////
// HEADROCK HAM 5:
// Read and verify XML sector names
BOOLEAN fSectorHasXMLNames = TRUE;
CHAR16 zUnexplored[MAX_SECTOR_NAME_LENGTH];
CHAR16 zExplored[MAX_SECTOR_NAME_LENGTH];
wcscpy( zUnexplored, gzSectorNames[ usTownSectorIndex ][0] );
wcscpy( zExplored, gzSectorNames[ usTownSectorIndex ][2] );
if (zUnexplored[0] == 0 || zExplored[0] == 0)
{
case SEC_B13:
AddMonoString( &hStringHandle, pLandTypeStrings[ DRASSEN_AIRPORT_SITE ] );
break;
case SEC_F8:
AddMonoString( &hStringHandle, pLandTypeStrings[ CAMBRIA_HOSPITAL_SITE ] );
break;
case SEC_J9: //Tixa
//if( !fFoundTixa )
if( gfHiddenTown[ TIXA ] == FALSE )
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND ] );
else
AddMonoString( &hStringHandle, pTownNames[ TIXA ] );
break;
case SEC_K4: //Orta
//if( !fFoundOrta )
if( gfHiddenTown[ ORTA ] == FALSE )
AddMonoString( &hStringHandle, pLandTypeStrings[ SWAMP ] );
else
AddMonoString( &hStringHandle, pTownNames[ ORTA ] );
break;
case SEC_N3:
AddMonoString( &hStringHandle, pLandTypeStrings[ MEDUNA_AIRPORT_SITE ] );
break;
default:
if( usTownSectorIndex == SEC_N4 && fSamSiteFound[ SAM_SITE_FOUR ] )
{ //Meduna's SAM site
AddMonoString( &hStringHandle, pLandTypeStrings[ MEDUNA_SAM_SITE ] );
}
else
{ // town name
swprintf( wString, L"%s", pTownNames[ ubTownId ] );
AddMonoString( &hStringHandle, wString );
}
break;
fSectorHasXMLNames = FALSE;
}
if (fSectorHasXMLNames) // ABOVE GROUND XML
{
// HEADROCK HAM 3.6: The program can now read custom names from XML for all above-ground sectors.
// In the event that a specific name or set of names is missing, the program generates a default
// name as it always has.
// I've also updated the SAM Site sectors to rely on SamSite.XML data.
BOOLEAN fVisited = (SectorInfo[ usTownSectorIndex ].uiFlags & SF_ALREADY_VISITED);
BOOLEAN fSAMSiteKnown = FALSE;
// Test for known SAM Site at this location
for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++)
{
if ( pSamList[x] == usTownSectorIndex )
{
if ( fSamSiteFound[ x ] )
{
fSAMSiteKnown = TRUE;
}
}
}
if (fVisited || fSAMSiteKnown)
{
AddMonoString( &hStringHandle, zExplored );
}
else
{
AddMonoString( &hStringHandle, zUnexplored );
}
}
else // ABOVE GROUND HARDCODED
{
switch( usTownSectorIndex )
{
case SEC_B13:
AddMonoString( &hStringHandle, pLandTypeStrings[ DRASSEN_AIRPORT_SITE ] );
break;
case SEC_F8:
AddMonoString( &hStringHandle, pLandTypeStrings[ CAMBRIA_HOSPITAL_SITE ] );
break;
case SEC_J9: //Tixa
//if( !fFoundTixa )
if( gfHiddenTown[ TIXA ] == FALSE )
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND ] );
else
AddMonoString( &hStringHandle, pTownNames[ TIXA ] );
break;
case SEC_K4: //Orta
//if( !fFoundOrta )
if( gfHiddenTown[ ORTA ] == FALSE )
AddMonoString( &hStringHandle, pLandTypeStrings[ SWAMP ] );
else
AddMonoString( &hStringHandle, pTownNames[ ORTA ] );
break;
case SEC_N3:
AddMonoString( &hStringHandle, pLandTypeStrings[ MEDUNA_AIRPORT_SITE ] );
break;
default:
if( usTownSectorIndex == SEC_N4 && fSamSiteFound[ SAM_SITE_FOUR ] )
{ //Meduna's SAM site
AddMonoString( &hStringHandle, pLandTypeStrings[ MEDUNA_SAM_SITE ] );
}
else
{ // town name
swprintf( wString, L"%s", pTownNames[ ubTownId ] );
AddMonoString( &hStringHandle, wString );
}
break;
}
}
// blank line
AddMonoString( &hStringHandle, L"" );
@@ -523,31 +578,83 @@ void AddTextToBlankSectorBox( void )
// get the sector value
usSectorValue = SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY );
switch( usSectorValue )
{
case SEC_D2: //Chitzena SAM
if( !fSamSiteFound[ SAM_SITE_ONE ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ TROPICS ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ TROPICS_SAM_SITE ] );
break;
case SEC_D15: //Drassen SAM
if( !fSamSiteFound[ SAM_SITE_TWO ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ SPARSE ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ SPARSE_SAM_SITE ] );
break;
case SEC_I8: //Cambria SAM
if( !fSamSiteFound[ SAM_SITE_THREE ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND_SAM_SITE ] );
break;
// SAM Site 4 in Meduna is within town limits, so it's handled in AddTextToTownBox()
AssertGE(usSectorValue, 0);
AssertLT(usSectorValue,256);
default:
AddMonoString( &hStringHandle, pLandTypeStrings[ ( SectorInfo[ usSectorValue ].ubTraversability[ 4 ] ) ] );
break;
////////////////////////////////////
// HEADROCK HAM 5:
// Read and verify XML sector names
BOOLEAN fSectorHasXMLNames = TRUE;
CHAR16 zUnexplored[MAX_SECTOR_NAME_LENGTH];
CHAR16 zExplored[MAX_SECTOR_NAME_LENGTH];
wcscpy( zUnexplored, gzSectorNames[ usSectorValue ][0] );
wcscpy( zExplored, gzSectorNames[ usSectorValue ][2] );
if (zUnexplored[0] == 0 || zExplored[0] == 0)
{
fSectorHasXMLNames = FALSE;
}
if (fSectorHasXMLNames) // ABOVE GROUND XML
{
// HEADROCK HAM 3.6: The program can now read custom names from XML for all above-ground sectors.
// In the event that a specific name or set of names is missing, the program generates a default
// name as it always has.
// I've also updated the SAM Site sectors to rely on SamSite.XML data.
BOOLEAN fVisited = (SectorInfo[ usSectorValue ].uiFlags & SF_ALREADY_VISITED);
BOOLEAN fSAMSiteKnown = FALSE;
// Test for known SAM Site at this location
for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++)
{
if ( pSamList[x] == usSectorValue )
{
if ( fSamSiteFound[ x ] )
{
fSAMSiteKnown = TRUE;
}
}
}
if (fVisited || fSAMSiteKnown)
{
AddMonoString( &hStringHandle, zExplored );
}
else
{
AddMonoString( &hStringHandle, zUnexplored );
}
}
else // ABOVE GROUND HARDCODED
{
switch( usSectorValue )
{
case SEC_D2: //Chitzena SAM
if( !fSamSiteFound[ SAM_SITE_ONE ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ TROPICS ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ TROPICS_SAM_SITE ] );
break;
case SEC_D15: //Drassen SAM
if( !fSamSiteFound[ SAM_SITE_TWO ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ SPARSE ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ SPARSE_SAM_SITE ] );
break;
case SEC_I8: //Cambria SAM
if( !fSamSiteFound[ SAM_SITE_THREE ] )
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND ] );
else
AddMonoString( &hStringHandle, pLandTypeStrings[ SAND_SAM_SITE ] );
break;
// SAM Site 4 in Meduna is within town limits, so it's handled in AddTextToTownBox()
default:
AddMonoString( &hStringHandle, pLandTypeStrings[ ( SectorInfo[ usSectorValue ].ubTraversability[ 4 ] ) ] );
break;
}
}
// blank line
@@ -723,7 +830,9 @@ void AddCommonInfoToBox(void)
wcscpy(wString, pwMiscSectorStrings[ 3 ] );
break;
// HEADROCK HAM 5: New Case
case KNOWS_THEYRE_THERE:
case KNOWS_THEYRE_THERE_AND_WHERE_GOING:
// if there are any there
if ( ubNumEnemies > 0 )
{
@@ -737,7 +846,9 @@ void AddCommonInfoToBox(void)
}
break;
// HEADROCK HAM 5: New case
case KNOWS_HOW_MANY:
case KNOWS_HOW_MANY_AND_WHERE_GOING:
// show exactly how many
if (numEnemiesOnMap != ubNumEnemies)
swprintf( wString, L"%d (%d)", numEnemiesOnMap, ubNumEnemies );
+17 -3
View File
@@ -71,7 +71,8 @@ UINT8 gubManualRestrictMilitia[ 256 ];
// HEADROCK HAM B1: Alternate array keeps track of dynamically unrestricted sectors
BOOLEAN gDynamicRestrictMilitia[ 256 ];
// HEADROCK HAM B1: Function that dynamically unrestricts sectors as we take over towns.
extern void AdjustRoamingRestrictions();
// HEADROCK HAM 5: New flag tells us to also recheck restriced sectors.
extern void AdjustRoamingRestrictions( BOOLEAN fRecheck );
DYNAMICRESTRICTIONS gDynamicRestrictions[5001];
@@ -2167,7 +2168,8 @@ void MilitiaFollowPlayer( INT16 sMapX, INT16 sMapY, INT16 sDMapX, INT16 sDMapY )
}
}*/
void AdjustRoamingRestrictions()
// HEADROCK HAM 5: New flag tells us to also recheck restriced sectors.
void AdjustRoamingRestrictions( BOOLEAN fRecheck )
{
UINT32 uiCapturedTownsFlag = 0;
UINT16 cnt = 0;
@@ -2203,7 +2205,19 @@ void AdjustRoamingRestrictions()
}
}
}
}
// HEADROCK HAM 5: All restricted sectors are checked to see they aren't manually-permitted.
if (fRecheck)
{
for (cnt = 0; cnt < 256; cnt++)
{
if (gDynamicRestrictMilitia[cnt] == FALSE)
{
gubManualRestrictMilitia[cnt] = MANUAL_MOBILE_RESTRICTED;
}
}
}
}
// HEADROCK HAM B2.7: This is a copy of an existing function that generates possible movement directions for militia.
+2 -1
View File
@@ -25,7 +25,8 @@ BOOLEAN MoveOneBestMilitiaMan(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMa
void MilitiaFollowPlayer( INT16 sMapX, INT16 sMapY, INT16 sDMapX, INT16 sDMapY );
// HEADROCK HAM B1: Changes the allowed militia sectors
extern void AdjustRoamingRestrictions();
// HEADROCK HAM 5: New flag tells us to also recheck restriced sectors.
extern void AdjustRoamingRestrictions( BOOLEAN fRecheck );
// HEADROCK HAM 4: Yet ANOTHER array, this one holds player-set restrictions. It interacts with the dynamic one below.
extern UINT8 gubManualRestrictMilitia[ 256 ];
// HEADROCK HAM B1: Alternate array keeps track of dynamically unrestricted sectors
+4 -2
View File
@@ -656,7 +656,9 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI )
// adjust the chance for what we know about the sector
if( WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) == KNOWS_NOTHING )
iChance += 20;
else if( WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) == KNOWS_THEYRE_THERE )
// HEADROCK HAM 5: Added new possible value...
else if( WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) == KNOWS_THEYRE_THERE ||
WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) == KNOWS_THEYRE_THERE_AND_WHERE_GOING )
iChance += 5;
//if( GetSectorFlagStatus( gubPBSectorX, gubPBSectorY, 0, SF_ALREADY_VISITED ) == TRUE )
// iChance -= 10; // if we already visited this sector
@@ -1246,7 +1248,7 @@ void RenderPreBattleInterface()
if( gubEnemyEncounterCode == CREATURE_ATTACK_CODE ||
gubEnemyEncounterCode == BLOODCAT_AMBUSH_CODE ||
gubEnemyEncounterCode == ENTERING_BLOODCAT_LAIR_CODE ||
WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) != KNOWS_HOW_MANY )
WhatPlayerKnowsAboutEnemiesInSector( gubPBSectorX, gubPBSectorY ) < KNOWS_HOW_MANY ) // HEADROCK HAM 5: New case above this one...
{
// don't know how many
swprintf( str, L"?" );
+2 -1
View File
@@ -587,7 +587,8 @@ void MercDailyUpdate()
// HEADROCK HAM B1: Run a function to redefine Roaming Militia Restrictions.
if (gGameExternalOptions.fDynamicRestrictRoaming)
{
AdjustRoamingRestrictions();
// HEADROCK HAM 5: New flag tells us to also recheck restriced sectors.
AdjustRoamingRestrictions( FALSE );
}
// HEADROCK HAM 3.6: Pay debt for operating Facilities today. If can't be paid, apply loyalty hit.
+2 -1
View File
@@ -69,7 +69,8 @@ class SOLDIERTYPE;
extern UINT32 guiLastTacticalRealTime;
// the delay for a group about to arrive
#define ABOUT_TO_ARRIVE_DELAY 5
// HEADROCK HAM 5: 5 minutes? Make it 30. 5 minutes tend to pass in an instant while unpaused...
#define ABOUT_TO_ARRIVE_DELAY 30
GROUP *gpGroupList;
+2 -1
View File
@@ -1859,7 +1859,8 @@ void CheckIfEntireTownHasBeenLiberated( INT8 bTownId, INT16 sSectorX, INT16 sSec
// HEADROCK HAM B1: Run a function to redefine Roaming Militia Restrictions on city capture.
if (gGameExternalOptions.fDynamicRestrictRoaming)
{
AdjustRoamingRestrictions();
// HEADROCK HAM 5: New flag tells us to also recheck restriced sectors.
AdjustRoamingRestrictions( FALSE );
}
// set flag even for towns where you can't train militia, useful for knowing Orta/Tixa were previously controlled
+1
View File
@@ -126,6 +126,7 @@
<ClCompile Include="UndergroundInit.cpp" />
<ClCompile Include="XML_Army.cpp" />
<ClCompile Include="XML_Bloodcats.cpp" />
<ClCompile Include="XML_CoolnessBySector.cpp" />
<ClCompile Include="XML_DynamicRestrictions.cpp" />
<ClCompile Include="XML_ExtraItems.cpp" />
<ClCompile Include="XML_Facilities.cpp" />
@@ -335,5 +335,8 @@
<ClCompile Include="MapScreen Quotes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="XML_CoolnessBySector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+169
View File
@@ -0,0 +1,169 @@
#ifdef PRECOMPILEDHEADERS
#include "Strategic All.h"
#include "XML.h"
#else
#include "builddefines.h"
#include <stdio.h>
#include "XML.h"
#include "expat.h"
#include "string.h"
#include "Campaign Types.h"
#include "FileMan.h"
#include "MemMan.h"
#include "Debug Control.h"
#include "mapscreen.h"
#include "Soldier Create.cpp"
#endif
#define MAX_CHAR_DATA_LENGTH 500
extern UINT32 gCoolnessBySector[256];
typedef struct
{
PARSE_STAGE curElement;
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
INT32 iCurCoolness;
UINT32 uiRowNumber;
UINT32 currentDepth;
UINT32 maxReadDepth;
} SectorCoolnessParseData;
static void XMLCALL
SectorCoolnessStartElementHandle(void *userData, const XML_Char *name, const char **atts)
{
SectorCoolnessParseData * pData = (SectorCoolnessParseData *) userData;
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
{
if(strcmp(name, "COOLNESS_BY_SECTOR") == 0 && pData->curElement == ELEMENT_NONE)
{
pData->curElement = ELEMENT_LIST;
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "MAP_ROW") == 0 && pData->curElement == ELEMENT_LIST)
{
UINT32 uiAttrIndex;
pData->curElement = ELEMENT;
for(uiAttrIndex = 0;atts[uiAttrIndex] != NULL;uiAttrIndex += 2)
if(strcmp(atts[uiAttrIndex], "row") == 0)
{
pData->uiRowNumber = atol(atts[uiAttrIndex+1]);
break;
}
if(atts[uiAttrIndex] != NULL && pData->uiRowNumber < MAP_WORLD_Y)
pData->maxReadDepth++; //we are not skipping this element
}
pData->szCharData[0] = '\0';
}
pData->currentDepth++;
}
static void XMLCALL
SectorCoolnessCharacterDataHandle(void *userData, const XML_Char *str, int len)
{
SectorCoolnessParseData * pData = (SectorCoolnessParseData *) userData;
if(pData->currentDepth <= pData->maxReadDepth && strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
static void XMLCALL
SectorCoolnessEndElementHandle(void *userData, const XML_Char *name)
{
SectorCoolnessParseData * pData = (SectorCoolnessParseData *) userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
{
if(strcmp(name, "COOLNESS_BY_SECTOR") == 0 && pData->curElement == ELEMENT_LIST)
{
pData->curElement = ELEMENT_NONE;
}
else if(strcmp(name, "MAP_ROW") == 0 && pData->curElement == ELEMENT)
{
STR8 curBuffer = pData->szCharData + strspn(pData->szCharData," \t\n\r");
UINT32 curCellIndex = 0;
UINT32 curNumber;
pData->curElement = ELEMENT_LIST;
while(curBuffer[0] != '\0')
{
sscanf( curBuffer,"%d",&curNumber);
gCoolnessBySector[SECTOR(curCellIndex+1, pData->uiRowNumber) ] = curNumber;
curCellIndex++;
curBuffer += strcspn(curBuffer," \t\n\r\0");
curBuffer += strspn(curBuffer," \t\n\r");
}
}
pData->maxReadDepth--;
}
pData->currentDepth--;
}
BOOLEAN ReadInCoolnessBySector(STR fileName)
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
SectorCoolnessParseData pData;
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, SectorCoolnessStartElementHandle, SectorCoolnessEndElementHandle);
XML_SetCharacterDataHandler(parser, SectorCoolnessCharacterDataHandle);
memset(&pData,0,sizeof(pData));
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in CoolnessBySector.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
XML_ParserFree(parser);
return TRUE;
}
+129 -21
View File
@@ -1016,7 +1016,7 @@ void MapscreenMarkButtonsDirty();
extern BOOLEAN CanRedistributeMilitiaInSector( INT16 sClickedSectorX, INT16 sClickedSectorY, INT8 bClickedTownId );
extern INT32 GetNumberOfMercsInUpdateList( void );
extern INT32 SellItem( OBJECTTYPE& object, BOOLEAN useModifier = TRUE );
extern INT32 SellItem( OBJECTTYPE& object, BOOLEAN fAll, BOOLEAN useModifier = TRUE );
void DeleteAllItemsInInventoryPool();
#ifdef JA2UB
@@ -1066,18 +1066,21 @@ void BeginSellAllCallBack( UINT8 bExitValue )
fMapPanelDirty = TRUE;
gpItemPointer = &gItemPointer;
// Sell Item
iPrice += SellItem( gItemPointer );
// HEADROCK HAM 5: Added argument
iPrice += SellItem( gItemPointer, TRUE );
gpItemPointer = NULL;
fMapInventoryItem = FALSE;
if (iPrice == 0) {
iPrice = 1;
}
// HEADROCK HAM 5: Sale of $0 now re-enabled.
//if (iPrice == 0) {
// iPrice = 1;
//}
anythingSold = true;
HandleButtonStatesWhileMapInventoryActive();
}
}
}
if(anythingSold == true)
// HEADROCK HAM 5: No transaction if no money.
if(anythingSold == true && iPrice > 0)
AddTransactionToPlayersBook( SOLD_ITEMS, 0, GetWorldTotalMin(), iPrice );
}
}
@@ -4761,6 +4764,18 @@ UINT32 MapScreenHandle(void)
FilenameForBPP("INTERFACE\\mapcursr.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiMAPCURSORS));
// HEADROCK HAM 5: New pathing arrows may replace the above eventually, but for now a separate variable will do.
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
if (iResolution == 0)
FilenameForBPP("INTERFACE\\map_pathing_arrows_640.sti", VObjectDesc.ImageFile);
else if (iResolution == 1)
FilenameForBPP("INTERFACE\\map_pathing_arrows_800.sti", VObjectDesc.ImageFile);
else if (iResolution == 2)
FilenameForBPP("INTERFACE\\map_pathing_arrows_1024.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiMapPathingArrows));
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\Mine_1.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiSubLevel1));
@@ -4908,20 +4923,42 @@ UINT32 MapScreenHandle(void)
}
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\merc_between_sector_icons.sti", VObjectDesc.ImageFile);
// HEADROCK HAM 5.4: Larger icons for merc movement
if (iResolution >= _640x480 && iResolution < _800x600)
FilenameForBPP("INTERFACE\\merc_between_sector_icons_640.sti", VObjectDesc.ImageFile);
else if (iResolution < _1024x768)
FilenameForBPP("INTERFACE\\merc_between_sector_icons_800.sti", VObjectDesc.ImageFile);
else
FilenameForBPP("INTERFACE\\merc_between_sector_icons_1024.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiCHARBETWEENSECTORICONS));
// HEADROCK HAM 5.1: Enemies between sectors
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\merc_mvt_green_arrows.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiCHARBETWEENSECTORICONSCLOSE));
if (iResolution >= _640x480 && iResolution < _800x600)
FilenameForBPP("INTERFACE\\enemy_between_sector_icons_640.sti", VObjectDesc.ImageFile);
else if (iResolution < _1024x768)
FilenameForBPP("INTERFACE\\enemy_between_sector_icons_800.sti", VObjectDesc.ImageFile);
else
FilenameForBPP("INTERFACE\\enemy_between_sector_icons_1024.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiENEMYBETWEENSECTORICONS));
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\GreenArr.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiLEVELMARKER));
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\Helicop.sti", VObjectDesc.ImageFile);
// HEADROCK HAM 5: Resolution-dependent icon
if (iResolution >= _640x480 && iResolution < _800x600)
FilenameForBPP("INTERFACE\\Helicopter_Map_Icon_640.sti", VObjectDesc.ImageFile);
else if (iResolution < _1024x768)
FilenameForBPP("INTERFACE\\Helicopter_Map_Icon_800.sti", VObjectDesc.ImageFile);
else
FilenameForBPP("INTERFACE\\Helicopter_Map_Icon_1024.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiHelicopterIcon));
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
@@ -4933,7 +4970,6 @@ UINT32 MapScreenHandle(void)
CHECKF(AddVideoObject(&VObjectDesc, &guiMapBorderHeliSectors));
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\secondary_gun_hidden.sti", VObjectDesc.ImageFile);
CHECKF( AddVideoObject( &VObjectDesc, &guiSecItemHiddenVO ) );
@@ -5602,14 +5638,23 @@ UINT32 MapScreenHandle(void)
// is there a description to be displayed?
// BOB : if we're displaying the attachment popup, don't redraw the IDB
if (giActiveAttachmentPopup > -1)
{
gItemDescAttachmentPopups[giActiveAttachmentPopup]->show();
}
// HEADROCK HAM 5: So... we need a separate case for each popup that we have? That's not too bright.
else if (gfItemDescTransformPopupVisible)
{
gItemDescTransformPopup->show();
}
else
RenderItemDescriptionBox( );
{
RenderItemDescriptionBox( );
}
// render clock
// WANNE: Renders the clock in the strategy screen
RenderClock(CLOCK_X, CLOCK_Y);
#ifdef JA2TESTVERSION
if( !gfWorldLoaded )
{
@@ -8195,9 +8240,38 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
break;
}
}
}
// HEADROCK HAM 5: Alt alone shows sale prices on items in the sector inventory.
if (fShowMapInventoryPool)
{
if (fAlt)
{
if ( _KeyDown( SHIFT ) )
{
if (gubRenderedMapInventorySalePrices < 2)
{
gubRenderedMapInventorySalePrices = 2;
fMapPanelDirty = TRUE;
}
}
else
{
if (gubRenderedMapInventorySalePrices == 0 ||
gubRenderedMapInventorySalePrices == 2 )
{
gubRenderedMapInventorySalePrices = 1;
fMapPanelDirty = TRUE;
}
}
}
else
{
HandleDefaultEvent(&InputEvent);
if (gubRenderedMapInventorySalePrices)
{
gubRenderedMapInventorySalePrices = 0;
fMapPanelDirty = TRUE;
}
}
}
}
@@ -8360,6 +8434,8 @@ INT32 iCounter2 = 0;
DeleteVideoObjectFromIndex(guiSubLevel3);
DeleteVideoObjectFromIndex( guiSleepIcon );
DeleteVideoObjectFromIndex(guiMAPCURSORS);
// HEADROCK HAM 5: New pathing arrows may replace the above eventually, but for now a separate variable will do.
DeleteVideoObjectFromIndex(guiMapPathingArrows);
//DeleteVideoObjectFromIndex(guiMAPBORDER);
DeleteVideoObjectFromIndex(guiCHARLIST);
//DeleteVideoObjectFromIndex(guiCORNERADDONS);
@@ -8377,7 +8453,8 @@ INT32 iCounter2 = 0;
DeleteVideoObjectFromIndex(guiORTAICON);
DeleteVideoObjectFromIndex(guiTIXAICON);
DeleteVideoObjectFromIndex( guiCHARBETWEENSECTORICONS );
DeleteVideoObjectFromIndex( guiCHARBETWEENSECTORICONSCLOSE );
// HEADROCK HAM 5.1: Enemies between sectors arrows
DeleteVideoObjectFromIndex( guiENEMYBETWEENSECTORICONS );
DeleteVideoObjectFromIndex( guiLEVELMARKER );
DeleteVideoObjectFromIndex( guiMapBorderEtaPopUp );
@@ -8866,7 +8943,9 @@ void PollRightButtonInMapView( UINT32 *puiNewEvent )
// HEADROCK HAM 4: Toggle Militia Restrictions manually. This occurs when the Mobile Restrictions
// view is turned on. Each click advances the sector's classification by 1. If max is reached,
// loops back to start.
if ( fShowMobileRestrictionsFlag == TRUE )
// HEADROCK HAM 5: Whoops, disallow changing restrictions for sectors that are
// not accessible to militia to begin with.
if ( fShowMobileRestrictionsFlag == TRUE && gDynamicRestrictMilitia[ SECTOR( sMapX, sMapY ) ] == TRUE)
{
// Restrict more.
if ( gubManualRestrictMilitia[ SECTOR( sMapX, sMapY ) ] > MANUAL_MOBILE_NO_ENTER )
@@ -9343,9 +9422,15 @@ void MAPInvClickCallback( MOUSE_REGION *pRegion, INT32 iReason )
// If we do not have an item in hand, start moving it
if ( gpItemPointer == NULL )
{
// Return if empty
if ( pSoldier->inv[ uiHandPos ].exists() == false )
{
if ( _KeyDown(CTRL) ){
PocketPopupFull( pSoldier, uiHandPos ); // if ctrl is pressed, display all options
} else {
PocketPopupDefault( pSoldier, uiHandPos ); // display pocket-specific options
}
return;
}
@@ -9446,7 +9531,17 @@ void MAPInvClickCallback( MOUSE_REGION *pRegion, INT32 iReason )
// it's an attempt to attach; bring up the inventory panel
if ( !InItemDescriptionBox( ) )
{
MAPInternalInitItemDescriptionBox( &(pSoldier->inv[ uiHandPos ]), 0, pSoldier );
// HEADROCK HAM 5: Sector Inventory Item Desc Box no longer accessible during combat.
if( gTacticalStatus.uiFlags & INCOMBAT )
{
DoScreenIndependantMessageBox( New113HAMMessage[ 23 ], MSG_BOX_FLAG_OK, NULL );
return;
}
else
{
MAPInternalInitItemDescriptionBox( &(pSoldier->inv[ uiHandPos ]), 0, pSoldier );
}
}
return;
}
@@ -9456,8 +9551,18 @@ void MAPInvClickCallback( MOUSE_REGION *pRegion, INT32 iReason )
// TOO PAINFUL TO DO!! --CC
if ( !InItemDescriptionBox( ) )
{
bJustOpenedItemDescPanel = true; // OJW - 20090319 - fix merging on mapscreen - see top of function
MAPInternalInitItemDescriptionBox( &(pSoldier->inv[ uiHandPos ]), 0, pSoldier );
// HEADROCK HAM 5: Sector Inventory Item Desc Box no longer accessible during combat.
if( gTacticalStatus.uiFlags & INCOMBAT )
{
DoScreenIndependantMessageBox( New113HAMMessage[ 24 ], MSG_BOX_FLAG_OK, NULL );
return;
}
else
{
bJustOpenedItemDescPanel = true; // OJW - 20090319 - fix merging on mapscreen - see top of function
MAPInternalInitItemDescriptionBox( &(pSoldier->inv[ uiHandPos ]), 0, pSoldier );
}
}
/*
@@ -13046,6 +13151,8 @@ INT32 iCounter2 = 0;
{
DeleteMapBottomGraphics( );
DeleteVideoObjectFromIndex( guiMAPCURSORS );
// HEADROCK HAM 5: New pathing arrows may replace the above eventually, but for now a separate variable will do.
DeleteVideoObjectFromIndex(guiMapPathingArrows);
DeleteVideoObjectFromIndex( guiSleepIcon );
//DeleteVideoObjectFromIndex(guiMAPBORDER);
@@ -13069,7 +13176,8 @@ INT32 iCounter2 = 0;
DeleteVideoObjectFromIndex(guiORTAICON);
DeleteVideoObjectFromIndex(guiTIXAICON);
DeleteVideoObjectFromIndex( guiCHARBETWEENSECTORICONS );
DeleteVideoObjectFromIndex( guiCHARBETWEENSECTORICONSCLOSE );
// HEADROCK HAM 5.1: Enemies between sectors arrows
DeleteVideoObjectFromIndex( guiENEMYBETWEENSECTORICONS );
DeleteVideoObjectFromIndex( guiLEVELMARKER );
DeleteVideoObjectFromIndex( guiMapBorderEtaPopUp );
DeleteVideoObjectFromIndex( guiSecItemHiddenVO );