From 41db6dcfdfea0f1de72cc520f780dba6d3ef193d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 23 Jan 2015 03:54:25 -0500 Subject: [PATCH] Fix indentation --- src/boe.actions.cpp | 12 +-- src/boe.combat.cpp | 6 +- src/boe.monster.cpp | 56 +++++----- src/boe.town.cpp | 60 +++++------ src/classes/pc.cpp | 38 +++---- src/classes/town.cpp | 4 +- src/dialogxml/button.cpp | 1 - src/dialogxml/dialog.cpp | 2 +- src/dialogxml/dlogutil.cpp | 2 +- src/dialogxml/pict.cpp | 2 +- src/pcedit/pc.main.cpp | 36 +++---- src/scenedit/scen.core.cpp | 2 +- src/scenedit/scen.fileio.cpp | 6 +- src/scenedit/scen.main.cpp | 76 ++++++------- src/scenedit/scen.townout.cpp | 22 ++-- src/tools/cursors.mac.mm | 2 +- src/tools/fileio.cpp | 54 +++++----- src/tools/mathutil.cpp | 2 +- src/tools/porting.cpp | 26 ++--- src/tools/soundtool.cpp | 195 +--------------------------------- src/tools/specials_parse.cpp | 14 +-- 21 files changed, 211 insertions(+), 407 deletions(-) diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index ad242f56..351399ce 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -562,7 +562,7 @@ static void handle_target_space(location destination, bool& did_something, bool& else if(overall_mode == MODE_FANCY_TARGET) { place_target(destination); need_reprint = true; - } + } if(overall_mode != MODE_FANCY_TARGET) { did_something = true; if(overall_mode == MODE_TOWN_TARGET) @@ -2632,7 +2632,7 @@ void start_new_game() { // (It also refreshed stores... with uninitialized items.) edit_party(); - + // if no PCs left, forget it for(i = 0 ; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ALIVE) @@ -2998,10 +2998,10 @@ bool town_move_party(location destination,short forced) { if((!is_blocked(destination)) && (!is_special(destination)) // If to bridge, exit if heading diagonal, keep going if heading horiz or vert && (!univ.scenario.ter_types[ter].boat_over - || ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)))) { - add_string_to_buf("You leave the boat. "); - univ.party.in_boat = -1; - } + || ((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)))) { + add_string_to_buf("You leave the boat. "); + univ.party.in_boat = -1; + } else if((destination.x != univ.town.p_loc.x) && (destination.y != univ.town.p_loc.y)) return false; // Crossing bridge: land or go through diff --git a/src/boe.combat.cpp b/src/boe.combat.cpp index d276fd1e..8ac7d2ce 100644 --- a/src/boe.combat.cpp +++ b/src/boe.combat.cpp @@ -2237,7 +2237,7 @@ void do_monster_turn() { if(dist(cur_monst->cur_loc, targ_space) > abil.second.missile.range) break; // Target not in range if(abil.second.missile.type != eMonstMissile::SPINE && monst_adjacent(targ_space, i)) - break; // Target adjacent; prefer melee attacks + break; // Target adjacent; prefer melee attacks if(get_ran(1,1,1000) >= abil.second.missile.odds) break; pick_abil = abil; @@ -2250,7 +2250,7 @@ void do_monster_turn() { if(dist(cur_monst->cur_loc, targ_space) > abil.second.gen.range) break; // Target not in range if(abil.second.gen.type == eMonstGen::SPIT && monst_adjacent(targ_space, i)) - break; // Target adjacent; prefer melee attacks + break; // Target adjacent; prefer melee attacks if(get_ran(1,1,1000) >= abil.second.gen.odds) break; pick_abil = abil; @@ -2902,7 +2902,7 @@ void monst_fire_missile(short m_num,short bless,std::pair a r1 += univ.party[target].get_prot_level(eItemAbil::EVASION); if(univ.party[target].parry < 100) r1 += 5 * univ.party[target].parry; - + if(r1 <= hit_chance[abil.second.missile.skill]) { r2 = get_ran(abil.second.missile.dice,1,abil.second.missile.sides) + min(10,bless); if(target < 100) { diff --git a/src/boe.monster.cpp b/src/boe.monster.cpp index 1beaa15b..0cd8382e 100644 --- a/src/boe.monster.cpp +++ b/src/boe.monster.cpp @@ -169,12 +169,12 @@ void get_monst_dims(mon_num_t monst,short *width, short *height) { void set_up_monst(short mode,mon_num_t m_num) { short which = univ.town.monst.size(); - cMonster& monst = m_num >= 10000 ? univ.party.summons[m_num - 10000] : univ.scenario.scen_monsters[m_num]; - univ.town.monst.assign(which, cCreature(m_num), monst, PSD[SDF_EASY_MODE], univ.difficulty_adjust()); - univ.town.monst[which].active = 2; - univ.town.monst[which].summoned = 0; - univ.town.monst[which].attitude = mode + 1; - univ.town.monst[which].mobility = 1; + cMonster& monst = m_num >= 10000 ? univ.party.summons[m_num - 10000] : univ.scenario.scen_monsters[m_num]; + univ.town.monst.assign(which, cCreature(m_num), monst, PSD[SDF_EASY_MODE], univ.difficulty_adjust()); + univ.town.monst[which].active = 2; + univ.town.monst[which].summoned = 0; + univ.town.monst[which].attitude = mode + 1; + univ.town.monst[which].mobility = 1; } void do_monsters() { @@ -1259,26 +1259,26 @@ short place_monster(mon_num_t which,location where) { i++; } - // 10000 or more means an exported summon saved with the party - cMonster& monst = which >= 10000 ? univ.party.summons[which - 10000] : univ.scenario.scen_monsters[which]; - univ.town.monst.assign(i, cCreature(which), monst, PSD[SDF_EASY_MODE], univ.difficulty_adjust()); - // TODO: Should this static_cast assignment be happening? - // One effect is resetting max health to ignore difficulty_adjust() - static_cast(univ.town.monst[i]) = monst; - univ.town.monst[i].attitude = monst.default_attitude; - if(univ.town.monst[i].attitude % 2 == 0) - univ.town.monst[i].attitude = 1; - univ.town.monst[i].mobility = 1; - univ.town.monst[i].active = 2; - univ.town.monst[i].cur_loc = where; - univ.town.monst[i].summoned = 0; - univ.town.monst[i].target = 6; - - univ.town.set_crate(where.x,where.y,false); - univ.town.set_barrel(where.x,where.y,false); - univ.town.set_block(where.x,where.y,false); - - return i; + // 10000 or more means an exported summon saved with the party + cMonster& monst = which >= 10000 ? univ.party.summons[which - 10000] : univ.scenario.scen_monsters[which]; + univ.town.monst.assign(i, cCreature(which), monst, PSD[SDF_EASY_MODE], univ.difficulty_adjust()); + // TODO: Should this static_cast assignment be happening? + // One effect is resetting max health to ignore difficulty_adjust() + static_cast(univ.town.monst[i]) = monst; + univ.town.monst[i].attitude = monst.default_attitude; + if(univ.town.monst[i].attitude % 2 == 0) + univ.town.monst[i].attitude = 1; + univ.town.monst[i].mobility = 1; + univ.town.monst[i].active = 2; + univ.town.monst[i].cur_loc = where; + univ.town.monst[i].summoned = 0; + univ.town.monst[i].target = 6; + + univ.town.set_crate(where.x,where.y,false); + univ.town.set_barrel(where.x,where.y,false); + univ.town.set_block(where.x,where.y,false); + + return i; } // returns true if placement was successful @@ -1318,8 +1318,8 @@ bool summon_monster(mon_num_t which,location where,short duration,short given_at univ.town.monst[spot].attitude = given_attitude; - univ.town.monst[spot].summoned = duration; - monst_spell_note(which,21); + univ.town.monst[spot].summoned = duration; + monst_spell_note(which,21); return true; } diff --git a/src/boe.town.cpp b/src/boe.town.cpp index 5f9e3dca..32c9fd27 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -381,38 +381,38 @@ void start_town_mode(short which_town, short entry_dir) { for(i = 0; i < univ.town->preset_items.size(); i++) if((univ.town->preset_items[i].code >= 0) && (((univ.party.item_taken[univ.town.num][i / 8] & s_pow(2,i % 8)) == 0) || - (univ.town->preset_items[i].always_there))) { + (univ.town->preset_items[i].always_there))) { j = univ.town.items.size(); - // place the preset item, if party hasn't gotten it already - univ.town.items.push_back(get_stored_item(univ.town->preset_items[i].code)); - // Don't place special items if already in the party's possession - if(univ.town.items[j].variety == eItemType::SPECIAL && univ.party.spec_items[univ.town.items[j].item_level]) + // place the preset item, if party hasn't gotten it already + univ.town.items.push_back(get_stored_item(univ.town->preset_items[i].code)); + // Don't place special items if already in the party's possession + if(univ.town.items[j].variety == eItemType::SPECIAL && univ.party.spec_items[univ.town.items[j].item_level]) + break; + univ.town.items[j].item_loc = univ.town->preset_items[i].loc; + + // Not use the items data flags, starting with forcing an ability + if(univ.town->preset_items[i].ability >= 0) { + switch(univ.town.items[j].variety) { + case eItemType::GOLD: + case eItemType::FOOD: // If gold or food, this value is amount + if(univ.town->preset_items[i].ability > 0) + univ.town.items[j].item_level = univ.town->preset_items[i].ability; break; - univ.town.items[j].item_loc = univ.town->preset_items[i].loc; - - // Not use the items data flags, starting with forcing an ability - if(univ.town->preset_items[i].ability >= 0) { - switch(univ.town.items[j].variety) { - case eItemType::GOLD: - case eItemType::FOOD: // If gold or food, this value is amount - if(univ.town->preset_items[i].ability > 0) - univ.town.items[j].item_level = univ.town->preset_items[i].ability; - break; - default: //leave other type alone - // TODO: Could resupport this "forcing an ability" thing... - break; - } - } - - // TODO: charges are unused! (Also, they're currently stored in ability, not in charges.) - - if(town_toast) - univ.town.items[j].property = false; - else - univ.town.items[j].property = univ.town->preset_items[i].property; - univ.town.items[j].contained = univ.town->preset_items[i].contained; - univ.town.items[j].is_special = i + 1; - } + default: //leave other type alone + // TODO: Could resupport this "forcing an ability" thing... + break; + } + } + + // TODO: charges are unused! (Also, they're currently stored in ability, not in charges.) + + if(town_toast) + univ.town.items[j].property = false; + else + univ.town.items[j].property = univ.town->preset_items[i].property; + univ.town.items[j].contained = univ.town->preset_items[i].contained; + univ.town.items[j].is_special = i + 1; + } for(i = 0; i < univ.town.monst.size(); i++) diff --git a/src/classes/pc.cpp b/src/classes/pc.cpp index b9bb5279..c8ba5611 100644 --- a/src/classes/pc.cpp +++ b/src/classes/pc.cpp @@ -71,7 +71,7 @@ short cPlayer::get_tnl(){ store_per = store_per + ap[trait]; } - tnl = (tnl * store_per) / 100; + tnl = (tnl * store_per) / 100; return tnl; } @@ -384,12 +384,12 @@ cPlayer::cPlayer(cParty& party) : party(party) { skills[eSkill::STRENGTH] = 1; skills[eSkill::DEXTERITY] = 1; skills[eSkill::INTELLIGENCE] = 1; - cur_health = 6; - max_health = 6; - cur_sp = 0; - max_sp = 0; - experience = 0; - skill_pts = 60; + cur_health = 6; + max_health = 6; + cur_sp = 0; + max_sp = 0; + experience = 0; + skill_pts = 60; level = 1; for(i = 0; i < 24; i++) items[i] = cItem(); @@ -402,7 +402,7 @@ cPlayer::cPlayer(cParty& party) : party(party) { } which_graphic = 0; weap_poisoned = 24; - + race = eRace::HUMAN; direction = 0; } @@ -439,11 +439,11 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : party(party) { skills[skill] = 8; } cur_health = 60; - max_health = 60; - cur_sp = 90; - max_sp = 90; - experience = 0; - skill_pts = 60; + max_health = 60; + cur_sp = 90; + max_sp = 90; + experience = 0; + skill_pts = 60; level = 1; for(i = 0; i < 24; i++) items[i] = cItem(); @@ -461,7 +461,7 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : party(party) { for(i = 0; i < 10; i++) { eTrait trait = eTrait(i); traits[trait] = true; - } + } race = eRace::HUMAN; direction = 0; @@ -536,17 +536,17 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : party(party) { skills[skill] = pc_stats[slot][skill]; } cur_health = pc_health[slot]; - max_health = pc_health[slot]; - experience = 0; - skill_pts = 0; + max_health = pc_health[slot]; + experience = 0; + skill_pts = 0; level = 1; for(i = 0; i < 24; i++) items[i] = cItem(); for(i = 0; i < 24; i++) equip[i] = false; - cur_sp = pc_sp[slot]; - max_sp = pc_sp[slot]; + cur_sp = pc_sp[slot]; + max_sp = pc_sp[slot]; for(i = 0; i < 62; i++) { priest_spells[i] = (i < 30) ? true : false; mage_spells[i] = (i < 30) ? true : false; diff --git a/src/classes/town.cpp b/src/classes/town.cpp index b9765807..b92d9eef 100644 --- a/src/classes/town.cpp +++ b/src/classes/town.cpp @@ -96,11 +96,11 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) { for(i = 0; i < 15; i++) { sign_locs[i] = d_loc; sign_locs[i].x = 100; - } + } for(i = 0; i < 8; i++) { timer_spec_times[i] = 0; timer_specs[i] = -1; - } + } for(i = 0; i < 100; i++) { specials[i] = cSpecial(); } diff --git a/src/dialogxml/button.cpp b/src/dialogxml/button.cpp index 8bd0ed29..38259218 100644 --- a/src/dialogxml/button.cpp +++ b/src/dialogxml/button.cpp @@ -523,7 +523,6 @@ void cButton::setBtnType(eBtnType newType){ frame.width() = 30; frame.height() = 30; break; - } } diff --git a/src/dialogxml/dialog.cpp b/src/dialogxml/dialog.cpp index 518ea1ef..2cf4cf59 100644 --- a/src/dialogxml/dialog.cpp +++ b/src/dialogxml/dialog.cpp @@ -841,7 +841,7 @@ void cDialog::loadFromFile(std::string path){ }catch(int){ throw xBadVal("text",name,val,attr->Row(),attr->Column(),fname); } - defTextClr = clr; + defTextClr = clr; } else if(name == "defbtn") { defaultButton = val; }else if(name != "debug") diff --git a/src/dialogxml/dlogutil.cpp b/src/dialogxml/dlogutil.cpp index 46d63564..be244864 100644 --- a/src/dialogxml/dlogutil.cpp +++ b/src/dialogxml/dlogutil.cpp @@ -345,7 +345,7 @@ void cThreeChoice::init_strings(std::vector& strings, unsigned shor TextStyle style; rectangle cur_text_rect = {2, left, 0, 0}; size_t total_len = 0, str_width, str_height; - for(unsigned int i = 0; i < strings.size(); i++) + for(unsigned int i = 0; i < strings.size(); i++) total_len += string_length(strings[i], style); total_len = total_len * 12; str_width = s_sqrt(total_len) + 20; diff --git a/src/dialogxml/pict.cpp b/src/dialogxml/pict.cpp index 06c2c471..fe48d899 100644 --- a/src/dialogxml/pict.cpp +++ b/src/dialogxml/pict.cpp @@ -587,7 +587,7 @@ void cPict::drawPresetTer(short num, rectangle to_rect){ std::shared_ptr from_gw = getSheet(SHEET_TER, num / 50); num = num % 50; rectangle from_rect = calc_rect(num % 10, num / 10); - if(to_rect.right - to_rect.left > 28) + if(to_rect.right - to_rect.left > 28) to_rect.inset(4,0); rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect); } diff --git a/src/pcedit/pc.main.cpp b/src/pcedit/pc.main.cpp index 8dc52b2f..59742093 100644 --- a/src/pcedit/pc.main.cpp +++ b/src/pcedit/pc.main.cpp @@ -63,24 +63,24 @@ char start_name[256]; //MW specified return type was 'void', changed to ISO C style for Carbonisation -jmr int main(int /*argc*/, char* argv[]) { try { - init_directories(argv[0]); - init_menubar(); - Initialize(); - init_fileio(); - init_main_buttons(); - Set_up_win(); - init_graph_tool(); - init_snd_tool(); - - set_up_apple_events(); - - cDialog::init(); - redraw_screen(); - menu_activate(); - update_item_menu(); - - while(!All_Done) - Handle_One_Event(); + init_directories(argv[0]); + init_menubar(); + Initialize(); + init_fileio(); + init_main_buttons(); + Set_up_win(); + init_graph_tool(); + init_snd_tool(); + + set_up_apple_events(); + + cDialog::init(); + redraw_screen(); + menu_activate(); + update_item_menu(); + + while(!All_Done) + Handle_One_Event(); return 0; } catch(std::exception& x) { giveError(x.what()); diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 81f53954..9645ef69 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -2544,7 +2544,7 @@ void edit_custom_pics_types() { pic_dlg["okay"].attachClickHandler(std::bind(save_pics_types, _1, std::ref(pics))); pic_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false)); pic_dlg.attachClickHandlers(std::bind(change_pics_page, _1, _2, std::ref(pics), std::ref(first_pic)), {"left", "right"}); - + fill_custom_pics_types(pic_dlg, pics, first_pic); if(spec_scen_g.count() <= 10) { pic_dlg["left"].hide(); diff --git a/src/scenedit/scen.fileio.cpp b/src/scenedit/scen.fileio.cpp index 0e063b5f..701ae406 100644 --- a/src/scenedit/scen.fileio.cpp +++ b/src/scenedit/scen.fileio.cpp @@ -273,7 +273,7 @@ void writeTerrainToXml(ticpp::Printer&& data) { data.OpenElement("editor"); if(ter.shortcut_key > 0) - data.PushElement("shortcut", ter.shortcut_key); + data.PushElement("shortcut", ter.shortcut_key); data.PushElement("ground", ter.ground_type); data.PushElement("trim-for", ter.trim_ter); if(ter.obj_num > 0) { @@ -303,7 +303,7 @@ void writeItemsToXml(ticpp::Printer&& data) { if(item.charges > 0) data.PushElement("charges", item.charges); if(isWeaponType(item.variety) && item.variety != eItemType::ARROW && item.variety != eItemType::BOLTS) - data.PushElement("weapon-type", item.weap_type); + data.PushElement("weapon-type", item.weap_type); data.PushElement("missile-type", item.missile); data.PushElement("pic", item.graphic_num); if(item.type_flag > 0) @@ -596,8 +596,6 @@ void writeTownToXml(ticpp::Printer&& data, cTown& town) { data.OpenElement("item"); data.PushAttribute("id", i); data.PushElement("type", town.preset_items[i].code); - if(town.preset_items[i].ability >= 0) - data.PushElement("mod", town.preset_items[i].ability); if(town.preset_items[i].charges > 0) data.PushElement("charges", town.preset_items[i].charges); if(town.preset_items[i].always_there) diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index df455a69..c5aa78cf 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -56,44 +56,44 @@ rectangle right_sbar_rect; //Changed to ISO C specified argument and return type. int main(int, char* argv[]) { try { - - init_directories(argv[0]); - init_menubar(); - - init_current_terrain(); - Initialize(); - init_fileio(); - init_snd_tool(); - load_graphics(); - - cDialog::init(); - cDialog::defaultBackground = cDialog::BG_LIGHT; - cDialog::doAnimations = true; - init_graph_tool(); - - cen_x = 18; - cen_y = 18; - - run_startup_g(); - init_lb(); - init_rb(); - - make_cursor_sword(); - - Set_up_win(); - init_screen_locs(); - - shut_down_menus(0); - - set_up_start_screen(); - - check_for_intel(); - redraw_screen(); - - while(!All_Done) - Handle_One_Event(); - - close_program(); + + init_directories(argv[0]); + init_menubar(); + + init_current_terrain(); + Initialize(); + init_fileio(); + init_snd_tool(); + load_graphics(); + + cDialog::init(); + cDialog::defaultBackground = cDialog::BG_LIGHT; + cDialog::doAnimations = true; + init_graph_tool(); + + cen_x = 18; + cen_y = 18; + + run_startup_g(); + init_lb(); + init_rb(); + + make_cursor_sword(); + + Set_up_win(); + init_screen_locs(); + + shut_down_menus(0); + + set_up_start_screen(); + + check_for_intel(); + redraw_screen(); + + while(!All_Done) + Handle_One_Event(); + + close_program(); return 0; } catch(std::exception& x) { giveError(x.what()); diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index 1b34a417..8dbf84cc 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -534,16 +534,16 @@ static bool edit_out_wand_event_filter(cDialog& me, std::string item_hit, short& cCreature store_m; if(item_hit == "left") { me.untoast(); - store_which_out_wand--; - if(store_which_out_wand < 0) store_which_out_wand = 3; - store_out_wand = (mode == 0) ? current_terrain->wandering[store_which_out_wand] : current_terrain->special_enc[store_which_out_wand]; - put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand); + store_which_out_wand--; + if(store_which_out_wand < 0) store_which_out_wand = 3; + store_out_wand = (mode == 0) ? current_terrain->wandering[store_which_out_wand] : current_terrain->special_enc[store_which_out_wand]; + put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand); } else if(item_hit == "right") { me.untoast(); - store_which_out_wand++; - if(store_which_out_wand > 3) store_which_out_wand = 0; - store_out_wand = (mode == 0) ? current_terrain->wandering[store_which_out_wand] : current_terrain->special_enc[store_which_out_wand]; - put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand); + store_which_out_wand++; + if(store_which_out_wand > 3) store_which_out_wand = 0; + store_out_wand = (mode == 0) ? current_terrain->wandering[store_which_out_wand] : current_terrain->special_enc[store_which_out_wand]; + put_out_wand_in_dlog(me, store_which_out_wand, store_out_wand); } return true; } @@ -1174,14 +1174,14 @@ location pick_out(location default_loc) { bool new_town(short which_town) { std::cout << "Town creation currently disabled.\n"; short i,j; - + cChoiceDlog new_dlg("new-town", {"okay", "cancel"}); new_dlg->getControl("num").setTextToNum(which_town); if(new_dlg.show() == "cancel") return false; std::string size = dynamic_cast(new_dlg->getControl("size")).getSelected(); std::string preset = dynamic_cast(new_dlg->getControl("preset")).getSelected(); - + if(size == "lg") scenario.towns.push_back(new cBigTown(scenario)); else if(size == "med") scenario.towns.push_back(new cMedTown(scenario)); else if(size == "sm") scenario.towns.push_back(new cTinyTown(scenario)); @@ -1190,7 +1190,7 @@ bool new_town(short which_town) { town = scenario.towns[cur_town]; scenario.last_town_edited = cur_town; town->town_name = new_dlg->getControl("name").getText().substr(0,30); - + for(i = 0; i < town->max_dim(); i++) for(j = 0; j < town->max_dim(); j++) if(preset == "cave") { diff --git a/src/tools/cursors.mac.mm b/src/tools/cursors.mac.mm index 2b762d75..ff5df37f 100644 --- a/src/tools/cursors.mac.mm +++ b/src/tools/cursors.mac.mm @@ -31,7 +31,7 @@ static NSImage* imageFromURL(CFURLRef url){ imageRect.size.width = CGImageGetWidth(theImage); // Create a new image to receive the Quartz image data. - NSImage *newImage = [[NSImage alloc] initWithSize:imageRect.size]; + NSImage* newImage = [[NSImage alloc] initWithSize:imageRect.size]; [newImage lockFocus]; // Get the Quartz context and draw. diff --git a/src/tools/fileio.cpp b/src/tools/fileio.cpp index 4ecd65e5..90073a40 100644 --- a/src/tools/fileio.cpp +++ b/src/tools/fileio.cpp @@ -85,7 +85,7 @@ void init_directories(const char* exec_path) { #endif // __APPLE__ #endif // _Win32||_Win64 tempDir /= "Temporary Files"; - + // Depending on the build environment, we may need to redirect stdout and stderr. #ifdef _MSC_VER #ifdef DEBUG @@ -175,26 +175,26 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario){ scenario.append(*temp_scenario); scenario.append(*item_data); - // TODO: Consider skipping the fread and assignment when len is 0 - for(i = 0; i < 270; i++) { - len = (long) (temp_scenario->scen_str_len[i]); - n = fread(temp_str, len, 1, file_id); - temp_str[len] = 0; - if(i == 0) scenario.scen_name = temp_str; - else if(i == 1 || i == 2) - scenario.who_wrote[i-1] = temp_str; - else if(i == 3) - scenario.contact_info = temp_str; - else if(i >= 4 && i < 10) - scenario.intro_strs[i-4] = temp_str; - else if(i >= 10 && i < 60) - scenario.journal_strs[i-10] = temp_str; - else if(i >= 60 && i < 160) { - if(i % 2 == 0) scenario.special_items[(i-60)/2].name = temp_str; - else scenario.special_items[(i-60)/2].descr = temp_str; - } else if(i >= 260) continue; // These were never ever used, for some reason. - else scenario.spec_strs[i-160] = temp_str; - } + // TODO: Consider skipping the fread and assignment when len is 0 + for(i = 0; i < 270; i++) { + len = (long) (temp_scenario->scen_str_len[i]); + n = fread(temp_str, len, 1, file_id); + temp_str[len] = 0; + if(i == 0) scenario.scen_name = temp_str; + else if(i == 1 || i == 2) + scenario.who_wrote[i-1] = temp_str; + else if(i == 3) + scenario.contact_info = temp_str; + else if(i >= 4 && i < 10) + scenario.intro_strs[i-4] = temp_str; + else if(i >= 10 && i < 60) + scenario.journal_strs[i-10] = temp_str; + else if(i >= 60 && i < 160) { + if(i % 2 == 0) scenario.special_items[(i-60)/2].name = temp_str; + else scenario.special_items[(i-60)/2].descr = temp_str; + } else if(i >= 260) continue; // These were never ever used, for some reason. + else scenario.spec_strs[i-160] = temp_str; + } fclose(file_id); @@ -687,14 +687,14 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo char *pc_ptr; long len,store_len,count; - // LOAD PARTY + // LOAD PARTY len = (long) sizeof(legacy::party_record_type); // should be 46398 store_len = len; fin.read((char*)&store_party, len); if(must_port) port_party(&store_party); party_ptr = (char*) &store_party; for(count = 0; count < store_len; count++) - party_ptr[count] ^= 0x5C; + party_ptr[count] ^= 0x5C; // LOAD SETUP len = (long) sizeof(legacy::setup_save_type); @@ -708,7 +708,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo if(must_port) port_pc(&store_pc[i]); pc_ptr = (char*) &store_pc[i]; for(count = 0; count < store_len; count++) - pc_ptr[count] ^= 0x6B; + pc_ptr[count] ^= 0x6B; } if(in_scen) { @@ -717,7 +717,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo len = (long) sizeof(legacy::out_info_type); fin.read((char*)&store_out_info, len); - // LOAD TOWN + // LOAD TOWN if(town_restore) { len = (long) sizeof(legacy::current_town_type); fin.read((char*)&store_c_town, len); @@ -728,7 +728,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo if(must_port) port_t_d(&t_d); len = (long) sizeof(legacy::town_item_list); - fin.read((char*)&t_i, len); + fin.read((char*)&t_i, len); }else univ.town.num = 200; // LOAD STORED ITEMS @@ -750,7 +750,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo len = (long) (64 * 64); fin.read((char*)sfx, len); - fin.read((char*)misc_i, len); + fin.read((char*)misc_i, len); } // end if_scen diff --git a/src/tools/mathutil.cpp b/src/tools/mathutil.cpp index 9b7ff80d..fe80f3cc 100644 --- a/src/tools/mathutil.cpp +++ b/src/tools/mathutil.cpp @@ -70,4 +70,4 @@ sf::Time time_in_ticks(int ticks) { return sf::microseconds(micro); } - + diff --git a/src/tools/porting.cpp b/src/tools/porting.cpp index 81fe7654..268295ac 100644 --- a/src/tools/porting.cpp +++ b/src/tools/porting.cpp @@ -31,12 +31,12 @@ void port_town(legacy::town_record_type* dummy_town_ptr){ flip_short(&dummy_town_ptr->max_num_monst); flip_short(&dummy_town_ptr->spec_on_entry); flip_short(&dummy_town_ptr->spec_on_entry_if_dead); - for(i =0 ; i < 8; i++) + for(i =0 ; i < 8; i++) flip_short(&dummy_town_ptr->timer_spec_times[i]); - for(i =0 ; i < 8; i++) + for(i =0 ; i < 8; i++) flip_short(&dummy_town_ptr->timer_specs[i]); flip_short(&dummy_town_ptr->difficulty); - for(i =0 ; i < 100; i++) + for(i =0 ; i < 100; i++) flip_spec_node(&dummy_town_ptr->specials[i]); } @@ -61,7 +61,7 @@ void port_t_d(legacy::big_tr_type* old) { if(cur_scen_is_mac != mac_is_intel) return; - for(i =0 ; i < 16; i++) + for(i =0 ; i < 16; i++) flip_rect(&old->room_rect[i]); for(i =0 ; i < 60; i++) { flip_short(&old->creatures[i].spec1); @@ -70,7 +70,7 @@ void port_t_d(legacy::big_tr_type* old) { flip_short(&old->creatures[i].personality); flip_short(&old->creatures[i].special_on_kill); flip_short(&old->creatures[i].facial_pic); - } + } } void port_ave_t(legacy::ave_tr_type* old) { @@ -78,7 +78,7 @@ void port_ave_t(legacy::ave_tr_type* old) { if(cur_scen_is_mac != mac_is_intel) return; - for(i =0 ; i < 16; i++) + for(i =0 ; i < 16; i++) flip_rect(&old->room_rect[i]); for(i =0 ; i < 40; i++) { flip_short(&old->creatures[i].spec1); @@ -95,7 +95,7 @@ void port_tiny_t(legacy::tiny_tr_type* old) { if(cur_scen_is_mac != mac_is_intel) return; - for(i =0 ; i < 16; i++) + for(i =0 ; i < 16; i++) flip_rect(&old->room_rect[i]); for(i =0 ; i < 30; i++) { flip_short(&old->creatures[i].spec1); @@ -104,7 +104,7 @@ void port_tiny_t(legacy::tiny_tr_type* old) { flip_short(&old->creatures[i].personality); flip_short(&old->creatures[i].special_on_kill); flip_short(&old->creatures[i].facial_pic); - } + } } void port_scenario(legacy::scenario_data_type* temp_scenario) { @@ -169,9 +169,9 @@ void port_scenario(legacy::scenario_data_type* temp_scenario) { for(i = 0; i < 30; i++) { flip_short(&temp_scenario->scen_horses[i].which_town); } - for(i = 0; i < 20; i++) + for(i = 0; i < 20; i++) flip_short(&temp_scenario->scenario_timer_times[i]); - for(i = 0; i < 20; i++) + for(i = 0; i < 20; i++) flip_short(&temp_scenario->scenario_timer_specs[i]); for(i = 0; i < 256; i++) { flip_spec_node(&temp_scenario->scen_specials[i]); @@ -219,11 +219,11 @@ void port_out(legacy::outdoor_record_type *out) { flip_short(&(out->special_enc[i].spec_on_flee)); flip_short(&(out->special_enc[i].cant_flee)); flip_short(&(out->special_enc[i].end_spec1)); - flip_short(&(out->special_enc[i].end_spec2)); + flip_short(&(out->special_enc[i].end_spec2)); } - for(i = 0; i < 8; i++) + for(i = 0; i < 8; i++) flip_rect(&(out->info_rect[i])); - for(i = 0; i < 60; i++) + for(i = 0; i < 60; i++) flip_spec_node(&(out->specials[i])); } diff --git a/src/tools/soundtool.cpp b/src/tools/soundtool.cpp index 654af155..1b1af3c6 100644 --- a/src/tools/soundtool.cpp +++ b/src/tools/soundtool.cpp @@ -78,7 +78,7 @@ void play_sound(short which, short how_many_times) { // if < 0, play asynch inited = true; ResMgr::setIdMapFn(sound_to_fname_map); } - + std::shared_ptr sndhandle; if(!play_sounds || how_many_times == 0) return; @@ -112,131 +112,8 @@ void play_sound(short which, short how_many_times) { // if < 0, play asynch sf::sleep(time_in_ticks(sound_delay[-1 * which])); if(how_many_times > 1) play_sound(which, how_many_times - 1); - // TODO: Since sounds are handled by SFML, all this Windows-specific code shouldn't be needed -#if 0 //defined(WIN32) - short i,num_fails = 0; - char snd_name[30]; - bool asyn = false,a_sound_did_get_played = false; - bool not_asyn = false,check_sound; - HRSRC h; - if((sounds_missing) || (!play_sounds) || (how_many_times == 0)) - return; - - if(which < 0) { - asyn = true; - which = which * -1; - } - if(which >= 1000) { - which -= 1000; - not_asyn = true; - } - - if(which >= 100) - return; - - if((always_asynch[which]) && - ((can_ignore[which] == 1) || (can_ignore[which] >= 3))) - asyn = true; - if((can_ignore[which] > 0) && (can_ignore[which] < 5) && (party.stuff_done[305][5] == 1)) - return; - if((can_ignore[which] != 1) && (can_ignore[which] < 3)) - asyn = false; - if((party.stuff_done[305][5] == 1) && (can_ignore[which] < 5)) - asyn = false; - if(not_asyn) - asyn = false; - - if((load_when_play[which]) && (sound_handles[which] == NULL)) { - asyn = false; - sprintf((char *)snd_name,"#%d",which + 1); - h = FindResource(hModule,snd_name,"#100"); - - sound_handles[which] = LoadResource(hModule,h); - snds[which] = (char *) LockResource(sound_handles[which]); - - } - - if(store_last_sound_played == 6) - sndPlaySound(NULL,0); - - if(asyn) { - if(can_ignore[which] >= 4) - check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP); - else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY); - - while(!check_sound) { - - if(can_ignore[store_last_sound_played] == 4) {// then sound goes away - return; - } - - - num_fails++; - if(num_fails < 40) - sound_pause(25); - else { - MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error a. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - print_nums(111,which,num_fails); - sounds_fucked = true; - return; - } - sndPlaySound(NULL,0); - - if(can_ignore[which] >= 4) - check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP); - else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY); - } - a_sound_did_get_played = true; - } - else { - if(can_ignore[which] >= 4) - check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP); - else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY); - while(!check_sound) { - if(can_ignore[store_last_sound_played] == 4) {// then sound goes away - return; - } - - - num_fails++; - if(num_fails < 40) - sound_pause(25); - else { - MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error b. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - print_nums(222,which,num_fails); - sounds_fucked = true; - return; - } - sndPlaySound(NULL,0); - - if(can_ignore[which] >= 4) - check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP); - else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY); - } - a_sound_did_get_played = true; - } - - store_last_sound_played = which; - - if((load_when_play[which]) && !asyn) - sound_handles[which] = NULL; - - for(i = 0; i < NUM_SOUNDS; i++) - if((load_when_play[which]) && (sound_handles[which] != NULL) - && (a_sound_did_get_played) && (i != which)) { - sound_handles[i] = NULL; - } -#endif } -#if 0 //def WIN32 -void kill_sound() { - sndPlaySound(NULL,0); -} -#endif - void one_sound(short which) { if(which == last_played) return; @@ -252,73 +129,3 @@ void flip_sound() { play_sounds = (play_sounds) ? false : true; } - -#if 0 //def WIN32 -void sound_pause(long len) { - long t1,t2; - - t1 = (long) GetCurrentTime(); - t2 = t1; - while(t2 - t1 < len) { - t2 = (long)GetCurrentTime(); - } -} - -void load_sounds(HMODULE handle) { - short i,t,err; - HRSRC h; - char snd_name[20]; - WAVEOUTCAPS wavecaps; - - hModule = handle; - - t = waveOutGetNumDevs(); - if(t == 0) { - sounds_missing = true; - return; - } - err = waveOutGetDevCaps(0,&wavecaps,sizeof(WAVEOUTCAPS)); - if(err != 0) { - sounds_missing = true; - switch(err) { - case MMSYSERR_BADDEVICEID: - MessageBox(mainPtr,"Cannot initialize sounds - No sound device detected. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - case MMSYSERR_NODRIVER: - MessageBox(mainPtr,"Cannot initialize sounds - No driver installed. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - case MMSYSERR_NOMEM : - MessageBox(mainPtr,"Cannot initialize sounds - can't find enough memory. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - case MMSYSERR_ALLOCATED: - MessageBox(mainPtr,"Cannot initialize sounds - sound card already allocated. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - case MMSYSERR_ERROR: - MessageBox(mainPtr,"Cannot initialize sounds - internal error. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - default: - MessageBox(mainPtr,"Cannot initialize sounds - unidentified error. Game can still be played, but quietly.", - "Sound Error",MB_OK | MB_ICONEXCLAMATION); - return; - - } - - } - - for(i = 0; i < NUM_SOUNDS; i++) { - sound_handles[i] = NULL; - if(!load_when_play[i]) { - sprintf((char *)snd_name,"#%d",i + 1); - h = FindResource(handle,snd_name,"#100"); - - sound_handles[i] = LoadResource(handle,h); - snds[i] = (char*) LockResource(sound_handles[i]); - } - } -} -#endif diff --git a/src/tools/specials_parse.cpp b/src/tools/specials_parse.cpp index e0ba231f..bd811d23 100644 --- a/src/tools/specials_parse.cpp +++ b/src/tools/specials_parse.cpp @@ -42,25 +42,25 @@ SpecialParser::SpecialParser() { symbol_ch = chset<>("A-Za-z$_-"); symbol = symbol_ch >> *symbol_ch; eol = eol_p[_(next_line)]; - + datcode = str_p("sdf")[_(for_sdf)] | str_p("pic")[_(for_pic)] | str_p("msg")[_(for_msg)] | str_p("ex1")[_(for_ex1)] | str_p("ex2")[_(for_ex2)] | str_p("goto")[_(for_goto)]; - + command = datcode >> +ws >> (int_p[_(set_first)] | defn[_(set_first)]) >> !(*ws >> ch_p(',') >> *ws >> (int_p[_(set_second)] | defn[_(set_second)]) >> !(*ws >> ch_p(',') >> *ws >> (int_p[_(set_third)] | defn[_(set_third)]))); - + null_line = !comment >> eol; init_line = null_line | def_line; def_line = str_p("def") >> +ws >> symbol[_(prep_add_symbol)] >> *ws >> ch_p('=') >> *ws >> int_p[_(add_symbol)] >> *ws >> !comment >> eol; cmd_line = command >> *ws >> !comment >> eol; op_line = ch_p('@') >> opcode[_(set_type)] >> *ws >> !(ch_p('=') >> *ws >> int_p[_(skip_to)]) >> *ws >> !comment >> eol; - + cmd_block = eps_p[_(init_block)] >> op_line >> *(*ws >> (cmd_line | def_line | null_line)); - + // TODO: This fails if the file doesn't end in a newline. nodes_file = /*guard*/err(eps_p[_(init_file)] >> *(*ws >> init_line) >> *cmd_block[_(add_command)] >> end_p);//[_(on_error)]; - + // Debugging. If BOOST_SPIRIT_DEBUG not defined, all these expand to nothing. BOOST_SPIRIT_DEBUG_NODE(ws); BOOST_SPIRIT_DEBUG_NODE(eol); @@ -79,7 +79,7 @@ SpecialParser::SpecialParser() { grammar_built = true; } - + #undef _ auto SpecialParser::on_error(const Rule::scanner_t&, spirit::parser_error) -> ErrStatus {