Add script functions for saving and loading non-custom player classes

coverity_scan^2
David Cernat 8 years ago
parent 7bb6020e51
commit 00e7810428

@ -63,7 +63,7 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept
if (player->Npc()->mRace == race)
return;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Seting race for %s: %s -> %s",
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Setting race for %s: %s -> %s",
player->Npc()->mName.c_str(),
player->Npc()->mRace.c_str(),
race);
@ -79,6 +79,30 @@ const char *ScriptFunctions::GetRace(unsigned short pid) noexcept
return player->Npc()->mRace.c_str();
}
void ScriptFunctions::SetClass(unsigned short pid, const char *className) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
if (player->Npc()->mClass == className)
return;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Setting class for %s: %s -> %s",
player->Npc()->mName.c_str(),
player->Npc()->mClass.c_str(),
className);
player->Npc()->mClass = className;
}
const char *ScriptFunctions::GetClass(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->Npc()->mClass.c_str();
}
void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept
{
Player *player;

@ -63,6 +63,9 @@ public:
static void SetRace(unsigned short pid, const char *race) noexcept;
static const char *GetRace(unsigned short pid) noexcept;
static void SetClass(unsigned short pid, const char *name) noexcept;
static const char *GetClass(unsigned short pid) noexcept;
static void SetHead(unsigned short pid, const char *head) noexcept;
static const char *GetHead(unsigned short pid) noexcept;
@ -197,6 +200,9 @@ public:
{"GetRace", ScriptFunctions::GetRace},
{"SetRace", ScriptFunctions::SetRace},
{"SetClass", ScriptFunctions::SetClass},
{"GetClass", ScriptFunctions::GetClass},
{"GetHead", ScriptFunctions::GetHead},
{"SetHead", ScriptFunctions::SetHead},
@ -209,10 +215,10 @@ public:
{"GetBirthsign", ScriptFunctions::GetBirthsign},
{"SetBirthsign", ScriptFunctions::SetBirthsign},
{"GetAttributeId", ScriptFunctions::GetAttributeId},
{"GetSkillId", ScriptFunctions::GetSkillId},
{"GetAttributeName", ScriptFunctions::GetAttributeName},
{"GetSkillName", ScriptFunctions::GetSkillName},
{"GetAttributeId", ScriptFunctions::GetAttributeId},
{"GetSkillId", ScriptFunctions::GetSkillId},
{"GetAttributeName", ScriptFunctions::GetAttributeName},
{"GetSkillName", ScriptFunctions::GetSkillName},
{"GetAttribute", ScriptFunctions::GetAttribute},
{"SetAttribute", ScriptFunctions::SetAttribute},
@ -238,8 +244,6 @@ public:
{"SetCurrentFatigue", ScriptFunctions::SetCurrentFatigue},
{"GetCurrentFatigue", ScriptFunctions::GetCurrentFatigue},
// {"SetClass", ScriptFunctions::SetClass},
// {"GetClass", ScriptFunctions::GetClass},
{"GetIncreaseSkill", ScriptFunctions::GetIncreaseSkill},
{"SetIncreaseSkill", ScriptFunctions::SetIncreaseSkill},

@ -54,6 +54,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id)
dedic_pl.mRace = _player->Npc()->mRace;
dedic_pl.mHead = _player->Npc()->mHead;
dedic_pl.mHair = _player->Npc()->mHair;
dedic_pl.mClass = _player->Npc()->mClass;
dedic_pl.mName = _player->Npc()->mName;
dedic_pl.mFlags = _player->Npc()->mFlags;

@ -579,5 +579,8 @@ void LocalPlayer::updateChar()
Npc()->mHead,
Npc()->mHair
);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(Npc()->mClass);
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
}

Loading…
Cancel
Save