Skip to content
This repository
Browse code

- register TaskTarget in TaskExecutor::AddTask if it wasn't registere…

…d before

- update project files
- don't allow bind handler to MSG_NULL_ACTION opcode
  • Loading branch information...
commit 759518bb5b6827bfad6c76b90b6e202847d3e800 1 parent 877525e
authored October 20, 2011
2  Movement/ClientImpl.h
@@ -130,6 +130,8 @@ namespace Movement
130 130
         HandlerMap handlers;
131 131
 
132 132
         void assignHandler(Handler hdl, uint16 opcode) {
  133
+            if (opcode == MSG_NULL_ACTION)
  134
+                return;
133 135
             HandlerMap::const_iterator it = handlers.find(opcode);
134 136
             assert_state(it == handlers.end());
135 137
             handlers.insert(HandlerMap::value_type(opcode,hdl));
12  Movement/TaskScheduler.cpp
@@ -121,8 +121,10 @@ namespace Tasks
121 121
     TaskExecutor::TaskExecutor() : impl(*new TaskExecutorImpl()), m_objectsRegistered(0) {}
122 122
     TaskExecutor::~TaskExecutor() { delete &impl;}
123 123
 
124  
-    void TaskExecutor::AddTask(CallBack * callback, MSTime exec_time, const TaskTarget& ownerId)
  124
+    void TaskExecutor::AddTask(CallBack * callback, MSTime exec_time, TaskTarget& ownerId)
125 125
     {
  126
+        if (!ownerId.isRegistered())
  127
+            Register(ownerId);
126 128
         impl.AddTask(callback, exec_time, ownerId.objectId);
127 129
     }
128 130
 
@@ -131,7 +133,7 @@ namespace Tasks
131 133
         impl.CancelTasks(ownerId.objectId);
132 134
     }
133 135
 
134  
-    void TaskExecutor::RegisterObject(TaskTarget& obj)
  136
+    void TaskExecutor::Register(TaskTarget& obj)
135 137
     {
136 138
         if (obj.isRegistered()){
137 139
             log_fatal("object is already registered somewhere");
@@ -143,7 +145,7 @@ namespace Tasks
143 145
         impl.RegisterObject(obj.objectId);
144 146
     }
145 147
 
146  
-    void TaskExecutor::RemoveObject(TaskTarget& obj)
  148
+    void TaskExecutor::Unregister(TaskTarget& obj)
147 149
     {
148 150
         if (!obj.isRegistered())
149 151
             return;
@@ -186,7 +188,7 @@ namespace Tasks
186 188
     {
187 189
         if (isRegistered()) {
188 190
             mov_assert(m_executor);
189  
-            m_executor->RemoveObject(m_objectId);
  191
+            m_executor->Unregister(m_objectId);
190 192
         }
191 193
         m_executor = NULL;
192 194
     }
@@ -194,8 +196,6 @@ namespace Tasks
194 196
     void TaskTarget_DEV::AddTask(CallBack * callback, MSTime exec_time)
195 197
     {
196 198
         mov_assert(m_executor);
197  
-        if (!isRegistered())
198  
-            m_executor->RegisterObject(m_objectId);
199 199
         m_executor->AddTask(callback, exec_time, m_objectId);
200 200
     }
201 201
 }
16  Movement/TaskScheduler.h
@@ -26,11 +26,11 @@ namespace Tasks
26 26
     class ITaskExecutor
27 27
     {
28 28
     public:
29  
-        virtual void AddTask(CallBack * callback, MSTime exec_time, const TaskTarget& ownerId) = 0;
  29
+        virtual void AddTask(CallBack * callback, MSTime exec_time, TaskTarget& ownerId) = 0;
30 30
         virtual void CancelTasks(const TaskTarget& ownerId) = 0;
31 31
         virtual void Update(MSTime time) = 0;
32  
-        virtual void RegisterObject(TaskTarget& obj) = 0;
33  
-        virtual void RemoveObject(TaskTarget& obj) = 0;
  32
+        virtual void Register(TaskTarget& obj) = 0;
  33
+        virtual void Unregister(TaskTarget& obj) = 0;
34 34
     protected:
35 35
         ~ITaskExecutor() {}
36 36
     };
@@ -47,14 +47,14 @@ namespace Tasks
47 47
         ~TaskExecutor();
48 48
 
49 49
         template<class T>
50  
-        void AddTask(T * functor, MSTime exec_time, const TaskTarget& ownerId);
51  
-        void AddTask(CallBack * callback, MSTime exec_time, const TaskTarget& ownerId) override;
  50
+        void AddTask(T * functor, MSTime exec_time, TaskTarget& ownerId);
  51
+        void AddTask(CallBack * callback, MSTime exec_time, TaskTarget& ownerId) override;
52 52
 
53 53
         void CancelTasks(const TaskTarget& ownerId) override;
54 54
         void CancelAllTasks();
55 55
 
56  
-        void RegisterObject(TaskTarget& obj) override;
57  
-        void RemoveObject(TaskTarget& obj) override;
  56
+        void Register(TaskTarget& obj) override;
  57
+        void Unregister(TaskTarget& obj) override;
58 58
 
59 59
         void Update(MSTime time) override;
60 60
 
@@ -160,7 +160,7 @@ namespace Tasks
160 160
     };
