Move calc_day() into party class
This commit is contained in:
@@ -602,7 +602,7 @@ void end_talk_mode() {
|
||||
static void fill_job_bank(cDialog& me, job_bank_t& bank, std::string) {
|
||||
// TODO: Maybe customize the icon?
|
||||
// TODO: Allow custom title?
|
||||
me["day"].setTextToNum(calc_day());
|
||||
me["day"].setTextToNum(univ.party.calc_day());
|
||||
for(int i = 0; i < 4; i++) {
|
||||
std::string id = std::to_string(i + 1);
|
||||
if(bank.jobs[i] >= 0 && bank.jobs[i] < univ.scenario.quests.size()) {
|
||||
@@ -631,7 +631,7 @@ static void show_job_bank(int which_bank, std::string title) {
|
||||
job_bank_t& bank = univ.party.job_banks[which_bank];
|
||||
univ.party.quest_status[bank.jobs[which]] = eQuestStatus::STARTED;
|
||||
univ.party.quest_source[bank.jobs[which]] = store_personality;
|
||||
univ.party.quest_start[bank.jobs[which]] = calc_day();
|
||||
univ.party.quest_start[bank.jobs[which]] = univ.party.calc_day();
|
||||
// Now, if there are spare jobs available, fill in. Otherwise, clear space.
|
||||
if(bank.jobs[4] >= 0)
|
||||
std::swap(bank.jobs[which], bank.jobs[4]);
|
||||
@@ -969,7 +969,7 @@ void handle_talk_event(location p) {
|
||||
case eQuestStatus::AVAILABLE:
|
||||
univ.party.quest_status[a] = eQuestStatus::STARTED;
|
||||
univ.party.quest_source[a] = -1;
|
||||
univ.party.quest_start[a] = calc_day();
|
||||
univ.party.quest_start[a] = univ.party.calc_day();
|
||||
break;
|
||||
case eQuestStatus::STARTED:
|
||||
break;
|
||||
|
||||
@@ -814,7 +814,7 @@ void journal() {
|
||||
}
|
||||
|
||||
void add_to_journal(short event) {
|
||||
if(univ.party.add_to_journal(univ.scenario.journal_strs[event], calc_day()))
|
||||
if(univ.party.add_to_journal(univ.scenario.journal_strs[event], univ.party.calc_day()))
|
||||
ASB("Something was added to your journal.");
|
||||
}
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ static bool display_item_event_filter(cDialog& me, std::string id, size_t& first
|
||||
set_item_flag(&item);
|
||||
} else if(item.variety == eItemType::QUEST) {
|
||||
univ.party.quest_status[item.item_level] == eQuestStatus::STARTED;
|
||||
univ.party.quest_start[item.item_level] = calc_day();
|
||||
univ.party.quest_start[item.item_level] = univ.party.calc_day();
|
||||
univ.party.quest_source[item.item_level] = -1;
|
||||
set_item_flag(&item);
|
||||
} else {
|
||||
|
||||
@@ -2197,7 +2197,7 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
if(spec.ex1a != minmax(1,10,spec.ex1a))
|
||||
giveError("Event code out of range.");
|
||||
else if(univ.party.key_times.count(spec.ex1a) == 0)
|
||||
univ.party.key_times[spec.ex1a] = calc_day();
|
||||
univ.party.key_times[spec.ex1a] = univ.party.calc_day();
|
||||
break;
|
||||
case eSpecType::FORCED_GIVE:
|
||||
check_mess = true;
|
||||
@@ -2418,7 +2418,7 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
break;
|
||||
}
|
||||
if(spec.ex1b == int(eQuestStatus::STARTED) && univ.party.quest_status[spec.ex1a] != eQuestStatus::STARTED) {
|
||||
univ.party.quest_start[spec.ex1a] = calc_day();
|
||||
univ.party.quest_start[spec.ex1a] = univ.party.calc_day();
|
||||
univ.party.quest_source[spec.ex1a] = max(-1,spec.ex2a);
|
||||
if(univ.party.quest_source[spec.ex1a] >= univ.party.job_banks.size())
|
||||
univ.party.job_banks.resize(univ.party.quest_source[spec.ex1a] + 1);
|
||||
@@ -3266,7 +3266,7 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
}
|
||||
break;
|
||||
case eSpecType::IF_DAY_REACHED:
|
||||
if(calc_day() >= spec.ex1a)
|
||||
if(univ.party.calc_day() >= spec.ex1a)
|
||||
*next_spec = spec.ex1b;
|
||||
break;
|
||||
case eSpecType::IF_FIELDS:
|
||||
|
||||
@@ -107,7 +107,7 @@ void put_pc_screen() {
|
||||
// Put food, gold, day
|
||||
win_draw_string(pc_stats_gworld,small_erase_rects[1],std::to_string(univ.party.gold),eTextMode::WRAP,style);
|
||||
win_draw_string(pc_stats_gworld,small_erase_rects[0],std::to_string(univ.party.food),eTextMode::WRAP,style);
|
||||
win_draw_string(pc_stats_gworld,small_erase_rects[2],std::to_string(calc_day()),eTextMode::WRAP,style);
|
||||
win_draw_string(pc_stats_gworld,small_erase_rects[2],std::to_string(univ.party.calc_day()),eTextMode::WRAP,style);
|
||||
style.colour = sf::Color::Black;
|
||||
|
||||
for(i = 0; i < 6; i++) {
|
||||
@@ -1150,10 +1150,6 @@ void make_cursor_sword() {
|
||||
set_cursor(sword_curs);
|
||||
}
|
||||
|
||||
short calc_day() {
|
||||
return (short) ((univ.party.age) / 3700) + 1;
|
||||
}
|
||||
|
||||
// which_day is day event should happen
|
||||
// which_event is the univ.party.key_times value to cross reference with.
|
||||
// if the key_time is reached before which_day, event won't happen
|
||||
@@ -1168,7 +1164,7 @@ bool day_reached(unsigned short which_day, unsigned short which_event) {
|
||||
if(univ.party.key_times[which_event] < which_day)
|
||||
return false;
|
||||
}
|
||||
if(calc_day() >= which_day)
|
||||
if(univ.party.calc_day() >= which_day)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ void restore_mode();
|
||||
void through_sending();
|
||||
rectangle coord_to_rect(short i,short j);
|
||||
void make_cursor_sword() ;
|
||||
short calc_day();
|
||||
bool day_reached(unsigned short which_day, unsigned short which_event);
|
||||
void Draw_Some_Item (sf::Texture& src_gworld, rectangle src_rect, sf::RenderTarget& targ_gworld, location target, char masked, short main_win);
|
||||
rectangle get_stat_effect_rect(int which_effect);
|
||||
|
||||
@@ -212,7 +212,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
switch(univ.town.monst[j].time_flag){
|
||||
case eMonstTime::ALWAYS: break; // Nothing to do.
|
||||
case eMonstTime::SOMETIMES_A: case eMonstTime::SOMETIMES_B: case eMonstTime::SOMETIMES_C:
|
||||
if((calc_day() % 3) + 3 != int(univ.town.monst[j].time_flag))
|
||||
if((univ.party.calc_day() % 3) + 3 != int(univ.town.monst[j].time_flag))
|
||||
univ.town.monst[j].active = 0;
|
||||
else {
|
||||
univ.town.monst[j].active = 1;
|
||||
@@ -238,7 +238,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
case eMonstTime::APPEAR_WHEN_EVENT:
|
||||
if(univ.party.key_times.find(univ.town.monst[j].time_code) == univ.party.key_times.end())
|
||||
break; // Event hasn't happened yet
|
||||
if(calc_day() >= univ.party.key_times[univ.town.monst[j].time_code]){ //calc_day is used because of the "definition" of univ.party.key_times
|
||||
if(univ.party.calc_day() >= univ.party.key_times[univ.town.monst[j].time_code]){ //calc_day is used because of the "definition" of univ.party.key_times
|
||||
univ.town.monst[j].active = 1;
|
||||
univ.town.monst[j].time_flag = eMonstTime::ALWAYS;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
case eMonstTime::DISAPPEAR_WHEN_EVENT:
|
||||
if(univ.party.key_times.find(univ.town.monst[j].time_code) == univ.party.key_times.end())
|
||||
break; // Event hasn't happened yet
|
||||
if(calc_day() >= univ.party.key_times[univ.town.monst[j].time_code]){
|
||||
if(univ.party.calc_day() >= univ.party.key_times[univ.town.monst[j].time_code]){
|
||||
univ.town.monst[j].active = 0;
|
||||
univ.town.monst[j].time_flag = eMonstTime::ALWAYS;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
univ.town.monst[i].active = 0;
|
||||
break;
|
||||
case eMonstTime::SOMETIMES_A: case eMonstTime::SOMETIMES_B: case eMonstTime::SOMETIMES_C:
|
||||
if((calc_day() % 3) + 3 != int(univ.town.monst[i].time_flag)) {
|
||||
if((univ.party.calc_day() % 3) + 3 != int(univ.town.monst[i].time_flag)) {
|
||||
univ.town.monst[i].active = 0;
|
||||
}
|
||||
else {
|
||||
@@ -312,14 +312,14 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
case eMonstTime::APPEAR_WHEN_EVENT:
|
||||
if(univ.party.key_times.find(univ.town.monst[j].time_code) == univ.party.key_times.end())
|
||||
univ.town.monst[i].active = 0; // Event hasn't happened yet
|
||||
else if(calc_day() < univ.party.key_times[univ.town.monst[i].time_code])
|
||||
else if(univ.party.calc_day() < univ.party.key_times[univ.town.monst[i].time_code])
|
||||
univ.town.monst[i].active = 0; // This would only be reached if the time was set back (or in a legacy save)
|
||||
break;
|
||||
|
||||
case eMonstTime::DISAPPEAR_WHEN_EVENT:
|
||||
if(univ.party.key_times.find(univ.town.monst[j].time_code) == univ.party.key_times.end())
|
||||
break; // Event hasn't happened yet
|
||||
if(calc_day() >= univ.party.key_times[univ.town.monst[i].time_code])
|
||||
if(univ.party.calc_day() >= univ.party.key_times[univ.town.monst[i].time_code])
|
||||
univ.town.monst[i].active = 0;
|
||||
break;
|
||||
case eMonstTime::APPEAR_AFTER_CHOP:
|
||||
|
||||
Reference in New Issue
Block a user