Files
source/Strategic/Player Command.cpp
T
Wanne e64d5a2fa6 MERGED source code from development trunk revision 4545 up to latest current revision 4882
Development Trunk: https://ja2svn.dyndns.org/source/ja2/branches/Wanne/JA2%201.13%20MP
A detailed list of all the features (changes) is visible in the history log of the development trunk:

INFO: The source code for the official 2011 release (4870) has been branched here:
https://ja2svn.dyndns.org/source/ja2/branches/JA2_rev.4870_2011

This commit contains the following features:

*** Externalized Vehicles ***
o Now with this feature we can add/remove vehicles
o New XML File: TableData\Vehicles.xml
o Added a new function parameter to lua file Scripts\Overhead lua to set up the helicopter in method: SetUpHelicopterForPlayer()
o Added example mini (Docs\Externalized Vehicles Example.zip) mod which adds 2 additional vehicles (hummer and ice-cream truck to sector A9)

*** Up to 255 save slots ***
- There is a "Next" and "Prev" button where you can scroll through the save slots
- It is now possible to load the automatic save (SAVE_EVERY_N_HOURS) from the load screen. This is the first slot after the quickload slot
- Added the 2 alternate players end turn saves (which can be enabled/disabled in option screen) to the save/load game form

*** New Feature: Externalized emails from Emails.edt to XML***
o This feature can be enabled/disabled in the Source:
--> See email.cpp: If "ReadXMLEmail" == FALSE, then normal way (read from Email.edt) otherwise read from XML files
o 2 new XML files: TableData\Email\EmailMercAvailable.xml and EmailMercLevelUp.xml
o Renamed SenderNamesList.xml to EmailSenderNamesList.xml and moved from TableData folder to TableData\Email folder
o Names for mercenaries are get from the file MercProfiles.xml and different names get from the file EmailSenderNamesList.xml

*** Externalized Hidden Towns (Tixa, Orta) ***
o Now it is possible to add new hidden towns (locations)
o See file: TableData/Map/Cities.xml
o New variable in TableData/Map/Cities.xml
- hiddenTown:   0 = show on strategy map, 1 = Hide on strategy map
- townIcon:     1 = on, 0 = off (This is the icon you see on the strategy map)
- szIconFile:   The path to the sti icon file (eg: interface\prison.sti, interface\my_icon.sti)
- iconPosition: The x,y position of the icon on the strategy map

*** Encyclopedia and Briefing Room, reachable from the laptop ***
o 2 new ja2_options.ini properties: BRIEFING_ROOM, ENCYCLOPEDIA
o demonstration video: http://www.youtube.com/watch?v=7CIXdXWLrAo
o Added Example usage of the Briefing Room
- Extract it in your JA2 1.13 folder and use the latest development executable
- The briefing room can be reached from the laptop. Enter SN5631 for the code and then click the "Exit" button
- See "Info_BriefingRoom.txt" and "BriefingRoom_Mission1.png"

*** Improved interrupt system (IIS) ***
o This system changes the way interrupts work. See: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=290787#Post290787
o Option system (see ja2_options.ini: IMPROVED_INTERRUPT_SYSTEM)
o A few more settings for the interrupt system in ja2_options.ini
o INFO: Multiplayer games always use the "old" interrupt system, not matter what the user selects in the ja2_options.ini

*** Walking and sidestepping with weapon raised ***
o Enable/disable the walking/sidestepping with raised weapon in ja2_options.ini: ALLOW_WALKING_WITH_WEAPON_RAISED
o You can set an AP/BP modifier when walking/sidestepping with weapon raised in APBPConstants.ini: AP_MODIFIER_WEAPON_READY
o The following feature apply when you walk/sidestep with weapon raised:
-> limited angle of view, but you can see more farther when the weapon has a scope
-> better change for interrupts if you see an enemy
-> less APs and BPs when shooting, because the weapon is already raised
-> It should cost more APs when walking. Maybe you can export the additional AP and BP modifier to the APBPConstants.ini

*** Increase squad size to 8 (800x600) and 8 and 10 (1024x768) ***
o Squad sizes (dependend on the screen resolution) can be selected in the start new game screen
o In a multiplayer game, the squad size will always be 6, because it does not work with more soldiers/squad

