Fix crash when quitting the game

This commit is contained in:
2014-04-13 19:34:12 -04:00
parent 2986ca80a8
commit 0087731ddb
6 changed files with 21 additions and 15 deletions

View File

@@ -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];

View File

@@ -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);