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)
This commit is contained in:
Glenn Maynard
2005-10-10 08:23:00 +00:00
parent eef0ed7ffb
commit 5c13eb7d35
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -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 );
+14 -1
View File
@@ -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: <Layer File="file2" OnCommand="x,10" />
* file2.xml: <Layer File="image" OffCommand="y,10" />
*
* 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: