Skip to content

Commit

Permalink
Implement some stuff for GameClient (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwil authored Feb 3, 2024
1 parent 2243feb commit 9cec511
Show file tree
Hide file tree
Showing 48 changed files with 1,890 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
set(DEFAULT_STANDALONE OFF)
set(DEFAULT_STDFS OFF)
set(DEFAULT_FFMPEG OFF)
set(DEFAULT_SDL2 OFF)
set(DEFAULT_ALSOFT OFF)
set(DEFAULT_SDL2 OFF)
set(DEFAULT_FREETYPE OFF)
set(DEFAULT_FONTCONFIG OFF)
else()
Expand Down
1 change: 1 addition & 0 deletions deps/baseconfig/src/unichar.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef wchar_t unichar_t;
#define u_isspace iswspace
#define u_tolower towlower
#define u_strchr(x, y) wcschr(x, y)
#define u_strrchr(x, y) wcsrchr(x, y)
#define U_COMPARE_CODE_POINT_ORDER 0x8000
#define U_CHAR(str) (L##str)
#else
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ set(GAMEENGINE_SRC
game/client/gui/loadscreen.cpp
game/client/gui/processanimatewindow.cpp
game/client/gui/shell/shell.cpp
game/client/gui/shell/shellmenuscheme.cpp
game/client/gui/windowlayout.cpp
game/client/gui/windowvideomanager.cpp
game/client/gui/wininstancedata.cpp
Expand All @@ -153,10 +154,14 @@ set(GAMEENGINE_SRC
game/client/line2d.cpp
game/client/maputil.cpp
game/client/messagestream/commandxlat.cpp
game/client/messagestream/guicommandtranslator.cpp
game/client/messagestream/hintspy.cpp
game/client/messagestream/hotkey.cpp
game/client/messagestream/lookatxlat.cpp
game/client/messagestream/metaevent.cpp
game/client/messagestream/placeeventtranslator.cpp
game/client/messagestream/selectionxlat.cpp
game/client/messagestream/windowxlat.cpp
game/client/optionpreferences.cpp
game/client/parabolicease.cpp
game/client/radiusdecal.cpp
Expand Down Expand Up @@ -761,7 +766,7 @@ if(BUILD_DLL)
endif()

if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
list(APPEND GAME_LINK_LIBRARIES winmm)
list(APPEND GAME_LINK_LIBRARIES winmm imm32)

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
list(APPEND GAME_LINK_LIBRARIES binkstub milesstub)
Expand Down
1 change: 1 addition & 0 deletions src/game/client/drawgroupinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class DrawGroupInfo
static const FieldParse s_parseTable[];
friend class Drawable;
friend class W3DDisplayStringManager;
friend class GameClient;
};

#ifdef GAME_DLL
Expand Down
46 changes: 44 additions & 2 deletions src/game/client/eva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,51 @@
Eva *g_theEva;
#endif

void Eva::Set_Should_Play(EvaMessage message)
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++) {
m_shouldPlay[i] = false;
}
}

Eva::~Eva()
{
for (auto it = m_checkInfo.begin(); it != m_checkInfo.end(); it++) {
if (*it != nullptr) {
(*it)->Delete_Instance();
}
}
}

void Eva::Init()
{
INI ini;
ini.Load("Data\\INI\\Eva.ini", INI_LOAD_OVERWRITE, nullptr);
}

void Eva::Reset()
{
m_unk2 = 0;
m_unk1 = 0;

for (auto it = m_check.begin(); it != m_check.end(); it = m_check.erase(it)) {
}

for (int i = 0; i < NUM_EVA_MESSAGES; i++) {
m_shouldPlay[i] = false;
}

m_evaEnabled = true;
}

void Eva::Update()
{
#ifdef GAME_DLL
Call_Method<void, Eva, EvaMessage>(PICK_ADDRESS(0x00513750, 0x009BBA4C), this, message);
Call_Method<void, Eva>(PICK_ADDRESS(0x00513340, 0x009BB4DA), this);
#endif
}

void Eva::Set_Should_Play(EvaMessage message)
{
m_shouldPlay[message] = true;
}
75 changes: 74 additions & 1 deletion src/game/client/eva.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
#pragma once
#include "always.h"
#include "asciistring.h"
#include "audioeventrts.h"
#include "mempoolobj.h"
#include "subsysteminterface.h"
#include <vector>

enum EvaMessage
{
Expand Down Expand Up @@ -71,12 +76,80 @@ enum EvaMessage
EVA_MESSAGE_SUPERWEAPONLAUNCHED_OWN_SNEAK_ATTACK,
EVA_MESSAGE_SUPERWEAPONLAUNCHED_ALLY_SNEAK_ATTACK,
EVA_MESSAGE_SUPERWEAPONLAUNCHED_ENEMY_SNEAK_ATTACK,
NUM_EVA_MESSAGES,
};

class Eva
struct EvaSideSounds
{
Utf8String m_side;
std::vector<Utf8String> m_sounds;

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

class EvaCheckInfo : public MemoryPoolObject
{
IMPLEMENT_POOL(EvaCheckInfo)

public:
EvaCheckInfo() : m_messageType(NUM_EVA_MESSAGES), m_timeBetweenChecksMS(900), m_expirationTimeMS(150), m_priority(1) {}

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

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;
unsigned int unk2;
bool unk3;
};

class Eva : public SubsystemInterface
{
public:
Eva();
virtual ~Eva() override;
virtual void Init() override;
virtual void Reset() override;
virtual void Update() override;

EvaCheckInfo *New_Eva_Check_Info(Utf8String name);
EvaCheckInfo *Get_Eva_Check_Info(Utf8String name);
void Set_Should_Play(EvaMessage message);
void Set_Eva_Enabled(bool enabled);
bool Is_Time_For_Check(EvaMessage message, unsigned int frame);
bool Message_Should_Play(EvaMessage message, unsigned int frame);
void Play_Message(EvaMessage message, unsigned int frame);
void Process_Playing_Message(unsigned int frame);

static void Parse(INI *ini);
static EvaMessage Name_To_Message(Utf8String const &name);
static Utf8String Message_To_Name(EvaMessage message);
static bool Should_Play_Low_Power(Player *player);
static bool Should_Play_Generic_Handler(Player *player);
static void Parse_Eva_Message_From_INI(INI *ini, void *formal, void *store, const void *user_data);

private:
std::vector<EvaCheckInfo *> m_checkInfo;
std::vector<EvaCheck> m_check;
AudioEventRTS m_sound;
Player *m_player;
int m_unk1;
int m_unk2;
EvaMessage m_currentMessageType;
bool m_shouldPlay[NUM_EVA_MESSAGES];
bool m_evaEnabled;
};

#ifdef GAME_DLL
Expand Down
Loading

0 comments on commit 9cec511

Please sign in to comment.