Fixed server crash on invalid gamemode in SetPlayerGameTypePacket

this really ought to be detected at the decode layer, but right now that's a bit difficult ...
This commit is contained in:
Dylan K. Taylor
2021-03-28 21:11:07 +01:00
parent 7fe6815f7c
commit 25998720ce
2 changed files with 4 additions and 4 deletions

View File

@ -667,8 +667,8 @@ class InGamePacketHandler extends PacketHandler{
}
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
$converter = TypeConverter::getInstance();
if(!$converter->protocolGameModeToCore($packet->gamemode)->equals($this->player->getGamemode())){
$gameMode = TypeConverter::getInstance()->protocolGameModeToCore($packet->gamemode);
if($gameMode === null || !$gameMode->equals($this->player->getGamemode())){
//Set this back to default. TODO: handle this properly
$this->session->syncGameMode($this->player->getGamemode(), true);
}