r148 - in trunk: . src src/objects

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Sep 6 04:24:41 EDT 2005


Author: jonas
Date: 2005-09-06 04:24:40 -0400 (Tue, 06 Sep 2005)
New Revision: 148

Modified:
   trunk/INSTALL
   trunk/TODO
   trunk/src/animation.cpp
   trunk/src/animation.h
   trunk/src/common.h
   trunk/src/events.cpp
   trunk/src/events.h
   trunk/src/gfxeng.cpp
   trunk/src/gfxeng.h
   trunk/src/imgcache.cpp
   trunk/src/monsters_common.cpp
   trunk/src/monsters_common.h
   trunk/src/objects/baleog.cpp
   trunk/src/objects/baleog.h
   trunk/src/objects/erik.cpp
   trunk/src/objects/erik.h
   trunk/src/objects/fang.cpp
   trunk/src/objects/fang.h
   trunk/src/objects/olaf.cpp
   trunk/src/objects/olaf.h
   trunk/src/objects/scorch.cpp
   trunk/src/objects/scorch.h
   trunk/src/objects/zombie.cpp
   trunk/src/objects/zombie.h
   trunk/src/objects_common.cpp
   trunk/src/objects_common.h
   trunk/src/players_common.cpp
   trunk/src/players_common.h
Log:
o We depend on Boost: boost::shared_ptr at the moment
o Replaced all EmptyAnimation* with typedef boost::shared_ptr<EmptyAnimation>
  EmptyAnimationPtr...
o Check for the validity of the returned surface in imgcache->loadImage(...)


Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/INSTALL	2005-09-06 08:24:40 UTC (rev 148)
@@ -4,6 +4,7 @@
 You need the data files from a game (atm only lost vikings), put the data
 directory into your lost_penguins/ directory...
 
+libboost-dev
 libsdl1.2
 libsdl-mixer1.2 (if compiled with -DSDL_MIXER)
 libsdl-image1.2 (if compiled with -DSDL_IMAGE)

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/TODO	2005-09-06 08:24:40 UTC (rev 148)
@@ -5,6 +5,8 @@
  o left/right move + switchPlayer (keeps moving)
  o key vs. trigger in map2
  o fall event (DONE?)
+ o left/right fallback?
+ o players die event segfault (eg. olaf)
 
 
 Code

Modified: trunk/src/animation.cpp
===================================================================
--- trunk/src/animation.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/animation.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -1,7 +1,7 @@
 #include "common.h"
 #include "animation.h"
 
-EmptyAnimation::EmptyAnimation(EmptyAnimation** afallback) : fallback(afallback) { }
+EmptyAnimation::EmptyAnimation(EmptyAnimationPtr* afallback) : fallback(afallback) { }
 void EmptyAnimation::setBasePos(SDL_Rect* abase_pos) {
     if (fallback) (*fallback)->setBasePos(abase_pos);
 }
@@ -47,7 +47,7 @@
     if (fallback) return (*fallback)->isFixed();
     else return true;
 }
