Permalink
Browse files

Sprite2D: add copy constructor

and copy method for copying subclasses with baseclass pointers
  • Loading branch information...
1 parent baa8252 commit 458b65b3e25b5a37fe435732bd9ad5438268e2bd @bradallred bradallred committed Jun 14, 2013
Showing with 23 additions and 0 deletions.
  1. +20 −0 gemrb/core/Sprite2D.cpp
  2. +3 −0 gemrb/core/Sprite2D.h
View
20 gemrb/core/Sprite2D.cpp
@@ -40,6 +40,26 @@ Sprite2D::Sprite2D(int Width, int Height, int Bpp, void* vptr, const void* pixel
renderFlags = 0;
}
+Sprite2D::Sprite2D(const Sprite2D &obj)
+{
+ BAM = false;
+ RefCount = 1;
+ vptr = obj.vptr; // TODO: vptr is deprecated
+
+ XPos = obj.XPos;
+ YPos = obj.YPos;
+ Width = obj.Width;
+ Height = obj.Height;
+ Bpp = obj.Bpp;
+
+ pixels = obj.pixels;
+}
+
+Sprite2D* Sprite2D::copy() const
+{
+ return new Sprite2D(*this);
+}
+
Sprite2D::~Sprite2D()
{
}
View
3 gemrb/core/Sprite2D.h
@@ -74,7 +74,10 @@ class GEM_EXPORT Sprite2D {
bool BAM;
ieDword renderFlags;
const void* pixels;
+
Sprite2D(int Width, int Height, int Bpp, void* vptr, const void* pixels);
+ Sprite2D(const Sprite2D &obj);
+ virtual Sprite2D* copy() const;
~Sprite2D();
bool IsPixelTransparent(unsigned short x, unsigned short y) const;
Palette *GetPalette() const;

0 comments on commit 458b65b

Please sign in to comment.