Skip to content

Commit

Permalink
SAO: re-add old ActiveObjectTypes for a future migration layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed Feb 17, 2015
1 parent f8d5af7 commit c58d499
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/activeobject.h
Expand Up @@ -27,6 +27,11 @@ enum ActiveObjectType {
ACTIVEOBJECT_TYPE_INVALID = 0,
ACTIVEOBJECT_TYPE_TEST = 1,
ACTIVEOBJECT_TYPE_ITEM = 2,
// Compat layer, migrating objects from 0.3 to 0.4+
ACTIVEOBJECT_TYPE_RAT = 3,
ACTIVEOBJECT_TYPE_OERKKI1 = 4,
ACTIVEOBJECT_TYPE_FIREFLY = 5,
ACTIVEOBJECT_TYPE_MOBV2 = 6,
ACTIVEOBJECT_TYPE_LUAENTITY = 7,
// Special type, not stored as a static object
ACTIVEOBJECT_TYPE_PLAYER = 100,
Expand Down
7 changes: 3 additions & 4 deletions src/clientobject.cpp
Expand Up @@ -39,14 +39,13 @@ ClientActiveObject::~ClientActiveObject()
removeFromScene(true);
}

ClientActiveObject* ClientActiveObject::create(u8 type, IGameDef *gamedef,
ClientEnvironment *env)
ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
IGameDef *gamedef, ClientEnvironment *env)
{
// Find factory function
std::map<u16, Factory>::iterator n;
n = m_types.find(type);
if(n == m_types.end())
{
if(n == m_types.end()) {
// If factory is not found, just return.
dstream<<"WARNING: ClientActiveObject: No factory for type="
<<(int)type<<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/clientobject.h
Expand Up @@ -86,7 +86,7 @@ class ClientActiveObject : public ActiveObject
virtual void initialize(const std::string &data){}

// Create a certain type of ClientActiveObject
static ClientActiveObject* create(u8 type, IGameDef *gamedef,
static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef,
ClientEnvironment *env);

// If returns true, punch will not be sent to the server
Expand Down
4 changes: 2 additions & 2 deletions src/environment.cpp
Expand Up @@ -1700,7 +1700,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
StaticObject &s_obj = *i;
// Create an active object from the data
ServerActiveObject *obj = ServerActiveObject::create
(s_obj.type, this, 0, s_obj.pos, s_obj.data);
((ActiveObjectType) s_obj.type, this, 0, s_obj.pos, s_obj.data);
// If couldn't create object, store static data back.
if(obj==NULL)
{
Expand Down Expand Up @@ -2488,7 +2488,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
const std::string &init_data)
{
ClientActiveObject* obj =
ClientActiveObject::create(type, m_gamedef, this);
ClientActiveObject::create((ActiveObjectType) type, m_gamedef, this);
if(obj == NULL)
{
infostream<<"ClientEnvironment::addActiveObject(): "
Expand Down
5 changes: 2 additions & 3 deletions src/serverobject.cpp
Expand Up @@ -38,15 +38,14 @@ ServerActiveObject::~ServerActiveObject()
{
}

ServerActiveObject* ServerActiveObject::create(u8 type,
ServerActiveObject* ServerActiveObject::create(ActiveObjectType type,
ServerEnvironment *env, u16 id, v3f pos,
const std::string &data)
{
// Find factory function
std::map<u16, Factory>::iterator n;
n = m_types.find(type);
if(n == m_types.end())
{
if(n == m_types.end()) {
// If factory is not found, just return.
dstream<<"WARNING: ServerActiveObject: No factory for type="
<<type<<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/serverobject.h
Expand Up @@ -71,7 +71,7 @@ class ServerActiveObject : public ActiveObject
{ return true; }

// Create a certain type of ServerActiveObject
static ServerActiveObject* create(u8 type,
static ServerActiveObject* create(ActiveObjectType type,
ServerEnvironment *env, u16 id, v3f pos,
const std::string &data);

Expand Down

0 comments on commit c58d499

Please sign in to comment.