Browse Source

Map from _talker_id to towner pointer when using gossip option (#6136)

pull/6137/head
Andrew James 3 years ago committed by GitHub
parent
commit
1b7608ea3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Source/stores.cpp
  2. 9
      Source/towners.cpp
  3. 6
      Source/towners.h

4
Source/stores.cpp

@ -2026,7 +2026,9 @@ void TalkEnter()
}
if (stextsel == sn - 2) {
InitQTextMsg(Towners[talker].gossip);
Towner *target = GetTowner(talker);
assert(target != nullptr);
InitQTextMsg(target->gossip);
return;
}

9
Source/towners.cpp

@ -841,6 +841,15 @@ bool IsTownerPresent(_talker_id npc)
}
}
Towner* GetTowner(_talker_id type)
{
for (Towner& towner : Towners) {
if (towner._ttype == type)
return &towner;
}
return nullptr;
}
void InitTowners()
{
assert(!CowSprites);

6
Source/towners.h

@ -68,6 +68,12 @@ struct Towner {
};
extern Towner Towners[NUM_TOWNERS];
/**
* @brief Maps from a _talker_id value to a pointer to the Towner object, if they have been initialised
* @param type enum constant identifying the towner
* @return Pointer to the Towner or nullptr if they are not available
*/
Towner *GetTowner(_talker_id type);
void InitTowners();
void FreeTownerGFX();

Loading…
Cancel
Save