From 64ee4a54f4730cdf777d75694ab48280f543ac88 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 8 Dec 2011 18:12:44 +0000 Subject: More scoping fixes --- Stars45/CampaignMissionStarship.cpp | 6 +++--- Stars45/CampaignSaveGame.cpp | 2 +- Stars45/CarrierAI.cpp | 2 +- Stars45/CmdIntelDlg.cpp | 10 +++++----- Stars45/CmdMissionsDlg.cpp | 2 +- Stars45/CmdTheaterDlg.cpp | 2 +- Stars45/CombatGroup.cpp | 2 +- Stars45/EngDlg.cpp | 2 +- Stars45/FlightDeck.cpp | 8 ++++---- Stars45/FltDlg.cpp | 15 ++++++++------- Stars45/Grid.cpp | 2 +- Stars45/HUDView.cpp | 21 ++++++++++---------- Stars45/Hangar.cpp | 2 +- Stars45/Hoop.cpp | 2 +- Stars45/JoyDlg.cpp | 2 +- Stars45/LandingGear.cpp | 3 ++- Stars45/MapView.cpp | 8 ++++---- Stars45/Mfd.cpp | 3 ++- Stars45/Mission.cpp | 4 ++-- Stars45/MissionTemplate.cpp | 2 +- Stars45/MsnWepDlg.cpp | 6 +++--- Stars45/NetData.cpp | 14 +++++++------- Stars45/NetGame.cpp | 2 +- Stars45/NetGameClient.cpp | 2 +- Stars45/NetGameServer.cpp | 2 +- Stars45/Player.cpp | 2 +- Stars45/PlayerDlg.cpp | 10 +++++----- Stars45/RadioView.cpp | 6 +++--- Stars45/ShieldRep.cpp | 2 +- Stars45/Ship.cpp | 38 ++++++++++++++++++------------------- Stars45/ShipDesign.cpp | 20 +++++++++---------- Stars45/ShipKiller.cpp | 2 +- Stars45/Sim.cpp | 6 +++--- Stars45/StarSystem.cpp | 2 +- Stars45/Stars.vcxproj | 5 +++++ Stars45/TerrainApron.cpp | 2 +- Stars45/TerrainPatch.cpp | 6 +++--- Stars45/TerrainRegion.cpp | 14 +++++++------- Stars45/Trail.cpp | 2 +- Stars45/VidDlg.cpp | 6 +++--- Stars45/WeaponDesign.cpp | 4 ++-- Stars45/Weather.cpp | 4 ++-- 42 files changed, 133 insertions(+), 124 deletions(-) diff --git a/Stars45/CampaignMissionStarship.cpp b/Stars45/CampaignMissionStarship.cpp index f0c935f..184ad00 100644 --- a/Stars45/CampaignMissionStarship.cpp +++ b/Stars45/CampaignMissionStarship.cpp @@ -550,7 +550,7 @@ CampaignMissionStarship::CreateSingleElement(CombatGroup* g, CombatUnit* u) elem->AddObjective(obj); } } - else if (u->Type() & Ship::STARSHIPS != 0) { + else if ((u->Type() & Ship::STARSHIPS) != 0) { elem->SetMissionRole(Mission::FLEET); } @@ -834,7 +834,7 @@ CampaignMissionStarship::CreateTargetsAssault() player_lead->AddNavPoint(instr); - for (i = 1; i < player_group_elements.size(); i++) { + for (int i = 1; i < player_group_elements.size(); i++) { MissionElement* pge = player_group_elements[i]; RLoc rloc2; @@ -921,7 +921,7 @@ CampaignMissionStarship::CreateTargetsPatrol() if (n) player->AddNavPoint(n); - for (i = 1; i < player_group_elements.size(); i++) { + for (int i = 1; i < player_group_elements.size(); i++) { MissionElement* elem = player_group_elements[i]; n = new(__FILE__,__LINE__) Instruction(region, diff --git a/Stars45/CampaignSaveGame.cpp b/Stars45/CampaignSaveGame.cpp index 5584f8f..0278573 100644 --- a/Stars45/CampaignSaveGame.cpp +++ b/Stars45/CampaignSaveGame.cpp @@ -528,7 +528,7 @@ CampaignSaveGame::Load(const char* filename) } // if no next campaign found, start over from the beginning: - for (i = 0; i < list.size() && !found; i++) { + for (int i = 0; i < list.size() && !found; i++) { Campaign* c = list.at(i); if (c->IsDynamic()) { diff --git a/Stars45/CarrierAI.cpp b/Stars45/CarrierAI.cpp index 8f584b9..ffd6ea0 100644 --- a/Stars45/CarrierAI.cpp +++ b/Stars45/CarrierAI.cpp @@ -348,7 +348,7 @@ CarrierAI::CreatePackage(int squadron, int size, int code, const char* target, c int npackage = 0; int slots[4]; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) slots[i] = -1; for (int slot = 0; slot < hangar->SquadronSize(squadron); slot++) { diff --git a/Stars45/CmdIntelDlg.cpp b/Stars45/CmdIntelDlg.cpp index a08e816..67e5424 100644 --- a/Stars45/CmdIntelDlg.cpp +++ b/Stars45/CmdIntelDlg.cpp @@ -186,14 +186,14 @@ CmdIntelDlg::ExecFrame() CombatEvent* info = events[i]; const char* unread = info->Visited() ? " " : "*"; - int i = lst_news->AddItemWithData(unread, (DWORD) info) - 1; + int j = lst_news->AddItemWithData(unread, (DWORD) info) - 1; char dateline[32]; FormatDayTime(dateline, info->Time()); - lst_news->SetItemText(i, 1, dateline); - lst_news->SetItemText(i, 2, info->Title()); - lst_news->SetItemText(i, 3, info->Region()); - lst_news->SetItemText(i, 4, Game::GetText(info->SourceName())); + lst_news->SetItemText(j, 1, dateline); + lst_news->SetItemText(j, 2, info->Title()); + lst_news->SetItemText(j, 3, info->Region()); + lst_news->SetItemText(j, 4, Game::GetText(info->SourceName())); if (!info->Visited()) auto_scroll = true; diff --git a/Stars45/CmdMissionsDlg.cpp b/Stars45/CmdMissionsDlg.cpp index 2df5ebd..0295d68 100644 --- a/Stars45/CmdMissionsDlg.cpp +++ b/Stars45/CmdMissionsDlg.cpp @@ -207,7 +207,7 @@ CmdMissionsDlg::ExecFrame() lst_missions->ClearItems(); seln = -1; - for (i = 0; i < missions.size(); i++) { + for (int i = 0; i < missions.size(); i++) { MissionInfo* info = missions[i]; lst_missions->AddItemWithData(info->name, info->id); diff --git a/Stars45/CmdTheaterDlg.cpp b/Stars45/CmdTheaterDlg.cpp index 74d351d..8b1f087 100644 --- a/Stars45/CmdTheaterDlg.cpp +++ b/Stars45/CmdTheaterDlg.cpp @@ -98,7 +98,7 @@ CmdTheaterDlg::RegisterControls() if (map_theater) map_view = new(__FILE__,__LINE__) MapView(map_theater); - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { view_btn[i] = (Button*) FindControl(401 + i); REGISTER_CLIENT(EID_CLICK, view_btn[i], CmdTheaterDlg, OnView); } diff --git a/Stars45/CombatGroup.cpp b/Stars45/CombatGroup.cpp index 2e8e270..c18f13e 100644 --- a/Stars45/CombatGroup.cpp +++ b/Stars45/CombatGroup.cpp @@ -401,7 +401,7 @@ CombatGroup::Clone(bool deep) } if (deep) { - for (i = 0; i < components.size(); i++) { + for (int i = 0; i < components.size(); i++) { CombatGroup* g = components[i]->Clone(deep); clone->AddComponent(g); diff --git a/Stars45/EngDlg.cpp b/Stars45/EngDlg.cpp index 9af1fce..810f29a 100644 --- a/Stars45/EngDlg.cpp +++ b/Stars45/EngDlg.cpp @@ -634,7 +634,7 @@ EngDlg::OnSource(AWEvent* event) selected_source = ship->Reactors()[source_index]; } - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { clients[i]->ClearSelection(); } diff --git a/Stars45/FlightDeck.cpp b/Stars45/FlightDeck.cpp index fe1f5db..4048923 100644 --- a/Stars45/FlightDeck.cpp +++ b/Stars45/FlightDeck.cpp @@ -212,10 +212,10 @@ FlightDeck::FlightDeck(const FlightDeck& s) slots[i].filter = s.slots[i].filter; } - for (i = 0; i < NUM_APPROACH_PTS; i++) + for (int i = 0; i < NUM_APPROACH_PTS; i++) approach_rel[i] = s.approach_rel[i]; - for (i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) runway_rel[i] = s.runway_rel[i]; if (s.light) { @@ -510,7 +510,7 @@ FlightDeck::ExecFrame(double seconds) } if (advance_queue) { - for (i = 0; i < num_slots; i++) { + for (int i = 0; i < num_slots; i++) { FlightDeckSlot* slot = &slots[i]; if (slot->state == QUEUED && slot->sequence > 1) slot->sequence--; @@ -688,7 +688,7 @@ FlightDeck::Orient(const Physical* rep) for (int i = 0; i < num_approach_pts; i++) approach_point[i] = (approach_rel[i] * orientation) + loc; - for (i = 0; i < num_slots; i++) + for (int i = 0; i < num_slots; i++) slots[i].spot_loc = (slots[i].spot_rel * orientation) + loc; if (IsRecoveryDeck()) { diff --git a/Stars45/FltDlg.cpp b/Stars45/FltDlg.cpp index 6a89b86..874d825 100644 --- a/Stars45/FltDlg.cpp +++ b/Stars45/FltDlg.cpp @@ -185,12 +185,13 @@ FltDlg::UpdateSelection() Hangar* hangar = ship->GetHangar(); int seln = filter_list->GetSelectedIndex(); char txt[32]; + int item; // selected squadron: if (seln < hangar->NumSquadrons()) { int nslots = hangar->SquadronSize(seln); - for (int item = 0; item < hangar_list->NumItems(); item++) { + for (item = 0; item < hangar_list->NumItems(); item++) { int i = hangar_list->GetItemData(item); const HangarSlot* s = hangar->GetSlot(seln, i); @@ -253,7 +254,7 @@ FltDlg::UpdateSelection() // selected pending filter: else if (seln == hangar->NumSquadrons()) { - for (int item = 0; item < hangar_list->NumItems(); item++) { + for (item = 0; item < hangar_list->NumItems(); item++) { int f = hangar_list->GetItemData(item, 1); int i = hangar_list->GetItemData(item, 2); @@ -316,7 +317,7 @@ FltDlg::UpdateSelection() else if (seln == hangar->NumSquadrons()+1) { int last_index = -1; - for (int item = 0; item < hangar_list->NumItems(); item++) { + for (item = 0; item < hangar_list->NumItems(); item++) { int squadron = hangar_list->GetItemData(item, 1); int slot = hangar_list->GetItemData(item, 2); @@ -717,10 +718,10 @@ FltDlg::OnPackage(AWEvent* event) int npackage = 0; int slots[4]; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) slots[i] = -1; - for (i = 0; i < hangar_list->NumItems(); i++) { + for (int i = 0; i < hangar_list->NumItems(); i++) { if (hangar_list->IsSelected(i)) { int nslot = hangar_list->GetItemData(i); hangar->GotoAlert(squad, nslot, deck, elem, load, true); @@ -799,10 +800,10 @@ FltDlg::OnAlert(AWEvent* event) int nalert = 0; int slots[4]; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) slots[i] = -1; - for (i = 0; i < hangar_list->NumItems(); i++) { + for (int i = 0; i < hangar_list->NumItems(); i++) { if (hangar_list->IsSelected(i)) { int nslot = hangar_list->GetItemData(i); slots[nalert] = nslot; diff --git a/Stars45/Grid.cpp b/Stars45/Grid.cpp index b4b75c9..3101e0f 100644 --- a/Stars45/Grid.cpp +++ b/Stars45/Grid.cpp @@ -64,7 +64,7 @@ void Grid::Render(Video* video, DWORD flags) c = 0; - for (i = 0; i <= size; i += step) { + for (int i = 0; i <= size; i += step) { Point p1(-size, 0, i); p1 += Location(); Point p2( size, 0, i); p2 += Location(); Point p3(-size, 0, -i); p3 += Location(); diff --git a/Stars45/HUDView.cpp b/Stars45/HUDView.cpp index 486ec19..cf035a2 100644 --- a/Stars45/HUDView.cpp +++ b/Stars45/HUDView.cpp @@ -255,7 +255,8 @@ HUDView::DrawHUDText(int index, const char* txt, Rect& rect, int align, int upca if (n > 250) n = 250; - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { if (upcase && islower(txt[i])) txt_buf[i] = toupper(txt[i]); else @@ -635,7 +636,7 @@ HUDView::~HUDView() mfd[i] = 0; } - for (i = 0; i < 32; i++) { + for (int i = 0; i < 32; i++) { GRAPHIC_DESTROY(hud_sprite[i]); } @@ -1705,7 +1706,7 @@ HUDView::DrawPitchLadder() pitch_ladder[15]->SetAngle(roll_angle); } - for (i = 1; i <= 15; i++) { + for (int i = 1; i <= 15; i++) { double angle = i * 5 * DEGREES; if (i > 12) @@ -2881,7 +2882,7 @@ HUDView::DrawMessages() if (!message_queue_empty) { // advance message pipeline: - for (i = 0; i < MAX_MSG; i++) { + for (int i = 0; i < MAX_MSG; i++) { if (msg_time[0] == 0) { for (int j = 0; j < MAX_MSG-1; j++) { msg_time[j] = msg_time[j+1]; @@ -2894,7 +2895,7 @@ HUDView::DrawMessages() } // draw messages: - for (i = 0; i < MAX_MSG; i++) { + for (int i = 0; i < MAX_MSG; i++) { int index = TXT_MSG_1 + i; if (msg_time[i] > 0) { @@ -3473,7 +3474,7 @@ HUDView::Refresh() Video* video = Video::GetInstance(); - for (i = 0; i < 31; i++) { + for (int i = 0; i < 31; i++) { Sprite* s = pitch_ladder[i]; if (s && !s->Hidden()) { @@ -3779,7 +3780,7 @@ HUDView::ExecFrame() for (int i = 0; i < 3; i++) mfd[i]->Hide(); - for (i = 0; i < 31; i++) + for (int i = 0; i < 31; i++) pitch_ladder[i]->Hide(); DrawILS(); @@ -3974,7 +3975,7 @@ HUDView::HideAll() sim->ShowGrid(false); - for (i = 0; i < 31; i++) + for (int i = 0; i < 31; i++) pitch_ladder[i]->Hide(); if (missile_lock_sound) @@ -4067,7 +4068,7 @@ HUDView::SetHUDColorSet(int c) if (font) font->SetColor(txt_color); - for (i = 0; i < TXT_LAST; i++) + for (int i = 0; i < TXT_LAST; i++) hud_text[i].color = txt_color; } @@ -4098,7 +4099,7 @@ HUDView::Message(const char* fmt, ...) // no space; advance pipeline: if (index < 0) { - for (i = 0; i < MAX_MSG-1; i++) { + for (int i = 0; i < MAX_MSG-1; i++) { hud_view->msg_text[i] = hud_view->msg_text[i+1]; hud_view->msg_time[i] = hud_view->msg_time[i+1]; } diff --git a/Stars45/Hangar.cpp b/Stars45/Hangar.cpp index f1e8019..843105c 100644 --- a/Stars45/Hangar.cpp +++ b/Stars45/Hangar.cpp @@ -312,7 +312,7 @@ Hangar::CreateSquadron(Text squadron, CombatGroup* group, nslots[nsquadrons] = count; names[nsquadrons] = squadron; - i = count-1; + int i = count-1; while (dead_count-- > 0) s[i--].state = UNAVAIL; diff --git a/Stars45/Hoop.cpp b/Stars45/Hoop.cpp index 176ba46..2e3be3e 100644 --- a/Stars45/Hoop.cpp +++ b/Stars45/Hoop.cpp @@ -99,7 +99,7 @@ Hoop::CreatePolys() vset->tv[i] = v; } - for (i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { Poly& poly = polys[i]; poly.nverts = 4; diff --git a/Stars45/JoyDlg.cpp b/Stars45/JoyDlg.cpp index 6581c94..0815690 100644 --- a/Stars45/JoyDlg.cpp +++ b/Stars45/JoyDlg.cpp @@ -186,7 +186,7 @@ JoyDlg::OnAxis(AWEvent* event) } } - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { samples[i] = 10000000; } } diff --git a/Stars45/LandingGear.cpp b/Stars45/LandingGear.cpp index 61135ed..2f04575 100644 --- a/Stars45/LandingGear.cpp +++ b/Stars45/LandingGear.cpp @@ -48,8 +48,9 @@ LandingGear::LandingGear(const LandingGear& g) { Mount(g); SetAbbreviation(g.Abbreviation()); + int i; - for (int i = 0; i < ngear; i++) { + for (i = 0; i < ngear; i++) { models[i] = 0; gear[i] = new(__FILE__,__LINE__) Solid; start[i] = g.start[i]; diff --git a/Stars45/MapView.cpp b/Stars45/MapView.cpp index 1c65d6e..48918d2 100644 --- a/Stars45/MapView.cpp +++ b/Stars45/MapView.cpp @@ -317,12 +317,12 @@ MapView::BuildMenu() ship_menu->AddItem(Game::GetText("MapView.item.Clear-All"), MAP_CLEAR); action_menu = new(__FILE__,__LINE__) Menu(Game::GetText("MapView.menu.ACTION")); - for (i = 0; i < Instruction::NUM_ACTIONS; i++) { + for (int i = 0; i < Instruction::NUM_ACTIONS; i++) { action_menu->AddItem(Game::GetText(Text("MapView.item.") + Instruction::ActionName(i)), MAP_ACTION + i); } formation_menu = new(__FILE__,__LINE__) Menu(Game::GetText("MapView.menu.FORMATION")); - for (i = 0; i < Instruction::NUM_FORMATIONS; i++) { + for (int i = 0; i < Instruction::NUM_FORMATIONS; i++) { formation_menu->AddItem(Game::GetText(Text("MapView.item.") + Instruction::FormationName(i)), MAP_FORMATION + i); } @@ -2598,7 +2598,7 @@ MapView::DrawNavRoute(OrbitalRegion* rgn, int y1 = (ioy-isy); if (draw_bold) { - if (fabs(x1) > fabs(y1)) { + if (x1 > y1) { window->DrawLine(iox, ioy+1, isx, isy+1, s_marker); } else { @@ -2724,7 +2724,7 @@ MapView::DrawNavRoute(OrbitalRegion* rgn, int y1 = (ioy-first_y); if (draw_bold) { - if (fabs(x1) > fabs(y1)) { + if (x1 > y1) { window->DrawLine(iox, ioy+1, first_x, first_y+1, s_marker); } else { diff --git a/Stars45/Mfd.cpp b/Stars45/Mfd.cpp index caf8bee..3bb341d 100644 --- a/Stars45/Mfd.cpp +++ b/Stars45/Mfd.cpp @@ -1355,8 +1355,9 @@ void MFD::DrawMFDText(int index, const char* txt, Rect& txt_rect, int align, int int n = strlen(txt); if (n > 250) n = 250; + int i; - for (int i = 0; i < n; i++) { + for (i = 0; i < n; i++) { if (islower(txt[i])) txt_buf[i] = toupper(txt[i]); else diff --git a/Stars45/Mission.cpp b/Stars45/Mission.cpp index be8a711..eaa89b0 100644 --- a/Stars45/Mission.cpp +++ b/Stars45/Mission.cpp @@ -1183,7 +1183,7 @@ Mission::ParseLoadout(TermStruct* val, MissionElement* element) if (name.length()) load->SetName(name); - for (i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) load->SetStation(i, stations[i]); element->loadouts.append(load); @@ -2137,7 +2137,7 @@ MissionShip::MissionShip() for (int i = 0; i < 16; i++) ammo[i] = -10; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) fuel[i] = -10; } diff --git a/Stars45/MissionTemplate.cpp b/Stars45/MissionTemplate.cpp index dbb6ca9..d84df07 100644 --- a/Stars45/MissionTemplate.cpp +++ b/Stars45/MissionTemplate.cpp @@ -645,7 +645,7 @@ MissionTemplate::ParseAlias(TermStruct* val) // re-parse the struct, dealing with stuff // that needs to be attached to the element: - for (i = 0; i < val->elements()->size(); i++) { + for (int i = 0; i < val->elements()->size(); i++) { TermDef* pdef = val->elements()->at(i)->isDef(); if (pdef) { Text defname = pdef->name()->value(); diff --git a/Stars45/MsnWepDlg.cpp b/Stars45/MsnWepDlg.cpp index 15cb125..922eb89 100644 --- a/Stars45/MsnWepDlg.cpp +++ b/Stars45/MsnWepDlg.cpp @@ -302,7 +302,7 @@ MsnWepDlg::BuildLists() loadout = msn_load->GetStations(); } - for (i = 0; i < nstations; i++) { + for (int i = 0; i < nstations; i++) { loads[i + first_station] = loadout[i]; } } @@ -485,10 +485,10 @@ MsnWepDlg::OnLoadout(AWEvent* event) for (int i = 0; i < 8; i++) loads[i] = -1; - for (i = 0; i < nstations; i++) + for (int i = 0; i < nstations; i++) loads[i + first_station] = PointIndexToLoad(i, loadout[i]); - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { for (int n = 0; n < 8; n++) { btn_load[i][n]->SetPicture(i == loads[n] ? led_on: led_off); } diff --git a/Stars45/NetData.cpp b/Stars45/NetData.cpp index 93d0cba..7f456b2 100644 --- a/Stars45/NetData.cpp +++ b/Stars45/NetData.cpp @@ -196,15 +196,15 @@ NetJoinRequest::Pack() for (int i = 0; i < name.length() && i < 16; i++) data[2+i] = name[i]; - for (i = 0; i < pass.length() && i < 16; i++) + for (int i = 0; i < pass.length() && i < 16; i++) data[18+i] = pass[i]; - for (i = 0; i < elem.length() && i < 31; i++) + for (int i = 0; i < elem.length() && i < 31; i++) data[34+i] = elem[i]; data[65] = (BYTE) index; - for (i = 0; i < serno.length() && i < 60; i++) + for (int i = 0; i < serno.length() && i < 60; i++) data[66+i] = serno[i]; return data; @@ -310,10 +310,10 @@ NetJoinAnnounce::Pack() for (int i = 0; i < name.length() && i < 16; i++) data[20+i] = name[i]; - for (i = 0; i < elem.length() && i < 32; i++) + for (int i = 0; i < elem.length() && i < 32; i++) data[36+i] = elem[i]; - for (i = 0; i < region.length() && i < 32; i++) + for (int i = 0; i < region.length() && i < 32; i++) data[68+i] = region[i]; int* p = (int*) (data + 100); @@ -325,7 +325,7 @@ NetJoinAnnounce::Pack() data[113]= (BYTE) shield; // byte 113 BYTE* a = data + 116; - for (i = 0; i < 16; i++) { // bytes 116 - 179 + for (int i = 0; i < 16; i++) { // bytes 116 - 179 if (ammo[i] >= 0) { *a++ = ammo[i]; } @@ -1166,7 +1166,7 @@ NetElemCreate::Unpack(const BYTE* p) squadron = data[150]; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { slots[i] = data[151+i]; if (slots[i] >= 255) slots[i] = -1; diff --git a/Stars45/NetGame.cpp b/Stars45/NetGame.cpp index 2e0e8eb..26a5a0d 100644 --- a/Stars45/NetGame.cpp +++ b/Stars45/NetGame.cpp @@ -80,7 +80,7 @@ NetGame::~NetGame() players.destroy(); if (link) { - double delta = fabs(NetLayer::GetUTC() - start_time); + double delta = fabs((double)(NetLayer::GetUTC() - start_time)); double bandwidth = 10.0 * (link->GetBytesSent() + link->GetBytesRecv()) / delta; double recvrate = link->GetPacketsRecv() / delta; diff --git a/Stars45/NetGameClient.cpp b/Stars45/NetGameClient.cpp index 76fb527..86869e2 100644 --- a/Stars45/NetGameClient.cpp +++ b/Stars45/NetGameClient.cpp @@ -706,7 +706,7 @@ NetGameClient::DoElemCreate(NetMsg* msg) } } - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int slot = slots[i]; if (slot > -1) { hangar->GotoAlert(squadron, slot, deck, elem, load, !alert); diff --git a/Stars45/NetGameServer.cpp b/Stars45/NetGameServer.cpp index 68b4c95..65b4f5e 100644 --- a/Stars45/NetGameServer.cpp +++ b/Stars45/NetGameServer.cpp @@ -683,7 +683,7 @@ NetGameServer::DoElemCreate(NetMsg* msg) } } - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int slot = slots[i]; if (slot > -1) { hangar->GotoAlert(squadron, slot, deck, elem, load, !alert); diff --git a/Stars45/Player.cpp b/Stars45/Player.cpp index 4a7c8aa..a042fd3 100644 --- a/Stars45/Player.cpp +++ b/Stars45/Player.cpp @@ -1193,7 +1193,7 @@ Player::Save() fprintf(f, " chat_%d: \"%s\",\n", i, SafeQuotes(p->chat_macros[i].data())); } - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (p->mfd[i] >= 0) { fprintf(f, " mfd%d: %d,\n", i, p->mfd[i]); } diff --git a/Stars45/PlayerDlg.cpp b/Stars45/PlayerDlg.cpp index d0eb8d9..234c724 100644 --- a/Stars45/PlayerDlg.cpp +++ b/Stars45/PlayerDlg.cpp @@ -90,7 +90,7 @@ PlayerDlg::RegisterControls() REGISTER_CLIENT(EID_CLICK, img_medals[i], PlayerDlg, OnMedal); } - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { txt_chat[i] = (EditBox*) FindControl(300 + i); } @@ -192,7 +192,7 @@ PlayerDlg::ShowPlayer() } } - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { if (txt_chat[i]) txt_chat[i]->SetText(p->ChatMacro(i)); } @@ -219,7 +219,7 @@ PlayerDlg::ShowPlayer() img_medals[i]->Hide(); } - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { if (txt_chat[i]) txt_chat[i]->SetText(""); } @@ -349,9 +349,9 @@ PlayerDlg::OnMedal(AWEvent* event) AwardShowDlg* award_dlg = manager->GetAwardDlg(); if (p && award_dlg) { - int m = -1; + int m = -1, i; - for (int i = 0; i < 15; i++) { + for (i = 0; i < 15; i++) { if (event->window == img_medals[i]) { m = i; break; diff --git a/Stars45/RadioView.cpp b/Stars45/RadioView.cpp index cdb5f84..89e26e0 100644 --- a/Stars45/RadioView.cpp +++ b/Stars45/RadioView.cpp @@ -293,7 +293,7 @@ RadioView::Refresh() if (!message_queue_empty) { // advance message pipeline: - for (i = 0; i < MAX_MSG; i++) { + for (int i = 0; i < MAX_MSG; i++) { if (msg_time[0] == 0) { for (int j = 0; j < MAX_MSG-1; j++) { msg_time[j] = msg_time[j+1]; @@ -312,7 +312,7 @@ RadioView::Refresh() // draw messages: if (!hud_off) { - for (i = 0; i < MAX_MSG; i++) { + for (int i = 0; i < MAX_MSG; i++) { if (msg_time[i] > 0) { Rect msg_rect(0, 95 + i*10, width, 12); @@ -615,7 +615,7 @@ RadioView::Message(const char* msg) // no space; advance pipeline: if (index < 0) { - for (i = 0; i < MAX_MSG-1; i++) { + for (int i = 0; i < MAX_MSG-1; i++) { radio_view->msg_text[i] = radio_view->msg_text[i+1]; radio_view->msg_time[i] = radio_view->msg_time[i+1]; } diff --git a/Stars45/ShieldRep.cpp b/Stars45/ShieldRep.cpp index 31ef1f4..edf5c93 100644 --- a/Stars45/ShieldRep.cpp +++ b/Stars45/ShieldRep.cpp @@ -170,7 +170,7 @@ ShieldRep::Illuminate() if (nhits < 1) return; - for (i = 0; i < MAX_SHIELD_HITS; i++) { + for (int i = 0; i < MAX_SHIELD_HITS; i++) { if (hits[i].damage > 0) { // add the hit's contribution to the shield verts: Vec3 hitloc = hits[i].hitloc; diff --git a/Stars45/Ship.cpp b/Stars45/Ship.cpp index 5753b00..f2ded5a 100644 --- a/Stars45/Ship.cpp +++ b/Stars45/Ship.cpp @@ -173,7 +173,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int systems.append(reactor); } - for (i = 0; i < design->drives.size(); i++) { + for (int i = 0; i < design->drives.size(); i++) { Drive* drive = new(__FILE__,__LINE__) Drive(*design->drives[i]); drive->SetShip(this); drive->SetID(sys_id++); @@ -242,7 +242,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int systems.append(shield); } - for (i = 0; i < design->flight_decks.size(); i++) { + for (int i = 0; i < design->flight_decks.size(); i++) { FlightDeck* deck = new(__FILE__,__LINE__) FlightDeck(*design->flight_decks[i]); deck->SetShip(this); deck->SetCarrier(this); @@ -270,7 +270,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int hangar->SetShip(this); } - for (i = 0; i < design->squadrons.size(); i++) { + for (int i = 0; i < design->squadrons.size(); i++) { ShipSquadron* s = design->squadrons[i]; hangar->CreateSquadron(s->name, 0, s->design, s->count, GetIFF(), 0, 0, s->avail); } @@ -305,7 +305,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int int wep_index = 1; - for (i = 0; i < design->weapons.size(); i++) { + for (int i = 0; i < design->weapons.size(); i++) { Weapon* gun = new(__FILE__,__LINE__) Weapon(*design->weapons[i]); gun->SetID(sys_id++); gun->SetOwner(this); @@ -332,7 +332,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int if (load && loadout_size > 0) { loadout = new(__FILE__,__LINE__) int[loadout_size]; - for (i = 0; i < loadout_size; i++) { + for (int i = 0; i < loadout_size; i++) { int mounted_weapon = loadout[i] = load[i]; if (mounted_weapon < 0) @@ -358,7 +358,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int primary = -1; secondary = -1; - for (i = 0; i < weapons.size(); i++) { + for (int i = 0; i < weapons.size(); i++) { WeaponGroup* group = weapons[i]; if (group->IsPrimary() && primary < 0) { primary = i; @@ -395,7 +395,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int systems.append(decoy); } - for (i = 0; i < design->navlights.size(); i++) { + for (int i = 0; i < design->navlights.size(); i++) { NavLight* navlight = new(__FILE__,__LINE__) NavLight(*design->navlights[i]); navlight->SetShip(this); navlight->SetID(sys_id++); @@ -429,7 +429,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int systems.append(probe); } - for (i = 0; i < design->computers.size(); i++) { + for (int i = 0; i < design->computers.size(); i++) { Computer* comp = 0; if (design->computers[i]->Subtype() == Computer::FLIGHT) { @@ -467,7 +467,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int radio_orders = new(__FILE__,__LINE__) Instruction("", Point(0,0,0)); // Load Detail Set: - for (i = 0; i < DetailSet::MAX_DETAIL; i++) { + for (int i = 0; i < DetailSet::MAX_DETAIL; i++) { if (design->models[i].size() > 0) { Solid* solid = new(__FILE__,__LINE__) ShipSolid(this); solid->UseModel(design->models[i].at(0)); @@ -530,7 +530,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int dir = 0; SetControls(0); - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { missile_id[i] = 0; missile_eta[i] = 0; trigger[i] = false; @@ -2919,7 +2919,7 @@ Ship::LinearFrame(double seconds) } // fore-and-aft - if (!trans_y && fabs(thrust < 1)) { + if (!trans_y && fabs(thrust) < 1.0f) { Point transvec = cam.vpn(); transvec *= (transvec * velocity) * seconds * 0.25; velocity -= transvec; @@ -2987,7 +2987,7 @@ Ship::DockFrame(double seconds) reactors[i]->ExecFrame(seconds); // count up weapon ammo for status mfd: - for (i = 0; i < weapons.size(); i++) + for (int i = 0; i < weapons.size(); i++) weapons[i]->ExecFrame(seconds); // show drive flare while on catapult: @@ -3256,7 +3256,7 @@ Ship::SelectDetail(double seconds) } } if (w->IsMissile()) { - for (i = 0; i < w->Ammo(); i++) { + for (int i = 0; i < w->Ammo(); i++) { Solid* store = w->GetVisibleStore(i); if (store) { if (detail_level == 0) @@ -3323,7 +3323,7 @@ Ship::ShowRep() } if (w->IsMissile()) { - for (i = 0; i < w->Ammo(); i++) { + for (int i = 0; i < w->Ammo(); i++) { Solid* store = w->GetVisibleStore(i); if (store) { store->Show(); @@ -3363,7 +3363,7 @@ Ship::HideRep() } if (w->IsMissile()) { - for (i = 0; i < w->Ammo(); i++) { + for (int i = 0; i < w->Ammo(); i++) { Solid* store = w->GetVisibleStore(i); if (store) { store->Hide(); @@ -4895,16 +4895,16 @@ Ship::ExecMaintFrame(double seconds) if (pwr != src) { List xfer; - for (int i = 0; i < pwr->Clients().size(); i++) { - System* s = pwr->Clients().at(i); + for (int j = 0; j < pwr->Clients().size(); i++) { + System* s = pwr->Clients().at(j); if (s->GetSourceIndex() == isrc) { xfer.append(s); } } - for (i = 0; i < xfer.size(); i++) { - System* s = xfer.at(i); + for (int j = 0; j < xfer.size(); i++) { + System* s = xfer.at(j); pwr->RemoveClient(s); src->AddClient(s); } diff --git a/Stars45/ShipDesign.cpp b/Stars45/ShipDesign.cpp index 8c1da09..f69023c 100644 --- a/Stars45/ShipDesign.cpp +++ b/Stars45/ShipDesign.cpp @@ -304,7 +304,7 @@ ShipDesign::ShipDesign(const char* n, const char* p, const char* fname, bool s) } while (term); - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int n = 0; ListIter iter = detail[i]; while (++iter) { @@ -454,7 +454,7 @@ ShipDesign::~ShipDesign() spin_rates.destroy(); - for (i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { delete debris[i].model; } } @@ -487,7 +487,7 @@ void AddModCatalogEntry(const char* design_name, const char* design_path) } } - for (i = 0; i < mod_catalog.size(); i++) { + for (int i = 0; i < mod_catalog.size(); i++) { ShipCatalogEntry* e = mod_catalog[i]; if (e->name == design_name) { if (design_path && *design_path) { @@ -1031,7 +1031,7 @@ ShipDesign::GetDesignList(int type, List& designs) } } - for (i = 0; i < mod_catalog.size(); i++) { + for (int i = 0; i < mod_catalog.size(); i++) { ShipCatalogEntry* e = mod_catalog[i]; int etype = ClassForName(e->type); @@ -2004,7 +2004,7 @@ ShipDesign::ParseFarcaster(TermStruct* val) caster->SetStartPoint(start); caster->SetEndPoint(end); - for (i = 0; i < napproach; i++) + for (int i = 0; i < napproach; i++) caster->SetApproachPoint(i, approach[i]); if (emcon_1 >= 0 && emcon_1 <= 100) @@ -2279,7 +2279,7 @@ ShipDesign::ParseNavlight(TermStruct* val) nav->SetDesign(sd); } - for (i = 0; i < nlights; i++) + for (int i = 0; i < nlights; i++) nav->AddBeacon(bloc[i], pattern[i], btype[i]); navlights.append(nav); @@ -2450,13 +2450,13 @@ ShipDesign::ParseFlightDeck(TermStruct* val) if (light > 0) deck->SetLight(light); - for (i = 0; i < napproach; i++) + for (int i = 0; i < napproach; i++) deck->SetApproachPoint(i, approach[i]); - for (i = 0; i < nrunway; i++) + for (int i = 0; i < nrunway; i++) deck->SetRunwayPoint(i, runway[i]); - for (i = 0; i < nslots; i++) + for (int i = 0; i < nslots; i++) deck->AddSlot(spots[i], filters[i]); if (cycle_time > 0) @@ -2555,7 +2555,7 @@ ShipDesign::ParseLandingGear(TermStruct* val) gear->SetDesign(sd); } - for (i = 0; i < ngear; i++) + for (int i = 0; i < ngear; i++) gear->AddGear(model[i], start[i], end[i]); } diff --git a/Stars45/ShipKiller.cpp b/Stars45/ShipKiller.cpp index 47f3ad8..68b443a 100644 --- a/Stars45/ShipKiller.cpp +++ b/Stars45/ShipKiller.cpp @@ -175,7 +175,7 @@ ShipKiller::ExecFrame(double seconds) } } - for (i = 0; i < ShipDesign::MAX_DEBRIS; i++) { + for (int i = 0; i < ShipDesign::MAX_DEBRIS; i++) { if (design->debris[i].model) { Point debris_loc = ship->Location() + (design->debris[i].loc * ship->Cam().Orientation()); Point debris_vel = debris_loc - ship->Location(); diff --git a/Stars45/Sim.cpp b/Stars45/Sim.cpp index 90986a4..b054b72 100644 --- a/Stars45/Sim.cpp +++ b/Stars45/Sim.cpp @@ -2124,7 +2124,7 @@ Sim::CreateMissionElement(Element* elem) } int num_inst = elem->NumInstructions(); - for (i = 0; i < num_inst; i++) { + for (int i = 0; i < num_inst; i++) { Text instr = elem->GetInstruction(i); msn_elem->AddInstruction(instr); } @@ -2145,7 +2145,7 @@ Sim::CreateMissionElement(Element* elem) msn_elem->AddNavPoint(npt); } - for (i = 0; i < elem->NumShips(); i++) { + for (int i = 0; i < elem->NumShips(); i++) { ship = elem->GetShip(i+1); if (ship) { @@ -3752,7 +3752,7 @@ SimRegion::CommitMission() s->GetCombatUnit()->Kill(1); } - for (i = 0; i < ships.size(); i++) { + for (int i = 0; i < ships.size(); i++) { Ship* s = ships[i]; CombatUnit* u = s->GetCombatUnit(); diff --git a/Stars45/StarSystem.cpp b/Stars45/StarSystem.cpp index b403cdb..bd8556d 100644 --- a/Stars45/StarSystem.cpp +++ b/Stars45/StarSystem.cpp @@ -936,7 +936,7 @@ StarSystem::ParseTerrain(TermStruct* val) weather.SetPeriod(w_period); - for (i = 0; i < Weather::NUM_STATES; i++) + for (int i = 0; i < Weather::NUM_STATES; i++) weather.SetChance(i, w_chances[i]); region->LoadSkyColors(sky_name); diff --git a/Stars45/Stars.vcxproj b/Stars45/Stars.vcxproj index 37a5cc1..f0c3bdc 100644 --- a/Stars45/Stars.vcxproj +++ b/Stars45/Stars.vcxproj @@ -51,11 +51,16 @@ .\Debug\ .\Debug\ true + $(DXSDK_DIR)\include;$(IncludePath) .\Release\ .\Release\ false + $(DXSDK_DIR)\include;$(IncludePath) + + + $(DXSDK_DIR)\include;$(IncludePath) diff --git a/Stars45/TerrainApron.cpp b/Stars45/TerrainApron.cpp index 24125ac..c3dd700 100644 --- a/Stars45/TerrainApron.cpp +++ b/Stars45/TerrainApron.cpp @@ -267,7 +267,7 @@ TerrainApron::Illuminate(Color ambient, List& lights) Vec3 vl = light->Location(); vl.Normalize(); - for (i = 0; i < nverts; i++) { + for (int i = 0; i < nverts; i++) { Vec3& nrm = vset->nrm[i]; double val = 0; diff --git a/Stars45/TerrainPatch.cpp b/Stars45/TerrainPatch.cpp index bb8718a..463ee9b 100644 --- a/Stars45/TerrainPatch.cpp +++ b/Stars45/TerrainPatch.cpp @@ -723,7 +723,7 @@ TerrainPatch::CalcLayer(Poly* poly) if (y <= terrain->GetLayers().first()->GetMinHeight()) return 0; - for (i = 0; i < terrain->GetLayers().size(); i++) { + for (int i = 0; i < terrain->GetLayers().size(); i++) { TerrainLayer* layer = terrain->GetLayers().at(i); if (y >= layer->GetMinHeight() && y < layer->GetMaxHeight()) { @@ -847,7 +847,7 @@ TerrainPatch::Illuminate(Color ambient, List& lights) Vec3 vl = light->Location(); vl.Normalize(); - for (i = 0; i < nverts; i++) { + for (int i = 0; i < nverts; i++) { Vec3& nrm = vset->nrm[i]; double val = 0; double gain = vl * nrm; @@ -867,7 +867,7 @@ TerrainPatch::Illuminate(Color ambient, List& lights) // combine blend weights: if (ndetail >= 2) { - for (i = 0; i < nverts; i++) { + for (int i = 0; i < nverts; i++) { vset->diffuse[i] = vset->specular[i] | (vset->diffuse[i] & 0x00ffffff); } } diff --git a/Stars45/TerrainRegion.cpp b/Stars45/TerrainRegion.cpp index 17be0bc..12e3938 100644 --- a/Stars45/TerrainRegion.cpp +++ b/Stars45/TerrainRegion.cpp @@ -190,31 +190,31 @@ TerrainRegion::LoadSkyColors(const char* bmp_name) shade_color[i] = Color::Gray; } - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) sky_color[i] = sky_colors_bmp.GetColor(i, 0); if (sky_colors_bmp.Height() > 1) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) fog_color[i].Set(sky_colors_bmp.GetColor(i, 1).Value() | Color(0,0,0,255).Value()); if (sky_colors_bmp.Height() > 2) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) ambient[i] = sky_colors_bmp.GetColor(i, 2); if (sky_colors_bmp.Height() > 3) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) sun_color[i] = sky_colors_bmp.GetColor(i, 3); if (sky_colors_bmp.Height() > 4) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) overcast[i] = sky_colors_bmp.GetColor(i, 4); if (sky_colors_bmp.Height() > 5) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) cloud_color[i] = sky_colors_bmp.GetColor(i, 5); if (sky_colors_bmp.Height() > 6) - for (i = 0; i < max_color; i++) + for (int i = 0; i < max_color; i++) shade_color[i] = sky_colors_bmp.GetColor(i, 6); } diff --git a/Stars45/Trail.cpp b/Stars45/Trail.cpp index ab9c7a7..69a937a 100644 --- a/Stars45/Trail.cpp +++ b/Stars45/Trail.cpp @@ -52,7 +52,7 @@ Trail::Trail(Bitmap* tex, int n) polys = new(__FILE__,__LINE__) Poly[maxtrail]; - for (i = 0; i < maxtrail; i++) { + for (int i = 0; i < maxtrail; i++) { polys[i].vertex_set = verts; polys[i].nverts = 4; polys[i].material = &mtl; diff --git a/Stars45/VidDlg.cpp b/Stars45/VidDlg.cpp index 329a17b..4dea6b7 100644 --- a/Stars45/VidDlg.cpp +++ b/Stars45/VidDlg.cpp @@ -144,7 +144,7 @@ VidDlg::Show() int n = stars->MaxTexSize(); for (int i = 0; i < 7; i++) { - if (n <= pow(2, i+6)) { + if (n <= pow(2.0f, i+6)) { selected_tex_size = i; break; } @@ -340,7 +340,7 @@ VidDlg::Apply() d = 32; if (selected_tex_size) - t = (int) pow(2, selected_tex_size + 6); + t = (int) pow(2.0f, selected_tex_size + 6); bool video_change = false; @@ -393,7 +393,7 @@ VidDlg::Apply() fprintf(f, "height: %4d\n", h); fprintf(f, "depth: %4d\n", d); fprintf(f, "\n"); - fprintf(f, "max_tex: %d\n", (int) pow(2, 6 + selected_tex_size)); + fprintf(f, "max_tex: %d\n", (int) pow(2.0f, 6 + selected_tex_size)); fprintf(f, "primary3D: %s\n", (a>0)?"true":"false"); fprintf(f, "gamma: %4d\n", g); fprintf(f, "\n"); diff --git a/Stars45/WeaponDesign.cpp b/Stars45/WeaponDesign.cpp index fecd505..c2ca199 100644 --- a/Stars45/WeaponDesign.cpp +++ b/Stars45/WeaponDesign.cpp @@ -672,7 +672,7 @@ WeaponDesign::Find(const char* name) } } - for (i = 0; i < mod_catalog.size(); i++) { + for (int i = 0; i < mod_catalog.size(); i++) { WeaponDesign* d = mod_catalog.at(i); if (d->name == name) { @@ -717,7 +717,7 @@ WeaponDesign::GetDesignList(List& designs) designs.append(&design->name); } - for (i = 0; i < mod_catalog.size(); i++) { + for (int i = 0; i < mod_catalog.size(); i++) { WeaponDesign* design = mod_catalog[i]; designs.append(&design->name); } diff --git a/Stars45/Weather.cpp b/Stars45/Weather.cpp index 49a6259..a55ec6c 100644 --- a/Stars45/Weather.cpp +++ b/Stars45/Weather.cpp @@ -66,14 +66,14 @@ Weather::NormalizeChances() else { chances[0] = 0; - for (i = 1; i < NUM_STATES; i++) + for (int i = 1; i < NUM_STATES; i++) chances[i] /= total; } int index = 0; double level = 0; - for (i = 0; i < NUM_STATES; i++) { + for (int i = 0; i < NUM_STATES; i++) { if (chances[i] > 0) { level += chances[i]; -- cgit v1.1