diff --git a/src/boe.combat.cpp b/src/boe.combat.cpp index 89071494..7bbbe78b 100644 --- a/src/boe.combat.cpp +++ b/src/boe.combat.cpp @@ -843,7 +843,7 @@ void pc_attack_weapon(short who_att,iLiving& target,short hit_adj,short dam_adj, target.drain_sp(weap.abil_data[0]); if(before > target.get_magic()) { add_string_to_buf(" Blade drains energy."); - univ.party[who_att].restore_sp((before > target.get_magic()) / 3); + univ.party[who_att].restore_sp(before / 3); } } else if(weap.ability == eItemAbil::WEAPON_CALL_SPECIAL) { short s1,s2,s3; @@ -1027,11 +1027,6 @@ void do_combat_cast(location target) { } force_wall_position = 10; - // TODO: Should we do this here? Or in the handling of targeting modes? - // (It really depends whether we want to be able to trigger it for targeting something other than a spell.) - if(adjust <= 4 && !cast_spell_on_space(target, spell_being_cast)) - return; // The special node intercepted and cancelled regular spell behaviour. - caster.void_sanctuary(); if(overall_mode == MODE_SPELL_TARGET) { spell_targets[0] = target; @@ -1066,8 +1061,14 @@ void do_combat_cast(location target) { caster.cur_sp -= store_sum_monst_cost; cost_taken = true; } - - if((adjust = can_see_light(caster.combat_pos,target,sight_obscurity)) > 4) { + + adjust = can_see_light(caster.combat_pos, target, sight_obscurity); + // TODO: Should we do this here? Or in the handling of targeting modes? + // (It really depends whether we want to be able to trigger it for targeting something other than a spell.) + if(adjust <= 4 && !cast_spell_on_space(target, spell_being_cast)) + continue; // The special node intercepted and cancelled regular spell behaviour. + + if(adjust > 4) { add_string_to_buf(" Can't see target."); } else if(loc_off_act_area(target)) { diff --git a/src/boe.graphics.cpp b/src/boe.graphics.cpp index a4c0ca0f..9f2e853a 100644 --- a/src/boe.graphics.cpp +++ b/src/boe.graphics.cpp @@ -62,6 +62,7 @@ extern cCustomGraphics spec_scen_g; extern sf::RenderWindow mini_map; bool map_visible = false; extern bool show_startup_splash; +extern std::string save_talk_str1, save_talk_str2; rectangle menuBarRect; Region originalGrayRgn, newGrayRgn, underBarRgn; @@ -575,7 +576,8 @@ void redraw_screen(int refresh) { draw_startup(0); break; case MODE_TALKING: - if(refresh & REFRESH_DLOG); // TODO: Should call place_talk_str, but we don't have the strings + if(refresh & REFRESH_DLOG) + place_talk_str(save_talk_str1, save_talk_str2, 0, rectangle()); refresh_talking(); break; case MODE_SHOPPING: diff --git a/src/boe.items.cpp b/src/boe.items.cpp index 1b26bb5e..b904dcc8 100644 --- a/src/boe.items.cpp +++ b/src/boe.items.cpp @@ -378,16 +378,17 @@ void set_town_attitude(short lo,short hi,short att) { return; give_help(53,0); univ.town.monst.friendly = 1; + long long num_monst = univ.town.monst.size(); // Nice smart indexing, like Python :D - if(lo <= -univ.town.monst.size()) + if(lo <= -num_monst) lo = 0; if(lo < 0) - lo = univ.town.monst.size() + lo; - if(hi <= -univ.town.monst.size()) + lo = num_monst + lo; + if(hi <= -num_monst) hi = 0; if(hi < 0) - hi = univ.town.monst.size() + hi; + hi = num_monst + hi; if(hi < lo) std::swap(lo, hi); @@ -970,9 +971,9 @@ void refresh_store_items() { continue; } else if(entry.type == eShopItemType::CLASS) { std::set choices; - for(int i = 0; i < univ.scenario.scen_items.size(); i++) { - if(univ.scenario.scen_items[i].special_class == entry.item.special_class) - choices.insert(i); + for(int k = 0; k < univ.scenario.scen_items.size(); k++) { + if(univ.scenario.scen_items[k].special_class == entry.item.special_class) + choices.insert(k); } int choice = get_ran(1,0,choices.size()); if(choice < choices.size()) { diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index d3171c60..f6614deb 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -3529,7 +3529,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, if(i > 0) *next_spec = spec.ex1b; break; case eSpecType::IF_RECIPE: - if(i < 0 || i >= 20) { + if(spec.ex1a < 0 || spec.ex1a >= 20) { giveError("Alchemy recipe out of range (0 - 19)."); break; } @@ -3734,7 +3734,7 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, *next_spec = -1; } else { - if(handle_lever(loc(PSD[SDF_SPEC_LOC_X], PSD[SDF_SPEC_LOC_Y])) > 0) + if(handle_lever(loc(PSD[SDF_SPEC_LOC_X], PSD[SDF_SPEC_LOC_Y]))) *next_spec = spec.ex1b; } break; diff --git a/src/classes/monster.cpp b/src/classes/monster.cpp index c9361940..b0e00725 100644 --- a/src/classes/monster.cpp +++ b/src/classes/monster.cpp @@ -1008,7 +1008,8 @@ void cMonster::readFrom(std::istream& file) { m_name = read_maybe_quoted_string(line); } else if(cur == "ATTACK") { int which; - line >> which >> a[which].dice >> a[which].sides >> a[which].type; + line >> which; + line >> a[which].dice >> a[which].sides >> a[which].type; which--; } else if(cur == "SIZE") { line >> temp1 >> temp2; diff --git a/src/classes/universe.h b/src/classes/universe.h index 4d131bd6..3d182068 100644 --- a/src/classes/universe.h +++ b/src/classes/universe.h @@ -169,9 +169,9 @@ public: cParty party; std::map stored_pcs; cCurTown town; - char town_maps[200][8][64]; // formerly stored_town_maps_type + unsigned char town_maps[200][8][64]; // formerly stored_town_maps_type cCurOut out; - char out_maps[100][6][48]; // formerly stored_outdoor_maps_type + unsigned char out_maps[100][6][48]; // formerly stored_outdoor_maps_type fs::path file; void clear_stored_pcs(); diff --git a/src/pcedit/pc.editors.cpp b/src/pcedit/pc.editors.cpp index 41f06ff5..455db285 100644 --- a/src/pcedit/pc.editors.cpp +++ b/src/pcedit/pc.editors.cpp @@ -240,7 +240,7 @@ void display_alchemy(bool allowEdit) { if(!allowEdit) showAlch->getControl(id).attachClickHandler(&cLed::noAction); cLed& led = dynamic_cast(showAlch->getControl(id)); - if(univ.party.alchemy[i] > 0) + if(univ.party.alchemy[i]) led.setState(led_red); else led.setState(led_off); } diff --git a/src/tools/fileio_scen.cpp b/src/tools/fileio_scen.cpp index 30e9e65d..4c2892f2 100644 --- a/src/tools/fileio_scen.cpp +++ b/src/tools/fileio_scen.cpp @@ -467,7 +467,7 @@ static void readShopFromXml(ticpp::Element& data, cShop& shop, cScenario& scen) shop.setPrompt(boost::lexical_cast(val)); } else if(type == "face") { pic_num_t face; - elem->GetText(face); + elem->GetText(&face); shop.setFace(face); } else if(type == "entries") { int entries_found = 0;