use at() to get exceptions
I encountered a new error from an out-of-bounds access on a terrain array, which I wasn't able to record because it caused a segfault, not throwing an exception. If the error happens again, I want to catch and record it.
This commit is contained in:
@@ -40,10 +40,10 @@ public:
|
||||
}
|
||||
public:
|
||||
Type& operator[](size_t x) {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
const Type& operator[](size_t x) const {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
row_ref operator=(row_ref&& other) {
|
||||
row_ref& me = *this;
|
||||
@@ -94,10 +94,10 @@ public:
|
||||
}
|
||||
public:
|
||||
Type& operator[](size_t y) {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
const Type& operator[](size_t y) const {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
col_ref operator=(col_ref&& other) {
|
||||
col_ref& me = *this;
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
const_row_ref(const vector2d<Type, Alloc>& ref, size_t row) : ref(ref), y(row) {}
|
||||
public:
|
||||
const Type& operator[](size_t x) const {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
};
|
||||
class const_col_ref {
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
const_col_ref(const vector2d<Type, Alloc>& ref, size_t col) : ref(ref), x(col) {}
|
||||
public:
|
||||
const Type& operator[](size_t y) const {
|
||||
return ref.data[ref.w * y + x];
|
||||
return ref.data.at(ref.w * y + x);
|
||||
}
|
||||
};
|
||||
col_ref operator[](size_t x) {
|
||||
|
@@ -821,19 +821,19 @@ bool cCurTown::is_on_map(short x, short y) const {
|
||||
}
|
||||
|
||||
auto cCurOut::operator [] (size_t i) -> arr_96& {
|
||||
return out[i];
|
||||
return out.at(i);
|
||||
}
|
||||
|
||||
auto cCurOut::operator [] (size_t i) const -> const arr_96& {
|
||||
return out[i];
|
||||
return out.at(i);
|
||||
}
|
||||
|
||||
ter_num_t& cCurOut::operator [] (location loc) {
|
||||
return out[loc.x][loc.y];
|
||||
return out.at(loc.x).at(loc.y);
|
||||
}
|
||||
|
||||
const ter_num_t& cCurOut::operator [] (location loc) const {
|
||||
return out[loc.x][loc.y];
|
||||
return out.at(loc.x).at(loc.y);
|
||||
}
|
||||
|
||||
void cCurOut::writeTo(std::ostream& file) const {
|
||||
|
Reference in New Issue
Block a user