From f6ae18533f8fc667462960a590de8dd28499c973 Mon Sep 17 00:00:00 2001 From: Flugente Date: Thu, 15 Nov 2012 00:03:39 +0000 Subject: [PATCH] - Optimized a few code bits - Enemy ranks has now size 20 instead of 500 - Fix: losing your disguise makes you lose your disguise again git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5687 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface.cpp | 446 ++++++++++++++++------------------- Tactical/Interface.h | 2 +- Tactical/Overhead.cpp | 18 +- Tactical/Soldier Control.cpp | 13 +- Tactical/TeamTurns.cpp | 2 +- Tactical/XML_EnemyRank.cpp | 2 +- 6 files changed, 222 insertions(+), 261 deletions(-) diff --git a/Tactical/Interface.cpp b/Tactical/Interface.cpp index e30d0ea11..134f8fba9 100644 --- a/Tactical/Interface.cpp +++ b/Tactical/Interface.cpp @@ -99,7 +99,7 @@ int INV_INTERFACE_START_Y;// = ( SCREEN_HEIGHT - INV_INTERFACE_HEIGHT ); HIDDEN_NAMES_VALUES zHiddenNames[500]; //legion2 Jazz ENEMY_NAMES_VALUES zEnemyName[500]; -ENEMY_RANK_VALUES zEnemyRank[500]; +ENEMY_RANK_VALUES zEnemyRank[20]; // Flugente: set this to 20, which should be way enough, as there are onyl 10 exp levels CIV_NAMES_VALUES zCivGroupName[NUM_CIV_GROUPS]; BOOLEAN gfInMovementMenu = FALSE; @@ -1653,7 +1653,6 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) INT32 iBack; TILE_ELEMENT TileElem; CHAR16 *pStr; - //CHAR16 *pStr2; CHAR16 NameStr[ 50 ]; UINT16 usGraphicToUse = THIRDPOINTERS1; BOOLEAN fRaiseName = FALSE; @@ -1709,8 +1708,8 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) //} if ( pSoldier->flags.fFlashLocator == pSoldier->ubNumLocateCycles ) { - pSoldier->flags.fFlashLocator = FALSE; - pSoldier->flags.fShowLocator = FALSE; + pSoldier->flags.fFlashLocator = FALSE; + pSoldier->flags.fShowLocator = FALSE; } //if ( pSoldier->flags.fShowLocator ) @@ -1741,15 +1740,12 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) } else { - BltVideoObjectFromIndex( FRAME_BUFFER, guiRADIO, pSoldier->sLocatorFrame, sXPos, sYPos, VO_BLT_SRCTRANSPARENCY, NULL ); - //BltVideoObjectFromIndex( FRAME_BUFFER, guiRADIO, 0, sXPos, sYPos, VO_BLT_SRCTRANSPARENCY, NULL ); + //BltVideoObjectFromIndex( FRAME_BUFFER, guiRADIO, 0, sXPos, sYPos, VO_BLT_SRCTRANSPARENCY, NULL ); } - } } - //return; } @@ -1786,7 +1782,6 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) } } - // If he is in the middle of a certain animation, ignore! if ( gAnimControl[ pSoldier->usAnimState ].uiFlags & ANIM_NOSHOW_MARKER ) { @@ -1798,11 +1793,9 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) { return; } - - + GetSoldierAboveGuyPositions( pSoldier, &sXPos, &sYPos, FALSE ); - - + // Display name SetFont( TINYFONT1 ); SetFontBackground( FONT_MCOLOR_BLACK ); @@ -1816,7 +1809,7 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, NameStr ); mprintf( sX, sY, NameStr ); - fRaiseName = TRUE; + fRaiseName = TRUE; } else if ( gfUIMouseOnValidCatcher == 3 && pSoldier->ubID == gubUIValidCatcherID ) { @@ -1824,7 +1817,7 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, NameStr ); mprintf( sX, sY, NameStr ); - fRaiseName = TRUE; + fRaiseName = TRUE; } else if ( gfUIMouseOnValidCatcher == 4 && pSoldier->ubID == gubUIValidCatcherID ) { @@ -1832,27 +1825,26 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, NameStr ); mprintf( sX, sY, NameStr ); - fRaiseName = TRUE; + fRaiseName = TRUE; } else if ( pSoldier->bAssignment >= ON_DUTY ) { - SetFontForeground( FONT_YELLOW ); - swprintf( NameStr, L"(%s)", pAssignmentStrings[ pSoldier->bAssignment ] ); - FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - fRaiseName = TRUE; + SetFontForeground( FONT_YELLOW ); + swprintf( NameStr, L"(%s)", pAssignmentStrings[ pSoldier->bAssignment ] ); + FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + fRaiseName = TRUE; } else if ( pSoldier->bTeam == gbPlayerNum && pSoldier->bAssignment < ON_DUTY && pSoldier->bAssignment != CurrentSquad() && !( pSoldier->flags.uiStatusFlags & SOLDIER_MULTI_SELECTED ) ) { - swprintf( NameStr, gzLateLocalizedString[ 34 ], ( pSoldier->bAssignment + 1 ) ); - FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - fRaiseName = TRUE; + swprintf( NameStr, gzLateLocalizedString[ 34 ], ( pSoldier->bAssignment + 1 ) ); + FindFontCenterCoordinates( sXPos, (INT16)(sYPos ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + fRaiseName = TRUE; } - // If not in a squad.... if ( ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) ) { @@ -1871,83 +1863,80 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) if ( fDoName ) { - if ( fRaiseName ) - { - - - //legion2 jazz - if (pSoldier->ubBodyType == ROBOTNOWEAPON && pSoldier->bTeam == ENEMY_TEAM ) - { - swprintf( NameStr, zGrod[0] ); - } - else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) - { - swprintf( NameStr,L"???" ); - } - else - { - swprintf( NameStr, L"%s", pSoldier->name ); - } + if ( fRaiseName ) + { + //legion2 jazz + if (pSoldier->ubBodyType == ROBOTNOWEAPON && pSoldier->bTeam == ENEMY_TEAM ) + { + swprintf( NameStr, zGrod[0] ); + } + else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) + { + swprintf( NameStr,L"???" ); + } + else + { + swprintf( NameStr, L"%s", pSoldier->name ); + } - //Legion - if (pSoldier->ubBodyType == TANK_NE || pSoldier->ubBodyType == TANK_NW) - { - swprintf( NameStr, gNewVehicle[164].NewVehicleStrings ); - //swprintf( NameStr, pVehicleStrings[4] ); - } - else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) - { - swprintf( NameStr,L"???" ); - } - else - { - swprintf( NameStr, L"%s", pSoldier->name ); - } - //------- + //Legion + if (pSoldier->ubBodyType == TANK_NE || pSoldier->ubBodyType == TANK_NW) + { + swprintf( NameStr, gNewVehicle[164].NewVehicleStrings ); + //swprintf( NameStr, pVehicleStrings[4] ); + } + else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) + { + swprintf( NameStr,L"???" ); + } + else + { + swprintf( NameStr, L"%s", pSoldier->name ); + } + //------- - //swprintf( NameStr, L"%s", pSoldier->name ); - FindFontCenterCoordinates( sXPos, (INT16)( sYPos - 10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - } - else - { - - //legion Jazz - if (pSoldier->ubBodyType == ROBOTNOWEAPON && pSoldier->bTeam == ENEMY_TEAM ) - { - swprintf( NameStr, zGrod[0] ); - } - else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) - { - swprintf( NameStr,L"???" ); + //swprintf( NameStr, L"%s", pSoldier->name ); + FindFontCenterCoordinates( sXPos, (INT16)( sYPos - 10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); } else { - swprintf( NameStr, L"%s", pSoldier->name ); - } + //legion Jazz + if (pSoldier->ubBodyType == ROBOTNOWEAPON && pSoldier->bTeam == ENEMY_TEAM ) + { + swprintf( NameStr, zGrod[0] ); + } + else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) + { + swprintf( NameStr,L"???" ); + } + else + { + swprintf( NameStr, L"%s", pSoldier->name ); + } - //Legion - if (pSoldier->ubBodyType == TANK_NE || pSoldier->ubBodyType == TANK_NW) - { - //swprintf( NameStr, pVehicleStrings[4] ); - swprintf( NameStr, gNewVehicle[164].NewVehicleStrings ); - } - else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) - { - swprintf( NameStr,L"???" ); - } - else - { - swprintf( NameStr, L"%s", pSoldier->name ); - } - //--------------- + //Legion + if (pSoldier->ubBodyType == TANK_NE || pSoldier->ubBodyType == TANK_NW) + { + //swprintf( NameStr, pVehicleStrings[4] ); + swprintf( NameStr, gNewVehicle[164].NewVehicleStrings ); + } + else if (zHiddenNames[pSoldier->ubProfile].Hidden == TRUE) + { + swprintf( NameStr,L"???" ); + } + else + { + wprintf( NameStr, L"%s", pSoldier->name ); + } + //--------------- - //swprintf( NameStr, L"%s", pSoldier->name ); - FindFontCenterCoordinates( sXPos, sYPos, (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - } + //swprintf( NameStr, L"%s", pSoldier->name ); + FindFontCenterCoordinates( sXPos, sYPos, (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + } } // if ( pSoldier->ubProfile < FIRST_RPC || pSoldier->ubProfile >= GASTON || RPC_RECRUITED( pSoldier ) || AM_AN_EPC( pSoldier ) || ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) ) @@ -2000,7 +1989,6 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) FindFontCenterCoordinates( sXPos, (INT16)(sYPos + 10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, NameStr ); mprintf( sX, sY, NameStr ); - } else { @@ -2008,91 +1996,80 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_MCOLOR_DKRED ); - pStr = GetSoldierHealthString( pSoldier ); - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 10 ), (INT16)(80 ), 1, pStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, pStr ); mprintf( sX, sY, pStr ); - //----------------- - if (gGameExternalOptions.fEnemyNames == TRUE && gGameExternalOptions.fEnemyRank == FALSE) + //----------------- + if ( pSoldier->bInSector && pSoldier->ubProfile == NO_PROFILE ) { - for( iCounter2 = 0; iCounter2 < 500; iCounter2++ ) - { - if (zEnemyName[iCounter2].Enabled == 1) + if ( pSoldier->bTeam == ENEMY_TEAM ) { + if (gGameExternalOptions.fEnemyNames == TRUE && gGameExternalOptions.fEnemyRank == FALSE) + { + for( iCounter2 = 0; iCounter2 < 500; ++iCounter2 ) + { + if (zEnemyName[iCounter2].Enabled == 1) + { + if ( pSoldier->sSectorX == zEnemyName[iCounter2].SectorX && pSoldier->sSectorY == zEnemyName[iCounter2].SectorY ) + { + swprintf(NameStr, zEnemyName[iCounter2].szCurGroup); - if ((gWorldSectorX == zEnemyName[iCounter2].SectorX && gWorldSectorY == zEnemyName[iCounter2].SectorY )) - { - if (NumEnemiesInSector( zEnemyName[iCounter2].SectorX , zEnemyName[iCounter2].SectorY ) && pSoldier->ubProfile == NO_PROFILE && pSoldier->bTeam == 1 ) - { - - swprintf(NameStr, zEnemyName[iCounter2].szCurGroup); - - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_YELLOW ); + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_YELLOW ); - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); - } - } - } - } - } - - if (gGameExternalOptions.fEnemyNames == FALSE && gGameExternalOptions.fEnemyRank == TRUE) - { - for( iCounter2 = 1; iCounter2 < 13; iCounter2++ ) - { - if (zEnemyRank[iCounter2].Enabled == 1) - { - - if ( zEnemyRank[iCounter2].Stats == 0 && zEnemyRank[iCounter2].ExpLevel > 0 && pSoldier->ubProfile == NO_PROFILE && pSoldier->bTeam == 1 && pSoldier->stats.bExpLevel == zEnemyRank[iCounter2].ExpLevel ) - { - - swprintf(NameStr, zEnemyRank[iCounter2].szCurRank); - - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_YELLOW ); - - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); + break; + } + } } } - } - - } - - - if (gGameExternalOptions.fCivGroupName == TRUE) - { - for( iCounter2 = 1; iCounter2 < NUM_CIV_GROUPS; iCounter2++ ) - { - if (zCivGroupName[iCounter2].Enabled == 1) - { - if (pSoldier->ubProfile == NO_PROFILE && pSoldier->ubCivilianGroup == iCounter2 ) - { + else if (gGameExternalOptions.fEnemyNames == FALSE && gGameExternalOptions.fEnemyRank == TRUE) + { + for( iCounter2 = 1; iCounter2 < 11; ++iCounter2 ) + { + if (zEnemyRank[iCounter2].Enabled == 1) + { + if ( zEnemyRank[iCounter2].Stats == 0 && pSoldier->stats.bExpLevel == zEnemyRank[iCounter2].ExpLevel ) + { + swprintf(NameStr, zEnemyRank[iCounter2].szCurRank); - swprintf(NameStr, zCivGroupName[iCounter2].szCurGroup); - - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_YELLOW ); + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_YELLOW ); - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - } + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + + break; + } + } + } + } + } + else if (gGameExternalOptions.fCivGroupName == TRUE && pSoldier->ubCivilianGroup > 0 ) + { + if (zCivGroupName[pSoldier->ubCivilianGroup].Enabled == 1) + { + swprintf(NameStr, zCivGroupName[pSoldier->ubCivilianGroup].szCurGroup); + + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_YELLOW ); + + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); } } } @@ -2109,10 +2086,10 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_YELLOW ); - swprintf( NameStr, gzLateLocalizedString[ 15 ] ); - FindFontCenterCoordinates( sXPos, (INT16)(sYPos + 10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); + swprintf( NameStr, gzLateLocalizedString[ 15 ] ); + FindFontCenterCoordinates( sXPos, (INT16)(sYPos + 10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); } pStr = GetSoldierHealthString( pSoldier ); @@ -2132,45 +2109,59 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) mprintf( sX, sY, pStr ); //----------------- - if (gGameExternalOptions.fEnemyNames == TRUE && gGameExternalOptions.fEnemyRank == FALSE) + if ( pSoldier->bInSector && pSoldier->ubProfile == NO_PROFILE ) { - for( iCounter2 = 0; iCounter2 < 500; iCounter2++ ) +#ifdef ENABLE_ZOMBIES + if ( pSoldier->IsZombie() ) { - if (zEnemyName[iCounter2].Enabled == 1 ) - { - - if ((gWorldSectorX == zEnemyName[iCounter2].SectorX && gWorldSectorY == zEnemyName[iCounter2].SectorY )) - { - if (NumEnemiesInSector( zEnemyName[iCounter2].SectorX , zEnemyName[iCounter2].SectorY ) && pSoldier->ubProfile == NO_PROFILE && pSoldier->bTeam == 1 ) - { - - swprintf(NameStr, zEnemyName[iCounter2].szCurGroup); + swprintf(NameStr, pSoldier->name); - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_YELLOW ); + // Display name + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_MCOLOR_WHITE ); - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos -10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + } + else +#endif + if ( pSoldier->bTeam == ENEMY_TEAM ) + { + if (gGameExternalOptions.fEnemyNames == TRUE && gGameExternalOptions.fEnemyRank == FALSE) + { + for( iCounter2 = 0; iCounter2 < 500; ++iCounter2 ) + { + if (zEnemyName[iCounter2].Enabled == 1 ) + { + if ( pSoldier->sSectorX == zEnemyName[iCounter2].SectorX && pSoldier->sSectorY == zEnemyName[iCounter2].SectorY ) + { + swprintf(NameStr, zEnemyName[iCounter2].szCurGroup); + + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_YELLOW ); + + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); + break; + } } } } - } - } - - if (gGameExternalOptions.fEnemyNames == FALSE && gGameExternalOptions.fEnemyRank == TRUE) + else if (gGameExternalOptions.fEnemyNames == FALSE && gGameExternalOptions.fEnemyRank == TRUE) { - for( iCounter2 = 1; iCounter2 < 13; iCounter2++ ) + for( iCounter2 = 1; iCounter2 < 11; ++iCounter2 ) { if (zEnemyRank[iCounter2].Enabled == 1) { - - if ( zEnemyRank[iCounter2].Stats == 0 && zEnemyRank[iCounter2].ExpLevel > 0 && pSoldier->ubProfile == NO_PROFILE && pSoldier->bTeam == 1 && pSoldier->stats.bExpLevel == zEnemyRank[iCounter2].ExpLevel ) - { - + if ( zEnemyRank[iCounter2].Stats == 0 && pSoldier->stats.bExpLevel == zEnemyRank[iCounter2].ExpLevel ) + { swprintf(NameStr, zEnemyRank[iCounter2].szCurRank); SetFont( TINYFONT1 ); @@ -2181,53 +2172,30 @@ void DrawSelectedUIAboveGuy( UINT16 usSoldierID ) FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); gprintfdirty( sX, sY, NameStr ); mprintf( sX, sY, NameStr ); + + break; } } } - } - - if (gGameExternalOptions.fCivGroupName == TRUE) - { - for( iCounter2 = 1; iCounter2 < NUM_CIV_GROUPS; iCounter2++ ) + } + else if (gGameExternalOptions.fCivGroupName == TRUE && pSoldier->ubCivilianGroup > 0 ) { - if (zCivGroupName[iCounter2].Enabled == 1) - { - - if (pSoldier->ubProfile == NO_PROFILE && pSoldier->ubCivilianGroup == iCounter2 ) - { - swprintf(NameStr, zCivGroupName[iCounter2].szCurGroup); - - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_YELLOW ); - - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - } + if (zCivGroupName[pSoldier->ubCivilianGroup].Enabled == 1) + { + swprintf(NameStr, zCivGroupName[pSoldier->ubCivilianGroup].szCurGroup); + + SetFont( TINYFONT1 ); + SetFontBackground( FONT_MCOLOR_BLACK ); + SetFontForeground( FONT_YELLOW ); + + //legion2 + FindFontCenterCoordinates( sXPos, (INT16)( sYPos + 20 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); + gprintfdirty( sX, sY, NameStr ); + mprintf( sX, sY, NameStr ); } } } - -#ifdef ENABLE_ZOMBIES - if ( pSoldier->IsZombie() ) - { - swprintf(NameStr, pSoldier->name); - - // Display name - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_MCOLOR_WHITE ); - - //legion2 - FindFontCenterCoordinates( sXPos, (INT16)( sYPos -10 ), (INT16)(80 ), 1, NameStr, TINYFONT1, &sX, &sY ); - gprintfdirty( sX, sY, NameStr ); - mprintf( sX, sY, NameStr ); - } -#endif - //------------ } } diff --git a/Tactical/Interface.h b/Tactical/Interface.h index 3f4008f6d..8178761e2 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -61,7 +61,7 @@ typedef struct } ENEMY_RANK_VALUES; -extern ENEMY_RANK_VALUES zEnemyRank[500]; +extern ENEMY_RANK_VALUES zEnemyRank[20]; typedef struct { diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 48025e4f5..9894a8f94 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -4040,7 +4040,7 @@ UINT8 LastActiveTeamMember( UINT8 ubTeam ) void CheckForPotentialAddToBattleIncrement( SOLDIERTYPE *pSoldier ) { -UINT16 iCounter2; + UINT16 iCounter2; // Check if we are a threat! if ( !pSoldier->aiData.bNeutral && (pSoldier->bSide != gbPlayerNum ) ) { @@ -4079,17 +4079,13 @@ UINT16 iCounter2; */ //New Group by Jazz - for( iCounter2 = REBEL_CIV_GROUP; iCounter2 < NUM_CIV_GROUPS; iCounter2++ ) - { - if ( pSoldier->ubCivilianGroup == iCounter2 && zCivGroupName[iCounter2].AddToBattle == TRUE ) - { - if ( FindObjClass( pSoldier, IC_WEAPON ) != NO_SLOT ) - { - gTacticalStatus.bNumFoughtInBattle[ pSoldier->bTeam ]++; - } - } + if ( FindObjClass( pSoldier, IC_WEAPON ) != NO_SLOT && pSoldier->ubCivilianGroup >= REBEL_CIV_GROUP && pSoldier->ubCivilianGroup < NUM_CIV_GROUPS ) + { + if ( zCivGroupName[pSoldier->ubCivilianGroup].AddToBattle == TRUE ) + { + gTacticalStatus.bNumFoughtInBattle[ pSoldier->bTeam ]++; } - + } } else { diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index a7010a78a..f5b07f767 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -15071,11 +15071,7 @@ BOOLEAN SOLDIERTYPE::RecognizeAsCombatant(UINT8 ubTargetID) // if neither of the 2 persons is covert, always return true if ( ( (pSoldier->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER)) == 0 ) && ( (this->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER)) == 0 ) ) return TRUE; - - // only members of the player team can ever be covert, sorry AI - if ( pSoldier->bTeam != OUR_TEAM ) - return TRUE; - + // neutral characters just dont care if ( this->aiData.bNeutral ) return TRUE; @@ -15119,6 +15115,8 @@ BOOLEAN SOLDIERTYPE::RecognizeAsCombatant(UINT8 ubTargetID) { pSoldier->LooseDisguise(); + pSoldier->Strip(); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szCovertTextStr[STR_COVERT_UNCOVERED], this->name, pSoldier->name ); // we have uncovered a spy! Get alerted, if we aren't already @@ -15140,14 +15138,13 @@ void SOLDIERTYPE::LooseDisguise( void ) } // undisguise or take off any clothes item and switch back to original clothes -// no - this function does not want you think it does. Leave Fox alone, you perv. +// no - this function does not do what you think it does. Leave Fox alone, you perv. void SOLDIERTYPE::Strip() { // if covert, loose that ability if ( this->bSoldierFlagMask & (SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER) ) { - // loose any covert flags - this->bSoldierFlagMask &= ~(SOLDIER_COVERT_CIV|SOLDIER_COVERT_SOLDIER); + LooseDisguise(); } // if already not covert, take off clothes else if ( this->bSoldierFlagMask & (SOLDIER_NEW_VEST|SOLDIER_NEW_PANTS) ) diff --git a/Tactical/TeamTurns.cpp b/Tactical/TeamTurns.cpp index 208119164..c0a393079 100644 --- a/Tactical/TeamTurns.cpp +++ b/Tactical/TeamTurns.cpp @@ -1072,7 +1072,7 @@ void StartInterrupt( void ) if (pTempSoldier != NULL) { - // Flugente 12-11-13: I observed an isntance where the pTempSoldier was a player merc, leading to a deadlock here. The reason was that during an iinterrupot by a civilian, he somehow did not win + // Flugente 12-11-13: I observed an instance where the pTempSoldier was a player merc, leading to a deadlock here. The reason was that during an iinterrupot by a civilian, he somehow did not win // instead the game used the last merc entry... which overflowed, and thus started at merc 0, which is always a player merc // I am not sure if this is the best solution... however it seems to work for me. // If anybody knows a better solution, feel free to do so diff --git a/Tactical/XML_EnemyRank.cpp b/Tactical/XML_EnemyRank.cpp index 9980970bf..b72d412d9 100644 --- a/Tactical/XML_EnemyRank.cpp +++ b/Tactical/XML_EnemyRank.cpp @@ -228,7 +228,7 @@ BOOLEAN WriteEnemyRank( STR fileName) UINT32 cnt; FilePrintf(hFile,"\r\n"); - for(cnt = 0;cnt < 500;cnt++) + for(cnt = 0;cnt < 20; ++cnt) { FilePrintf(hFile,"\t\r\n"); FilePrintf(hFile,"\t\t%d\r\n", cnt);