mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 23:19:56 +00:00
29556a1802
A Warning indicates a potential problem in the content file(s) that the user told OpenMW to load. E.g. this might cause an object to not display at all or as intended, however the rest of the game will run fine. An Error, however, is more likely to be a bug with the engine itself - it means that basic assumptions have been violated and the engine might not run correctly anymore. The above mostly applies to errors/warnings during game-play; startup issues are handled differently: when a file is completely invalid/corrupted to the point that the engine can not start, that might cause messages that are worded as Error due to the severity of the issue but are not necessarily the engine's fault. Hopefully, being a little more consistent here will alleviate confusion among users as to when a log message should be reported and to whom.
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
#include "livecellref.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
#include <components/esm/objectstate.hpp>
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "ptr.hpp"
|
|
#include "class.hpp"
|
|
#include "esmstore.hpp"
|
|
|
|
MWWorld::LiveCellRefBase::LiveCellRefBase(const std::string& type, const ESM::CellRef &cref)
|
|
: mClass(&Class::get(type)), mRef(cref), mData(cref)
|
|
{
|
|
}
|
|
|
|
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
|
|
{
|
|
mRef = state.mRef;
|
|
mData = RefData (state, mData.isDeletedByContentFile());
|
|
|
|
Ptr ptr (this);
|
|
|
|
if (state.mHasLocals)
|
|
{
|
|
std::string scriptId = mClass->getScript (ptr);
|
|
// Make sure we still have a script. It could have been coming from a content file that is no longer active.
|
|
if (!scriptId.empty())
|
|
{
|
|
if (const ESM::Script* script = MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().search (scriptId))
|
|
{
|
|
try
|
|
{
|
|
mData.setLocals (*script);
|
|
mData.getLocals().read (state.mLocals, scriptId);
|
|
}
|
|
catch (const std::exception& exception)
|
|
{
|
|
std::cerr
|
|
<< "Error: failed to load state for local script " << scriptId
|
|
<< " because an exception has been thrown: " << exception.what()
|
|
<< std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
mClass->readAdditionalState (ptr, state);
|
|
}
|
|
|
|
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
|
|
{
|
|
mRef.writeState(state);
|
|
|
|
ConstPtr ptr (this);
|
|
|
|
mData.write (state, mClass->getScript (ptr));
|
|
|
|
mClass->writeAdditionalState (ptr, state);
|
|
}
|
|
|
|
bool MWWorld::LiveCellRefBase::checkStateImp (const ESM::ObjectState& state)
|
|
{
|
|
return true;
|
|
}
|