From 76168b207102daf12587f80731a07ea95fd8eba5 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 6 Oct 2015 19:06:46 -0400 Subject: [PATCH] Nuke several globals; some were unused, others moved to universe --- src/boe.actions.cpp | 77 +++++++++++++++++--------------------- src/boe.combat.cpp | 6 +-- src/boe.fileio.cpp | 7 +--- src/boe.graphics.cpp | 5 ++- src/boe.graphutil.cpp | 2 +- src/boe.items.cpp | 2 +- src/boe.main.cpp | 11 ++---- src/boe.party.cpp | 7 ++-- src/boe.specials.cpp | 18 ++++----- src/boe.town.cpp | 2 +- src/classes/universe.hpp | 1 + src/pcedit/pc.action.cpp | 1 - src/pcedit/pc.editors.cpp | 2 +- src/pcedit/pc.main.cpp | 2 +- src/scenedit/scen.main.cpp | 3 +- 15 files changed, 64 insertions(+), 82 deletions(-) diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index d816fa79..be6cb73e 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -58,13 +58,11 @@ rectangle item_buttons[8][6]; // name, use, give, drip, info, sell/id rectangle pc_buttons[6][5]; // name, hp, sp, info, trade -short num_chirps_played = 0; extern rectangle startup_button[6]; extern bool flushingInput; extern bool fog_lifted; extern bool cartoon_happening; -bool ghost_mode, node_step_through; rectangle startup_top; bool item_area_button_active[8][6]; @@ -74,10 +72,9 @@ short item_bottom_button_active[9] = {0,0,0,0,0, 0,1,1,1}; rectangle pc_help_button,pc_area_rect,item_area_rect; short current_terrain_type = 0,num_out_moves = 0; -short door_pc,store_drop_item; +short store_drop_item; short current_switch = 6; cOutdoors::cWandering store_wandering_special; -long dummy; short store_selling_values[8] = {0,0,0,0,0,0,0,0}; extern cShop active_shop; @@ -86,8 +83,8 @@ extern rectangle shop_frame; extern short cen_x, cen_y, stat_window;//,pc_moves[6]; extern eGameMode overall_mode; extern location to_create; -extern bool All_Done,frills_on,spell_forced,monsters_going; -extern bool party_in_memory,in_scen_debug; +extern bool All_Done,spell_forced,monsters_going; +extern bool party_in_memory; // game info globals extern sf::RenderWindow mainPtr; @@ -108,7 +105,7 @@ extern short current_pc; extern short combat_active_pc; extern eStatMode stat_screen_mode; -extern bool map_visible,diff_depth_ok; +extern bool map_visible; extern sf::RenderWindow mini_map; extern location ul; @@ -943,8 +940,6 @@ static void handle_victory() { univ.clear_stored_pcs(); reload_startup(); overall_mode = MODE_STARTUP; - in_scen_debug = false; - ghost_mode = false; draw_startup(0); menu_activate(); univ.party.scen_name = ""; // should be harmless... @@ -1018,8 +1013,6 @@ bool handle_action(sf::Event event) { return false; } - num_chirps_played = 0; - // MARK: First, figure out where party is switch(overall_mode) { case MODE_OUTDOORS: case MODE_LOOK_OUTDOORS: @@ -1795,11 +1788,11 @@ bool handle_keystroke(sf::Event& event){ case 'D': - if(in_scen_debug) { - in_scen_debug = false; + if(univ.debug_mode) { + univ.debug_mode = false; ASB("Debug mode OFF."); } else { - in_scen_debug = true; + univ.debug_mode = true; ASB("Debug mode ON."); } print_buf(); @@ -1815,7 +1808,7 @@ bool handle_keystroke(sf::Event& event){ break; case '=': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; univ.party.gold += 100; univ.party.food += 100; for(i = 0; i < 6; i++) { @@ -1836,7 +1829,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'B': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; if(overall_mode == MODE_OUTDOORS){ add_string_to_buf("Debug - Leave Town: You're not in town!"); print_buf(); @@ -1852,7 +1845,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'C': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; univ.party.clear_bad_status(); add_string_to_buf("Debug: You get cleaned up!"); print_buf(); @@ -1860,7 +1853,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'E': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; univ.party.status[ePartyStatus::STEALTH] += 10; univ.party.status[ePartyStatus::DETECT_LIFE] += 10; univ.party.status[ePartyStatus::FIREWALK] += 10; @@ -1871,7 +1864,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'F': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; if(overall_mode != MODE_OUTDOORS){ add_string_to_buf("Debug: Can only fly outdoors."); }else{ @@ -1883,19 +1876,19 @@ bool handle_keystroke(sf::Event& event){ break; case 'G': - if(!in_scen_debug) break; - if(ghost_mode){ - ghost_mode = false; + if(!univ.debug_mode) break; + if(univ.ghost_mode){ + univ.ghost_mode = false; ASB("Debug: Ghost mode OFF."); }else{ - ghost_mode = true; + univ.ghost_mode = true; ASB("Debug:Ghost mode ON."); } print_buf(); break; case 'H': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; univ.party.gold += 100; univ.party.food += 100; for(i = 0; i < 6; i++) { @@ -1910,7 +1903,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'K': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; for(i = 0; i < univ.town.monst.size(); i++) { if(is_combat() && univ.town.monst[i].active > 0 && !univ.town.monst[i].is_friendly()) univ.town.monst[i].active = 0; @@ -1926,12 +1919,12 @@ bool handle_keystroke(sf::Event& event){ break; case 'N': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; handle_victory(); break; case 'O': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; if(is_town()) { sout << "Debug: You're at x " << (short) univ.town.p_loc.x << ", y " << (short) univ.town.p_loc.y << " in town " << univ.town.num << '.'; @@ -1950,7 +1943,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'I': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; i = get_num_response(0, univ.scenario.scen_items.size()-1, "Which item?"); j = univ.scenario.scen_items[i].ident; univ.scenario.scen_items[i].ident = true; @@ -1962,7 +1955,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'Q': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; if(overall_mode == MODE_OUTDOORS) { for(i = 0; i < 96; i++) for(j = 0; j < 96; j++) @@ -1978,7 +1971,7 @@ bool handle_keystroke(sf::Event& event){ break; case 'R': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; if(univ.party.in_boat >= 0) { add_string_to_buf(" Not while in boat."); break; @@ -1998,12 +1991,12 @@ bool handle_keystroke(sf::Event& event){ break; case 'S': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; edit_stuff_done(); break; case 'T': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; short find_direction_from; i = get_num_response(0, univ.scenario.towns.size() - 1, "Enter Town Number"); if(i >= 0 && i < univ.scenario.towns.size()) { @@ -2016,14 +2009,14 @@ bool handle_keystroke(sf::Event& event){ break; case 'W': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; refresh_store_items(); add_string_to_buf("Debug: Refreshed jobs/shops."); print_buf(); break; case '<': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; ASB("Debug: Increase age."); ASB(" It is now 1 day later."); print_buf(); @@ -2031,7 +2024,7 @@ bool handle_keystroke(sf::Event& event){ put_pc_screen(); break; case '>': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; ASB("DEBUG: Towns have short memory."); ASB("Your deeds have been forgotten."); print_buf(); @@ -2039,18 +2032,18 @@ bool handle_keystroke(sf::Event& event){ univ.party.creature_save[i].which_town = 200; break; case '!': - if(!in_scen_debug) break; - if(node_step_through) { - node_step_through = false; + if(!univ.debug_mode) break; + if(univ.node_step_through) { + univ.node_step_through = false; add_string_to_buf("Debug: Step-through disabled"); } else { - node_step_through = true; + univ.node_step_through = true; add_string_to_buf("Debug: Step-through enabled"); } print_buf(); break; case '/': - if(!in_scen_debug) break; + if(!univ.debug_mode) break; cChoiceDlog("help-debug").show(); break; case 'a': @@ -2833,7 +2826,7 @@ bool outd_move_party(location destination,bool forced) { keep_going = check_special_terrain(destination,eSpecCtx::OUT_MOVE,univ.party[0],&check_f); if(check_f) forced = true; - if(in_scen_debug && ghost_mode) + if(univ.debug_mode && univ.ghost_mode) forced = keep_going = true; // If not blocked and not put in town by a special, process move @@ -3034,7 +3027,7 @@ bool town_move_party(location destination,short forced) { keep_going = check_special_terrain(destination,eSpecCtx::TOWN_MOVE,univ.party[0],&check_f); if(check_f) forced = true; - if(in_scen_debug && ghost_mode) + if(univ.debug_mode && univ.ghost_mode) forced = keep_going = true; ter = univ.town->terrain(destination.x,destination.y); diff --git a/src/boe.combat.cpp b/src/boe.combat.cpp index cf76729b..07ada28a 100644 --- a/src/boe.combat.cpp +++ b/src/boe.combat.cpp @@ -25,7 +25,6 @@ #include "prefs.hpp" extern eGameMode overall_mode; -extern bool ghost_mode; extern short which_combat_type; extern short stat_window; extern location center; @@ -40,7 +39,6 @@ extern short store_spell_target,pc_casting,current_spell_range; extern effect_pat_type current_pat; extern short num_targets_left; extern location spell_targets[8]; -extern bool in_scen_debug; extern short fast_bang; extern short store_current_pc; extern short combat_posing_monster , current_working_monster ; // 0-5 PC 100 + x - monster x @@ -395,7 +393,7 @@ bool pc_combat_move(location destination) { if(check_f) forced = true; - if(in_scen_debug && ghost_mode) forced = true; + if(univ.debug_mode && univ.ghost_mode) forced = true; if(keep_going) { @@ -2278,7 +2276,7 @@ void do_monster_turn() { } if(cur_monst->status[eStatus::ASLEEP] > 0 || cur_monst->status[eStatus::PARALYZED] > 0) cur_monst->ap = 0; - if(in_scen_debug) + if(univ.debug_mode) cur_monst->ap = 0; center_on_monst = false; diff --git a/src/boe.fileio.cpp b/src/boe.fileio.cpp index 16313fdc..1deb365b 100644 --- a/src/boe.fileio.cpp +++ b/src/boe.fileio.cpp @@ -26,7 +26,7 @@ extern eStatMode stat_screen_mode; extern eGameMode overall_mode; -extern bool party_in_memory,in_scen_debug,ghost_mode,node_step_through; +extern bool party_in_memory; extern location center; extern long register_flag; extern sf::RenderWindow mainPtr; @@ -63,9 +63,6 @@ void finish_load_party(){ bool in_scen = univ.party.scen_name.length() > 0; party_in_memory = true; - in_scen_debug = false; - ghost_mode = false; - node_step_through = false; // now if not in scen, this is it. if(!in_scen) { @@ -130,8 +127,6 @@ void finish_load_party(){ store_file_reply = file_to_load; add_string_to_buf("Load: Game loaded."); - - in_scen_debug = false; } void shift_universe_left() { diff --git a/src/boe.graphics.cpp b/src/boe.graphics.cpp index 97435442..bea7277a 100644 --- a/src/boe.graphics.cpp +++ b/src/boe.graphics.cpp @@ -35,7 +35,7 @@ extern sf::RenderWindow mainPtr; extern short stat_window; extern eGameMode overall_mode; extern short current_spell_range; -extern bool anim_onscreen,frills_on,party_in_memory; +extern bool anim_onscreen,party_in_memory; extern bool flushingInput; extern bool cartoon_happening, fog_lifted; extern short anim_step; @@ -729,6 +729,7 @@ void draw_terrain(short mode) { char can_draw; ter_num_t spec_terrain; bool off_terrain = false,draw_frills = true; + bool frills_on = get_bool_pref("DrawTerrainShoreFrills", true); short i,j; if(overall_mode == MODE_TALKING || overall_mode == MODE_SHOPPING || overall_mode == MODE_STARTUP) @@ -1168,7 +1169,7 @@ void draw_trim(short q,short r,short which_trim,ter_num_t ground_ter) { } sf::Color test_color = {0,0,0}, store_color; - if(!frills_on) + if(!get_bool_pref("DrawTerrainShoreFrills", true)) return; unsigned short pic = univ.scenario.ter_types[ground_ter].picture; diff --git a/src/boe.graphutil.cpp b/src/boe.graphutil.cpp index 823816ce..da1b2fff 100644 --- a/src/boe.graphutil.cpp +++ b/src/boe.graphutil.cpp @@ -26,7 +26,7 @@ extern short stat_window; extern bool cartoon_happening; extern eGameMode overall_mode; extern short current_spell_range; -extern bool anim_onscreen,frills_on; +extern bool anim_onscreen; extern cUniverse univ; extern effect_pat_type current_pat; extern sf::RenderWindow mini_map; diff --git a/src/boe.items.cpp b/src/boe.items.cpp index 39725f14..22952f6e 100644 --- a/src/boe.items.cpp +++ b/src/boe.items.cpp @@ -36,7 +36,7 @@ extern bool allow_junk_treasure; extern rectangle d_rects[80]; extern short d_rect_index[80]; -extern bool map_visible,diff_depth_ok; +extern bool map_visible; extern sf::RenderWindow mini_map; extern sf::Texture pc_gworld; extern cUniverse univ; diff --git a/src/boe.main.cpp b/src/boe.main.cpp index 697d76f5..10a39790 100644 --- a/src/boe.main.cpp +++ b/src/boe.main.cpp @@ -39,7 +39,7 @@ sf::Event event; sf::RenderWindow mainPtr; short had_text_freeze = 0,num_fonts; bool first_startup_update = true; -bool diff_depth_ok = false,first_sound_played = false,spell_forced = false; +bool first_sound_played = false,spell_forced = false; bool party_in_memory = false; std::shared_ptr text_sbar, item_sbar, shop_sbar; std::shared_ptr done_btn, help_btn; @@ -60,8 +60,7 @@ signed char dir_x_dif[9] = {0,1,1,1,0,-1,-1,-1,0}; signed char dir_y_dif[9] = {-1,-1,0,1,1,1,0,-1,0}; extern bool map_visible; -bool in_scen_debug = false; -bool belt_present = false; + std::string scenario_temp_dir_name = "scenario"; /* Display globals */ @@ -70,16 +69,14 @@ short fast_bang = false; // Note: This mostly behaves as a boolean variable, but std::vector spec_item_array; short current_spell_range; eGameMode overall_mode = MODE_STARTUP; -bool first_update = true,anim_onscreen = false,frills_on = true,changed_display_mode = false; -short stat_window = 0,store_modifier; +bool anim_onscreen = false,changed_display_mode = false; +short stat_window = 0; bool monsters_going = false,boom_anim_active = false; bool finished_init = false; sf::RenderWindow mini_map; short which_item_page[6] = {0,0,0,0,0,0}; // Remembers which of the 2 item pages pc looked at location ul = {28,10}; -long stored_key; -short pixel_depth,old_depth = 8; short current_ground = 0; eStatMode stat_screen_mode; short anim_step = -1; diff --git a/src/boe.party.cpp b/src/boe.party.cpp index 2582bf6f..039536ae 100644 --- a/src/boe.party.cpp +++ b/src/boe.party.cpp @@ -78,7 +78,6 @@ extern location golem_m_locs[16]; extern cUniverse univ; extern sf::Texture pc_gworld; extern std::queue special_queue; -extern bool in_scen_debug, ghost_mode, node_step_through; // First icon is displayed for positive values, second for negative, if -1 no negative icon. // This omits two special cases - major poison, and normal speed; they are hard-coded. @@ -239,9 +238,9 @@ void put_party_in_scen(std::string scen_name) { bool item_took = false; // Drop debug mode - in_scen_debug = false; - ghost_mode = false; - node_step_through = false; + univ.debug_mode = false; + univ.ghost_mode = false; + univ.node_step_through = false; for(j = 0; j < 6; j++) { univ.party[j].status.clear(); diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 07f56b36..9bd0e29d 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -37,7 +37,7 @@ extern sf::RenderWindow mainPtr; extern eGameMode overall_mode; extern short which_combat_type,current_pc,stat_window; extern location center; -extern bool in_scen_debug,node_step_through,belt_present,processing_fields,monsters_going,boom_anim_active; +extern bool processing_fields,monsters_going,boom_anim_active; extern effect_pat_type single,t,square,radius2,radius3,small_square,open_square,field[8]; extern effect_pat_type current_pat; extern cOutdoors::cWandering store_wandering_special; @@ -1515,7 +1515,7 @@ bool damage_monst(cCreature& victim, short who_hit, short how_much, eDamageType victim.damaged_msg(how_much,0); victim.health = victim.health - how_much; - if(in_scen_debug) + if(univ.debug_mode) victim.health = -1; // splitting monsters @@ -1611,7 +1611,7 @@ void kill_monst(cCreature& which_m,short who_killed,eMainStatus type) { if(which_m.abil[eMonstAbil::DEATH_TRIGGER].active) run_special(eSpecCtx::KILL_MONST,0,which_m.abil[eMonstAbil::DEATH_TRIGGER].special.extra1,which_m.cur_loc,&s1,&s2,&s3); - if(!in_scen_debug && (which_m.summon_time == 0 || !which_m.party_summoned)) { // no xp for party-summoned monsters + if(!univ.debug_mode && (which_m.summon_time == 0 || !which_m.party_summoned)) { // no xp for party-summoned monsters xp = which_m.level * 2; if(who_killed < 6) award_xp(who_killed,xp); @@ -1626,7 +1626,7 @@ void kill_monst(cCreature& which_m,short who_killed,eMainStatus type) { place_glands(l,which_m.number); } - if(!in_scen_debug && which_m.summon_time == 0) + if(!univ.debug_mode && which_m.summon_time == 0) place_treasure(which_m.cur_loc, which_m.level / 2, which_m.treasure, 0); i = which_m.cur_loc.x; @@ -1673,7 +1673,7 @@ void push_things() { if(is_out()) // TODO: Make these work outdoors return; - if(!belt_present) + if(!univ.town.belt_present) return; for(i = 0; i < univ.town.monst.size(); i++) @@ -2018,7 +2018,7 @@ void run_special(eSpecCtx which_mode,short which_type,short start_spec,location next_spec = -1; cur_node = get_node(cur_spec,cur_spec_type); - if(node_step_through) { + if(univ.node_step_through) { give_help(68,69); std::string debug = "Step: "; debug += (*cur_node.type).name(); @@ -2032,7 +2032,7 @@ void run_special(eSpecCtx which_mode,short which_type,short start_spec,location break; } if(evt.type == sf::Event::KeyPressed && evt.key.code == sf::Keyboard::Escape) - node_step_through = false; + univ.node_step_through = false; } // Convert pointer values to reference values @@ -2063,7 +2063,7 @@ void run_special(eSpecCtx which_mode,short which_type,short start_spec,location } switch(getNodeCategory(cur_node.type)) { case eSpecCat::GENERAL: - if(cur_node.type == eSpecType::NONE && in_scen_debug) { + if(cur_node.type == eSpecType::NONE && univ.debug_mode) { std::string type("???"); switch(cur_spec_type) { case 0: type = "scenario"; break; @@ -2348,7 +2348,7 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, } break; case eSpecType::PRINT_NUMS: - if(!in_scen_debug) break; + if(!univ.debug_mode) break; check_mess = false; get_strs(str1,str2, cur_spec_type,cur_node.m1, cur_node.m2); if(cur_node.m1 >= 0) diff --git a/src/boe.town.cpp b/src/boe.town.cpp index bb6905dc..2cded58a 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -37,7 +37,7 @@ extern short store_current_pc,current_ground; extern eGameMode store_pre_shop_mode,store_pre_talk_mode; extern std::queue special_queue; -extern bool map_visible,diff_depth_ok; +extern bool map_visible; extern sf::RenderWindow mini_map; extern location hor_vert_place[14]; diff --git a/src/classes/universe.hpp b/src/classes/universe.hpp index 56fc1bb4..f22f68bb 100644 --- a/src/classes/universe.hpp +++ b/src/classes/universe.hpp @@ -181,6 +181,7 @@ public: cCurOut out; unsigned char out_maps[100][6][48]; // formerly stored_outdoor_maps_type fs::path file; + bool debug_mode, ghost_mode, node_step_through; void clear_stored_pcs(); void append(legacy::stored_town_maps_type& old); diff --git a/src/pcedit/pc.action.cpp b/src/pcedit/pc.action.cpp index 51ffa1a0..2f1a2830 100644 --- a/src/pcedit/pc.action.cpp +++ b/src/pcedit/pc.action.cpp @@ -18,7 +18,6 @@ extern cUniverse univ; extern sf::RenderWindow mainPtr; extern fs::path file_in_mem; extern sf::Texture pc_gworld; -extern bool diff_depth_ok; short which_pc_displayed,store_pc_trait_mode,store_which_to_edit; extern short current_active_pc; diff --git a/src/pcedit/pc.editors.cpp b/src/pcedit/pc.editors.cpp index cbccc94d..fc574f04 100644 --- a/src/pcedit/pc.editors.cpp +++ b/src/pcedit/pc.editors.cpp @@ -40,7 +40,7 @@ extern sf::RenderWindow mainPtr; extern rectangle d_rects[80]; extern short d_rect_index[80]; -extern bool diff_depth_ok,current_file_has_maps; +extern bool current_file_has_maps; bool choice_active[6]; extern short which_pc_displayed; diff --git a/src/pcedit/pc.main.cpp b/src/pcedit/pc.main.cpp index 0e8db944..e1592f2d 100644 --- a/src/pcedit/pc.main.cpp +++ b/src/pcedit/pc.main.cpp @@ -42,7 +42,7 @@ std::string scenario_temp_dir_name = "pc_scenario"; short current_active_pc = 0; /* Mac stuff globals */ -bool All_Done = false,diff_depth_ok = false; +bool All_Done = false; sf::Event event; sf::RenderWindow mainPtr; bool gInBackground = false; diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index ec2e6983..87add3b2 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -30,14 +30,13 @@ bool All_Done = false; sf::Event event; sf::RenderWindow mainPtr; cTown* town = nullptr; -bool diff_depth_ok = false,mouse_button_held = false,editing_town = false; +bool mouse_button_held = false,editing_town = false; short cur_viewing_mode = 0; short cen_x, cen_y; eScenMode overall_mode = MODE_INTRO_SCREEN; std::shared_ptr right_sbar, pal_sbar; short mode_count = 0; cOutdoors* current_terrain; -short pixel_depth,old_depth = 8; std::string scenario_temp_dir_name = "ed_scenario"; bool change_made = false, ae_loading = false;