boe.items.cpp: try to display the recovered stored items with good picture,

boe.locutils.cpp: protect loc_off_act_area against array bound
This commit is contained in:
Laurent alonso
2021-11-06 14:23:41 +01:00
committed by Celtic Minstrel
parent baa0bf81c4
commit bbaaa4779c
5 changed files with 9 additions and 5 deletions

View File

@@ -378,7 +378,7 @@ void draw_fields(location where){
Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_block(fields))
Draw_Some_Item(fields_gworld,calc_rect(3,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_spot(fields))
if(!is_combat() && univ.town.is_spot(fields))
Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0);
if(univ.town.is_web(fields))
Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0);

View File

@@ -411,7 +411,9 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
me[name].setText(item.ident ? item.full_name : item.name);
// TODO: Party sheet items
cPict& pic = dynamic_cast<cPict&>(me[pict]);
if(item.graphic_num >= 1000)
if(item.graphic_num>=10000)
pic.setPict(item.graphic_num-10000, PIC_PARTY_ITEM);
else if(item.graphic_num >= 1000)
pic.setPict(item.graphic_num - 1000, PIC_CUSTOM_ITEM);
else pic.setPict(item.graphic_num, PIC_ITEM);
me[detail].setText(get_item_interesting_string(item));

View File

@@ -146,6 +146,8 @@ bool loc_off_world(location p1) {
}
bool loc_off_act_area(location p1) {
if (is_out())
return p1.x < 0 || p1.x >= 48 || p1.y < 0 || p1.y >= 48;
if (!univ.town->is_on_map(p1)) return true;
if((p1.x > univ.town->in_town_rect.left) && (p1.x < univ.town->in_town_rect.right) &&
(p1.y > univ.town->in_town_rect.top) && (p1.y < univ.town->in_town_rect.bottom))
@@ -266,7 +268,6 @@ void update_explored(location dest) {
// All purpose function to check is spot is free for travel into.
bool is_blocked(location to_check) {
short gr;
ter_num_t ter;
// ASAN: location can be bad if we are called by place_party
if (to_check.x<0 || to_check.y<0)

View File

@@ -238,7 +238,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
add_string_to_buf(" Force cage!");
can_enter = false;
}
if((mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1))
if((mode == eSpecCtx::TOWN_MOVE || (mode == eSpecCtx::COMBAT_MOVE && which_combat_type == 1 && !univ.town.is_spot(where_check.x,where_check.y)))
&& can_enter && univ.town.is_special(where_check.x,where_check.y)) {
for(auto const &spec_loc : univ.town->special_locs) {
if(where_check != spec_loc) continue;

View File

@@ -484,7 +484,8 @@ bool cCurTown::set_block(short x, short y, bool b){ // currently unused
bool cCurTown::set_spot(short x, short y, bool b){
if(!record()->is_on_map(x,y)) return false;
if(b) fields[x][y] |= SPECIAL_SPOT;
if(b)
fields[x][y] |= SPECIAL_SPOT;
else fields[x][y] &= ~SPECIAL_SPOT;
return true;
}