- 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
This commit is contained in:
Lesh
2006-10-23 19:13:58 +00:00
parent a9b21bda21
commit a2e54a2cd4
2 changed files with 36 additions and 27 deletions
+18 -1
View File
@@ -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<townRebelSentiment>%d</townRebelSentiment>\r\n", gubTownRebelSentiment[cnt] );
FilePrintf(hFile,"\t\t\t<townMilitiaAllowed>%d</townMilitiaAllowed>\r\n", gfMilitiaAllowedInTown[cnt] );
FilePrintf(hFile,"\t\t\t<baseSector>\r\n");
FilePrintf(hFile,"\t\t\t\t<x>%d</x>\r\n",(sBaseSectorList[cnt-1]%16)+1);
FilePrintf(hFile,"\t\t\t\t<y>%d</y>\r\n",(sBaseSectorList[cnt-1]/16)+1);