161 161
 
162 162
     template<class T>
163  
-    inline void TaskExecutor::AddTask(T * functor, MSTime exec_time, const TaskTarget& ownerId)
  163
+    inline void TaskExecutor::AddTask(T * functor, MSTime exec_time, TaskTarget& ownerId)
164 164
     {
165 165
         AddTask(CallBackPublic(functor), exec_time, ownerId);
166 166
     }
2  Movement/UnitMovementImpl.h
@@ -140,7 +140,7 @@ namespace Movement
140 140
         _ClientMoveState m_unused; 
141 141
 
142 142
         float m_float_values[Parameter_End];
143  
-        TaskTarget_DEV m_updateRotationTask;
  143
+        TaskTarget m_updateRotationTask;
144 144
         LinkedListElement<TargetLink> m_target_link;
145 145
         LinkedList<TargetLink> m_targeter_references;
146 146
     };
11  Movement/UnitMovementImpl.hpp
@@ -130,7 +130,6 @@ namespace Movement
130 130
         {
131 131
             m_updater = &updater;
132 132
             commonTasks.SetExecutor(updater);
133  
-            m_updateRotationTask.SetExecutor(updater);
134 133
             struct RegularUpdater : StaticExecutor<UnitMovementImpl,RegularUpdater,false> {
135 134
                 static void Execute(UnitMovementImpl& me, TaskExecutor_Args& args) {
136 135
                     me.UpdateState(args.now);
@@ -203,7 +202,13 @@ namespace Movement
203 202
             }
204 203
         };
205 204
 
206  
-        m_updateRotationTask.AddTask(CallBackPublic(this,&OrientationUpdater::Static_Execute), 0);
  205
+        // TODO: this place is big field for improvements. List of units that are subscibed to receive
  206
+        // orientation updates might be moved to new class. This class can be automatically deleted when none targets unit
  207
+
  208
+        // create OrientationUpdater task only in case there is no more such tasks
  209
+        if (!m_updateRotationTask.isRegistered())
  210
+            m_updater->AddTask(CallBackPublic(this,&OrientationUpdater::Static_Execute),0,m_updateRotationTask);
  211
+
207 212
         m_target_link.delink();
208 213
         m_target_link.Value = TargetLink(&target, this);
209 214
         target.m_targeter_references.link(m_target_link);
@@ -212,7 +217,7 @@ namespace Movement
212 217
 
213 218
     void UnitMovementImpl::UnbindOrientation()
214 219
     {
215  
-        m_updateRotationTask.Unregister();
  220
+        m_updater->Unregister(m_updateRotationTask);
216 221
         m_target_link.delink();
217 222
         m_target_link.Value = TargetLink();
218 223
         Owner.SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid());
24  VC9/movement.vcproj
@@ -251,15 +251,11 @@
251 251
 				>
252 252
 			</File>
253 253
 			<File
254  
-				RelativePath="..\Movement\MoveUpdater.h"
255  
-				>
256  
-			</File>
257  
-			<File
258 254
 				RelativePath="..\Movement\MSTime.h"
259 255
 				>
260 256
 			</File>
261 257
 			<File
262  
-				RelativePath="..\Movement\RdtscTimer.h"
  258
+				RelativePath="..\Movement\typedefs_p.h"
263 259
 				>
264 260
 			</File>
265 261
 			<File
@@ -317,6 +313,14 @@
317 313
 					RelativePath="..\Movement\UnitMovementImpl.hpp"
318 314
 					>
319 315
 				</File>
  316
+				<File
  317
+					RelativePath="..\Movement\UpdatableSpline.h"
  318
+					>
  319
+				</File>
  320
+				<File
  321
+					RelativePath="..\Movement\UpdatableSpline.hpp"
  322
+					>
  323
+				</File>
320 324
 				<Filter
321 325
 					Name="MoveSpline"
322 326
 					>
@@ -418,6 +422,10 @@
418 422
 				Name="TaskScheduler"
419 423
 				>
420 424
 				<File
  425
+					RelativePath="..\Movement\POD_Arrays.h"
  426
+					>
  427
+				</File>
  428
+				<File
421 429
 					RelativePath="..\Movement\TaskExecutorImpl_Deque.hpp"
422 430
 					>
423 431
 				</File>
@@ -434,7 +442,7 @@
434 442
 					>
435 443
 				</File>
436 444
 				<File
437  
-					RelativePath="..\Movement\TaskExecutorImpl_Vector1.1.hpp"
  445
+					RelativePath="..\Movement\TaskExecutorImpl_Vector1.10.hpp"
438 446
 					>
439 447
 				</File>
440 448
 				<File
@@ -484,6 +492,10 @@
484 492
 			>
485 493
 		</File>
486 494
 		<File
  495
+			RelativePath="..\Movement\MoveUpdater.h"
  496
+			>
  497
+		</File>
  498
+		<File
487 499
 			RelativePath="..\Movement\typedefs.h"
488 500
 			>
489 501
 		</File>

0 notes on commit 759518b

Please sign in to comment.
Something went wrong with that request. Please try again.