X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=aa14e093b0808330bcd313bfb66792f86e88c2d4;hb=44146d06c780d3aaa283672fedb08b8870ebe1b9;hp=de6c79ecf1ed1fd9d0bb80db9ad413ab61351ecd;hpb=c26c5303fbc3fcc607681b848bc4fd0641320691;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index de6c79e..aa14e09 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1,3 +1,24 @@ +/* +Copyright (C) 2003, 2010 - Wolfire Games + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + #if PLATFORM_UNIX #include #include @@ -203,7 +224,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); @@ -1844,9 +1865,11 @@ 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(ConvertFileName(":Data:config.txt", "w")); @@ -2106,6 +2129,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; @@ -2116,8 +2185,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; } @@ -2149,6 +2219,11 @@ void Game::Tick() newscreenwidth=1344; newscreenheight=840; } + if(whichres==7){ + newscreenwidth=1920; + newscreenheight=1200; + } + #endif } if(Button()&&!oldbutton&&selected==1){ newdetail++; @@ -2239,9 +2314,11 @@ 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; @@ -2985,9 +3062,11 @@ 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(ConvertFileName(":Data:config.txt", "w")); @@ -3169,7 +3248,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; @@ -5623,9 +5708,11 @@ 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(ConvertFileName(":Data:config.txt", "w")); @@ -10762,6 +10849,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);