diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index 9a6c6a65..b2f66d72 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -3253,7 +3253,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, univ.party.stuff_done[spec.sd1][spec.sd2] = univ.party[pc_num].unique_id - 1000; if(spec.ex1a == 1) break; who->main_status += eMainStatus::SPLIT; - univ.stored_pcs[who->unique_id] = who; + univ.stored_pcs[who->unique_id] = who->leave_party(); univ.party.new_pc(pc_num); } break; diff --git a/src/classes/party.cpp b/src/classes/party.cpp index fd4c6bdb..4923dfde 100644 --- a/src/classes/party.cpp +++ b/src/classes/party.cpp @@ -232,6 +232,7 @@ void cParty::new_pc(size_t spot) { void cParty::replace_pc(size_t spot, cPlayer* with) { if(spot < 6 && with != nullptr) { + with->join_party(*this); delete adven[spot]; adven[spot] = with; } diff --git a/src/classes/pc.hpp b/src/classes/pc.hpp index 3b995217..0f97d41d 100644 --- a/src/classes/pc.hpp +++ b/src/classes/pc.hpp @@ -111,6 +111,9 @@ public: short stat_adj(eSkill skill) const; eBuyStatus ok_to_buy(short cost,cItem item) const; + void join_party(cParty& p) {party = &p;} + cPlayer* leave_party() {party = nullptr; return this;} + void append(legacy::pc_record_type old); cPlayer(cParty& party); cPlayer(cParty& party,long key,short slot); diff --git a/src/classes/universe.hpp b/src/classes/universe.hpp index 4e5894fe..82c668bf 100644 --- a/src/classes/universe.hpp +++ b/src/classes/universe.hpp @@ -171,7 +171,7 @@ public: void swap_buf(int newbuf) {std::swap(strbuf, extrabufs[newbuf]);} unsigned char& cpn_flag(unsigned int x, unsigned int y, std::string id = ""); - + cScenario scenario; cParty party; std::map stored_pcs; diff --git a/src/tools/fileio_party.cpp b/src/tools/fileio_party.cpp index 3ecece7d..35b3dc9c 100644 --- a/src/tools/fileio_party.cpp +++ b/src/tools/fileio_party.cpp @@ -319,7 +319,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ){ std::string fname = "save/pc~" + std::to_string(next_uid) + ".txt"; cPlayer* stored_pc = new cPlayer(univ.party); stored_pc->readFrom(partyIn.getFile(fname)); - univ.stored_pcs[next_uid] = stored_pc; + univ.stored_pcs[next_uid] = stored_pc->leave_party(); } }