Monday, April 20, 2009

Quick Fix to run testgame of N3 April. 2009 version.

Someone mentioned, 'testgame' application of N3 April. 2009 version does not run.

The following might fix the problem:

Modified:
trunk/code/application/
appgame/gameapplication.cc
trunk/code/application/appgame/gameapplication.h
trunk/code/application/basegamefeature/statehandlers/gamestatehandler.cc
trunk/code/application/basegamefeature/statehandlers/gamestatehandler.h

Modified: trunk/code/application/appgame/gameapplication.cc
==============================================================================
--- trunk/code/application/appgame/gameapplication.cc (original)
+++ trunk/code/application/appgame/gameapplication.cc Fri Apr 17 14:32:54 2009
@@ -336,6 +336,11 @@
GameApplication::SetupGameFeatures()
{
// create any features in derived class
+ //@csy
+ this->graphicsFeature = GraphicsFeature::GraphicsFeatureUnit::Create();
+ this->graphicsFeature->SetCmdLineArgs(this->GetCmdLineArgs());
+ this->graphicsFeature->SetRenderDebug(true);
+ this->gameServer->AttachGameFeature(this->graphicsFeature.upcast<Game::FeatureUnit>());
}

//------------------------------------------------------------------------------
@@ -346,6 +351,9 @@
GameApplication::CleanupGameFeatures()
{
// cleanup your features in derived class
+ //@csy
+ this->gameServer->RemoveGameFeature(this->graphicsFeature.upcast<Game::FeatureUnit>());
+ this->graphicsFeature = 0;
}

} // namespace App

Modified: trunk/code/application/appgame/gameapplication.h
==============================================================================
--- trunk/code/application/appgame/gameapplication.h (original)
+++ trunk/code/application/appgame/gameapplication.h Fri Apr 17 14:32:54 2009
@@ -22,6 +22,8 @@
#include "http/httpinterface.h"
#include "http/httpserverproxy.h"
#include "timing/mastertime.h"
+//@csy
+#include "graphicsfeature/graphicsfeatureunit.h"

//------------------------------------------------------------------------------
namespace App
@@ -91,6 +93,9 @@
// game server
Ptr<Game::GameServer> gameServer;

+ //@csy default game features
+ Ptr<GraphicsFeature::GraphicsFeatureUnit> graphicsFeature;
+
// profiling
_declare_timer(GameApplicationFrameTimeAll);
};

Modified: trunk/code/application/basegamefeature/statehandlers/gamestatehandler.cc
==============================================================================
--- trunk/code/application/basegamefeature/statehandlers/gamestatehandler.cc (original)
+++ trunk/code/application/basegamefeature/statehandlers/gamestatehandler.cc Fri Apr 17 14:32:54 2009
@@ -5,7 +5,7 @@
#include "stdneb.h"
#include "appgame/gameapplication.h"
#include "game/gameserver.h"
-#include "basegamefeature/basegamefeatureunit.h"
+
#include "basegamefeature/statehandlers/gamestatehandler.h"

namespace BaseGameFeature
@@ -40,7 +40,12 @@
*/
void
GameStateHandler::OnStateEnter(const Util::String& prevState)
-{
+{
+ //@csy
+ this->defaultGameFeature = BaseGameFeature::BaseGameFeatureUnit::Create();
+ App::GameApplication* app = App::GameApplication::Instance();
+ this->defaultGameFeature->SetCmdLineArgs(app->GetCmdLineArgs());
+ Game::GameServer::Instance()->AttachGameFeature(this->defaultGameFeature.upcast<Game::FeatureUnit>());
BaseGameFeatureUnit::Instance()->SetRenderDebug(true);

// setup the game

Modified: trunk/code/application/basegamefeature/statehandlers/gamestatehandler.h
==============================================================================
--- trunk/code/application/basegamefeature/statehandlers/gamestatehandler.h (original)
+++ trunk/code/application/basegamefeature/statehandlers/gamestatehandler.h Fri Apr 17 14:32:54 2009
@@ -13,7 +13,7 @@
(C) 2003 RadonLabs GmbH
*/
#include "appgame/statehandler.h"
-
+#include "basegamefeature/basegamefeatureunit.h"
//------------------------------------------------------------------------------
namespace BaseGameFeature
{
@@ -61,6 +61,8 @@
Util::String exitState;
Util::String levelName;
Util::String saveGame;
+ //@csy
+ Ptr<BaseGameFeature::BaseGameFeatureUnit> defaultGameFeature;
};

//------------------------------------------------------------------------------


3 comments:

Larry said...

Thanks for the fix posted on Floh's blog however, I still get an assert from ..\code\foundation\util\array.h

I've tracked the problem to ResourceDictionary::Load, it seems my resources.dic has 0 entries which causes the assert on line 76 of ..code\render\resources\resourcedictionary.cc

Kim, Hyoun Woo said...

Hey, we had not have any issues with ResourceDictionary::Load().

The error may occur if no proper resources are there.

Could you tell me what uri is of heapbuffer string?

Additional speaking, the vanilla version of April 2009 dose not call the function. To be call the function, resource.dic file should be exist in the export.zip file but the current released version does not include it. Check it. (you might find resource.dic file in the export_win32 resource directory)

Massa said...

Great post! thanks for writting this solution. I confirm it works. now i can study the engine with an living example (an reuse some code).