*** Added UB-1.13 source code ***
o Merged the UB-1.13 source code (Revision: 4721) from svn: http://subversion.assembla.com/svn/ub-source113
o If you want to build UB-EXE or UB-MapEditor, just enable the 2 defines (JA2UB and JA2UBMAPS) in "builddefines.h"
o The UB-Verion reads from "ja2_UB.ini" instead of "ja2.ini"
o There are 2 new XML files
- Layout\LayoutMainMenu.xml
- MapAction\ActionItems.xml
o There are 2 new LUA-Script files
- Scripts\ExplosionControl.lua
- Scripts\InterfaceDialogue.lua

*** Hide enemy health text / enemy hit count ***
o ja2_options.ini: HIDE_ENEMY_HEALTH_TEXT, HIDE_ENEMY_HIT_COUNT
o both new settings only have effect in a singleplayer game
o see: http://www.ja-galaxy-forum.com/board/ubbthreads.php?ubb=showflat&Number=128840&page=1


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4885 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2012-01-18 11:19:01 +00:00

591 lines
18 KiB
C++

#ifdef PRECOMPILEDHEADERS
#include "Strategic All.h"
#else
#include "Player Command.h"
#include "Queen Command.h"
#include "Campaign Types.h"
#include "Strategic.h"
#include "Strategic Town Loyalty.h"
#include "Strategic Mines.h"
#include "text.h"
#include "laptopsave.h"
#include "quests.h"
#include "Morale.h"
#include "Overhead.h"
#include "strategicmap.h"
#include "Map Screen Helicopter.h"
#include "Game Clock.h"
#include "meanwhile.h"
#include "email.h"
#include "GameSettings.h"
#include "Strategic Status.h"
#include "Strategic AI.h"
#include "PreBattle Interface.h"
#include "Map Screen Interface.h"
#include "Tactical Save.h"
#include "interface Dialogue.h"
#include "Random.h"
// HEADROCK HAM 3.6: Added for facility string printing...
#include "PopUpBox.h"
#endif
#include "postalservice.h"
extern BOOLEAN fMapScreenBottomDirty;
extern CPostalService gPostalService;
void AddFacilitiesToBox( INT16 sMapX, INT16 sMapY, UINT32 *uiHandle, BOOLEAN fCityInfoBox )
{
// will build a string stating current facilities present in sector
// HEADROCK HAM 3.5: Facilities are now read from XMLs, including their names.
UINT32 cnt = 0;
UINT32 uiNumFacilities = 0;
BOOLEAN fHeaderAdded = FALSE;
CHAR16 szFacilityString[30];
Assert(sMapX > 0 && sMapY > 0 && sMapX < 17 && sMapY < 17);
for ( cnt = 0; cnt < NUM_FACILITY_TYPES; cnt++ )
{
if (fCityInfoBox && uiNumFacilities == 0 && !fHeaderAdded )
{
// For a city info box, always show this line on the left side.
swprintf( szFacilityString, L"%s:", pwTownInfoStrings[ 8 ] );
AddMonoString( uiHandle, szFacilityString );
fHeaderAdded = TRUE;
}
// Facility type exists at this location?
if (gFacilityLocations[SECTOR(sMapX,sMapY)][cnt].fFacilityHere)
{
if (gFacilityLocations[SECTOR(sMapX,sMapY)][cnt].ubHidden == 0 ||
(gFacilityLocations[SECTOR(sMapX,sMapY)][cnt].ubHidden == 1 && SectorInfo[SECTOR(sMapX,sMapY)].fSurfaceWasEverPlayerControlled) )
{
if (!fCityInfoBox && uiNumFacilities == 0 && !fHeaderAdded )
{
// For a non-city info box, show this line on the left side only if there's at least one facility.
swprintf( szFacilityString, L"%s:", pwTownInfoStrings[ 8 ] );
AddMonoString( uiHandle, szFacilityString );
}
else if (uiNumFacilities > 0)
{
// Add empty line on the left size to make room for text on the right.
AddMonoString( uiHandle, L"" );
}
AddSecondColumnMonoString( uiHandle, gFacilityTypes[cnt].szFacilityName );
uiNumFacilities++;
}
}
}
if( uiNumFacilities == 0 && fCityInfoBox )
{
// Add "NONE" on the right side. Only happens when the sector is a city.
AddSecondColumnMonoString( uiHandle, sFacilitiesStrings[0] );
return;
}
/* HEADROCK HAM 3.4: Hardcodes removed.
// hospital
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_HOSPITAL) )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ FACILITY_HOSPITAL ] );
}
// industry
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_INDUSTRY) )
{
if( wcslen( sFacilitiesString ) == 0 )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ 2 ] );
}
else
{
wcscat( sFacilitiesString, L", ");
wcscat( sFacilitiesString, sFacilitiesStrings[ 2 ]);
}
}
// prison
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_PRISON) )
{
if( wcslen( sFacilitiesString ) == 0 )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ 3 ] );
}
else
{
wcscat( sFacilitiesString, L", ");
wcscat( sFacilitiesString, sFacilitiesStrings[ 3 ]);
}
}
// HEADROCK HAM 3.4: What about the military base!
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_MILITARY) )
{
if( wcslen( sFacilitiesString ) == 0 )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ 4 ] );
}
else
{
wcscat( sFacilitiesString, L", ");
wcscat( sFacilitiesString, sFacilitiesStrings[ 4 ]);
}
}
// airport
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_AIRPORT) )
{
if( wcslen( sFacilitiesString ) == 0 )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ 5 ] );
}
else
{
wcscat( sFacilitiesString, L", ");
wcscat( sFacilitiesString, sFacilitiesStrings[ 5 ]);
}
}
// gun range
if( SectorInfo[ SECTOR( sMapX, sMapY ) ].uiFacilitiesFlags & (1 << FACILITY_GUNRANGE) )
{
if( wcslen( sFacilitiesString ) == 0 )
{
swprintf( sFacilitiesString, L"%s", sFacilitiesStrings[ 6 ] );
}
else
{
wcscat( sFacilitiesString, L", ");
wcscat( sFacilitiesString, sFacilitiesStrings[ 6 ]);
}
}
*/
return;
}
// ALL changes of control to player must be funneled through here!
BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BOOLEAN fContested )
{
// NOTE: MapSector must be 16-bit, cause MAX_WORLD_X is actually 18, so the sector numbers exceed 256 although we use only 16x16
UINT16 usMapSector = 0;
BOOLEAN fWasEnemyControlled = FALSE;
INT8 bTownId = 0;
UINT8 ubSectorID;
#ifdef JA2UB
//Ja25: No meanwhiles
#else
if( AreInMeanwhile( ) )
{
return FALSE;
}
#endif
if( bMapZ == 0 )
{
usMapSector = sMapX + ( sMapY * MAP_WORLD_X );
/*
// if enemies formerly controlled this sector
if (StrategicMap[ usMapSector ].fEnemyControlled)
{
// remember that the enemies have lost it
StrategicMap[ usMapSector ].fLostControlAtSomeTime = TRUE;
}
*/
if( NumHostilesInSector( sMapX, sMapY, bMapZ ) )
{ //too premature: enemies still in sector.
return FALSE;
}
if (LaptopSaveInfo.fBobbyRSiteCanBeAccessed == FALSE)
{
// Check if the sector is a shipment sector
BOOLEAN isShipmentSector = gPostalService.IsSectorAShipmentSector((UINT8)sMapX, (UINT8)sMapY, (UINT8)bMapZ);
if (isShipmentSector)
LaptopSaveInfo.fBobbyRSiteCanBeAccessed = TRUE;
}
// WANNE: Get Airport sector from ShippingDestination.xml file!
// check if we ever grabbed drassen airport, if so, set fact we can go to BR's
//if( ( sMapX == BOBBYR_SHIPPING_DEST_SECTOR_X ) && ( sMapY == BOBBYR_SHIPPING_DEST_SECTOR_Y ) )
if (LaptopSaveInfo.fBobbyRSiteCanBeAccessed)
{
//LaptopSaveInfo.fBobbyRSiteCanBeAccessed = TRUE;
//If the player has been to Bobbyr when it was down, and we havent already sent email, send him an email
if( LaptopSaveInfo.ubHaveBeenToBobbyRaysAtLeastOnceWhileUnderConstruction == BOBBYR_BEEN_TO_SITE_ONCE && LaptopSaveInfo.ubHaveBeenToBobbyRaysAtLeastOnceWhileUnderConstruction != BOBBYR_ALREADY_SENT_EMAIL )
{
#ifdef JA2UB
// no UB
#else
AddEmail( BOBBYR_NOW_OPEN, BOBBYR_NOW_OPEN_LENGTH, BOBBY_R, GetWorldTotalMin(), -1, -1, TYPE_EMAIL_EMAIL_EDT);
#endif
LaptopSaveInfo.ubHaveBeenToBobbyRaysAtLeastOnceWhileUnderConstruction = BOBBYR_ALREADY_SENT_EMAIL;
}
}
fWasEnemyControlled = StrategicMap[ usMapSector ].fEnemyControlled;
StrategicMap[ usMapSector ].fEnemyControlled = FALSE;
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = TRUE;
bTownId = StrategicMap[ usMapSector ].bNameId;
// check if there's a town in the sector
if ((bTownId >= FIRST_TOWN) && (bTownId < NUM_TOWNS))
{
// yes, start tracking (& displaying) this town's loyalty if not already doing so
StartTownLoyaltyIfFirstTime( bTownId );
}
// if player took control away from enemy
if( fWasEnemyControlled )
{
// WDS - New AI
// Hook in here for some stuff
// and it's a town
if ((bTownId >= FIRST_TOWN) && (bTownId < NUM_TOWNS))
{
// don't do these for takeovers of Omerta sectors at the beginning of the game
if ((bTownId != OMERTA) || (GetWorldDay() != 1))
{
ubSectorID = (UINT8)SECTOR( sMapX, sMapY );
if( !bMapZ && ubSectorID != SEC_J9 && ubSectorID != SEC_K4 )
{
HandleMoraleEvent( NULL, MORALE_TOWN_LIBERATED, sMapX, sMapY, bMapZ );
#ifdef JA2UB
//Ja25: no loyalty
#else
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_GAIN_TOWN_SECTOR, sMapX, sMapY, bMapZ );
#endif
// liberation by definition requires that the place was enemy controlled in the first place
CheckIfEntireTownHasBeenLiberated( bTownId, sMapX, sMapY );
}
}
}
// if it's a mine that's still worth something
if ( IsThereAMineInThisSector( sMapX, sMapY ) )
{
if ( GetTotalLeftInMine( GetMineIndexForSector( sMapX, sMapY ) ) > 0)
{
HandleMoraleEvent( NULL, MORALE_MINE_LIBERATED, sMapX, sMapY, bMapZ );
#ifdef JA2UB
// Ja25: no loyalty
#else
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_GAIN_MINE, sMapX, sMapY, bMapZ );
#endif
}
}
// if it's a SAM site sector
if( IsThisSectorASAMSector( sMapX, sMapY, bMapZ ) )
{
if ( 1 /*!GetSectorFlagStatus( sMapX, sMapY, bMapZ, SF_SECTOR_HAS_BEEN_LIBERATED_ONCE ) */)
{
// SAM site liberated for first time, schedule meanwhile
#ifdef JA2UB
//JA25 No meanwhiles
#else
HandleMeanWhileEventPostingForSAMLiberation( GetSAMIdFromSector( sMapX, sMapY, bMapZ ) );
#endif
}
HandleMoraleEvent( NULL, MORALE_SAM_SITE_LIBERATED, sMapX, sMapY, bMapZ );
#ifdef JA2UB
// Ja25: no loyalty
#else
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_GAIN_SAM, sMapX, sMapY, bMapZ );
UpdateAirspaceControl( );
#endif
// if Skyrider has been delivered to chopper, and already mentioned Drassen SAM site, but not used this quote yet
if ( IsHelicopterPilotAvailable( ) && ( guiHelicopterSkyriderTalkState >= 1 ) && ( !gfSkyriderSaidCongratsOnTakingSAM ) )
{
SkyRiderTalk( SAM_SITE_TAKEN );
gfSkyriderSaidCongratsOnTakingSAM = TRUE;
}
if ( !SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled )
{
// grant grace period
if ( gGameOptions.ubDifficultyLevel >= DIF_LEVEL_HARD )
{
UpdateLastDayOfPlayerActivity( ( UINT16 ) ( GetWorldDay() + 2 ) );
}
else
{
UpdateLastDayOfPlayerActivity( ( UINT16 ) ( GetWorldDay() + 1 ) );
}
}
}
// if it's a helicopter refueling site sector
if( IsRefuelSiteInSector( sMapX, sMapY) )
{
UpdateRefuelSiteAvailability( );
}
// SetSectorFlag( sMapX, sMapY, bMapZ, SF_SECTOR_HAS_BEEN_LIBERATED_ONCE );
if ( bMapZ == 0 && ( ( sMapY == MAP_ROW_M && (sMapX >= 2 && sMapX <= 6) ) || sMapY == MAP_ROW_N && sMapX == 6) )
{
#ifdef JA2UB
//Ja25 No meanwhiles
#else
HandleOutskirtsOfMedunaMeanwhileScene();
#endif
}
}
#ifdef JA2UB
//Ja25 No strategic ai
#else
if( fContested )
{
StrategicHandleQueenLosingControlOfSector( (UINT8)sMapX, (UINT8)sMapY, (UINT8)bMapZ );
}
#endif
}
else
{
#ifdef JA2UB
//Ja25 No strategic ai
#else
if( sMapX == 3 && sMapY == 16 && bMapZ == 1 )
{ //Basement sector (P3_b1)
gfUseAlternateQueenPosition = TRUE;
}
#endif
}
// also set fact the player knows they own it
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = TRUE;
if ( bMapZ == 0 )
{
SectorInfo[ SECTOR( sMapX, sMapY ) ].fSurfaceWasEverPlayerControlled = TRUE;
}
//KM : Aug 11, 1999 -- Patch fix: Relocated this check so it gets called everytime a sector changes hands,
// even if the sector isn't a SAM site. There is a bug _somewhere_ that fails to update the airspace,
// even though the player controls it.
//UpdateAirspaceControl( );
// redraw map/income if in mapscreen
fMapPanelDirty = TRUE;
fMapScreenBottomDirty = TRUE;
return fWasEnemyControlled;
}
// ALL changes of control to enemy must be funneled through here!
BOOLEAN SetThisSectorAsEnemyControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BOOLEAN fContested )
{
UINT16 usMapSector = 0;
BOOLEAN fWasPlayerControlled = FALSE;
INT8 bTownId = 0;
UINT8 ubTheftChance;
UINT8 ubSectorID;
//KM : August 6, 1999 Patch fix
// This check was added because this function gets called when player mercs retreat from an unresolved
// battle between militia and enemies. It will get called again AFTER autoresolve is finished.
if( gfAutomaticallyStartAutoResolve )
{
return( FALSE );
}
if( bMapZ == 0 )
{
usMapSector = sMapX + ( sMapY * MAP_WORLD_X );
fWasPlayerControlled = !StrategicMap[ usMapSector ].fEnemyControlled;
StrategicMap[ usMapSector ].fEnemyControlled = TRUE;
// if player lost control to the enemy
if ( fWasPlayerControlled )
{
if( PlayerMercsInSector( (UINT8)sMapX, (UINT8)sMapY, (UINT8)bMapZ ) )
{ //too premature: Player mercs still in sector.
return FALSE;
}
// check if there's a town in the sector
bTownId = StrategicMap[ usMapSector ].bNameId;
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = FALSE;
// and it's a town
if ((bTownId >= FIRST_TOWN) && (bTownId < NUM_TOWNS))
{
ubSectorID = (UINT8)SECTOR( sMapX, sMapY );
if( !bMapZ && ubSectorID != SEC_J9 && ubSectorID != SEC_K4 )
{
HandleMoraleEvent( NULL, MORALE_TOWN_LOST, sMapX, sMapY, bMapZ );
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_LOSE_TOWN_SECTOR, sMapX, sMapY, bMapZ );
CheckIfEntireTownHasBeenLost( bTownId, sMapX, sMapY );
}
}
// if the sector has a mine which is still worth something
if ( IsThereAMineInThisSector( sMapX, sMapY ) )
{
// if it isn't empty
if ( GetTotalLeftInMine( GetMineIndexForSector( sMapX, sMapY ) ) > 0)
{
QueenHasRegainedMineSector(GetMineIndexForSector (sMapX, sMapY));
HandleMoraleEvent( NULL, MORALE_MINE_LOST, sMapX, sMapY, bMapZ );
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_LOSE_MINE, sMapX, sMapY, bMapZ );
}
}
// if it's a SAM site sector
if( IsThisSectorASAMSector( sMapX, sMapY, bMapZ ) )
{
HandleMoraleEvent( NULL, MORALE_SAM_SITE_LOST, sMapX, sMapY, bMapZ );
HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_LOSE_SAM, sMapX, sMapY, bMapZ );
UpdateAirspaceControl( );
}
// if it's a helicopter refueling site sector
if( IsRefuelSiteInSector( sMapX, sMapY) )
{
UpdateRefuelSiteAvailability( );
}
// ARM: this must be AFTER all resulting loyalty effects are resolved, or reduced mine income shown won't be accurate
NotifyPlayerWhenEnemyTakesControlOfImportantSector( sMapX, sMapY, 0, fContested );
}
// NOTE: Stealing is intentionally OUTSIDE the fWasPlayerControlled branch. This function gets called if new
// enemy reinforcements arrive, and they deserve another crack at stealing what the first group missed! :-)
// stealing should fail anyway 'cause there shouldn't be a temp file for unvisited sectors, but let's check anyway
if ( GetSectorFlagStatus( sMapX, sMapY, ( UINT8 ) bMapZ, SF_ALREADY_VISITED ) == TRUE )
{
// enemies can steal items left lying about (random chance). The more there are, the more they take!
ubTheftChance = 5 * NumEnemiesInAnySector( sMapX, sMapY, bMapZ );
// max 90%, some stuff may just simply not get found
if (ubTheftChance > 90 )
{
ubTheftChance = 90;
}
RemoveRandomItemsInSector( sMapX, sMapY, bMapZ, ubTheftChance );
}
// don't touch fPlayer flag for a surface sector lost to the enemies!
// just because player has lost the sector doesn't mean he realizes it - that's up to our caller to decide!
}
else
{
// underground sector control is always up to date, because we don't track control down there
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = FALSE;
}
//KM : Aug 11, 1999 -- Patch fix: Relocated this check so it gets called everytime a sector changes hands,
// even if the sector isn't a SAM site. There is a bug _somewhere_ that fails to update the airspace,
// even though the player controls it.
//UpdateAirspaceControl( );
// redraw map/income if in mapscreen
fMapPanelDirty = TRUE;
fMapScreenBottomDirty = TRUE;
return fWasPlayerControlled;
}
#ifdef JA2TESTVERSION
void ClearMapControlledFlags( void )
{
INT32 iCounterA = 0, iCounterB = 0;
UINT16 usMapSector = 0;
for( iCounterA = 1; iCounterA < MAP_WORLD_X - 1; iCounterA++ )
{
for( iCounterB = 1; iCounterB < MAP_WORLD_Y - 1; iCounterB++ )
{
usMapSector = iCounterA + ( iCounterB * MAP_WORLD_X );
StrategicMap[ usMapSector ].fEnemyControlled = FALSE;
SectorInfo[ SECTOR( iCounterA, iCounterB ) ].fPlayer[ 0 ] = TRUE;
}
}
UpdateAirspaceControl( );
}
#endif
/*
BOOLEAN IsTheSectorPerceivedToBeUnderEnemyControl( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
{
// are we in battle in this sector?
if( ( sMapX == gWorldSectorX ) && ( sMapY == gWorldSectorY ) && ( bMapZ == gbWorldSectorZ ) && ( gTacticalStatus.uiFlags & INCOMBAT ) )
{
return( TRUE );
}
// does the player believe this sector is under enemy control?
return( !( SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] ) );
}
void MakePlayerPerceptionOfSectorControlCorrect( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
{
if (bMapZ == 0)
{
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = !( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sMapX, sMapY ) ].fEnemyControlled );
}
// else nothing, underground sector control is always up to date, because we don't track control down there
fMapPanelDirty = TRUE;
}
*/
void ReplaceSoldierProfileInPlayerGroup( UINT8 ubGroupID, UINT8 ubOldProfile, UINT8 ubNewProfile )
{
GROUP *pGroup;
PLAYERGROUP *curr;
pGroup = GetGroup( ubGroupID );
if ( !pGroup )
{
return;
}
curr = pGroup->pPlayerList;
while( curr )
{
if( curr->ubProfileID == ubOldProfile )
{
// replace and return!
curr->ubProfileID = ubNewProfile;
return;
}
curr = curr->next;
}
}