X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=e4939b193db1d697d81d11b3ca64539397690346;hb=30eb586d06bc4d1ee7388dced1c20e530292aa93;hp=4a71d544c166cd0563494cc18d2d4078fbe4a385;hpb=d3e7f0533cacbe8dc912a702bf51109ede78820b;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 4a71d544..e4939b19 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -336,7 +336,7 @@ boolean getTokenValueFromString(char *string, char **token, char **value) /* maximal allowed length of a command line option */ #define MAX_OPTION_LEN 256 -static unsigned int getCurrentMS() +static unsigned int getCurrentMS(void) { return SDL_GetTicks(); } @@ -558,7 +558,7 @@ static char *get_corrected_real_name(char *real_name) } #endif -char *getLoginName() +char *getLoginName(void) { static char *login_name = NULL; @@ -588,7 +588,7 @@ char *getLoginName() return login_name; } -char *getRealName() +char *getRealName(void) { static char *real_name = NULL; @@ -1141,7 +1141,7 @@ void SetError(char *format, ...) va_end(ap); } -char *GetError() +char *GetError(void) { return internal_error; } @@ -1507,7 +1507,7 @@ void WriteUnusedBytesToFile(FILE *file, unsigned int bytes) #define TRANSLATE_KEYNAME_TO_KEYSYM 2 #define TRANSLATE_X11KEYNAME_TO_KEYSYM 3 -void translate_keyname(Key *keysym, char **x11name, char **name, int mode) +static void translate_keyname(Key *keysym, char **x11name, char **name, int mode) { static struct { @@ -1516,6 +1516,10 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) char *name; } translate_key[] = { + /* return and escape keys */ + { KSYM_Return, "XK_Return", "return" }, + { KSYM_Escape, "XK_Escape", "escape" }, + /* normal cursor keys */ { KSYM_Left, "XK_Left", "cursor left" }, { KSYM_Right, "XK_Right", "cursor right" }, @@ -2039,12 +2043,37 @@ int get_switch3_from_string(char *s) return result; } +int get_player_nr_from_string(char *s) +{ + static char *player_text[] = + { + "player_1", + "player_2", + "player_3", + "player_4", + + NULL + }; + + char *s_lower = getStringToLower(s); + int result = 0; + int i; + + for (i = 0; player_text[i] != NULL; i++) + if (strEqual(s_lower, player_text[i])) + result = i; + + free(s_lower); + + return result; +} + /* ------------------------------------------------------------------------- */ /* functions for generic lists */ /* ------------------------------------------------------------------------- */ -ListNode *newListNode() +ListNode *newListNode(void) { return checked_calloc(sizeof(ListNode)); } @@ -2116,7 +2145,8 @@ int getNumNodes(ListNode *node_first) return (node_first ? 1 + getNumNodes(node_first->next) : 0); } -void dumpList(ListNode *node_first) +#if 0 +static void dumpList(ListNode *node_first) { ListNode *node = node_first; @@ -2129,6 +2159,7 @@ void dumpList(ListNode *node_first) printf("[%d nodes]\n", getNumNodes(node_first)); } +#endif /* ------------------------------------------------------------------------- */ @@ -2515,7 +2546,8 @@ boolean fileExists(char *filename) return success; } -boolean fileHasPrefix(char *basename, char *prefix) +#if 0 +static boolean fileHasPrefix(char *basename, char *prefix) { static char *basename_lower = NULL; int basename_length, prefix_length; @@ -2536,8 +2568,9 @@ boolean fileHasPrefix(char *basename, char *prefix) return FALSE; } +#endif -boolean fileHasSuffix(char *basename, char *suffix) +static boolean fileHasSuffix(char *basename, char *suffix) { static char *basename_lower = NULL; int basename_length, suffix_length; @@ -2641,7 +2674,8 @@ char *get_mapped_token(char *token) return NULL; } -char *get_special_base_token(struct ArtworkListInfo *artwork_info, char *token) +static char *get_special_base_token(struct ArtworkListInfo *artwork_info, + char *token) { /* !!! make this dynamically configurable (init.c:InitArtworkConfig) !!! */ static struct ConfigTypeInfo prefix_list[] = @@ -2739,7 +2773,7 @@ static boolean string_has_parameter(char *s, char *s_contained) return string_has_parameter(substring, s_contained); } -int get_anim_parameter_value(char *s) +static int get_anim_parameter_value(char *s) { char *pattern_1 = "click:anim_"; char *pattern_2 = ".part_"; @@ -2806,7 +2840,7 @@ int get_anim_parameter_value(char *s) return result; } -int get_anim_action_parameter_value(char *token) +static int get_anim_action_parameter_value(char *token) { int result = getImageIDFromToken(token); @@ -2819,6 +2853,14 @@ int get_anim_action_parameter_value(char *token) checked_free(gfx_token); } + if (result == -1) + { + Key key = getKeyFromX11KeyName(token); + + if (key != KSYM_UNDEFINED) + result = -(int)key; + } + if (result == -1) result = ANIM_EVENT_ACTION_NONE; @@ -2909,7 +2951,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) else if (strEqual(suffix, ".init_event_action") || strEqual(suffix, ".anim_event_action")) { - result = get_anim_action_parameter_value(value); + result = get_anim_action_parameter_value(value_raw); } else if (strEqual(suffix, ".class")) { @@ -2931,6 +2973,9 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "passthrough_clicks")) result |= STYLE_PASSTHROUGH; + + if (string_has_parameter(value, "multiple_actions")) + result |= STYLE_MULTIPLE_ACTIONS; } else if (strEqual(suffix, ".fade_mode")) { @@ -3837,7 +3882,7 @@ char *getLogFilename(char *basename) return getPath2(getUserGameDataDir(), basename); } -void OpenLogFiles() +void OpenLogFiles(void) { int i; @@ -3859,7 +3904,7 @@ void OpenLogFiles() } } -void CloseLogFiles() +void CloseLogFiles(void) { int i; @@ -3881,7 +3926,7 @@ void DumpLogFile(int nr) fclose(log_file); } -void NotifyUserAboutErrorFile() +void NotifyUserAboutErrorFile(void) { #if defined(PLATFORM_WIN32) char *title_text = getStringCat2(program.program_title, " Error Message"); @@ -3908,7 +3953,7 @@ void NotifyUserAboutErrorFile() #define DEBUG_TIME_IN_MICROSECONDS 0 #if DEBUG_TIME_IN_MICROSECONDS -static double Counter_Microseconds() +static double Counter_Microseconds(void) { static struct timeval base_time = { 0, 0 }; struct timeval current_time; @@ -3928,7 +3973,7 @@ static double Counter_Microseconds() } #endif -char *debug_print_timestamp_get_padding(int padding_size) +static char *debug_print_timestamp_get_padding(int padding_size) { static char *padding = NULL; int max_padding_size = 100; @@ -3977,7 +4022,8 @@ void debug_print_timestamp(int counter_nr, char *message) unit); } -void debug_print_parent_only(char *format, ...) +#if 0 +static void debug_print_parent_only(char *format, ...) { if (!IS_PARENT_PROCESS()) return; @@ -3993,10 +4039,11 @@ void debug_print_parent_only(char *format, ...) printf("\n"); } } +#endif #endif /* DEBUG */ -void print_timestamp_ext(char *message, char *mode) +static void print_timestamp_ext(char *message, char *mode) { #if DEBUG_PRINT_INIT_TIMESTAMPS static char *debug_message = NULL;