Skip to content

Commit c5a5671

Browse files
committed
Make Set, GetForce* take uint, fix other sign compare issues
1 parent 4a2eb3b commit c5a5671

File tree

6 files changed

+34
-34
lines changed

6 files changed

+34
-34
lines changed

Source/Activities/GATutorial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ namespace RTE {
186186
// If teh screen has just changed and needs to be redrawn
187187
bool m_ScreenChange;
188188
// Which tutorial step of the current area currently being played back
189-
int m_CurrentStep;
189+
unsigned int m_CurrentStep;
190190
// Which frame of the current step's animation are we on?
191191
int m_CurrentFrame;
192192
// Current room
193193
TutorialRoom m_CurrentRoom;
194194
// Trigger box for the subsequent fight
195195
Box m_FightTriggers[FIGHTSTAGECOUNT];
196-
int m_EnemyCount; //!< The amount of enemy actors at the start of the activity.
196+
unsigned int m_EnemyCount; //!< The amount of enemy actors at the start of the activity.
197197
// The current fight stage
198198
FightStage m_CurrentFightStage;
199199
// The CPU opponent brain; not owned!

Source/Entities/LimbPath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ namespace RTE {
375375
// The iterator to the segment of the path that the limb ended up on the end of
376376
std::deque<Vector>::iterator m_CurrentSegment;
377377

378-
int m_FootCollisionsDisabledSegment; //!< The segment after which foot collisions will be disabled for this limbpath, if it's for legs.
378+
unsigned int m_FootCollisionsDisabledSegment; //!< The segment after which foot collisions will be disabled for this limbpath, if it's for legs.
379379

380380
// Normalized measure of how far the limb has progressed toward the
381381
// current segment's target. 0.0 means its farther away than the

Source/Entities/MovableObject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ namespace RTE {
719719
/// Returns force vector in newtons of the specified Force record.
720720
/// @param n Force record index to get data from.
721721
/// @return Force vector in newtons of the specified Force record.
722-
Vector GetForceVector(int n) {
722+
Vector GetForceVector(unsigned int n) {
723723
if (n > 0 && n < m_Forces.size())
724724
return m_Forces[n].first;
725725
else
@@ -733,7 +733,7 @@ namespace RTE {
733733
/// Returns offset vector in METERS (not pixels) of the specified Force record.
734734
/// @param n Force record index to get data from.
735735
/// @return Offset vector in meters of the specified Force record.
736-
Vector GetForceOffset(int n) {
736+
Vector GetForceOffset(unsigned int n) {
737737
if (n > 0 && n < m_Forces.size())
738738
return m_Forces[n].second;
739739
else
@@ -742,14 +742,14 @@ namespace RTE {
742742

743743
/// Sets force vector in newtons of the specified Force record.
744744
/// @param n Force record index to get data from. New Vector force value in newtons.
745-
void SetForceVector(int n, Vector v) {
745+
void SetForceVector(unsigned int n, Vector v) {
746746
if (n > 0 && n < m_Forces.size())
747747
m_Forces[n].first = v;
748748
}
749749

750750
/// Sets offset vector in METERS (not pixels) of the specified Force record.
751751
/// @param n Force record index to get data from. New Vector offset value in meters.
752-
void SetForceOffset(int n, Vector v) {
752+
void SetForceOffset(unsigned int n, Vector v) {
753753
if (n > 0 && n < m_Forces.size())
754754
m_Forces[n].second = v;
755755
}

Source/Managers/MetaMan.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ namespace RTE {
145145
/// Gets the designated team of a specific player
146146
/// @param metaPlayer Which player.
147147
/// @return The team of that player.
148-
int GetTeamOfPlayer(int metaPlayer) const { return metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size() ? m_Players[metaPlayer].GetTeam() : Activity::NoTeam; }
148+
int GetTeamOfPlayer(int metaPlayer) const { return metaPlayer >= Players::PlayerOne && metaPlayer < static_cast<int>(m_Players.size()) ? m_Players[metaPlayer].GetTeam() : Activity::NoTeam; }
149149

150150
/// Gets the specified MetaPlayer
151151
/// @param metaPlayer Which player.
152152
/// @return The requested MetaPlayer
153-
MetaPlayer* GetPlayer(int metaPlayer) { return (metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size()) ? &(m_Players[metaPlayer]) : 0; }
153+
MetaPlayer* GetPlayer(int metaPlayer) { return (metaPlayer >= Players::PlayerOne && metaPlayer < static_cast<int>(m_Players.size())) ? &(m_Players[metaPlayer]) : nullptr; }
154154

155155
/// Gets the MetaPlayer playing a specific in-game player, if any.
156156
/// @param inGamePlayer Which in-game player to translate into a metaplayer.
@@ -247,7 +247,7 @@ namespace RTE {
247247

248248
/// Checks wheter a certain player index is valid for the current game
249249
/// @return Whether the player index passed in is active for the current game.
250-
bool IsActivePlayer(int metaPlayer) { return metaPlayer >= Players::PlayerOne && metaPlayer < m_Players.size(); }
250+
bool IsActivePlayer(int metaPlayer) { return metaPlayer >= Players::PlayerOne && metaPlayer < static_cast<int>(m_Players.size()); }
251251

252252
/// Checks wheter a certain team index is valid for the current game
253253
/// @return Whether the team index passed in is active for the current game.
@@ -332,7 +332,7 @@ namespace RTE {
332332
// The Activities generated by the current round's offensive maneuvers
333333
std::vector<GAScripted*> m_RoundOffensives;
334334
// The current offensive action that we're about to play next
335-
int m_CurrentOffensive;
335+
unsigned int m_CurrentOffensive;
336336
// Game difficulty
337337
int m_Difficulty;
338338
// Teams AI Skill

Source/Menus/MetagameGUI.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ bool MetagameGUI::LoadGame() {
10421042
UpdateScenesBox(true);
10431043

10441044
// Make sure GUI boxes are on the screen; save game might have been made on wonky resolution
1045-
for (int metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer)
1045+
for (unsigned int metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer)
10461046
KeepBoxOnScreen(m_apPlayerBox[metaPlayer], 30);
10471047
KeepBoxOnScreen(m_pPhaseBox, 30);
10481048
KeepBoxOnScreen(m_pSceneInfoPopup, 30);
@@ -1617,7 +1617,7 @@ void MetagameGUI::Update() {
16171617
UpdateScenesBox();
16181618

16191619
// Update the site lines, if neccessary
1620-
for (int metaPlayer = 0; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) {
1620+
for (unsigned int metaPlayer = 0; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) {
16211621
// The tradestar is a moving target
16221622
if (m_aStationIncomeLineIndices[metaPlayer] >= 0 && !m_IncomeSiteLines.empty())
16231623
m_IncomeSiteLines[m_aStationIncomeLineIndices[metaPlayer]].m_PlanetPoint = m_StationPosOnOrbit;
@@ -2161,7 +2161,7 @@ void MetagameGUI::UpdateInput() {
21612161
// Add the players who own this place, if any - their actors and brains are in the scene and should be shown
21622162
if (g_MetaMan.IsActiveTeam(m_pSelectedScene->GetTeamOwnership())) {
21632163
// Go through all players and add the ones of the defending team, based on who has resident brains here
2164-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
2164+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
21652165
// Got to remember to translate from metagame player index into the in-game player index and to flag them as not a human so they dont' get their own screens
21662166
// if (g_MetaMan.m_Players[mp].GetTeam() == m_pSelectedScene->GetTeamOwnership())
21672167
if (m_pSelectedScene->GetResidentBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()))
@@ -3585,7 +3585,7 @@ void MetagameGUI::UpdateBaseBuilding() {
35853585

35863586
// Make sure all fund labels and line ratios are good
35873587
Scene* pScene = 0;
3588-
for (int metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) {
3588+
for (unsigned int metaPlayer = Players::PlayerOne; metaPlayer < g_MetaMan.m_Players.size(); ++metaPlayer) {
35893589
// Reset the funds to the full value before we started messing with animating them
35903590
g_MetaMan.m_Players[metaPlayer].m_Funds = g_MetaMan.m_Players[metaPlayer].m_PhaseStartFunds;
35913591

@@ -3676,7 +3676,7 @@ void MetagameGUI::SetupOffensives() {
36763676
// Unless exploring an unclaimed spot, there's going to be defenders
36773677
if ((*sItr)->GetTeamOwnership() != Activity::NoTeam) {
36783678
// Go through all players and add the ones of the defending team, based on who has resident brains here
3679-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3679+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
36803680
// Got to remember to translate from metagame player index into the in-game player index
36813681
// TODO: Remove this requirement to have a brain resident to play? error-prone and not so fun for co-op player on sme team if they can't all play
36823682
// if (g_MetaMan.m_Players[mp].GetTeam() == (*sItr)->GetTeamOwnership())
@@ -3774,7 +3774,7 @@ void MetagameGUI::UpdateOffensives() {
37743774
m_AnimDefenseTeam = m_pAnimScene->GetTeamOwnership();
37753775

37763776
// Set up all the offensive and defensive lines for each player involved in this site's battle
3777-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3777+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
37783778
// If this player is involved in this fight, show his lines etc
37793779
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
37803780
// Save the fund levels FROM THE START of each battle so we can calculate the after state if players skip the animation
@@ -3890,7 +3890,7 @@ void MetagameGUI::UpdateOffensives() {
38903890
if (m_AnimMode == LINECONNECTFW) {
38913891
if (NewAnimMode()) {
38923892
// Make sure all offensive action lines are set up for this phase
3893-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3893+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
38943894
// Find all players that are active during this battle
38953895
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
38963896
// If this player is attacking, indicate that we've got a brain in transit.. this just changes the display, not the actual brain pool count yet
@@ -3920,7 +3920,7 @@ void MetagameGUI::UpdateOffensives() {
39203920
// Keep revealing segments simultaneously from all attackers until they are all revealed
39213921
if (m_AnimSegment < 15) {
39223922
if (m_AnimTimer1.GetElapsedRealTimeMS() > 150) {
3923-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3923+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
39243924
// Only care if this player is attacking this site
39253925
if (m_pAnimScene->GetPresetName() == g_MetaMan.m_Players[mp].GetOffensiveTargetName() && g_MetaMan.m_Players[mp].GetOffensiveBudget() > 0)
39263926
// if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer()))
@@ -3962,7 +3962,7 @@ void MetagameGUI::UpdateOffensives() {
39623962
if (m_AnimMode == SHOWDEFENDERS) {
39633963
if (NewAnimMode()) {
39643964
// Make sure all defensive and unallocated budget action lines are set up for this phase
3965-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3965+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
39663966
}
39673967

39683968
m_AnimModeDuration = 500;
@@ -3996,7 +3996,7 @@ void MetagameGUI::UpdateOffensives() {
39963996
if (m_AnimMode == LINECONNECTBW) {
39973997
if (NewAnimMode()) {
39983998
// Make sure all defensive and unallocated budget action lines are set up for this phase
3999-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
3999+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
40004000
// Only care of this player is involved in this particular battle
40014001
// Only care about defending players of this site
40024002
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer()) &&
@@ -4025,7 +4025,7 @@ void MetagameGUI::UpdateOffensives() {
40254025
// Keep revealing segments simultaneously from all attackers until they are all revealed
40264026
if (m_AnimSegment < 15) {
40274027
if (m_AnimTimer1.GetElapsedRealTimeMS() > 150) {
4028-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4028+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
40294029
// Only care of this player is involved in this particular battle
40304030
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
40314031
// Find their defensive-related funds site lines
@@ -4094,7 +4094,7 @@ void MetagameGUI::UpdateOffensives() {
40944094
m_AnimModeDuration = 2000;
40954095

40964096
// Make sure all offensive action-related lines are set up for this battle review animation
4097-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4097+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
40984098
// Only the players of this battle
40994099
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
41004100
// Find their site lines that are connected to the site
@@ -4122,7 +4122,7 @@ void MetagameGUI::UpdateOffensives() {
41224122
}
41234123

41244124
// Find the players who are involved in this battle
4125-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4125+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
41264126
// Only the players of this battle
41274127
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
41284128
// The brains who DID NOT MAKE IT - Show them blowing up at some random interval into the animation
@@ -4181,7 +4181,7 @@ void MetagameGUI::UpdateOffensives() {
41814181
if (m_AnimTimer2.GetElapsedRealTimeMS() > m_AnimModeDuration) {
41824182
// Blow up any remaining brains who are doomed
41834183
// Find the players who are involved in this battle
4184-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4184+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
41854185
// Only the players of this battle who didn't evacuate
41864186
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer()) &&
41874187
!g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
@@ -4206,7 +4206,7 @@ void MetagameGUI::UpdateOffensives() {
42064206
if (m_AnimMode == SHOWPOSTBATTLEBRAINS) {
42074207
if (NewAnimMode()) {
42084208
// Make sure all defensive and unallocated budget action lines are set up for this phase
4209-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4209+
for (unsigned mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
42104210
}
42114211

42124212
// The duration of this depends on whethere there are any evacuees to travel back
@@ -4235,7 +4235,7 @@ void MetagameGUI::UpdateOffensives() {
42354235
// Change the display to show the evacuees transferring back to their brain pools
42364236
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->AnyBrainWasEvacuated()) {
42374237
// Find the players who are evacuated anything this battle
4238-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4238+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
42394239
// Only the players of this battle who evac'd their brain
42404240
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->BrainWasEvacuated(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
42414241
// Both an Attacker aborting an attack, and a Defender abandoning his site has the same effect here on the brian pool display
@@ -4253,7 +4253,7 @@ void MetagameGUI::UpdateOffensives() {
42534253
if (m_AnimMode == SHOWNEWRESIDENTS) {
42544254
if (NewAnimMode()) {
42554255
// Make sure all defensive and unallocated budget action lines are set up for this phase
4256-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4256+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
42574257
}
42584258

42594259
m_AnimModeDuration = m_BattleCausedOwnershipChange ? 500 : 750;
@@ -4275,7 +4275,7 @@ void MetagameGUI::UpdateOffensives() {
42754275
UpdatePostBattleResidents(EaseOut(0, 1.0, MIN(1.0, m_AnimTimer2.GetElapsedRealTimeMS() / m_AnimModeDuration)));
42764276

42774277
// Find the players who are involved in this battle
4278-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4278+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
42794279
// Only the players of this battle
42804280
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
42814281
// The guys who died - remove their icons completely
@@ -4303,7 +4303,7 @@ void MetagameGUI::UpdateOffensives() {
43034303
UpdateSiteNameLabel(false);
43044304

43054305
// Max out the offensive lines in case the player started the battle before the lines were fully animated as connected
4306-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4306+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
43074307
// Only care of this player is involved in this particular battle
43084308
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerActive(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
43094309
for (std::vector<SiteLine>::iterator slItr = m_ActionSiteLines[mp].begin(); slItr != m_ActionSiteLines[mp].end(); ++slItr) {
@@ -4378,7 +4378,7 @@ bool MetagameGUI::FinalizeOffensive() {
43784378
}
43794379

43804380
// Deduct the original funds contribution of each player - less any unused funds of the team, taking original player contribution ratios into account
4381-
for (int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
4381+
for (unsigned int mp = Players::PlayerOne; mp < g_MetaMan.m_Players.size(); ++mp) {
43824382
// Only the players who were battling this offensive
43834383
if (g_MetaMan.m_RoundOffensives[g_MetaMan.m_CurrentOffensive]->PlayerHadBrain(g_MetaMan.m_Players[mp].GetInGamePlayer())) {
43844384
// Re-set the funds level to where it was at the start of this offensive (NOT at the start of the phase, actually)
@@ -5667,7 +5667,7 @@ float MetagameGUI::GetPlayerLineFunds(std::vector<SiteLine>& lineList, int metaP
56675667
return totalFunds;
56685668
}
56695669

5670-
void MetagameGUI::UpdatePlayerLineRatios(std::vector<SiteLine>& lineList, int metaPlayer, bool onlyVisible, float total) {
5670+
void MetagameGUI::UpdatePlayerLineRatios(std::vector<SiteLine>& lineList, unsigned int metaPlayer, bool onlyVisible, float total) {
56715671
if (metaPlayer < Players::PlayerOne || metaPlayer >= g_MetaMan.m_Players.size())
56725672
return;
56735673

Source/Menus/MetagameGUI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ namespace RTE {
460460
/// @param onlyVisible Whetehr to only care about visible lines. (default: true)
461461
/// @param total The total funds to be calculating the ratios against. If negative, (default: -1)
462462
/// the total line amounts is what will be used.
463-
void UpdatePlayerLineRatios(std::vector<SiteLine>& lineList, int player, bool onlyVisible = true, float total = -1);
463+
void UpdatePlayerLineRatios(std::vector<SiteLine>& lineList, unsigned int player, bool onlyVisible = true, float total = -1);
464464

465465
/// Draws a fancy thick flickering line to point out scene points on the
466466
/// planet.
@@ -637,7 +637,7 @@ namespace RTE {
637637
float m_AnimFundsMax;
638638
float m_AnimFundsMin;
639639
int m_AnimBuildCount;
640-
int m_AnimIncomeLine;
640+
unsigned int m_AnimIncomeLine;
641641
bool m_AnimIncomeLineChange;
642642
int m_AnimActionLine;
643643
bool m_AnimActionLineChange;

0 commit comments

Comments
 (0)