mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
Fix: if no squad name is provided in xml, fall back on hardcoded name
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8867 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+10
-10
@@ -12957,8 +12957,8 @@ void SquadMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
|
||||
switch( bCanJoinSquad )
|
||||
{
|
||||
case CHARACTER_CANT_JOIN_SQUAD_SQUAD_MOVING:
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, pMapErrorString[ 36 ], pSoldier->GetName(), SquadNames[ iValue ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && iValue < gSquadNameVector.size() )
|
||||
swprintf( sString, pMapErrorString[ 36 ], pSoldier->GetName(), gSquadNameVector[iValue].c_str() );
|
||||
else
|
||||
swprintf( sString, pMapErrorString[ 36 ], pSoldier->GetName(), pLongAssignmentStrings[ iValue ] );
|
||||
break;
|
||||
@@ -12966,14 +12966,14 @@ void SquadMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
|
||||
swprintf( sString, pMapErrorString[ 37 ], pSoldier->GetName() );
|
||||
break;
|
||||
case CHARACTER_CANT_JOIN_SQUAD_TOO_FAR:
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, pMapErrorString[ 20 ], pSoldier->GetName(), SquadNames[ iValue ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && iValue < gSquadNameVector.size() )
|
||||
swprintf( sString, pMapErrorString[ 20 ], pSoldier->GetName(), gSquadNameVector[iValue].c_str() );
|
||||
else
|
||||
swprintf( sString, pMapErrorString[ 20 ], pSoldier->GetName(), pLongAssignmentStrings[ iValue ] );
|
||||
break;
|
||||
case CHARACTER_CANT_JOIN_SQUAD_FULL:
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, pMapErrorString[ 19 ], pSoldier->GetName(), SquadNames[ iValue ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && iValue < gSquadNameVector.size() )
|
||||
swprintf( sString, pMapErrorString[ 19 ], pSoldier->GetName(), gSquadNameVector[iValue].c_str() );
|
||||
else
|
||||
swprintf( sString, pMapErrorString[ 19 ], pSoldier->GetName(), pLongAssignmentStrings[ iValue ] );
|
||||
break;
|
||||
@@ -14382,8 +14382,8 @@ void CreateSquadBox( void )
|
||||
{
|
||||
// get info about current squad and put in string
|
||||
//SQUAD10 FIX
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, L"%s ( %d/%d )", SquadNames[ uiCounter ].squadname, NumberOfPeopleInSquad( ( INT8 )uiCounter ), gGameOptions.ubSquadSize );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && uiCounter < gSquadNameVector.size() )
|
||||
swprintf( sString, L"%s ( %d/%d )", gSquadNameVector[uiCounter].c_str(), NumberOfPeopleInSquad( ( INT8 )uiCounter ), gGameOptions.ubSquadSize );
|
||||
else
|
||||
swprintf( sString, L"%s ( %d/%d )", pSquadMenuStrings[uiCounter], NumberOfPeopleInSquad( ( INT8 )uiCounter ), gGameOptions.ubSquadSize );
|
||||
|
||||
@@ -15303,8 +15303,8 @@ void CreateAssignmentsBox( void )
|
||||
if( ( uiCounter == ASSIGN_MENU_ON_DUTY ) && ( pSoldier != NULL ) && ( pSoldier->bAssignment < ON_DUTY ) )
|
||||
{
|
||||
// show his squad # in brackets
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, L"%s(%s)", pAssignMenuStrings[uiCounter], SquadNames[ pSoldier->bAssignment ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < gSquadNameVector.size() )
|
||||
swprintf( sString, L"%s(%s)", pAssignMenuStrings[uiCounter], gSquadNameVector[uiCounter].c_str() );
|
||||
else
|
||||
swprintf( sString, L"%s(%d)", pAssignMenuStrings[uiCounter], pSoldier->bAssignment + 1 );
|
||||
}
|
||||
|
||||
@@ -1720,8 +1720,8 @@ void PlotPathForCharacter( SOLDIERTYPE *pCharacter, INT16 sX, INT16 sY, BOOLEAN
|
||||
}
|
||||
else // squad
|
||||
{
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
MapScreenMessage( FONT_MCOLOR_DKRED, MSG_INTERFACE, L"%s %s", SquadNames[ pCharacter->bAssignment ].squadname, gsUndergroundString[0] );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pCharacter->bAssignment < gSquadNameVector.size() )
|
||||
MapScreenMessage( FONT_MCOLOR_DKRED, MSG_INTERFACE, L"%s %s", gSquadNameVector[pCharacter->bAssignment].c_str(), gsUndergroundString[0] );
|
||||
else
|
||||
MapScreenMessage( FONT_MCOLOR_DKRED, MSG_INTERFACE, L"%s %s", pLongAssignmentStrings[ pCharacter->bAssignment ], gsUndergroundString[0] );
|
||||
}
|
||||
|
||||
@@ -375,8 +375,6 @@ SGPPoint OrigSnitchSectorPosition={320,150};
|
||||
|
||||
SGPPoint OrigPrisonerPosition = {320, 150};
|
||||
|
||||
SQUAD_NAMES SquadNames[20];
|
||||
|
||||
//extern BOOLEAN fMapExitDueToMessageBox;
|
||||
|
||||
// at least one merc was hired at some time
|
||||
@@ -3845,15 +3843,15 @@ void AddStringsToMoveBox( void )
|
||||
// add this squad, now add all the grunts in it
|
||||
if( fSquadIsMoving[ iCount ] )
|
||||
{
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, L"*%s*", SquadNames[ iSquadMovingList[ iCount ] ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && iSquadMovingList[iCount] < gSquadNameVector.size() )
|
||||
swprintf( sString, L"*%s*", gSquadNameVector[iSquadMovingList[iCount]].c_str() );
|
||||
else
|
||||
swprintf( sString, L"*%s*", pSquadMenuStrings[iSquadMovingList[ iCount ] ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
swprintf( sString, L"%s", SquadNames[ iSquadMovingList[ iCount ] ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && iSquadMovingList[iCount] < gSquadNameVector.size() )
|
||||
swprintf( sString, L"%s", gSquadNameVector[iSquadMovingList[iCount]].c_str() );
|
||||
else
|
||||
swprintf( sString, L"%s", pSquadMenuStrings[iSquadMovingList[ iCount ] ] );
|
||||
}
|
||||
|
||||
@@ -22,13 +22,7 @@ typedef struct FASTHELPREGION {
|
||||
} FASTHELPREGION;
|
||||
|
||||
// Flugente: externalised squad names
|
||||
typedef struct
|
||||
{
|
||||
UINT32 uiIndex;
|
||||
CHAR16 squadname[10];
|
||||
} SQUAD_NAMES;
|
||||
|
||||
extern SQUAD_NAMES SquadNames[20];
|
||||
extern std::vector<std::wstring> gSquadNameVector;
|
||||
|
||||
extern UINT8 FIRSTmercTOdisplay ;
|
||||
extern UINT8 maxNumberOfMercVisibleInStrategyList;
|
||||
|
||||
@@ -2102,8 +2102,8 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe
|
||||
{
|
||||
// squad
|
||||
// HEADROCK HAM 3.6: Messages are no longer yellow by default.
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames )
|
||||
ScreenMsg( FONT_MCOLOR_LTGREEN, MSG_INTERFACE, pMessageStrings[ MSG_ARRIVE ], SquadNames[ pGroup->pPlayerList->pSoldier->bAssignment ].squadname, pMapVertIndex[ pGroup->pPlayerList->pSoldier->sSectorY ], pMapHortIndex[ pGroup->pPlayerList->pSoldier->sSectorX ]);
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pGroup->pPlayerList->pSoldier->bAssignment < gSquadNameVector.size() )
|
||||
ScreenMsg( FONT_MCOLOR_LTGREEN, MSG_INTERFACE, pMessageStrings[ MSG_ARRIVE ], gSquadNameVector[pGroup->pPlayerList->pSoldier->bAssignment].c_str(), pMapVertIndex[ pGroup->pPlayerList->pSoldier->sSectorY ], pMapHortIndex[ pGroup->pPlayerList->pSoldier->sSectorX ]);
|
||||
else
|
||||
ScreenMsg( FONT_MCOLOR_LTGREEN, MSG_INTERFACE, pMessageStrings[ MSG_ARRIVE ], pAssignmentStrings[ pGroup->pPlayerList->pSoldier->bAssignment ], pMapVertIndex[ pGroup->pPlayerList->pSoldier->sSectorY ], pMapHortIndex[ pGroup->pPlayerList->pSoldier->sSectorX ]);
|
||||
}
|
||||
@@ -5725,8 +5725,8 @@ BOOLEAN HandlePlayerGroupEnteringSectorToCheckForNPCsOfNote( GROUP *pGroup )
|
||||
// build string for squad
|
||||
GetSectorIDString( sSectorX, sSectorY, bSectorZ, wSectorName, FALSE );
|
||||
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pGroup->pPlayerList->pSoldier->bAssignment < ON_DUTY )
|
||||
swprintf( sString, pLandMarkInSectorString[ 1 ], SquadNames[ pGroup->pPlayerList->pSoldier->bAssignment ].squadname, wSectorName );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pGroup->pPlayerList->pSoldier->bAssignment < min(ON_DUTY, gSquadNameVector .size()) )
|
||||
swprintf( sString, pLandMarkInSectorString[ 1 ], gSquadNameVector[pGroup->pPlayerList->pSoldier->bAssignment].c_str(), wSectorName );
|
||||
else
|
||||
swprintf( sString, pLandMarkInSectorString[ 0 ], pGroup->pPlayerList->pSoldier->bAssignment + 1, wSectorName );
|
||||
|
||||
|
||||
@@ -9,21 +9,19 @@
|
||||
#include "XML.h"
|
||||
#endif
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
PARSE_STAGE curElement;
|
||||
|
||||
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
|
||||
SQUAD_NAMES curSquadNames;
|
||||
SQUAD_NAMES * curArray;
|
||||
UINT32 maxArraySize;
|
||||
|
||||
UINT32 currentDepth;
|
||||
UINT32 maxReadDepth;
|
||||
}
|
||||
typedef squadnamesParseData;
|
||||
|
||||
std::vector<std::wstring> gSquadNameVector;
|
||||
|
||||
static void XMLCALL
|
||||
squadnamesStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
@@ -34,17 +32,13 @@ squadnamesStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
|
||||
if(strcmp(name, "SQUAD_NAMES") == 0 && pData->curElement == ELEMENT_NONE)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
memset(pData->curArray,0,sizeof(SQUAD_NAMES)*pData->maxArraySize);
|
||||
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if(strcmp(name, "SQUADNAME") == 0 && pData->curElement == ELEMENT_LIST)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
|
||||
memset(&pData->curSquadNames,0,sizeof(SQUAD_NAMES));
|
||||
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if(pData->curElement == ELEMENT &&
|
||||
@@ -58,9 +52,8 @@ squadnamesStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
|
||||
|
||||
pData->szCharData[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
pData->currentDepth++;
|
||||
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
@@ -75,7 +68,6 @@ squadnamesCharacterDataHandle(void *userData, const XML_Char *str, int len)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void XMLCALL
|
||||
squadnamesEndElementHandle(void *userData, const XML_Char *name)
|
||||
{
|
||||
@@ -90,25 +82,22 @@ squadnamesEndElementHandle(void *userData, const XML_Char *name)
|
||||
else if(strcmp(name, "SQUADNAME") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
if(pData->curSquadNames.uiIndex < pData->maxArraySize)
|
||||
{
|
||||
pData->curArray[pData->curSquadNames.uiIndex] = pData->curSquadNames; //write the squadnames into the table
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "uiIndex") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->curSquadNames.uiIndex = (UINT32) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "Squad") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
|
||||
MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curSquadNames.squadname, sizeof(pData->curSquadNames.squadname)/sizeof(pData->curSquadNames.squadname[0]) );
|
||||
pData->curSquadNames.squadname[sizeof(pData->curSquadNames.squadname)/sizeof(pData->curSquadNames.squadname[0]) - 1] = '\0';
|
||||
CHAR16 bla[30];
|
||||
|
||||
MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, bla, sizeof( bla ) / sizeof( bla[0] ) );
|
||||
bla[sizeof( bla ) / sizeof( bla[0] ) - 1] = '\0';
|
||||
|
||||
gSquadNameVector.push_back( bla );
|
||||
}
|
||||
|
||||
|
||||
pData->maxReadDepth--;
|
||||
}
|
||||
@@ -116,9 +105,6 @@ squadnamesEndElementHandle(void *userData, const XML_Char *name)
|
||||
pData->currentDepth--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOLEAN ReadInSquadNamesStats(STR fileName)
|
||||
{
|
||||
HWFILE hFile;
|
||||
@@ -149,19 +135,14 @@ BOOLEAN ReadInSquadNamesStats(STR fileName)
|
||||
lpcBuffer[uiFSize] = 0; //add a null terminator
|
||||
|
||||
FileClose( hFile );
|
||||
|
||||
|
||||
|
||||
XML_SetElementHandler(parser, squadnamesStartElementHandle, squadnamesEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, squadnamesCharacterDataHandle);
|
||||
|
||||
|
||||
|
||||
memset(&pData,0,sizeof(pData));
|
||||
pData.curArray = SquadNames;
|
||||
pData.maxArraySize = 20;
|
||||
|
||||
XML_SetUserData(parser, &pData);
|
||||
|
||||
|
||||
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
@@ -174,16 +155,13 @@ BOOLEAN ReadInSquadNamesStats(STR fileName)
|
||||
}
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
|
||||
|
||||
|
||||
XML_ParserFree(parser);
|
||||
|
||||
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
BOOLEAN WriteSquadNamesStats()
|
||||
{
|
||||
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
@@ -2849,8 +2849,8 @@ void DrawCharacterInfo(INT16 sCharNumber)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < ON_DUTY )
|
||||
swprintf( sString, L"%s", SquadNames[ pSoldier->bAssignment ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < min(ON_DUTY, gSquadNameVector.size()) )
|
||||
swprintf( sString, L"%s", gSquadNameVector[pSoldier->bAssignment].c_str() );
|
||||
else
|
||||
wcscpy( sString, pAssignmentStrings[ pSoldier->bAssignment ] );
|
||||
}
|
||||
@@ -15871,8 +15871,8 @@ void GetMapscreenMercAssignmentString( SOLDIERTYPE *pSoldier, CHAR16 sString[] )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < ON_DUTY )
|
||||
swprintf( sString, L" %s", SquadNames[ pSoldier->bAssignment ].squadname );
|
||||
if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < min(ON_DUTY, gSquadNameVector.size() ) )
|
||||
swprintf( sString, L" %s", gSquadNameVector[pSoldier->bAssignment].c_str() );
|
||||
else
|
||||
wcscpy(sString, pAssignmentStrings[ pSoldier->bAssignment ] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user