From: sf17k Date: Sun, 29 May 2011 06:55:36 +0000 (-0400) Subject: convert Game class to namespace X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=c44a844d9305c4f1f7dd0479e4a3af3e90b96a1b convert Game class to namespace --- diff --git a/Source/Game.cpp b/Source/Game.cpp index 5e001a1..1c250ca 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -26,8 +26,156 @@ int directing; float dialoguetime; int dialoguegonethrough[20]; -Game::Game() +namespace Game{ + GLuint terraintexture; + GLuint terraintexture2; + GLuint terraintexture3; + GLuint screentexture; + GLuint screentexture2; + GLuint logotexture; + GLuint loadscreentexture; + GLuint Maparrowtexture; + GLuint Mapboxtexture; + GLuint Mapcircletexture; + GLuint cursortexture; + GLuint Mainmenuitems[10]; + + int selected; + int keyselect; + int indemo; + + bool won; + + bool entername; + + char menustring[100][256]; + char registrationname[256]; + float registrationnumber; + + int newdetail; + int newscreenwidth; + int newscreenheight; + + bool gameon; + float deltah,deltav; + int mousecoordh,mousecoordv; + int oldmousecoordh,oldmousecoordv; + float rotation,rotation2; + SkyBox skybox; + bool cameramode; + int olddrawmode; + int drawmode; + bool firstload; + bool oldbutton; + + float leveltime; + float loadtime; + + Model hawk; + XYZ hawkcoords; + XYZ realhawkcoords; + GLuint hawktexture; + float hawkrotation; + float hawkcalldelay; + + Model eye; + Model iris; + Model cornea; + + bool stealthloading; + + std::vector campaignlevels; + int whichchoice; + int actuallevel; + bool winhotspot; + bool windialogue; + + bool minimap; + + int musictype,oldmusictype,oldoldmusictype; + bool realthreat; + + Model rabbit; + XYZ rabbitcoords; + + XYZ mapcenter; + float mapradius; + + Text* text; + float fps; + + XYZ cameraloc; + float cameradist; + + int drawtoggle; + + bool editorenabled; + int editortype; + float editorsize; + float editorrotation; + float editorrotation2; + + float brightness; + + int quit; + int tryquit; + + XYZ pathpoint[30]; + int numpathpoints; + int numpathpointconnect[30]; + int pathpointconnect[30][30]; + int pathpointselected; + + int endgame; + bool scoreadded; + int numchallengelevels; + + bool console; + int archiveselected; + char consoletext[15][256]; + int consolechars[15]; + bool chatting; + char displaytext[15][256]; + int displaychars[15]; + float displaytime[15]; + float displayblinkdelay; + bool displayblink; + int displayselected; + bool consolekeydown; + float consoleblinkdelay; + bool consoleblink; + int consoleselected; + bool autocam; + + unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; + unsigned short consolekey; + bool oldattackkey; + + int loading; + float talkdelay; + + int numboundaries; + XYZ boundary[360]; + + int whichlevel; + int oldenvironment; + int targetlevel; + float changedelay; + + float musicvolume[4]; + float oldmusicvolume[4]; + int musicselected; + int change; + + bool waiting; + Account* accountactive; +} + +void Game::newGame() { + text=NULL; + text=new Text(); + terraintexture = 0; terraintexture2 = 0; terraintexture3 = 0; @@ -181,10 +329,26 @@ Game::Game() accountactive = NULL; } -typedef struct { - Game* game; - void (Game::*method)(); -} params_thread; +void Game::deleteGame(){ + if(text) + delete text; + for(int i=0;i<10;i++){ + if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] ); + } + glDeleteTextures( 1, &cursortexture ); + glDeleteTextures( 1, &Maparrowtexture ); + glDeleteTextures( 1, &Mapboxtexture ); + glDeleteTextures( 1, &Mapcircletexture ); + glDeleteTextures( 1, &terraintexture ); + glDeleteTextures( 1, &terraintexture2 ); + if(screentexture>0)glDeleteTextures( 1, &screentexture ); + if(screentexture2>0)glDeleteTextures( 1, &screentexture2 ); + glDeleteTextures( 1, &hawktexture ); + glDeleteTextures( 1, &logotexture ); + glDeleteTextures( 1, &loadscreentexture ); + + Dispose(); +} void Game::fireSound(int sound) { emit_sound_at(sound); @@ -255,11 +419,8 @@ void Game::inputText(char* str, int* charselected, int* nb_chars) { void Game::setKeySelected() { waiting=true; - params_thread* data = new params_thread; - data->game = this; - data->method = &Game::setKeySelected_thread; printf("launch thread\n"); - SDL_Thread* thread = SDL_CreateThread(Game::thread, data); + SDL_Thread* thread = SDL_CreateThread(Game::setKeySelected_thread,NULL); if ( thread == NULL ) { fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError()); waiting=false; @@ -267,7 +428,7 @@ void Game::setKeySelected() { } } -void Game::setKeySelected_thread() { +int Game::setKeySelected_thread(void* data) { int keycode=-1; SDL_Event evenement; while(keycode==-1) { @@ -312,13 +473,7 @@ void Game::setKeySelected_thread() { } keyselect=-1; waiting=false; -} - -int Game::thread(void *data) { - params_thread* pt = (params_thread*)data; - if(pt) { - (pt->game->*(pt->method))(); - } + return 0; } void Game::DrawGL() { diff --git a/Source/Game.h b/Source/Game.h index bc7ac53..500d9b6 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -152,216 +152,198 @@ public: } }; -class Game +namespace Game { - public: - GLuint terraintexture; - GLuint terraintexture2; - GLuint terraintexture3; - GLuint screentexture; - GLuint screentexture2; - GLuint logotexture; - GLuint loadscreentexture; - GLuint Maparrowtexture; - GLuint Mapboxtexture; - GLuint Mapcircletexture; - GLuint cursortexture; - GLuint Mainmenuitems[10]; - - int selected; - int keyselect; - int indemo; - - bool won; - - bool entername; - - char menustring[100][256]; - char registrationname[256]; - float registrationnumber; - - int newdetail; - int newscreenwidth; - int newscreenheight; - - bool gameon; - float deltah,deltav; - int mousecoordh,mousecoordv; - int oldmousecoordh,oldmousecoordv; - float rotation,rotation2; - SkyBox skybox; - bool cameramode; - int olddrawmode; - int drawmode; - bool firstload; - bool oldbutton; - - float leveltime; - float loadtime; - - Model hawk; - XYZ hawkcoords; - XYZ realhawkcoords; - GLuint hawktexture; - float hawkrotation; - float hawkcalldelay; - - Model eye; - Model iris; - Model cornea; - - bool stealthloading; - - std::vector campaignlevels; - int whichchoice; - int actuallevel; - bool winhotspot; - bool windialogue; - - bool minimap; - - int musictype,oldmusictype,oldoldmusictype; - bool realthreat; - - Model rabbit; - XYZ rabbitcoords; - - XYZ mapcenter; - float mapradius; - - Text text; - float fps; - - XYZ cameraloc; - float cameradist; - - int drawtoggle; - - bool editorenabled; - int editortype; - float editorsize; - float editorrotation; - float editorrotation2; - - float brightness; - - int quit; - int tryquit; - - XYZ pathpoint[30]; - int numpathpoints; - int numpathpointconnect[30]; - int pathpointconnect[30][30]; - int pathpointselected; - - int endgame; - bool scoreadded; - int numchallengelevels; - - bool console; - int archiveselected; - char consoletext[15][256]; - int consolechars[15]; - bool chatting; - char displaytext[15][256]; - int displaychars[15]; - float displaytime[15]; - float displayblinkdelay; - bool displayblink; - int displayselected; - bool consolekeydown; - float consoleblinkdelay; - bool consoleblink; - int consoleselected; - bool autocam; - - unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; - unsigned short consolekey; - bool oldattackkey; - - static void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha); - static void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize); - void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize); - bool AddClothes(const char *fileName, GLubyte *array); - void InitGame(); - void LoadScreenTexture(); - void LoadStuff(); - void LoadingScreen(); - void LoadCampaign(); - static std::vector ListCampaigns(); - void FadeLoadingScreen(float howmuch); - void Dispose(); - int DrawGLScene(StereoSide side); - void DrawMenu(); - void DrawGL(); - //factored from Tick() -sf17k - void MenuTick(); - void doTutorial(); - void doDebugKeys(); - void doJumpReversals(); - void doAerialAcrobatics(); - void doAttacks(); - void doPlayerCollisions(); - void doAI(int i); - //end factored - void Tick(); - void TickOnce(); - void TickOnceAfter(); - void SetUpLighting(); - void Loadlevel(int which); - void Loadlevel(const char *name); - void Setenvironment(int which); - GLvoid ReSizeGLScene(float fov, float near); - int findPathDist(int start,int end); - int checkcollide(XYZ startpoint, XYZ endpoint); - int checkcollide(XYZ startpoint, XYZ endpoint, int what); - int loading; - float talkdelay; - - void fireSound(int sound=fireendsound); - void setKeySelected(); - - int numboundaries; - XYZ boundary[360]; - - int whichlevel; - int oldenvironment; - int targetlevel; - float changedelay; - - float musicvolume[4]; - float oldmusicvolume[4]; - int musicselected; - int change; - Game(); - ~Game() { - for(int i=0;i<10;i++){ - if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] ); - } - glDeleteTextures( 1, &cursortexture ); - glDeleteTextures( 1, &Maparrowtexture ); - glDeleteTextures( 1, &Mapboxtexture ); - glDeleteTextures( 1, &Mapcircletexture ); - glDeleteTextures( 1, &terraintexture ); - glDeleteTextures( 1, &terraintexture2 ); - if(screentexture>0)glDeleteTextures( 1, &screentexture ); - if(screentexture2>0)glDeleteTextures( 1, &screentexture2 ); - glDeleteTextures( 1, &hawktexture ); - glDeleteTextures( 1, &logotexture ); - glDeleteTextures( 1, &loadscreentexture ); - - Dispose(); - } - bool isWaiting() { return waiting; }; - private: - void setKeySelected_thread(); - static int thread(void *data); - void inputText(char* str, int* charselected, int* nb_chars); - void flash(); - bool waiting; - //int mainmenu; - Account* accountactive; -}; + //public: + extern GLuint terraintexture; + extern GLuint terraintexture2; + extern GLuint terraintexture3; + extern GLuint screentexture; + extern GLuint screentexture2; + extern GLuint logotexture; + extern GLuint loadscreentexture; + extern GLuint Maparrowtexture; + extern GLuint Mapboxtexture; + extern GLuint Mapcircletexture; + extern GLuint cursortexture; + extern GLuint Mainmenuitems[10]; + + extern int selected; + extern int keyselect; + extern int indemo; + + extern bool won; + + extern bool entername; + + extern char menustring[100][256]; + extern char registrationname[256]; + extern float registrationnumber; + + extern int newdetail; + extern int newscreenwidth; + extern int newscreenheight; + + extern bool gameon; + extern float deltah,deltav; + extern int mousecoordh,mousecoordv; + extern int oldmousecoordh,oldmousecoordv; + extern float rotation,rotation2; + extern SkyBox skybox; + extern bool cameramode; + extern int olddrawmode; + extern int drawmode; + extern bool firstload; + extern bool oldbutton; + + extern float leveltime; + extern float loadtime; + + extern Model hawk; + extern XYZ hawkcoords; + extern XYZ realhawkcoords; + extern GLuint hawktexture; + extern float hawkrotation; + extern float hawkcalldelay; + + extern Model eye; + extern Model iris; + extern Model cornea; + + extern bool stealthloading; + + extern std::vector campaignlevels; + extern int whichchoice; + extern int actuallevel; + extern bool winhotspot; + extern bool windialogue; + + extern bool minimap; + + extern int musictype,oldmusictype,oldoldmusictype; + extern bool realthreat; + + extern Model rabbit; + extern XYZ rabbitcoords; + + extern XYZ mapcenter; + extern float mapradius; + + extern Text* text; + extern float fps; + + extern XYZ cameraloc; + extern float cameradist; + + extern int drawtoggle; + + extern bool editorenabled; + extern int editortype; + extern float editorsize; + extern float editorrotation; + extern float editorrotation2; + + extern float brightness; + + extern int quit; + extern int tryquit; + + extern XYZ pathpoint[30]; + extern int numpathpoints; + extern int numpathpointconnect[30]; + extern int pathpointconnect[30][30]; + extern int pathpointselected; + + extern int endgame; + extern bool scoreadded; + extern int numchallengelevels; + + extern bool console; + extern int archiveselected; + extern char consoletext[15][256]; + extern int consolechars[15]; + extern bool chatting; + extern char displaytext[15][256]; + extern int displaychars[15]; + extern float displaytime[15]; + extern float displayblinkdelay; + extern bool displayblink; + extern int displayselected; + extern bool consolekeydown; + extern float consoleblinkdelay; + extern bool consoleblink; + extern int consoleselected; + extern bool autocam; + + extern unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; + extern unsigned short consolekey; + extern bool oldattackkey; + + void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha); + void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize); + void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize); + bool AddClothes(const char *fileName, GLubyte *array); + void InitGame(); + void LoadScreenTexture(); + void LoadStuff(); + void LoadingScreen(); + void LoadCampaign(); + std::vector ListCampaigns(); + void FadeLoadingScreen(float howmuch); + void Dispose(); + int DrawGLScene(StereoSide side); + void DrawMenu(); + void DrawGL(); + //factored from Tick() -sf17k + void MenuTick(); + void doTutorial(); + void doDebugKeys(); + void doJumpReversals(); + void doAerialAcrobatics(); + void doAttacks(); + void doPlayerCollisions(); + void doAI(int i); + //end factored + void Tick(); + void TickOnce(); + void TickOnceAfter(); + void SetUpLighting(); + void Loadlevel(int which); + void Loadlevel(const char *name); + void Setenvironment(int which); + GLvoid ReSizeGLScene(float fov, float near); + int findPathDist(int start,int end); + int checkcollide(XYZ startpoint, XYZ endpoint); + int checkcollide(XYZ startpoint, XYZ endpoint, int what); + extern int loading; + extern float talkdelay; + + void fireSound(int sound=fireendsound); + void setKeySelected(); + + extern int numboundaries; + extern XYZ boundary[360]; + + extern int whichlevel; + extern int oldenvironment; + extern int targetlevel; + extern float changedelay; + + extern float musicvolume[4]; + extern float oldmusicvolume[4]; + extern int musicselected; + extern int change; + void newGame(); + void deleteGame(); + extern bool waiting; + //private: + int setKeySelected_thread(void*); + int thread(void *data); + void inputText(char* str, int* charselected, int* nb_chars); + void flash(); + //bool waiting; + extern Account* accountactive; +} #ifndef __forceinline # ifdef __GNUC__ diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index ad67446..f5d0513 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -583,7 +583,7 @@ int Game::DrawGLScene(StereoSide side) glColor4f(.5,.5,.5,1); if(!console) { sprintf (string, " ",(int)(fps)); - text.glPrint(10,30,string,0,.8,screenwidth,screenheight); + text->glPrint(10,30,string,0,.8,screenwidth,screenheight); if(!tutoriallevel) if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){ @@ -594,15 +594,15 @@ int Game::DrawGLScene(StereoSide side) bonus_name = "Excellent!"; // When does this happen? glColor4f(0,0,0,1-bonustime); - text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768); + text->glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768); glColor4f(1,0,0,1-bonustime); - text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768); + text->glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768); sprintf (string, "%d",(int)bonusvalue); glColor4f(0,0,0,1-bonustime); - text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768); + text->glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768); glColor4f(1,0,0,1-bonustime); - text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768); + text->glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768); glColor4f(.5,.5,.5,1); } @@ -880,26 +880,26 @@ int Game::DrawGLScene(StereoSide side) } glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); glColor4f(1,1,1,tutorialopac); - text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight); sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey)); sprintf (string2, "Press escape at any time to"); sprintf (string3, "pause or exit the tutorial."); glColor4f(0,0,0,1); - text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight); glColor4f(0.5,0.5,0.5,1); - text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); - text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); + text->glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight); } //Hot spots @@ -937,9 +937,9 @@ int Game::DrawGLScene(StereoSide side) while(!done){ if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){ glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); glColor4f(1,1,1,tutorialopac); - text.glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); lastline=i+1; line++; if(string[i]=='\0')done=1; @@ -1055,14 +1055,14 @@ int Game::DrawGLScene(StereoSide side) if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){ glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); glColor4f(0.7,0.7,0.7,tutorialopac); - text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight); + text->glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight); } else { glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); + text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); } tempnum=0; @@ -1081,14 +1081,14 @@ int Game::DrawGLScene(StereoSide side) if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){ if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){ glColor4f(0,0,0,tutorialopac); - text.glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/-4,starty-4-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/-4,starty-4-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i); glColor4f(1,1,1,tutorialopac); - text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); } else { glColor4f(0,0,0,tutorialopac); - text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); + text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i); } lastline=i+1; line++; @@ -1108,9 +1108,9 @@ int Game::DrawGLScene(StereoSide side) } if(!campaign)sprintf (string, "Score: %d", (int)bonustotal); glColor4f(0,0,0,1); - text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768); + text->glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768); glColor4f(1,0,0,1); - text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768); + text->glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768); if(showdamagebar) { glDisable(GL_DEPTH_TEST); // Disables Depth Testing glDisable(GL_CULL_FACE); @@ -1191,9 +1191,9 @@ int Game::DrawGLScene(StereoSide side) // writing the numbers : sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss)); glColor4f(0,0,0,1); - text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768); + text->glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768); glColor4f(1,0,0,1); - text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768); + text->glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768); } } @@ -1202,28 +1202,28 @@ int Game::DrawGLScene(StereoSide side) if((texttoggle||editorenabled)&&debugmode&&!mainmenu){ sprintf (string, "The framespersecond is %d.",(int)(fps)); - text.glPrint(10,30,string,0,.8,1024,768); + text->glPrint(10,30,string,0,.8,1024,768); sprintf (string, "Name: %s", registrationname); - text.glPrint(10,260,string,0,.8,1024,768); + text->glPrint(10,260,string,0,.8,1024,768); if(editorenabled) sprintf (string, "Map editor enabled."); else sprintf (string, "Map editor disabled."); - text.glPrint(10,60,string,0,.8,1024,768); + text->glPrint(10,60,string,0,.8,1024,768); if(editorenabled){ sprintf (string, "Object size: %f",editorsize); - text.glPrint(10,75,string,0,.8,1024,768); + text->glPrint(10,75,string,0,.8,1024,768); if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation); else sprintf (string, "Object rotation: Random"); - text.glPrint(10,90,string,0,.8,1024,768); + text->glPrint(10,90,string,0,.8,1024,768); if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2); else sprintf (string, "Object rotation2: Random"); - text.glPrint(10,105,string,0,.8,1024,768); + text->glPrint(10,105,string,0,.8,1024,768); sprintf (string, "Object type: %d",editortype); - text.glPrint(10,120,string,0,.8,1024,768); + text->glPrint(10,120,string,0,.8,1024,768); switch(editortype) { case boxtype: sprintf (string, "(box)"); @@ -1262,15 +1262,15 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "(fire)"); break; } - text.glPrint(130,120,string,0,.8,1024,768); + text->glPrint(130,120,string,0,.8,1024,768); sprintf (string, "Numplayers: %d",numplayers); - text.glPrint(10,155,string,0,.8,1024,768); + text->glPrint(10,155,string,0,.8,1024,768); sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints); - text.glPrint(10,140,string,0,.8,1024,768); + text->glPrint(10,140,string,0,.8,1024,768); } sprintf (string, "Difficulty: %d",difficulty); - text.glPrint(10,240,string,0,.8,1024,768); + text->glPrint(10,240,string,0,.8,1024,768); } } @@ -1397,10 +1397,10 @@ int Game::DrawGLScene(StereoSide side) glColor4f(1,1,1,1); if(chatting){ sprintf (string, " ]"); - text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight); + text->glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight); if(displayblink){ sprintf (string, "_"); - text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight); + text->glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight); } } for(i=0;i<15;i++) @@ -1409,7 +1409,7 @@ int Game::DrawGLScene(StereoSide side) glColor4f(1,1,1,4-displaytime[i]); if(jglPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight); } } } @@ -1643,7 +1643,7 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glColor4f(1,1,1,1); sprintf (string, "Loading..."); - text.glPrint(1024/2-90,768/2,string,1,2,1024,768); + text->glPrint(1024/2-90,768/2,string,1,2,1024,768); } loading=2; //if(ismotionblur)drawmode=motionblurmode; @@ -1693,16 +1693,16 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glColor4f(1,1,1,1); sprintf (string, "Level Cleared!"); - text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768); + text->glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768); sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal)); - text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768); if(campaign) sprintf (string, "Press Escape or Space to continue"); else sprintf (string, "Press Escape to return to menu or Space to continue"); - text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480); + text->glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480); char temp[255]; @@ -1712,14 +1712,14 @@ int Game::DrawGLScene(StereoSide side) if((int)(leveltime)%60<10)strcat(string,"0"); sprintf (temp, "%d",(int)(leveltime)%60); strcat(string,temp); - text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768); //Awards int awards[award_count]; int numawards = award_awards(awards); for (i = 0; i < numawards && i < 6; i++) - text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768); + text->glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768); } if(drawmode!=normalmode){ @@ -1977,17 +1977,17 @@ int Game::DrawGLScene(StereoSide side) if(consoleselected>=60) offset=consoleselected-60; sprintf (string, " ]"); - text.glPrint(10,30,string,0,1,1024,768); + text->glPrint(10,30,string,0,1,1024,768); if(consoleblink){ sprintf (string, "_"); - text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); + text->glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); } for(i=0;i<15;i++) for(j=0;jglPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768); } } } @@ -2397,7 +2397,7 @@ void Game::DrawMenu() { oldmainmenu=mainmenu; selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight); - Menu::GUITick(this); + Menu::GUITick(); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix @@ -2408,7 +2408,7 @@ void Game::DrawMenu() { glLoadIdentity(); // Reset The Modelview Matrix glEnable(GL_TEXTURE_2D); - Menu::drawItems(this); + Menu::drawItems(); //draw mouse cursor glMatrixMode(GL_PROJECTION); // Select The Projection Matrix diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index eb55bb3..ba38ecb 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -646,8 +646,8 @@ void Game::InitGame() int temptexdetail=texdetail; texdetail=1; - text.LoadFontTexture(":Data:Textures:Font.png"); - text.BuildFont(); + text->LoadFontTexture(":Data:Textures:Font.png"); + text->BuildFont(); texdetail=temptexdetail; FadeLoadingScreen(10); @@ -786,8 +786,8 @@ void Game::LoadStuff() temptexdetail=texdetail; texdetail=1; - text.LoadFontTexture(":Data:Textures:Font.png"); - text.BuildFont(); + text->LoadFontTexture(":Data:Textures:Font.png"); + text->BuildFont(); texdetail=temptexdetail; numsounds=71; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 8b51988..74419e6 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include using namespace std; +using namespace Game; // Added more evilness needed for MSVC #ifdef _MSC_VER @@ -172,9 +173,9 @@ static const char *cmd_names[] = { #undef DECLARE_COMMAND }; -typedef void (*console_handler)(Game *game, const char *args); +typedef void (*console_handler)(const char *args); -#define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args); +#define DECLARE_COMMAND(cmd) static void ch_##cmd(const char *args); #include "ConsoleCmds.h" #undef DECLARE_COMMAND @@ -258,19 +259,19 @@ void playdialogueboxsound(){ -static void ch_quit(Game *game, const char *args) +static void ch_quit(const char *args) { - game->tryquit = 1; + tryquit = 1; } -static void ch_map(Game *game, const char *args) +static void ch_map(const char *args) { - game->Loadlevel(args); - game->whichlevel = -2; + Loadlevel(args); + whichlevel = -2; campaign = 0; } -static void ch_save(Game *game, const char *args){ +static void ch_save(const char *args){ char buf[64]; snprintf(buf, 63, ":Data:Maps:%s", args); @@ -423,59 +424,59 @@ static void ch_save(Game *game, const char *args){ } } - fpackf(tfile, "Bi", game->numpathpoints); - for(int j=0;jnumpathpoints;j++){ - fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]); - for(int k=0;knumpathpointconnect[j];k++) - fpackf(tfile, "Bi", game->pathpointconnect[j][k]); + fpackf(tfile, "Bi", numpathpoints); + for(int j=0;jmapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); + fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius); fclose(tfile); } -static void ch_cellar(Game *game, const char *args) +static void ch_cellar(const char *args) { - game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); + LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_tint(Game *game, const char *args) +static void ch_tint(const char *args) { sscanf(args, "%f%f%f", &tintr, &tintg, &tintb); } -static void ch_tintr(Game *game, const char *args) +static void ch_tintr(const char *args) { tintr = atof(args); } -static void ch_tintg(Game *game, const char *args) +static void ch_tintg(const char *args) { tintg = atof(args); } -static void ch_tintb(Game *game, const char *args) +static void ch_tintb(const char *args) { tintb = atof(args); } -static void ch_speed(Game *game, const char *args) +static void ch_speed(const char *args) { player[0].speedmult = atof(args); } -static void ch_strength(Game *game, const char *args) +static void ch_strength(const char *args) { player[0].power = atof(args); } -static void ch_power(Game *game, const char *args) +static void ch_power(const char *args) { player[0].power = atof(args); } -static void ch_size(Game *game, const char *args) +static void ch_size(const char *args) { player[0].scale = atof(args) * .2; } @@ -496,7 +497,7 @@ static int find_closest() return closest; } -static void ch_sizenear(Game *game, const char *args) +static void ch_sizenear(const char *args) { int closest = find_closest(); @@ -524,12 +525,12 @@ static void set_proportion(int pnum, const char *args) } } -static void ch_proportion(Game *game, const char *args) +static void ch_proportion(const char *args) { set_proportion(0, args); } -static void ch_proportionnear(Game *game, const char *args) +static void ch_proportionnear(const char *args) { int closest = find_closest(); if (closest) @@ -546,12 +547,12 @@ static void set_protection(int pnum, const char *args) player[pnum].protectionlow = low; } -static void ch_protection(Game *game, const char *args) +static void ch_protection(const char *args) { set_protection(0, args); } -static void ch_protectionnear(Game *game, const char *args) +static void ch_protectionnear(const char *args) { int closest = find_closest(); if (closest) @@ -568,19 +569,19 @@ static void set_armor(int pnum, const char *args) player[pnum].armorlow = low; } -static void ch_armor(Game *game, const char *args) +static void ch_armor(const char *args) { set_armor(0, args); } -static void ch_armornear(Game *game, const char *args) +static void ch_armornear(const char *args) { int closest = find_closest(); if (closest) set_armor(closest, args); } -static void ch_protectionreset(Game *game, const char *args) +static void ch_protectionreset(const char *args) { set_protection(0, "1 1 1"); set_armor(0, "1 1 1"); @@ -596,38 +597,38 @@ static void set_metal(int pnum, const char *args) player[pnum].metallow = low; } -static void ch_metal(Game *game, const char *args) +static void ch_metal(const char *args) { set_metal(0, args); } -static void set_noclothes(int pnum, Game *game, const char *args) +static void set_noclothes(int pnum, const char *args) { player[pnum].numclothes = 0; - game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], + LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin], &player[pnum].skeleton.drawmodel.textureptr,1, &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize); } -static void ch_noclothes(Game *game, const char *args) +static void ch_noclothes(const char *args) { - set_noclothes(0, game, args); + set_noclothes(0, args); } -static void ch_noclothesnear(Game *game, const char *args) +static void ch_noclothesnear(const char *args) { int closest = find_closest(); if (closest) - set_noclothes(closest, game, args); + set_noclothes(closest, args); } -static void set_clothes(int pnum, Game *game, const char *args) +static void set_clothes(int pnum, const char *args) { char buf[64]; snprintf(buf, 63, ":Data:Textures:%s.png", args); - if (!game->AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) + if (!AddClothes(buf,&player[pnum].skeleton.skinText[pnum])) return; player[pnum].DoMipmaps(); @@ -638,25 +639,25 @@ static void set_clothes(int pnum, Game *game, const char *args) player[pnum].numclothes++; } -static void ch_clothes(Game *game, const char *args) +static void ch_clothes(const char *args) { - set_clothes(0, game, args); + set_clothes(0, args); } -static void ch_clothesnear(Game *game, const char *args) +static void ch_clothesnear(const char *args) { int closest = find_closest(); if (closest) - set_clothes(closest, game, args); + set_clothes(closest, args); } -static void ch_belt(Game *game, const char *args) +static void ch_belt(const char *args) { player[0].skeleton.clothes = !player[0].skeleton.clothes; } -static void ch_cellophane(Game *game, const char *args) +static void ch_cellophane(const char *args) { cellophane = !cellophane; float mul = cellophane ? 0 : 1; @@ -669,7 +670,7 @@ static void ch_cellophane(Game *game, const char *args) } } -static void ch_funnybunny(Game *game, const char *args) +static void ch_funnybunny(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow", @@ -678,7 +679,7 @@ static void ch_funnybunny(Game *game, const char *args) ":Data:Models:Body4.solid",":Data:Models:Body5.solid", ":Data:Models:Body6.solid",":Data:Models:Body7.solid", ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1); - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=rabbittype; player[0].scale=.2; @@ -687,7 +688,7 @@ static void ch_funnybunny(Game *game, const char *args) set_proportion(0, "1 1 1 1"); } -static void ch_wolfie(Game *game, const char *args) +static void ch_wolfie(const char *args) { player[0].skeleton.id=0; player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low", @@ -696,80 +697,80 @@ static void ch_wolfie(Game *game, const char *args) ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid", ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid", ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0); - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); player[0].creature=wolftype; player[0].damagetolerance=300; set_proportion(0, "1 1 1 1"); } -static void ch_wolfieisgod(Game *game, const char *args) +static void ch_wolfieisgod(const char *args) { - ch_wolfie(game, args); + ch_wolfie(args); } -static void ch_wolf(Game *game, const char *args) +static void ch_wolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_snowwolf(Game *game, const char *args) +static void ch_snowwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_darkwolf(Game *game, const char *args) +static void ch_darkwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_lizardwolf(Game *game, const char *args) +static void ch_lizardwolf(const char *args) { - game->LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_white(Game *game, const char *args) +static void ch_white(const char *args) { - game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_brown(Game *game, const char *args) +static void ch_brown(const char *args) { - game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_black(Game *game, const char *args) +static void ch_black(const char *args) { - game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1, + LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1, &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize); } -static void ch_sizemin(Game *game, const char *args) +static void ch_sizemin(const char *args) { for (int i = 1; i < numplayers; i++) if (player[i].scale < 0.8 * 0.2) player[i].scale = 0.8 * 0.2; } -static void ch_tutorial(Game *game, const char *args) +static void ch_tutorial(const char *args) { tutoriallevel = atoi(args); } -static void ch_hostile(Game *game, const char *args) +static void ch_hostile(const char *args) { hostile = atoi(args); } -static void ch_indemo(Game *game, const char *args) +static void ch_indemo(const char *args) { - game->indemo=1; + indemo=1; hotspot[numhotspots]=player[0].coords; hotspotsize[numhotspots]=0; hotspottype[numhotspots]=-111; @@ -777,13 +778,13 @@ static void ch_indemo(Game *game, const char *args) numhotspots++; } -static void ch_notindemo(Game *game, const char *args) +static void ch_notindemo(const char *args) { - game->indemo=0; + indemo=0; numhotspots--; } -static void ch_type(Game *game, const char *args) +static void ch_type(const char *args) { int n = sizeof(editortypenames) / sizeof(editortypenames[0]); for (int i = 0; i < n; i++) @@ -793,7 +794,7 @@ static void ch_type(Game *game, const char *args) } } -static void ch_path(Game *game, const char *args) +static void ch_path(const char *args) { int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]); for (int i = 0; i < n; i++) @@ -803,7 +804,7 @@ static void ch_path(Game *game, const char *args) } } -static void ch_hs(Game *game, const char *args) +static void ch_hs(const char *args) { hotspot[numhotspots]=player[0].coords; @@ -820,7 +821,7 @@ static void ch_hs(Game *game, const char *args) numhotspots++; } -static void ch_dialogue(Game *game, const char *args) +static void ch_dialogue(const char *args) { int dlg; char buf1[32], buf2[64]; @@ -871,7 +872,7 @@ static void ch_dialogue(Game *game, const char *args) numdialogues++; } -static void ch_fixdialogue(Game *game, const char *args) +static void ch_fixdialogue(const char *args) { char buf1[32], buf2[64]; int whichdi; @@ -909,47 +910,47 @@ static void ch_fixdialogue(Game *game, const char *args) ipstream.close(); } -static void ch_fixtype(Game *game, const char *args) +static void ch_fixtype(const char *args) { int dlg; sscanf(args, "%d", &dlg); dialoguetype[0] = dlg; } -static void ch_fixrotation(Game *game, const char *args) +static void ch_fixrotation(const char *args) { participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation; } -static void ch_ddialogue(Game *game, const char *args) +static void ch_ddialogue(const char *args) { if (numdialogues) numdialogues--; } -static void ch_dhs(Game *game, const char *args) +static void ch_dhs(const char *args) { if (numhotspots) numhotspots--; } -static void ch_immobile(Game *game, const char *args) +static void ch_immobile(const char *args) { player[0].immobile = 1; } -static void ch_allimmobile(Game *game, const char *args) +static void ch_allimmobile(const char *args) { for (int i = 1; i < numplayers; i++) player[i].immobile = 1; } -static void ch_mobile(Game *game, const char *args) +static void ch_mobile(const char *args) { player[0].immobile = 0; } -static void ch_default(Game *game, const char *args) +static void ch_default(const char *args) { player[0].armorhead=1; player[0].armorhigh=1; @@ -978,7 +979,7 @@ static void ch_default(Game *game, const char *args) } player[0].numclothes=0; - game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], + LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin], &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0], &player[0].skeleton.skinsize); @@ -986,7 +987,7 @@ static void ch_default(Game *game, const char *args) player[0].immobile=0; } -static void ch_play(Game *game, const char *args) +static void ch_play(const char *args) { int dlg; sscanf(args, "%d", &dlg); @@ -1010,49 +1011,49 @@ static void ch_play(Game *game, const char *args) playdialogueboxsound(); } -static void ch_mapkilleveryone(Game *game, const char *args) +static void ch_mapkilleveryone(const char *args) { maptype = mapkilleveryone; } -static void ch_mapkillmost(Game *game, const char *args) +static void ch_mapkillmost(const char *args) { maptype = mapkillmost; } -static void ch_mapkillsomeone(Game *game, const char *args) +static void ch_mapkillsomeone(const char *args) { maptype = mapkillsomeone; } -static void ch_mapgosomewhere(Game *game, const char *args) +static void ch_mapgosomewhere(const char *args) { maptype = mapgosomewhere; } -static void ch_viewdistance(Game *game, const char *args) +static void ch_viewdistance(const char *args) { viewdistance = atof(args)*100; } -static void ch_fadestart(Game *game, const char *args) +static void ch_fadestart(const char *args) { fadestart = atof(args); } -static void ch_slomo(Game *game, const char *args) +static void ch_slomo(const char *args) { slomospeed = atof(args); slomo = !slomo; slomodelay = 1000; } -static void ch_slofreq(Game *game, const char *args) +static void ch_slofreq(const char *args) { slomofreq = atof(args); } -static void ch_skytint(Game *game, const char *args) +static void ch_skytint(const char *args) { sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb); @@ -1060,33 +1061,33 @@ static void ch_skytint(Game *game, const char *args) skyboxlightg=skyboxg; skyboxlightb=skyboxb; - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skylight(Game *game, const char *args) +static void ch_skylight(const char *args) { sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb); - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void ch_skybox(Game *game, const char *args) +static void ch_skybox(const char *args) { skyboxtexture = !skyboxtexture; - game->SetUpLighting(); + SetUpLighting(); terrain.DoShadows(); objects.DoShadows(); } -static void cmd_dispatch(Game *game, const string cmd) +static void cmd_dispatch(const string cmd) { int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]); @@ -1094,7 +1095,7 @@ static void cmd_dispatch(Game *game, const string cmd) if (cmd.substr(0,cmd.find(' '))==string(cmd_names[i])) { cout << "|" << cmd.substr(cmd.find(' ')+1) << "|" << endl; - cmd_handlers[i](game, cmd.substr(cmd.find(' ')+1).c_str()); + cmd_handlers[i](cmd.substr(cmd.find(' ')+1).c_str()); break; } emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound); @@ -5544,7 +5545,7 @@ void Game::MenuTick(){ case 8: flash(); - SaveSettings(*this); + SaveSettings(); mainmenu=gameon?2:1; break; case 9: @@ -5753,7 +5754,7 @@ void Game::MenuTick(){ if(Input::isKeyDown(SDLK_q) && Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } @@ -5892,7 +5893,7 @@ void Game::Tick(){ } //finished with settings menu if(mainmenu==3){ - SaveSettings(*this); + SaveSettings(); } //effects if(mainmenu>=3&&mainmenu!=8){ @@ -5970,7 +5971,7 @@ void Game::Tick(){ archiveselected=0; if(consolechars[0]>0) { consoletext[0][consolechars[0]]='\0'; - cmd_dispatch(this, consoletext[0]); + cmd_dispatch(consoletext[0]); for(int k=14;k>=1;k--) { for(int j=0;j<255;j++) consoletext[k][j]=consoletext[k-1][j]; @@ -5995,7 +5996,7 @@ void Game::Tick(){ if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3) { - SaveSettings(*this); + SaveSettings(); } } diff --git a/Source/Input.h b/Source/Input.h index 17f11b0..0895cb4 100644 --- a/Source/Input.h +++ b/Source/Input.h @@ -38,7 +38,6 @@ class Input { static bool isKeyDown(int k); static bool isKeyPressed(int k); static const char* keyToChar(unsigned short which); - static void setKeyFor(Game* g); static unsigned short CharToKey(const char* which); static Boolean MouseClicked(); }; diff --git a/Source/Menu.cpp b/Source/Menu.cpp index affdf9a..a661b6d 100644 --- a/Source/Menu.cpp +++ b/Source/Menu.cpp @@ -47,9 +47,9 @@ vector items; -void Menu::GUITick(Game* game){ +void Menu::GUITick(){ for(vector::iterator it=items.begin();it!=items.end();it++){ - if(it->id==game->selected){ + if(it->id==Game::selected){ it->effectfade+=multiplier*5; if(it->effectfade>1) it->effectfade=1; @@ -137,7 +137,7 @@ int Menu::getSelected(int mousex, int mousey){ return -1; } -void Menu::drawItems(Game* game){ +void Menu::drawItems(){ glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); @@ -191,20 +191,20 @@ void Menu::drawItems(Game* game){ case MenuItem::BUTTON: glColor4f(it->r,it->g,it->b,1); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - game->text.glPrint(it->x,it->y,it->label.c_str(),0,1,640,480); + Game::text->glPrint(it->x,it->y,it->label.c_str(),0,1,640,480); if(it->type!=MenuItem::LABEL){ //mouseover highlight glBlendFunc(GL_SRC_ALPHA,GL_ONE); for(int i=0;i<15;i++){ if(1-((float)i)/15-(1-it->effectfade)>0){ glColor4f(it->r,it->g,it->b,(1-((float)i)/10-(1-it->effectfade))*.25); - game->text.glPrint(it->x-((float)i),it->y,it->label.c_str(),0,1+((float)i)/70,640,480); + Game::text->glPrint(it->x-((float)i),it->y,it->label.c_str(),0,1+((float)i)/70,640,480); } } } break; case MenuItem::MAPLABEL: - game->text.glPrintOutlined(0.9,0,0,it->x,it->y,it->label.c_str(),0,0.6,640,480); + Game::text->glPrintOutlined(0.9,0,0,it->x,it->y,it->label.c_str(),0,0.6,640,480); break; case MenuItem::MAPLINE: { XYZ linestart; diff --git a/Source/Menu.h b/Source/Menu.h index 6f5de85..49d009c 100644 --- a/Source/Menu.h +++ b/Source/Menu.h @@ -6,7 +6,7 @@ namespace Menu { typedef void(*MBCallback)(int id); - void GUITick(Game* game); + void GUITick(); void clearMenu(); void addLabel(int id,const string& label,int x,int y); void addButton(int id,const string& label,MBCallback cb,int x,int y,int w,int h,float r=1,float g=0,float b=0); @@ -18,7 +18,7 @@ namespace Menu { void setButtonText(int id,const string& label); void setButtonText(int id,const string& label,int x,int y,int w,int h); int getSelected(int mousex, int mousey); - void drawItems(Game* game); + void drawItems(); } #endif diff --git a/Source/Models.cpp b/Source/Models.cpp index 4db0b74..f49ddd0 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -29,7 +29,6 @@ extern float fadestart; extern float texdetail; extern bool decals; -extern Game * pgame; extern bool visibleloading; int Model::LineCheck(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate) @@ -481,7 +480,7 @@ bool Model::load(const char *filename,bool texture ) LOG(std::string("Loading model...") + filename); if(visibleloading) - pgame->LoadingScreen(); + Game::LoadingScreen(); int oldvertexNum,oldTriangleNum; oldvertexNum=vertexNum; @@ -844,7 +843,7 @@ void Model::Rotate(float xang,float yang,float zang) void Model::CalculateNormals(bool facenormalise) { if(visibleloading) - pgame->LoadingScreen(); + Game::LoadingScreen(); static int i; if(type!=normaltype&&type!=decalstype)return; diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index c2091fb..a9edfb5 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -45,6 +45,8 @@ extern "C" { #endif } +using namespace Game; + static bool load_image(const char * fname, TGAImageRec & tex); static bool load_png(const char * fname, TGAImageRec & tex); static bool load_jpg(const char * fname, TGAImageRec & tex); @@ -99,10 +101,8 @@ static SDL_Rect *hardcoded_resolutions[] = { NULL }; -void DrawGL(Game & game); - -Boolean SetUp (Game & game); -void DoUpdate (Game & game); +Boolean SetUp (); +void DoUpdate (); void CleanUp (void); @@ -163,8 +163,6 @@ int kContextHeight; Boolean gDone = false; -Game * pgame = 0; - #ifndef __MINGW32__ static int _argc = 0; static char **_argv = NULL; @@ -256,12 +254,12 @@ static void toggleFullscreen(){ //~ pgame->LoadScreenTexture(); } -static void sdlEventProc(const SDL_Event &e, Game &game) +static void sdlEventProc(const SDL_Event &e) { switch(e.type) { case SDL_MOUSEMOTION: - game.deltah += e.motion.xrel; - game.deltav += e.motion.yrel; + deltah += e.motion.xrel; + deltav += e.motion.yrel; break; case SDL_KEYDOWN: @@ -282,7 +280,7 @@ static void sdlEventProc(const SDL_Event &e, Game &game) static Point gMidPoint; -Boolean SetUp (Game & game) +Boolean SetUp () { char string[10]; @@ -295,7 +293,7 @@ Boolean SetUp (Game & game) slomofreq=8012; numplayers=1; - DefaultSettings(game); + DefaultSettings(); if (!SDL_WasInit(SDL_INIT_VIDEO)) if (SDL_Init(SDL_INIT_VIDEO) == -1) @@ -303,9 +301,9 @@ Boolean SetUp (Game & game) fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); return false; } - if(!LoadSettings(game)) { + if(!LoadSettings()) { fprintf(stderr, "Failed to load config, creating default\n"); - SaveSettings(game); + SaveSettings(); } if(kBitsPerPixel!=32&&kBitsPerPixel!=16){ kBitsPerPixel=16; @@ -415,33 +413,33 @@ Boolean SetUp (Game & game) screenwidth=width; screenheight=height; - game.newdetail=detail; - game.newscreenwidth=screenwidth; - game.newscreenheight=screenheight; + newdetail=detail; + newscreenwidth=screenwidth; + newscreenheight=screenheight; - game.InitGame(); + InitGame(); return true; } -static void DoMouse(Game & game) +static void DoMouse() { - if(mainmenu|| ( (abs(game.deltah)<10*realmultiplier*1000) && (abs(game.deltav)<10*realmultiplier*1000) )) + if(mainmenu|| ( (abs(deltah)<10*realmultiplier*1000) && (abs(deltav)<10*realmultiplier*1000) )) { - game.deltah *= usermousesensitivity; - game.deltav *= usermousesensitivity; - game.mousecoordh += game.deltah; - game.mousecoordv += game.deltav; - if (game.mousecoordh < 0) - game.mousecoordh = 0; - else if (game.mousecoordh >= kContextWidth) - game.mousecoordh = kContextWidth - 1; - if (game.mousecoordv < 0) - game.mousecoordv = 0; - else if (game.mousecoordv >= kContextHeight) - game.mousecoordv = kContextHeight - 1; + deltah *= usermousesensitivity; + deltav *= usermousesensitivity; + mousecoordh += deltah; + mousecoordv += deltav; + if (mousecoordh < 0) + mousecoordh = 0; + else if (mousecoordh >= kContextWidth) + mousecoordh = kContextWidth - 1; + if (mousecoordv < 0) + mousecoordv = 0; + else if (mousecoordv >= kContextHeight) + mousecoordv = kContextHeight - 1; } } @@ -482,7 +480,7 @@ void DoFrameRate (int update) } -void DoUpdate (Game & game) +void DoUpdate () { static float sps=200; static int count; @@ -491,7 +489,7 @@ void DoUpdate (Game & game) DoFrameRate(1); if(multiplier>.6)multiplier=.6; - game.fps=1/multiplier; + fps=1/multiplier; count = multiplier*sps; if(count<2)count=2; @@ -501,22 +499,22 @@ void DoUpdate (Game & game) if(difficulty==1)multiplier*=.9; if(difficulty==0)multiplier*=.8; - if(game.loading==4)multiplier*=.00001; + if(loading==4)multiplier*=.00001; if(slomo&&!mainmenu)multiplier*=slomospeed; oldmult=multiplier; multiplier/=(float)count; - DoMouse(game); + DoMouse(); - game.TickOnce(); + TickOnce(); for(int i=0;i2) game.newdetail=2; - if(game.newscreenwidth>3000) game.newscreenwidth=screenwidth; - if(game.newscreenwidth<0) game.newscreenwidth=screenwidth; - if(game.newscreenheight>3000) game.newscreenheight=screenheight; - if(game.newscreenheight<0) game.newscreenheight=screenheight; +void SaveSettings() { + if(newdetail<0) newdetail=0; + if(newdetail>2) newdetail=2; + if(newscreenwidth>3000) newscreenwidth=screenwidth; + if(newscreenwidth<0) newscreenwidth=screenwidth; + if(newscreenheight>3000) newscreenheight=screenheight; + if(newscreenheight<0) newscreenheight=screenheight; ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; - opstream << game.newscreenwidth; + opstream << newscreenwidth; opstream << "\nScreenheight:\n"; - opstream << game.newscreenheight; + opstream << newscreenheight; opstream << "\nMouse sensitivity:\n"; opstream << usermousesensitivity; opstream << "\nBlur(0,1):\n"; opstream << ismotionblur; opstream << "\nOverall Detail(0,1,2) higher=better:\n"; - opstream << game.newdetail; + opstream << newdetail; opstream << "\nFloating jump:\n"; opstream << floatjump; opstream << "\nMouse jump:\n"; @@ -106,27 +108,27 @@ void SaveSettings(Game &game) { opstream << "\nVolume:\n"; opstream << volume; opstream << "\nForward key:\n"; - opstream << Input::keyToChar(game.forwardkey); + opstream << Input::keyToChar(forwardkey); opstream << "\nBack key:\n"; - opstream << Input::keyToChar(game.backkey); + opstream << Input::keyToChar(backkey); opstream << "\nLeft key:\n"; - opstream << Input::keyToChar(game.leftkey); + opstream << Input::keyToChar(leftkey); opstream << "\nRight key:\n"; - opstream << Input::keyToChar(game.rightkey); + opstream << Input::keyToChar(rightkey); opstream << "\nJump key:\n"; - opstream << Input::keyToChar(game.jumpkey); + opstream << Input::keyToChar(jumpkey); opstream << "\nCrouch key:\n"; - opstream << Input::keyToChar(game.crouchkey); + opstream << Input::keyToChar(crouchkey); opstream << "\nDraw key:\n"; - opstream << Input::keyToChar(game.drawkey); + opstream << Input::keyToChar(drawkey); opstream << "\nThrow key:\n"; - opstream << Input::keyToChar(game.throwkey); + opstream << Input::keyToChar(throwkey); opstream << "\nAttack key:\n"; - opstream << Input::keyToChar(game.attackkey); + opstream << Input::keyToChar(attackkey); opstream << "\nConsole key:\n"; - opstream << Input::keyToChar(game.consolekey); + opstream << Input::keyToChar(consolekey); opstream << "\nChat key:\n"; - opstream << Input::keyToChar(game.chatkey); + opstream << Input::keyToChar(chatkey); opstream << "\nDamage bar:\n"; opstream << showdamagebar; opstream << "\nStereoMode:\n"; @@ -138,7 +140,7 @@ void SaveSettings(Game &game) { opstream.close(); } -bool LoadSettings(Game &game) { +bool LoadSettings() { ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in); if ( !ipstream || ipstream.fail() ) { printf("Config file not found\n"); @@ -224,37 +226,37 @@ bool LoadSettings(Game &game) { ipstream >> volume; } else if ( !strncmp(setting, "Forward key", 11) ) { ipstream.getline( string, sizeof(string) ); - game.forwardkey = Input::CharToKey(string); + forwardkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Back key", 8) ) { ipstream.getline( string, sizeof(string) ); - game.backkey = Input::CharToKey(string); + backkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Left key", 8) ) { ipstream.getline( string, sizeof(string) ); - game.leftkey = Input::CharToKey(string); + leftkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Right key", 9) ) { ipstream.getline( string, sizeof(string) ); - game.rightkey = Input::CharToKey(string); + rightkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Jump key", 8) ) { ipstream.getline( string, sizeof(string) ); - game.jumpkey = Input::CharToKey(string); + jumpkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Crouch key", 10) ) { ipstream.getline( string, sizeof(string) ); - game.crouchkey = Input::CharToKey(string); + crouchkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Draw key", 8) ) { ipstream.getline( string, sizeof(string) ); - game.drawkey = Input::CharToKey(string); + drawkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Throw key", 9) ) { ipstream.getline( string, sizeof(string) ); - game.throwkey = Input::CharToKey(string); + throwkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Attack key", 10) ) { ipstream.getline( string, sizeof(string) ); - game.attackkey = Input::CharToKey(string); + attackkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Console key", 11) ) { ipstream.getline( string, sizeof(string) ); - game.consolekey = Input::CharToKey(string); + consolekey = Input::CharToKey(string); } else if ( !strncmp(setting, "Chat key", 8) ) { ipstream.getline( string, sizeof(string) ); - game.chatkey = Input::CharToKey(string); + chatkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Damage bar", 10) ) { ipstream >> showdamagebar; } else if ( !strncmp(setting, "StereoMode", 10) ) { diff --git a/Source/Settings.h b/Source/Settings.h index bae9910..e7526a9 100644 --- a/Source/Settings.h +++ b/Source/Settings.h @@ -34,9 +34,9 @@ extern int kContextWidth; extern int kContextHeight; extern float screenwidth,screenheight; -void DefaultSettings(Game &game); -void SaveSettings(Game &game); -bool LoadSettings(Game &game); +void DefaultSettings(); +void SaveSettings(); +bool LoadSettings(); #endif diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 5b28f73..b338724 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -43,7 +43,6 @@ extern int tutoriallevel; extern int whichjointstartarray[26]; extern int whichjointendarray[26]; -extern Game * pgame; extern bool visibleloading; void dealloc2(void* param){ @@ -835,7 +834,7 @@ void Animation::Load(const char *filename, int aheight, int aattack) height=aheight; attack=aattack; - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); tfile=fopen( fixedFN, "rb" ); if(tfile){ diff --git a/Source/TGALoader.cpp b/Source/TGALoader.cpp index a5eae85..172ed5f 100644 --- a/Source/TGALoader.cpp +++ b/Source/TGALoader.cpp @@ -28,14 +28,13 @@ extern TGAImageRec texture; extern short vRefNum; extern long dirID; extern bool visibleloading; -extern Game * pgame; extern bool LoadImage(const char * fname, TGAImageRec & tex); /********************> LoadTGA() <*****/ bool upload_image(const unsigned char* filePath, bool hasalpha) { if(visibleloading) - pgame->LoadingScreen(); + Game::LoadingScreen(); #if !PLATFORM_MACOSX diff --git a/Source/Terrain.cpp b/Source/Terrain.cpp index d9c73b0..4c4ff74 100644 --- a/Source/Terrain.cpp +++ b/Source/Terrain.cpp @@ -38,7 +38,6 @@ extern float blurness; extern float targetblurness; extern Objects objects; extern TGAImageRec texture; -extern Game * pgame; extern bool visibleloading; extern bool skyboxtexture; extern int tutoriallevel; @@ -401,7 +400,7 @@ bool Terrain::load(const char *fileName) } } texture.bpp=24; - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); texdetail=temptexdetail; @@ -433,7 +432,7 @@ bool Terrain::load(const char *fileName) } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); float slopeness; @@ -442,7 +441,7 @@ bool Terrain::load(const char *fileName) textureness[i][j]=-1; } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); for(i=0;iLoadingScreen(); + if(visibleloading) Game::LoadingScreen(); /*float total; int todivide; @@ -598,7 +597,7 @@ bool Terrain::load(const char *fileName) } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); patch_size=size/subdivision; patch_elements=(patch_size)*(patch_size)*54; @@ -1465,7 +1464,7 @@ void Terrain::DoShadows() } } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); } brightness=dotproduct(&lightloc,&normals[i][j]); if(shadowed)brightness*=1-shadowed; @@ -1486,7 +1485,7 @@ void Terrain::DoShadows() } } - if(visibleloading)pgame->LoadingScreen(); + if(visibleloading) Game::LoadingScreen(); //Smooth shadows for(i=0;i