@@ -35,54 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
35
35
36
36
std::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
37
37
38
- /*
39
- DummyLoadSAO
40
- */
41
-
42
- class DummyLoadSAO : public ServerActiveObject
43
- {
44
- public:
45
- DummyLoadSAO (ServerEnvironment *env, v3f pos, u8 type):
46
- ServerActiveObject (env, pos)
47
- {
48
- ServerActiveObject::registerType (type, create);
49
- }
50
- // Pretend to be the test object (to fool the client)
51
- u8 getType () const
52
- { return ACTIVEOBJECT_TYPE_TEST; }
53
- // And never save to disk
54
- bool isStaticAllowed () const
55
- { return false ; }
56
-
57
- static ServerActiveObject* create (ServerEnvironment *env, v3f pos,
58
- const std::string &data)
59
- {
60
- return new DummyLoadSAO (env, pos, 0 );
61
- }
62
-
63
- void step (float dtime, bool send_recommended)
64
- {
65
- m_removed = true ;
66
- infostream<<" DummyLoadSAO step" <<std::endl;
67
- }
68
-
69
- bool getCollisionBox (aabb3f *toset) {
70
- return false ;
71
- }
72
-
73
- bool collideWithObjects () {
74
- return false ;
75
- }
76
-
77
- private:
78
- };
79
-
80
- // Prototype (registers item for deserialization)
81
- DummyLoadSAO proto1_DummyLoadSAO (NULL , v3f(0 ,0 ,0 ), ACTIVEOBJECT_TYPE_RAT);
82
- DummyLoadSAO proto2_DummyLoadSAO (NULL , v3f(0 ,0 ,0 ), ACTIVEOBJECT_TYPE_OERKKI1);
83
- DummyLoadSAO proto3_DummyLoadSAO (NULL , v3f(0 ,0 ,0 ), ACTIVEOBJECT_TYPE_FIREFLY);
84
- DummyLoadSAO proto4_DummyLoadSAO (NULL , v3f(0 ,0 ,0 ), ACTIVEOBJECT_TYPE_MOBV2);
85
-
86
38
/*
87
39
TestSAO
88
40
*/
@@ -97,7 +49,7 @@ class TestSAO : public ServerActiveObject
97
49
{
98
50
ServerActiveObject::registerType (getType (), create);
99
51
}
100
- u8 getType () const
52
+ ActiveObjectType getType () const
101
53
{ return ACTIVEOBJECT_TYPE_TEST; }
102
54
103
55
static ServerActiveObject* create (ServerEnvironment *env, v3f pos,
@@ -158,203 +110,6 @@ class TestSAO : public ServerActiveObject
158
110
// Prototype (registers item for deserialization)
159
111
TestSAO proto_TestSAO (NULL , v3f(0 ,0 ,0 ));
160
112
161
- /*
162
- ItemSAO
163
-
164
- DEPRECATED: New dropped items are implemented in Lua; see
165
- builtin/item_entity.lua.
166
- */
167
-
168
- class ItemSAO : public ServerActiveObject
169
- {
170
- public:
171
- u8 getType () const
172
- { return ACTIVEOBJECT_TYPE_ITEM; }
173
-
174
- float getMinimumSavedMovement ()
175
- { return 0.1 *BS; }
176
-
177
- static ServerActiveObject* create (ServerEnvironment *env, v3f pos,
178
- const std::string &data)
179
- {
180
- std::istringstream is (data, std::ios::binary);
181
- char buf[1 ];
182
- // read version
183
- is.read (buf, 1 );
184
- u8 version = buf[0 ];
185
- // check if version is supported
186
- if (version != 0 )
187
- return NULL ;
188
- std::string itemstring = deSerializeString (is);
189
- infostream<<" create(): Creating item \" "
190
- <<itemstring<<" \" " <<std::endl;
191
- return new ItemSAO (env, pos, itemstring);
192
- }
193
-
194
- ItemSAO (ServerEnvironment *env, v3f pos,
195
- const std::string &itemstring):
196
- ServerActiveObject (env, pos),
197
- m_itemstring (itemstring),
198
- m_itemstring_changed (false ),
199
- m_speed_f (0 ,0 ,0 ),
200
- m_last_sent_position (0 ,0 ,0 )
201
- {
202
- ServerActiveObject::registerType (getType (), create);
203
- }
204
-
205
- void step (float dtime, bool send_recommended)
206
- {
207
- ScopeProfiler sp2 (g_profiler, " step avg" , SPT_AVG);
208
-
209
- assert (m_env);
210
-
211
- const float interval = 0.2 ;
212
- if (m_move_interval.step (dtime, interval)==false )
213
- return ;
214
- dtime = interval;
215
-
216
- core::aabbox3d<f32> box (-BS/3 .,0.0 ,-BS/3 ., BS/3 .,BS*2 ./3 .,BS/3 .);
217
- collisionMoveResult moveresult;
218
- // Apply gravity
219
- m_speed_f += v3f (0 , -dtime*9.81 *BS, 0 );
220
- // Maximum movement without glitches
221
- f32 pos_max_d = BS*0.25 ;
222
- // Limit speed
223
- if (m_speed_f.getLength ()*dtime > pos_max_d)
224
- m_speed_f *= pos_max_d / (m_speed_f.getLength ()*dtime);
225
- v3f pos_f = getBasePosition ();
226
- v3f accel_f = v3f (0 ,0 ,0 );
227
- f32 stepheight = 0 ;
228
- moveresult = collisionMoveSimple (m_env,m_env->getGameDef (),
229
- pos_max_d, box, stepheight, dtime,
230
- pos_f, m_speed_f, accel_f);
231
-
232
- if (send_recommended == false )
233
- return ;
234
-
235
- if (pos_f.getDistanceFrom (m_last_sent_position) > 0.05 *BS)
236
- {
237
- setBasePosition (pos_f);
238
- m_last_sent_position = pos_f;
239
-
240
- std::ostringstream os (std::ios::binary);
241
- // command (0 = update position)
242
- writeU8 (os, 0 );
243
- // pos
244
- writeV3F1000 (os, m_base_position);
245
- // create message and add to list
246
- ActiveObjectMessage aom (getId (), false , os.str ());
247
- m_messages_out.push_back (aom);
248
- }
249
- if (m_itemstring_changed)
250
- {
251
- m_itemstring_changed = false ;
252
-
253
- std::ostringstream os (std::ios::binary);
254
- // command (1 = update itemstring)
255
- writeU8 (os, 1 );
256
- // itemstring
257
- os<<serializeString (m_itemstring);
258
- // create message and add to list
259
- ActiveObjectMessage aom (getId (), false , os.str ());
260
- m_messages_out.push_back (aom);
261
- }
262
- }
263
-
264
- std::string getClientInitializationData (u16 protocol_version)
265
- {
266
- std::ostringstream os (std::ios::binary);
267
- // version
268
- writeU8 (os, 0 );
269
- // pos
270
- writeV3F1000 (os, m_base_position);
271
- // itemstring
272
- os<<serializeString (m_itemstring);
273
- return os.str ();
274
- }
275
-
276
- std::string getStaticData ()
277
- {
278
- infostream<<__FUNCTION_NAME<<std::endl;
279
- std::ostringstream os (std::ios::binary);
280
- // version
281
- writeU8 (os, 0 );
282
- // itemstring
283
- os<<serializeString (m_itemstring);
284
- return os.str ();
285
- }
286
-
287
- ItemStack createItemStack ()
288
- {
289
- try {
290
- IItemDefManager *idef = m_env->getGameDef ()->idef ();
291
- ItemStack item;
292
- item.deSerialize (m_itemstring, idef);
293
- infostream<<__FUNCTION_NAME<<" : m_itemstring=\" " <<m_itemstring
294
- <<" \" -> item=\" " <<item.getItemString ()<<" \" "
295
- <<std::endl;
296
- return item;
297
- }
298
- catch (SerializationError &e)
299
- {
300
- infostream<<__FUNCTION_NAME<<" : serialization error: "
301
- <<" m_itemstring=\" " <<m_itemstring<<" \" " <<std::endl;
302
- return ItemStack ();
303
- }
304
- }
305
-
306
- int punch (v3f dir,
307
- const ToolCapabilities *toolcap,
308
- ServerActiveObject *puncher,
309
- float time_from_last_punch)
310
- {
311
- // Take item into inventory
312
- ItemStack item = createItemStack ();
313
- Inventory *inv = puncher->getInventory ();
314
- if (inv != NULL )
315
- {
316
- std::string wieldlist = puncher->getWieldList ();
317
- ItemStack leftover = inv->addItem (wieldlist, item);
318
- puncher->setInventoryModified ();
319
- if (leftover.empty ())
320
- {
321
- m_removed = true ;
322
- }
323
- else
324
- {
325
- m_itemstring = leftover.getItemString ();
326
- m_itemstring_changed = true ;
327
- }
328
- }
329
-
330
- return 0 ;
331
- }
332
-
333
- bool getCollisionBox (aabb3f *toset) {
334
- return false ;
335
- }
336
-
337
- bool collideWithObjects () {
338
- return false ;
339
- }
340
-
341
- private:
342
- std::string m_itemstring;
343
- bool m_itemstring_changed;
344
- v3f m_speed_f;
345
- v3f m_last_sent_position;
346
- IntervalLimiter m_move_interval;
347
- };
348
-
349
- // Prototype (registers item for deserialization)
350
- ItemSAO proto_ItemSAO (NULL , v3f(0 ,0 ,0 ), "");
351
-
352
- ServerActiveObject* createItemSAO (ServerEnvironment *env, v3f pos,
353
- const std::string &itemstring)
354
- {
355
- return new ItemSAO (env, pos, itemstring);
356
- }
357
-
358
113
/*
359
114
LuaEntitySAO
360
115
*/
0 commit comments