Some dialogue saving stuff

- Saved talk strings weren't loaded correctly from legacy saves
- Talk strings from special encounters weren't recordable
This commit is contained in:
2015-02-06 23:12:28 -05:00
parent 2cf301eece
commit 6d26d430b3
3 changed files with 48 additions and 63 deletions

View File

@@ -75,7 +75,7 @@ std::string title_string;
mon_num_t store_monst_type; mon_num_t store_monst_type;
short store_m_num; short store_m_num;
rectangle dummy_rect = {0,0,0,0}; rectangle dummy_rect = {0,0,0,0};
short strnum1,strnum2,oldstrnum1,oldstrnum2; bool can_save_talk;
short store_talk_face_pic; short store_talk_face_pic;
int current_talk_node; int current_talk_node;
extern std::vector<word_rect_t> talk_words; extern std::vector<word_rect_t> talk_words;
@@ -170,8 +170,7 @@ void end_shop_mode() {
shop_sbar->hide(); shop_sbar->hide();
done_btn->hide(); done_btn->hide();
help_btn->hide(); help_btn->hide();
if(store_pre_shop_mode == 20) { if(store_pre_shop_mode == MODE_TALKING) {
strnum1 = strnum2 = oldstrnum1 = oldstrnum2 = 0;
place_talk_str("You conclude your business.", "", 0, dummy_rect); place_talk_str("You conclude your business.", "", 0, dummy_rect);
update_last_talk(TALK_BUSINESS); update_last_talk(TALK_BUSINESS);
} }
@@ -573,8 +572,7 @@ void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short st
// Bring up and place first strings. // Bring up and place first strings.
place_string1 = univ.town.cur_talk().people[personality % 10].look; place_string1 = univ.town.cur_talk().people[personality % 10].look;
strnum1 = personality % 10 + 10; can_save_talk = true;
strnum2 = 0;
place_talk_str(place_string1, "", 0, dummy_rect); place_talk_str(place_string1, "", 0, dummy_rect);
@@ -735,7 +733,7 @@ void handle_talk_event(location p) {
if(which_talk_entry == -1) goto SPECIAL_DUNNO; if(which_talk_entry == -1) goto SPECIAL_DUNNO;
break; break;
case TALK_RECORD: case TALK_RECORD:
if(strnum1 <= 0) { if(!can_save_talk) {
beep(); beep();
return; return;
} }
@@ -777,26 +775,22 @@ void handle_talk_event(location p) {
save_talk_str1 = univ.town.cur_talk().talk_nodes[which_talk_entry].str1; save_talk_str1 = univ.town.cur_talk().talk_nodes[which_talk_entry].str1;
save_talk_str2 = univ.town.cur_talk().talk_nodes[which_talk_entry].str2; save_talk_str2 = univ.town.cur_talk().talk_nodes[which_talk_entry].str2;
oldstrnum1 = strnum1; oldstrnum2 = strnum2; can_save_talk = true;
strnum1 = 40 + which_talk_entry * 2; strnum2 = 40 + which_talk_entry * 2 + 1;
switch(ttype) { switch(ttype) {
case eTalkNode::REGULAR: case eTalkNode::REGULAR:
break; break;
case eTalkNode::DEP_ON_SDF: case eTalkNode::DEP_ON_SDF:
if(PSD[a][b] > c) { if(PSD[a][b] > c) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
break; break;
case eTalkNode::SET_SDF: case eTalkNode::SET_SDF:
PSD[a][b] = 1; PSD[a][b] = 1;
break; break;
case eTalkNode::INN: case eTalkNode::INN:
if(univ.party.gold < a) { if(univ.party.gold < a) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
else { else {
@@ -808,36 +802,29 @@ void handle_talk_event(location p) {
univ.town.p_loc.y = d; univ.town.p_loc.y = d;
center = univ.town.p_loc; center = univ.town.p_loc;
} }
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
case eTalkNode::DEP_ON_TIME: case eTalkNode::DEP_ON_TIME:
if(day_reached((unsigned char) a,0)) { if(day_reached((unsigned char) a,0)) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
break; break;
case eTalkNode::DEP_ON_TIME_AND_EVENT: case eTalkNode::DEP_ON_TIME_AND_EVENT:
if(day_reached((unsigned char) a,(unsigned char) b)) { if(day_reached((unsigned char) a,(unsigned char) b)) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
break; break;
case eTalkNode::DEP_ON_TOWN: case eTalkNode::DEP_ON_TOWN:
if(univ.town.num != a) { if(univ.town.num != a) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
break; break;
case eTalkNode::TRAINING: case eTalkNode::TRAINING:
if((get_pc = char_select_pc(0,"Train who?")) < 6) { if((get_pc = char_select_pc(0,"Train who?")) < 6) {
strnum1 = -1; can_save_talk = false;
spend_xp(get_pc,1, NULL); spend_xp(get_pc,1, NULL);
} }
save_talk_str1 = "You conclude your training."; save_talk_str1 = "You conclude your training.";
@@ -849,13 +836,11 @@ void handle_talk_event(location p) {
return; return;
} }
start_shop_mode(b,a,save_talk_str1); start_shop_mode(b,a,save_talk_str1);
strnum1 = -1; can_save_talk = false;
return; return;
case eTalkNode::JOB_BANK: case eTalkNode::JOB_BANK:
if(a < univ.party.job_banks.size() && univ.party.job_banks[a].anger >= 50) { if(a < univ.party.job_banks.size() && univ.party.job_banks[a].anger >= 50) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
} else { } else {
@@ -863,25 +848,25 @@ void handle_talk_event(location p) {
return; return;
} }
case eTalkNode::SELL_WEAPONS: case eTalkNode::SELL_WEAPONS:
strnum1 = -1; can_save_talk = false;
stat_screen_mode = MODE_SELL_WEAP; stat_screen_mode = MODE_SELL_WEAP;
put_item_screen(stat_window,1); put_item_screen(stat_window,1);
give_help(42,43); give_help(42,43);
break; break;
case eTalkNode::SELL_ARMOR: case eTalkNode::SELL_ARMOR:
strnum1 = -1; can_save_talk = false;
stat_screen_mode = MODE_SELL_ARMOR; stat_screen_mode = MODE_SELL_ARMOR;
put_item_screen(stat_window,1); put_item_screen(stat_window,1);
give_help(42,43); give_help(42,43);
break; break;
case eTalkNode::SELL_ITEMS: case eTalkNode::SELL_ITEMS:
strnum1 = -1; can_save_talk = false;
stat_screen_mode = MODE_SELL_ANY; stat_screen_mode = MODE_SELL_ANY;
put_item_screen(stat_window,1); put_item_screen(stat_window,1);
give_help(42,43); give_help(42,43);
break; break;
case eTalkNode::IDENTIFY: case eTalkNode::ENCHANT: case eTalkNode::IDENTIFY: case eTalkNode::ENCHANT:
strnum1 = -1; can_save_talk = false;
stat_screen_mode = (ttype == eTalkNode::IDENTIFY) ? MODE_IDENTIFY : MODE_ENCHANT; stat_screen_mode = (ttype == eTalkNode::IDENTIFY) ? MODE_IDENTIFY : MODE_ENCHANT;
shop_identify_cost = a; shop_identify_cost = a;
put_item_screen(stat_window,1); put_item_screen(stat_window,1);
@@ -889,7 +874,6 @@ void handle_talk_event(location p) {
break; break;
case eTalkNode::BUY_INFO: case eTalkNode::BUY_INFO:
if(univ.party.gold < a) { if(univ.party.gold < a) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
else { else {
@@ -898,15 +882,13 @@ void handle_talk_event(location p) {
} }
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
break; break;
case eTalkNode::BUY_SDF: case eTalkNode::BUY_SDF:
if((univ.party.sd_legit(b,c)) && (PSD[b][c] == d)) { if((univ.party.sd_legit(b,c)) && (PSD[b][c] == d)) {
save_talk_str1 = "You've already learned that."; save_talk_str1 = "You've already learned that.";
strnum1 = -1; can_save_talk = false;
} }
else if(univ.party.gold < a) { else if(univ.party.gold < a) {
strnum1 = strnum2;
save_talk_str1 + save_talk_str2; save_talk_str1 + save_talk_str2;
} }
else { else {
@@ -916,13 +898,10 @@ void handle_talk_event(location p) {
PSD[b][c] = d; PSD[b][c] = d;
else giveError("Invalid Stuff Done flag called in conversation."); else giveError("Invalid Stuff Done flag called in conversation.");
} }
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
case eTalkNode::BUY_SHIP: case eTalkNode::BUY_SHIP:
if(univ.party.gold < a) { if(univ.party.gold < a) {
strnum1 = strnum2;
strnum2 = 0;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
@@ -934,7 +913,6 @@ void handle_talk_event(location p) {
put_pc_screen(); put_pc_screen();
univ.party.boats[i].property = false; univ.party.boats[i].property = false;
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
i = 1000; i = 1000;
} }
if(i >= 1000) if(i >= 1000)
@@ -942,13 +920,10 @@ void handle_talk_event(location p) {
} }
save_talk_str1 = "There are no boats left."; save_talk_str1 = "There are no boats left.";
save_talk_str2 = ""; save_talk_str2 = "";
strnum1 = -1; can_save_talk = false;
strnum2 = -1;
break; break;
case eTalkNode::BUY_HORSE: case eTalkNode::BUY_HORSE:
if(univ.party.gold < a) { if(univ.party.gold < a) {
strnum1 = strnum2;
strnum2 = 0;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
@@ -960,7 +935,6 @@ void handle_talk_event(location p) {
put_pc_screen(); put_pc_screen();
univ.party.horses[i].property = false; univ.party.horses[i].property = false;
save_talk_str2 = ""; save_talk_str2 = "";
strnum2 = 0;
i = 1000; i = 1000;
} }
if(i >= 1000) if(i >= 1000)
@@ -968,24 +942,21 @@ void handle_talk_event(location p) {
} }
save_talk_str1 = "There are no horses left."; save_talk_str1 = "There are no horses left.";
save_talk_str2 = ""; save_talk_str2 = "";
strnum1 = -1; can_save_talk = false;
strnum2 = -1;
break; break;
case eTalkNode::BUY_SPEC_ITEM: case eTalkNode::BUY_SPEC_ITEM:
if(univ.party.spec_items[a]) { if(univ.party.spec_items[a]) {
save_talk_str1 = "You already have it."; save_talk_str1 = "You already have it.";
strnum1 = -1; can_save_talk = false;
} }
else if(univ.party.gold < b) { else if(univ.party.gold < b) {
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
strnum1 = strnum2;
} }
else { else {
univ.party.gold -= b; univ.party.gold -= b;
put_pc_screen(); put_pc_screen();
univ.party.spec_items[a] = true; univ.party.spec_items[a] = true;
} }
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
case eTalkNode::RECEIVE_QUEST: case eTalkNode::RECEIVE_QUEST:
@@ -1002,14 +973,12 @@ void handle_talk_event(location p) {
case eQuestStatus::STARTED: case eQuestStatus::STARTED:
break; break;
case eQuestStatus::COMPLETED: case eQuestStatus::COMPLETED:
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
break; break;
case eQuestStatus::FAILED: case eQuestStatus::FAILED:
// TODO: How to handle this? // TODO: How to handle this?
return; return;
} }
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
case eTalkNode::BUY_TOWN_LOC: case eTalkNode::BUY_TOWN_LOC:
@@ -1017,7 +986,6 @@ void handle_talk_event(location p) {
// TODO: Uh, is something supposed to happen here? // TODO: Uh, is something supposed to happen here?
} }
else if(univ.party.gold < a) { else if(univ.party.gold < a) {
strnum1 = strnum2;
save_talk_str1 = save_talk_str2; save_talk_str1 = save_talk_str2;
} }
else { else {
@@ -1025,7 +993,6 @@ void handle_talk_event(location p) {
put_pc_screen(); put_pc_screen();
univ.party.can_find_town[b] = 1; univ.party.can_find_town[b] = 1;
} }
strnum2 = 0;
save_talk_str2 = ""; save_talk_str2 = "";
break; break;
case eTalkNode::END_FORCE: case eTalkNode::END_FORCE:
@@ -1057,14 +1024,10 @@ void handle_talk_event(location p) {
run_special(eSpecCtx::TALK,2,a,univ.town.p_loc,&s1,&s2,&s3); run_special(eSpecCtx::TALK,2,a,univ.town.p_loc,&s1,&s2,&s3);
// check s1 & s2 to see if we got diff str, and, if so, munch old strs // check s1 & s2 to see if we got diff str, and, if so, munch old strs
if((s1 >= 0) || (s2 >= 0)) { if((s1 >= 0) || (s2 >= 0)) {
strnum1 = -1; save_talk_str1 = s1 >= 0 ? univ.town->spec_strs[s1] : "";
strnum2 = -1; save_talk_str2 = s2 >= 0 ? univ.town->spec_strs[s2] : "";
save_talk_str1 = "";
save_talk_str2 = "";
} }
get_strs(save_talk_str1,save_talk_str2,2,s1,s2); get_strs(save_talk_str1,save_talk_str2,2,s1,s2);
if(s1 >= 0) strnum1 = 2000 + s1;
if(s2 >= 0) strnum2 = 2000 + s2;
put_pc_screen(); put_pc_screen();
put_item_screen(stat_window,0); put_item_screen(stat_window,0);
break; break;
@@ -1072,14 +1035,10 @@ void handle_talk_event(location p) {
run_special(eSpecCtx::TALK,0,a,univ.town.p_loc,&s1,&s2,&s3); run_special(eSpecCtx::TALK,0,a,univ.town.p_loc,&s1,&s2,&s3);
// check s1 & s2 to see if we got diff str, and, if so, munch old strs // check s1 & s2 to see if we got diff str, and, if so, munch old strs
if((s1 >= 0) || (s2 >= 0)) { if((s1 >= 0) || (s2 >= 0)) {
strnum1 = -1; save_talk_str1 = s1 >= 0 ? univ.scenario.spec_strs[s1] : "";
strnum2 = -1; save_talk_str2 = s2 >= 0 ? univ.scenario.spec_strs[s2] : "";
save_talk_str1 = "";
save_talk_str2 = "";
} }
get_strs(save_talk_str1,save_talk_str2,0,s1,s2); get_strs(save_talk_str1,save_talk_str2,0,s1,s2);
if(s1 >= 0) strnum1 = 3000 + s1;
if(s2 >= 0) strnum2 = 3000 + s2;
put_pc_screen(); put_pc_screen();
put_item_screen(stat_window,0); put_item_screen(stat_window,0);
break; break;

View File

@@ -163,8 +163,34 @@ void cParty::append(legacy::setup_save_type& old){
void cParty::cConvers::append(legacy::talk_save_type old, const cScenario& scenario){ void cParty::cConvers::append(legacy::talk_save_type old, const cScenario& scenario){
who_said = scenario.towns[old.personality / 10]->talking.people[old.personality % 10].title; who_said = scenario.towns[old.personality / 10]->talking.people[old.personality % 10].title;
in_town = scenario.towns[old.town_num]->town_name; in_town = scenario.towns[old.town_num]->town_name;
the_str1 = scenario.towns[old.personality / 10]->spec_strs[old.str1]; int strnums[2] = {old.str1, old.str2};
the_str2 = scenario.towns[old.personality / 10]->spec_strs[old.str2]; std::string* strs[2] = {&the_str1, &the_str2};
for(int i = 0; i < 2; i++) {
// Okay, so there's a ton of different places where the actual strings might be found.
// 0 means no string
// 10 + n is the "look" string for the nth personality in the town (ie, n is personality % 10)
// 20 + n is the "name" string for the nth personality in the town
// 30 + n is the "job" string for the nth personality in the town
// 40 + 2n is the first string from the nth talk node in the town
// 40 + 2n + 1 is the second string from the nth talk not in the town
// 2000 + n is the nth town special text
// 3000 + n is the nth scenario special text
if(strnums[i] == 0) continue;
if(strnums[i] >= 3000)
strs[i]->assign(scenario.spec_strs[strnums[i] - 3000]);
else if(strnums[i] >= 2000)
strs[i]->assign(scenario.towns[old.personality / 10]->spec_strs[strnums[i] - 2000]);
else if(strnums[i] >= 40 && strnums[i] % 2 == 0)
strs[i]->assign(scenario.towns[old.personality / 10]->talking.talk_nodes[(strnums[i] - 40) / 2].str1);
else if(strnums[i] >= 40 && strnums[i] % 2 == 1)
strs[i]->assign(scenario.towns[old.personality / 10]->talking.talk_nodes[(strnums[i] - 40) / 2].str2);
else if(strnums[i] >= 30)
strs[i]->assign(scenario.towns[old.personality / 10]->talking.people[old.personality % 10].job);
else if(strnums[i] >= 20)
strs[i]->assign(scenario.towns[old.personality / 10]->talking.people[old.personality % 10].name);
else if(strnums[i] >= 10)
strs[i]->assign(scenario.towns[old.personality / 10]->talking.people[old.personality % 10].look);
}
} }
void cParty::cEncNote::append(int16_t(& old)[2], const cScenario& scenario) { void cParty::cEncNote::append(int16_t(& old)[2], const cScenario& scenario) {

View File

@@ -105,7 +105,7 @@ public:
size_t left_in; size_t left_in;
eDirection direction; eDirection direction;
short at_which_save_slot; short at_which_save_slot;
char alchemy[20]; bool alchemy[20];
bool can_find_town[200]; bool can_find_town[200];
short key_times[100]; short key_times[100];
std::vector<cTimer> party_event_timers; std::vector<cTimer> party_event_timers;