diff --git a/src/dialogxml/widgets/pict.hpp b/src/dialogxml/widgets/pict.hpp index 7a3b2719..b31fca56 100644 --- a/src/dialogxml/widgets/pict.hpp +++ b/src/dialogxml/widgets/pict.hpp @@ -20,6 +20,29 @@ #include "pictypes.hpp" #include "texture.hpp" +class cPictNum { +public: + explicit cPictNum(pic_num_t nNum=-1, ePicType nType=ePicType::PIC_NONE) + : num(nNum) + , type(nType) + { + } + static cPictNum getPN_for_terrain(short num) + { + if(num < 960) + return cPictNum(num,PIC_TER); + else if(num < 1000) + return cPictNum(num-960,PIC_TER_ANIM); + else if(num < 2000) + return cPictNum(num-1000,PIC_CUSTOM_TER); + else + return cPictNum(num-2000,PIC_CUSTOM_TER_ANIM); + } + + pic_num_t num; + ePicType type; +}; + /// A simple icon. /// This control can also be made clickable. class cPict : public cControl { @@ -44,6 +67,7 @@ public: /// and applies the custom modifier. (If type is PIC_TER_MAP, it does not take the remainder by 1000.) /// - If num is 10000 or greater and type is PIC_TER_MAP, it automatically subtracts 10000 and applies the party modifier. void setPict(pic_num_t num, ePicType type); + void setPict(cPictNum const &num) { setPict(num.num, num.type); } /// Set the pict's icon. /// @param num The new icon index. void setPict(pic_num_t num); diff --git a/src/game/boe.locutils.cpp b/src/game/boe.locutils.cpp index 71892ab2..d7fdfdbc 100644 --- a/src/game/boe.locutils.cpp +++ b/src/game/boe.locutils.cpp @@ -304,13 +304,19 @@ bool is_blocked(location to_check) { return true; } - // checkme in combat.c this is only called when is_combat() && ter_pic==406 - // due to a logical error - if(is_combat() && !univ.scenario.is_legacy && univ.town.is_spot(to_check.x, to_check.y)) - return true; - if(is_combat() && univ.scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY) - return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check - // Note: The purpose of the above check is to avoid portals. + if (is_combat()) { + if (univ.scenario.is_legacy) { + // checkme in combat.c this is only called when is_combat() && ter_pic==406 + // (ie. ter_anim+6) due to a logical error + if (univ.scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].picture==966) + return true; + } + else { + if(univ.town.is_spot(to_check.x, to_check.y) || univ.scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY) + return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check + // Note: The purpose of the above check is to avoid portals. + } + } // Party there? if(is_town()) diff --git a/src/game/boe.specials.cpp b/src/game/boe.specials.cpp index 1ab39d86..fb024661 100644 --- a/src/game/boe.specials.cpp +++ b/src/game/boe.specials.cpp @@ -211,11 +211,22 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, } } - // checkme in combat.c this is only called when is_combat() && ter_pic==406 - // due to a logical error - if(is_combat() && ((!univ.scenario.is_legacy && univ.town.is_spot(where_check.x, where_check.y)) || terrain.trim_type == eTrimType::CITY)) { - ASB("Move: Can't trigger this special in combat."); - return false; // TODO: Maybe replace eTrimType::CITY check with a blockage == clear/special && is_special() check? + if (is_combat()) { + if (univ.scenario.is_legacy) { + // checkme in combat.c this is only called when is_combat() && ter_pic==406 + // (ie. ter_anim+6) due to a logical error + if (univ.scenario.ter_types[coord_to_ter(where_check.x,where_check.y)].picture==966) { + ASB("Move: Can't trigger this special in combat."); + return true; + } + } + else { + if(univ.town.is_spot(where_check.x, where_check.y) || univ.scenario.ter_types[coord_to_ter(where_check.x,where_check.y)].trim_type == eTrimType::CITY) { + ASB("Move: Can't trigger this special in combat."); + return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check + // Note: The purpose of the above check is to avoid portals. + } + } } if(mode != eSpecCtx::OUT_MOVE && univ.town.is_force_barr(where_check.x,where_check.y)) { diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 7c664bc1..ae87a14b 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -354,14 +354,7 @@ static void fill_ter_info(cDialog& me, short ter){ { cPict& pic_ctrl = dynamic_cast(me["graphic"]); pic_num_t pic = ter_type.picture; - if(pic < 960) - pic_ctrl.setPict(pic, PIC_TER); - else if(pic < 1000) - pic_ctrl.setPict(pic - 960, PIC_TER_ANIM); - else if(pic < 2000) - pic_ctrl.setPict(pic % 1000, PIC_CUSTOM_TER); - else - pic_ctrl.setPict(pic % 2000, PIC_CUSTOM_TER_ANIM); + pic_ctrl.setPict(cPictNum::getPN_for_terrain(pic)); me["pict"].setTextToNum(pic); }{ cPict& pic_ctrl = dynamic_cast(me["seemap"]); @@ -492,7 +485,7 @@ static bool edit_ter_obj(cDialog& me, ter_num_t which_ter) { for(int x = 0; x < 4; x++) { for(int y = 0; y < 4; y++) { std::string id = "x" + std::to_string(x) + "y" + std::to_string(y); - dynamic_cast(me[id]).setPict(obj[x][y]); + dynamic_cast(me[id]).setPict(cPictNum::getPN_for_terrain(obj[x][y])); } } return true; diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index 0cd4f22a..1d06fb1a 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -368,12 +368,7 @@ void edit_sign(sign_loc_t& which_sign,short num,short picture) { cDialog sign_dlg("edit-sign"); sign_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, &sign_dlg, false)); sign_dlg["okay"].attachClickHandler(std::bind(edit_sign_event_filter, _1, std::ref(which_sign))); - cPict& icon = dynamic_cast(sign_dlg["pic"]); - if(picture >= 960 && picture < 1000) - icon.setPict(picture, PIC_TER_ANIM); - else if(picture >= 2000) - icon.setPict(picture - 2000, PIC_CUSTOM_TER_ANIM); - else icon.setPict(picture, PIC_TER); // automatically adjusts for custom graphics + dynamic_cast(sign_dlg["pic"]).setPict(cPictNum::getPN_for_terrain(picture)); sign_dlg["num"].setTextToNum(num); sign_dlg["text"].setText(which_sign.text);