X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=dbc0b3072d24eda9f839f44221f980ed79b196ce;hb=cb528019c5229698c6e4af7998c34bc45cb6b124;hp=3a7c28f4a3b0fe51fcf1d32e755286c119cab217;hpb=2e8b5b6b088bbb3840837fb1ea0acc8af44c54d9;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 3a7c28f4..dbc0b307 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -357,25 +357,7 @@ unsigned int Counter() /* get milliseconds since last call of InitCounter() */ static void sleep_milliseconds(unsigned int milliseconds_delay) { - boolean do_busy_waiting = (milliseconds_delay < 5 ? TRUE : FALSE); - - if (do_busy_waiting) - { - /* we want to wait only a few ms -- if we assume that we have a - kernel timer resolution of 10 ms, we would wait far too long; - therefore it's better to do a short interval of busy waiting - to get our sleeping time more accurate */ - - unsigned int base_counter = Counter(), actual_counter = Counter(); - - while (actual_counter < base_counter + milliseconds_delay && - actual_counter >= base_counter) - actual_counter = Counter(); - } - else - { - SDL_Delay(milliseconds_delay); - } + SDL_Delay(milliseconds_delay); } void Delay(unsigned int delay) /* Sleep specified number of milliseconds */ @@ -383,32 +365,42 @@ void Delay(unsigned int delay) /* Sleep specified number of milliseconds */ sleep_milliseconds(delay); } -boolean FrameReached(unsigned int *frame_counter_var, - unsigned int frame_delay) +boolean DelayReachedExt(unsigned int *counter_var, unsigned int delay, + unsigned int actual_counter) { - unsigned int actual_frame_counter = FrameCounter; - - if (actual_frame_counter >= *frame_counter_var && - actual_frame_counter < *frame_counter_var + frame_delay) + if (actual_counter >= *counter_var && + actual_counter < *counter_var + delay) return FALSE; - *frame_counter_var = actual_frame_counter; + *counter_var = actual_counter; return TRUE; } -boolean DelayReached(unsigned int *counter_var, - unsigned int delay) +boolean FrameReached(unsigned int *frame_counter_var, unsigned int frame_delay) { - unsigned int actual_counter = Counter(); + return DelayReachedExt(frame_counter_var, frame_delay, FrameCounter); +} - if (actual_counter >= *counter_var && - actual_counter < *counter_var + delay) - return FALSE; +boolean DelayReached(unsigned int *counter_var, unsigned int delay) +{ + return DelayReachedExt(counter_var, delay, Counter()); +} - *counter_var = actual_counter; +void ResetDelayCounterExt(unsigned int *counter_var, + unsigned int actual_counter) +{ + DelayReachedExt(counter_var, 0, actual_counter); +} - return TRUE; +void ResetFrameCounter(unsigned int *frame_counter_var) +{ + FrameReached(frame_counter_var, 0); +} + +void ResetDelayCounter(unsigned int *counter_var) +{ + DelayReached(counter_var, 0); } int WaitUntilDelayReached(unsigned int *counter_var, unsigned int delay) @@ -1139,6 +1131,12 @@ void GetOptions(int argc, char *argv[], /* when doing batch processing, always enable verbose mode (warnings) */ options.verbose = TRUE; } +#if defined(PLATFORM_MACOSX) + else if (strPrefix(option, "-psn")) + { + /* ignore process serial number when launched via GUI on Mac OS X */ + } +#endif else if (*option == '-') { Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str); @@ -2647,6 +2645,17 @@ int get_parameter_value(char *value_raw, char *suffix, int type) strEqual(value, "up") ? MV_UP : strEqual(value, "down") ? MV_DOWN : MV_NONE); } + else if (strEqual(suffix, ".position")) + { + result = (strEqual(value, "left") ? POS_LEFT : + strEqual(value, "right") ? POS_RIGHT : + strEqual(value, "top") ? POS_TOP : + strEqual(value, "upper") ? POS_UPPER : + strEqual(value, "middle") ? POS_MIDDLE : + strEqual(value, "lower") ? POS_LOWER : + strEqual(value, "bottom") ? POS_BOTTOM : + strEqual(value, "any") ? POS_ANY : POS_UNDEFINED); + } else if (strEqual(suffix, ".align")) { result = (strEqual(value, "left") ? ALIGN_LEFT : @@ -2675,6 +2684,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : string_has_parameter(value, "vertical") ? ANIM_VERTICAL : string_has_parameter(value, "centered") ? ANIM_CENTERED : + string_has_parameter(value, "all") ? ANIM_ALL : ANIM_DEFAULT); if (string_has_parameter(value, "reverse")) @@ -2706,6 +2716,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "fade") ? FADE_MODE_FADE : string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : string_has_parameter(value, "melt") ? FADE_MODE_MELT : + string_has_parameter(value, "curtain") ? FADE_MODE_CURTAIN : FADE_MODE_DEFAULT); } else if (strPrefix(suffix, ".font")) /* (may also be ".font_xyz") */ @@ -3269,8 +3280,8 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, boolean unknown_tokens_found = FALSE; boolean undefined_values_found = (hashtable_count(empty_file_hash) != 0); - if ((setup_file_list = loadSetupFileList(filename)) == NULL) - Error(ERR_EXIT, "loadSetupFileHash works, but loadSetupFileList fails"); + /* list may be NULL for empty artwork config files */ + setup_file_list = loadSetupFileList(filename); BEGIN_HASH_ITERATION(extra_file_hash, itr) {