diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 6841e20d6..393f057fa 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -323,9 +323,10 @@ TFB_FlushGraphics () // Only call from main thread!! if (current_fade != 255 && current_fade != last_fade) TFB_SwapBuffers(); // if fading, redraw every frame + else + SDL_Delay(5); last_fade = current_fade; - - SDL_Delay(5); + return; } @@ -391,6 +392,7 @@ TFB_FlushGraphics () // Only call from main thread!! SDL_Rect targetRect; SDL_Surface *surf; + if (DC_image == 0) { printf ("TFB_FlushGraphics(): error, DC_image == 0\n"); diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 31d6a83d9..46a5893ea 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -16,11 +16,43 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef WIN32 +#include +#else +#include +#endif + #include "libs/graphics/gfx_common.h" #include "libs/sound/sound_common.h" #include "libs/input/input_common.h" #include "libs/tasklib.h" + +BOOLEAN FileExists (char *filename) +{ + FILE *fp; + if ((fp = fopen(filename, "rb")) == NULL) + return FALSE; + + fclose (fp); + return TRUE; +} + +void +CDToContentDir (char *contentdir) +{ + char *testfile = "starcon.txt"; + + if (!FileExists (testfile)) + { + if (chdir(contentdir) || !FileExists (testfile)) + { + fprintf(stderr, "Fatal error: content not available, running from wrong dir?\n"); + exit(-1); + } + } +} + int main (int argc, char *argv[]) { @@ -29,6 +61,13 @@ main (int argc, char *argv[]) int gfxflags = 0; int width = 640, height = 480, bpp = 16; int frequency = 44100; + char contentdir[1000]; + +#ifndef WIN32 + strcpy (contentdir, "content"); +#else + strcpy (contentdir, "../../content"); +#endif // TODO: proper commandline parser, this is just a quick hack for (i=1;i