Really fix the talking crash this time, I'm pretty sure
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace legacy {
|
||||
};
|
||||
|
||||
class cCurTown {
|
||||
cSpeech* curTalk = NULL;
|
||||
bool talkNeedsDeleting = false;
|
||||
short cur_talk_loaded = -1;
|
||||
public:
|
||||
cTown* record;
|
||||
// formerly current_town_type
|
||||
@@ -40,8 +43,6 @@ public:
|
||||
cPopulation monst;
|
||||
bool in_boat; // is this really needed?
|
||||
location p_loc;
|
||||
cSpeech* cur_talk; // my addition
|
||||
short cur_talk_loaded; // my addition
|
||||
|
||||
cItemRec items[115]; // formerly town_item_list type
|
||||
|
||||
@@ -64,6 +65,8 @@ public:
|
||||
bool loaded() const;
|
||||
void unload();
|
||||
short countMonsters();
|
||||
cSpeech& cur_talk(); // Get the currently loaded speech
|
||||
bool prep_talk(short which); // Prepare for loading specified speech, returning true if already loaded
|
||||
|
||||
bool is_explored(char x, char y) const;
|
||||
bool is_force_wall(char x, char y) const;
|
||||
@@ -121,6 +124,8 @@ public:
|
||||
// bool set_trim(char x, char y, char t, bool b);
|
||||
void writeTo(std::ostream& file);
|
||||
void readFrom(std::istream& file);
|
||||
|
||||
~cCurTown();
|
||||
};
|
||||
|
||||
class cCurOut {
|
||||
|
||||
Reference in New Issue
Block a user