[Client] Ignore ObjectSpawn packets trying to spawn non-actors

remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent d93b67ef21
commit c7bcf70c32

@ -402,41 +402,45 @@ void ObjectList::spawnObjects(MWWorld::CellStore* cellStore)
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), baseObject.refId, 1);
MWWorld::Ptr newPtr = ref.getPtr();
newPtr.getCellRef().setMpNum(baseObject.mpNum);
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
if (baseObject.isSummon)
if (newPtr.getClass().isActor())
{
MWWorld::Ptr masterPtr;
if (baseObject.master.isPlayer)
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
else
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
newPtr = MWBase::Environment::get().getWorld()->placeObject(newPtr, cellStore, baseObject.position);
MWMechanics::CreatureStats& creatureStats = newPtr.getClass().getCreatureStats(newPtr);
if (masterPtr)
if (baseObject.isSummon)
{
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
MWWorld::Ptr masterPtr;
MWMechanics::AiFollow package(masterPtr);
newPtr.getClass().getCreatureStats(newPtr).getAiSequence().stack(package, newPtr);
if (baseObject.master.isPlayer)
masterPtr = MechanicsHelper::getPlayerPtr(baseObject.master);
else
masterPtr = cellStore->searchExact(baseObject.master.refNum, baseObject.master.mpNum);
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
if (anim)
if (masterPtr)
{
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
.search("VFX_Summon_Start");
if (fx)
anim->addEffect("meshes\\" + fx->mModel, -1, false);
}
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor has master: %s", masterPtr.getCellRef().getRefId().c_str());
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
MWMechanics::AiFollow package(masterPtr);
creatureStats.getAiSequence().stack(package, newPtr);
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(newPtr);
if (anim)
{
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
.search("VFX_Summon_Start");
if (fx)
anim->addEffect("meshes\\" + fx->mModel, -1, false);
}
int creatureActorId = newPtr.getClass().getCreatureStats(newPtr).getActorId();
MWMechanics::CreatureStats& masterCreatureStats = masterPtr.getClass().getCreatureStats(masterPtr);
masterCreatureStats.setSummonedCreatureActorId(baseObject.refId, creatureActorId);
}
}
}
else
LOG_APPEND(Log::LOG_VERBOSE, "-- Cannot spawn non-actor object!");
}
else
LOG_APPEND(Log::LOG_VERBOSE, "-- Actor already existed!");

Loading…
Cancel
Save