diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 412beaa6..734058c6 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -1117,7 +1117,7 @@ UINT32 ProcessFileIO() //ATE: Any current mercs are transfered here... //UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - + AddSoldierInitListTeamToWorld( ENEMY_TEAM, TOTAL_SOLDIERS + 1 ); AddSoldierInitListTeamToWorld( CREATURE_TEAM, TOTAL_SOLDIERS + 1 ); AddSoldierInitListTeamToWorld( MILITIA_TEAM, TOTAL_SOLDIERS + 1 ); diff --git a/GameVersion.cpp b/GameVersion.cpp index 16c7e3cc..1ee00afb 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8094 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8094 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8094 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8094 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8094 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,11 +46,11 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8094 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8094 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8084 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8094 (Development Build)" }; #endif #endif diff --git a/Laptop/DropDown.h b/Laptop/DropDown.h index d138eed3..23e5757b 100644 --- a/Laptop/DropDown.h +++ b/Laptop/DropDown.h @@ -134,7 +134,8 @@ enum definedDropDowns DROPDOWNNR_IMPGEAR_MAX = DROPDOWNNR_IMPGEAR_MISC_7, - DROPDOWNNR_MSGBOX, + DROPDOWNNR_MSGBOX_1, + DROPDOWNNR_MSGBOX_2, }; /* @@ -205,7 +206,7 @@ public: * Set the content of a dropdown. Each entry consists of an INT16 key, by which you can later identify which entry was selected, and a STR16 that will be displayed. * There can be multiple instances of the same key or name. */ - void SetEntries( std::vector >& arEntryVec ) { mEntryVector = arEntryVec; } + void SetEntries( std::vector >& arEntryVec ) { mEntryVector = arEntryVec; mNumDisplayedEntries = min( DROPDOWN_REGIONS, mEntryVector.size( ) ); } /* * Set help text decribing what can be selected diff --git a/MessageBoxScreen.cpp b/MessageBoxScreen.cpp index db3325e9..fb13239d 100644 --- a/MessageBoxScreen.cpp +++ b/MessageBoxScreen.cpp @@ -21,7 +21,8 @@ #include "text.h" #include "Text Input.h" #include "overhead map.h" - #include "DropDown.h" + #include "DropDown.h" // added by Flugente + #include "Utilities.h" // added by Flugente for FilenameForBPP(...) #endif #define MSGBOX_DEFAULT_WIDTH 300 @@ -47,6 +48,9 @@ BOOLEAN gfInMsgBox = FALSE; extern BOOLEAN fInMapMode; extern BOOLEAN gfOverheadMapDirty; +UINT32 guiMessageBoxImage = 0; +UINT16 guiMessageBoxImageIndex = 0; + //OJW - 20090208 CHAR16 gszMsgBoxInputString[255]; @@ -243,9 +247,12 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN if ( usFlags & MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS ) heightincrease = 90; - if ( usFlags & MSG_BOX_FLAG_DROPDOWN ) + if ( gMsgBox.usFlags & MSG_BOX_FLAG_IMAGE ) heightincrease = 130; + if ( usFlags & MSG_BOX_FLAG_DROPDOWN ) + heightincrease = 130; + UINT16 usMBWidth=MSGBOX_DEFAULT_WIDTH; BOOLEAN bFixedWidth = FALSE; // sevenfm: custom width for 16-medium-button messagebox @@ -914,7 +921,8 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN if ( gMsgBox.usFlags & MSG_BOX_FLAG_DROPDOWN ) { - DropDownTemplate::getInstance( ).Create( (INT16)(gMsgBox.sX + 15), (INT16)(gMsgBox.sY + 30) ); + DropDownTemplate::getInstance( ).Create( (INT16)(gMsgBox.sX + 15), (INT16)(gMsgBox.sY + 35) ); + DropDownTemplate::getInstance( ).Create( (INT16)(gMsgBox.sX + 15), (INT16)(gMsgBox.sY + 66) ); } #if 0 @@ -940,12 +948,58 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN return( iId ); } +// once the dropdowns in messagebox are used in more than one occasion, this obviously has to be changed... // this has to be defined. As the MessageBoxScreenHandle() runs all time, there is nothing to do here though -template<> void DropDownTemplate::SetRefresh( ) +template<> void DropDownTemplate::SetRefresh() { - // for now, nothing needed, update happens automatically + INT16 box1key = DropDownTemplate::getInstance( ).GetSelectedEntryKey( ); + + std::vector > dropdownvector_2 = GetTileSetIndexVector( box1key ); + + DropDownTemplate::getInstance( ).SetEntries( dropdownvector_2 ); + + if ( !dropdownvector_2.empty( ) ) + { + BOOLEAN found = FALSE; + for ( std::vector >::iterator it = dropdownvector_2.begin( ); it != dropdownvector_2.end( ); ++it ) + { + if ( (*it).first == guiMessageBoxImageIndex ) + { + found = TRUE; + break; + } + } + + if ( !found ) + guiMessageBoxImageIndex = dropdownvector_2[0].first; + } + + DropDownTemplate::getInstance( ).SetSelectedEntryKey( guiMessageBoxImageIndex ); + + if ( gMsgBox.usFlags & MSG_BOX_FLAG_IMAGE ) + { + DeleteVideoObjectFromIndex( guiMessageBoxImage ); + guiMessageBoxImage = 0; + + VOBJECT_DESC VObjectDesc; + VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; + + sprintf( VObjectDesc.ImageFile, "TILESETS\\%d\\%s", giCurrentTilesetID, gStructureConstruct[box1key].szTileSetName ); + + // even if AddVideoObject fails, continue, as we might 'repair' it while the box is open + if ( !AddVideoObject( &VObjectDesc, &guiMessageBoxImage ) ) + { + sprintf( VObjectDesc.ImageFile, "TILESETS\\0\\%s", gStructureConstruct[box1key].szTileSetName ); + + AddVideoObject( &VObjectDesc, &guiMessageBoxImage ); + } + } } +template<> void DropDownTemplate::SetRefresh() +{ + guiMessageBoxImageIndex = DropDownTemplate::getInstance( ).GetSelectedEntryKey( ); +} void MsgBoxClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) { @@ -1190,11 +1244,17 @@ UINT32 ExitMsgBox( INT8 ubExitCode ) } } - if ( gMsgBox.usFlags & MSG_BOX_FLAG_DROPDOWN ) + if ( gMsgBox.usFlags & MSG_BOX_FLAG_IMAGE ) { - DropDownTemplate::getInstance( ).Destroy( ); + DeleteVideoObjectFromIndex( guiMessageBoxImage ); } + if ( gMsgBox.usFlags & MSG_BOX_FLAG_DROPDOWN ) + { + DropDownTemplate::getInstance( ).Destroy( ); + DropDownTemplate::getInstance( ).Destroy( ); + } + // Delete button images UnloadButtonImage( gMsgBox.iButtonImages ); @@ -1596,11 +1656,22 @@ UINT32 MessageBoxScreenHandle( ) } } - if ( gMsgBox.usFlags & MSG_BOX_FLAG_DROPDOWN ) + if ( gMsgBox.usFlags & MSG_BOX_FLAG_IMAGE ) { - DropDownTemplate::getInstance( ).Display( ); + HVOBJECT hIconHandle; + + GetVideoObject( &hIconHandle, guiMessageBoxImage ); + + if ( hIconHandle ) + BltVideoObject( FRAME_BUFFER, hIconHandle, guiMessageBoxImageIndex, gMsgBox.sX + 70, gMsgBox.sY + 90, VO_BLT_SRCTRANSPARENCY, NULL ); } + if ( gMsgBox.usFlags & MSG_BOX_FLAG_DROPDOWN ) + { + DropDownTemplate::getInstance( ).Display( ); + DropDownTemplate::getInstance( ).Display( ); + } + if ( gMsgBox.bHandled ) { SetRenderFlags( RENDER_FLAG_FULL ); diff --git a/MessageBoxScreen.h b/MessageBoxScreen.h index 59b6ab07..8369959e 100644 --- a/MessageBoxScreen.h +++ b/MessageBoxScreen.h @@ -24,6 +24,7 @@ #define MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS 0x00008000 // Displays sixteen numbered buttons with definable labels #define MSG_BOX_FLAG_DROPDOWN 0x00010000 // Displays an aditional dropdown box +#define MSG_BOX_FLAG_IMAGE 0x00020000 // Displays an image // message box return codes #define MSG_BOX_RETURN_OK 1 // ENTER or on OK button diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index aef88b51..be21cfb5 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -5051,10 +5051,12 @@ BOOLEAN LoadSavedGame( int ubSavedGameID ) FileClose( hFile ); return( FALSE ); } - #ifdef JA2BETAVERSION - LoadGameFilePosition( FileGetPos( hFile ), "UnderGround Information" ); - #endif +#ifdef JA2BETAVERSION + LoadGameFilePosition( FileGetPos( hFile ), "UnderGround Information" ); +#endif + // Flugente: at this point we need to reevaluate the fortification costs, as the fortification plan may have changed + UpdateFortificationPossibleAmount(); uiRelEndPerc += 1; SetRelativeStartAndEndPercentage( 0, uiRelStartPerc, uiRelEndPerc, L"Squad Info..." ); diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 6008ddc8..809ee2d1 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -472,6 +472,9 @@ void HandleRadioScanInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ); void HandleDiseaseDiagnosis(); void HandleDiseaseSectorTreatment( ); +// Flugente: fortification +void HandleFortification(); + // reset scan flags in all sectors void ClearSectorScanResults(); @@ -935,6 +938,28 @@ BOOLEAN CanCharacterTreatSectorDisease( SOLDIERTYPE *pSoldier ) return FALSE; } +BOOLEAN CanCharacterFortify( SOLDIERTYPE *pSoldier ) +{ + if ( pSoldier->bSectorZ ) + { + UNDERGROUND_SECTORINFO *pSectorInfo; + pSectorInfo = FindUnderGroundSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ); + + if ( pSectorInfo && pSectorInfo->dFortification_MaxPossible > pSectorInfo->dFortification_UnappliedProgress ) + return TRUE; + } + else + { + SECTORINFO *pSectorInfo; + pSectorInfo = &SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )]; + + if ( pSectorInfo && pSectorInfo->dFortification_MaxPossible > pSectorInfo->dFortification_UnappliedProgress ) + return TRUE; + } + + return FALSE; +} + BOOLEAN IsAnythingAroundForSoldierToRepair( SOLDIERTYPE * pSoldier ) { AssertNotNIL(pSoldier); @@ -2536,6 +2561,9 @@ void UpdateAssignments() // Flugente: PMC recruits new personnel HourlyUpdatePMC(); + // handle fortification + HandleFortification(); + // check to see if anyone is done healing? UpdatePatientsWhoAreDoneHealing( ); @@ -7374,6 +7402,51 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ ) } } +// Flugente: fortification +void HandleFortification() +{ + SOLDIERTYPE* pSoldier = NULL; + UINT16 uiCnt = 0; + + for ( uiCnt = 0, pSoldier = MercPtrs[uiCnt]; uiCnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; ++uiCnt, ++pSoldier ) + { + if ( pSoldier->bActive && !pSoldier->flags.fMercAsleep && EnoughTimeOnAssignment( pSoldier ) ) + { + if ( (pSoldier->bAssignment == FORTIFICATION) && CanCharacterFortify( pSoldier ) ) + { + if ( pSoldier->bSectorZ ) + { + UNDERGROUND_SECTORINFO *pSectorInfo; + pSectorInfo = FindUnderGroundSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ); + + if ( pSectorInfo ) + { + pSectorInfo->dFortification_UnappliedProgress = min( pSectorInfo->dFortification_UnappliedProgress + pSoldier->GetConstructionPoints( ), pSectorInfo->dFortification_MaxPossible ); + } + } + else + { + SECTORINFO *pSectorInfo; + pSectorInfo = &SectorInfo[SECTOR( pSoldier->sSectorX, pSoldier->sSectorY )]; + + if ( pSectorInfo ) + { + pSectorInfo->dFortification_UnappliedProgress = min( pSectorInfo->dFortification_UnappliedProgress + pSoldier->GetConstructionPoints( ), pSectorInfo->dFortification_MaxPossible ); + } + } + + StatChange( pSoldier, STRAMT, 6, TRUE ); + + // if we cannot fortify any longer, this means we're finished - tell us so + if ( !CanCharacterFortify( pSoldier ) ) + AssignmentDone( pSoldier, TRUE, TRUE ); + } + } + } + + HandleFortificationUpdate( ); +} + INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts ) { INT16 sTotalTrainingPts = 0; @@ -7593,7 +7666,7 @@ void AssignmentDone( SOLDIERTYPE *pSoldier, BOOLEAN fSayQuote, BOOLEAN fMeToo ) if ( fSayQuote ) { if (IS_DOCTOR( pSoldier->bAssignment ) || IS_REPAIR( pSoldier->bAssignment ) || - IS_PATIENT( pSoldier->bAssignment ) || (pSoldier->bAssignment == ASSIGNMENT_HOSPITAL)) + IS_PATIENT( pSoldier->bAssignment ) || pSoldier->bAssignment == ASSIGNMENT_HOSPITAL || pSoldier->bAssignment == FORTIFICATION ) { TacticalCharacterDialogue( pSoldier, QUOTE_ASSIGNMENT_COMPLETE ); } @@ -9057,6 +9130,18 @@ void HandleShadingOfLinesForAssignmentMenus( void ) // shade line ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_SNITCH ); } + + // fortify + if ( CanCharacterFortify( pSoldier ) ) + { + // unshade patient line + UnShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_FORTIFY ); + } + else + { + // shade patient line + ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_FORTIFY ); + } } } @@ -12502,6 +12587,42 @@ void AssignmentMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) } break; + case ASSIGN_MENU_FORTIFY: + if ( CanCharacterFortify(pSoldier) ) + { + // stop showing menu + fShowAssignmentMenu = FALSE; + giAssignHighLine = -1; + + pSoldier->bOldAssignment = pSoldier->bAssignment; + + if ( (pSoldier->bAssignment != FORTIFICATION) ) + { + SetTimeOfAssignmentChangeForMerc( pSoldier ); + } + + // remove from squad + if ( pSoldier->bOldAssignment == VEHICLE ) + { + TakeSoldierOutOfVehicle( pSoldier ); + } + RemoveCharacterFromSquads( pSoldier ); + + ChangeSoldiersAssignment( pSoldier, FORTIFICATION ); + + AssignMercToAMovementGroup( pSoldier ); + + MakeSoldiersTacticalAnimationReflectAssignment( pSoldier ); + + // set dirty flag + fTeamPanelDirty = TRUE; + fMapScreenBottomDirty = TRUE; + + // set assignment for group + SetAssignmentForList( (INT8)FORTIFICATION, 0 ); + } + break; + // HEADROCK HAM 3.6: New assignments for Facility operation. case( ASSIGN_MENU_FACILITY ): if ( BasicCanCharacterFacility( pSoldier ) ) @@ -15268,6 +15389,30 @@ void SetSoldierAssignment( SOLDIERTYPE *pSoldier, INT8 bAssignment, INT32 iParam } break; + case FORTIFICATION: + if ( CanCharacterFortify( pSoldier ) ) + { + pSoldier->bOldAssignment = pSoldier->bAssignment; + + // remove from squad + RemoveCharacterFromSquads( pSoldier ); + + // remove from any vehicle + if ( pSoldier->bOldAssignment == VEHICLE ) + { + TakeSoldierOutOfVehicle( pSoldier ); + } + + if ( pSoldier->bAssignment != bAssignment ) + { + SetTimeOfAssignmentChangeForMerc( pSoldier ); + } + + ChangeSoldiersAssignment( pSoldier, bAssignment ); + AssignMercToAMovementGroup( pSoldier ); + } + break; + case( VEHICLE ): if( CanCharacterVehicle( pSoldier ) && IsThisVehicleAccessibleToSoldier( pSoldier, iParam1 ) ) { @@ -16558,6 +16703,10 @@ void ReEvaluateEveryonesNothingToDo() fNothingToDo = !CanCharacterTreatSectorDisease( pSoldier ); break; + case FORTIFICATION: + fNothingToDo = !CanCharacterFortify( pSoldier ); + break; + case VEHICLE: default: // squads fNothingToDo = FALSE; @@ -16867,6 +17016,14 @@ void SetAssignmentForList( INT8 bAssignment, INT8 bParam ) fItWorked = TRUE; } break; + case FORTIFICATION: + if ( CanCharacterFortify( pSoldier ) ) + { + pSoldier->bOldAssignment = pSoldier->bAssignment; + SetSoldierAssignment( pSoldier, FORTIFICATION, bParam, 0, 0 ); + fItWorked = TRUE; + } + break; case( SQUAD_1 ): case( SQUAD_2 ): case( SQUAD_3 ): diff --git a/Strategic/Assignments.h b/Strategic/Assignments.h index c14c4abb..e15742cd 100644 --- a/Strategic/Assignments.h +++ b/Strategic/Assignments.h @@ -84,6 +84,7 @@ enum FACILITY_DOCTOR, FACILITY_PATIENT, FACILITY_REPAIR, + FORTIFICATION, // Flugente: sectors can be fortified according to external layout plans NUM_ASSIGNMENTS, }; @@ -166,6 +167,8 @@ BOOLEAN CanCharacterDiagnoseDisease( SOLDIERTYPE *pSoldier ); // can this character treat diseases of the population (NOT mercs)? BOOLEAN CanCharacterTreatSectorDisease( SOLDIERTYPE *pSoldier ); +BOOLEAN CanCharacterFortify( SOLDIERTYPE *pSoldier ); + // can this character be assigned as a repairman? BOOLEAN CanCharacterRepair( SOLDIERTYPE *pCharacter ); diff --git a/Strategic/Campaign Types.h b/Strategic/Campaign Types.h index 03f9bec1..5d203fb0 100644 --- a/Strategic/Campaign Types.h +++ b/Strategic/Campaign Types.h @@ -522,10 +522,13 @@ typedef struct SECTORINFO UINT16 usInfected; // how many people (civilians + enemy + militia) are infected in this sector? Does NOT count our mercs FLOAT fInfectionSeverity; // mean infection rate of those infected (percentage) UINT8 usDiseaseDoctoringDelay; // AI doctoring in this sector is delayed due to player interference - UINT8 usInfectionFlag; + UINT8 usInfectionFlag; + // Flugente: fortification + FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector + FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded - INT8 bPadding[ 12 ]; + INT8 bPadding[ 4 ]; }SECTORINFO; @@ -567,7 +570,11 @@ typedef struct UNDERGROUND_SECTORINFO UINT8 ubNumTanks; UINT8 ubTanksInBattle; - INT8 bPadding[26]; + // Flugente: fortification + FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector + FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded + + INT8 bPadding[16]; //no padding left! }UNDERGROUND_SECTORINFO; diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 0a322f03..9e824e2f 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -846,6 +846,9 @@ static int l_AddVolunteers( lua_State *L ); static int l_CreateArmedCivilain( lua_State *L ); +static int l_BuildFortification( lua_State *L ); +static int l_RemoveFortification( lua_State *L ); + static int l_GetFact( lua_State *L ); static int l_SetFact( lua_State *L ); @@ -1703,6 +1706,9 @@ void IniFunction(lua_State *L, BOOLEAN bQuests ) lua_register( L, "AddVolunteers", l_AddVolunteers ); lua_register(L, "CreateArmedCivilain", l_CreateArmedCivilain ); + + lua_register( L, "BuildFortification", l_BuildFortification ); + lua_register( L, "RemoveFortification", l_RemoveFortification ); lua_register(L, "GetFact", l_GetFact ); lua_register(L, "SetFact", l_SetFact ); @@ -2595,6 +2601,8 @@ BOOLEAN LuaHandleQuestCodeOnSector( INT16 sSectorX, INT16 sSectorY, INT8 bSector lua_register(_LS.L(), "CheckForKingpinsMoneyMissing", l_FunctionCheckForKingpinsMoneyMissing); lua_register(_LS.L(), "SetProfileStrategicInsertionData", l_ProfilesStrategicInsertionData ); lua_register(_LS.L(), "CreateArmedCivilain", l_CreateArmedCivilain ); + lua_register(_LS.L(), "BuildFortification", l_BuildFortification ); + lua_register(_LS.L(), "RemoveFortification", l_RemoveFortification ); IniFunction( _LS.L(), TRUE ); IniGlobalGameSetting( _LS.L() ); @@ -13066,6 +13074,35 @@ static int l_CreateArmedCivilain( lua_State *L ) return 0; } +static int l_BuildFortification( lua_State *L ) +{ + if ( lua_gettop( L ) ) + { + INT32 sGridNo = lua_tointeger( L, 1 ); + INT8 sLevel = lua_tointeger( L, 2 ); + UINT8 usIndex = lua_tointeger( L, 3 ); + UINT8 usStructureIndex = lua_tointeger( L, 4 ); + + BuildFortification( sGridNo, sLevel, usIndex, usStructureIndex ); + } + + return 0; +} + +static int l_RemoveFortification( lua_State *L ) +{ + if ( lua_gettop( L ) ) + { + INT32 sGridNo = lua_tointeger( L, 1 ); + INT8 sLevel = lua_tointeger( L, 2 ); + UINT8 usStructureIndex = lua_tointeger( L, 3 ); + + RemoveFortification( sGridNo, sLevel, usStructureIndex ); + } + + return 0; +} + static int l_GetFact( lua_State *L ) { UINT8 val = 0; diff --git a/Strategic/Map Screen Interface.h b/Strategic/Map Screen Interface.h index fba03a02..9bdaae7a 100644 --- a/Strategic/Map Screen Interface.h +++ b/Strategic/Map Screen Interface.h @@ -130,6 +130,7 @@ enum { ASSIGN_MENU_SNITCH, ASSIGN_MENU_TRAIN, ASSIGN_MENU_MOVE_ITEMS, // added by Flugente + ASSIGN_MENU_FORTIFY, // added by Flugente ASSIGN_MENU_FACILITY, // HEAROCK HAM 3.6: Facility List menu ASSIGN_MENU_CANCEL, MAX_ASSIGN_STRING_COUNT, diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index d4836b36..850c2fb8 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -1,109 +1,109 @@ #include "builddefines.h" #ifdef PRECOMPILEDHEADERS - #include "Strategic All.h" - #include "Loading Screen.h" - #include "Enemy Soldier Save.h" - #include "points.h" +#include "Strategic All.h" +#include "Loading Screen.h" +#include "Enemy Soldier Save.h" +#include "points.h" #else - #include "strategicmap.h" - #include "strategic.h" - #include "Strategic Mines.h" - #include "types.h" - #include "memory.h" - #include - #include - #include - #include - #include "jascreens.h" - #include "worlddef.h" - #include "Soldier Control.h" - #include "overhead.h" - #include "interface panels.h" - #include "isometric utils.h" - #include "Ambient Control.h" - #include "worlddef.h" - #include "worlddat.h" - #include "text.h" - #include "Soldier add.h" - #include "soldier macros.h" - #include "Strategic Pathing.h" - #include "soldier create.h" - #include "handle UI.h" - #include "faces.h" - #include "renderworld.h" - #include "gamescreen.h" - #include "game clock.h" - #include "Soldier Init List.h" - #include "strategic turns.h" - #include "merc entering.h" - #include "Map Information.h" - #include "Assignments.h" - #include "message.h" - #include "Font Control.h" - #include "environment.h" - #include "Game Events.h" - #include "quests.h" - #include "FileMan.h" - #include "animated progressbar.h" - #include "music control.h" - #include "fade screen.h" - #include "Strategic Movement.h" - #include "Campaign Types.h" - #include "sys globals.h" - #include "Exit Grids.h" - #include "Tactical Save.h" - #include "pathai.h" - #include "animation control.h" - #include "squads.h" - #include "worldman.h" - #include "Overhead.h" - #include "Strategic Town Loyalty.h" - #include "Queen Command.h" - #include "cursor control.h" - #include "PreBattle Interface.h" - #include "Shade Table Util.h" - #include "Scheduling.h" - #include "gameloop.h" - #include "Random.h" - #include "ai.h" - #include "opplist.h" - #include "keys.h" - #include "Tactical Placement GUI.h" - #include "Map Screen Helicopter.h" - #include "map edgepoints.h" - #include "Player Command.h" - #include "Event Pump.h" - #include "meanwhile.h" - #include "air raid.h" - #include "Strategic Mines.h" - #include "Creature Spreading.h" - #include "SaveLoadMap.h" - #include "Militia Control.h" - #include "gamesettings.h" - #include "dialogue control.h" - #include "Town Militia.h" - #include "sysutil.h" - #include "Sound Control.h" - #include "points.h" - #include "render dirty.h" - #include "Debug Control.h" - #include "expat.h" - #include "Loading Screen.h" - #include "Queen Command.h" - #include "Enemy Soldier Save.h" - #include "NPC.h" - #include "Strategic Event Handler.h" - #include "MessageBoxScreen.h" - #include "interface dialogue.h" - #include "Map Screen Interface.h" - #include "history.h" - #include "Bullets.h" - #include "physics.h" - #include "Explosion Control.h" - #include "Auto Resolve.h" - #include "cursors.h" - #include "GameVersion.h" +#include "strategicmap.h" +#include "strategic.h" +#include "Strategic Mines.h" +#include "types.h" +#include "memory.h" +#include +#include +#include +#include +#include "jascreens.h" +#include "worlddef.h" +#include "Soldier Control.h" +#include "overhead.h" +#include "interface panels.h" +#include "isometric utils.h" +#include "Ambient Control.h" +#include "worlddef.h" +#include "worlddat.h" +#include "text.h" +#include "Soldier add.h" +#include "soldier macros.h" +#include "Strategic Pathing.h" +#include "soldier create.h" +#include "handle UI.h" +#include "faces.h" +#include "renderworld.h" +#include "gamescreen.h" +#include "game clock.h" +#include "Soldier Init List.h" +#include "strategic turns.h" +#include "merc entering.h" +#include "Map Information.h" +#include "Assignments.h" +#include "message.h" +#include "Font Control.h" +#include "environment.h" +#include "Game Events.h" +#include "quests.h" +#include "FileMan.h" +#include "animated progressbar.h" +#include "music control.h" +#include "fade screen.h" +#include "Strategic Movement.h" +#include "Campaign Types.h" +#include "sys globals.h" +#include "Exit Grids.h" +#include "Tactical Save.h" +#include "pathai.h" +#include "animation control.h" +#include "squads.h" +#include "worldman.h" +#include "Overhead.h" +#include "Strategic Town Loyalty.h" +#include "Queen Command.h" +#include "cursor control.h" +#include "PreBattle Interface.h" +#include "Shade Table Util.h" +#include "Scheduling.h" +#include "gameloop.h" +#include "Random.h" +#include "ai.h" +#include "opplist.h" +#include "keys.h" +#include "Tactical Placement GUI.h" +#include "Map Screen Helicopter.h" +#include "map edgepoints.h" +#include "Player Command.h" +#include "Event Pump.h" +#include "meanwhile.h" +#include "air raid.h" +#include "Strategic Mines.h" +#include "Creature Spreading.h" +#include "SaveLoadMap.h" +#include "Militia Control.h" +#include "gamesettings.h" +#include "dialogue control.h" +#include "Town Militia.h" +#include "sysutil.h" +#include "Sound Control.h" +#include "points.h" +#include "render dirty.h" +#include "Debug Control.h" +#include "expat.h" +#include "Loading Screen.h" +#include "Queen Command.h" +#include "Enemy Soldier Save.h" +#include "NPC.h" +#include "Strategic Event Handler.h" +#include "MessageBoxScreen.h" +#include "interface dialogue.h" +#include "Map Screen Interface.h" +#include "history.h" +#include "Bullets.h" +#include "physics.h" +#include "Explosion Control.h" +#include "Auto Resolve.h" +#include "cursors.h" +#include "GameVersion.h" #endif #include "LuaInitNPCs.h" @@ -168,7 +168,7 @@ extern BOOLEAN gfUndergroundTacticalTraversal; //extern MINE_STATUS_TYPE gMineStatus[MAX_NUMBER_OF_MINES]; -extern void CalculateNonPersistantPBIInfo(); +extern void CalculateNonPersistantPBIInfo( ); extern void MapScreenDefaultOkBoxCallback( UINT8 bExitValue ); @@ -209,27 +209,27 @@ BOOLEAN fFoundOrta = FALSE; UINT8 NUMBER_OF_SAMS; // have any of the sam sites been found (actual values, saved to savegames) -BOOLEAN fSamSiteFound[ MAX_NUMBER_OF_SAMS ]; +BOOLEAN fSamSiteFound[MAX_NUMBER_OF_SAMS]; // original of previous for proper initialization of a new game -BOOLEAN fSamSiteFoundOrig[ MAX_NUMBER_OF_SAMS ]; +BOOLEAN fSamSiteFoundOrig[MAX_NUMBER_OF_SAMS]; // sectors with sam sites -INT16 pSamList[ MAX_NUMBER_OF_SAMS ]; +INT16 pSamList[MAX_NUMBER_OF_SAMS]; // girdno's of control terminal of sam site -INT32 pSamGridNoAList[ MAX_NUMBER_OF_SAMS ]; -INT32 pSamGridNoBList[ MAX_NUMBER_OF_SAMS ]; +INT32 pSamGridNoAList[MAX_NUMBER_OF_SAMS]; +INT32 pSamGridNoBList[MAX_NUMBER_OF_SAMS]; // coordinates X,Y of sam sites on strategic map -INT16 gpSamSectorX[ MAX_NUMBER_OF_SAMS ]; -INT16 gpSamSectorY[ MAX_NUMBER_OF_SAMS ]; +INT16 gpSamSectorX[MAX_NUMBER_OF_SAMS]; +INT16 gpSamSectorY[MAX_NUMBER_OF_SAMS]; // ATE: Update this w/ graphic used // Use 3 if / orientation, 4 if \ orientation -INT8 gbSAMGraphicList[ MAX_NUMBER_OF_SAMS ]; +INT8 gbSAMGraphicList[MAX_NUMBER_OF_SAMS]; -INT8 gbMercIsNewInThisSector[ MAX_NUM_SOLDIERS ]; +INT8 gbMercIsNewInThisSector[MAX_NUM_SOLDIERS]; // the amount of time that a soldier will wait to return to desired/old squad @@ -238,7 +238,7 @@ INT8 gbMercIsNewInThisSector[ MAX_NUM_SOLDIERS ]; BOOLEAN localizedMapTextOnly; -UINT8 ubSAMControlledSectors[ MAP_WORLD_Y ][ MAP_WORLD_X ];// = { +UINT8 ubSAMControlledSectors[MAP_WORLD_Y][MAP_WORLD_X];// = { // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // @@ -263,8 +263,8 @@ UINT8 ubSAMControlledSectors[ MAP_WORLD_Y ][ MAP_WORLD_X ];// = { //}; INT16 DirXIncrementer[8] = - { - 0, //N +{ + 0, //N 1, //NE 1, //E 1, //SE @@ -272,11 +272,11 @@ INT16 DirXIncrementer[8] = -1, //SW -1, //W -1 //NW - }; +}; INT16 DirYIncrementer[8] = - { - -1, //N +{ + -1, //N -1, //NE 0, //E 1, //SE @@ -284,50 +284,50 @@ INT16 DirYIncrementer[8] = 1, //SW 0, //W -1 //NW - }; - - -STR8 pVertStrings[]={ -"X", -"A", -"B", -"C", -"D", -"E", -"F", -"G", -"H", -"I", -"J", -"K", -"L", -"M", -"N", -"O", -"P", -"Q", -"R", }; -STR8 pHortStrings[]={ -"X", -"1", -"2", -"3", -"4", -"5", -"6", -"7", -"8", -"9", -"10", -"11", -"12", -"13", -"14", -"15", -"16", -"17", + +STR8 pVertStrings[] = { + "X", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", +}; + +STR8 pHortStrings[] = { + "X", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", }; // HEADROCK HAM 3.6: Array to hold user-defined sector names @@ -338,7 +338,7 @@ CHAR16 gzSectorNames[256][4][MAX_SECTOR_NAME_LENGTH]; //CHAR16 gzSectorUndergroundNames2[256][4][MAX_SECTOR_NAME_LENGTH]; //CHAR16 gzSectorUndergroundNames3[256][4][MAX_SECTOR_NAME_LENGTH]; -BOOLEAN ReadInStrategicMapSectorTownNames(STR fileName, BOOLEAN localizedVersion); +BOOLEAN ReadInStrategicMapSectorTownNames( STR fileName, BOOLEAN localizedVersion ); void DoneFadeOutAdjacentSector( void ); void DoneFadeOutExitGridSector( void ); @@ -353,70 +353,70 @@ void HandleQuestCodeOnSectorExit( INT16 sOldSectorX, INT16 sOldSectorY, INT8 bOl void HandlePotentialMoraleHitForSkimmingSectors( GROUP *pGroup ); void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); void ShouldNpcBeAddedToSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ); -void HandlePlayerQuotesWhenEnteringFirstTunnelSector(); -void AddExitGridForFanToPowerGenSector(); +void HandlePlayerQuotesWhenEnteringFirstTunnelSector( ); +void AddExitGridForFanToPowerGenSector( ); void HandleSectorSpecificUnLoadingOfMap( INT16 sMapX, INT16 sMapY, INT8 bMapZ ); //void MakeAllTeamMembersCrouchedThenStand(); -void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap(); -void HandleFortifiedDoor(); +void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap( ); +void HandleFortifiedDoor( ); void CreateAndAddMoneyObjectToGround( UINT32 sGridNo, INT32 iEasyAmount, INT32 iNormalAmount, INT32 iHardAmount ); void HandleGoingUpOrDownStairsForLoadScreensPurposes( INT16 sCurrentlyInSectorZ, INT16 sGoingToSectorZ ); -void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap(); -void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap(); -void HandleFirstPartOfTunnelFanSound(); -void HandlePowerGenFanSoundModification(); +void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap( ); +void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap( ); +void HandleFirstPartOfTunnelFanSound( ); +void HandlePowerGenFanSoundModification( ); BOOLEAN MoveEnemyFromGridNoToRoofGridNo( UINT32 sSourceGridNo, UINT32 sDestGridNo ); -void HandleMovingEnemiesOntoRoofs(); +void HandleMovingEnemiesOntoRoofs( ); #endif void HandleQuestCodeOnSectorExit( INT16 sOldSectorX, INT16 sOldSectorY, INT8 bOldSectorZ ); void HandlePotentialMoraleHitForSkimmingSectors( GROUP *pGroup ); -extern void InitializeTacticalStatusAtBattleStart(); +extern void InitializeTacticalStatusAtBattleStart( ); extern HVSURFACE ghFrameBuffer; extern BOOLEAN gfOverrideSector; -extern BOOLEAN sBadSectorsList[ WORLD_MAP_X ][ WORLD_MAP_X ]; +extern BOOLEAN sBadSectorsList[WORLD_MAP_X][WORLD_MAP_X]; extern STR16 pBullseyeStrings[]; extern void HandleRPCDescription( ); #ifdef CRIPPLED_VERSION void CrippledVersionFailureToLoadMapCallBack( UINT8 bExitValue ); -void CrippledVersionFailureToLoadMapCheck(); +void CrippledVersionFailureToLoadMapCheck( ); #endif //temp timer stuff -- to measure the time it takes to load a map. #ifdef JA2TESTVERSION - extern INT16 gsAINumAdmins; - extern INT16 gsAINumTroops; - extern INT16 gsAINumElites; - extern INT16 gsAINumTanks; - extern INT16 gsAINumCreatures; - //The wrapper time for EnterSector - BOOLEAN fStartNewFile = TRUE; - UINT32 uiEnterSectorStartTime; - UINT32 uiEnterSectorEndTime; - //The grand total time for loading a map - UINT32 uiLoadWorldStartTime; - UINT32 uiLoadWorldEndTime; - //The time spent in FileRead - UINT32 uiTotalFileReadTime; - UINT32 uiTotalFileReadCalls; - //LoadWorld and parts - UINT32 uiLoadWorldTime; - UINT32 uiTrashWorldTime; - UINT32 uiLoadMapTilesetTime; - UINT32 uiLoadMapLightsTime; - UINT32 uiBuildShadeTableTime; - UINT32 uiNumTablesSaved; - UINT32 uiNumTablesLoaded; - UINT32 uiNumImagesReloaded; - #include "render dirty.h" - #include "tiledat.h" +extern INT16 gsAINumAdmins; +extern INT16 gsAINumTroops; +extern INT16 gsAINumElites; +extern INT16 gsAINumTanks; +extern INT16 gsAINumCreatures; +//The wrapper time for EnterSector +BOOLEAN fStartNewFile = TRUE; +UINT32 uiEnterSectorStartTime; +UINT32 uiEnterSectorEndTime; +//The grand total time for loading a map +UINT32 uiLoadWorldStartTime; +UINT32 uiLoadWorldEndTime; +//The time spent in FileRead +UINT32 uiTotalFileReadTime; +UINT32 uiTotalFileReadCalls; +//LoadWorld and parts +UINT32 uiLoadWorldTime; +UINT32 uiTrashWorldTime; +UINT32 uiLoadMapTilesetTime; +UINT32 uiLoadMapLightsTime; +UINT32 uiBuildShadeTableTime; +UINT32 uiNumTablesSaved; +UINT32 uiNumTablesLoaded; +UINT32 uiNumImagesReloaded; +#include "render dirty.h" +#include "tiledat.h" #endif // SAM externalization stuff @@ -458,7 +458,7 @@ typedef struct { SAMSITE_PARSE_STAGE curElement; - CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1]; + CHAR8 szCharData[MAX_CHAR_DATA_LENGTH + 1]; samInfo curSamInfo; UINT32 uiRowNumber; UINT32 uiHighestIndex; @@ -468,53 +468,53 @@ typedef struct } samsiteParseData; static void XMLCALL -samsiteStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts) +samsiteStartElementHandle( void *userData, const XML_Char *name, const XML_Char **atts ) { - samsiteParseData * pData = (samsiteParseData *) userData; + samsiteParseData * pData = (samsiteParseData *)userData; - if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element? + if ( pData->currentDepth <= pData->maxReadDepth ) //are we reading this element? { - if(strcmp(name, "SAM_INFO") == 0 && pData->curElement == SAMSITE_ELEMENT_NONE) + if ( strcmp( name, "SAM_INFO" ) == 0 && pData->curElement == SAMSITE_ELEMENT_NONE ) { pData->curElement = SAMSITE_ELEMENT_SAMINFO; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "SAM_CONTROLLED_SECTORS") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO) + else if ( strcmp( name, "SAM_CONTROLLED_SECTORS" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO ) { pData->curElement = SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "MAP_ROW") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS) + else if ( strcmp( name, "MAP_ROW" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS ) { UINT32 uiAttrIndex; pData->curElement = SAMSITE_ELEMENT_MAP_ROW; - for(uiAttrIndex = 0;atts[uiAttrIndex] != NULL;uiAttrIndex += 2) - if(strcmp(atts[uiAttrIndex], "row") == 0) - { - pData->uiRowNumber = atol(atts[uiAttrIndex+1]); - break; - } + for ( uiAttrIndex = 0; atts[uiAttrIndex] != NULL; uiAttrIndex += 2 ) + if ( strcmp( atts[uiAttrIndex], "row" ) == 0 ) + { + pData->uiRowNumber = atol( atts[uiAttrIndex + 1] ); + break; + } - if(atts[uiAttrIndex] != NULL && pData->uiRowNumber < MAP_WORLD_Y) + if ( atts[uiAttrIndex] != NULL && pData->uiRowNumber < MAP_WORLD_Y ) pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "SAMLIST") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO) + else if ( strcmp( name, "SAMLIST" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO ) { pData->curElement = SAMSITE_ELEMENT_SAMLIST; - memset( fSamSiteFoundOrig, 0, sizeof(fSamSiteFoundOrig) ); - memset( pSamList, 0, sizeof(pSamList) ); - memset( pSamGridNoAList, 0, sizeof(pSamGridNoAList) ); - memset( pSamGridNoBList, 0, sizeof(pSamGridNoBList) ); - memset( gbSAMGraphicList, 0, sizeof(gbSAMGraphicList) ); - memset( gpSamSectorX, 0, sizeof(gpSamSectorX) ); - memset( gpSamSectorY, 0, sizeof(gpSamSectorY) ); + memset( fSamSiteFoundOrig, 0, sizeof(fSamSiteFoundOrig) ); + memset( pSamList, 0, sizeof(pSamList) ); + memset( pSamGridNoAList, 0, sizeof(pSamGridNoAList) ); + memset( pSamGridNoBList, 0, sizeof(pSamGridNoBList) ); + memset( gbSAMGraphicList, 0, sizeof(gbSAMGraphicList) ); + memset( gpSamSectorX, 0, sizeof(gpSamSectorX) ); + memset( gpSamSectorY, 0, sizeof(gpSamSectorY) ); pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "SAM") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMLIST) + else if ( strcmp( name, "SAM" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMLIST ) { pData->curElement = SAMSITE_ELEMENT_SAM; @@ -522,42 +522,42 @@ samsiteStartElementHandle(void *userData, const XML_Char *name, const XML_Char * pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samIndex") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samIndex" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_INDEX; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samSector") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samSector" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAMSECTOR; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "x") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR ) { pData->curElement = SAMSITE_ELEMENT_SAMSECTOR_X; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "y") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR ) { pData->curElement = SAMSITE_ELEMENT_SAMSECTOR_Y; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samHidden") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samHidden" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAM_HIDDEN; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samOrientation") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samOrientation" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAM_ORIENTATION; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samGridNoA") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samGridNoA" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAM_GRIDNO_A; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "samGridNoB") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "samGridNoB" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAM_GRIDNO_B; pData->maxReadDepth++; //we are not skipping this element @@ -570,76 +570,76 @@ samsiteStartElementHandle(void *userData, const XML_Char *name, const XML_Char * } static void XMLCALL -samsiteCharacterDataHandle(void *userData, const XML_Char *str, int len) +samsiteCharacterDataHandle( void *userData, const XML_Char *str, int len ) { - samsiteParseData * pData = (samsiteParseData *) userData; + samsiteParseData * pData = (samsiteParseData *)userData; - if(pData->currentDepth <= pData->maxReadDepth && strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH) - strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData))); + if ( pData->currentDepth <= pData->maxReadDepth && strlen( pData->szCharData ) < MAX_CHAR_DATA_LENGTH ) + strncat( pData->szCharData, str, __min( (unsigned int)len, MAX_CHAR_DATA_LENGTH - strlen( pData->szCharData ) ) ); } static void XMLCALL -samsiteEndElementHandle(void *userData, const XML_Char *name) +samsiteEndElementHandle( void *userData, const XML_Char *name ) { - samsiteParseData * pData = (samsiteParseData *) userData; + samsiteParseData * pData = (samsiteParseData *)userData; - if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading + if ( pData->currentDepth <= pData->maxReadDepth ) //we're at the end of an element that we've been reading { - if(strcmp(name, "SAM_INFO") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO) + if ( strcmp( name, "SAM_INFO" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMINFO ) { pData->curElement = SAMSITE_ELEMENT_NONE; } - else if(strcmp(name, "SAM_CONTROLLED_SECTORS") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS) + else if ( strcmp( name, "SAM_CONTROLLED_SECTORS" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS ) { pData->curElement = SAMSITE_ELEMENT_SAMINFO; } - else if(strcmp(name, "MAP_ROW") == 0 && pData->curElement == SAMSITE_ELEMENT_MAP_ROW) + else if ( strcmp( name, "MAP_ROW" ) == 0 && pData->curElement == SAMSITE_ELEMENT_MAP_ROW ) { - STR8 curBuffer = pData->szCharData + strspn(pData->szCharData," \t\n\r"); + STR8 curBuffer = pData->szCharData + strspn( pData->szCharData, " \t\n\r" ); UINT32 curCellIndex = 0; UINT32 curNumber; pData->curElement = SAMSITE_ELEMENT_SAM_CONTROLLED_SECTORS; - while(curBuffer[0] != '\0') + while ( curBuffer[0] != '\0' ) { - sscanf( curBuffer,"%d",&curNumber); + sscanf( curBuffer, "%d", &curNumber ); ubSAMControlledSectors[pData->uiRowNumber][curCellIndex] = curNumber; curCellIndex++; - curBuffer += strcspn(curBuffer," \t\n\r\0"); - curBuffer += strspn(curBuffer," \t\n\r"); + curBuffer += strcspn( curBuffer, " \t\n\r\0" ); + curBuffer += strspn( curBuffer, " \t\n\r" ); } } - else if(strcmp(name, "SAMLIST") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMLIST) + else if ( strcmp( name, "SAMLIST" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMLIST ) { pData->curElement = SAMSITE_ELEMENT_SAMINFO; NUMBER_OF_SAMS = pData->uiHighestIndex; } - else if(strcmp(name, "SAM") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM) + else if ( strcmp( name, "SAM" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM ) { pData->curElement = SAMSITE_ELEMENT_SAMLIST; if ( pData->curSamInfo.uiIndex != INVALID_SAMSITE_INDEX ) { pData->curSamInfo.uiIndex--; - fSamSiteFoundOrig[ pData->curSamInfo.uiIndex ] = !pData->curSamInfo.samHidden; - gpSamSectorX [ pData->curSamInfo.uiIndex ] = pData->curSamInfo.samSectorX; - gpSamSectorY [ pData->curSamInfo.uiIndex ] = pData->curSamInfo.samSectorY; - pSamList [ pData->curSamInfo.uiIndex ] = SECTOR(pData->curSamInfo.samSectorX,pData->curSamInfo.samSectorY); - gbSAMGraphicList [ pData->curSamInfo.uiIndex ] = pData->curSamInfo.samOrientation; - pSamGridNoAList [ pData->curSamInfo.uiIndex ] = pData->curSamInfo.samGridNoA; - pSamGridNoBList [ pData->curSamInfo.uiIndex ] = pData->curSamInfo.samGridNoB; + fSamSiteFoundOrig[pData->curSamInfo.uiIndex] = !pData->curSamInfo.samHidden; + gpSamSectorX[pData->curSamInfo.uiIndex] = pData->curSamInfo.samSectorX; + gpSamSectorY[pData->curSamInfo.uiIndex] = pData->curSamInfo.samSectorY; + pSamList[pData->curSamInfo.uiIndex] = SECTOR( pData->curSamInfo.samSectorX, pData->curSamInfo.samSectorY ); + gbSAMGraphicList[pData->curSamInfo.uiIndex] = pData->curSamInfo.samOrientation; + pSamGridNoAList[pData->curSamInfo.uiIndex] = pData->curSamInfo.samGridNoA; + pSamGridNoBList[pData->curSamInfo.uiIndex] = pData->curSamInfo.samGridNoB; } } - else if(strcmp(name, "samIndex") == 0 && pData->curElement == SAMSITE_ELEMENT_INDEX) + else if ( strcmp( name, "samIndex" ) == 0 && pData->curElement == SAMSITE_ELEMENT_INDEX ) { pData->curElement = SAMSITE_ELEMENT_SAM; - pData->curSamInfo.uiIndex = atol(pData->szCharData); + pData->curSamInfo.uiIndex = atol( pData->szCharData ); if ( !pData->curSamInfo.uiIndex || pData->curSamInfo.uiIndex > MAX_NUMBER_OF_SAMS ) { pData->curSamInfo.uiIndex = INVALID_SAMSITE_INDEX; @@ -649,53 +649,53 @@ samsiteEndElementHandle(void *userData, const XML_Char *name) pData->uiHighestIndex = pData->curSamInfo.uiIndex; } } - else if(strcmp(name, "samSector") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR) + else if ( strcmp( name, "samSector" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR ) { pData->curElement = SAMSITE_ELEMENT_SAM; } - else if(strcmp(name, "x") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR_X) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR_X ) { pData->curElement = SAMSITE_ELEMENT_SAMSECTOR; - pData->curSamInfo.samSectorX = (INT16) atol(pData->szCharData); + pData->curSamInfo.samSectorX = (INT16)atol( pData->szCharData ); } - else if(strcmp(name, "y") == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR_Y) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAMSECTOR_Y ) { pData->curElement = SAMSITE_ELEMENT_SAMSECTOR; - pData->curSamInfo.samSectorY = (INT16) atol(pData->szCharData); + pData->curSamInfo.samSectorY = (INT16)atol( pData->szCharData ); } - else if(strcmp(name, "samHidden") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_HIDDEN ) + else if ( strcmp( name, "samHidden" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_HIDDEN ) { pData->curElement = SAMSITE_ELEMENT_SAM; - pData->curSamInfo.samHidden = (BOOLEAN)atol(pData->szCharData); + pData->curSamInfo.samHidden = (BOOLEAN)atol( pData->szCharData ); } - else if(strcmp(name, "samOrientation") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_ORIENTATION ) + else if ( strcmp( name, "samOrientation" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_ORIENTATION ) { pData->curElement = SAMSITE_ELEMENT_SAM; - pData->curSamInfo.samOrientation = (INT8)atol(pData->szCharData); + pData->curSamInfo.samOrientation = (INT8)atol( pData->szCharData ); if ( pData->curSamInfo.samOrientation != 3 || pData->curSamInfo.samOrientation != 4 ) { pData->curSamInfo.samOrientation = 3; } } - else if(strcmp(name, "samGridNoA") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_GRIDNO_A ) + else if ( strcmp( name, "samGridNoA" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_GRIDNO_A ) { pData->curElement = SAMSITE_ELEMENT_SAM; - pData->curSamInfo.samGridNoA = atol(pData->szCharData); + pData->curSamInfo.samGridNoA = atol( pData->szCharData ); if ( pData->curSamInfo.samGridNoA >= MAX_ALLOWED_WORLD_MAX ) { pData->curSamInfo.samGridNoA = 0; } } - else if(strcmp(name, "samGridNoB") == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_GRIDNO_B ) + else if ( strcmp( name, "samGridNoB" ) == 0 && pData->curElement == SAMSITE_ELEMENT_SAM_GRIDNO_B ) { pData->curElement = SAMSITE_ELEMENT_SAM; - pData->curSamInfo.samGridNoB = atol(pData->szCharData); + pData->curSamInfo.samGridNoB = atol( pData->szCharData ); if ( pData->curSamInfo.samGridNoB >= MAX_ALLOWED_WORLD_MAX ) { pData->curSamInfo.samGridNoB = 1; @@ -707,13 +707,13 @@ samsiteEndElementHandle(void *userData, const XML_Char *name) pData->currentDepth--; } -BOOLEAN ReadInSAMInfo(STR fileName) +BOOLEAN ReadInSAMInfo( STR fileName ) { HWFILE hFile; UINT32 uiBytesRead; UINT32 uiFSize; CHAR8 * lpcBuffer; - XML_Parser parser = XML_ParserCreate(NULL); + XML_Parser parser = XML_ParserCreate( NULL ); samsiteParseData pData; @@ -722,16 +722,16 @@ BOOLEAN ReadInSAMInfo(STR fileName) // Open weapons file hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE ); if ( !hFile ) - return( FALSE ); + return(FALSE); - uiFSize = FileGetSize(hFile); - lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1); + uiFSize = FileGetSize( hFile ); + lpcBuffer = (CHAR8 *)MemAlloc( uiFSize + 1 ); //Read in block if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) ) { - MemFree(lpcBuffer); - return( FALSE ); + MemFree( lpcBuffer ); + return(FALSE); } lpcBuffer[uiFSize] = 0; //add a null terminator @@ -739,87 +739,87 @@ BOOLEAN ReadInSAMInfo(STR fileName) FileClose( hFile ); - XML_SetElementHandler(parser, samsiteStartElementHandle, samsiteEndElementHandle); - XML_SetCharacterDataHandler(parser, samsiteCharacterDataHandle); + XML_SetElementHandler( parser, samsiteStartElementHandle, samsiteEndElementHandle ); + XML_SetCharacterDataHandler( parser, samsiteCharacterDataHandle ); - memset(&pData,0,sizeof(pData)); + memset( &pData, 0, sizeof(pData) ); NUMBER_OF_SAMS = 0; - XML_SetUserData(parser, &pData); + XML_SetUserData( parser, &pData ); - if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) + if ( !XML_Parse( parser, lpcBuffer, uiFSize, TRUE ) ) { CHAR8 errorBuf[511]; - sprintf(errorBuf, "XML Parser Error in SamSites.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); - LiveMessage(errorBuf); + sprintf( errorBuf, "XML Parser Error in SamSites.xml: %s at line %d", XML_ErrorString( XML_GetErrorCode( parser ) ), XML_GetCurrentLineNumber( parser ) ); + LiveMessage( errorBuf ); - MemFree(lpcBuffer); + MemFree( lpcBuffer ); return FALSE; } - MemFree(lpcBuffer); + MemFree( lpcBuffer ); - XML_ParserFree(parser); + XML_ParserFree( parser ); return TRUE; } -BOOLEAN WriteInSAMInfo(STR fileName) +BOOLEAN WriteInSAMInfo( STR fileName ) { HWFILE hFile; hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) - return( FALSE ); + return(FALSE); { UINT32 x, y; INT8 cnt; - FilePrintf(hFile,"\r\n"); - FilePrintf(hFile,"\t\r\n"); - for(cnt = 0; cnt < NUMBER_OF_SAMS; cnt++) + FilePrintf( hFile, "\r\n" ); + FilePrintf( hFile, "\t\r\n" ); + for ( cnt = 0; cnt < NUMBER_OF_SAMS; cnt++ ) { - FilePrintf(hFile,"\t\t\r\n"); + FilePrintf( hFile, "\t\t\r\n" ); - FilePrintf(hFile,"\t\t\t%d\r\n",cnt+1); + FilePrintf( hFile, "\t\t\t%d\r\n", cnt + 1 ); - FilePrintf(hFile,"\t\t\t\r\n"); - FilePrintf(hFile,"\t\t\t\t%d\r\n",(pSamList[cnt]%16)+1); - FilePrintf(hFile,"\t\t\t\t%d\r\n",(pSamList[cnt]/16)+1); - FilePrintf(hFile,"\t\t\t\r\n"); + FilePrintf( hFile, "\t\t\t\r\n" ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", (pSamList[cnt] % 16) + 1 ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", (pSamList[cnt] / 16) + 1 ); + FilePrintf( hFile, "\t\t\t\r\n" ); - FilePrintf(hFile,"\t\t\t%d\r\n", !fSamSiteFound[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", !fSamSiteFound[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", gbSAMGraphicList[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", gbSAMGraphicList[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", pSamGridNoAList[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", pSamGridNoAList[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", pSamGridNoBList[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", pSamGridNoBList[cnt] ); - FilePrintf(hFile,"\t\t\r\n"); + FilePrintf( hFile, "\t\t\r\n" ); } - FilePrintf(hFile,"\t\r\n"); + FilePrintf( hFile, "\t\r\n" ); - FilePrintf(hFile,"\t\r\n"); - for(y = 0;y < MAP_WORLD_Y;y++) + FilePrintf( hFile, "\t\r\n" ); + for ( y = 0; y < MAP_WORLD_Y; y++ ) { - FilePrintf(hFile,"\t\t",y); - for(x = 0;x < MAP_WORLD_X;x++) + FilePrintf( hFile, "\t\t", y ); + for ( x = 0; x < MAP_WORLD_X; x++ ) { - if(x < MAP_WORLD_X-1) + if ( x < MAP_WORLD_X - 1 ) { - FilePrintf(hFile,"%2d ",ubSAMControlledSectors[y][x]); + FilePrintf( hFile, "%2d ", ubSAMControlledSectors[y][x] ); } else - FilePrintf(hFile,"%2d \r\n",ubSAMControlledSectors[y][x]); + FilePrintf( hFile, "%2d \r\n", ubSAMControlledSectors[y][x] ); } } - FilePrintf(hFile,"\t\r\n"); - FilePrintf(hFile,"\r\n"); + FilePrintf( hFile, "\t\r\n" ); + FilePrintf( hFile, "\r\n" ); } FileClose( hFile ); @@ -830,15 +830,15 @@ BOOLEAN WriteInSAMInfo(STR fileName) // town externalization stuff INT8 NUM_TOWNS; -extern UINT8 gubTownRebelSentiment [ MAX_TOWNS ]; -extern BOOLEAN gfTownUsesLoyalty [ MAX_TOWNS ]; -extern BOOLEAN gfMilitiaAllowedInTown [ MAX_TOWNS ]; -BOOLEAN gfHiddenTown [ MAX_TOWNS ]; // Info: Visible town are TRUE, hidden towns are FALSE -BOOLEAN gfDrawHiddenTown [ MAX_TOWNS ]; -BOOLEAN gfDrawHiddenTownTemp [ MAX_TOWNS ]; -BOOLEAN gfHiddenTownTemp [ MAX_TOWNS ]; -BOOLEAN gfIconTown [ MAX_TOWNS ]; -BOOLEAN gfIconTownTemp [ MAX_TOWNS ]; +extern UINT8 gubTownRebelSentiment[MAX_TOWNS]; +extern BOOLEAN gfTownUsesLoyalty[MAX_TOWNS]; +extern BOOLEAN gfMilitiaAllowedInTown[MAX_TOWNS]; +BOOLEAN gfHiddenTown[MAX_TOWNS]; // Info: Visible town are TRUE, hidden towns are FALSE +BOOLEAN gfDrawHiddenTown[MAX_TOWNS]; +BOOLEAN gfDrawHiddenTownTemp[MAX_TOWNS]; +BOOLEAN gfHiddenTownTemp[MAX_TOWNS]; +BOOLEAN gfIconTown[MAX_TOWNS]; +BOOLEAN gfIconTownTemp[MAX_TOWNS]; #define INVALID_TOWN_INDEX -1 @@ -870,7 +870,7 @@ typedef enum CITYTABLE_ELEMENT_COUNTRYINFO, CITYTABLE_ELEMENT_COUNTRYNAME, CITYTABLE_ELEMENT_COUNTRYNOUN - + } CITYTABLE_PARSE_STAGE; typedef struct @@ -894,11 +894,11 @@ typedef struct { CITYTABLE_PARSE_STAGE curElement; - CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1]; + CHAR8 szCharData[MAX_CHAR_DATA_LENGTH + 1]; CHAR8 countryName[MAX_TOWN_NAME_LENGHT]; CHAR8 countryNoun[MAX_TOWN_NAME_LENGHT]; cityInfo curCityInfo; - + //cityInfo * curArray; // ROMAN: added //UINT32 maxArraySize; // ROMAN: added @@ -910,180 +910,180 @@ typedef struct } citytableParseData; static void XMLCALL -citytableStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts) +citytableStartElementHandle( void *userData, const XML_Char *name, const XML_Char **atts ) { - citytableParseData * pData = (citytableParseData *) userData; + citytableParseData * pData = (citytableParseData *)userData; - memset( pData->szCharData, 0, sizeof( pData->szCharData) ); + memset( pData->szCharData, 0, sizeof(pData->szCharData) ); - if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element? + if ( pData->currentDepth <= pData->maxReadDepth ) //are we reading this element? { - if(strcmp(name, "CITY_INFO") == 0 && pData->curElement == CITYTABLE_ELEMENT_NONE) + if ( strcmp( name, "CITY_INFO" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_NONE ) { pData->curElement = CITYTABLE_ELEMENT_CITYINFO; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "CITY_TABLE") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO) + else if ( strcmp( name, "CITY_TABLE" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO ) { pData->curElement = CITYTABLE_ELEMENT_CITYTABLE; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "CITY_TABLE_ROW") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLE) + else if ( strcmp( name, "CITY_TABLE_ROW" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLE ) { UINT32 uiAttrIndex; pData->curElement = CITYTABLE_ELEMENT_CITYTABLEROW; - for(uiAttrIndex = 0;atts[uiAttrIndex] != NULL;uiAttrIndex += 2) - if(strcmp(atts[uiAttrIndex], "row") == 0) - { - pData->uiRowNumber = atol(atts[uiAttrIndex+1]); - break; - } + for ( uiAttrIndex = 0; atts[uiAttrIndex] != NULL; uiAttrIndex += 2 ) + if ( strcmp( atts[uiAttrIndex], "row" ) == 0 ) + { + pData->uiRowNumber = atol( atts[uiAttrIndex + 1] ); + break; + } - if(atts[uiAttrIndex] != NULL && pData->uiRowNumber < MAP_WORLD_Y) + if ( atts[uiAttrIndex] != NULL && pData->uiRowNumber < MAP_WORLD_Y ) pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "CITYLIST") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO) + else if ( strcmp( name, "CITYLIST" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO ) { pData->curElement = CITYTABLE_ELEMENT_CITYLIST; if ( !localizedMapTextOnly ) { - memset(sBaseSectorList,0,sizeof(sBaseSectorList)); - memset(pTownPoints,0,sizeof(pTownPoints)); - memset(gfTownUsesLoyalty,0,sizeof(gfTownUsesLoyalty)); - memset(gubTownRebelSentiment,0,sizeof(gubTownRebelSentiment)); - memset(gfMilitiaAllowedInTown,0,sizeof(gfMilitiaAllowedInTown)); - memset(gfHiddenTown,0,sizeof(gfHiddenTown)); - memset(gfHiddenTownTemp,0,sizeof(gfHiddenTownTemp)); - memset(gfIconTown,0,sizeof(gfIconTown)); - memset(gfIconTownTemp,0,sizeof(gfIconTownTemp)); - memset(gfDrawHiddenTown,0,sizeof(gfDrawHiddenTown)); - memset(gfDrawHiddenTownTemp,0,sizeof(gfDrawHiddenTownTemp)); - - strncpy(gHiddenIcon[pData->curCityInfo.uiIndex].IconSti, pData->curCityInfo.IconSTI,MAX_ICON_CHARS); - + memset( sBaseSectorList, 0, sizeof(sBaseSectorList) ); + memset( pTownPoints, 0, sizeof(pTownPoints) ); + memset( gfTownUsesLoyalty, 0, sizeof(gfTownUsesLoyalty) ); + memset( gubTownRebelSentiment, 0, sizeof(gubTownRebelSentiment) ); + memset( gfMilitiaAllowedInTown, 0, sizeof(gfMilitiaAllowedInTown) ); + memset( gfHiddenTown, 0, sizeof(gfHiddenTown) ); + memset( gfHiddenTownTemp, 0, sizeof(gfHiddenTownTemp) ); + memset( gfIconTown, 0, sizeof(gfIconTown) ); + memset( gfIconTownTemp, 0, sizeof(gfIconTownTemp) ); + memset( gfDrawHiddenTown, 0, sizeof(gfDrawHiddenTown) ); + memset( gfDrawHiddenTownTemp, 0, sizeof(gfDrawHiddenTownTemp) ); + + strncpy( gHiddenIcon[pData->curCityInfo.uiIndex].IconSti, pData->curCityInfo.IconSTI, MAX_ICON_CHARS ); + //if ( pData->curCityInfo.ubPosIconX < 0 ) // gHiddenIcon[pData->curCityInfo.uiIndex].IconX = 0; //else - gHiddenIcon[pData->curCityInfo.uiIndex].IconX = pData->curCityInfo.ubPosIconX; - + gHiddenIcon[pData->curCityInfo.uiIndex].IconX = pData->curCityInfo.ubPosIconX; + //if ( pData->curCityInfo.ubPosIconY < 0 ) // gHiddenIcon[pData->curCityInfo.uiIndex].IconY = 0; //else - gHiddenIcon[pData->curCityInfo.uiIndex].IconY = pData->curCityInfo.ubPosIconY; - + gHiddenIcon[pData->curCityInfo.uiIndex].IconY = pData->curCityInfo.ubPosIconY; + } pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "CITY") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYLIST) + else if ( strcmp( name, "CITY" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYLIST ) { pData->curElement = CITYTABLE_ELEMENT_CITY; if ( !localizedMapTextOnly ) - memset(&pData->curCityInfo,0,sizeof(cityInfo)); + memset( &pData->curCityInfo, 0, sizeof(cityInfo) ); pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townName") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townName" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_NAME; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "uiIndex") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "uiIndex" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_INDEX; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townUsesLoyalty") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townUsesLoyalty" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_USES_LOYALTY; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townRebelSentiment") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townRebelSentiment" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_REBEL_SENTIMENT; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townMilitiaAllowed") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townMilitiaAllowed" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_MILITIA; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "hiddenTown") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "hiddenTown" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_HIDDENTOWN; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townIcon") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townIcon" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_ICONTOWN; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "szIconFile") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "szIconFile" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_ICONFILE; pData->maxReadDepth++; //we are not skipping this element } - - else if(strcmp(name, "iconPosition") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + + else if ( strcmp( name, "iconPosition" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_ICON_POSITION; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION ) { pData->curElement = CITYTABLE_ELEMENT_ICON_POSITION_X; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION ) { pData->curElement = CITYTABLE_ELEMENT_ICON_POSITION_Y; pData->maxReadDepth++; //we are not skipping this element } - - else if(strcmp(name, "baseSector") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + + else if ( strcmp( name, "baseSector" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR ) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR_X; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR ) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR_Y; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "townPoint") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "townPoint" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_TOWNPOINT; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT ) { pData->curElement = CITYTABLE_ELEMENT_TOWNPOINT_X; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT ) { pData->curElement = CITYTABLE_ELEMENT_TOWNPOINT_Y; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "COUNTRY") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO) + else if ( strcmp( name, "COUNTRY" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO ) { pData->curElement = CITYTABLE_ELEMENT_COUNTRYINFO; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "countryName") == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO) + else if ( strcmp( name, "countryName" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO ) { pData->curElement = CITYTABLE_ELEMENT_COUNTRYNAME; pData->maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "countryNoun") == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO) + else if ( strcmp( name, "countryNoun" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO ) { pData->curElement = CITYTABLE_ELEMENT_COUNTRYNOUN; pData->maxReadDepth++; //we are not skipping this element @@ -1097,91 +1097,91 @@ citytableStartElementHandle(void *userData, const XML_Char *name, const XML_Char } static void XMLCALL -citytableCharacterDataHandle(void *userData, const XML_Char *str, int len) +citytableCharacterDataHandle( void *userData, const XML_Char *str, int len ) { - citytableParseData * pData = (citytableParseData *) userData; + citytableParseData * pData = (citytableParseData *)userData; - if(pData->currentDepth <= pData->maxReadDepth && strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH) - strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData))); + if ( pData->currentDepth <= pData->maxReadDepth && strlen( pData->szCharData ) < MAX_CHAR_DATA_LENGTH ) + strncat( pData->szCharData, str, __min( (unsigned int)len, MAX_CHAR_DATA_LENGTH - strlen( pData->szCharData ) ) ); } static void XMLCALL -citytableEndElementHandle(void *userData, const XML_Char *name) +citytableEndElementHandle( void *userData, const XML_Char *name ) { -char temp; + char temp; - citytableParseData * pData = (citytableParseData *) userData; + citytableParseData * pData = (citytableParseData *)userData; - if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading + if ( pData->currentDepth <= pData->maxReadDepth ) //we're at the end of an element that we've been reading { - if(strcmp(name, "CITY_INFO") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO) + if ( strcmp( name, "CITY_INFO" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYINFO ) { pData->curElement = CITYTABLE_ELEMENT_NONE; } - else if(strcmp(name, "CITY_TABLE") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLE) + else if ( strcmp( name, "CITY_TABLE" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLE ) { pData->curElement = CITYTABLE_ELEMENT_CITYINFO; } - else if(strcmp(name, "CITY_TABLE_ROW") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLEROW) + else if ( strcmp( name, "CITY_TABLE_ROW" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYTABLEROW ) { - STR8 curBuffer = pData->szCharData + strspn(pData->szCharData," \t\n\r"); + STR8 curBuffer = pData->szCharData + strspn( pData->szCharData, " \t\n\r" ); UINT32 curCellIndex = 0; UINT32 curNumber; pData->curElement = CITYTABLE_ELEMENT_CITYTABLE; - while(curBuffer[0] != '\0') + while ( curBuffer[0] != '\0' ) { - sscanf( curBuffer,"%d",&curNumber); + sscanf( curBuffer, "%d", &curNumber ); - StrategicMap[curCellIndex+MAP_WORLD_X*pData->uiRowNumber].bNameId = curNumber; + StrategicMap[curCellIndex + MAP_WORLD_X*pData->uiRowNumber].bNameId = curNumber; curCellIndex++; - curBuffer += strcspn(curBuffer," \t\n\r\0"); - curBuffer += strspn(curBuffer," \t\n\r"); + curBuffer += strcspn( curBuffer, " \t\n\r\0" ); + curBuffer += strspn( curBuffer, " \t\n\r" ); } } - else if(strcmp(name, "CITYLIST") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYLIST) + else if ( strcmp( name, "CITYLIST" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITYLIST ) { pData->curElement = CITYTABLE_ELEMENT_CITYINFO; NUM_TOWNS = pData->uiHighestIndex + 1; } - else if(strcmp(name, "CITY") == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY) + else if ( strcmp( name, "CITY" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_CITY ) { pData->curElement = CITYTABLE_ELEMENT_CITYLIST; - if ( pData->curCityInfo.uiIndex != INVALID_TOWN_INDEX && !localizedMapTextOnly) + if ( pData->curCityInfo.uiIndex != INVALID_TOWN_INDEX && !localizedMapTextOnly ) { - sBaseSectorList [pData->curCityInfo.uiIndex-1] = SECTOR(pData->curCityInfo.ubBaseX,pData->curCityInfo.ubBaseY); - pTownPoints [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townPoint; - gfTownUsesLoyalty [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townUsesLoyalty; - gubTownRebelSentiment [pData->curCityInfo.uiIndex ] = pData->curCityInfo.townRebelSentiment; - gfMilitiaAllowedInTown[pData->curCityInfo.uiIndex ] = pData->curCityInfo.townMilitiaAllowed; + sBaseSectorList[pData->curCityInfo.uiIndex - 1] = SECTOR( pData->curCityInfo.ubBaseX, pData->curCityInfo.ubBaseY ); + pTownPoints[pData->curCityInfo.uiIndex] = pData->curCityInfo.townPoint; + gfTownUsesLoyalty[pData->curCityInfo.uiIndex] = pData->curCityInfo.townUsesLoyalty; + gubTownRebelSentiment[pData->curCityInfo.uiIndex] = pData->curCityInfo.townRebelSentiment; + gfMilitiaAllowedInTown[pData->curCityInfo.uiIndex] = pData->curCityInfo.townMilitiaAllowed; //mbstowcs( pTownNames[pData->curCityInfo.uiIndex], pData->curCityInfo.cityName, MAX_TOWN_NAME_LENGHT); - MultiByteToWideChar( CP_UTF8, 0, pData->curCityInfo.cityName, -1, pTownNames[pData->curCityInfo.uiIndex], MAX_TOWN_NAME_LENGHT); - - strncpy(gHiddenIcon[pData->curCityInfo.uiIndex].IconSti, pData->curCityInfo.IconSTI,MAX_ICON_CHARS); - + MultiByteToWideChar( CP_UTF8, 0, pData->curCityInfo.cityName, -1, pTownNames[pData->curCityInfo.uiIndex], MAX_TOWN_NAME_LENGHT ); + + strncpy( gHiddenIcon[pData->curCityInfo.uiIndex].IconSti, pData->curCityInfo.IconSTI, MAX_ICON_CHARS ); + //if ( pData->curCityInfo.ubPosIconX < 0 ) // gHiddenIcon[pData->curCityInfo.uiIndex].IconX = 0; //else - gHiddenIcon[pData->curCityInfo.uiIndex].IconX = pData->curCityInfo.ubPosIconX; - + gHiddenIcon[pData->curCityInfo.uiIndex].IconX = pData->curCityInfo.ubPosIconX; + //if ( pData->curCityInfo.ubPosIconY < 0 ) // gHiddenIcon[pData->curCityInfo.uiIndex].IconY = 0; //else - gHiddenIcon[pData->curCityInfo.uiIndex].IconY = pData->curCityInfo.ubPosIconY; - - if ( pData->curCityInfo.HiddenTown == FALSE ) + gHiddenIcon[pData->curCityInfo.uiIndex].IconY = pData->curCityInfo.ubPosIconY; + + if ( pData->curCityInfo.HiddenTown == FALSE ) { gfHiddenTown[pData->curCityInfo.uiIndex] = TRUE; gfHiddenTownTemp[pData->curCityInfo.uiIndex] = gfHiddenTown[pData->curCityInfo.uiIndex]; - gfDrawHiddenTown[pData->curCityInfo.uiIndex] = FALSE; + gfDrawHiddenTown[pData->curCityInfo.uiIndex] = FALSE; } - else + else { gfHiddenTown[pData->curCityInfo.uiIndex] = FALSE; gfHiddenTownTemp[pData->curCityInfo.uiIndex] = gfHiddenTown[pData->curCityInfo.uiIndex]; @@ -1191,16 +1191,16 @@ char temp; gfIconTown[pData->curCityInfo.uiIndex] = pData->curCityInfo.TownIcon; gfIconTownTemp[pData->curCityInfo.uiIndex] = gfIconTown[pData->curCityInfo.uiIndex]; } - else if ( pData->curCityInfo.uiIndex != INVALID_TOWN_INDEX && localizedMapTextOnly) + else if ( pData->curCityInfo.uiIndex != INVALID_TOWN_INDEX && localizedMapTextOnly ) { - MultiByteToWideChar( CP_UTF8, 0, pData->curCityInfo.cityName, -1, pTownNames[pData->curCityInfo.uiIndex], MAX_TOWN_NAME_LENGHT); + MultiByteToWideChar( CP_UTF8, 0, pData->curCityInfo.cityName, -1, pTownNames[pData->curCityInfo.uiIndex], MAX_TOWN_NAME_LENGHT ); } } - else if(strcmp(name, "uiIndex") == 0 && pData->curElement == CITYTABLE_ELEMENT_INDEX) + else if ( strcmp( name, "uiIndex" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_INDEX ) { pData->curElement = CITYTABLE_ELEMENT_CITY; - pData->curCityInfo.uiIndex = atol(pData->szCharData); + pData->curCityInfo.uiIndex = atol( pData->szCharData ); if ( !pData->curCityInfo.uiIndex || pData->curCityInfo.uiIndex >= MAX_TOWNS ) { pData->curCityInfo.uiIndex = INVALID_TOWN_INDEX; @@ -1210,24 +1210,24 @@ char temp; pData->uiHighestIndex = pData->curCityInfo.uiIndex; } } - else if(strcmp(name, "townName") == 0 && pData->curElement == CITYTABLE_ELEMENT_NAME) + else if ( strcmp( name, "townName" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_NAME ) { - strncpy(pData->curCityInfo.cityName, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1); + strncpy( pData->curCityInfo.cityName, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1 ); pData->curCityInfo.cityName[MAX_TOWN_NAME_LENGHT - 1] = 0; pData->curElement = CITYTABLE_ELEMENT_CITY; } - else if(strcmp(name, "townUsesLoyalty") == 0 && pData->curElement == CITYTABLE_ELEMENT_USES_LOYALTY ) + else if ( strcmp( name, "townUsesLoyalty" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_USES_LOYALTY ) { pData->curElement = CITYTABLE_ELEMENT_CITY; - pData->curCityInfo.townUsesLoyalty = (BOOLEAN)atol(pData->szCharData); + pData->curCityInfo.townUsesLoyalty = (BOOLEAN)atol( pData->szCharData ); } - else if(strcmp(name, "townRebelSentiment") == 0 && pData->curElement == CITYTABLE_ELEMENT_REBEL_SENTIMENT ) + else if ( strcmp( name, "townRebelSentiment" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_REBEL_SENTIMENT ) { pData->curElement = CITYTABLE_ELEMENT_CITY; - pData->curCityInfo.townRebelSentiment = (UINT8)atol(pData->szCharData); + pData->curCityInfo.townRebelSentiment = (UINT8)atol( pData->szCharData ); if ( pData->curCityInfo.townRebelSentiment > 100 ) { pData->curCityInfo.townRebelSentiment = 100; @@ -1235,119 +1235,119 @@ char temp; else if ( !pData->curCityInfo.townRebelSentiment ) pData->curCityInfo.townRebelSentiment = 1; } - else if(strcmp(name, "townMilitiaAllowed") == 0 && pData->curElement == CITYTABLE_ELEMENT_MILITIA ) + else if ( strcmp( name, "townMilitiaAllowed" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_MILITIA ) { pData->curElement = CITYTABLE_ELEMENT_CITY; - pData->curCityInfo.townMilitiaAllowed = (BOOLEAN)atol(pData->szCharData); + pData->curCityInfo.townMilitiaAllowed = (BOOLEAN)atol( pData->szCharData ); } - else if(strcmp(name, "hiddenTown") == 0 && pData->curElement == CITYTABLE_ELEMENT_HIDDENTOWN) + else if ( strcmp( name, "hiddenTown" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_HIDDENTOWN ) { pData->curElement = CITYTABLE_ELEMENT_CITY; - - pData->curCityInfo.HiddenTown = (BOOLEAN)atol(pData->szCharData); - } - else if(strcmp(name, "townIcon") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICONTOWN) - { - pData->curElement = CITYTABLE_ELEMENT_CITY; - - pData->curCityInfo.TownIcon = (INT32)atol(pData->szCharData); + + pData->curCityInfo.HiddenTown = (BOOLEAN)atol( pData->szCharData ); } - else if(strcmp(name, "szIconFile") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICONFILE) + else if ( strcmp( name, "townIcon" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICONTOWN ) { - pData->curElement = CITYTABLE_ELEMENT_CITY; - - if(MAX_ICON_CHARS >= strlen(pData->szCharData)) - strcpy(pData->curCityInfo.IconSTI,pData->szCharData); + + pData->curCityInfo.TownIcon = (INT32)atol( pData->szCharData ); + } + else if ( strcmp( name, "szIconFile" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICONFILE ) + { + + pData->curElement = CITYTABLE_ELEMENT_CITY; + + if ( MAX_ICON_CHARS >= strlen( pData->szCharData ) ) + strcpy( pData->curCityInfo.IconSTI, pData->szCharData ); else { - strncpy(pData->curCityInfo.IconSTI,pData->szCharData,MAX_ICON_CHARS); - pData->curCityInfo.IconSTI[MAX_ICON_CHARS-1] = '\0'; + strncpy( pData->curCityInfo.IconSTI, pData->szCharData, MAX_ICON_CHARS ); + pData->curCityInfo.IconSTI[MAX_ICON_CHARS - 1] = '\0'; } - for(int i=0;iszCharData),MAX_ICON_CHARS);i++) + for ( int i = 0; iszCharData ), MAX_ICON_CHARS ); i++ ) { temp = pData->szCharData[i]; pData->curCityInfo.IconSTI[i] = temp; } } - - else if(strcmp(name, "iconPosition") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION) + + else if ( strcmp( name, "iconPosition" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION ) { pData->curElement = CITYTABLE_ELEMENT_CITY; } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION_X) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION_X ) { pData->curElement = CITYTABLE_ELEMENT_ICON_POSITION; - pData->curCityInfo.ubPosIconX = (INT32) atol(pData->szCharData); + pData->curCityInfo.ubPosIconX = (INT32)atol( pData->szCharData ); } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION_Y) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_ICON_POSITION_Y ) { pData->curElement = CITYTABLE_ELEMENT_ICON_POSITION; - pData->curCityInfo.ubPosIconY = (INT32) atol(pData->szCharData); + pData->curCityInfo.ubPosIconY = (INT32)atol( pData->szCharData ); } - - else if(strcmp(name, "baseSector") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR) + + else if ( strcmp( name, "baseSector" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR ) { pData->curElement = CITYTABLE_ELEMENT_CITY; } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR_X) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR_X ) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR; - pData->curCityInfo.ubBaseX = (UINT8) atol(pData->szCharData); + pData->curCityInfo.ubBaseX = (UINT8)atol( pData->szCharData ); } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR_Y) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_BASESECTOR_Y ) { pData->curElement = CITYTABLE_ELEMENT_BASESECTOR; - pData->curCityInfo.ubBaseY = (UINT8) atol(pData->szCharData); + pData->curCityInfo.ubBaseY = (UINT8)atol( pData->szCharData ); } - else if(strcmp(name, "townPoint") == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT) + else if ( strcmp( name, "townPoint" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT ) { pData->curElement = CITYTABLE_ELEMENT_CITY; } - else if(strcmp(name, "x") == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT_X) + else if ( strcmp( name, "x" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT_X ) { pData->curElement = CITYTABLE_ELEMENT_TOWNPOINT; - pData->curCityInfo.townPoint.x = atol(pData->szCharData); + pData->curCityInfo.townPoint.x = atol( pData->szCharData ); } - else if(strcmp(name, "y") == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT_Y) + else if ( strcmp( name, "y" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_TOWNPOINT_Y ) { pData->curElement = CITYTABLE_ELEMENT_TOWNPOINT; - pData->curCityInfo.townPoint.y = atol(pData->szCharData); + pData->curCityInfo.townPoint.y = atol( pData->szCharData ); } - else if(strcmp(name, "COUNTRY") == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO) + else if ( strcmp( name, "COUNTRY" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYINFO ) { pData->curElement = CITYTABLE_ELEMENT_CITYINFO; if ( !localizedMapTextOnly ) { - MultiByteToWideChar( CP_UTF8, 0, pData->countryName, -1, pCountryNames[COUNTRY_NAME], MAX_TOWN_NAME_LENGHT); - MultiByteToWideChar( CP_UTF8, 0, pData->countryNoun, -1, pCountryNames[COUNTRY_NOUN], MAX_TOWN_NAME_LENGHT); - + MultiByteToWideChar( CP_UTF8, 0, pData->countryName, -1, pCountryNames[COUNTRY_NAME], MAX_TOWN_NAME_LENGHT ); + MultiByteToWideChar( CP_UTF8, 0, pData->countryNoun, -1, pCountryNames[COUNTRY_NOUN], MAX_TOWN_NAME_LENGHT ); + } else if ( localizedMapTextOnly ) { - MultiByteToWideChar( CP_UTF8, 0, pData->countryName, -1, pCountryNames[COUNTRY_NAME], MAX_TOWN_NAME_LENGHT); - MultiByteToWideChar( CP_UTF8, 0, pData->countryNoun, -1, pCountryNames[COUNTRY_NOUN], MAX_TOWN_NAME_LENGHT); + MultiByteToWideChar( CP_UTF8, 0, pData->countryName, -1, pCountryNames[COUNTRY_NAME], MAX_TOWN_NAME_LENGHT ); + MultiByteToWideChar( CP_UTF8, 0, pData->countryNoun, -1, pCountryNames[COUNTRY_NOUN], MAX_TOWN_NAME_LENGHT ); } } - else if(strcmp(name, "countryName") == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYNAME) + else if ( strcmp( name, "countryName" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYNAME ) { - strncpy(pData->countryName, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1); + strncpy( pData->countryName, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1 ); pData->countryName[MAX_TOWN_NAME_LENGHT - 1] = 0; pData->curElement = CITYTABLE_ELEMENT_COUNTRYINFO; } - else if(strcmp(name, "countryNoun") == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYNOUN) + else if ( strcmp( name, "countryNoun" ) == 0 && pData->curElement == CITYTABLE_ELEMENT_COUNTRYNOUN ) { - strncpy(pData->countryNoun, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1); + strncpy( pData->countryNoun, pData->szCharData, MAX_TOWN_NAME_LENGHT - 1 ); pData->countryNoun[MAX_TOWN_NAME_LENGHT - 1] = 0; pData->curElement = CITYTABLE_ELEMENT_COUNTRYINFO; @@ -1359,87 +1359,87 @@ char temp; pData->currentDepth--; } -BOOLEAN WriteInStrategicMapSectorTownNames(STR fileName) +BOOLEAN WriteInStrategicMapSectorTownNames( STR fileName ) { HWFILE hFile; hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) - return( FALSE ); + return(FALSE); { UINT32 x, y; INT8 cnt; - FilePrintf(hFile,"\r\n"); - FilePrintf(hFile,"\t\r\n"); - for(cnt = 1; cnt < NUM_TOWNS; cnt++) + FilePrintf( hFile, "\r\n" ); + FilePrintf( hFile, "\t\r\n" ); + for ( cnt = 1; cnt < NUM_TOWNS; cnt++ ) { - FilePrintf(hFile,"\t\t\r\n"); + FilePrintf( hFile, "\t\t\r\n" ); - FilePrintf(hFile,"\t\t\t%d\r\n",cnt); + FilePrintf( hFile, "\t\t\t%d\r\n", cnt ); - FilePrintf(hFile,"\t\t\t%S\r\n", pTownNames[cnt] ); + FilePrintf( hFile, "\t\t\t%S\r\n", pTownNames[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", gfTownUsesLoyalty[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", gfTownUsesLoyalty[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", gubTownRebelSentiment[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", gubTownRebelSentiment[cnt] ); - FilePrintf(hFile,"\t\t\t%d\r\n", gfMilitiaAllowedInTown[cnt] ); - - if ( gfHiddenTown[cnt] == TRUE) - FilePrintf(hFile,"\t\t\t%d\r\n", 0 ); + FilePrintf( hFile, "\t\t\t%d\r\n", gfMilitiaAllowedInTown[cnt] ); + + if ( gfHiddenTown[cnt] == TRUE ) + FilePrintf( hFile, "\t\t\t%d\r\n", 0 ); else - FilePrintf(hFile,"\t\t\t%d\r\n", 1 ); - - FilePrintf(hFile,"\t\t\t%d\r\n", gfIconTown[cnt] ); + FilePrintf( hFile, "\t\t\t%d\r\n", 1 ); - FilePrintf(hFile,"\t\t\t\r\n"); - FilePrintf(hFile,"\t\t\t\t%d\r\n",(sBaseSectorList[cnt-1]%16)+1); - FilePrintf(hFile,"\t\t\t\t%d\r\n",(sBaseSectorList[cnt-1]/16)+1); - FilePrintf(hFile,"\t\t\t\r\n"); + FilePrintf( hFile, "\t\t\t%d\r\n", gfIconTown[cnt] ); + + FilePrintf( hFile, "\t\t\t\r\n" ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", (sBaseSectorList[cnt - 1] % 16) + 1 ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", (sBaseSectorList[cnt - 1] / 16) + 1 ); + FilePrintf( hFile, "\t\t\t\r\n" ); - FilePrintf(hFile,"\t\t\t\r\n"); - FilePrintf(hFile,"\t\t\t\t%d\r\n",pTownPoints[cnt].x); - FilePrintf(hFile,"\t\t\t\t%d\r\n",pTownPoints[cnt].y); - FilePrintf(hFile,"\t\t\t\r\n"); + FilePrintf( hFile, "\t\t\t\r\n" ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", pTownPoints[cnt].x ); + FilePrintf( hFile, "\t\t\t\t%d\r\n", pTownPoints[cnt].y ); + FilePrintf( hFile, "\t\t\t\r\n" ); - FilePrintf(hFile,"\t\t\r\n"); + FilePrintf( hFile, "\t\t\r\n" ); } - FilePrintf(hFile,"\t\r\n"); + FilePrintf( hFile, "\t\r\n" ); - FilePrintf(hFile,"\t\r\n"); - for(y = 0;y < MAP_WORLD_Y;y++) + FilePrintf( hFile, "\t\r\n" ); + for ( y = 0; y < MAP_WORLD_Y; y++ ) { - FilePrintf(hFile,"\t\t",y); - for(x = 0;x < MAP_WORLD_X;x++) + FilePrintf( hFile, "\t\t", y ); + for ( x = 0; x < MAP_WORLD_X; x++ ) { - if(x < MAP_WORLD_X-1) + if ( x < MAP_WORLD_X - 1 ) { - FilePrintf(hFile,"%3d",StrategicMap[x+y*MAP_WORLD_X].bNameId); + FilePrintf( hFile, "%3d", StrategicMap[x + y*MAP_WORLD_X].bNameId ); } else - FilePrintf(hFile,"%3d \r\n",StrategicMap[x+y*MAP_WORLD_X].bNameId); + FilePrintf( hFile, "%3d \r\n", StrategicMap[x + y*MAP_WORLD_X].bNameId ); } } - FilePrintf(hFile,"\t\r\n"); - FilePrintf(hFile,"\r\n"); + FilePrintf( hFile, "\t\r\n" ); + FilePrintf( hFile, "\r\n" ); } FileClose( hFile ); return TRUE; } -BOOLEAN ReadInStrategicMapSectorTownNames(STR fileName, BOOLEAN localizedVersion) +BOOLEAN ReadInStrategicMapSectorTownNames( STR fileName, BOOLEAN localizedVersion ) { HWFILE hFile; UINT32 uiBytesRead; UINT32 uiFSize; CHAR8 * lpcBuffer; - XML_Parser parser = XML_ParserCreate(NULL); + XML_Parser parser = XML_ParserCreate( NULL ); citytableParseData pData; @@ -1448,16 +1448,16 @@ BOOLEAN ReadInStrategicMapSectorTownNames(STR fileName, BOOLEAN localizedVersion // Open weapons file hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE ); if ( !hFile ) - return( FALSE ); + return(FALSE); - uiFSize = FileGetSize(hFile); - lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1); + uiFSize = FileGetSize( hFile ); + lpcBuffer = (CHAR8 *)MemAlloc( uiFSize + 1 ); //Read in block if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) ) { - MemFree(lpcBuffer); - return( FALSE ); + MemFree( lpcBuffer ); + return(FALSE); } lpcBuffer[uiFSize] = 0; //add a null terminator @@ -1465,66 +1465,66 @@ BOOLEAN ReadInStrategicMapSectorTownNames(STR fileName, BOOLEAN localizedVersion FileClose( hFile ); - XML_SetElementHandler(parser, citytableStartElementHandle, citytableEndElementHandle); - XML_SetCharacterDataHandler(parser, citytableCharacterDataHandle); + XML_SetElementHandler( parser, citytableStartElementHandle, citytableEndElementHandle ); + XML_SetCharacterDataHandler( parser, citytableCharacterDataHandle ); // TODO: ROMAN //pData.curCityInfo - memset(&pData,0,sizeof(pData)); + memset( &pData, 0, sizeof(pData) ); NUM_TOWNS = 0; - XML_SetUserData(parser, &pData); + XML_SetUserData( parser, &pData ); - if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) + if ( !XML_Parse( parser, lpcBuffer, uiFSize, TRUE ) ) { CHAR8 errorBuf[511]; - sprintf(errorBuf, "XML Parser Error in Cities.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); - LiveMessage(errorBuf); + sprintf( errorBuf, "XML Parser Error in Cities.xml: %s at line %d", XML_ErrorString( XML_GetErrorCode( parser ) ), XML_GetCurrentLineNumber( parser ) ); + LiveMessage( errorBuf ); - MemFree(lpcBuffer); + MemFree( lpcBuffer ); return FALSE; } - MemFree(lpcBuffer); + MemFree( lpcBuffer ); - XML_ParserFree(parser); + XML_ParserFree( parser ); return TRUE; } -BOOLEAN ReadInMapStructure(STR fileName, BOOLEAN localizedVersion) +BOOLEAN ReadInMapStructure( STR fileName, BOOLEAN localizedVersion ) { - memset(StrategicMap, 0, sizeof(StrategicMap)); + memset( StrategicMap, 0, sizeof(StrategicMap) ); - return ReadInStrategicMapSectorTownNames(fileName,localizedVersion); + return ReadInStrategicMapSectorTownNames( fileName, localizedVersion ); } UINT32 UndergroundTacticalTraversalTime( INT8 bExitDirection ) { //We are attempting to traverse in an underground environment. We need to use a complete different //method. When underground, all sectors are instantly adjacent. - switch( bExitDirection ) + switch ( bExitDirection ) { - case NORTH_STRATEGIC_MOVE: - if( gMapInformation.sNorthGridNo != -1 ) - return 0; - break; - case EAST_STRATEGIC_MOVE: - if( gMapInformation.sEastGridNo != -1 ) - return 0; - break; - case SOUTH_STRATEGIC_MOVE: - if( gMapInformation.sSouthGridNo != -1 ) - return 0; - break; - case WEST_STRATEGIC_MOVE: - if( gMapInformation.sWestGridNo != -1 ) - return 0; - break; + case NORTH_STRATEGIC_MOVE: + if ( gMapInformation.sNorthGridNo != -1 ) + return 0; + break; + case EAST_STRATEGIC_MOVE: + if ( gMapInformation.sEastGridNo != -1 ) + return 0; + break; + case SOUTH_STRATEGIC_MOVE: + if ( gMapInformation.sSouthGridNo != -1 ) + return 0; + break; + case WEST_STRATEGIC_MOVE: + if ( gMapInformation.sWestGridNo != -1 ) + return 0; + break; } return 0xffffffff; } @@ -1542,13 +1542,13 @@ void BeginLoadScreen( void ) SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); #ifdef JA2UB - if( guiCurrentScreen == MAP_SCREEN && !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + if ( guiCurrentScreen == MAP_SCREEN && !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) #else -//Ja25: No meanwhiles - if( guiCurrentScreen == MAP_SCREEN && !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) && !AreInMeanwhile() ) + //Ja25: No meanwhiles + if ( guiCurrentScreen == MAP_SCREEN && !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) && !AreInMeanwhile( ) ) #endif { - if (!gGameExternalOptions.fDisableStrategicTransition) + if ( !gGameExternalOptions.fDisableStrategicTransition ) { DstRect.iLeft = 0; DstRect.iTop = 0; @@ -1557,24 +1557,24 @@ void BeginLoadScreen( void ) uiTimeRange = 2000; iPercentage = 0; iLastShadePercentage = 0; - uiStartTime = GetJA2Clock(); + uiStartTime = GetJA2Clock( ); BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); PlayJA2SampleFromFile( "SOUNDS\\Final Psionic Blast 01 (16-44).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); - while( iPercentage < 100 ) + while ( iPercentage < 100 ) { - uiCurrTime = GetJA2Clock(); - iPercentage = (uiCurrTime-uiStartTime) * 100 / uiTimeRange; + uiCurrTime = GetJA2Clock( ); + iPercentage = (uiCurrTime - uiStartTime) * 100 / uiTimeRange; iPercentage = min( iPercentage, 100 ); //Factor the percentage so that it is modified by a gravity falling acceleration effect. iFactor = (iPercentage - 50) * 2; - if( iPercentage < 50 ) + if ( iPercentage < 50 ) iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); else - iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.05); + iPercentage = (UINT32)(iPercentage + (100 - iPercentage) * iFactor * 0.01 + 0.05); - if( iPercentage > 50 ) + if ( iPercentage > 50 ) { ShadowVideoSurfaceRectUsingLowPercentTable( guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); } @@ -1585,7 +1585,7 @@ void BeginLoadScreen( void ) SrcRect.iBottom = SCREEN_HEIGHT - 39 * iPercentage / 100; BltStretchVideoSurface( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, 0, &SrcRect, &DstRect ); - InvalidateScreen(); + InvalidateScreen( ); RefreshScreen( NULL ); } } @@ -1597,7 +1597,7 @@ void BeginLoadScreen( void ) #ifdef JA2UB //if we are going to the intro screen, return before putting up a loadscreen - if( gbExitingMapScreenToWhere == MAP_EXIT_TO_INTRO_SCREEN ) + if ( gbExitingMapScreenToWhere == MAP_EXIT_TO_INTRO_SCREEN ) { SetPendingNewScreen( INTRO_SCREEN ); return; @@ -1606,9 +1606,9 @@ void BeginLoadScreen( void ) //If we are loading a saved game, use the Loading screen we saved into the SavedGameHeader file // ( which gets reloaded into gubLastLoadingScreenID ) - if( !gfGotoSectorTransition ) + if ( !gfGotoSectorTransition ) { - if( gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) + if ( gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) { DisplayLoadScreenWithID( gubLastLoadingScreenID ); } @@ -1634,7 +1634,7 @@ void BeginLoadScreen( void ) uiLoadMapTilesetTime = 0; uiLoadMapLightsTime = 0; uiBuildShadeTableTime = 0; - uiEnterSectorStartTime = GetJA2Clock(); + uiEnterSectorStartTime = GetJA2Clock( ); #endif } @@ -1649,27 +1649,27 @@ void EndLoadScreen( ) UINT32 uiHundreths; UINT32 uiUnaccounted; UINT32 uiPercentage; - uiEnterSectorEndTime = GetJA2Clock(); + uiEnterSectorEndTime = GetJA2Clock( ); uiSeconds = (uiEnterSectorEndTime - uiEnterSectorStartTime) / 1000; uiHundreths = ((uiEnterSectorEndTime - uiEnterSectorStartTime) / 10) % 100; SetFont( FONT10ARIAL ); SetFontForeground( FONT_YELLOW ); SetFontBackground( FONT_NEARBLACK ); - if( !gbWorldSectorZ ) + if ( !gbWorldSectorZ ) { swprintf( str, L"%c%d ENTER SECTOR TIME: %d.%02d seconds.", - 'A' + gWorldSectorY - 1, gWorldSectorX, uiSeconds, uiHundreths ); + 'A' + gWorldSectorY - 1, gWorldSectorX, uiSeconds, uiHundreths ); } else { swprintf( str, L"%c%d_b%d ENTER SECTOR TIME: %d.%02d seconds.", - 'A' + gWorldSectorY - 1, gWorldSectorX, gbWorldSectorZ, uiSeconds, uiHundreths ); + 'A' + gWorldSectorY - 1, gWorldSectorX, gbWorldSectorZ, uiSeconds, uiHundreths ); } ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, str ); #ifndef USE_VFS FILE *fp; - if( fStartNewFile ) + if ( fStartNewFile ) { //start new file fp = fopen( "TimeResults.txt", "w" ); ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, L"See JA2\\Data\\TimeResults.txt for more detailed timings." ); @@ -1684,11 +1684,11 @@ void EndLoadScreen( ) fprintf( fp, "\n\n--------------------------------------------------------------------\n\n" ); } } - if( fp ) + if ( fp ) { //Record all of the timings. fprintf( fp, "%S\n", str ); - fprintf( fp, "EnterSector() supersets LoadWorld(). This includes other external sections.\n"); + fprintf( fp, "EnterSector() supersets LoadWorld(). This includes other external sections.\n" ); //FileRead() fprintf( fp, "\n\nVARIOUS FUNCTION TIMINGS (exclusive of actual function timings in second heading)\n" ); uiSeconds = uiTotalFileReadTime / 1000; @@ -1714,16 +1714,16 @@ void EndLoadScreen( ) uiPercentage = uiNumImagesReloaded * 100 / giNumberOfTileTypes; fprintf( fp, " 2) %d%% of the tileset images were actually reloaded.\n", uiPercentage ); - if ( ( uiNumTablesSaved+uiNumTablesLoaded ) != 0 ) + if ( (uiNumTablesSaved + uiNumTablesLoaded) != 0 ) { - uiPercentage = uiNumTablesSaved * 100 / (uiNumTablesSaved+uiNumTablesLoaded); + uiPercentage = uiNumTablesSaved * 100 / (uiNumTablesSaved + uiNumTablesLoaded); } else { uiPercentage = 0; } fprintf( fp, " 3) Of that, %d%% of the shade tables were generated (not loaded).\n", uiPercentage ); - if( gfForceBuildShadeTables ) + if ( gfForceBuildShadeTables ) fprintf( fp, " NOTE: Force building of shadetables enabled on this local computer.\n" ); @@ -1740,21 +1740,21 @@ void EndLoadScreen( ) fclose( fp ); } #else - sgp::Logger_ID time_log_id = sgp::Logger::instance().createLogger(); - sgp::Logger::instance().connectFile(time_log_id, L"TimeResults.txt", true, sgp::Logger::FLUSH_ON_ENDL); - sgp::Logger::LogInstance timeResults = SGP_LOG(time_log_id); + sgp::Logger_ID time_log_id = sgp::Logger::instance( ).createLogger( ); + sgp::Logger::instance( ).connectFile( time_log_id, L"TimeResults.txt", true, sgp::Logger::FLUSH_ON_ENDL ); + sgp::Logger::LogInstance timeResults = SGP_LOG( time_log_id ); ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, L"See JA2\\Data\\TimeResults.txt for more detailed timings." ); //Record all of the timings. timeResults << str << sgp::endl; timeResults << "EnterSector() supersets LoadWorld(). This includes other external sections." << vfs::Log::endl; - //FileRead() + //FileRead() timeResults << sgp::endl << vfs::Log::endl << "VARIOUS FUNCTION TIMINGS (exclusive of actual function timings in second heading)" << sgp::endl; uiSeconds = uiTotalFileReadTime / 1000; uiHundreths = (uiTotalFileReadTime / 10) % 100; //fprintf( fp, "FileRead: %d.%02d (called %d times)\n", uiSeconds, uiHundreths, uiTotalFileReadCalls ); - timeResults << "FileRead: " <= 5 && sMapY != 16 ) + if ( sMapY >= 5 && sMapY != 16 ) { - CrippledVersionFailureToLoadMapCheck(); + CrippledVersionFailureToLoadMapCheck( ); return FALSE; } #endif // ATE: Zero out accounting functions - memset( gbMercIsNewInThisSector, 0, sizeof( gbMercIsNewInThisSector ) ); + memset( gbMercIsNewInThisSector, 0, sizeof(gbMercIsNewInThisSector) ); - SyncStrategicTurnTimes(); + SyncStrategicTurnTimes( ); #ifdef JA2BETAVERSION - if( gfOverrideSector ) + if ( gfOverrideSector ) { //skip the cancel, and force load the sector. This is used by the AIViewer to "reset" a level with //different numbers of various types of enemies. @@ -2096,304 +2096,304 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) #endif // reset goggle warning gogglewarning = FALSE; - // is the sector already loaded? - if( ( gWorldSectorX == sMapX ) && ( sMapY == gWorldSectorY) && ( bMapZ == gbWorldSectorZ) ) + // is the sector already loaded? + if ( (gWorldSectorX == sMapX) && (sMapY == gWorldSectorY) && (bMapZ == gbWorldSectorZ) ) + { + //Inserts the enemies into the already loaded map based on the strategic information. + //Note, the flag will return TRUE only if enemies were added. The game may wish to + //do something else in a case where no enemies are present. + + PrepareMilitiaForTactical( FALSE ); + + SetPendingNewScreen( GAME_SCREEN ); + if ( !NumEnemyInSector( ) ) { - //Inserts the enemies into the already loaded map based on the strategic information. - //Note, the flag will return TRUE only if enemies were added. The game may wish to - //do something else in a case where no enemies are present. - - PrepareMilitiaForTactical( FALSE); - - SetPendingNewScreen(GAME_SCREEN); - if( !NumEnemyInSector( ) ) + if ( is_networked ) { - if (is_networked) - { - if(is_server && gEnemyEnabled == 1) - PrepareEnemyForSectorBattle(); - } - else - { - PrepareEnemyForSectorBattle(); - } + if ( is_server && gEnemyEnabled == 1 ) + PrepareEnemyForSectorBattle( ); } - - for (int i=0; iflags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE) - { - //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); - Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds(MercPtrs[i]->sGridNo) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); - } + PrepareEnemyForSectorBattle( ); } - - if( gubNumCreaturesAttackingTown && !gbWorldSectorZ && - gubSectorIDOfCreatureAttack == SECTOR( gWorldSectorX, gWorldSectorY ) ) - { - if (is_networked) - { - if(is_server && gCreatureEnabled == 1) - PrepareCreaturesForBattle(); - } - else - { - PrepareCreaturesForBattle(); - } - } - if( gfGotoSectorTransition ) - { - BeginLoadScreen( ); - gfGotoSectorTransition = FALSE; - } - - // Check for helicopter being on the ground in this sector... - HandleHelicopterOnGroundGraphic( ); - - HandleEnemyHelicopterOnGroundGraphic(); - - // 0verhaul: Okay, it is apparent that the enemies are not reset correctly. So I will now try to add symmetry - // between enemy placement and militia placement. The enemies do have one advantage here, though: If a sector - // is in enemy hands, then their sector is not actually loaded. At least not normally. Perhaps it would be useful - // to lose a battle with one group of mercs, then bring in another group without changing to another sector to see - // if enemy integrity holds. But this would require the enemies to come up with reinforcements inbetween the battles - // to really test out. - // - // Anyway, for now I will remove this call from here. The objective is to add militia any time we could add enemies - // except for the case of training new militia. But that case can be handled each time militia training finishes. -// ResetMilitia(); - AllTeamsLookForAll( TRUE ); - - for (int i=0; iflags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE) - { - //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); - Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds(MercPtrs[i]->sGridNo) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); - } - } - - return( TRUE ); } - if( gWorldSectorX && gWorldSectorY && gbWorldSectorZ != -1 ) + for ( int i = 0; iflags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE ) + { + //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); + Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); + } } - // make this the currently loaded sector - gWorldSectorX = sMapX; - gWorldSectorY = sMapY; - gbWorldSectorZ = bMapZ; - - // update currently selected map sector to match - ChangeSelectedMapSector( sMapX, sMapY, bMapZ ); - - - //Check to see if the sector we are loading is the cave sector under Tixa. If so - //then we will set up the meanwhile scene to start the creature quest. - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( gubNumCreaturesAttackingTown && !gbWorldSectorZ && + gubSectorIDOfCreatureAttack == SECTOR( gWorldSectorX, gWorldSectorY ) ) { - StopAnyCurrentlyTalkingSpeech( ); + if ( is_networked ) + { + if ( is_server && gCreatureEnabled == 1 ) + PrepareCreaturesForBattle( ); + } + else + { + PrepareCreaturesForBattle( ); + } + } + if ( gfGotoSectorTransition ) + { + BeginLoadScreen( ); + gfGotoSectorTransition = FALSE; + } + + // Check for helicopter being on the ground in this sector... + HandleHelicopterOnGroundGraphic( ); + + HandleEnemyHelicopterOnGroundGraphic( ); + + // 0verhaul: Okay, it is apparent that the enemies are not reset correctly. So I will now try to add symmetry + // between enemy placement and militia placement. The enemies do have one advantage here, though: If a sector + // is in enemy hands, then their sector is not actually loaded. At least not normally. Perhaps it would be useful + // to lose a battle with one group of mercs, then bring in another group without changing to another sector to see + // if enemy integrity holds. But this would require the enemies to come up with reinforcements inbetween the battles + // to really test out. + // + // Anyway, for now I will remove this call from here. The objective is to add militia any time we could add enemies + // except for the case of training new militia. But that case can be handled each time militia training finishes. + // ResetMilitia(); + AllTeamsLookForAll( TRUE ); + + for ( int i = 0; iflags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE ) + { + //Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); + Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId ); + } + } + + return(TRUE); + } + + if ( gWorldSectorX && gWorldSectorY && gbWorldSectorZ != -1 ) + { + HandleDefiniteUnloadingOfWorld( ABOUT_TO_LOAD_NEW_MAP ); + } + + // make this the currently loaded sector + gWorldSectorX = sMapX; + gWorldSectorY = sMapY; + gbWorldSectorZ = bMapZ; + + // update currently selected map sector to match + ChangeSelectedMapSector( sMapX, sMapY, bMapZ ); + + + //Check to see if the sector we are loading is the cave sector under Tixa. If so + //then we will set up the meanwhile scene to start the creature quest. + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { + StopAnyCurrentlyTalkingSpeech( ); #ifdef JA2UB -/* Ja25 no creatures */ + /* Ja25 no creatures */ #else - if( gWorldSectorX == gCreaturesSettings.ubCrepitusFeedingSectorX && gWorldSectorY == gCreaturesSettings.ubCrepitusFeedingSectorY - && gbWorldSectorZ == gCreaturesSettings.ubCrepitusFeedingSectorZ ) // (9, 10, 2) - { - InitCreatureQuest(); //Ignored if already active. - } + if ( gWorldSectorX == gCreaturesSettings.ubCrepitusFeedingSectorX && gWorldSectorY == gCreaturesSettings.ubCrepitusFeedingSectorY + && gbWorldSectorZ == gCreaturesSettings.ubCrepitusFeedingSectorZ ) // (9, 10, 2) + { + InitCreatureQuest( ); //Ignored if already active. + } #endif - } + } - //Stop playing any music -- will fade out. - // SetMusicMode( MUSIC_NONE ); + //Stop playing any music -- will fade out. + // SetMusicMode( MUSIC_NONE ); - // ATE: Determine if we should set the default music... + // ATE: Determine if we should set the default music... - // Are we already in 'tense' music... + // Are we already in 'tense' music... - // ATE: Change music only if not loading.... - /*- - if ( gubMusicMode == MUSIC_TACTICAL_ENEMYPRESENT ) - { - fChangeMusic = FALSE; - } + // ATE: Change music only if not loading.... + /*- + if ( gubMusicMode == MUSIC_TACTICAL_ENEMYPRESENT ) + { + fChangeMusic = FALSE; + } - // Did we 'tactically traverse' over.... - if ( gfTacticalTraversal ) - { - fChangeMusic = FALSE; - } + // Did we 'tactically traverse' over.... + if ( gfTacticalTraversal ) + { + fChangeMusic = FALSE; + } - // If we have no music playing at all.... - if ( gubMusicMode == MUSIC_NONE ) - { + // If we have no music playing at all.... + if ( gubMusicMode == MUSIC_NONE ) + { + fChangeMusic = TRUE; + } + -*/ + + if ( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { fChangeMusic = TRUE; - } - -*/ - - if( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - fChangeMusic = TRUE; - } - else - { - fChangeMusic = FALSE; - } + } + else + { + fChangeMusic = FALSE; + } - if ( fChangeMusic ) - { - SetMusicMode( MUSIC_MAIN_MENU ); - } + if ( fChangeMusic ) + { + SetMusicMode( MUSIC_MAIN_MENU ); + } - // ATE: Do this stuff earlier! - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - // Update the last time we were in tactical... - gTacticalStatus.uiTimeSinceLastInTactical = GetWorldTotalMin( ); + // ATE: Do this stuff earlier! + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { + // Update the last time we were in tactical... + gTacticalStatus.uiTimeSinceLastInTactical = GetWorldTotalMin( ); - // init some AI stuff - InitializeTacticalStatusAtBattleStart(); + // init some AI stuff + InitializeTacticalStatusAtBattleStart( ); - // CJC: delay this until after entering the sector! - //InitAI(); + // CJC: delay this until after entering the sector! + //InitAI(); - // Check for helicopter being on the ground in this sector... - HandleHelicopterOnGroundSkyriderProfile( ); + // Check for helicopter being on the ground in this sector... + HandleHelicopterOnGroundSkyriderProfile( ); #ifdef JA2UB //Check to see if we should add Manuel to this sector, if so add him ShouldNpcBeAddedToSector( gWorldSectorX, gWorldSectorY, bMapZ ); #endif + } + + //Load and enter the new sector + if ( EnterSector( gWorldSectorX, gWorldSectorY, bMapZ ) ) + { + // CJC: moved this here Feb 17 + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { + InitAI( ); } - //Load and enter the new sector - if( EnterSector( gWorldSectorX, gWorldSectorY, bMapZ ) ) + //If there are any people with schedules, now is the time to process them. + //CJC: doesn't work here if we're going through the tactical placement GUI; moving + // this call to PrepareLoadedSector() + //PostSchedules(); + + // ATE: OK, add code here to update the states of doors if they should + // be closed...... + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { - // CJC: moved this here Feb 17 - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - InitAI(); - } - - //If there are any people with schedules, now is the time to process them. - //CJC: doesn't work here if we're going through the tactical placement GUI; moving - // this call to PrepareLoadedSector() - //PostSchedules(); - - // ATE: OK, add code here to update the states of doors if they should - // be closed...... - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - ExamineDoorsOnEnteringSector( ); - } - - // Update all the doors in the sector according to the temp file previously - // loaded, and any changes made by the schedules - UpdateDoorGraphicsFromStatus( TRUE, FALSE ); - - //Set the fact we have visited the sector - SetSectorFlag( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, SF_ALREADY_LOADED ); - - // Check for helicopter being on the ground in this sector... - HandleHelicopterOnGroundGraphic( ); - - HandleEnemyHelicopterOnGroundGraphic(); + ExamineDoorsOnEnteringSector( ); } - else - return( FALSE ); - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + // Update all the doors in the sector according to the temp file previously + // loaded, and any changes made by the schedules + UpdateDoorGraphicsFromStatus( TRUE, FALSE ); + + //Set the fact we have visited the sector + SetSectorFlag( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, SF_ALREADY_LOADED ); + + // Check for helicopter being on the ground in this sector... + HandleHelicopterOnGroundGraphic( ); + + HandleEnemyHelicopterOnGroundGraphic( ); + } + else + return(FALSE); + + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { + if ( (GetMusicMode( ) != MUSIC_TACTICAL_ENEMYPRESENT && GetMusicMode( ) != MUSIC_TACTICAL_BATTLE) || + (!NumHostilesInSector( sMapX, sMapY, bMapZ ) && GetMusicMode( ) == MUSIC_TACTICAL_ENEMYPRESENT) ) { - if( (GetMusicMode() != MUSIC_TACTICAL_ENEMYPRESENT && GetMusicMode() != MUSIC_TACTICAL_BATTLE) || - (!NumHostilesInSector( sMapX, sMapY, bMapZ ) && GetMusicMode() == MUSIC_TACTICAL_ENEMYPRESENT) ) - { - // ATE; Fade FA.T.... - SetMusicFadeSpeed( 5 ); - - #ifdef NEWMUSIC - GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; - if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) - SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); - else - #endif + // ATE; Fade FA.T.... + SetMusicFadeSpeed( 5 ); + +#ifdef NEWMUSIC + GlobalSoundID = MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ] ); + else +#endif SetMusicMode( MUSIC_TACTICAL_NOTHING ); - } - - #ifdef JA2UB - // Say a quote from a merc who has new lines for the sector ( if any ) - HandlePlayerTeamQuotesWhenEnteringSector( sMapX, sMapY, bMapZ ); - #else - // ATE: Check what sector we are in, to show description if we have an RPC..... - HandleRPCDescriptionOfSector( sMapX, sMapY, bMapZ ); - #endif + } - - // ATE: Set Flag for being visited... - SetSectorFlag( sMapX, sMapY, bMapZ, SF_HAS_ENTERED_TACTICAL ); #ifdef JA2UB - //ja2ub - // If any emails should be sent from this sector - HandleEmailBeingSentWhenEnteringSector( sMapX, sMapY, bMapZ, FALSE ); + // Say a quote from a merc who has new lines for the sector ( if any ) + HandlePlayerTeamQuotesWhenEnteringSector( sMapX, sMapY, bMapZ ); +#else + // ATE: Check what sector we are in, to show description if we have an RPC..... + HandleRPCDescriptionOfSector( sMapX, sMapY, bMapZ ); #endif - // ATE; Reset some flags for creature sayings.... - gTacticalStatus.fSaidCreatureFlavourQuote = FALSE; - gTacticalStatus.fHaveSeenCreature = FALSE; - gTacticalStatus.fBeenInCombatOnce = FALSE; - gTacticalStatus.fSaidCreatureSmellQuote = FALSE; - ResetMultiSelection( ); - // ATE: Decide if we can have crows here.... - gTacticalStatus.fGoodToAllowCrows = FALSE; - gTacticalStatus.fHasEnteredCombatModeSinceEntering = FALSE; - gTacticalStatus.fDontAddNewCrows = FALSE; + // ATE: Set Flag for being visited... + SetSectorFlag( sMapX, sMapY, bMapZ, SF_HAS_ENTERED_TACTICAL ); +#ifdef JA2UB + //ja2ub + // If any emails should be sent from this sector + HandleEmailBeingSentWhenEnteringSector( sMapX, sMapY, bMapZ, FALSE ); +#endif + + // ATE; Reset some flags for creature sayings.... + gTacticalStatus.fSaidCreatureFlavourQuote = FALSE; + gTacticalStatus.fHaveSeenCreature = FALSE; + gTacticalStatus.fBeenInCombatOnce = FALSE; + gTacticalStatus.fSaidCreatureSmellQuote = FALSE; + ResetMultiSelection( ); + + // ATE: Decide if we can have crows here.... + gTacticalStatus.fGoodToAllowCrows = FALSE; + gTacticalStatus.fHasEnteredCombatModeSinceEntering = FALSE; + gTacticalStatus.fDontAddNewCrows = FALSE; #ifdef JA2UB //Call this function, if Jerry doesnt need to be added, it will return - UpdateJerryMiloInInitialSector(); + UpdateJerryMiloInInitialSector( ); #endif - // Adjust delay for tense quote - gTacticalStatus.sCreatureTenseQuoteDelay = (INT16)( 10 + Random( 20 ) ); + // Adjust delay for tense quote + gTacticalStatus.sCreatureTenseQuoteDelay = (INT16)(10 + Random( 20 )); + { + INT16 sWarpWorldX; + INT16 sWarpWorldY; + INT8 bWarpWorldZ; + INT32 sWarpGridNo; + + if ( GetWarpOutOfMineCodes( &sWarpWorldX, &sWarpWorldY, &bWarpWorldZ, &sWarpGridNo ) && gbWorldSectorZ >= 2 ) { - INT16 sWarpWorldX; - INT16 sWarpWorldY; - INT8 bWarpWorldZ; - INT32 sWarpGridNo; - - if ( GetWarpOutOfMineCodes( &sWarpWorldX, &sWarpWorldY, &bWarpWorldZ, &sWarpGridNo ) && gbWorldSectorZ >= 2 ) - { - gTacticalStatus.uiFlags |= IN_CREATURE_LAIR; - } - else - { - gTacticalStatus.uiFlags &= ( ~IN_CREATURE_LAIR ); - } + gTacticalStatus.uiFlags |= IN_CREATURE_LAIR; } - - // Every third turn - //if ( Random( 3 ) == 0 ) + else { - if(gGameSettings.fOptions[ TOPTION_ALLOW_CROWS ] == TRUE) - { - gTacticalStatus.fGoodToAllowCrows = TRUE; - gTacticalStatus.ubNumCrowsPossible = (UINT8)( 5 + Random( 5 ) ); - } + gTacticalStatus.uiFlags &= (~IN_CREATURE_LAIR); } - } - return( TRUE ); + // Every third turn + //if ( Random( 3 ) == 0 ) + { + if ( gGameSettings.fOptions[TOPTION_ALLOW_CROWS] == TRUE ) + { + gTacticalStatus.fGoodToAllowCrows = TRUE; + gTacticalStatus.ubNumCrowsPossible = (UINT8)(5 + Random( 5 )); + } + } + + } + + return(TRUE); } BOOLEAN MapExists( UINT8 * szFilename ) @@ -2402,7 +2402,7 @@ BOOLEAN MapExists( UINT8 * szFilename ) HWFILE fp; sprintf( str, "MAPS\\%s", szFilename ); fp = FileOpen( str, FILE_ACCESS_READ, FALSE ); - if( !fp ) + if ( !fp ) return FALSE; FileClose( fp ); return TRUE; @@ -2414,12 +2414,12 @@ void RemoveMercsInSector( ) SOLDIERTYPE *pSoldier; // IF IT'S THE SELECTED GUY, MAKE ANOTHER SELECTED! - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + cnt = gTacticalStatus.Team[gbPlayerNum].bFirstID; // ATE: only for OUR guys.. the rest is taken care of in TrashWorld() when a new sector is added... - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++, pSoldier++) + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; cnt++, pSoldier++ ) { - if ( pSoldier->bActive ) + if ( pSoldier->bActive ) { pSoldier->RemoveSoldierFromGridNo( ); } @@ -2427,144 +2427,148 @@ void RemoveMercsInSector( ) } -void PrepareLoadedSector() +void PrepareLoadedSector( ) { BOOLEAN fEnemyPresenceInThisSector = FALSE; BOOLEAN fAddCivs = TRUE; INT8 bMineIndex = -1; #ifdef JA2UB -//Ja25 No meanwhiles + //Ja25 No meanwhiles #else - if( AreInMeanwhile( ) == FALSE ) + if ( AreInMeanwhile( ) == FALSE ) #endif { - if( gbWorldSectorZ == 0 ) + if ( gbWorldSectorZ == 0 ) { -// MakePlayerPerceptionOfSectorControlCorrect( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + // MakePlayerPerceptionOfSectorControlCorrect( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); } else { // we always think we control underground sectors once we've visited them - SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ].fPlayer[ gbWorldSectorZ ] = TRUE; + SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )].fPlayer[gbWorldSectorZ] = TRUE; } } - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); } // Reset ambients! - HandleNewSectorAmbience( gTilesets[ giCurrentTilesetID ].ubAmbientID ); + HandleNewSectorAmbience( gTilesets[giCurrentTilesetID].ubAmbientID ); + + // Flugente: fortification + LoadSectorFortificationPlan( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + HandleFortificationUpdate( ); //if we are loading a 'pristine' map ( ie, not loading a saved game ) - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME )) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { #ifdef JA2UB -//Ja25 No meanwhiles + //Ja25 No meanwhiles #else if ( !AreReloadingFromMeanwhile( ) ) #endif { - SetPendingNewScreen(GAME_SCREEN); + SetPendingNewScreen( GAME_SCREEN ); - // Make interface the team panel always... + // Make interface the team panel always... SetCurrentInterfacePanel( (UINT8)TEAM_PANEL ); } //Check to see if civilians should be added. Always add civs to maps unless they are //in a mine that is shutdown. - if( gbWorldSectorZ ) + if ( gbWorldSectorZ ) { bMineIndex = GetIdOfMineForSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - if( bMineIndex != -1 ) + if ( bMineIndex != -1 ) { - if( !AreThereMinersInsideThisMine( (UINT8)bMineIndex ) ) + if ( !AreThereMinersInsideThisMine( (UINT8)bMineIndex ) ) { fAddCivs = FALSE; } } } - if (is_networked) + if ( is_networked ) { - if( is_server && fAddCivs && gCivEnabled == 1)//hayden its around here we apply .ini choices for Ai + if ( is_server && fAddCivs && gCivEnabled == 1 )//hayden its around here we apply .ini choices for Ai { AddSoldierInitListTeamToWorld( CIV_TEAM, 255 ); } } - else if (fAddCivs) + else if ( fAddCivs ) { AddSoldierInitListTeamToWorld( CIV_TEAM, 255 ); } - if (is_networked) + if ( is_networked ) { - if(is_server && gMilitiaEnabled == 1) + if ( is_server && gMilitiaEnabled == 1 ) AddSoldierInitListTeamToWorld( MILITIA_TEAM, 255 ); } else { AddSoldierInitListTeamToWorld( MILITIA_TEAM, 255 ); } - - if (is_networked) + + if ( is_networked ) { - if(is_server && gCreatureEnabled == 1) - AddSoldierInitListBloodcats(); + if ( is_server && gCreatureEnabled == 1 ) + AddSoldierInitListBloodcats( ); } else { - AddSoldierInitListBloodcats(); + AddSoldierInitListBloodcats( ); } //Creatures are only added if there are actually some of them. It has to go through some //additional checking. - #ifdef JA2TESTVERSION +#ifdef JA2TESTVERSION //Override the sector with the populations specified in the AIViewer - if( gfOverrideSector ) + if ( gfOverrideSector ) { - if( gbWorldSectorZ > 0 ) + if ( gbWorldSectorZ > 0 ) { UNDERGROUND_SECTORINFO *pSector; pSector = FindUnderGroundSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - pSector->ubNumAdmins = (UINT8)( gsAINumAdmins > 0 ? gsAINumAdmins : 0 ); - pSector->ubNumTroops = (UINT8)( gsAINumTroops > 0 ? gsAINumTroops : 0 ); - pSector->ubNumElites = (UINT8)( gsAINumElites > 0 ? gsAINumElites : 0 ); - pSector->ubNumTanks = (UINT8)( gsAINumTanks > 0 ? gsAINumTanks : 0 ); - pSector->ubNumCreatures = (UINT8)( gsAINumCreatures > 0 ? gsAINumCreatures : 0 ); + pSector->ubNumAdmins = (UINT8)(gsAINumAdmins > 0 ? gsAINumAdmins : 0); + pSector->ubNumTroops = (UINT8)(gsAINumTroops > 0 ? gsAINumTroops : 0); + pSector->ubNumElites = (UINT8)(gsAINumElites > 0 ? gsAINumElites : 0); + pSector->ubNumTanks = (UINT8)(gsAINumTanks > 0 ? gsAINumTanks : 0); + pSector->ubNumCreatures = (UINT8)(gsAINumCreatures > 0 ? gsAINumCreatures : 0); } - else if( !gbWorldSectorZ ) + else if ( !gbWorldSectorZ ) { SECTORINFO *pSector; - pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; - pSector->ubNumAdmins = (UINT8)( gsAINumAdmins > 0 ? gsAINumAdmins : 0 ); - pSector->ubNumTroops = (UINT8)( gsAINumTroops > 0 ? gsAINumTroops : 0 ); - pSector->ubNumElites = (UINT8)( gsAINumElites > 0 ? gsAINumElites : 0 ); - pSector->ubNumTanks = (UINT8)( gsAINumTanks > 0 ? gsAINumTanks : 0 ); - pSector->ubNumCreatures = (UINT8)( gsAINumCreatures > 0 ? gsAINumCreatures : 0 ); + pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )]; + pSector->ubNumAdmins = (UINT8)(gsAINumAdmins > 0 ? gsAINumAdmins : 0); + pSector->ubNumTroops = (UINT8)(gsAINumTroops > 0 ? gsAINumTroops : 0); + pSector->ubNumElites = (UINT8)(gsAINumElites > 0 ? gsAINumElites : 0); + pSector->ubNumTanks = (UINT8)(gsAINumTanks > 0 ? gsAINumTanks : 0); + pSector->ubNumCreatures = (UINT8)(gsAINumCreatures > 0 ? gsAINumCreatures : 0); } } - #endif +#endif // Haydent - if (is_networked) + if ( is_networked ) { - if(is_server && gCreatureEnabled == 1) - PrepareCreaturesForBattle(); + if ( is_server && gCreatureEnabled == 1 ) + PrepareCreaturesForBattle( ); // Haydent - if(is_server && gMilitiaEnabled == 1) - PrepareMilitiaForTactical(FALSE); + if ( is_server && gMilitiaEnabled == 1 ) + PrepareMilitiaForTactical( FALSE ); } else { - PrepareCreaturesForBattle(); - PrepareMilitiaForTactical(TRUE); + PrepareCreaturesForBattle( ); + PrepareMilitiaForTactical( TRUE ); } // OK, set varibles for entring this new sector... @@ -2573,35 +2577,35 @@ void PrepareLoadedSector() //Inserts the enemies into the newly loaded map based on the strategic information. //Note, the flag will return TRUE only if enemies were added. The game may wish to //do something else in a case where no enemies are present. - if( !gfRestoringEnemySoldiersFromTempFile ) + if ( !gfRestoringEnemySoldiersFromTempFile ) { //AddSoldierInitListTeamToWorld( CIV_TEAM, 255 ); -// fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle(); + // fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle(); } - - if (is_networked) + + if ( is_networked ) { - if(is_server && gCivEnabled == 1) - AddProfilesNotUsingProfileInsertionData(); //hayden: is just for civ's + if ( is_server && gCivEnabled == 1 ) + AddProfilesNotUsingProfileInsertionData( ); //hayden: is just for civ's } else { - AddProfilesNotUsingProfileInsertionData(); + AddProfilesNotUsingProfileInsertionData( ); } #ifdef JA2UB -//Ja25 No meanwhiles + //Ja25 No meanwhiles #else - if( !AreInMeanwhile() || GetMeanwhileID() == INTERROGATION ) + if ( !AreInMeanwhile( ) || GetMeanwhileID( ) == INTERROGATION ) #endif { - if (is_networked) + if ( is_networked ) { - if(is_server && gEnemyEnabled == 1) - fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle(); + if ( is_server && gEnemyEnabled == 1 ) + fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle( ); } else { - fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle(); + fEnemyPresenceInThisSector = PrepareEnemyForSectorBattle( ); } } @@ -2615,22 +2619,22 @@ void PrepareLoadedSector() // SetThisSectorAsPlayerControlled( gWorldSectorX, gWorldSectorY, 0 ); //} - if( gbWorldSectorZ > 0 ) + if ( gbWorldSectorZ > 0 ) { // we always think we control underground sectors once we've visited them - SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ].fPlayer[ gbWorldSectorZ ] = TRUE; + SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )].fPlayer[gbWorldSectorZ] = TRUE; } //@@@Evaluate //Add profiles to world using strategic info, not editor placements. - AddProfilesUsingProfileInsertionData(); + AddProfilesUsingProfileInsertionData( ); - PostSchedules(); + PostSchedules( ); } if ( gubEnemyEncounterCode == ENEMY_AMBUSH_CODE || gubEnemyEncounterCode == BLOODCAT_AMBUSH_CODE || gubEnemyEncounterCode == ENEMY_AMBUSH_DEPLOYMENT_CODE ) { - if( gMapInformation.sCenterGridNo != NOWHERE ) + if ( gMapInformation.sCenterGridNo != NOWHERE ) { CallAvailableEnemiesTo( gMapInformation.sCenterGridNo ); } @@ -2644,7 +2648,7 @@ void PrepareLoadedSector() EndLoadScreen( ); - if( !( gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { // unpause game UnPauseGame( ); @@ -2652,12 +2656,12 @@ void PrepareLoadedSector() gpBattleGroup = NULL; - if( gfTacticalTraversal ) + if ( gfTacticalTraversal ) { - CalculateNonPersistantPBIInfo(); + CalculateNonPersistantPBIInfo( ); } - ScreenMsg( FONT_YELLOW, MSG_DEBUG, L"Current Time is: %d", GetWorldTotalMin() ); + ScreenMsg( FONT_YELLOW, MSG_DEBUG, L"Current Time is: %d", GetWorldTotalMin( ) ); #ifdef JA2UB HandleSectorSpecificModificatioToMap( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, FALSE ); @@ -2679,7 +2683,7 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN SOLDIERTYPE * pSoldier; // are we in a mine sector, on the surface? - if ( IsThereAMineInThisSector( sNewSectorX, sNewSectorY ) && ( bNewSectorZ == 0 )) + if ( IsThereAMineInThisSector( sNewSectorX, sNewSectorY ) && (bNewSectorZ == 0) ) { if ( CheckFact( FACT_MINERS_PLACED, 0 ) == FALSE ) { @@ -2687,25 +2691,25 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN ubThisMine = GetMineIndexForSector( sNewSectorX, sNewSectorY ); // hardcoded logic has been moved to Lua script - if (g_luaMines.InitializeHeadMiners(ubThisMine)) + if ( g_luaMines.InitializeHeadMiners( ubThisMine ) ) SetFactTrue( FACT_MINERS_PLACED ); #if 0 //if (ubThisMine != MINE_SAN_MONA) // San Mona is abandoned - if (!gMineStatus[ubThisMine].fEmpty) + if ( !gMineStatus[ubThisMine].fEmpty ) { ubMinersPlaced = 0; - if (ubThisMine != MINE_ALMA) + if ( ubThisMine != MINE_ALMA ) { // Fred Morris is always in the first mine sector we enter, unless that's Alma (then he's randomized, too) - gMercProfiles[ 106 ].sSectorX = sNewSectorX; - gMercProfiles[ 106 ].sSectorY = sNewSectorY; - gMercProfiles[ 106 ].bSectorZ = 0; + gMercProfiles[106].sSectorX = sNewSectorX; + gMercProfiles[106].sSectorY = sNewSectorY; + gMercProfiles[106].bSectorZ = 0; //gMercProfiles[ 106 ].bTown = gMineLocation[ ubThisMine ].bAssociatedTown; - gMercProfiles[ 106 ].bTown = gMineStatus[ ubThisMine ].bAssociatedTown; + gMercProfiles[106].bTown = gMineStatus[ubThisMine].bAssociatedTown; // mark miner as placed - ubRandomMiner[ 0 ] = 0; + ubRandomMiner[0] = 0; ubMinersPlaced++; } @@ -2721,21 +2725,21 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN do { - ubMiner = (UINT8) Random( RANDOM_HEAD_MINERS ); + ubMiner = (UINT8)Random( RANDOM_HEAD_MINERS ); } while( ubRandomMiner[ ubMiner ] == 0 ); - GetMineSector( ubMine, (INT16 *)&(gMercProfiles[ ubRandomMiner[ ubMiner ] ].sSectorX), - (INT16 *)&(gMercProfiles[ ubRandomMiner[ ubMiner ] ].sSectorY) ); - gMercProfiles[ ubRandomMiner[ ubMiner ] ].bSectorZ = 0; + GetMineSector( ubMine, (INT16 *)&(gMercProfiles[ubRandomMiner[ubMiner]].sSectorX), + (INT16 *)&(gMercProfiles[ubRandomMiner[ubMiner]].sSectorY) ); + gMercProfiles[ubRandomMiner[ubMiner]].bSectorZ = 0; //gMercProfiles[ ubRandomMiner[ ubMiner ] ].bTown = gMineLocation[ ubMine ].bAssociatedTown; - gMercProfiles[ ubRandomMiner[ ubMiner ] ].bTown = gMineStatus[ ubMine ].bAssociatedTown; + gMercProfiles[ubRandomMiner[ubMiner]].bTown = gMineStatus[ubMine].bAssociatedTown; // mark miner as placed - ubRandomMiner[ ubMiner ] = 0; + ubRandomMiner[ubMiner] = 0; ubMinersPlaced++; - if (ubMinersPlaced == RANDOM_HEAD_MINERS) + if ( ubMinersPlaced == RANDOM_HEAD_MINERS ) { break; } @@ -2746,23 +2750,23 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN #endif } } - + if ( CheckFact( FACT_ALL_TERRORISTS_KILLED, 0 ) ) { // end terrorist quest // SANDRO - removed ending quest from here, placed to Interface Dialogue //EndQuest( QUEST_KILL_TERRORISTS, gMercProfiles[ CARMEN ].sSectorX, gMercProfiles[ CARMEN ].sSectorY ); // remove Carmen - gMercProfiles[ CARMEN ].sSectorX = 0; - gMercProfiles[ CARMEN ].sSectorY = 0; - gMercProfiles[ CARMEN ].bSectorZ = 0; + gMercProfiles[CARMEN].sSectorX = 0; + gMercProfiles[CARMEN].sSectorY = 0; + gMercProfiles[CARMEN].bSectorZ = 0; } // Check to see if any player merc has the Chalice; if so, // note it as stolen - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + cnt = gTacticalStatus.Team[gbPlayerNum].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++cnt,pSoldier++) + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; ++cnt, pSoldier++ ) { if ( pSoldier->bActive ) { @@ -2772,17 +2776,17 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN } } } - + if ( (gubQuest[QUEST_KINGPIN_MONEY] == QUESTINPROGRESS) && CheckFact( FACT_KINGPIN_CAN_SEND_ASSASSINS, 0 ) && (GetTownIdForSector( sNewSectorX, sNewSectorY ) != BLANK_SECTOR) && !bNewSectorZ && Random( 10 + NumNonPlayerTeamMembersInSector( sNewSectorX, sNewSectorY, MILITIA_TEAM ) ) < 3 ) { - DecideOnAssassin(); + DecideOnAssassin( ); } - + if ( CheckFact( FACT_ROBOT_RECRUITED_AND_MOVED, 0 ) == FALSE ) { SOLDIERTYPE * pRobot; pRobot = FindSoldierByProfileID( ROBOT, TRUE ); - if (pRobot) + if ( pRobot ) { // robot is on our team and we have changed sectors, so we can // replace the robot-under-construction in Madlab's sector @@ -2790,65 +2794,65 @@ void HandleQuestCodeOnSectorEntry( INT16 sNewSectorX, INT16 sNewSectorY, INT8 bN SetFactTrue( FACT_ROBOT_RECRUITED_AND_MOVED ); } } - - #ifdef LUA_HANDLE_QUEST_CODE_ON_SECTOR - - LuaHandleQuestCodeOnSector( sNewSectorX, sNewSectorY, bNewSectorZ, 1); - #else +#ifdef LUA_HANDLE_QUEST_CODE_ON_SECTOR -/* + LuaHandleQuestCodeOnSector( sNewSectorX, sNewSectorY, bNewSectorZ, 1 ); + +#else + + /* if ( sNewSectorX == 5 && sNewSectorY == MAP_ROW_C ) { - // reset Madame Layla counters - gMercProfiles[ MADAME ].bNPCData = 0; - gMercProfiles[ MADAME ].bNPCData2 = 0; + // reset Madame Layla counters + gMercProfiles[ MADAME ].bNPCData = 0; + gMercProfiles[ MADAME ].bNPCData2 = 0; } */ - if ( sNewSectorX == 6 && sNewSectorY == MAP_ROW_C && gubQuest[ QUEST_RESCUE_MARIA ] == QUESTDONE ) + if ( sNewSectorX == 6 && sNewSectorY == MAP_ROW_C && gubQuest[QUEST_RESCUE_MARIA] == QUESTDONE ) { // make sure Maria and Angel are gone - gMercProfiles[ MARIA ].sSectorX = 0; - gMercProfiles[ ANGEL ].sSectorY = 0; - gMercProfiles[ MARIA ].sSectorX = 0; - gMercProfiles[ ANGEL ].sSectorY = 0; + gMercProfiles[MARIA].sSectorX = 0; + gMercProfiles[ANGEL].sSectorY = 0; + gMercProfiles[MARIA].sSectorX = 0; + gMercProfiles[ANGEL].sSectorY = 0; } if ( sNewSectorX == 5 && sNewSectorY == MAP_ROW_D ) { - gubBoxerID[ 0 ] = NOBODY; - gubBoxerID[ 1 ] = NOBODY; - gubBoxerID[ 2 ] = NOBODY; + gubBoxerID[0] = NOBODY; + gubBoxerID[1] = NOBODY; + gubBoxerID[2] = NOBODY; } if ( sNewSectorX == 3 && sNewSectorY == MAP_ROW_P ) { // heal up Elliot if he's been hurt - if ( gMercProfiles[ ELLIOT ].bLife < gMercProfiles[ ELLIOT ].bLifeMax ) + if ( gMercProfiles[ELLIOT].bLife < gMercProfiles[ELLIOT].bLifeMax ) { - gMercProfiles[ ELLIOT ].bLife = gMercProfiles[ ELLIOT ].bLifeMax; + gMercProfiles[ELLIOT].bLife = gMercProfiles[ELLIOT].bLifeMax; } } - - #endif - - ResetOncePerConvoRecordsForAllNPCsInLoadedSector(); + +#endif + + ResetOncePerConvoRecordsForAllNPCsInLoadedSector( ); } void HandleQuestCodeOnSectorExit( INT16 sOldSectorX, INT16 sOldSectorY, INT8 bOldSectorZ ) { #ifdef JA2UB -SOLDIERTYPE *pSoldier=NULL; + SOLDIERTYPE *pSoldier = NULL; #endif - #ifdef LUA_HANDLE_QUEST_CODE_ON_SECTOR - - LuaHandleQuestCodeOnSector( sOldSectorX, sOldSectorY, bOldSectorZ, 0); +#ifdef LUA_HANDLE_QUEST_CODE_ON_SECTOR + + LuaHandleQuestCodeOnSector( sOldSectorX, sOldSectorY, bOldSectorZ, 0 ); + +#else - #else - if ( sOldSectorX == KINGPIN_MONEY_SECTOR_X && sOldSectorY == KINGPIN_MONEY_SECTOR_Y && bOldSectorZ == KINGPIN_MONEY_SECTOR_Z ) { CheckForKingpinsMoneyMissing( TRUE ); @@ -2857,80 +2861,80 @@ SOLDIERTYPE *pSoldier=NULL; if ( sOldSectorX == 13 && sOldSectorY == MAP_ROW_H && bOldSectorZ == 0 && CheckFact( FACT_CONRAD_SHOULD_GO, 0 ) ) { // remove Conrad from the map - gMercProfiles[ CONRAD ].sSectorX = 0; - gMercProfiles[ CONRAD ].sSectorY = 0; + gMercProfiles[CONRAD].sSectorX = 0; + gMercProfiles[CONRAD].sSectorY = 0; } #ifdef JA2UB //JA25 UB - if( sOldSectorX == 7 && sOldSectorY == MAP_ROW_H && bOldSectorZ == 0 ) + if ( sOldSectorX == 7 && sOldSectorY == MAP_ROW_H && bOldSectorZ == 0 ) { // remove Jerry from the map - gMercProfiles[ JERRY_MILO_UB ].sSectorX = 0; - gMercProfiles[ JERRY_MILO_UB ].sSectorY = 0; + gMercProfiles[JERRY_MILO_UB].sSectorX = 0; + gMercProfiles[JERRY_MILO_UB].sSectorY = 0; } //if the player is leaving a sector with Tex in it - if( sOldSectorX == gMercProfiles[ TEX_UB ].sSectorX && sOldSectorY == gMercProfiles[ TEX_UB ].sSectorY && bOldSectorZ == 0 && gMercProfiles[ TEX_UB ].ubLastDateSpokenTo != 0 ) + if ( sOldSectorX == gMercProfiles[TEX_UB].sSectorX && sOldSectorY == gMercProfiles[TEX_UB].sSectorY && bOldSectorZ == 0 && gMercProfiles[TEX_UB].ubLastDateSpokenTo != 0 ) { pSoldier = FindSoldierByProfileID( TEX_UB, TRUE ); //if the npc isnt on the players team AND the player has never spoken to them - if( pSoldier == NULL && gMercProfiles[ TEX_UB ].ubLastDateSpokenTo != 0 ) + if ( pSoldier == NULL && gMercProfiles[TEX_UB].ubLastDateSpokenTo != 0 ) { // remove Tex from the map - gMercProfiles[ TEX_UB ].sSectorX = 0; - gMercProfiles[ TEX_UB ].sSectorY = 0; + gMercProfiles[TEX_UB].sSectorX = 0; + gMercProfiles[TEX_UB].sSectorY = 0; } } //if the player is leaving a sector with John kulba in it - if( sOldSectorX == gMercProfiles[ JOHN_K_UB ].sSectorX && sOldSectorY == gMercProfiles[ JOHN_K_UB ].sSectorY && bOldSectorZ == 0 && gMercProfiles[ JOHN_K_UB ].ubLastDateSpokenTo != 0 ) + if ( sOldSectorX == gMercProfiles[JOHN_K_UB].sSectorX && sOldSectorY == gMercProfiles[JOHN_K_UB].sSectorY && bOldSectorZ == 0 && gMercProfiles[JOHN_K_UB].ubLastDateSpokenTo != 0 ) { pSoldier = FindSoldierByProfileID( JOHN_K_UB, TRUE ); //if the npc isnt on the players team AND the player has never spoken to them - if( pSoldier == NULL && gMercProfiles[ JOHN_K_UB ].ubLastDateSpokenTo != 0 ) + if ( pSoldier == NULL && gMercProfiles[JOHN_K_UB].ubLastDateSpokenTo != 0 ) { // remove Tex from the map - gMercProfiles[ JOHN_K_UB ].sSectorX = 0; - gMercProfiles[ JOHN_K_UB ].sSectorY = 0; + gMercProfiles[JOHN_K_UB].sSectorX = 0; + gMercProfiles[JOHN_K_UB].sSectorY = 0; } } //if the player is leaving a sector with Manuel in it - if( sOldSectorX == gMercProfiles[ MANUEL_UB ].sSectorX && sOldSectorY == gMercProfiles[ MANUEL_UB ].sSectorY && bOldSectorZ == 0 ) + if ( sOldSectorX == gMercProfiles[MANUEL_UB].sSectorX && sOldSectorY == gMercProfiles[MANUEL_UB].sSectorY && bOldSectorZ == 0 ) { pSoldier = FindSoldierByProfileID( MANUEL_UB, TRUE ); //if the npc isnt on the players team AND the player has never spoken to them - if( pSoldier == NULL && gMercProfiles[ MANUEL_UB ].ubLastDateSpokenTo != 0 ) + if ( pSoldier == NULL && gMercProfiles[MANUEL_UB].ubLastDateSpokenTo != 0 ) { // remove Manuel from the map - gMercProfiles[ MANUEL_UB ].sSectorX = 0; - gMercProfiles[ MANUEL_UB ].sSectorY = 0; + gMercProfiles[MANUEL_UB].sSectorX = 0; + gMercProfiles[MANUEL_UB].sSectorY = 0; } } #endif if ( sOldSectorX == HOSPITAL_SECTOR_X && sOldSectorY == HOSPITAL_SECTOR_Y && bOldSectorZ == HOSPITAL_SECTOR_Z ) { - CheckForMissingHospitalSupplies(); + CheckForMissingHospitalSupplies( ); } // reset the state of the museum alarm for Eldin's quotes SetFactFalse( FACT_MUSEUM_ALARM_WENT_OFF ); - - #endif + +#endif } -extern void SetLastTimePlayerWasInSector(); +extern void SetLastTimePlayerWasInSector( ); //Moa: 09/14/2013 this function modifies uiTimeCurrentSectorWasLastLoaded and the various decay of items in that sector as well // @calls HandleSectorCooldownFunctions // @calls SetLastTimePlayerWasInSector -BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) +BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) { INT32 i; UNDERGROUND_SECTORINFO *pNode = NULL; - CHAR8 bFilename[ 50 ]; + CHAR8 bFilename[50]; // Reset //ResetLoadScreenHint(); @@ -2943,18 +2947,18 @@ BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) //Setup the tactical existance of RPCs and CIVs in the last sector before moving on to a new sector. //@@@Evaluate - if( gfWorldLoaded ) + if ( gfWorldLoaded ) { - for( i = gTacticalStatus.Team[ CIV_TEAM ].bFirstID; i <= gTacticalStatus.Team[ CIV_TEAM ].bLastID; i++ ) + for ( i = gTacticalStatus.Team[CIV_TEAM].bFirstID; i <= gTacticalStatus.Team[CIV_TEAM].bLastID; i++ ) { - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->bInSector ) + if ( MercPtrs[i]->bActive && MercPtrs[i]->bInSector ) { - SetupProfileInsertionDataForSoldier( MercPtrs[ i ] ); + SetupProfileInsertionDataForSoldier( MercPtrs[i] ); } } } - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { // Handle NPC stuff related to changing sectors HandleQuestCodeOnSectorEntry( sSectorX, sSectorY, bSectorZ ); @@ -2967,37 +2971,37 @@ BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) RemoveMercsInSector( ); // SANDRO - reset number of enemies here - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) + { + memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); } #ifdef JA2UB -//Ja25 No meanwhiles + //Ja25 No meanwhiles #else - if( AreInMeanwhile() == FALSE ) + if ( AreInMeanwhile( ) == FALSE ) #endif { SetSectorFlag( sSectorX, sSectorY, bSectorZ, SF_ALREADY_VISITED ); } - - GetMapFileName( sSectorX, sSectorY, bSectorZ, bFilename, TRUE, TRUE ); + + GetMapFileName( sSectorX, sSectorY, bSectorZ, bFilename, TRUE, TRUE ); //Load the placeholder map if the real map doesn't exist. - if( !MapExists((UINT8 *) bFilename ) ) + if ( !MapExists( (UINT8 *)bFilename ) ) { - if( !MapExists( (UINT8 *)"Placeholder1.dat" ) ) + if ( !MapExists( (UINT8 *)"Placeholder1.dat" ) ) AssertMsg( 0, "Failed to find Placeholder1.dat (placeholder map)." ); } - CreateLoadingScreenProgressBar(TRUE); - #ifdef JA2BETAVERSION + CreateLoadingScreenProgressBar( TRUE ); +#ifdef JA2BETAVERSION //set the font SetProgressBarMsgAttributes( 0, FONT12ARIAL, FONT_MCOLOR_WHITE, 0 ); //Set the tile so we don see the text come up SetProgressBarTextDisplayFlag( 0, TRUE, TRUE, TRUE ); - #endif +#endif //CreateProgressBar( 0, 160, 380, 480, 400 ); //#ifdef JA2TESTVERSION @@ -3006,18 +3010,18 @@ BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) // swprintf( str, L"Loading map: %S", bFilename ); // SetProgressBarTitle( 0, str, FONT12POINT1, FONT_BLACK, FONT_BLACK ); //#endif - if( !LoadWorld(bFilename) ) + if ( !LoadWorld( bFilename ) ) { - return( FALSE ); + return(FALSE); } // underground? - if( bSectorZ ) + if ( bSectorZ ) { pNode = FindUnderGroundSector( sSectorX, sSectorY, bSectorZ ); // is there a sector?..if so set flag - if( pNode ) + if ( pNode ) { pNode->fVisited = TRUE; } @@ -3026,33 +3030,33 @@ BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) // if we arent loading a saved game // ATE: Moved this form above, so that we can have the benefit of // changing the world BEFORE adding guys to it... - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { // Load the current sectors Information From the temporary files - if( !LoadCurrentSectorsInformationFromTempItemsFile() ) + if ( !LoadCurrentSectorsInformationFromTempItemsFile( ) ) { //The integrity of the temp files have been compromised. Boot out of the game after warning message. - InitExitGameDialogBecauseFileHackDetected(); + InitExitGameDialogBecauseFileHackDetected( ); return TRUE; } } - RemoveLoadingScreenProgressBar(); + RemoveLoadingScreenProgressBar( ); //RemoveProgressBar( 0 ); - if( gfEnterTacticalPlacementGUI ) + if ( gfEnterTacticalPlacementGUI ) { - SetPendingNewScreen(GAME_SCREEN); - InitTacticalPlacementGUI(); + SetPendingNewScreen( GAME_SCREEN ); + InitTacticalPlacementGUI( ); } else { - PrepareLoadedSector(); + PrepareLoadedSector( ); } -// UnPauseGame( ); + // UnPauseGame( ); // This function will either hide or display the tree tops, depending on the game setting - SetTreeTopStateForMap(); + SetTreeTopStateForMap( ); // Flugente: certain features need to alter an item's temperature value depending on the time passed // if we do these functions here and adjust for the time passed since this sector was loaded last, it will seem to the player @@ -3063,11 +3067,11 @@ BOOLEAN EnterSector( INT16 sSectorX, INT16 sSectorY , INT8 bSectorZ ) //Since we have allready loaded the items previously we can use the globals here. HandleSectorCooldownFunctions( sSectorX, sSectorY, (INT8)bSectorZ, gWorldItems, guiNumWorldItems, TRUE ); //Update LastTimePlayerWasInSector - SetLastTimePlayerWasInSector(); - + SetLastTimePlayerWasInSector( ); + //Save to tempfile SaveWorldItemsToTempItemFile( sSectorX, sSectorY, (INT8)bSectorZ, guiNumWorldItems, gWorldItems ); - + return TRUE; //because the map was loaded. } @@ -3077,7 +3081,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) INT32 cnt; SOLDIERTYPE *pSoldier; BOOLEAN fPOWSquadSet = FALSE; - UINT8 ubPOWSquad=0; + UINT8 ubPOWSquad = 0; CHAR16 zTemp[256]; // Remove from interface slot @@ -3087,7 +3091,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) guiPendingOverrideEvent = I_CHANGE_TO_IDLE; //If we are in this function during the loading of a sector - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { //DONT set these values gusSelectedSoldier = NOBODY; @@ -3099,16 +3103,16 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) if ( fUsingEdgePointsForStrategicEntry ) { - BeginMapEdgepointSearch(); + BeginMapEdgepointSearch( ); } //if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { - for ( cnt = 0, pSoldier = MercPtrs[ cnt ]; cnt < MAX_NUM_SOLDIERS; ++cnt, ++pSoldier) + for ( cnt = 0, pSoldier = MercPtrs[cnt]; cnt < MAX_NUM_SOLDIERS; ++cnt, ++pSoldier ) { if ( gfRestoringEnemySoldiersFromTempFile && - cnt >= gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID && - cnt <= gTacticalStatus.Team[ CREATURE_TEAM ].bLastID ) + cnt >= gTacticalStatus.Team[ENEMY_TEAM].bFirstID && + cnt <= gTacticalStatus.Team[CREATURE_TEAM].bLastID ) { //Don't update enemies/creatures (consec. teams) if they were //just restored via the temp map files... continue; @@ -3118,12 +3122,12 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) pSoldier->bInSector = FALSE; - if ( pSoldier->bActive ) + if ( pSoldier->bActive ) { - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { - if( gMapInformation.sCenterGridNo != NOWHERE && gfBlitBattleSectorLocator && - (gubEnemyEncounterCode == ENEMY_AMBUSH_CODE || gubEnemyEncounterCode == BLOODCAT_AMBUSH_CODE) && pSoldier->bTeam != CIV_TEAM ) + if ( gMapInformation.sCenterGridNo != NOWHERE && gfBlitBattleSectorLocator && + (gubEnemyEncounterCode == ENEMY_AMBUSH_CODE || gubEnemyEncounterCode == BLOODCAT_AMBUSH_CODE) && pSoldier->bTeam != CIV_TEAM ) { // Flugente: improved ambush if ( gGameExternalOptions.fAmbushSpreadMercs ) @@ -3132,7 +3136,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; pSoldier->usStrategicInsertionData = FindRandomGridNoFromSweetSpotExcludingSweetSpot( pSoldier, gMapInformation.sCenterGridNo, gGameExternalOptions.usAmbushSpreadRadiusMercs, &ubDirection ); - + // have the merc look outward. We add + 100 because later on we use this to signify that we want really enforce this direction pSoldier->ubInsertionDirection = (UINT8)GetDirectionToGridNoFromGridNo( gMapInformation.sCenterGridNo, pSoldier->usStrategicInsertionData ) + 100; } @@ -3142,7 +3146,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) pSoldier->usStrategicInsertionData = gMapInformation.sCenterGridNo; } } - else if( gfOverrideInsertionWithExitGrid ) + else if ( gfOverrideInsertionWithExitGrid ) { pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; pSoldier->usStrategicInsertionData = gExitGrid.usGridNo; @@ -3151,11 +3155,11 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) if ( pSoldier->sSectorX == sSectorX && pSoldier->sSectorY == sSectorY && pSoldier->bSectorZ == bSectorZ && !pSoldier->flags.fBetweenSectors ) { - gbMercIsNewInThisSector[ pSoldier->ubID ] = 1; + gbMercIsNewInThisSector[pSoldier->ubID] = 1; UpdateMercInSector( pSoldier, sSectorX, sSectorY, bSectorZ ); - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { if ( pSoldier->bAssignment == ASSIGNMENT_POW ) { @@ -3166,14 +3170,14 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) // ATE: If we are in i13 - pop up message! if ( sSectorX == gModSettings.ubInitialPOWSectorX && sSectorY == gModSettings.ubInitialPOWSectorY ) //(13, 9) { - swprintf( zTemp, TacticalStr[ POW_MERCS_ARE_HERE ], gMercProfiles[ QUEEN ].zNickname ); - DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL ); + swprintf( zTemp, TacticalStr[POW_MERCS_ARE_HERE], gMercProfiles[QUEEN].zNickname ); + DoMessageBox( MSG_BOX_BASIC_STYLE, zTemp, GAME_SCREEN, (UINT8)MSG_BOX_FLAG_OK, NULL, NULL ); } else { AddCharacterToUniqueSquad( pSoldier ); ubPOWSquad = pSoldier->bAssignment; - pSoldier->aiData.bNeutral = FALSE; + pSoldier->aiData.bNeutral = FALSE; } } else @@ -3185,7 +3189,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) } // ATE: Call actions based on what POW we are on... - if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTINPROGRESS ) + if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTINPROGRESS ) { // Complete quest EndQuest( QUEST_HELD_IN_ALMA, sSectorX, sSectorY ); @@ -3206,7 +3210,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) if ( fUsingEdgePointsForStrategicEntry ) { - EndMapEdgepointSearch(); + EndMapEdgepointSearch( ); // Set to false fUsingEdgePointsForStrategicEntry = FALSE; @@ -3216,7 +3220,7 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) { BOOLEAN fError = FALSE; - if( pSoldier->flags.uiStatusFlags & SOLDIER_IS_TACTICALLY_VALID) + if ( pSoldier->flags.uiStatusFlags & SOLDIER_IS_TACTICALLY_VALID ) { pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; } @@ -3229,8 +3233,8 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, if ( pSoldier->bAssignment != IN_TRANSIT ) { // CHECK UBINSERTION CODE.. - if( pSoldier->ubStrategicInsertionCode == INSERTION_CODE_PRIMARY_EDGEINDEX || - pSoldier->ubStrategicInsertionCode == INSERTION_CODE_SECONDARY_EDGEINDEX ) + if ( pSoldier->ubStrategicInsertionCode == INSERTION_CODE_PRIMARY_EDGEINDEX || + pSoldier->ubStrategicInsertionCode == INSERTION_CODE_SECONDARY_EDGEINDEX ) { if ( !fUsingEdgePointsForStrategicEntry ) { @@ -3239,9 +3243,9 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, } } - MAPEDGEPOINT_SEARCH_FAILED: + MAPEDGEPOINT_SEARCH_FAILED: - if ( pSoldier->ubProfile != NO_PROFILE && gMercProfiles[ pSoldier->ubProfile ].ubMiscFlags3 & PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE ) + if ( pSoldier->ubProfile != NO_PROFILE && gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 & PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE ) { // override orders pSoldier->aiData.bOrders = STATIONARY; @@ -3249,168 +3253,168 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, // Use insertion direction from loaded map! - switch( pSoldier->ubStrategicInsertionCode ) + switch ( pSoldier->ubStrategicInsertionCode ) { - case INSERTION_CODE_NORTH: - pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; - if ( !gfEditMode && gMapInformation.sNorthGridNo == -1 ) - fError = TRUE; - break; - case INSERTION_CODE_SOUTH: - pSoldier->sInsertionGridNo = gMapInformation.sSouthGridNo; - if ( !gfEditMode && gMapInformation.sSouthGridNo == -1) - fError = TRUE; - break; - case INSERTION_CODE_EAST: - pSoldier->sInsertionGridNo = gMapInformation.sEastGridNo; - if ( !gfEditMode && gMapInformation.sEastGridNo == -1) - fError = TRUE; - break; - case INSERTION_CODE_WEST: - pSoldier->sInsertionGridNo = gMapInformation.sWestGridNo; - if ( !gfEditMode && gMapInformation.sWestGridNo == -1) - fError = TRUE; - break; - case INSERTION_CODE_CENTER: - pSoldier->sInsertionGridNo = gMapInformation.sCenterGridNo; - if ( !gfEditMode && gMapInformation.sCenterGridNo == -1) - fError = TRUE; - break; - case INSERTION_CODE_GRIDNO: - pSoldier->sInsertionGridNo = pSoldier->usStrategicInsertionData; - break; + case INSERTION_CODE_NORTH: + pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; + if ( !gfEditMode && gMapInformation.sNorthGridNo == -1 ) + fError = TRUE; + break; + case INSERTION_CODE_SOUTH: + pSoldier->sInsertionGridNo = gMapInformation.sSouthGridNo; + if ( !gfEditMode && gMapInformation.sSouthGridNo == -1 ) + fError = TRUE; + break; + case INSERTION_CODE_EAST: + pSoldier->sInsertionGridNo = gMapInformation.sEastGridNo; + if ( !gfEditMode && gMapInformation.sEastGridNo == -1 ) + fError = TRUE; + break; + case INSERTION_CODE_WEST: + pSoldier->sInsertionGridNo = gMapInformation.sWestGridNo; + if ( !gfEditMode && gMapInformation.sWestGridNo == -1 ) + fError = TRUE; + break; + case INSERTION_CODE_CENTER: + pSoldier->sInsertionGridNo = gMapInformation.sCenterGridNo; + if ( !gfEditMode && gMapInformation.sCenterGridNo == -1 ) + fError = TRUE; + break; + case INSERTION_CODE_GRIDNO: + pSoldier->sInsertionGridNo = pSoldier->usStrategicInsertionData; + break; - case INSERTION_CODE_PRIMARY_EDGEINDEX: - //dnl ch48 041009 Risky translation, must never occur again on same element - gMapTrn.ResizeTrnCnt(pSoldier->aiData.sPendingActionData2); - if(fUsingEdgePointsForStrategicEntry) + case INSERTION_CODE_PRIMARY_EDGEINDEX: + //dnl ch48 041009 Risky translation, must never occur again on same element + gMapTrn.ResizeTrnCnt( pSoldier->aiData.sPendingActionData2 ); + if ( fUsingEdgePointsForStrategicEntry ) + { + INT32 sWorldX, sWorldY; + INT16 sScreenX, sScreenY, sX, sY; + // Determine 'mirror' gridno... + ConvertGridNoToXY( pSoldier->aiData.sPendingActionData2, &sX, &sY ); + // Convert to absolute xy + GetWorldXYAbsoluteScreenXY( sX, sY, &sScreenX, &sScreenY ); + // Get 'mirror', depending on what direction... + switch ( gubTacticalDirection ) { - INT32 sWorldX, sWorldY; - INT16 sScreenX, sScreenY, sX, sY; - // Determine 'mirror' gridno... - ConvertGridNoToXY(pSoldier->aiData.sPendingActionData2, &sX, &sY); - // Convert to absolute xy - GetWorldXYAbsoluteScreenXY(sX, sY, &sScreenX, &sScreenY); - // Get 'mirror', depending on what direction... - switch(gubTacticalDirection) - { - case NORTH: - sScreenY = MAPHEIGHT; - break; - case SOUTH: - sScreenY = 0; - break; - case EAST: - sScreenX = 0; - break; - case WEST: - sScreenX = MAPWIDTH; - break; - } - // Convert into a gridno again..... - GetFromAbsoluteScreenXYWorldXY(&sWorldX, &sWorldY, sScreenX, sScreenY); - // Save this gridNo.... - pSoldier->aiData.sPendingActionData2 = GETWORLDINDEXFROMWORLDCOORDS(sWorldY, sWorldX); + case NORTH: + sScreenY = MAPHEIGHT; + break; + case SOUTH: + sScreenY = 0; + break; + case EAST: + sScreenX = 0; + break; + case WEST: + sScreenX = MAPWIDTH; + break; } - pSoldier->sInsertionGridNo = SearchForClosestPrimaryMapEdgepoint(pSoldier->aiData.sPendingActionData2, (UINT8)pSoldier->usStrategicInsertionData); - #ifdef JA2BETAVERSION - { - CHAR8 str[256]; - sprintf( str, "%S's primary insertion gridno is %d using %d as initial search gridno and %d insertion code.", - pSoldier->name, pSoldier->sInsertionGridNo, pSoldier->aiData.sPendingActionData2, pSoldier->usStrategicInsertionData ); - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); - } - #endif - if( TileIsOutOfBounds(pSoldier->sInsertionGridNo)) - { - ScreenMsg( FONT_RED, MSG_ERROR, L"Main edgepoint search failed for %s -- substituting entrypoint.", pSoldier->name ); - pSoldier->ubStrategicInsertionCode = (UINT8)pSoldier->usStrategicInsertionData; - goto MAPEDGEPOINT_SEARCH_FAILED; - } - break; - case INSERTION_CODE_SECONDARY_EDGEINDEX: - pSoldier->sInsertionGridNo = SearchForClosestSecondaryMapEdgepoint( pSoldier->aiData.sPendingActionData2, (UINT8)pSoldier->usStrategicInsertionData ); - #ifdef JA2BETAVERSION - { - CHAR8 str[256]; - sprintf( str, "%S's isolated insertion gridno is %d using %d as initial search gridno and %d insertion code.", - pSoldier->name, pSoldier->sInsertionGridNo, pSoldier->aiData.sPendingActionData2, pSoldier->usStrategicInsertionData ); - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); - } - #endif - if(TileIsOutOfBounds(pSoldier->sInsertionGridNo)) - { - ScreenMsg( FONT_RED, MSG_ERROR, L"Isolated edgepont search failed for %s -- substituting entrypoint.", pSoldier->name ); - pSoldier->ubStrategicInsertionCode = (UINT8)pSoldier->usStrategicInsertionData; - goto MAPEDGEPOINT_SEARCH_FAILED; - } - break; + // Convert into a gridno again..... + GetFromAbsoluteScreenXYWorldXY( &sWorldX, &sWorldY, sScreenX, sScreenY ); + // Save this gridNo.... + pSoldier->aiData.sPendingActionData2 = GETWORLDINDEXFROMWORLDCOORDS( sWorldY, sWorldX ); + } + pSoldier->sInsertionGridNo = SearchForClosestPrimaryMapEdgepoint( pSoldier->aiData.sPendingActionData2, (UINT8)pSoldier->usStrategicInsertionData ); +#ifdef JA2BETAVERSION + { + CHAR8 str[256]; + sprintf( str, "%S's primary insertion gridno is %d using %d as initial search gridno and %d insertion code.", + pSoldier->name, pSoldier->sInsertionGridNo, pSoldier->aiData.sPendingActionData2, pSoldier->usStrategicInsertionData ); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); + } +#endif + if ( TileIsOutOfBounds( pSoldier->sInsertionGridNo ) ) + { + ScreenMsg( FONT_RED, MSG_ERROR, L"Main edgepoint search failed for %s -- substituting entrypoint.", pSoldier->name ); + pSoldier->ubStrategicInsertionCode = (UINT8)pSoldier->usStrategicInsertionData; + goto MAPEDGEPOINT_SEARCH_FAILED; + } + break; + case INSERTION_CODE_SECONDARY_EDGEINDEX: + pSoldier->sInsertionGridNo = SearchForClosestSecondaryMapEdgepoint( pSoldier->aiData.sPendingActionData2, (UINT8)pSoldier->usStrategicInsertionData ); +#ifdef JA2BETAVERSION + { + CHAR8 str[256]; + sprintf( str, "%S's isolated insertion gridno is %d using %d as initial search gridno and %d insertion code.", + pSoldier->name, pSoldier->sInsertionGridNo, pSoldier->aiData.sPendingActionData2, pSoldier->usStrategicInsertionData ); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); + } +#endif + if ( TileIsOutOfBounds( pSoldier->sInsertionGridNo ) ) + { + ScreenMsg( FONT_RED, MSG_ERROR, L"Isolated edgepont search failed for %s -- substituting entrypoint.", pSoldier->name ); + pSoldier->ubStrategicInsertionCode = (UINT8)pSoldier->usStrategicInsertionData; + goto MAPEDGEPOINT_SEARCH_FAILED; + } + break; - case INSERTION_CODE_ARRIVING_GAME: - // Are we in Omerta! - if ( sSectorX == gWorldSectorX && gWorldSectorX == 9 && sSectorY == gWorldSectorY && gWorldSectorY == 1 && bSectorZ == gbWorldSectorZ && gbWorldSectorZ == 0 ) - { - // TODO.WANNE: Hardcoded grid number - // Try another location and walk into map - pSoldier->sInsertionGridNo = 4379;//dnl!!! - } - else - { - #ifdef JA2UB - //pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; - //pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; - pSoldier->sInsertionGridNo = gGameUBOptions.LOCATEGRIDNO; - #else - //pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; - //pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; - pSoldier->sInsertionGridNo = gGameExternalOptions.iInitialMercArrivalLocation; - #endif - } - break; - case INSERTION_CODE_CHOPPER: + case INSERTION_CODE_ARRIVING_GAME: + // Are we in Omerta! + if ( sSectorX == gWorldSectorX && gWorldSectorX == 9 && sSectorY == gWorldSectorY && gWorldSectorY == 1 && bSectorZ == gbWorldSectorZ && gbWorldSectorZ == 0 ) + { + // TODO.WANNE: Hardcoded grid number // Try another location and walk into map - // Add merc to chopper.... - //pSoldier->sInsertionGridNo = 4058; - AddMercToHeli( pSoldier->ubID ); - return; - break; - default: - //Moa: Hardcoded grid number set to CenterGrid - pSoldier->sInsertionGridNo = ( WORLD_ROWS * WORLD_COLS + WORLD_COLS ) / 2;//12880 - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion code %d given to UpdateMercsInSector", pSoldier->ubStrategicInsertionCode ) ); - break; + pSoldier->sInsertionGridNo = 4379;//dnl!!! + } + else + { +#ifdef JA2UB + //pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; + //pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + pSoldier->sInsertionGridNo = gGameUBOptions.LOCATEGRIDNO; +#else + //pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; + //pSoldier->sInsertionGridNo = gMapInformation.sNorthGridNo; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + pSoldier->sInsertionGridNo = gGameExternalOptions.iInitialMercArrivalLocation; +#endif + } + break; + case INSERTION_CODE_CHOPPER: + // Try another location and walk into map + // Add merc to chopper.... + //pSoldier->sInsertionGridNo = 4058; + AddMercToHeli( pSoldier->ubID ); + return; + break; + default: + //Moa: Hardcoded grid number set to CenterGrid + pSoldier->sInsertionGridNo = (WORLD_ROWS * WORLD_COLS + WORLD_COLS) / 2;//12880 + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion code %d given to UpdateMercsInSector", pSoldier->ubStrategicInsertionCode ) ); + break; } - if( fError ) + if ( fError ) { //strategic insertion failed because it expected to find an entry point. This is likely //a missing part of the map or possible fault in strategic movement costs, traversal logic, etc. CHAR16 szEntry[10]; CHAR16 szSector[10]; INT32 sGridNo; GetLoadedSectorString( szSector ); - if( gMapInformation.sNorthGridNo != -1 ) + if ( gMapInformation.sNorthGridNo != -1 ) { swprintf( szEntry, L"north" ); sGridNo = gMapInformation.sNorthGridNo; } - else if( gMapInformation.sEastGridNo != -1 ) + else if ( gMapInformation.sEastGridNo != -1 ) { swprintf( szEntry, L"east" ); sGridNo = gMapInformation.sEastGridNo; } - else if( gMapInformation.sSouthGridNo != -1 ) + else if ( gMapInformation.sSouthGridNo != -1 ) { swprintf( szEntry, L"south" ); sGridNo = gMapInformation.sSouthGridNo; } - else if( gMapInformation.sWestGridNo != -1 ) + else if ( gMapInformation.sWestGridNo != -1 ) { swprintf( szEntry, L"west" ); sGridNo = gMapInformation.sWestGridNo; } - else if( gMapInformation.sCenterGridNo != -1 ) + else if ( gMapInformation.sCenterGridNo != -1 ) { swprintf( szEntry, L"center" ); sGridNo = gMapInformation.sCenterGridNo; @@ -3418,35 +3422,35 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, else { ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s has NO entrypoints -- using precise center of map for %s.", szSector, pSoldier->name ); - pSoldier->sInsertionGridNo = ( WORLD_ROWS * WORLD_COLS + WORLD_COLS ) / 2;//12880 + pSoldier->sInsertionGridNo = (WORLD_ROWS * WORLD_COLS + WORLD_COLS) / 2;//12880 AddSoldierToSector( pSoldier->ubID ); return; } pSoldier->sInsertionGridNo = sGridNo; - switch( pSoldier->ubStrategicInsertionCode ) + switch ( pSoldier->ubStrategicInsertionCode ) { - case INSERTION_CODE_NORTH: - ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a north entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); - break; - case INSERTION_CODE_EAST: - ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a east entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); - break; - case INSERTION_CODE_SOUTH: - ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a south entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); - break; - case INSERTION_CODE_WEST: - ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a west entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); - break; - case INSERTION_CODE_CENTER: - ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a center entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); - break; + case INSERTION_CODE_NORTH: + ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a north entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); + break; + case INSERTION_CODE_EAST: + ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a east entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); + break; + case INSERTION_CODE_SOUTH: + ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a south entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); + break; + case INSERTION_CODE_WEST: + ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a west entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); + break; + case INSERTION_CODE_CENTER: + ScreenMsg( FONT_RED, MSG_BETAVERSION, L"Sector %s doesn't have a center entrypoint -- substituting %s entrypoint for %s.", szSector, szEntry, pSoldier->name ); + break; } } // If no insertion direction exists, this is bad! if ( pSoldier->sInsertionGridNo == -1 ) { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Insertion gridno for direction %d not added to map sector %d %d", pSoldier->ubStrategicInsertionCode, sSectorX, sSectorY ) ); - pSoldier->sInsertionGridNo = ( WORLD_ROWS * WORLD_COLS + WORLD_COLS ) / 2;//12880 + pSoldier->sInsertionGridNo = (WORLD_ROWS * WORLD_COLS + WORLD_COLS) / 2;//12880 } AddSoldierToSector( pSoldier->ubID ); @@ -3455,7 +3459,7 @@ void UpdateMercInSector( SOLDIERTYPE *pSoldier, INT16 sSectorX, INT16 sSectorY, } // Get sector ID string makes a string like 'A9 - OMERTA', or just J11 if no town.... -void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zString, BOOLEAN fDetailed ) +void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, STR16 zString, BOOLEAN fDetailed ) { SECTORINFO *pSector = NULL; UNDERGROUND_SECTORINFO *pUnderground; @@ -3463,73 +3467,73 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS UINT8 ubSectorID = 0; UINT8 ubLandType = 0; - if( sSectorX <= 0 || sSectorY <= 0 || bSectorZ < 0 ) + if ( sSectorX <= 0 || sSectorY <= 0 || bSectorZ < 0 ) { //swprintf( zString, L"%s", pErrorStrings[0] ); } - else if( bSectorZ != 0 ) // UNDERGROUND SECTORS + else if ( bSectorZ != 0 ) // UNDERGROUND SECTORS { pUnderground = FindUnderGroundSector( sSectorX, sSectorY, bSectorZ ); - #if 0 // reading sector names from lua now +#if 0 // reading sector names from lua now //////////////////////////////////// // Read and verify XML sector names - + INT8 bMineIndex; ubSectorID = (UINT8)SECTOR( sSectorX, sSectorY ); - AssertGE(ubSectorID, 0); - AssertLT(ubSectorID,256); - pSector = &SectorInfo[ ubSectorID ]; - ubLandType = pSector->ubTraversability[ 4 ]; + AssertGE( ubSectorID, 0 ); + AssertLT( ubSectorID, 256 ); + pSector = &SectorInfo[ubSectorID]; + ubLandType = pSector->ubTraversability[4]; swprintf( zString, L"%c%d: ", 'A' + sSectorY - 1, sSectorX ); - + BOOLEAN fSectorHasXMLNames = TRUE; CHAR16 zUnexploredUnderground[MAX_SECTOR_NAME_LENGTH]; CHAR16 zDetailedUnexploredUnderground[MAX_SECTOR_NAME_LENGTH]; CHAR16 zExploredUnderground[MAX_SECTOR_NAME_LENGTH]; - CHAR16 zDetailedExploredUnderground[MAX_SECTOR_NAME_LENGTH]; - + CHAR16 zDetailedExploredUnderground[MAX_SECTOR_NAME_LENGTH]; + if ( bSectorZ == 1 ) - { - wcscpy( zUnexploredUnderground, gzSectorUndergroundNames1[ ubSectorID ][0] ); - wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames1[ ubSectorID ][1] ); - wcscpy( zExploredUnderground, gzSectorUndergroundNames1[ ubSectorID ][2] ); - wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames1[ ubSectorID ][3] ); + { + wcscpy( zUnexploredUnderground, gzSectorUndergroundNames1[ubSectorID][0] ); + wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames1[ubSectorID][1] ); + wcscpy( zExploredUnderground, gzSectorUndergroundNames1[ubSectorID][2] ); + wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames1[ubSectorID][3] ); } else if ( bSectorZ == 2 ) { - wcscpy( zUnexploredUnderground, gzSectorUndergroundNames2[ ubSectorID ][0] ); - wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames2[ ubSectorID ][1] ); - wcscpy( zExploredUnderground, gzSectorUndergroundNames2[ ubSectorID ][2] ); - wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames2[ ubSectorID ][3] ); + wcscpy( zUnexploredUnderground, gzSectorUndergroundNames2[ubSectorID][0] ); + wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames2[ubSectorID][1] ); + wcscpy( zExploredUnderground, gzSectorUndergroundNames2[ubSectorID][2] ); + wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames2[ubSectorID][3] ); } else if ( bSectorZ == 3 ) { - wcscpy( zUnexploredUnderground, gzSectorUndergroundNames3[ ubSectorID ][0] ); - wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames3[ ubSectorID ][1] ); - wcscpy( zExploredUnderground, gzSectorUndergroundNames3[ ubSectorID ][2] ); - wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames3[ ubSectorID ][3] ); + wcscpy( zUnexploredUnderground, gzSectorUndergroundNames3[ubSectorID][0] ); + wcscpy( zDetailedUnexploredUnderground, gzSectorUndergroundNames3[ubSectorID][1] ); + wcscpy( zExploredUnderground, gzSectorUndergroundNames3[ubSectorID][2] ); + wcscpy( zDetailedExploredUnderground, gzSectorUndergroundNames3[ubSectorID][3] ); } - - if (zUnexploredUnderground[0] == 0 || zDetailedUnexploredUnderground[0] == 0 || zExploredUnderground[0] == 0 || zDetailedExploredUnderground[0] == 0) + + if ( zUnexploredUnderground[0] == 0 || zDetailedUnexploredUnderground[0] == 0 || zExploredUnderground[0] == 0 || zDetailedExploredUnderground[0] == 0 ) { fSectorHasXMLNames = FALSE; } - if (fSectorHasXMLNames) // UNDERGROUND XML + if ( fSectorHasXMLNames ) // UNDERGROUND XML { if ( pUnderground ) { bMineIndex = GetIdOfMineForSector( sSectorX, sSectorY, bSectorZ ); - if( bMineIndex != -1 ) + if ( bMineIndex != -1 ) { - swprintf( zString, L"%c%d: %s %s", 'A' + sSectorY - 1, sSectorX, pTownNames[ GetTownAssociatedWithMine( bMineIndex ) ], pwMineStrings[ 0 ] ); - } + swprintf( zString, L"%c%d: %s %s", 'A' + sSectorY - 1, sSectorX, pTownNames[GetTownAssociatedWithMine( bMineIndex )], pwMineStrings[0] ); + } else if ( pUnderground->fVisited ) { - if (fDetailed) - { - wcscat( zString, zDetailedExploredUnderground ); + if ( fDetailed ) + { + wcscat( zString, zDetailedExploredUnderground ); } else { @@ -3538,7 +3542,7 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS } else { - if (fDetailed) + if ( fDetailed ) { wcscat( zString, zDetailedUnexploredUnderground ); } @@ -3548,45 +3552,45 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS } } - if (pUnderground->ubNumCreatures) - swprintf( zString, L"%c%d: %s", 'A' + sSectorY - 1, sSectorX, pLandTypeStrings[ CREATURE_LAIR ] ); + if ( pUnderground->ubNumCreatures ) + swprintf( zString, L"%c%d: %s", 'A' + sSectorY - 1, sSectorX, pLandTypeStrings[CREATURE_LAIR] ); //else // swprintf( zString, L"%c%d-%d", 'A' + sSectorY - 1, sSectorX, bSectorZ ); - } + } } else // UNDERGROUND HARDCODED - { + { pUnderground = FindUnderGroundSector( sSectorX, sSectorY, bSectorZ ); - if( pUnderground && ( pUnderground->fVisited || gfGettingNameFromSaveLoadScreen ) ) + if ( pUnderground && (pUnderground->fVisited || gfGettingNameFromSaveLoadScreen) ) { bMineIndex = GetIdOfMineForSector( sSectorX, sSectorY, bSectorZ ); - if( bMineIndex != -1 ) + if ( bMineIndex != -1 ) { - swprintf( zString, L"%c%d: %s %s", 'A' + sSectorY - 1, sSectorX, pTownNames[ GetTownAssociatedWithMine( bMineIndex ) ], pwMineStrings[ 0 ] ); + swprintf( zString, L"%c%d: %s %s", 'A' + sSectorY - 1, sSectorX, pTownNames[GetTownAssociatedWithMine( bMineIndex )], pwMineStrings[0] ); } - else switch( SECTOR( sSectorX, sSectorY ) ) + else switch ( SECTOR( sSectorX, sSectorY ) ) { - case SEC_A10: - swprintf( zString, L"A10: %s", pLandTypeStrings[ REBEL_HIDEOUT ] ); - break; - case SEC_J9: - swprintf( zString, L"J9: %s", pLandTypeStrings[ TIXA_DUNGEON ] ); - break; - case SEC_K4: - swprintf( zString, L"K4: %s", pLandTypeStrings[ ORTA_BASEMENT ] ); - break; - case SEC_O3: - swprintf( zString, L"O3: %s", pLandTypeStrings[ TUNNEL ] ); - break; - case SEC_P3: - swprintf( zString, L"P3: %s", pLandTypeStrings[ SHELTER ] ); - break; - default: - if (pUnderground->ubNumCreatures) - swprintf( zString, L"%c%d: %s", 'A' + sSectorY - 1, sSectorX, pLandTypeStrings[ CREATURE_LAIR ] ); - else - swprintf( zString, L"%c%d-%d", 'A' + sSectorY - 1, sSectorX, bSectorZ ); - break; + case SEC_A10: + swprintf( zString, L"A10: %s", pLandTypeStrings[REBEL_HIDEOUT] ); + break; + case SEC_J9: + swprintf( zString, L"J9: %s", pLandTypeStrings[TIXA_DUNGEON] ); + break; + case SEC_K4: + swprintf( zString, L"K4: %s", pLandTypeStrings[ORTA_BASEMENT] ); + break; + case SEC_O3: + swprintf( zString, L"O3: %s", pLandTypeStrings[TUNNEL] ); + break; + case SEC_P3: + swprintf( zString, L"P3: %s", pLandTypeStrings[SHELTER] ); + break; + default: + if ( pUnderground->ubNumCreatures ) + swprintf( zString, L"%c%d: %s", 'A' + sSectorY - 1, sSectorX, pLandTypeStrings[CREATURE_LAIR] ); + else + swprintf( zString, L"%c%d-%d", 'A' + sSectorY - 1, sSectorX, bSectorZ ); + break; } } else @@ -3594,25 +3598,25 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS wcscpy( zString, L"" ); } } - #else +#else // TODO: the code is riddled with (potential) buffer overruns // this totally needs to be fixed sometime // anyway, only trying to not create another one here // found calls to this function with buffers as small as 50 elements - g_luaUnderground.GetSectorName(sSectorX, sSectorY, bSectorZ, pUnderground, zString, 50, fDetailed); + g_luaUnderground.GetSectorName( sSectorX, sSectorY, bSectorZ, pUnderground, zString, 50, fDetailed ); - #endif +#endif } else // SECTORS ABOVE GROUND { - bTownNameID = StrategicMap[ CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].bNameId; + bTownNameID = StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].bNameId; ubSectorID = (UINT8)SECTOR( sSectorX, sSectorY ); - AssertGE(ubSectorID, 0); - AssertLT(ubSectorID,256); - pSector = &SectorInfo[ ubSectorID ]; - ubLandType = pSector->ubTraversability[ 4 ]; + AssertGE( ubSectorID, 0 ); + AssertLT( ubSectorID, 256 ); + pSector = &SectorInfo[ubSectorID]; + ubLandType = pSector->ubTraversability[4]; swprintf( zString, L"%c%d: ", 'A' + sSectorY - 1, sSectorX ); //////////////////////////////////// @@ -3622,33 +3626,33 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS CHAR16 zDetailedUnexplored[MAX_SECTOR_NAME_LENGTH]; CHAR16 zExplored[MAX_SECTOR_NAME_LENGTH]; CHAR16 zDetailedExplored[MAX_SECTOR_NAME_LENGTH]; - - wcscpy( zUnexplored, gzSectorNames[ ubSectorID ][0] ); - wcscpy( zDetailedUnexplored, gzSectorNames[ ubSectorID ][1] ); - wcscpy( zExplored, gzSectorNames[ ubSectorID ][2] ); - wcscpy( zDetailedExplored, gzSectorNames[ ubSectorID ][3] ); - if (zUnexplored[0] == 0 || zDetailedUnexplored[0] == 0 || zExplored[0] == 0 || zDetailedExplored[0] == 0) + wcscpy( zUnexplored, gzSectorNames[ubSectorID][0] ); + wcscpy( zDetailedUnexplored, gzSectorNames[ubSectorID][1] ); + wcscpy( zExplored, gzSectorNames[ubSectorID][2] ); + wcscpy( zDetailedExplored, gzSectorNames[ubSectorID][3] ); + + if ( zUnexplored[0] == 0 || zDetailedUnexplored[0] == 0 || zExplored[0] == 0 || zDetailedExplored[0] == 0 ) { fSectorHasXMLNames = FALSE; } - if (fSectorHasXMLNames) // ABOVE GROUND XML + if ( fSectorHasXMLNames ) // ABOVE GROUND XML { // HEADROCK HAM 3.6: The program can now read custom names from XML for all above-ground sectors. // In the event that a specific name or set of names is missing, the program generates a default // name as it always has. // I've also updated the SAM Site sectors to rely on SamSite.XML data. - - BOOLEAN fVisited = (SectorInfo[ ubSectorID ].uiFlags & SF_ALREADY_VISITED); + + BOOLEAN fVisited = (SectorInfo[ubSectorID].uiFlags & SF_ALREADY_VISITED); BOOLEAN fSAMSiteKnown = FALSE; // Test for known SAM Site at this location - for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++) + for ( UINT16 x = 0; x < MAX_NUMBER_OF_SAMS; x++ ) { if ( pSamList[x] == ubSectorID ) { - if ( fSamSiteFound[ x ] ) + if ( fSamSiteFound[x] ) { fSAMSiteKnown = TRUE; break; @@ -3656,22 +3660,22 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS } } - if (fVisited || fSAMSiteKnown) + if ( fVisited || fSAMSiteKnown ) { - if (fDetailed) + if ( fDetailed ) { wcscat( zString, zDetailedExplored ); } else { - wcscat( zString, zExplored); + wcscat( zString, zExplored ); } } else { - if (fDetailed) + if ( fDetailed ) { - wcscat( zString, zDetailedUnexplored); + wcscat( zString, zDetailedUnexplored ); } else { @@ -3686,108 +3690,108 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS { // OK, build string id like J11 // are we dealing with the unfound towns? - switch( ubSectorID ) + switch ( ubSectorID ) { - case SEC_D2: //Chitzena SAM - if( !fSamSiteFound[ SAM_SITE_ONE ] ) - wcscat( zString, pLandTypeStrings[ TROPICS ] ); - else if( fDetailed ) - wcscat( zString, pLandTypeStrings[ TROPICS_SAM_SITE ] ); - else - wcscat( zString, pLandTypeStrings[ SAM_SITE ] ); - break; - case SEC_D15: //Drassen SAM - if( !fSamSiteFound[ SAM_SITE_TWO ] ) - wcscat( zString, pLandTypeStrings[ SPARSE ] ); - else if( fDetailed ) - wcscat( zString, pLandTypeStrings[ SPARSE_SAM_SITE ] ); - else - wcscat( zString, pLandTypeStrings[ SAM_SITE ] ); - break; - case SEC_I8: //Cambria SAM - if( !fSamSiteFound[ SAM_SITE_THREE ] ) - wcscat( zString, pLandTypeStrings[ SAND ] ); - else if( fDetailed ) - wcscat( zString, pLandTypeStrings[ SAND_SAM_SITE ] ); - else - wcscat( zString, pLandTypeStrings[ SAM_SITE ] ); - break; - default: - wcscat( zString, pLandTypeStrings[ ubLandType ] ); - break; + case SEC_D2: //Chitzena SAM + if ( !fSamSiteFound[SAM_SITE_ONE] ) + wcscat( zString, pLandTypeStrings[TROPICS] ); + else if ( fDetailed ) + wcscat( zString, pLandTypeStrings[TROPICS_SAM_SITE] ); + else + wcscat( zString, pLandTypeStrings[SAM_SITE] ); + break; + case SEC_D15: //Drassen SAM + if ( !fSamSiteFound[SAM_SITE_TWO] ) + wcscat( zString, pLandTypeStrings[SPARSE] ); + else if ( fDetailed ) + wcscat( zString, pLandTypeStrings[SPARSE_SAM_SITE] ); + else + wcscat( zString, pLandTypeStrings[SAM_SITE] ); + break; + case SEC_I8: //Cambria SAM + if ( !fSamSiteFound[SAM_SITE_THREE] ) + wcscat( zString, pLandTypeStrings[SAND] ); + else if ( fDetailed ) + wcscat( zString, pLandTypeStrings[SAND_SAM_SITE] ); + else + wcscat( zString, pLandTypeStrings[SAM_SITE] ); + break; + default: + wcscat( zString, pLandTypeStrings[ubLandType] ); + break; } } else { - switch( ubSectorID ) + switch ( ubSectorID ) { - case SEC_B13: - if( fDetailed ) - wcscat( zString, pLandTypeStrings[ DRASSEN_AIRPORT_SITE ] ); + case SEC_B13: + if ( fDetailed ) + wcscat( zString, pLandTypeStrings[DRASSEN_AIRPORT_SITE] ); + else + wcscat( zString, pTownNames[DRASSEN] ); + break; + case SEC_F8: + if ( fDetailed ) + wcscat( zString, pLandTypeStrings[CAMBRIA_HOSPITAL_SITE] ); + else + wcscat( zString, pTownNames[CAMBRIA] ); + break; + case SEC_J9: //Tixa + //if( !fFoundTixa ) + if ( gfHiddenTown[TIXA] == FALSE ) + wcscat( zString, pLandTypeStrings[SAND] ); + else + wcscat( zString, pTownNames[TIXA] ); + break; + case SEC_K4: //Orta + //if( !fFoundOrta ) + if ( gfHiddenTown[ORTA] == FALSE ) + wcscat( zString, pLandTypeStrings[SWAMP] ); + else + wcscat( zString, pTownNames[ORTA] ); + break; + case SEC_N3: + if ( fDetailed ) + wcscat( zString, pLandTypeStrings[MEDUNA_AIRPORT_SITE] ); + else + wcscat( zString, pTownNames[MEDUNA] ); + break; + default: + if ( ubSectorID == SEC_N4 && fSamSiteFound[SAM_SITE_FOUR] ) + { //Meduna's SAM site + if ( fDetailed ) + wcscat( zString, pLandTypeStrings[MEDUNA_SAM_SITE] ); else - wcscat( zString, pTownNames[ DRASSEN ] ); - break; - case SEC_F8: - if( fDetailed ) - wcscat( zString, pLandTypeStrings[ CAMBRIA_HOSPITAL_SITE ] ); - else - wcscat( zString, pTownNames[ CAMBRIA ] ); - break; - case SEC_J9: //Tixa - //if( !fFoundTixa ) - if( gfHiddenTown[ TIXA ] == FALSE ) - wcscat( zString, pLandTypeStrings[ SAND ] ); - else - wcscat( zString, pTownNames[ TIXA ] ); - break; - case SEC_K4: //Orta - //if( !fFoundOrta ) - if( gfHiddenTown[ ORTA ] == FALSE ) - wcscat( zString, pLandTypeStrings[ SWAMP ] ); - else - wcscat( zString, pTownNames[ ORTA ] ); - break; - case SEC_N3: - if( fDetailed ) - wcscat( zString, pLandTypeStrings[ MEDUNA_AIRPORT_SITE ] ); - else - wcscat( zString, pTownNames[ MEDUNA ] ); - break; - default: - if( ubSectorID == SEC_N4 && fSamSiteFound[ SAM_SITE_FOUR ] ) - { //Meduna's SAM site - if( fDetailed ) - wcscat( zString, pLandTypeStrings[ MEDUNA_SAM_SITE ] ); - else - wcscat( zString, pLandTypeStrings[ SAM_SITE ] ); - } - else - { //All other towns that are known since beginning of the game. - wcscat( zString, pTownNames[ bTownNameID ] ); - if( fDetailed ) + wcscat( zString, pLandTypeStrings[SAM_SITE] ); + } + else + { //All other towns that are known since beginning of the game. + wcscat( zString, pTownNames[bTownNameID] ); + if ( fDetailed ) + { + /* + UINT8 ubMineIndex = GetMineIndexForSector( sSectorX, sSectorY ); + if ( gMineStatus[ubMineIndex].sSectorX == sSectorX && gMineStatus[ubMineIndex].sSectorY == sSectorY ) { - /* - UINT8 ubMineIndex = GetMineIndexForSector( sSectorX, sSectorY ); - if ( gMineStatus[ubMineIndex].sSectorX == sSectorX && gMineStatus[ubMineIndex].sSectorY == sSectorY ) - { - swprintf( zString, L" %s", MineralsName[gMineStatus[ubMineIndex].ubMineType].sType ); - } - */ - switch( ubSectorID ) - { //Append the word, "mine" for town sectors containing a mine. - case SEC_B2: - case SEC_D4: - case SEC_D13: - case SEC_H3: - case SEC_H8: - case SEC_I14: - wcscat( zString, L" " ); //space - wcscat( zString, pwMineStrings[ 0 ] ); //then "Mine" - break; - } + swprintf( zString, L" %s", MineralsName[gMineStatus[ubMineIndex].ubMineType].sType ); + } + */ + switch ( ubSectorID ) + { //Append the word, "mine" for town sectors containing a mine. + case SEC_B2: + case SEC_D4: + case SEC_D13: + case SEC_H3: + case SEC_H8: + case SEC_I14: + wcscat( zString, L" " ); //space + wcscat( zString, pwMineStrings[0] ); //then "Mine" + break; } } - break; + } + break; } } } @@ -3795,126 +3799,126 @@ void GetSectorIDString( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ , STR16 zS } -UINT8 SetInsertionDataFromAdjacentMoveDirection( SOLDIERTYPE *pSoldier, UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 +UINT8 SetInsertionDataFromAdjacentMoveDirection( SOLDIERTYPE *pSoldier, UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 { UINT8 ubDirection; EXITGRID ExitGrid; // Set insertion code - switch( ubTacticalDirection ) + switch ( ubTacticalDirection ) { // OK, we are using an exit grid - set insertion values... - case 255: - if ( !GetExitGrid( sAdditionalData, &ExitGrid ) ) - { - AssertMsg( 0, String( "No valid Exit grid can be found when one was expected: SetInsertionDataFromAdjacentMoveDirection." ) ); - } - ubDirection = 255; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; - pSoldier->usStrategicInsertionData = ExitGrid.usGridNo; - pSoldier->bUseExitGridForReentryDirection = TRUE; - break; + case 255: + if ( !GetExitGrid( sAdditionalData, &ExitGrid ) ) + { + AssertMsg( 0, String( "No valid Exit grid can be found when one was expected: SetInsertionDataFromAdjacentMoveDirection." ) ); + } + ubDirection = 255; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + pSoldier->usStrategicInsertionData = ExitGrid.usGridNo; + pSoldier->bUseExitGridForReentryDirection = TRUE; + break; - case NORTH: - ubDirection = NORTH_STRATEGIC_MOVE; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_SOUTH; - break; - case SOUTH: - ubDirection = SOUTH_STRATEGIC_MOVE; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; - break; - case EAST: - ubDirection = EAST_STRATEGIC_MOVE; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_WEST; - break; - case WEST: - ubDirection = WEST_STRATEGIC_MOVE; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_EAST; - break; - default: - // Wrong direction given! - #ifdef JA2BETAVERSION - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); - ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); - #endif - ubDirection = EAST_STRATEGIC_MOVE; - pSoldier->ubStrategicInsertionCode = INSERTION_CODE_WEST; - } - - return( ubDirection ); -} - -UINT8 GetInsertionDataFromAdjacentMoveDirection( UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 -{ - UINT8 ubDirection; - - // Set insertion code - switch( ubTacticalDirection ) - { - // OK, we are using an exit grid - set insertion values... - - case 255: - ubDirection = 255; - break; - case NORTH: - ubDirection = NORTH_STRATEGIC_MOVE; - break; - case SOUTH: - ubDirection = SOUTH_STRATEGIC_MOVE; - break; - case EAST: - ubDirection = EAST_STRATEGIC_MOVE; - break; - case WEST: - ubDirection = WEST_STRATEGIC_MOVE; - break; - default: - // Wrong direction given! - #ifdef JA2BETAVERSION - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to GetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); - ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to GetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); - #endif - ubDirection = EAST_STRATEGIC_MOVE; - } - - return( ubDirection ); -} - -UINT8 GetStrategicInsertionDataFromAdjacentMoveDirection( UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 -{ - UINT8 ubDirection; - - // Set insertion code - switch( ubTacticalDirection ) - { - // OK, we are using an exit grid - set insertion values... - - case 255: - ubDirection = 255; - break; - case NORTH: - ubDirection = INSERTION_CODE_SOUTH; - break; - case SOUTH: - ubDirection = INSERTION_CODE_NORTH; - break; - case EAST: - ubDirection = INSERTION_CODE_WEST; - break; - case WEST: - ubDirection = INSERTION_CODE_EAST; - break; - default: - // Wrong direction given! + case NORTH: + ubDirection = NORTH_STRATEGIC_MOVE; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_SOUTH; + break; + case SOUTH: + ubDirection = SOUTH_STRATEGIC_MOVE; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_NORTH; + break; + case EAST: + ubDirection = EAST_STRATEGIC_MOVE; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_WEST; + break; + case WEST: + ubDirection = WEST_STRATEGIC_MOVE; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_EAST; + break; + default: + // Wrong direction given! #ifdef JA2BETAVERSION - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); - ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to GetStrategicInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); + ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); #endif - ubDirection = EAST_STRATEGIC_MOVE; + ubDirection = EAST_STRATEGIC_MOVE; + pSoldier->ubStrategicInsertionCode = INSERTION_CODE_WEST; } - return( ubDirection ); + return(ubDirection); +} + +UINT8 GetInsertionDataFromAdjacentMoveDirection( UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 +{ + UINT8 ubDirection; + + // Set insertion code + switch ( ubTacticalDirection ) + { + // OK, we are using an exit grid - set insertion values... + + case 255: + ubDirection = 255; + break; + case NORTH: + ubDirection = NORTH_STRATEGIC_MOVE; + break; + case SOUTH: + ubDirection = SOUTH_STRATEGIC_MOVE; + break; + case EAST: + ubDirection = EAST_STRATEGIC_MOVE; + break; + case WEST: + ubDirection = WEST_STRATEGIC_MOVE; + break; + default: + // Wrong direction given! +#ifdef JA2BETAVERSION + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to GetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); + ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to GetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); +#endif + ubDirection = EAST_STRATEGIC_MOVE; + } + + return(ubDirection); +} + +UINT8 GetStrategicInsertionDataFromAdjacentMoveDirection( UINT8 ubTacticalDirection, INT32 sAdditionalData )//dnl ch56 151009 +{ + UINT8 ubDirection; + + // Set insertion code + switch ( ubTacticalDirection ) + { + // OK, we are using an exit grid - set insertion values... + + case 255: + ubDirection = 255; + break; + case NORTH: + ubDirection = INSERTION_CODE_SOUTH; + break; + case SOUTH: + ubDirection = INSERTION_CODE_NORTH; + break; + case EAST: + ubDirection = INSERTION_CODE_WEST; + break; + case WEST: + ubDirection = INSERTION_CODE_EAST; + break; + default: + // Wrong direction given! +#ifdef JA2BETAVERSION + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Improper insertion direction %d given to SetInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ) ); + ScreenMsg( FONT_RED, MSG_ERROR, L"Improper insertion direction %d given to GetStrategicInsertionDataFromAdjacentMoveDirection", ubTacticalDirection ); +#endif + ubDirection = EAST_STRATEGIC_MOVE; + } + + return(ubDirection); } @@ -3924,7 +3928,7 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 SOLDIERTYPE *pSoldier; SOLDIERTYPE *pValidSoldier = NULL; GROUP *pGroup; - UINT32 uiTraverseTime=0; + UINT32 uiTraverseTime = 0; UINT8 ubDirection = 0xff; EXITGRID ExitGrid; INT8 bPrevAssignment; @@ -3938,13 +3942,13 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 { // TODO: Check flags to see if we can jump! // Move controllable mercs! - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + cnt = gTacticalStatus.Team[gbPlayerNum].bFirstID; // look for all mercs on the same team, - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++,pSoldier++) + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; cnt++, pSoldier++ ) { // If we are controllable - if ( OK_CONTROLLABLE_MERC( pSoldier) && pSoldier->bAssignment == CurrentSquad( ) ) + if ( OK_CONTROLLABLE_MERC( pSoldier ) && pSoldier->bAssignment == CurrentSquad( ) ) { pValidSoldier = pSoldier; //This now gets handled by strategic movement. It is possible that the @@ -3957,22 +3961,22 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 } } } - else if ( ( ubJumpCode == JUMP_SINGLE_LOAD_NEW || ubJumpCode == JUMP_SINGLE_NO_LOAD ) ) + else if ( (ubJumpCode == JUMP_SINGLE_LOAD_NEW || ubJumpCode == JUMP_SINGLE_NO_LOAD) ) { // Use selected soldier... // This guy should always be 1 ) selected and 2 ) close enough to exit sector to leave if ( gusSelectedSoldier != NOBODY ) { - pValidSoldier = MercPtrs[ gusSelectedSoldier ]; + pValidSoldier = MercPtrs[gusSelectedSoldier]; ubDirection = GetInsertionDataFromAdjacentMoveDirection( ubTacticalDirection, sAdditionalData ); } // save info for desired squad and and time for all single mercs leaving their squad. - Assert(pValidSoldier); + Assert( pValidSoldier ); bPrevAssignment = pValidSoldier->bAssignment; ubPrevGroupID = pValidSoldier->ubGroupID; - if( ubJumpCode == JUMP_SINGLE_NO_LOAD ) + if ( ubJumpCode == JUMP_SINGLE_NO_LOAD ) { // handle soldier moving by themselves HandleSoldierLeavingSectorByThemSelf( pValidSoldier ); } @@ -3980,7 +3984,7 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 { // now add char to a squad all their own AddCharacterToUniqueSquad( pValidSoldier ); } - if( !pValidSoldier->ubNumTraversalsAllowedToMerge && bPrevAssignment < ON_DUTY ) + if ( !pValidSoldier->ubNumTraversalsAllowedToMerge && bPrevAssignment < ON_DUTY ) { PLAYERGROUP *pPlayer; pValidSoldier->ubDesiredSquadAssignment = bPrevAssignment; @@ -3990,9 +3994,9 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 Assert( pGroup->usGroupTeam == OUR_TEAM ); Assert( pGroup->ubGroupSize ); pPlayer = pGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { - if( pPlayer->pSoldier != pValidSoldier ) + if ( pPlayer->pSoldier != pValidSoldier ) { pPlayer->pSoldier->ubNumTraversalsAllowedToMerge = 100; pPlayer->pSoldier->ubDesiredSquadAssignment = NO_ASSIGNMENT; @@ -4012,22 +4016,22 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 //Now, determine the traversal time. pGroup = GetGroup( pValidSoldier->ubGroupID ); - AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)",pValidSoldier->name, pValidSoldier->ubGroupID) ); + AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)", pValidSoldier->name, pValidSoldier->ubGroupID ) ); // If we are going through an exit grid, don't get traversal direction! if ( ubTacticalDirection != 255 ) { - if( !gbWorldSectorZ ) + if ( !gbWorldSectorZ ) { uiTraverseTime = GetSectorMvtTimeForGroup( (UINT8)SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ), ubDirection, pGroup ); } - else if( gbWorldSectorZ > 0 ) + else if ( gbWorldSectorZ > 0 ) { //We are attempting to traverse in an underground environment. We need to use a complete different //method. When underground, all sectors are instantly adjacent. uiTraverseTime = UndergroundTacticalTraversalTime( ubDirection ); } - if( uiTraverseTime == 0xffffffff ) - AssertMsg( 0, "Attempting to tactically traverse to adjacent sector, despite being unable to do so."); + if ( uiTraverseTime == 0xffffffff ) + AssertMsg( 0, "Attempting to tactically traverse to adjacent sector, despite being unable to do so." ); } // Alrighty, we want to do whatever our omnipotent player asked us to do @@ -4038,18 +4042,18 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 // Setup some globals so our callback that deals when guys go off screen is handled.... // Look in the handler function AllMercsHaveWalkedOffSector() below... - gpAdjacentGroup = pGroup; - gubAdjacentJumpCode = ubJumpCode; - guiAdjacentTraverseTime = uiTraverseTime; - gubTacticalDirection = ubTacticalDirection; - gsAdditionalData = sAdditionalData; + gpAdjacentGroup = pGroup; + gubAdjacentJumpCode = ubJumpCode; + guiAdjacentTraverseTime = uiTraverseTime; + gubTacticalDirection = ubTacticalDirection; + gsAdditionalData = sAdditionalData; // If normal direction, use it! if ( ubTacticalDirection != 255 ) { - gsAdjacentSectorX = (INT16)(gWorldSectorX + DirXIncrementer[ ubTacticalDirection ]); - gsAdjacentSectorY = (INT16)(gWorldSectorY + DirYIncrementer[ ubTacticalDirection ]); - gbAdjacentSectorZ = pValidSoldier->bSectorZ; + gsAdjacentSectorX = (INT16)(gWorldSectorX + DirXIncrementer[ubTacticalDirection]); + gsAdjacentSectorY = (INT16)(gWorldSectorY + DirYIncrementer[ubTacticalDirection]); + gbAdjacentSectorZ = pValidSoldier->bSectorZ; } else { @@ -4059,10 +4063,10 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 AssertMsg( 0, String( "Told to use exit grid at %d but one does not exist", sAdditionalData ) ); } - gsAdjacentSectorX = ExitGrid.ubGotoSectorX; - gsAdjacentSectorY = ExitGrid.ubGotoSectorY; - gbAdjacentSectorZ = ExitGrid.ubGotoSectorZ; - gusDestExitGridNo = ExitGrid.usGridNo; + gsAdjacentSectorX = ExitGrid.ubGotoSectorX; + gsAdjacentSectorY = ExitGrid.ubGotoSectorY; + gbAdjacentSectorZ = ExitGrid.ubGotoSectorZ; + gusDestExitGridNo = ExitGrid.usGridNo; } // Give guy(s) orders to walk off sector... @@ -4074,10 +4078,10 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 UINT8 ubNum = 0; curr = pGroup->pPlayerList; - while( curr ) + while ( curr ) { // anv: passengers can't move anyway - if( curr->pSoldier->bAssignment == VEHICLE ) + if ( curr->pSoldier->bAssignment == VEHICLE ) { curr->pSoldier->ubWaitActionToDo = 0; } @@ -4089,12 +4093,12 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 curr->pSoldier->sPreTraversalGridNo = curr->pSoldier->sGridNo; - if (!TileIsOutOfBounds(sGridNo)) + if ( !TileIsOutOfBounds( sGridNo ) ) { // Save wait code - this will make buddy walk off screen into oblivion curr->pSoldier->ubWaitActionToDo = 2; // This will set the direction so we know now to move into oblivion - curr->pSoldier->aiData.uiPendingActionData1 = ubTacticalDirection; + curr->pSoldier->aiData.uiPendingActionData1 = ubTacticalDirection; } else { @@ -4107,11 +4111,11 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 { // Here, get closest location for exit grid.... sGridNo = FindGridNoFromSweetSpotCloseToExitGrid( curr->pSoldier, sAdditionalData, 10, &ubDirection ); - - if (!TileIsOutOfBounds(sGridNo)) + + if ( !TileIsOutOfBounds( sGridNo ) ) { // Save wait code - this will make buddy walk off screen into oblivion - // curr->pSoldier->ubWaitActionToDo = 2; + // curr->pSoldier->ubWaitActionToDo = 2; } else { @@ -4138,14 +4142,14 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 } // ATE: Do another round, removing guys from group that can't go on... -BEGINNING_LOOP: + BEGINNING_LOOP: curr = pGroup->pPlayerList; - while( curr ) + while ( curr ) { if ( !OK_CONTROLLABLE_MERC( curr->pSoldier ) ) { - if(OK_CONTROL_MERC(curr->pSoldier) && curr->pSoldier->bAssignment == VEHICLE && pGroup->fVehicle) + if ( OK_CONTROL_MERC( curr->pSoldier ) && curr->pSoldier->bAssignment == VEHICLE && pGroup->fVehicle ) { //CHRISL: passengers in a vehicle movement group will not pass the OK_CONTROLLABLE_MERC check because their assignment is not "ON_DUTY". // The above conditions should allow passengers in a vehicle movement group to remain in the group. @@ -4158,7 +4162,7 @@ BEGINNING_LOOP: } curr = curr->next; } - + // OK, setup TacticalOverhead polling system that will notify us once everybody // has made it to our destination. if ( ubTacticalDirection != 255 ) @@ -4183,22 +4187,22 @@ void HandleSoldierLeavingSectorByThemSelf( SOLDIERTYPE *pSoldier ) // soldier leaving thier squad behind, will rejoin later // if soldier in a squad, set the fact they want to return here - if( pSoldier->bAssignment < ON_DUTY ) + if ( pSoldier->bAssignment < ON_DUTY ) { - RemoveCharacterFromSquads( pSoldier ); + RemoveCharacterFromSquads( pSoldier ); // are they in a group?..remove from group - if( pSoldier->ubGroupID != 0 ) + if ( pSoldier->ubGroupID != 0 ) { // remove from group - RemovePlayerFromGroup( pSoldier->ubGroupID, pSoldier ); + RemovePlayerFromGroup( pSoldier->ubGroupID, pSoldier ); pSoldier->ubGroupID = 0; } } else { // otherwise, they are on thier own, not in a squad, simply remove mvt group - if( pSoldier->ubGroupID && pSoldier->bAssignment != VEHICLE ) + if ( pSoldier->ubGroupID && pSoldier->bAssignment != VEHICLE ) { //Can only remove groups if they aren't persistant (not in a squad or vehicle) // delete group RemoveGroup( pSoldier->ubGroupID ); @@ -4209,21 +4213,21 @@ void HandleSoldierLeavingSectorByThemSelf( SOLDIERTYPE *pSoldier ) // set to guard AddCharacterToUniqueSquad( pSoldier ); - if( pSoldier->ubGroupID == 0 ) + if ( pSoldier->ubGroupID == 0 ) { - // create independant group + // create independant group UINT8 ubGroupId = CreateNewPlayerGroupDepartingFromSector( (UINT8)pSoldier->sSectorX, (UINT8)pSoldier->sSectorY ); - AddPlayerToGroup( ubGroupId , pSoldier ); + AddPlayerToGroup( ubGroupId, pSoldier ); } } -void AllMercsWalkedToExitGrid() +void AllMercsWalkedToExitGrid( ) { PLAYERGROUP *pPlayer; BOOLEAN fDone; // SANDRO was here.. made some tweaks, fixed some stuff BOOLEAN fEnemiesInLoadedSector = FALSE; - if( NumEnemiesInAnySector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) ) + if ( NumEnemiesInAnySector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) ) { fEnemiesInLoadedSector = TRUE; //////////////////////////////////////////////////////////////////////////////////////// @@ -4232,14 +4236,14 @@ void AllMercsWalkedToExitGrid() // if all mercs leaving, morale gets hit // if one merc only leaves, but there are others fighting on, don't reduce the morale // if sector is about to be loaded and there are enemies in the current, then all mercs are leaving, so the morale gets hit - if( ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD && gpAdjacentGroup->ubGroupSize >= PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ )) || - ( gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD && PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ ) <= 1 ) || - ( gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW ) ) + if ( (gubAdjacentJumpCode == JUMP_ALL_NO_LOAD && gpAdjacentGroup->ubGroupSize >= PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ )) || + (gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD && PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ ) <= 1) || + (gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) ) { HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - + // End inetrrogation quest if we left the sector, but haven't killed all enemies - if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[ QUEST_INTERROGATION ] == QUESTINPROGRESS ) + if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS ) { // Finish quest, although not give points here... InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE ); @@ -4254,17 +4258,17 @@ void AllMercsWalkedToExitGrid() HandlePotentialMoraleHitForSkimmingSectors( gpAdjacentGroup ); } - if( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) + if ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) { Assert( gpAdjacentGroup ); //pPlayer = gpAdjacentGroup->pPlayerList; // SANDRO - why was this here twice? pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { ///////////////////////////////////////////////////////////////////////////////// // SANDRO - merc records - times retreated counter - if( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) - gMercProfiles[ pPlayer->pSoldier->ubProfile ].records.usBattlesRetreated++; + if ( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) + gMercProfiles[pPlayer->pSoldier->ubProfile].records.usBattlesRetreated++; ///////////////////////////////////////////////////////////////////////////////// SetInsertionDataFromAdjacentMoveDirection( pPlayer->pSoldier, gubTacticalDirection, gsAdditionalData ); @@ -4274,14 +4278,14 @@ void AllMercsWalkedToExitGrid() pPlayer = pPlayer->next; } - SetGroupSectorValue( gsAdjacentSectorX, gsAdjacentSectorY, (INT16) gbAdjacentSectorZ, gpAdjacentGroup->ubGroupID ); + SetGroupSectorValue( gsAdjacentSectorX, gsAdjacentSectorY, (INT16)gbAdjacentSectorZ, gpAdjacentGroup->ubGroupID ); AttemptToMergeSeparatedGroups( gpAdjacentGroup, FALSE ); SetDefaultSquadOnSectorEntry( TRUE ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SANDRO - reset num enemies here if the sector was unloaded - if( gWorldSectorX == 0 && gWorldSectorY == 0 && gbWorldSectorZ == -1 ) + if ( gWorldSectorX == 0 && gWorldSectorY == 0 && gbWorldSectorZ == -1 ) { memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); } @@ -4290,7 +4294,7 @@ void AllMercsWalkedToExitGrid() else { // SANDRO - reset number of enemies here, we are about to load a new sector - memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); + memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); //Because we are actually loading the new map, and we are physically traversing, we don't want //to bring up the prebattle interface when we arrive if there are enemies there. This flag @@ -4301,13 +4305,13 @@ void AllMercsWalkedToExitGrid() //Check for any unconcious and/or dead merc and remove them from the current squad, so that they //don't get moved to the new sector. fDone = FALSE; - while( !fDone ) + while ( !fDone ) { fDone = FALSE; pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { - if( pPlayer->pSoldier->stats.bLife < OKLIFE ) + if ( pPlayer->pSoldier->stats.bLife < OKLIFE ) { AddCharacterToUniqueSquad( pPlayer->pSoldier ); break; @@ -4315,7 +4319,7 @@ void AllMercsWalkedToExitGrid() InitSoldierOppList( pPlayer->pSoldier ); pPlayer = pPlayer->next; } - if( !pPlayer ) + if ( !pPlayer ) { fDone = TRUE; } @@ -4324,19 +4328,19 @@ void AllMercsWalkedToExitGrid() // OK, Set insertion direction for all these guys.... Assert( gpAdjacentGroup ); pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { ///////////////////////////////////////////////////////////////////////////////// // SANDRO - merc records - times retreated counter - if( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) - gMercProfiles[ pPlayer->pSoldier->ubProfile ].records.usBattlesRetreated++; + if ( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) + gMercProfiles[pPlayer->pSoldier->ubProfile].records.usBattlesRetreated++; ///////////////////////////////////////////////////////////////////////////////// SetInsertionDataFromAdjacentMoveDirection( pPlayer->pSoldier, gubTacticalDirection, gsAdditionalData ); pPlayer = pPlayer->next; } - SetGroupSectorValue( gsAdjacentSectorX, gsAdjacentSectorY, (INT16) gbAdjacentSectorZ, gpAdjacentGroup->ubGroupID ); + SetGroupSectorValue( gsAdjacentSectorX, gsAdjacentSectorY, (INT16)gbAdjacentSectorZ, gpAdjacentGroup->ubGroupID ); AttemptToMergeSeparatedGroups( gpAdjacentGroup, FALSE ); gFadeOutDoneCallback = DoneFadeOutExitGridSector; @@ -4347,7 +4351,7 @@ void AllMercsWalkedToExitGrid() //{ // HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gsAdjacentSectorX, gsAdjacentSectorY, gbAdjacentSectorZ ); //} - if( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) + if ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) { gfTacticalTraversal = FALSE; gpTacticalTraversalGroup = NULL; @@ -4355,14 +4359,14 @@ void AllMercsWalkedToExitGrid() } } -void SetupTacticalTraversalInformation() +void SetupTacticalTraversalInformation( ) { SOLDIERTYPE *pSoldier; PLAYERGROUP *pPlayer; Assert( gpAdjacentGroup ); pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { pSoldier = pPlayer->pSoldier; @@ -4372,21 +4376,21 @@ void SetupTacticalTraversalInformation() PlotPathForCharacter( pSoldier, gsAdjacentSectorX, gsAdjacentSectorY, TRUE ); //dnl ch48 041009 - if(guiAdjacentTraverseTime <= 5) + if ( guiAdjacentTraverseTime <= 5 ) { // Save this gridNo.... - pSoldier->aiData.sPendingActionData2 = GETWORLDINDEXFROMWORLDCOORDS(pSoldier->sY, pSoldier->sX); + pSoldier->aiData.sPendingActionData2 = GETWORLDINDEXFROMWORLDCOORDS( pSoldier->sY, pSoldier->sX ); // Copy CODe computed earlier into data pSoldier->usStrategicInsertionData = pSoldier->ubStrategicInsertionCode; // Now use NEW code.... - pSoldier->ubStrategicInsertionCode = CalcMapEdgepointClassInsertionCode(pSoldier->sPreTraversalGridNo); - if(gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW || gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW) + pSoldier->ubStrategicInsertionCode = CalcMapEdgepointClassInsertionCode( pSoldier->sPreTraversalGridNo ); + if ( gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW || gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW ) fUsingEdgePointsForStrategicEntry = TRUE; } pPlayer = pPlayer->next; } - if( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) + if ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) { gfTacticalTraversal = FALSE; gpTacticalTraversalGroup = NULL; @@ -4396,12 +4400,12 @@ void SetupTacticalTraversalInformation() void AllMercsHaveWalkedOffSector( ) { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"AllMercsHaveWalkedOffSector"); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "AllMercsHaveWalkedOffSector" ); PLAYERGROUP *pPlayer; BOOLEAN fEnemiesInLoadedSector = FALSE; - if( NumEnemiesInAnySector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) ) + if ( NumEnemiesInAnySector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) ) { fEnemiesInLoadedSector = TRUE; //////////////////////////////////////////////////////////////////////////////////////// @@ -4410,14 +4414,14 @@ void AllMercsHaveWalkedOffSector( ) // if all mercs leaving, morale gets hit // if one merc only leaves, but there are others fighting on, don't reduce the morale // if sector is about to be loaded and there are enemies in the current, then all mercs are leaving alway - if( ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD && gpAdjacentGroup->ubGroupSize >= PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ )) || - ( gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD && PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ ) <= 1 ) || - ( gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW ) ) + if ( (gubAdjacentJumpCode == JUMP_ALL_NO_LOAD && gpAdjacentGroup->ubGroupSize >= PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ )) || + (gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD && PlayerMercsInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, (UINT8)gbWorldSectorZ ) <= 1) || + (gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) ) { HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - + // End inetrrogation quest if we left the sector, but haven't killed all enemies - if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[ QUEST_INTERROGATION ] == QUESTINPROGRESS ) + if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS ) { // Finish quest, although not give points here... InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE ); @@ -4431,36 +4435,36 @@ void AllMercsHaveWalkedOffSector( ) } //Setup strategic traversal information - if( guiAdjacentTraverseTime <= 5 ) + if ( guiAdjacentTraverseTime <= 5 ) { gfTacticalTraversal = TRUE; gpTacticalTraversalGroup = gpAdjacentGroup; - if( gbAdjacentSectorZ > 0 && guiAdjacentTraverseTime <= 5 ) + if ( gbAdjacentSectorZ > 0 && guiAdjacentTraverseTime <= 5 ) { //Nasty strategic movement logic doesn't like underground sectors! gfUndergroundTacticalTraversal = TRUE; } } ClearMercPathsAndWaypointsForAllInGroup( gpAdjacentGroup ); AddWaypointToPGroup( gpAdjacentGroup, (UINT8)gsAdjacentSectorX, (UINT8)gsAdjacentSectorY ); - if( gbAdjacentSectorZ > 0 && guiAdjacentTraverseTime <= 5 ) + if ( gbAdjacentSectorZ > 0 && guiAdjacentTraverseTime <= 5 ) { //Nasty strategic movement logic doesn't like underground sectors! gfUndergroundTacticalTraversal = TRUE; } - SetupTacticalTraversalInformation(); + SetupTacticalTraversalInformation( ); // ATE: Added here: donot load another screen if we were told not to.... - if( ( gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD ) ) + if ( (gubAdjacentJumpCode == JUMP_ALL_NO_LOAD || gubAdjacentJumpCode == JUMP_SINGLE_NO_LOAD) ) { //Case 1: Group is leaving sector, but there are other mercs in sector and player wants to stay, or // there are other mercs in sector while a battle is in progress. pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { ///////////////////////////////////////////////////////////////////////////////// // SANDRO - merc records - times retreated counter - if( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) - gMercProfiles[ pPlayer->pSoldier->ubProfile ].records.usBattlesRetreated++; + if ( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) + gMercProfiles[pPlayer->pSoldier->ubProfile].records.usBattlesRetreated++; ///////////////////////////////////////////////////////////////////////////////// RemoveSoldierFromTacticalSector( pPlayer->pSoldier, TRUE ); pPlayer = pPlayer->next; @@ -4468,7 +4472,7 @@ void AllMercsHaveWalkedOffSector( ) SetDefaultSquadOnSectorEntry( TRUE ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SANDRO - reset num enemies here if the sector was unloaded - if( !fEnemiesInLoadedSector || (gWorldSectorX == 0 && gWorldSectorY == 0 && gbWorldSectorZ == -1 ) ) + if ( !fEnemiesInLoadedSector || (gWorldSectorX == 0 && gWorldSectorY == 0 && gbWorldSectorZ == -1) ) { memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); } @@ -4477,17 +4481,17 @@ void AllMercsHaveWalkedOffSector( ) else { // SANDRO - reset number of enemies here, we are about to load a new sector - memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); + memset( &(gTacticalStatus.bNumFoughtInBattle), 0, MAXTEAMS ); - if( fEnemiesInLoadedSector ) + if ( fEnemiesInLoadedSector ) { ///////////////////////////////////////////////////////////////////////////////// // SANDRO - merc records - times retreated counter pPlayer = gpAdjacentGroup->pPlayerList; - while( pPlayer ) + while ( pPlayer ) { - if( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) - gMercProfiles[ pPlayer->pSoldier->ubProfile ].records.usBattlesRetreated++; + if ( fEnemiesInLoadedSector && pPlayer->pSoldier->ubProfile != NO_PROFILE ) + gMercProfiles[pPlayer->pSoldier->ubProfile].records.usBattlesRetreated++; pPlayer = pPlayer->next; } ///////////////////////////////////////////////////////////////////////////////// @@ -4499,25 +4503,25 @@ void AllMercsHaveWalkedOffSector( ) //are "in" the sector rather than 75% of the way to the next sector if that is the case. ResetMovementForNonPlayerGroupsInLocation( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY ); - if( guiAdjacentTraverseTime > 5 ) + if ( guiAdjacentTraverseTime > 5 ) { //Because this final group is retreating, simulate extra time to retreat, so they can't immediately come back. WarpGameTime( 300, WARPTIME_NO_PROCESSING_OF_EVENTS ); } } - if( guiAdjacentTraverseTime <= 5 ) + if ( guiAdjacentTraverseTime <= 5 ) { //Case 2: Immediatly loading the next sector - if( !gbAdjacentSectorZ ) + if ( !gbAdjacentSectorZ ) { UINT32 uiWarpTime; - uiWarpTime = (GetWorldTotalMin() + 5) * 60 - GetWorldTotalSeconds(); + uiWarpTime = (GetWorldTotalMin( ) + 5) * 60 - GetWorldTotalSeconds( ); WarpGameTime( uiWarpTime, WARPTIME_PROCESS_TARGET_TIME_FIRST ); } - else if( gbAdjacentSectorZ > 0 ) + else if ( gbAdjacentSectorZ > 0 ) { UINT32 uiWarpTime; - uiWarpTime = (GetWorldTotalMin() + 1) * 60 - GetWorldTotalSeconds(); + uiWarpTime = (GetWorldTotalMin( ) + 1) * 60 - GetWorldTotalSeconds( ); WarpGameTime( uiWarpTime, WARPTIME_PROCESS_TARGET_TIME_FIRST ); } @@ -4535,25 +4539,25 @@ void AllMercsHaveWalkedOffSector( ) // ATE; Fade FAST.... SetMusicFadeSpeed( 5 ); - - #ifdef NEWMUSIC - GlobalSoundID = MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ]; - if ( MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] != -1 ) - SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[ SECTOR( gWorldSectorX, gWorldSectorY ) ].SoundTacticalNothing[gbWorldSectorZ] ); + +#ifdef NEWMUSIC + GlobalSoundID = MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ]; + if ( MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ] != -1 ) + SetMusicModeID( MUSIC_TACTICAL_NOTHING, MusicSoundValues[SECTOR( gWorldSectorX, gWorldSectorY )].SoundTacticalNothing[gbWorldSectorZ] ); else - #endif - SetMusicMode( MUSIC_TACTICAL_NOTHING ); +#endif + SetMusicMode( MUSIC_TACTICAL_NOTHING ); } } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"AllMercsHaveWalkedOffSector done"); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "AllMercsHaveWalkedOffSector done" ); } void DoneFadeOutExitGridSector( ) { SetCurrentWorldSector( gsAdjacentSectorX, gsAdjacentSectorY, gbAdjacentSectorZ ); - if( gfTacticalTraversal && gpTacticalTraversalGroup && gpTacticalTraversalChosenSoldier ) + if ( gfTacticalTraversal && gpTacticalTraversalGroup && gpTacticalTraversalChosenSoldier ) { - if( gTacticalStatus.fEnemyInSector ) + if ( gTacticalStatus.fEnemyInSector ) { TacticalCharacterDialogueWithSpecialEvent( gpTacticalTraversalChosenSoldier, QUOTE_ENEMY_PRESENCE, 0, 0, 0 ); } @@ -4570,9 +4574,9 @@ void DoneFadeOutAdjacentSector( ) SetCurrentWorldSector( gsAdjacentSectorX, gsAdjacentSectorY, gbAdjacentSectorZ ); ubDirection = GetStrategicInsertionDataFromAdjacentMoveDirection( gubTacticalDirection, gsAdditionalData ); - if( gfTacticalTraversal && gpTacticalTraversalGroup && gpTacticalTraversalChosenSoldier ) + if ( gfTacticalTraversal && gpTacticalTraversalGroup && gpTacticalTraversalChosenSoldier ) { - if( gTacticalStatus.fEnemyInSector ) + if ( gTacticalStatus.fEnemyInSector ) { TacticalCharacterDialogueWithSpecialEvent( gpTacticalTraversalChosenSoldier, QUOTE_ENEMY_PRESENCE, 0, 0, 0 ); } @@ -4599,24 +4603,24 @@ void DoneFadeOutAdjacentSector( ) UINT8 ubNum = 0; INT16 sWorldX, sWorldY; curr = gpAdjacentGroup->pPlayerList; - while( curr ) + while ( curr ) { - if( !(curr->pSoldier->flags.uiStatusFlags & SOLDIER_IS_TACTICALLY_VALID) ) - { - if(!TileIsOutOfBounds(curr->pSoldier->sGridNo)) + if ( !(curr->pSoldier->flags.uiStatusFlags & SOLDIER_IS_TACTICALLY_VALID) ) + { + if ( !TileIsOutOfBounds( curr->pSoldier->sGridNo ) ) { sGridNo = PickGridNoToWalkIn( curr->pSoldier, ubDirection, &uiAttempts ); //If the search algorithm failed due to too many attempts, simply reset the //the gridno as the destination is a reserved gridno and we will place the //merc there without walking into the sector. - - if (TileIsOutOfBounds(sGridNo) && uiAttempts == MAX_ATTEMPTS ) + + if ( TileIsOutOfBounds( sGridNo ) && uiAttempts == MAX_ATTEMPTS ) { sGridNo = curr->pSoldier->sGridNo; } - if(!TileIsOutOfBounds(sGridNo)) + if ( !TileIsOutOfBounds( sGridNo ) ) { curr->pSoldier->ubWaitActionToDo = 1; // OK, here we have been given a position, a gridno has been given to use as well.... @@ -4624,7 +4628,7 @@ void DoneFadeOutAdjacentSector( ) sWorldX = CenterX( sGridNo ); sWorldY = CenterY( sGridNo ); curr->pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); - if( sGridNo != sOldGridNo ) + if ( sGridNo != sOldGridNo ) { curr->pSoldier->EVENT_GetNewSoldierPath( sOldGridNo, WALKING ); } @@ -4633,11 +4637,11 @@ void DoneFadeOutAdjacentSector( ) } else { - #ifdef JA2BETAVERSION - CHAR8 str[256]; - sprintf( str, "%S's gridno is NOWHERE, and is attempting to walk into sector.", curr->pSoldier->name ); - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); - #endif +#ifdef JA2BETAVERSION + CHAR8 str[256]; + sprintf( str, "%S's gridno is NOWHERE, and is attempting to walk into sector.", curr->pSoldier->name ); + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, str ); +#endif } } curr = curr->next; @@ -4666,92 +4670,92 @@ BOOLEAN SoldierOKForSectorExit( SOLDIERTYPE * pSoldier, INT8 bExitDirection, INT INT16 sAPs; // if the soldiers gridno is not NOWHERE - if(TileIsOutOfBounds(pSoldier->sGridNo)) - return( FALSE ); + if ( TileIsOutOfBounds( pSoldier->sGridNo ) ) + return(FALSE); // OK, anyone on roofs cannot! if ( pSoldier->pathing.bLevel > 0 ) - return( FALSE ); + return(FALSE); // get world absolute XY ConvertGridNoToXY( pSoldier->sGridNo, &sXMapPos, &sYMapPos ); // Get screen coordinates for current position of soldier - GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY); + GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY ); // Check direction - switch( bExitDirection ) + switch ( bExitDirection ) { - case EAST_STRATEGIC_MOVE: + case EAST_STRATEGIC_MOVE: - if ( sWorldX < ( ( gsTRX - gsTLX ) - CHECK_DIR_X_DELTA ) ) + if ( sWorldX < ((gsTRX - gsTLX) - CHECK_DIR_X_DELTA) ) + { + // NOT OK, return FALSE + return(FALSE); + } + break; + + case WEST_STRATEGIC_MOVE: + + if ( sWorldX > CHECK_DIR_X_DELTA ) + { + // NOT OK, return FALSE + return(FALSE); + } + break; + + case SOUTH_STRATEGIC_MOVE: + + if ( sWorldY < ((gsBLY - gsTRY) - CHECK_DIR_Y_DELTA) ) + { + // NOT OK, return FALSE + return(FALSE); + } + break; + + case NORTH_STRATEGIC_MOVE: + + if ( sWorldY > CHECK_DIR_Y_DELTA ) + { + // NOT OK, return FALSE + return(FALSE); + } + break; + + // This case is for an exit grid.... + // check if we are close enough..... + + case -1: + + + // FOR REALTIME - DO MOVEMENT BASED ON STANCE! + if ( (gTacticalStatus.uiFlags & REALTIME) || !(gTacticalStatus.uiFlags & INCOMBAT) ) + { + pSoldier->usUIMovementMode = pSoldier->GetMoveStateBasedOnStance( gAnimControl[pSoldier->usAnimState].ubEndHeight ); + } + + sGridNo = FindGridNoFromSweetSpotCloseToExitGrid( pSoldier, usAdditionalData, 10, &ubDirection ); + + if ( TileIsOutOfBounds( sGridNo ) ) + { + return(FALSE); + } + + // ATE: if we are in combat, get cost to move here.... + if ( gTacticalStatus.uiFlags & INCOMBAT ) + { + // Turn off at end of function... + sAPs = PlotPath( pSoldier, sGridNo, NO_COPYROUTE, NO_PLOT, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); + + if ( !EnoughPoints( pSoldier, sAPs, 0, FALSE ) ) { - // NOT OK, return FALSE - return( FALSE ); + return(FALSE); } - break; - - case WEST_STRATEGIC_MOVE: - - if ( sWorldX > CHECK_DIR_X_DELTA ) - { - // NOT OK, return FALSE - return( FALSE ); - } - break; - - case SOUTH_STRATEGIC_MOVE: - - if ( sWorldY < ( ( gsBLY - gsTRY ) - CHECK_DIR_Y_DELTA ) ) - { - // NOT OK, return FALSE - return( FALSE ); - } - break; - - case NORTH_STRATEGIC_MOVE: - - if ( sWorldY > CHECK_DIR_Y_DELTA ) - { - // NOT OK, return FALSE - return( FALSE ); - } - break; - - // This case is for an exit grid.... - // check if we are close enough..... - - case -1: - - - // FOR REALTIME - DO MOVEMENT BASED ON STANCE! - if ( ( gTacticalStatus.uiFlags & REALTIME ) || !( gTacticalStatus.uiFlags & INCOMBAT ) ) - { - pSoldier->usUIMovementMode = pSoldier->GetMoveStateBasedOnStance( gAnimControl[ pSoldier->usAnimState ].ubEndHeight ); - } - - sGridNo = FindGridNoFromSweetSpotCloseToExitGrid( pSoldier, usAdditionalData, 10, &ubDirection ); - - if (TileIsOutOfBounds(sGridNo)) - { - return( FALSE ); - } - - // ATE: if we are in combat, get cost to move here.... - if ( gTacticalStatus.uiFlags & INCOMBAT ) - { - // Turn off at end of function... - sAPs = PlotPath( pSoldier, sGridNo, NO_COPYROUTE, NO_PLOT, TEMPORARY, (UINT16)pSoldier->usUIMovementMode, NOT_STEALTH, FORWARD, pSoldier->bActionPoints ); - - if ( !EnoughPoints( pSoldier, sAPs, 0, FALSE ) ) - { - return( FALSE ); - } - } - break; + } + break; } - return( TRUE ); + return(TRUE); } //ATE: Returns FALSE if NOBODY is close enough, 1 if ONLY selected guy is and 2 if all on squad are... @@ -4767,13 +4771,13 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu UINT8 ubNumMercs = 0, ubNumEPCs = 0; UINT8 ubPlayerControllableMercsInSquad = 0; - if( gusSelectedSoldier == NOBODY ) + if ( gusSelectedSoldier == NOBODY ) { //must have a selected soldier to be allowed to tactically traverse. return FALSE; } // anv: vehicles can't use inner exit grids - if( bExitDirection == (-1) && MercPtrs[gusSelectedSoldier]->bAssignment == VEHICLE ) + if ( bExitDirection == (-1) && MercPtrs[gusSelectedSoldier]->bAssignment == VEHICLE ) { return FALSE; } @@ -4784,13 +4788,13 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu //the cave entrance. if( gWorldSectorX == 4 && gWorldSectorY == 4 && !gbWorldSectorZ && bExitDirection == EAST_STRATEGIC_MOVE ) { - gfInvalidTraversal = TRUE; - return FALSE; + gfInvalidTraversal = TRUE; + return FALSE; } if( gWorldSectorX == 5 && gWorldSectorY == 4 && !gbWorldSectorZ && bExitDirection == WEST_STRATEGIC_MOVE ) { - gfInvalidTraversal = TRUE; - return FALSE; + gfInvalidTraversal = TRUE; + return FALSE; } */ @@ -4800,15 +4804,15 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu gbPotentiallyAbandonedEPCSlotID = -1; // Look through all mercs and check if they are within range of east end.... - cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + cnt = gTacticalStatus.Team[gbPlayerNum].bFirstID; - // look for all mercs on the same team, - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++cnt, ++pSoldier) + // look for all mercs on the same team, + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[gbPlayerNum].bLastID; ++cnt, ++pSoldier ) { // If we are controllable //if ( OK_CONTROLLABLE_MERC( pSoldier) && pSoldier->bAssignment == CurrentSquad( ) ) - if ( OK_CONTROLLABLE_MERC( pSoldier) && ( pSoldier->bAssignment == CurrentSquad( ) || - ( pSoldier->bAssignment == VEHICLE && GetSoldierStructureForVehicle(pSoldier->iVehicleId)->bAssignment == CurrentSquad( ) ) ) ) + if ( OK_CONTROLLABLE_MERC( pSoldier ) && (pSoldier->bAssignment == CurrentSquad( ) || + (pSoldier->bAssignment == VEHICLE && GetSoldierStructureForVehicle( pSoldier->iVehicleId )->bAssignment == CurrentSquad( ))) ) { //Need to keep a copy of a good soldier, so we can access it later, and //not more than once. @@ -4819,12 +4823,12 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu //We need to keep track of the number of EPCs and mercs in this squad. If we have //only one merc and one or more EPCs, then we can't allow the merc to tactically traverse, //if he is the only merc near enough to traverse. - if( AM_AN_EPC( pSoldier ) ) + if ( AM_AN_EPC( pSoldier ) ) { ubNumEPCs++; //Also record the EPC's slot ID incase we later build a string using the EPC's name. gbPotentiallyAbandonedEPCSlotID = (INT8)cnt; - if( AM_A_ROBOT( pSoldier ) && !pSoldier->CanRobotBeControlled( ) ) + if ( AM_A_ROBOT( pSoldier ) && !pSoldier->CanRobotBeControlled( ) ) { gfRobotWithoutControllerAttemptingTraversal = TRUE; ubNumControllableMercs--; @@ -4854,17 +4858,17 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu { //Now, determine if this is a valid path. pGroup = GetGroup( pValidSoldier->ubGroupID ); - AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)",pValidSoldier->name, pValidSoldier->ubGroupID) ); - if( !gbWorldSectorZ ) + AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)", pValidSoldier->name, pValidSoldier->ubGroupID ) ); + if ( !gbWorldSectorZ ) { *puiTraverseTimeInMinutes = GetSectorMvtTimeForGroup( (UINT8)SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ), bExitDirection, pGroup ); } - else if( gbWorldSectorZ > 1 ) + else if ( gbWorldSectorZ > 1 ) { //We are attempting to traverse in an underground environment. We need to use a complete different //method. When underground, all sectors are instantly adjacent. *puiTraverseTimeInMinutes = UndergroundTacticalTraversalTime( bExitDirection ); } - if( *puiTraverseTimeInMinutes == 0xffffffff ) + if ( *puiTraverseTimeInMinutes == 0xffffffff ) { gfInvalidTraversal = TRUE; return FALSE; @@ -4879,21 +4883,21 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu } // If we are here, at least one guy is controllable in this sector, at least he can go! - if( fAtLeastOneMercControllable ) + if ( fAtLeastOneMercControllable ) { - ubPlayerControllableMercsInSquad = (UINT8)NumberOfPlayerControllableMercsInSquad( MercPtrs[ gusSelectedSoldier ]->bAssignment ); - if( fAtLeastOneMercControllable <= ubPlayerControllableMercsInSquad ) + ubPlayerControllableMercsInSquad = (UINT8)NumberOfPlayerControllableMercsInSquad( MercPtrs[gusSelectedSoldier]->bAssignment ); + if ( fAtLeastOneMercControllable <= ubPlayerControllableMercsInSquad ) { //if the selected merc is an EPC and we can only leave with that merc, then prevent it //as EPCs aren't allowed to leave by themselves. Instead of restricting this in the //exiting sector gui, we restrict it by explaining it with a message box. - if ( AM_AN_EPC( MercPtrs[ gusSelectedSoldier ] ) ) + if ( AM_AN_EPC( MercPtrs[gusSelectedSoldier] ) ) { - if( AM_A_ROBOT( pSoldier ) && !pSoldier->CanRobotBeControlled( ) ) + if ( AM_A_ROBOT( pSoldier ) && !pSoldier->CanRobotBeControlled( ) ) { //gfRobotWithoutControllerAttemptingTraversal = TRUE; return FALSE; } - else if( fAtLeastOneMercControllable < ubPlayerControllableMercsInSquad || fAtLeastOneMercControllable == 1 ) + else if ( fAtLeastOneMercControllable < ubPlayerControllableMercsInSquad || fAtLeastOneMercControllable == 1 ) { gfLoneEPCAttemptingTraversal = TRUE; return FALSE; @@ -4902,7 +4906,7 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu else { //We previously counted the number of EPCs and mercs, and if the selected merc is not an EPC and there are no //other mercs in the squad able to escort the EPCs, we will prohibit this merc from tactically traversing. - if( ubNumEPCs && ubNumMercs == 1 && fAtLeastOneMercControllable < ubPlayerControllableMercsInSquad ) + if ( ubNumEPCs && ubNumMercs == 1 && fAtLeastOneMercControllable < ubPlayerControllableMercsInSquad ) { gubLoneMercAttemptingToAbandonEPCs = ubNumEPCs; return FALSE; @@ -4914,17 +4918,17 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu GROUP *pGroup; //Now, determine if this is a valid path. pGroup = GetGroup( pValidSoldier->ubGroupID ); - AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)",pValidSoldier->name, pValidSoldier->ubGroupID) ); - if( !gbWorldSectorZ ) + AssertMsg( pGroup, String( "%S is not in a valid group (pSoldier->ubGroupID is %d)", pValidSoldier->name, pValidSoldier->ubGroupID ) ); + if ( !gbWorldSectorZ ) { *puiTraverseTimeInMinutes = GetSectorMvtTimeForGroup( (UINT8)SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ), bExitDirection, pGroup ); } - else if( gbWorldSectorZ > 0 ) + else if ( gbWorldSectorZ > 0 ) { //We are attempting to traverse in an underground environment. We need to use a complete different //method. When underground, all sectors are instantly adjacent. *puiTraverseTimeInMinutes = UndergroundTacticalTraversalTime( bExitDirection ); } - if( *puiTraverseTimeInMinutes == 0xffffffff ) + if ( *puiTraverseTimeInMinutes == 0xffffffff ) { gfInvalidTraversal = TRUE; ubReturnVal = FALSE; @@ -4961,7 +4965,7 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu } } - return( ubReturnVal ); + return(ubReturnVal); } @@ -4972,25 +4976,25 @@ void SetupNewStrategicGame( ) { for ( INT16 sSectorY = 0; sSectorY < MAP_WORLD_Y; ++sSectorY ) { - StrategicMap[ CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].fEnemyControlled = TRUE; + StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].fEnemyControlled = TRUE; } } - + #ifdef JA2UB //Ja25 // Make the initial sector free of enemies - StrategicMap[ CALCULATE_STRATEGIC_INDEX( JA2_5_START_SECTOR_X, JA2_5_START_SECTOR_Y ) ].fEnemyControlled = FALSE; + StrategicMap[CALCULATE_STRATEGIC_INDEX( JA2_5_START_SECTOR_X, JA2_5_START_SECTOR_Y )].fEnemyControlled = FALSE; #endif //Initialize the game time - InitNewGameClock(); + InitNewGameClock( ); //Remove all events - DeleteAllStrategicEvents(); + DeleteAllStrategicEvents( ); //Set up all events that get processed daily... //............................................. - BuildDayLightLevels(); + BuildDayLightLevels( ); // Check for quests each morning AddEveryDayStrategicEvent( EVENT_CHECKFORQUESTS, QUEST_CHECK_EVENT_TIME, 0 ); // Some things get updated in the very early morning @@ -4999,14 +5003,14 @@ void SetupNewStrategicGame( ) AddEveryDayStrategicEvent( EVENT_DAILY_UPDATE_BOBBY_RAY_INVENTORY, BOBBYRAY_UPDATE_TIME, 0 ); //Daily Update of the M.E.R.C. site. AddEveryDayStrategicEvent( EVENT_DAILY_UPDATE_OF_MERC_SITE, 0, 0 ); - + #ifdef JA2UB -//Ja25: No insurance for mercs -//JA25: There is no mines -//Ja25 no town opinions + //Ja25: No insurance for mercs + //JA25: There is no mines + //Ja25 no town opinions #else //Daily update of insured mercs - AddEveryDayStrategicEvent( EVENT_HANDLE_INSURED_MERCS, INSURANCE_UPDATE_TIME, 0 ); + AddEveryDayStrategicEvent( EVENT_HANDLE_INSURED_MERCS, INSURANCE_UPDATE_TIME, 0 ); //Daily update of mercs AddEveryDayStrategicEvent( EVENT_MERC_DAILY_UPDATE, 0, 0 ); // Daily mine production processing events @@ -5014,25 +5018,25 @@ void SetupNewStrategicGame( ) // Daily merc reputation processing events AddEveryDayStrategicEvent( EVENT_SETUP_TOWN_OPINION, 0, 0 ); // Daily checks for E-mail from Enrico - AddEveryDayStrategicEvent( EVENT_ENRICO_MAIL, ENRICO_MAIL_TIME , 0 ); + AddEveryDayStrategicEvent( EVENT_ENRICO_MAIL, ENRICO_MAIL_TIME, 0 ); #endif - -// if ( gGameOptions.fAirStrikes ) -// { -// //Daily check for an air raid -// AddEveryDayStrategicEvent( EVENT_CHECK_FOR_AIR_RAID, 360, 0 ); -// } -// + + // if ( gGameOptions.fAirStrikes ) + // { + // //Daily check for an air raid + // AddEveryDayStrategicEvent( EVENT_CHECK_FOR_AIR_RAID, 360, 0 ); + // } + // // Hourly update of all sorts of things AddPeriodStrategicEvent( EVENT_HOURLY_UPDATE, 60, 0 ); AddPeriodStrategicEvent( EVENT_QUARTER_HOUR_UPDATE, 15, 0 ); - + // Flugente: ASD AddPeriodStrategicEvent( EVENT_ASD_UPDATE, 90, 0 ); //Clear any possible battle locator gfBlitBattleSectorLocator = FALSE; - + StrategicTurnsNewGame( ); } @@ -5041,9 +5045,9 @@ void SetupNewStrategicGame( ) INT8 GetSAMIdFromSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) { // check if valid sector - if( bSectorZ != 0 ) + if ( bSectorZ != 0 ) { - return( -1 ); + return(-1); } // get the sector value @@ -5052,13 +5056,13 @@ INT8 GetSAMIdFromSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) // run through list of sam sites for ( INT8 bCounter = 0; bCounter < NUMBER_OF_SAMS; ++bCounter ) { - if( pSamList[ bCounter ] == sSectorValue ) + if ( pSamList[bCounter] == sSectorValue ) { - return( bCounter ); + return(bCounter); } } - return( -1 ); + return(-1); } @@ -5068,9 +5072,9 @@ BOOLEAN CanGoToTacticalInSector( INT16 sX, INT16 sY, UINT8 ubZ ) //SOLDIERTYPE *pSoldier; // if not a valid sector - if( ( sX < 1 ) || ( sX > 16 ) || ( sY < 1 ) || ( sY > 16 ) || ( ubZ > 3 ) ) + if ( (sX < 1) || (sX > 16) || (sY < 1) || (sY > 16) || (ubZ > 3) ) { - return( FALSE ); + return(FALSE); } @@ -5086,16 +5090,16 @@ BOOLEAN CanGoToTacticalInSector( INT16 sX, INT16 sY, UINT8 ubZ ) // ) //if( (SectorInfo[ SECTOR( gWorldSectorX,gWorldSectorY) ].uiFlags & SF_ALREADY_VISITED) ) - if( GetSectorFlagStatus( sSelMapX, sSelMapY, ( UINT8 )iCurrentMapSectorZ, SF_ALREADY_VISITED ) == TRUE ) + if ( GetSectorFlagStatus( sSelMapX, sSelMapY, (UINT8)iCurrentMapSectorZ, SF_ALREADY_VISITED ) == TRUE ) { //if ( !pSoldier->flags.fBetweenSectors && pSoldier->sSectorX == sX && pSoldier->sSectorY == sY && pSoldier->bSectorZ == ubZ ) { - return( TRUE ); + return(TRUE); } } } - return( FALSE ); + return(FALSE); } @@ -5106,31 +5110,31 @@ INT32 GetNumberOfSAMSitesUnderPlayerControl( void ) // if the sam site is under player control, up the number for ( INT32 iCounter = 0; iCounter < NUMBER_OF_SAMS; ++iCounter ) { - if( StrategicMap[ SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[ iCounter ] ) ].fEnemyControlled == FALSE ) + if ( StrategicMap[SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[iCounter] )].fEnemyControlled == FALSE ) { ++iNumber; } } - return( iNumber ); + return(iNumber); } INT32 SAMSitesUnderPlayerControl( INT16 sX, INT16 sY ) { BOOLEAN fSamSiteUnderControl = FALSE; - + // is this sector a SAM sector? - if( IsThisSectorASAMSector( sX, sY, 0 ) == TRUE ) + if ( IsThisSectorASAMSector( sX, sY, 0 ) == TRUE ) { // is it under control by the player - if( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sX , sY ) ].fEnemyControlled == FALSE ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sX, sY )].fEnemyControlled == FALSE ) { // yes fSamSiteUnderControl = TRUE; } } - return( fSamSiteUnderControl ); + return(fSamSiteUnderControl); } @@ -5151,11 +5155,11 @@ void UpdateAirspaceControl( void ) } // IMPORTANT: B and A are reverse here, since the table is stored transposed - ubControllingSAM = ubSAMControlledSectors[ iCounterB ][ iCounterA ]; + ubControllingSAM = ubSAMControlledSectors[iCounterB][iCounterA]; if ( ubControllingSAM >= 1 && ubControllingSAM <= NUMBER_OF_SAMS ) { - pSAMStrategicMap = &( StrategicMap[ SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[ubControllingSAM - 1] ) ] ); + pSAMStrategicMap = &(StrategicMap[SECTOR_INFO_TO_STRATEGIC_INDEX( pSamList[ubControllingSAM - 1] )]); // different status depending on who controls the SAM sector, and whether the SAM is operational if ( pSAMStrategicMap->fEnemyControlled ) @@ -5187,7 +5191,7 @@ void UpdateAirspaceControl( void ) if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( gsMercArriveSectorX, gsMercArriveSectorY )].usAirType == AIRSPACE_ENEMY_ACTIVE ) { // NOPE! - CHAR16 sMsgString[ 256 ], sMsgSubString1[ 64 ], sMsgSubString2[ 64 ]; + CHAR16 sMsgString[256], sMsgSubString1[64], sMsgSubString2[64]; // get the name of the old sector GetSectorIDString( gsMercArriveSectorX, gsMercArriveSectorY, 0, sMsgSubString1, FALSE ); @@ -5201,9 +5205,9 @@ void UpdateAirspaceControl( void ) } else { - for (UINT8 ubSectorX = 1; ubSectorX <= 16; ++ubSectorX) + for ( UINT8 ubSectorX = 1; ubSectorX <= 16; ++ubSectorX ) { - for (UINT8 ubSectorY = 1; ubSectorY <=16; ++ubSectorY) + for ( UINT8 ubSectorY = 1; ubSectorY <= 16; ++ubSectorY ) { if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( ubSectorX, ubSectorY )].usAirType != AIRSPACE_ENEMY_ACTIVE && !sBadSectorsList[ubSectorX][ubSectorY] ) { @@ -5218,11 +5222,11 @@ void UpdateAirspaceControl( void ) GetSectorIDString( gsMercArriveSectorX, gsMercArriveSectorY, 0, sMsgSubString2, FALSE ); // now build the string - swprintf( sMsgString, pBullseyeStrings[ 4 ], sMsgSubString1, sMsgSubString2 ); + swprintf( sMsgString, pBullseyeStrings[4], sMsgSubString1, sMsgSubString2 ); // confirm the change with overlay message // HEADROCK HAM 3.5: If we do this during SaveLoad, the message box prevents loading the game at all! - if (guiCurrentScreen != SAVE_LOAD_SCREEN) + if ( guiCurrentScreen != SAVE_LOAD_SCREEN ) { DoScreenIndependantMessageBox( sMsgString, MSG_BOX_FLAG_OK, NULL ); } @@ -5233,7 +5237,7 @@ void UpdateAirspaceControl( void ) // update destination column for any mercs in transit fTeamPanelDirty = TRUE; } - + // ARM: airspace control now affects refueling site availability, so update that too with every change! UpdateRefuelSiteAvailability( ); } @@ -5241,17 +5245,17 @@ void UpdateAirspaceControl( void ) BOOLEAN IsThereAFunctionalSAMSiteInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) { - if( IsThisSectorASAMSector( sSectorX, sSectorY, bSectorZ ) == FALSE ) + if ( IsThisSectorASAMSector( sSectorX, sSectorY, bSectorZ ) == FALSE ) { - return( FALSE ); + return(FALSE); } - if( StrategicMap[ CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].bSAMCondition < MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].bSAMCondition < MIN_CONDITION_FOR_SAM_SITE_TO_WORK ) { - return( FALSE ); + return(FALSE); } - return( TRUE ); + return(TRUE); } BOOLEAN IsThisSectorASAMSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) @@ -5259,100 +5263,100 @@ BOOLEAN IsThisSectorASAMSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ) INT32 cnt; // is the sector above ground? - if( bSectorZ != 0 ) + if ( bSectorZ != 0 ) { - return( FALSE ); + return(FALSE); } for ( cnt = 0; cnt < NUMBER_OF_SAMS; cnt++ ) { - if( ( sSectorX == gpSamSectorX[cnt] ) && ( sSectorY == gpSamSectorY[cnt] ) ) - return( TRUE ); + if ( (sSectorX == gpSamSectorX[cnt]) && (sSectorY == gpSamSectorY[cnt]) ) + return(TRUE); } - return ( FALSE ); + return (FALSE); } // is this sector part of the town? BOOLEAN SectorIsPartOfTown( INT8 bTownId, INT16 sSectorX, INT16 sSectorY ) { - if( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY ) ].bNameId == bTownId ) + if ( StrategicMap[CALCULATE_STRATEGIC_INDEX( sSectorX, sSectorY )].bNameId == bTownId ) { // is in the town - return ( TRUE ); + return (TRUE); } // not in the town - return ( FALSE ); + return (FALSE); } BOOLEAN SaveStrategicInfoToSavedFile( HWFILE hFile ) { - UINT32 uiNumBytesWritten=0; - UINT32 uiSize = sizeof( StrategicMapElement ) * ( MAP_WORLD_X * MAP_WORLD_Y ); + UINT32 uiNumBytesWritten = 0; + UINT32 uiSize = sizeof(StrategicMapElement)* (MAP_WORLD_X * MAP_WORLD_Y); // Save the strategic map information FileWrite( hFile, StrategicMap, uiSize, &uiNumBytesWritten ); - if( uiNumBytesWritten != uiSize) + if ( uiNumBytesWritten != uiSize ) { return(FALSE); } // Save the Sector Info - for (int sectorID = 0; sectorID <= 255; ++ sectorID) { - FileWrite( hFile, &SectorInfo[sectorID], sizeof( SECTORINFO ), &uiNumBytesWritten ); - if( uiNumBytesWritten != sizeof( SECTORINFO )) { + for ( int sectorID = 0; sectorID <= 255; ++sectorID ) { + FileWrite( hFile, &SectorInfo[sectorID], sizeof(SECTORINFO), &uiNumBytesWritten ); + if ( uiNumBytesWritten != sizeof(SECTORINFO) ) { return(FALSE); } } -// uiSize = sizeof( SECTORINFO ) * 256; -// FileWrite( hFile, SectorInfo, uiSize, &uiNumBytesWritten ); -// if( uiNumBytesWritten != uiSize) -// { -// return(FALSE); -// } + // uiSize = sizeof( SECTORINFO ) * 256; + // FileWrite( hFile, SectorInfo, uiSize, &uiNumBytesWritten ); + // if( uiNumBytesWritten != uiSize) + // { + // return(FALSE); + // } // Save the SAM Controlled Sector Information uiSize = MAP_WORLD_X * MAP_WORLD_Y; -/* + /* FileWrite( hFile, ubSAMControlledSectors, uiSize, &uiNumBytesWritten ); if( uiNumBytesWritten != uiSize) { - return(FALSE); + return(FALSE); } -*/ + */ FileSeek( hFile, uiSize, FILE_SEEK_FROM_CURRENT ); // Save the fFoundOrta - FileWrite( hFile, &fFoundOrta, sizeof( BOOLEAN ), &uiNumBytesWritten ); - if( uiNumBytesWritten != sizeof( BOOLEAN ) ) + FileWrite( hFile, &fFoundOrta, sizeof(BOOLEAN), &uiNumBytesWritten ); + if ( uiNumBytesWritten != sizeof(BOOLEAN) ) { return(FALSE); } - return( TRUE ); + return(TRUE); } BOOLEAN LoadStrategicInfoFromSavedFile( HWFILE hFile ) { - UINT32 uiNumBytesRead=0; + UINT32 uiNumBytesRead = 0; - UINT32 uiSize = sizeof( StrategicMapElement ); + UINT32 uiSize = sizeof(StrategicMapElement); if ( guiCurrentSaveGameVersion >= MILITIA_MOVEMENT ) { - for(UINT16 i = 0; i < MAP_WORLD_X * MAP_WORLD_Y; ++i) + for ( UINT16 i = 0; i < MAP_WORLD_X * MAP_WORLD_Y; ++i ) { // Load the strategic map information FileRead( hFile, &StrategicMap[i], uiSize, &uiNumBytesRead ); - if( uiNumBytesRead != uiSize) + if ( uiNumBytesRead != uiSize ) { return(FALSE); } @@ -5362,11 +5366,11 @@ BOOLEAN LoadStrategicInfoFromSavedFile( HWFILE hFile ) { uiSize = 41; - for(UINT16 i = 0; i < MAP_WORLD_X * MAP_WORLD_Y; ++i) + for ( UINT16 i = 0; i < MAP_WORLD_X * MAP_WORLD_Y; ++i ) { // Load the strategic map information FileRead( hFile, &StrategicMap[i], uiSize, &uiNumBytesRead ); - if( uiNumBytesRead != uiSize) + if ( uiNumBytesRead != uiSize ) { return(FALSE); } @@ -5374,53 +5378,53 @@ BOOLEAN LoadStrategicInfoFromSavedFile( HWFILE hFile ) StrategicMap[i].usFlags = 0; } } - + // Load the Sector Info - for (int sectorID = 0; sectorID <= 255; ++sectorID) + for ( int sectorID = 0; sectorID <= 255; ++sectorID ) { - FileRead( hFile, &SectorInfo[sectorID], sizeof( SECTORINFO ), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( SECTORINFO )) + FileRead( hFile, &SectorInfo[sectorID], sizeof(SECTORINFO), &uiNumBytesRead ); + if ( uiNumBytesRead != sizeof(SECTORINFO) ) { return(FALSE); } - // Flugente: changes in SECTORINFO require a weird-looking remapping - if ( guiCurrentSaveGameVersion < PRISONER_EXPANSION ) - { - SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_GENERAL] = 0; - SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_CIVILIAN] = 0; - SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_SECRET1] = 0; - SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_SECRET2] = 0; - SectorInfo[sectorID].ubNumTanks = SectorInfo[sectorID].uiInterrogationHundredsLeft[PRISONER_GENERAL]; - SectorInfo[sectorID].ubTanksInBattle = SectorInfo[sectorID].uiInterrogationHundredsLeft[PRISONER_CIVILIAN]; + // Flugente: changes in SECTORINFO require a weird-looking remapping + if ( guiCurrentSaveGameVersion < PRISONER_EXPANSION ) + { + SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_GENERAL] = 0; + SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_CIVILIAN] = 0; + SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_SECRET1] = 0; + SectorInfo[sectorID].uiNumberOfPrisonersOfWar[PRISONER_SECRET2] = 0; + SectorInfo[sectorID].ubNumTanks = SectorInfo[sectorID].uiInterrogationHundredsLeft[PRISONER_GENERAL]; + SectorInfo[sectorID].ubTanksInBattle = SectorInfo[sectorID].uiInterrogationHundredsLeft[PRISONER_CIVILIAN]; + } } - } -// uiSize = sizeof( SECTORINFO ) * 256; -// FileRead( hFile, SectorInfo, uiSize, &uiNumBytesRead ); -// if( uiNumBytesRead != uiSize) -// { -// return(FALSE); -// } + // uiSize = sizeof( SECTORINFO ) * 256; + // FileRead( hFile, SectorInfo, uiSize, &uiNumBytesRead ); + // if( uiNumBytesRead != uiSize) + // { + // return(FALSE); + // } // Load the SAM Controlled Sector Information uiSize = MAP_WORLD_X * MAP_WORLD_Y; -/* + /* FileRead( hFile, ubSAMControlledSectors, uiSize, &uiNumBytesRead ); if( uiNumBytesRead != uiSize) { - return(FALSE); + return(FALSE); } -*/ + */ FileSeek( hFile, uiSize, FILE_SEEK_FROM_CURRENT ); // Load the fFoundOrta - FileRead( hFile, &fFoundOrta, sizeof( BOOLEAN ), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( BOOLEAN ) ) + FileRead( hFile, &fFoundOrta, sizeof(BOOLEAN), &uiNumBytesRead ); + if ( uiNumBytesRead != sizeof(BOOLEAN) ) { return(FALSE); } - return( TRUE ); + return(TRUE); } @@ -5431,264 +5435,264 @@ INT32 PickGridNoNearestEdge( SOLDIERTYPE *pSoldier, UINT8 ubTacticalDirection ) UINT8 bAdjustedDist = 0; UINT32 cnt; - switch( ubTacticalDirection ) + switch ( ubTacticalDirection ) { - case EAST: + case EAST: - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; - // Move directly to the right! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + // Move directly to the right! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo -= WORLD_COLS; - } - else - { - sGridNo++; - } - - bOdd = (INT8)!bOdd; + sGridNo -= WORLD_COLS; + } + else + { + sGridNo++; } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd = (INT8)!bOdd; + } - do + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + do + { + // OK, here we go back one, check for OK destination... + if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) { - // OK, here we go back one, check for OK destination... - if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) - { - return( sGridNo ); - } - - // If here, try another place! - // ( alternate up/down ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS - 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS + 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - - } while( TRUE ); - - break; - - case WEST: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the left! - while( GridNoOnVisibleWorldTile( sGridNo ) ) - { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo += WORLD_COLS; - } - else - { - sGridNo--; - } - - bOdd = (INT8)!bOdd; + return(sGridNo); } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; - - do + // If here, try another place! + // ( alternate up/down ) + if ( bOdd2 ) { - // OK, here we go back one, check for OK destination... - if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - return( sGridNo ); + sGridNo = (sGridNo - WORLD_COLS - 1); } - - // If here, try another place! - // ( alternate up/down ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS - 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS + 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - - } while( TRUE ); - - break; - - case NORTH: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the left! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + } + else { - sOldGridNo = sGridNo; + sGridNo = sStartGridNo; - if ( bOdd ) + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - sGridNo -= WORLD_COLS; + sGridNo = (sGridNo + WORLD_COLS + 1); } - else - { - sGridNo--; - } - - bOdd = (INT8)(!bOdd); } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd2 = (INT8)(!bOdd2); - do + } while ( TRUE ); + + break; + + case WEST: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the left! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) { - // OK, here we go back one, check for OK destination... - if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) - { - return( sGridNo ); - } - - // If here, try another place! - // ( alternate left/right ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS - 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS + 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - - } while( TRUE ); - - break; - - case SOUTH: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the left! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + sGridNo += WORLD_COLS; + } + else { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo += WORLD_COLS; - } - else - { - sGridNo++; - } - - bOdd = (INT8)(!bOdd); + sGridNo--; } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd = (INT8)!bOdd; + } - do + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + do + { + // OK, here we go back one, check for OK destination... + if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) { - // OK, here we go back one, check for OK destination... - if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) + return(sGridNo); + } + + // If here, try another place! + // ( alternate up/down ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - return( sGridNo ); + sGridNo = (sGridNo - WORLD_COLS - 1); } + } + else + { + sGridNo = sStartGridNo; - // If here, try another place! - // ( alternate left/right ) - if ( bOdd2 ) + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS - 1); - } + sGridNo = (sGridNo + WORLD_COLS + 1); } - else + } + + bOdd2 = (INT8)(!bOdd2); + + } while ( TRUE ); + + break; + + case NORTH: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the left! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) + { + sGridNo -= WORLD_COLS; + } + else + { + sGridNo--; + } + + bOdd = (INT8)(!bOdd); + } + + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + do + { + // OK, here we go back one, check for OK destination... + if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) + { + return(sGridNo); + } + + // If here, try another place! + // ( alternate left/right ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS + 1); - } + sGridNo = (sGridNo + WORLD_COLS - 1); } + } + else + { + sGridNo = sStartGridNo; - bOdd2 = (INT8)(!bOdd2); + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo - WORLD_COLS + 1); + } + } - } while( TRUE ); + bOdd2 = (INT8)(!bOdd2); - break; + } while ( TRUE ); + + break; + + case SOUTH: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the left! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) + { + sGridNo += WORLD_COLS; + } + else + { + sGridNo++; + } + + bOdd = (INT8)(!bOdd); + } + + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + do + { + // OK, here we go back one, check for OK destination... + if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) + { + return(sGridNo); + } + + // If here, try another place! + // ( alternate left/right ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo + WORLD_COLS - 1); + } + } + else + { + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo - WORLD_COLS + 1); + } + } + + bOdd2 = (INT8)(!bOdd2); + + } while ( TRUE ); + + break; } - return( NOWHERE ); + return(NOWHERE); } @@ -5698,17 +5702,17 @@ void AdjustSoldierPathToGoOffEdge( SOLDIERTYPE *pSoldier, INT32 sEndGridNo, UINT INT32 iLoop; // will this path segment actually take us to our desired destination in the first place? - if (pSoldier->pathing.usPathDataSize + 2 > MAX_PATH_LIST_SIZE) + if ( pSoldier->pathing.usPathDataSize + 2 > MAX_PATH_LIST_SIZE ) { sTempGridNo = pSoldier->sGridNo; - for (iLoop = 0; iLoop < pSoldier->pathing.usPathDataSize; iLoop++) + for ( iLoop = 0; iLoop < pSoldier->pathing.usPathDataSize; iLoop++ ) { - sTempGridNo += DirectionInc( (UINT8) pSoldier->pathing.usPathingData[ iLoop ] ); + sTempGridNo += DirectionInc( (UINT8)pSoldier->pathing.usPathingData[iLoop] ); } - if (sTempGridNo == sEndGridNo) + if ( sTempGridNo == sEndGridNo ) { // we can make it, but there isn't enough path room for the two steps required. // truncate our path so there's guaranteed the merc will have to generate another @@ -5723,121 +5727,121 @@ void AdjustSoldierPathToGoOffEdge( SOLDIERTYPE *pSoldier, INT32 sEndGridNo, UINT } } - switch( ubTacticalDirection ) + switch ( ubTacticalDirection ) { - case EAST: + case EAST: - sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)NORTHEAST ) ); + sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)NORTHEAST ) ); - if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) - { - return; - } + if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) + { + return; + } - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = NORTHEAST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = NORTHEAST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)NORTHEAST ) ); + sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)NORTHEAST ) ); - if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) - { - return; - } - sNewGridNo = sTempGridNo; + if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) + { + return; + } + sNewGridNo = sTempGridNo; - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = NORTHEAST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = NORTHEAST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - break; + break; - case WEST: + case WEST: - sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)SOUTHWEST ) ); + sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)SOUTHWEST ) ); - if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) - { - return; - } + if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) + { + return; + } - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = SOUTHWEST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = SOUTHWEST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)SOUTHWEST ) ); + sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)SOUTHWEST ) ); - if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) - { - return; - } - sNewGridNo = sTempGridNo; + if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) + { + return; + } + sNewGridNo = sTempGridNo; - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = SOUTHWEST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; - break; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = SOUTHWEST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; + break; - case NORTH: + case NORTH: - sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)NORTHWEST ) ); + sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)NORTHWEST ) ); - if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) - { - return; - } + if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) + { + return; + } - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = NORTHWEST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = NORTHWEST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)NORTHWEST ) ); + sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)NORTHWEST ) ); - if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) - { - return; - } - sNewGridNo = sTempGridNo; + if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) + { + return; + } + sNewGridNo = sTempGridNo; - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = NORTHWEST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = NORTHWEST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - break; + break; - case SOUTH: + case SOUTH: - sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)SOUTHEAST ) ); + sNewGridNo = NewGridNo( sEndGridNo, (UINT16)DirectionInc( (UINT8)SOUTHEAST ) ); - if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) - { - return; - } + if ( OutOfBounds( sEndGridNo, sNewGridNo ) ) + { + return; + } - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = SOUTHEAST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = SOUTHEAST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; - sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)SOUTHEAST ) ); + sTempGridNo = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)SOUTHEAST ) ); - if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) - { - return; - } - sNewGridNo = sTempGridNo; + if ( OutOfBounds( sNewGridNo, sTempGridNo ) ) + { + return; + } + sNewGridNo = sTempGridNo; - pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathDataSize ] = SOUTHEAST; - pSoldier->pathing.usPathDataSize++; - pSoldier->pathing.sFinalDestination = sNewGridNo; - pSoldier->aiData.usActionData = sNewGridNo; - break; + pSoldier->pathing.usPathingData[pSoldier->pathing.usPathDataSize] = SOUTHEAST; + pSoldier->pathing.usPathDataSize++; + pSoldier->pathing.sFinalDestination = sNewGridNo; + pSoldier->aiData.usActionData = sNewGridNo; + break; } } @@ -5851,283 +5855,283 @@ INT32 PickGridNoToWalkIn( SOLDIERTYPE *pSoldier, UINT8 ubInsertionDirection, UIN *puiNumAttempts = 0; - switch( ubInsertionDirection ) + switch ( ubInsertionDirection ) { // OK, we're given a direction on visible map, let's look for the first oone // we find that is just on the start of visible map... - case INSERTION_CODE_WEST: + case INSERTION_CODE_WEST: - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; - // Move directly to the left! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + // Move directly to the left! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo += WORLD_COLS; - } - else - { - sGridNo--; - } - - bOdd = (INT8)(!bOdd); + sGridNo += WORLD_COLS; + } + else + { + sGridNo--; } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd = (INT8)(!bOdd); + } - while( *puiNumAttempts < MAX_ATTEMPTS ) + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + while ( *puiNumAttempts < MAX_ATTEMPTS ) + { + (*puiNumAttempts)++; + // OK, here we go back one, check for OK destination... + if ( (gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES) || (NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE )) ) { - (*puiNumAttempts)++; - // OK, here we go back one, check for OK destination... - if ( ( gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES ) || ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) ) - { - return( sGridNo ); - } - - // If here, try another place! - // ( alternate up/down ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS - 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS + 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - - } - return NOWHERE; - - case INSERTION_CODE_EAST: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the right! - while( GridNoOnVisibleWorldTile( sGridNo ) ) - { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo -= WORLD_COLS; - } - else - { - sGridNo++; - } - - bOdd = (INT8)(!bOdd); + return(sGridNo); } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; - - while( *puiNumAttempts < MAX_ATTEMPTS ) + // If here, try another place! + // ( alternate up/down ) + if ( bOdd2 ) { - (*puiNumAttempts)++; - // OK, here we go back one, check for OK destination... - if ( ( gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES ) || ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) ) + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - return( sGridNo ); + sGridNo = (sGridNo - WORLD_COLS - 1); } - - // If here, try another place! - // ( alternate up/down ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS - 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS + 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - } - return NOWHERE; - - case INSERTION_CODE_NORTH: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the up! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + else { - sOldGridNo = sGridNo; + sGridNo = sStartGridNo; - if ( bOdd ) + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) { - sGridNo -= WORLD_COLS; + sGridNo = (sGridNo + WORLD_COLS + 1); } - else - { - sGridNo--; - } - - bOdd = (INT8)(!bOdd); } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd2 = (INT8)(!bOdd2); - while( *puiNumAttempts < MAX_ATTEMPTS ) + } + return NOWHERE; + + case INSERTION_CODE_EAST: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the right! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) { - (*puiNumAttempts)++; - // OK, here we go back one, check for OK destination... - if ( ( gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES ) || ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) ) - { - return( sGridNo ); - } - - // If here, try another place! - // ( alternate left/right ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS + 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS - 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - + sGridNo -= WORLD_COLS; } - return NOWHERE; - - case INSERTION_CODE_SOUTH: - - sGridNo = pSoldier->sGridNo; - sStartGridNo = pSoldier->sGridNo; - sOldGridNo = pSoldier->sGridNo; - - // Move directly to the down! - while( GridNoOnVisibleWorldTile( sGridNo ) ) + else { - sOldGridNo = sGridNo; - - if ( bOdd ) - { - sGridNo += WORLD_COLS; - } - else - { - sGridNo++; - } - - bOdd = (INT8)(!bOdd); + sGridNo++; } - sGridNo = sOldGridNo; - sStartGridNo = sOldGridNo; + bOdd = (INT8)(!bOdd); + } - while( *puiNumAttempts < MAX_ATTEMPTS ) + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + while ( *puiNumAttempts < MAX_ATTEMPTS ) + { + (*puiNumAttempts)++; + // OK, here we go back one, check for OK destination... + if ( (gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES) || (NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE )) ) { - (*puiNumAttempts)++; - // OK, here we go back one, check for OK destination... - if ( ( gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES ) || ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE ) ) ) - { - return( sGridNo ); - } - - // If here, try another place! - // ( alternate left/right ) - if ( bOdd2 ) - { - bAdjustedDist++; - - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo - WORLD_COLS + 1); - } - } - else - { - sGridNo = sStartGridNo; - - for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) - { - sGridNo = (sGridNo + WORLD_COLS - 1); - } - } - - bOdd2 = (INT8)(!bOdd2); - + return(sGridNo); } - return NOWHERE; + + // If here, try another place! + // ( alternate up/down ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo - WORLD_COLS - 1); + } + } + else + { + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo + WORLD_COLS + 1); + } + } + + bOdd2 = (INT8)(!bOdd2); + + } + return NOWHERE; + + case INSERTION_CODE_NORTH: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the up! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) + { + sGridNo -= WORLD_COLS; + } + else + { + sGridNo--; + } + + bOdd = (INT8)(!bOdd); + } + + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + while ( *puiNumAttempts < MAX_ATTEMPTS ) + { + (*puiNumAttempts)++; + // OK, here we go back one, check for OK destination... + if ( (gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES) || (NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE )) ) + { + return(sGridNo); + } + + // If here, try another place! + // ( alternate left/right ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo - WORLD_COLS + 1); + } + } + else + { + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo + WORLD_COLS - 1); + } + } + + bOdd2 = (INT8)(!bOdd2); + + } + return NOWHERE; + + case INSERTION_CODE_SOUTH: + + sGridNo = pSoldier->sGridNo; + sStartGridNo = pSoldier->sGridNo; + sOldGridNo = pSoldier->sGridNo; + + // Move directly to the down! + while ( GridNoOnVisibleWorldTile( sGridNo ) ) + { + sOldGridNo = sGridNo; + + if ( bOdd ) + { + sGridNo += WORLD_COLS; + } + else + { + sGridNo++; + } + + bOdd = (INT8)(!bOdd); + } + + sGridNo = sOldGridNo; + sStartGridNo = sOldGridNo; + + while ( *puiNumAttempts < MAX_ATTEMPTS ) + { + (*puiNumAttempts)++; + // OK, here we go back one, check for OK destination... + if ( (gTacticalStatus.uiFlags & IGNORE_ALL_OBSTACLES) || (NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) && FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, NO_COPYROUTE, PATH_THROUGH_PEOPLE )) ) + { + return(sGridNo); + } + + // If here, try another place! + // ( alternate left/right ) + if ( bOdd2 ) + { + bAdjustedDist++; + + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo - WORLD_COLS + 1); + } + } + else + { + sGridNo = sStartGridNo; + + for ( cnt = 0; cnt < bAdjustedDist; cnt++ ) + { + sGridNo = (sGridNo + WORLD_COLS - 1); + } + } + + bOdd2 = (INT8)(!bOdd2); + + } + return NOWHERE; } //Unhandled exit *puiNumAttempts = 0; - return( NOWHERE ); + return(NOWHERE); } void GetLoadedSectorString( STR16 pString ) { - if( !gfWorldLoaded ) + if ( !gfWorldLoaded ) { swprintf( pString, L"" ); return; } - if( gbWorldSectorZ ) + if ( gbWorldSectorZ ) { swprintf( pString, L"%c%d_b%d", gWorldSectorY + 'A' - 1, gWorldSectorX, gbWorldSectorZ ); } - else if( !gbWorldSectorZ ) + else if ( !gbWorldSectorZ ) { swprintf( pString, L"%c%d", gWorldSectorY + 'A' - 1, gWorldSectorX ); } @@ -6143,13 +6147,13 @@ void HandleSlayDailyEvent( void ) // grab slay pSoldier = FindSoldierByProfileID( 64, TRUE ); - if( pSoldier == NULL ) + if ( pSoldier == NULL ) { return; } // valid soldier? - if( ( pSoldier->bActive == FALSE ) || ( pSoldier->stats.bLife == 0 ) || ( pSoldier->bAssignment == IN_TRANSIT ) ||( pSoldier->bAssignment == ASSIGNMENT_POW ) ) + if ( (pSoldier->bActive == FALSE) || (pSoldier->stats.bLife == 0) || (pSoldier->bAssignment == IN_TRANSIT) || (pSoldier->bAssignment == ASSIGNMENT_POW) ) { // no return; @@ -6158,7 +6162,7 @@ void HandleSlayDailyEvent( void ) // ATE: This function is used to check for the ultimate last day SLAY can stay for // he may decide to leave randomly while asleep... //if the user hasnt renewed yet, and is still leaving today - if( ( pSoldier->iEndofContractTime /1440 ) <= (INT32)GetWorldDay( ) ) + if ( (pSoldier->iEndofContractTime / 1440) <= (INT32)GetWorldDay( ) ) { pSoldier->ubLeaveHistoryCode = HISTORY_SLAY_MYSTERIOUSLY_LEFT; TacticalCharacterDialogueWithSpecialEvent( pSoldier, 0, DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING_NO_ASK_EQUIP, 0, 0 ); @@ -6169,36 +6173,36 @@ void HandleSlayDailyEvent( void ) BOOLEAN IsSectorDesert( INT16 sSectorX, INT16 sSectorY ) { // HEADROCK HAM 3.5: Fix for assertion errors associated with rain checks. - if (sSectorX <= 0 || sSectorY <=0 || sSectorX > 16 || sSectorY > 16) + if ( sSectorX <= 0 || sSectorY <= 0 || sSectorX > 16 || sSectorY > 16 ) { - return( FALSE ); + return(FALSE); } // SANDRO - added more terrain types for heat intolerant feature - if ( SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == SAND || - SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == SAND_ROAD || - SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == SAND_SAM_SITE ) + if ( SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == SAND || + SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == SAND_ROAD || + SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == SAND_SAM_SITE ) { // desert - return( TRUE ); + return(TRUE); } else { - return( FALSE ); + return(FALSE); } } // SANDRO - added function BOOLEAN IsSectorTropical( INT16 sSectorX, INT16 sSectorY ) { - if (SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == TROPICS || - SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == TROPICS_ROAD || - SectorInfo[ SECTOR(sSectorX, sSectorY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] == TROPICS_SAM_SITE ) + if ( SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == TROPICS || + SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == TROPICS_ROAD || + SectorInfo[SECTOR( sSectorX, sSectorY )].ubTraversability[THROUGH_STRATEGIC_MOVE] == TROPICS_SAM_SITE ) { - return ( TRUE ); + return (TRUE); } - - return ( FALSE ); + + return (FALSE); } BOOLEAN IsSectorFarm( INT16 sSectorX, INT16 sSectorY ) @@ -6235,15 +6239,15 @@ BOOLEAN HandleDefiniteUnloadingOfWorld( UINT8 ubUnloadCode ) INT32 i; // clear tactical queue - ClearEventQueue(); + ClearEventQueue( ); // ATE: End all bullets.... - DeleteAllBullets(); + DeleteAllBullets( ); // End all physics objects... - RemoveAllPhysicsObjects(); + RemoveAllPhysicsObjects( ); - RemoveAllActiveTimedBombs(); + RemoveAllActiveTimedBombs( ); // Flugente: remove any marker that an explosion is active but has not yet occured (to be used when leaving a sector) RemoveActiveExplosionMarkers( ); @@ -6252,51 +6256,54 @@ BOOLEAN HandleDefiniteUnloadingOfWorld( UINT8 ubUnloadCode ) HandleQuestCodeOnSectorExit( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); //if we arent loading a saved game - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { //Clear any potential battle flags. They will be set if necessary. gTacticalStatus.fEnemyInSector = FALSE; gTacticalStatus.uiFlags &= ~INCOMBAT; } + // Flugente: update possible fortification potential in current sector + UpdateFortificationPossibleAmount( ); + if ( ubUnloadCode == ABOUT_TO_LOAD_NEW_MAP ) { //if we arent loading a saved game - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { // Flugente: cause all militia whose equipment is from this sector to drop it TeamDropAll( MILITIA_TEAM ); // Save the current sectors Item list to a temporary file, if its not the first time in - SaveCurrentSectorsInformationToTempItemFile(); + SaveCurrentSectorsInformationToTempItemFile( ); // Update any mercs currently in sector, their profile info... UpdateSoldierPointerDataIntoProfile( FALSE ); } } - else if( ubUnloadCode == ABOUT_TO_TRASH_WORLD ) + else if ( ubUnloadCode == ABOUT_TO_TRASH_WORLD ) { //if we arent loading a saved game - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) + if ( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME) ) { // Flugente: cause all militia whose equipment is from this sector to drop it TeamDropAll( MILITIA_TEAM ); } //Save the current sectors open temp files to the disk - if( !SaveCurrentSectorsInformationToTempItemFile() ) + if ( !SaveCurrentSectorsInformationToTempItemFile( ) ) { - ScreenMsg( FONT_MCOLOR_WHITE, MSG_TESTVERSION, L"ERROR in SaveCurrentSectorsInformationToTempItemFile()"); + ScreenMsg( FONT_MCOLOR_WHITE, MSG_TESTVERSION, L"ERROR in SaveCurrentSectorsInformationToTempItemFile()" ); return FALSE; } //Setup the tactical existance of the current soldier. //@@@Evaluate - for( i = gTacticalStatus.Team[ CIV_TEAM ].bFirstID; i <= gTacticalStatus.Team[ CIV_TEAM ].bLastID; i++ ) + for ( i = gTacticalStatus.Team[CIV_TEAM].bFirstID; i <= gTacticalStatus.Team[CIV_TEAM].bLastID; i++ ) { - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->bInSector ) + if ( MercPtrs[i]->bActive && MercPtrs[i]->bInSector ) { - SetupProfileInsertionDataForSoldier( MercPtrs[ i ] ); + SetupProfileInsertionDataForSoldier( MercPtrs[i] ); } } @@ -6304,29 +6311,29 @@ BOOLEAN HandleDefiniteUnloadingOfWorld( UINT8 ubUnloadCode ) } //Handle cases for both types of unloading - HandleMilitiaStatusInCurrentMapBeforeLoadingNewMap(); + HandleMilitiaStatusInCurrentMapBeforeLoadingNewMap( ); return TRUE; } -BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle(int pSectorX, int pSectorY, int pSectorZ) +BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle( int pSectorX, int pSectorY, int pSectorZ ) { //We don't have mercs in the sector. Now, we check to see if there are BOTH enemies and militia. If both //co-exist in the sector, then make them fight for control of the sector via autoresolve. - for( int i = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; i <= gTacticalStatus.Team[ CREATURE_TEAM ].bLastID; i++ ) + for ( int i = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; i <= gTacticalStatus.Team[CREATURE_TEAM].bLastID; i++ ) { - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife ) + if ( MercPtrs[i]->bActive && MercPtrs[i]->stats.bLife ) { - if( MercPtrs[ i ]->sSectorX == pSectorX && - MercPtrs[ i ]->sSectorY == pSectorY && - MercPtrs[ i ]->bSectorZ == pSectorZ ) + if ( MercPtrs[i]->sSectorX == pSectorX && + MercPtrs[i]->sSectorY == pSectorY && + MercPtrs[i]->bSectorZ == pSectorZ ) { //We have enemies, now look for militia! - for( i = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID; i <= gTacticalStatus.Team[ MILITIA_TEAM ].bLastID; i++ ) + for ( i = gTacticalStatus.Team[MILITIA_TEAM].bFirstID; i <= gTacticalStatus.Team[MILITIA_TEAM].bLastID; i++ ) { - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && MercPtrs[ i ]->bSide == OUR_TEAM ) + if ( MercPtrs[i]->bActive && MercPtrs[i]->stats.bLife && MercPtrs[i]->bSide == OUR_TEAM ) { - if( MercPtrs[ i ]->sSectorX == pSectorX && - MercPtrs[ i ]->sSectorY == pSectorY && - MercPtrs[ i ]->bSectorZ == pSectorZ ) + if ( MercPtrs[i]->sSectorX == pSectorX && + MercPtrs[i]->sSectorY == pSectorY && + MercPtrs[i]->bSectorZ == pSectorZ ) { //We have militia and enemies and no mercs! Let's finish this battle in autoresolve. gfEnteringMapScreen = TRUE; gfEnteringMapScreenToEnterPreBattleInterface = TRUE; @@ -6337,7 +6344,7 @@ BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle(int pSectorX, int pSecto gubPBSectorZ = (UINT8)pSectorZ; gfBlitBattleSectorLocator = TRUE; gfTransferTacticalOppositionToAutoResolve = TRUE; - if( gubEnemyEncounterCode != CREATURE_ATTACK_CODE ) + if ( gubEnemyEncounterCode != CREATURE_ATTACK_CODE ) { gubEnemyEncounterCode = ENEMY_INVASION_CODE; //has to be, if militia are here. } @@ -6346,55 +6353,55 @@ BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle(int pSectorX, int pSecto //DoScreenIndependantMessageBox( gzLateLocalizedString[ 39 ], MSG_BOX_FLAG_OK, MapScreenDefaultOkBoxCallback ); } - return( TRUE ); + return(TRUE); } } } } } - } + } - return( FALSE ); + return(FALSE); } -BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() +BOOLEAN CheckAndHandleUnloadingOfCurrentWorld( ) { INT32 i; INT16 sBattleSectorX, sBattleSectorY, sBattleSectorZ; //Don't bother checking this if we don't have a world loaded. - if( !gfWorldLoaded ) + if ( !gfWorldLoaded ) { return FALSE; } - if(is_client)//hayden - if multiplayer dont kick from level, allow spectate. + if ( is_client )//hayden - if multiplayer dont kick from level, allow spectate. { return FALSE; } - if( gTacticalStatus.fDidGameJustStart && gWorldSectorX == gGameExternalOptions.ubDefaultArrivalSectorX && gWorldSectorY == gGameExternalOptions.ubDefaultArrivalSectorY && !gbWorldSectorZ ) + if ( gTacticalStatus.fDidGameJustStart && gWorldSectorX == gGameExternalOptions.ubDefaultArrivalSectorX && gWorldSectorY == gGameExternalOptions.ubDefaultArrivalSectorY && !gbWorldSectorZ ) { return FALSE; } GetCurrentBattleSectorXYZ( &sBattleSectorX, &sBattleSectorY, &sBattleSectorZ ); - if( guiCurrentScreen == AUTORESOLVE_SCREEN ) + if ( guiCurrentScreen == AUTORESOLVE_SCREEN ) { //The user has decided to let the game autoresolve the current battle. - if( gWorldSectorX == sBattleSectorX && gWorldSectorY == sBattleSectorY && gbWorldSectorZ == sBattleSectorZ ) + if ( gWorldSectorX == sBattleSectorX && gWorldSectorY == sBattleSectorY && gbWorldSectorZ == sBattleSectorZ ) { - for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; i++ ) + for ( i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; i++ ) { //If we have a live and valid soldier - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && !MercPtrs[ i ]->flags.fBetweenSectors && !(MercPtrs[ i ]->flags.uiStatusFlags & SOLDIER_VEHICLE ) && !AM_A_ROBOT( MercPtrs[ i ] ) && !AM_AN_EPC( MercPtrs[ i ] ) ) + if ( MercPtrs[i]->bActive && MercPtrs[i]->stats.bLife && !MercPtrs[i]->flags.fBetweenSectors && !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_VEHICLE) && !AM_A_ROBOT( MercPtrs[i] ) && !AM_AN_EPC( MercPtrs[i] ) ) { - if( MercPtrs[ i ]->sSectorX == gWorldSectorX && - MercPtrs[ i ]->sSectorY == gWorldSectorY && - MercPtrs[ i ]->bSectorZ == gbWorldSectorZ ) + if ( MercPtrs[i]->sSectorX == gWorldSectorX && + MercPtrs[i]->sSectorY == gWorldSectorY && + MercPtrs[i]->bSectorZ == gbWorldSectorZ ) { - MercPtrs[ i ]->RemoveSoldierFromGridNo( ); - InitSoldierOppList( MercPtrs[ i ] ); + MercPtrs[i]->RemoveSoldierFromGridNo( ); + InitSoldierOppList( MercPtrs[i] ); } } } @@ -6402,13 +6409,13 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() } else { //Check and see if we have any live mercs in the sector. - for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; i++ ) + for ( i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; i++ ) { //If we have a live and valid soldier - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && !MercPtrs[ i ]->flags.fBetweenSectors && !(MercPtrs[ i ]->flags.uiStatusFlags & SOLDIER_VEHICLE ) && !AM_A_ROBOT( MercPtrs[ i ] ) && !AM_AN_EPC( MercPtrs[ i ] )) + if ( MercPtrs[i]->bActive && MercPtrs[i]->stats.bLife && !MercPtrs[i]->flags.fBetweenSectors && !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_VEHICLE) && !AM_A_ROBOT( MercPtrs[i] ) && !AM_AN_EPC( MercPtrs[i] ) ) { - if( MercPtrs[ i ]->sSectorX == gWorldSectorX && - MercPtrs[ i ]->sSectorY == gWorldSectorY && - MercPtrs[ i ]->bSectorZ == gbWorldSectorZ ) + if ( MercPtrs[i]->sSectorX == gWorldSectorX && + MercPtrs[i]->sSectorY == gWorldSectorY && + MercPtrs[i]->bSectorZ == gbWorldSectorZ ) { return FALSE; } @@ -6418,13 +6425,13 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() // Added logic to prevent a crash when player mercs would retreat from a battle involving militia and enemies. // Without the return here, it would proceed to trash the world, and then when autoresolve would come up to // finish the tactical battle, it would fail to find the existing soldier information (because it was trashed). - if( HandlePotentialBringUpAutoresolveToFinishBattle( sBattleSectorX, sBattleSectorY, sBattleSectorZ ) ) + if ( HandlePotentialBringUpAutoresolveToFinishBattle( sBattleSectorX, sBattleSectorY, sBattleSectorZ ) ) { // Flugente: cause all militia whose equipment is from this sector to drop it - otherwise it can get lost TeamDropAll( MILITIA_TEAM, TRUE ); // Save the current sectors Item list to a temporary file, if its not the first time in - SaveCurrentSectorsInformationToTempItemFile(); + SaveCurrentSectorsInformationToTempItemFile( ); return FALSE; } @@ -6435,7 +6442,7 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() CheckForEndOfCombatMode( FALSE ); - EndTacticalBattleForEnemy(); + EndTacticalBattleForEnemy( ); // ATE: Change cursor to wait cursor for duration of frame..... // save old cursor ID.... @@ -6443,11 +6450,11 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() RefreshScreen( NULL ); // JA2Gold: Leaving sector, so get rid of ambients! - DeleteAllAmbients(); + DeleteAllAmbients( ); - if( guiCurrentScreen == GAME_SCREEN ) + if ( guiCurrentScreen == GAME_SCREEN ) { - if( !gfTacticalTraversal ) + if ( !gfTacticalTraversal ) { //if we are in tactical and don't intend on going to another sector immediately, then gfEnteringMapScreen = TRUE; } @@ -6458,14 +6465,14 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() } //We have passed all the checks and can Trash the world. - if( !HandleDefiniteUnloadingOfWorld( ABOUT_TO_TRASH_WORLD ) ) + if ( !HandleDefiniteUnloadingOfWorld( ABOUT_TO_TRASH_WORLD ) ) { return FALSE; } - if( guiCurrentScreen == AUTORESOLVE_SCREEN ) + if ( guiCurrentScreen == AUTORESOLVE_SCREEN ) { - if( gWorldSectorX == sBattleSectorX && gWorldSectorY == sBattleSectorY && gbWorldSectorZ == sBattleSectorZ ) + if ( gWorldSectorX == sBattleSectorX && gWorldSectorY == sBattleSectorY && gbWorldSectorZ == sBattleSectorZ ) { //Yes, this is and looks like a hack. The conditions of this if statement doesn't work inside //TrashWorld() or more specifically, TacticalRemoveSoldier() from within TrashWorld(). Because //we are in the autoresolve screen, soldiers are internally created different (from pointers instead of @@ -6474,19 +6481,19 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() //complete, it'll delete the autoresolve soldiers properly. As you can now see, the above if conditions //don't change throughout this whole process which makes it necessary to do it this way. guiCurrentScreen = MAP_SCREEN; - TrashWorld(); + TrashWorld( ); guiCurrentScreen = AUTORESOLVE_SCREEN; } } else { - TrashWorld(); + TrashWorld( ); } //Clear all combat related flags. gTacticalStatus.fEnemyInSector = FALSE; gTacticalStatus.uiFlags &= ~INCOMBAT; - EndTopMessage( ); + EndTopMessage( ); //Clear the world sector values. @@ -6511,13 +6518,13 @@ BOOLEAN CheckAndHandleUnloadingOfCurrentWorld() //@@@Evaluate void SetupProfileInsertionDataForSoldier( SOLDIERTYPE *pSoldier ) { - if( !pSoldier || pSoldier->ubProfile == NO_PROFILE ) + if ( !pSoldier || pSoldier->ubProfile == NO_PROFILE ) { //Doesn't have profile information. return; } - if ( gMercProfiles[ pSoldier->ubProfile ].ubMiscFlags3 & PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE ) - //if ( gMercProfiles[ pSoldier->ubProfile ].ubStrategicInsertionCode == INSERTION_CODE_PERMANENT_GRIDNO ) + if ( gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 & PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE ) + //if ( gMercProfiles[ pSoldier->ubProfile ].ubStrategicInsertionCode == INSERTION_CODE_PERMANENT_GRIDNO ) { // can't be changed! return; @@ -6526,9 +6533,9 @@ void SetupProfileInsertionDataForSoldier( SOLDIERTYPE *pSoldier ) if ( gfWorldLoaded && pSoldier->bActive && pSoldier->bInSector ) { //This soldier is currently in the sector - //@@@Evaluate -- insert code here - //SAMPLE CODE: There are multiple situations that I didn't code. The gridno should be the final destination - //or reset??? + //@@@Evaluate -- insert code here + //SAMPLE CODE: There are multiple situations that I didn't code. The gridno should be the final destination + //or reset??? if ( pSoldier->ubQuoteRecord && pSoldier->ubQuoteActionID ) { @@ -6537,10 +6544,10 @@ void SetupProfileInsertionDataForSoldier( SOLDIERTYPE *pSoldier ) { // Handle traversal. This NPC's sector will NOT already be set correctly, so we have to call for that too HandleNPCChangesForTacticalTraversal( pSoldier ); - gMercProfiles[ pSoldier->ubProfile ].fUseProfileInsertionInfo = FALSE; + gMercProfiles[pSoldier->ubProfile].fUseProfileInsertionInfo = FALSE; if ( pSoldier->ubProfile != NO_PROFILE && NPCHasUnusedRecordWithGivenApproach( pSoldier->ubProfile, APPROACH_DONE_TRAVERSAL ) ) { - gMercProfiles[ pSoldier->ubProfile ].ubMiscFlags3 |= PROFILE_MISC_FLAG3_HANDLE_DONE_TRAVERSAL; + gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 |= PROFILE_MISC_FLAG3_HANDLE_DONE_TRAVERSAL; } } @@ -6548,26 +6555,26 @@ void SetupProfileInsertionDataForSoldier( SOLDIERTYPE *pSoldier ) { if ( pSoldier->pathing.sFinalDestination == pSoldier->sGridNo ) { - gMercProfiles[ pSoldier->ubProfile ].usStrategicInsertionData = pSoldier->sGridNo; - } - else if (!TileIsOutOfBounds(pSoldier->sAbsoluteFinalDestination)) + gMercProfiles[pSoldier->ubProfile].usStrategicInsertionData = pSoldier->sGridNo; + } + else if ( !TileIsOutOfBounds( pSoldier->sAbsoluteFinalDestination ) ) { - gMercProfiles[ pSoldier->ubProfile ].usStrategicInsertionData = pSoldier->sAbsoluteFinalDestination; + gMercProfiles[pSoldier->ubProfile].usStrategicInsertionData = pSoldier->sAbsoluteFinalDestination; } else { - gMercProfiles[ pSoldier->ubProfile ].usStrategicInsertionData = pSoldier->pathing.sFinalDestination; + gMercProfiles[pSoldier->ubProfile].usStrategicInsertionData = pSoldier->pathing.sFinalDestination; } - gMercProfiles[ pSoldier->ubProfile ].fUseProfileInsertionInfo = TRUE; - gMercProfiles[ pSoldier->ubProfile ].ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; - gMercProfiles[ pSoldier->ubProfile ].ubQuoteActionID = pSoldier->ubQuoteActionID; - gMercProfiles[ pSoldier->ubProfile ].ubQuoteRecord = pSoldier->ubQuoteActionID; + gMercProfiles[pSoldier->ubProfile].fUseProfileInsertionInfo = TRUE; + gMercProfiles[pSoldier->ubProfile].ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + gMercProfiles[pSoldier->ubProfile].ubQuoteActionID = pSoldier->ubQuoteActionID; + gMercProfiles[pSoldier->ubProfile].ubQuoteRecord = pSoldier->ubQuoteActionID; } } else { - gMercProfiles[ pSoldier->ubProfile ].fUseProfileInsertionInfo = FALSE; + gMercProfiles[pSoldier->ubProfile].fUseProfileInsertionInfo = FALSE; } } @@ -6576,11 +6583,11 @@ void SetupProfileInsertionDataForSoldier( SOLDIERTYPE *pSoldier ) //It appears to set the soldier's strategic insertion code everytime a group arrives in a new sector. The insertion data //isn't needed for these cases as the code is a direction only. - gMercProfiles[ pSoldier->ubProfile ].ubStrategicInsertionCode = pSoldier->ubStrategicInsertionCode; - gMercProfiles[ pSoldier->ubProfile ].usStrategicInsertionData = 0; + gMercProfiles[pSoldier->ubProfile].ubStrategicInsertionCode = pSoldier->ubStrategicInsertionCode; + gMercProfiles[pSoldier->ubProfile].usStrategicInsertionData = 0; //Strategic system should now work. - gMercProfiles[ pSoldier->ubProfile ].fUseProfileInsertionInfo = TRUE; + gMercProfiles[pSoldier->ubProfile].fUseProfileInsertionInfo = TRUE; } } @@ -6589,32 +6596,32 @@ void HandlePotentialMoraleHitForSkimmingSectors( GROUP *pGroup ) { //PLAYERGROUP *pPlayer; - if ( !gTacticalStatus.fHasEnteredCombatModeSinceEntering && gTacticalStatus.fEnemyInSector ) - { + if ( !gTacticalStatus.fHasEnteredCombatModeSinceEntering && gTacticalStatus.fEnemyInSector ) + { //Flag is set so if "wilderness" enemies are in the adjacent sector of this group, the group has //a 90% chance of ambush. Because this typically doesn't happen very often, the chance is high. //This reflects the enemies radioing ahead to other enemies of the group's arrival, so they have //time to setup a good ambush! pGroup->uiFlags |= GROUPFLAG_HIGH_POTENTIAL_FOR_AMBUSH; - //SANDRO - WTF?!? - //pPlayer = pGroup->pPlayerList; + //SANDRO - WTF?!? + //pPlayer = pGroup->pPlayerList; - //while( pPlayer ) - //{ - // // Do morale hit... - // // CC look here! - // // pPlayer->pSoldier + //while( pPlayer ) + //{ + // // Do morale hit... + // // CC look here! + // // pPlayer->pSoldier - // pPlayer = pPlayer->next; - //} - } + // pPlayer = pPlayer->next; + //} + } } #ifdef CRIPPLED_VERSION -void CrippledVersionFailureToLoadMapCheck() +void CrippledVersionFailureToLoadMapCheck( ) { CHAR16 zString[512]; @@ -6626,12 +6633,12 @@ void CrippledVersionFailureToLoadMapCheck() void CrippledVersionFailureToLoadMapCallBack( UINT8 bExitValue ) { //clean up the code - ReStartingGame(); + ReStartingGame( ); //go to the main menu - if( guiCurrentScreen == MAP_SCREEN ) + if ( guiCurrentScreen == MAP_SCREEN ) { - SetPendingNewScreen(MAINMENU_SCREEN); + SetPendingNewScreen( MAINMENU_SCREEN ); } else { @@ -6642,32 +6649,32 @@ void CrippledVersionFailureToLoadMapCallBack( UINT8 bExitValue ) BOOLEAN EscapeDirectionIsValid( INT8 * pbDirection ) { UINT8 ubSectorID = SECTOR( gWorldSectorX, gWorldSectorY ); - - switch( *pbDirection ) + + switch ( *pbDirection ) { - case NORTHEAST: // east - if( gWorldSectorX + 1 > MAXIMUM_VALID_X_COORDINATE || gMapInformation.sEastGridNo == NOWHERE || - SectorInfo[ ubSectorID ].ubTraversability[ EAST_STRATEGIC_MOVE ] == GROUNDBARRIER || SectorInfo[ ubSectorID ].ubTraversability[ EAST_STRATEGIC_MOVE ] == EDGEOFWORLD ) - *pbDirection = -1; - break; - case SOUTHEAST: // south - if( gWorldSectorY + 1 > MAXIMUM_VALID_Y_COORDINATE || gMapInformation.sSouthGridNo == NOWHERE || - SectorInfo[ ubSectorID ].ubTraversability[ SOUTH_STRATEGIC_MOVE ] == GROUNDBARRIER || SectorInfo[ ubSectorID ].ubTraversability[ SOUTH_STRATEGIC_MOVE ] == EDGEOFWORLD ) - *pbDirection = -1; - break; - case SOUTHWEST: // west - if( gWorldSectorX - 1 < MINIMUM_VALID_X_COORDINATE || gMapInformation.sWestGridNo == NOWHERE || - SectorInfo[ ubSectorID ].ubTraversability[ WEST_STRATEGIC_MOVE ] == GROUNDBARRIER || SectorInfo[ ubSectorID ].ubTraversability[ WEST_STRATEGIC_MOVE ] == EDGEOFWORLD ) - *pbDirection = -1; - break; - case NORTHWEST: // north - if( gWorldSectorY - 1 < MINIMUM_VALID_Y_COORDINATE || gMapInformation.sNorthGridNo == NOWHERE || - SectorInfo[ ubSectorID ].ubTraversability[ NORTH_STRATEGIC_MOVE ] == GROUNDBARRIER || SectorInfo[ ubSectorID ].ubTraversability[ NORTH_STRATEGIC_MOVE ] == EDGEOFWORLD ) - *pbDirection = -1; - break; - default: *pbDirection = -1; + case NORTHEAST: // east + if ( gWorldSectorX + 1 > MAXIMUM_VALID_X_COORDINATE || gMapInformation.sEastGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == EDGEOFWORLD ) + *pbDirection = -1; + break; + case SOUTHEAST: // south + if ( gWorldSectorY + 1 > MAXIMUM_VALID_Y_COORDINATE || gMapInformation.sSouthGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == EDGEOFWORLD ) + *pbDirection = -1; + break; + case SOUTHWEST: // west + if ( gWorldSectorX - 1 < MINIMUM_VALID_X_COORDINATE || gMapInformation.sWestGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == EDGEOFWORLD ) + *pbDirection = -1; + break; + case NORTHWEST: // north + if ( gWorldSectorY - 1 < MINIMUM_VALID_Y_COORDINATE || gMapInformation.sNorthGridNo == NOWHERE || + SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == EDGEOFWORLD ) + *pbDirection = -1; + break; + default: *pbDirection = -1; } - return( *pbDirection != -1 ); + return(*pbDirection != -1); } #ifdef JA2UB @@ -6684,116 +6691,116 @@ typedef struct void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) { UINT32 uiCnt; - INT8 bNumValidMercs=-1; + INT8 bNumValidMercs = -1; INT32 iSectorID = SECTOR( sSectorX, sSectorY ); - UINT8 ubValidMercProfileIDArray[ NUM_MERCS_WITH_NEW_QUOTES ]; - SOLDIERTYPE *pSoldier=NULL; + UINT8 ubValidMercProfileIDArray[NUM_MERCS_WITH_NEW_QUOTES]; + SOLDIERTYPE *pSoldier = NULL; - #define NUM_VALID_SECTORS 6 - #define DELAY_FOR_PLAYER_DESC_OF_SECTOR 2 - ENTER_SECTOR_PLAYER_QUOTE PlayerSectorDescQuote[ NUM_VALID_SECTORS ] = +#define NUM_VALID_SECTORS 6 +#define DELAY_FOR_PLAYER_DESC_OF_SECTOR 2 + ENTER_SECTOR_PLAYER_QUOTE PlayerSectorDescQuote[NUM_VALID_SECTORS] = { - { SEC_H9, 0, QUOTE_HATE_MERC_1_ON_TEAM }, - { SEC_I9, 0, QUOTE_LEARNED_TO_HATE_MERC_ON_TEAM }, - { SEC_H10, 0, QUOTE_LEARNED_TO_HATE_MERC_ON_TEAM }, - { SEC_I10, 0, QUOTE_HATE_MERC_2_ON_TEAM }, - { SEC_J13, 0, QUOTE_ENTER_SECTOR_WITH_FAN_1 }, - { SEC_J14, 1, 0 }, + {SEC_H9, 0, QUOTE_HATE_MERC_1_ON_TEAM}, + {SEC_I9, 0, QUOTE_LEARNED_TO_HATE_MERC_ON_TEAM}, + {SEC_H10, 0, QUOTE_LEARNED_TO_HATE_MERC_ON_TEAM}, + {SEC_I10, 0, QUOTE_HATE_MERC_2_ON_TEAM}, + {SEC_J13, 0, QUOTE_ENTER_SECTOR_WITH_FAN_1}, + {SEC_J14, 1, 0}, }; //loop through all the sectors that have the quotes - for( uiCnt=0; uiCntbActive && pSoldier->bInSector ) - { - pSoldier->EVENT_InitNewSoldierAnim( CRAWLING, 1, TRUE ); - pSoldier->ChangeSoldierStance( PRONE ); - } - } +// Loop through the list and move some of the enemies +for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; cnt++, pSoldier++) +{ +//if the soldier is active, +if( pSoldier->bActive && pSoldier->bInSector ) +{ +pSoldier->EVENT_InitNewSoldierAnim( CRAWLING, 1, TRUE ); +pSoldier->ChangeSoldierStance( PRONE ); +} +} } */ -void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap() +void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap( ) { - SOLDIERTYPE *pSoldier=NULL; - UINT8 ubNumEnemiesMoved=0; + SOLDIERTYPE *pSoldier = NULL; + UINT8 ubNumEnemiesMoved = 0; //if we are loading a saved game, or we have already moved the enemies, get out. - if( gTacticalStatus.uiFlags & LOADING_SAVED_GAME || - gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__ALREADY_MOVED_ENEMIES_IN_COMPLEX ) + if ( gTacticalStatus.uiFlags & LOADING_SAVED_GAME || + gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__ALREADY_MOVED_ENEMIES_IN_COMPLEX ) { return; } //if the player made a 'noise' going through the gate at the end of the tunnel sector - if( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__DID_PLAYER_MAKE_SOUND_GOING_THROUGH_TUNNEL_GATE ) + if ( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__DID_PLAYER_MAKE_SOUND_GOING_THROUGH_TUNNEL_GATE ) { UINT8 cnt; @@ -7222,29 +7229,29 @@ void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap() // // Loop through the list and move some of the enemies - cnt = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID; cnt++, pSoldier++) - { + cnt = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[ENEMY_TEAM].bLastID; cnt++, pSoldier++ ) + { //if the soldier is active, - if ( pSoldier->bActive ) + if ( pSoldier->bActive ) { // // move the soldier to the modified location // - if( pSoldier->sGridNo == 13959 ) + if ( pSoldier->sGridNo == 13959 ) { - pSoldier->SetSoldierGridNo( 15705, TRUE ); + pSoldier->SetSoldierGridNo( 15705, TRUE ); ubNumEnemiesMoved++; } - if( pSoldier->sGridNo == 13983 ) + if ( pSoldier->sGridNo == 13983 ) { pSoldier->SetSoldierGridNo( 15712, TRUE ); ubNumEnemiesMoved++; } - if( pSoldier->sGridNo == 12543 ) + if ( pSoldier->sGridNo == 12543 ) { pSoldier->SetSoldierGridNo( 15233, TRUE ); ubNumEnemiesMoved++; @@ -7252,11 +7259,11 @@ void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap() } } - while( ubNumEnemiesMoved < 3 ) + while ( ubNumEnemiesMoved < 3 ) { - cnt = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID; cnt++, pSoldier++) - { + cnt = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[ENEMY_TEAM].bLastID; cnt++, pSoldier++ ) + { //if the soldier is active, if ( pSoldier->bActive && pSoldier->sGridNo != 15705 && pSoldier->sGridNo != 15712 && pSoldier->sGridNo != 15233 ) { @@ -7264,19 +7271,19 @@ void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap() // move the soldier to the modified location // - if( ubNumEnemiesMoved == 0 ) + if ( ubNumEnemiesMoved == 0 ) { pSoldier->SetSoldierGridNo( 15706, TRUE ); ubNumEnemiesMoved++; } - if( ubNumEnemiesMoved == 1 ) + if ( ubNumEnemiesMoved == 1 ) { pSoldier->SetSoldierGridNo( 15713, TRUE ); ubNumEnemiesMoved++; } - if( ubNumEnemiesMoved == 2 ) + if ( ubNumEnemiesMoved == 2 ) { pSoldier->SetSoldierGridNo( 15234, TRUE ); ubNumEnemiesMoved++; @@ -7290,10 +7297,10 @@ void HandleMovingTheEnemiesToBeNearPlayerWhenEnteringComplexMap() } } -void HandleFortifiedDoor() +void HandleFortifiedDoor( ) { //if the fortified door should be open - if( gJa25SaveStruct.ubStatusOfFortifiedDoor == FD__OPEN ) + if ( gJa25SaveStruct.ubStatusOfFortifiedDoor == FD__OPEN ) { ModifyDoorStatus( 11419, TRUE, DONTSETDOORSTATUS ); } @@ -7302,27 +7309,27 @@ void HandleFortifiedDoor() void CreateAndAddMoneyObjectToGround( UINT32 sGridNo, INT32 iEasyAmount, INT32 iNormalAmount, INT32 iHardAmount ) { OBJECTTYPE Object; - INT32 iCash=0; -// INT8 bAmountToAdd=0; + INT32 iCash = 0; + // INT8 bAmountToAdd=0; - switch( gGameOptions.ubDifficultyLevel ) + switch ( gGameOptions.ubDifficultyLevel ) { - case DIF_LEVEL_EASY: - iCash = iEasyAmount; - break; + case DIF_LEVEL_EASY: + iCash = iEasyAmount; + break; - case DIF_LEVEL_MEDIUM: - iCash = iNormalAmount; - break; + case DIF_LEVEL_MEDIUM: + iCash = iNormalAmount; + break; - case DIF_LEVEL_HARD: - iCash = iHardAmount; - break; + case DIF_LEVEL_HARD: + iCash = iHardAmount; + break; - default: - iCash = iNormalAmount; - //Assert(0); - break; + default: + iCash = iNormalAmount; + //Assert(0); + break; } CreateMoney( iCash, &Object ); @@ -7334,11 +7341,11 @@ void CreateAndAddMoneyObjectToGround( UINT32 sGridNo, INT32 iEasyAmount, INT32 i void HandleGoingUpOrDownStairsForLoadScreensPurposes( INT16 sCurrentlyInSectorZ, INT16 sGoingToSectorZ ) { - if( sCurrentlyInSectorZ == sGoingToSectorZ ) + if ( sCurrentlyInSectorZ == sGoingToSectorZ ) { gJa25SaveStruct.ubLoadScreenStairTraversal = LS__NOT_GOING_UP_STAIRS; } - else if( sCurrentlyInSectorZ < sGoingToSectorZ ) + else if ( sCurrentlyInSectorZ < sGoingToSectorZ ) { gJa25SaveStruct.ubLoadScreenStairTraversal = LS__GOING_DOWN_STAIRS; } @@ -7348,22 +7355,22 @@ void HandleGoingUpOrDownStairsForLoadScreensPurposes( INT16 sCurrentlyInSectorZ, } } -void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap() +void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap( ) { - SOLDIERTYPE *pSoldier=NULL; - UINT8 ubIndex=0; + SOLDIERTYPE *pSoldier = NULL; + UINT8 ubIndex = 0; UINT32 cnt; - BOOLEAN fDone=FALSE; + BOOLEAN fDone = FALSE; INT16 sXPos, sYPos; - UINT32 sGridNos[27]={ 18200, 18360, 18520, - 18199, 18359, 18519, - 18198, 18358, 18518, - 18197, 18357, 18517, - 18196, 18356, 18516, - 18195, 18355, 18515, - 18194, 18354, 18514, - 18193, 18353, 18513, - 18035, 18034, 18033, + UINT32 sGridNos[27] = {18200, 18360, 18520, + 18199, 18359, 18519, + 18198, 18358, 18518, + 18197, 18357, 18517, + 18196, 18356, 18516, + 18195, 18355, 18515, + 18194, 18354, 18514, + 18193, 18353, 18513, + 18035, 18034, 18033, }; @@ -7372,31 +7379,31 @@ void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap() // // Loop through the list and move some of the enemies - cnt = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID; cnt++, pSoldier++) - { + cnt = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[ENEMY_TEAM].bLastID; cnt++, pSoldier++ ) + { //if the soldier is active, - if ( pSoldier->bActive ) + if ( pSoldier->bActive ) { fDone = FALSE; - while( !fDone ) + while ( !fDone ) { //if there is no one in the gridno - if( WhoIsThere2( sGridNos[ ubIndex ], 0 ) == NOBODY ) + if ( WhoIsThere2( sGridNos[ubIndex], 0 ) == NOBODY ) { // move the soldier to the modified location - ConvertGridNoToCenterCellXY( sGridNos[ ubIndex ], &sXPos, &sYPos ); + ConvertGridNoToCenterCellXY( sGridNos[ubIndex], &sXPos, &sYPos ); pSoldier->EVENT_SetSoldierPosition( sXPos, sYPos ); -// SetSoldierGridNo( pSoldier, sGridNos[ ubIndex ], TRUE ); + // SetSoldierGridNo( pSoldier, sGridNos[ ubIndex ], TRUE ); ubIndex++; - fDone=TRUE; + fDone = TRUE; } else { ubIndex++; } - if( ubIndex >= 27 ) + if ( ubIndex >= 27 ) { Assert( 0 ); return; @@ -7406,19 +7413,19 @@ void HandleMovingEnemiesCloseToEntranceInFirstTunnelMap() } } -void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap() +void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap( ) { - SOLDIERTYPE *pSoldier=NULL; - UINT8 ubIndex=0; - BOOLEAN fDone=FALSE; + SOLDIERTYPE *pSoldier = NULL; + UINT8 ubIndex = 0; + BOOLEAN fDone = FALSE; UINT32 cnt; INT16 sXPos, sYPos; - UINT32 sGridNos[30]={ 4900, 4901, 4902, 4903, 4904, - 5060, 5061, 5062, 5063, 5064, - 5220, 5221, 5222, 5223, 5224, - 5380, 5381, 5382, 5383, 5384, - 5540, 5541, 5542, 5543, 5544, - 5700, 5701, 5702, 5703, 5704 }; + UINT32 sGridNos[30] = {4900, 4901, 4902, 4903, 4904, + 5060, 5061, 5062, 5063, 5064, + 5220, 5221, 5222, 5223, 5224, + 5380, 5381, 5382, 5383, 5384, + 5540, 5541, 5542, 5543, 5544, + 5700, 5701, 5702, 5703, 5704}; @@ -7427,31 +7434,31 @@ void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap() // // Loop through the list and move some of the enemies - cnt = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID; cnt++, pSoldier++) - { + cnt = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[ENEMY_TEAM].bLastID; cnt++, pSoldier++ ) + { //if the soldier is active, - if ( pSoldier->bActive ) + if ( pSoldier->bActive ) { fDone = FALSE; - while( !fDone ) + while ( !fDone ) { //if there is no one in the gridno - if( WhoIsThere2( sGridNos[ ubIndex ], 0 ) == NOBODY ) + if ( WhoIsThere2( sGridNos[ubIndex], 0 ) == NOBODY ) { // move the soldier to the modified location - ConvertGridNoToCenterCellXY( sGridNos[ ubIndex ], &sXPos, &sYPos ); + ConvertGridNoToCenterCellXY( sGridNos[ubIndex], &sXPos, &sYPos ); pSoldier->EVENT_SetSoldierPosition( sXPos, sYPos ); -// SetSoldierGridNo( pSoldier, sGridNos[ ubIndex ], TRUE ); + // SetSoldierGridNo( pSoldier, sGridNos[ ubIndex ], TRUE ); ubIndex++; - fDone=TRUE; + fDone = TRUE; } else { ubIndex++; } - if( ubIndex >= 26 ) + if ( ubIndex >= 26 ) { Assert( 0 ); return; @@ -7461,85 +7468,85 @@ void HandleMovingEnemiesCloseToEntranceInSecondTunnelMap() } } -void HandlePowerGenFanSoundModification() +void HandlePowerGenFanSoundModification( ) { SetTileAnimCounter( TILE_ANIM__FAST_SPEED ); - switch( gJa25SaveStruct.ubStateOfFanInPowerGenSector ) + switch ( gJa25SaveStruct.ubStateOfFanInPowerGenSector ) { - case PGF__RUNNING_NORMALLY: - HandleAddingPowerGenFanSound(); + case PGF__RUNNING_NORMALLY: + HandleAddingPowerGenFanSound( ); - //MAKE SURE the fan does not have an exit grid - RemoveExitGridFromWorld( PGF__FAN_EXIT_GRID_GRIDNO ); - break; - - case PGF__STOPPED: - //Add an exit grid to the map - AddExitGridForFanToPowerGenSector(); - break; - - case PGF__BLOWN_UP: - break; + //MAKE SURE the fan does not have an exit grid + RemoveExitGridFromWorld( PGF__FAN_EXIT_GRID_GRIDNO ); + break; - default: - Assert( 0 ); + case PGF__STOPPED: + //Add an exit grid to the map + AddExitGridForFanToPowerGenSector( ); + break; + + case PGF__BLOWN_UP: + break; + + default: + Assert( 0 ); } } -void HandleFirstPartOfTunnelFanSound() +void HandleFirstPartOfTunnelFanSound( ) { - switch( gJa25SaveStruct.ubStateOfFanInPowerGenSector ) + switch ( gJa25SaveStruct.ubStateOfFanInPowerGenSector ) { - case PGF__RUNNING_NORMALLY: - case PGF__STOPPED: + case PGF__RUNNING_NORMALLY: + case PGF__STOPPED: - //add the sound to the world - HandleAddingPowerGenFanSound(); - break; + //add the sound to the world + HandleAddingPowerGenFanSound( ); + break; } } -void HandleMovingEnemiesOntoRoofs() +void HandleMovingEnemiesOntoRoofs( ) { - if( gWorldSectorX <= 0 || gWorldSectorY <= 0 || gbWorldSectorZ < 0 ) + if ( gWorldSectorX <= 0 || gWorldSectorY <= 0 || gbWorldSectorZ < 0 ) { return; } //if this is the sector south of the town - if( gWorldSectorX == 11 && gWorldSectorY == MAP_ROW_J && gbWorldSectorZ == 0 ) + if ( gWorldSectorX == 11 && gWorldSectorY == MAP_ROW_J && gbWorldSectorZ == 0 ) { - switch( gGameOptions.ubDifficultyLevel ) + switch ( gGameOptions.ubDifficultyLevel ) { - case DIF_LEVEL_EASY: - case DIF_LEVEL_MEDIUM: - break; - case DIF_LEVEL_HARD: - MoveEnemyFromGridNoToRoofGridNo( 15446, 13993 ); - MoveEnemyFromGridNoToRoofGridNo( 15436, 14006 ); - break; - default: - MoveEnemyFromGridNoToRoofGridNo( 15446, 13993 ); - MoveEnemyFromGridNoToRoofGridNo( 15436, 14006 ); - break; + case DIF_LEVEL_EASY: + case DIF_LEVEL_MEDIUM: + break; + case DIF_LEVEL_HARD: + MoveEnemyFromGridNoToRoofGridNo( 15446, 13993 ); + MoveEnemyFromGridNoToRoofGridNo( 15436, 14006 ); + break; + default: + MoveEnemyFromGridNoToRoofGridNo( 15446, 13993 ); + MoveEnemyFromGridNoToRoofGridNo( 15436, 14006 ); + break; } } //else if this is the sector south of the town - else if( gWorldSectorX == 11 && gWorldSectorY == MAP_ROW_H && gbWorldSectorZ == 0 ) + else if ( gWorldSectorX == 11 && gWorldSectorY == MAP_ROW_H && gbWorldSectorZ == 0 ) { - switch( gGameOptions.ubDifficultyLevel ) + switch ( gGameOptions.ubDifficultyLevel ) { - case DIF_LEVEL_EASY: - case DIF_LEVEL_MEDIUM: - break; - case DIF_LEVEL_HARD: - MoveEnemyFromGridNoToRoofGridNo( 8711, 5521 ); - break; - default: - MoveEnemyFromGridNoToRoofGridNo( 8711, 5521 ); - break; + case DIF_LEVEL_EASY: + case DIF_LEVEL_MEDIUM: + break; + case DIF_LEVEL_HARD: + MoveEnemyFromGridNoToRoofGridNo( 8711, 5521 ); + break; + default: + MoveEnemyFromGridNoToRoofGridNo( 8711, 5521 ); + break; } } } @@ -7548,15 +7555,15 @@ void HandleMovingEnemiesOntoRoofs() BOOLEAN MoveEnemyFromGridNoToRoofGridNo( UINT32 sSourceGridNo, UINT32 sDestGridNo ) { - SOLDIERTYPE *pSoldier=NULL; + SOLDIERTYPE *pSoldier = NULL; INT32 cnt; INT16 sXPos, sYPos; - cnt = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; - for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ ENEMY_TEAM ].bLastID; cnt++, pSoldier++) - { - if( pSoldier->stats.bLife >= OKLIFE && pSoldier->bActive && pSoldier->bInSector && - pSoldier->sGridNo == sSourceGridNo ) + cnt = gTacticalStatus.Team[ENEMY_TEAM].bFirstID; + for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[ENEMY_TEAM].bLastID; cnt++, pSoldier++ ) + { + if ( pSoldier->stats.bLife >= OKLIFE && pSoldier->bActive && pSoldier->bInSector && + pSoldier->sGridNo == sSourceGridNo ) { pSoldier->SetSoldierHeight( 50.0 ); @@ -7564,12 +7571,12 @@ BOOLEAN MoveEnemyFromGridNoToRoofGridNo( UINT32 sSourceGridNo, UINT32 sDestGridN ConvertGridNoToCenterCellXY( sDestGridNo, &sXPos, &sYPos ); pSoldier->EVENT_SetSoldierPosition( sXPos, sYPos ); - return( TRUE ); -// pSoldier->bOrders = SEEKENEMY; + return(TRUE); + // pSoldier->bOrders = SEEKENEMY; } } - return( FALSE ); + return(FALSE); } #endif @@ -7583,8 +7590,8 @@ BOOLEAN CanRequestMilitiaReinforcements( INT16 sMapX, INT16 sMapY, INT16 sSrcMap if ( !NumNonPlayerTeamMembersInSector( sSrcMapX, sSrcMapY, MILITIA_TEAM ) ) return FALSE; - UINT8 townid_A = GetTownIdForSector( sMapX, sMapY ); - UINT8 townid_B = GetTownIdForSector( sSrcMapX, sSrcMapY ); + UINT8 townid_A = GetTownIdForSector( sMapX, sMapY ); + UINT8 townid_B = GetTownIdForSector( sSrcMapX, sSrcMapY ); switch ( gSkillTraitValues.usVOReinforcementSetting ) { diff --git a/Tactical/DisplayCover.cpp b/Tactical/DisplayCover.cpp index 750adc76..b53f03c1 100644 --- a/Tactical/DisplayCover.cpp +++ b/Tactical/DisplayCover.cpp @@ -69,13 +69,9 @@ CoverCell gCoverViewArea[ COVER_X_CELLS ][ COVER_Y_CELLS ][ COVER_Z_CELLS ]; DWORD guiCoverNextUpdateTime = 0; -COVER_DRAW_MODE gubDrawMode = COVER_DRAW_OFF; +COVER_DRAW_MODE gubDrawMode = DRAW_MODE_OFF; -MINES_DRAW_MODE gubDrawModeMine = MINES_DRAW_OFF; // Flugente: mines display - -TRAIT_DRAW_MODE gubDrawModeTrait = TRAIT_DRAW_OFF; // Flugente: mines display - -TRACKER_DRAW_MODE gubDrawModeTracker = TRACKER_DRAW_OFF; // Flugente: tracker display +BOOLEAN gNoRedraw = FALSE; //******* Local Function Prototypes *********************************** @@ -84,8 +80,8 @@ CHAR16* GetTerrainName( const UINT8& ubTerrainType ); // anv: additional tile properties CHAR16* GetDetailedTerrainName( ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProperties ); -void AddCoverObjectToWorld( const INT32& sGridNo, const UINT16& usGraphic, const BOOLEAN& fRoof, BOOLEAN fNightTime ); -void RemoveCoverObjectFromWorld( const INT32 sGridNo, const UINT16& usGraphic, const BOOLEAN& fRoof ); +void AddCoverObjectToWorld( INT32 sGridNo, UINT16 usGraphic, BOOLEAN fRoof, BOOLEAN fNightTime ); +void RemoveCoverObjectFromWorld( INT32 sGridNo, UINT16 usGraphic, BOOLEAN fRoof ); void AddCoverObjectsToViewArea(); void RemoveCoverObjectsFromViewArea(); @@ -94,6 +90,7 @@ void CalculateCover(); void CalculateMines(); void CalculateTraitRange(); void CalculateTrackerRange(); +void CalculateFortify(); void GetGridNoForViewPort( const INT32& ubX, const INT32& ubY, INT32& sGridNo ); @@ -102,16 +99,7 @@ BOOLEAN GridNoOnScreenAndAround( const INT32& sGridNo, const UINT8& ubRadius=2 ) BOOLEAN IsTheRoofVisible( const INT32& sGridNo ); BOOLEAN HasAdjTile( const INT32& ubX, const INT32& ubY ); -// resets the overlay modes so that everything will be reset at the NEXT display cycle -void ResetOverlayModes() -{ - gubDrawMode = COVER_DRAW_OFF; - gubDrawModeMine = MINES_DRAW_OFF; - gubDrawModeTrait = TRAIT_DRAW_OFF; - gubDrawModeTracker = TRACKER_DRAW_OFF; -} - -TileDefines GetOverlayIndex( const INT8& bOverlayType ) +TileDefines GetOverlayIndex( INT8 bOverlayType ) { switch ( bOverlayType ) { @@ -125,6 +113,8 @@ TileDefines GetOverlayIndex( const INT8& bOverlayType ) case MINES_LVL_4: case TRACKS_BLOOD: + + case FORTIFICATIONNODE_REMOVE: return SPECIALTILE_COVER_1; // red case MIN_COVER: @@ -138,6 +128,8 @@ TileDefines GetOverlayIndex( const INT8& bOverlayType ) case TRAIT_2: case TRACKS_VERYOLD: + + case FORTIFICATIONNODE_ADJACENTADJUSTMENT: return SPECIALTILE_COVER_2; // orange case MED_COVER: @@ -151,6 +143,8 @@ TileDefines GetOverlayIndex( const INT8& bOverlayType ) case TRAIT_ALL: case TRACKS_OLD: + + case FORTIFICATIONNODE_NORMAL: return SPECIALTILE_COVER_3; // yellow case MAX_COVER: @@ -197,10 +191,10 @@ void SwitchToEnemyView() void SwitchViewOff() { - if (gubDrawMode == COVER_DRAW_OFF) + if ( gubDrawMode == DRAW_MODE_OFF ) return; - gubDrawMode = COVER_DRAW_OFF; + gubDrawMode = DRAW_MODE_OFF; ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzDisplayCoverText[DC_MSG__COVER_DRAW_OFF]); DisplayCover(TRUE); } @@ -314,7 +308,7 @@ CHAR16* GetDetailedTerrainName( ADDITIONAL_TILE_PROPERTIES_VALUES zGivenTileProp } } -void AddCoverObjectToWorld( const INT32& sGridNo, const UINT16& usGraphic, const BOOLEAN& fRoof, BOOLEAN fNightTime ) +void AddCoverObjectToWorld( INT32 sGridNo, UINT16 usGraphic, BOOLEAN fRoof, BOOLEAN fNightTime ) { LEVELNODE *pNode; @@ -338,7 +332,7 @@ void AddCoverObjectToWorld( const INT32& sGridNo, const UINT16& usGraphic, const } } -void RemoveCoverObjectFromWorld( const INT32 sGridNo, const UINT16& usGraphic, const BOOLEAN& fRoof ) +void RemoveCoverObjectFromWorld( INT32 sGridNo, UINT16 usGraphic, BOOLEAN fRoof ) { if( fRoof ) { @@ -380,7 +374,7 @@ BOOLEAN HasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ) void AddCoverObjectsToViewArea() { - if (gsMaxCellY == -1) + if ( gsMaxCellY < 0 ) return; register INT32 ubX, ubY, ubZ; @@ -394,14 +388,9 @@ void AddCoverObjectsToViewArea() { for ( ubZ=0; ubZ guiCoverNextUpdateTime ) ) { - if ( gubDrawMode != COVER_DRAW_OFF ) + // remove old cover objects + RemoveCoverObjectsFromViewArea(); + + switch ( gubDrawMode ) + { + case COVER_DRAW_MERC_VIEW: + case COVER_DRAW_ENEMY_VIEW: CalculateCover(); - else if ( gubDrawModeMine != MINES_DRAW_OFF ) - CalculateMines( ); - else if ( gubDrawModeTrait != TRAIT_DRAW_OFF ) - CalculateTraitRange( ); - else //if ( gubDrawModeTracker != TRAIT_DRAW_OFF ) - CalculateTrackerRange( ); + break; + + case MINES_DRAW_DETECT_ENEMY: + case MINES_DRAW_PLAYERTEAM_NETWORKS: + case MINES_DRAW_NETWORKCOLOURING: + case MINES_DRAW_NET_A: + case MINES_DRAW_NET_B: + case MINES_DRAW_NET_C: + case MINES_DRAW_NET_D: + CalculateMines(); + break; + + case DRAW_MODE_TRAIT_RANGE: + CalculateTraitRange(); + break; + + case DRAW_MODE_TRACKER_SMELL: + CalculateTrackerRange(); + break; + + case DRAW_MODE_FORTIFY: + CalculateFortify( ); + break; + } guiCoverNextUpdateTime = GetTickCount() + gGameExternalOptions.ubCoverDisplayUpdateWait; } @@ -504,26 +526,11 @@ void CalculateCover() register INT8 ubZ; SOLDIERTYPE* pSoldier; - RemoveCoverObjectsFromViewArea(); - - if( gubDrawMode == COVER_DRAW_OFF ) - { - return; - } - if( gusSelectedSoldier == NOBODY ) - { return; - } GetSoldier( &pSoldier, gusSelectedSoldier ); - INT16 usTmp; - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMinCellX, &usTmp ); - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMaxCellX, &usTmp ); - - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMinCellY ); - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMaxCellY ); for ( ubX=gsMinCellX; ubX<=gsMaxCellX; ++ubX ) { for ( ubY=gsMinCellY; ubY<=gsMaxCellY; ++ubY ) @@ -531,8 +538,6 @@ void CalculateCover() for ( ubZ=0; ubZ MINES_DRAW_NET_D ) return; - gubDrawModeMine = MINES_DRAW_OFF; + gubDrawMode = DRAW_MODE_OFF; ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); DisplayCover( TRUE ); } void ToggleHostileTrapsView() { - if (gubDrawModeMine == MINES_DRAW_DETECT_ENEMY) { + if ( gubDrawMode == MINES_DRAW_DETECT_ENEMY ) { SwitchMineViewOff(); } else { SwitchToHostileTrapsView(); @@ -918,44 +923,41 @@ void ToggleHostileTrapsView() void ToggleTrapNetworkView() { - SwitchMinesDrawModeForNetworks(); -} - -void SwitchMinesDrawModeForNetworks() -{ - switch ( gubDrawModeMine ) + switch ( gubDrawMode ) { - case MINES_DRAW_OFF: - case MINES_DRAW_DETECT_ENEMY: - gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network"); - break; - case MINES_DRAW_PLAYERTEAM_NETWORKS: - gubDrawModeMine = MINES_DRAW_NETWORKCOLOURING; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network colouring"); - break; - case MINES_DRAW_NETWORKCOLOURING: - gubDrawModeMine = MINES_DRAW_NET_A; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network A"); - break; - case MINES_DRAW_NET_A: - gubDrawModeMine = MINES_DRAW_NET_B; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network B"); - break; - case MINES_DRAW_NET_B: - gubDrawModeMine = MINES_DRAW_NET_C; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network C"); - break; - case MINES_DRAW_NET_C: - gubDrawModeMine = MINES_DRAW_NET_D; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network D"); - break; - case MINES_DRAW_NET_D: - case MINES_DRAW_MAX: - default: - gubDrawModeMine = MINES_DRAW_OFF; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display"); - break; + case MINES_DRAW_DETECT_ENEMY: + gubDrawMode = MINES_DRAW_PLAYERTEAM_NETWORKS; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network" ); + break; + case MINES_DRAW_PLAYERTEAM_NETWORKS: + gubDrawMode = MINES_DRAW_NETWORKCOLOURING; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network colouring" ); + break; + case MINES_DRAW_NETWORKCOLOURING: + gubDrawMode = MINES_DRAW_NET_A; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network A" ); + break; + case MINES_DRAW_NET_A: + gubDrawMode = MINES_DRAW_NET_B; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network B" ); + break; + case MINES_DRAW_NET_B: + gubDrawMode = MINES_DRAW_NET_C; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network C" ); + break; + case MINES_DRAW_NET_C: + gubDrawMode = MINES_DRAW_NET_D; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trap network D" ); + break; + case MINES_DRAW_NET_D: + gubDrawMode = DRAW_MODE_OFF; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Turning off trap display" ); + break; + + default: + gubDrawMode = MINES_DRAW_DETECT_ENEMY; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display enemy traps" ); + break; } DisplayCover( TRUE ); @@ -964,7 +966,7 @@ void SwitchMinesDrawModeForNetworks() void AddMinesObjectsToViewArea() { - if (gsMaxCellY == -1) + if ( gsMaxCellY < 0 ) return; register INT32 ubX, ubY, ubZ; @@ -974,7 +976,7 @@ void AddMinesObjectsToViewArea() BOOLEAN fSearchAdjTile = TRUE; // no search for adjacent tiles when looking at a specific network (we have only 4 colours, need them all :-) - if ( gubDrawModeMine == MINES_DRAW_NETWORKCOLOURING || gubDrawModeMine == MINES_DRAW_NET_A || gubDrawModeMine == MINES_DRAW_NET_B || gubDrawModeMine == MINES_DRAW_NET_C || gubDrawModeMine == MINES_DRAW_NET_D ) + if ( gubDrawMode == MINES_DRAW_NETWORKCOLOURING || gubDrawMode == MINES_DRAW_NET_A || gubDrawMode == MINES_DRAW_NET_B || gubDrawMode == MINES_DRAW_NET_C || gubDrawMode == MINES_DRAW_NET_D ) fSearchAdjTile = FALSE; for ( ubX=gsMinCellX; ubX<=gsMaxCellX; ++ubX ) @@ -983,16 +985,11 @@ void AddMinesObjectsToViewArea() { for ( ubZ=0; ubZbInSector ) return; // if we want to detect hostile mines and we have an metal detector in our hands, allow seeking BOOLEAN fWithMineDetector = FALSE; - if ( pSoldier && gubDrawModeMine == MINES_DRAW_DETECT_ENEMY ) + if ( pSoldier && gubDrawMode == MINES_DRAW_DETECT_ENEMY ) { if ( FindMetalDetectorInHand(pSoldier) != NO_SLOT ) fWithMineDetector = TRUE; - - // TODO: perhaps even consume batteries one day... - } - - // if we are looking for mines via mine detector, but don't have one equipped, return, we won't detect anything - if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && !fWithMineDetector ) - { - return; + // if we are looking for mines via mine detector, but don't have one equipped, return, we won't detect anything + else + return; } const INT32& sSelectedSoldierGridNo = MercPtrs[ gusSelectedSoldier ]->sGridNo; - - INT16 usTmp; - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMinCellX, &usTmp ); - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMaxCellX, &usTmp ); - - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMinCellY ); - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMaxCellY ); + for ( ubX=gsMinCellX; ubX<=gsMaxCellX; ++ubX ) { for ( ubY=gsMinCellY; ubY<=gsMaxCellY; ++ubY ) @@ -1054,8 +1033,6 @@ void CalculateMines() for ( ubZ=0; ubZ 4 ) continue; @@ -1108,7 +1085,7 @@ void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bOverlayType, { // we are looking for hostile mines and have got an detector equipped // some bombs cannot be found via metal detector - if ( gubDrawModeMine == MINES_DRAW_DETECT_ENEMY && fWithMineDetector && !( HasItemFlag(pObj->usItem, NO_METAL_DETECTION) || HasItemFlag((*pObj)[0]->data.misc.usBombItem, NO_METAL_DETECTION) ) ) + if ( gubDrawMode == MINES_DRAW_DETECT_ENEMY && fWithMineDetector && !(HasItemFlag( pObj->usItem, NO_METAL_DETECTION ) || HasItemFlag( (*pObj)[0]->data.misc.usBombItem, NO_METAL_DETECTION )) ) { // display all mines bOverlayType = MINE_BOMB; @@ -1118,7 +1095,7 @@ void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bOverlayType, // look for mines from our own team if ( (*pObj)[0]->data.misc.ubBombOwner > 1 ) { - switch ( gubDrawModeMine ) + switch ( gubDrawMode ) { case MINES_DRAW_PLAYERTEAM_NETWORKS: { @@ -1193,7 +1170,7 @@ void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bOverlayType, if ( Item[pObj->usItem].tripwire == 1 ) { UINT32 specificnet = 0; - switch ( gubDrawModeMine ) + switch ( gubDrawMode ) { case MINES_DRAW_NET_A: specificnet = TRIPWIRE_NETWORK_NET_1; break; case MINES_DRAW_NET_B: specificnet = TRIPWIRE_NETWORK_NET_2; break; @@ -1222,7 +1199,6 @@ void DetermineMineDisplayInTile( INT32 sGridNo, INT8 bLevel, INT8& bOverlayType, break; case MINES_DRAW_DETECT_ENEMY: - case MINES_DRAW_MAX: default: break; } @@ -1247,20 +1223,16 @@ INT32 sTraitgridNo = NOWHERE; void ToggleTraitRangeView(BOOLEAN fOn) { if ( fOn ) - { - gubDrawModeTrait = TRAIT_DRAW_RANGE; - gubDrawMode = COVER_DRAW_OFF; - gubDrawModeMine = MINES_DRAW_OFF; - gubDrawModeTracker = TRACKER_DRAW_OFF; + { + gubDrawMode = DRAW_MODE_TRAIT_RANGE; } else { - gubDrawModeTrait = TRAIT_DRAW_OFF; + gubDrawMode = DRAW_MODE_OFF; SetTraitToDisplay( NO_SKILLTRAIT_NT ); SetGridNoForTraitDisplay( NOWHERE ); } - //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trait ranges"); DisplayCover( TRUE ); } @@ -1280,12 +1252,7 @@ void CalculateTraitRange() INT32 ubX, ubY; INT8 ubZ; SOLDIERTYPE* pSoldier; - - RemoveCoverObjectsFromViewArea( ); - - if ( gubDrawModeTrait == TRAIT_DRAW_OFF ) - return; - + if ( gusSelectedSoldier == NOBODY || !GetSoldier( &pSoldier, gusSelectedSoldier ) || !pSoldier->bInSector ) return; @@ -1313,12 +1280,6 @@ void CalculateTraitRange() const INT32& sSelectedSoldierGridNo = MercPtrs[ gusSelectedSoldier ]->sGridNo; - INT16 usTmp; - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMinCellX, &usTmp ); - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMaxCellX, &usTmp ); - - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMinCellY ); - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMaxCellY ); for ( ubX=gsMinCellX; ubX<=gsMaxCellX; ++ubX ) { for ( ubY=gsMinCellY; ubY<=gsMaxCellY; ++ubY ) @@ -1327,8 +1288,6 @@ void CalculateTraitRange() { INT32& sGridNo = gCoverViewArea[ ubX ][ ubY ][ ubZ ].sGridNo; - GetGridNoForViewPort( ubX, ubY, sGridNo ); - if( !GridNoOnScreenAndAround( sGridNo, 2 ) ) continue; @@ -1366,7 +1325,7 @@ void CalculateTraitRange() void AddTraitObjectsToViewArea() { - if (gsMaxCellY == -1) + if ( gsMaxCellY < 0 ) return; register INT32 ubX, ubY, ubZ; @@ -1380,13 +1339,9 @@ void AddTraitObjectsToViewArea() { for ( ubZ=0; ubZbInSector ) return; @@ -1467,13 +1417,7 @@ void CalculateTrackerRange( ) UINT16 range = gSkillTraitValues.usSVTrackerMaxRange * trackerskill; const INT32& sSelectedSoldierGridNo = MercPtrs[gusSelectedSoldier]->sGridNo; - - INT16 usTmp; - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_START_Y, &gsMinCellX, &usTmp ); - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_END_Y, &gsMaxCellX, &usTmp ); - - GetScreenXYWorldCell( gsVIEWPORT_END_X, gsVIEWPORT_START_Y, &usTmp, &gsMinCellY ); - GetScreenXYWorldCell( gsVIEWPORT_START_X, gsVIEWPORT_END_Y, &usTmp, &gsMaxCellY ); + for ( ubX = gsMinCellX; ubX <= gsMaxCellX; ++ubX ) { for ( ubY = gsMinCellY; ubY <= gsMaxCellY; ++ubY ) @@ -1482,8 +1426,6 @@ void CalculateTrackerRange( ) { INT32& sGridNo = gCoverViewArea[ubX][ubY][ubZ].sGridNo; - GetGridNoForViewPort( ubX, ubY, sGridNo ); - if ( !GridNoOnScreenAndAround( sGridNo, 2 ) ) continue; @@ -1537,7 +1479,7 @@ void CalculateTrackerRange( ) void AddTrackerObjectsToViewArea( ) { - if ( gsMaxCellY == -1 ) + if ( gsMaxCellY < 0 ) return; register INT32 ubX, ubY, ubZ; @@ -1551,13 +1493,9 @@ void AddTrackerObjectsToViewArea( ) { for ( ubZ = 0; ubZ > > vec = GetAllForticationGridNo( ); + + std::vector< std::pair > >::iterator itend = vec.end( ); + for ( std::vector< std::pair > >::iterator it = vec.begin( ); it != itend; ++it ) + { + INT16 sX, sY; + ConvertGridNoToXY( (*it).first, &sX, &sY ); + + gCoverViewArea[sX][sY][(*it).second.second].bOverlayType = (*it).second.first; + } + + if ( gsMaxCellY < 0 ) + return; + + register INT32 ubX, ubY, ubZ; + BOOLEAN fChanged = FALSE; + + BOOLEAN fNightTime = NightTime( ); + + for ( ubX = gsMinCellX; ubX <= gsMaxCellX; ++ubX ) + { + for ( ubY = gsMinCellY; ubY <= gsMaxCellY; ++ubY ) + { + for ( ubZ = 0; ubZubSoldierID]->GetConstructionPoints( )); + fShowNumber = TRUE; + fShowMaximum = TRUE; + + { + if ( MercPtrs[pFace->ubSoldierID]->bSectorZ ) + { + UNDERGROUND_SECTORINFO *pSectorInfo; + pSectorInfo = FindUnderGroundSector( MercPtrs[pFace->ubSoldierID]->sSectorX, MercPtrs[pFace->ubSoldierID]->sSectorY, MercPtrs[pFace->ubSoldierID]->bSectorZ ); + + if ( pSectorInfo ) + usMaximumPts = (INT16)(pSectorInfo->dFortification_MaxPossible); + } + else + { + SECTORINFO *pSectorInfo; + pSectorInfo = &SectorInfo[SECTOR( MercPtrs[pFace->ubSoldierID]->sSectorX, MercPtrs[pFace->ubSoldierID]->sSectorY )]; + + if ( pSectorInfo ) + usMaximumPts = (INT16)(pSectorInfo->dFortification_MaxPossible); + } + } + + break; } // Check for being serviced... diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 00600d84..845a4897 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -67,6 +67,12 @@ #include "Food.h" // added by sevenfm - this is needed for _keydown(SHIFT) to work #include "english.h" + + #include // added by Flugente + #include // added by Flugente + #include "DisplayCover.h" // added by Flugente + #include "Queen Command.h" // added by Flugente for FindUnderGroundSector(...) + #include // added by Flugente for vfs-stuff #endif #ifdef JA2UB @@ -78,6 +84,8 @@ #define NUM_ITEM_FLASH_SLOTS 50 #define MIN_LOB_RANGE 6 +// directory for fortification plans (locaed in Profiles sub-folder) +#define FORTIFICATIONPLAN_DIRECTORY "FortificationPlan\\" ITEM_POOL_LOCATOR FlashItemSlots[ NUM_ITEM_FLASH_SLOTS ]; UINT32 guiNumFlashItemSlots = 0; @@ -6938,7 +6946,7 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO { UINT32 fHeadType; UINT16 usUseIndex; - UINT16 usUseObjIndex = 0; + INT16 sUseObjIndex = -1; INT32 iRandSelIndex = 1; BOOLEAN fOkayToAdd; UINT8 ubDirection; @@ -6955,12 +6963,8 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO if ( TileIsOutOfBounds( sGridNo ) ) return FALSE; - //if( InARoom( sGridNo, NULL ) ) - //return FALSE; - // don't build in water - INT8 bOverTerrainType = GetTerrainType( sGridNo ); - if( bOverTerrainType == MED_WATER || bOverTerrainType == DEEP_WATER || bOverTerrainType == LOW_WATER ) + if ( TERRAIN_IS_WATER( GetTerrainType( sGridNo ) ) ) return FALSE; ubDirection = pSoldier->ubDirection; @@ -7051,32 +7055,29 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO } // search wether structure exists in the current tilesets. If not, well, too bad - for (UINT32 uiType = 0; uiType < giNumberOfTileTypes; ++uiType) + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) { // if tileset is from the current tileset, check that - if ( gTilesets[ giCurrentTilesetID ].TileSurfaceFilenames[ uiType ][0] ) + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType][0] ) { - if ( structureconstructindex >= 0 ) + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], gStructureConstruct[structureconstructindex].szTileSetName, 10 ) ) { - if ( !_strnicmp(gTilesets[ giCurrentTilesetID ].TileSurfaceFilenames[ uiType ], gStructureConstruct[structureconstructindex].szTileSetName, 10) ) - { - usUseObjIndex = uiType; - break; - } + sUseObjIndex = iType; + break; } } // otherwise, check first tileset (GENERIC 1) - else if ( gTilesets[0].TileSurfaceFilenames[uiType][0] ) + else if ( gTilesets[0].TileSurfaceFilenames[iType][0] ) { - if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[uiType], gStructureConstruct[structureconstructindex].szTileSetName, 10 ) ) + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[iType], gStructureConstruct[structureconstructindex].szTileSetName, 10 ) ) { - usUseObjIndex = uiType; + sUseObjIndex = iType; break; } } } - if ( !usUseObjIndex ) + if ( sUseObjIndex < 0 ) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szMTATextStr[ STR_MTA_CANNOT_BUILD ] ); return FALSE; @@ -7107,16 +7108,16 @@ BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pO // TODO: if we create an earth pile, create a decal (signifiying the 'hole' we created at our position) // Check with Structure Database (aka ODB) if we can put the object here! - fOkayToAdd = OkayToAddStructureToWorld( sGridNo, 0, gTileDatabase[ (gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) ].pDBStructureRef, INVALID_STRUCTURE_ID ); - if ( fOkayToAdd || (gTileDatabase[ (gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) ].pDBStructureRef == NULL) ) + fOkayToAdd = OkayToAddStructureToWorld( sGridNo, 0, gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usUseIndex)].pDBStructureRef, INVALID_STRUCTURE_ID ); + if ( fOkayToAdd || (gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usUseIndex)].pDBStructureRef == NULL) ) { // Remove old graphic ApplyMapChangesToMapTempFile( TRUE ); //dnl Remove existing structure before adding the same, seems to solve problem with stacking but still need test to be sure that is not removed something what should stay - RemoveStruct( sGridNo, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );//dnl + RemoveStruct( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usUseIndex) );//dnl // Actual structure info is added by the functions below - AddStructToHead( sGridNo, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) ); + AddStructToHead( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usUseIndex) ); // For now, adjust to shadows by a hard-coded amount, // Add mask if in long grass @@ -7239,6 +7240,1257 @@ BOOLEAN RemoveFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *p return FALSE; } +UINT8 CheckBuildFortification( INT32 sGridNo, INT8 sLevel, UINT8 usIndex, UINT32 usStructureconstructindex ) +{ + UINT16 usUseIndex; + INT16 sUseObjIndex = -1; + INT32 iRandSelIndex = 1; + BOOLEAN fOkayToAdd; + + // needs to be a valid location + if ( TileIsOutOfBounds( sGridNo ) ) + return 1; + + // if we want to build on a roof, a roof is required + if ( sLevel && !FlatRoofAboveGridNo( sGridNo ) ) + return 1; + + // don't build in water + if ( TERRAIN_IS_WATER( GetTerrainType( sGridNo ) ) ) + return 1; + + // we'll check wether this item is in our index of known creation items + BOOLEAN indexfound = FALSE; + INT16 structureconstructindex = 0; + usUseIndex = usIndex; + + // search wether structure exists in the current tilesets. If not, well, too bad + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + // if tileset is from the current tileset, check that + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], gStructureConstruct[usStructureconstructindex].szTileSetName, 10 ) ) + { + sUseObjIndex = iType; + break; + } + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[iType], gStructureConstruct[usStructureconstructindex].szTileSetName, 10 ) ) + { + sUseObjIndex = iType; + break; + } + } + } + + if ( sUseObjIndex < 0 ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szMTATextStr[STR_MTA_CANNOT_BUILD] ); + return 1; + } + + // do not build into people + if ( NOBODY != WhoIsThere2( sGridNo, sLevel ) ) + return 2; + + // Check with Structure Database (aka ODB) if we can put the object here! + fOkayToAdd = OkayToAddStructureToWorld( sGridNo, sLevel, gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usUseIndex)].pDBStructureRef, INVALID_STRUCTURE_ID ); + if ( fOkayToAdd || (gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usUseIndex)].pDBStructureRef == NULL) ) + { + return 0; + } + + return 1; +} + +BOOLEAN BuildFortification( INT32 sGridNo, INT8 sLevel, UINT8 usIndex, UINT32 usStructureconstructindex ) +{ + INT16 sUseObjIndex = -1; + BOOLEAN fOkayToAdd; + + // needs to be a valid location + if ( TileIsOutOfBounds( sGridNo ) ) + return FALSE; + + // if we want to build on a roof, a roof is required + if ( sLevel && !FlatRoofAboveGridNo( sGridNo ) ) + return FALSE; + + // don't build in water + if ( TERRAIN_IS_WATER( GetTerrainType( sGridNo ) ) ) + return FALSE; + + // do not build into people + if ( NOBODY != WhoIsThere2( sGridNo, sLevel ) ) + return FALSE; + + // search wether structure exists in the current tilesets. If not, well, too bad + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + // if tileset is from the current tileset, check that + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], gStructureConstruct[usStructureconstructindex].szTileSetName, 10 ) ) + { + sUseObjIndex = iType; + break; + } + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[iType], gStructureConstruct[usStructureconstructindex].szTileSetName, 10 ) ) + { + sUseObjIndex = iType; + break; + } + } + } + + if ( sUseObjIndex < 0 ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szMTATextStr[STR_MTA_CANNOT_BUILD] ); + return FALSE; + } + + // Check with Structure Database (aka ODB) if we can put the object here! + fOkayToAdd = OkayToAddStructureToWorld( sGridNo, sLevel, gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usIndex)].pDBStructureRef, INVALID_STRUCTURE_ID ); + if ( fOkayToAdd || (gTileDatabase[(gTileTypeStartIndex[sUseObjIndex] + usIndex)].pDBStructureRef == NULL) ) + { + // Remove old graphic + ApplyMapChangesToMapTempFile( TRUE ); + + //dnl Remove existing structure before adding the same, seems to solve problem with stacking but still need test to be sure that is not removed something what should stay + // Actual structure info is added by the functions below + if ( sLevel ) + { + RemoveOnRoofStruct( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usIndex) ); + + AddOnRoofToTail( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usIndex) ); + } + else + { + RemoveStruct( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usIndex) ); + + AddStructToHead( sGridNo, (UINT16)(gTileTypeStartIndex[sUseObjIndex] + usIndex) ); + } + + RecompileLocalMovementCosts( sGridNo ); + + // Turn off permanent changes.... + ApplyMapChangesToMapTempFile( FALSE ); + SetRenderFlags( RENDER_FLAG_FULL ); + + return TRUE; + } + + return FALSE; +} + +BOOLEAN CanRemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex ) +{ + // needs to be a valid location + if ( TileIsOutOfBounds( sGridNo ) ) + return FALSE; + + STRUCTURE* pStruct = GetTallestStructureOnGridno( sGridNo, sLevel ); + + if ( pStruct != NULL ) + { + // Get LEVELNODE for struct and remove! + LEVELNODE* pNode = FindLevelNodeBasedOnStructure( pStruct->sGridNo, pStruct ); + + if ( pNode ) + { + UINT16 usIndex = pNode->usIndex; + UINT32 uiTileType = 0; + if ( GetTileType( usIndex, &uiTileType ) ) + { + // if tileset is from the current tileset, check that + BOOLEAN found = FALSE; + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[usStructureconstructindex].szTileSetName, 11 ) ) + found = TRUE; + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[usStructureconstructindex].szTileSetName, 11 ) ) + found = TRUE; + } + + if ( found ) + { + // we have to check wether this specific structure can be removed. Just checking the tileset name won't be enough. + // For example, we could have a set consisting of crates and piles of earth, which we want to remove via applying a shovel on it. + // We only want to do this on the earth piles, of course - flattening crates via a shovel would be odd :-) + UINT8 numbertofind = (UINT8)(pStruct->pDBStructureRef->pDBStructure->usStructureNumber); + + UINT8 size = gStructureDeconstruct[usStructureconstructindex].tilevector.size( ); + for ( UINT8 j = 0; j < size; ++j ) + { + if ( gStructureDeconstruct[usStructureconstructindex].tilevector[j] == numbertofind ) + { + return TRUE; + } + } + } + } + } + } + + return FALSE; +} + +BOOLEAN RemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex ) +{ + // needs to be a valid location + if ( TileIsOutOfBounds( sGridNo ) ) + return FALSE; + + STRUCTURE* pStruct = GetTallestStructureOnGridno( sGridNo, sLevel ); + + if ( pStruct != NULL ) + { + // Get LEVELNODE for struct and remove! + LEVELNODE* pNode = FindLevelNodeBasedOnStructure( pStruct->sGridNo, pStruct ); + + if ( pNode ) + { + UINT16 usIndex = pNode->usIndex; + UINT32 uiTileType = 0; + if ( GetTileType( usIndex, &uiTileType ) ) + { + // if tileset is from the current tileset, check that + BOOLEAN found = FALSE; + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[usStructureconstructindex].szTileSetName, 11 ) ) + found = TRUE; + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[uiTileType][0] ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[uiTileType], gStructureDeconstruct[usStructureconstructindex].szTileSetName, 11 ) ) + found = TRUE; + } + + if ( found ) + { + // we have to check wether this specific structure can be removed. Just checking the tileset name won't be enough. + // For example, we could have a set consisting of crates and piles of earth, which we want to remove via applying a shovel on it. + // We only want to do this on the earth piles, of course - flattening crates via a shovel would be odd :-) + UINT8 numbertofind = (UINT8)(pStruct->pDBStructureRef->pDBStructure->usStructureNumber); + + UINT8 size = gStructureDeconstruct[usStructureconstructindex].tilevector.size( ); + for ( UINT8 j = 0; j < size; ++j ) + { + if ( gStructureDeconstruct[usStructureconstructindex].tilevector[j] == numbertofind ) + { + // Remove old graphic + ApplyMapChangesToMapTempFile( TRUE ); + + if ( sLevel ) + { + RemoveOnRoofStruct( sGridNo, pNode->usIndex ); + } + + // if this is a wall, check wether the roof will collapse. + // Yes, the player can damage himself by collapsing the roof of the house he is currently in. Such stupidity has to be punished. + if ( pStruct->fFlags & STRUCTURE_WALL ) + { + // this isn't an explosion, so the structural damage is moderate + HandleRoofDestruction( sGridNo, 50 ); + } + + RemoveStruct( sGridNo, pNode->usIndex ); + + if ( !GridNoIndoors( sGridNo ) && gTileDatabase[usIndex].uiFlags & HAS_SHADOW_BUDDY && gTileDatabase[usIndex].sBuddyNum != -1 ) + { + RemoveShadow( sGridNo, gTileDatabase[usIndex].sBuddyNum ); + } + + RecompileLocalMovementCosts( sGridNo ); + + // Turn off permanent changes.... + ApplyMapChangesToMapTempFile( FALSE ); + SetRenderFlags( RENDER_FLAG_FULL ); + + return TRUE; + } + } + } + } + } + } + + return FALSE; +} + +class FORTIFICATION_NODE +{ +public: + FORTIFICATION_NODE( INT32 a, INT8 b, BOOLEAN c, UINT32 d, UINT8 e ) : + sGridNo( a ), sLevel( b ), fBuild( c ), structurexmlindex( d ), usIndex( e ) {} + + FORTIFICATION_NODE() : + sGridNo( NOWHERE ), sLevel( 0 ), fBuild( TRUE ), structurexmlindex(0), usIndex( 0 ) {} + + void swap( FORTIFICATION_NODE& other ) + { + std::swap( sGridNo, other.sGridNo ); + std::swap( sLevel, other.sLevel ); + std::swap( fBuild, other.fBuild ); + std::swap( structurexmlindex, other.structurexmlindex ); + std::swap( usIndex, other.usIndex ); + } + + INT32 sGridNo; + INT8 sLevel; + BOOLEAN fBuild; + UINT32 structurexmlindex; + UINT8 usIndex; +}; + +std::ostream& operator<<(std::ostream& stream, FORTIFICATION_NODE const& data) +{ + stream << data.sGridNo << " " + << (INT32)(data.sLevel) << " " + << (INT32)(data.fBuild) << " " + << (INT32)(data.structurexmlindex) << " " + << (INT32)(data.usIndex) << std::endl; + + return stream; +} + +std::istream& operator>>(std::istream& stream, FORTIFICATION_NODE& data) +{ + FORTIFICATION_NODE tmp; + if ( stream >> tmp.sGridNo ) + { + INT32 a, b, c, d; + if ( stream >> a >> b >> c >> d ) + { + tmp.sLevel = a; + tmp.fBuild = (BOOLEAN)b; + tmp.structurexmlindex = (UINT32)c; + tmp.usIndex = (UINT8)d; + + data.swap( tmp ); + } + } + + return stream; +} + + +typedef std::vector SectorFortificationVector; + +std::map gSectorFortificationMap; + +CHAR16 gCurrentSectorTileNamesChar16[STRUCTURE_CONSTRUCT_MAX][20]; +CHAR16 gCurrentSectorTileIndexNamesChar16[STRUCTURE_CONSTRUCT_MAX][20]; + +std::vector > GetCurrentSectorTileSetVector() +{ + std::vector > vec; + + // search wether structure exists in the current tilesets. If not, well, too bad + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + swprintf( gCurrentSectorTileNamesChar16[iType], L"" ); + + // if tileset is from the current tileset, check that + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType][0] ) + { + int nChars = MultiByteToWideChar( CP_ACP, 0, gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], -1, NULL, 0 ); + MultiByteToWideChar( CP_UTF8, 0, gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], -1, gCurrentSectorTileNamesChar16[iType], nChars ); + + vec.push_back( std::make_pair( iType, gCurrentSectorTileNamesChar16[iType] ) ); + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[iType][0] ) + { + int nChars = MultiByteToWideChar( CP_ACP, 0, gTilesets[0].TileSurfaceFilenames[iType], -1, NULL, 0 ); + MultiByteToWideChar( CP_UTF8, 0, gTilesets[0].TileSurfaceFilenames[iType], -1, gCurrentSectorTileNamesChar16[iType], nChars ); + + vec.push_back( std::make_pair( iType, gCurrentSectorTileNamesChar16[iType] ) ); + } + } + + return vec; +} + +// get a vector of all tilesets that are allowed to be built in this sector (the above filtered by structure construct/deconstruct basically) +std::vector > GetCurrentSectorAllowedFortificationTileSetVector( INT32 asTileSetId ) +{ + std::vector > vec; + std::set< std::pair > pairset; + + // search wether structure exists in the current tilesets. If not, well, too bad + for ( UINT16 i = 0; i < STRUCTURE_CONSTRUCT_MAX; ++i ) + { + swprintf( gCurrentSectorTileNamesChar16[i], L"" ); + + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + // if tileset is from the current tileset, check that + if ( gTilesets[asTileSetId].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[asTileSetId].TileSurfaceFilenames[iType], gStructureConstruct[i].szTileSetName, 11 ) ) + { + int nChars = MultiByteToWideChar( CP_ACP, 0, gStructureConstruct[i].szTileSetDisplayName, -1, NULL, 0 ); + MultiByteToWideChar( CP_UTF8, 0, gStructureConstruct[i].szTileSetDisplayName, -1, gCurrentSectorTileNamesChar16[i], nChars ); + + pairset.insert( std::make_pair( i, gCurrentSectorTileNamesChar16[i] ) ); + + break; + } + } + else + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[iType], gStructureConstruct[i].szTileSetName, 11 ) ) + { + int nChars = MultiByteToWideChar( CP_ACP, 0, gStructureConstruct[i].szTileSetDisplayName, -1, NULL, 0 ); + MultiByteToWideChar( CP_UTF8, 0, gStructureConstruct[i].szTileSetDisplayName, -1, gCurrentSectorTileNamesChar16[i], nChars ); + + pairset.insert( std::make_pair( i, gCurrentSectorTileNamesChar16[i] ) ); + + break; + } + } + } + } + + for ( std::set< std::pair >::iterator it = pairset.begin( ); it != pairset.end( ); ++it ) + { + vec.push_back( (*it) ); + } + + return vec; +} + +// get all allowed indizes for a specific tileset. 'Allowed' as in: used in our structure construct entries +std::vector > GetTileSetIndexVector( INT16 aKey ) +{ + std::vector > vec; + + if ( 0 <= aKey && aKey <= STRUCTURE_CONSTRUCT_MAX ) + { + std::set indexset; + + for ( INT16 j = 0; j < gStructureConstruct[aKey].northtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aKey].northtilevector[j] ); + for ( INT16 j = 0; j < gStructureConstruct[aKey].southtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aKey].southtilevector[j] ); + for ( INT16 j = 0; j < gStructureConstruct[aKey].easttilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aKey].easttilevector[j] ); + for ( INT16 j = 0; j < gStructureConstruct[aKey].westtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aKey].westtilevector[j] ); + + for ( std::set::iterator it = indexset.begin( ); it != indexset.end( ); ++it ) + { + swprintf( gCurrentSectorTileIndexNamesChar16[(*it)], L"%d", (*it) ); + + vec.push_back( std::make_pair( (*it), gCurrentSectorTileIndexNamesChar16[(*it)] ) ); + } + } + + return vec; +} + +std::string GetNameToTileSet( UINT8 aIndex ) +{ + // if tileset is from the current tileset, check that + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aIndex][0] ) + { + std::string str( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aIndex], std::find( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aIndex], gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aIndex] + 32, '\0' ) ); + + return str; + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[aIndex][0] ) + { + std::string str( gTilesets[0].TileSurfaceFilenames[aIndex], std::find( gTilesets[0].TileSurfaceFilenames[aIndex], gTilesets[0].TileSurfaceFilenames[aIndex] + 32, '\0' ) ); + + return str; + } + + return ""; +} + +INT16 GetStructureConstructIndexToTileset( INT16 aTileset ) +{ + // find the structure construct entry that fits to this + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aTileset][0] ) + { + for ( INT16 i = 0; i < STRUCTURE_CONSTRUCT_MAX; ++i ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aTileset], gStructureConstruct[i].szTileSetName, 11 ) ) + { + return i; + } + } + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[aTileset][0] ) + { + for ( INT16 i = 0; i < STRUCTURE_CONSTRUCT_MAX; ++i ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[aTileset], gStructureConstruct[i].szTileSetName, 11 ) ) + { + return i; + } + } + } + + return -1; +} + +INT16 GetStructureDeConstructIndexToTileset( INT16 aTileset ) +{ + // find the structure construct entry that fits to this + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aTileset][0] ) + { + for ( INT16 i = 0; i < STRUCTURE_CONSTRUCT_MAX; ++i ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[aTileset], gStructureDeconstruct[i].szTileSetName, 11 ) ) + { + return i; + } + } + } + // otherwise, check first tileset (GENERIC 1) + else if ( gTilesets[0].TileSurfaceFilenames[aTileset][0] ) + { + for ( INT16 i = 0; i < STRUCTURE_CONSTRUCT_MAX; ++i ) + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[aTileset], gStructureDeconstruct[i].szTileSetName, 11 ) ) + { + return i; + } + } + } + + return -1; +} + +std::set GetStructureConstructDirectionIndizes( INT16 aEntry, BOOLEAN afNorth, BOOLEAN afEast, BOOLEAN afSouth, BOOLEAN afWest ) +{ + std::set indexset; + + if ( aEntry >= 0 ) + { + if ( afNorth ) for ( int j = 0; j < gStructureConstruct[aEntry].northtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aEntry].northtilevector[j] ); + if ( afSouth ) for ( int j = 0; j < gStructureConstruct[aEntry].southtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aEntry].southtilevector[j] ); + if ( afEast ) for ( int j = 0; j < gStructureConstruct[aEntry].easttilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aEntry].easttilevector[j] ); + if ( afWest ) for ( int j = 0; j < gStructureConstruct[aEntry].westtilevector.size( ); ++j ) indexset.insert( gStructureConstruct[aEntry].westtilevector[j] ); + } + + return indexset; +} + +void AddFortificationPlanNode( INT32 sGridNo, INT8 sLevel, INT16 sFortificationStructure, UINT8 usFortificationTileLibraryIndex, BOOLEAN fAdd ) +{ + if ( !gWorldSectorX || !gWorldSectorY ) + return; + + // no nonsense + if ( sLevel < 0 || sLevel > 1 ) + return; + + // needs to be a valid location + if ( TileIsOutOfBounds( sGridNo ) ) + return; + + // if we want to build on a roof, a roof is required + if ( sLevel && !FlatRoofAboveGridNo( sGridNo ) ) + return; + + // don't build in water + if ( TERRAIN_IS_WATER( GetTerrainType( sGridNo ) ) ) + return; + + // we have to check whether what we are ordered to build can bere built here (this is necessary, as the selection menu can be avoided) + BOOLEAN found = FALSE; + + if ( fAdd ) + { + if ( sFortificationStructure >= 0 && sFortificationStructure < STRUCTURE_CONSTRUCT_MAX ) + { + for ( INT32 iType = 0; iType < giNumberOfTileTypes; ++iType ) + { + // if tileset is from the current tileset, check that + if ( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType][0] ) + { + if ( !_strnicmp( gTilesets[giCurrentTilesetID].TileSurfaceFilenames[iType], gStructureConstruct[sFortificationStructure].szTileSetName, 11 ) ) + { + found = TRUE; + + break; + } + } + else + { + if ( !_strnicmp( gTilesets[0].TileSurfaceFilenames[iType], gStructureConstruct[sFortificationStructure].szTileSetName, 11 ) ) + { + found = TRUE; + + break; + } + } + } + } + + // check index as well + if ( found ) + { + std::vector > dropdownvector_2 = GetTileSetIndexVector( sFortificationStructure ); + + for ( std::vector >::iterator it = dropdownvector_2.begin( ); it != dropdownvector_2.end(); ++it ) + { + if ( (*it).first == usFortificationTileLibraryIndex ) + { + found = TRUE; + + break; + } + } + } + } + // if we try to add a 'remove structure' node, we determine the correct Deconstruct index (it would be annoying if the player has to always set that by themself) + else + { + STRUCTURE* pStruct = GetTallestStructureOnGridno( sGridNo, sLevel ); + + if ( pStruct != NULL ) + { + // Get LEVELNODE for struct and remove! + LEVELNODE* pNode = FindLevelNodeBasedOnStructure( pStruct->sGridNo, pStruct ); + + if ( pNode ) + { + UINT16 usIndex = pNode->usIndex; + UINT32 uiTileType = 0; + if ( GetTileType( usIndex, &uiTileType ) ) + { + // as sFortificationStructure and usFortificationTileLibraryIndex are no references, we can reset them without any repercussions outside of this function + sFortificationStructure = GetStructureDeConstructIndexToTileset( (INT16)uiTileType ); + + if ( sFortificationStructure > -1 ) + { + usFortificationTileLibraryIndex = (UINT8)(pStruct->pDBStructureRef->pDBStructure->usStructureNumber); + + UINT8 size = gStructureDeconstruct[sFortificationStructure].tilevector.size( ); + for ( UINT8 j = 0; j < size; ++j ) + { + if ( gStructureDeconstruct[sFortificationStructure].tilevector[j] == usFortificationTileLibraryIndex ) + { + found = TRUE; + + break; + } + } + } + } + } + } + } + + if ( !found ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szFortificationText[0] ); + + return; + } + + FORTIFICATION_NODE node( sGridNo, sLevel, fAdd, sFortificationStructure, usFortificationTileLibraryIndex ); + + UINT8 sector = SECTOR( gWorldSectorX, gWorldSectorY ); + + if ( gSectorFortificationMap.find( sector ) != gSectorFortificationMap.end( ) ) + { + // if a node already exists at this gridno, erase the old one. This allows to easily remove nodes + SectorFortificationVector& vec = gSectorFortificationMap[sector]; + + BOOLEAN alreadyexists = FALSE; + SectorFortificationVector::iterator nodeitend = vec.end( ); + for ( SectorFortificationVector::iterator nodeit = vec.begin( ); nodeit != nodeitend; ++nodeit ) + { + if ( node.sGridNo == (*nodeit).sGridNo && node.sLevel == (*nodeit).sLevel ) + { + vec.erase( nodeit ); + + alreadyexists = TRUE; + break; + } + } + + if ( !alreadyexists ) + { + // if specified, try to get adjacent nodes to match each other + if ( fAdd && gStructureConstruct[node.structurexmlindex].fFortifyAdjacentAdjustment ) + { + // check the adjacent nodes and alter the index fittingly (northern-southern vs eastern-western kind) + INT32 nextGridNoinSight = node.sGridNo; + + for ( int i = NORTH; i < NUM_WORLD_DIRECTIONS; i += 2 ) + { + nextGridNoinSight = NewGridNo( node.sGridNo, DirectionInc( i ) ); + + for ( SectorFortificationVector::iterator nodeit = vec.begin( ); nodeit != nodeitend; ++nodeit ) + { + if ( nextGridNoinSight == (*nodeit).sGridNo && node.sLevel == (*nodeit).sLevel && node.structurexmlindex == (*nodeit).structurexmlindex ) + { + // 2 adjacent nodes of the same type -> make them 'compatible' + std::set indexset = GetStructureConstructDirectionIndizes( node.structurexmlindex, + (i == EAST || i == WEST), (i == NORTH || i == SOUTH), (i == EAST || i == WEST), (i == NORTH || i == SOUTH) ); + + if ( !indexset.empty() ) + { + std::set::iterator it = indexset.begin(); + + int k = Random( indexset.size( ) ); + for (; k > 0; --k) + ++it; + + (*nodeit).usIndex = (*it); + + it = indexset.begin( ); + + k = Random( indexset.size( ) ); + for ( ; k > 0; --k ) + ++it; + + node.usIndex = (*it); + + break; + } + } + } + } + } + + vec.push_back( node ); + } + } + // otherwise, create a new node vector + else + { + SectorFortificationVector vec; + vec.push_back( node ); + gSectorFortificationMap[ sector ] = vec; + } + + // save the new plan + SaveSectorFortificationPlan( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + + UpdateFortificationPossibleAmount(); +} + +std::vector< std::pair > > GetAllForticationGridNo( ) +{ + std::vector< std::pair > > gridnovector; + + if ( !gWorldSectorX || !gWorldSectorY ) + return gridnovector; + + UINT8 sector = SECTOR( gWorldSectorX, gWorldSectorY ); + + SECTORINFO *pSectorInfo = &(SectorInfo[sector]); + + if ( pSectorInfo && gSectorFortificationMap.find( sector ) != gSectorFortificationMap.end( ) ) + { + SectorFortificationVector vec = gSectorFortificationMap[sector]; + + SectorFortificationVector::iterator nodeitend = vec.end( ); + for ( SectorFortificationVector::iterator nodeit = vec.begin( ); nodeit != nodeitend; ++nodeit ) + { + UINT16 type = FORTIFICATIONNODE_REMOVE; + + if ( (*nodeit).fBuild ) + { + if ( gStructureConstruct[(*nodeit).structurexmlindex].fFortifyAdjacentAdjustment ) + type = FORTIFICATIONNODE_ADJACENTADJUSTMENT; + else + type = FORTIFICATIONNODE_NORMAL; + } + + gridnovector.push_back( std::make_pair( (*nodeit).sGridNo, std::make_pair( type, (*nodeit).sLevel ) ) ); + } + } + + return gridnovector; +} + +void LoadSectorFortificationPlan( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ ) +{ + if ( !sSectorX || !sSectorY ) + return; + + CHAR8 filename[MAX_PATH]; + + UINT8 sector = SECTOR( sSectorX, sSectorY ); + + // get sector name for filename + CHAR16 wSectorName[64]; + GetShortSectorString( sSectorX, sSectorY, wSectorName ); + + if ( sSectorZ ) + sprintf( filename, "%s%S_%d.txt", FORTIFICATIONPLAN_DIRECTORY, wSectorName, sSectorZ ); + else + sprintf( filename, "%s%S.txt", FORTIFICATIONPLAN_DIRECTORY, wSectorName ); + + // get full path to save file + vfs::Path vfsPath; + vfs::COpenWriteFile rfile( filename, true ); + rfile->_getRealPath( vfsPath ); + std::string str = vfsPath.to_string( ); + + const char* filenamewithpath = str.c_str( ); + + // Read data + std::ifstream file; + file.open( filenamewithpath, std::ios::in ); + std::vector vec; + + std::copy( std::istream_iterator( file ), + std::istream_iterator( ), + std::back_inserter( vec ) + ); + file.close( ); + + gSectorFortificationMap[sector] = vec; +} + +void SaveSectorFortificationPlan( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ ) +{ + if ( !sSectorX || !sSectorY ) + return; + + UINT8 sector = SECTOR( sSectorX, sSectorY ); + + if ( gSectorFortificationMap.find( sector ) != gSectorFortificationMap.end( ) ) + { + SectorFortificationVector vec = gSectorFortificationMap[sector]; + + if ( !vec.empty() ) + { + CHAR8 filename[MAX_PATH]; + + // get sector name for filename + CHAR16 wSectorName[64]; + GetShortSectorString( sSectorX, sSectorY, wSectorName ); + + if ( sSectorZ ) + sprintf( filename, "%s%S_%d.txt", FORTIFICATIONPLAN_DIRECTORY, wSectorName, sSectorZ ); + else + sprintf( filename, "%s%S.txt", FORTIFICATIONPLAN_DIRECTORY, wSectorName ); + + // get full path to save file + // what we are doing here might seem rather odd. If the file does not exist, we are creating a new file via vfs... and then create a fresh binary file afterwards. + // I found this to be the easiest solution for using both vfs pathing and being able to use a std::fstream + // If you don't like it, fix it yourself, or make vfs not such a pain to use + vfs::Path vfsPath; + vfs::COpenWriteFile rfile( filename, true ); + rfile->_getRealPath( vfsPath ); + std::string str = vfsPath.to_string( ); + + const char* filenamewithpath = str.c_str( ); + + // write + std::fstream binary_file( filenamewithpath, std::ios::out ); + + SectorFortificationVector::iterator nodeitend = vec.end( ); + for ( SectorFortificationVector::iterator nodeit = vec.begin( ); nodeit != nodeitend; ++nodeit ) + { + FORTIFICATION_NODE node = (*nodeit); + + binary_file << node; + } + + binary_file.close( ); + } + } +} + +void UpdateFortificationPossibleAmount() +{ + if ( !gWorldSectorX || !gWorldSectorY ) + return; + + // update the sector value of how much can still be built by looping through the plan. Only works in the currently loaded sector + UINT8 sector = SECTOR( gWorldSectorX, gWorldSectorY ); + + if ( gSectorFortificationMap.find( sector ) != gSectorFortificationMap.end( ) ) + { + SectorFortificationVector vec = gSectorFortificationMap[sector]; + + FLOAT maxpossible = 0.0f; + + SectorFortificationVector::iterator nodeitend = vec.end( ); + for ( SectorFortificationVector::iterator nodeit = vec.begin(); nodeit != nodeitend; ++nodeit ) + { + FORTIFICATION_NODE node = (*nodeit); + + if ( node.fBuild ) + { + UINT8 buildpossiblestate = CheckBuildFortification( node.sGridNo, node.sLevel, node.usIndex, node.structurexmlindex ); + + if ( buildpossiblestate == 0 ) + { + maxpossible += gStructureConstruct[node.structurexmlindex].dCreationCost; + } + else if ( buildpossiblestate == 2 ) + { + // for now, also add this as a possible thing to build if the obstacle is merely a person + maxpossible += gStructureConstruct[node.structurexmlindex].dCreationCost; + } + } + else if ( CanRemoveFortification( node.sGridNo, node.sLevel, node.structurexmlindex ) ) + { + maxpossible += gStructureDeconstruct[node.structurexmlindex].dCreationCost; + } + } + + if ( gbWorldSectorZ ) + { + UNDERGROUND_SECTORINFO *pSector = FindUnderGroundSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + + if ( pSector ) + { + pSector->dFortification_MaxPossible = maxpossible; + + // make sure the current progress isn't too high + pSector->dFortification_UnappliedProgress = min( pSector->dFortification_UnappliedProgress, pSector->dFortification_MaxPossible ); + } + } + else + { + SECTORINFO *pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )]; + + if ( pSector ) + { + pSector->dFortification_MaxPossible = maxpossible; + + // make sure the current progress isn't too high + pSector->dFortification_UnappliedProgress = min( pSector->dFortification_UnappliedProgress, pSector->dFortification_MaxPossible ); + } + } + } +} + +void HandleFortificationUpdate() +{ + if ( !gWorldSectorX || !gWorldSectorY ) + return; + + UINT8 sector = SECTOR( gWorldSectorX, gWorldSectorY ); + + if ( gSectorFortificationMap.find( sector ) != gSectorFortificationMap.end() ) + { + SectorFortificationVector vec = gSectorFortificationMap[sector]; + + SectorFortificationVector::iterator nodeit = vec.begin(); + + BOOLEAN peopleblockingnodes = FALSE; + BOOLEAN insufficientresources = FALSE; + + FLOAT dFortification_UnappliedProgress = 0.0; + FLOAT dFortification_MaxPossible = 0.0; + + if ( gbWorldSectorZ ) + { + UNDERGROUND_SECTORINFO *pSector; + pSector = FindUnderGroundSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + + if ( pSector ) + { + dFortification_UnappliedProgress = pSector->dFortification_UnappliedProgress; + dFortification_MaxPossible = pSector->dFortification_MaxPossible; + } + } + else + { + SECTORINFO *pSector; + pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )]; + + if ( pSector ) + { + dFortification_UnappliedProgress = pSector->dFortification_UnappliedProgress; + dFortification_MaxPossible = pSector->dFortification_MaxPossible; + } + } + + // as we consume resources, we use a map to keep track of them (and lower the amount of looping over the inventory required) + std::map< UINT16, INT32 > builditemobjectmap; + + // removing structures can gain us items. We use a map to store what we need and create items afterwards, which might save unnecessary creations (1 item at 80% is better than 80 with 1%) + std::map< UINT16, UINT32 > itemcreatemap; + INT32 itemdropoffgridno = NOWHERE; + + // in order to help the player know what items are missing, make a list of all required build items not present + std::set< UINT16 > missingitemsmap; + + OBJECTTYPE* pBuildItemObject = NULL; + INT32 slot = -1; + + while ( dFortification_UnappliedProgress > 0.0 ) + { + if ( nodeit == vec.end( ) ) + break; + + FORTIFICATION_NODE node = (*nodeit); + + FLOAT cost = node.fBuild ? gStructureConstruct[node.structurexmlindex].dCreationCost : gStructureDeconstruct[node.structurexmlindex].dCreationCost; + + if ( cost <= dFortification_UnappliedProgress ) + { + if ( node.fBuild ) + { + UINT8 buildpossiblestate = CheckBuildFortification( node.sGridNo, node.sLevel, node.usIndex, node.structurexmlindex ); + + if ( buildpossiblestate == 0 ) + { + // check for build items and possibly consume them + BOOLEAN itemconsumptionpassed = TRUE; + + if ( gStructureConstruct[node.structurexmlindex].usCreationItem ) + { + itemconsumptionpassed = FALSE; + + UINT8 itemreduction = gStructureConstruct[node.structurexmlindex].usItemStatusLoss; + + std::map< UINT16, INT32 >::iterator objectit = builditemobjectmap.find( gStructureConstruct[node.structurexmlindex].usCreationItem ); + + if ( objectit != builditemobjectmap.end( ) && objectit->second > -1 ) + { + slot = objectit->second; + } + else + { + slot = GetFirstObjectInSectorPosition( gStructureConstruct[node.structurexmlindex].usCreationItem ); + + if ( slot > -1 ) + { + builditemobjectmap[gStructureConstruct[node.structurexmlindex].usCreationItem] = slot; + } + } + + if ( slot > -1 ) + { + for ( INT16 i = 0; i < gWorldItems[slot].object.ubNumberOfObjects; ++i ) + { + UINT8 reduce = min( (gWorldItems[slot].object)[i]->data.objectStatus, itemreduction ); + + (gWorldItems[slot].object)[i]->data.objectStatus -= reduce; + itemreduction -= reduce; + + if ( !(gWorldItems[slot].object)[i]->data.objectStatus ) + { + gWorldItems[slot].object.RemoveObjectAtIndex( i ); + } + } + + if ( gWorldItems[slot].object.ubNumberOfObjects < 1 ) + { + if ( gWorldItems[slot].sGridNo != NOWHERE ) + RemoveItemFromPool( gWorldItems[slot].sGridNo, slot, gWorldItems[slot].ubLevel ); + + gWorldItems[slot].fExists = FALSE; + } + } + + if ( !itemreduction ) + { + itemconsumptionpassed = TRUE; + } + } + + // only if we successfully used resources a strucuture can be built + if ( itemconsumptionpassed ) + { + BuildFortification( node.sGridNo, node.sLevel, node.usIndex, node.structurexmlindex ); + + dFortification_UnappliedProgress -= cost; + dFortification_MaxPossible -= cost; + } + else + { + insufficientresources = TRUE; + + if ( gStructureConstruct[node.structurexmlindex].usCreationItem ) + missingitemsmap.insert( gStructureConstruct[node.structurexmlindex].usCreationItem ); + } + } + else if ( buildpossiblestate == 2 ) + { + // note if some structures could not be built due to people being in the way + peopleblockingnodes = TRUE; + } + } + else if ( CanRemoveFortification( node.sGridNo, node.sLevel, node.structurexmlindex ) ) + { + // check for build items and possibly consume them + BOOLEAN itemconsumptionpassed = TRUE; + + if ( gStructureDeconstruct[node.structurexmlindex].usDeconstructItem ) + { + itemconsumptionpassed = FALSE; + + std::map< UINT16, INT32 >::iterator objectit = builditemobjectmap.find( gStructureDeconstruct[node.structurexmlindex].usDeconstructItem ); + + if ( objectit != builditemobjectmap.end( ) && objectit->second > -1 ) + { + slot = objectit->second; + } + else + { + slot = GetFirstObjectInSectorPosition( gStructureDeconstruct[node.structurexmlindex].usDeconstructItem ); + + if ( slot > -1 ) + { + builditemobjectmap[gStructureDeconstruct[node.structurexmlindex].usDeconstructItem] = slot; + } + } + + if ( slot > -1 ) + { + itemconsumptionpassed = TRUE; + } + } + + // only if we successfully used resources a strucuture can be built + if ( itemconsumptionpassed ) + { + if ( RemoveFortification( node.sGridNo, node.sLevel, node.structurexmlindex ) ) + { + // eventually create item + if ( gStructureDeconstruct[node.structurexmlindex].usItemToCreate && gStructureDeconstruct[node.structurexmlindex].usCreatedItemStatus ) + { + std::map< UINT16, UINT32 >::iterator objectit = itemcreatemap.find( gStructureDeconstruct[node.structurexmlindex].usItemToCreate ); + + if ( objectit != itemcreatemap.end( ) ) + { + objectit->second += gStructureDeconstruct[node.structurexmlindex].usCreatedItemStatus; + } + else + { + itemcreatemap[gStructureDeconstruct[node.structurexmlindex].usItemToCreate] = gStructureDeconstruct[node.structurexmlindex].usCreatedItemStatus; + } + } + + // if the node's gridno is valid, we might use it + if ( TileIsOutOfBounds( itemdropoffgridno ) && !TileIsOutOfBounds( node.sGridNo ) ) + { + itemdropoffgridno = node.sGridNo; + } + + dFortification_UnappliedProgress -= cost; + dFortification_MaxPossible -= cost; + } + } + else + { + insufficientresources = TRUE; + + if ( gStructureDeconstruct[node.structurexmlindex].usDeconstructItem ) + missingitemsmap.insert( gStructureDeconstruct[node.structurexmlindex].usDeconstructItem ); + } + } + } + + ++nodeit; + } + + // update progress + if ( gbWorldSectorZ ) + { + UNDERGROUND_SECTORINFO *pSector; + pSector = FindUnderGroundSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + + if ( pSector ) + { + pSector->dFortification_UnappliedProgress = dFortification_UnappliedProgress; + pSector->dFortification_MaxPossible = dFortification_MaxPossible; + } + } + else + { + SECTORINFO *pSector; + pSector = &SectorInfo[SECTOR( gWorldSectorX, gWorldSectorY )]; + + if ( pSector ) + { + pSector->dFortification_UnappliedProgress = dFortification_UnappliedProgress; + pSector->dFortification_MaxPossible = dFortification_MaxPossible; + } + } + + CHAR16 wSectorName[64]; + GetShortSectorString( gWorldSectorX, gWorldSectorY, wSectorName ); + + // create items, or warn us if that isn't possible + if ( !itemcreatemap.empty() ) + { + if ( !TileIsOutOfBounds( itemdropoffgridno ) ) + { + for ( std::map< UINT16, UINT32 >::iterator it = itemcreatemap.begin( ); it != itemcreatemap.end(); ++it ) + { + while ( it->second > 0 ) + { + UINT8 tmpstat = min( 100, it->second ); + it->second -= tmpstat; + + OBJECTTYPE tmpobject; + + CreateItem( it->first, tmpstat, &tmpobject ); + + AddItemToPool( itemdropoffgridno, &tmpobject, 1, 0, 0, -1 ); + } + } + } + else + { + ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, szFortificationText[1], wSectorName ); + } + } + + // warn us if we lack resources or if nodes are blocked + if ( peopleblockingnodes || insufficientresources ) + { + if ( peopleblockingnodes ) + ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, szFortificationText[2], wSectorName ); + + if ( insufficientresources ) + { + ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, szFortificationText[3], wSectorName ); + + for ( std::set::iterator it = missingitemsmap.begin( ); it != missingitemsmap.end(); ++it ) + { + ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L" - %s", Item[(*it)].szLongItemName ); + } + } + } + + UpdateFortificationPossibleAmount(); + } +} + +INT32 GetFirstObjectInSectorPosition( UINT16 ausItem ) +{ + for ( UINT32 uiCount = 0; uiCount < guiNumWorldItems; ++uiCount ) + { + if ( gWorldItems[uiCount].fExists && gWorldItems[uiCount].object.usItem == ausItem ) + { + return uiCount; + } + } + + return -1; +} + INT32 CheckBombDisarmChance(void) { // NB owner grossness... bombs 'owned' by the enemy are stored with side value 1 in diff --git a/Tactical/Handle Items.h b/Tactical/Handle Items.h index 885e885c..32b1ace0 100644 --- a/Tactical/Handle Items.h +++ b/Tactical/Handle Items.h @@ -84,7 +84,9 @@ typedef struct { UINT16 usDeconstructItem; // the item that has to be used to deconstruct the structure UINT16 usItemToCreate; // the item that will be created when we deconstruct a structure UINT8 usCreatedItemStatus; // status of the item to create + char szTileSetDisplayName[20]; // name of this structure to the player (tileset names are obscure) char szTileSetName[20]; // name of the tileset + FLOAT dCreationCost; // assignment cost per structure built std::vector tilevector; // structures in the tileset that we can deconstruct } STRUCTURE_DECONSTRUCT; @@ -95,7 +97,10 @@ extern STRUCTURE_DECONSTRUCT gStructureDeconstruct[STRUCTURE_DECONSTRUCT_MAX]; typedef struct { UINT16 usCreationItem; // the item that will be consumed when creating the structure UINT8 usItemStatusLoss; // item will lose this number of status points + char szTileSetDisplayName[20]; // name of this structure to the player (tileset names are obscure) char szTileSetName[20]; // name of the tileset + FLOAT dCreationCost; // assignment cost per structure built + BOOLEAN fFortifyAdjacentAdjustment; // if true, try to fit adjacent fortifications std::vector northtilevector; // structures in the tileset we can create while facing north std::vector southtilevector; // structures in the tileset we can create while facing south std::vector easttilevector; // structures in the tileset we can create while facing east @@ -214,6 +219,38 @@ BOOLEAN IsStructureDeconstructItem( UINT16 usItem, INT32 sGridNo, SOLDIERTYPE* p BOOLEAN BuildFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj ); // build a structure, return true if sucessful BOOLEAN RemoveFortification( INT32 sGridNo, SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj ); // remove a structure, return true if sucessful +// Flugente: functions for fortification +UINT8 CheckBuildFortification( INT32 sGridNo, INT8 sLevel, UINT8 usIndex, UINT32 usStructureconstructindex ); +BOOLEAN BuildFortification( INT32 sGridNo, INT8 sLevel, UINT8 usIndex, UINT32 usStructureconstructindex ); + +BOOLEAN CanRemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex ); +BOOLEAN RemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex ); + +void UpdateFortificationPossibleAmount(); +void HandleFortificationUpdate(); + +// get a vector of all tilesets the current sector has +std::vector > GetCurrentSectorTileSetVector(); + +// get a vector of all tilesets that are allowed to be built in this sector (the above filtered by structure construct/deconstruct basically) +std::vector > GetCurrentSectorAllowedFortificationTileSetVector( INT32 asTileSetId ); + +// get all allowed indizes for a specific tileset. 'Allowed' as in: used in our structure construct entries +std::vector > GetTileSetIndexVector( INT16 aKey ); + +std::string GetNameToTileSet( UINT8 aIndex ); +INT16 GetStructureConstructIndexToTileset( INT16 aTileset ); +INT16 GetStructureDeConstructIndexToTileset( INT16 aTileset ); +std::set GetStructureConstructDirectionIndizes( INT16 aEntry, BOOLEAN afNorth, BOOLEAN afEast, BOOLEAN afSouth, BOOLEAN afWest ); +void AddFortificationPlanNode( INT32 sGridNo, INT8 sLevel, INT16 sFortificationStructure, UINT8 usFortificationTileLibraryIndex, BOOLEAN fAdd ); + +void LoadSectorFortificationPlan( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ ); +void SaveSectorFortificationPlan( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ ); + +std::vector< std::pair > > GetAllForticationGridNo( ); + +INT32 GetFirstObjectInSectorPosition( UINT16 ausItem ); + extern ITEM_POOL *gpItemPool;//dnl ch26 210909 #endif \ No newline at end of file diff --git a/Tactical/Interface.h b/Tactical/Interface.h index 7eddf36b..e7f0d0fe 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -196,6 +196,7 @@ enum { BG_DISLIKEBG, // dislike any other background that has the negative of this value set BG_SMOKERTYPE, // 0: doesnt care about smoking 1: will consume cigarettes, dislikes non-smokers 2: will refuse to smoke, dislikes smokers BG_CROUCHEDDEFENSE, // lowers enemy cth if they fire at us while we are crouched against cover in the direction the shots come from + BG_FORTIFY_ASSIGNMENT, // modifies effectivity of 'FORTIFICATION' assignemnt BG_MAX, }; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 4e8dcff0..8cb716dc 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -18965,6 +18965,25 @@ BOOLEAN SOLDIERTYPE::IsCrouchedAgainstCoverFromDir( UINT8 aDirection ) } +// Flugente: fortification +FLOAT SOLDIERTYPE::GetConstructionPoints( ) +{ + if ( this->stats.bLife < OKLIFE || this->flags.fMercAsleep || this->bCollapsed || (this->usSoldierFlagMask & SOLDIER_POW) ) + return 0; + + UINT32 val = EffectiveStrength( this, FALSE ); + + ReducePointsForFatigue( this, &val ); + + FLOAT dval = val; + + dval = dval * (100 + this->GetBackgroundValue( BG_FORTIFY_ASSIGNMENT )) / 100.0f; + + dval = (dval * this->stats.bLife / this->stats.bLifeMax); + + return dval; +} + INT32 CheckBleeding( SOLDIERTYPE *pSoldier ) { INT8 bBandaged; //,savedOurTurn; @@ -22773,13 +22792,13 @@ void HandleVolunteerRecruitment( SOLDIERTYPE* pRecruiter, SOLDIERTYPE* pTarget ) } // several factors determine whether we can successfully recruit this guy - FLOAT leadershipfactor = EffectiveLeadership( pRecruiter ) / 100.0; + FLOAT leadershipfactor = EffectiveLeadership( pRecruiter ) / 100.0f; // bonus for assertive characters if ( DoesMercHavePersonality( pRecruiter, CHAR_TRAIT_ASSERTIVE ) ) leadershipfactor *= 1.05; - FLOAT recruitmodifier = (100 + pRecruiter->GetBackgroundValue( BG_PERC_APPROACH_RECRUIT )) / 100.0; + FLOAT recruitmodifier = (100 + pRecruiter->GetBackgroundValue( BG_PERC_APPROACH_RECRUIT )) / 100.0f; FLOAT rating = leadershipfactor * recruitmodifier * gMercProfiles[pRecruiter->ubProfile].usApproachFactor[3]; diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 752b64b3..8fc18adc 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1914,6 +1914,9 @@ public: // Flugente: are we crouched against cover from a specific direction? WARNING: This does not suffice to determine our cover! BOOLEAN IsCrouchedAgainstCoverFromDir( UINT8 aDirection ); + + // Flugente: fortification + FLOAT GetConstructionPoints( ); ////////////////////////////////////////////////////////////////////////////// }; // SOLDIERTYPE; diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 587fc91b..37a840f2 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -121,6 +121,7 @@ #include "DisplayCover.h" // added by Sevenfm #include "InterfaceItemImages.h" // added by Sevenfm #include "DynamicDialogueWidget.h" // added by Flugente for DelayBoxDestructionBy(...) +#include "Utilities.h" // added by Flugente //forward declarations of common classes to eliminate includes class OBJECTTYPE; @@ -161,7 +162,6 @@ UINT32 guiUITargetSoldierId = NOBODY; // sevenfm: for cover dialog extern COVER_DRAW_MODE gubDrawMode; -extern MINES_DRAW_MODE gubDrawModeMine; extern MOUSE_REGION gMPanelRegion; @@ -193,6 +193,12 @@ extern INT32 giSMStealthButton; SOLDIERTYPE *gpExchangeSoldier1; SOLDIERTYPE *gpExchangeSoldier2; +// Flugente: fortification +INT16 gCurrentFortificationStructure = -1; +UINT8 gCurrentFortificationTileLibraryIndex = 0; + +extern UINT32 guiMessageBoxImage; +extern UINT16 guiMessageBoxImageIndex; BOOLEAN ConfirmActionCancel( INT32 usMapPos, INT32 usOldMapPos ); @@ -338,6 +344,7 @@ INT32 InvItemType( UINT16 usItem ); void HandleTacticalInventoryMenu( void ); void HandleTacticalMoveItems( void ); void TacticalInventoryMessageBoxCallBack( UINT8 ubExitValue ); +void FortificationSettingCallBack( UINT8 ubExitValue ); void HandleTacticalCoverMenu( void ); void TacticalCoverMessageBoxCallBack( UINT8 ubExitValue ); void ActivateCheatsMessageBoxCallBack( UINT8 ubExitValue ); @@ -3000,9 +3007,93 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) case 'a': - if ( fCtrl ) + if ( fCtrl && fAlt ) { - // free to use + // Flugente: fortification + // set details on how to place fortification nodes + // loop over all structure constructs, and select those entries that are possible in this map + std::vector > dropdownvector_1 = GetCurrentSectorAllowedFortificationTileSetVector( giCurrentTilesetID ); + + DropDownTemplate::getInstance( ).SetEntries( dropdownvector_1 ); + + if ( !dropdownvector_1.empty() ) + { + BOOLEAN found = FALSE; + for ( std::vector >::iterator it = dropdownvector_1.begin( ); it != dropdownvector_1.end(); ++it ) + { + if ( (*it).first == gCurrentFortificationStructure ) + { + found = TRUE; + break; + } + } + + if ( !found ) + gCurrentFortificationStructure = dropdownvector_1[0].first; + } + + DropDownTemplate::getInstance( ).SetSelectedEntryKey( gCurrentFortificationStructure ); + + std::vector > dropdownvector_2 = GetTileSetIndexVector( gCurrentFortificationStructure ); + + DropDownTemplate::getInstance( ).SetEntries( dropdownvector_2 ); + + if ( !dropdownvector_2.empty( ) ) + { + BOOLEAN found = FALSE; + for ( std::vector >::iterator it = dropdownvector_2.begin( ); it != dropdownvector_2.end( ); ++it ) + { + if ( (*it).first == guiMessageBoxImageIndex ) + { + found = TRUE; + break; + } + } + + if ( !found ) + guiMessageBoxImageIndex = dropdownvector_2[0].first; + } + + DropDownTemplate::getInstance( ).SetSelectedEntryKey( guiMessageBoxImageIndex ); + + if ( dropdownvector_1.empty( ) || dropdownvector_2.empty() ) + { + CHAR16 text[100]; + swprintf( text, szFortificationText[4], giCurrentTilesetID, gTilesets[giCurrentTilesetID].zName ); + + DoMessageBox( MSG_BOX_BASIC_STYLE, text, GAME_SCREEN, MSG_BOX_FLAG_OK, NULL, NULL ); + } + else + { + CHAR16 text[100]; + swprintf( text, szFortificationText[5], giCurrentTilesetID, gTilesets[giCurrentTilesetID].zName ); + + VOBJECT_DESC VObjectDesc; + VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; + + sprintf( VObjectDesc.ImageFile, "TILESETS\\%d\\%s", giCurrentTilesetID, gStructureConstruct[gCurrentFortificationStructure].szTileSetName ); + + // even if AddVideoObject fails, we still set MSG_BOX_FLAG_IMAGE, as we might 'repair' it while the box is open + if ( !AddVideoObject( &VObjectDesc, &guiMessageBoxImage ) ) + { + sprintf( VObjectDesc.ImageFile, "TILESETS\\0\\%s", gStructureConstruct[gCurrentFortificationStructure].szTileSetName ); + + AddVideoObject( &VObjectDesc, &guiMessageBoxImage ); + } + + DoMessageBox( MSG_BOX_BASIC_STYLE, text, GAME_SCREEN, (MSG_BOX_FLAG_OK | MSG_BOX_FLAG_DROPDOWN | MSG_BOX_FLAG_IMAGE), FortificationSettingCallBack, NULL ); + } + } + else if ( fCtrl ) + { + // Flugente: fortification + INT32 sGridNo; + + //Get the gridno the cursor is at + GetMouseMapPos( &sGridNo ); + + // a node to add a structure + AddFortificationPlanNode( sGridNo, gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, TRUE ); } else if ( fAlt ) { @@ -3047,7 +3138,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } else if( fCtrl ) { - // free to use + // Flugente: fortification + INT32 sGridNo; + + //Get the gridno the cursor is at + GetMouseMapPos( &sGridNo ); + + // a node to delete a structure + AddFortificationPlanNode( sGridNo, gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, FALSE ); } else { @@ -3066,7 +3164,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) break; case 'c': - if( fAlt ) + if ( fAlt && fCtrl ) + { + if ( CHEATER_CHEAT_LEVEL( ) ) + { + ToggleCliffDebug( ); + } + } + else if ( fAlt ) { if ( CHEATER_CHEAT_LEVEL( ) ) { @@ -3075,14 +3180,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } else if( fCtrl ) { - if ( CHEATER_CHEAT_LEVEL( ) ) - { - ToggleCliffDebug(); - } - else - { - HandleTacticalCoverMenu(); - } + HandleTacticalCoverMenu(); } else { @@ -8093,6 +8191,12 @@ void TacticalInventoryMessageBoxCallBack( UINT8 ubExitValue ) } } +void FortificationSettingCallBack( UINT8 ubExitValue ) +{ + gCurrentFortificationStructure = (UINT8)(DropDownTemplate::getInstance( ).GetSelectedEntryKey( )); + gCurrentFortificationTileLibraryIndex = (UINT8)(DropDownTemplate::getInstance( ).GetSelectedEntryKey( )); +} + void HandleTacticalCoverMenu( void ) { for( INT32 cnt = 0; cnt < TACTICAL_COVER_DIALOG_NUM; ++cnt) @@ -8101,17 +8205,21 @@ void HandleTacticalCoverMenu( void ) gzUserDefinedButtonColor[cnt] = 0; } gzUserDefinedButtonColor[0] = 0; - gzUserDefinedButtonColor[1] = FONT_MCOLOR_LTYELLOW; - gzUserDefinedButtonColor[2] = FONT_MCOLOR_LTYELLOW; + gzUserDefinedButtonColor[1] = (gubDrawMode != COVER_DRAW_ENEMY_VIEW) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[2] = (gubDrawMode != COVER_DRAW_MERC_VIEW) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[3] = 0; gzUserDefinedButtonColor[4] = gDisplayEnemyRoles ? FONT_MCOLOR_LTGREEN : FONT_LTRED; - gzUserDefinedButtonColor[6] = (gubDrawModeTracker == TRACKER_DRAW_OFF) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; - gzUserDefinedButtonColor[8] = FONT_ORANGE; - gzUserDefinedButtonColor[9] = FONT_ORANGE; - gzUserDefinedButtonColor[10] = FONT_ORANGE; - gzUserDefinedButtonColor[12] = FONT_MCOLOR_LTGREEN; - gzUserDefinedButtonColor[13] = FONT_MCOLOR_LTGREEN; - gzUserDefinedButtonColor[14] = FONT_MCOLOR_LTGREEN; - gzUserDefinedButtonColor[15] = FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[5] = (gubDrawMode != DRAW_MODE_FORTIFY) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[6] = (gubDrawMode != DRAW_MODE_TRACKER_SMELL) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[7] = 0; + gzUserDefinedButtonColor[8] = (gubDrawMode != MINES_DRAW_PLAYERTEAM_NETWORKS) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; + gzUserDefinedButtonColor[9] = (gubDrawMode != MINES_DRAW_NETWORKCOLOURING) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; + gzUserDefinedButtonColor[10] = (gubDrawMode != MINES_DRAW_DETECT_ENEMY) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; + gzUserDefinedButtonColor[11] = 0; + gzUserDefinedButtonColor[12] = (gubDrawMode != MINES_DRAW_NET_A) ? FONT_LTRED : FONT_MCOLOR_LTGREEN; + gzUserDefinedButtonColor[13] = (gubDrawMode != MINES_DRAW_NET_B) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; + gzUserDefinedButtonColor[14] = (gubDrawMode != MINES_DRAW_NET_C) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; + gzUserDefinedButtonColor[15] = (gubDrawMode != MINES_DRAW_NET_D) ? FONT_LTRED : FONT_MCOLOR_LTGREEN;; DoMessageBox( MSG_BOX_BASIC_STYLE, szTacticalCoverDialogString[0], GAME_SCREEN, MSG_BOX_FLAG_GENERIC_SIXTEEN_BUTTONS, TacticalCoverMessageBoxCallBack, NULL ); } @@ -8121,14 +8229,12 @@ void TacticalCoverMessageBoxCallBack( UINT8 ubExitValue ) switch( ubExitValue ) { case 1: - ResetOverlayModes( ); + gubDrawMode = DRAW_MODE_OFF; break; case 2: - ResetOverlayModes( ); gubDrawMode = COVER_DRAW_ENEMY_VIEW; break; case 3: - ResetOverlayModes( ); gubDrawMode = COVER_DRAW_MERC_VIEW; break; case 4: @@ -8137,49 +8243,41 @@ void TacticalCoverMessageBoxCallBack( UINT8 ubExitValue ) gDisplayEnemyRoles = !gDisplayEnemyRoles; break; case 6: + if ( gubDrawMode == DRAW_MODE_FORTIFY ) + gubDrawMode = DRAW_MODE_OFF; + else + gubDrawMode = DRAW_MODE_FORTIFY; break; case 7: - if ( gubDrawModeTracker == TRACKER_DRAW_SMELL ) - { - ResetOverlayModes( ); - } + if ( gubDrawMode == DRAW_MODE_TRACKER_SMELL ) + gubDrawMode = DRAW_MODE_OFF; else - { - ResetOverlayModes( ); - gubDrawModeTracker = TRACKER_DRAW_SMELL; - } + gubDrawMode = DRAW_MODE_TRACKER_SMELL; break; case 8: break; case 9: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_PLAYERTEAM_NETWORKS; + gubDrawMode = MINES_DRAW_PLAYERTEAM_NETWORKS; break; case 10: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_NETWORKCOLOURING; + gubDrawMode = MINES_DRAW_NETWORKCOLOURING; break; case 11: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_DETECT_ENEMY; + gubDrawMode = MINES_DRAW_DETECT_ENEMY; break; case 12: break; case 13: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_NET_A; + gubDrawMode = MINES_DRAW_NET_A; break; case 14: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_NET_B; + gubDrawMode = MINES_DRAW_NET_B; break; case 15: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_NET_C; + gubDrawMode = MINES_DRAW_NET_C; break; case 16: - ResetOverlayModes( ); - gubDrawModeMine = MINES_DRAW_NET_D; + gubDrawMode = MINES_DRAW_NET_D; break; } diff --git a/Tactical/XML_Background.cpp b/Tactical/XML_Background.cpp index 18f89ae9..4d15f390 100644 --- a/Tactical/XML_Background.cpp +++ b/Tactical/XML_Background.cpp @@ -133,6 +133,7 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha strcmp(name, "dislikebackground" ) == 0 || strcmp(name, "smoker" ) == 0 || strcmp(name, "croucheddefense" ) == 0 || + strcmp(name, "fortify_assignment" ) == 0 || strcmp(name, "druguse") == 0 || strcmp(name, "xenophobic") == 0 || strcmp(name, "corruptionspread") == 0 || @@ -567,6 +568,11 @@ backgroundEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curBackground.value[BG_CROUCHEDDEFENSE] = min( 30, max( -30, (INT16)atol( pData->szCharData ) ) ); } + else if ( strcmp( name, "fortify_assignment" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curBackground.value[BG_FORTIFY_ASSIGNMENT] = min( 200, max( -50, (INT16)atol( pData->szCharData ) ) ); + } else if(strcmp(name, "druguse") == 0) { pData->curElement = ELEMENT; diff --git a/Tactical/XML_StructureConstruct.cpp b/Tactical/XML_StructureConstruct.cpp index e61b1cb9..2a42dcd2 100644 --- a/Tactical/XML_StructureConstruct.cpp +++ b/Tactical/XML_StructureConstruct.cpp @@ -51,7 +51,10 @@ structureconstructStartElementHandle(void *userData, const XML_Char *name, const else if(pData->curElement == ELEMENT && (strcmp(name, "usCreationItem") == 0 || strcmp(name, "usItemStatusLoss") == 0 || - strcmp(name, "szTileSetName") == 0 || + strcmp(name, "szTileSetDisplayName") == 0 || + strcmp(name, "szTileSetName" ) == 0 || + strcmp(name, "dCreationCost" ) == 0 || + strcmp(name, "fFortifyAdjacentAdjustment" ) == 0 || strcmp(name, "northfacingtile") == 0 || strcmp(name, "southfacingtile" ) == 0 || strcmp(name, "eastfacingtile" ) == 0 || @@ -107,7 +110,10 @@ structureconstructEndElementHandle(void *userData, const XML_Char *name) // for now, copy over the content by hand pData->curArray[structureconstructcnt].usCreationItem = pData->curFood.usCreationItem; pData->curArray[structureconstructcnt].usItemStatusLoss= pData->curFood.usItemStatusLoss; - strncpy(pData->curArray[structureconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20); + strncpy( pData->curArray[structureconstructcnt].szTileSetDisplayName, pData->curFood.szTileSetDisplayName, 20 ); + strncpy( pData->curArray[structureconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20 ); + pData->curArray[structureconstructcnt].dCreationCost = pData->curFood.dCreationCost; + pData->curArray[structureconstructcnt].fFortifyAdjacentAdjustment = pData->curFood.fFortifyAdjacentAdjustment; pData->curArray[structureconstructcnt].northtilevector = staticnorthtilevector; pData->curArray[structureconstructcnt].southtilevector = staticsouthtilevector; pData->curArray[structureconstructcnt].easttilevector = staticeasttilevector; @@ -136,11 +142,27 @@ structureconstructEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curFood.usItemStatusLoss = (UINT8) atol(pData->szCharData); } - else if(strcmp(name, "szTileSetName") == 0) + else if(strcmp(name, "szTileSetDisplayName") == 0) { pData->curElement = ELEMENT; - strncpy(pData->curFood.szTileSetName, pData->szCharData, 20); + strncpy( pData->curFood.szTileSetDisplayName, pData->szCharData, 20 ); + } + else if ( strcmp( name, "szTileSetName" ) == 0 ) + { + pData->curElement = ELEMENT; + + strncpy( pData->curFood.szTileSetName, pData->szCharData, 20 ); + } + else if ( strcmp( name, "dCreationCost" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curFood.dCreationCost = (FLOAT)atof( pData->szCharData ); + } + else if ( strcmp( name, "fFortifyAdjacentAdjustment" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curFood.fFortifyAdjacentAdjustment = (BOOLEAN)atol( pData->szCharData ); } else if(strcmp(name, "northfacingtile") == 0) { @@ -251,8 +273,11 @@ BOOLEAN WriteStructureConstructStats() FilePrintf(hFile,"\t\t%d\r\n", gStructureConstruct[cnt].usCreationItem ); FilePrintf(hFile,"\t\t%d\r\n", gStructureConstruct[cnt].usItemStatusLoss ); - FilePrintf(hFile,"\t\t%s\r\n", gStructureConstruct[cnt].szTileSetName ); - + FilePrintf(hFile,"\t\t%s\r\n", gStructureConstruct[cnt].szTileSetDisplayName ); + FilePrintf(hFile,"\t\t%s\r\n", gStructureConstruct[cnt].szTileSetName ); + FilePrintf(hFile,"\t\t%d\r\n", gStructureConstruct[cnt].dCreationCost ); + FilePrintf(hFile,"\t\t%d\r\n", gStructureConstruct[cnt].fFortifyAdjacentAdjustment ); + FilePrintf(hFile,"\t\r\n"); } FilePrintf(hFile,"\r\n"); diff --git a/Tactical/XML_StructureDeconstruct.cpp b/Tactical/XML_StructureDeconstruct.cpp index e3707718..7c4c70d4 100644 --- a/Tactical/XML_StructureDeconstruct.cpp +++ b/Tactical/XML_StructureDeconstruct.cpp @@ -52,8 +52,10 @@ structuredeconstructStartElementHandle(void *userData, const XML_Char *name, con (strcmp(name, "usDeconstructItem") == 0 || strcmp( name, "usItemToCreate" ) == 0 || strcmp( name, "usCreatedItemStatus" ) == 0 || - strcmp(name, "szTileSetName") == 0 || - strcmp(name, "allowedtile") == 0 )) + strcmp( name, "szTileSetDisplayName" ) == 0 || + strcmp( name, "szTileSetName") == 0 || + strcmp( name, "dCreationCost" ) == 0 || + strcmp( name, "allowedtile") == 0 )) { pData->curElement = ELEMENT_PROPERTY; @@ -105,9 +107,11 @@ structuredeconstructEndElementHandle(void *userData, const XML_Char *name) pData->curArray[structuredeconstructcnt].usDeconstructItem = pData->curFood.usDeconstructItem; pData->curArray[structuredeconstructcnt].usItemToCreate= pData->curFood.usItemToCreate; pData->curArray[structuredeconstructcnt].usCreatedItemStatus = pData->curFood.usCreatedItemStatus; - strncpy(pData->curArray[structuredeconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20); + strncpy( pData->curArray[structuredeconstructcnt].szTileSetDisplayName, pData->curFood.szTileSetDisplayName, 20 ); + strncpy( pData->curArray[structuredeconstructcnt].szTileSetName, pData->curFood.szTileSetName, 20 ); + pData->curArray[structuredeconstructcnt].dCreationCost = pData->curFood.dCreationCost; pData->curArray[structuredeconstructcnt].tilevector = statictilevector; - + statictilevector.clear(); } @@ -128,11 +132,22 @@ structuredeconstructEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curFood.usCreatedItemStatus = (UINT8)atol( pData->szCharData ); } - else if(strcmp(name, "szTileSetName") == 0) + else if(strcmp(name, "szTileSetDisplayName") == 0) { pData->curElement = ELEMENT; - strncpy(pData->curFood.szTileSetName, pData->szCharData, 20); + strncpy( pData->curFood.szTileSetDisplayName, pData->szCharData, 20 ); + } + else if ( strcmp( name, "szTileSetName" ) == 0 ) + { + pData->curElement = ELEMENT; + + strncpy( pData->curFood.szTileSetName, pData->szCharData, 20 ); + } + else if ( strcmp( name, "dCreationCost" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curFood.dCreationCost = (FLOAT)atof( pData->szCharData ); } else if(strcmp(name, "allowedtile") == 0) { @@ -234,6 +249,7 @@ BOOLEAN WriteStructureDeconstructStats() FilePrintf(hFile,"\t\t%d\r\n", gStructureDeconstruct[cnt].usDeconstructItem ); FilePrintf(hFile,"\t\t%d\r\n", gStructureDeconstruct[cnt].usItemToCreate ); FilePrintf(hFile,"\t\t%d\r\n", gStructureDeconstruct[cnt].usCreatedItemStatus ); + FilePrintf(hFile,"\t\t%s\r\n", gStructureDeconstruct[cnt].szTileSetDisplayName ); FilePrintf(hFile,"\t\t%s\r\n", gStructureDeconstruct[cnt].szTileSetName ); FilePrintf(hFile,"\t\r\n"); diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index d558aca9..1c7eead6 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -5851,7 +5851,7 @@ gridnoarmourvector GetArmourSharedRoofNetwork( gridnoarmourvector& arNetwork ) // handle destroying if a single roof tile -void RoofDestruction( INT32 sGridNo ) +void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion ) { SOLDIERTYPE* pSoldier = NULL; @@ -5953,11 +5953,14 @@ void RoofDestruction( INT32 sGridNo ) ApplyMapChangesToMapTempFile( TRUE ); // play an animation of falling roof tiles - // if we merely collected the tiles that collapse and then call them all together, it would be possible to have animations for multi-tile collapses - static UINT16 usRoofCollapseExplosionIndex = 1727; - if ( HasItemFlag( usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) || GetFirstItemWithFlag( &usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) ) + if ( fWithExplosion ) { - InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 ); + // if we merely collected the tiles that collapse and then call them all together, it would be possible to have animations for multi-tile collapses + static UINT16 usRoofCollapseExplosionIndex = 1727; + if ( HasItemFlag( usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) || GetFirstItemWithFlag( &usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) ) + { + InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 ); + } } RemoveAllRoofsOfTypeRangeAdjustSaveFile( sGridNo, FIRSTTEXTURE, WIREFRAMES ); diff --git a/TileEngine/Explosion Control.h b/TileEngine/Explosion Control.h index c73d7287..14017d07 100644 --- a/TileEngine/Explosion Control.h +++ b/TileEngine/Explosion Control.h @@ -177,6 +177,7 @@ BOOLEAN FindBinderAttachment (OBJECTTYPE * pObj); BOOLEAN CheckExplosiveTypeAsDetonator(UINT16 ubType); // Flugente: destroy rooftops +void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion = TRUE ); void HandleRoofDestruction( INT32 sGridNo, INT16 sDamage ); #endif diff --git a/TileEngine/tiledef.cpp b/TileEngine/tiledef.cpp index 39cd4744..1d51d327 100644 --- a/TileEngine/tiledef.cpp +++ b/TileEngine/tiledef.cpp @@ -842,18 +842,15 @@ void DeallocateTileDatabase( ) BOOLEAN GetLandHeadType( INT32 iMapIndex, UINT32 *puiType ) { - UINT16 usIndex; + Assert( puiType != NULL ); - Assert( puiType != NULL ); + CHECKF( gpWorldLevelData[ iMapIndex ].pLandHead != NULL ); - CHECKF( gpWorldLevelData[ iMapIndex ].pLandHead != NULL ); + UINT16 usIndex = gpWorldLevelData[iMapIndex].pLandHead->usIndex; - usIndex = gpWorldLevelData[ iMapIndex ].pLandHead->usIndex; - - GetTileType( usIndex, puiType ); - - return( TRUE ); + GetTileType( usIndex, puiType ); + return( TRUE ); } BOOLEAN SetLandIndex( INT32 iMapIndex, UINT16 usIndex, UINT32 uiNewType, BOOLEAN fDelete ) @@ -869,21 +866,19 @@ BOOLEAN SetLandIndex( INT32 iMapIndex, UINT16 usIndex, UINT32 uiNewType, BOOLEAN if ( AnyHeigherLand( iMapIndex, uiNewType, &ubLastHighLevel ) ) { - // Check if type exists and get it's index if so - if ( TypeExistsInLandLayer( iMapIndex, uiNewType, &usTempIndex ) ) - { - // Replace with new index - return( ReplaceLandIndex( iMapIndex, usTempIndex, usIndex ) ); - } - else - { - return( InsertLandIndexAtLevel( iMapIndex, usIndex, (UINT8)(ubLastHighLevel+1) ) ); - } - + // Check if type exists and get it's index if so + if ( TypeExistsInLandLayer( iMapIndex, uiNewType, &usTempIndex ) ) + { + // Replace with new index + return( ReplaceLandIndex( iMapIndex, usTempIndex, usIndex ) ); + } + else + { + return( InsertLandIndexAtLevel( iMapIndex, usIndex, (UINT8)(ubLastHighLevel+1) ) ); + } } else { - // Check if type exists and get it's index if so if ( TypeExistsInLandLayer( iMapIndex, uiNewType, &usTempIndex ) ) { @@ -896,7 +891,6 @@ BOOLEAN SetLandIndex( INT32 iMapIndex, UINT16 usIndex, UINT32 uiNewType, BOOLEAN return( AddLandToHead( iMapIndex, usIndex ) ); } } - } diff --git a/Utils/Text.h b/Utils/Text.h index 0f0c9b10..0e77fb41 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -2931,6 +2931,9 @@ extern STR16 szMilitiaStrategicMovementText[]; // Flugente: enemy heli/SAM extern STR16 szEnemyHeliText[]; +// Flugente: fortification +extern STR16 szFortificationText[]; + #define TACTICAL_INVENTORY_DIALOG_NUM 16 #define TACTICAL_COVER_DIALOG_NUM 16 diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index a7bdc74e..8ce7ecc2 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -2463,6 +2463,7 @@ STR16 pAssignmentStrings[] = L"医生",// administering medical aid L"病人", // getting medical aid L"修理", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2564,6 +2565,7 @@ STR16 pPersonnelAssignmentStrings[] = L"医生", L"病人", L"修理", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2624,6 +2626,7 @@ STR16 pLongAssignmentStrings[] = L"医生", L"病人", L"修理", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2744,6 +2747,7 @@ STR16 pAssignMenuStrings[] = L"告发", // anv: snitch actions L"训练", L"搬运物品", // get items + L"Fortify", // fortify sector // TODO.Translate L"设施", // the merc is using/staffing a facility //ham3.6 L"取消", }; @@ -8916,6 +8920,7 @@ STR16 szBackgroundText_Value[]= L"吸烟者", //L"Smoker", L"非吸烟者", //L"Nonsmoker", L" %s%d%% 如果敌人 CTH 蹲在厚覆盖他们的方向\n", //L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = @@ -9786,7 +9791,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"角色", //L"Roles", - L"", + L"Fortification", // TODO.Translate L"跟踪者",// L"Tracker", L"", @@ -9809,9 +9814,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"显示佣兵视野", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"显示绊线网络", @@ -10862,6 +10867,17 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + // WANNE: Some Chinese specific strings that needs to be in unicode! STR16 ChineseSpecString1 = L"%%"; //defined in _ChineseText.cpp as this file is already unicode STR16 ChineseSpecString2 = L"*%3d%%%%"; //defined in _ChineseText.cpp as this file is already unicode diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 7b33c76d..a05692f7 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -2461,6 +2461,7 @@ STR16 pAssignmentStrings[] = L"Dokter", // administering medical aid L"Patiënt", // getting medical aid L"Repareer", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2562,6 +2563,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Dokter", // administering medical aid L"Patiënt", // getting medical aid L"Repareer", // repairing + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2622,6 +2624,7 @@ STR16 pLongAssignmentStrings[] = L"Dokter", // administering medical aid L"Patiënt", // getting medical aid L"Repareer", // repairing + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2742,6 +2745,7 @@ STR16 pAssignMenuStrings[] = L"Snitch", // TODO.Translate // anv: snitch actions L"Train", // the merc is training L"Get Item", // get items // TODO.Translate + L"Fortify", // fortify sector // TODO.Translate L"Facility", // the merc is using/staffing a facility // TODO.Translate L"Stop", // cancel this menu }; @@ -8930,6 +8934,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = // TODO.Translate @@ -9799,7 +9804,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", // TODO.Translate - L"", + L"Fortification", // TODO.Translate L"Tracker", L"", @@ -9822,9 +9827,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Showing merc view", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Display trap network", @@ -10876,4 +10881,15 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //DUTCH diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 50a09e45..414c209e 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -2462,6 +2462,7 @@ STR16 pAssignmentStrings[] = L"Doctor", // administering medical aid L"Patient", // getting medical aid L"Repair", // repairing + L"Fortify", // build structures according to external layout }; @@ -2563,6 +2564,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Doctor", L"Patient", L"Repair", + L"Fortify sector", // build structures according to external layout }; @@ -2623,6 +2625,7 @@ STR16 pLongAssignmentStrings[] = L"Doctor", L"Patient", L"Repair", + L"Fortify sector", // build structures according to external layout }; @@ -2743,6 +2746,7 @@ STR16 pAssignMenuStrings[] = L"Snitch", // anv: snitch actions L"Train", // the merc is training L"Get Item", // move items + L"Fortify", // fortify sector L"Facility", // the merc is using/staffing a facility L"Cancel", // cancel this menu }; @@ -8914,6 +8918,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = @@ -9837,7 +9842,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", - L"", + L"Fortification", L"Tracker", L"", @@ -9860,9 +9865,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Showing merc view", L"", - L"", - L"", - L"", + L"Display enemy role symbols", + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Display trap network", @@ -10914,4 +10919,15 @@ STR16 szEnemyHeliText[] = L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //ENGLISH diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index d5f9e268..cd0bdb1c 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -2470,6 +2470,7 @@ STR16 pAssignmentStrings[] = L"Docteur", // administering medical aid L"Patient(e)", // getting medical aid L"Réparat.", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2571,6 +2572,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Docteur", L"Patient", L"Réparation", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2631,6 +2633,7 @@ STR16 pLongAssignmentStrings[] = L"Docteur", L"Patient", L"Réparation", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2751,6 +2754,7 @@ STR16 pAssignMenuStrings[] = L"Infiltré", // anv: snitch actions L"Formation", // the merc is training L"Dépl obj.", // move items + L"Fortify", // fortify sector // TODO.Translate L"Affectat.", // the merc is using/staffing a facility L"Annuler", // cancel this menu }; @@ -8915,6 +8919,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = @@ -9784,7 +9789,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", // TODO.Translate - L"", + L"Fortification", // TODO.Translate L"Tracker", L"", @@ -9807,9 +9812,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Afficher la vue du mercenaire", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Afficher réseau (piège)", @@ -10861,4 +10866,15 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //FRENCH diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index d7f1997f..840c12eb 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -2475,6 +2475,7 @@ STR16 pAssignmentStrings[] = L"Doktor", // administering medical aid L"Patient", // getting medical aid L"Repar.", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; STR16 pMilitiaString[] = @@ -2572,6 +2573,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Doktor", L"Patient", L"Reparieren", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; // refer to above for comments @@ -2630,6 +2632,7 @@ STR16 pLongAssignmentStrings[] = L"Doktor", L"Patient", L"Reparieren", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; // the contract options @@ -2746,6 +2749,7 @@ STR16 pAssignMenuStrings[] = L"Snitch", // TODO.Translate // anv: snitch actions L"Training", // the merc is training L"Umzug", // move items + L"Fortify", // fortify sector // TODO.Translate L"Betrieb", // the merc is using/staffing a facility L"Abbrechen", // cancel this menu }; @@ -8746,6 +8750,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = // TODO.Translate @@ -9615,7 +9620,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", // TODO.Translate - L"", + L"Fortification", // TODO.Translate L"Tracker", L"", @@ -9638,9 +9643,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Showing merc view", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Display trap network", @@ -10692,4 +10697,15 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //GERMAN diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index b424f5a7..948fe577 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -2456,6 +2456,7 @@ STR16 pAssignmentStrings[] = L"Dottore", // administering medical aid L"Paziente", // getting medical aid L"Riparare", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2557,6 +2558,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Dottore", L"Paziente", L"Riparare", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2617,6 +2619,7 @@ STR16 pLongAssignmentStrings[] = L"Dottore", L"Paziente", L"Ripara", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2737,6 +2740,7 @@ STR16 pAssignMenuStrings[] = L"Snitch", // TODO.Translate // anv: snitch actions L"Si esercita", // the merc is training L"Get Item", // get items // TODO.Translate + L"Fortify", // fortify sector // TODO.Translate L"Facility", // the merc is using/staffing a facility // TODO.Translate L"Annulla", // cancel this menu }; @@ -8924,6 +8928,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = // TODO.Translate @@ -9793,7 +9798,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", // TODO.Translate - L"", + L"Fortification", // TODO.Translate L"Tracker", L"", @@ -9816,9 +9821,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Showing merc view", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Display trap network", @@ -10870,4 +10875,15 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //ITALIAN diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 770c3847..6bf65094 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -2468,6 +2468,7 @@ STR16 pAssignmentStrings[] = L"Lekarz", // administering medical aid L"Pacjent", // getting medical aid L"Naprawa", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2569,6 +2570,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Lekarz", L"Pacjent", L"Naprawa", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2629,6 +2631,7 @@ STR16 pLongAssignmentStrings[] = L"Lekarz", L"Pacjent", L"Naprawa", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2749,6 +2752,7 @@ STR16 pAssignMenuStrings[] = L"Kapuś", // anv: snitch actions L"Szkolenie", // the merc is training L"Get Item", // get items // TODO.Translate + L"Fortify", // fortify sector // TODO.Translate L"Facility", // the merc is using/staffing a facility // TODO.Translate L"Anuluj", // cancel this menu }; @@ -8937,6 +8941,7 @@ STR16 szBackgroundText_Value[]= L"Smoker", L"Nonsmoker", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = // TODO.Translate @@ -9806,7 +9811,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Roles", // TODO.Translate - L"", + L"Fortification", // TODO.Translate L"Tracker", L"", @@ -9829,9 +9834,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Showing merc view", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Display trap network", @@ -10883,4 +10888,15 @@ STR16 szEnemyHeliText[] = // TODO.Translate L"SAM in %s fires at enemy helicopter in %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //POLISH diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index 2a660db6..a8db611e 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -2462,6 +2462,7 @@ STR16 pAssignmentStrings[] = L"Медик", // administering medical aid L"Пациент", // getting medical aid L"Ремонт", // repairing + L"Fortify", // build structures according to external layout // TODO.Translate }; @@ -2563,6 +2564,7 @@ STR16 pPersonnelAssignmentStrings[] = L"Медик", L"Пациент", L"Ремонт", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2623,6 +2625,7 @@ STR16 pLongAssignmentStrings[] = L"Медик", L"Пациент", L"Ремонтирует", + L"Fortify sector", // build structures according to external layout // TODO.Translate }; @@ -2743,6 +2746,7 @@ STR16 pAssignMenuStrings[] = L"Осведомитель", // anv: snitch actions L"Обучение", // the merc is training L"Носильщик", // move items + L"Fortify", // fortify sector // TODO.Translate L"Занятия", // the merc is using/staffing a facility L"Отмена", // cancel this menu }; @@ -8914,6 +8918,7 @@ STR16 szBackgroundText_Value[]= L"Курит", L"Не курит", L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% building speed\n", }; STR16 szBackgroundTitleText[] = @@ -9837,7 +9842,7 @@ STR16 szTacticalCoverDialogString[]= L"", L"Задачи", - L"", + L"Fortification", // TODO.Translate L"Слежение", L"", @@ -9860,9 +9865,9 @@ STR16 szTacticalCoverDialogPrintString[]= L"Показывать что видит боец", L"", - L"", - L"", - L"", + L"Display enemy role symbols", // TODO.Translate + L"Display planned fortifications", + L"Display enemy tracks", L"", L"Показать сеть ловушек", @@ -10914,4 +10919,15 @@ STR16 szEnemyHeliText[] = L"База ПВО в %s обстреляла вражеский вертолёт в %s.", }; +STR16 szFortificationText[] = +{ + L"No valid structure selected, nothing added to build plan.", + L"No gridno found to create items in %s - created items are lost.", + L"Structures could not be built in %s - people are in the way.", + L"Structures could not be built in %s - the following items are required:", + + L"No fitting fortifications found for tileset %d: %s", + L"Tileset %d: %s", +}; + #endif //RUSSIAN