From cb14a9c5d7f428cdb73d233856546892966724be Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 23 Jun 2015 20:17:06 -0400 Subject: [PATCH] Add a Swap Buffer node, giving you an infinite number of string variables - Also fix the string buffer so that it actually works. - Also add a node to change the text of a sign --- rsrc/strings/specials-opcodes.txt | 4 ++-- rsrc/strings/specials-text-general.txt | 32 ++++++++++++++++++++++++++ src/boe.specials.cpp | 13 +++++++++++ src/classes/simpletypes.hpp | 4 +++- src/classes/special.cpp | 22 +++++++++--------- src/classes/universe.hpp | 5 +++- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/rsrc/strings/specials-opcodes.txt b/rsrc/strings/specials-opcodes.txt index ffc0ac75..41dd06b0 100644 --- a/rsrc/strings/specials-opcodes.txt +++ b/rsrc/strings/specials-opcodes.txt @@ -43,8 +43,8 @@ append-ter pause start-talk quest - - +swap-buf +sign-buf once-give-item diff --git a/rsrc/strings/specials-text-general.txt b/rsrc/strings/specials-text-general.txt index 90dbc918..d6dbd103 100644 --- a/rsrc/strings/specials-text-general.txt +++ b/rsrc/strings/specials-text-general.txt @@ -734,6 +734,38 @@ Unused Unused Special to Jump To -------------------- +Swap String Buffer +Unused +Unused +First part of message +Second part of message +Unused +Unused +Unused +Which string buffer? +Unused +Unused +Unused +Unused +Unused +Special to Jump To +-------------------- +Alter Sign Text +Unused +Unused +First part of message +Second part of message +Unused +Unused +Unused +Which sign? +Unused +Unused +Unused +Unused +Unused +Special to Jump To +-------------------- Special Name sdf1 sdf2 diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index a6ee9032..19d6842a 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -2410,6 +2410,19 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, case eSpecType::APPEND_TER: univ.get_buf() += univ.scenario.ter_types[spec.ex1a].name; break; + case eSpecType::SWAP_STR_BUF: + univ.swap_buf(spec.ex1a); + break; + case eSpecType::STR_BUF_TO_SIGN: + if(spec.ex1a < 0) break; + if(is_out()) { + if(spec.ex1a >= univ.out->sign_locs.size()) break; + std::swap(univ.out->sign_locs[spec.ex1a].text, univ.get_buf()); + } else { + if(spec.ex1a >= univ.town->sign_locs.size()) break; + std::swap(univ.town->sign_locs[spec.ex1a].text, univ.get_buf()); + } + break; case eSpecType::PAUSE: if(spec.ex1a < 0) break; redraw_screen(REFRESH_TERRAIN | REFRESH_STATS); diff --git a/src/classes/simpletypes.hpp b/src/classes/simpletypes.hpp index c25e4e88..932b5a77 100644 --- a/src/classes/simpletypes.hpp +++ b/src/classes/simpletypes.hpp @@ -614,6 +614,8 @@ enum class eSpecType { PAUSE = 43, START_TALK = 44, UPDATE_QUEST = 45, + SWAP_STR_BUF = 46, + STR_BUF_TO_SIGN = 47, ONCE_GIVE_ITEM = 50, ONCE_GIVE_SPEC_ITEM = 51, ONCE_NULL = 52, @@ -744,7 +746,7 @@ enum class eSpecCat { inline eSpecCat getNodeCategory(eSpecType node) { int code = (int) node; - if(code >= 0 && code <= 45) + if(code >= 0 && code <= 47) return eSpecCat::GENERAL; if(code >= 50 && code <= 63) return eSpecCat::ONCE; diff --git a/src/classes/special.cpp b/src/classes/special.cpp index b8d93dbc..496ff53d 100644 --- a/src/classes/special.cpp +++ b/src/classes/special.cpp @@ -387,17 +387,17 @@ void cSpecial::append(legacy::special_node_type& old){ // (terrain, monster, dialog, talk, item, pc, field, boom, missile, status) static const char*const button_dict[7][11] = { { // general nodes - " mmmMmmmmmMmmm mmmmmm Mmm $ mmmmmm m", // msg1 - " ", // msg2 - " ", // msg3 - " p 3 ", // pic - " ? ", // pictype - " & x T i M cit j", // ex1a - " % S ss cJ", // ex1b - " ", // ex1c - " tt ", // ex2a - " t ", // ex2b - " ", // ex2c + " mmmMmmmmmMmmm mmmmmm Mmm $ mmmmmm mmm", // msg1 + " ", // msg2 + " ", // msg3 + " p 3 ", // pic + " ? ", // pictype + " & x T i M cit j ", // ex1a + " % S ss cJ ", // ex1b + " ", // ex1c + " tt ", // ex2a + " t ", // ex2b + " ", // ex2c }, { // one-shot nodes "mm md d mmm", // msg1 " ", // msg2 diff --git a/src/classes/universe.hpp b/src/classes/universe.hpp index 662344b4..2dbf76e1 100644 --- a/src/classes/universe.hpp +++ b/src/classes/universe.hpp @@ -158,6 +158,7 @@ class cUniverse{ void check_monst(cMonster& monst); void check_item(cItem& item); std::string strbuf; + std::map extrabufs; public: void exportSummons(); void exportGraphics(); @@ -165,7 +166,9 @@ public: iLiving& get_target(size_t which); iLiving* target_there(location pos, eTargetType type = TARG_ANY); size_t get_target_i(iLiving& who); - std::string get_buf() {return strbuf;} + + std::string& get_buf() {return strbuf;} + void swap_buf(int newbuf) {std::swap(strbuf, extrabufs[newbuf]);} cScenario scenario; cParty party;