Jart DM assistance

- anonymous namespace for filescope variables, funcs
- Step away from std::optional, use anonymous initialiser instead
This commit is contained in:
toaster 2023-12-03 13:01:33 +00:00
parent ffb34204f5
commit 40566274d9

View file

@ -56,7 +56,8 @@ menu_t MAIN_GonerDef = {
M_GonerInputs, M_GonerInputs,
}; };
// --- namespace
{
typedef enum typedef enum
{ {
@ -68,7 +69,7 @@ typedef enum
class GonerSpeaker class GonerSpeaker
{ {
public: public:
float offset; float offset = 0;
GonerSpeaker(std::string skinName, float offset) GonerSpeaker(std::string skinName, float offset)
{ {
@ -80,6 +81,8 @@ public:
this->offset = offset; this->offset = offset;
}; };
GonerSpeaker() {};
sfxenum_t TalkSound(void) sfxenum_t TalkSound(void)
{ {
if (!ValidID()) if (!ValidID())
@ -105,7 +108,7 @@ private:
}; };
}; };
std::array<std::optional<GonerSpeaker>, MAXGONERSPEAKERS> goner_speakers = {}; std::array<GonerSpeaker, MAXGONERSPEAKERS> goner_speakers = {};
srb2::Dialogue::Typewriter goner_typewriter; srb2::Dialogue::Typewriter goner_typewriter;
@ -136,11 +139,7 @@ public:
if (speaker >= MAXGONERSPEAKERS) if (speaker >= MAXGONERSPEAKERS)
return false; return false;
goner_typewriter.voiceSfx = sfx_ktalk; goner_typewriter.voiceSfx = goner_speakers[speaker].TalkSound();
if (goner_speakers[speaker])
{
goner_typewriter.voiceSfx = (*goner_speakers[speaker]).TalkSound();
}
goner_typewriter.NewText(dialogue); goner_typewriter.NewText(dialogue);
@ -155,7 +154,7 @@ public:
std::forward_list<GonerChatLine> LinesToDigest; std::forward_list<GonerChatLine> LinesToDigest;
std::forward_list<GonerChatLine> LinesOutput; std::forward_list<GonerChatLine> LinesOutput;
// --- }; // namespace
void M_GonerTick(void) void M_GonerTick(void)
{ {
@ -262,10 +261,7 @@ static void M_GonerDrawer(void)
//if (newy > BASEVIDHEIGHT) continue; -- not needed yet //if (newy > BASEVIDHEIGHT) continue; -- not needed yet
if (!goner_speakers[element.speaker]) auto speaker = goner_speakers[element.speaker];
continue;
auto speaker = *goner_speakers[element.speaker];
srb2::Draw line = drawer srb2::Draw line = drawer
.xy(speaker.offset, newy) .xy(speaker.offset, newy)