Really fix the talking crash this time, I'm pretty sure

This commit is contained in:
2014-04-18 01:19:13 -04:00
parent 14fe8fcd7b
commit dca3c3c18f
10 changed files with 67 additions and 47 deletions

View File

@@ -46,7 +46,8 @@ void cCurTown::append(legacy::current_town_type& old,short which_size){
in_boat = old.in_boat;
p_loc.x = old.p_loc.x;
p_loc.y = old.p_loc.y;
cur_talk = &record->talking;
curTalk = &record->talking;
talkNeedsDeleting = false;
cur_talk_loaded = num;
}
@@ -113,6 +114,32 @@ void cCurTown::unload(){
record = NULL;
}
cSpeech& cCurTown::cur_talk() {
// Make sure we actually have a valid speech stored
if(curTalk == NULL) prep_talk(num);
return *curTalk;
}
bool cCurTown::prep_talk(short which) {
if(which == cur_talk_loaded) return true;
if(talkNeedsDeleting && curTalk != NULL) delete curTalk;
cur_talk_loaded = which;
if(which == num) {
curTalk = &record->talking;
talkNeedsDeleting = false;
return true;
} else {
curTalk = new cSpeech;
talkNeedsDeleting = true;
return false;
}
}
cCurTown::~cCurTown() {
if(talkNeedsDeleting && curTalk != NULL) delete curTalk;
}
bool cCurTown::is_explored(char x, char y) const{
if(x > record->max_dim() || y > record->max_dim()) return false;
return fields[x][y] & 1L;