Merge lp:~luke-jr/armagetronad/armagetronad-zonesv2-cleanup into lp:~armagetronad-dev/armagetronad/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
Reviewer Review Type Date Requested Status
Manuel Moos Approve
Review via email: mp+4020@code.launchpad.net
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
=== modified file 'src/engine/eGameObject.cpp'
--- src/engine/eGameObject.cpp 2008-04-25 18:00:53 +0000
+++ src/engine/eGameObject.cpp 2009-02-27 08:05:29 +0000
@@ -638,6 +638,14 @@
638638
639void eGameObject::OnRoundBegin(){}639void eGameObject::OnRoundBegin(){}
640void eGameObject::OnRoundEnd(){}640void eGameObject::OnRoundEnd(){}
641void eGameObject::OnBirth(){}
642
643void eGameObject::EnsureBorn() {
644 if (_born)
645 return;
646 _born = true;
647 OnBirth();
648}
641649
642void eGameObject::Kill(){}650void eGameObject::Kill(){}
643651
@@ -703,6 +711,8 @@
703711
704 tJUST_CONTROLLED_PTR< eGameObject > keep( c ); // keep object alive712 tJUST_CONTROLLED_PTR< eGameObject > keep( c ); // keep object alive
705713
714 c->EnsureBorn();
715
706 REAL maxstep=.2;716 REAL maxstep=.2;
707717
708 // don't do a thing if the timestep is too small718 // don't do a thing if the timestep is too small
709719
=== modified file 'src/engine/eGameObject.h'
--- src/engine/eGameObject.h 2008-03-08 16:55:06 +0000
+++ src/engine/eGameObject.h 2009-02-27 08:05:29 +0000
@@ -57,6 +57,9 @@
57 // small wrapper of TimestepThis doing preparation and cleanup work57 // small wrapper of TimestepThis doing preparation and cleanup work
58 static void TimestepThisWrapper(eGrid * grid, REAL currentTime, eGameObject *t, REAL minTimestep);58 static void TimestepThisWrapper(eGrid * grid, REAL currentTime, eGameObject *t, REAL minTimestep);
5959
60 //! called immediately after the object is created, either right after round beginning or mid-game creation
61 virtual void OnBirth();
62
60protected:63protected:
61 // does a timestep and all interactions for this gameobject,64 // does a timestep and all interactions for this gameobject,
62 // divided in many small steps65 // divided in many small steps
@@ -89,6 +92,8 @@
89 tJUST_CONTROLLED_PTR<eFace> currentFace; // the eFace pos it is currently92 tJUST_CONTROLLED_PTR<eFace> currentFace; // the eFace pos it is currently
90 tCHECKED_PTR(eGrid) grid; // the game grid we are on93 tCHECKED_PTR(eGrid) grid; // the game grid we are on
9194
95 bool _born;
96
92 // entry and deletion in the list of all eGameObjects97 // entry and deletion in the list of all eGameObjects
93public:98public:
94 //! tells game objects what the maximum lag caused by lazy simulation of timesteps is99 //! tells game objects what the maximum lag caused by lazy simulation of timesteps is
@@ -164,6 +169,9 @@
164 //! called when the round ends169 //! called when the round ends
165 virtual void OnRoundEnd();170 virtual void OnRoundEnd();
166171
172 //! call to ensure the object is "born"
173 void EnsureBorn();
174
167 //! destroys the gameobject (in the game)175 //! destroys the gameobject (in the game)
168 virtual void Kill();176 virtual void Kill();
169177
170178
=== modified file 'src/tools/tPolynomial.cpp'
--- src/tools/tPolynomial.cpp 2009-02-22 23:34:35 +0000
+++ src/tools/tPolynomial.cpp 2009-02-27 09:07:52 +0000
@@ -74,6 +74,14 @@
74 // Empty74 // Empty
75}75}
7676
77tPolynomial::tPolynomial(const tFunction &tf, REAL refValue) //!< constructor
78 : referenceVarValue(refValue),
79 coefs(2)
80{
81 coefs[0] = tf.offset_;
82 coefs[1] = tf.slope_;
83}
84
77tPolynomial::tPolynomial(const tFunction &tf) //!< constructor85tPolynomial::tPolynomial(const tFunction &tf) //!< constructor
78 : referenceVarValue(0.0),86 : referenceVarValue(0.0),
79 coefs(2)87 coefs(2)
8088
=== modified file 'src/tools/tPolynomial.h'
--- src/tools/tPolynomial.h 2009-02-22 23:34:35 +0000
+++ src/tools/tPolynomial.h 2009-02-27 09:07:52 +0000
@@ -54,6 +54,7 @@
54 tPolynomial(REAL value); //!< constructor for constant polynomial54 tPolynomial(REAL value); //!< constructor for constant polynomial
55 tPolynomial(tArray<REAL> const & newCoefs); //!< constructor55 tPolynomial(tArray<REAL> const & newCoefs); //!< constructor
56 tPolynomial(const tPolynomial &tf); //!< constructor56 tPolynomial(const tPolynomial &tf); //!< constructor
57 tPolynomial(const tFunction &tf, REAL refValue); //!< constructor
57 tPolynomial(const tFunction &tf); //!< constructor58 tPolynomial(const tFunction &tf); //!< constructor
58 tPolynomial(std::string str); //!< constructor59 tPolynomial(std::string str); //!< constructor
5960
6061
=== modified file 'src/tron/gGame.cpp'
--- src/tron/gGame.cpp 2009-02-26 19:57:28 +0000
+++ src/tron/gGame.cpp 2009-02-27 08:05:29 +0000
@@ -2728,6 +2728,7 @@
2728 if ( e )2728 if ( e )
2729 {2729 {
2730 e->OnRoundBegin();2730 e->OnRoundBegin();
2731 e->EnsureBorn();
2731 }2732 }
2732 }2733 }
2733 }2734 }
27342735
=== modified file 'src/tron/gParser.cpp'
--- src/tron/gParser.cpp 2009-02-26 22:15:59 +0000
+++ src/tron/gParser.cpp 2009-02-27 18:21:24 +0000
@@ -933,7 +933,9 @@
933 // Get the label of the effector to be used933 // Get the label of the effector to be used
934 string effectorAttribute( myxmlGetProp(cur, "effect"));934 string effectorAttribute( myxmlGetProp(cur, "effect"));
935935
936 effector = zEffectorPtr(zEffectorManager::Create(effectorAttribute, tXmlParser::node(cur)));936 effector = zEffectorPtr(zEffectorManager::Create(effectorAttribute));
937 effector->applyContext(state);
938 effector->readXML(tXmlParser::node(cur));
937939
938 return effector;940 return effector;
939}941}
@@ -2013,20 +2015,35 @@
20132015
2014bool2016bool
2015gParser::State_t::exists(std::string const & var)2017gParser::State_t::exists(std::string const & var)
2018const
2016{2019{
2017 return _varstack.front().find(var) != _varstack.front().end();2020 return _varstack.front().find(var) != _varstack.front().end();
2018}2021}
20192022
2020bool2023bool
2021gParser::State_t::isset(std::string const & var)2024gParser::State_t::isset(std::string const & var)
2025const
2022{2026{
2023 return exists(var) && !_varstack.front()[var]->empty();2027 if (!exists(var))
2028 return false;
2029 my_map_t vars = _varstack.front();
2030 my_map_t::const_iterator i;
2031 if ((i = vars.find(var)) == vars.end())
2032 return false;
2033 if (i->second->empty())
2034 return false;
2035 return true;
2024}2036}
20252037
2026boost::any2038boost::any
2027gParser::State_t::getAny(std::string const & var)2039gParser::State_t::getAny(std::string const & var)
2040const
2028{2041{
2029 return *(_varstack.front()[var]);2042 my_map_t vars = _varstack.front();
2043 my_map_t::const_iterator i;
2044 if ((i = vars.find(var)) == vars.end())
2045 return boost::any();
2046 return *(i->second);
2030}2047}
20312048
2032void2049void
20332050
=== modified file 'src/tron/gParser.h'
--- src/tron/gParser.h 2009-02-26 21:28:08 +0000
+++ src/tron/gParser.h 2009-02-27 18:21:24 +0000
@@ -32,13 +32,13 @@
32public:32public:
33 gParserState();33 gParserState();
3434
35 bool exists(std::string const & var);35 bool exists(std::string const & var) const;
36 bool isset(std::string const & var);36 bool isset(std::string const & var) const;
37 template<typename T> bool istype(std::string const & var) {37 template<typename T> bool istype(std::string const & var) const {
38 if (!isset(var))38 if (!isset(var))
39 return false;39 return false;
40 try {40 try {
41 boost::any_cast<T>(*(_varstack.front()[var]));41 boost::any_cast<T>(getAny(var));
42 return true;42 return true;
43 }43 }
44 catch (const boost::bad_any_cast &)44 catch (const boost::bad_any_cast &)
@@ -46,8 +46,8 @@
46 return false;46 return false;
47 }47 }
48 }48 }
49 boost::any getAny(std::string const & var);49 boost::any getAny(std::string const & var) const;
50 template<typename T> T get(std::string const & var) {50 template<typename T> T get(std::string const & var) const {
51 return boost::any_cast<T>(getAny(var));51 return boost::any_cast<T>(getAny(var));
52 }52 }
53 void setAny(std::string const & var, boost::any val);53 void setAny(std::string const & var, boost::any val);
5454
=== removed file 'src/tron/zone/shapeCircle.h'
--- src/tron/zone/shapeCircle.h 2006-08-02 20:19:33 +0000
+++ src/tron/zone/shapeCircle.h 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1typedef boost::shared_ptr<shape> ShapePtr;
2
3class shape {
4 virtual ~shape();
5};
6
7class shapeCircle : public shape {
8 tValue::Base() x;
9 tValue::Base() y;
10 tValue::Base() radius;
11
12public :
13 shapeCircle(tValue::Base() _x, tValue::Base() _y, tValue::Base() _radius): x(_x), y(_y), radius(_radius) { };
14
15};
16
17class shapeTriangle : public shape {
18 tValue::Base() x1;
19 tValue::Base() y1;
20 tValue::Base() x2;
21 tValue::Base() y2;
22 tValue::Base() x3;
23 tValue::Base() y3;
24
25public:
26 shapeSquare(tValue::Base() _x1, tValue::Base() _y1,
27 tValue::Base() _x2, tValue::Base() _y2,
28 tValue::Base() _x3, tValue::Base() _y3,
29 ):
30 x1(_x1), y1(_y1),
31 x2(_x2), y2(_y2),
32 x3(_x3), y3(_y3)
33 {};
34};
350
=== modified file 'src/tron/zone/zEffectGroup.cpp'
--- src/tron/zone/zEffectGroup.cpp 2009-02-03 08:50:43 +0000
+++ src/tron/zone/zEffectGroup.cpp 2009-02-27 16:25:51 +0000
@@ -29,8 +29,6 @@
2929
30zEffectGroup::zEffectGroup(gVectorExtra< nNetObjectID > const owners, gVectorExtra< nNetObjectID > const teamOwners):30zEffectGroup::zEffectGroup(gVectorExtra< nNetObjectID > const owners, gVectorExtra< nNetObjectID > const teamOwners):
31 validators(),31 validators(),
32 // monitorInfluences(),
33 // zoneInfluences(),
34 d_owners(owners),32 d_owners(owners),
35 d_teamOwners(teamOwners),33 d_teamOwners(teamOwners),
36 d_calculatedTargets()34 d_calculatedTargets()
@@ -38,8 +36,6 @@
3836
39zEffectGroup::zEffectGroup(zEffectGroup const &other) :37zEffectGroup::zEffectGroup(zEffectGroup const &other) :
40 validators(other.validators),38 validators(other.validators),
41 // monitorInfluences(other.monitorInfluences),
42 // zoneInfluences(other.zoneInfluences),
43 d_owners(other.d_owners),39 d_owners(other.d_owners),
44 d_teamOwners(other.d_teamOwners),40 d_teamOwners(other.d_teamOwners),
45 d_calculatedTargets(other.d_calculatedTargets)41 d_calculatedTargets(other.d_calculatedTargets)
4642
=== modified file 'src/tron/zone/zEffector.cpp'
--- src/tron/zone/zEffector.cpp 2009-02-26 19:57:28 +0000
+++ src/tron/zone/zEffector.cpp 2009-02-27 18:21:24 +0000
@@ -86,6 +86,9 @@
86 */86 */
87}87}
8888
89void zEffector::applyContext(gParserState const &) {
90}
91
89void92void
90zEffector::readXML(tXmlParser::node const & node)93zEffector::readXML(tXmlParser::node const & node)
91{94{
@@ -291,17 +294,9 @@
291294
292static zEffectorRegistration regSpawnPlayer("spawnplayer", "", zEffectorSpawnPlayer::create);295static zEffectorRegistration regSpawnPlayer("spawnplayer", "", zEffectorSpawnPlayer::create);
293296
294void297void zEffectorSpawnPlayer::applyContext(gParserState const & state) {
295zEffectorSpawnPlayer::readXML(tXmlParser::node const & node)298 setGrid( state.get<eGrid*>("grid") );
296{299 setArena( state.get<gArena*>("arena") );
297 // FIXME: Unique issue, we just care about context, not the node itself
298 // FIXME: Someday, this will need to be checked for the right arena/grid
299
300 gParser*parser = dynamic_cast<gParser*>(node.ownerDocument());
301 assert(parser);
302
303 setGrid(parser->contextGrid(node));
304 setArena(parser->contextArena(node));
305}300}
306301
307void zEffectorSpawnPlayer::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)302void zEffectorSpawnPlayer::effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets)
308303
=== modified file 'src/tron/zone/zEffector.h'
--- src/tron/zone/zEffector.h 2009-02-26 19:57:28 +0000
+++ src/tron/zone/zEffector.h 2009-02-27 18:21:24 +0000
@@ -41,6 +41,8 @@
41#include "tFunction.h"41#include "tFunction.h"
42#include "tXmlParser.h"42#include "tXmlParser.h"
4343
44class gParserState;
45
44class zEffector46class zEffector
45{47{
46public:48public:
@@ -54,6 +56,7 @@
54 void apply(gVectorExtra<ePlayerNetID *> &d_calculatedTargets);56 void apply(gVectorExtra<ePlayerNetID *> &d_calculatedTargets);
55 virtual void effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) { };57 virtual void effect(gVectorExtra<ePlayerNetID *> &d_calculatedTargets) { };
5658
59 virtual void applyContext(gParserState const &);
57 virtual void readXML(tXmlParser::node const &);60 virtual void readXML(tXmlParser::node const &);
5861
59 void setCount(int _count) {count = _count;};62 void setCount(int _count) {count = _count;};
@@ -245,7 +248,7 @@
245 virtual zEffectorSpawnPlayer *copy(void) const { return new zEffectorSpawnPlayer(*this); };248 virtual zEffectorSpawnPlayer *copy(void) const { return new zEffectorSpawnPlayer(*this); };
246 virtual ~zEffectorSpawnPlayer() {};249 virtual ~zEffectorSpawnPlayer() {};
247250
248 void readXML(tXmlParser::node const &);251 void applyContext(gParserState const &);
249252
250 void setGrid(eGrid *_grid) {grid = _grid;};253 void setGrid(eGrid *_grid) {grid = _grid;};
251 void setArena(gArena *_arena) {arena = _arena;};254 void setArena(gArena *_arena) {arena = _arena;};
252255
=== modified file 'src/tron/zone/zFortress.cpp'
--- src/tron/zone/zFortress.cpp 2009-02-27 03:35:38 +0000
+++ src/tron/zone/zFortress.cpp 2009-02-27 08:58:49 +0000
@@ -341,7 +341,10 @@
341 {341 {
342 int kills = int( sg_onConquestKillRatio * team->NumPlayers() );342 int kills = int( sg_onConquestKillRatio * team->NumPlayers() );
343 kills = kills > sg_onConquestKillMin ? kills : sg_onConquestKillMin;343 kills = kills > sg_onConquestKillMin ? kills : sg_onConquestKillMin;
344 eCoord pos = GetPosition();344 tCoord pos;
345 if (shape)
346 pos = shape->Position();
347 // FIXME: What should we use for origin if there is no shape?
345348
346 while ( kills > 0 )349 while ( kills > 0 )
347 {350 {
@@ -395,7 +398,14 @@
395{398{
396 if ( team )399 if ( team )
397 {400 {
398 sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name()) << GetPosition().x << GetPosition().y;401 if (shape)
402 {
403 tCoord p = shape->Position();
404
405 sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name()) << p.x << p.y;
406 }
407 else
408 sg_basezoneConqueredWriter << ePlayerNetID::FilterName(team->Name());
399 sg_basezoneConqueredWriter.write();409 sg_basezoneConqueredWriter.write();
400 }410 }
401 if (shape)411 if (shape)
@@ -553,7 +563,10 @@
553 const tList<eGameObject>& gameObjects = Grid()->GameObjects();563 const tList<eGameObject>& gameObjects = Grid()->GameObjects();
554 gCycle * closest = NULL;564 gCycle * closest = NULL;
555 REAL closestDistance = 0;565 REAL closestDistance = 0;
556 eCoord pos = GetPosition();566 tCoord pos;
567 if (shape)
568 pos = shape->Position();
569 // FIXME: What should we use for origin if there is no shape?
557 for (int i=gameObjects.Len()-1;i>=0;i--)570 for (int i=gameObjects.Len()-1;i>=0;i--)
558 {571 {
559 gCycle *other=dynamic_cast<gCycle *>(gameObjects(i));572 gCycle *other=dynamic_cast<gCycle *>(gameObjects(i));
560573
=== modified file 'src/tron/zone/zMisc.h'
--- src/tron/zone/zMisc.h 2007-06-08 21:17:35 +0000
+++ src/tron/zone/zMisc.h 2009-02-27 18:30:44 +0000
@@ -33,13 +33,4 @@
33 return false;33 return false;
34}34}
3535
36/*
37 * HACK
38 * This is a very bad solution that hopefully will find a better design
39 *
40 * Basis for the "other" data that might be passed to an effect group
41 * ATM: only the value from the monitor is passed
42 * We use an auto_ptr so we can control if there is a value or not
43*/
44typedef boost::shared_ptr<REAL> miscDataPtr;
45#endif36#endif
4637
=== modified file 'src/tron/zone/zSelector.cpp'
--- src/tron/zone/zSelector.cpp 2008-01-04 21:38:34 +0000
+++ src/tron/zone/zSelector.cpp 2009-02-27 18:36:17 +0000
@@ -839,29 +839,6 @@
839}839}
840840
841841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865//842//
866// Count the number of other alive players in the same team as thePlayer, ie: excluding thePlayer843// Count the number of other alive players in the same team as thePlayer, ie: excluding thePlayer
867//844//
868845
=== modified file 'src/tron/zone/zShape.cpp'
--- src/tron/zone/zShape.cpp 2009-02-27 06:14:39 +0000
+++ src/tron/zone/zShape.cpp 2009-02-27 09:12:12 +0000
@@ -1,3 +1,4 @@
1#include "eSoundMixer.h"
1#include "rScreen.h"2#include "rScreen.h"
2#include "zShape.hpp"3#include "zShape.hpp"
3#include "gCycle.h"4#include "gCycle.h"
@@ -143,6 +144,13 @@
143 setScale( state.get<tFunction>("scale") );144 setScale( state.get<tFunction>("scale") );
144}145}
145146
147void
148zShape::OnBirth() {
149 eSoundMixer* mixer = eSoundMixer::GetMixer();
150 mixer->PushButton(ZONE_SPAWN, Position());
151}
152
153
146REAL zShape::calcDistanceNear(tCoord & p) {154REAL zShape::calcDistanceNear(tCoord & p) {
147 return (findPointNear(p) - p).Norm();155 return (findPointNear(p) - p).Norm();
148}156}
@@ -216,6 +224,10 @@
216 );224 );
217}225}
218226
227REAL zShape::GetCurrentScale() const {
228 return scale_.Evaluate(lasttime_ - referencetime_);
229}
230
219REAL zShape::GetEffectiveBottom() const {231REAL zShape::GetEffectiveBottom() const {
220 if (bottom_.Len())232 if (bottom_.Len())
221 return bottom_.evaluate(lastTime);233 return bottom_.evaluate(lastTime);
@@ -228,6 +240,12 @@
228 return sz_zoneHeight;240 return sz_zoneHeight;
229}241}
230242
243tCoord zShape::GetRotation() const {
244 REAL currAngle = rotation2.evaluate(lasttime_);
245 tCoord rot( cos(currAngle), sin(currAngle) );
246 return rot;
247}
248
231REAL zShape::GetRotationSpeed() {249REAL zShape::GetRotationSpeed() {
232 return getRotation2().evaluateRate(1, lasttime_);250 return getRotation2().evaluateRate(1, lasttime_);
233}251}
@@ -357,8 +375,7 @@
357 if ( color_.a_ <= 0 )375 if ( color_.a_ <= 0 )
358 return;376 return;
359377
360 REAL currAngle = rotation2.evaluate(lasttime_);378 tCoord rot = GetRotation();
361 eCoord rot( cos(currAngle), sin(currAngle) );
362379
363 GLfloat m[4][4]={{rot.x,rot.y,0,0},380 GLfloat m[4][4]={{rot.x,rot.y,0,0},
364 {-rot.y,rot.x,0,0},381 {-rot.y,rot.x,0,0},
@@ -444,8 +461,7 @@
444 if ( color_.a_ <= 0 )461 if ( color_.a_ <= 0 )
445 return;462 return;
446463
447 REAL currAngle = rotation2.evaluate(lasttime_);464 tCoord rot = GetRotation();
448 eCoord rot( cos(currAngle), sin(currAngle) );
449465
450 GLfloat m[4][4]={{rot.x,rot.y,0,0},466 GLfloat m[4][4]={{rot.x,rot.y,0,0},
451 {-rot.y,rot.x,0,0},467 {-rot.y,rot.x,0,0},
@@ -586,8 +602,7 @@
586 REAL x_ = (*iter).first.Evaluate(lasttime_ - referencetime_);602 REAL x_ = (*iter).first.Evaluate(lasttime_ - referencetime_);
587 REAL y_ = (*iter).second.Evaluate(lasttime_ - referencetime_);603 REAL y_ = (*iter).second.Evaluate(lasttime_ - referencetime_);
588 tCoord centerPos = tCoord(posx_.Evaluate(lasttime_ - referencetime_), posy_.Evaluate(lasttime_ - referencetime_));604 tCoord centerPos = tCoord(posx_.Evaluate(lasttime_ - referencetime_), posy_.Evaluate(lasttime_ - referencetime_));
589 // tCoord rotation = tCoord( cosf(rotation_.Evaluate(lasttime_ - referencetime_)), sinf(rotation_.Evaluate(lasttime_ - referencetime_)) );605 tCoord rotation = GetRotation();
590 tCoord rotation = tCoord( cosf(rotation2.evaluate(lasttime_)), sinf(rotation2.evaluate(lasttime_)) );
591 currentScale = scale_.Evaluate(lasttime_ - referencetime_);606 currentScale = scale_.Evaluate(lasttime_ - referencetime_);
592 tCoord previous = tCoord(x_, y_).Turn( rotation )*currentScale + centerPos;607 tCoord previous = tCoord(x_, y_).Turn( rotation )*currentScale + centerPos;
593608
594609
=== modified file 'src/tron/zone/zShape.hpp'
--- src/tron/zone/zShape.hpp 2009-02-27 06:14:39 +0000
+++ src/tron/zone/zShape.hpp 2009-02-27 09:12:12 +0000
@@ -67,6 +67,7 @@
67 tFunction getPosX() {return posx_;};67 tFunction getPosX() {return posx_;};
68 tFunction getPosY() {return posy_;};68 tFunction getPosY() {return posy_;};
69 tPolynomial getRotation2() { return rotation2; };69 tPolynomial getRotation2() { return rotation2; };
70 REAL GetCurrentScale() const;
70 tFunction getScale() {return scale_;};71 tFunction getScale() {return scale_;};
71 rColor getColor() {return color_;};72 rColor getColor() {return color_;};
7273
@@ -74,6 +75,7 @@
74 REAL GetEffectiveHeight() const;75 REAL GetEffectiveHeight() const;
7576
76 //! shortcut rotation functions77 //! shortcut rotation functions
78 tCoord GetRotation() const;
77 REAL GetRotationSpeed();79 REAL GetRotationSpeed();
78 void SetRotationSpeed(REAL r);80 void SetRotationSpeed(REAL r);
79 REAL GetRotationAcceleration();81 REAL GetRotationAcceleration();
@@ -87,6 +89,10 @@
87 virtual void setGrowth(REAL growth); //!< similar to old zones v1 setExpansionSpeed, but generic89 virtual void setGrowth(REAL growth); //!< similar to old zones v1 setExpansionSpeed, but generic
88 virtual void collapse(REAL speed); //!< set growth such that collapse happens in a timeframe90 virtual void collapse(REAL speed); //!< set growth such that collapse happens in a timeframe
8991
92private:
93 //! called immediately after the object is created, either right after round beginning or mid-game creation
94 virtual void OnBirth();
95
90public: // DEPRECATED -- DO NOT USE96public: // DEPRECATED -- DO NOT USE
91 void __deprecated render(const eCamera*cam) { Render(cam); }97 void __deprecated render(const eCamera*cam) { Render(cam); }
92 void __deprecated render2d(tCoord&scale) { Render2D(scale); }98 void __deprecated render2d(tCoord&scale) { Render2D(scale); }
@@ -103,8 +109,6 @@
103 tPolynomial seglength_; //!< Length of each segment making up the zone109 tPolynomial seglength_; //!< Length of each segment making up the zone
104 rColor color_;110 rColor color_;
105111
106 eCoord Position() { return eCoord(posx_(lastTime - referencetime_), posy_(lastTime - referencetime_) ); };
107
108 void setCreatedTime(REAL time);112 void setCreatedTime(REAL time);
109113
110 REAL createdtime_; // The in-game time when this shape was first instantiated114 REAL createdtime_; // The in-game time when this shape was first instantiated
111115
=== modified file 'src/tron/zone/zTimedZone.cpp'
--- src/tron/zone/zTimedZone.cpp 2009-02-26 22:20:40 +0000
+++ src/tron/zone/zTimedZone.cpp 2009-02-27 18:38:14 +0000
@@ -70,14 +70,5 @@
7070
71 zone->setShape( shape );71 zone->setShape( shape );
7272
73 /* TODO FIXME
74 // initialize radius and expansion speed
75 static_cast<eGameObject*>(ret)->Timestep( se_GameTime() );
76 ret->SetReferenceTime();
77 ret->SetRadius( sg_initialSize );
78 ret->SetExpansionSpeed( sg_expansionSpeed );
79 ret->SetRotationSpeed( .3f );
80 */
81
82 return zone;73 return zone;
83}74}
8475
=== modified file 'src/tron/zone/zZone.cpp'
--- src/tron/zone/zZone.cpp 2009-02-27 03:53:07 +0000
+++ src/tron/zone/zZone.cpp 2009-02-27 09:12:12 +0000
@@ -39,7 +39,6 @@
39#include "nConfig.h"39#include "nConfig.h"
40#include "tString.h"40#include "tString.h"
41#include "rScreen.h"41#include "rScreen.h"
42#include "eSoundMixer.h"
43#include "tPolynomial.h"42#include "tPolynomial.h"
4443
4544
@@ -61,9 +60,6 @@
6160
62std::deque<zZone *> sz_Zones;61std::deque<zZone *> sz_Zones;
6362
64// number of segments to render a zone with
65static const int sg_segments = 11;
66
67// *******************************************************************************63// *******************************************************************************
68// *64// *
69// * EvaluateFunctionNow65// * EvaluateFunctionNow
@@ -115,7 +111,6 @@
115 effectGroupOutside(),111 effectGroupOutside(),
116 playersInside(),112 playersInside(),
117 playersOutside(),113 playersOutside(),
118 oldFortressAutomaticAssignmentBehavior_(false),
119 name_()114 name_()
120{115{
121 // store creation time116 // store creation time
@@ -125,11 +120,6 @@
125 this->AddToList();120 this->AddToList();
126121
127 sz_Zones.push_back(this);122 sz_Zones.push_back(this);
128
129 // initialize position functions
130 // SetPosition( pos );
131 eSoundMixer* mixer = eSoundMixer::GetMixer();
132 mixer->PushButton(ZONE_SPAWN, pos);
133}123}
134124
135static nVersionFeature sz_ShapedZones(20);125static nVersionFeature sz_ShapedZones(20);
@@ -149,25 +139,16 @@
149 //rotation_(1,0),139 //rotation_(1,0),
150 playersInside(),140 playersInside(),
151 playersOutside(),141 playersOutside(),
152 oldFortressAutomaticAssignmentBehavior_(false),
153 name_()142 name_()
154{143{
155 // read creation time144 // read creation time
156 createTime_ = sync.create_time();145 createTime_ = sync.create_time();
157 referenceTime_ = lastTime = createTime_;146 referenceTime_ = lastTime = createTime_;
158147
159 // initialize color to white, ReadSync will fill in the true value if available
160 // color_.r_ = color_.g_ = color_.b_ = 1.0f;
161
162 // add to game grid148 // add to game grid
163 this->AddToList();149 this->AddToList();
164150
165 sz_Zones.push_back(this);151 sz_Zones.push_back(this);
166
167 // initialize position functions
168 // SetPosition( pos );
169 eSoundMixer* mixer = eSoundMixer::GetMixer();
170 mixer->PushButton(ZONE_SPAWN, pos);
171}152}
172153
173// *******************************************************************************154// *******************************************************************************
@@ -319,31 +300,6 @@
319300
320bool zZone::Timestep( REAL time )301bool zZone::Timestep( REAL time )
321{302{
322 /*
323 if(!emulateOldZoneShape) {
324 shape->TimeStep( time );
325 }
326 else { // Old representation of zone
327 // rotate
328 REAL speed = GetRotationSpeed();
329 REAL angle = ( time - lastTime ) * speed;
330 // angle /= ( 1 + 2 * 3.14159 * angle/sg_segments );
331 rotation_ = rotation_.Turn( cos( angle ), sin( angle ) );
332
333 // move to new position
334 REAL dt = time - referenceTime_;
335 Move( eCoord( posx_( dt ), posy_( dt ) ), lastTime, time );
336
337
338 // kill this zone if it shrunk down to zero scale
339 if ( GetExpansionSpeed() < 0 && GetScale() <= 0 )
340 {
341 OnVanish();
342 return true;
343 }
344 }
345 // update time
346 */
347 lastTime = time;303 lastTime = time;
348304
349 return false;305 return false;
@@ -519,24 +475,6 @@
519 return zone_init;475 return zone_init;
520}476}
521477
522/*
523// *******************************************************************************
524// *
525// * Scale
526// *
527// *******************************************************************************
528//!
529//! @return
530//!
531// *******************************************************************************
532
533REAL zZone::Scale( void ) const
534{
535 // return GetScale();
536 return shape->getScale();
537}
538*/
539
540478
541// *******************************************************************************479// *******************************************************************************
542// *480// *
@@ -571,8 +509,7 @@
571zZone const & zZone::GetPosition( eCoord & position ) const509zZone const & zZone::GetPosition( eCoord & position ) const
572{510{
573 if(0 != shape) {511 if(0 != shape) {
574 position.x = EvaluateFunctionNow( shape->getPosX() );512 position = shape->Position();
575 position.y = EvaluateFunctionNow( shape->getPosY() );
576 }513 }
577 return *this;514 return *this;
578}515}
@@ -589,15 +526,11 @@
589526
590REAL zZone::GetScale( void ) const527REAL zZone::GetScale( void ) const
591{528{
592 // REAL ret = EvaluateFunctionNow( this->scale_ );
593 // ret = ret > 0 ? ret : 0;
594
595
596 // HACK, to be implemented later and differently529 // HACK, to be implemented later and differently
597 // Should get this info from the shape, not the zone530 // Should get this info from the shape, not the zone
598 REAL scale = 0.0;531 REAL scale = 0.0;
599 if(0 != shape) {532 if(0 != shape) {
600 scale = EvaluateFunctionNow( shape->getScale() ) ;533 scale = shape->GetCurrentScale();
601 }534 }
602 return scale;535 return scale;
603}536}
@@ -613,14 +546,6 @@
613546
614void zZone::SetReferenceTime( void )547void zZone::SetReferenceTime( void )
615{548{
616 // set offsets to current values
617 /*
618 this->posx_.SetOffset( EvaluateFunctionNow( this->posx_ ) );
619 this->posy_.SetOffset( EvaluateFunctionNow( this->posy_ ) );
620 this->scale_.SetOffset( EvaluateFunctionNow( this->scale_ ) );
621 this->rotationSpeed_.SetOffset( EvaluateFunctionNow( this->rotationSpeed_ ) );
622 */
623
624 // FIXME: zZone didn't originally do this, but it is added for compat w/549 // FIXME: zZone didn't originally do this, but it is added for compat w/
625 // Zones v1 porting; nothing in zones v2 seems to actually use this550 // Zones v1 porting; nothing in zones v2 seems to actually use this
626 // function551 // function
@@ -645,7 +570,9 @@
645{570{
646 // HACK, to be implemented later and differently571 // HACK, to be implemented later and differently
647 // Should get this info from the shape, not the zone572 // Should get this info from the shape, not the zone
573 if (!shape)
648 return tCoord(0.0, 0.0);574 return tCoord(0.0, 0.0);
575 return shape->GetRotation();
649}576}
650577
651// *******************************************************************************578// *******************************************************************************
652579
=== modified file 'src/tron/zone/zZone.h'
--- src/tron/zone/zZone.h 2009-02-26 19:57:28 +0000
+++ src/tron/zone/zZone.h 2009-02-27 09:02:54 +0000
@@ -44,34 +44,9 @@
4444
45class gParserState;45class gParserState;
4646
47/*47class zZone: public eNetGameObject
48class zZone: public eNetGameObject48{
49{49private:
50 zZone(eGrid *grid); //!< local constructor
51 zZone(nMessage &m); //!< network constructor
52 ~zZone(); //!< destructor
53
54 void SetReferenceTime(); //!< sets the reference time to the current time
55
56 protected:
57 virtual bool Timestep(REAL currentTime); //!< simulates behaviour up to currentTime
58 virtual void OnVanish(); //!< called when the zone vanishes
59private:
60 virtual void WriteCreate(nMessage &m); //!< writes data for network constructor
61 virtual void WriteSync(nMessage &m); //!< writes sync data
62 virtual void ReadSync(nMessage &m); //!< reads sync data
63
64 virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 ); //!< looks for objects inzide the zone and reacts on them
65 virtual nDescriptor& CreatorDescriptor() const; //!< returns the descriptor to recreate this object over the network
66
67 virtual void Render(const eCamera *cam); //!< renders the zone
68}
69*/
70
71class zZone: public eNetGameObject
72{
73private:
74 // TODO FIXME \
75 void*pos; //!< pos is not valid for zones50 void*pos; //!< pos is not valid for zones
76public: // DEPRECATED methods: please do NOT use in new code, and REPLACE in old code51public: // DEPRECATED methods: please do NOT use in new code, and REPLACE in old code
77 REAL __deprecated GetRotationSpeed();52 REAL __deprecated GetRotationSpeed();
@@ -100,32 +75,11 @@
100 virtual void setupVisuals(gParserState &);75 virtual void setupVisuals(gParserState &);
101 virtual void readXML(tXmlParser::node const &);76 virtual void readXML(tXmlParser::node const &);
10277
103 eCoord GetPosition ( void ) const; //!< Gets the current position78 eCoord __deprecated GetPosition ( void ) const; //!< Gets the current position
104 zZone const & GetPosition ( eCoord & position ) const; //!< Gets the current position79 zZone const & __deprecated GetPosition ( eCoord & position ) const; //!< Gets the current position
105 tCoord const GetRotation ( void ) const; //!< Gets the current rotation state80 tCoord const __deprecated GetRotation ( void ) const; //!< Gets the current rotation state
106 REAL GetScale ( void ) const; //!< Gets the current scale81 REAL __deprecated GetScale ( void ) const; //!< Gets the current scale
107 rColor const GetColor( void ) const; //!< Gets the current color82 rColor const __deprecated GetColor( void ) const; //!< Gets the current color
108 /*
109 zZone & SetPosition ( eCoord const & position ); //!< Sets the current position
110 zZone & SetVelocity ( eCoord const & velocity ); //!< Sets the current velocity
111 eCoord GetVelocity ( void ) const; //!< Gets the current velocity
112 zZone const & GetVelocity ( eCoord & velocity ) const; //!< Gets the current velocity
113 zZone & SetScale ( REAL scale ); //!< Sets the current scale
114 REAL GetScale ( void ) const; //!< Gets the current scale
115 zZone const & GetScale ( REAL & scale ) const; //!< Gets the current scale
116 zZone & SetExpansionSpeed ( REAL expansionSpeed ); //!< Sets the current expansion speed
117 REAL GetExpansionSpeed ( void ) const; //!< Gets the current expansion speed
118 zZone const & GetExpansionSpeed ( REAL & expansionSpeed ) const;//!< Gets the current expansion speed
119 zZone & SetRotationSpeed ( REAL rotationSpeed ); //!< Sets the current rotation speed
120 REAL GetRotationSpeed ( void ) const; //!< Gets the current rotation speed
121 tCoord const & GetRotation ( void ) const; //!< Gets the current rotation state
122 zZone const & GetRotationSpeed ( REAL & rotationSpeed ) const; //!< Gets the current rotation speed
123 zZone & SetRotationAcceleration( REAL rotationAcceleration ); //!< Sets the current acceleration of the rotation
124 REAL GetRotationAcceleration( void ) const; //!< Gets the current acceleration of the rotation
125 zZone const & GetRotationAcceleration( REAL & rotationAcceleration ) const; //!< Gets the current acceleration of the rotation
126 rColor const & GetColor( void ) const; //!< Gets the current color
127 void SetColor( rColor const & color ); //!< Sets the current color
128 */
12983
130 void addEffectGroupEnter (zEffectGroupPtr anEffectGroup) {effectGroupEnter.push_back (anEffectGroup);};84 void addEffectGroupEnter (zEffectGroupPtr anEffectGroup) {effectGroupEnter.push_back (anEffectGroup);};
131 void addEffectGroupInside (zEffectGroupPtr anEffectGroup) {effectGroupInside.push_back (anEffectGroup);};85 void addEffectGroupInside (zEffectGroupPtr anEffectGroup) {effectGroupInside.push_back (anEffectGroup);};
@@ -135,30 +89,14 @@
135 void setShape (zShapePtr aShape) { shape = aShape; };89 void setShape (zShapePtr aShape) { shape = aShape; };
136 zShapePtr getShape() { return shape; };90 zShapePtr getShape() { return shape; };
13791
138 // HACK
139 // Enables fortress described in maps from format 1 to be assigned to a team according to the old behavior
140 void setOldFortressAutomaticAssignmentBehavior(bool oldFortressAutomaticAssignmentBehavior)
141 {
142 oldFortressAutomaticAssignmentBehavior_ = oldFortressAutomaticAssignmentBehavior;
143 };
144 bool getOldFortressAutomaticAssignmentBehavior() { return oldFortressAutomaticAssignmentBehavior_; };
145
146 void setName(string name) {name_ = name;};92 void setName(string name) {name_ = name;};
147 string getName() { return name_; };93 string getName() { return name_; };
14894
149protected:95protected:
150 // rColor color_; //!< the zone's color
151 REAL createTime_; //!< the time the zone was created at96 REAL createTime_; //!< the time the zone was created at
152 zShapePtr shape; //!< the shape(s) of this zone97 zShapePtr shape; //!< the shape(s) of this zone
15398
154 REAL referenceTime_; //!< reference time for function evaluations99 REAL referenceTime_; //!< reference time for function evaluations
155 /*
156 tFunction posx_; //!< time dependence of x component of position
157 tFunction posy_; //!< time dependence of y component of position
158 tFunction scale_; //!< time dependence of scale
159 tFunction rotationSpeed_; //!< the zone's rotation speed
160 eCoord rotation_; //!< the current rotation state
161 */
162100
163 virtual bool Timestep(REAL currentTime); //!< simulates behaviour up to currentTime101 virtual bool Timestep(REAL currentTime); //!< simulates behaviour up to currentTime
164 virtual void OnVanish(); //!< called when the zone vanishes102 virtual void OnVanish(); //!< called when the zone vanishes
@@ -183,15 +121,11 @@
183 //! returns the descriptor responsible for this class121 //! returns the descriptor responsible for this class
184 virtual nNetObjectDescriptorBase const & DoGetDescriptor() const;122 virtual nNetObjectDescriptorBase const & DoGetDescriptor() const;
185123
186 // REAL Scale() const; //!< returns the current scale124 inline REAL __deprecated EvaluateFunctionNow( tFunction const & f ) const; //!< evaluates the given function with lastTime - referenceTime_ as argument
187125 inline void __deprecated SetFunctionNow( tFunction & f, REAL value ) const; //!< makes sure EvaluateFunctionNow() returns the given value
188 inline REAL EvaluateFunctionNow( tFunction const & f ) const; //!< evaluates the given function with lastTime - referenceTime_ as argument
189 inline void SetFunctionNow( tFunction & f, REAL value ) const; //!< makes sure EvaluateFunctionNow() returns the given value
190126
191 void RemoveFromZoneList(void); //!< Removes the zone from the sg_Zones list if it's there127 void RemoveFromZoneList(void); //!< Removes the zone from the sg_Zones list if it's there
192128
193 bool oldFortressAutomaticAssignmentBehavior_;
194
195 string name_;129 string name_;
196130
197};131};

Subscribers

People subscribed via source and target branches

to status/vote changes: