diff --git a/Source/Entities/AHuman.cpp b/Source/Entities/AHuman.cpp index 71c5e885a7..5cf483ea88 100644 --- a/Source/Entities/AHuman.cpp +++ b/Source/Entities/AHuman.cpp @@ -1865,7 +1865,7 @@ void AHuman::PreControllerUpdate() { } } else { m_CanActivateBGItem = true; - if (thrownDevice = dynamic_cast(device)) { + if ((thrownDevice = dynamic_cast(device))) { thrownDevice->SetSharpAim(isSharpAiming ? 1.0F : 0); if (m_Controller.IsState(WEAPON_FIRE)) { if (m_ArmsState != THROWING_PREP) { @@ -2718,7 +2718,7 @@ void AHuman::DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos, int whichSc return; } - Actor::DrawHUD(pTargetBitmap, targetPos, whichScreen); + Actor::DrawHUD(pTargetBitmap, targetPos, whichScreen, playerControlled); if (!m_HUDVisible) { return; diff --git a/Source/Entities/Activity.cpp b/Source/Entities/Activity.cpp index b984c51b09..0c0724cf59 100644 --- a/Source/Entities/Activity.cpp +++ b/Source/Entities/Activity.cpp @@ -583,7 +583,7 @@ float Activity::GetPlayerFundsShare(int player) const { } void Activity::SetPlayerBrain(Actor* newBrain, int player) { - if ((player >= Players::PlayerOne || player < Players::MaxPlayerCount) && newBrain) { + if ((player >= Players::PlayerOne && player < Players::MaxPlayerCount) && newBrain) { if (newBrain->GetTeam() != m_Team[player]) { newBrain->SetTeam(m_Team[player]); } diff --git a/Source/Entities/LimbPath.cpp b/Source/Entities/LimbPath.cpp index 84d72dff20..07532dd8c0 100644 --- a/Source/Entities/LimbPath.cpp +++ b/Source/Entities/LimbPath.cpp @@ -397,7 +397,7 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) { m_CurrentSegment = m_Segments.begin(); // Find the first start segment that has an obstacle on it - int i = 0; + size_t i = 0; for (; i < m_StartSegCount; ++i) { Vector segmentStart = GetProgressPos(); ++m_CurrentSegment; diff --git a/Source/Entities/LimbPath.h b/Source/Entities/LimbPath.h index 6153f43378..3ab0c98eff 100644 --- a/Source/Entities/LimbPath.h +++ b/Source/Entities/LimbPath.h @@ -375,7 +375,7 @@ namespace RTE { // The number of starting segments, counting into the path from its beginning, // that upon restart of this path will be tried in reverse order till one which // yields a starting position that is clear of terrain is found. - int m_StartSegCount; + size_t m_StartSegCount; // Array containing the actual 'waypoints' or segments for the path. std::deque m_Segments; diff --git a/Source/Entities/MovableObject.cpp b/Source/Entities/MovableObject.cpp index 36b2e9cc44..a8190cc418 100644 --- a/Source/Entities/MovableObject.cpp +++ b/Source/Entities/MovableObject.cpp @@ -1100,7 +1100,7 @@ bool MovableObject::DrawToTerrain(SLTerrain* terrain) { } }; BITMAP* tempBitmap = g_SceneMan.GetIntermediateBitmapForSettlingIntoTerrain(static_cast(GetDiameter())); - Vector tempBitmapPos = m_Pos.GetFloored() - Vector(static_cast(tempBitmap->w / 2), static_cast(tempBitmap->w / 2)); + Vector tempBitmapPos = m_Pos.GetFloored() - Vector(static_cast(tempBitmap->w) / 2, static_cast(tempBitmap->w) / 2); clear_bitmap(tempBitmap); // Draw the object to the temp bitmap, then draw the foreground layer on top of it, then draw it to the foreground layer. diff --git a/Source/Entities/MovableObject.h b/Source/Entities/MovableObject.h index 60dd5b94a2..c0a59b8283 100644 --- a/Source/Entities/MovableObject.h +++ b/Source/Entities/MovableObject.h @@ -1302,7 +1302,7 @@ namespace RTE { // Unique ID of particle hit this MO long int m_ParticleUniqueIDHit; // Number of sim update frame when last collision was detected - int m_LastCollisionSimFrameNumber; + unsigned int m_LastCollisionSimFrameNumber; int m_SimUpdatesBetweenScriptedUpdates; //!< The number of Sim updates between each scripted update for this MovableObject. int m_SimUpdatesSinceLastScriptedUpdate; //!< The counter for the current number of Sim updates since this MovableObject last ran a scripted update. diff --git a/Source/Managers/SceneMan.cpp b/Source/Managers/SceneMan.cpp index 346db5e84b..281a6df780 100644 --- a/Source/Managers/SceneMan.cpp +++ b/Source/Managers/SceneMan.cpp @@ -3,7 +3,6 @@ #include "PresetMan.h" #include "FrameMan.h" #include "ActivityMan.h" -#include "UInputMan.h" #include "CameraMan.h" #include "ConsoleMan.h" #include "PrimitiveMan.h" @@ -14,14 +13,10 @@ #include "TerrainObject.h" #include "MovableObject.h" #include "ContentFile.h" -#include "AHuman.h" -#include "ACRocket.h" #include "MOPixel.h" #include "Atom.h" #include "Material.h" #include "SoundContainer.h" -// Temp -#include "Controller.h" #include "tracy/Tracy.hpp" @@ -133,7 +128,6 @@ int SceneMan::LoadScene(Scene* pNewScene, bool placeObjects, bool placeUnits) { g_ConsoleMan.PrintString("SYSTEM: Scene \"" + m_pCurrentScene->GetPresetName() + "\" was loaded"); // Set the proper scales of the unseen obscuring SceneLayers - SceneLayer* pUnseenLayer = 0; for (int team = Activity::TeamOne; team < Activity::MaxTeamCount; ++team) { if (!g_ActivityMan.GetActivity()->TeamActive(team)) continue; @@ -1046,7 +1040,7 @@ void SceneMan::RestoreUnseenBox(const int posX, const int posY, const int width, } bool SceneMan::CastTerrainPenetrationRay(const Vector& start, const Vector& ray, Vector& endPos, int strengthLimit, int skip) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool stopped = false; unsigned char materialID; @@ -1138,7 +1132,7 @@ bool SceneMan::CastUnseenRay(int team, const Vector& start, const Vector& ray, V if (!m_pCurrentScene->GetUnseenLayer(team)) return false; - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int size = 40 - GetUnseenResolution(team).GetLargest(); int intPos[2], delta[2], delta2[2], increment[2]; bool affectedAny = false; @@ -1202,14 +1196,18 @@ bool SceneMan::CastUnseenRay(int team, const Vector& start, const Vector& ray, V // Scene wrapping WrapPosition(intPos[X], intPos[Y]); + bool is_unseen = IsUnseen(intPos[X], intPos[Y], team) || IsUnseen(intPos[X] - size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y], team) || IsUnseen(intPos[X] + size, intPos[Y], team) || IsUnseen(intPos[X], intPos[Y] - size, team) || IsUnseen(intPos[X], intPos[Y] + size, team); + // Reveal if we can, save the result if (reveal) { - if (affectedAny = IsUnseen(intPos[X], intPos[Y], team) || IsUnseen(intPos[X] - size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y], team) || IsUnseen(intPos[X] + size, intPos[Y], team) || IsUnseen(intPos[X], intPos[Y] - size, team) || IsUnseen(intPos[X], intPos[Y] + size, team)) { + if (is_unseen) { RevealUnseenBox(intPos[X] - size / 2, intPos[Y] - size / 2, size, size, team); + affectedAny = true; } } else { - if (affectedAny = !(IsUnseen(intPos[X], intPos[Y], team) || IsUnseen(intPos[X] - size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] - size, team) || IsUnseen(intPos[X] + size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y] + size, team) || IsUnseen(intPos[X] - size, intPos[Y], team) || IsUnseen(intPos[X] + size, intPos[Y], team) || IsUnseen(intPos[X], intPos[Y] - size, team) || IsUnseen(intPos[X], intPos[Y] + size, team))) { + if (!is_unseen) { RestoreUnseenBox(intPos[X] - size / 2, intPos[Y] - size / 2, size, size, team); + affectedAny = true; } } @@ -1246,7 +1244,7 @@ bool SceneMan::CastUnseeRay(int team, const Vector& start, const Vector& ray, Ve bool SceneMan::CastMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip, bool wrap) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool foundPixel = false; @@ -1339,7 +1337,7 @@ float SceneMan::CastMaterialRay(const Vector& start, const Vector& ray, unsigned } bool SceneMan::CastNotMaterialRay(const Vector& start, const Vector& ray, unsigned char material, Vector& result, int skip, bool checkMOs) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool foundPixel = false; @@ -1437,7 +1435,6 @@ float SceneMan::CastStrengthSumRay(const Vector& start, const Vector& end, int s int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; - bool foundPixel = false; unsigned char materialID; Material foundMaterial; @@ -1522,7 +1519,6 @@ const Material* SceneMan::CastMaxStrengthRayMaterial(const Vector& start, const int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; - bool foundPixel = false; intPos[X] = std::floor(start.m_X); intPos[Y] = std::floor(start.m_Y); @@ -1600,7 +1596,7 @@ const Material* SceneMan::CastMaxStrengthRayMaterial(const Vector& start, const } bool SceneMan::CastStrengthRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip, unsigned char ignoreMaterial, bool wrap) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool foundPixel = false; unsigned char materialID; @@ -1693,7 +1689,7 @@ bool SceneMan::CastStrengthRay(const Vector& start, const Vector& ray, float str } bool SceneMan::CastWeaknessRay(const Vector& start, const Vector& ray, float strength, Vector& result, int skip, bool wrap) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool foundPixel = false; unsigned char materialID; @@ -1783,7 +1779,7 @@ bool SceneMan::CastWeaknessRay(const Vector& start, const Vector& ray, float str } MOID SceneMan::CastMORay(const Vector& start, const Vector& ray, const std::vector& ignoreMOIDs, int ignoreTeam, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; MOID hitMOID = g_NoMOID; unsigned char hitTerrain = 0; @@ -1884,7 +1880,7 @@ MOID SceneMan::CastMORay(const Vector& start, const Vector& ray, const std::vect } bool SceneMan::CastFindMORay(const Vector& start, const Vector& ray, MOID targetMOID, Vector& resultPos, unsigned char ignoreMaterial, bool ignoreAllTerrain, int skip, bool findChildMOIDs) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; MOID hitMOID = g_NoMOID; unsigned char hitTerrain = 0; @@ -1980,7 +1976,7 @@ const std::vector* SceneMan::CastAllMOsRay(const Vector& start, const SpatialPartitionGrid& partitionGrid = GetMOIDGrid(); - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; unsigned char hitTerrain = 0; @@ -2041,7 +2037,7 @@ const std::vector* SceneMan::CastAllMOsRay(const Vector& start, // Detect MOs std::vector hitMOs; - hitMOs = std::move(partitionGrid.GetMOsAtPosition(intPos[X], intPos[Y], ignoreTeam, false)); + hitMOs = partitionGrid.GetMOsAtPosition(intPos[X], intPos[Y], ignoreTeam, false); // Loop through the gotten MOs and check if we're ignoring their IDs - if not, put them onto our return vector for (MovableObject* mo : hitMOs) { @@ -2078,7 +2074,7 @@ const std::vector* SceneMan::CastAllMOsRay(const Vector& start, } float SceneMan::CastObstacleRay(const Vector& start, const Vector& ray, Vector& obstaclePos, Vector& freePos, const std::vector& ignoreMOIDs, int ignoreTeam, unsigned char ignoreMaterial, int skip) { - int hitCount = 0, error, dom, sub, domSteps, skipped = skip; + int error, dom, sub, domSteps, skipped = skip; int intPos[2], delta[2], delta2[2], increment[2]; bool hitObstacle = false; @@ -2591,11 +2587,11 @@ void SceneMan::Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector& Box targetDimensions(Vector(), targetBitmap->w, targetBitmap->h); if (!terrain->WrapsX() && targetBitmap->w > GetSceneWidth()) { - targetBox.SetCorner(Vector(static_cast((targetBitmap->w - GetSceneWidth()) / 2), targetBox.GetCorner().GetY())); + targetBox.SetCorner(Vector(static_cast((targetBitmap->w - GetSceneWidth())) / 2, targetBox.GetCorner().GetY())); targetBox.SetWidth(static_cast(GetSceneWidth())); } if (!terrain->WrapsY() && targetBitmap->h > GetSceneHeight()) { - targetBox.SetCorner(Vector(targetBox.GetCorner().GetX(), static_cast((targetBitmap->h - GetSceneHeight()) / 2))); + targetBox.SetCorner(Vector(targetBox.GetCorner().GetX(), static_cast((targetBitmap->h - GetSceneHeight())) / 2)); targetBox.SetHeight(static_cast(GetSceneHeight())); } @@ -2656,7 +2652,7 @@ void SceneMan::Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector& static int s_drawPathfinderDebugForTeam = -2; if (s_drawPathfinderDebugForTeam > -2) { - m_pCurrentScene->GetPathFinder(static_cast(s_drawPathfinderDebugForTeam)).DebugRender(targetBitmap, targetPos, m_LastUpdatedScreen); + m_pCurrentScene->GetPathFinder(static_cast(s_drawPathfinderDebugForTeam)).DebugRender(targetBitmap, targetPos); } if (m_pDebugLayer) { diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp index be5100127b..e2e96c4341 100644 --- a/Source/Menus/MetagameGUI.cpp +++ b/Source/Menus/MetagameGUI.cpp @@ -157,7 +157,7 @@ void MetagameGUI::Clear() { m_AnimMetaPlayer = Players::NoPlayer; m_AnimDefenseTeam = Activity::NoTeam; m_AnimActivityChange = false; - Scene* m_pAnimScene = 0; + m_pAnimScene = 0; m_AnimRatio = 0; m_AnimProgress = 0; m_AnimTotalFunds = 0; @@ -594,7 +594,7 @@ void MetagameGUI::MoveLocationsIntoTheScreen() { // We need to calculate planet center manually because m_PlanetCenter reflects coords of moving planet // which is outside the screen when this is called first time - Vector planetCenter = Vector(m_RootBoxMaxWidth / 2, g_WindowMan.GetResY() / 2); + Vector planetCenter = Vector(m_RootBoxMaxWidth / 2.0, g_WindowMan.GetResY() / 2.0); // Correct planet pos a bit when it's location is known if (!m_PlanetCenter.IsZero()) planetCenter = m_PlanetCenter; @@ -828,33 +828,32 @@ void MetagameGUI::SwitchToScreen(int newScreen) { } std::string MetagameGUI::GetRoundName(int roundNumber) { - if (roundNumber < 12) { - if (roundNumber == 0) - return "ONE"; - else if (roundNumber == 1) - return "TWO"; - else if (roundNumber == 2) - return "THREE"; - else if (roundNumber == 3) - return "FOUR"; - else if (roundNumber == 4) - return "FIVE"; - else if (roundNumber == 5) - return "SIX"; - else if (roundNumber == 6) - return "SEVEN"; - else if (roundNumber == 7) - return "EIGHT"; - else if (roundNumber == 8) - return "NINE"; - else if (roundNumber == 9) - return "TEN"; - else if (roundNumber == 10) - return "ELEVEN"; - else if (roundNumber == 11) - return "TWELVE"; - } - char numStr[8]; + if (roundNumber == 0) + return "ONE"; + else if (roundNumber == 1) + return "TWO"; + else if (roundNumber == 2) + return "THREE"; + else if (roundNumber == 3) + return "FOUR"; + else if (roundNumber == 4) + return "FIVE"; + else if (roundNumber == 5) + return "SIX"; + else if (roundNumber == 6) + return "SEVEN"; + else if (roundNumber == 7) + return "EIGHT"; + else if (roundNumber == 8) + return "NINE"; + else if (roundNumber == 9) + return "TEN"; + else if (roundNumber == 10) + return "ELEVEN"; + else if (roundNumber == 11) + return "TWELVE"; + + char numStr[11]; std::snprintf(numStr, sizeof(numStr), "%d", roundNumber + 1); return std::string(numStr); } @@ -1059,7 +1058,7 @@ bool MetagameGUI::LoadGame() { UpdateIncomeCounting(true); // Reconstruct the player action lines - they are important! - for (int metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) + for (size_t metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) UpdatePlayerActionLines(metaPlayer); // Re-init some other GUI elements @@ -1574,7 +1573,6 @@ void MetagameGUI::Update() { if (!m_pDraggedBox && (mousePos - m_PlanetCenter).MagnitudeIsLessThan(m_PlanetRadius)) { // If unlocked, detect any Scene close to the mouse and highlight it bool foundAnyHover = false; - bool foundNewHover = false; std::vector::iterator sItr; std::vector::iterator newCandidateItr = g_MetaMan.m_Scenes.end(); @@ -1607,7 +1605,6 @@ void MetagameGUI::Update() { // Set new hovered scene to be the one now closest to the cursor, if there is any and if it is different the a currently hovered one if (newCandidateItr != g_MetaMan.m_Scenes.end() && (*newCandidateItr) != m_pHoveredScene) { m_pHoveredScene = (*newCandidateItr); - foundNewHover = true; g_GUISound.SelectionChangeSound()->Play(); } @@ -1698,7 +1695,7 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { // Make sure team is within bounds to show an icon pIcon = g_MetaMan.IsActiveTeam(team) ? g_MetaMan.GetTeamIcon(team).GetBitmaps32()[0] : 0; if (pIcon) - masked_blit(pIcon, drawBitmap, 0, 0, screenLocation.m_X - (pIcon->w / 2), screenLocation.m_Y - (pIcon->h / 2), pIcon->w, pIcon->h); + masked_blit(pIcon, drawBitmap, 0, 0, screenLocation.m_X - (pIcon->w / 2.0), screenLocation.m_Y - (pIcon->h / 2.0), pIcon->w, pIcon->h); // Ownership not known, so place nondescript dot instead else { // Make it flicker more if it's currently being fought over @@ -1714,7 +1711,7 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { // Draw the lines etc pointing at the selected Scene from the Scene Info box if (m_pSelectedScene && m_pSceneInfoPopup->GetVisible() && !m_PreTurn) { - Vector sceneInfoBoxPos(m_pSceneInfoPopup->GetXPos() + (m_pSceneInfoPopup->GetWidth() / 2), m_pSceneInfoPopup->GetYPos() + (m_pSceneInfoPopup->GetHeight() / 2)); + Vector sceneInfoBoxPos(m_pSceneInfoPopup->GetXPos() + (m_pSceneInfoPopup->GetWidth() / 2.0), m_pSceneInfoPopup->GetYPos() + (m_pSceneInfoPopup->GetHeight() / 2.0)); DrawScreenLineToSitePoint(drawBitmap, sceneInfoBoxPos, m_pSelectedScene->GetLocation() + m_pSelectedScene->GetLocationOffset(), c_GUIColorWhite, -1, -1, (m_pSceneInfoPopup->GetHeight() / 2) + CHAMFERSIZE + 6, 1.0, g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())); } @@ -1738,7 +1735,7 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { // Action lines // If during a player's round phase, and not showing any income lines if (!m_PreTurn && !g_MetaMan.m_StateChanged && g_MetaMan.m_GameState >= MetaMan::PLAYER1TURN && g_MetaMan.m_GameState <= MetaMan::BUILDBASES && m_ActivePlayerIncomeLines == Players::NoPlayer) { - int metaPlayer = 0; + size_t metaPlayer = 0; // Show the lines of the relevant player during turns if (g_MetaMan.m_GameState >= MetaMan::PLAYER1TURN && g_MetaMan.m_GameState <= MetaMan::PLAYER4TURN) metaPlayer = g_MetaMan.m_GameState - MetaMan::PLAYER1TURN; @@ -1746,7 +1743,7 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { else if (g_MetaMan.m_GameState == MetaMan::BUILDBASES && m_AnimMetaPlayer < g_MetaMan.m_Players.size()) metaPlayer = m_AnimMetaPlayer; - for (int slI = 0; slI < m_ActionSiteLines[metaPlayer].size(); ++slI) { + for (size_t slI = 0; slI < m_ActionSiteLines[metaPlayer].size(); ++slI) { // Only draw the lines of the active player // if (m_ActionSiteLines[metaPlayer][slI].m_Player != m_ActivePlayerIncomeLines) // continue; @@ -1779,7 +1776,7 @@ void MetagameGUI::Draw(BITMAP* drawBitmap) { // Draw the attack lines that are currently being revealed by possibly multiple attackers for (int metaPlayer = Players::PlayerOne; metaPlayer < Players::MaxPlayerCount; ++metaPlayer) { - for (int slI = 0; slI < m_ActionSiteLines[metaPlayer].size(); ++slI) { + for (size_t slI = 0; slI < m_ActionSiteLines[metaPlayer].size(); ++slI) { DrawPlayerLineToSitePoint(drawBitmap, m_ActionSiteLines[metaPlayer][slI], m_ActionMeterDrawOverride); } } @@ -2118,7 +2115,6 @@ void MetagameGUI::UpdateInput() { if (anEvent.GetControl() == m_apMetaButton[SCENEACTION] && m_pSelectedScene) { // Set up site scan of it (for a price) int metaPlayer = g_MetaMan.GetPlayerTurn(); - int team = g_MetaMan.m_Players[metaPlayer]->GetTeam(); // Check if we have enough money for this! if (g_MetaMan.GetRemainingFundsOfPlayer(metaPlayer, 0, false, false) < SCANCOST) { m_apMetaButton[SCENEACTION]->SetText("NOT ENOUGH FUNDS!"); @@ -2678,8 +2674,9 @@ bool MetagameGUI::AutoResolveOffensive(GAScripted* pOffensive, Scene* pScene, bo // NOTE: Brain pool resource counter gets adjusted down in FinalizeOffense // Find the player's tech's brain, and instantiate it - if (pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", "Infantry Brain", pMetaPlayer->GetNativeTechModule()))) + if ((pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", "Infantry Brain", pMetaPlayer->GetNativeTechModule())))) pBrain = pLoadout->CreateFirstActor(pMetaPlayer->GetNativeTechModule(), pMetaPlayer->GetForeignCostMultiplier(), pMetaPlayer->GetNativeCostMultiplier(), cost); + // Pass the instance and ownership thereof to the scene as a resident if (pBrain) { // Set a pos outside the Scene so it'll be gracefully placed later when Scene's Terrain is actually loaded @@ -2791,8 +2788,10 @@ bool MetagameGUI::AutoResolveOffensive(GAScripted* pOffensive, Scene* pScene, bo // NOTE: Brain pool resource counter gets adjusted down in FinalizeOffense // Find the player's tech's brain, and instantiate it - if (pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", "Infantry Brain", aMetaPlayers[player]->GetNativeTechModule()))) + + if ((pLoadout = dynamic_cast(g_PresetMan.GetEntityPreset("Loadout", "Infantry Brain", aMetaPlayers[player]->GetNativeTechModule())))) pBrain = pLoadout->CreateFirstActor(aMetaPlayers[player]->GetNativeTechModule(), aMetaPlayers[player]->GetForeignCostMultiplier(), aMetaPlayers[player]->GetNativeCostMultiplier(), cost); + // Pass the instance and ownership thereof to the scene as a resident if (pBrain) { // Set a pos outside the Scene so it'll be gracefully placed later when Scene's Terrain is actually loaded @@ -2853,7 +2852,7 @@ void MetagameGUI::UpdateSiteRevealing() { // Reset the extra to 0 now after we've applied it g_MetaMan.m_RevealExtra = 0; // Don't reveal more than there are scenes! - if ((int)std::floor(g_MetaMan.m_RevealedScenes) >= g_MetaMan.m_Scenes.size()) + if ((size_t)std::floor(g_MetaMan.m_RevealedScenes) >= g_MetaMan.m_Scenes.size()) g_MetaMan.m_RevealedScenes = g_MetaMan.m_Scenes.size(); // Figure out how many new sites we gots this round int delta = (int)std::floor(g_MetaMan.m_RevealedScenes) - m_AnimCountStart; @@ -2891,7 +2890,7 @@ void MetagameGUI::UpdateSiteRevealing() { // Animate the existing crosshairs double shrinkTime = 0; double shrinkInterval = 600; - for (int i = 0; i < (m_AnimCountCurrent - m_AnimCountStart); ++i) { + for (size_t i = 0; i < (m_AnimCountCurrent - m_AnimCountStart); ++i) { // How long have we been animating this one? shrinkTime = m_AnimTimer2.GetElapsedRealTimeMS() - m_NewSiteIndicators[i].m_StartTime; // If it's still in the shrink interval, keep doing it @@ -2962,7 +2961,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { // Init all the SiteLine:s and make them hidden; we will reveal each one sequentially with an animation m_IncomeSiteLines.clear(); - for (int metaPlayer = 0; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) + for (size_t metaPlayer = 0; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) m_aStationIncomeLineIndices[metaPlayer] = -1; m_AnimMetaPlayer = m_ActivePlayerIncomeLines = Players::PlayerOne; m_pAnimScene = 0; @@ -2997,7 +2996,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { // SCENE INCOME // Loop through the scenes owned by that player, setting up the site line for each if (!initOverride) { - while (m_pAnimScene = g_MetaMan.GetNextSceneOfPlayer(m_AnimMetaPlayer, m_pAnimScene)) { + while ((m_pAnimScene = g_MetaMan.GetNextSceneOfPlayer(m_AnimMetaPlayer, m_pAnimScene))) { m_IncomeSiteLines.push_back(SiteLine(m_AnimMetaPlayer, 1.0, 0, m_pAnimScene->GetLocation() + m_pAnimScene->GetLocationOffset(), m_pAnimScene->GetPresetName(), m_pAnimScene, c_GUIColorYellow, -1, 0, channelHeight, 1.0f, g_MetaMan.IsActiveTeam(m_pAnimScene->GetTeamOwnership()))); // Star them at 0, make them go to the round income for this base m_IncomeSiteLines.back().m_FundsAmount = 0; @@ -3222,7 +3221,7 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { // Check if there's more lines to draw, and if so, if the next one is of a different player // OR if there's no lines left at all, just retract the last player's lines we just finished // Then pause to retract all the lines of the just finished player - if ((m_AnimIncomeLineIndex + 1) >= static_cast(m_IncomeSiteLines.size()) || m_IncomeSiteLines[m_AnimIncomeLineIndex + 1].m_Player != m_AnimMetaPlayer) { + if ((m_AnimIncomeLineIndex + 1) >= m_IncomeSiteLines.size() || m_IncomeSiteLines[m_AnimIncomeLineIndex + 1].m_Player != m_AnimMetaPlayer) { // Wait for a little bit when we've displayed all sites of a player if (m_AnimTimer2.IsPastRealMS(500)) ChangeAnimMode(RETRACTLINES); @@ -3244,12 +3243,12 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { // Show the change, if any if (fabs(m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget - m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount) > 0) { // Show why we are paying money - PlayerTextIndication(m_AnimMetaPlayer, "TradeStar brain storage rent", Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth() / 2), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetHeight() / 2)), m_AnimModeDuration); + PlayerTextIndication(m_AnimMetaPlayer, "TradeStar brain storage rent", Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth() / 2.0), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetHeight() / 2.0)), m_AnimModeDuration); FundsChangeIndication(m_AnimMetaPlayer, m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsTarget - m_IncomeSiteLines[m_AnimIncomeLineIndex].m_FundsAmount, Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth(), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos()), m_AnimModeDuration); } // Indicate why we're not paying anything else - PlayerTextIndication(m_AnimMetaPlayer, "No brains; no rent!", Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth() / 2), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetHeight() / 2)), m_AnimModeDuration); + PlayerTextIndication(m_AnimMetaPlayer, "No brains; no rent!", Vector(m_apPlayerBarLabel[m_AnimMetaPlayer]->GetXPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetWidth() / 2.0), m_apPlayerBarLabel[m_AnimMetaPlayer]->GetYPos() + (m_apPlayerBarLabel[m_AnimMetaPlayer]->GetHeight() / 2.0)), m_AnimModeDuration); /* This is done above on init now // Only charge rent if we've still got brains at the tradestar @@ -3331,13 +3330,13 @@ void MetagameGUI::UpdateIncomeCounting(bool initOverride) { } // If no more lines, DONE, continue phase to next - if (m_AnimIncomeLineIndex >= static_cast(m_IncomeSiteLines.size()) && !initOverride) + if (m_AnimIncomeLineIndex >= m_IncomeSiteLines.size() && !initOverride) m_ContinuePhase = true; // Phase ending, make sure everything is set up to continue if (m_ContinuePhase || initOverride) { // Set all lines' fund amounts to their targets and reset their segment animations so we can see them - int lineIndex = 0; + size_t lineIndex = 0; for (std::vector::iterator slItr = m_IncomeSiteLines.begin(); slItr != m_IncomeSiteLines.end(); ++slItr) { (*slItr).m_FundsAmount = (*slItr).m_FundsTarget; (*slItr).m_OnlyFirstSegments = -1; @@ -3461,7 +3460,7 @@ void MetagameGUI::UpdateBaseBuilding() { // ChangeAnimMode(PAUSEANIM); // Find the next green defense line of this player - while (m_AnimActionLine < static_cast(m_ActionSiteLines[m_AnimMetaPlayer].size()) && m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_Color != c_GUIColorGreen) + while (m_AnimActionLine < m_ActionSiteLines[m_AnimMetaPlayer].size() && m_ActionSiteLines[m_AnimMetaPlayer][m_AnimActionLine].m_Color != c_GUIColorGreen) m_AnimActionLine++; // Regular site line, start with bar bracket and line appearing toward the site @@ -3474,7 +3473,7 @@ void MetagameGUI::UpdateBaseBuilding() { // Animate defense spending sitelines into view, and then count them away one by one // for (vector::iterator slItr = m_ActionSiteLines[m_AnimMetaPlayer].begin(); slItr != m_ActionSiteLines[m_AnimMetaPlayer].end(); ++slItr) - if (!m_ActionSiteLines[m_AnimMetaPlayer].empty() && m_AnimActionLine < static_cast(m_ActionSiteLines[m_AnimMetaPlayer].size())) { + if (!m_ActionSiteLines[m_AnimMetaPlayer].empty() && m_AnimActionLine < m_ActionSiteLines[m_AnimMetaPlayer].size()) { if (m_AnimMode == BLINKMETER) { if (NewAnimMode()) { m_AnimTimer1.Reset(); @@ -3598,7 +3597,7 @@ void MetagameGUI::UpdateBaseBuilding() { } // If no more lines, DONE, continue to next player, and if no more players, continue to next phase of the round - if (m_AnimActionLine >= static_cast(m_ActionSiteLines[m_AnimMetaPlayer].size())) { + if (m_AnimActionLine >= m_ActionSiteLines[m_AnimMetaPlayer].size()) { m_AnimActionLineChange = true; m_AnimActionLine = 0; @@ -3834,7 +3833,7 @@ void MetagameGUI::UpdateOffensives() { // Find out how much gold this player has left after all allocations and previous battles this turn float remainingFunds = g_MetaMan.GetRemainingFundsOfPlayer(mp); // UPDATE the contributed funds of the defending player to whatever gold he has left after all (if any) previous battles this turn! - bool updated = g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->UpdatePlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer(), remainingFunds); + g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->UpdatePlayerFundsContribution(g_MetaMan.m_Players[mp]->GetInGamePlayer(), remainingFunds); // Add the unused build budget FOR THIS SCENE to the battle funds display - doesn't do anyhting now because build budgets are set to 0 in UpdateBaseBuilding m_aBattleFunds[mp] += m_pAnimScene->GetBuildBudget(g_MetaMan.m_Players[mp]->GetInGamePlayer()); // Add the unallocated funds meter, even if there's 0 left.. it shows why there's 0, and also the meter can grow after battle if the defending player digs up gold diff --git a/Source/System/Atom.cpp b/Source/System/Atom.cpp index 73c39aa87c..e0f3ae690c 100644 --- a/Source/System/Atom.cpp +++ b/Source/System/Atom.cpp @@ -518,7 +518,7 @@ int Atom::SetupSeg(Vector startPos, Vector trajectory, float stepRatio) { return m_Delta[m_Dom] - m_DomSteps; } -bool Atom::StepForward(int numSteps) { +bool Atom::StepForward() { RTEAssert(m_OwnerMO, "Stepping an Atom without a parent MO!"); // Only take the step if the step ratio permits it @@ -1046,7 +1046,7 @@ int Atom::Travel(float travelTime, bool autoTravel) { Vector bottomRightExtent = topLeftExtent + Vector(1.0F, 1.0F); int length = static_cast(static_cast(m_TrailLength) * RandomNum(1.0F - m_TrailLengthVariation, 1.0F)); - for (int i = trailPoints.size() - std::min(length, static_cast(trailPoints.size())); i < trailPoints.size(); ++i) { + for (size_t i = trailPoints.size() - std::min(length, static_cast(trailPoints.size())); i < trailPoints.size(); ++i) { putpixel(trailBitmap, trailPoints[i].first, trailPoints[i].second, m_TrailColor.GetIndex()); topLeftExtent.m_X = std::min(topLeftExtent.m_X, static_cast(trailPoints[i].first)); diff --git a/Source/System/Atom.h b/Source/System/Atom.h index 094d916a22..ea5f3d2d03 100644 --- a/Source/System/Atom.h +++ b/Source/System/Atom.h @@ -293,7 +293,7 @@ namespace RTE { /// @return /// Whether anything was hit during the steps or not. MO hits will only be reported if this Atom is set to hit them, and the MO hit is not ignored by this Atom (if the segment started on that MO). /// Also if terrain hits are temporarily disabled, they will not be reported. - bool StepForward(int numSteps = 1); + bool StepForward(); /// Takes one step back, or undos the step, if any, previously taken along the trajectory segment set up by SetupSeg(). /// @remark CAUTION: The previous HitWhat vars are not reset to what they previously were! diff --git a/Source/System/Box.cpp b/Source/System/Box.cpp index 5f30a7c9c5..9fa1267b0d 100644 --- a/Source/System/Box.cpp +++ b/Source/System/Box.cpp @@ -79,10 +79,7 @@ void Box::Unflip() { } bool Box::IsWithinBox(const Vector& point) const { - return !IsEmpty() && (((m_Width > 0 && point.m_X >= m_Corner.m_X && point.m_X < (m_Corner.m_X + m_Width)) || - (m_Width < 0 && point.m_X < m_Corner.m_X && point.m_X >= (m_Corner.m_X + m_Width))) && - (m_Height > 0 && point.m_Y >= m_Corner.m_Y && point.m_Y < (m_Corner.m_Y + m_Height)) || - (m_Height < 0 && point.m_Y < m_Corner.m_Y && point.m_Y <= (m_Corner.m_Y + m_Height))); + return !IsEmpty() && IsWithinBoxX(point.m_X) && IsWithinBoxY(point.m_Y); } bool Box::IsWithinBoxX(float pointX) const { @@ -142,4 +139,4 @@ Box Box::GetIntersection(const Box& rhs) const { std::min(box1.m_Corner.m_Y + box1.m_Height, box2.m_Corner.m_Y + box2.m_Height))); return returnBox; -} \ No newline at end of file +} diff --git a/Source/System/Entity.cpp b/Source/System/Entity.cpp index c8f34f15fe..e3fb49bb67 100644 --- a/Source/System/Entity.cpp +++ b/Source/System/Entity.cpp @@ -1,7 +1,6 @@ #include "Entity.h" #include "RTETools.h" #include "PresetMan.h" -#include "ConsoleMan.h" #include "DataModule.h" namespace RTE { @@ -64,7 +63,7 @@ namespace RTE { MatchForwards("PresetName") MatchProperty("InstanceName", { SetPresetName(reader.ReadPropValue()); // Preset name might have "[ModuleName]/" preceding it, detect it here and select proper module! - int slashPos = m_PresetName.find_first_of('/'); + size_t slashPos = m_PresetName.find_first_of('/'); if (slashPos != std::string::npos) { m_PresetName = m_PresetName.substr(slashPos + 1); } diff --git a/Source/System/Entity.h b/Source/System/Entity.h index 07a19751bc..8caa3ccae8 100644 --- a/Source/System/Entity.h +++ b/Source/System/Entity.h @@ -358,7 +358,7 @@ namespace RTE { /// Gets the class name of this Entity. /// @return A string with the friendly-formatted type name of this Entity. - virtual const std::string& GetClassName() const { return m_sClass.GetName(); } + virtual const std::string& GetClassName() const override { return m_sClass.GetName(); } #pragma endregion protected: diff --git a/Source/System/PathFinder.cpp b/Source/System/PathFinder.cpp index 16de46f553..843895c145 100644 --- a/Source/System/PathFinder.cpp +++ b/Source/System/PathFinder.cpp @@ -4,7 +4,6 @@ #include "Scene.h" #include "SceneMan.h" #include "ThreadMan.h" -#include "ConsoleMan.h" #include "tracy/Tracy.hpp" @@ -259,14 +258,14 @@ void PathFinder::RecalculateAllCosts() { // I hate this copy, but fuck it. std::vector pathNodesIdsVec; pathNodesIdsVec.reserve(m_NodeGrid.size()); - for (int i = 0; i < m_NodeGrid.size(); ++i) { + for (size_t i = 0; i < m_NodeGrid.size(); ++i) { pathNodesIdsVec.push_back(i); } UpdateNodeList(pathNodesIdsVec); } -std::vector PathFinder::RecalculateAreaCosts(std::deque& boxList, int nodeUpdateLimit) { +std::vector PathFinder::RecalculateAreaCosts(std::deque& boxList, size_t nodeUpdateLimit) { ZoneScoped; std::unordered_set nodeIDsToUpdate; @@ -611,7 +610,7 @@ void PathFinder::MarkBoxNavigable(Box box, bool navigable) { void PathFinder::MarkAllNodesNavigable(bool navigable) { std::vector pathNodesIdsVec; pathNodesIdsVec.reserve(m_NodeGrid.size()); - for (int i = 0; i < m_NodeGrid.size(); ++i) { + for (size_t i = 0; i < m_NodeGrid.size(); ++i) { pathNodesIdsVec.push_back(i); } @@ -648,7 +647,7 @@ int PathFinder::ConvertCoordsToNodeId(int x, int y) const { return (y * m_GridWidth) + x; } -void PathFinder::DebugRender(BITMAP* targetBitmap, const Vector& targetPos, int whichScreen) const { +void PathFinder::DebugRender(BITMAP* targetBitmap, const Vector& targetPos) const { for (int x = 0; x < m_GridWidth; ++x) { Vector startPos = (m_NodeGrid[ConvertCoordsToNodeId(x, 0)].Pos - m_Offset) - targetPos; Vector endPos = startPos + Vector(0.0F, m_NodeDimension * m_GridHeight); diff --git a/Source/System/PathFinder.h b/Source/System/PathFinder.h index 008bd1add4..13adbae122 100644 --- a/Source/System/PathFinder.h +++ b/Source/System/PathFinder.h @@ -127,7 +127,7 @@ namespace RTE { /// @param boxList The deque of Boxes representing the updated areas. /// @param nodeUpdateLimit The maximum number of PathNodes we'll try to update this frame. True PathNode update count can be higher if we received a big box, as we always do at least 1 box. /// @return The set of PathNode ids that were updated. - std::vector RecalculateAreaCosts(std::deque& boxList, int nodeUpdateLimit); + std::vector RecalculateAreaCosts(std::deque& boxList, size_t nodeUpdateLimit); /// Updates a set of PathNodes, adjusting their transitions. /// This does NOT update the pather, which is required if PathNode costs changed. @@ -173,8 +173,8 @@ namespace RTE { /// Draws a debug rendering for this pathfinder to a BITMAP of choice. /// @param targetBitmap A pointer to a BITMAP to draw on. - /// @param targetGUIBitmap The offset into the scene where the target bitmap's upper left corner is located. - void DebugRender(BITMAP* targetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0) const; + /// @param targetPos The offset into the scene where the target bitmap's upper left corner is located. + void DebugRender(BITMAP* targetBitmap, const Vector& targetPos = Vector()) const; #pragma endregion private: diff --git a/Source/System/Reader.h b/Source/System/Reader.h index 9159c3e0f3..3bf4b6f016 100644 --- a/Source/System/Reader.h +++ b/Source/System/Reader.h @@ -185,6 +185,16 @@ namespace RTE { *m_Stream >> var; return *this; } + Reader& operator>>(long long& var) { + DiscardEmptySpace(); + *m_Stream >> var; + return *this; + } + Reader& operator>>(unsigned long long& var) { + DiscardEmptySpace(); + *m_Stream >> var; + return *this; + } // Yeah, this is dumb - read as double and cast. // This is because, for whatever fucking reason, iostream can save out floats at a precision that it's then unable to read... Reader& operator>>(float& var) { diff --git a/Source/System/Serializable.h b/Source/System/Serializable.h index ffc782c5f1..7af59c409e 100644 --- a/Source/System/Serializable.h +++ b/Source/System/Serializable.h @@ -3,9 +3,7 @@ #include "Reader.h" #include "Writer.h" -#include #include -#include #include namespace RTE { diff --git a/Source/System/Timer.h b/Source/System/Timer.h index 86b8ebbbd8..cac289e3e2 100644 --- a/Source/System/Timer.h +++ b/Source/System/Timer.h @@ -39,6 +39,15 @@ namespace RTE { Create(reference); } + /// Copy assignment operator for Timers. + /// @param rhs A Timer reference. + /// @return A reference to the changed Timer. + inline Timer& operator=(const Timer& rhs) { + Clear(); + Create(rhs); + return *this; + } + /// Makes the Timer object ready for use. /// @return An error return value signaling success or any particular failure. Anything below 0 is an error signal. int Create(); diff --git a/Source/System/Vector.h b/Source/System/Vector.h index cf8d40e7d0..1c7fa28916 100644 --- a/Source/System/Vector.h +++ b/Source/System/Vector.h @@ -31,6 +31,14 @@ namespace RTE { /// @param inputY Float defining the initial Y value of this Vector. inline Vector(const float inputX, const float inputY) : m_X(inputX), m_Y(inputY){}; + + /// Copy constructor method used to instantiate a Vector object + /// identical to an already existing one. + /// @param reference A Vector object which is passed in by reference. + Vector(const Vector& reference) { + m_X = reference.m_X; + m_Y = reference.m_Y; + } #pragma endregion #pragma region Destruction