[General] Allow changes from PlayerBaseInfo without player stat reset

pull/404/head
David Cernat 7 years ago
parent 34893ff631
commit 73dea494c4

@ -440,13 +440,6 @@ void LocalPlayer::updateCell(bool forceUpdate)
}
}
void LocalPlayer::updateChar()
{
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(npc.mRace, npc.isMale(), npc.mHead, npc.mHair);
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(birthsign);
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
}
void LocalPlayer::updateEquipment(bool forceUpdate)
{
MWWorld::Ptr ptrPlayer = getPlayerPtr();
@ -838,6 +831,40 @@ void LocalPlayer::closeInventoryWindows()
MWBase::Environment::get().getWindowManager()->finishDragDrop();
}
void LocalPlayer::setCharacter()
{
MWBase::World *world = MWBase::Environment::get().getWorld();
// Ignore invalid races
if (world->getStore().get<ESM::Race>().search(npc.mRace) != 0)
{
MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(birthsign);
if (resetStats)
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(npc.mRace, npc.isMale(), npc.mHead, npc.mHair);
else
{
ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase;
player.mRace = npc.mRace;
player.mHead = npc.mHead;
player.mHair = npc.mHair;
player.setIsMale(npc.isMale());
world->createRecord(player);
MWBase::Environment::get().getMechanicsManager()->playerLoaded();
}
setEquipment();
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Character update was ignored due to invalid race %s", npc.mRace.c_str());
}
}
void LocalPlayer::setDynamicStats()
{
MWBase::World *world = MWBase::Environment::get().getWorld();

@ -33,7 +33,6 @@ namespace mwmp
void updateReputation(bool forceUpdate = false);
void updatePosition(bool forceUpdate = false);
void updateCell(bool forceUpdate = false);
void updateChar();
void updateEquipment(bool forceUpdate = false);
void updateInventory(bool forceUpdate = false);
void updateAttack();
@ -52,6 +51,7 @@ namespace mwmp
void closeInventoryWindows();
void setCharacter();
void setDynamicStats();
void setAttributes();
void setSkills();

@ -32,8 +32,8 @@ namespace mwmp
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Updating LocalPlayer");
static_cast<LocalPlayer*>(player)->updateChar();
LOG_APPEND(Log::LOG_INFO, "- Setting character for LocalPlayer");
static_cast<LocalPlayer*>(player)->setCharacter();
}
}
else

@ -225,6 +225,7 @@ namespace mwmp
spellbookChanges.action = 0;
spellbookChanges.count = 0;
displayCreatureName = false;
resetStats = false;
}
BasePlayer()
@ -285,6 +286,7 @@ namespace mwmp
std::string sound;
Animation animation;
bool resetStats;
float scale;
bool isWerewolf;

Loading…
Cancel
Save