-void EmptyAnimation::setFallBack(EmptyAnimation** newfallback) {
+void EmptyAnimation::setFallBack(EmptyAnimationPtr* newfallback) {
     fallback=newfallback;
 }
 

Modified: trunk/src/animation.h
===================================================================
--- trunk/src/animation.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/animation.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -3,7 +3,7 @@
 
 class EmptyAnimation {
     public:
-        EmptyAnimation(EmptyAnimation** afallback=NULL);
+        EmptyAnimation(EmptyAnimationPtr* afallback=NULL);
         virtual ~EmptyAnimation() { }
         virtual void setBasePos(SDL_Rect*);
         virtual void unsetBasePos();
@@ -17,11 +17,11 @@
         virtual bool isRunning() const;
         virtual bool isImage() const;
         virtual bool isFixed() const;
-        virtual void setFallBack(EmptyAnimation** newfallback=NULL);
+        virtual void setFallBack(EmptyAnimationPtr* newfallback=NULL);
     protected:
         Frame base_frame;
     private:
-        EmptyAnimation** fallback;
+        EmptyAnimationPtr* fallback;
 };
 
 /** \brief Animation is responsible to return the correct frame of an animation
@@ -87,7 +87,7 @@
         virtual bool isFixed() const {
             return is_fixed;
         }
-        virtual void setFallBack(EmptyAnimation**) { }
+        virtual void setFallBack(EmptyAnimationPtr*) { }
     protected:
         /// Helper function to set the shift values of the animation
         void setShift();

Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/common.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -19,6 +19,7 @@
 #ifdef SDL_IMAGE
 #include <SDL_image.h>
 #endif
+#include <boost/shared_ptr.hpp>
 
 using namespace std;
 
@@ -48,6 +49,7 @@
 typedef std::set<Character *>::iterator character_iterator;
 typedef std::set<Player *>::iterator player_iterator;
 typedef std::set<Monster *>::iterator monster_iterator;
+typedef boost::shared_ptr<EmptyAnimation> EmptyAnimationPtr;
 
 //Data
 #define DATA_LVLFPS 6

Modified: trunk/src/events.cpp
===================================================================
--- trunk/src/events.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/events.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -52,7 +52,7 @@
     delete this;
 }
 
-AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim):
+AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim):
   Event(obj,length,edelay,switchstate),
   anim(runanim),
   del(delanim),
@@ -74,14 +74,12 @@
 }
 void AnimEvent::end() {
     if (started && state&ESTATE_ANIM) {
-        if (del) delete anim; 
         owner->resetAnimState();
     }
     Event::end();
 }
 void AnimEvent::cancel() {
     if (started && state&ESTATE_ANIM) {
-        if (del) delete anim;
         owner->resetAnimState();
     }
     Event::cancel();
@@ -93,7 +91,7 @@
   charowner(chr) { }
   
 //Exactly the same as AnimEvent with Character* instead of Object*
-CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim):
+CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim):
   CEvent(chr,length,edelay,switchstate),
   anim(runanim),
   del(delanim),
@@ -115,21 +113,19 @@
 }
 void CAnimEvent::end() {
     if (started && state&ESTATE_ANIM) {
-        if (del) delete anim;
         charowner->resetAnimState();
     }
     CEvent::end();
 }
 void CAnimEvent::cancel() {
     if (started && state&ESTATE_ANIM) { 
-        if (del) delete anim;
         charowner->resetAnimState();
     }
     CEvent::cancel();
 }
 
 
-ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim):
+ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim):
   CAnimEvent(chr,length,edelay,(switchstate|STATE_PRESS_LR),esound,runanim,delanim),
   dmax(edmax),
   t_reset(0) {
@@ -169,7 +165,7 @@
 }
 
 
-EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim):
+EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim):
   CAnimEvent(chr,length,edelay,switchstate|ESTATE_BUSY,esound,runanim,delanim),
   weapon(atweapon),
   direction(dir),

Modified: trunk/src/events.h
===================================================================
--- trunk/src/events.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/events.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -62,7 +62,7 @@
         /// \todo Get rid of the delanim parameter
         /// \param delanim True if the animation should be deleted
         AnimEvent(Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING,
-          Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false);
+          Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false);
         /// \brief Updates the events
         /// \return Event state: either delayed (EV_DELAY), starting (EV_START),
         ///         running (EV_RUN), stopping (EV_END) or canceled (EV_CANCEL)
@@ -71,7 +71,7 @@
         virtual void end();  
         virtual void cancel();
     protected:
-        EmptyAnimation* anim;
+        EmptyAnimationPtr anim;
         bool del;
         Mix_Chunk* sound;
 };
@@ -83,13 +83,13 @@
 class CAnimEvent : public CEvent {
     public:
         CAnimEvent(Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING,
-          Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false);
+          Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false);
         virtual Uint16 update(Uint16 dt);
         virtual void start();
         virtual void end();  
         virtual void cancel();
     protected:
-        EmptyAnimation* anim;
+        EmptyAnimationPtr anim;
         bool del;
         Mix_Chunk* sound;
 };
@@ -116,7 +116,7 @@
         /// \param delanim True if the animation should be deleted
         EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0,
           Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL,
-          EmptyAnimation* runanim=NULL, bool delanim=false);
+          EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false);
         virtual void end();
     protected:
         Weapon* weapon;
@@ -134,7 +134,7 @@
     public:
         /// Adds the initial speed
         ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0,
-          Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false);
+          Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false);
         virtual ~ERun();
         /// Forces the event to continue
         virtual void start(); 

Modified: trunk/src/gfxeng.cpp
===================================================================
--- trunk/src/gfxeng.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/gfxeng.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -24,11 +24,10 @@
     shift.x=0;
     shift.y=0;
     resize(config.width, config.height);
-    lifeimage=new Animation(imgcache->loadImage(1,"life.bmp"));
+    lifeimage.reset(new Animation(imgcache->loadImage(1,"life.bmp")));
 }
 
 GraphicsEngine::~GraphicsEngine() {
-    delete lifeimage;
     if (menubg) SDL_FreeSurface(menubg);
     SDL_FreeSurface(screen);
 }

Modified: trunk/src/gfxeng.h
===================================================================
--- trunk/src/gfxeng.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/gfxeng.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -47,8 +47,6 @@
         SDL_Surface* menubg;
         /// player bar
         SDL_Rect bar;
-        /// symbol for one life of a player
-        EmptyAnimation* lifeimage;
         bool show_bar;
         bool show_fps;
         bool show_debug;
@@ -58,6 +56,8 @@
         Uint8 updatetype;
         // current shift
         SDL_Rect shift;
+        /// symbol for one life of a player
+        EmptyAnimationPtr lifeimage;
     protected:
         /// Draw the background and all objects in the pool. This is a very time
         /// consuming function...

Modified: trunk/src/imgcache.cpp
===================================================================
--- trunk/src/imgcache.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/imgcache.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -115,6 +115,17 @@
             }
             SDL_FreeSurface(tmp_surface);
         }
+        if (return_image.surface==NULL) {
+            cout << "Couldn't load the image " << imagename << ": probably failed at setting to display format...." << endl;
+            //Even the fallback image was not found
+            if (not_found==imagename) {
+                quitGame(3);
+            //Try to load the fallback image...
+            } else {
+                std::vector<SDL_Rect> empty_vector;
+                return loadImage(empty_vector,not_found);
+            }
+        }
         // Nice return statement, isn't it ;-)))
         return (*(imgcache.insert(make_pair(make_pair(imagename,scale_factor),return_image))).first).second;
     // Return the existing Image in cache...

Modified: trunk/src/monsters_common.cpp
===================================================================
--- trunk/src/monsters_common.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/monsters_common.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -13,7 +13,9 @@
 Monster::Monster(string imagename, Sint16 xcord, Sint16 ycord, string pname):
   Character(imagename,xcord,ycord,pname),
   Dai(0),
-  Dattack(0) {
+  Dattack(0),
+  anim_left(new EmptyAnimation(&anim_right)),
+  anim_right(new EmptyAnimation()) {
     health=1;
     maxspeedx=50;
     maxspeedy=0;
@@ -21,14 +23,10 @@
     otype|=OTYPE_MONSTER;
     enemy_types|=OTYPE_PLAYER;
     dense_types|=OTYPE_PLAYER;
-    anim_left=new EmptyAnimation(&anim_right);
-    anim_right=new EmptyAnimation();
     au_hit=scenario->sndcache->loadWAV("monhit.wav");
 }
 
 Monster::~Monster() {
-    delete anim_left;
-    delete anim_right;
 }
 
 void Monster::addEnter(std::set<Object *>& aset) {

Modified: trunk/src/monsters_common.h
===================================================================
--- trunk/src/monsters_common.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/monsters_common.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -36,10 +36,10 @@
         std::set<Player *> targets;
         virtual Hit move(Uint16 dt, bool check=false);
         //common animations
-        EmptyAnimation* anim_left;
-        EmptyAnimation* anim_right;
         Mix_Chunk* au_hit;
         Sint16 Dai,Dattack;
+        EmptyAnimationPtr anim_left;
+        EmptyAnimationPtr anim_right;
 };
 
 #endif

Modified: trunk/src/objects/baleog.cpp
===================================================================
--- trunk/src/objects/baleog.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/baleog.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -22,11 +22,6 @@
     au_sword=scenario->sndcache->loadWAV("swrdsw2.wav");
 }
 
-Baleog::~Baleog() {
-    delete anim_sword_left;
-    delete anim_sword_right;
-}
-
 //Baleog1: Sword attack
 void Baleog::in_sp1() {
     setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right));

Modified: trunk/src/objects/baleog.h
===================================================================
--- trunk/src/objects/baleog.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/baleog.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -6,11 +6,10 @@
 class Baleog : public Player {
     public:
         Baleog(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Baleog");
-        virtual ~Baleog();
         /// \brief Baleog attacks with a sword
         virtual void in_sp1();
     private:
         Mix_Chunk* au_sword;
-        EmptyAnimation* anim_sword_left;
-        EmptyAnimation* anim_sword_right;
+        EmptyAnimationPtr anim_sword_left;
+        EmptyAnimationPtr anim_sword_right;
 };

Modified: trunk/src/objects/erik.cpp
===================================================================
--- trunk/src/objects/erik.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/erik.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -16,45 +16,45 @@
   jump2(V_JUMP2) {
     weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE);
 /*
-    delete anim_left;           anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp"));
-    delete anim_right;          anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp"));
-    delete anim_land_left;      anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_land_right;     anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_crash_left;     anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_crash_right;    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp"));
+    anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
 */
-    delete anim_left;            anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD);
-    delete anim_right;           anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD);
-    delete anim_rock_left;       anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD);
-    delete anim_rock_right;      anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD);
-    delete anim_walk_left;       anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD);
-    delete anim_walk_right;      anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD);
-    delete anim_push_left;       anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD);
-    delete anim_push_right;      anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD);
-    delete anim_fall_middle;     anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale);
-    delete anim_fall_left;       anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD);
-    delete anim_fall_right;      anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD);
-    delete anim_fall_fast_left;  anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD);
-    delete anim_fall_fast_right; anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD);
-    delete anim_land_left;       anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_land_right;      anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_crash_left;      anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_crash_right;     anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_rope_left;       anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD);
-    delete anim_rope_right;      anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD);
-    delete anim_teleport_left;   anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_teleport_right;  anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_die_crash_left;  anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_die_crash_right; anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_die_burn_left;   anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_die_burn_right;  anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_die_bones_left;  anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_die_bones_right; anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_die_elec_left;   anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_die_elec_right;  anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_die_spike_left;  anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
-    delete anim_die_spike_right; anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
-    delete anim_bar;             anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE);
+    anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD);
+    anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD);
+    anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD);
+    anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD);
+    anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD);
+    anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD);
+    anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD);
+    anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD);
+    anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale);
+    anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD);
+    anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD);
+    anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD);
+    anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD);
+    anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD);
+    anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD);
+    anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END);
+    anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END);
+    anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE);
     /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */
 
     anim_erik_jump_left=loadAnimation("erik_jump_left",config.lvlscale,BP_RD,ATYPE_ONCE);
