Better range check for Set Monster Attitude
This commit is contained in:
@@ -4147,9 +4147,10 @@ void townmode_spec(const runtime_state& ctx) {
|
||||
else increase_light(-spec.ex2a);
|
||||
}
|
||||
break;
|
||||
case eSpecType::TOWN_SET_ATTITUDE:
|
||||
if((spec.ex1a < 0) || (spec.ex1a > 59)){
|
||||
showError("Tried to change the attitude of a nonexistent monster (should be 0...59).");
|
||||
case eSpecType::TOWN_SET_ATTITUDE:{
|
||||
int num_monst = univ.town.monst.size();
|
||||
if((spec.ex1a < 0) || (spec.ex1a >= num_monst)){
|
||||
showError("Tried to change the attitude of nonexistent monster " + std::to_string(spec.ex1a) + " of 0..." + std::to_string(num_monst));
|
||||
break;
|
||||
}
|
||||
if(spec.ex1b < 0 || spec.ex1b > 3){
|
||||
@@ -4157,7 +4158,7 @@ void townmode_spec(const runtime_state& ctx) {
|
||||
break;
|
||||
}
|
||||
univ.town.monst[spec.ex1a].attitude = eAttitude(spec.ex1b);
|
||||
break;
|
||||
}break;
|
||||
case eSpecType::TOWN_RUN_MISSILE:
|
||||
if(ctx.which_mode != eSpecCtx::TALK) {
|
||||
int i;
|
||||
|
@@ -31,6 +31,15 @@ cCreature& cPopulation::operator[](size_t n){
|
||||
return dudes[n];
|
||||
}
|
||||
|
||||
const cCreature& cPopulation::at(size_t n) const {
|
||||
return dudes.at(n);
|
||||
}
|
||||
|
||||
cCreature& cPopulation::at(size_t n){
|
||||
return dudes.at(n);
|
||||
}
|
||||
|
||||
|
||||
void cPopulation::init(size_t n) {
|
||||
if(n >= dudes.size()) dudes.resize(n + 1);
|
||||
dudes[n].active = eCreatureStatus::IDLE;
|
||||
|
@@ -32,6 +32,8 @@ public:
|
||||
void clear() {dudes.clear();}
|
||||
cCreature& operator[](size_t n);
|
||||
const cCreature& operator[](size_t n) const;
|
||||
cCreature& at(size_t n);
|
||||
const cCreature& at(size_t n) const;
|
||||
cPopulation() : which_town(200), hostile(false) {}
|
||||
std::deque<cCreature>::iterator begin() {return dudes.begin();}
|
||||
std::deque<cCreature>::iterator end() {return dudes.end();}
|
||||
|
Reference in New Issue
Block a user