1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-06 00:33:01 +00:00

Consistently apply override (and not virtual) to overriding virtuals

Three functions were missing `override`, triggering `-Wsuggest-override` on Clang.
Many functions had redundant `virtual ... override`.
This commit is contained in:
Arthur O'Dwyer
2023-08-21 10:23:48 -07:00
parent a250a4d430
commit 28880f2985
9 changed files with 40 additions and 40 deletions

View File

@@ -133,7 +133,7 @@ template<class T> struct enum_setting : list_setting {
}
*value = (T) parseint(s);
}
virtual void check_change() override {
void check_change() override {
if(*value != last_value) {
last_value = *value;
add_to_changed(this);
@@ -173,15 +173,15 @@ template<class T> struct val_setting : public setting {
T *value, last_value, anim_value, dft;
bool affects(void *v) override { return v == value; }
virtual void check_change() override {
void check_change() override {
if(*value != last_value) {
last_value = *value;
add_to_changed(this);
}
}
virtual bool anim_unchanged() override { return *value == anim_value; }
virtual void anim_restore() override { *value = anim_value; if(reaction) reaction(); }
bool anim_unchanged() override { return *value == anim_value; }
void anim_restore() override { *value = anim_value; if(reaction) reaction(); }
virtual void load_from_raw(const string& s) { throw hr_exception("load_from_raw not defined"); }
@@ -221,7 +221,7 @@ struct float_setting : public val_setting<ld> {
supersaver *make_saver() override;
void show_edit_option(int key) override;
void load_from_raw(const string& s) override { *value = parseld(s); }
virtual cld get_cld() override { return *value; }
cld get_cld() override { return *value; }
void set_cld_raw(cld x) override { *value = real(x); }
};
@@ -249,12 +249,12 @@ struct int_setting : public val_setting<int> {
return this;
}
virtual cld get_cld() override { return *value; }
cld get_cld() override { return *value; }
void load_from_raw(const string& s) override { *value = parseint(s); }
void set_cld_raw(cld x) override { *value = (int)(real(x) + .5); }
virtual void check_change() override {
void check_change() override {
if(*value != last_value) {
last_value = *value;
add_to_changed(this);
@@ -313,7 +313,7 @@ struct bool_setting : public val_setting<bool> {
void load_from_raw(const string& s) override { *value = parseint(s); }
virtual cld get_cld() override { return *value; }
cld get_cld() override { return *value; }
};
struct custom_setting : public setting {
@@ -322,9 +322,9 @@ struct custom_setting : public setting {
function<cld()> custom_value;
function<bool(void*)> custom_affect;
void show_edit_option(int key) override { custom_viewer(key); }
supersaver *make_saver() { throw hr_exception("make_saver for custom_setting"); }
supersaver *make_saver() override { throw hr_exception("make_saver for custom_setting"); }
bool affects(void *v) override { return custom_affect(v); }
virtual void check_change() override {
void check_change() override {
if(custom_value() != last_value) {
last_value = custom_value();
add_to_changed(this);
@@ -410,40 +410,40 @@ template<> struct saver<int> : dsaver<int> {
explicit saver(int& val) : dsaver<int>(val) { }
string save() override { return its(val); }
void load(const string& s) override { val = atoi(s.c_str()); }
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(int*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<int>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(int*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<int>*)s)->val); }
};
template<> struct saver<char> : dsaver<char> {
explicit saver(char& val) : dsaver<char>(val) { }
string save() override { return its(val); }
void load(const string& s) override { val = atoi(s.c_str()); }
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(char*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<char>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(char*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<char>*)s)->val); }
};
template<> struct saver<bool> : dsaver<bool> {
explicit saver(bool& val) : dsaver<bool>(val) { }
string save() override { return val ? "yes" : "no"; }
void load(const string& s) override { val = isize(s) && s[0] == 'y'; }
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(bool*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<bool>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(bool*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<bool>*)s)->val); }
};
template<> struct saver<unsigned> : dsaver<unsigned> {
explicit saver(unsigned& val) : dsaver<unsigned>(val) { }
string save() override { return itsh(val); }
void load(const string& s) override { val = (unsigned) strtoll(s.c_str(), NULL, 16); }
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(unsigned*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<unsigned>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(unsigned*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<unsigned>*)s)->val); }
};
template<> struct saver<string> : dsaver<string> {
explicit saver(string& val) : dsaver<string>(val) { }
string save() override { return val; }
void load(const string& s) override { val = s; }
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(string*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<string>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(string*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<string>*)s)->val); }
};
template<> struct saver<matrix_eq> : supersaver {
@@ -468,8 +468,8 @@ template<> struct saver<matrix_eq> : supersaver {
ss.s = s;
for(int a=0; a<4; a++) for(int b=0; b<4; b++) scan(ss, val[a][b]);
}
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(matrix_eq*) value, lps.label + name); }
virtual void swap_with(supersaver *s) override { swap(val, ((saver<matrix_eq>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(matrix_eq*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<matrix_eq>*)s)->val); }
};
template<> struct saver<ld> : dsaver<ld> {
@@ -479,8 +479,8 @@ template<> struct saver<ld> : dsaver<ld> {
if(s == "0.0000000000e+000") ; // ignore!
else val = atof(s.c_str());
}
virtual void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(ld*) value, lps.label + name); }
virtual void swap_with(supersaver *s) { swap(val, ((saver<ld>*)s)->val); }
void clone(struct local_parameter_set& lps, void *value) override { addsaver(*(ld*) value, lps.label + name); }
void swap_with(supersaver *s) override { swap(val, ((saver<ld>*)s)->val); }
};
#endif
#endif