Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't reset cl_antiping subconfig on restart #333

Merged
merged 5 commits into from Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/engine/client/client.cpp
Expand Up @@ -3315,10 +3315,10 @@ int main(int argc, const char **argv) // ignore_convention
pClient->InitInterfaces();

// execute config file
IOHANDLE file = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(file)
IOHANDLE File = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
{
io_close(file);
io_close(File);
pConsole->ExecuteFile(CONFIG_FILE);
}
else // fallback
Expand All @@ -3327,17 +3327,28 @@ int main(int argc, const char **argv) // ignore_convention
}

// execute autoexec file
file = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(file)
File = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
{
io_close(file);
io_close(File);
pConsole->ExecuteFile(AUTOEXEC_CLIENT_FILE);
}
else // fallback
{
pConsole->ExecuteFile(AUTOEXEC_FILE);
}

if(g_Config.m_ClConfigVersion < 1)
{
if(g_Config.m_ClAntiPing == 0)
{
g_Config.m_ClAntiPingPlayers = 1;
g_Config.m_ClAntiPingGrenade = 1;
g_Config.m_ClAntiPingWeapons = 1;
}
}
g_Config.m_ClConfigVersion = 1;

// parse the command line arguments
if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/config_variables.h
Expand Up @@ -360,6 +360,7 @@ MACRO_CONFIG_INT(InpJoystick, inp_joystick, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT
#else
MACRO_CONFIG_INT(InpJoystick, inp_joystick, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use a joystick as input")
#endif
MACRO_CONFIG_INT(ClConfigVersion, cl_config_version, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "The config version. Helps newer clients fix bugs with older configs.")

// demo editor
MACRO_CONFIG_INT(ClDemoSliceBegin, cl_demo_slice_begin, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Begin marker for demo slice")
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/items.cpp
Expand Up @@ -57,7 +57,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)

int PrevTick = Client()->PrevGameTick();

if (g_Config.m_ClAntiPingGrenade && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
if (m_pClient->AntiPingGrenade() && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
{
// calc predicted game tick
static int Offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/nameplates.cpp
Expand Up @@ -88,7 +88,7 @@ void CNamePlates::RenderNameplate(

void CNamePlates::OnRender()
{
if (!g_Config.m_ClNameplates || g_Config.m_ClAntiPingPlayers)
if (!g_Config.m_ClNameplates || m_pClient->AntiPingPlayers())
return;

for(int i = 0; i < MAX_CLIENTS; i++)
Expand Down
16 changes: 8 additions & 8 deletions src/game/client/components/players.cpp
Expand Up @@ -257,7 +257,7 @@ void CPlayers::RenderHook(
// set size
RenderInfo.m_Size = 64.0f;

if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
// use preditect players if needed
if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
Expand Down Expand Up @@ -290,7 +290,7 @@ void CPlayers::RenderHook(
}

vec2 Position;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
else
Position = parPosition;
Expand All @@ -305,7 +305,7 @@ void CPlayers::RenderHook(
vec2 Pos = Position;
vec2 HookPos;

if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
if(pPlayerChar->m_HookedPlayer != -1)
{
Expand Down Expand Up @@ -440,7 +440,7 @@ void CPlayers::RenderPlayer(


// use preditect players if needed
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
Expand Down Expand Up @@ -475,7 +475,7 @@ void CPlayers::RenderPlayer(

vec2 Direction = GetDirection((int)(Angle*256.0f));
vec2 Position;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
else
Position = parPosition;
Expand Down Expand Up @@ -878,7 +878,7 @@ void CPlayers::RenderPlayer(
Graphics()->QuadsEnd();
}

if(g_Config.m_ClNameplates && g_Config.m_ClAntiPingPlayers)
if(g_Config.m_ClNameplates && m_pClient->AntiPingPlayers())
{
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
Expand Down Expand Up @@ -972,7 +972,7 @@ void CPlayers::OnRender()

static int predcnt = 0;

if (g_Config.m_ClAntiPingPlayers)
if (m_pClient->AntiPingPlayers())
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
Expand All @@ -999,7 +999,7 @@ void CPlayers::OnRender()
}
}

if(g_Config.m_ClAntiPingPlayers && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
if(m_pClient->AntiPingPlayers() && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
if(m_pClient->m_Snap.m_pLocalCharacter && !(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
{
// double ping = m_pClient->m_Snap.m_pLocalInfo->m_Latency;
Expand Down
26 changes: 9 additions & 17 deletions src/game/client/gameclient.cpp
Expand Up @@ -461,7 +461,7 @@ void CGameClient::UpdatePositions()
// local character position
if(g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
if (!g_Config.m_ClAntiPingPlayers)
if(!AntiPingPlayers())
{
if(!m_Snap.m_pLocalCharacter || (m_Snap.m_pGameInfoObj && m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
{
Expand All @@ -488,7 +488,7 @@ void CGameClient::UpdatePositions()
vec2(m_Snap.m_pLocalCharacter->m_X, m_Snap.m_pLocalCharacter->m_Y), Client()->IntraGameTick());
}

if (g_Config.m_ClAntiPingPlayers)
if (AntiPingPlayers())
{
for (int i = 0; i < MAX_CLIENTS; i++)
{
Expand Down Expand Up @@ -579,14 +579,6 @@ void CGameClient::OnRender()
m_NewTick = false;
m_NewPredictedTick = false;

if(g_Config.m_ClAntiPing != m_CurrentAntiPing)
{
g_Config.m_ClAntiPingPlayers = g_Config.m_ClAntiPing;
g_Config.m_ClAntiPingGrenade = g_Config.m_ClAntiPing;
g_Config.m_ClAntiPingWeapons = g_Config.m_ClAntiPing;
m_CurrentAntiPing = g_Config.m_ClAntiPing;
}

if(g_Config.m_ClDummy && !Client()->DummyConnected())
g_Config.m_ClDummy = 0;

Expand Down Expand Up @@ -664,7 +656,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy)

g_GameClient.m_pItems->AddExtraProjectile(&Proj);

if(g_Config.m_ClAntiPingWeapons && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj))
if(AntiPingWeapons() && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj))
{
vec2 StartPos;
vec2 Direction;
Expand Down Expand Up @@ -1310,7 +1302,7 @@ void CGameClient::OnPredict()
}

static bool IsWeaker[2][MAX_CLIENTS] = {{0}};
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
FindWeaker(IsWeaker);

// repredict character
Expand Down Expand Up @@ -1338,7 +1330,7 @@ void CGameClient::OnPredict()
int ReloadTimer = 0;
vec2 PrevPos;

if(g_Config.m_ClAntiPingWeapons)
if(AntiPingWeapons())
{
for(int Index = 0; Index < MaxProjectiles; Index++)
PredictedProjectiles[Index].Deactivate();
Expand Down Expand Up @@ -1419,7 +1411,7 @@ void CGameClient::OnPredict()
}
}

if(g_Config.m_ClAntiPingWeapons)
if(AntiPingWeapons())
{
const float ProximityRadius = 28.0f;
CNetObj_PlayerInput Input;
Expand Down Expand Up @@ -1593,7 +1585,7 @@ void CGameClient::OnPredict()
}

// calculate where everyone should move
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
{
//first apply Tick to weaker players (players that the local client has strong hook against), then local, then stronger players
for(int h = 0; h < 3; h++)
Expand Down Expand Up @@ -1623,7 +1615,7 @@ void CGameClient::OnPredict()
}

// move all players and quantize their data
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
{
// Everyone with weaker hook
for(int c = 0; c < MAX_CLIENTS; c++)
Expand Down Expand Up @@ -1700,7 +1692,7 @@ void CGameClient::OnPredict()
{
m_PredictedChar = *World.m_apCharacters[m_Snap.m_LocalClientID];

if (g_Config.m_ClAntiPingPlayers)
if (AntiPingPlayers())
{
for (int c = 0; c < MAX_CLIENTS; c++)
{
Expand Down
6 changes: 4 additions & 2 deletions src/game/client/gameclient.h
Expand Up @@ -363,11 +363,13 @@ class CGameClient : public IGameClient

void FindWeaker(bool IsWeaker[2][MAX_CLIENTS]);

private:
bool AntiPingPlayers() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingPlayers; }
bool AntiPingGrenade() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingGrenade; }
bool AntiPingWeapons() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingWeapons; }

private:
bool m_DDRaceMsgSent[2];
int m_ShowOthers[2];
bool m_CurrentAntiPing;
};


Expand Down
8 changes: 4 additions & 4 deletions src/game/variables.h
Expand Up @@ -7,10 +7,10 @@
// client
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")
MACRO_CONFIG_INT(ClAntiPingLimit, cl_antiping_limit, 0, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping limit (0 to disable)")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (sets all Antiping settings)")
MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements)")
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict grenades)")
MACRO_CONFIG_INT(ClAntiPingWeapons, cl_antiping_weapons, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict weapons)")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable antiping, i. e. more aggressive prediction.")
MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict other player's movement more aggressively (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict grenades (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClAntiPingWeapons, cl_antiping_weapons, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict weapon projectiles (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance")
MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")
Expand Down