From d8ab1701111a4617dec56d60cd189f184bc2a0ce Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Sat, 2 Oct 2021 13:12:39 +0200 Subject: [PATCH] boe.actions.cpp: allow escaping the first phase of look/talking mode + correction of minor details... --- src/game/boe.actions.cpp | 29 +++++++++++++++++++++++------ src/game/boe.items.cpp | 12 ++++++------ src/tools/winutil.mac.mm | 4 ++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 0d62ed5f..3685b95c 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -1585,12 +1585,29 @@ bool handle_keystroke(const sf::Event& event){ Key talk_chars[9] = {kb::L,kb::N,kb::J,kb::B,kb::S,kb::R,kb::D,kb::G,kb::A}; Key shop_chars[8] = {kb::A,kb::B,kb::C,kb::D,kb::E,kb::F,kb::G,kb::H}; - if(map_visible && event.key.code == kb::Escape - && (overall_mode != MODE_TALKING) && (overall_mode != MODE_SHOPPING)) { - mini_map.setVisible(false); - map_visible = false; - mainPtr.setActive(); - return false; + if(event.key.code == kb::Escape) { + bool abort=true; + if (overall_mode == MODE_TALK_TOWN || overall_mode == MODE_LOOK_TOWN) + 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_COMBAT; + else + abort = false; + if (abort) { + play_sound(37); + add_string_to_buf("Aborted."); + print_buf(); + obscureCursor(); + return false; + } + if(map_visible && (overall_mode != MODE_TALKING) && (overall_mode != MODE_SHOPPING)) { + mini_map.setVisible(false); + map_visible = false; + mainPtr.setActive(); + return false; + } } if(overall_mode == MODE_STARTUP) diff --git a/src/game/boe.items.cpp b/src/game/boe.items.cpp index 676f472d..982c1ed0 100644 --- a/src/game/boe.items.cpp +++ b/src/game/boe.items.cpp @@ -750,11 +750,6 @@ void place_treasure(location where,short level,short loot,short mode) { {100,90,80,70,0,0}, {100,80,80,75,75,75} }; - static const short id_odds[21] = { - 0,10,15,20,25,30,35, - 39,43,47,51,55,59,63, - 67,71,73,75,77,79,81 - }; static const short max_mult[5][10] = { {0,0,0,0,0,0,0,0,0,1}, {0,0,1,1,1,1,2,3,5,20}, @@ -838,9 +833,14 @@ void place_treasure(location where,short level,short loot,short mode) { new_item.variety = eItemType::NO_ITEM; if(new_item.variety != eItemType::NO_ITEM) { + static const short id_odds[21] = { + 0,10,15,20,25,30,35, + 39,43,47,51,55,59,63, + 67,71,73,75,77,79,81 + }; for(short i = 0; i < 6; i++) if((univ.party[i].main_status == eMainStatus::ALIVE) - && get_ran(1,1,100) < id_odds[univ.party[i].skill(eSkill::ITEM_LORE)]) + && get_ran(1,1,100) <= id_odds[univ.party[i].skill(eSkill::ITEM_LORE)]) new_item.ident = true; place_item(new_item,where); } diff --git a/src/tools/winutil.mac.mm b/src/tools/winutil.mac.mm index 894ff92c..16a18656 100644 --- a/src/tools/winutil.mac.mm +++ b/src/tools/winutil.mac.mm @@ -79,7 +79,7 @@ std::string get_os_version() { NSProcessInfo* info = [NSProcessInfo processInfo]; std::ostringstream os; os << "Apple Mac OS X "; - os << [[info operatingSystemVersionString] cStringUsingEncoding:NSASCIIStringEncoding]; + os << [[info operatingSystemVersionString] UTF8String]; return os.str(); } @@ -148,9 +148,9 @@ void set_clipboard_img(sf::Image& img) { std::copy(img.getPixelsPtr(), img.getPixelsPtr() + data_sz, [bmp bitmapData]); NSImage * image = [[NSImage alloc] initWithSize: NSMakeSize(sz.x, sz.y)]; [image addRepresentation: bmp]; + [bmp release]; NSArray* contents = [NSArray arrayWithObject: image]; [image release]; - [bmp release]; NSPasteboard* pb = [NSPasteboard generalPasteboard]; [pb clearContents]; [pb writeObjects: contents];