• entries
292
557
• views
154306

# 139 source files, and what does it do?

73 views

I opened up my SDL/SDL_image/SDL_mixer/SDL_net/SDL_ttf/eXpat wrapper/framework/engine/codebase today. I got it to compile and to link.

And it does nothing, which is really what it is supposed to do.

Although, truth be told, it doesn't exactly do "nothing" per se... it writes the following to stderr.txt:

Quote:
 IApplication::Execute: No appliction object exists.

This tells me a few things. One, I somehow failed to spell "application" correctly, and two, it works.

The wrapper/framework/engine/codebase doesn't do anything on its own. IApplication is an abstract base class for... applications (duh), and there need to be a derived class and an instance of such a class in order to IApplication::Execute(static member function) to be happy.

IApplication::Execute is the sole function called by main. In fact, since it is short, I'll post the entire main function:

int main(int argc,char* argv[]){	return(IApplication::Execute(argc,argv));}

If I could make IApplication::Execute the entry point, I surely would, as the only think main accomplishes is a handful of extra bytes on the stack.

of course, IApplication::Execute is much more interesting:

int IApplication::Execute(int argc,char* argv[]){	if(!GetApplication())	{		throw EGeneric(ERRID_NoApplication,"IApplication::Execute:\n\tNo appliction object exists.\n");	}	if(GetApplication()->OnStart(argc,argv))	{		while(!s_bQuit)		{			SDL_Event* pEvent;			switch(GetApplication()->GetAppType())			{			case APPTYPE_WAITEVENT:				{					pEvent=SEventManager::Wait();					GetApplication()->HandleBroadcast(MEventPointer(IEventHandler::MSGID_Event,pEvent),true);					GetApplication()->OnIdle();				}break;			case APPTYPE_POLLEVENT:				{					pEvent=SEventManager::Poll();					if(pEvent)					{						GetApplication()->HandleBroadcast(MEventPointer(IEventHandler::MSGID_Event,pEvent),true);					}					else					{						GetApplication()->OnIdle();					}				}break;			case APPTYPE_NOEVENT:				{					GetApplication()->OnIdle();					Quit();				}break;			}		}		GetApplication()->OnFinish();	}	return(GetApplication()->GetReturnValue());}

Anyway, it's fun to look at some of this old code. I guess I'm doing okay as far as being a developer goes, as while I look at this stuff, I don't feel any major need to change anything.

## 1 Comment

Foo! Your main() is shorter than mine! :P
int main(int argc, char* argv[])
{
new CKatanaEngine;
KatanaEngine->Start("data/app.cfg");

while (KatanaEngine->IsRunning())
KatanaEngine->Run();

KatanaEngine->End();
delete KatanaEngine;

return 1;
}


Hm. I just noticed that instead of looping the Run() function, I should prob just have it not return until runtime is over. Funny how/when you notice things like that

## Create an account

Register a new account