1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Initial version of antilag support

This commit is contained in:
Ivan Savenko
2025-06-28 21:42:54 +03:00
parent 58de180083
commit 3576efc3f3
24 changed files with 490 additions and 23 deletions

View File

@@ -8,8 +8,9 @@
*
*/
#include "StdInc.h"
#include "CServerHandler.h"
#include "AntilagServer.h"
#include "Client.h"
#include "ServerRunner.h"
#include "GameChatHandler.h"
@@ -616,6 +617,9 @@ void CServerHandler::startGameplay(std::shared_ptr<CGameState> gameState)
if(GAME->mainmenu())
GAME->mainmenu()->disable();
// if (isGuest())
antilagServer = std::make_unique<AntilagServer>(getNetworkHandler(), gameState);
switch(si->mode)
{
case EStartMode::NEW_GAME:
@@ -940,10 +944,12 @@ void CServerHandler::visitForLobby(CPackForLobby & lobbyPack)
void CServerHandler::visitForClient(CPackForClient & clientPack)
{
if (antilagServer && antilagServer->verifyReply(clientPack))
return;
client->handlePack(clientPack);
}
void CServerHandler::sendLobbyPack(const CPackForLobby & pack) const
{
if(getState() != EClientState::STARTING)
@@ -959,3 +965,11 @@ bool CServerHandler::inGame() const
{
return logicConnection != nullptr;
}
void CServerHandler::sendGamePack(const CPackForServer & pack) const
{
if (antilagServer)
antilagServer->tryPredictReply(pack);
logicConnection->sendPack(pack);
}