From c108dce3576fa8b6c3f95afd29c0cef47bf256a2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 28 Jan 2005 19:54:52 +0000 Subject: [PATCH] add copy ctor for ActorCommands. (This was an attempt to fix a crash, and wasn't the problem, but is very important anyway; it's currently unused, so untested.) --- stepmania/src/ActorCommands.cpp | 23 +++++++++++++++++++++++ stepmania/src/ActorCommands.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp index d50821caa0..d9edc34e2c 100644 --- a/stepmania/src/ActorCommands.cpp +++ b/stepmania/src/ActorCommands.cpp @@ -27,6 +27,29 @@ ActorCommands::~ActorCommands() Unregister(); } +ActorCommands::ActorCommands( const ActorCommands& cpy ) +{ + m_sLuaFunctionName = GetNextFunctionName(); + + /* We need to make a new function, since we'll be unregistered separately. Set + * the function by reference, so we don't make a new function unless we're actually + * changed. */ + ostringstream s; + s << m_sLuaFunctionName << " = " << cpy.GetFunctionName(); + + CString s2 = s.str(); + LUA->RunScript( s2 ); +} + +ActorCommands &ActorCommands::operator=( const ActorCommands& cpy ) +{ + if( this == &cpy ) + return *this; + + *this = cpy; + return *this; +} + CString ActorCommands::GetFunctionName() const { return m_sLuaFunctionName; diff --git a/stepmania/src/ActorCommands.h b/stepmania/src/ActorCommands.h index 8c730c2d56..9ad8879b26 100644 --- a/stepmania/src/ActorCommands.h +++ b/stepmania/src/ActorCommands.h @@ -11,6 +11,8 @@ class ActorCommands public: ActorCommands( const Commands& cmds ); ~ActorCommands(); + ActorCommands( const ActorCommands& cpy ); + ActorCommands &operator=( const ActorCommands& cpy ); CString GetFunctionName() const;