Mercurial > fife-parpg
annotate engine/core/model/structures/instance.cpp @ 625:92290efadab7
* This fixes a small bug that causes some primitives to not be rendered by the OpenGL renderbackend
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 01 Oct 2010 21:27:37 +0000 |
parents | a46368b3d8a0 |
children | 4f36c890b1dd |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 /*************************************************************************** |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 * Copyright (C) 2005-2008 by the FIFE team * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 * http://www.fifengine.de * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 * This file is part of FIFE. * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
6 * FIFE is free software; you can redistribute it and/or * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
8 * License as published by the Free Software Foundation; either * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
14 * Lesser General Public License for more details. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
17 * License along with this library; if not, write to the * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 * Free Software Foundation, Inc., * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 ***************************************************************************/ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 // Standard C++ library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 #include <iostream> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 // 3rd party library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 #include <SDL.h> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 // FIFE includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 // These includes are split up in two parts, separated by one empty line |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 // First block: files included from the FIFE root src directory |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 // Second block: files included from the same folder |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 #include "util/log/logger.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 #include "util/base/exception.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 #include "util/math/fife_math.h" |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
35 #include "util/time/timemanager.h" |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 #include "model/metamodel/grids/cellgrid.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 #include "model/metamodel/abstractpather.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 #include "model/metamodel/action.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 #include "model/metamodel/timeprovider.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 #include "model/structures/layer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 #include "model/structures/map.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 #include "model/structures/instancetree.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 #include "instance.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 static Logger _log(LM_INSTANCE); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
48 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 class ActionInfo { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 public: |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
51 ActionInfo(AbstractPather* pather, const Location& curloc): |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
52 m_action(NULL), |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
53 m_target(NULL), |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
54 m_speed(0), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 m_repeating(false), |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
56 m_action_start_time(0), |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
57 m_action_offset_time(0), |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
58 m_prev_call_time(0), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 m_pather_session_id(-1), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 m_pather(pather), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 m_leader(NULL) {} |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 ~ActionInfo() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 if (m_pather_session_id != -1) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 m_pather->cancelSession(m_pather_session_id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 delete m_target; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 m_target = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 // Current action, owned by object |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 Action* m_action; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 // target location for ongoing movement |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 Location* m_target; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 // current movement speed |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 double m_speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 // should action be repeated? used only for non-moving actions, moving ones repeat until movement is finished |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 bool m_repeating; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 // action start time (ticks) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 unsigned int m_action_start_time; |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
81 // action offset time (ticks) for resuming an action |
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
82 unsigned int m_action_offset_time; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 // ticks since last call |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 unsigned int m_prev_call_time; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 // session id for pather |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 int m_pather_session_id; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 // pather |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 AbstractPather* m_pather; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 // leader for follow activity |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 Instance* m_leader; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 }; |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
92 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 class SayInfo { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 public: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 SayInfo(const std::string& txt, unsigned int duration): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 m_txt(txt), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 m_duration(duration), |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
98 m_start_time(0) {} |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
99 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 std::string m_txt; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 unsigned int m_duration; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 unsigned int m_start_time; |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
103 }; |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
104 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 Instance::InstanceActivity::InstanceActivity(Instance& source): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 m_location(source.m_location), |
587
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
107 m_rotation(source.m_rotation), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 m_facinglocation(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 m_action(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 m_speed(0), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 m_timemultiplier(1.0), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 m_saytxt(""), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 m_changelisteners(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 m_actionlisteners(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 m_actioninfo(NULL), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 m_sayinfo(NULL), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 m_timeprovider(NULL) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 if (source.m_facinglocation) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 m_facinglocation = *source.m_facinglocation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
122 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 Instance::InstanceActivity::~InstanceActivity() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 delete m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 delete m_sayinfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 delete m_timeprovider; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
128 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 void Instance::InstanceActivity::update(Instance& source) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 source.m_changeinfo = ICHANGE_NO_CHANGES; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 if (m_location != source.m_location) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 source.m_changeinfo |= ICHANGE_LOC; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 m_location = source.m_location; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 } |
587
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
135 if (m_rotation != source.m_rotation) { |
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
136 source.m_changeinfo |= ICHANGE_ROTATION; |
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
137 m_rotation = source.m_rotation; |
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
138 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
139 if (source.m_facinglocation && (m_facinglocation != *source.m_facinglocation)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 source.m_changeinfo |= ICHANGE_FACING_LOC; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 m_facinglocation = *source.m_facinglocation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
142 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
143 if (m_actioninfo && (m_speed != m_actioninfo->m_speed)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
144 source.m_changeinfo |= ICHANGE_SPEED; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 m_speed = m_actioninfo->m_speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
146 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 if (m_actioninfo && (m_action != m_actioninfo->m_action)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 source.m_changeinfo |= ICHANGE_ACTION; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 m_action = m_actioninfo->m_action; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 if (m_timeprovider && (m_timemultiplier != m_timeprovider->getMultiplier())) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
152 source.m_changeinfo |= ICHANGE_TIME_MULTIPLIER; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 m_timemultiplier = m_timeprovider->getMultiplier(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 if (m_sayinfo && (m_saytxt != m_sayinfo->m_txt)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 source.m_changeinfo |= ICHANGE_SAYTEXT; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 m_saytxt = m_sayinfo->m_txt; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
159 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 if (source.m_changeinfo != ICHANGE_NO_CHANGES) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 std::vector<InstanceChangeListener*>::iterator i = m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 while (i != m_changelisteners.end()) { |
338 | 163 if (NULL != *i) |
164 { | |
165 (*i)->onInstanceChanged(&source, source.m_changeinfo); | |
166 } | |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 } |
338 | 169 // Really remove "removed" listeners. |
170 m_changelisteners.erase( | |
171 std::remove(m_changelisteners.begin(),m_changelisteners.end(), | |
172 (InstanceChangeListener*)NULL), | |
173 m_changelisteners.end()); | |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 Instance::Instance(Object* object, const Location& location, const std::string& identifier): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 m_id(identifier), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 m_rotation(0), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 m_activity(NULL), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 m_changeinfo(ICHANGE_NO_CHANGES), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 m_object(object), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 m_location(location), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 m_facinglocation(NULL), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 m_visual(NULL) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 Instance::~Instance() { |
219
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
189 std::vector<InstanceDeleteListener *>::iterator itor; |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
190 for(itor = m_deletelisteners.begin(); |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
191 itor != m_deletelisteners.end(); |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
192 ++itor) { |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
193 (*itor)->onInstanceDeleted(this); |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
194 } |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
195 |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
196 if(m_activity && m_activity->m_actioninfo) { |
244
7887f3854862
'Fixed' segfault in rio de hola. Font system in FIFE is odd.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
219
diff
changeset
|
197 // Don't ditribute onActionFinished in case we're already |
7887f3854862
'Fixed' segfault in rio de hola. Font system in FIFE is odd.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
219
diff
changeset
|
198 // deleting. |
7887f3854862
'Fixed' segfault in rio de hola. Font system in FIFE is odd.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
219
diff
changeset
|
199 m_activity->m_actionlisteners.clear(); |
219
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
200 finalizeAction(); |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
201 } |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
202 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 delete m_activity; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
204 delete m_facinglocation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
205 delete m_visual; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
207 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 void Instance::initializeChanges() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
209 if (!m_activity) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
210 m_activity = new InstanceActivity(*this); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
211 if(m_location.getLayer()) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
212 m_location.getLayer()->setInstanceActivityStatus(this, true); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
213 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
215 } |
587
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
216 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
217 bool Instance::isActive() const { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
218 return bool(m_activity); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
219 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
220 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 void Instance::setLocation(const Location& loc) { |
588
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
222 if(m_location != loc) { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
223 m_location = loc; |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
224 if(isActive()) { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
225 refresh(); |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
226 } else { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
227 initializeChanges(); |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
228 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
348
diff
changeset
|
229 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
230 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
231 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 void Instance::setRotation(int rotation) { |
588
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
233 if(m_rotation != rotation) { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
234 m_rotation = rotation; |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
235 if(isActive()) { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
236 refresh(); |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
237 } else { |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
238 initializeChanges(); |
a46368b3d8a0
* Added checks to setRotation() and setLocation() to prevent performance decrease.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
587
diff
changeset
|
239 } |
587
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
240 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 |
99
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
243 void Instance::setId(const std::string& identifier) { |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
244 m_id = identifier; |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
245 } |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
246 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 void Instance::addActionListener(InstanceActionListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 initializeChanges(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 m_activity->m_actionlisteners.push_back(listener); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 void Instance::removeActionListener(InstanceActionListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 if (!m_activity) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 while (i != m_activity->m_actionlisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 if ((*i) == listener) { |
339 | 259 *i = NULL; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 FL_WARN(_log, "Cannot remove unknown listener"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 void Instance::addChangeListener(InstanceChangeListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 initializeChanges(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 m_activity->m_changelisteners.push_back(listener); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
270 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 void Instance::removeChangeListener(InstanceChangeListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 if (!m_activity) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
274 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
276 std::vector<InstanceChangeListener*>::iterator i = m_activity->m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
277 while (i != m_activity->m_changelisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
278 if ((*i) == listener) { |
338 | 279 *i = NULL; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
281 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
282 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
283 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
284 FL_WARN(_log, "Cannot remove unknown listener"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
285 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
286 void Instance::initializeAction(const std::string& action_name) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 assert(m_object); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 assert(m_activity); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
289 const Action *old_action = m_activity->m_actioninfo ? m_activity->m_actioninfo->m_action : NULL; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 if (m_activity->m_actioninfo) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
291 delete m_activity->m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
292 m_activity->m_actioninfo = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
293 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
294 m_activity->m_actioninfo = new ActionInfo(m_object->getPather(), m_location); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
295 m_activity->m_actioninfo->m_action = m_object->getAction(action_name); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
296 if (!m_activity->m_actioninfo->m_action) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
297 delete m_activity->m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
298 m_activity->m_actioninfo = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 throw NotFound(std::string("action ") + action_name + " not found"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
300 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
301 m_activity->m_actioninfo->m_prev_call_time = getRuntime(); |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
302 if (m_activity->m_actioninfo->m_action != old_action) { |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
303 m_activity->m_actioninfo->m_action_start_time = m_activity->m_actioninfo->m_prev_call_time; |
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
304 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
305 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
306 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
307 void Instance::move(const std::string& action_name, const Location& target, const double speed) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
308 initializeChanges(); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
309 initializeAction(action_name); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
310 m_activity->m_actioninfo->m_target = new Location(target); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
311 m_activity->m_actioninfo->m_speed = speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
312 setFacingLocation(target); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
313 FL_DBG(_log, LMsg("starting action ") << action_name << " from" << m_location << " to " << target << " with speed " << speed); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
314 } |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
315 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
316 void Instance::follow(const std::string& action_name, Instance* leader, const double speed) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
317 initializeChanges(); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
318 initializeAction(action_name); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
319 m_activity->m_actioninfo->m_target = new Location(leader->getLocationRef()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
320 m_activity->m_actioninfo->m_speed = speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
321 m_activity->m_actioninfo->m_leader = leader; |
338 | 322 leader->addDeleteListener(this); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
323 setFacingLocation(*m_activity->m_actioninfo->m_target); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
324 FL_DBG(_log, LMsg("starting action ") << action_name << " from" << m_location << " to " << *m_activity->m_actioninfo->m_target << " with speed " << speed); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
325 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
326 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
327 void Instance::act(const std::string& action_name, const Location& direction, bool repeating) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
328 initializeChanges(); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
329 initializeAction(action_name); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
330 m_activity->m_actioninfo->m_repeating = repeating; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
331 setFacingLocation(direction); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
332 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
333 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
334 void Instance::say(const std::string& text, unsigned int duration) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
335 initializeChanges(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
336 delete m_activity->m_sayinfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
337 m_activity->m_sayinfo = NULL; |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
338 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
339 if (text != "") { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
340 m_activity->m_sayinfo = new SayInfo(text, duration); |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
341 m_activity->m_sayinfo->m_start_time = getRuntime(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
342 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
343 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
344 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
345 const std::string* Instance::getSayText() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
346 if (m_activity && m_activity->m_sayinfo) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
347 return &m_activity->m_sayinfo->m_txt; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
348 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
349 return NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
350 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
351 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
352 void Instance::setFacingLocation(const Location& loc) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
353 if (!m_facinglocation) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
354 m_facinglocation = new Location(loc); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
355 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
356 *m_facinglocation = loc; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
357 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
358 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
359 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
360 bool Instance::process_movement() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
361 FL_DBG(_log, "Moving..."); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
362 ActionInfo* info = m_activity->m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
363 // timeslice for this movement |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
364 unsigned int timedelta = m_activity->m_timeprovider->getGameTime() - info->m_prev_call_time; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
365 FL_DBG(_log, LMsg("timedelta ") << timedelta << " prevcalltime " << info->m_prev_call_time); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
366 // how far we can travel |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
367 double distance_to_travel = (static_cast<double>(timedelta) / 1000.0) * info->m_speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
368 FL_DBG(_log, LMsg("dist ") << distance_to_travel); |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
369 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
370 Location nextLocation = m_location; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
371 info->m_pather_session_id = info->m_pather->getNextLocation( |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
372 this, *info->m_target, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
373 distance_to_travel, nextLocation, *m_facinglocation, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
374 info->m_pather_session_id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
375 m_location.getLayer()->getInstanceTree()->removeInstance(this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
376 m_location = nextLocation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
377 //ExactModelCoordinate a = nextLocation.getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
378 //ExactModelCoordinate b = m_actioninfo->m_target->getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
379 m_location.getLayer()->getInstanceTree()->addInstance(this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
380 // return if we are close enough to target to stop |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
381 if (info->m_pather_session_id == -1) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
382 return true; |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
383 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
384 return false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
385 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
386 |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
387 InstanceChangeInfo Instance::update() { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
388 if (!m_activity) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
389 return ICHANGE_NO_CHANGES; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
390 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
391 m_activity->update(*this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
392 if (!m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
393 bindTimeProvider(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
394 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
395 ActionInfo* info = m_activity->m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
396 if (info) { |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
397 FL_DBG(_log, "updating instance"); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
398 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
399 if (info->m_target) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
400 FL_DBG(_log, "action contains target for movement"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
401 // update target if needed |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
402 if (info->m_leader && (info->m_leader->getLocationRef() != *info->m_target)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
403 *info->m_target = info->m_leader->getLocation(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
404 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
405 bool movement_finished = process_movement(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
406 if (movement_finished) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
407 FL_DBG(_log, "movement finished"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
408 finalizeAction(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
409 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
410 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
411 FL_DBG(_log, "action does not contain target for movement"); |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
412 if (m_activity->m_timeprovider->getGameTime() - info->m_action_start_time + info->m_action_offset_time >= info->m_action->getDuration()) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
413 if (info->m_repeating) { |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
414 info->m_action_start_time = m_activity->m_timeprovider->getGameTime(); |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
415 // prock: offset no longer needed |
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
416 info->m_action_offset_time = 0; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
417 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
418 finalizeAction(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
419 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
420 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
421 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
422 |
204
5816ab527da8
Fix for broken unit test.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
423 // previous code may invalidate actioninfo. |
5816ab527da8
Fix for broken unit test.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
424 if( m_activity->m_actioninfo ) { |
5816ab527da8
Fix for broken unit test.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
425 m_activity->m_actioninfo->m_prev_call_time = m_activity->m_timeprovider->getGameTime(); |
5816ab527da8
Fix for broken unit test.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
189
diff
changeset
|
426 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
427 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
428 if (m_activity->m_sayinfo) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
429 if (m_activity->m_sayinfo->m_duration > 0) { |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
430 if (m_activity->m_timeprovider->getGameTime() >= m_activity->m_sayinfo->m_start_time + m_activity->m_sayinfo->m_duration) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
431 say(""); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
432 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
433 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
434 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
435 return m_changeinfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
436 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
437 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
438 void Instance::finalizeAction() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
439 FL_DBG(_log, "finalizing action"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
440 assert(m_activity); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
441 assert(m_activity->m_actioninfo); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
442 |
219
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
443 if( m_activity->m_actioninfo->m_leader ) { |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
444 m_activity->m_actioninfo->m_leader->removeDeleteListener(this); |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
445 } |
852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
210
diff
changeset
|
446 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
447 Action* action = m_activity->m_actioninfo->m_action; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
448 delete m_activity->m_actioninfo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
449 m_activity->m_actioninfo = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
450 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
451 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
452 while (i != m_activity->m_actionlisteners.end()) { |
339 | 453 if(*i) |
454 (*i)->onInstanceActionFinished(this, action); | |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
455 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
456 } |
339 | 457 m_activity->m_actionlisteners.erase( |
458 std::remove(m_activity->m_actionlisteners.begin(), | |
459 m_activity->m_actionlisteners.end(), | |
460 (InstanceActionListener*)NULL), | |
461 m_activity->m_actionlisteners.end()); | |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
462 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
463 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
464 Action* Instance::getCurrentAction() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
465 if (m_activity && m_activity->m_actioninfo) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
466 return m_activity->m_actioninfo->m_action; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
467 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
468 return NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
469 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
470 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
471 Location Instance::getTargetLocation() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
472 if (m_activity && m_activity->m_actioninfo && m_activity->m_actioninfo->m_target) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
473 return *m_activity->m_actioninfo->m_target; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
474 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
475 return m_location; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
476 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
477 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
478 double Instance::getMovementSpeed() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
479 if (m_activity && m_activity->m_actioninfo) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
480 return m_activity->m_actioninfo->m_speed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
481 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
482 return 0; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
483 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
484 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
485 Location Instance::getFacingLocation() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
486 return this->getFacingLocationRef(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
487 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
488 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
489 Location& Instance::getFacingLocationRef() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
490 if (!m_facinglocation) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
491 m_facinglocation = new Location(m_location); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
492 m_facinglocation->setExactLayerCoordinates(m_facinglocation->getExactLayerCoordinates() + ExactModelCoordinate(1.0, 0.0)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
493 //m_facinglocation->setLayerCoordinates(ModelCoordinate(1,0)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
494 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
495 return *m_facinglocation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
496 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
497 |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
498 unsigned int Instance::getActionRuntime() { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
499 if (m_activity && m_activity->m_actioninfo) { |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
500 if(!m_activity->m_timeprovider) |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
501 bindTimeProvider(); |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
502 return m_activity->m_timeprovider->getGameTime() - m_activity->m_actioninfo->m_action_start_time + m_activity->m_actioninfo->m_action_offset_time; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
503 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
504 return getRuntime(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
505 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
506 |
348
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
507 void Instance::setActionRuntime(unsigned int time_offset) { |
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
508 m_activity->m_actioninfo->m_action_offset_time = time_offset; |
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
509 } |
48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
339
diff
changeset
|
510 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
511 void Instance::bindTimeProvider() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
512 float multiplier = 1.0; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
513 if (m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
514 multiplier = m_activity->m_timeprovider->getMultiplier(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
515 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
516 delete m_activity->m_timeprovider; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
517 m_activity->m_timeprovider = NULL; |
189
3d0cc4545938
* Applied two patches from icelus
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
518 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
519 if (m_location.getLayer()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
520 Map* map = m_location.getLayer()->getMap(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
521 if (map) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
522 m_activity->m_timeprovider = new TimeProvider(map->getTimeProvider()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
523 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
524 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
525 if (!m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
526 m_activity->m_timeprovider = new TimeProvider(NULL); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
527 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
528 m_activity->m_timeprovider->setMultiplier(multiplier); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
529 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
530 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
531 void Instance::refresh() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
532 initializeChanges(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
533 bindTimeProvider(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
534 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
535 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
536 void Instance::setTimeMultiplier(float multip) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
537 initializeChanges(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
538 if (!m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
539 bindTimeProvider(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
540 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
541 m_activity->m_timeprovider->setMultiplier(multip); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
542 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
543 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
544 float Instance::getTimeMultiplier() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
545 if (m_activity && m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
546 return m_activity->m_timeprovider->getMultiplier(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
547 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
548 return 1.0; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
549 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
550 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
551 float Instance::getTotalTimeMultiplier() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
552 if (m_activity && m_activity->m_timeprovider) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
553 return m_activity->m_timeprovider->getTotalMultiplier(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
554 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
555 if (m_location.getLayer()) { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
556 Map* map = m_location.getLayer()->getMap(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
557 if (map && map->getTimeProvider()) { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
558 return map->getTimeProvider()->getTotalMultiplier(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
559 } |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
560 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
561 return 1.0; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
562 } |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
563 |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
564 unsigned int Instance::getRuntime() { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
565 if (m_activity) { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
566 if(!m_activity->m_timeprovider) |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
567 bindTimeProvider(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
568 return m_activity->m_timeprovider->getGameTime(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
569 } |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
570 if (m_location.getLayer()) { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
571 Map* map = m_location.getLayer()->getMap(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
572 if (map && map->getTimeProvider()) { |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
573 return map->getTimeProvider()->getGameTime(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
574 } |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
575 } |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
576 return TimeManager::instance()->getTime(); |
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
577 } |
210
be246fb3a0df
Remove mutable from m_deletelisteners
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
209
diff
changeset
|
578 void Instance::addDeleteListener(InstanceDeleteListener *listener) { |
209
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
579 m_deletelisteners.push_back(listener); |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
580 } |
210
be246fb3a0df
Remove mutable from m_deletelisteners
icelus@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
209
diff
changeset
|
581 void Instance::removeDeleteListener(InstanceDeleteListener *listener) { |
209
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
582 std::vector<InstanceDeleteListener*>::iterator itor; |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
583 itor = std::find(m_deletelisteners.begin(), |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
584 m_deletelisteners.end(), |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
585 listener); |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
586 if(itor != m_deletelisteners.end()) { |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
587 m_deletelisteners.erase(itor); |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
588 } else { |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
589 FL_WARN(_log, "Cannot remove unknown listener"); |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
590 } |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
591 } |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
592 void Instance::onInstanceDeleted(Instance* instance) { |
587
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
593 if(m_activity && |
2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
594 m_activity->m_actioninfo && |
209
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
595 m_activity->m_actioninfo->m_leader == instance) { |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
596 m_activity->m_actioninfo->m_leader = NULL; |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
597 } |
044d1fead5d2
* Applying icelus' "leader is not around anymore" patch from #350
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
204
diff
changeset
|
598 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
599 } |