3478: Fix server crash with too many items (fixes #3477) r=heinrich5991 a=def-

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

## Checklist

- [ ] 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
- [ ] 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: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-01-05 18:20:24 +00:00 committed by GitHub
commit f68e7853be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -404,6 +404,8 @@ void CPlayer::Snap(int SnappingClient)
GameServer()->m_apPlayers[SnappingClient]->m_TimerType == TIMERTYPE_SIXUP)
{
protocol7::CNetObj_PlayerInfoRace *pRaceInfo = static_cast<protocol7::CNetObj_PlayerInfoRace *>(Server()->SnapNewItem(-protocol7::NETOBJTYPE_PLAYERINFORACE, id, sizeof(protocol7::CNetObj_PlayerInfoRace)));
if(!pRaceInfo)
return;
pRaceInfo->m_RaceStartTick = m_pCharacter->m_StartTime;
}
@ -418,6 +420,9 @@ void CPlayer::Snap(int SnappingClient)
if(ShowSpec)
{
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, id, sizeof(CNetObj_SpecChar)));
if(!pSpecChar)
return;
pSpecChar->m_X = m_pCharacter->Core()->m_Pos.x;
pSpecChar->m_Y = m_pCharacter->Core()->m_Pos.y;
}