From 2b924101d6942ca6e837226dd8e704707aeb74d3 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 15 Apr 2014 02:54:16 -0400 Subject: [PATCH] Nuke nearly all of the unused local variables --- osx/boe.dlgutil.cpp | 9 --------- osx/boe.fileio.cpp | 8 -------- osx/boe.graphics.cpp | 6 ------ osx/boe.graphutil.cpp | 2 +- osx/boe.infodlg.cpp | 24 ++++-------------------- osx/boe.items.cpp | 6 ------ osx/boe.main.cpp | 4 ---- osx/boe.menus.mac.mm | 3 +-- osx/boe.newgraph.cpp | 3 --- osx/boe.party.cpp | 10 ++-------- osx/boe.specials.cpp | 2 +- osx/boe.text.cpp | 2 -- osx/boe.town.cpp | 1 - osx/dialogxml/control.cpp | 8 -------- osx/dialogxml/dialog.cpp | 1 - osx/dialogxml/field.cpp | 1 + osx/tools/cursors.m | 2 +- osx/tools/graphtool.cpp | 2 +- osx/tools/mathutil.cpp | 8 ++++---- osx/tools/qdpict.cpp | 7 ------- osx/tools/soundtool.cpp | 2 +- osx/tools/winutil.mac.mm | 1 - 22 files changed, 17 insertions(+), 95 deletions(-) diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 8b981f35..217d3189 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -1048,8 +1048,6 @@ void do_sign(short town_num, short which_sign, short sign_type,location sign_loc //town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors //short sign_type; // terrain type { - - short item_hit; char sign_text[256]; location view_loc; @@ -1189,8 +1187,6 @@ bool prefs_event_filter (cDialog& me, std::string id, eKeyMod mods) void pick_preferences() { - short item_hit; - make_cursor_sword(); cDialog prefsDlog("preferences.xml"); @@ -1338,7 +1334,6 @@ bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) extern bool pc_gworld_loaded; void edit_party(short can_create,short can_cancel) { - short item_hit; bool munch_pc_graphic = false; make_cursor_sword(); @@ -1394,8 +1389,6 @@ bool tip_of_day_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) void tip_of_day() { - - short item_hit; std::string place_str; store_tip_page_on = get_ran(1,0,NUM_HINTS - 1); @@ -1475,8 +1468,6 @@ bool pick_a_scen_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) short pick_a_scen() { - - short item_hit; build_scen_headers(); diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index 0ec94299..0eabfa89 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -101,8 +101,6 @@ cCustomGraphics spec_scen_g; std::ofstream flog("bladeslog.txt"); void init_directories() { - short error; - char cPath[768]; CFBundleRef mainBundle=CFBundleGetMainBundle(); @@ -1050,9 +1048,7 @@ typedef struct { */ void build_scen_headers() { - short index = 1; unsigned short cur_entry = 0; - OSErr err; fs::path scenDir = progDir; // scenDir.erase(scenDir.find_last_of("/")); scenDir /= "Blades of Exile Scenarios"; @@ -1076,9 +1072,6 @@ void build_scen_headers() return; } #endif - // TODO: What on earth is the ItemCount type? - ItemCount numScens = 0; - //myCPB.dirInfo.ioCompletion = NULL; //myCPB.dirInfo.ioNamePtr = scen_name; //myCPB.dirInfo.ioVRefNum = start_volume; @@ -1103,7 +1096,6 @@ void build_scen_headers() // This wipes out the scenario record, so be sure not to call it while in an active scenario. bool load_scenario_header(fs::path file/*,short header_entry*/){ bool file_ok = false; - OSErr error; long len; bool mac_header = true; diff --git a/osx/boe.graphics.cpp b/osx/boe.graphics.cpp index 0d6acb0b..2eb9e945 100644 --- a/osx/boe.graphics.cpp +++ b/osx/boe.graphics.cpp @@ -544,10 +544,6 @@ void Set_up_win () RECT temp_rect = {0,0,0,280},map_world_rect; RECT map_rect = {0,0,384,384}; RECT pc_rect = {0,0,216,113}; - char fn1[] = "Geneva"; - char fn2[] = "Dungeon Bold"; - char fn3[] = "Palatino"; - short i; RECT r; // TODO: I think this is a relic of the Exile III demo screen at the main menu; we don't actually need to load it until the function below @@ -688,8 +684,6 @@ void draw_buttons(short mode) mode -= 100; } - sf::Texture& buttons_to_draw = buttons_gworld; - if (is_combat()) { // TODO: Draw buttons one at a time instead of singly source_rect.top += 37; source_rect.bottom += 37; diff --git a/osx/boe.graphutil.cpp b/osx/boe.graphutil.cpp index 6e3c37c5..d6efcecf 100644 --- a/osx/boe.graphutil.cpp +++ b/osx/boe.graphutil.cpp @@ -309,7 +309,7 @@ void draw_monsters() //// } void play_see_monster_str(unsigned short m){ - short str1, str2, pic, snd, spec, s1 = 0, s2 = 0, s3 = 0; + short str1, str2, pic, snd, spec; ePicType type; str1 = scenario.scen_monsters[m].see_str1; str2 = scenario.scen_monsters[m].see_str2; diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index 2040c821..a5429a25 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -127,8 +127,6 @@ void display_spells(short mode,short force_spell,cDialog* parent) //short force_spell; // if 100, ignore { using namespace std::placeholders; - short item_hit; - if (force_spell < 100) { if (mode == 0) mage_spell_pos = force_spell; @@ -186,9 +184,6 @@ bool display_skills_event_filter(cDialog& me, std::string item_hit, eKeyMod mods void display_skills(short force_skill,cDialog* parent) { - - short item_hit; - if (force_skill < 100) skill_pos = force_skill; if (skill_pos < 0) @@ -244,7 +239,7 @@ bool display_pc_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) void display_pc(short pc_num,short mode,cDialog* parent) { - short i,item_hit; + short i; std::string label_str; if (univ.party[pc_num].main_status == 0) { @@ -276,7 +271,6 @@ void put_item_info(cDialog& me,short pc,short item)//// { char store_text[256]; std::string desc_str; - short i; cItemRec s_i; const char *item_types[] = {"","1-Handed weapon","2-Handed weapon","","Bow","Arrows","Thrown missile", "Potion/Magic Item","Scroll/Magic Item","Wand","Tool","","Shield","Armor","Helm", @@ -423,8 +417,6 @@ bool display_pc_item_event_filter(cDialog& me, std::string item_hit, eKeyMod mod void display_pc_item(short pc_num,short item,cItemRec si,short parent) { - short item_hit; - store_item_pc = pc_num; if (pc_num == 6) store_i = si; @@ -569,9 +561,6 @@ void display_monst(short array_pos,cCreature *which_m,short mode) //creature_data_type *which_m; // if NULL, show full roster //short mode; // if 1, full roster, else use monster from storwhich_me_m { - - short item_hit; - position = array_pos; full_roster = false; if (mode == 1) { @@ -648,8 +637,6 @@ bool display_alchemy_event_filter(cDialog& me, std::string item_hit, eKeyMod mod void display_alchemy(cDialog* parent) { std::string get_text; - long get_val; - short item_hit; cur_entry = 3; @@ -670,7 +657,7 @@ void display_alchemy(cDialog* parent) void display_alchemy() { - short i,item_hit; + short i; make_cursor_sword(); @@ -756,7 +743,6 @@ void pick_race_abil(cPlayer *pc,short mode,cDialog* parent) { static const char*const start_str1 = "Click on button by name for description."; static const char*const start_str2 = "Click on advantage button to add/remove."; - short item_hit; store_trait_mode = mode; store_pc = pc; @@ -901,7 +887,7 @@ bool give_pc_extra_info(cDialog& me, std::string item_hit, eKeyMod mods) { void give_pc_info(short pc_num) { - short item_hit ,i; + short i; std::string str; store_pc_num = pc_num; @@ -998,7 +984,6 @@ void adventure_notes() { unsigned short i; - short item_hit; char place_str[256]; store_num_i = 0; @@ -1107,7 +1092,7 @@ bool talk_notes_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) void talk_notes() { - short i,item_hit; + short i; store_num_i = 0; for (i = 0; i < 120; i++) @@ -1168,7 +1153,6 @@ void journal() { unsigned short i; - short item_hit; char place_str[256]; store_num_i = 0; diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index ed0a6382..c3d451ad 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -951,7 +951,6 @@ void put_item_graphics(cDialog& me) bool display_item_event_filter(cDialog& me, std::string id, eKeyMod mods) { cItemRec item; - short i; if(id == "done") { me.toast(); @@ -1210,8 +1209,6 @@ short get_num_of_items(short max_num) //town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors //short sign_type; // terrain type { - - short item_hit; char sign_text[256]; make_cursor_sword(); @@ -1480,9 +1477,6 @@ bool get_text_response_event_filter(cDialog& me, std::string item_hit, eKeyMod m std::string get_text_response(short dlg,short parent_num) { - - short item_hit,i; - make_cursor_sword(); cDialog strPanel("get-response.xml"); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index e0e6e1fb..838d7b68 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -307,7 +307,6 @@ void Handle_One_Event() static const long fiveTicks = time_in_ticks(5).asMilliseconds(); static const long twentyTicks = time_in_ticks(20).asMilliseconds(); static const long fortyTicks = time_in_ticks(40).asMilliseconds(); - long menu_choice; bool event_in_dialog = false; through_sending(); @@ -540,8 +539,6 @@ void Mouse_Pressed() { // TODO: What about other windows? // sf::Window& the_window = mainPtr; - short the_part,choice,i,content_part; - long menu_choice; if (had_text_freeze > 0) { had_text_freeze--; return; @@ -1032,7 +1029,6 @@ void incidental_noises(bool on_surface){ void pause(short length) { long len; - unsigned long dummy; len = (long) length; diff --git a/osx/boe.menus.mac.mm b/osx/boe.menus.mac.mm index b4ccfdf2..34cedeff 100644 --- a/osx/boe.menus.mac.mm +++ b/osx/boe.menus.mac.mm @@ -71,7 +71,6 @@ void showMenuBar() { void adjust_monst_menu() { short i,monst_pos = 0; NSMenu* monst_menu; - char monst_name[256]; if(overall_mode == MODE_STARTUP) return; @@ -109,7 +108,7 @@ void setMenuCallback(NSMenuItem* item, id targ, SEL selector, int num) { void init_menubar() { NSApplication* app = [NSApplication sharedApplication]; - BOOL loaded = [NSBundle loadNibNamed: @"menu" owner: app]; + [NSBundle loadNibNamed: @"menu" owner: app]; menu_bar_handle = [app mainMenu]; apple_menu = [[menu_bar_handle itemWithTitle: @"Blades of Exile"] submenu]; diff --git a/osx/boe.newgraph.cpp b/osx/boe.newgraph.cpp index 5e1cdbfa..0bbe2455 100644 --- a/osx/boe.newgraph.cpp +++ b/osx/boe.newgraph.cpp @@ -1083,14 +1083,11 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col RECT dest_rect,help_from = {85,36,101,54}; std::string str; sf::Text str_to_draw; - static const char fn2[] = "Dungeon Bold"; - static const char fn3[] = "Palatino"; short i,j,str_len,line_height = 17; // Str255 p_str,str,str_to_draw,str_to_draw2; short text_len[257],current_rect,store_last_word_break = 0,start_of_last_kept_word = -1; short last_line_break = 0,last_word_break = 0,on_what_line = 0,last_stored_word_break = 0; - bool force_skip = false; short face_to_draw; // In the 0..65535 range, these blue components were: 0, 32767, 14535, 26623, 59391 diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index c80307f0..e0cb41e7 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -2640,8 +2640,6 @@ short pick_spell(short pc_num,short type,short situation) // 70 - no spell OW s //short type; // 0 - mage 1 - priest //short situation; // 0 - out 1 - town 2 - combat { - short item_hit; - store_mage_store = store_mage; store_priest_store = store_priest; store_store_target = store_spell_target; @@ -2917,7 +2915,7 @@ bool alch_choice_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) short alch_choice(short pc_num) { short difficulty[20] = {1,1,1,3,3, 4,5,5,7,9, 9,10,12,12,9, 14,19,10,16,20}; - short i,item_hit,store_alchemy_pc; + short i,store_alchemy_pc; char get_text[256]; make_cursor_sword(); @@ -2950,7 +2948,6 @@ extern bool pc_gworld_loaded; bool pick_pc_graphic(short pc_num,short mode,cDialog* parent) // mode ... 0 - create 1 - created { - short i,item_hit; bool munch_pc_graphic = false; store_graphic_pc_num = pc_num; @@ -2996,9 +2993,6 @@ bool pick_pc_name(short pc_num,cDialog* parent) //town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors //short sign_type; // terrain type { - - short item_hit; - store_train_pc = pc_num; make_cursor_sword(); @@ -3015,7 +3009,7 @@ bool pick_pc_name(short pc_num,cDialog* parent) m_num_t pick_trapped_monst() // ignore parent in Mac version { - short item_hit,i; + short i; std::string sp; cMonster get_monst; diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index d56f2d27..bd35b291 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -2178,7 +2178,7 @@ void oneshot_spec(short which_mode,cSpecial cur_node,short cur_spec_type, { bool check_mess = true,set_sd = true; std::array strs; - short i,j,pic; + short i,j; std::array buttons = {-1,-1,-1}; cSpecial spec; cItemRec store_i; diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index 65904ae3..bf2a432d 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -251,8 +251,6 @@ void put_item_screen(short screen_num,short suppress_buttons) short i = 0,j,pc; RECT erase_rect = {17,2,122,255},dest_rect; RECT upper_frame_rect = {3,3,15,268}; - // TODO: The duplication of RECT here shouldn't be necessary... - RECT parts_of_area_to_draw[3] = {RECT{0,0,17,271},RECT{16,0,123,256},RECT{123,0,144,271}}; item_stats_gworld.setActive(); diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index 48c8c4a5..1283318a 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -1647,7 +1647,6 @@ void display_map() { // Show the automap if it's not already visible if(map_visible) return; - short the_type; RECT the_rect; RECT dlogpicrect = {6,6,42,42}; diff --git a/osx/dialogxml/control.cpp b/osx/dialogxml/control.cpp index c893238e..253756e2 100644 --- a/osx/dialogxml/control.cpp +++ b/osx/dialogxml/control.cpp @@ -177,7 +177,6 @@ void cControl::setActive(bool active) { bool cControl::handleClick(){ sf::Event e; - unsigned long dummy; bool done = false, clicked = false; inWindow->setActive(); depressed = true; @@ -274,13 +273,6 @@ bool cControl::triggerFocusHandler(cDialog& me __attribute__((unused)), std::str std::string cControl::font_nums[4] = {"Dungeon", "Geneva", "Silom", "MaidenWord"}; void cControl::init(){ - char fnGeneva[] = "Geneva"; - char fnDungeon[] = "Dungeon Bold"; - char fnMaiden[] = "MaidenWord"; - char fnSilom[] = "Silom"; - char fnPalatino[] = "Palatino"; - char fnChancery[] = "Apple Chancery"; - // Check if Silom is available // TODO: Ultimately, I'd like to distribute all needed fonts with the game, rendering this unnecessary try { diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index 0b280fab..241d3b0a 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -1134,7 +1134,6 @@ bool cDialog::addLabelFor(std::string key, std::string label, eLabelPos where, s } std::string cDialog::process_keystroke(cKey keyHit){ - unsigned long dummy; ctrlIter iter = controls.begin(); while(iter != controls.end()){ if(iter->second->getType() == CTRL_FIELD && iter->second->isVisible() && dynamic_cast(iter->second)->hasFocus()) { diff --git a/osx/dialogxml/field.cpp b/osx/dialogxml/field.cpp index 0e86d388..ee4f5c9b 100644 --- a/osx/dialogxml/field.cpp +++ b/osx/dialogxml/field.cpp @@ -107,6 +107,7 @@ void cTextField::draw(){ selectRect.left += sel_start; selectRect.right = selectRect.left + sel_width; fill_rect(*inWindow, selectRect, ipClr); + // TODO: I forget whether this was supposed to be = or -= selectRect.right - 1; fill_rect(*inWindow, selectRect, hiliteClr); } else if(ip_timer.getElapsedTime().asMilliseconds() < 500) { diff --git a/osx/tools/cursors.m b/osx/tools/cursors.m index 879bbb33..d46a9436 100644 --- a/osx/tools/cursors.m +++ b/osx/tools/cursors.m @@ -41,7 +41,7 @@ NSImage* ImageFromURL(CFURLRef url){ CursorRef CreateCursorFromFile(const char* path, float hotSpotX, float hotSpotY){ FSRef ref; - OSStatus err = FSPathMakeRef((UInt8*)path, &ref, NULL); + FSPathMakeRef((UInt8*)path, &ref, NULL); CFURLRef imgPath = CFURLCreateFromFSRef(NULL, &ref); #if 0 static BOOL inited = NO; diff --git a/osx/tools/graphtool.cpp b/osx/tools/graphtool.cpp index e2cadce6..eb6b6303 100644 --- a/osx/tools/graphtool.cpp +++ b/osx/tools/graphtool.cpp @@ -300,7 +300,7 @@ void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,const char* st } short string_length(const char *str){ // Why not just use strlen? - short total_width = 0,i,len; + short total_width = 0; sf::Text text; TEXT.applyTo(text); diff --git a/osx/tools/mathutil.cpp b/osx/tools/mathutil.cpp index f321008c..45c5fd07 100644 --- a/osx/tools/mathutil.cpp +++ b/osx/tools/mathutil.cpp @@ -72,10 +72,10 @@ short gcd(short a, short b){ // Grabbed from Wikipedia and translated to C code // According to Macintosh Toolbox Essentials, a tick is about 1/60ths of a second. sf::Time time_in_ticks(int ticks) { unsigned long long micro = ticks; - ticks *= 1000; - ticks *= 1000; - ticks /= 60; - return sf::microseconds(ticks); + micro *= 1000; + micro *= 1000; + micro /= 60; + return sf::microseconds(micro); } diff --git a/osx/tools/qdpict.cpp b/osx/tools/qdpict.cpp index 045300d1..347328ac 100644 --- a/osx/tools/qdpict.cpp +++ b/osx/tools/qdpict.cpp @@ -18,12 +18,6 @@ // TODO: Don't use the resource manager #include -static int32_t extract_long(char* ptr) { - int32_t l = *(int32_t*) ptr; - flip_long(&l); - return l; -} - static int16_t extract_word(char* ptr) { int16_t s = *(int16_t*) ptr; flip_short(&s); @@ -200,7 +194,6 @@ rectangle loadFromPictResource(Handle resHandle, unsigned char*& pixelStore) { ptr_guard pixels(pixelStore, pixelStore + picDataSize); // Then 4 reserved bytes picData += 4; - int pixMapType = 0; legacy::Rect bounds; // Now we need to skip any superfluous opcodes until we get to pixel data - opcode 90, 91, 98, or 99 // We're assuming it's stored as pixel data, so any other opcodes will just be ignored diff --git a/osx/tools/soundtool.cpp b/osx/tools/soundtool.cpp index 01a68c8a..85b63852 100644 --- a/osx/tools/soundtool.cpp +++ b/osx/tools/soundtool.cpp @@ -88,7 +88,7 @@ std::string sound_to_fname_map(int snd_num) { } void init_snd_tool(){ - short i,t; + short i; // TODO: Might need sound 0, not sure for (i = 1; i < NUM_SOUNDS; i++) { diff --git a/osx/tools/winutil.mac.mm b/osx/tools/winutil.mac.mm index 01bbb7d5..3226f4d8 100644 --- a/osx/tools/winutil.mac.mm +++ b/osx/tools/winutil.mac.mm @@ -15,7 +15,6 @@ bool isFrontWindow(sf::Window& win) { id nsHandle = id(handle); if([nsHandle isKindOfClass: [NSWindow class]]) { BOOL main = [nsHandle isMainWindow]; - BOOL key = [nsHandle isKeyWindow]; return main; } return false;