@@ -74,8 +74,6 @@
     au_hit=scenario->sndcache->loadWAV("erikhit.wav");
     au_run=NULL;
 }
-Erik::~Erik() {
-}
 
 void Erik::idle(Uint16 dt) {
     Player::idle(dt);

Modified: trunk/src/objects/erik.h
===================================================================
--- trunk/src/objects/erik.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/erik.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -14,7 +14,6 @@
 class Erik : public Player {
     public:
         Erik(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Erik");
-        virtual ~Erik();
         virtual void idle(Uint16); 
        /// \brief Erik jumps
         virtual void in_sp1();
@@ -25,18 +24,18 @@
         virtual void crash(Uint16 dir);
         virtual Uint16 hit(Uint16 direction,Weapon& weap);
     private:
-        EmptyAnimation* anim_erik_jump_left;
-        EmptyAnimation* anim_erik_jump_right;
-        EmptyAnimation* anim_erik_jump2_left;
-        EmptyAnimation* anim_erik_jump2_right;
-        EmptyAnimation* anim_erik_start_run_left;
-        EmptyAnimation* anim_erik_start_run_right;
-        EmptyAnimation* anim_erik_swim_left;
-        EmptyAnimation* anim_erik_swim_right;
-        EmptyAnimation* anim_erik_swim_up_left;
-        EmptyAnimation* anim_erik_swim_up_right;
-        EmptyAnimation* anim_erik_hit_water_left;
-        EmptyAnimation* anim_erik_hit_water_right;
+        EmptyAnimationPtr anim_erik_jump_left;
+        EmptyAnimationPtr anim_erik_jump_right;
+        EmptyAnimationPtr anim_erik_jump2_left;
+        EmptyAnimationPtr anim_erik_jump2_right;
+        EmptyAnimationPtr anim_erik_start_run_left;
+        EmptyAnimationPtr anim_erik_start_run_right;
+        EmptyAnimationPtr anim_erik_swim_left;
+        EmptyAnimationPtr anim_erik_swim_right;
+        EmptyAnimationPtr anim_erik_swim_up_left;
+        EmptyAnimationPtr anim_erik_swim_up_right;
+        EmptyAnimationPtr anim_erik_hit_water_left;
+        EmptyAnimationPtr anim_erik_hit_water_right;
         Mix_Chunk* au_jump;
         Mix_Chunk* au_run;
         Sint16 jump,jump2;

Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/fang.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -12,22 +12,18 @@
   Player(imagename,xcord,ycord,pname),
   jump(V_JUMP) {
     weapon=Weapon(-1,W_STRIKE);
-    delete anim_left;           anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4);
-    delete anim_right;          anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4);
-    delete anim_walk_left;      anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8);
-    delete anim_walk_right;     anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8);
-    delete anim_crash_left;     anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_crash_right;    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4);
+    anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4);
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
     anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8);
     anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8);
     au_hit=scenario->sndcache->loadWAV("wolfhit.wav");
     au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav");
     au_jump=scenario->sndcache->loadWAV("fangjump.wav");
 }
-Fang::~Fang() {
-    delete anim_claw_left;
-    delete anim_claw_right;
-}
 
 void Fang::in_left(Uint16 dt) {
     Player::in_left(dt);

Modified: trunk/src/objects/fang.h
===================================================================
--- trunk/src/objects/fang.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/fang.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -23,7 +23,6 @@
 class Fang : public Player {
     public:
         Fang(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Fang");
-        virtual ~Fang();
         virtual void fall(Uint16);
         virtual void in_left(Uint16);
         virtual void in_right(Uint16);
@@ -34,8 +33,8 @@
         virtual void clearStates(bool reset=false);
     private:
         virtual void crash(Uint16 dir=DIR_DOWN);
-        EmptyAnimation* anim_claw_left;
-        EmptyAnimation* anim_claw_right;
+        EmptyAnimationPtr anim_claw_left;
+        EmptyAnimationPtr anim_claw_right;
         Mix_Chunk* au_jump;
         Mix_Chunk* au_claw;
         Sint16 jump;

Modified: trunk/src/objects/olaf.cpp
===================================================================
--- trunk/src/objects/olaf.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/olaf.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -26,27 +26,15 @@
     anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,BP_MD,ATYPE_LOOP,3.5);
     anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp"));
     anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp"));
-    anim_walk_shield_left=new EmptyAnimation(&anim_shield_left);
-    anim_walk_shield_right=new EmptyAnimation(&anim_shield_right);
-    anim_fall_shield_left=new EmptyAnimation(&anim_shield_left);
-    anim_fall_shield_right=new EmptyAnimation(&anim_shield_right);
+    anim_walk_shield_left.reset(new EmptyAnimation(&anim_shield_left));
+    anim_walk_shield_right.reset(new EmptyAnimation(&anim_shield_right));
+    anim_fall_shield_left.reset(new EmptyAnimation(&anim_shield_left));
+    anim_fall_shield_right.reset(new EmptyAnimation(&anim_shield_right));
     au_small=scenario->sndcache->loadWAV("blob.wav");
     au_big=scenario->sndcache->loadWAV("unblob.wav");
     au_fart=scenario->sndcache->loadWAV("fart1.wav");
     au_hit=scenario->sndcache->loadWAV("fathit.wav");
 }
-Olaf::~Olaf() {
-    delete anim_small_left;
-    delete anim_small_right;
-    delete anim_walk_small_left;
-    delete anim_walk_small_right;
-    delete anim_walk_shield_left;
-    delete anim_walk_shield_right;
-    delete anim_shield_left;
-    delete anim_shield_right;
-    delete anim_fall_shield_left;
-    delete anim_fall_shield_right;
-}
 
 void Olaf::updateAnimState() {
     if (state&STATE_SMALL) {
@@ -113,16 +101,13 @@
     //Are we already small?
     if ((small && (state&STATE_SMALL)) || ((!small) && (!(state&STATE_SMALL)))) return true;
 
-    EmptyAnimation* tmpanim;
     SDL_Rect tmppos=pos;
-    if (small) tmpanim=anim_small_left;
     //Assume both images have the same dimension
-    else tmpanim=anim_orig;
     //IDEA: left/right edge instead of bottom?
-    tmppos.x+=(Sint16)((tmppos.w-tmpanim->getFrameDim().w)/2);
-    tmppos.y+=tmppos.h-tmpanim->getFrameDim().h;
-    tmppos.w=tmpanim->getFrameDim().w;
-    tmppos.h=tmpanim->getFrameDim().h;
+    tmppos.x+=(Sint16)((tmppos.w-(small ? anim_small_left : anim_orig)->getFrameDim().w)/2);
+    tmppos.y+=tmppos.h-(small ? anim_small_left : anim_orig)->getFrameDim().h;
+    tmppos.w=(small ? anim_small_left : anim_orig)->getFrameDim().w;
+    tmppos.h=(small ? anim_small_left : anim_orig)->getFrameDim().h;
     if (!(checkMove(tmppos,true).enter&DIR_ALL)) {
         pos=tmppos;
         if (small) {

Modified: trunk/src/objects/olaf.h
===================================================================
--- trunk/src/objects/olaf.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/olaf.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -17,7 +17,6 @@
 class Olaf : public Player {
     public:
         Olaf(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Olaf");
-        virtual ~Olaf();
         /// Additionally checks if Olaf is small and how he wears his shield
         virtual void updateAnimState();
         virtual void in_left(Uint16);
@@ -41,16 +40,16 @@
         /// \return True if successfull
         inline bool trySmall(bool small);
         //@{
-        EmptyAnimation* anim_small_left;
-        EmptyAnimation* anim_small_right;
-        EmptyAnimation* anim_walk_small_left;
-        EmptyAnimation* anim_walk_small_right;
-        EmptyAnimation* anim_shield_left;
-        EmptyAnimation* anim_shield_right;
-        EmptyAnimation* anim_walk_shield_left;
-        EmptyAnimation* anim_walk_shield_right;
-        EmptyAnimation* anim_fall_shield_left;
-        EmptyAnimation* anim_fall_shield_right;
+        EmptyAnimationPtr anim_small_left;
+        EmptyAnimationPtr anim_small_right;
+        EmptyAnimationPtr anim_walk_small_left;
+        EmptyAnimationPtr anim_walk_small_right;
+        EmptyAnimationPtr anim_shield_left;
+        EmptyAnimationPtr anim_shield_right;
+        EmptyAnimationPtr anim_walk_shield_left;
+        EmptyAnimationPtr anim_walk_shield_right;
+        EmptyAnimationPtr anim_fall_shield_left;
+        EmptyAnimationPtr anim_fall_shield_right;
         //@}
         //@{
         Mix_Chunk* au_small;

Modified: trunk/src/objects/scorch.cpp
===================================================================
--- trunk/src/objects/scorch.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/scorch.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -12,18 +12,16 @@
   Player(imagename,xcord,ycord,pname),
   left_wings(SCORCH_MAX_WINGS),
   wing(V_FLY) {
-    delete anim_left;           anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
-    delete anim_right;          anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
-    delete anim_walk_left;      anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8);
-    delete anim_walk_right;     anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8);
-    delete anim_crash_left;     anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
-    delete anim_crash_right;    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp"));
+    anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp"));
+    anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8);
+    anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8);
+    anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
+    anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR));
     au_swing=scenario->sndcache->loadWAV("flapwngs.wav");
     au_tired=scenario->sndcache->loadWAV("flwings.wav");
     au_hit=scenario->sndcache->loadWAV("draghit.wav");
 }
-Scorch::~Scorch() {
-}
 
 void Scorch::idle(Uint16 dt) {
     Player::idle(dt);

Modified: trunk/src/objects/scorch.h
===================================================================
--- trunk/src/objects/scorch.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/scorch.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -17,7 +17,6 @@
 class Scorch : public Player {
     public:
         Scorch(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Scorch");
-        virtual ~Scorch();
         virtual void fall(Uint16);
         /// \brief Scorch uses his wings
         virtual void idle(Uint16);

Modified: trunk/src/objects/zombie.cpp
===================================================================
--- trunk/src/objects/zombie.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/zombie.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -15,14 +15,11 @@
   au_attack(scenario->sndcache->loadWAV("clang.wav")),
   T_Attack_Bite(1500) {
     maxspeedx=80;
-    delete anim_left;   anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2);
-    delete anim_right;  anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2);
+    anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2);
+    anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2);
     weapon=Weapon(-1,W_STRIKE);
 }
 
-Zombie::~Zombie() {
-}
-
 void Zombie::idle(Uint16 dt) {
     Character::idle(dt);
     runAI(dt);

Modified: trunk/src/objects/zombie.h
===================================================================
--- trunk/src/objects/zombie.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects/zombie.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -9,7 +9,6 @@
 class Zombie : public Monster {
     public:
         Zombie(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Zombie");
-        virtual ~Zombie();
         virtual void idle(Uint16);
     private:
         virtual void runAI(Uint16);

Modified: trunk/src/objects_common.cpp
===================================================================
--- trunk/src/objects_common.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects_common.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -12,8 +12,8 @@
   event(NULL),
   otype(NOTHING),
   name(oname),
-  delete_flag(false) {
-    anim_orig=loadAnimation(scenario->imgcache->loadImage(1,imagename));
+  delete_flag(false),
+  anim_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))) {
     animation=anim_orig;
     pos=animation->getFrameDim();
     pos.x=xcord;
@@ -23,7 +23,6 @@
 
 Object::~Object() {
     if (event) event->cancel();
-    if (!(otype&OTYPE_CHARACTER)) delete animation;
 }
 
 bool Object::operator<(const Object& obj) const {
@@ -59,13 +58,12 @@
     return ok;
 }
 
-EmptyAnimation* Object::loadAnimation(string anim_name,
-                         double scale_factor,
-                         BasePointType abp_type,
-                         Uint16 aanimation_type,
-                         double afps,
-                         AllignType aallign_type) {
-
+EmptyAnimationPtr Object::loadAnimation(string anim_name,
+                                        double scale_factor,
+                                        BasePointType abp_type,
+                                        Uint16 aanimation_type,
+                                        double afps,
+                                        AllignType aallign_type) {
     /* Parse animation data file */
     ifstream file;
     string tmpline;
@@ -74,7 +72,7 @@
     file.open(loadfile.c_str());
     if (!file) {
         cout << "Failed to open the animation data file: " << loadfile << " => Couldn't load " << anim_name << " animation!\n" << endl;
-        return new EmptyAnimation();
+        return EmptyAnimationPtr(new EmptyAnimation());
     } else {
         string arg1,arg2,arg3,arg4,arg5,arg6;
         string tmp_anim_name="";
@@ -115,17 +113,17 @@
         }
     }
     cout << "Animation " << anim_name << " not found!" << endl;
-    return new EmptyAnimation();
+    return EmptyAnimationPtr(new EmptyAnimation());
 }
 
-EmptyAnimation* Object::loadAnimation(const Image& abase_image,
-                         Uint16 aframes,
-                         BasePointType abp_type, 
-                         Uint16 aanimation_type,
-                         double afps,
-                         Uint16 astart_pos,
-                         AllignType aallign_type) {
-    EmptyAnimation* anim=new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type);
+EmptyAnimationPtr Object::loadAnimation(const Image& abase_image,
+                                        Uint16 aframes,
+                                        BasePointType abp_type, 
+                                        Uint16 aanimation_type,
+                                        double afps,
+                                        Uint16 astart_pos,
+                                        AllignType aallign_type) {
+    EmptyAnimationPtr anim(new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type));
     anim->setBasePos(&pos);
     return anim;
 }
@@ -139,7 +137,7 @@
 bool Object::updateAnim(Uint16 dt) {
     return (animation->updateAnim(dt));
 }
-bool Object::setAnim(EmptyAnimation* anim, bool start) {
+bool Object::setAnim(EmptyAnimationPtr anim, bool start) {
     if (anim && anim->isValid()) {
         animation=anim;
         if (start) {

Modified: trunk/src/objects_common.h
===================================================================
--- trunk/src/objects_common.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/objects_common.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -88,7 +88,7 @@
         /// and starts it right away. Should not be used with updateAnimState,
         /// set ESTATE_ANIM to deactivate an updateAnimState. This is usually
         /// controlled by an AnimationEvent
-        bool setAnim(EmptyAnimation* anim, bool start=false);
+        bool setAnim(EmptyAnimationPtr anim, bool start=false);
         /// Sets the animation back to the default one.
         virtual void resetAnimState();
         bool isRunning() const;
@@ -106,20 +106,20 @@
         }
         //@}
         /// Load an animation bound onto this object from an animation data file
-        EmptyAnimation* loadAnimation(string anim_name,
-                                 double scale_factor=1,
-                                 BasePointType abp_type=BP_MD,
-                                 Uint16 aanimation_type=ATYPE_LOOP,
-                                 double afps=0,
-                                 AllignType aallign_type=AT_MD);
+        EmptyAnimationPtr loadAnimation(string anim_name,
+                                        double scale_factor=1,
+                                        BasePointType abp_type=BP_MD,
+                                        Uint16 aanimation_type=ATYPE_LOOP,
+                                        double afps=0,
+                                        AllignType aallign_type=AT_MD);
         /// Load an animation bound onto this object
-        EmptyAnimation* loadAnimation(const Image& abase_image,
-                                 Uint16 aframes=1,
-                                 BasePointType abp_type=BP_MD,
-                                 Uint16 aanimation_type=ATYPE_LOOP,
-                                 double afps=0,
-                                 Uint16 astart_pos=0,
-                                 AllignType aallign_type=AT_MD);
+        EmptyAnimationPtr loadAnimation(const Image& abase_image,
+                                        Uint16 aframes=1,
+                                        BasePointType abp_type=BP_MD,
+                                        Uint16 aanimation_type=ATYPE_LOOP,
+                                        double afps=0,
+                                        Uint16 astart_pos=0,
+                                        AllignType aallign_type=AT_MD);
         //Events (triggered animations/effects)
         //@{
         /// Clears the event field (sets it to NULL). This should only be used by
@@ -179,8 +179,6 @@
     protected:
         Uint32 state;
         Event* event;
-        EmptyAnimation* anim_orig;
-        EmptyAnimation* animation;
         ///\todo Document this!
         /// Upper left logical position of the object (used for decisions)
         SDL_Rect pos;
@@ -190,6 +188,8 @@
         string name;
         //delete me flag
         bool delete_flag;
+        EmptyAnimationPtr anim_orig;
+        EmptyAnimationPtr animation;
 };
 
 /** \brief Item

Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/players_common.cpp	2005-09-06 08:24:40 UTC (rev 148)
@@ -15,7 +15,42 @@
 
 Player::Player(string imagename, Sint16 xcord, Sint16 ycord, string pname):
   Character(imagename,xcord,ycord,pname),
-  currentitem(0) {
+  currentitem(0),
+  anim_left(new EmptyAnimation(&anim_right)),
+  anim_right(new EmptyAnimation()),
+  anim_rock_left(new EmptyAnimation(&anim_left)),
+  anim_rock_right(new EmptyAnimation(&anim_right)),
+  anim_walk_left(new EmptyAnimation(&anim_left)),
+  anim_walk_right(new EmptyAnimation(&anim_right)),
+  anim_push_left(new EmptyAnimation(&anim_left)),
+  anim_push_right(new EmptyAnimation(&anim_right)),
+  anim_fall_left(new EmptyAnimation(&anim_left)),
+  anim_fall_right(new EmptyAnimation(&anim_right)),
+  anim_fall_fast_left(new EmptyAnimation(&anim_fall_left)),
+  anim_fall_fast_right(new EmptyAnimation(&anim_fall_right)),
+  anim_land_left(new EmptyAnimation()),
+  anim_land_right(new EmptyAnimation()),
+  anim_crash_left(new EmptyAnimation()),
+  anim_crash_right(new EmptyAnimation()),
+  anim_rope_left(new EmptyAnimation(&anim_left)),
+  anim_rope_right(new EmptyAnimation(&anim_right)),
+  anim_teleport_left(new EmptyAnimation()),
+  anim_teleport_right(new EmptyAnimation()),
+  anim_die_crash_left(new EmptyAnimation(&anim_die_bones_left)),
+  anim_die_crash_right(new EmptyAnimation(&anim_die_bones_right)),
+  anim_die_burn_left(new EmptyAnimation(&anim_die_bones_left)),
+  anim_die_burn_right(new EmptyAnimation(&anim_die_bones_right)),
+  anim_die_bones_left(new EmptyAnimation(&anim_die_bones_right)),
+  anim_die_bones_right(new EmptyAnimation()),
+  anim_die_elec_left(new EmptyAnimation(&anim_die_bones_left)),
+  anim_die_elec_right(new EmptyAnimation(&anim_die_bones_right)),
+  anim_die_spike_left(new EmptyAnimation(&anim_die_bones_left)),
+  anim_die_spike_right(new EmptyAnimation(&anim_die_bones_right)),
+  anim_die_water_left(new EmptyAnimation(&anim_die_bones_left)),
+  anim_die_water_right(new EmptyAnimation(&anim_die_bones_right)),
+  anim_fall_middle(new EmptyAnimation(&anim_fall_right)),
+  anim_climb(new EmptyAnimation(&anim_right)),
+  anim_bar(new EmptyAnimation(&anim_right)) {
     health=3;
     maxhealth=4;
     maxspeedx=300;
@@ -26,41 +61,6 @@
     state=STATE_FALL;
     otype|=OTYPE_PLAYER;
     enemy_types|=OTYPE_MONSTER;
-    anim_left=new EmptyAnimation(&anim_right);
-    anim_right=new EmptyAnimation();
-    anim_rock_left=new EmptyAnimation(&anim_left);
-    anim_rock_right=new EmptyAnimation(&anim_right);
-    anim_walk_left=new EmptyAnimation(&anim_left);
-    anim_walk_right=new EmptyAnimation(&anim_right);
-    anim_push_left=new EmptyAnimation(&anim_left);
-    anim_push_right=new EmptyAnimation(&anim_right);
-    anim_fall_left=new EmptyAnimation(&anim_left);
-    anim_fall_right=new EmptyAnimation(&anim_right);
-    anim_fall_fast_left=new EmptyAnimation(&anim_fall_left);
-    anim_fall_fast_right=new EmptyAnimation(&anim_fall_right);
-    anim_land_left=new EmptyAnimation();
-    anim_land_right=new EmptyAnimation();
-    anim_crash_left=new EmptyAnimation();
-    anim_crash_right=new EmptyAnimation();
-    anim_rope_left=new EmptyAnimation(&anim_left);
-    anim_rope_right=new EmptyAnimation(&anim_right);
-    anim_teleport_left=new EmptyAnimation();
-    anim_teleport_right=new EmptyAnimation();
-    anim_die_crash_left=new EmptyAnimation(&anim_die_bones_left);
-    anim_die_crash_right=new EmptyAnimation(&anim_die_bones_right);
-    anim_die_burn_left=new EmptyAnimation(&anim_die_bones_left);
-    anim_die_burn_right=new EmptyAnimation(&anim_die_bones_right);
-    anim_die_bones_left=new EmptyAnimation(&anim_die_bones_right);
-    anim_die_bones_right=new EmptyAnimation();
-    anim_die_elec_left=new EmptyAnimation(&anim_die_bones_left);
-    anim_die_elec_right=new EmptyAnimation(&anim_die_bones_right);
-    anim_die_spike_left=new EmptyAnimation(&anim_die_bones_left);
-    anim_die_spike_right=new EmptyAnimation(&anim_die_bones_right);
-    anim_die_water_left=new EmptyAnimation(&anim_die_bones_left);
-    anim_die_water_right=new EmptyAnimation(&anim_die_bones_right);
-    anim_fall_middle=new EmptyAnimation(&anim_fall_right);
-    anim_climb=new EmptyAnimation(&anim_right);
-    anim_bar=new EmptyAnimation(&anim_right);
     au_land=scenario->sndcache->loadWAV("dizzy.wav");
     au_act=scenario->sndcache->loadWAV("button.wav");
     au_useerror=scenario->sndcache->loadWAV("useerror.wav");
@@ -74,41 +74,6 @@
 }
 
 Player::~Player() {
-    delete anim_left;
-    delete anim_right;
-    delete anim_rock_left;
-    delete anim_rock_right;
-    delete anim_walk_left;
-    delete anim_walk_right;
-    delete anim_push_left;
-    delete anim_push_right;
-    delete anim_fall_left;
-    delete anim_fall_right;
-    delete anim_fall_fast_left;
-    delete anim_fall_fast_right;
-    delete anim_land_left;
-    delete anim_land_right;
-    delete anim_crash_left;
-    delete anim_crash_right;
-    delete anim_rope_left;
-    delete anim_rope_right;
-    delete anim_teleport_left;
-    delete anim_teleport_right;
-    delete anim_die_crash_left;
-    delete anim_die_crash_right;
-    delete anim_die_burn_left;
-    delete anim_die_burn_right;
-    delete anim_die_bones_left;
-    delete anim_die_bones_right;
-    delete anim_die_elec_left;
-    delete anim_die_elec_right;
-    delete anim_die_spike_left;
-    delete anim_die_spike_right;
-    delete anim_die_water_left;
-    delete anim_die_water_right;
-    delete anim_fall_middle;
-    delete anim_climb;
-    delete anim_bar;
     for (Uint8 i=0; i<MAX_ITEMS; i++) {
         if (items[i]) {
             removeItem(i);

Modified: trunk/src/players_common.h
===================================================================
--- trunk/src/players_common.h	2005-09-05 21:53:57 UTC (rev 147)
+++ trunk/src/players_common.h	2005-09-06 08:24:40 UTC (rev 148)
@@ -114,41 +114,8 @@
         virtual void die();
         virtual Hit move(Uint16 dt, bool check=false);
         //@{
-        EmptyAnimation* anim_left;
-        EmptyAnimation* anim_right;
-        EmptyAnimation* anim_rock_left;
-        EmptyAnimation* anim_rock_right;
-        EmptyAnimation* anim_walk_left;
-        EmptyAnimation* anim_walk_right;
-        EmptyAnimation* anim_push_left;
-        EmptyAnimation* anim_push_right;
-        EmptyAnimation* anim_fall_left;
-        EmptyAnimation* anim_fall_right;
-        EmptyAnimation* anim_fall_fast_left;
-        EmptyAnimation* anim_fall_fast_right;
-        EmptyAnimation* anim_land_left;
-        EmptyAnimation* anim_land_right;
-        EmptyAnimation* anim_crash_left;
-        EmptyAnimation* anim_crash_right;
-        EmptyAnimation* anim_rope_left;
-        EmptyAnimation* anim_rope_right;
-        EmptyAnimation* anim_teleport_left;
-        EmptyAnimation* anim_teleport_right;
-        EmptyAnimation* anim_die_crash_left;
-        EmptyAnimation* anim_die_crash_right;
-        EmptyAnimation* anim_die_burn_left;
-        EmptyAnimation* anim_die_burn_right;
-        EmptyAnimation* anim_die_bones_left;
-        EmptyAnimation* anim_die_bones_right;
-        EmptyAnimation* anim_die_elec_left;
-        EmptyAnimation* anim_die_elec_right;
-        EmptyAnimation* anim_die_spike_left;
-        EmptyAnimation* anim_die_spike_right;
-        EmptyAnimation* anim_die_water_left;
-        EmptyAnimation* anim_die_water_right;
-        EmptyAnimation* anim_fall_middle;
-        EmptyAnimation* anim_climb;
-        EmptyAnimation* anim_bar;
+        Item* items[MAX_ITEMS];
+        Uint8 currentitem;
         //@}
         //@{
         Mix_Chunk*  au_hit;
@@ -163,8 +130,41 @@
         Mix_Chunk*  au_heal;
         //@}
         //@{
-        Item* items[MAX_ITEMS];
-        Uint8 currentitem;
+        EmptyAnimationPtr anim_left;
+        EmptyAnimationPtr anim_right;
+        EmptyAnimationPtr anim_rock_left;
+        EmptyAnimationPtr anim_rock_right;
+        EmptyAnimationPtr anim_walk_left;
+        EmptyAnimationPtr anim_walk_right;
+        EmptyAnimationPtr anim_push_left;
+        EmptyAnimationPtr anim_push_right;
+        EmptyAnimationPtr anim_fall_left;
+        EmptyAnimationPtr anim_fall_right;
+        EmptyAnimationPtr anim_fall_fast_left;
+        EmptyAnimationPtr anim_fall_fast_right;
+        EmptyAnimationPtr anim_land_left;
+        EmptyAnimationPtr anim_land_right;
+        EmptyAnimationPtr anim_crash_left;
+        EmptyAnimationPtr anim_crash_right;
+        EmptyAnimationPtr anim_rope_left;
+        EmptyAnimationPtr anim_rope_right;
+        EmptyAnimationPtr anim_teleport_left;
+        EmptyAnimationPtr anim_teleport_right;
+        EmptyAnimationPtr anim_die_crash_left;
+        EmptyAnimationPtr anim_die_crash_right;
+        EmptyAnimationPtr anim_die_burn_left;
+        EmptyAnimationPtr anim_die_burn_right;
+        EmptyAnimationPtr anim_die_bones_left;
+        EmptyAnimationPtr anim_die_bones_right;
+        EmptyAnimationPtr anim_die_elec_left;
+        EmptyAnimationPtr anim_die_elec_right;
+        EmptyAnimationPtr anim_die_spike_left;
+        EmptyAnimationPtr anim_die_spike_right;
+        EmptyAnimationPtr anim_die_water_left;
+        EmptyAnimationPtr anim_die_water_right;
+        EmptyAnimationPtr anim_fall_middle;
+        EmptyAnimationPtr anim_climb;
+        EmptyAnimationPtr anim_bar;
         //@}
 };
 




More information about the lostpenguins-commits mailing list