diff --git a/src/game/boe.specials.cpp b/src/game/boe.specials.cpp index fe1d0a95..9b9b648f 100644 --- a/src/game/boe.specials.cpp +++ b/src/game/boe.specials.cpp @@ -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; diff --git a/src/universe/population.cpp b/src/universe/population.cpp index faef9f66..b48cfc43 100644 --- a/src/universe/population.cpp +++ b/src/universe/population.cpp @@ -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; diff --git a/src/universe/population.hpp b/src/universe/population.hpp index 36456d72..bd43ca82 100644 --- a/src/universe/population.hpp +++ b/src/universe/population.hpp @@ -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::iterator begin() {return dudes.begin();} std::deque::iterator end() {return dudes.end();}