From 5c13eb7d35805bdf23574ae5a02c644ea08e726d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 10 Oct 2005 08:23:00 +0000 Subject: [PATCH] Oops. Actor::LoadFromNode wasn't virtual, but we were treating it as if it was (BitmapText::LoadFromNode, etc. called it). This worked because REGISTER_ACTOR_CLASS called it before the object was downcasted to an Actor. We then re-called Actor::LoadFromNode from ActorUtil::LoadFromActorFile; this worked because all it did was re-run Actor init (causing double calls to Init) and not the whole actor. (first half fix: make Actor::LoadFromNode virtual and add comment) --- stepmania/src/Actor.h | 2 +- stepmania/src/ActorUtil.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index a27db0cabc..cd53fa54f4 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -31,7 +31,7 @@ public: virtual Actor *Copy() const; void UnsubcribeAndClearCommands(); virtual void Reset(); - void LoadFromNode( const CString& sDir, const XNode* pNode ); + virtual void LoadFromNode( const CString& sDir, const XNode* pNode ); static void SetBGMTime( float fTime, float fBeat ); static void SetBGMLight( int iLightNumber, float fCabinetLights ); diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 72c961706f..cd6f73f738 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -197,7 +197,20 @@ Actor* ActorUtil::LoadFromActorFile( const CString& sDir, const XNode* pNode ) pReturn = ActorUtil::MakeActor( sNewPath ); if( pReturn == NULL ) goto all_done; - pReturn->LoadFromNode( sDir, pNode ); + + /* + * Hack: take attributes from the file loading the new actor, + * and load them on top of the new file. This way, you can do + * eg: + * + * file1.xml: + * file2.xml: + * + * Be sure to only run the low-level load, to pull in commands; + * don't reload the high-level actor, and don't rerun Init (which + * has already been run). + */ + pReturn->Actor::LoadFromNode( sDir, pNode ); } all_done: