summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--src/monster.cpp12
-rw-r--r--src/particleemitter.cpp33
-rw-r--r--src/particleemitter.h10
-rw-r--r--src/player.cpp11
-rw-r--r--src/resources/spritedef.cpp5
6 files changed, 77 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f1cc57d..1437d251 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-12-13 Philipp Sehmisch <tmw@crushnet.org>
+
+ * src/particleemitter.cpp, src/particleemitter.h: Particle images
+ are now reference-counted properly.
+ * src/resources/spritedef.cpp: Error placeholder is now used when attempting
+ to load a sprite definition file that doesn't exist.
+ * src/monster.cpp, src/player.cpp: Avoided attempts to load "data/graphics/"
+ when a monster or equipment piece has no sprite.
+ * data/graphics/particles/cookingfire.particle.xml: Removed some particle
+ properties that did nothing because they were misspelled.
+
2007-12-22 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/winver.h, README, configure.ac, INSTALL, data/help/header.txt,
diff --git a/src/monster.cpp b/src/monster.cpp
index 40b36849..779b4f56 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -35,8 +35,16 @@
Monster::Monster(Uint32 id, Uint16 job, Map *map):
Being(id, job, map)
{
- mSprites[BASE_SPRITE] = AnimatedSprite::load(
- "graphics/sprites/" + MonsterDB::get(job - 1002).getSprite());
+ std::string filename = MonsterDB::get(job - 1002).getSprite();
+ if (filename != "")
+ {
+ mSprites[BASE_SPRITE] = AnimatedSprite::load(
+ "graphics/sprites/" + filename);
+ }
+ else
+ {
+ mSprites[BASE_SPRITE] = AnimatedSprite::load("graphics/sprites/error.xml");
+ }
}
void
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 035882b6..7a465ec3 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -237,9 +237,42 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *
}
}
+ParticleEmitter::ParticleEmitter(const ParticleEmitter &o)
+{
+ *this = o;
+}
+
+ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
+{
+ mParticlePosX = o.mParticlePosX;
+ mParticlePosY = o.mParticlePosY;
+ mParticlePosZ = o.mParticlePosZ;
+ mParticleAngleHorizontal = o.mParticleAngleHorizontal;
+ mParticleAngleVertical = o.mParticleAngleVertical;
+ mParticlePower = o.mParticlePower;
+ mParticleGravity = o.mParticleGravity;
+ mParticleRandomnes = o.mParticleRandomnes;
+ mParticleBounce = o.mParticleBounce;
+ mParticleTarget = o.mParticleTarget;
+ mParticleAcceleration = o.mParticleAcceleration;
+ mParticleDieDistance = o.mParticleDieDistance;
+ mParticleMomentum = o.mParticleMomentum;
+ mParticleLifetime = o.mParticleLifetime;
+ mParticleFadeOut = o.mParticleFadeOut;
+ mParticleFadeIn = o.mParticleFadeIn;
+ mMap = o.mMap;
+ mOutput = o.mOutput;
+ mParticleImage = o.mParticleImage;
+ mParticleAnimation = o.mParticleAnimation;
+ mParticleChildEmitters = o.mParticleChildEmitters;
+
+ if (mParticleImage) mParticleImage->incRef();
+}
+
ParticleEmitter::~ParticleEmitter()
{
+ if (mParticleImage) mParticleImage->decRef();
}
diff --git a/src/particleemitter.h b/src/particleemitter.h
index 37d067a6..c9524488 100644
--- a/src/particleemitter.h
+++ b/src/particleemitter.h
@@ -48,6 +48,16 @@ class ParticleEmitter
ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map);
/**
+ * Copy Constructor (necessary for reference counting of particle images)
+ */
+ ParticleEmitter(const ParticleEmitter &o);
+
+ /**
+ * Assignment operator that calls the copy constructor
+ */
+ ParticleEmitter & operator=(const ParticleEmitter &o);
+
+ /**
* Destructor.
*/
~ParticleEmitter();
diff --git a/src/player.cpp b/src/player.cpp
index a1a86587..3d8a8b6e 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -153,8 +153,15 @@ void Player::setSprite(int slot, int id, std::string color)
}
else
{
- AnimatedSprite *equipmentSprite = AnimatedSprite::load(
- "graphics/sprites/" + ItemDB::get(id).getSprite(mGender) + "|" + color);
+ std::string filename = ItemDB::get(id).getSprite(mGender);
+ AnimatedSprite *equipmentSprite = NULL;
+
+ if (filename != "")
+ {
+ if (color!="") filename += "|" + color;
+ equipmentSprite = AnimatedSprite::load(
+ "graphics/sprites/" + filename);
+ }
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index de6f8d0b..ee823c3f 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -62,7 +62,10 @@ SpriteDef *SpriteDef::load(std::string const &animationFile, int variant)
char *data = (char*) resman->loadFile
(animationFile.substr(0, pos).c_str(), size);
- if (!data) return NULL;
+ if (!data && animationFile != "graphics/sprites/error.xml")
+ {
+ return load("graphics/sprites/error.xml", 0);
+ }
xmlDocPtr doc = xmlParseMemory(data, size);
free(data);