From a2e54a2cd4fee5ad57a8d8e90d9bfff8295a2d33 Mon Sep 17 00:00:00 2001 From: Lesh Date: Mon, 23 Oct 2006 19:13:58 +0000 Subject: [PATCH] - updated cities.xml handling code so now it is possible to control can player train militia in town or not. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@604 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Town Militia.cpp | 44 ++++++++++++++++---------------------- Strategic/strategicmap.cpp | 19 +++++++++++++++- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Strategic/Town Militia.cpp b/Strategic/Town Militia.cpp index 37a1e47f..0e90941e 100644 --- a/Strategic/Town Militia.cpp +++ b/Strategic/Town Militia.cpp @@ -49,7 +49,23 @@ INT16 gsUnpaidStrategicSector[ MAX_CHARACTER_COUNT ]; // the selected list of mercs extern BOOLEAN fSelectedListOfMercsForMapScreen[ MAX_CHARACTER_COUNT ]; - +// towns with militia training allowed +BOOLEAN gfMilitiaAllowedInTown[NUM_TOWNS] = +{ + 0, // blank sector + 0, // omerta + 1, // drassen + 1, // alma + 1, // grumm + 0, // tixa + 1, // cambria + 0, // san mona + 0, // estoni + 0, // orta + 1, // balime + 1, // meduna + 1, // chitzena +}; // private prototypes void PayMilitiaTrainingYesNoBoxCallback( UINT8 bExitValue ); @@ -1437,31 +1453,7 @@ BOOLEAN MilitiaTrainingAllowedInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSe BOOLEAN MilitiaTrainingAllowedInTown( INT8 bTownId ) { - switch ( bTownId ) - { - case DRASSEN: - case ALMA: - case GRUMM: - case CAMBRIA: - case BALIME: - case MEDUNA: - case CHITZENA: - return(TRUE); - - case OMERTA: - case ESTONI: - case SAN_MONA: - case TIXA: - case ORTA: - // can't keep militia in these towns - return(FALSE); - - case BLANK_SECTOR: - default: - // not a town sector! - return(FALSE); - - } + return( gfMilitiaAllowedInTown[bTownId] ); } void BuildMilitiaPromotionsString( UINT16 *str ) diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index ce45a8d5..d5fd9fc6 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -349,6 +349,7 @@ void CrippledVersionFailureToLoadMapCheck(); extern UINT8 gubTownRebelSentiment[ NUM_TOWNS ]; extern BOOLEAN gfTownUsesLoyalty[ NUM_TOWNS ]; +extern BOOLEAN gfMilitiaAllowedInTown[NUM_TOWNS]; #define MAX_CHAR_DATA_LENGTH 500 @@ -369,7 +370,8 @@ typedef enum CITYTABLE_ELEMENT_TOWNPOINT_X, CITYTABLE_ELEMENT_TOWNPOINT_Y, CITYTABLE_ELEMENT_USES_LOYALTY, - CITYTABLE_ELEMENT_REBEL_SENTIMENT + CITYTABLE_ELEMENT_REBEL_SENTIMENT, + CITYTABLE_ELEMENT_MILITIA } CITYTABLE_PARSE_STAGE; typedef struct @@ -380,6 +382,7 @@ typedef struct POINT townPoint; BOOLEAN townUsesLoyalty; UINT8 townRebelSentiment; + BOOLEAN townMilitiaAllowed; CHAR8 cityName[MAX_TOWN_NAME_LENGHT]; } cityInfo; @@ -467,6 +470,11 @@ citytableStartElementHandle(void *userData, const char *name, const char **atts) pData->curElement = CITYTABLE_ELEMENT_REBEL_SENTIMENT; pData->maxReadDepth++; //we are not skipping this element } + else if(strcmp(name, "townMilitiaAllowed") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + { + pData->curElement = CITYTABLE_ELEMENT_MILITIA; + pData->maxReadDepth++; //we are not skipping this element + } else if(strcmp(name, "baseSector") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR; @@ -561,6 +569,7 @@ citytableEndElementHandle(void *userData, const char *name) pTownPoints [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townPoint; gfTownUsesLoyalty [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townUsesLoyalty; gubTownRebelSentiment [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townRebelSentiment; + gfMilitiaAllowedInTown[pData->curCityInfo.uiIndex ] = pData->curCityInfo.townMilitiaAllowed; mbstowcs( pTownNames[pData->curCityInfo.uiIndex], pData->curCityInfo.cityName, MAX_TOWN_NAME_LENGHT); } @@ -595,6 +604,12 @@ citytableEndElementHandle(void *userData, const char *name) else if ( !pData->curCityInfo.townRebelSentiment ) pData->curCityInfo.townRebelSentiment = 1; } + else if(strcmp(name, "townMilitiaAllowed") == 0 && pData->curElement == CITYTABLE_ELEMENT_MILITIA ) + { + pData->curElement = CITYTABLE_ELEMENT_CITY; + + pData->curCityInfo.townMilitiaAllowed = (BOOLEAN)atol(pData->szCharData); + } else if(strcmp(name, "baseSector") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR) { pData->curElement = CITYTABLE_ELEMENT_CITY; @@ -660,6 +675,8 @@ BOOLEAN WriteInStrategicMapSectorTownNames(STR fileName) FilePrintf(hFile,"\t\t\t%d\r\n", gubTownRebelSentiment[cnt] ); + FilePrintf(hFile,"\t\t\t%d\r\n", gfMilitiaAllowedInTown[cnt] ); + FilePrintf(hFile,"\t\t\t\r\n"); FilePrintf(hFile,"\t\t\t\t%d\r\n",(sBaseSectorList[cnt-1]%16)+1); FilePrintf(hFile,"\t\t\t\t%d\r\n",(sBaseSectorList[cnt-1]/16)+1);