Merge lp:~luke-jr/armagetronad/armagetronad-zonesv2-cleanup into lp:~armagetronad-dev/armagetronad/trunk-armagetronad-work
- armagetronad-zonesv2-cleanup
- Merge into trunk-armagetronad-work
Proposed by
Luke-Jr
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~luke-jr/armagetronad/armagetronad-zonesv2-cleanup |
Merge into: | lp:~armagetronad-dev/armagetronad/trunk-armagetronad-work |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~luke-jr/armagetronad/armagetronad-zonesv2-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Manuel Moos | Approve | ||
Review via email: mp+4020@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Manuel Moos (z-man) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/engine/eGameObject.cpp' |
2 | --- src/engine/eGameObject.cpp 2008-04-25 18:00:53 +0000 |
3 | +++ src/engine/eGameObject.cpp 2009-02-27 08:05:29 +0000 |
4 | @@ -638,6 +638,14 @@ |
5 | |
6 | void eGameObject::OnRoundBegin(){} |
7 | void eGameObject::OnRoundEnd(){} |
8 | +void eGameObject::OnBirth(){} |
9 | + |
10 | +void eGameObject::EnsureBorn() { |
11 | + if (_born) |
12 | + return; |
13 | + _born = true; |
14 | + OnBirth(); |
15 | +} |
16 | |
17 | void eGameObject::Kill(){} |
18 | |
19 | @@ -703,6 +711,8 @@ |
20 | |
21 | tJUST_CONTROLLED_PTR< eGameObject > keep( c ); // keep object alive |
22 | |
23 | + c->EnsureBorn(); |
24 | + |
25 | REAL maxstep=.2; |
26 | |
27 | // don't do a thing if the timestep is too small |
28 | |
29 | === modified file 'src/engine/eGameObject.h' |
30 | --- src/engine/eGameObject.h 2008-03-08 16:55:06 +0000 |
31 | +++ src/engine/eGameObject.h 2009-02-27 08:05:29 +0000 |
32 | @@ -57,6 +57,9 @@ |
33 | // small wrapper of TimestepThis doing preparation and cleanup work |
34 | static void TimestepThisWrapper(eGrid * grid, REAL currentTime, eGameObject *t, REAL minTimestep); |
35 | |
36 | + //! called immediately after the object is created, either right after round beginning or mid-game creation |
37 | + virtual void OnBirth(); |
38 | + |
39 | protected: |
40 | // does a timestep and all interactions for this gameobject, |
41 | // divided in many small steps |
42 | @@ -89,6 +92,8 @@ |
43 | tJUST_CONTROLLED_PTR<eFace> currentFace; // the eFace pos it is currently |
44 | tCHECKED_PTR(eGrid) grid; // the game grid we are on |
45 | |
46 | + bool _born; |
47 | + |
48 | // entry and deletion in the list of all eGameObjects |
49 | public: |
50 | //! tells game objects what the maximum lag caused by lazy simulation of timesteps is |
51 | @@ -164,6 +169,9 @@ |
52 | //! called when the round ends |
53 | virtual void OnRoundEnd(); |
54 | |
55 | + //! call to ensure the object is "born" |
56 | + void EnsureBorn(); |
57 | + |
58 | //! destroys the gameobject (in the game) |
59 | virtual void Kill(); |
60 | |
61 | |
62 | === modified file 'src/tools/tPolynomial.cpp' |
63 | --- src/tools/tPolynomial.cpp 2009-02-22 23:34:35 +0000 |
64 | +++ src/tools/tPolynomial.cpp 2009-02-27 09:07:52 +0000 |
65 | @@ -74,6 +74,14 @@ |
66 | // Empty |
67 | } |
68 | |
69 | +tPolynomial::tPolynomial(const tFunction &tf, REAL refValue) //!< constructor |
70 | + : referenceVarValue(refValue), |
71 | + coefs(2) |
72 | +{ |
73 | + coefs[0] = tf.offset_; |
74 | + coefs[1] = tf.slope_; |
75 | +} |
76 | + |
77 | tPolynomial::tPolynomial(const tFunction &tf) //!< constructor |
78 | : referenceVarValue(0.0), |
79 | coefs(2) |
80 | |
81 | === modified file 'src/tools/tPolynomial.h' |
82 | --- src/tools/tPolynomial.h 2009-02-22 23:34:35 +0000 |
83 | +++ src/tools/tPolynomial.h 2009-02-27 09:07:52 +0000 |
84 | @@ -54,6 +54,7 @@ |
85 | tPolynomial(REAL value); //!< constructor for constant polynomial |
86 | tPolynomial(tArray<REAL> const & newCoefs); //!< constructor |
87 | tPolynomial(const tPolynomial &tf); //!< constructor |
88 | + tPolynomial(const tFunction &tf, REAL refValue); //!< constructor |
89 | tPolynomial(const tFunction &tf); //!< constructor |
90 | tPolynomial(std::string str); //!< constructor |
91 | |
92 | |
93 | === modified file 'src/tron/gGame.cpp' |
94 | --- src/tron/gGame.cpp 2009-02-26 19:57:28 +0000 |
95 | +++ src/tron/gGame.cpp 2009-02-27 08:05:29 +0000 |
96 | @@ -2728,6 +2728,7 @@ |
97 | if ( e ) |
98 | { |
99 | e->OnRoundBegin(); |
100 | + e->EnsureBorn(); |
101 | } |
102 | } |
103 | } |
104 | |
105 | === modified file 'src/tron/gParser.cpp' |
106 | --- src/tron/gParser.cpp 2009-02-26 22:15:59 +0000 |
107 | +++ src/tron/gParser.cpp 2009-02-27 18:21:24 +0000 |
108 | @@ -933,7 +933,9 @@ |
109 | // Get the label of the effector to be used |
110 | string effectorAttribute( myxmlGetProp(cur, "effect")); |
111 | |
112 | - effector = zEffectorPtr(zEffectorManager::Create(effectorAttribute, tXmlParser::node(cur))); |
113 | + effector = zEffectorPtr(zEffectorManager::Create(effectorAttribute)); |
114 | + effector->applyContext(state); |
115 | + effector->readXML(tXmlParser::node(cur)); |
116 | |
117 | return effector; |
118 | } |
119 | @@ -2013,20 +2015,35 @@ |
120 | |
121 | bool |
122 | gParser::State_t::exists(std::string const & var) |
123 | +const |
124 | { |
125 | return _varstack.front().find(var) != _varstack.front().end(); |
126 | } |
127 | |
128 | bool |
129 | gParser::State_t::isset(std::string const & var) |
130 | +const |
131 | { |
132 | - return exists(var) && !_varstack.front()[var]->empty(); |
133 | + if (!exists(var)) |
134 | + return false; |
135 | + my_map_t vars = _varstack.front(); |
136 | + my_map_t::const_iterator i; |
137 | + if ((i = vars.find(var)) == vars.end()) |
138 | + return false; |
139 | + if (i->second->empty()) |
140 | + return false; |
141 | + return true; |
142 | } |
143 | |
144 | boost::any |
145 | gParser::State_t::getAny(std::string const & var) |
146 | +const |
147 | { |
148 | - return *(_varstack.front()[var]); |
149 | + my_map_t vars = _varstack.front(); |
150 | + my_map_t::const_iterator i; |
151 | + if ((i = vars.find(var)) == vars.end()) |
152 | + return boost::any(); |
153 | + return *(i->second); |
154 | } |
155 | |
156 | void |
157 | |
158 | === modified file 'src/tron/gParser.h' |
159 | --- src/tron/gParser.h 2009-02-26 21:28:08 +0000 |
160 | +++ src/tron/gParser.h 2009-02-27 18:21:24 +0000 |
161 | @@ -32,13 +32,13 @@ |
162 | public: |
163 | gParserState(); |
164 | |
165 | - bool exists(std::string const & var); |
166 | - bool isset(std::string const & var); |
167 | - template<typename T> bool istype(std::string const & var) { |
168 | + bool exists(std::string const & var) const; |
169 | + bool isset(std::string const & var) const; |
170 | + template<typename T> bool istype(std::string const & var) const { |
171 | if (!isset(var)) |
172 | return false; |
173 | try { |
174 | - boost::any_cast<T>(*(_varstack.front()[var])); |
175 | + boost::any_cast<T>(getAny(var)); |
176 | return true; |
177 | } |
178 | catch (const boost::bad_any_cast &) |
179 | @@ -46,8 +46,8 @@ |
180 | return false; |
181 | } |
182 | } |
183 | - boost::any getAny(std::string const & var); |
184 | - template<typename T> T get(std::string const & var) { |
185 | + boost::any getAny(std::string const & var) const; |
186 | + template<typename T> T get(std::string const & var) const { |
187 | return boost::any_cast<T>(getAny(var)); |
188 | } |
189 | void setAny(std::string const & var, boost::any val); |
190 | |
191 | === removed file 'src/tron/zone/shapeCircle.h' |
192 | --- src/tron/zone/shapeCircle.h 2006-08-02 20:19:33 +0000 |
193 | +++ src/tron/zone/shapeCircle.h 1970-01-01 00:00:00 +0000 |
194 | @@ -1,34 +0,0 @@ |
195 | -typedef boost::shared_ptr<shape> ShapePtr; |
196 | - |
197 | -class shape { |
198 | - virtual ~shape(); |
199 | -}; |
200 | - |
201 | -class shapeCircle : public shape { |
202 | - tValue::Base() x; |
203 | - tValue::Base() y; |
204 | - tValue::Base() radius; |
205 | - |
206 | -public : |
207 | - shapeCircle(tValue::Base() _x, tValue::Base() _y, tValue::Base() _radius): x(_x), y(_y), radius(_radius) { }; |
208 | - |
209 | -}; |
210 | - |
211 | -class shapeTriangle : public shape { |
212 | - tValue::Base() x1; |
213 | - tValue::Base() y1; |
214 | - tValue::Base() x2; |
215 | - tValue::Base() y2; |
216 | - tValue::Base() x3; |
217 | - tValue::Base() y3; |
218 | - |
219 | -public: |
220 | - shapeSquare(tValue::Base() _x1, tValue::Base() _y1, |
221 | - tValue::Base() _x2, tValue::Base() _y2, |
222 | - tValue::Base() _x3, tValue::Base() _y3, |
223 | - ): |
224 | - x1(_x1), y1(_y1), |
225 | - x2(_x2), y2(_y2), |
226 | - x3(_x3), y3(_y3) |
227 | - {}; |
228 | -}; |
229 | |
230 | === modified file 'src/tron/zone/zEffectGroup.cpp' |
231 | --- src/tron/zone/zEffectGroup.cpp 2009-02-03 08:50:43 +0000 |
232 | +++ src/tron/zone/zEffectGroup.cpp 2009-02-27 16:25:51 +0000 |
233 | @@ -29,8 +29,6 @@ |
234 | |
235 | zEffectGroup::zEffectGroup(gVectorExtra< nNetObjectID > const owners, gVectorExtra< nNetObjectID > const teamOwners): |
236 | validators(), |
237 | - // monitorInfluences(), |
238 | - // zoneInfluences(), |
239 | d_owners(owners), |
240 | d_teamOwners(teamOwners), |
241 | d_calculatedTargets() |
242 | @@ -38,8 +36,6 @@ |
243 | |
244 | zEffectGroup::zEffectGroup(zEffectGroup const &other) : |
245 | validators(other.validators), |
246 | - // monitorInfluences(other.monitorInfluences), |
247 | - // zoneInfluences(other.zoneInfluences), |
248 | d_owners(other.d_owners), |
249 | d_teamOwners(other.d_teamOwners), |
250 | d_calculatedTargets(other.d_calculatedTargets) |
251 | |
252 | === modified file 'src/tron/zone/zEffector.cpp' |
253 | --- src/tron/zone/zEffector.cpp 2009-02-26 19:57:28 +0000 |
254 | +++ src/tron/zone/zEffector.cpp 2009-02-27 18:21:24 +0000 |
255 | @@ -86,6 +86,9 @@ |
256 | */ |
257 | } |
258 | |
259 | +void zEffector::applyContext(gParserState const &) { |
260 | +} |
261 | + |
262 | void |
263 | zEffector::readXML(tXmlParser::node const & node) |
264 | { |
265 | @@ -291,17 +294,9 @@ |
266 | |
267 | static zEffectorRegistration regSpawnPlayer("spawnplayer", "", zEffectorSpawnPlayer::create); |
268 | |
269 | -void |
270 | -zEffectorSpawnPlayer::readXML(tXmlParser::node const & node) |
271 | -{ |
272 | - // FIXME: Unique issue, we just care about context, not the node itself |
273 | - // FIXME: Someday, this will need to be checked for the right arena/grid |
274 | - |
275 | - gParser*parser = dynamic_cast<gParser*>(node.ownerDocument()); |
276 | - assert(parser); |
277 | - |
278 | - setGrid(parser->contextGrid(node)); |
279 | - setArena(parser->contextArena(node)); |
280 | +void zEffectorSpawnPlayer::applyContext(gParserState const & state) { |
281 | + setGrid( state.get<eGrid*>("grid") ); |
282 | + setArena( state.get<gArena*>("arena") ); |
283 | } |
284 | |
285 | void zEffectorSpawnPlayer::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) |
286 | |
287 | === modified file 'src/tron/zone/zEffector.h' |
288 | --- src/tron/zone/zEffector.h 2009-02-26 19:57:28 +0000 |
289 | +++ src/tron/zone/zEffector.h 2009-02-27 18:21:24 +0000 |
290 | @@ -41,6 +41,8 @@ |
291 | #include "tFunction.h" |
292 | #include "tXmlParser.h" |
293 | |
294 | +class gParserState; |
295 | + |
296 | class zEffector |
297 | { |
298 | public: |
299 | @@ -54,6 +56,7 @@ |
300 | void apply(gVectorExtra<ePlayerNetID *> &d_calculatedTargets); |
301 | virtual void effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) { }; |
302 | |
303 | + virtual void applyContext(gParserState const &); |
304 | virtual void readXML(tXmlParser::node const &); |
305 | |
306 | void setCount(int _count) {count = _count;}; |
307 | @@ -245,7 +248,7 @@ |
308 | virtual zEffectorSpawnPlayer *copy(void) const { return new zEffectorSpawnPlayer(*this); }; |
309 | virtual ~zEffectorSpawnPlayer() {}; |
310 | |
311 | - void readXML(tXmlParser::node const &); |
312 | + void applyContext(gParserState const &); |
313 | |
314 | void setGrid(eGrid *_grid) {grid = _grid;}; |
315 | void setArena(gArena *_arena) {arena = _arena;}; |
316 | |
317 | === modified file 'src/tron/zone/zFortress.cpp' |
318 | --- src/tron/zone/zFortress.cpp 2009-02-27 03:35:38 +0000 |
319 | +++ src/tron/zone/zFortress.cpp 2009-02-27 08:58:49 +0000 |
320 | @@ -341,7 +341,10 @@ |
321 | { |
322 | int kills = int( sg_onConquestKillRatio * team->NumPlayers() ); |
323 | kills = kills > sg_onConquestKillMin ? kills : sg_onConquestKillMin; |
324 | - eCoord pos = GetPosition(); |
325 | + tCoord pos; |
326 | + if (shape) |
327 | + pos = shape->Position(); |
328 | + // FIXME: What should we use for origin if there is no shape? |
329 | |
330 | while ( kills > 0 ) |
331 | { |
332 | @@ -395,7 +398,14 @@ |
333 | { |
334 | if ( team ) |
335 | { |
336 | - sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name()) << GetPosition().x << GetPosition().y; |
337 | + if (shape) |
338 | + { |
339 | + tCoord p = shape->Position(); |
340 | + |
341 | + sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name()) << p.x << p.y; |
342 | + } |
343 | + else |
344 | + sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name()); |
345 | sg_basezoneConqueredWriter.write(); |
346 | } |
347 | if (shape) |
348 | @@ -553,7 +563,10 @@ |
349 | const tList<eGameObject>& gameObjects = Grid()->GameObjects(); |
350 | gCycle * closest = NULL; |
351 | REAL closestDistance = 0; |
352 | - eCoord pos = GetPosition(); |
353 | + tCoord pos; |
354 | + if (shape) |
355 | + pos = shape->Position(); |
356 | + // FIXME: What should we use for origin if there is no shape? |
357 | for (int i=gameObjects.Len()-1;i>=0;i--) |
358 | { |
359 | gCycle *other=dynamic_cast<gCycle *>(gameObjects(i)); |
360 | |
361 | === modified file 'src/tron/zone/zMisc.h' |
362 | --- src/tron/zone/zMisc.h 2007-06-08 21:17:35 +0000 |
363 | +++ src/tron/zone/zMisc.h 2009-02-27 18:30:44 +0000 |
364 | @@ -33,13 +33,4 @@ |
365 | return false; |
366 | } |
367 | |
368 | -/* |
369 | - * HACK |
370 | - * This is a very bad solution that hopefully will find a better design |
371 | - * |
372 | - * Basis for the "other" data that might be passed to an effect group |
373 | - * ATM: only the value from the monitor is passed |
374 | - * We use an auto_ptr so we can control if there is a value or not |
375 | -*/ |
376 | -typedef boost::shared_ptr<REAL> miscDataPtr; |
377 | #endif |
378 | |
379 | === modified file 'src/tron/zone/zSelector.cpp' |
380 | --- src/tron/zone/zSelector.cpp 2008-01-04 21:38:34 +0000 |
381 | +++ src/tron/zone/zSelector.cpp 2009-02-27 18:36:17 +0000 |
382 | @@ -839,29 +839,6 @@ |
383 | } |
384 | |
385 | |
386 | - |
387 | - |
388 | - |
389 | - |
390 | - |
391 | - |
392 | - |
393 | - |
394 | - |
395 | - |
396 | - |
397 | - |
398 | - |
399 | - |
400 | - |
401 | - |
402 | - |
403 | - |
404 | - |
405 | - |
406 | - |
407 | - |
408 | - |
409 | // |
410 | // Count the number of other alive players in the same team as thePlayer, ie: excluding thePlayer |
411 | // |
412 | |
413 | === modified file 'src/tron/zone/zShape.cpp' |
414 | --- src/tron/zone/zShape.cpp 2009-02-27 06:14:39 +0000 |
415 | +++ src/tron/zone/zShape.cpp 2009-02-27 09:12:12 +0000 |
416 | @@ -1,3 +1,4 @@ |
417 | +#include "eSoundMixer.h" |
418 | #include "rScreen.h" |
419 | #include "zShape.hpp" |
420 | #include "gCycle.h" |
421 | @@ -143,6 +144,13 @@ |
422 | setScale( state.get<tFunction>("scale") ); |
423 | } |
424 | |
425 | +void |
426 | +zShape::OnBirth() { |
427 | + eSoundMixer* mixer = eSoundMixer::GetMixer(); |
428 | + mixer->PushButton(ZONE_SPAWN, Position()); |
429 | +} |
430 | + |
431 | + |
432 | REAL zShape::calcDistanceNear(tCoord & p) { |
433 | return (findPointNear(p) - p).Norm(); |
434 | } |
435 | @@ -216,6 +224,10 @@ |
436 | ); |
437 | } |
438 | |
439 | +REAL zShape::GetCurrentScale() const { |
440 | + return scale_.Evaluate(lasttime_ - referencetime_); |
441 | +} |
442 | + |
443 | REAL zShape::GetEffectiveBottom() const { |
444 | if (bottom_.Len()) |
445 | return bottom_.evaluate(lastTime); |
446 | @@ -228,6 +240,12 @@ |
447 | return sz_zoneHeight; |
448 | } |
449 | |
450 | +tCoord zShape::GetRotation() const { |
451 | + REAL currAngle = rotation2.evaluate(lasttime_); |
452 | + tCoord rot( cos(currAngle), sin(currAngle) ); |
453 | + return rot; |
454 | +} |
455 | + |
456 | REAL zShape::GetRotationSpeed() { |
457 | return getRotation2().evaluateRate(1, lasttime_); |
458 | } |
459 | @@ -357,8 +375,7 @@ |
460 | if ( color_.a_ <= 0 ) |
461 | return; |
462 | |
463 | - REAL currAngle = rotation2.evaluate(lasttime_); |
464 | - eCoord rot( cos(currAngle), sin(currAngle) ); |
465 | + tCoord rot = GetRotation(); |
466 | |
467 | GLfloat m[4][4]={{rot.x,rot.y,0,0}, |
468 | {-rot.y,rot.x,0,0}, |
469 | @@ -444,8 +461,7 @@ |
470 | if ( color_.a_ <= 0 ) |
471 | return; |
472 | |
473 | - REAL currAngle = rotation2.evaluate(lasttime_); |
474 | - eCoord rot( cos(currAngle), sin(currAngle) ); |
475 | + tCoord rot = GetRotation(); |
476 | |
477 | GLfloat m[4][4]={{rot.x,rot.y,0,0}, |
478 | {-rot.y,rot.x,0,0}, |
479 | @@ -586,8 +602,7 @@ |
480 | REAL x_ = (*iter).first.Evaluate(lasttime_ - referencetime_); |
481 | REAL y_ = (*iter).second.Evaluate(lasttime_ - referencetime_); |
482 | tCoord centerPos = tCoord(posx_.Evaluate(lasttime_ - referencetime_), posy_.Evaluate(lasttime_ - referencetime_)); |
483 | - // tCoord rotation = tCoord( cosf(rotation_.Evaluate(lasttime_ - referencetime_)), sinf(rotation_.Evaluate(lasttime_ - referencetime_)) ); |
484 | - tCoord rotation = tCoord( cosf(rotation2.evaluate(lasttime_)), sinf(rotation2.evaluate(lasttime_)) ); |
485 | + tCoord rotation = GetRotation(); |
486 | currentScale = scale_.Evaluate(lasttime_ - referencetime_); |
487 | tCoord previous = tCoord(x_, y_).Turn( rotation )*currentScale + centerPos; |
488 | |
489 | |
490 | === modified file 'src/tron/zone/zShape.hpp' |
491 | --- src/tron/zone/zShape.hpp 2009-02-27 06:14:39 +0000 |
492 | +++ src/tron/zone/zShape.hpp 2009-02-27 09:12:12 +0000 |
493 | @@ -67,6 +67,7 @@ |
494 | tFunction getPosX() {return posx_;}; |
495 | tFunction getPosY() {return posy_;}; |
496 | tPolynomial getRotation2() { return rotation2; }; |
497 | + REAL GetCurrentScale() const; |
498 | tFunction getScale() {return scale_;}; |
499 | rColor getColor() {return color_;}; |
500 | |
501 | @@ -74,6 +75,7 @@ |
502 | REAL GetEffectiveHeight() const; |
503 | |
504 | //! shortcut rotation functions |
505 | + tCoord GetRotation() const; |
506 | REAL GetRotationSpeed(); |
507 | void SetRotationSpeed(REAL r); |
508 | REAL GetRotationAcceleration(); |
509 | @@ -87,6 +89,10 @@ |
510 | virtual void setGrowth(REAL growth); //!< similar to old zones v1 setExpansionSpeed, but generic |
511 | virtual void collapse(REAL speed); //!< set growth such that collapse happens in a timeframe |
512 | |
513 | +private: |
514 | + //! called immediately after the object is created, either right after round beginning or mid-game creation |
515 | + virtual void OnBirth(); |
516 | + |
517 | public: // DEPRECATED -- DO NOT USE |
518 | void __deprecated render(const eCamera*cam) { Render(cam); } |
519 | void __deprecated render2d(tCoord&scale) { Render2D(scale); } |
520 | @@ -103,8 +109,6 @@ |
521 | tPolynomial seglength_; //!< Length of each segment making up the zone |
522 | rColor color_; |
523 | |
524 | - eCoord Position() { return eCoord(posx_(lastTime - referencetime_), posy_(lastTime - referencetime_) ); }; |
525 | - |
526 | void setCreatedTime(REAL time); |
527 | |
528 | REAL createdtime_; // The in-game time when this shape was first instantiated |
529 | |
530 | === modified file 'src/tron/zone/zTimedZone.cpp' |
531 | --- src/tron/zone/zTimedZone.cpp 2009-02-26 22:20:40 +0000 |
532 | +++ src/tron/zone/zTimedZone.cpp 2009-02-27 18:38:14 +0000 |
533 | @@ -70,14 +70,5 @@ |
534 | |
535 | zone->setShape( shape ); |
536 | |
537 | - /* TODO FIXME |
538 | - // initialize radius and expansion speed |
539 | - static_cast<eGameObject*>(ret)->Timestep( se_GameTime() ); |
540 | - ret->SetReferenceTime(); |
541 | - ret->SetRadius( sg_initialSize ); |
542 | - ret->SetExpansionSpeed( sg_expansionSpeed ); |
543 | - ret->SetRotationSpeed( .3f ); |
544 | - */ |
545 | - |
546 | return zone; |
547 | } |
548 | |
549 | === modified file 'src/tron/zone/zZone.cpp' |
550 | --- src/tron/zone/zZone.cpp 2009-02-27 03:53:07 +0000 |
551 | +++ src/tron/zone/zZone.cpp 2009-02-27 09:12:12 +0000 |
552 | @@ -39,7 +39,6 @@ |
553 | #include "nConfig.h" |
554 | #include "tString.h" |
555 | #include "rScreen.h" |
556 | -#include "eSoundMixer.h" |
557 | #include "tPolynomial.h" |
558 | |
559 | |
560 | @@ -61,9 +60,6 @@ |
561 | |
562 | std::deque<zZone *> sz_Zones; |
563 | |
564 | -// number of segments to render a zone with |
565 | -static const int sg_segments = 11; |
566 | - |
567 | // ******************************************************************************* |
568 | // * |
569 | // * EvaluateFunctionNow |
570 | @@ -115,7 +111,6 @@ |
571 | effectGroupOutside(), |
572 | playersInside(), |
573 | playersOutside(), |
574 | - oldFortressAutomaticAssignmentBehavior_(false), |
575 | name_() |
576 | { |
577 | // store creation time |
578 | @@ -125,11 +120,6 @@ |
579 | this->AddToList(); |
580 | |
581 | sz_Zones.push_back(this); |
582 | - |
583 | - // initialize position functions |
584 | - // SetPosition( pos ); |
585 | - eSoundMixer* mixer = eSoundMixer::GetMixer(); |
586 | - mixer->PushButton(ZONE_SPAWN, pos); |
587 | } |
588 | |
589 | static nVersionFeature sz_ShapedZones(20); |
590 | @@ -149,25 +139,16 @@ |
591 | //rotation_(1,0), |
592 | playersInside(), |
593 | playersOutside(), |
594 | - oldFortressAutomaticAssignmentBehavior_(false), |
595 | name_() |
596 | { |
597 | // read creation time |
598 | createTime_ = sync.create_time(); |
599 | referenceTime_ = lastTime = createTime_; |
600 | |
601 | - // initialize color to white, ReadSync will fill in the true value if available |
602 | - // color_.r_ = color_.g_ = color_.b_ = 1.0f; |
603 | - |
604 | // add to game grid |
605 | this->AddToList(); |
606 | |
607 | sz_Zones.push_back(this); |
608 | - |
609 | - // initialize position functions |
610 | - // SetPosition( pos ); |
611 | - eSoundMixer* mixer = eSoundMixer::GetMixer(); |
612 | - mixer->PushButton(ZONE_SPAWN, pos); |
613 | } |
614 | |
615 | // ******************************************************************************* |
616 | @@ -319,31 +300,6 @@ |
617 | |
618 | bool zZone::Timestep( REAL time ) |
619 | { |
620 | - /* |
621 | - if(!emulateOldZoneShape) { |
622 | - shape->TimeStep( time ); |
623 | - } |
624 | - else { // Old representation of zone |
625 | - // rotate |
626 | - REAL speed = GetRotationSpeed(); |
627 | - REAL angle = ( time - lastTime ) * speed; |
628 | - // angle /= ( 1 + 2 * 3.14159 * angle/sg_segments ); |
629 | - rotation_ = rotation_.Turn( cos( angle ), sin( angle ) ); |
630 | - |
631 | - // move to new position |
632 | - REAL dt = time - referenceTime_; |
633 | - Move( eCoord( posx_( dt ), posy_( dt ) ), lastTime, time ); |
634 | - |
635 | - |
636 | - // kill this zone if it shrunk down to zero scale |
637 | - if ( GetExpansionSpeed() < 0 && GetScale() <= 0 ) |
638 | - { |
639 | - OnVanish(); |
640 | - return true; |
641 | - } |
642 | - } |
643 | - // update time |
644 | - */ |
645 | lastTime = time; |
646 | |
647 | return false; |
648 | @@ -519,24 +475,6 @@ |
649 | return zone_init; |
650 | } |
651 | |
652 | -/* |
653 | -// ******************************************************************************* |
654 | -// * |
655 | -// * Scale |
656 | -// * |
657 | -// ******************************************************************************* |
658 | -//! |
659 | -//! @return |
660 | -//! |
661 | -// ******************************************************************************* |
662 | - |
663 | -REAL zZone::Scale( void ) const |
664 | -{ |
665 | - // return GetScale(); |
666 | - return shape->getScale(); |
667 | -} |
668 | -*/ |
669 | - |
670 | |
671 | // ******************************************************************************* |
672 | // * |
673 | @@ -571,8 +509,7 @@ |
674 | zZone const & zZone::GetPosition( eCoord & position ) const |
675 | { |
676 | if(0 != shape) { |
677 | - position.x = EvaluateFunctionNow( shape->getPosX() ); |
678 | - position.y = EvaluateFunctionNow( shape->getPosY() ); |
679 | + position = shape->Position(); |
680 | } |
681 | return *this; |
682 | } |
683 | @@ -589,15 +526,11 @@ |
684 | |
685 | REAL zZone::GetScale( void ) const |
686 | { |
687 | - // REAL ret = EvaluateFunctionNow( this->scale_ ); |
688 | - // ret = ret > 0 ? ret : 0; |
689 | - |
690 | - |
691 | // HACK, to be implemented later and differently |
692 | // Should get this info from the shape, not the zone |
693 | REAL scale = 0.0; |
694 | if(0 != shape) { |
695 | - scale = EvaluateFunctionNow( shape->getScale() ) ; |
696 | + scale = shape->GetCurrentScale(); |
697 | } |
698 | return scale; |
699 | } |
700 | @@ -613,14 +546,6 @@ |
701 | |
702 | void zZone::SetReferenceTime( void ) |
703 | { |
704 | - // set offsets to current values |
705 | - /* |
706 | - this->posx_.SetOffset( EvaluateFunctionNow( this->posx_ ) ); |
707 | - this->posy_.SetOffset( EvaluateFunctionNow( this->posy_ ) ); |
708 | - this->scale_.SetOffset( EvaluateFunctionNow( this->scale_ ) ); |
709 | - this->rotationSpeed_.SetOffset( EvaluateFunctionNow( this->rotationSpeed_ ) ); |
710 | - */ |
711 | - |
712 | // FIXME: zZone didn't originally do this, but it is added for compat w/ |
713 | // Zones v1 porting; nothing in zones v2 seems to actually use this |
714 | // function |
715 | @@ -645,7 +570,9 @@ |
716 | { |
717 | // HACK, to be implemented later and differently |
718 | // Should get this info from the shape, not the zone |
719 | + if (!shape) |
720 | return tCoord(0.0, 0.0); |
721 | + return shape->GetRotation(); |
722 | } |
723 | |
724 | // ******************************************************************************* |
725 | |
726 | === modified file 'src/tron/zone/zZone.h' |
727 | --- src/tron/zone/zZone.h 2009-02-26 19:57:28 +0000 |
728 | +++ src/tron/zone/zZone.h 2009-02-27 09:02:54 +0000 |
729 | @@ -44,34 +44,9 @@ |
730 | |
731 | class gParserState; |
732 | |
733 | -/* |
734 | -class zZone: public eNetGameObject |
735 | -{ |
736 | - zZone(eGrid *grid); //!< local constructor |
737 | - zZone(nMessage &m); //!< network constructor |
738 | - ~zZone(); //!< destructor |
739 | - |
740 | - void SetReferenceTime(); //!< sets the reference time to the current time |
741 | - |
742 | - protected: |
743 | - virtual bool Timestep(REAL currentTime); //!< simulates behaviour up to currentTime |
744 | - virtual void OnVanish(); //!< called when the zone vanishes |
745 | -private: |
746 | - virtual void WriteCreate(nMessage &m); //!< writes data for network constructor |
747 | - virtual void WriteSync(nMessage &m); //!< writes sync data |
748 | - virtual void ReadSync(nMessage &m); //!< reads sync data |
749 | - |
750 | - virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 ); //!< looks for objects inzide the zone and reacts on them |
751 | - virtual nDescriptor& CreatorDescriptor() const; //!< returns the descriptor to recreate this object over the network |
752 | - |
753 | - virtual void Render(const eCamera *cam); //!< renders the zone |
754 | -} |
755 | -*/ |
756 | - |
757 | -class zZone: public eNetGameObject |
758 | -{ |
759 | -private: |
760 | - // TODO FIXME \ |
761 | +class zZone: public eNetGameObject |
762 | +{ |
763 | +private: |
764 | void*pos; //!< pos is not valid for zones |
765 | public: // DEPRECATED methods: please do NOT use in new code, and REPLACE in old code |
766 | REAL __deprecated GetRotationSpeed(); |
767 | @@ -100,32 +75,11 @@ |
768 | virtual void setupVisuals(gParserState &); |
769 | virtual void readXML(tXmlParser::node const &); |
770 | |
771 | - eCoord GetPosition ( void ) const; //!< Gets the current position |
772 | - zZone const & GetPosition ( eCoord & position ) const; //!< Gets the current position |
773 | - tCoord const GetRotation ( void ) const; //!< Gets the current rotation state |
774 | - REAL GetScale ( void ) const; //!< Gets the current scale |
775 | - rColor const GetColor( void ) const; //!< Gets the current color |
776 | - /* |
777 | - zZone & SetPosition ( eCoord const & position ); //!< Sets the current position |
778 | - zZone & SetVelocity ( eCoord const & velocity ); //!< Sets the current velocity |
779 | - eCoord GetVelocity ( void ) const; //!< Gets the current velocity |
780 | - zZone const & GetVelocity ( eCoord & velocity ) const; //!< Gets the current velocity |
781 | - zZone & SetScale ( REAL scale ); //!< Sets the current scale |
782 | - REAL GetScale ( void ) const; //!< Gets the current scale |
783 | - zZone const & GetScale ( REAL & scale ) const; //!< Gets the current scale |
784 | - zZone & SetExpansionSpeed ( REAL expansionSpeed ); //!< Sets the current expansion speed |
785 | - REAL GetExpansionSpeed ( void ) const; //!< Gets the current expansion speed |
786 | - zZone const & GetExpansionSpeed ( REAL & expansionSpeed ) const;//!< Gets the current expansion speed |
787 | - zZone & SetRotationSpeed ( REAL rotationSpeed ); //!< Sets the current rotation speed |
788 | - REAL GetRotationSpeed ( void ) const; //!< Gets the current rotation speed |
789 | - tCoord const & GetRotation ( void ) const; //!< Gets the current rotation state |
790 | - zZone const & GetRotationSpeed ( REAL & rotationSpeed ) const; //!< Gets the current rotation speed |
791 | - zZone & SetRotationAcceleration( REAL rotationAcceleration ); //!< Sets the current acceleration of the rotation |
792 | - REAL GetRotationAcceleration( void ) const; //!< Gets the current acceleration of the rotation |
793 | - zZone const & GetRotationAcceleration( REAL & rotationAcceleration ) const; //!< Gets the current acceleration of the rotation |
794 | - rColor const & GetColor( void ) const; //!< Gets the current color |
795 | - void SetColor( rColor const & color ); //!< Sets the current color |
796 | - */ |
797 | + eCoord __deprecated GetPosition ( void ) const; //!< Gets the current position |
798 | + zZone const & __deprecated GetPosition ( eCoord & position ) const; //!< Gets the current position |
799 | + tCoord const __deprecated GetRotation ( void ) const; //!< Gets the current rotation state |
800 | + REAL __deprecated GetScale ( void ) const; //!< Gets the current scale |
801 | + rColor const __deprecated GetColor( void ) const; //!< Gets the current color |
802 | |
803 | void addEffectGroupEnter (zEffectGroupPtr anEffectGroup) {effectGroupEnter.push_back (anEffectGroup);}; |
804 | void addEffectGroupInside (zEffectGroupPtr anEffectGroup) {effectGroupInside.push_back (anEffectGroup);}; |
805 | @@ -135,30 +89,14 @@ |
806 | void setShape (zShapePtr aShape) { shape = aShape; }; |
807 | zShapePtr getShape() { return shape; }; |
808 | |
809 | - // HACK |
810 | - // Enables fortress described in maps from format 1 to be assigned to a team according to the old behavior |
811 | - void setOldFortressAutomaticAssignmentBehavior(bool oldFortressAutomaticAssignmentBehavior) |
812 | - { |
813 | - oldFortressAutomaticAssignmentBehavior_ = oldFortressAutomaticAssignmentBehavior; |
814 | - }; |
815 | - bool getOldFortressAutomaticAssignmentBehavior() { return oldFortressAutomaticAssignmentBehavior_; }; |
816 | - |
817 | void setName(string name) {name_ = name;}; |
818 | string getName() { return name_; }; |
819 | |
820 | protected: |
821 | - // rColor color_; //!< the zone's color |
822 | REAL createTime_; //!< the time the zone was created at |
823 | zShapePtr shape; //!< the shape(s) of this zone |
824 | |
825 | REAL referenceTime_; //!< reference time for function evaluations |
826 | - /* |
827 | - tFunction posx_; //!< time dependence of x component of position |
828 | - tFunction posy_; //!< time dependence of y component of position |
829 | - tFunction scale_; //!< time dependence of scale |
830 | - tFunction rotationSpeed_; //!< the zone's rotation speed |
831 | - eCoord rotation_; //!< the current rotation state |
832 | - */ |
833 | |
834 | virtual bool Timestep(REAL currentTime); //!< simulates behaviour up to currentTime |
835 | virtual void OnVanish(); //!< called when the zone vanishes |
836 | @@ -183,15 +121,11 @@ |
837 | //! returns the descriptor responsible for this class |
838 | virtual nNetObjectDescriptorBase const & DoGetDescriptor() const; |
839 | |
840 | - // REAL Scale() const; //!< returns the current scale |
841 | - |
842 | - inline REAL EvaluateFunctionNow( tFunction const & f ) const; //!< evaluates the given function with lastTime - referenceTime_ as argument |
843 | - inline void SetFunctionNow( tFunction & f, REAL value ) const; //!< makes sure EvaluateFunctionNow() returns the given value |
844 | + inline REAL __deprecated EvaluateFunctionNow( tFunction const & f ) const; //!< evaluates the given function with lastTime - referenceTime_ as argument |
845 | + inline void __deprecated SetFunctionNow( tFunction & f, REAL value ) const; //!< makes sure EvaluateFunctionNow() returns the given value |
846 | |
847 | void RemoveFromZoneList(void); //!< Removes the zone from the sg_Zones list if it's there |
848 | |
849 | - bool oldFortressAutomaticAssignmentBehavior_; |
850 | - |
851 | string name_; |
852 | |
853 | }; |