1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-28 20:36:42 +00:00

[Client] Fix crashes in PlayerProcessors from NULL players

Also rename ProcessorPlayerDrawState into ProcessorPlayerAnimFlags
This commit is contained in:
David Cernat 2017-04-24 01:46:27 +03:00
parent dba0d47973
commit e70faf1016
15 changed files with 23 additions and 21 deletions

View file

@ -107,7 +107,7 @@ add_openmw_dir (mwmp\\processors\\actor ProcessorActorAnimFlags ProcessorActorAn
add_openmw_dir (mwmp\\processors\\player ProcessorChatMessage ProcessorGameConsole ProcessorGameTime ProcessorGUIMessageBox add_openmw_dir (mwmp\\processors\\player ProcessorChatMessage ProcessorGameConsole ProcessorGameTime ProcessorGUIMessageBox
ProcessorHandshake ProcessorPlayerAttack ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerCellChange ProcessorHandshake ProcessorPlayerAttack ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerCellChange
ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDrawState ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerAnimFlags
ProcessorPlayerDynamicStats ProcessorPlayerEquipment ProcessorPlayerInventory ProcessorPlayerJournal ProcessorPlayerDynamicStats ProcessorPlayerEquipment ProcessorPlayerInventory ProcessorPlayerJournal
ProcessorPlayerLevel ProcessorPlayerPos ProcessorPlayerResurrect ProcessorPlayerSkill ProcessorPlayerSpellbook ProcessorPlayerLevel ProcessorPlayerPos ProcessorPlayerResurrect ProcessorPlayerSkill ProcessorPlayerSpellbook
ProcessorUserDisconnected ProcessorUserMyID ProcessorUserDisconnected ProcessorUserMyID

View file

@ -19,7 +19,7 @@
#include "processors/player/ProcessorPlayerDynamicStats.hpp" #include "processors/player/ProcessorPlayerDynamicStats.hpp"
#include "processors/player/ProcessorPlayerDeath.hpp" #include "processors/player/ProcessorPlayerDeath.hpp"
#include "processors/player/ProcessorPlayerResurrect.hpp" #include "processors/player/ProcessorPlayerResurrect.hpp"
#include "processors/player/ProcessorPlayerDrawState.hpp" #include "processors/player/ProcessorPlayerAnimFlags.hpp"
#include "processors/player/ProcessorChatMessage.hpp" #include "processors/player/ProcessorChatMessage.hpp"
#include "processors/player/ProcessorPlayerCharGen.hpp" #include "processors/player/ProcessorPlayerCharGen.hpp"
#include "processors/player/ProcessorGUIMessageBox.hpp" #include "processors/player/ProcessorGUIMessageBox.hpp"
@ -76,7 +76,7 @@ void ProcessorInitializer()
PlayerProcessor::AddProcessor(new ProcessorPlayerDynamicStats()); PlayerProcessor::AddProcessor(new ProcessorPlayerDynamicStats());
PlayerProcessor::AddProcessor(new ProcessorPlayerDeath()); PlayerProcessor::AddProcessor(new ProcessorPlayerDeath());
PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect()); PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect());
PlayerProcessor::AddProcessor(new ProcessorPlayerDrawState()); PlayerProcessor::AddProcessor(new ProcessorPlayerAnimFlags());
PlayerProcessor::AddProcessor(new ProcessorChatMessage()); PlayerProcessor::AddProcessor(new ProcessorChatMessage());
PlayerProcessor::AddProcessor(new ProcessorPlayerCharGen()); PlayerProcessor::AddProcessor(new ProcessorPlayerCharGen());
PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox()); PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox());

View file

@ -22,7 +22,8 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player) virtual void Do(PlayerPacket &packet, BasePlayer *player)
{ {
Main::get().getGUIController()->printChatMessage(player->chatMessage); if (player != 0)
Main::get().getGUIController()->printChatMessage(player->chatMessage);
} }
}; };
} }

View file

