Fix crash when quitting the game
This commit is contained in:
@@ -526,9 +526,7 @@ void start_talk_mode(short m_num,short personality,m_num_t monst_type,short stor
|
||||
|
||||
// first make sure relevant talk strs are loaded in
|
||||
if (personality / 10 != univ.town.cur_talk_loaded){
|
||||
if(personality / 10 == univ.town.num) univ.town.cur_talk = &univ.town->talking;
|
||||
else load_town(personality / 10,*univ.town.cur_talk);
|
||||
univ.town.cur_talk_loaded = personality / 10;
|
||||
load_town(personality / 10,univ.town.cur_talk);
|
||||
}
|
||||
|
||||
// load all possible responses
|
||||
|
@@ -1050,9 +1050,7 @@ void put_talk(cDialog& me)
|
||||
|
||||
if ((personality = univ.party.talk_save[store_page_on].personality) >= 0) {
|
||||
if (personality / 10 != univ.town.cur_talk_loaded){
|
||||
if(personality / 10 == univ.town.num) univ.town.cur_talk = &univ.town->talking;
|
||||
else load_town(personality / 10,*univ.town.cur_talk);
|
||||
univ.town.cur_talk_loaded = personality / 10;
|
||||
load_town(personality / 10,univ.town.cur_talk);
|
||||
}
|
||||
|
||||
// TODO: Use cached strings instead of loading them
|
||||
|
@@ -613,9 +613,11 @@ void Mouse_Pressed()
|
||||
|
||||
void close_program()
|
||||
{
|
||||
// TODO: Ultimately we would like to have cleanup happen automatically, negating the need for this function
|
||||
//end_music();
|
||||
if(univ.town.loaded()) univ.town.unload();
|
||||
if(univ.town.cur_talk != NULL) delete univ.town.cur_talk;
|
||||
if(univ.town.cur_talk_loaded != univ.town.num)
|
||||
delete univ.town.cur_talk;
|
||||
clean_up_graphtool();
|
||||
}
|
||||
|
||||
|
@@ -178,8 +178,7 @@ void start_town_mode(short which_town, short entry_dir)
|
||||
load_town(town_number,univ.town.record);
|
||||
|
||||
univ.town.num = town_number;
|
||||
univ.town.cur_talk = &univ.town->talking;
|
||||
univ.town.cur_talk_loaded = univ.town.num;
|
||||
load_town(town_number,univ.town.cur_talk);
|
||||
init_town();
|
||||
|
||||
// if (play_town_sound == true) {
|
||||
|
@@ -334,7 +334,16 @@ bool load_town(short which_town, cTown*& the_town){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool load_town(short which_town, cSpeech& the_talk){
|
||||
bool load_town(short which_town, cSpeech*& the_talk){
|
||||
if(which_town == univ.town.cur_talk_loaded) return true;
|
||||
if(univ.town.num != univ.town.cur_talk_loaded) delete the_talk;
|
||||
univ.town.cur_talk_loaded = which_town;
|
||||
if(which_town == univ.town.num) {
|
||||
the_talk = &univ.town->talking;
|
||||
return true;
|
||||
}
|
||||
the_talk = new cSpeech;
|
||||
|
||||
short i,n;
|
||||
long len,len_to_jump = 0;
|
||||
legacy::town_record_type store_town;
|
||||
@@ -399,12 +408,12 @@ bool load_town(short which_town, cSpeech& the_talk){
|
||||
return false;
|
||||
}
|
||||
port_talk_nodes(&store_talk);
|
||||
the_talk = store_talk;
|
||||
*the_talk = store_talk;
|
||||
|
||||
for (i = 0; i < 170; i++) {
|
||||
len = (long) (the_talk.strlens[i]);
|
||||
n = fread(&(the_talk.talk_strs[i]), len, 1, file_id);
|
||||
the_talk.talk_strs[i][len] = 0;
|
||||
len = (long) (the_talk->strlens[i]);
|
||||
n = fread(&(the_talk->talk_strs[i]), len, 1, file_id);
|
||||
the_talk->talk_strs[i][len] = 0;
|
||||
}
|
||||
|
||||
// town_type = scenario.town_size[which_town];
|
||||
|
@@ -16,7 +16,7 @@ namespace fs = boost::filesystem; // TODO: Centralize this alias!
|
||||
|
||||
bool load_scenario(fs::path file_to_load);
|
||||
bool load_town(short which_town, cTown*& the_town);
|
||||
bool load_town(short which_town, cSpeech& the_talk);
|
||||
bool load_town(short which_town, cSpeech*& the_talk);
|
||||
bool load_town_str(short which_town, short which_str, char* str);
|
||||
bool load_town_str(short which_town, cTown*& the_town);
|
||||
bool load_outdoors(location which_out,cOutdoors& the_out);
|
||||
|
Reference in New Issue
Block a user