[Fftrader-cvs] fftrader/src engine.cpp,1.3,1.4 engine.h,1.3,1.4 fftfile.cpp,1.3,1.4 graphics.cpp,1.1
Status: Alpha
Brought to you by:
tomt64
|
From: TomT64 <to...@us...> - 2005-08-23 09:56:56
|
Update of /cvsroot/fftrader/fftrader/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15827/src Modified Files: engine.cpp engine.h fftfile.cpp graphics.cpp graphics.h guiapply.cpp guiapply.h log.cpp log.h main.cpp map.cpp map.h mapobject.cpp py_baselib.cpp py_baselib.h scenario.cpp shop.cpp units.cpp Log Message: More scripting code, and added verbose option to Log and commandline options Index: engine.h =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/engine.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** engine.h 23 Aug 2005 03:40:09 -0000 1.3 --- engine.h 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 26,29 **** --- 26,30 ---- StarField *stars; bool above; + int factor; }; struct FFTSound *************** *** 44,49 **** ~Engine(); void Quit(); ! void StartGame(); void CleanUpGame(); void SetMainModule(std::string modulename); Unit *GetMainShip(); --- 45,51 ---- ~Engine(); void Quit(); ! bool StartGame(); void CleanUpGame(); + void Render(); void SetMainModule(std::string modulename); Unit *GetMainShip(); *************** *** 63,67 **** SDL_Surface *GetSurface(std::string name); void AddSurface(std::string name, SDL_Surface *surface); ! void AddStarfield(StarField *stars, bool above); private: bool running; --- 65,69 ---- SDL_Surface *GetSurface(std::string name); void AddSurface(std::string name, SDL_Surface *surface); ! void AddStarfield(StarField *stars, bool above, int factor); private: bool running; Index: units.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/units.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** units.cpp 19 Aug 2005 08:22:34 -0000 1.2 --- units.cpp 23 Aug 2005 09:56:44 -0000 1.3 *************** *** 685,689 **** this->RemoveWeaponFromSlot(slotid); this->NextWeapon(); ! Log::Write("Removed and changed weapon"); } } --- 685,689 ---- this->RemoveWeaponFromSlot(slotid); this->NextWeapon(); ! Log::WriteVerbose("Removed and changed weapon"); } } *************** *** 1089,1096 **** void Unit::FPK_NewImages(std::string fpk, std::string imagename) { ! Log::Write("FPK_NewImages: Loading new image (%s) from fpk %s",imagename.c_str(),fpk.c_str()); usingfpk=fpk; imgload=imagename; ! Log::Write("FPK_NewImages: Freeing existing images"); FreeImages(); if(hasShield) --- 1089,1096 ---- void Unit::FPK_NewImages(std::string fpk, std::string imagename) { ! Log::WriteVerbose("FPK_NewImages: Loading new image (%s) from fpk %s",imagename.c_str(),fpk.c_str()); usingfpk=fpk; imgload=imagename; ! Log::WriteVerbose("FPK_NewImages: Freeing existing images"); FreeImages(); if(hasShield) *************** *** 1104,1111 **** hasShield=false; } ! Log::Write("FPK_NewImages: Loading new images"); LoadImages(0, 71); int i; ! Log::Write("FPK_NewImages: Making new bitmasks"); for (i=0; i<UNITS_NUM_FRAMES; i++) { --- 1104,1111 ---- hasShield=false; } ! Log::WriteVerbose("FPK_NewImages: Loading new images"); LoadImages(0, 71); int i; ! Log::WriteVerbose("FPK_NewImages: Making new bitmasks"); for (i=0; i<UNITS_NUM_FRAMES; i++) { *************** *** 1127,1131 **** if (end<0) { end=0; } if (start<0) { start=0; } ! Log::Write("Unit::LoadImages: Loading base image (%s) from fpk %s",imgload.c_str(),usingfpk.c_str()); temp=FPK_LoadIMG(usingfpk, imgload); if (dispimg) --- 1127,1131 ---- if (end<0) { end=0; } if (start<0) { start=0; } ! Log::WriteVerbose("Unit::LoadImages: Loading base image (%s) from fpk %s",imgload.c_str(),usingfpk.c_str()); temp=FPK_LoadIMG(usingfpk, imgload); if (dispimg) *************** *** 1134,1149 **** dispimg=0; } ! Log::Write("Unit::LoadImages: Setting display image"); dispimg=rotozoomSurface(temp, 0, 0.5, SMOOTH); if (cr>0 || cg>0 || cb>0) { ! Log::Write("Unit::LoadImages: Colorizing images"); ColorizeSurface(temp, cr, cg, cb); ColorizeSurface(dispimg, cr, cg, cb); } ! Log::Writen("Unit::LoadImages: Freeing images and reloading: "); for (i=start; i<=end; i++) { ! Log::Writen("%d, ",i); if (image[i]) { --- 1134,1149 ---- dispimg=0; } ! Log::WriteVerbose("Unit::LoadImages: Setting display image"); dispimg=rotozoomSurface(temp, 0, 0.5, SMOOTH); if (cr>0 || cg>0 || cb>0) { ! Log::WriteVerbose("Unit::LoadImages: Colorizing images"); ColorizeSurface(temp, cr, cg, cb); ColorizeSurface(dispimg, cr, cg, cb); } ! Log::WriteVerbosen("Unit::LoadImages: Freeing images and reloading: "); for (i=start; i<=end; i++) { ! Log::WriteVerbosen("%d, ",i); if (image[i]) { *************** *** 1153,1160 **** image[i]=rotozoomSurface(temp, 360-i*angleinc, zoom, SMOOTH); } ! Log::Writen("\n"); if (hasShield) { ! Log::Write("Loading shield"); SDL_FreeSurface(temp); temp=0; --- 1153,1160 ---- image[i]=rotozoomSurface(temp, 360-i*angleinc, zoom, SMOOTH); } ! Log::WriteVerbosen("\n"); if (hasShield) { ! Log::WriteVerbose("Loading shield"); SDL_FreeSurface(temp); temp=0; Index: main.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 23 Aug 2005 03:40:09 -0000 1.4 --- main.cpp 23 Aug 2005 09:56:44 -0000 1.5 *************** *** 103,106 **** --- 103,110 ---- Log::Init("fft.log"); } + if (!strcmp(argv[i],"-verbose")) + { + Log::EnableVerbose(); + } } } *************** *** 115,129 **** if (!init) { ! Log::Write("Failed to initialize PHYSFS. Reason: %s",PHYSFS_getLastError()); exit(1); } ! Log::Write("PHYSFS initialized successfully"); char **i; for (i = PHYSFS_getSearchPath(); *i != NULL; i++) ! Log::Write("[%s] is in the search path.at the beginning of execution", *i); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 0); //fpk dir PHYSFS_setWriteDir(PHYSFS_getBaseDir()); ! Log::Write("Loading Preferences"); prefs=new Preferences("prefs"); delete fftinput; --- 119,133 ---- if (!init) { ! Log::WriteVerbose("Failed to initialize PHYSFS. Reason: %s",PHYSFS_getLastError()); exit(1); } ! Log::WriteVerbose("PHYSFS initialized successfully"); char **i; for (i = PHYSFS_getSearchPath(); *i != NULL; i++) ! Log::WriteVerbose("[%s] is in the search path.at the beginning of execution", *i); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 0); //fpk dir PHYSFS_setWriteDir(PHYSFS_getBaseDir()); ! Log::WriteVerbose("Loading Preferences"); prefs=new Preferences("prefs"); delete fftinput; *************** *** 135,147 **** if(TTF_Init()==-1) { ! Log::Write("TTF_Init: %s", TTF_GetError()); exit(2); } ! Log::Write("SDL_ttf initialized successfully"); // load font font=LoadTTF("fonts/arial.ttf", 10); if(!font) { ! Log::Write("Unable to Open font 'fonts/arial.ttf' - TTF_OpenFont: %s", TTF_GetError()); // handle error } --- 139,151 ---- if(TTF_Init()==-1) { ! Log::WriteVerbose("TTF_Init: %s", TTF_GetError()); exit(2); } ! Log::WriteVerbose("SDL_ttf initialized successfully"); // load font font=LoadTTF("fonts/arial.ttf", 10); if(!font) { ! Log::WriteVerbose("Unable to Open font 'fonts/arial.ttf' - TTF_OpenFont: %s", TTF_GetError()); // handle error } *************** *** 149,172 **** font2=LoadTTF("fonts/arial.ttf", 14); if(!font2) { ! Log::Write("Unable to Open font 'fonts/arial.ttf' - TTF_OpenFont: %s", TTF_GetError()); // handle error } engine->AddFont("font14",font2); ! Log::Write("Main Fonts loaded"); /* initialize SDL */ #ifdef DEBUG if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE) < 0 ) { ! Log::Write("Could not initialize SDL: %s",SDL_GetError()); return -1; } #else if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0 ) { ! Log::Write("Could not initialize SDL: %s",SDL_GetError()); return -1; } #endif ! Log::Write("SDL initialized successfully"); //atexit(SDL_Quit); --- 153,176 ---- font2=LoadTTF("fonts/arial.ttf", 14); if(!font2) { ! Log::WriteVerbose("Unable to Open font 'fonts/arial.ttf' - TTF_OpenFont: %s", TTF_GetError()); // handle error } engine->AddFont("font14",font2); ! Log::WriteVerbose("Main Fonts loaded"); /* initialize SDL */ #ifdef DEBUG if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE) < 0 ) { ! Log::WriteVerbose("Could not initialize SDL: %s",SDL_GetError()); return -1; } #else if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0 ) { ! Log::WriteVerbose("Could not initialize SDL: %s",SDL_GetError()); return -1; } #endif ! Log::WriteVerbose("SDL initialized successfully"); //atexit(SDL_Quit); *************** *** 177,186 **** engine->AddSurface("main icon",icon); SDL_WM_SetIcon(icon, NULL); ! Log::Write("Icon and caption in place"); /* create window */ screen = SDL_SetVideoMode(400, 300, 0, SDL_HWSURFACE|SDL_DOUBLEBUF); //CenterWindow(); ! Log::Write("Video mode set and centered"); SDL_Surface *bg = LoadIMG("gfx/startupbg.png"); --- 181,190 ---- engine->AddSurface("main icon",icon); SDL_WM_SetIcon(icon, NULL); ! Log::WriteVerbose("Icon and caption in place"); /* create window */ screen = SDL_SetVideoMode(400, 300, 0, SDL_HWSURFACE|SDL_DOUBLEBUF); //CenterWindow(); ! Log::WriteVerbose("Video mode set and centered"); SDL_Surface *bg = LoadIMG("gfx/startupbg.png"); *************** *** 188,192 **** DrawIMG(bg,0,0); SDL_Flip(screen); ! Log::Write("Splash screen displayed"); stars = new StarField; --- 192,196 ---- DrawIMG(bg,0,0); SDL_Flip(screen); ! Log::WriteVerbose("Splash screen displayed"); stars = new StarField; *************** *** 194,200 **** stars->Init(SCREEN_WIDTH, SCREEN_HEIGHT); stars2->Init(SCREEN_WIDTH, SCREEN_HEIGHT); ! engine->AddStarfield(stars, false); ! engine->AddStarfield(stars2, true); ! Log::Write("Beginning warp stars initialized"); char **k; --- 198,204 ---- stars->Init(SCREEN_WIDTH, SCREEN_HEIGHT); stars2->Init(SCREEN_WIDTH, SCREEN_HEIGHT); ! engine->AddStarfield(stars, false, 10); ! engine->AddStarfield(stars2, true, 20); ! Log::WriteVerbose("Beginning warp stars initialized"); char **k; *************** *** 211,229 **** } PHYSFS_freeList(fpklist); ! Log::Write("All FPKs placed in search path"); ship = new Unit; ! ship->Init(0, 0, "gfx/ship/ship.png","base.fpk",(float)0.1); engine->SetMainShip(ship); ! Log::Write("Main ship initialized"); map = new Map; map->Init(1); engine->SetMap(map); ! Log::Write("Map initialized"); if(Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 2048) < 0) { ! Log::Write("Warning: Couldn't set 22050 Hz 16-bit audio\n- Reason: %s", SDL_GetError()); } shot = LoadSound("sound/shoot.wav"); --- 215,233 ---- } PHYSFS_freeList(fpklist); ! Log::WriteVerbose("All FPKs placed in search path"); ship = new Unit; ! ship->Init(0, 0, "gfx/ship/ship.png","base.fpk",(float)0.01); engine->SetMainShip(ship); ! Log::WriteVerbose("Main ship initialized"); map = new Map; map->Init(1); engine->SetMap(map); ! Log::WriteVerbose("Map initialized"); if(Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 2048) < 0) { ! Log::WriteVerbose("Warning: Couldn't set 22050 Hz 16-bit audio\n- Reason: %s", SDL_GetError()); } shot = LoadSound("sound/shoot.wav"); *************** *** 231,235 **** engine->AddSound("shot", shot); engine->AddSound("explode", explode); ! Log::Write("Audio initialized and sounds loaded"); gui2=new GUI; --- 235,239 ---- engine->AddSound("shot", shot); engine->AddSound("explode", explode); ! Log::WriteVerbose("Audio initialized and sounds loaded"); gui2=new GUI; *************** *** 259,294 **** else screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWSURFACE|SDL_DOUBLEBUF); CenterWindow(); ! Log::Writen("Main window set to 640x480 "); ! if (fullscreen) Log::Writen("at fullscreen "); ! else Log::Writen("at windowed "); ! if (software) Log::Writen("software mode"); ! else Log::Writen("hardware mode"); ! Log::Write(" and centered"); int done=0; int maintemp=0; int GUIresult; ! Log::Write("Proceeding to main loop"); while(!done) { GUIresult=RunStartingGUI(SCREEN_WIDTH, SCREEN_HEIGHT); ! Log::Write("Option from Starting GUI selected"); if (GUIresult==-1) { done=1; ! Log::Write("Exiting game"); } if (GUIresult==2) { bool goahead=false; ! Log::Write("Entering New Game"); goahead=LoadScenario(); if (goahead) { ! Log::Write("Proceeding to main game play"); ! engine->StartGame(); engine->CleanUpGame(); ! //maintemp=mainLoop(); ! Log::Write("Main gameplay exited"); if (maintemp==-1) done=1; } --- 263,298 ---- else screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWSURFACE|SDL_DOUBLEBUF); CenterWindow(); ! Log::WriteVerbosen("Main window set to 640x480 "); ! if (fullscreen) Log::WriteVerbosen("at fullscreen "); ! else Log::WriteVerbosen("at windowed "); ! if (software) Log::WriteVerbosen("software mode"); ! else Log::WriteVerbosen("hardware mode"); ! Log::WriteVerbose(" and centered"); int done=0; int maintemp=0; int GUIresult; ! Log::WriteVerbose("Proceeding to main loop"); while(!done) { GUIresult=RunStartingGUI(SCREEN_WIDTH, SCREEN_HEIGHT); ! Log::WriteVerbose("Option from Starting GUI selected"); if (GUIresult==-1) { done=1; ! Log::WriteVerbose("Exiting game"); } if (GUIresult==2) { bool goahead=false; ! Log::WriteVerbose("Entering New Game"); goahead=LoadScenario(); if (goahead) { ! Log::WriteVerbose("Proceeding to main game play"); ! bool init=engine->StartGame(); ! if (init) maintemp=mainLoop(); engine->CleanUpGame(); ! Log::WriteVerbose("Main gameplay exited"); if (maintemp==-1) done=1; } *************** *** 304,308 **** static int AskToQuitGame() { ! Log::Write("AskToQuitGame()"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); --- 308,312 ---- static int AskToQuitGame() { ! Log::WriteVerbose("AskToQuitGame()"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); *************** *** 399,403 **** static int InGameMenu() { ! Log::Write("InGameMenu()"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); --- 403,407 ---- static int InGameMenu() { ! Log::WriteVerbose("InGameMenu()"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); *************** *** 499,510 **** { //bool goahead=false; ! Log::Write("LoadScenario()"); ! Log::Write("Entering Scenario selection"); std::string scenselect=ChooseScenario(); if (!strcmp(scenselect.c_str(),"")) return false; ! Log::Write("Scenario Selection is %s",scenselect.c_str()); delete mainScen; mainScen = new Scenario(); ! Log::Write("Reading Scenario information"); engine->SetMainModule(scenselect); done=1; --- 503,514 ---- { //bool goahead=false; ! Log::WriteVerbose("LoadScenario()"); ! Log::WriteVerbose("Entering Scenario selection"); std::string scenselect=ChooseScenario(); if (!strcmp(scenselect.c_str(),"")) return false; ! Log::WriteVerbose("Scenario Selection is %s",scenselect.c_str()); delete mainScen; mainScen = new Scenario(); ! Log::WriteVerbose("Reading Scenario information"); engine->SetMainModule(scenselect); done=1; *************** *** 518,522 **** static bool ShipSelect(float zoom, std::string scenselect) { ! Log::Write("Entering ship selection"); SDL_Surface *screen=SDL_GetVideoSurface(); ship->SetZoom(zoom); --- 522,526 ---- static bool ShipSelect(float zoom, std::string scenselect) { ! Log::WriteVerbose("Entering ship selection"); SDL_Surface *screen=SDL_GetVideoSurface(); ship->SetZoom(zoom); *************** *** 529,533 **** if (quit==1) return false; Uint32 ticks=SDL_GetTicks(); ! Log::Write("Loading Game..."); SDL_FillRect(screen,0,0); centerString(font2, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, "Loading Game....", white); --- 533,537 ---- if (quit==1) return false; Uint32 ticks=SDL_GetTicks(); ! Log::WriteVerbose("Loading Game..."); SDL_FillRect(screen,0,0); centerString(font2, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, "Loading Game....", white); *************** *** 537,567 **** map->Init(zoom); engine->SetMap(map); ! Log::Write("Setting map to scenario"); mainScen->SetMap(map); ! Log::Write("Loading map file"); LoadMap(map, mainScen->GetMapFn(), zoom); delete gui2; ! Log::Write("Creating opening message"); std::string message=mainScen->GetOpenMessage(); gui2=MakeCenterOKWindow(message); ! Log::Write("Placing ship"); ship->SetAngle(mainScen->GetStartAngle()); ! Log::Writen("Ship: Angle: %d",mainScen->GetStartAngle()); ship->SetSpeed(mainScen->GetStartSpeed()); ! Log::Writen(" Speed: %d",mainScen->GetStartSpeed()); ship->SetWarp(false); ship->SetX(mainScen->GetStartX()); ! Log::Writen(" X: %d",mainScen->GetStartX()); ship->SetY(mainScen->GetStartY()); ! Log::Writen(" Y: %d",mainScen->GetStartY()); ! Log::Write(" Remaining credits: %d",ship->GetCredits()); //ship->SetZoom(zoom); ! //Log::Write("Loading images"); //ship->ReloadImages(); ! Log::Write("Adjusting shoot point"); ship->AdjustShootPoint(); ! Log::Write("Adding main ship to map"); map->AddMainShip(ship); ! Log::Write("Starting up Scenario"); mainScen->Startup(); Uint32 timepassed=SDL_GetTicks()-ticks; --- 541,571 ---- map->Init(zoom); engine->SetMap(map); ! Log::WriteVerbose("Setting map to scenario"); mainScen->SetMap(map); ! Log::WriteVerbose("Loading map file"); LoadMap(map, mainScen->GetMapFn(), zoom); delete gui2; ! Log::WriteVerbose("Creating opening message"); std::string message=mainScen->GetOpenMessage(); gui2=MakeCenterOKWindow(message); ! Log::WriteVerbose("Placing ship"); ship->SetAngle(mainScen->GetStartAngle()); ! Log::WriteVerbosen("Ship: Angle: %d",mainScen->GetStartAngle()); ship->SetSpeed(mainScen->GetStartSpeed()); ! Log::WriteVerbosen(" Speed: %d",mainScen->GetStartSpeed()); ship->SetWarp(false); ship->SetX(mainScen->GetStartX()); ! Log::WriteVerbosen(" X: %d",mainScen->GetStartX()); ship->SetY(mainScen->GetStartY()); ! Log::WriteVerbosen(" Y: %d",mainScen->GetStartY()); ! Log::WriteVerbose(" Remaining credits: %d",ship->GetCredits()); //ship->SetZoom(zoom); ! //Log::WriteVerbose("Loading images"); //ship->ReloadImages(); ! Log::WriteVerbose("Adjusting shoot point"); ship->AdjustShootPoint(); ! Log::WriteVerbose("Adding main ship to map"); map->AddMainShip(ship); ! Log::WriteVerbose("Starting up Scenario"); mainScen->Startup(); Uint32 timepassed=SDL_GetTicks()-ticks; *************** *** 569,573 **** Uint32 secs=(unsigned int)((double)timepassed/1000.0); Uint32 mins=(unsigned int)((double)secs/60.0); ! Log::Write("Scenario loaded in %d minutes, %d seconds, and %d milliseconds",mins,secs,ms); return true; } --- 573,577 ---- Uint32 secs=(unsigned int)((double)timepassed/1000.0); Uint32 mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Scenario loaded in %d minutes, %d seconds, and %d milliseconds",mins,secs,ms); return true; } *************** *** 575,579 **** static int mainLoop() { ! Log::Write("Main Loop begin"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); --- 579,583 ---- static int mainLoop() { ! Log::WriteVerbose("Main Loop begin"); SDL_Event event; SDL_Surface *screen=SDL_GetVideoSurface(); *************** *** 602,606 **** fpscount=0; int aiunit=-1; ! int aiunits=map->GetAICount(); fps=0; range=3; --- 606,610 ---- fpscount=0; int aiunit=-1; ! int aiunits=map->GetUnitCount(); fps=0; range=3; *************** *** 622,626 **** map->CheckSectors(sx, sy); float zoom=0.5; ! Log::Write("Variables set, displaying opening message"); TTF_Font *font9=TTF_OpenFont("fonts/arial.ttf", 9); engine->AddFont("font9",font9); --- 626,630 ---- map->CheckSectors(sx, sy); float zoom=0.5; ! Log::WriteVerbose("Variables set, displaying opening message"); TTF_Font *font9=TTF_OpenFont("fonts/arial.ttf", 9); engine->AddFont("font9",font9); *************** *** 702,706 **** char disppause[100]; sprintf(disppause, "Press '%s' to unpause", fftinput->GetPauseStr().c_str()); ! Log::Write("Entering gameplay loop"); while(!done) { --- 706,710 ---- char disppause[100]; sprintf(disppause, "Press '%s' to unpause", fftinput->GetPauseStr().c_str()); ! Log::WriteVerbose("Entering gameplay loop"); while(!done) { *************** *** 715,719 **** { paused=true; ! Log::Write("Game was paused because the window lost focus"); if (paused) { --- 719,723 ---- { paused=true; ! Log::WriteVerbose("Game was paused because the window lost focus"); if (paused) { *************** *** 765,773 **** { zoom+=0.25; ! Log::Write("Zooming ship"); ship->SetZoom(zoom); ! Log::Write("Loading Ship images"); ship->ReloadImages(); ! Log::Write("Zooming map"); map->SetZoom(zoom); } --- 769,777 ---- { zoom+=0.25; ! Log::WriteVerbose("Zooming ship"); ship->SetZoom(zoom); ! Log::WriteVerbose("Loading Ship images"); ship->ReloadImages(); ! Log::WriteVerbose("Zooming map"); map->SetZoom(zoom); } *************** *** 778,786 **** { zoom-=0.25; ! Log::Write("Zooming ship"); ship->SetZoom(zoom); ! Log::Write("Loading Ship images"); ship->ReloadImages(); ! Log::Write("Zooming map"); map->SetZoom(zoom); } --- 782,790 ---- { zoom-=0.25; ! Log::WriteVerbose("Zooming ship"); ship->SetZoom(zoom); ! Log::WriteVerbose("Loading Ship images"); ship->ReloadImages(); ! Log::WriteVerbose("Zooming map"); map->SetZoom(zoom); } *************** *** 858,862 **** sy=ship->GetSectorY(); curslot=ship->GetCurWeaponSlot(); ! aiunits=map->GetAICount(); if (curslot.image) { --- 862,866 ---- sy=ship->GetSectorY(); curslot=ship->GetCurWeaponSlot(); ! aiunits=map->GetUnitCount(); if (curslot.image) { *************** *** 865,870 **** if (aiunit<aiunits && aiunit!=-1) { ! targetx=map->GetAIUnitX(aiunit); ! targety=map->GetAIUnitY(aiunit); } else --- 869,874 ---- if (aiunit<aiunits && aiunit!=-1) { ! targetx=map->GetUnitX(aiunit); ! targety=map->GetUnitY(aiunit); } else Index: guiapply.h =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/guiapply.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** guiapply.h 19 Aug 2005 22:39:52 -0000 1.2 --- guiapply.h 23 Aug 2005 09:56:44 -0000 1.3 *************** *** 17,20 **** --- 17,21 ---- int ChangeControl(int w, int h, SDL_Surface *bg=0, bool fill=true); int AskToQuit(int SCREEN_WIDTH, int SCREEN_HEIGHT); + int MsgBox(int SCREEN_WIDTH, int SCREEN_HEIGHT, std::string message); int YesNoBox(int SCREEN_WIDTH, int SCREEN_HEIGHT, std::string message); int ExitToMenuBox(int SCREEN_WIDTH, int SCREEN_HEIGHT, std::string message); Index: shop.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/shop.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** shop.cpp 23 Aug 2005 03:40:09 -0000 1.3 --- shop.cpp 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 20,24 **** ShipyardShop::ShipyardShop(int sx, int sy, int sw, int sh, FPKShip **fpkships, bool sstarting) { ! Log::Write("New ShipyardShop"); int i; x=sx; --- 20,24 ---- ShipyardShop::ShipyardShop(int sx, int sy, int sw, int sh, FPKShip **fpkships, bool sstarting) { ! Log::WriteVerbose("New ShipyardShop"); int i; x=sx; *************** *** 66,70 **** } } ! Log::Write("Max FPKShips=%d",shipmax); cur=0; curcolor=0; --- 66,70 ---- } } ! Log::WriteVerbose("Max FPKShips=%d",shipmax); cur=0; curcolor=0; *************** *** 154,188 **** if ((int)ship->GetCredits()>=(ships[cur]->GetPrice()-(ship->GetPriceBought()*0.75))) { ! Log::Write("Giving New Ship"); ! Log::Write("Colorizing ship"); ship->Colorize(cr[curcolor], cg[curcolor], cb[curcolor]); ! Log::Write("Getting New ship images"); ship->FPK_NewImages(ships[cur]->GetFPK(), ships[cur]->GetImageFN()); ! Log::Write("Setting max speed"); ship->SetMaxSpeed(engine->GetMaxSpeed()); ! Log::Write("Setting max warp speed"); ship->SetMaxWarp(engine->GetMaxWarpSpeed()); ! Log::Write("Setting max safe warp speed"); ship->SetMaxSafeWarp(engine->GetMaxSafeWarpSpeed()); ! Log::Write("Setting turn delay"); ship->SetTurnDelay(engine->GetTurnDelay()); ! Log::Write("Setting warp turn delay"); ship->SetWarpTurnDelay(engine->GetWarpTurnDelay()); ! Log::Write("Filling slots"); ship->FillSlots(ships[cur]->GetSlots(),ships[cur]->GetSlotCount()); ! Log::Write("Setting shoot point"); ship->SetShootPoint(ships[cur]->GetShootX(),ships[cur]->GetShootY()); ! Log::Write("Setting overheat"); ship->SetOverHeatMax(engine->GetOverHeatMax()); ! Log::Write("Adding weapons"); ship->AddWeaponToSlot(101,"base.fpk","gfx/object/bullet.png"); //ship->AddWeaponToSlot(102,"base.fpk","gfx/object/bullet2.png"); ! if (ships[cur]->HasShield()) Log::Write("Adding shield"); if (ships[cur]->HasShield()) ship->AddShield(ships[cur]->GetShieldFN()); ! Log::Write("Setting battle hits"); ship->SetHullHitMax(ships[cur]->GetHullHitMax()); ship->SetShieldHitMax(10); ship->ResetHits(); ! Log::Write("Ship loaded"); ship->SetCredits((int)(ship->GetCredits()-(ships[cur]->GetPrice()-(ship->GetPriceBought()*0.75)))); ship->SetPriceBought(ships[cur]->GetPrice()); --- 154,188 ---- if ((int)ship->GetCredits()>=(ships[cur]->GetPrice()-(ship->GetPriceBought()*0.75))) { ! Log::WriteVerbose("Giving New Ship"); ! Log::WriteVerbose("Colorizing ship"); ship->Colorize(cr[curcolor], cg[curcolor], cb[curcolor]); ! Log::WriteVerbose("Getting New ship images"); ship->FPK_NewImages(ships[cur]->GetFPK(), ships[cur]->GetImageFN()); ! Log::WriteVerbose("Setting max speed"); ship->SetMaxSpeed(engine->GetMaxSpeed()); ! Log::WriteVerbose("Setting max warp speed"); ship->SetMaxWarp(engine->GetMaxWarpSpeed()); ! Log::WriteVerbose("Setting max safe warp speed"); ship->SetMaxSafeWarp(engine->GetMaxSafeWarpSpeed()); ! Log::WriteVerbose("Setting turn delay"); ship->SetTurnDelay(engine->GetTurnDelay()); ! Log::WriteVerbose("Setting warp turn delay"); ship->SetWarpTurnDelay(engine->GetWarpTurnDelay()); ! Log::WriteVerbose("Filling slots"); ship->FillSlots(ships[cur]->GetSlots(),ships[cur]->GetSlotCount()); ! Log::WriteVerbose("Setting shoot point"); ship->SetShootPoint(ships[cur]->GetShootX(),ships[cur]->GetShootY()); ! Log::WriteVerbose("Setting overheat"); ship->SetOverHeatMax(engine->GetOverHeatMax()); ! Log::WriteVerbose("Adding weapons"); ship->AddWeaponToSlot(101,"base.fpk","gfx/object/bullet.png"); //ship->AddWeaponToSlot(102,"base.fpk","gfx/object/bullet2.png"); ! if (ships[cur]->HasShield()) Log::WriteVerbose("Adding shield"); if (ships[cur]->HasShield()) ship->AddShield(ships[cur]->GetShieldFN()); ! Log::WriteVerbose("Setting battle hits"); ship->SetHullHitMax(ships[cur]->GetHullHitMax()); ship->SetShieldHitMax(10); ship->ResetHits(); ! Log::WriteVerbose("Ship loaded"); ship->SetCredits((int)(ship->GetCredits()-(ships[cur]->GetPrice()-(ship->GetPriceBought()*0.75)))); ship->SetPriceBought(ships[cur]->GetPrice()); *************** *** 325,332 **** cury+=80; } ! Log::Write("column=%d, cury=%d",column,cury); curx=x+(column*100)+80; slotshow->MakeWindow(curx, cury, 80, 66); ! Log::Write("Window %d, %d, %d, %d",curx, cury, 80, 66); sprintf(c, "ID: %d", slots[i].id); std::string slotid=c; --- 325,332 ---- cury+=80; } ! Log::WriteVerbose("column=%d, cury=%d",column,cury); curx=x+(column*100)+80; slotshow->MakeWindow(curx, cury, 80, 66); ! Log::WriteVerbose("Window %d, %d, %d, %d",curx, cury, 80, 66); sprintf(c, "ID: %d", slots[i].id); std::string slotid=c; *************** *** 354,358 **** int NewShipOptions(int w, int h, FPKShip **fpkships) { ! Log::Write("Inside Ship options"); SDL_Event event; ShipyardShop *shipyard=new ShipyardShop(0,0,w,h,fpkships,true); --- 354,358 ---- int NewShipOptions(int w, int h, FPKShip **fpkships) { ! Log::WriteVerbose("Inside Ship options"); SDL_Event event; ShipyardShop *shipyard=new ShipyardShop(0,0,w,h,fpkships,true); *************** *** 373,377 **** } delete shipyard; ! Log::Write("End Ship options"); return done; } --- 373,377 ---- } delete shipyard; ! Log::WriteVerbose("End Ship options"); return done; } Index: graphics.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/graphics.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** graphics.cpp 19 Aug 2005 07:32:29 -0000 1.1 --- graphics.cpp 23 Aug 2005 09:56:44 -0000 1.2 *************** *** 383,386 **** --- 383,401 ---- } } + StaticAnim::StaticAnim(const StaticAnim &oldanim) + { + animbase=oldanim.animbase; + int i; + for (i=0; i<12; i++) + { + anim[i]=rotozoomSurface(oldanim.anim[i], 0, 1, 0); + } + nextframe=oldanim.nextframe; + x=oldanim.x; + y=oldanim.y; + w=oldanim.w; + h=oldanim.h; + zoom=oldanim.zoom; + } void StaticAnim::SetX(int sx) { Index: log.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/log.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** log.cpp 19 Aug 2005 08:22:34 -0000 1.2 --- log.cpp 23 Aug 2005 09:56:44 -0000 1.3 *************** *** 4,7 **** --- 4,8 ---- { bool isLogging = false; + bool verbose = false; std::string logName; std::ofstream logFile; *************** *** 16,19 **** --- 17,24 ---- logFile.open(fname); }; + void Log::EnableVerbose() + { + verbose = true; + } void Log::Write(const std::string& s) { *************** *** 45,47 **** --- 50,81 ---- logFile << buffer; }; + void Log::WriteVerbose(const std::string& s) + { + if (!isLogging || !verbose) return; + logFile << s << std::endl; + }; + void Log::WriteVerbose(const char* s, ...) + { + if (!isLogging || !verbose) return; + va_list lst; + va_start(lst, s); + char buffer[2048]; + vsprintf(buffer, s, lst); + logFile << buffer; + logFile << std::endl; + }; + void Log::WriteVerbosen(const std::string& s) + { + if (!isLogging || !verbose) return; + logFile << s; + }; + void Log::WriteVerbosen(const char* s, ...) + { + if (!isLogging || !verbose) return; + va_list lst; + va_start(lst, s); + char buffer[2048]; + vsprintf(buffer, s, lst); + logFile << buffer; + }; Index: scenario.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/scenario.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** scenario.cpp 23 Aug 2005 03:40:09 -0000 1.3 --- scenario.cpp 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 12,16 **** Uint32 secs=0; Uint32 mins=0; ! Log::Write("LoadMap() at ticks=%d",ticks); struct Local { --- 12,16 ---- Uint32 secs=0; Uint32 mins=0; ! Log::WriteVerbose("LoadMap() at ticks=%d",ticks); struct Local { *************** *** 43,47 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Loading Map Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = mapobjects.begin(); iter != mapobjects.end(); iter++) { --- 43,47 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Loading Map Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = mapobjects.begin(); iter != mapobjects.end(); iter++) { *************** *** 79,83 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading Map Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList bullets = objectsNode->getChildren("bullet"); --- 79,83 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading Map Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList bullets = objectsNode->getChildren("bullet"); *************** *** 88,92 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Loading Bullets, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = bullets.begin(); iter != bullets.end(); iter++) { --- 88,92 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Loading Bullets, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = bullets.begin(); iter != bullets.end(); iter++) { *************** *** 115,119 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading Bullets, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList actobjects = objectsNode->getChildren("actobject"); --- 115,119 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading Bullets, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList actobjects = objectsNode->getChildren("actobject"); *************** *** 124,128 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Loading Active Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); std::string imagefn; SDL_Surface *image=0; --- 124,128 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Loading Active Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); std::string imagefn; SDL_Surface *image=0; *************** *** 219,223 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading Active Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList aiships = objectsNode->getChildren("aiship"); --- 219,223 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading Active Objects, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList aiships = objectsNode->getChildren("aiship"); *************** *** 228,232 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Loading AI Ships, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = aiships.begin(); iter != aiships.end(); iter++) { --- 228,232 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Loading AI Ships, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = aiships.begin(); iter != aiships.end(); iter++) { *************** *** 341,345 **** if (cr||cg||cb) object->Colorize(cr,cg,cb); object->FreeImages(); ! map->AddToAIUnits(object); } timepassed=SDL_GetTicks()-ticks; --- 341,345 ---- if (cr||cg||cb) object->Colorize(cr,cg,cb); object->FreeImages(); ! map->AddToUnits(object); } timepassed=SDL_GetTicks()-ticks; *************** *** 347,351 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading AI Ships, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList stations = objectsNode->getChildren("station"); --- 347,351 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading AI Ships, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } DataNodeList stations = objectsNode->getChildren("station"); *************** *** 356,360 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Loading Stations, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = stations.begin(); iter != stations.end(); iter++) { --- 356,360 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Loading Stations, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); for (iter = stations.begin(); iter != stations.end(); iter++) { *************** *** 522,528 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading Stations, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } ! Log::Write("Loading Animations"); StaticAnim *anim=new StaticAnim; anim->LoadFrames("gfx/anim/explosion"); --- 522,528 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading Stations, %d minutes, %d seconds, %d ms after LoadMap() begin", mins, secs, ms); } ! Log::WriteVerbose("Loading Animations"); StaticAnim *anim=new StaticAnim; anim->LoadFrames("gfx/anim/explosion"); *************** *** 532,536 **** secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::Write("Done Loading Map, %d minutes, %d seconds, %d ms total", mins, secs, ms); delete rootNode; } --- 532,536 ---- secs=(unsigned int)((double)timepassed/1000.0); mins=(unsigned int)((double)secs/60.0); ! Log::WriteVerbose("Done Loading Map, %d minutes, %d seconds, %d ms total", mins, secs, ms); delete rootNode; } *************** *** 1155,1163 **** SDL_FillRect(screen,0,0); drawString(font, screen->w/2-200, 20, msghead, white); ! if (!logged) Log::Write(msghead); for (i=0; i<=end; i++) { drawString(font, screen->w/2-200, 40+(i*20), msg[i], white); ! if (!logged) Log::Write(msg[i]); } drawString(font, screen->w/2-200, 40+((i+1)*20), "This game will autoclose in 30 seconds", white); --- 1155,1163 ---- SDL_FillRect(screen,0,0); drawString(font, screen->w/2-200, 20, msghead, white); ! if (!logged) Log::WriteVerbose(msghead); for (i=0; i<=end; i++) { drawString(font, screen->w/2-200, 40+(i*20), msg[i], white); ! if (!logged) Log::WriteVerbose(msg[i]); } drawString(font, screen->w/2-200, 40+((i+1)*20), "This game will autoclose in 30 seconds", white); *************** *** 1169,1173 **** FPKShip **LoadShipsFromScen(Scenario *Scen) { ! Log::Write("Inside LoadShipsFromScen"); char **fpklist; char **k; --- 1169,1173 ---- FPKShip **LoadShipsFromScen(Scenario *Scen) { ! Log::WriteVerbose("Inside LoadShipsFromScen"); char **fpklist; char **k; Index: py_baselib.h =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/py_baselib.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** py_baselib.h 23 Aug 2005 03:40:09 -0000 1.3 --- py_baselib.h 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- PyObject* fft_loss(PyObject* self); PyObject* fft_exit(PyObject* self, PyObject* args); + PyObject* fft_messagebox(PyObject* self, PyObject* args); + PyObject* fft_yesnobox(PyObject* self, PyObject* args); + PyObject* fft_render(PyObject* self); #endif /* __PY_BASELIB_H__ */ Index: mapobject.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/mapobject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mapobject.cpp 19 Aug 2005 08:22:34 -0000 1.2 --- mapobject.cpp 23 Aug 2005 09:56:44 -0000 1.3 *************** *** 501,505 **** ship->SetCredits(ship->GetCredits()-shop.buyitems[buycur].price); ship->AddWeaponToSlot(bayid,shop.buyitems[buycur].fpk,shop.buyitems[buycur].imagefn,shop.buyitems[buycur].amount); ! Log::Write("Inserted %d of ammo into bay id %d\n",shop.buyitems[buycur].amount,bayid); } } --- 501,505 ---- ship->SetCredits(ship->GetCredits()-shop.buyitems[buycur].price); ship->AddWeaponToSlot(bayid,shop.buyitems[buycur].fpk,shop.buyitems[buycur].imagefn,shop.buyitems[buycur].amount); ! Log::WriteVerbose("Inserted %d of ammo into bay id %d\n",shop.buyitems[buycur].amount,bayid); } } Index: fftfile.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/fftfile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fftfile.cpp 23 Aug 2005 03:40:09 -0000 1.3 --- fftfile.cpp 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 8,12 **** return buffer; } ! else Log::Write(PHYSFS_getLastError()); return 0; } --- 8,12 ---- return buffer; } ! else Log::WriteVerbose(PHYSFS_getLastError()); return 0; } *************** *** 558,566 **** SDL_FillRect(screen,0,0); drawString(font, screen->w/2-200, 20, msghead, white); ! if (!logged) Log::Write(msghead); for (i=0; i<=end; i++) { drawString(font, screen->w/2-200, 40+(i*20), msg[i], white); ! if (!logged) Log::Write(msg[i]); } drawString(font, screen->w/2-200, 40+((i+1)*20), "This game will autoclose in 30 seconds", white); --- 558,566 ---- SDL_FillRect(screen,0,0); drawString(font, screen->w/2-200, 20, msghead, white); ! if (!logged) Log::WriteVerbose(msghead); for (i=0; i<=end; i++) { drawString(font, screen->w/2-200, 40+(i*20), msg[i], white); ! if (!logged) Log::WriteVerbose(msg[i]); } drawString(font, screen->w/2-200, 40+((i+1)*20), "This game will autoclose in 30 seconds", white); *************** *** 643,647 **** FPKShip::FPKShip(int listindex, int num) { ! Log::Write("New FPKShip"); int i; for(i=0; i<__MAXSHIPSLOTS; i++) --- 643,647 ---- FPKShip::FPKShip(int listindex, int num) { ! Log::WriteVerbose("New FPKShip"); int i; for(i=0; i<__MAXSHIPSLOTS; i++) *************** *** 653,669 **** shootx=0; shooty=0; ! //Log::Write("FPKShip CP"); this->ZeroSlots(); ! //Log::Write("FPKShip CP"); this->GetFileInfo(listindex, num); ! //Log::Write("FPKShip CP"); image=LoadIMG(imagefn); ! //Log::Write("FPKShip CP"); if (hasShield) shield=LoadIMG(shieldfn); ! //Log::Write("FPKShip CP"); } FPKShip::FPKShip(std::string sfpk, std::string shipname) { ! Log::Write("New FPKShip"); int i; for(i=0; i<__MAXSHIPSLOTS; i++) --- 653,669 ---- shootx=0; shooty=0; ! //Log::WriteVerbose("FPKShip CP"); this->ZeroSlots(); ! //Log::WriteVerbose("FPKShip CP"); this->GetFileInfo(listindex, num); ! //Log::WriteVerbose("FPKShip CP"); image=LoadIMG(imagefn); ! //Log::WriteVerbose("FPKShip CP"); if (hasShield) shield=LoadIMG(shieldfn); ! //Log::WriteVerbose("FPKShip CP"); } FPKShip::FPKShip(std::string sfpk, std::string shipname) { ! Log::WriteVerbose("New FPKShip"); int i; for(i=0; i<__MAXSHIPSLOTS; i++) *************** *** 689,693 **** void FPKShip::GetFileInfo(int listindex, int num) { ! Log::Write("FPKShip::GetFileInfo Begin"); char **spath = PHYSFS_getSearchPath(); --- 689,693 ---- void FPKShip::GetFileInfo(int listindex, int num) { ! Log::WriteVerbose("FPKShip::GetFileInfo Begin"); char **spath = PHYSFS_getSearchPath(); *************** *** 737,741 **** void FPKShip::GetFileInfo(std::string sfpk, std::string shipname) { ! Log::Write("FPKShip::GetFileInfo Begin"); fpk = sfpk; --- 737,741 ---- void FPKShip::GetFileInfo(std::string sfpk, std::string shipname) { ! Log::WriteVerbose("FPKShip::GetFileInfo Begin"); fpk = sfpk; *************** *** 786,794 **** if (ships[num]->hasChild("displayname")) name=ships[num]->getChild("displayname")->getString(); else FPK_Invalid(temp, "displayname command not found in a playership in FPK"); ! //Log::Write("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("image")) imagefn=ships[num]->getChild("image")->getString(); else FPK_Invalid(temp, "image command not found in a playership in FPK"); ! //Log::Write("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("shield")) --- 786,794 ---- if (ships[num]->hasChild("displayname")) name=ships[num]->getChild("displayname")->getString(); else FPK_Invalid(temp, "displayname command not found in a playership in FPK"); ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("image")) imagefn=ships[num]->getChild("image")->getString(); else FPK_Invalid(temp, "image command not found in a playership in FPK"); ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("shield")) *************** *** 798,802 **** } else hasShield=false; ! //Log::Write("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("price")) --- 798,802 ---- } else hasShield=false; ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("price")) *************** *** 831,835 **** } else FPK_Invalid(temp, "dimensions command not found in a playership in FPK"); ! //Log::Write("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("shootpoint")) --- 831,835 ---- } else FPK_Invalid(temp, "dimensions command not found in a playership in FPK"); ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); if (ships[num]->hasChild("shootpoint")) *************** *** 849,856 **** shooty=image->h/2; } ! //Log::Write("FPKShip::GetFileInfo CP shootpoint"); DataNodeList shipslots = ships[num]->getChildren("slot"); ! //Log::Write("FPKShip::GetFileInfo CP"); slotcount=shipslots.size(); int j=0; --- 849,856 ---- shooty=image->h/2; } ! //Log::WriteVerbose("FPKShip::GetFileInfo CP shootpoint"); DataNodeList shipslots = ships[num]->getChildren("slot"); ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); slotcount=shipslots.size(); int j=0; *************** *** 1017,1021 **** FPKEngine::FPKEngine(std::string sfpk, std::string sengine) { ! Log::Write("New FPKShip"); image=0; price=0; --- 1017,1021 ---- FPKEngine::FPKEngine(std::string sfpk, std::string sengine) { ! Log::WriteVerbose("New FPKShip"); image=0; price=0; *************** *** 1029,1033 **** void FPKEngine::GetFileInfo(std::string sfpk, std::string sengine) { ! Log::Write("FPKEngine::GetFileInfo Begin"); fpk = sfpk; --- 1029,1033 ---- void FPKEngine::GetFileInfo(std::string sfpk, std::string sengine) { ! Log::WriteVerbose("FPKEngine::GetFileInfo Begin"); fpk = sfpk; *************** *** 1128,1132 **** if (engines[num]->hasChild("turndelay")) turndelay=atoi(engines[num]->getChild("turndelay")->getString().c_str()); else FPK_Invalid(temp, "turndelay command not found in an engine in FPK"); ! //Log::Write("FPKShip::GetFileInfo CP"); if (engines[num]->hasChild("turndelaywarp")) warpturndelay=atoi(engines[num]->getChild("turndelaywarp")->getString().c_str()); --- 1128,1132 ---- if (engines[num]->hasChild("turndelay")) turndelay=atoi(engines[num]->getChild("turndelay")->getString().c_str()); else FPK_Invalid(temp, "turndelay command not found in an engine in FPK"); ! //Log::WriteVerbose("FPKShip::GetFileInfo CP"); if (engines[num]->hasChild("turndelaywarp")) warpturndelay=atoi(engines[num]->getChild("turndelaywarp")->getString().c_str()); Index: engine.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/engine.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** engine.cpp 23 Aug 2005 03:40:09 -0000 1.3 --- engine.cpp 23 Aug 2005 09:56:44 -0000 1.4 *************** *** 1,4 **** --- 1,7 ---- #include "engine.h" + extern int SCREEN_WIDTH; + extern int SCREEN_HEIGHT; + extern PyMethodDef fftMethods[]; extern PyMethodDef catchMethods[]; *************** *** 11,15 **** Engine::Engine() { ! Log::Write("Initializing Engine"); running=false; mainship=0; --- 14,18 ---- Engine::Engine() { ! Log::WriteVerbose("Initializing Engine"); running=false; mainship=0; *************** *** 24,28 **** starfields.clear(); Py_Initialize(); ! Log::Write("Loading FFTrader Python Library"); PyImport_AddModule("fft"); module = Py_InitModule3("fft", fftMethods, "fft standard module.\n"); --- 27,31 ---- starfields.clear(); Py_Initialize(); ! Log::WriteVerbose("Loading FFTrader Python Library"); PyImport_AddModule("fft"); module = Py_InitModule3("fft", fftMethods, "fft standard module.\n"); *************** *** 33,42 **** PyRun_SimpleString("import sys; sys.path.insert(0, './scenario')"); ! PyObject* sysModule = PyImport_ImportModule("sys"); PyObject_SetAttrString(sysModule, "stdout", catchmodule); PyObject_SetAttrString(sysModule, "stderr", catchmodule); /* - PyRun_SimpleString( "import fft\n" --- 36,44 ---- PyRun_SimpleString("import sys; sys.path.insert(0, './scenario')"); ! PyObject *sysModule = PyImport_ImportModule("sys"); PyObject_SetAttrString(sysModule, "stdout", catchmodule); PyObject_SetAttrString(sysModule, "stderr", catchmodule); /* PyRun_SimpleString( "import fft\n" *************** *** 47,55 **** PyObject *pDict = PyModule_GetDict(module); //get the dict of the module (listing of all symbols in there), PyObject *pFunc = PyDict_GetItemString(pDict, "Victory"); ! Log::Write("ok so far"); PyObject *test=PyObject_CallFunction(pFunc, 0); ! if(PyObject_IsTrue(test)) Log::Write("method is true"); ! else Log::Write("method is false"); ! Log::Write("got through!"); */ } --- 49,57 ---- PyObject *pDict = PyModule_GetDict(module); //get the dict of the module (listing of all symbols in there), PyObject *pFunc = PyDict_GetItemString(pDict, "Victory"); ! Log::WriteVerbose("ok so far"); PyObject *test=PyObject_CallFunction(pFunc, 0); ! if(PyObject_IsTrue(test)) Log::WriteVerbose("method is true"); ! else Log::WriteVerbose("method is false"); ! Log::WriteVerbose("got through!"); */ } *************** *** 85,98 **** Mix_CloseAudio(); this->CleanUpGame(); ! Py_XDECREF(module); ! Py_XDECREF(catchmodule); //Py_XDECREF(objectiveModule); PHYSFS_deinit(); TTF_Quit(); SDL_Quit(); - Py_Finalize(); Log::Write("Thank you for playing!"); } ! void Engine::StartGame() { PyObject* sysModule = PyImport_ImportModule("sys"); --- 87,100 ---- Mix_CloseAudio(); this->CleanUpGame(); ! //Py_XDECREF(module); ! //Py_XDECREF(catchmodule); //Py_XDECREF(objectiveModule); + Py_Finalize(); PHYSFS_deinit(); TTF_Quit(); SDL_Quit(); Log::Write("Thank you for playing!"); } ! bool Engine::StartGame() { PyObject* sysModule = PyImport_ImportModule("sys"); *************** *** 102,106 **** { Log::Write("The main module hasn't been set yet"); ! return; } PyObject *pModuleName = PyString_FromString(mainmodule.c_str()); --- 104,108 ---- { Log::Write("The main module hasn't been set yet"); ! return false; } PyObject *pModuleName = PyString_FromString(mainmodule.c_str()); *************** *** 109,134 **** Log::Write("Could not create Python string from %s",mainmodule.c_str()); PyErr_Print(); ! return; } ! mainModule = PyImport_Import(pModuleName); ! if (mainModule == NULL) { ! //Log::Write("Could not import file %s",mainmodule.c_str()); ! return; } ! else running=true; } void Engine::CleanUpGame() { running=false; - Py_XDECREF(mainModule); char c[2048]; sprintf(c,"del sys.modules['%s']",mainmodule.c_str()); PyRun_SimpleString(c); } void Engine::SetMainModule(std::string modulename) { if (!running) mainmodule=modulename; ! else Log::Write("\nWARNING:\nAttempted to set a new module while the game is already running\n"); } Unit *Engine::GetMainShip() --- 111,169 ---- Log::Write("Could not create Python string from %s",mainmodule.c_str()); PyErr_Print(); ! return false; } ! else { ! Log::Write("**********************\nLoading module: %s\n",mainmodule.c_str()); ! running=true; } ! mainModule = PyImport_Import(pModuleName); ! if (mainModule == NULL) running=false; ! return running; } void Engine::CleanUpGame() { running=false; char c[2048]; sprintf(c,"del sys.modules['%s']",mainmodule.c_str()); PyRun_SimpleString(c); + Py_XDECREF(mainModule); + } + void Engine::Render() + { + SDL_Surface *screen=SDL_GetVideoSurface(); + SDL_FillRect(screen,0,0); + int x=0; + int y=0; + double dx=0.0; + double dy=0.0; + if(mainship) + { + x=mainship->GetX(); + y=mainship->GetY(); + dx=mainship->GetDX(); + dy=mainship->GetDY(); + } + if(mainmap) + { + int i; + for (i=0; i<(int)starfields.size(); i++) + { + starfields[i].stars->Display((int)(-dx/starfields[i].factor),(int)(-dy/starfields[i].factor)); + } + mainmap->DisplayOnScreenObjects(x,y,SCREEN_WIDTH,SCREEN_HEIGHT); + } + if(mainship) + { + int shipx=(SCREEN_WIDTH/2)-(ship->GetImageWidth()/2); + int shipy=(SCREEN_HEIGHT/2)-(ship->GetImageHeight()/2); + mainship->Display(shipx,shipy); + //mainmap->DisplayMinimap(4,10,x,y,range); + } } void Engine::SetMainModule(std::string modulename) { if (!running) mainmodule=modulename; ! else Log::WriteVerbose("\nWARNING:\nAttempted to set a new module while the game is already running\n"); } Unit *Engine::GetMainShip() *************** *** 288,296 **** } } ! void Engine::AddStarfield(StarField *stars, bool above) { FFTStars fftstars; fftstars.stars=stars; fftstars.above=above; starfields.push_back(fftstars); } --- 323,332 ---- } } ! void Engine::AddStarfield(StarField *stars, bool above, int factor) { FFTStars fftstars; fftstars.stars=stars; fftstars.above=above; + fftstars.factor=factor; starfields.push_back(fftstars); } Index: map.cpp =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/map.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** map.cpp 19 Aug 2005 08:22:34 -0000 1.2 --- map.cpp 23 Aug 2005 09:56:44 -0000 1.3 *************** *** 1,52 **** #include "map.h" Map::~Map() { ! int i; ! for (i=0; i<next; i++) ! { ! delete objects[i]; ! } ! for (i=0; i<stationnext; i++) [...1092 lines suppressed...] ! return (int)objects.size(); } ! int Map::GetUnitCount() { ! int retval=(int)units.size(); ! if (mainship) retval--; ! return retval; } void Map::SendPauseTime(Uint32 time) { int i; ! for (i=0; i<(int)stations.size(); i++) { stations[i]->AddToWaitTime(time); } ! for (i=0; i<(int)sobjects.size(); i++) { ! sobjects[i]->ticks+=time; } } Index: map.h =================================================================== RCS file: /cvsroot/fftrader/fftrader/src/map.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** map.h 19 Aug 2005 07:32:29 -0000 1.1 --- map.h 23 Aug 2005 09:56:44 -0000 1.2 *************** *** 2,12 **** #define __MAP_H__ #include "units.h" #include "mapobject.h" class Map { public: ! Map() {} ~Map(); void Init(float zzoom); --- 2,22 ---- #define __MAP_H__ + #include <deque> + #include <algorithm> #include "units.h" #include "mapobject.h" + struct MapBullet + { + Unit* bullet; + bool enemyfire; + Uint32 ticks; + int target; + }; + class Map { public: ! Map(); ~Map(); void Init(float zzoom); *************** *** 15,23 **** void AddToStations(Station *object); void AddToActiveObjects(Unit *object); ! void RemoveFromActiveObjects(int start); void AddToShootingObjects(Unit *object, int aishipindex); - void RemoveFromShootingObjects(int j); void AddToAIShootingObjects(Unit *object); ! void RemoveFromAIShootingObjects(int j); void DestroyObjects(); void DisplayMinimap(int x, int y, int shipx, int shipy, int range); --- 25,32 ---- void AddToStations(Station *object); void AddToActiveObjects(Unit *object); ! void RemoveFromActiveObjects(int index); void AddToShootingObjects(Unit *object, int aishipindex); void AddToAIShootingObjects(Unit *object); ! void RemoveFromShootingObjects(int index); void DestroyObjects(); void DisplayMinimap(int x, int y, int shipx, int shipy, int range); *************** *** 25,29 **** void CheckSectors(int sectorx, int sectory); int CheckCollisions(Unit *a); ! int CheckAIUnitCollisions(Unit *a); int CheckShipCollisions(Unit *a); void SpawnBullet(int x, int y, int speed, int angle, std::string img, std::string fpk, SDL_Surface *image, int aishipindex=-1, int slotid=0); --- 34,38 ---- void CheckSectors(int sectorx, int sectory); int CheckCollisions(Unit *a); ! int CheckUnitCollisions(Unit *a); int CheckShipCollisions(Unit *a); void SpawnBullet(int x, int y, int speed, int angle, std::string img, std::string fpk, SDL_Surface *image, int aishipindex=-1, int slotid=0); *************** *** 33,74 **** void SetZoom(float szoom); void AddToAnimations(StaticAnim *anim); ! void RemoveFromActiveAnims(int start); ! void AddToAIUnits(Unit *unit); ! void RemoveFromAIUnits(int start); void SpawnAnim(int index, int x, int y); void Dock(int x, int y); ! int GetAIUnitX(int index); ! int GetAIUnitY(int index); void SetTarget(int index); void DisplayAITarget(int sx, int sy, int sw, int sh, TTF_Font *font, int targetx, int targety); ! int Map::GetAIUnitImageW(int index); ! int Map::GetAIUnitImageH(int index); int GetObjCount(); ! int GetAICount(); void SendPauseTime(Uint32 time); Unit *mainship; private: ! MapObject *objects[5000]; ! Station *stations[500]; ! Unit *actobjects[1000]; ! Unit *sobjects[100]; ! Unit *aisobjects[100]; ! StaticAnim *anims[20]; ! Unit *aiunits[100]; ! int next; ! int stationnext; ! int actnext; ! int snext; ! int aisnext; ! int animnext; ! int activeanimnext; ! int aiunitnext; int target; - int shootindex[100]; - Uint32 s_ticks[100]; - Uint32 ais_ticks[100]; float zoom; - StaticAnim *activeanims[20]; - bool activeanim[20]; }; --- 42,70 ---- void SetZoom(float szoom); void AddToAnimations(StaticAnim *anim); ! void RemoveFromActiveAnims(int index); ! void AddToUnits(Unit *unit); ! void RemoveFromUnits(int index); void SpawnAnim(int index, int x, int y); void Dock(int x, int y); ! int GetUnitX(int index); ! int GetUnitY(int index); void SetTarget(int index); void DisplayAITarget(int sx, int sy, int sw, int sh, TTF_Font *font, int targetx, int targety); ! int GetUnitImageW(int index); ! int GetUnitImageH(int index); int GetObjCount(); ! int GetUnitCount(); void SendPauseTime(Uint32 time); U... [truncated message content] |