X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=6ff358a13adb6bca67711d17c0eb71e2bb765e8d;hb=3c8f67c3c66a86fc9e45469ce2fed4222d486c9f;hp=73b815b13347470d79770d83d2ad737d84df4fa0;hpb=36cc3af3e5074215817ddee16defde754e2ad67f;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 73b815b..6ff358a 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1,4 +1,11 @@ +#if PLATFORM_UNIX +#include +#include +#include +#else #include +#endif + #include #include "Game.h" @@ -196,7 +203,7 @@ extern float accountcampaigntime[10]; extern int accountcampaignchoicesmade[10]; extern int accountcampaignchoices[10][5000]; /********************> Tick() <*****/ -extern FSOUND_STREAM * strm[10]; +extern FSOUND_STREAM * strm[20]; extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); @@ -208,7 +215,7 @@ void Screenshot (void) struct tm *tme = localtime(&t); sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec); - mkdir("Screenshots"); + mkdir("Screenshots", S_IRWXU); ScreenShot(temp/*"Screenshots\\Screenshot.png"*/); /*FSSpec MAC_file; @@ -624,10 +631,10 @@ void Game::Setenvironment(int which) FSOUND_Sample_Free(samp[footstepsound2]); FSOUND_Sample_Free(samp[footstepsound3]); FSOUND_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0); - samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0); - samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0); - samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0); + samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); @@ -678,10 +685,10 @@ void Game::Setenvironment(int which) FSOUND_Sample_Free(samp[footstepsound2]); FSOUND_Sample_Free(samp[footstepsound3]); FSOUND_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0); - samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0); - samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0); - samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0); + samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); @@ -729,10 +736,10 @@ void Game::Setenvironment(int which) FSOUND_Sample_Free(samp[footstepsound2]); FSOUND_Sample_Free(samp[footstepsound3]); FSOUND_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0); - samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0); - samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0); - samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0); + samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0); + samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); @@ -1837,13 +1844,14 @@ void Game::Tick() if(newdetail>2)newdetail=detail; if(newdetail<0)newdetail=detail; +#if !USE_SDL // we'll take anything that works. if(newscreenwidth>3000)newscreenwidth=screenwidth; - if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight>3000)newscreenheight=screenheight; +#endif + if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight<0)newscreenheight=screenheight; - //ofstream opstream(":Data:config.txt"); - ofstream opstream("./Data/config.txt"); + ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; opstream << newscreenwidth; opstream << "\nScreenheight:\n"; @@ -2100,6 +2108,52 @@ void Game::Tick() FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); } if(Button()&&!oldbutton&&selected==0){ + #if USE_SDL + extern SDL_Rect **resolutions; + bool isCustomResolution = true; + bool found = false; + for (int i = 0; (!found) && (resolutions[i]); i++) + { + if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth)) + isCustomResolution = false; + + if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight)) + { + i++; + if (resolutions[i] != NULL) + { + newscreenwidth = (int) resolutions[i]->w; + newscreenheight = (int) resolutions[i]->h; + } + else if (isCustomResolution) + { + if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight)) + { + newscreenwidth = (int) resolutions[0]->w; + newscreenheight = (int) resolutions[0]->h; + } + else + { + newscreenwidth = screenwidth; + newscreenheight = screenheight; + } + } + else + { + newscreenwidth = (int) resolutions[0]->w; + newscreenheight = (int) resolutions[0]->h; + } + found = true; + } + } + + if (!found) + { + newscreenwidth = (int) resolutions[0]->w; + newscreenheight = (int) resolutions[0]->h; + } + + #else int whichres; whichres=-1; if(newscreenwidth==640&&newscreenheight==480)whichres=0; @@ -2110,8 +2164,9 @@ void Game::Tick() if(newscreenwidth==840&&newscreenheight==524)whichres=5; if(newscreenwidth==1024&&newscreenheight==640)whichres=6; if(newscreenwidth==1344&&newscreenheight==840)whichres=7; + if(newscreenwidth==1920&&newscreenheight==1200)whichres=8; - if(whichres==-1||whichres==7){ + if(whichres==-1||whichres==8){ newscreenwidth=640; newscreenheight=480; } @@ -2143,6 +2198,11 @@ void Game::Tick() newscreenwidth=1344; newscreenheight=840; } + if(whichres==7){ + newscreenwidth=1920; + newscreenheight=1200; + } + #endif } if(Button()&&!oldbutton&&selected==1){ newdetail++; @@ -2233,14 +2293,15 @@ void Game::Tick() if(newdetail>2)newdetail=detail; if(newdetail<0)newdetail=detail; +#if !USE_SDL // we'll take anything that works. if(newscreenwidth>3000)newscreenwidth=screenwidth; - if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight>3000)newscreenheight=screenheight; +#endif + if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight<0)newscreenheight=screenheight; - //ofstream opstream(":Data:config.txt"); - ofstream opstream("./Data/config.txt"); + ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; opstream << newscreenwidth; opstream << "\nScreenheight:\n"; @@ -2980,13 +3041,14 @@ void Game::Tick() if(mainmenu==3){ if(newdetail>2)newdetail=detail; if(newdetail<0)newdetail=detail; +#if !USE_SDL // we'll take anything that works. if(newscreenwidth>3000)newscreenwidth=screenwidth; - if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight>3000)newscreenheight=screenheight; +#endif + if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight<0)newscreenheight=screenheight; - //ofstream opstream(":Data:config.txt"); - ofstream opstream("./Data/config.txt"); + ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; opstream << newscreenwidth; opstream << "\nScreenheight:\n"; @@ -3165,7 +3227,13 @@ void Game::Tick() if(displaychars[0]){ char serialstring[256]; char tempstring[256]; + #if defined(__APPLE__) + sprintf (tempstring, "%s", registrationname); + #elif defined(_MSC_VER) || defined(__linux__) sprintf (tempstring, "%s-windows", registrationname); + #else + #error Please make sure you have the right registration key stuff here! + #endif long num1; long num2; long num3; @@ -3202,7 +3270,7 @@ void Game::Tick() if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--; } - if(longnum==5077041556214789)goodcode=-1; + if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1; if(goodcode<0)goodcode=0; @@ -4511,7 +4579,7 @@ void Game::Tick() } } - ifstream ipstream(mapname); + ifstream ipstream(ConvertFileName(mapname)); ipstream.ignore(256,':'); ipstream >> numdialogueboxes[numdialogues]; for(i=0;i> numdialogueboxes[whichdi]; for(i=0;i2)newdetail=detail; if(newdetail<0)newdetail=detail; +#if !USE_SDL // we'll take anything that works. if(newscreenwidth>3000)newscreenwidth=screenwidth; - if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight>3000)newscreenheight=screenheight; +#endif + if(newscreenwidth<0)newscreenwidth=screenwidth; if(newscreenheight<0)newscreenheight=screenheight; - //ofstream opstream(":Data:config.txt"); - ofstream opstream("./Data/config.txt"); + ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; opstream << newscreenwidth; opstream << "\nScreenheight:\n"; @@ -10759,6 +10828,7 @@ void Game::Tick() oldtemp2=temp2; if(tutorialstage>=51) if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){ + FSOUND_StopSound(FSOUND_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu... FSOUND_SetFrequency(FSOUND_ALL, 0.001); PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE); @@ -11339,8 +11409,7 @@ void Game::TickOnceAfter(){ startbonustotal=0; - // ifstream ipstream(":Data:Campaigns:main.txt"); - ifstream ipstream("./Data/Campaigns/main.txt"); + ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt")); //campaignnumlevels=0; //accountcampaignchoicesmade[accountactive]=0; ipstream.ignore(256,':');