- provided code for:

1) changing max number of slots for towns (hardcoded value).
2) highest town index defines the number of towns on map (user defined value via xml).


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@606 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Lesh
2006-10-29 07:10:44 +00:00
parent 4ae5382557
commit c1bddf1c9c
13 changed files with 73 additions and 35 deletions
+12 -12
View File
@@ -102,14 +102,14 @@
// town loyalty table
TOWN_LOYALTY gTownLoyalty[ NUM_TOWNS ];
TOWN_LOYALTY gTownLoyalty[ MAX_TOWNS ];
// town name and locations arrays, for town theft and what not
INT32 pTownNamesList[ 40 ];
INT32 pTownLocationsList[ 40 ];
INT32 iTownDistances[ NUM_TOWNS ][ NUM_TOWNS ];
INT32 iTownDistances[ MAX_TOWNS ][ MAX_TOWNS ];
#define BASIC_COST_FOR_CIV_MURDER (10 * GAIN_PTS_PER_LOYALTY_PT)
@@ -129,7 +129,7 @@ UINT32 uiPercentLoyaltyDecreaseForCivMurder[]={
// on a scale of 1-100, this is a measure of how much each town hates the Queen's opression & is willing to stand against it
// it primarily controls the RATE of loyalty change in each town: the loyalty effect of the same events depends on it
UINT8 gubTownRebelSentiment[ NUM_TOWNS ]; // =
UINT8 gubTownRebelSentiment[ MAX_TOWNS ]; // =
//{
// 0, // not a town - blank sector index
// 90, // OMERTA, - They ARE the rebels!!!
@@ -146,7 +146,7 @@ UINT8 gubTownRebelSentiment[ NUM_TOWNS ]; // =
// 35, // CHITZENA, - Artificially high 'cause there's not enough fights near it to get the loyalty up otherwise
//};
BOOLEAN gfTownUsesLoyalty[ NUM_TOWNS ];// =
BOOLEAN gfTownUsesLoyalty[ MAX_TOWNS ];// =
//{
// FALSE, // not a town - blank sector index
// TRUE , // OMERTA
@@ -172,7 +172,7 @@ extern UINT32 guiNumWorldItems;
// preprocess sector for mercs in it
extern BOOLEAN fSectorsWithSoldiers[ MAP_WORLD_X * MAP_WORLD_X ][ 4 ];
extern CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT];
extern CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT];
@@ -1295,7 +1295,7 @@ void WriteOutDistancesBetweenTowns( void )
hFileHandle = FileOpen( "BinaryData\\TownDistances.dat", FILE_ACCESS_WRITE|FILE_OPEN_ALWAYS, FALSE );
FileWrite( hFileHandle, &( iTownDistances ), ( sizeof( INT32 ) * NUM_TOWNS * NUM_TOWNS ), NULL );
FileWrite( hFileHandle, &( iTownDistances ), ( sizeof( INT32 ) * MAX_TOWNS * MAX_TOWNS ), NULL );
// close file
FileClose( hFileHandle );
@@ -1360,7 +1360,7 @@ void ReadInDistancesBetweenTowns( void )
hFileHandle = FileOpen( "BinaryData\\TownDistances.dat", FILE_ACCESS_READ, FALSE );
FileRead( hFileHandle, &( iTownDistances ), ( sizeof( INT32 ) * NUM_TOWNS * NUM_TOWNS ), NULL );
FileRead( hFileHandle, &( iTownDistances ), ( sizeof( INT32 ) * MAX_TOWNS * MAX_TOWNS ), NULL );
// close file
FileClose( hFileHandle );
@@ -1432,8 +1432,8 @@ BOOLEAN SaveStrategicTownLoyaltyToSaveGameFile( HWFILE hFile )
UINT32 uiNumBytesWritten;
//Save the Town Loyalty
FileWrite( hFile, gTownLoyalty, sizeof( TOWN_LOYALTY ) * NUM_TOWNS, &uiNumBytesWritten );
if( uiNumBytesWritten != sizeof( TOWN_LOYALTY ) * NUM_TOWNS )
FileWrite( hFile, gTownLoyalty, sizeof( TOWN_LOYALTY ) * MAX_TOWNS, &uiNumBytesWritten );
if( uiNumBytesWritten != sizeof( TOWN_LOYALTY ) * MAX_TOWNS )
{
return( FALSE );
}
@@ -1446,8 +1446,8 @@ BOOLEAN LoadStrategicTownLoyaltyFromSavedGameFile( HWFILE hFile )
UINT32 uiNumBytesRead;
//Restore the Town Loyalty
FileRead( hFile, gTownLoyalty, sizeof( TOWN_LOYALTY ) * NUM_TOWNS, &uiNumBytesRead );
if( uiNumBytesRead != sizeof( TOWN_LOYALTY ) * NUM_TOWNS )
FileRead( hFile, gTownLoyalty, sizeof( TOWN_LOYALTY ) * MAX_TOWNS, &uiNumBytesRead );
if( uiNumBytesRead != sizeof( TOWN_LOYALTY ) * MAX_TOWNS )
{
return( FALSE );
}
@@ -1678,7 +1678,7 @@ void AffectAllTownsLoyaltyByDistanceFrom( INT32 iLoyaltyChange, INT16 sSectorX,
INT8 bTownId;
UINT32 uiIndex;
INT32 iThisDistance;
INT32 iShortestDistance[NUM_TOWNS];
INT32 iShortestDistance[MAX_TOWNS];
INT32 iPercentAdjustment;
INT32 iDistanceAdjustedLoyalty;
+2 -2
View File
@@ -81,14 +81,14 @@ typedef struct TOWN_LOYALTY
// the loyalty variables for each town
extern TOWN_LOYALTY gTownLoyalty[ NUM_TOWNS ];
extern TOWN_LOYALTY gTownLoyalty[ MAX_TOWNS ];
// town names list
extern INT32 pTownNamesList[];
// town locations list
extern INT32 pTownLocationsList[];
// whether town maintains/displays loyalty or not
extern BOOLEAN gfTownUsesLoyalty[ NUM_TOWNS ];
extern BOOLEAN gfTownUsesLoyalty[ MAX_TOWNS ];
+1 -1
View File
@@ -50,7 +50,7 @@ INT16 gsUnpaidStrategicSector[ MAX_CHARACTER_COUNT ];
extern BOOLEAN fSelectedListOfMercsForMapScreen[ MAX_CHARACTER_COUNT ];
// towns with militia training allowed
BOOLEAN gfMilitiaAllowedInTown[NUM_TOWNS] =
BOOLEAN gfMilitiaAllowedInTown[MAX_TOWNS] =
{
0, // blank sector
0, // omerta
+5 -1
View File
@@ -10,6 +10,8 @@
#define MAX_TOWN_NAME_LENGHT 32
#define MAX_TOWNS 13
// Sector name identifiers
enum Towns
{
@@ -27,9 +29,11 @@ enum Towns
MEDUNA,
CHITZENA,
NUM_TOWNS
//NUM_TOWNS
} ;
extern INT8 NUM_TOWNS;
#define FIRST_TOWN OMERTA
//#define PALACE NUM_TOWNS
+45 -11
View File
@@ -347,11 +347,14 @@ void CrippledVersionFailureToLoadMapCheck();
#include "tiledat.h"
#endif
extern UINT8 gubTownRebelSentiment[ NUM_TOWNS ];
extern BOOLEAN gfTownUsesLoyalty[ NUM_TOWNS ];
extern BOOLEAN gfMilitiaAllowedInTown[NUM_TOWNS];
INT8 NUM_TOWNS;
extern UINT8 gubTownRebelSentiment[ MAX_TOWNS ];
extern BOOLEAN gfTownUsesLoyalty[ MAX_TOWNS ];
extern BOOLEAN gfMilitiaAllowedInTown[MAX_TOWNS];
#define MAX_CHAR_DATA_LENGTH 500
#define INVALID_TOWN_INDEX -1
typedef enum
{
@@ -393,6 +396,7 @@ typedef struct
INT8 szCharData[MAX_CHAR_DATA_LENGTH+1];
cityInfo curCityInfo;
UINT32 uiRowNumber;
UINT32 uiHighestIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
@@ -439,6 +443,7 @@ citytableStartElementHandle(void *userData, const char *name, const char **atts)
memset(pTownPoints,0,sizeof(pTownPoints));
memset(gfTownUsesLoyalty,0,sizeof(gfTownUsesLoyalty));
memset(gubTownRebelSentiment,0,sizeof(gubTownRebelSentiment));
memset(gfMilitiaAllowedInTown,0,sizeof(gfMilitiaAllowedInTown));
pData->maxReadDepth++; //we are not skipping this element
}
@@ -526,6 +531,8 @@ citytableCharacterDataHandle(void *userData, const char *str, int len)
static void XMLCALL
citytableEndElementHandle(void *userData, const char *name)
{
FILE *pDebug;
citytableParseData * pData = (citytableParseData *) userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
@@ -560,24 +567,49 @@ citytableEndElementHandle(void *userData, const char *name)
else if(strcmp(name, "CITYLIST") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYLIST)
{
pData->curElement = CITYTABLE_ELEMENT_CITYINFO;
NUM_TOWNS = pData->uiHighestIndex + 1;
pDebug = fopen("towns.log", "a+t");
fprintf(pDebug, "NUM_TOWNS = %d\n", NUM_TOWNS);
fclose(pDebug);
}
else if(strcmp(name, "CITY") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY)
{
pData->curElement = CITYTABLE_ELEMENT_CITYLIST;
sBaseSectorList [pData->curCityInfo.uiIndex-1] = SECTOR(pData->curCityInfo.ubBaseX,pData->curCityInfo.ubBaseY);
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);
if ( pData->curCityInfo.uiIndex != INVALID_TOWN_INDEX )
{
sBaseSectorList [pData->curCityInfo.uiIndex-1] = SECTOR(pData->curCityInfo.ubBaseX,pData->curCityInfo.ubBaseY);
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);
}
}
else if(strcmp(name, "uiIndex") == 0 && pData->curElement == CITYTABLE_ELEMENT_INDEX)
{
pData->curElement = CITYTABLE_ELEMENT_CITY;
pData->curCityInfo.uiIndex = atol(pData->szCharData);
pDebug = fopen("towns.log", "a+t");
fprintf(pDebug, "Got Index %d\n", pData->curCityInfo.uiIndex );
fprintf(pDebug, "Highest = %d, Current = %d\n", pData->uiHighestIndex, pData->curCityInfo.uiIndex);
fclose(pDebug);
if ( !pData->curCityInfo.uiIndex || pData->curCityInfo.uiIndex >= MAX_TOWNS )
{
pData->curCityInfo.uiIndex = INVALID_TOWN_INDEX;
pDebug = fopen("towns.log", "a+t");
fprintf(pDebug, "Index Discarded\n");
fclose(pDebug);
}
else if ( pData->curCityInfo.uiIndex > pData->uiHighestIndex )
{
pData->uiHighestIndex = pData->curCityInfo.uiIndex;
pDebug = fopen("towns.log", "a+t");
fprintf(pDebug, "Set new Highest = %d\n", pData->uiHighestIndex);
fclose(pDebug);
}
}
else if(strcmp(name, "townName") == 0 && pData->curElement == CITYTABLE_ELEMENT_NAME)
{
@@ -658,7 +690,8 @@ BOOLEAN WriteInStrategicMapSectorTownNames(STR fileName)
return( FALSE );
{
UINT32 x, y, cnt;
UINT32 x, y;
INT8 cnt;
FilePrintf(hFile,"<CITY_INFO>\r\n");
@@ -752,6 +785,7 @@ BOOLEAN ReadInStrategicMapSectorTownNames(STR fileName)
memset(&pData,0,sizeof(pData));
NUM_TOWNS = 0;
XML_SetUserData(parser, &pData);
+1 -1
View File
@@ -27,7 +27,7 @@ extern STR16 pLongAttributeStrings[];
extern STR16 pContractStrings[];
extern STR16 pAssignmentStrings[];
extern STR16 pConditionStrings[];
extern CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT]; // Lesh: look mapscreen.h for definitions
extern CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT]; // Lesh: look mapscreen.h for definitions
extern STR16 pPersonnelScreenStrings[];
extern STR16 pPersonnelTitle[];
extern STR16 pUpperLeftMapScreenStrings[];
+1 -1
View File
@@ -290,7 +290,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -305,7 +305,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -296,7 +296,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -295,7 +295,7 @@ UINT16 Message[][STRING_LENGTH] =
L"kein Einzelschuss",
};
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -289,7 +289,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -290,7 +290,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Omerta",
+1 -1
View File
@@ -297,7 +297,7 @@ UINT16 Message[][STRING_LENGTH] =
// the names of the towns in the game
CHAR16 pTownNames[NUM_TOWNS][MAX_TOWN_NAME_LENGHT] =
CHAR16 pTownNames[MAX_TOWNS][MAX_TOWN_NAME_LENGHT] =
{
L"",
L"Îìåðòà",