@ -2,18 +2,18 @@
// Created by koncord on 16.04.17. // Created by koncord on 16.04.17.
// //
#ifndef OPENMW_PROCESSORPLAYERDRAWSTATE_HPP #ifndef OPENMW_PROCESSORPLAYERANIMFLAGS_HPP
#define OPENMW_PROCESSORPLAYERDRAWSTATE_HPP #define OPENMW_PROCESSORPLAYERANIMFLAGS_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp" #include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp namespace mwmp
{ {
class ProcessorPlayerDrawState : public PlayerProcessor class ProcessorPlayerAnimFlags : public PlayerProcessor
{ {
public: public:
ProcessorPlayerDrawState() ProcessorPlayerAnimFlags()
{ {
BPP_INIT(ID_PLAYER_ANIM_FLAGS) BPP_INIT(ID_PLAYER_ANIM_FLAGS)
} }
@ -25,11 +25,11 @@ namespace mwmp
if(isRequest()) if(isRequest())
static_cast<LocalPlayer *>(player)->updateAnimFlags(true); static_cast<LocalPlayer *>(player)->updateAnimFlags(true);
} }
else else if (player != 0)
static_cast<DedicatedPlayer *>(player)->updateAnimFlags(); static_cast<DedicatedPlayer *>(player)->updateAnimFlags();
} }
}; };
} }
#endif //OPENMW_PROCESSORPLAYERDRAWSTATE_HPP #endif //OPENMW_PROCESSORPLAYERANIMFLAGS_HPP

View file

@ -27,7 +27,8 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player) virtual void Do(PlayerPacket &packet, BasePlayer *player)
{ {
Main::get().getMechanicsHelper()->processAttack(player->attack, static_cast<DedicatedPlayer*>(player)->getPtr()); if (player != 0)
Main::get().getMechanicsHelper()->processAttack(player->attack, static_cast<DedicatedPlayer*>(player)->getPtr());
} }
}; };
} }

View file

@ -29,7 +29,7 @@ namespace mwmp
else else
static_cast<LocalPlayer *>(player)->setAttributes(); static_cast<LocalPlayer *>(player)->setAttributes();
} }
else else if (player != 0)
{ {
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr(); MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);

View file

@ -27,7 +27,7 @@ namespace mwmp
else else
static_cast<LocalPlayer *>(player)->setCell(); static_cast<LocalPlayer *>(player)->setCell();
} }
else else if (player != 0)
static_cast<DedicatedPlayer*>(player)->updateCell(); static_cast<DedicatedPlayer*>(player)->updateCell();
} }
}; };

View file

@ -33,7 +33,7 @@ namespace mwmp
packet.setPlayer(player); packet.setPlayer(player);
packet.Send(serverAddr); packet.Send(serverAddr);
} }
else else if (player != 0)
{ {
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str()); LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());

View file

@ -27,7 +27,7 @@ namespace mwmp
else else
static_cast<LocalPlayer *>(player)->setDynamicStats(); static_cast<LocalPlayer *>(player)->setDynamicStats();
} }
else else if (player != 0)
{ {
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer*>(player)->getPtr(); MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer*>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);

View file

@ -27,7 +27,7 @@ namespace mwmp
else else
static_cast<LocalPlayer*>(player)->setEquipment(); static_cast<LocalPlayer*>(player)->setEquipment();
} }
else else if (player != 0)
static_cast<DedicatedPlayer*>(player)->updateEquipment(); static_cast<DedicatedPlayer*>(player)->updateEquipment();
} }
}; };

View file

@ -27,7 +27,7 @@ namespace mwmp
else else
static_cast<LocalPlayer *>(player)->setLevel(); static_cast<LocalPlayer *>(player)->setLevel();
} }
else else if (player != 0)
{ {
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr(); MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);

View file

@ -31,7 +31,7 @@ namespace mwmp
else else
static_cast<LocalPlayer*>(player)->updatePosition(true); static_cast<LocalPlayer*>(player)->updatePosition(true);
} }
else // dedicated player else if (player != 0) // dedicated player
static_cast<DedicatedPlayer*>(player)->updateMarker(); static_cast<DedicatedPlayer*>(player)->updateMarker();
} }
}; };

View file

@ -43,7 +43,7 @@ namespace mwmp
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player); Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr); Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_STATS_DYNAMIC)->Send(serverAddr);
} }
else else if (player != 0)
{ {
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str()); LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());

View file

@ -27,7 +27,7 @@ namespace mwmp
else else
static_cast<LocalPlayer *>(player)->setSkills(); static_cast<LocalPlayer *>(player)->setSkills();
} }
else else if (player != 0)
{ {
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr(); MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);

View file

@ -24,7 +24,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
MWBase::Environment::get().getStateManager()->requestQuit(); MWBase::Environment::get().getStateManager()->requestQuit();
else else if (player != 0)
PlayerList::disconnectPlayer(guid); PlayerList::disconnectPlayer(guid);
} }
}; };