forked from mirror/openmw-tes3mp
[Client] Add ability to look like a creature for the DedicatedPlayers
This commit is contained in:
parent
7af73782f3
commit
465a05bad0
2 changed files with 59 additions and 18 deletions
|
@ -68,10 +68,30 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Setting up character info");
|
LOG_APPEND(Log::LOG_INFO, "- Setting up character info");
|
||||||
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
DedicatedPlayer *dedicPlayer = players[guid];
|
||||||
|
|
||||||
|
ESM::Creature creature;
|
||||||
|
ESM::NPC npc;
|
||||||
|
if (!dedicPlayer->creatureModel.empty())
|
||||||
|
{
|
||||||
|
const ESM::Creature *tmpCreature = world->getStore().get<ESM::Creature>().search(dedicPlayer->creatureModel);
|
||||||
|
if(tmpCreature == 0)
|
||||||
|
{
|
||||||
|
dedicPlayer->creatureModel = "";
|
||||||
|
createPlayer(guid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
creature = *tmpCreature;
|
||||||
|
creature.mScript = "";
|
||||||
|
if(!dedicPlayer->useCreatureName)
|
||||||
|
creature.mName = dedicPlayer->npc.mName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MWWorld::Ptr player = world->getPlayerPtr();
|
MWWorld::Ptr player = world->getPlayerPtr();
|
||||||
|
|
||||||
ESM::NPC npc = *player.get<ESM::NPC>()->mBase;
|
npc = *player.get<ESM::NPC>()->mBase;
|
||||||
DedicatedPlayer *dedicPlayer = players[guid];
|
|
||||||
|
|
||||||
// To avoid freezes caused by invalid races, only set race if we find it
|
// To avoid freezes caused by invalid races, only set race if we find it
|
||||||
// on our client
|
// on our client
|
||||||
|
@ -83,12 +103,21 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
|
||||||
npc.mClass = dedicPlayer->npc.mClass;
|
npc.mClass = dedicPlayer->npc.mClass;
|
||||||
npc.mName = dedicPlayer->npc.mName;
|
npc.mName = dedicPlayer->npc.mName;
|
||||||
npc.mFlags = dedicPlayer->npc.mFlags;
|
npc.mFlags = dedicPlayer->npc.mFlags;
|
||||||
|
}
|
||||||
|
|
||||||
if (dedicPlayer->state == 0)
|
if (dedicPlayer->state == 0)
|
||||||
|
{
|
||||||
|
string recid;
|
||||||
|
if (!dedicPlayer->creatureModel.empty())
|
||||||
|
{
|
||||||
|
creature.mId = "Dedicated Player";
|
||||||
|
recid = world->createRecord(npc)->mId;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
npc.mId = "Dedicated Player";
|
npc.mId = "Dedicated Player";
|
||||||
|
recid = world->createRecord(creature)->mId;
|
||||||
std::string recid = world->createRecord(npc)->mId;
|
}
|
||||||
|
|
||||||
dedicPlayer->reference = new MWWorld::ManualRef(world->getStore(), recid, 1);
|
dedicPlayer->reference = new MWWorld::ManualRef(world->getStore(), recid, 1);
|
||||||
}
|
}
|
||||||
|
@ -115,12 +144,21 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Updating reference pointer for %s", dedicPlayer->npc.mName.c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Updating reference pointer for %s", dedicPlayer->npc.mName.c_str());
|
||||||
|
|
||||||
npc.mId = players[guid]->ptr.get<ESM::NPC>()->mBase->mId;
|
|
||||||
|
|
||||||
MWWorld::ESMStore *store = const_cast<MWWorld::ESMStore *>(&world->getStore());
|
MWWorld::ESMStore *store = const_cast<MWWorld::ESMStore *>(&world->getStore());
|
||||||
MWWorld::Store<ESM::NPC> *esm_store = const_cast<MWWorld::Store<ESM::NPC> *> (&store->get<ESM::NPC>());
|
|
||||||
|
|
||||||
|
if (!dedicPlayer->creatureModel.empty())
|
||||||
|
{
|
||||||
|
creature.mId = players[guid]->ptr.get<ESM::Creature>()->mBase->mId;
|
||||||
|
MWWorld::Store<ESM::Creature> *esm_store = const_cast<MWWorld::Store<ESM::Creature> *> (&store->get<ESM::Creature>());
|
||||||
|
esm_store->insert(creature);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
npc.mId = players[guid]->ptr.get<ESM::NPC>()->mBase->mId;
|
||||||
|
MWWorld::Store<ESM::NPC> *esm_store = const_cast<MWWorld::Store<ESM::NPC> *> (&store->get<ESM::NPC>());
|
||||||
esm_store->insert(npc);
|
esm_store->insert(npc);
|
||||||
|
}
|
||||||
|
|
||||||
// Disable Ptr to avoid graphical glitches caused by race changes
|
// Disable Ptr to avoid graphical glitches caused by race changes
|
||||||
world->disable(players[guid]->ptr);
|
world->disable(players[guid]->ptr);
|
||||||
|
|
|
@ -138,6 +138,7 @@ namespace mwmp
|
||||||
inventoryChanges.count = 0;
|
inventoryChanges.count = 0;
|
||||||
spellbookChanges.action = 0;
|
spellbookChanges.action = 0;
|
||||||
spellbookChanges.count = 0;
|
spellbookChanges.count = 0;
|
||||||
|
useCreatureName = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasePlayer()
|
BasePlayer()
|
||||||
|
@ -179,6 +180,8 @@ namespace mwmp
|
||||||
std::string chatMessage;
|
std::string chatMessage;
|
||||||
CGStage charGenStage;
|
CGStage charGenStage;
|
||||||
std::string passw;
|
std::string passw;
|
||||||
|
std::string creatureModel;
|
||||||
|
bool useCreatureName;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue