Skip to content

Commit c58d499

Browse files
committedFeb 17, 2015
SAO: re-add old ActiveObjectTypes for a future migration layer
1 parent f8d5af7 commit c58d499

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed
 

Diff for: ‎src/activeobject.h

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ enum ActiveObjectType {
2727
ACTIVEOBJECT_TYPE_INVALID = 0,
2828
ACTIVEOBJECT_TYPE_TEST = 1,
2929
ACTIVEOBJECT_TYPE_ITEM = 2,
30+
// Compat layer, migrating objects from 0.3 to 0.4+
31+
ACTIVEOBJECT_TYPE_RAT = 3,
32+
ACTIVEOBJECT_TYPE_OERKKI1 = 4,
33+
ACTIVEOBJECT_TYPE_FIREFLY = 5,
34+
ACTIVEOBJECT_TYPE_MOBV2 = 6,
3035
ACTIVEOBJECT_TYPE_LUAENTITY = 7,
3136
// Special type, not stored as a static object
3237
ACTIVEOBJECT_TYPE_PLAYER = 100,

Diff for: ‎src/clientobject.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ ClientActiveObject::~ClientActiveObject()
3939
removeFromScene(true);
4040
}
4141

42-
ClientActiveObject* ClientActiveObject::create(u8 type, IGameDef *gamedef,
43-
ClientEnvironment *env)
42+
ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
43+
IGameDef *gamedef, ClientEnvironment *env)
4444
{
4545
// Find factory function
4646
std::map<u16, Factory>::iterator n;
4747
n = m_types.find(type);
48-
if(n == m_types.end())
49-
{
48+
if(n == m_types.end()) {
5049
// If factory is not found, just return.
5150
dstream<<"WARNING: ClientActiveObject: No factory for type="
5251
<<(int)type<<std::endl;

Diff for: ‎src/clientobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ClientActiveObject : public ActiveObject
8686
virtual void initialize(const std::string &data){}
8787

8888
// Create a certain type of ClientActiveObject
89-
static ClientActiveObject* create(u8 type, IGameDef *gamedef,
89+
static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef,
9090
ClientEnvironment *env);
9191

9292
// If returns true, punch will not be sent to the server

Diff for: ‎src/environment.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
17001700
StaticObject &s_obj = *i;
17011701
// Create an active object from the data
17021702
ServerActiveObject *obj = ServerActiveObject::create
1703-
(s_obj.type, this, 0, s_obj.pos, s_obj.data);
1703+
((ActiveObjectType) s_obj.type, this, 0, s_obj.pos, s_obj.data);
17041704
// If couldn't create object, store static data back.
17051705
if(obj==NULL)
17061706
{
@@ -2488,7 +2488,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
24882488
const std::string &init_data)
24892489
{
24902490
ClientActiveObject* obj =
2491-
ClientActiveObject::create(type, m_gamedef, this);
2491+
ClientActiveObject::create((ActiveObjectType) type, m_gamedef, this);
24922492
if(obj == NULL)
24932493
{
24942494
infostream<<"ClientEnvironment::addActiveObject(): "

Diff for: ‎src/serverobject.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ ServerActiveObject::~ServerActiveObject()
3838
{
3939
}
4040

41-
ServerActiveObject* ServerActiveObject::create(u8 type,
41+
ServerActiveObject* ServerActiveObject::create(ActiveObjectType type,
4242
ServerEnvironment *env, u16 id, v3f pos,
4343
const std::string &data)
4444
{
4545
// Find factory function
4646
std::map<u16, Factory>::iterator n;
4747
n = m_types.find(type);
48-
if(n == m_types.end())
49-
{
48+
if(n == m_types.end()) {
5049
// If factory is not found, just return.
5150
dstream<<"WARNING: ServerActiveObject: No factory for type="
5251
<<type<<std::endl;

Diff for: ‎src/serverobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ServerActiveObject : public ActiveObject
7171
{ return true; }
7272

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

0 commit comments

Comments
 (0)
Please sign in to comment.