X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=b8f2fe5c4d502d6e3896dedc7103613be5fcb52c;hb=ef45167ef6edc052f7d551b2fe1906432d12777f;hp=1535b69cd04d7d1c5dd92d6d6b7c6f3f5c3887b4;hpb=dc856cea3f61d1fecaf875fa519ac72c1c129713;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 1535b69c..b8f2fe5c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -182,6 +182,46 @@ END_OF_FUNCTION(increment_counter); /* maximal allowed length of a command line option */ #define MAX_OPTION_LEN 256 +#if 1 + +#ifdef TARGET_SDL +static unsigned long getCurrentMS() +{ + return SDL_GetTicks(); +} + +#else /* !TARGET_SDL */ + +#if defined(PLATFORM_UNIX) +static unsigned long getCurrentMS() +{ + struct timeval current_time; + + gettimeofday(¤t_time, NULL); + + return current_time.tv_sec * 1000 + current_time.tv_usec / 1000; +} +#endif /* PLATFORM_UNIX */ +#endif /* !TARGET_SDL */ + +static unsigned long mainCounter(int mode) +{ + static unsigned long base_ms = 0; + unsigned long current_ms; + + /* get current system milliseconds */ + current_ms = getCurrentMS(); + + /* reset base timestamp in case of counter reset or wrap-around */ + if (mode == INIT_COUNTER || current_ms < base_ms) + base_ms = current_ms; + + /* return milliseconds since last counter reset */ + return current_ms - base_ms; +} + +#else + #ifdef TARGET_SDL static unsigned long mainCounter(int mode) { @@ -223,6 +263,8 @@ static unsigned long mainCounter(int mode) #endif /* PLATFORM_UNIX */ #endif /* !TARGET_SDL */ +#endif + void InitCounter() /* set counter back to zero */ { #if !defined(PLATFORM_MSDOS) @@ -1831,7 +1873,7 @@ boolean FileIsMusic(char *filename) return TRUE; #if defined(TARGET_SDL) - if (fileHasPrefix(basename, "mod") || + if ((fileHasPrefix(basename, "mod") && !fileHasSuffix(basename, "txt")) || fileHasSuffix(basename, "mod") || fileHasSuffix(basename, "s3m") || fileHasSuffix(basename, "it") ||