1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 14:23:53 +00:00

store created character classes as dynamic records

This commit is contained in:
greye 2012-11-07 17:49:45 +04:00
parent 78740306db
commit 9ab2c16055
5 changed files with 12 additions and 20 deletions

View file

@ -559,9 +559,12 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
klass.mData.mSkills[i][1] = majorSkills[i]; klass.mData.mSkills[i][1] = majorSkills[i];
klass.mData.mSkills[i][0] = minorSkills[i]; klass.mData.mSkills[i][0] = minorSkills[i];
} }
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); std::pair<std::string, const ESM::Class *> res =
mPlayerClass = klass; MWBase::Environment::get().getWorld()->createRecord(klass);
mWM->setPlayerClass(klass);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(*res.second);
mPlayerClass = *res.second;
mWM->setPlayerClass(*res.second);
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0; mCreateClassDialog = 0;

View file

@ -83,7 +83,6 @@ WindowManager::WindowManager(
, mSpellCreationDialog(NULL) , mSpellCreationDialog(NULL)
, mEnchantingDialog(NULL) , mEnchantingDialog(NULL)
, mTrainingWindow(NULL) , mTrainingWindow(NULL)
, mPlayerClass()
, mPlayerName() , mPlayerName()
, mPlayerRaceId() , mPlayerRaceId()
, mPlayerAttributes() , mPlayerAttributes()
@ -499,8 +498,7 @@ void WindowManager::setValue (const std::string& id, int value)
void WindowManager::setPlayerClass (const ESM::Class &class_) void WindowManager::setPlayerClass (const ESM::Class &class_)
{ {
mPlayerClass = class_; mStatsWindow->setValue("class", class_.mName);
mStatsWindow->setValue("class", mPlayerClass.mName);
} }
void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) void WindowManager::configureSkills (const SkillList& major, const SkillList& minor)

View file

@ -261,7 +261,6 @@ namespace MWGui
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
// Various stats about player as needed by window manager // Various stats about player as needed by window manager
ESM::Class mPlayerClass;
std::string mPlayerName; std::string mPlayerName;
std::string mPlayerRaceId; std::string mPlayerRaceId;
std::map<int, MWMechanics::Stat<int> > mPlayerAttributes; std::map<int, MWMechanics::Stat<int> > mPlayerAttributes;

View file

@ -26,8 +26,7 @@ namespace MWWorld
float* playerPos = mPlayer.mData.getPosition().pos; float* playerPos = mPlayer.mData.getPosition().pos;
playerPos[0] = playerPos[1] = playerPos[2] = 0; playerPos[0] = playerPos[1] = playerPos[2] = 0;
/// \todo Do not make a copy of classes defined in esm/p records. mClass = world.getStore().get<ESM::Class>().find (player->mClass);
mClass = new ESM::Class (*world.getStore().get<ESM::Class>().find (player->mClass));
} }
Player::~Player() Player::~Player()
@ -35,13 +34,6 @@ namespace MWWorld
delete mClass; delete mClass;
} }
void Player::setClass (const ESM::Class& class_)
{
ESM::Class *new_class = new ESM::Class (class_);
delete mClass;
mClass = new_class;
}
void Player::setDrawState (MWMechanics::DrawState_ state) void Player::setDrawState (MWMechanics::DrawState_ state)
{ {
MWWorld::Ptr ptr = getPlayer(); MWWorld::Ptr ptr = getPlayer();

View file

@ -1,8 +1,6 @@
#ifndef GAME_MWWORLD_PLAYER_H #ifndef GAME_MWWORLD_PLAYER_H
#define GAME_MWWORLD_PLAYER_H #define GAME_MWWORLD_PLAYER_H
#include "OgreCamera.h"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -27,7 +25,7 @@ namespace MWWorld
bool mMale; bool mMale;
std::string mRace; std::string mRace;
std::string mBirthsign; std::string mBirthsign;
ESM::Class *mClass; const ESM::Class *mClass;
bool mAutoMove; bool mAutoMove;
int mForwardBackward; int mForwardBackward;
public: public:
@ -67,7 +65,9 @@ namespace MWWorld
mBirthsign = birthsign; mBirthsign = birthsign;
} }
void setClass (const ESM::Class& class_); void setClass (const ESM::Class& class_) {
mClass = &class_;
}
void setDrawState (MWMechanics::DrawState_ state); void setDrawState (MWMechanics::DrawState_ state);