1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-01 00:32:52 +00:00

added missing record classes

This commit is contained in:
Marc Zinnschlag 2010-08-03 15:24:44 +02:00
parent 0851044fa6
commit f50ced4616
36 changed files with 646 additions and 110 deletions

View File

@ -98,6 +98,21 @@ set(GAMECLASS
mwclass/npc.cpp mwclass/npc.cpp
mwclass/weapon.cpp mwclass/weapon.cpp
mwclass/armor.cpp mwclass/armor.cpp
mwclass/potion.cpp
mwclass/apparatus.cpp
mwclass/book.cpp
mwclass/clothing.cpp
mwclass/container.cpp
mwclass/door.cpp
mwclass/ingredient.cpp
mwclass/creaturelevlist.cpp
mwclass/itemlevlist.cpp
mwclass/light.cpp
mwclass/lockpick.cpp
mwclass/misc.cpp
mwclass/probe.cpp
mwclass/repair.cpp
mwclass/static.cpp
) )
set(GAMECLASS_HEADER set(GAMECLASS_HEADER
mwclass/classes.hpp mwclass/classes.hpp
@ -106,6 +121,21 @@ set(GAMECLASS_HEADER
mwclass/npc.hpp mwclass/npc.hpp
mwclass/weapon.hpp mwclass/weapon.hpp
mwclass/armor.hpp mwclass/armor.hpp
mwclass/potion.hpp
mwclass/apparatus.hpp
mwclass/book.hpp
mwclass/clothing.hpp
mwclass/container.hpp
mwclass/door.hpp
mwclass/ingredient.hpp
mwclass/creaturelevlist.hpp
mwclass/itemlevlist.hpp
mwclass/light.hpp
mwclass/lockpick.hpp
mwclass/misc.hpp
mwclass/probe.hpp
mwclass/repair.hpp
mwclass/static.hpp
) )
source_group(apps\\openmw\\mwclass FILES ${GAMECLASS} ${GAMECLASS_HEADER}) source_group(apps\\openmw\\mwclass FILES ${GAMECLASS} ${GAMECLASS_HEADER})

View File

@ -0,0 +1,14 @@
#include "apparatus.hpp"
#include <components/esm/loadappa.hpp>
namespace MWClass
{
void Apparatus::registerSelf()
{
boost::shared_ptr<Class> instance (new Apparatus);
registerClass (typeid (ESM::Apparatus).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_APPARATUS_H
#define GAME_MWCLASS_APPARATUS_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Apparatus : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "book.hpp"
#include <components/esm/loadbook.hpp>
namespace MWClass
{
void Book::registerSelf()
{
boost::shared_ptr<Class> instance (new Book);
registerClass (typeid (ESM::Book).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_BOOK_H
#define GAME_MWCLASS_BOOK_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Book : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -6,6 +6,21 @@
#include "npc.hpp" #include "npc.hpp"
#include "weapon.hpp" #include "weapon.hpp"
#include "armor.hpp" #include "armor.hpp"
#include "potion.hpp"
#include "apparatus.hpp"
#include "book.hpp"
#include "clothing.hpp"
#include "container.hpp"
#include "door.hpp"
#include "ingredient.hpp"
#include "creaturelevlist.hpp"
#include "itemlevlist.hpp"
#include "light.hpp"
#include "lockpick.hpp"
#include "misc.hpp"
#include "probe.hpp"
#include "repair.hpp"
#include "static.hpp"
namespace MWClass namespace MWClass
{ {
@ -16,5 +31,20 @@ namespace MWClass
Npc::registerSelf(); Npc::registerSelf();
Weapon::registerSelf(); Weapon::registerSelf();
Armor::registerSelf(); Armor::registerSelf();
Potion::registerSelf();
Apparatus::registerSelf();
Book::registerSelf();
Clothing::registerSelf();
Container::registerSelf();
Door::registerSelf();
Ingredient::registerSelf();
CreatureLevList::registerSelf();
ItemLevList::registerSelf();
Light::registerSelf();
Lockpick::registerSelf();
Misc::registerSelf();
Probe::registerSelf();
Repair::registerSelf();
Static::registerSelf();
} }
} }

View File

@ -0,0 +1,14 @@
#include "clothing.hpp"
#include <components/esm/loadclot.hpp>
namespace MWClass
{
void Clothing::registerSelf()
{
boost::shared_ptr<Class> instance (new Clothing);
registerClass (typeid (ESM::Clothing).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_CLOTHING_H
#define GAME_MWCLASS_CLOTHING_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Clothing : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "container.hpp"
#include <components/esm/loadcont.hpp>
namespace MWClass
{
void Container::registerSelf()
{
boost::shared_ptr<Class> instance (new Container);
registerClass (typeid (ESM::Container).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_CONTAINER_H
#define GAME_MWCLASS_CONTAINER_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Container : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "creaturelevlist.hpp"
#include <components/esm/loadlevlist.hpp>
namespace MWClass
{
void CreatureLevList::registerSelf()
{
boost::shared_ptr<Class> instance (new CreatureLevList);
registerClass (typeid (ESM::CreatureLevList).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_CREATURELEVLIST_H
#define GAME_MWCLASS_CREATURELEVLIST_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class CreatureLevList : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "door.hpp"
#include <components/esm/loaddoor.hpp>
namespace MWClass
{
void Door::registerSelf()
{
boost::shared_ptr<Class> instance (new Door);
registerClass (typeid (ESM::Door).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_DOOR_H
#define GAME_MWCLASS_DOOR_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Door : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "ingredient.hpp"
#include <components/esm/loadingr.hpp>
namespace MWClass
{
void Ingredient::registerSelf()
{
boost::shared_ptr<Class> instance (new Ingredient);
registerClass (typeid (ESM::Ingredient).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_INGREDIENT_H
#define GAME_MWCLASS_INGREDIENT_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Ingredient : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "itemlevlist.hpp"
#include <components/esm/loadlevlist.hpp>
namespace MWClass
{
void ItemLevList::registerSelf()
{
boost::shared_ptr<Class> instance (new ItemLevList);
registerClass (typeid (ESM::ItemLevList).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_ITEMLEVLIST_H
#define GAME_MWCLASS_ITEMLEVLIST_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class ItemLevList : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "light.hpp"
#include <components/esm/loadligh.hpp>
namespace MWClass
{
void Light::registerSelf()
{
boost::shared_ptr<Class> instance (new Light);
registerClass (typeid (ESM::Light).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_LIGHT_H
#define GAME_MWCLASS_LIGHT_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Light : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "lockpick.hpp"
#include <components/esm/loadlocks.hpp>
namespace MWClass
{
void Lockpick::registerSelf()
{
boost::shared_ptr<Class> instance (new Lockpick);
registerClass (typeid (ESM::Tool).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_LOCKPICK_H
#define GAME_MWCLASS_LOCKPICK_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Lockpick : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "misc.hpp"
#include <components/esm/loadmisc.hpp>
namespace MWClass
{
void Misc::registerSelf()
{
boost::shared_ptr<Class> instance (new Misc);
registerClass (typeid (ESM::Misc).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_MISC_H
#define GAME_MWCLASS_MISC_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Misc : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "potion.hpp"
#include <components/esm/loadalch.hpp>
namespace MWClass
{
void Potion::registerSelf()
{
boost::shared_ptr<Class> instance (new Potion);
registerClass (typeid (ESM::Potion).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_POTION_H
#define GAME_MWCLASS_POTION_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Potion : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "probe.hpp"
#include <components/esm/loadlocks.hpp>
namespace MWClass
{
void Probe::registerSelf()
{
boost::shared_ptr<Class> instance (new Probe);
registerClass (typeid (ESM::Probe).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_PROBE_H
#define GAME_MWCLASS_PROBE_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Probe : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "repair.hpp"
#include <components/esm/loadlocks.hpp>
namespace MWClass
{
void Repair::registerSelf()
{
boost::shared_ptr<Class> instance (new Repair);
registerClass (typeid (ESM::Repair).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_REPAIR_H
#define GAME_MWCLASS_REPAIR_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Repair : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -0,0 +1,14 @@
#include "static.hpp"
#include <components/esm/loadstat.hpp>
namespace MWClass
{
void Static::registerSelf()
{
boost::shared_ptr<Class> instance (new Static);
registerClass (typeid (ESM::Static).name(), instance);
}
}

View File

@ -0,0 +1,17 @@
#ifndef GAME_MWCLASS_STATIC_H
#define GAME_MWCLASS_STATIC_H
#include "../mwworld/class.hpp"
namespace MWClass
{
class Static : public MWWorld::Class
{
public:
static void registerSelf();
};
}
#endif

View File

@ -28,9 +28,9 @@ namespace
if (!iter->base->script.empty()) if (!iter->base->script.empty())
{ {
if (const ESM::Script *script = store.scripts.find (iter->base->script)) if (const ESM::Script *script = store.scripts.find (iter->base->script))
{ {
iter->mData.setLocals (*script); iter->mData.setLocals (*script);
scriptList.push_back ( scriptList.push_back (
std::make_pair (iter->base->script, MWWorld::Ptr (&*iter, cell))); std::make_pair (iter->base->script, MWWorld::Ptr (&*iter, cell)));
} }
@ -61,7 +61,7 @@ namespace MWWorld
listCellScripts (mStore, cell.repairs, mLocalScripts, &cell); listCellScripts (mStore, cell.repairs, mLocalScripts, &cell);
listCellScripts (mStore, cell.weapons, mLocalScripts, &cell); listCellScripts (mStore, cell.weapons, mLocalScripts, &cell);
} }
Ptr World::getPtr (const std::string& name, Ptr::CellStore& cell) Ptr World::getPtr (const std::string& name, Ptr::CellStore& cell)
{ {
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = cell.activators.find (name)) if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = cell.activators.find (name))
@ -69,68 +69,68 @@ namespace MWWorld
if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = cell.potions.find (name)) if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = cell.potions.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = cell.appas.find (name)) if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = cell.appas.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = cell.armors.find (name)) if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = cell.armors.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = cell.books.find (name)) if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = cell.books.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = cell.clothes.find (name)) if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = cell.clothes.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Container, RefData> *ref = cell.containers.find (name)) if (ESMS::LiveCellRef<ESM::Container, RefData> *ref = cell.containers.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref = cell.creatures.find (name)) if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref = cell.creatures.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = cell.doors.find (name)) if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = cell.doors.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref = cell.ingreds.find (name)) if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref = cell.ingreds.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::CreatureLevList, RefData> *ref = cell.creatureLists.find (name)) if (ESMS::LiveCellRef<ESM::CreatureLevList, RefData> *ref = cell.creatureLists.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::ItemLevList, RefData> *ref = cell.itemLists.find (name)) if (ESMS::LiveCellRef<ESM::ItemLevList, RefData> *ref = cell.itemLists.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = cell.lights.find (name)) if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = cell.lights.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name)) if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Misc, RefData> *ref = cell.miscItems.find (name)) if (ESMS::LiveCellRef<ESM::Misc, RefData> *ref = cell.miscItems.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name)) if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.probes.find (name)) if (ESMS::LiveCellRef<ESM::Probe, RefData> *ref = cell.probes.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.repairs.find (name)) if (ESMS::LiveCellRef<ESM::Repair, RefData> *ref = cell.repairs.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name)) if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = cell.weapons.find (name)) if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = cell.weapons.find (name))
return Ptr (ref, &cell); return Ptr (ref, &cell);
return Ptr(); return Ptr();
} }
MWRender::CellRender *World::searchRender (Ptr::CellStore *store) MWRender::CellRender *World::searchRender (Ptr::CellStore *store)
{ {
CellRenderCollection::iterator iter = mActiveCells.find (store); CellRenderCollection::iterator iter = mActiveCells.find (store);
if (iter!=mActiveCells.end()) if (iter!=mActiveCells.end())
{ {
return iter->second; return iter->second;
@ -141,10 +141,10 @@ namespace MWWorld
if (iter!=mBufferedCells.end()) if (iter!=mBufferedCells.end())
return iter->second; return iter->second;
} }
return 0; return 0;
} }
int World::getDaysPerMonth (int month) const int World::getDaysPerMonth (int month) const
{ {
switch (month) switch (month)
@ -162,84 +162,84 @@ namespace MWWorld
case 10: return 30; case 10: return 30;
case 11: return 31; case 11: return 31;
} }
throw std::runtime_error ("month out of range"); throw std::runtime_error ("month out of range");
} }
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir, World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
const std::string& master, bool newGame, Environment& environment) const std::string& master, bool newGame, Environment& environment)
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0), : mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
mSky (false), mCellChanged (false), mEnvironment (environment) mSky (false), mCellChanged (false), mEnvironment (environment)
{ {
boost::filesystem::path masterPath (dataDir); boost::filesystem::path masterPath (dataDir);
masterPath /= master; masterPath /= master;
std::cout << "Loading ESM " << masterPath.string() << "\n"; std::cout << "Loading ESM " << masterPath.string() << "\n";
// This parses the ESM file and loads a sample cell // This parses the ESM file and loads a sample cell
mEsm.open (masterPath.file_string()); mEsm.open (masterPath.file_string());
mStore.load (mEsm); mStore.load (mEsm);
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player")); mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"));
// global variables // global variables
mGlobalVariables = new Globals (mStore); mGlobalVariables = new Globals (mStore);
if (newGame) if (newGame)
{ {
// set new game mark // set new game mark
mGlobalVariables->setInt ("chargenstate", 1); mGlobalVariables->setInt ("chargenstate", 1);
} }
mSkyManager = mSkyManager =
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera()); MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera());
} }
World::~World() World::~World()
{ {
for (CellRenderCollection::iterator iter (mActiveCells.begin()); for (CellRenderCollection::iterator iter (mActiveCells.begin());
iter!=mActiveCells.end(); ++iter) iter!=mActiveCells.end(); ++iter)
delete iter->second; delete iter->second;
for (CellRenderCollection::iterator iter (mBufferedCells.begin()); for (CellRenderCollection::iterator iter (mBufferedCells.begin());
iter!=mBufferedCells.end(); ++iter) iter!=mBufferedCells.end(); ++iter)
delete iter->second; delete iter->second;
delete mPlayerPos; delete mPlayerPos;
delete mSkyManager; delete mSkyManager;
delete mGlobalVariables; delete mGlobalVariables;
} }
MWRender::PlayerPos& World::getPlayerPos() MWRender::PlayerPos& World::getPlayerPos()
{ {
return *mPlayerPos; return *mPlayerPos;
} }
ESMS::ESMStore& World::getStore() ESMS::ESMStore& World::getStore()
{ {
return mStore; return mStore;
} }
const World::ScriptList& World::getLocalScripts() const const World::ScriptList& World::getLocalScripts() const
{ {
return mLocalScripts; return mLocalScripts;
} }
bool World::hasCellChanged() const bool World::hasCellChanged() const
{ {
return mCellChanged; return mCellChanged;
} }
Globals::Data& World::getGlobalVariable (const std::string& name) Globals::Data& World::getGlobalVariable (const std::string& name)
{ {
return (*mGlobalVariables)[name]; return (*mGlobalVariables)[name];
} }
char World::getGlobalVariableType (const std::string& name) const char World::getGlobalVariableType (const std::string& name) const
{ {
return mGlobalVariables->getType (name); return mGlobalVariables->getType (name);
} }
Ptr World::getPtr (const std::string& name, bool activeOnly) Ptr World::getPtr (const std::string& name, bool activeOnly)
{ {
// the player is always in an active cell. // the player is always in an active cell.
@ -247,35 +247,35 @@ namespace MWWorld
{ {
return mPlayerPos->getPlayer(); return mPlayerPos->getPlayer();
} }
// active cells // active cells
for (CellRenderCollection::iterator iter (mActiveCells.begin()); for (CellRenderCollection::iterator iter (mActiveCells.begin());
iter!=mActiveCells.end(); ++iter) iter!=mActiveCells.end(); ++iter)
{ {
Ptr ptr = getPtr (name, *iter->first); Ptr ptr = getPtr (name, *iter->first);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
return ptr; return ptr;
} }
if (!activeOnly) if (!activeOnly)
{ {
// TODO: inactive cells // TODO: inactive cells
} }
throw std::runtime_error ("unknown ID: " + name); throw std::runtime_error ("unknown ID: " + name);
} }
void World::enable (Ptr reference) void World::enable (Ptr reference)
{ {
if (!reference.getRefData().isEnabled()) if (!reference.getRefData().isEnabled())
{ {
reference.getRefData().enable(); reference.getRefData().enable();
if (MWRender::CellRender *render = searchRender (reference.getCell())) if (MWRender::CellRender *render = searchRender (reference.getCell()))
{ {
render->enable (reference.getRefData().getHandle()); render->enable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() && if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) || (reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>))) reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
@ -285,69 +285,69 @@ namespace MWWorld
} }
} }
} }
void World::disable (Ptr reference) void World::disable (Ptr reference)
{ {
if (!reference.getRefData().isEnabled()) if (!reference.getRefData().isEnabled())
{ {
reference.getRefData().enable(); reference.getRefData().enable();
if (MWRender::CellRender *render = searchRender (reference.getCell())) if (MWRender::CellRender *render = searchRender (reference.getCell()))
{ {
render->disable (reference.getRefData().getHandle()); render->disable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() && if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) || (reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>))) reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
{ {
mEnvironment.mMechanicsManager->removeActor (reference); mEnvironment.mMechanicsManager->removeActor (reference);
} }
} }
} }
} }
void World::advanceTime (double hours) void World::advanceTime (double hours)
{ {
hours += mGlobalVariables->getFloat ("gamehour"); hours += mGlobalVariables->getFloat ("gamehour");
setHour (hours); setHour (hours);
int days = hours / 24; int days = hours / 24;
if (days>0) if (days>0)
mGlobalVariables->setInt ("dayspassed", days + mGlobalVariables->getInt ("dayspassed")); mGlobalVariables->setInt ("dayspassed", days + mGlobalVariables->getInt ("dayspassed"));
} }
void World::setHour (double hour) void World::setHour (double hour)
{ {
if (hour<0) if (hour<0)
hour = 0; hour = 0;
int days = hour / 24; int days = hour / 24;
hour = std::fmod (hour, 24); hour = std::fmod (hour, 24);
mGlobalVariables->setFloat ("gamehour", hour); mGlobalVariables->setFloat ("gamehour", hour);
mSkyManager->setHour (hour); mSkyManager->setHour (hour);
if (days>0) if (days>0)
setDay (days + mGlobalVariables->getInt ("day")); setDay (days + mGlobalVariables->getInt ("day"));
} }
void World::setDay (int day) void World::setDay (int day)
{ {
if (day<0) if (day<0)
day = 0; day = 0;
int month = mGlobalVariables->getInt ("month"); int month = mGlobalVariables->getInt ("month");
while (true) while (true)
{ {
int days = getDaysPerMonth (month); int days = getDaysPerMonth (month);
if (day<days) if (day<days)
break; break;
if (month<11) if (month<11)
{ {
++month; ++month;
@ -357,37 +357,37 @@ namespace MWWorld
month = 0; month = 0;
mGlobalVariables->setInt ("year", mGlobalVariables->getInt ("year")+1); mGlobalVariables->setInt ("year", mGlobalVariables->getInt ("year")+1);
} }
day -= days; day -= days;
} }
mGlobalVariables->setInt ("day", day); mGlobalVariables->setInt ("day", day);
mGlobalVariables->setInt ("month", month); mGlobalVariables->setInt ("month", month);
mSkyManager->setDate (day, month); mSkyManager->setDate (day, month);
} }
void World::setMonth (int month) void World::setMonth (int month)
{ {
if (month<0) if (month<0)
month = 0; month = 0;
int years = month / 12; int years = month / 12;
month = month % 12; month = month % 12;
int days = getDaysPerMonth (month); int days = getDaysPerMonth (month);
if (mGlobalVariables->getInt ("day")>=days) if (mGlobalVariables->getInt ("day")>=days)
mGlobalVariables->setInt ("day", days-1); mGlobalVariables->setInt ("day", days-1);
mGlobalVariables->setInt ("month", month); mGlobalVariables->setInt ("month", month);
if (years>0) if (years>0)
mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year")); mGlobalVariables->setInt ("year", years+mGlobalVariables->getInt ("year"));
mSkyManager->setDate (mGlobalVariables->getInt ("day"), month); mSkyManager->setDate (mGlobalVariables->getInt ("day"), month);
} }
void World::toggleSky() void World::toggleSky()
{ {
if (mSky) if (mSky)
@ -405,36 +405,36 @@ namespace MWWorld
mSkyManager->enable(); mSkyManager->enable();
} }
} }
int World::getMasserPhase() const int World::getMasserPhase() const
{ {
return mSkyManager->getMasserPhase(); return mSkyManager->getMasserPhase();
} }
int World::getSecundaPhase() const int World::getSecundaPhase() const
{ {
return mSkyManager->getSecundaPhase(); return mSkyManager->getSecundaPhase();
} }
void World::setMoonColour (bool red) void World::setMoonColour (bool red)
{ {
mSkyManager->setMoonColour (red); mSkyManager->setMoonColour (red);
} }
float World::getTimeScaleFactor() const float World::getTimeScaleFactor() const
{ {
return mGlobalVariables->getInt ("timescale"); return mGlobalVariables->getInt ("timescale");
} }
void World::changeCell (const std::string& cellName, const ESM::Position& position) void World::changeCell (const std::string& cellName, const ESM::Position& position)
{ {
// Load cell. // Load cell.
mInteriors[cellName].loadInt (cellName, mStore, mEsm); mInteriors[cellName].loadInt (cellName, mStore, mEsm);
Ptr::CellStore *cell = &mInteriors[cellName]; Ptr::CellStore *cell = &mInteriors[cellName];
// remove active // remove active
CellRenderCollection::iterator active = mActiveCells.begin(); CellRenderCollection::iterator active = mActiveCells.begin();
if (active!=mActiveCells.end()) if (active!=mActiveCells.end())
{ {
mEnvironment.mMechanicsManager->dropActors (active->first); mEnvironment.mMechanicsManager->dropActors (active->first);
@ -444,7 +444,7 @@ namespace MWWorld
} }
// register local scripts // register local scripts
mLocalScripts.clear(); // FIXME won't work with exteriors mLocalScripts.clear(); // FIXME won't work with exteriors
insertInteriorScripts (*cell); insertInteriorScripts (*cell);
// adjust player // adjust player
@ -458,11 +458,11 @@ namespace MWWorld
new MWRender::InteriorCellRender (*cell, mScene))); new MWRender::InteriorCellRender (*cell, mScene)));
if (result.second) if (result.second)
{ {
// Load the cell and insert it into the renderer // Load the cell and insert it into the renderer
result.first->second->show(); result.first->second->show();
} }
// Actors // Actors
mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer()); mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer());
mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer()); mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer());
@ -496,12 +496,12 @@ namespace MWWorld
// TODO set weather // TODO set weather
toggleSky(); toggleSky();
} }
mCellChanged = true; mCellChanged = true;
} }
void World::markCellAsUnchanged() void World::markCellAsUnchanged()
{ {
mCellChanged = false; mCellChanged = false;
} }
} }

