5770: Fix physics change by weak hook fix (fixes #5769) r=def- a=fokkonaut

<!-- What is the motivation for the changes of this pull request -->
fixes #5769

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2022-11-01 10:29:53 +00:00 committed by GitHub
commit 571b0b36de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 20 deletions

View file

@ -26,7 +26,7 @@ GameInfoFlags = [
] ]
GameInfoFlags2 = [ GameInfoFlags2 = [
"ALLOW_X_SKINS", "GAMETYPE_CITY", "GAMETYPE_FDDRACE", "ENTITIES_FDDRACE", "HUD_HEALTH_ARMOR", "HUD_AMMO", "ALLOW_X_SKINS", "GAMETYPE_CITY", "GAMETYPE_FDDRACE", "ENTITIES_FDDRACE", "HUD_HEALTH_ARMOR", "HUD_AMMO",
"HUD_DDRACE", "NO_WEAK_HOOK_AND_BOUNCE" "HUD_DDRACE", "NO_WEAK_HOOK"
] ]
ExPlayerFlags = ["AFK", "PAUSED", "SPEC"] ExPlayerFlags = ["AFK", "PAUSED", "SPEC"]
ProjectileFlags = [f"CLIENTID_BIT{i}" for i in range(8)] + [ ProjectileFlags = [f"CLIENTID_BIT{i}" for i in range(8)] + [

View file

@ -288,7 +288,7 @@ MACRO_CONFIG_INT(SvOldLaser, sv_old_laser, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAM
MACRO_CONFIG_INT(SvSlashMe, sv_slash_me, 0, 0, 1, CFGFLAG_SERVER, "Whether /me is active on the server or not") MACRO_CONFIG_INT(SvSlashMe, sv_slash_me, 0, 0, 1, CFGFLAG_SERVER, "Whether /me is active on the server or not")
MACRO_CONFIG_INT(SvRejoinTeam0, sv_rejoin_team_0, 1, 0, 1, CFGFLAG_SERVER, "Make a team automatically rejoin team 0 after finish (only if not locked)") MACRO_CONFIG_INT(SvRejoinTeam0, sv_rejoin_team_0, 1, 0, 1, CFGFLAG_SERVER, "Make a team automatically rejoin team 0 after finish (only if not locked)")
MACRO_CONFIG_INT(SvNoWeakHookAndBounce, sv_no_weak_hook_and_bounce, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether to use an alternative calculation for world ticks, that makes hook and bounce behave like all players have strong.") MACRO_CONFIG_INT(SvNoWeakHook, sv_no_weak_hook, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether to use an alternative calculation for world ticks, that makes the hook behave like all players have strong.")
MACRO_CONFIG_INT(ClReconnectTimeout, cl_reconnect_timeout, 120, 0, 600, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (after timeout, 0 for off)") MACRO_CONFIG_INT(ClReconnectTimeout, cl_reconnect_timeout, 120, 0, 600, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (after timeout, 0 for off)")
MACRO_CONFIG_INT(ClReconnectFull, cl_reconnect_full, 5, 0, 600, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (when server is full, 0 for off)") MACRO_CONFIG_INT(ClReconnectFull, cl_reconnect_full, 5, 0, 600, CFGFLAG_CLIENT | CFGFLAG_SAVE, "How many seconds to wait before reconnecting (when server is full, 0 for off)")

View file

@ -1124,7 +1124,7 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
} }
if(Version >= 8) if(Version >= 8)
{ {
Info.m_NoWeakHookAndBounce = Flags2 & GAMEINFOFLAG2_NO_WEAK_HOOK_AND_BOUNCE; Info.m_NoWeakHookAndBounce = Flags2 & GAMEINFOFLAG2_NO_WEAK_HOOK;
} }
return Info; return Info;
} }

View file

