/[enigma]/enigma/src/laser.cc
ViewVC logotype

Diff of /enigma/src/laser.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by reallysoft, Fri Mar 28 14:52:33 2003 UTC revision 1.7 by dheck, Fri Apr 4 19:44:04 2003 UTC
# Line 91  an incoming beam). Line 91  an incoming beam).
91    
92  */  */
93      class LaserStone : public LaserEmitter, public OnOffStone {      class LaserStone : public LaserEmitter, public OnOffStone {
         INSTANCELISTOBJ(LaserStone);  
94      public:      public:
95          LaserStone() : OnOffStone("st-laser") {          LaserStone (Direction dir=EAST);
             set_attrib("dir", Value(EAST));  
         }  
96          static void reemit_all();          static void reemit_all();
97    
98      private:      private:
99          // LaserEmitter interface  
100          DirectionBits emission_directions() const {  //        INSTANCELISTOBJ(LaserStone);
101              if (is_on()) {  
102                  return to_bits(get_dir());  // We can't use this macro here, sorry.  Problem is: g++ can't deal
103              }  // with both multiple inheritance and covariant return types at the
104              return NODIRBIT;  // same time ("sorry, not implemented: ..." first time I ever saw this
105    // error message :-) So far LaserStone is the only object with this
106    // problem, so it's easier to insert the appropriate code by hand.
107    // Doing away with the covariant return type in INSTANCELISTOBJ would
108    // also be a solution; I'm not quite sure which is better...
109    
110            typedef std::vector<LaserStone*> InstanceList;
111            static InstanceList instances;
112            Object *clone() {
113                LaserStone *o = new LaserStone(*this);
114                instances.push_back(o);
115                return o;
116            }
117            void dispose() {
118                instances.erase(find(instances.begin(), instances.end(), this));
119                delete this;
120          }          }
121    
122            // LaserEmitter interface
123            DirectionBits emission_directions() const;
124    
125          // OnOffStone interface.          // OnOffStone interface.
126          void notify_onoff(bool on);          void notify_onoff(bool on);
127    
# Line 318  LaserBeam::dispose() Line 333  LaserBeam::dispose()
333  //----------------------------------------  //----------------------------------------
334  LaserStone::InstanceList LaserStone::instances;  LaserStone::InstanceList LaserStone::instances;
335    
336    LaserStone::LaserStone (Direction dir)
337    : OnOffStone("st-laser")
338    {
339        set_attrib("dir", Value(dir));
340    }
341    
342    DirectionBits
343    LaserStone::emission_directions() const
344    {
345        if (is_on()) {
346            return to_bits(get_dir());
347        }
348        return NODIRBIT;
349    }
350    
351    
352  void  void
353  LaserStone::reemit_all()  LaserStone::reemit_all()
354  {  {
# Line 348  void Line 379  void
379  LaserStone::on_creation()  LaserStone::on_creation()
380  {  {
381      if (is_on())      if (is_on())
382          RecalcLight(); //LaserBeam::emit_from(get_pos(), get_dir());          RecalcLight();
383      Stone::on_creation();      Stone::on_creation();
384  }  }
385    
# Line 597  namespace Line 628  namespace
628  void  void
629  world::laser::Init()  world::laser::Init()
630  {  {
631      Register(new LaserStone);      Register (new LaserStone);
632      Register(new TriangleMirror);      Register ("st-laser-n", new LaserStone(NORTH));
633      Register(new PlaneMirror);      Register ("st-laser-e", new LaserStone(EAST));
634        Register ("st-laser-s", new LaserStone(SOUTH));
635        Register ("st-laser-w", new LaserStone(WEST));
636    
637        Register (new TriangleMirror);
638        Register (new PlaneMirror);
639  }  }
640    
641    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26