[Maps] Check map hash and redownload when different
This commit is contained in:
parent
a54e322f9c
commit
991056b362
@ -442,11 +442,20 @@ namespace Components
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Maps::TriggerReconnectForMap(const char* mapname)
|
void Maps::LoadNewMapCommand(char* buffer, size_t size, const char* /*format*/, const char* mapname, const char* gametype)
|
||||||
|
{
|
||||||
|
unsigned int hash = Maps::GetUsermapHash(mapname);
|
||||||
|
_snprintf_s(buffer, size, size, "loadingnewmap\n%s\n%s\n%d", mapname, gametype, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Maps::TriggerReconnectForMap(Game::msg_t* msg, const char* mapname)
|
||||||
{
|
{
|
||||||
Theatre::StopRecording();
|
Theatre::StopRecording();
|
||||||
|
|
||||||
if(!Maps::CheckMapInstalled(mapname, false, true))
|
char hashBuf[100] = { 0 };
|
||||||
|
unsigned int hash = atoi(Game::MSG_ReadStringLine(msg, hashBuf, sizeof hashBuf));
|
||||||
|
|
||||||
|
if(!Maps::CheckMapInstalled(mapname, false, true) || hash && hash != Maps::GetUsermapHash(mapname))
|
||||||
{
|
{
|
||||||
// Reconnecting forces the client to download the new map
|
// Reconnecting forces the client to download the new map
|
||||||
Command::Execute("disconnect", false);
|
Command::Execute("disconnect", false);
|
||||||
@ -468,8 +477,9 @@ namespace Components
|
|||||||
pushad
|
pushad
|
||||||
|
|
||||||
push [esp + 28h]
|
push [esp + 28h]
|
||||||
|
push ebp
|
||||||
call Maps::TriggerReconnectForMap
|
call Maps::TriggerReconnectForMap
|
||||||
add esp, 4h
|
add esp, 8h
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov[esp + 20h], eax
|
||||||
|
|
||||||
@ -1000,6 +1010,11 @@ namespace Components
|
|||||||
}, 6s);
|
}, 6s);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(Dedicated::IsEnabled())
|
||||||
|
{
|
||||||
|
Utils::Hook(0x4A7251, Maps::LoadNewMapCommand, HOOK_CALL).install()->quick();
|
||||||
|
}
|
||||||
|
|
||||||
// Download the map before a maprotation if necessary
|
// Download the map before a maprotation if necessary
|
||||||
// Conflicts with Theater's SV map rotation check, but this one is safer!
|
// Conflicts with Theater's SV map rotation check, but this one is safer!
|
||||||
Utils::Hook(0x5AA91C, Maps::RotateCheckStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x5AA91C, Maps::RotateCheckStub, HOOK_CALL).install()->quick();
|
||||||
|
@ -112,8 +112,9 @@ namespace Components
|
|||||||
static void SpawnServerStub();
|
static void SpawnServerStub();
|
||||||
static void LoadMapLoadscreenStub();
|
static void LoadMapLoadscreenStub();
|
||||||
|
|
||||||
static int TriggerReconnectForMap(const char* mapname);
|
static int TriggerReconnectForMap(Game::msg_t* msg, const char* mapname);
|
||||||
static void RotateCheckStub();
|
static void RotateCheckStub();
|
||||||
|
static void LoadNewMapCommand(char* buffer, size_t size, const char* format, const char* mapname, const char* gametype);
|
||||||
|
|
||||||
static const char* LoadArenaFileStub(const char* name, char* buffer, int size);
|
static const char* LoadArenaFileStub(const char* name, char* buffer, int size);
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ namespace Game
|
|||||||
MSG_ReadShort_t MSG_ReadShort = MSG_ReadShort_t(0x40BDD0);
|
MSG_ReadShort_t MSG_ReadShort = MSG_ReadShort_t(0x40BDD0);
|
||||||
MSG_ReadInt64_t MSG_ReadInt64 = MSG_ReadInt64_t(0x4F1850);
|
MSG_ReadInt64_t MSG_ReadInt64 = MSG_ReadInt64_t(0x4F1850);
|
||||||
MSG_ReadString_t MSG_ReadString = MSG_ReadString_t(0x60E2B0);
|
MSG_ReadString_t MSG_ReadString = MSG_ReadString_t(0x60E2B0);
|
||||||
|
MSG_ReadStringLine_t MSG_ReadStringLine = MSG_ReadStringLine_t(0x4FEF30);
|
||||||
MSG_WriteByte_t MSG_WriteByte = MSG_WriteByte_t(0x48C520);
|
MSG_WriteByte_t MSG_WriteByte = MSG_WriteByte_t(0x48C520);
|
||||||
MSG_WriteData_t MSG_WriteData = MSG_WriteData_t(0x4F4120);
|
MSG_WriteData_t MSG_WriteData = MSG_WriteData_t(0x4F4120);
|
||||||
MSG_WriteLong_t MSG_WriteLong = MSG_WriteLong_t(0x41CA20);
|
MSG_WriteLong_t MSG_WriteLong = MSG_WriteLong_t(0x41CA20);
|
||||||
|
@ -394,6 +394,9 @@ namespace Game
|
|||||||
typedef char* (__cdecl * MSG_ReadString_t)(msg_t* msg);
|
typedef char* (__cdecl * MSG_ReadString_t)(msg_t* msg);
|
||||||
extern MSG_ReadString_t MSG_ReadString;
|
extern MSG_ReadString_t MSG_ReadString;
|
||||||
|
|
||||||
|
typedef char* (__cdecl * MSG_ReadStringLine_t)(msg_t *msg, char *string, unsigned int maxChars);
|
||||||
|
extern MSG_ReadStringLine_t MSG_ReadStringLine;
|
||||||
|
|
||||||
typedef int(__cdecl * MSG_ReadByte_t)(msg_t* msg);
|
typedef int(__cdecl * MSG_ReadByte_t)(msg_t* msg);
|
||||||
extern MSG_ReadByte_t MSG_ReadByte;
|
extern MSG_ReadByte_t MSG_ReadByte;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user