[Theatre]: Do not draw broken selector (#700)

This commit is contained in:
Edo 2023-01-04 18:57:32 +00:00 committed by GitHub
parent c5be92602f
commit 46a3f62406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 24 deletions

View File

@ -38,8 +38,8 @@ namespace Components
void Theatre::RecordGamestateStub() void Theatre::RecordGamestateStub()
{ {
const auto sequence = (*Game::serverMessageSequence - 1); const auto sequence = (Game::clientConnections->serverMessageSequence - 1);
Game::FS_WriteToDemo(&sequence, 4, *Game::demoFile); Game::FS_WriteToDemo(&sequence, 4, Game::clientConnections->demofile);
} }
void Theatre::StoreBaseline(PBYTE snapshotMsg) void Theatre::StoreBaseline(PBYTE snapshotMsg)
@ -72,7 +72,7 @@ namespace Components
Game::msg_t buf; Game::msg_t buf;
Game::MSG_Init(&buf, bufData, 131072); Game::MSG_Init(&buf, bufData, sizeof(bufData));
Game::MSG_WriteData(&buf, &BaselineSnapshot[BaselineSnapshotMsgOff], BaselineSnapshotMsgLen - BaselineSnapshotMsgOff); Game::MSG_WriteData(&buf, &BaselineSnapshot[BaselineSnapshotMsgOff], BaselineSnapshotMsgLen - BaselineSnapshotMsgOff);
Game::MSG_WriteByte(&buf, 6); Game::MSG_WriteByte(&buf, 6);
@ -80,12 +80,12 @@ namespace Components
const auto fileCompressedSize = compressedSize + 4; const auto fileCompressedSize = compressedSize + 4;
int byte8 = 8; int byte8 = 8;
char byte0 = 0; unsigned char byte0 = 0;
Game::FS_WriteToDemo(&byte0, 1, *Game::demoFile); Game::FS_WriteToDemo(&byte0, sizeof(unsigned char), Game::clientConnections->demofile);
Game::FS_WriteToDemo(Game::serverMessageSequence, 4, *Game::demoFile); Game::FS_WriteToDemo(&Game::clientConnections->serverMessageSequence, sizeof(int), Game::clientConnections->demofile);
Game::FS_WriteToDemo(&fileCompressedSize, 4, *Game::demoFile); Game::FS_WriteToDemo(&fileCompressedSize, sizeof(int), Game::clientConnections->demofile);
Game::FS_WriteToDemo(&byte8, 4, *Game::demoFile); Game::FS_WriteToDemo(&byte8, sizeof(int), Game::clientConnections->demofile);
for (auto i = 0; i < compressedSize; i += 1024) for (auto i = 0; i < compressedSize; i += 1024)
{ {
@ -97,7 +97,7 @@ namespace Components
break; break;
} }
Game::FS_WriteToDemo(&cmpData[i], size, *Game::demoFile); Game::FS_WriteToDemo(&cmpData[i], size, Game::clientConnections->demofile);
} }
} }
@ -123,7 +123,7 @@ namespace Components
{ {
__asm __asm
{ {
mov eax, Game::demoPlaying mov eax, 0xA5EA0C // clientConnections.demoplaying
mov eax, [eax] mov eax, [eax]
test al, al test al, al
jz continue jz continue
@ -141,7 +141,7 @@ namespace Components
{ {
__asm __asm
{ {
mov eax, Game::demoPlaying mov eax, 0xA5EA0C // clientConnections.demoplaying
mov eax, [eax] mov eax, [eax]
test al, al test al, al
jz continue jz continue
@ -160,7 +160,7 @@ namespace Components
{ {
__asm __asm
{ {
mov eax, Game::demoPlaying mov eax, 0xA5EA0C // clientConnections.demoplaying
mov eax, [eax] mov eax, [eax]
test al, al test al, al
jz continue jz continue
@ -177,6 +177,14 @@ namespace Components
} }
} }
void Theatre::CG_CompassDrawPlayerMapLocationSelector_Stub(const int localClientNum, Game::CompassType compassType, const Game::rectDef_s* parentRect, const Game::rectDef_s* rect, Game::Material* material, float* color)
{
if (!Game::clientConnections->demoplaying)
{
Utils::Hook::Call<void(int, Game::CompassType, const Game::rectDef_s*, const Game::rectDef_s*, Game::Material*, float*)>(0x45BD60)(localClientNum, compassType, parentRect, rect, material, color);
}
}
void Theatre::CL_WriteDemoClientArchive_Hk(void(*write)(const void* buffer, int len, int localClientNum), const Game::playerState_s* ps, const float* viewangles, [[maybe_unused]] const float* selectedLocation, [[maybe_unused]] const float selectedLocationAngle, int localClientNum, int index) void Theatre::CL_WriteDemoClientArchive_Hk(void(*write)(const void* buffer, int len, int localClientNum), const Game::playerState_s* ps, const float* viewangles, [[maybe_unused]] const float* selectedLocation, [[maybe_unused]] const float selectedLocationAngle, int localClientNum, int index)
{ {
assert(write); assert(write);
@ -334,7 +342,7 @@ namespace Components
int Theatre::CL_FirstSnapshot_Stub() int Theatre::CL_FirstSnapshot_Stub()
{ {
if (CLAutoRecord.get<bool>() && !*Game::demoPlaying) if (CLAutoRecord.get<bool>() && !Game::clientConnections->demoplaying)
{ {
std::vector<std::string> files; std::vector<std::string> files;
auto demos = FileSystem::GetFileList("demos/", "dm_13"); auto demos = FileSystem::GetFileList("demos/", "dm_13");
@ -370,7 +378,7 @@ namespace Components
void Theatre::StopRecording() void Theatre::StopRecording()
{ {
if (*Game::demoRecording) if (Game::clientConnections->demorecording)
{ {
Command::Execute("stoprecord", true); Command::Execute("stoprecord", true);
} }
@ -378,6 +386,11 @@ namespace Components
Theatre::Theatre() Theatre::Theatre()
{ {
AssertOffset(Game::clientConnection_t, demorecording, 0x40190);
AssertOffset(Game::clientConnection_t, demoplaying, 0x40194);
AssertOffset(Game::clientConnection_t, demofile, 0x401A4);
AssertOffset(Game::clientConnection_t, serverMessageSequence, 0x2013C);
CLAutoRecord = Dvar::Register<bool>("cl_autoRecord", true, Game::DVAR_ARCHIVE, "Automatically record games"); CLAutoRecord = Dvar::Register<bool>("cl_autoRecord", true, Game::DVAR_ARCHIVE, "Automatically record games");
CLDemosKeep = Dvar::Register<int>("cl_demosKeep", 30, 1, 999, Game::DVAR_ARCHIVE, "How many demos to keep with autorecord"); CLDemosKeep = Dvar::Register<int>("cl_demosKeep", 30, 1, 999, Game::DVAR_ARCHIVE, "How many demos to keep with autorecord");
@ -391,6 +404,7 @@ namespace Components
// Fix issue with locationSelectionInfo by disabling it // Fix issue with locationSelectionInfo by disabling it
Utils::Hook(0x5AC20F, CL_WriteDemoClientArchive_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x5AC20F, CL_WriteDemoClientArchive_Hk, HOOK_CALL).install()->quick();
Utils::Hook(0x4964A6, CG_CompassDrawPlayerMapLocationSelector_Stub, HOOK_CALL).install()->quick();
// Hook commands to enforce metadata generation // Hook commands to enforce metadata generation
Utils::Hook(0x5A82AE, RecordStub, HOOK_CALL).install()->quick(); Utils::Hook(0x5A82AE, RecordStub, HOOK_CALL).install()->quick();

View File

@ -56,6 +56,7 @@ namespace Components
static int CL_FirstSnapshot_Stub(); static int CL_FirstSnapshot_Stub();
static void SV_SpawnServer_Stub(); static void SV_SpawnServer_Stub();
static void CG_CompassDrawPlayerMapLocationSelector_Stub(int localClientNum, Game::CompassType compassType, const Game::rectDef_s* parentRect, const Game::rectDef_s* rect, Game::Material* material, float* color);
static void CL_WriteDemoClientArchive_Hk(void(*write)(const void* buffer, int len, int localClientNum), const Game::playerState_s* ps, const float* viewangles, const float* selectedLocation, float selectedLocationAngle, int localClientNum, int index); static void CL_WriteDemoClientArchive_Hk(void(*write)(const void* buffer, int len, int localClientNum), const Game::playerState_s* ps, const float* viewangles, const float* selectedLocation, float selectedLocationAngle, int localClientNum, int index);
static void RecordStub(int channel, char* message, char* file); static void RecordStub(int channel, char* message, char* file);

View File

@ -290,11 +290,6 @@ namespace Game
int* numIP = reinterpret_cast<int*>(0x64A1E68); int* numIP = reinterpret_cast<int*>(0x64A1E68);
netIP_t* localIP = reinterpret_cast<netIP_t*>(0x64A1E28); netIP_t* localIP = reinterpret_cast<netIP_t*>(0x64A1E28);
int* demoFile = reinterpret_cast<int*>(0xA5EA1C);
int* demoPlaying = reinterpret_cast<int*>(0xA5EA0C);
int* demoRecording = reinterpret_cast<int*>(0xA5EA08);
int* serverMessageSequence = reinterpret_cast<int*>(0xA3E9B4);
netadr_t* connectedHost = reinterpret_cast<netadr_t*>(0xA1E888); netadr_t* connectedHost = reinterpret_cast<netadr_t*>(0xA1E888);
SOCKET* ip_socket = reinterpret_cast<SOCKET*>(0x64A3008); SOCKET* ip_socket = reinterpret_cast<SOCKET*>(0x64A3008);

View File

@ -633,11 +633,6 @@ namespace Game
extern int* numIP; extern int* numIP;
extern netIP_t* localIP; extern netIP_t* localIP;
extern int* demoFile;
extern int* demoPlaying;
extern int* demoRecording;
extern int* serverMessageSequence;
extern netadr_t* connectedHost; extern netadr_t* connectedHost;
extern SOCKET* ip_socket; extern SOCKET* ip_socket;

View File

@ -7107,6 +7107,12 @@ namespace Game
static_assert(sizeof(client_t) == 0xA6790); static_assert(sizeof(client_t) == 0xA6790);
enum CompassType
{
COMPASS_TYPE_PARTIAL = 0x0,
COMPASS_TYPE_FULL = 0x1,
};
struct clientConnection_t struct clientConnection_t
{ {
int qport; int qport;