Consolidate active quest data into a single map
This commit is contained in:
@@ -86,9 +86,7 @@ cParty::cParty(const cParty& other)
|
||||
, special_notes(other.special_notes)
|
||||
, talk_save(other.talk_save)
|
||||
, status(other.status)
|
||||
, quest_status(other.quest_status)
|
||||
, quest_start(other.quest_start)
|
||||
, quest_source(other.quest_source)
|
||||
, active_quests(other.active_quests)
|
||||
, left_at(other.left_at)
|
||||
, left_in(other.left_in)
|
||||
, direction(other.direction)
|
||||
@@ -158,9 +156,7 @@ void cParty::swap(cParty& other) {
|
||||
std::swap(special_notes, other.special_notes);
|
||||
std::swap(talk_save, other.talk_save);
|
||||
std::swap(status, other.status);
|
||||
std::swap(quest_status, other.quest_status);
|
||||
std::swap(quest_start, other.quest_start);
|
||||
std::swap(quest_source, other.quest_source);
|
||||
std::swap(active_quests, other.active_quests);
|
||||
std::swap(left_at, other.left_at);
|
||||
std::swap(left_in, other.left_in);
|
||||
std::swap(direction, other.direction);
|
||||
@@ -741,8 +737,8 @@ void cParty::writeTo(std::ostream& file, const cScenario& scen) const {
|
||||
file << "SCENARIO " << scen_name << '\n';
|
||||
file << "WON " << scen_won << '\n';
|
||||
file << "PLAYED " << scen_played << '\n';
|
||||
for(auto p : quest_status)
|
||||
file << "QUEST " << p.first << ' ' << p.second << ' ' << quest_start.at(p.first) << ' ' << quest_source.at(p.first) << '\n';
|
||||
for(auto p : active_quests)
|
||||
file << "QUEST " << p.first << ' ' << p.second.status << ' ' << p.second.start << ' ' << p.second.source << '\n';
|
||||
for(auto p : store_limited_stock) {
|
||||
for(auto p2 : p.second) {
|
||||
file << "SHOPSTOCK " << p.first << p2.first << p2.second;
|
||||
@@ -990,7 +986,7 @@ void cParty::readFrom(std::istream& file, cScenario& scen){
|
||||
} else if(cur == "QUEST") {
|
||||
int i;
|
||||
sin >> i;
|
||||
sin >> quest_status[i] >> quest_start[i] >> quest_source[i];
|
||||
sin >> active_quests[i].status >> active_quests[i].start >> active_quests[i].source;
|
||||
} else if(cur == "SHOPSTOCK") {
|
||||
int i, j;
|
||||
sin >> i >> j >> store_limited_stock[i][j];
|
||||
|
||||
@@ -111,10 +111,7 @@ public:
|
||||
std::vector<cEncNote> special_notes;
|
||||
std::vector<cConvers> talk_save;
|
||||
std::map<ePartyStatus,short> status;
|
||||
// Quest stuff
|
||||
std::map<int, eQuestStatus> quest_status;
|
||||
std::map<int, int> quest_start; // the day the quest was started; used for quests with relative deadlines
|
||||
std::map<int, int> quest_source; // if gotten from a job board, this is the number of the job board; otherwise -1
|
||||
std::map<int, cJob> active_quests;
|
||||
location left_at;
|
||||
size_t left_in;
|
||||
eDirection direction;
|
||||
|
||||
@@ -465,9 +465,7 @@ bool cPlayer::give_item(cItem item, int flags) {
|
||||
}
|
||||
if(item.variety == eItemType::QUEST) {
|
||||
if(!party) return false;
|
||||
party->quest_status[item.item_level] = eQuestStatus::STARTED;
|
||||
party->quest_start[item.item_level] = party->calc_day();
|
||||
party->quest_source[item.item_level] = -1;
|
||||
party->active_quests[item.item_level] = cJob(party->calc_day());
|
||||
if(do_print && print_result)
|
||||
print_result("You get a quest.");
|
||||
return true;
|
||||
@@ -832,7 +830,7 @@ eBuyStatus cPlayer::ok_to_buy(short cost,cItem item) const {
|
||||
if(party->spec_items.count(item.item_level))
|
||||
return eBuyStatus::HAVE_LOTS;
|
||||
} else if(item.variety == eItemType::QUEST) {
|
||||
if(party->quest_status[item.item_level] != eQuestStatus::AVAILABLE)
|
||||
if(party->active_quests[item.item_level].status != eQuestStatus::AVAILABLE)
|
||||
return eBuyStatus::HAVE_LOTS;
|
||||
} else if(item.variety != eItemType::GOLD && item.variety != eItemType::FOOD) {
|
||||
for(int i = 0; i < items.size(); i++)
|
||||
|
||||
@@ -1369,9 +1369,7 @@ void cUniverse::enter_scenario(const std::string& name) {
|
||||
}
|
||||
for(short i = 0; i < scenario.quests.size(); i++) {
|
||||
if(scenario.quests[i].flags >= 10) {
|
||||
party.quest_status[i] = eQuestStatus::STARTED;
|
||||
party.quest_start[i] = 1;
|
||||
party.quest_source[i] = -1;
|
||||
party.active_quests[i] = cJob(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1397,7 +1395,7 @@ void cUniverse::generate_job_bank(int which, job_bank_t& bank) {
|
||||
for(size_t i = 0; iSlot < 4 && i < scenario.quests.size(); i++) {
|
||||
if(scenario.quests[i].bank1 != which && scenario.quests[i].bank2 != which)
|
||||
continue;
|
||||
if(party.quest_status[i] != eQuestStatus::AVAILABLE)
|
||||
if(party.active_quests[i].status != eQuestStatus::AVAILABLE)
|
||||
continue;
|
||||
if(get_ran(1,1,100) <= 50 - bank.anger)
|
||||
bank.jobs[iSlot++] = i;
|
||||
|
||||
Reference in New Issue
Block a user