Externalizations and fixes (by Buggler)

- Externalized heli tile index for helisites.xml
- More checks and fixes for hidden towns and sam sites to be hidden in infobox

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6611 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
silversurfer
2013-11-16 10:45:00 +00:00
parent dad39391ce
commit f986cc1292
3 changed files with 79 additions and 56 deletions
+52 -31
View File
@@ -196,6 +196,9 @@ INT16 sRefuelSectorY[ MAX_NUMBER_OF_REFUEL_SITES ];
BOOLEAN fRefuelingSiteHidden[ MAX_NUMBER_OF_REFUEL_SITES ]; BOOLEAN fRefuelingSiteHidden[ MAX_NUMBER_OF_REFUEL_SITES ];
// heli tile index no in tileset
INT32 iRefuelHeliTileIndex[ MAX_NUMBER_OF_REFUEL_SITES ];
// heli graphics grid no // heli graphics grid no
INT32 iRefuelHeliGridNo[ MAX_NUMBER_OF_REFUEL_SITES ]; INT32 iRefuelHeliGridNo[ MAX_NUMBER_OF_REFUEL_SITES ];
// skyrider standing grid no // skyrider standing grid no
@@ -216,6 +219,7 @@ typedef enum
HELISITE_ELEMENT_REFUELSECTOR_X, HELISITE_ELEMENT_REFUELSECTOR_X,
HELISITE_ELEMENT_REFUELSECTOR_Y, HELISITE_ELEMENT_REFUELSECTOR_Y,
HELISITE_ELEMENT_REFUEL_HIDDEN, HELISITE_ELEMENT_REFUEL_HIDDEN,
HELISITE_ELEMENT_REFUEL_HELI_TILE_INDEX,
HELISITE_ELEMENT_REFUEL_HELI_GRIDNO, HELISITE_ELEMENT_REFUEL_HELI_GRIDNO,
HELISITE_ELEMENT_REFUEL_SKYRIDER_GRIDNO, HELISITE_ELEMENT_REFUEL_SKYRIDER_GRIDNO,
} HELISITE_PARSE_STAGE; } HELISITE_PARSE_STAGE;
@@ -226,6 +230,7 @@ typedef struct
INT16 refuelSectorX; INT16 refuelSectorX;
INT16 refuelSectorY; INT16 refuelSectorY;
BOOLEAN refuelHidden; BOOLEAN refuelHidden;
INT32 refuelHeliTileIndex;
INT32 refuelHeliGridNo; INT32 refuelHeliGridNo;
INT32 refuelSkyriderGridNo; INT32 refuelSkyriderGridNo;
} heliInfo; } heliInfo;
@@ -261,7 +266,8 @@ helisiteStartElementHandle(void *userData, const XML_Char *name, const XML_Char
memset( sRefuelSectorX, 0, sizeof(sRefuelSectorX) ); memset( sRefuelSectorX, 0, sizeof(sRefuelSectorX) );
memset( sRefuelSectorY, 0, sizeof(sRefuelSectorY) ); memset( sRefuelSectorY, 0, sizeof(sRefuelSectorY) );
memset( fRefuelingSiteHidden, 0, sizeof(fRefuelingSiteHidden) ); memset( fRefuelingSiteHidden, 0, sizeof(fRefuelingSiteHidden) );
memset( iRefuelHeliTileIndex, 0, sizeof(iRefuelHeliTileIndex) );
memset( iRefuelHeliGridNo, 0, sizeof(iRefuelHeliGridNo) ); memset( iRefuelHeliGridNo, 0, sizeof(iRefuelHeliGridNo) );
memset( iRefuelSkyriderGridNo, 0, sizeof(iRefuelSkyriderGridNo) ); memset( iRefuelSkyriderGridNo, 0, sizeof(iRefuelSkyriderGridNo) );
@@ -300,6 +306,11 @@ helisiteStartElementHandle(void *userData, const XML_Char *name, const XML_Char
pData->curElement = HELISITE_ELEMENT_REFUEL_HIDDEN; pData->curElement = HELISITE_ELEMENT_REFUEL_HIDDEN;
pData->maxReadDepth++; //we are not skipping this element pData->maxReadDepth++; //we are not skipping this element
} }
else if(strcmp(name, "refuelHeliTileIndex") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL)
{
pData->curElement = HELISITE_ELEMENT_REFUEL_HELI_TILE_INDEX;
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "refuelHeliGridNo") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL) else if(strcmp(name, "refuelHeliGridNo") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL)
{ {
pData->curElement = HELISITE_ELEMENT_REFUEL_HELI_GRIDNO; pData->curElement = HELISITE_ELEMENT_REFUEL_HELI_GRIDNO;
@@ -354,6 +365,7 @@ helisiteEndElementHandle(void *userData, const XML_Char *name)
sRefuelSectorX [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSectorX; sRefuelSectorX [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSectorX;
sRefuelSectorY [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSectorY; sRefuelSectorY [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSectorY;
fRefuelingSiteHidden [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelHidden; fRefuelingSiteHidden [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelHidden;
iRefuelHeliTileIndex [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelHeliTileIndex;
iRefuelHeliGridNo [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelHeliGridNo; iRefuelHeliGridNo [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelHeliGridNo;
iRefuelSkyriderGridNo [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSkyriderGridNo; iRefuelSkyriderGridNo [ pData->curHeliInfo.uiIndex ] = pData->curHeliInfo.refuelSkyriderGridNo;
} }
@@ -394,6 +406,12 @@ helisiteEndElementHandle(void *userData, const XML_Char *name)
pData->curHeliInfo.refuelHidden = (BOOLEAN)atol(pData->szCharData); pData->curHeliInfo.refuelHidden = (BOOLEAN)atol(pData->szCharData);
} }
else if(strcmp(name, "refuelHeliTileIndex") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL_HELI_TILE_INDEX )
{
pData->curElement = HELISITE_ELEMENT_REFUEL;
pData->curHeliInfo.refuelHeliTileIndex = atol(pData->szCharData);
}
else if(strcmp(name, "refuelHeliGridNo") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL_HELI_GRIDNO ) else if(strcmp(name, "refuelHeliGridNo") == 0 && pData->curElement == HELISITE_ELEMENT_REFUEL_HELI_GRIDNO )
{ {
pData->curElement = HELISITE_ELEMENT_REFUEL; pData->curElement = HELISITE_ELEMENT_REFUEL;
@@ -504,6 +522,8 @@ BOOLEAN WriteInInfo(STR fileName)
FilePrintf(hFile,"\t\t\t<refuelHidden>%d</refuelHidden>\r\n", fRefuelingSiteHidden[cnt] ); FilePrintf(hFile,"\t\t\t<refuelHidden>%d</refuelHidden>\r\n", fRefuelingSiteHidden[cnt] );
FilePrintf(hFile,"\t\t\t<refuelHeliTileIndex>%d</refuelHeliTileIndex>\r\n", iRefuelHeliTileIndex[cnt] );
FilePrintf(hFile,"\t\t\t<refuelHeliGridNo>%d</refuelHeliGridNo>\r\n", iRefuelHeliGridNo[cnt] ); FilePrintf(hFile,"\t\t\t<refuelHeliGridNo>%d</refuelHeliGridNo>\r\n", iRefuelHeliGridNo[cnt] );
FilePrintf(hFile,"\t\t\t<refuelSkyriderGridNo>%d</refuelSkyriderGridNo>\r\n", iRefuelSkyriderGridNo[cnt] ); FilePrintf(hFile,"\t\t\t<refuelSkyriderGridNo>%d</refuelSkyriderGridNo>\r\n", iRefuelSkyriderGridNo[cnt] );
@@ -2263,74 +2283,75 @@ BOOLEAN CanHelicopterTakeOff( void )
return( FALSE ); return( FALSE );
} }
void AddHeliPeice( INT32 sGridNo, UINT16 sOStruct ) void AddHeliPiece( INT32 iGridNo, UINT16 sOStruct )
{ {
UINT16 usDummy; UINT16 usDummy;
// ATE: Check first if already exists.... // ATE: Check first if already exists....
if ( !TypeExistsInStructLayer( sGridNo, sOStruct, &usDummy ) ) if ( !TypeExistsInStructLayer( iGridNo, sOStruct, &usDummy ) )
{ {
// place in the world // place in the world
AddStructToTail( sGridNo, sOStruct ); AddStructToTail( iGridNo, sOStruct );
} }
} }
void AddHelicopterToMaps( BOOLEAN fAdd, UINT8 ubSite ) void AddHelicopterToMaps( BOOLEAN fAdd, UINT8 ubSite )
{ {
INT32 sGridNo = iRefuelHeliGridNo[ ubSite ]; INT32 iGridNo = iRefuelHeliGridNo[ ubSite ];
INT16 sOStruct = 0; INT32 iTileIndexNo = iRefuelHeliTileIndex[ ubSite ];
//INT16 sOStruct = 0;
INT16 sGridX, sGridY; INT16 sGridX, sGridY;
INT16 sCentreGridX, sCentreGridY; INT16 sCentreGridX, sCentreGridY;
// find out what slot it is by which site // find out what slot it is by which site
if( ubSite == 0 ) //if( ubSite == 0 )
{ //{
// drassen // // drassen
sOStruct = FIRSTOSTRUCT1; // sOStruct = FIRSTOSTRUCT1;
} //}
else //else
{ //{
// estoni // // estoni
sOStruct = FOURTHOSTRUCT1; // sOStruct = FOURTHOSTRUCT1;
} //}
// are we adding or taking away // are we adding or taking away
if( fAdd ) if( fAdd )
{ {
AddHeliPeice( sGridNo, sOStruct ); AddHeliPiece( iGridNo, ( UINT16 ) iTileIndexNo ); // AddHeliPiece( iGridNo, sOStruct );
AddHeliPeice( sGridNo, ( UINT16 )( sOStruct + 1)); AddHeliPiece( iGridNo, ( UINT16 )( iTileIndexNo + 1 ) );
AddHeliPeice( ( sGridNo - 800 ), ( UINT16 )( sOStruct + 2 )); AddHeliPiece( ( iGridNo - WORLD_ROWS * 5 ), ( UINT16 )( iTileIndexNo + 2 ) ); // ( iGridNo - 800 )
AddHeliPeice( sGridNo, ( UINT16 )(sOStruct + 3 )); AddHeliPiece( iGridNo, ( UINT16 )( iTileIndexNo + 3 ) );
AddHeliPeice( sGridNo, ( UINT16 )(sOStruct + 4)); AddHeliPiece( iGridNo, ( UINT16 )( iTileIndexNo + 4 ) );
AddHeliPeice( ( sGridNo - 800 ), ( UINT16 )(sOStruct + 5)); AddHeliPiece( ( iGridNo - WORLD_ROWS * 5 ), ( UINT16 )( iTileIndexNo + 5 ) ); // ( iGridNo - 800 )
InvalidateWorldRedundency(); InvalidateWorldRedundency();
SetRenderFlags( RENDER_FLAG_FULL ); SetRenderFlags( RENDER_FLAG_FULL );
// ATE: If any mercs here, bump them off! // ATE: If any mercs here, bump them off!
ConvertGridNoToXY( sGridNo, &sCentreGridX, &sCentreGridY ); ConvertGridNoToXY( iGridNo, &sCentreGridX, &sCentreGridY );
for( sGridY = sCentreGridY - 5; sGridY < sCentreGridY + 5; sGridY++ ) for( sGridY = sCentreGridY - 5; sGridY < sCentreGridY + 5; sGridY++ )
{ {
for( sGridX = sCentreGridX - 5; sGridX < sCentreGridX + 5; sGridX++ ) for( sGridX = sCentreGridX - 5; sGridX < sCentreGridX + 5; sGridX++ )
{ {
sGridNo = MAPROWCOLTOPOS( sGridY, sGridX ); iGridNo = MAPROWCOLTOPOS( sGridY, sGridX );
BumpAnyExistingMerc( sGridNo ); BumpAnyExistingMerc( iGridNo );
} }
} }
} }
else else
{ {
// remove from the world // remove from the world
RemoveStruct( iRefuelHeliGridNo[ ubSite ], ( UINT16 )(sOStruct )); RemoveStruct( iGridNo, ( UINT16 )iTileIndexNo );
RemoveStruct( iRefuelHeliGridNo[ ubSite ], ( UINT16 )(sOStruct + 1 )); RemoveStruct( iGridNo, ( UINT16 )( iTileIndexNo + 1 ) );
RemoveStruct( iRefuelHeliGridNo[ ubSite ] - 800, ( UINT16 )(sOStruct + 2)); RemoveStruct( ( iGridNo - WORLD_ROWS * 5 ), ( UINT16 )( iTileIndexNo + 2 ) ); // ( iGridNo - 800 )
RemoveStruct( iRefuelHeliGridNo[ ubSite ], ( UINT16 )(sOStruct + 3)); RemoveStruct( iGridNo, ( UINT16 )( iTileIndexNo + 3 ) );
RemoveStruct( iRefuelHeliGridNo[ ubSite ], ( UINT16 )(sOStruct + 4)); RemoveStruct( iGridNo, ( UINT16 )( iTileIndexNo + 4 ) );
RemoveStruct( iRefuelHeliGridNo[ ubSite ] - 800, ( UINT16 )(sOStruct +5)); RemoveStruct( ( iGridNo - WORLD_ROWS * 5 ), ( UINT16 )( iTileIndexNo + 5 ) ); // ( iGridNo - 800 )
InvalidateWorldRedundency(); InvalidateWorldRedundency();
SetRenderFlags( RENDER_FLAG_FULL ); SetRenderFlags( RENDER_FLAG_FULL );
+1
View File
@@ -128,6 +128,7 @@ extern BOOLEAN fShowCambriaHospitalHighLight;
extern INT32 iTotalAccumulatedCostByPlayer; extern INT32 iTotalAccumulatedCostByPlayer;
extern UINT32 guiTimeOfLastSkyriderMonologue; extern UINT32 guiTimeOfLastSkyriderMonologue;
extern BOOLEAN fSkyRiderSetUp; extern BOOLEAN fSkyRiderSetUp;
extern UINT8 NUMBER_OF_REFUEL_SITES;
extern BOOLEAN fRefuelingSiteAvailable[ MAX_NUMBER_OF_REFUEL_SITES ]; extern BOOLEAN fRefuelingSiteAvailable[ MAX_NUMBER_OF_REFUEL_SITES ];
extern BOOLEAN fRefuelingSiteHidden[ MAX_NUMBER_OF_REFUEL_SITES ]; extern BOOLEAN fRefuelingSiteHidden[ MAX_NUMBER_OF_REFUEL_SITES ];
@@ -701,52 +701,53 @@ void AddCommonInfoToBox(void)
{ {
CHAR16 wString[ 64 ]; CHAR16 wString[ 64 ];
UINT32 hStringHandle = 0; UINT32 hStringHandle = 0;
BOOLEAN fHiddenSite = FALSE; BOOLEAN fKnownSite = FALSE;
UINT8 ubMilitiaTotal = 0; UINT8 ubMilitiaTotal = 0;
UINT8 ubNumEnemies; UINT8 ubNumEnemies;
UINT16 usSectorValue = 0; UINT16 usSectorValue = 0;
// get the sector value // get the sector value
usSectorValue = SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); usSectorValue = SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY );
// check for hidden town BOOLEAN fVisited = (SectorInfo[ usSectorValue ].uiFlags & SF_ALREADY_VISITED);
if( !gfHiddenTown[ GetTownIdForSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ] ) UINT8 ubTownId = GetTownIdForSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY );
fHiddenSite = TRUE;
// visited sector check
if ( fVisited )
fKnownSite = TRUE;
// known town check, exclude TownId 0 for non-town sectors
else if( gfHiddenTown[ ubTownId ] && ubTownId != 0 )
fKnownSite = TRUE;
// check for unknown SAM Site // known SAM Site check
else else
{ {
for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++) for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++)
{ {
// SAM Site 4 in Meduna is within town limits, so it's always known if ( pSamList[x] == usSectorValue )
if ( usSectorValue == SEC_N4 && x == 3)
fHiddenSite = FALSE;
else if ( pSamList[x] == usSectorValue )
{ {
if ( !fSamSiteFound[ x ] ) if ( fSamSiteFound[ x ] )
{ fKnownSite = TRUE;
fHiddenSite = TRUE;
}
} }
} }
} }
/*// ABOVE GROUND HARDCODED /*// ABOVE GROUND HARDCODED
if( ubSectorID == SEC_N4 && fSamSiteFound[ SAM_SITE_FOUR ] ) fKnownSite = TRUE;
switch( SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ) switch( usSectorValue )
{ {
case SEC_D2: //Chitzena SAM case SEC_D2: //Chitzena SAM
if( !fSamSiteFound[ SAM_SITE_ONE ] ) if( !fSamSiteFound[ SAM_SITE_ONE ] )
fHiddenSite = TRUE; fKnownSite = FALSE;
break; break;
case SEC_D15: //Drassen SAM case SEC_D15: //Drassen SAM
if( !fSamSiteFound[ SAM_SITE_TWO ] ) if( !fSamSiteFound[ SAM_SITE_TWO ] )
fHiddenSite = TRUE; fKnownSite = FALSE;
break; break;
case SEC_I8: //Cambria SAM case SEC_I8: //Cambria SAM
if( !fSamSiteFound[ SAM_SITE_THREE ] ) if( !fSamSiteFound[ SAM_SITE_THREE ] )
fHiddenSite = TRUE; fKnownSite = FALSE;
break; break;
// SAM Site 4 in Meduna is within town limits, so it's always controllable // SAM Site 4 in Meduna is within town limits, so it's always controllable
default: default:
@@ -756,7 +757,7 @@ void AddCommonInfoToBox(void)
// in sector where militia can be trained, // in sector where militia can be trained,
// control of the sector matters, display who controls this sector. Map brightness no longer gives this! // control of the sector matters, display who controls this sector. Map brightness no longer gives this!
if ( MilitiaTrainingAllowedInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, 0 ) && !fHiddenSite ) if ( MilitiaTrainingAllowedInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, 0 ) && fKnownSite )
{ {
// controlled: // controlled:
swprintf( wString, L"%s:", pwMiscSectorStrings[ 4 ] ); swprintf( wString, L"%s:", pwMiscSectorStrings[ 4 ] );
@@ -799,7 +800,7 @@ void AddCommonInfoToBox(void)
// Sector contains Militia training facility? // Sector contains Militia training facility?
for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++) for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++)
{ {
if (gFacilityLocations[SECTOR(bCurrentTownMineSectorX, bCurrentTownMineSectorY)][ubCounter].fFacilityHere) if (gFacilityLocations[usSectorValue][ubCounter].fFacilityHere)
{ {
if (gFacilityTypes[ubCounter].ubMilitiaTrainersAllowed) if (gFacilityTypes[ubCounter].ubMilitiaTrainersAllowed)
{ {
@@ -810,7 +811,7 @@ void AddCommonInfoToBox(void)
if (fMilitiaTrainingAllowed) if (fMilitiaTrainingAllowed)
{ {
// Show percent completed // Show percent completed
swprintf( wString, L"%d%%%%", SectorInfo[ SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ].ubMilitiaTrainingPercentDone ); swprintf( wString, L"%d%%%%", SectorInfo[ usSectorValue ].ubMilitiaTrainingPercentDone );
AddSecondColumnMonoString( &hStringHandle, wString ); AddSecondColumnMonoString( &hStringHandle, wString );
} }
else else
@@ -826,7 +827,7 @@ void AddCommonInfoToBox(void)
// Sector contains Mobile training facility? // Sector contains Mobile training facility?
for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++) for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++)
{ {
if (gFacilityLocations[SECTOR(bCurrentTownMineSectorX, bCurrentTownMineSectorY)][ubCounter].fFacilityHere) if (gFacilityLocations[usSectorValue][ubCounter].fFacilityHere)
{ {
if (gFacilityTypes[ubCounter].ubMobileMilitiaTrainersAllowed) if (gFacilityTypes[ubCounter].ubMobileMilitiaTrainersAllowed)
{ {
@@ -838,7 +839,7 @@ void AddCommonInfoToBox(void)
if (fMobileTrainingAllowed) if (fMobileTrainingAllowed)
{ {
// Show percentage completed // Show percentage completed
swprintf( wString, L"%d%%%%", SectorInfo[ SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ].ubMobileMilitiaTrainingPercentDone ); swprintf( wString, L"%d%%%%", SectorInfo[ usSectorValue ].ubMobileMilitiaTrainingPercentDone );
AddSecondColumnMonoString( &hStringHandle, wString ); AddSecondColumnMonoString( &hStringHandle, wString );
} }
else else