From bbaaa4779c94866281f2389259a2622fa3f108f4 Mon Sep 17 00:00:00 2001 From: Laurent alonso Date: Sat, 6 Nov 2021 14:23:41 +0100 Subject: [PATCH] boe.items.cpp: try to display the recovered stored items with good picture, boe.locutils.cpp: protect loc_off_act_area against array bound --- src/game/boe.graphutil.cpp | 2 +- src/game/boe.items.cpp | 4 +++- src/game/boe.locutils.cpp | 3 ++- src/game/boe.specials.cpp | 2 +- src/universe/universe.cpp | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/game/boe.graphutil.cpp b/src/game/boe.graphutil.cpp index ae0ffaa6..89218641 100644 --- a/src/game/boe.graphutil.cpp +++ b/src/game/boe.graphutil.cpp @@ -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); diff --git a/src/game/boe.items.cpp b/src/game/boe.items.cpp index 3e69964f..5c2d4dcf 100644 --- a/src/game/boe.items.cpp +++ b/src/game/boe.items.cpp @@ -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(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)); diff --git a/src/game/boe.locutils.cpp b/src/game/boe.locutils.cpp index 7e49f0fd..1821b6f3 100644 --- a/src/game/boe.locutils.cpp +++ b/src/game/boe.locutils.cpp @@ -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) diff --git a/src/game/boe.specials.cpp b/src/game/boe.specials.cpp index ba241847..7468bc5d 100644 --- a/src/game/boe.specials.cpp +++ b/src/game/boe.specials.cpp @@ -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; diff --git a/src/universe/universe.cpp b/src/universe/universe.cpp index 2f5a0683..ffc8381a 100644 --- a/src/universe/universe.cpp +++ b/src/universe/universe.cpp @@ -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; }