cPlayer give_help use bool flag instead of function pointer

This commit is contained in:
2025-02-15 08:13:47 -06:00
committed by Celtic Minstrel
parent 576a40b3e1
commit 18a425be0d
3 changed files with 13 additions and 10 deletions

View File

@@ -962,7 +962,7 @@ void init_boe(int argc, char* argv[]) {
plop_fancy_startup(fps_limiter); plop_fancy_startup(fps_limiter);
cUniverse::print_result = iLiving::print_result = add_string_to_buf; cUniverse::print_result = iLiving::print_result = add_string_to_buf;
cPlayer::give_help = give_help; cPlayer::give_help_enabled = true;
init_fileio(); init_fileio();
init_debug_actions(); init_debug_actions();
init_spell_menus(); init_spell_menus();

View File

@@ -21,11 +21,14 @@
#include "fileio/fileio.hpp" #include "fileio/fileio.hpp"
#include "fileio/tagfile.hpp" #include "fileio/tagfile.hpp"
#include "sounds.hpp" #include "sounds.hpp"
#include "dialogxml/dialogs/strdlog.hpp"
extern short skill_bonus[21]; extern short skill_bonus[21];
// A nice convenient bitset with just the low 30 bits set, for initializing spells // A nice convenient bitset with just the low 30 bits set, for initializing spells
const uint32_t cPlayer::basic_spells = std::numeric_limits<uint32_t>::max() >> 2; const uint32_t cPlayer::basic_spells = std::numeric_limits<uint32_t>::max() >> 2;
bool cPlayer::give_help_enabled = false;
void cPlayer::import_legacy(legacy::pc_record_type old){ void cPlayer::import_legacy(legacy::pc_record_type old){
main_status = (eMainStatus) old.main_status; main_status = (eMainStatus) old.main_status;
name = old.name; name = old.name;
@@ -152,7 +155,7 @@ void cPlayer::curse(int how_much) {
else if(how_much > 0) else if(how_much > 0)
print_result(" " + name + " cursed."); print_result(" " + name + " cursed.");
} }
if(give_help) { if(give_help_enabled) {
if(how_much > 0) if(how_much > 0)
give_help(59,0); give_help(59,0);
else if(how_much > 0) else if(how_much > 0)
@@ -180,7 +183,7 @@ void cPlayer::dumbfound(int how_much) {
if(print_result) if(print_result)
print_result(" " + name + " dumbfounded."); print_result(" " + name + " dumbfounded.");
one_sound(67); one_sound(67);
if(give_help) if(give_help_enabled)
give_help(28,0); give_help(28,0);
} }
@@ -203,7 +206,7 @@ void cPlayer::disease(int how_much) {
if(print_result) if(print_result)
print_result(" " + name + " diseased."); print_result(" " + name + " diseased.");
one_sound(66); one_sound(66);
if(give_help) if(give_help_enabled)
give_help(29,0); give_help(29,0);
} }
@@ -250,7 +253,7 @@ void cPlayer::sleep(eStatus what_type,int how_much,int adjust) {
else play_sound(90); else play_sound(90);
if(what_type != eStatus::FORCECAGE) if(what_type != eStatus::FORCECAGE)
ap = 0; ap = 0;
if(give_help) { if(give_help_enabled) {
if(what_type == eStatus::ASLEEP) if(what_type == eStatus::ASLEEP)
give_help(30,0); give_help(30,0);
else if(what_type == eStatus::PARALYZED) else if(what_type == eStatus::PARALYZED)
@@ -272,7 +275,7 @@ void cPlayer::slow(int how_much) {
else if(how_much > 0) else if(how_much > 0)
print_result(" " + name + " slowed."); print_result(" " + name + " slowed.");
} }
if(give_help) if(give_help_enabled)
give_help(35,0); give_help(35,0);
} }
@@ -1345,6 +1348,4 @@ void cPlayer::readFrom(const cTagFile& file) {
items[i].readFrom(page); items[i].readFrom(page);
} }
} }
} }
void(* cPlayer::give_help)(short,short) = nullptr;

View File

@@ -81,7 +81,9 @@ class cPlayer : public iLiving {
public: public:
// A nice convenient bitset with just the low 30 bits set, for initializing spells // A nice convenient bitset with just the low 30 bits set, for initializing spells
static const uint32_t basic_spells; static const uint32_t basic_spells;
static void(* give_help)(short,short); // This class is shared between the game and the editors, but it should only show help dialogs
// when being used in the game, which sets this flag to true on startup.
static bool give_help_enabled;
eMainStatus main_status; eMainStatus main_status;
std::string name; std::string name;
// HACK: This is only really marked mutable so that I can use operator[] from const methods // HACK: This is only really marked mutable so that I can use operator[] from const methods