Skip to content

Commit

Permalink
Implement more GameClient stuff (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwil authored Feb 4, 2024
1 parent 9cec511 commit 7e77fc8
Show file tree
Hide file tree
Showing 29 changed files with 1,213 additions and 48 deletions.
128 changes: 128 additions & 0 deletions src/game/client/eva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,47 @@
Eva *g_theEva;
#endif

// clang-format off
const FieldParse EvaSideSounds::s_evaSideSounds[] = {
{"Side", &INI::Parse_AsciiString, nullptr, offsetof(EvaSideSounds, m_side)},
{"Sounds", &INI::Parse_Sounds_List, nullptr, offsetof(EvaSideSounds, m_sounds)},
{nullptr, nullptr, nullptr, 0}
};
// clang-format on

void Parse_Side_Sounds_List(INI *ini, void *formal, void *store, const void *user_data)
{
EvaSideSounds sounds;
ini->Init_From_INI(&sounds, EvaSideSounds::Get_Field_Parse());
static_cast<std::vector<EvaSideSounds> *>(store)->push_back(sounds);
}

// clang-format off
const FieldParse EvaCheckInfo::s_evaEventInfo[] = {
{"Priority", &INI::Parse_Unsigned_Int, nullptr, offsetof(EvaCheckInfo, m_priority)},
{"TimeBetweenChecksMS", &INI::Parse_Duration_Unsigned_Int, nullptr, offsetof(EvaCheckInfo, m_timeBetweenChecksMS)},
{"ExpirationTimeMS", &INI::Parse_Duration_Unsigned_Int, nullptr, offsetof(EvaCheckInfo, m_expirationTimeMS)},
{"SideSounds", &Parse_Side_Sounds_List, nullptr, offsetof(EvaCheckInfo, m_sideSounds)},
{nullptr, nullptr, nullptr, 0}
};
// clang-format on

EvaCheckInfo *Eva::New_Eva_Check_Info(Utf8String name)
{
EvaMessage message = Name_To_Message(name);

for (auto it = m_checkInfo.begin(); it != m_checkInfo.end(); it++) {
if (*it != nullptr && (*it)->m_messageType == message) {
return nullptr;
}
}

EvaCheckInfo *info = new EvaCheckInfo();
m_checkInfo.push_back(info);
info->m_messageType = message;
return info;
}

Eva::Eva() : m_player(nullptr), m_unk1(0), m_unk2(0), m_currentMessageType(NUM_EVA_MESSAGES), m_evaEnabled(true)
{
for (int i = 0; i < NUM_EVA_MESSAGES; i++) {
Expand Down Expand Up @@ -69,3 +110,90 @@ void Eva::Set_Should_Play(EvaMessage message)
{
m_shouldPlay[message] = true;
}

static const char *s_theEvaMessageNames[] = { "LOWPOWER",
"INSUFFICIENTFUNDS",
"SUPERWEAPONDETECTED_OWN_PARTICLECANNON",
"SUPERWEAPONDETECTED_OWN_NUKE",
"SUPERWEAPONDETECTED_OWN_SCUDSTORM",
"SUPERWEAPONDETECTED_ALLY_PARTICLECANNON",
"SUPERWEAPONDETECTED_ALLY_NUKE",
"SUPERWEAPONDETECTED_ALLY_SCUDSTORM",
"SUPERWEAPONDETECTED_ENEMY_PARTICLECANNON",
"SUPERWEAPONDETECTED_ENEMY_NUKE",
"SUPERWEAPONDETECTED_ENEMY_SCUDSTORM",
"SUPERWEAPONLAUNCHED_OWN_PARTICLECANNON",
"SUPERWEAPONLAUNCHED_OWN_NUKE",
"SUPERWEAPONLAUNCHED_OWN_SCUDSTORM",
"SUPERWEAPONLAUNCHED_ALLY_PARTICLECANNON",
"SUPERWEAPONLAUNCHED_ALLY_NUKE",
"SUPERWEAPONLAUNCHED_ALLY_SCUDSTORM",
"SUPERWEAPONLAUNCHED_ENEMY_PARTICLECANNON",
"SUPERWEAPONLAUNCHED_ENEMY_NUKE",
"SUPERWEAPONLAUNCHED_ENEMY_SCUDSTORM",
"SUPERWEAPONREADY_OWN_PARTICLECANNON",
"SUPERWEAPONREADY_OWN_NUKE",
"SUPERWEAPONREADY_OWN_SCUDSTORM",
"SUPERWEAPONREADY_ALLY_PARTICLECANNON",
"SUPERWEAPONREADY_ALLY_NUKE",
"SUPERWEAPONREADY_ALLY_SCUDSTORM",
"SUPERWEAPONREADY_ENEMY_PARTICLECANNON",
"SUPERWEAPONREADY_ENEMY_NUKE",
"SUPERWEAPONREADY_ENEMY_SCUDSTORM",
"BUILDINGLOST",
"BASEUNDERATTACK",
"ALLYUNDERATTACK",
"BEACONDETECTED",
"ENEMYBLACKLOTUSDETECTED",
"ENEMYJARMENKELLDETECTED",
"ENEMYCOLONELBURTONDETECTED",
"OWNBLACKLOTUSDETECTED",
"OWNJARMENKELLDETECTED",
"OWNCOLONELBURTONDETECTED",
"UNITLOST",
"GENERALLEVELUP",
"VEHICLESTOLEN",
"BUILDINGSTOLEN",
"CASHSTOLEN",
"UPGRADECOMPLETE",
"BUILDINGBEINGSTOLEN",
"BUILDINGSABOTAGED",
"SUPERWEAPONLAUNCHED_OWN_GPS_SCRAMBLER",
"SUPERWEAPONLAUNCHED_ALLY_GPS_SCRAMBLER",
"SUPERWEAPONLAUNCHED_ENEMY_GPS_SCRAMBLER",
"SUPERWEAPONLAUNCHED_OWN_SNEAK_ATTACK",
"SUPERWEAPONLAUNCHED_ALLY_SNEAK_ATTACK",
"SUPERWEAPONLAUNCHED_ENEMY_SNEAK_ATTACK" };

EvaMessage Eva::Name_To_Message(Utf8String const &name)
{
for (int i = 0; i < NUM_EVA_MESSAGES; i++) {
if (name.Compare_No_Case(s_theEvaMessageNames[i]) == 0) {
return static_cast<EvaMessage>(i);
}
}

return EVA_MESSAGE_INVALID;
}

void Eva::Parse(INI *ini)
{
Utf8String name;
name.Set(ini->Get_Next_Token());
EvaCheckInfo *info = g_theEva->New_Eva_Check_Info(name);

if (info != nullptr) {
ini->Init_From_INI(info, EvaCheckInfo::Get_Field_Parse());
}
}

void Eva::Parse_Eva_Message_From_INI(INI *ini, void *formal, void *store, const void *user_data)
{
EvaMessage message = Name_To_Message(ini->Get_Next_Token());

if (message == EVA_MESSAGE_INVALID) {
throw CODE_06;
}

*static_cast<EvaMessage *>(store) = message;
}
8 changes: 5 additions & 3 deletions src/game/client/eva.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct EvaSideSounds
Utf8String m_side;
std::vector<Utf8String> m_sounds;

static FieldParse *Get_Field_Parse();
static const FieldParse *Get_Field_Parse() { return s_evaSideSounds; }
static const FieldParse s_evaSideSounds[];
};

Expand All @@ -96,18 +96,20 @@ class EvaCheckInfo : public MemoryPoolObject
EvaCheckInfo() : m_messageType(NUM_EVA_MESSAGES), m_timeBetweenChecksMS(900), m_expirationTimeMS(150), m_priority(1) {}

private:
static const FieldParse *Get_Field_Parse() { return s_evaEventInfo; }
static const FieldParse s_evaEventInfo[];

EvaMessage m_messageType;
unsigned int m_timeBetweenChecksMS;
unsigned int m_expirationTimeMS;
unsigned int m_priority;
std::vector<EvaSideSounds> m_sideSounds;
friend class Eva;
};

struct EvaCheck
{
EvaCheck() : check_info(nullptr), unk1(0xFFFFFFFF), unk2(0), unk3(0) {}
static FieldParse *Get_Field_Parse();
static const FieldParse s_evaEventInfo[];

EvaCheckInfo *check_info;
unsigned int unk1;
Expand Down
Loading

0 comments on commit 7e77fc8

Please sign in to comment.