]> git.lizzy.rs Git - dragonfireclient.git/blob - src/serverobject.cpp
ffb6059dc6902fa1c25736c925d95d40d976f731
[dragonfireclient.git] / src / serverobject.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "serverobject.h"
21
22 ServerActiveObject::ServerActiveObject(u16 id, v3f pos):
23         ActiveObject(id),
24         m_known_by_count(0),
25         m_removed(false),
26         m_base_position(pos)
27 {
28 }
29
30 ServerActiveObject::~ServerActiveObject()
31 {
32 }
33
34 TestSAO::TestSAO(u16 id, v3f pos):
35         ServerActiveObject(id, pos),
36         m_timer1(0),
37         m_age(0)
38 {
39 }
40
41 void TestSAO::step(float dtime, Queue<ActiveObjectMessage> &messages)
42 {
43         m_age += dtime;
44         if(m_age > 10)
45         {
46                 m_removed = true;
47                 return;
48         }
49
50         m_base_position.Y += dtime * BS * 2;
51         if(m_base_position.Y > 8*BS)
52                 m_base_position.Y = 2*BS;
53
54         m_timer1 -= dtime;
55         if(m_timer1 < 0.0)
56         {
57                 m_timer1 += 0.125;
58                 //dstream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl;
59
60                 std::string data;
61
62                 data += itos(0); // 0 = position
63                 data += " ";
64                 data += itos(m_base_position.X);
65                 data += " ";
66                 data += itos(m_base_position.Y);
67                 data += " ";
68                 data += itos(m_base_position.Z);
69
70                 //ActiveObjectMessage aom(getId(), true, data);
71                 ActiveObjectMessage aom(getId(), false, data);
72                 messages.push_back(aom);
73         }
74 }
75