diff --git a/Laptop/merccompare.cpp b/Laptop/merccompare.cpp index a710d8f1..333c0584 100644 --- a/Laptop/merccompare.cpp +++ b/Laptop/merccompare.cpp @@ -968,6 +968,8 @@ template<> void DropDownTemplate::SetRefr fMercCompareMatrixRedraw = TRUE; } +CHAR16 sSquadString[NUMBER_OF_SQUADS][80]; + BOOLEAN EnterMercCompareMatrix( ) { InitDefaults( ); @@ -976,7 +978,7 @@ BOOLEAN EnterMercCompareMatrix( ) std::vector > dropdownvector; // create a map of all current squads with at least 2 members - std::map squadmap; + std::map squadmap; SOLDIERTYPE* pSoldier = NULL; UINT16 id = gTacticalStatus.Team[gbPlayerNum].bFirstID; @@ -991,17 +993,23 @@ BOOLEAN EnterMercCompareMatrix( ) ++squadmap[pSoldier->bAssignment]; } } - - std::map::iterator itend = squadmap.end(); - for ( std::map::iterator it = squadmap.begin(); it != itend; ++it ) + + int squadcnt = 0; + for ( std::map::iterator it = squadmap.begin(), itend = squadmap.end(); it != itend; ++it ) { if ( (*it).second > 1 ) { - if ( gGameExternalOptions.fUseXMLSquadNames ) - dropdownvector.push_back( std::make_pair( (*it).first, SquadNames[(*it).first].squadname ) ); + if ( gGameExternalOptions.fUseXMLSquadNames && ( *it ).first < gSquadNameVector.size() ) + { + swprintf( sSquadString[squadcnt], L"%s", gSquadNameVector[( *it ).first].c_str() ); + + dropdownvector.push_back( std::make_pair( ( *it ).first, sSquadString[squadcnt] ) ); + } else dropdownvector.push_back( std::make_pair( (*it).first, pSquadMenuStrings[(*it).first] ) ); } + + ++squadcnt; } if ( !dropdownvector.empty() ) diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index 71bf1e0e..ea135a96 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -1287,8 +1287,8 @@ void DisplayCharName( INT32 iId, INT32 iSlot ) //Display the mercs name mprintf( sX + iSlot*IMAGE_BOX_WIDTH, CHAR_NAME_Y, sString ); - if ( Menptr[iId].bAssignment < ON_DUTY && gGameExternalOptions.fUseXMLSquadNames ) - swprintf( sString, L"%s", SquadNames[ Menptr[iId].bAssignment ].squadname); + if ( gGameExternalOptions.fUseXMLSquadNames && Menptr[iId].bAssignment < min(ON_DUTY, gSquadNameVector.size() ) ) + swprintf( sString, L"%s", gSquadNameVector[Menptr[iId].bAssignment].c_str() ); else swprintf( sString, L"%s", pPersonnelAssignmentStrings[Menptr[iId].bAssignment]); diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index b015d256..c6204d87 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -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 ); } diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 6202d38b..9135534e 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -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] ); } diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index df7200ee..a697ab0e 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -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 ] ] ); } diff --git a/Strategic/Map Screen Interface.h b/Strategic/Map Screen Interface.h index d1386f9b..6e13fc10 100644 --- a/Strategic/Map Screen Interface.h +++ b/Strategic/Map Screen Interface.h @@ -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 gSquadNameVector; extern UINT8 FIRSTmercTOdisplay ; extern UINT8 maxNumberOfMercVisibleInStrategyList; diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index a3589d29..fe5a5302 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -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 ); diff --git a/Strategic/XML_SquadNames.cpp b/Strategic/XML_SquadNames.cpp index 6be99e0c..1225da6d 100644 --- a/Strategic/XML_SquadNames.cpp +++ b/Strategic/XML_SquadNames.cpp @@ -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 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 ); } \ No newline at end of file diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index f3ad4685..85f38aab 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -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 ] ); } diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index 80b65538..b4a0c29c 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -1549,8 +1549,8 @@ UINT32 UIHandleSelectMerc( UI_EVENT *pUIEvent ) // If different, display message if ( CurrentSquad( ) != iCurrentSquad ) { - if ( gGameExternalOptions.fUseXMLSquadNames && CurrentSquad( ) + 1 < ON_DUTY ) - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_SQUAD_ACTIVE_STRING], SquadNames[CurrentSquad( ) + 1].squadname ); + if ( gGameExternalOptions.fUseXMLSquadNames && CurrentSquad( ) + 1 < min( ON_DUTY, gSquadNameVector.size() ) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_SQUAD_ACTIVE_STRING], gSquadNameVector[CurrentSquad() + 1].c_str() ); else ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( CurrentSquad( ) + 1 ) ); } diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index f1a1691b..a8e8be6c 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -5553,21 +5553,21 @@ void RenderTEAMPanel( BOOLEAN fDirty ) if (gGameOptions.fNewTraitSystem) // SANDRO - old/new traits check { UINT8 ubTempSkillArray[30]; - INT8 bNumSkillTraits = 0; + int bNumSkillTraits = 0; // lets rearrange our skills to a temp array // we also get the number of lines (skills) to be displayed - for ( UINT8 ubCnt = 1; ubCnt < NUM_SKILLTRAITS_NT; ubCnt++ ) + for ( UINT8 ubCnt = 1; ubCnt < NUM_SKILLTRAITS_NT; ++ubCnt ) { if ( ProfileHasSkillTrait( pSoldier->ubProfile, ubCnt ) == 2 ) { ubTempSkillArray[bNumSkillTraits] = (ubCnt + NEWTRAIT_MERCSKILL_EXPERTOFFSET); - bNumSkillTraits++; + ++bNumSkillTraits; } else if ( ProfileHasSkillTrait( pSoldier->ubProfile, ubCnt ) == 1 ) { ubTempSkillArray[bNumSkillTraits] = ubCnt; - bNumSkillTraits++; + ++bNumSkillTraits; } } @@ -5578,7 +5578,7 @@ void RenderTEAMPanel( BOOLEAN fDirty ) } else { - for ( UINT8 ubCnt = 0; ubCnt < bNumSkillTraits; ubCnt++ ) + for ( int ubCnt = 0; ubCnt < bNumSkillTraits; ++ubCnt ) { swprintf( sTemp, L"%s\n", gzMercSkillTextNew[ ubTempSkillArray[ubCnt] ] ); wcscat( pStr, sTemp ); @@ -7157,8 +7157,8 @@ UINT8 FindNextMercInTeamPanel( SOLDIERTYPE *pSoldier, BOOLEAN fGoodForLessOKLife if ( pNewSoldier->bAssignment != iCurrentSquad ) { - if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < ON_DUTY ) - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_SQUAD_ACTIVE_STRING], SquadNames[pNewSoldier->bAssignment].squadname ); + if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < min(ON_DUTY, gSquadNameVector.size()) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_SQUAD_ACTIVE_STRING], gSquadNameVector[pNewSoldier->bAssignment].c_str() ); else //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( CurrentSquad( ) + 1 ) ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( pNewSoldier->bAssignment + 1 ) ); diff --git a/Tactical/Interface.cpp b/Tactical/Interface.cpp index 44e4d945..c8bdcb99 100644 --- a/Tactical/Interface.cpp +++ b/Tactical/Interface.cpp @@ -1987,8 +1987,8 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) } else if ( pSoldier->bTeam == gbPlayerNum && pSoldier->bAssignment < ON_DUTY && pSoldier->bAssignment != CurrentSquad() && !( pSoldier->flags.uiStatusFlags & SOLDIER_MULTI_SELECTED ) ) { - if ( gGameExternalOptions.fUseXMLSquadNames ) - swprintf( NameStr, SquadNames[ pSoldier->bAssignment ].squadname ); + if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < gSquadNameVector.size() ) + swprintf( NameStr, gSquadNameVector[pSoldier->bAssignment].c_str() ); else swprintf( NameStr, gzLateLocalizedString[ 34 ], ( pSoldier->bAssignment + 1 ) ); diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index b5f8ec8a..67230917 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -2242,8 +2242,8 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) { HandleLocateSelectMerc( pNewSoldier->ubID, LOCATEANDSELECT_MERC ); - if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < ON_DUTY ) - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE_STRING ], SquadNames[pNewSoldier->bAssignment].squadname ); + if ( gGameExternalOptions.fUseXMLSquadNames && pNewSoldier->bAssignment < min(ON_DUTY, gSquadNameVector.size() ) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE_STRING ], gSquadNameVector[pNewSoldier->bAssignment].c_str() ); else //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( CurrentSquad( ) + 1 ) ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( pNewSoldier->bAssignment + 1 ) ); @@ -5961,8 +5961,8 @@ void ChangeCurrentSquad( INT32 iSquad ) //set active squad SetCurrentSquad( cnt, FALSE ); - if ( gGameExternalOptions.fUseXMLSquadNames && cnt < ON_DUTY ) - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE_STRING ], SquadNames[cnt].squadname ); + if ( gGameExternalOptions.fUseXMLSquadNames && cnt < min(ON_DUTY, gSquadNameVector.size()) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE_STRING ], gSquadNameVector[cnt].c_str() ); else ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_SQUAD_ACTIVE ], ( cnt + 1 ) ); diff --git a/TileEngine/Radar Screen.cpp b/TileEngine/Radar Screen.cpp index 06e01791..25399e03 100644 --- a/TileEngine/Radar Screen.cpp +++ b/TileEngine/Radar Screen.cpp @@ -847,6 +847,7 @@ void RenderSquadList( void ) // show list of squads INT16 sCounter = 0; INT16 sX, sY; + CHAR16 sString[40]; // clear region // CHRISL: @@ -865,16 +866,24 @@ void RenderSquadList( void ) if( sCounter < NUMBER_OF_SQUADS / 2 ) { // CHRISL: - if ( gGameExternalOptions.fUseXMLSquadNames ) - FindFontCenterCoordinates( RADAR_WINDOW_TM_X , ( INT16 )( SQUAD_WINDOW_TM_Y + ( sCounter * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, ( INT16 )( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ) , SquadNames[ sCounter ].squadname , SQUAD_FONT, &sX, &sY); + if ( gGameExternalOptions.fUseXMLSquadNames && sCounter < gSquadNameVector.size() ) + { + swprintf( sString, L"%s", gSquadNameVector[sCounter].c_str() ); + + FindFontCenterCoordinates( RADAR_WINDOW_TM_X, (INT16)( SQUAD_WINDOW_TM_Y + ( sCounter * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, (INT16)( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), sString, SQUAD_FONT, &sX, &sY ); + } else - FindFontCenterCoordinates( RADAR_WINDOW_TM_X , ( INT16 )( SQUAD_WINDOW_TM_Y + ( sCounter * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, ( INT16 )( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ) ,pSquadMenuStrings[ sCounter ] , SQUAD_FONT, &sX, &sY); + FindFontCenterCoordinates( RADAR_WINDOW_TM_X , ( INT16 )( SQUAD_WINDOW_TM_Y + ( sCounter * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, ( INT16 )( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ) , pSquadMenuStrings[ sCounter ] , SQUAD_FONT, &sX, &sY); } else { // CHRISL: - if ( gGameExternalOptions.fUseXMLSquadNames ) - FindFontCenterCoordinates(RADAR_WINDOW_TM_X + RADAR_WINDOW_WIDTH / 2, ( INT16 )( SQUAD_WINDOW_TM_Y + ( ( sCounter - ( NUMBER_OF_SQUADS / 2) ) * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, ( INT16 )( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), SquadNames[ sCounter ].squadname , SQUAD_FONT, &sX, &sY); + if ( gGameExternalOptions.fUseXMLSquadNames && sCounter < gSquadNameVector.size() ) + { + swprintf( sString, L"%s", gSquadNameVector[sCounter].c_str() ); + + FindFontCenterCoordinates( RADAR_WINDOW_TM_X + RADAR_WINDOW_WIDTH / 2, (INT16)( SQUAD_WINDOW_TM_Y + ( ( sCounter - ( NUMBER_OF_SQUADS / 2 ) ) * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, (INT16)( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), sString, SQUAD_FONT, &sX, &sY ); + } else FindFontCenterCoordinates(RADAR_WINDOW_TM_X + RADAR_WINDOW_WIDTH / 2, ( INT16 )( SQUAD_WINDOW_TM_Y + ( ( sCounter - ( NUMBER_OF_SQUADS / 2) ) * ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), RADAR_WINDOW_WIDTH / 2 - 1, ( INT16 )( ( ( 2 * ( SQUAD_REGION_HEIGHT - SUBTRACTOR_FOR_SQUAD_LIST ) / NUMBER_OF_SQUADS ) ) ), pSquadMenuStrings[ sCounter ] , SQUAD_FONT, &sX, &sY); } @@ -914,8 +923,12 @@ void RenderSquadList( void ) sX = RADAR_WINDOW_TM_X + ( RADAR_WINDOW_WIDTH / 2 ) - 2; } - if ( gGameExternalOptions.fUseXMLSquadNames ) - mprintf( sX, sY , SquadNames[ sCounter ].squadname); + if ( gGameExternalOptions.fUseXMLSquadNames && sCounter < gSquadNameVector.size() ) + { + swprintf( sString, L"%s", gSquadNameVector[sCounter].c_str() ); + + mprintf( sX, sY , sString ); + } else mprintf( sX, sY , pSquadMenuStrings[ sCounter ]); } diff --git a/Utils/Text.h b/Utils/Text.h index b91269b9..4a9755b4 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -3025,7 +3025,7 @@ enum // links to other pages TEXT_MILITIAWEBSITE_SUBSITE1, - TEXT_MILITIAWEBSITE_MAIN1 = TEXT_PMC_SUBSITE1 + 3, + TEXT_MILITIAWEBSITE_MAIN1 = TEXT_MILITIAWEBSITE_SUBSITE1 + 3, TEXT_MILITIAWEBSITE_MAX, };