View File

@ -50,5 +50,16 @@ struct Tool
icon = esm.getHNOString("ITEX"); icon = esm.getHNOString("ITEX");
} }
}; };
struct Probe : Tool
{
};
struct Repair : Tool
{
};
} }
#endif #endif

View File

@ -63,7 +63,7 @@ namespace ESMS
list.push_back(lr); list.push_back(lr);
} }
LiveRef *find (const std::string& name) LiveRef *find (const std::string& name)
{ {
for (typename std::list<LiveRef>::iterator iter (list.begin()); iter!=list.end(); ++iter) for (typename std::list<LiveRef>::iterator iter (list.begin()); iter!=list.end(); ++iter)
@ -71,9 +71,9 @@ namespace ESMS
if (iter->ref.refID==name) if (iter->ref.refID==name)
return &*iter; return &*iter;
} }
return 0; return 0;
} }
}; };
/// A storage struct for one single cell reference. /// A storage struct for one single cell reference.
@ -102,8 +102,8 @@ namespace ESMS
CellRefList<Tool, D> lockpicks; CellRefList<Tool, D> lockpicks;
CellRefList<Misc, D> miscItems; CellRefList<Misc, D> miscItems;
CellRefList<NPC, D> npcs; CellRefList<NPC, D> npcs;
CellRefList<Tool, D> probes; CellRefList<Probe, D> probes;
CellRefList<Tool, D> repairs; CellRefList<Repair, D> repairs;
CellRefList<Static, D> statics; CellRefList<Static, D> statics;
CellRefList<Weapon, D> weapons; CellRefList<Weapon, D> weapons;
@ -119,12 +119,12 @@ namespace ESMS
throw str_exception("Cell not found - " + name); throw str_exception("Cell not found - " + name);
loadRefs(store, esm); loadRefs(store, esm);
} }
/** Ditto for exterior cell. */ /** Ditto for exterior cell. */
void loadExt(int X, int Y, const ESMStore &store, ESMReader &esm) void loadExt(int X, int Y, const ESMStore &store, ESMReader &esm)
{ {
} }
private: private:
@ -176,7 +176,7 @@ namespace ESMS
} }
} }
} }
}; };
} }

View File

@ -55,10 +55,10 @@ namespace ESMS
RecListT<Misc> miscItems; RecListT<Misc> miscItems;
RecListT<NPC> npcs; RecListT<NPC> npcs;
RecListT<LoadNPCC> npcChange; RecListT<LoadNPCC> npcChange;
RecListT<Tool> probes; RecListT<Probe> probes;
RecListT<Race> races; RecListT<Race> races;
RecListT<Region> regions; RecListT<Region> regions;
RecListT<Tool> repairs; RecListT<Repair> repairs;
RecListT<SoundGenerator> soundGens; RecListT<SoundGenerator> soundGens;
RecListT<Sound> sounds; RecListT<Sound> sounds;
RecListT<Spell> spells; RecListT<Spell> spells;