From 22ca77fa77d165033dcebef8fcb7aa6e026698ae Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 1 Sep 2015 14:41:53 -0400 Subject: [PATCH] Some cleanup --- src/boe.actions.cpp | 37 +++++++++++++--------- src/boe.dlgutil.cpp | 3 +- src/boe.graphics.cpp | 63 +++++++++++++++++--------------------- src/boe.graphutil.cpp | 12 +++----- src/boe.newgraph.cpp | 14 +++++---- src/boe.specials.cpp | 1 - src/boe.text.cpp | 12 +++----- src/classes/pc.cpp | 26 ++++++++-------- src/pcedit/pc.graphics.cpp | 3 +- src/tools/graphtool.cpp | 15 +++------ 10 files changed, 87 insertions(+), 99 deletions(-) diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index a67ec07a..49cd632d 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -38,17 +38,21 @@ rectangle bottom_buttons[14]; rectangle world_screen = {23, 23, 346, 274}; -// TODO: The duplication of rectangle here shouldn't be necessary... rectangle item_screen_button_rects[9] = { - rectangle{125,10,141,28},rectangle{125,40,141,58},rectangle{125,68,141,86},rectangle{125,98,141,116},rectangle{125,126,141,144},rectangle{125,156,141,174}, - rectangle{126,176,141,211}, - rectangle{126,213,141,248}, - rectangle{127,251,140,267}}; + {125,10,141,28},{125,40,141,58},{125,68,141,86},{125,98,141,116},{125,126,141,144},{125,156,141,174}, + {126,176,141,211}, + {126,213,141,248}, + {127,251,140,267} +}; -rectangle border_rect[4] = {rectangle{5, 5, 15, 283}, rectangle{5, 5, 355, 15}, - rectangle{345, 5, 355, 283}, rectangle{5, 273, 355, 283}}; -rectangle medium_buttons[4] = {rectangle{383,190,401,225}, rectangle{402, 190, 420, 225}, - rectangle{383, 227, 401, 263}, rectangle{402, 227,420, 263}}; ; +rectangle border_rect[4] = { + {5, 5, 15, 283}, {5, 5, 355, 15}, + {345, 5, 355, 283}, {5, 273, 355, 283} +}; +rectangle medium_buttons[4] = { + {383,190,401,225}, {402, 190, 420, 225}, + {383, 227, 401, 263}, {402, 227,420, 263} +}; rectangle item_buttons[8][6]; // name, use, give, drip, info, sell/id @@ -1615,11 +1619,16 @@ bool handle_keystroke(sf::Event& event){ using kb = sf::Keyboard; using Key = sf::Keyboard::Key; - Key keypad[10] = {kb::Numpad0,kb::Numpad1,kb::Numpad2,kb::Numpad3,kb::Numpad4,kb::Numpad5,kb::Numpad6,kb::Numpad7,kb::Numpad8,kb::Numpad9}; - // TODO: The duplication of location here shouldn't be necessary... - location terrain_click[10] = {location{150,185},location{120,215},location{150,215},location{180,215}, - location{120,185},location{150,185},location{180,185}, - location{120,155},location{150,155},location{180,135}}; + Key keypad[10] = { + kb::Numpad0,kb::Numpad1,kb::Numpad2,kb::Numpad3, + kb::Numpad4,kb::Numpad5,kb::Numpad6, + kb::Numpad7,kb::Numpad8,kb::Numpad9 + }; + location terrain_click[10] = { + {150,185},{120,215},{150,215},{180,215}, + {120,185},{150,185},{180,185}, + {120,155},{150,155},{180,135} + }; Key talk_chars[9] = {kb::L,kb::N,kb::J,kb::B,kb::S,kb::R,kb::D,kb::G,kb::A}; Key shop_chars[8] = {kb::A,kb::B,kb::C,kb::D,kb::E,kb::F,kb::G,kb::H}; diff --git a/src/boe.dlgutil.cpp b/src/boe.dlgutil.cpp index 2941d9a0..8f90792b 100644 --- a/src/boe.dlgutil.cpp +++ b/src/boe.dlgutil.cpp @@ -92,8 +92,7 @@ extern std::vector talk_words; // talk_area_rect and talk_help_rect used for this too eGameMode store_pre_shop_mode; extern rectangle shopping_rects[8][7]; -// TODO: The duplication of rectangle here shouldn't be necessary... -rectangle bottom_help_rects[4] = {rectangle{356,6,368,250},rectangle{374,6,386,270},rectangle{386,6,398,250},rectangle{398,6,410,250}}; +rectangle bottom_help_rects[4] = {{356,6,368,250},{374,6,386,270},{386,6,398,250},{398,6,410,250}}; rectangle shop_name_str = {44,6,56,200}; rectangle shop_frame = {62,10,352,269}; rectangle shop_done_rect = {388,212,411,275}; diff --git a/src/boe.graphics.cpp b/src/boe.graphics.cpp index 6c71ab7e..edc48b60 100644 --- a/src/boe.graphics.cpp +++ b/src/boe.graphics.cpp @@ -73,17 +73,13 @@ long anim_ticks = 0; // 0 - terrain 1 - buttons 2 - pc stats // 3 - item stats 4 - text bar 5 - text area (not right) -// TODO: The duplication of rectangle here shouldn't be necessary... -rectangle win_from_rects[6] = {rectangle{0,0,350,278},rectangle{0,0,37,258},rectangle{0,0,115,288},rectangle{0,0,143,288},rectangle{0,0,21,279},rectangle{0,0,0,288}}; -rectangle win_to_rects[6] = {rectangle{5,5,356,284},rectangle{383,5,421,271},rectangle{0,0,116,271},rectangle{0,0,144,271},rectangle{358,5,379,284},rectangle{0,0,138,256}}; +rectangle win_from_rects[6] = {{0,0,350,278},{0,0,37,258},{0,0,115,288},{0,0,143,288},{0,0,21,279},{0,0,0,288}}; +rectangle win_to_rects[6] = {{5,5,356,284},{383,5,421,271},{0,0,116,271},{0,0,144,271},{358,5,379,284},{0,0,138,256}}; // 0 - title 1 - button 2 - credits 3 - base button -rectangle startup_from[4] = {rectangle{0,0,274,602},rectangle{274,0,322,301},rectangle{0,301,67,579},rectangle{274,301,314,341}}; //// +rectangle startup_from[4] = {{0,0,274,602},{274,0,322,301},{0,301,67,579},{274,301,314,341}}; extern rectangle startup_button[6]; -// rectangle trim_rects[8] = {{0,0,5,28},{31,0,36,28},{0,0,36,5},{0,24,36,28}, -// {0,0,5,5},{0,24,5,28},{31,24,36,28},{31,0,36,5}}; - rectangle top_left_rec = {0,0,36,28}; short which_graphic_index[6] = {50,50,50,50,50,50}; @@ -1241,17 +1237,16 @@ void draw_trim(short q,short r,short which_trim,ter_num_t ground_ter) { // 50 - walkway bl, 51 - walkway tl, 52 - walkway tr, 53 - walkway br // 54 - walkway top, 55 - walkway right, 56 - walkway bottom, 57 - walkway left // 58 - lone walkway - // TODO: The duplication of rectangle here shouldn't be necessary... static rectangle trim_rects[12] = { - rectangle{0,0,36,14}, rectangle{0,0,36,14}, - rectangle{0,0,18,28}, rectangle{0,0,18,28}, - rectangle{0,0,18,14}, rectangle{0,0,18,14}, rectangle{0,0,18,14}, rectangle{0,0,18,14}, - rectangle{0,0,18,14}, rectangle{0,0,18,14}, rectangle{0,0,18,14}, rectangle{0,0,18,14}, + {0,0,36,14}, {0,0,36,14}, + {0,0,18,28}, {0,0,18,28}, + {0,0,18,14}, {0,0,18,14}, {0,0,18,14}, {0,0,18,14}, + {0,0,18,14}, {0,0,18,14}, {0,0,18,14}, {0,0,18,14}, }; static rectangle walkway_rects[9] = { - rectangle{0,0,36,28}, rectangle{0,0,36,28}, rectangle{0,0,36,28}, rectangle{0,0,36,28}, - rectangle{0,0,36,28}, rectangle{0,0,36,28}, rectangle{0,0,36,28}, rectangle{0,0,36,28}, - rectangle{0,0,36,28}, + {0,0,36,28}, {0,0,36,28}, {0,0,36,28}, {0,0,36,28}, + {0,0,36,28}, {0,0,36,28}, {0,0,36,28}, {0,0,36,28}, + {0,0,36,28}, }; static std::unique_ptr trim_masks[12], walkway_masks[9]; rectangle from_rect = {0,0,36,28},to_rect; @@ -1379,22 +1374,19 @@ void place_road(short q,short r,location where, bool here) { location draw_loc; ter_num_t ter = coord_to_ter(where.x, where.y); rectangle to_rect; - //rectangle road_rects[2] = {{76,112,80,125},{72,144,90,148}}; // 0 - rl partial 1 - ud partial - // TODO: The duplication of rectangle here shouldn't be necessary... static const rectangle road_rects[4] = { - rectangle{4,112,8,125}, // horizontal partial - rectangle{0,144,18,148}, // vertical partial - rectangle{0,112,4,140}, // horizontal full - rectangle{0,140,36,144}, // vertical full + {4,112,8,125}, // horizontal partial + {0,144,18,148}, // vertical partial + {0,112,4,140}, // horizontal full + {0,140,36,144}, // vertical full }; - //rectangle road_dest_rects[4] = {{0,12,18,16},{16,15,20,28},{18,12,36,16},{16,0,20,13}}; // top right bottom left static const rectangle road_dest_rects[6] = { - rectangle{0,12,18,16}, // top - rectangle{16,15,20,28}, // right - rectangle{18,12,36,16}, // bottom - rectangle{16,0,20,13}, // left - rectangle{0,12,36,16}, // top + bottom - rectangle{16,0,20,28}, // right + left + {0,12,18,16}, // top + {16,15,20,28}, // right + {18,12,36,16}, // bottom + {16,0,20,13}, // left + {0,12,36,16}, // top + bottom + {16,0,20,28}, // right + left }; draw_loc.x = q; draw_loc.y = r; @@ -1614,15 +1606,16 @@ void boom_space(location where,short mode,short type,short damage,short sound) { void draw_pointing_arrows() { - // TODO: The duplication of rectangle here shouldn't be necessary... rectangle sources[4] = { - rectangle{351,28,359,36}, // up - rectangle{351,10,359,18}, // left - rectangle{351,01,359,9}, // down - rectangle{351,19,359,27} // right + {351,28,359,36}, // up + {351,10,359,18}, // left + {351,01,359,9}, // down + {351,19,359,27} // right + }; + rectangle dests[8] = { + {7,100,15,108},{7,170,15,178},{140,7,148,15},{212,7,220,15}, + {346,100,354,108},{346,170,354,178},{140,274,148,282},{212,274,220,282} }; - rectangle dests[8] = {rectangle{7,100,15,108},rectangle{7,170,15,178},rectangle{140,7,148,15},rectangle{212,7,220,15}, - rectangle{346,100,354,108},rectangle{346,170,354,178},rectangle{140,274,148,282},rectangle{212,274,220,282}}; short i; if(monsters_going || !scrollableModes.count(overall_mode)) diff --git a/src/boe.graphutil.cpp b/src/boe.graphutil.cpp index 164238b4..637d0bb7 100644 --- a/src/boe.graphutil.cpp +++ b/src/boe.graphutil.cpp @@ -56,8 +56,7 @@ extern location ok_space[4]; extern bool can_draw_pcs; extern cCustomGraphics spec_scen_g; -// TODO: The duplication of rectangle here shouldn't be necessary... -rectangle boat_rects[4] = {rectangle{0,0,36,28}, rectangle{0,28,36,56},rectangle{0,56,36,84},rectangle{0,84,36,112}}; +rectangle boat_rects[4] = {{0,0,36,28}, {0,28,36,56},{0,56,36,84},{0,84,36,112}}; bool gave_no_g_error = false; //short dest; // 0 - terrain gworld 1 - screen @@ -124,12 +123,11 @@ void draw_monsters() { location where_draw,store_loc; short picture_wanted; ter_num_t ter; - // TODO: The duplication of rectangle here shouldn't be necessary... rectangle monst_rects[4][4] = { - {rectangle{0,0,36,28}}, - {rectangle{0,7,18,21},rectangle{18,7,36,21}}, - {rectangle{9,0,27,14},rectangle{9,14,27,28}}, - {rectangle{0,0,18,14},rectangle{0,14,18,28},rectangle{18,0,36,14},rectangle{18,14,36,28}} + {{0,0,36,28}}, + {{0,7,18,21},{18,7,36,21}}, + {{9,0,27,14},{9,14,27,28}}, + {{0,0,18,14},{0,14,18,28},{18,0,36,14},{18,14,36,28}} }; if(is_out()) diff --git a/src/boe.newgraph.cpp b/src/boe.newgraph.cpp index 49f23dcc..1e3cfa33 100644 --- a/src/boe.newgraph.cpp +++ b/src/boe.newgraph.cpp @@ -662,10 +662,11 @@ void draw_shop_graphics(bool pressed,rectangle clip_area_rect) { short i; // In the 0..65535 range, these blue components were: 0, 32767, 14535, 26623, 59391 // The green components on the second line were 40959 and 24575 - // TODO: The duplication of sf::Color here shouldn't be necessary... // TODO: The Windows version appears to use completely different colours? - sf::Color c[7] = {sf::Color{0,0,0},sf::Color{0,0,128},sf::Color{0,0,57},sf::Color{0,0,104},sf::Color{0,0,232}, - sf::Color{0,160,0},sf::Color{0,96,0}}; + sf::Color c[7] = { + {0,0,0},{0,0,128},{0,0,57},{0,0,104},{0,0,232}, + {0,160,0},{0,96,0} + }; rectangle shopper_name = {44,6,56,260}; long current_pos; @@ -945,9 +946,10 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col // In the 0..65535 range, these blue components were: 0, 32767, 14535, 26623, 59391 // The green components on the second line were 40959 and 24575 - // TODO: The duplication of sf::Color here shouldn't be necessary... - sf::Color c[8] = {sf::Color{0,0,0},sf::Color{0,0,128},sf::Color{0,0,57},sf::Color{0,0,104},sf::Color{0,0,232}, - sf::Color{0,160,0},sf::Color{0,96,0},sf::Color(160,0,20)}; + sf::Color c[8] = { + {0,0,0},{0,0,128},{0,0,57},{0,0,104},{0,0,232}, + {0,160,0},{0,96,0},{160,0,20} + }; talk_gworld.setActive(); diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 3f765905..d90f9340 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -4290,7 +4290,6 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, if(i >= 100) { std::set checked; std::queue to_check; - cCreature& who = dynamic_cast(univ.get_target(i)); location cur_check = l; for(int tries = 0; tries < 100 && !monst_can_be_there(cur_check, i - 100); tries++) { for(int x = -1; x <= 1; x++) { diff --git a/src/boe.text.cpp b/src/boe.text.cpp index f6a115eb..fa175123 100644 --- a/src/boe.text.cpp +++ b/src/boe.text.cpp @@ -29,10 +29,10 @@ bool save_mess_given = false; rectangle status_panel_clip_rect = {11, 299, 175, 495},item_panel_clip_rect = {11,297,175,463}; -// TODO: The duplication of rectangle here shouldn't be necessary... rectangle item_buttons_from[7] = { - rectangle{11,0,24,14},rectangle{11,14,24,28},rectangle{11,28,24,42},rectangle{11,42,24,56}, - rectangle{24,0,36,30},rectangle{24,30,36,60},rectangle{36,0,48,30}}; + {11,0,24,14},{11,14,24,28},{11,28,24,42},{11,42,24,56}, + {24,0,36,30},{24,30,36,60},{36,0,48,30} +}; eGameMode store_mode; @@ -367,8 +367,7 @@ void put_item_screen(short screen_num) { void place_buy_button(short position,short pc_num,short item_num) { rectangle dest_rect,source_rect; - // TODO: The duplication of rectangle here shouldn't be necessary... - rectangle button_sources[3] = {rectangle{24,0,36,30},rectangle{36,0,48,30},rectangle{48,0,60,30}}; + rectangle button_sources[3] = {{24,0,36,30},{36,0,48,30},{48,0,60,30}}; short val_to_place; // TODO: This is now duplicated here and in start_town_mode() short aug_cost[10] = {4,7,10,8, 15,15,10, 0,0,0}; @@ -607,8 +606,7 @@ short first_active_pc() { void refresh_stat_areas(short mode) { short i; sf::BlendMode x; - // TODO: The duplication of rectangle here shouldn't be necessary... - rectangle dest_rect,parts_of_area_to_draw[3] = {rectangle{0,0,17,271},rectangle{16,0,123,256},rectangle{123,0,144,271}}; + rectangle dest_rect,parts_of_area_to_draw[3] = {{0,0,17,271},{16,0,123,256},{123,0,144,271}}; dest_rect = rectangle(pc_stats_gworld); rectangle oldRect = dest_rect; diff --git a/src/classes/pc.cpp b/src/classes/pc.cpp index e4afe401..9cf0901e 100644 --- a/src/classes/pc.cpp +++ b/src/classes/pc.cpp @@ -918,29 +918,28 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : cPlayer(party) { race = eRace::HUMAN; direction = DIR_N; }else if(key == 'dflt'){ - // TODO: The duplication of std::map shouldn't be needed here static std::map pc_stats[6] = { - std::map{ + { {eSkill::STRENGTH,8}, {eSkill::DEXTERITY,6}, {eSkill::INTELLIGENCE,2}, {eSkill::EDGED_WEAPONS,6}, {eSkill::ITEM_LORE,1}, {eSkill::ASSASSINATION,2}, - }, std::map{ + }, { {eSkill::STRENGTH,8}, {eSkill::DEXTERITY,7}, {eSkill::INTELLIGENCE,2}, {eSkill::POLE_WEAPONS,6}, {eSkill::THROWN_MISSILES,3}, {eSkill::DEFENSE,3}, {eSkill::POISON,2}, - }, std::map{ + }, { {eSkill::STRENGTH,8}, {eSkill::DEXTERITY,6}, {eSkill::INTELLIGENCE,2}, {eSkill::EDGED_WEAPONS,3}, {eSkill::BASHING_WEAPONS,3}, {eSkill::ARCHERY,2}, {eSkill::DISARM_TRAPS,4}, {eSkill::LOCKPICKING,4}, {eSkill::POISON,2}, {eSkill::LUCK,1}, - }, std::map{ + }, { {eSkill::STRENGTH,3}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6}, {eSkill::EDGED_WEAPONS,2}, {eSkill::THROWN_MISSILES,2}, {eSkill::MAGE_SPELLS,3}, {eSkill::MAGE_LORE,3}, {eSkill::ITEM_LORE,1}, - }, std::map{ + }, { {eSkill::STRENGTH,2}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6}, {eSkill::EDGED_WEAPONS,3}, {eSkill::THROWN_MISSILES,2}, {eSkill::MAGE_SPELLS,2}, {eSkill::PRIEST_SPELLS,1}, {eSkill::MAGE_LORE,4}, {eSkill::LUCK,1}, - }, std::map{ + }, { {eSkill::STRENGTH,2}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6}, {eSkill::BASHING_WEAPONS,2}, {eSkill::THROWN_MISSILES,2}, {eSkill::DEFENSE,1}, {eSkill::PRIEST_SPELLS,3}, {eSkill::MAGE_LORE,3}, {eSkill::ALCHEMY,2}, @@ -950,14 +949,13 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : cPlayer(party) { static const short pc_sp[6] = {0,0,0,20,20,21}; static const short pc_graphics[6] = {3,32,29,16,23,14}; static const short pc_race[6] = {0,2,1,0,0,0}; - // TODO: The duplication of std::set should not be necessary here static const std::set pc_t[6] = { - std::set{eTrait::AMBIDEXTROUS, eTrait::GOOD_CONST, eTrait::MAGICALLY_INEPT}, - std::set{eTrait::TOUGHNESS, eTrait::WOODSMAN, eTrait::SLUGGISH}, - std::set{eTrait::NIMBLE, eTrait::FRAIL}, - std::set{eTrait::MAGICALLY_APT}, - std::set{eTrait::CAVE_LORE, eTrait::GOOD_CONST, eTrait::HIGHLY_ALERT, eTrait::BAD_BACK}, - std::set{eTrait::MAGICALLY_APT}, + {eTrait::AMBIDEXTROUS, eTrait::GOOD_CONST, eTrait::MAGICALLY_INEPT}, + {eTrait::TOUGHNESS, eTrait::WOODSMAN, eTrait::SLUGGISH}, + {eTrait::NIMBLE, eTrait::FRAIL}, + {eTrait::MAGICALLY_APT}, + {eTrait::CAVE_LORE, eTrait::GOOD_CONST, eTrait::HIGHLY_ALERT, eTrait::BAD_BACK}, + {eTrait::MAGICALLY_APT}, }; main_status = eMainStatus::ALIVE; diff --git a/src/pcedit/pc.graphics.cpp b/src/pcedit/pc.graphics.cpp index 8907d87e..68471d31 100644 --- a/src/pcedit/pc.graphics.cpp +++ b/src/pcedit/pc.graphics.cpp @@ -47,8 +47,7 @@ short store_str2a; short store_str2b; short store_which_string_dlog; short store_page_on,store_num_i; -// TODO: The duplication of rectangle here shouldn't be necessary... -rectangle ed_buttons_from[2] = {rectangle{0,0,57,57},rectangle{0,57,57,114}}; +rectangle ed_buttons_from[2] = {{0,0,57,57},{0,57,57,114}}; short current_pressed_button = -1; cCustomGraphics spec_scen_g; // not actually needed; just here to silence compiler because it's referenced in fileio.h // (actually, it WILL be needed eventually; the same is true about most of the rest of these.) diff --git a/src/tools/graphtool.cpp b/src/tools/graphtool.cpp index ef79ce6f..d743902f 100644 --- a/src/tools/graphtool.cpp +++ b/src/tools/graphtool.cpp @@ -83,23 +83,16 @@ void init_graph_tool(){ delete[] vbuf; } while(false); int i; - // TODO: The duplication of location here shouldn't be necessary static const location pat_offs[17] = { - location{0,3}, location{1,1}, location{2,1}, location{2,0}, - location{3,0}, location{3,1}, location{1,3}, location{0,0}, - location{0,2}, location{1,2}, location{0,1}, location{2,2}, - location{2,3}, location{3,2}, location{1,0}, location{4,0}, location{3,3} + {0,3}, {1,1}, {2,1}, {2,0}, + {3,0}, {3,1}, {1,3}, {0,0}, + {0,2}, {1,2}, {0,1}, {2,2}, + {2,3}, {3,2}, {1,0}, {4,0}, {3,3} }; static const int pat_i[17] = { 2, 3, 4, 5, 6, 8, 9, 10, 11,12,13,14,15,16,17,19,20 }; - static const int map_i[26] = { - 0, 1, 2, 3, 4, 5, 6, 9, - 10,11,12,13,14,15,16,17, - 18,19,20,21,22,24,25,27, - 28,29 - }; for(i = 0; i < 17; i++){ bg_rects[pat_i[i]] = {0,0,64,64}; bg_rects[pat_i[i]].offset(64 * pat_offs[i].x,64 * pat_offs[i].y);