From 2aa932ca3a4ab2ea3ae5fb7496850266da4d49a2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 15 Jul 2005 04:16:31 +0000 Subject: [PATCH] Sprite copy ctor, same reason (refcounted textures) this is the sort of thing HiddenPtr is meant to avoid, but I'm not ready to start using it on refcounted objects just yet ... --- stepmania/src/Sprite.cpp | 21 +++++++++++++++++++++ stepmania/src/Sprite.h | 1 + 2 files changed, 22 insertions(+) diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 830f1712e0..c0755cacd6 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -14,6 +14,7 @@ #include "Foreach.h" #include "LuaBinding.h" #include "LuaManager.h" +#include "RageUtil_AutoPtr.h" REGISTER_ACTOR_CLASS( Sprite ) @@ -40,6 +41,26 @@ Sprite::~Sprite() UnloadTexture(); } +Sprite::Sprite( const Sprite &cpy ) +{ +#define CPY(a) a = cpy.a + CPY( m_sSpritePath ); + CPY( m_bDrawIfTextureNull ); + CPY( m_States ); + CPY( m_iCurState ); + CPY( m_fSecsIntoState ); + CPY( m_bUsingCustomTexCoords ); + CPY( m_bSkipNextUpdate ); + memcpy( m_CustomTexCoords, cpy.m_CustomTexCoords, sizeof(m_CustomTexCoords) ); + CPY( m_fRememberedClipWidth ); + CPY( m_fRememberedClipHeight ); + CPY( m_fTexCoordVelocityX ); + CPY( m_fTexCoordVelocityY ); +#undef CPY + + m_pTexture = TEXTUREMAN->CopyTexture( cpy.m_pTexture ); +} + RageTextureID Sprite::SongBGTexture( RageTextureID ID ) { ID.bMipMaps = true; diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 1622a2fcb6..aedc15bbad 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -12,6 +12,7 @@ class Sprite: public Actor { public: Sprite(); + Sprite( const Sprite &cpy ); virtual ~Sprite(); void LoadFromNode( const CString& sDir, const XNode* pNode );