@ -738,12 +738,12 @@ void CCharacter::PreTick()
Antibot()->OnCharacterTick(m_pPlayer->GetCID()); Antibot()->OnCharacterTick(m_pPlayer->GetCID());
m_Core.m_Input = m_Input; m_Core.m_Input = m_Input;
m_Core.Tick(true, !g_Config.m_SvNoWeakHookAndBounce); m_Core.Tick(true, !g_Config.m_SvNoWeakHook);
} }
void CCharacter::Tick() void CCharacter::Tick()
{ {
if(g_Config.m_SvNoWeakHookAndBounce) if(g_Config.m_SvNoWeakHook)
{ {
if(m_Paused) if(m_Paused)
return; return;

View file

@ -33,7 +33,7 @@ public:
void Reset() override; void Reset() override;
void Destroy() override; void Destroy() override;
void PreTick() override; void PreTick();
void Tick() override; void Tick() override;
void TickDeferred() override; void TickDeferred() override;
void TickPaused() override; void TickPaused() override;

View file

@ -86,13 +86,6 @@ public: // TODO: Maybe make protected
*/ */
virtual void Reset() {} virtual void Reset() {}
/*
Function: PreTick
Called to progress the entity before the next tick.
Can be used to prepare variables for all clients before the next tick is executed.
*/
virtual void PreTick() {}
/* /*
Function: Tick Function: Tick
Called to progress the entity to the next tick. Updates Called to progress the entity to the next tick. Updates

View file

@ -605,8 +605,8 @@ void IGameController::Snap(int SnappingClient)
GAMEINFOFLAG_ENTITIES_RACE | GAMEINFOFLAG_ENTITIES_RACE |
GAMEINFOFLAG_RACE; GAMEINFOFLAG_RACE;
pGameInfoEx->m_Flags2 = GAMEINFOFLAG2_HUD_DDRACE; pGameInfoEx->m_Flags2 = GAMEINFOFLAG2_HUD_DDRACE;
if(g_Config.m_SvNoWeakHookAndBounce) if(g_Config.m_SvNoWeakHook)
pGameInfoEx->m_Flags2 |= GAMEINFOFLAG2_NO_WEAK_HOOK_AND_BOUNCE; pGameInfoEx->m_Flags2 |= GAMEINFOFLAG2_NO_WEAK_HOOK;
pGameInfoEx->m_Version = GAMEINFO_CURVERSION; pGameInfoEx->m_Version = GAMEINFO_CURVERSION;
if(Server()->IsSixup(SnappingClient)) if(Server()->IsSixup(SnappingClient))

View file

@ -267,25 +267,31 @@ void CGameWorld::Tick()
{ {
if(GameServer()->m_pController->IsForceBalanced()) if(GameServer()->m_pController->IsForceBalanced())
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced"); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced");
// update all objects // update all objects
if(g_Config.m_SvNoWeakHookAndBounce) for(int i = 0; i < NUM_ENTTYPES; i++)
{ {
for(auto *pEnt : m_apFirstEntityTypes) // It's important to call PreTick() and Tick() after each other.
// If we call PreTick() before, and Tick() after other entities have been processed, it causes physics changes such as a stronger shotgun or grenade.
if(g_Config.m_SvNoWeakHook && i == ENTTYPE_CHARACTER)
{
auto *pEnt = m_apFirstEntityTypes[i];
for(; pEnt;) for(; pEnt;)
{ {
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->PreTick(); ((CCharacter *)pEnt)->PreTick();
pEnt = m_pNextTraverseEntity; pEnt = m_pNextTraverseEntity;
} }
} }
for(auto *pEnt : m_apFirstEntityTypes) auto *pEnt = m_apFirstEntityTypes[i];
for(; pEnt;) for(; pEnt;)
{ {
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity; m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->Tick(); pEnt->Tick();
pEnt = m_pNextTraverseEntity; pEnt = m_pNextTraverseEntity;
} }
}
for(auto *pEnt : m_apFirstEntityTypes) for(auto *pEnt : m_apFirstEntityTypes)
for(; pEnt;) for(; pEnt;)