5231: Fix windows crash r=def- a=C0D3D3V

Fixes #5226

I tested it in a Windows VM.
`@sjrc6` is it correct that `TempCore` is this way zero initialized, can you check that maybe in the debugger? I do not want to change the behaviour, even tho the core is read in two lines later with `TempCore.ReadCharacter(pCharacter);`

## 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 if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
This commit is contained in:
bors[bot] 2022-05-26 08:57:22 +00:00 committed by GitHub
commit 3b81157013
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -1098,10 +1098,8 @@ void CGameClient::OnNewSnapshot()
{
auto &&Evolve = [this](CNetObj_Character *pCharacter, int Tick) {
CWorldCore TempWorld;
CCharacterCore TempCore;
CTeamsCore TempTeams;
mem_zero(&TempCore, sizeof(TempCore));
mem_zero(&TempTeams, sizeof(TempTeams));
CCharacterCore TempCore = CCharacterCore();
CTeamsCore TempTeams = CTeamsCore();
TempCore.Init(&TempWorld, Collision(), &TempTeams);
TempCore.ReadCharacter(pCharacter);

View file

@ -550,7 +550,7 @@ void CCharacterCore::ReadCharacterCore(const CNetObj_CharacterCore *pObjCore)
m_HookPos.y = pObjCore->m_HookY;
m_HookDir.x = pObjCore->m_HookDx / 256.0f;
m_HookDir.y = pObjCore->m_HookDy / 256.0f;
m_HookedPlayer = pObjCore->m_HookedPlayer;
SetHookedPlayer(pObjCore->m_HookedPlayer);
m_Jumped = pObjCore->m_Jumped;
m_Direction = pObjCore->m_Direction;
m_Angle = pObjCore->m_Angle;