diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 6cf3bbc2..f47723c0 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -1575,11 +1575,11 @@ bool handle_keystroke(const sf::Event& event){ if(event.key.code == kb::Escape) { bool abort=true; - if (overall_mode == MODE_TALK_TOWN || overall_mode == MODE_LOOK_TOWN || overall_mode == MODE_TOWN_TARGET) + if (overall_mode == MODE_DROP_TOWN || overall_mode == MODE_TALK_TOWN || overall_mode == MODE_LOOK_TOWN || overall_mode == MODE_TOWN_TARGET) overall_mode = MODE_TOWN; else if(overall_mode == MODE_LOOK_OUTDOORS) overall_mode = MODE_OUTDOORS; - else if (overall_mode == MODE_LOOK_COMBAT || overall_mode == MODE_SPELL_TARGET || overall_mode == MODE_FANCY_TARGET || overall_mode == MODE_FIRING || overall_mode == MODE_THROWING) + else if (overall_mode == MODE_DROP_COMBAT || overall_mode == MODE_LOOK_COMBAT || overall_mode == MODE_SPELL_TARGET || overall_mode == MODE_FANCY_TARGET || overall_mode == MODE_FIRING || overall_mode == MODE_THROWING) overall_mode = MODE_COMBAT; else abort = false; diff --git a/src/game/boe.graphutil.cpp b/src/game/boe.graphutil.cpp index fc594577..ae0ffaa6 100644 --- a/src/game/boe.graphutil.cpp +++ b/src/game/boe.graphutil.cpp @@ -358,51 +358,55 @@ void draw_fields(location where){ Draw_Some_Item(fields_gworld,calc_rect(4,0),terrain_screen_gworld,where_draw,1,0); return; } - if(univ.town.is_force_wall(where.x,where.y)) + if (!univ.town->is_on_map(where)) + return; + auto const fields=univ.town.fields[where.x][where.y]; + if ((fields&~(unsigned long)SPECIAL_EXPLORED)==0) return; + if(univ.town.is_force_wall(fields)) Draw_Some_Item(fields_gworld,calc_rect(0,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_fire_wall(where.x,where.y)) + if(univ.town.is_fire_wall(fields)) Draw_Some_Item(fields_gworld,calc_rect(1,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_antimagic(where.x,where.y)) + if(univ.town.is_antimagic(fields)) Draw_Some_Item(fields_gworld,calc_rect(2,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_scloud(where.x,where.y)) + if(univ.town.is_scloud(fields)) Draw_Some_Item(fields_gworld,calc_rect(3,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_ice_wall(where.x,where.y)) + if(univ.town.is_ice_wall(fields)) Draw_Some_Item(fields_gworld,calc_rect(4,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_blade_wall(where.x,where.y)) + if(univ.town.is_blade_wall(fields)) Draw_Some_Item(fields_gworld,calc_rect(5,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_sleep_cloud(where.x,where.y)) + if(univ.town.is_sleep_cloud(fields)) Draw_Some_Item(fields_gworld,calc_rect(6,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_block(where.x,where.y)) + 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(where.x,where.y)) + if(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(where.x,where.y)) + if(univ.town.is_web(fields)) Draw_Some_Item(fields_gworld,calc_rect(5,0),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_crate(where.x,where.y)) + if(univ.town.is_crate(fields)) Draw_Some_Item(fields_gworld,calc_rect(6,0),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_barrel(where.x,where.y)) + if(univ.town.is_barrel(fields)) Draw_Some_Item(fields_gworld,calc_rect(7,0),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_fire_barr(where.x,where.y) || univ.town.is_force_barr(where.x,where.y)) + if(univ.town.is_fire_barr(fields) || univ.town.is_force_barr(fields)) Draw_Some_Item(*ResMgr::textures.get("teranim"),calc_rect(8+(anim_ticks%4),4),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_quickfire(where.x,where.y)) + if(univ.town.is_quickfire(fields)) Draw_Some_Item(fields_gworld,calc_rect(7,1),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_sm_blood(where.x,where.y)) + if(univ.town.is_sm_blood(fields)) Draw_Some_Item(fields_gworld,calc_rect(0,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_med_blood(where.x,where.y)) + if(univ.town.is_med_blood(fields)) Draw_Some_Item(fields_gworld,calc_rect(1,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_lg_blood(where.x,where.y)) + if(univ.town.is_lg_blood(fields)) Draw_Some_Item(fields_gworld,calc_rect(2,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_sm_slime(where.x,where.y)) + if(univ.town.is_sm_slime(fields)) Draw_Some_Item(fields_gworld,calc_rect(3,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_lg_slime(where.x,where.y)) + if(univ.town.is_lg_slime(fields)) Draw_Some_Item(fields_gworld,calc_rect(4,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_ash(where.x,where.y)) + if(univ.town.is_ash(fields)) Draw_Some_Item(fields_gworld,calc_rect(5,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_bones(where.x,where.y)) + if(univ.town.is_bones(fields)) Draw_Some_Item(fields_gworld,calc_rect(6,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_rubble(where.x,where.y)) + if(univ.town.is_rubble(fields)) Draw_Some_Item(fields_gworld,calc_rect(7,3),terrain_screen_gworld,where_draw,1,0); - if(univ.town.is_force_cage(where.x,where.y)) { + if(univ.town.is_force_cage(fields)) { Draw_Some_Item(fields_gworld,calc_rect(1,0),terrain_screen_gworld,where_draw,1,0); forcecage_locs.push_back(where_draw); } diff --git a/src/game/boe.items.cpp b/src/game/boe.items.cpp index d9c3d08e..3e69964f 100644 --- a/src/game/boe.items.cpp +++ b/src/game/boe.items.cpp @@ -385,13 +385,13 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr else me.addLabelFor(id," ", LABEL_LEFT, 7, true); } + if (first_item_shown >= item_array.size()) + first_item_shown=std::max(size_t(8),item_array.size())-8; // darken arrows, as appropriate if(first_item_shown == 0) me["up"].hide(); else me["up"].show(); - // ASAN undefined behaviour, ie. item_array.size can be less than 7 - if(first_item_shown+7 > item_array.size() || - item_array.size() <= 8) + if(first_item_shown+8 >= item_array.size()) me["down"].hide(); else me["down"].show(); diff --git a/src/game/boe.text.cpp b/src/game/boe.text.cpp index 3ffe5a22..6981b8f0 100644 --- a/src/game/boe.text.cpp +++ b/src/game/boe.text.cpp @@ -1048,7 +1048,7 @@ void print_buf () { long start_print_point; rectangle store_text_rect,dest_rect,erase_rect = {2,2,136,255}; - text_area_gworld.setActive(); + text_area_gworld.setActive(false); // First clean up gworld with pretty patterns tileImage(text_area_gworld, erase_rect,bg[6]); @@ -1077,6 +1077,7 @@ void print_buf () { } text_area_gworld.display(); + text_area_gworld.setActive(); } void restart_printing() { diff --git a/src/universe/universe.cpp b/src/universe/universe.cpp index 86b87d89..2f5a0683 100644 --- a/src/universe/universe.cpp +++ b/src/universe/universe.cpp @@ -208,60 +208,61 @@ cTown*const cCurTown::record() const { bool cCurTown::is_explored(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SPECIAL_EXPLORED; + return is_explored(fields[x][y]); } bool cCurTown::is_force_wall(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & WALL_FORCE; + return is_force_wall(fields[x][y]); } bool cCurTown::is_fire_wall(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & WALL_FIRE; + return is_fire_wall(fields[x][y]); } bool cCurTown::is_antimagic(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & FIELD_ANTIMAGIC; + return is_antimagic(fields[x][y]); } bool cCurTown::is_scloud(short x, short y) const{ // stinking cloud if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & CLOUD_STINK; + return is_scloud(fields[x][y]); } bool cCurTown::is_ice_wall(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & WALL_ICE; + return is_ice_wall(fields[x][y]); } bool cCurTown::is_blade_wall(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & WALL_BLADES; + return is_blade_wall(fields[x][y]); } bool cCurTown::is_sleep_cloud(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & CLOUD_SLEEP; + return is_sleep_cloud(fields[x][y]); } bool cCurTown::is_block(short x, short y) const{ // currently unused if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & OBJECT_BLOCK; + return is_block(fields[x][y]); } bool cCurTown::is_spot(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SPECIAL_SPOT; + return is_spot(fields[x][y]); } bool cCurTown::is_road(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SPECIAL_ROAD; + return is_road(fields[x][y]); } bool cCurTown::is_special(short x, short y) const{ + if(!record()->is_on_map(x,y)) return false; location check(x,y); for(int i = 0; i < record()->special_locs.size(); i++) if(check == record()->special_locs[i] && record()->special_locs[i].spec >= 0) @@ -271,77 +272,77 @@ bool cCurTown::is_special(short x, short y) const{ bool cCurTown::is_web(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & FIELD_WEB; + return is_web(fields[x][y]); } bool cCurTown::is_crate(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & OBJECT_CRATE; + return is_crate(fields[x][y]); } bool cCurTown::is_barrel(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & OBJECT_BARREL; + return is_barrel(fields[x][y]); } bool cCurTown::is_fire_barr(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & BARRIER_FIRE; + return is_fire_barr(fields[x][y]); } bool cCurTown::is_force_barr(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & BARRIER_FORCE; + return is_force_barr(fields[x][y]); } bool cCurTown::is_quickfire(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & FIELD_QUICKFIRE; + return is_quickfire(fields[x][y]); } bool cCurTown::is_sm_blood(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_SMALL_BLOOD; + return is_sm_blood(fields[x][y]); } bool cCurTown::is_med_blood(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_MEDIUM_BLOOD; + return is_med_blood(fields[x][y]); } bool cCurTown::is_lg_blood(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_LARGE_BLOOD; + return is_lg_blood(fields[x][y]); } bool cCurTown::is_sm_slime(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_SMALL_SLIME; + return is_sm_slime(fields[x][y]); } bool cCurTown::is_lg_slime(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_LARGE_SLIME; + return is_lg_slime(fields[x][y]); } bool cCurTown::is_ash(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_ASH; + return is_ash(fields[x][y]); } bool cCurTown::is_bones(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_BONES; + return is_bones(fields[x][y]); } bool cCurTown::is_rubble(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & SFX_RUBBLE; + return is_rubble(fields[x][y]); } bool cCurTown::is_force_cage(short x, short y) const{ if(!record()->is_on_map(x,y)) return false; - return fields[x][y] & BARRIER_CAGE; + return is_force_cage(fields[x][y]); } bool cCurTown::set_explored(short x, short y, bool b){ diff --git a/src/universe/universe.hpp b/src/universe/universe.hpp index 44a920bb..cbb6d9b7 100644 --- a/src/universe/universe.hpp +++ b/src/universe/universe.hpp @@ -61,6 +61,32 @@ public: void prep_arena(); // Set up for a combat arena void place_preset_fields(); + static bool is_explored(unsigned long allFields) { return allFields & SPECIAL_EXPLORED; } + static bool is_force_wall(unsigned long allFields) { return allFields & WALL_FORCE; } + static bool is_fire_wall(unsigned long allFields) { return allFields & WALL_FIRE; } + static bool is_antimagic(unsigned long allFields) { return allFields & FIELD_ANTIMAGIC; } + static bool is_scloud(unsigned long allFields) { return allFields & CLOUD_STINK; } // stinking cloud + static bool is_ice_wall(unsigned long allFields) { return allFields & WALL_ICE; } + static bool is_blade_wall(unsigned long allFields) { return allFields & WALL_BLADES; } + static bool is_sleep_cloud(unsigned long allFields) { return allFields & CLOUD_SLEEP; } + static bool is_block(unsigned long allFields) { return allFields & OBJECT_BLOCK; } // currently unused + static bool is_spot(unsigned long allFields) { return allFields & SPECIAL_SPOT; } + static bool is_web(unsigned long allFields) { return allFields & FIELD_WEB; } + static bool is_crate(unsigned long allFields) { return allFields & OBJECT_CRATE; } + static bool is_barrel(unsigned long allFields) { return allFields & OBJECT_BARREL; } + static bool is_fire_barr(unsigned long allFields) { return allFields & BARRIER_FIRE; } + static bool is_force_barr(unsigned long allFields) { return allFields & BARRIER_FORCE; } + static bool is_quickfire(unsigned long allFields) { return allFields & FIELD_QUICKFIRE; } + static bool is_sm_blood(unsigned long allFields) { return allFields & SFX_SMALL_BLOOD; } + static bool is_med_blood(unsigned long allFields) { return allFields & SFX_MEDIUM_BLOOD; } + static bool is_lg_blood(unsigned long allFields) { return allFields & SFX_LARGE_BLOOD; } + static bool is_sm_slime(unsigned long allFields) { return allFields & SFX_SMALL_SLIME; } + static bool is_lg_slime(unsigned long allFields) { return allFields & SFX_LARGE_SLIME; } + static bool is_ash(unsigned long allFields) { return allFields & SFX_ASH; } + static bool is_bones(unsigned long allFields) { return allFields & SFX_BONES; } + static bool is_rubble(unsigned long allFields) { return allFields & SFX_RUBBLE; } + static bool is_force_cage(unsigned long allFields) { return allFields & BARRIER_CAGE; } + static bool is_road(unsigned long allFields) { return allFields & SPECIAL_ROAD; } bool is_explored(short x, short y) const; bool is_force_wall(short x, short y) const; bool is_fire_wall(short x, short y) const;