From a812642c17eed3675ba0e25a780ed46a892b1b74 Mon Sep 17 00:00:00 2001 From: Tomas Chvatal Date: Sun, 1 May 2011 12:55:21 +0200 Subject: [PATCH 8/8] [warn] Silence all simple warnings in client build. The remaining ones are real issues requiring addressing. --- src/base/arena.c | 17 +++-- src/base/arenaFile.c | 6 +- src/base/buffer.c | 2 +- src/base/buffer.h | 2 +- src/base/downServer.c | 5 +- src/base/idManager.c | 5 -- src/base/idManager.h | 5 ++ src/base/net_multiplayer.c | 2 + src/base/proto.c | 8 ++- src/base/proto.h | 2 +- src/base/storage.c | 8 -- src/base/storage.h | 7 ++- src/client/client.c | 26 +++---- src/client/client.h | 10 ++- src/client/config.c | 32 +++------ src/client/config.h | 24 +++++-- src/client/configFile.c | 19 +++--- src/client/configFile.h | 12 ++-- src/client/font.c | 2 +- src/client/font.h | 2 +- src/client/mouse_buffer.c | 7 -- src/client/mouse_buffer.h | 6 ++ src/client/pauza.c | 14 ++-- src/client/pauza.h | 10 ++-- src/client/radar.c | 9 --- src/client/radar.h | 6 ++ src/client/term.c | 20 ++--- src/client/term.h | 8 +- src/client/yes_no_dialog.c | 14 ++-- src/client/yes_no_dialog.h | 12 ++-- src/screen/analyze.c | 24 +++--- src/screen/analyze.h | 20 +++--- src/screen/browser.c | 154 +++++++++++++++++++++-------------------- src/screen/browser.h | 12 ++-- src/screen/choiceArena.c | 30 ++++---- src/screen/choiceArena.h | 10 ++-- src/screen/credits.c | 26 +++---- src/screen/credits.h | 12 ++-- src/screen/downArena.c | 34 ++++----- src/screen/downArena.h | 12 ++-- src/screen/gameType.c | 41 ++++------- src/screen/gameType.h | 18 +++--- src/screen/mainMenu.c | 28 ++------ src/screen/mainMenu.h | 12 ++-- src/screen/setting.c | 34 +++++----- src/screen/setting.h | 16 ++-- src/screen/settingKeys.c | 14 ++-- src/screen/table.c | 20 +++--- src/screen/table.h | 14 ++-- src/screen/world.c | 16 +++-- src/widget/widget_button.c | 2 +- src/widget/widget_button.h | 2 +- src/widget/widget_label.c | 2 +- src/widget/widget_label.h | 2 +- src/widget/widget_statusbar.c | 14 +--- src/widget/widget_statusbar.h | 15 +++-- 56 files changed, 429 insertions(+), 457 deletions(-) diff --git a/src/base/arena.c b/src/base/arena.c index ca28ddc..253104c 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -63,7 +63,7 @@ static void hotkey_splitArena(void) } } -void arena_init() +void arena_init(void) { splitType = SCREEN_SPLIT_VERTICAL; @@ -80,7 +80,7 @@ void arena_init() hot_key_register(SDLK_F3, hotkey_splitArena); } -void arena_quit() +void arena_quit(void) { hot_key_unregister(SDLK_F3); } @@ -245,7 +245,7 @@ static void drawSplitArenaForTux(arena_t *arena, tux_t *tux, int location_x, int default: screen_x = -1; screen_y = -1; - fatal("Unknown method of splitting the screen"); + fatal("Unknown method of splitting the screen [%d]", splitType); break; } @@ -262,12 +262,12 @@ static void drawSplitArenaForTux(arena_t *arena, tux_t *tux, int location_x, int default: screen_x = -1; screen_y = -1; - fatal("Unknown method of splitting the screen"); + fatal("Unknown method of splitting the screen [%d]", splitType); break; } } -void drawSplitArena(arena_t *arena) +static void drawSplitArena(arena_t *arena) { tux_t *tux = NULL; @@ -281,6 +281,9 @@ void drawSplitArena(arena_t *arena) case SCREEN_SPLIT_VERTICAL: drawSplitArenaForTux(arena, tux, WINDOW_SIZE_X / 2, 0); break; + default: + fatal("Unknown method of splitting the screen [%d]", splitType); + break; } } @@ -291,7 +294,7 @@ void drawSplitArena(arena_t *arena) } } -void drawCenterArena(arena_t *arena, int x, int y) +static void drawCenterArena(arena_t *arena, int x, int y) { int screen_x, screen_y; @@ -301,7 +304,7 @@ void drawCenterArena(arena_t *arena, int x, int y) layer_draw_center(x, y); } -void drawSimpleArena(arena_t *arena) +static void drawSimpleArena(arena_t *arena) { int screen_x, screen_y; tux_t *tux = NULL; diff --git a/src/base/arenaFile.c b/src/base/arenaFile.c index 110993f..88481ed 100644 --- a/src/base/arenaFile.c +++ b/src/base/arenaFile.c @@ -78,7 +78,7 @@ int arena_file_get_value(const char *line, const char *env, const char *val, int #ifndef PUBLIC_SERVER image_t *arena_file_load_image(arenaFile_t *arenaFile, const char *filename, const char *group, const char *name, int alpha) { - char *extractFile; + const char *extractFile; image_t *image; extractFile = archive_extract_file(arenaFile->path, filename); @@ -89,9 +89,9 @@ image_t *arena_file_load_image(arenaFile_t *arenaFile, const char *filename, con } #ifndef NO_SOUND -void loadMusicFromArena(arenaFile_t *arenaFile, const char *filename, const char *group, const char *name) +static void loadMusicFromArena(arenaFile_t *arenaFile, const char *filename, const char *group, const char *name) { - char *extractFile; + const char *extractFile; extractFile = archive_extract_file(arenaFile->path, filename); music_add(extractFile, name, group); diff --git a/src/base/buffer.c b/src/base/buffer.c index 1b36b1c..09b1753 100644 --- a/src/base/buffer.c +++ b/src/base/buffer.c @@ -28,7 +28,7 @@ int buffer_get_size(buffer_t *p) return p->size; } -int buffer_append(buffer_t *p, char *data, int len) +int buffer_append(buffer_t *p, const char *data, int len) { assert(p != NULL); assert(data != NULL); diff --git a/src/base/buffer.h b/src/base/buffer.h index 9ddc5e6..2542dad 100644 --- a/src/base/buffer.h +++ b/src/base/buffer.h @@ -12,7 +12,7 @@ typedef struct str_buffer { extern buffer_t *buffer_new(int n); extern void *buffer_get_data(buffer_t *p); extern int buffer_get_size(buffer_t *p); -extern int buffer_append(buffer_t *p, char *data, int len); +extern int buffer_append(buffer_t *p, const char *data, int len); extern int buffer_cut(buffer_t *p, int len); extern int buffer_count_line(buffer_t *p); extern int buffer_get_line(buffer_t *p, char *line, int len); diff --git a/src/base/downServer.c b/src/base/downServer.c index 5117552..b9c36bd 100644 --- a/src/base/downServer.c +++ b/src/base/downServer.c @@ -47,6 +47,7 @@ static void proto_getarena(client_ds_t *client, char *msg) arenaFile_t *arenaFile; char msg_out[STR_PROTO_SIZE]; char *arenaName; + const char *error_msg = ""; arenaName = msg + 9; @@ -54,7 +55,7 @@ static void proto_getarena(client_ds_t *client, char *msg) arenaFile = arena_file_get_file_format_net_name(arenaName); if (arenaFile == NULL) { - char *error_msg = _("[Error] Arena not found\n"); + error_msg = _("[Error] Arena not found\n"); buffer_append(client->sendBuffer, error_msg, strlen(error_msg)); return; } @@ -62,7 +63,7 @@ static void proto_getarena(client_ds_t *client, char *msg) client->file = fopen(arenaFile->path, "rb"); if (client->file == NULL) { - char *error_msg = _("[Error] Server has some problem\n"); + error_msg = _("[Error] Server has some problem\n"); buffer_append(client->sendBuffer, error_msg, strlen(error_msg)); return; } diff --git a/src/base/idManager.c b/src/base/idManager.c index ef9c968..16b7a3a 100644 --- a/src/base/idManager.c +++ b/src/base/idManager.c @@ -9,11 +9,6 @@ static list_t *listID; static int lastID; -typedef struct id_item_struct { - int id; - int count; -} id_item_t; - static id_item_t *newIdItem(int id, int count) { id_item_t *new; diff --git a/src/base/idManager.h b/src/base/idManager.h index f959f3e..54cd019 100644 --- a/src/base/idManager.h +++ b/src/base/idManager.h @@ -10,6 +10,11 @@ #define random rand #endif /* __WIN32__ */ +typedef struct id_item_struct { + int id; + int count; +} id_item_t; + extern void id_init_list(void); extern int id_is_register(int id); extern int id_get_newcount(int count); diff --git a/src/base/net_multiplayer.c b/src/base/net_multiplayer.c index 85f8a12..3669a43 100644 --- a/src/base/net_multiplayer.c +++ b/src/base/net_multiplayer.c @@ -29,6 +29,7 @@ int net_multiplayer_get_game_type(void) return netGameType; } +#ifdef PUBLIC_SERVER int net_multiplayer_init_for_game_server(char *ip4, char *ip6, int port) { int ret; @@ -41,6 +42,7 @@ int net_multiplayer_init_for_game_server(char *ip4, char *ip6, int port) return ret; } +#endif int net_multiplayer_init(int type, char *ip, int port, int proto) { diff --git a/src/base/proto.c b/src/base/proto.c index 4d800af..c50374a 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -74,6 +74,9 @@ void proto_recv_error_client(char *msg) analyze_set_msg(_("Server is full")); world_do_end(); break; + default: + fatal("Recieved unknown error code [%d]", errorcode); + break; } } @@ -590,8 +593,7 @@ void proto_send_del_server(int type, client_t *client, int id) } #ifndef PUBLIC_SERVER - -void timer_delShot(void *p) +static void timer_delShot(void *p) { shot_t *shot; int *id; @@ -862,7 +864,7 @@ void proto_recv_module_client(char *msg) module_recv_msg(msg + 7); } -void proto_send_ping_client() +void proto_send_ping_client(void) { char msg[STR_PROTO_SIZE]; snprintf(msg, STR_PROTO_SIZE, "ping\n"); diff --git a/src/base/proto.h b/src/base/proto.h index b3f2380..174ffd6 100644 --- a/src/base/proto.h +++ b/src/base/proto.h @@ -82,7 +82,7 @@ extern void proto_recv_module_server(client_t *client, char *msg); extern void proto_send_module_server(int type, client_t *client, char *msg); extern void proto_recv_module_client(char *msg); -extern void proto_send_ping_client(); +extern void proto_send_ping_client(void); extern void proto_recv_ping_server(client_t *client, char *msg); extern void proto_send_ping_server(int type, client_t *client); extern void proto_recv_ping_client(char *msg); diff --git a/src/base/storage.c b/src/base/storage.c index 6bb2e52..d606149 100644 --- a/src/base/storage.c +++ b/src/base/storage.c @@ -3,16 +3,8 @@ #include #include -#include "main.h" -#include "list.h" #include "storage.h" -typedef struct struct_storage_item { - char *name; - char *group; - void *data; -} storage_item_t; - list_t *storage_new(void) { return list_new(); diff --git a/src/base/storage.h b/src/base/storage.h index 6e89075..7b8e5dd 100644 --- a/src/base/storage.h +++ b/src/base/storage.h @@ -1,9 +1,14 @@ #ifndef STORAGE_H #define STORAGE_H -#include "main.h" #include "list.h" +typedef struct struct_storage_item { + char *name; + char *group; + void *data; +} storage_item_t; + extern list_t *storage_new(void); extern void storage_add(list_t *list, const char *group, const char *name, void *data); extern void *storage_get(list_t *list, const char *group, const char *name); diff --git a/src/client/client.c b/src/client/client.c index 054b3ea..06f8c18 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -44,12 +44,6 @@ static int traffic_down; static int traffic_up; #endif /* SUPPORT_TRAFFIC */ -typedef struct proto_cmd_client_struct { - char *name; - int len; - void (*fce_proto) (char *msg); -} proto_cmd_client_t; - static proto_cmd_client_t proto_cmd_list[] = { {.name = "error",.len = 5,.fce_proto = proto_recv_error_client}, {.name = "init",.len = 4,.fce_proto = proto_recv_init_client}, @@ -130,7 +124,7 @@ int client_init(char *ip, int port) return 0; } -static void errorWithServer() +static void errorWithServer(void) { error("Game server is not responding"); analyze_set_msg(_("Unable to connect to the game server")); @@ -163,7 +157,7 @@ void client_send(char *msg) } } -static int server_eventSelect() +static int server_eventSelect(void) { char buffer[STR_PROTO_SIZE]; int ret; @@ -189,7 +183,7 @@ static int server_eventSelect() return ret; } -static void client_eventWorkRecvList() +static void client_eventWorkRecvList(void) { proto_cmd_client_t *protoCmd; char *line; @@ -217,7 +211,7 @@ static void client_eventWorkRecvList() listRecvMsg = list_new(); } -static void eventPingServer() +static void eventPingServer(void) { my_time_t currentTime; @@ -229,7 +223,7 @@ static void eventPingServer() } } -static bool_t isServerAlive() +static bool_t isServerAlive(void) { my_time_t currentTime; @@ -242,7 +236,7 @@ static bool_t isServerAlive() return TRUE; } -static void selectClientSocket() +static void selectClientSocket(void) { fd_set readfds; struct timeval tv; @@ -286,7 +280,7 @@ static void selectClientSocket() } #ifdef SUPPORT_TRAFFIC -static void eventTraffic() +static void eventTraffic(void) { my_time_t currentTime; @@ -303,7 +297,7 @@ static void eventTraffic() } #endif /* SUPPORT_TRAFFIC */ -void client_event() +void client_event(void) { #ifdef SUPPORT_TRAFFIC eventTraffic(); @@ -314,7 +308,7 @@ void client_event() client_eventWorkRecvList(); } -static void quitUdpClient() +static void quitUdpClient(void) { assert(sock_server_udp != NULL); sock_udp_close(sock_server_udp); @@ -322,7 +316,7 @@ static void quitUdpClient() debug("Closing connection to game server"); } -void client_quit() +void client_quit(void) { proto_send_end_client(); diff --git a/src/client/client.h b/src/client/client.h index ce41ffb..005edef 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -8,9 +8,15 @@ #define CLIENT_BUFFER_LIMIT 4096 +typedef struct proto_cmd_client_struct { + const char *name; + int len; + void (*fce_proto) (char *msg); +} proto_cmd_client_t; + extern int client_init(char *ip, int port); extern void client_send(char *msg); -extern void client_event(); -extern void client_quit(); +extern void client_event(void); +extern void client_quit(void); #endif /* MY_CLIENT_H */ diff --git a/src/client/config.c b/src/client/config.c index 130fcdf..e11c03c 100644 --- a/src/client/config.c +++ b/src/client/config.c @@ -10,18 +10,6 @@ #include "configFile.h" #include "config.h" -typedef struct setting_int_struct { - int key; /* identification key */ - char *param; /* parameter of the program */ - char *var; /* variable in the config file */ - int type; /* type of the data - string/number */ - int value_int; /* numeric data */ - char *value_str; /* textual data */ -} config_t; - -#define CONFIG_TYPE_INT 1 -#define CONFIG_TYPE_STR 2 - static config_t config_list[] = { { .key=CFG_NAME_RIGHT, .var="NAME_PLAYER_RIGHT", .param="--name-right", .type=CONFIG_TYPE_STR, .value_str="name1" }, @@ -66,7 +54,7 @@ static config_t *find_config(int key) return NULL; } -static void check_param() +static void check_param(void) { int i; @@ -80,7 +68,7 @@ static void check_param() config_list[i].value_int = atoi(str); } else { if (config_list[i].value_str != NULL) { - free(config_list[i].value_str); + free((char*)config_list[i].value_str); } config_list[i].value_str = strdup(str); @@ -89,7 +77,7 @@ static void check_param() } } -int config_init() +int config_init(void) { config_load(); check_param(); @@ -97,7 +85,7 @@ int config_init() return 0; } -void config_load() +void config_load(void) { char path[STR_PATH_SIZE]; char val[STR_SIZE]; @@ -133,7 +121,7 @@ void config_load() } } -void config_save() +void config_save(void) { int i; @@ -167,7 +155,7 @@ int config_get_int_value(int key) return tmp->value_int; } -char *config_get_str_value(int key) +const char *config_get_str_value(int key) { config_t *tmp; @@ -191,7 +179,7 @@ void config_set_int_value(int key, int n) tmp->value_int = n; } -void config_set_str_value(int key, char *str) +void config_set_str_value(int key, const char *str) { config_t *tmp; @@ -201,13 +189,13 @@ void config_set_str_value(int key, char *str) assert(tmp->type == CONFIG_TYPE_STR); if (tmp->value_str != NULL) { - free(tmp->value_str); /* has to be allocated */ + free((char*)tmp->value_str); /* has to be allocated */ } tmp->value_str = strdup(str); } -int config_quit() +int config_quit(void) { int i; @@ -219,7 +207,7 @@ int config_quit() for (i = 0; i < CONFIG_LIST_COUNT; i++) { if (config_list[i].type == CONFIG_TYPE_STR && config_list[i].value_str != NULL) { - free(config_list[i].value_str); + free((char*)config_list[i].value_str); } } diff --git a/src/client/config.h b/src/client/config.h index 46e0da5..2d67c42 100644 --- a/src/client/config.h +++ b/src/client/config.h @@ -30,13 +30,25 @@ #define CONFIG_LIST_COUNT 22 -extern int config_init(); -extern void config_load(); -extern void config_save(); +#define CONFIG_TYPE_INT 1 +#define CONFIG_TYPE_STR 2 + +typedef struct setting_int_struct { + int key; /* identification key */ + const char *param; /* parameter of the program */ + const char *var; /* variable in the config file */ + int type; /* type of the data - string/number */ + int value_int; /* numeric data */ + const char *value_str; /* textual data */ +} config_t; + +extern int config_init(void); +extern void config_load(void); +extern void config_save(void); extern int config_get_int_value(int key); -extern char *config_get_str_value(int key); +extern const char *config_get_str_value(int key); extern void config_set_int_value(int key, int n); -extern void config_set_str_value(int key, char *str); -extern int config_quit(); +extern void config_set_str_value(int key, const char *str); +extern int config_quit(void); #endif /* CONFIG_H */ diff --git a/src/client/configFile.c b/src/client/configFile.c index 5edc70a..6b0b01c 100644 --- a/src/client/configFile.c +++ b/src/client/configFile.c @@ -15,7 +15,7 @@ int isYesOrNO(char *s) } } -int getValue(char *line, char *env, char *val, int len) +int getValue(const char *line, const char *env, const char *val, int len) { char *offset_env; char *offset_val_begin; @@ -49,13 +49,13 @@ int getValue(char *line, char *env, char *val, int len) val_len = len - 1; } - memset(val, 0, len); - memcpy(val, offset_val_begin + 1, val_len); + memset((char*)val, 0, len); + memcpy((char*)val, offset_val_begin + 1, val_len); return 0; } -char *setValue(char *line, char *env, char *val) +char *setValue(const char *line, const char *env, const char *val) { char *offset_env; char *offset_val_begin; @@ -92,7 +92,7 @@ char *setValue(char *line, char *env, char *val) return strdup(clone); } -int getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len) +int getValueInConfigFile(textFile_t * textFile, const char *env, const char *val, int len) { int i; char *line; @@ -108,7 +108,7 @@ int getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len) return -1; } -int setValueInConfigFile(textFile_t * textFile, char *env, char *val) +int setValueInConfigFile(textFile_t * textFile, const char *env, const char *val) { int i; char *line; @@ -132,13 +132,12 @@ int setValueInConfigFile(textFile_t * textFile, char *env, char *val) return -1; } -void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len, char *butVal) +void loadValueFromConfigFile(textFile_t * textFile, const char *env, const char *val, int len, const char *butVal) { - strcpy(val, butVal); + char line[STR_SIZE] = ""; + strcpy((char*)val, butVal); if (getValueInConfigFile(textFile, env, val, len) != 0) { - char line[STR_SIZE]; - sprintf(line, "%s=\"%s\"", env, butVal); list_add(textFile->text, strdup(line)); diff --git a/src/client/configFile.h b/src/client/configFile.h index d056e90..f926cfc 100644 --- a/src/client/configFile.h +++ b/src/client/configFile.h @@ -6,13 +6,13 @@ extern int isYesOrNO(char *s); -extern int getValue(char *line, char *env, char *val, int len); -extern char *setValue(char *line, char *env, char *val); +extern int getValue(const char *line, const char *env, const char *val, int len); +extern char *setValue(const char *line, const char *env, const char *val); -extern int getValueInConfigFile(textFile_t *textFile, char *env, char *val, int len); -extern int setValueInConfigFile(textFile_t *textFile, char *env, char *val); +extern int getValueInConfigFile(textFile_t *textFile, const char *env, const char *val, int len); +extern int setValueInConfigFile(textFile_t *textFile, const char *env, const char *val); -extern void loadValueFromConfigFile(textFile_t *textFile, char *env, char *val, - int len, char *butVal); +extern void loadValueFromConfigFile(textFile_t *textFile, const char *env, const char *val, + int len, const char *butVal); #endif /* CONFIGFILE_H */ diff --git a/src/client/font.c b/src/client/font.c index 1741d46..a4b3283 100644 --- a/src/client/font.c +++ b/src/client/font.c @@ -118,7 +118,7 @@ int font_get_size(void) return fontSize; } -void font_text_size(char *s, int *w, int *h) +void font_text_size(const char *s, int *w, int *h) { assert(s != NULL); assert(w != NULL); diff --git a/src/client/font.h b/src/client/font.h index d7e7704..fb3c250 100644 --- a/src/client/font.h +++ b/src/client/font.h @@ -21,7 +21,7 @@ extern void font_draw(const char *s, int x, int y, int r, int g, int b); extern void font_drawMaxSize(const char *s, int x, int y, int w, int h, int r, int g, int b); extern int font_get_size(void); -extern void font_text_size(char *s, int *w, int *h); +extern void font_text_size(const char *s, int *w, int *h); extern void font_quit(void); #endif /* FONT_H */ diff --git a/src/client/mouse_buffer.c b/src/client/mouse_buffer.c index 5d27f21..0cb0027 100644 --- a/src/client/mouse_buffer.c +++ b/src/client/mouse_buffer.c @@ -4,18 +4,11 @@ #include #include -#include "main.h" #include "list.h" #include "mouse_buffer.h" static list_t *list_event; -typedef struct mouse_event_struct { - Uint8 button; - int x; - int y; -} mouse_event_t; - static mouse_event_t *mouse_event_new(int x, int y, Uint8 button) { mouse_event_t *mouse_event; diff --git a/src/client/mouse_buffer.h b/src/client/mouse_buffer.h index 327e5df..601e539 100644 --- a/src/client/mouse_buffer.h +++ b/src/client/mouse_buffer.h @@ -9,6 +9,12 @@ #define MOUSE_BUF_CLICK 8 #define MOUSE_BUF_AREA_NONE 16 +typedef struct mouse_event_struct { + Uint8 button; + int x; + int y; +} mouse_event_t; + extern int mouse_buffer_init(void); extern int mouse_buffer_event(SDL_MouseButtonEvent *button); extern int mouse_buffer_clean(void); diff --git a/src/client/pauza.c b/src/client/pauza.c index 61f80ea..833f984 100644 --- a/src/client/pauza.c +++ b/src/client/pauza.c @@ -14,7 +14,7 @@ static image_t *g_pauza; static bool_t activePauza; -static void switchPauzed() +static void switchPauzed(void) { if (activePauza == TRUE) { activePauza = FALSE; @@ -23,12 +23,12 @@ static void switchPauzed() } } -static void hotkey_pauze() +static void hotkey_pauze(void) { switchPauzed(); } -void pauza_init() +void pauza_init(void) { g_pauza = image_add("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER); activePauza = FALSE; @@ -36,7 +36,7 @@ void pauza_init() hot_key_register(SDLK_p, hotkey_pauze); } -void pauza_draw() +void pauza_draw(void) { if (activePauza) { image_draw(g_pauza, @@ -46,16 +46,16 @@ void pauza_draw() } } -void pauza_event() +void pauza_event(void) { } -bool_t pauza_is_active() +bool_t pauza_is_active(void) { return activePauza; } -void pauza_quit() +void pauza_quit(void) { hot_key_unregister(SDLK_p); } diff --git a/src/client/pauza.h b/src/client/pauza.h index a432d5f..63e6a8a 100644 --- a/src/client/pauza.h +++ b/src/client/pauza.h @@ -5,10 +5,10 @@ #define PAUZE_ACTIVE_TIME_INTERVAL 1000 -extern void pauza_init(); -extern void pauza_draw(); -extern void pauza_event(); -extern bool_t pauza_is_active(); -extern void pauza_quit(); +extern void pauza_init(void); +extern void pauza_draw(void); +extern void pauza_event(void); +extern bool_t pauza_is_active(void); +extern void pauza_quit(void); #endif /* PAUZA_H */ diff --git a/src/client/radar.c b/src/client/radar.c index 4c7a4ab..858020c 100644 --- a/src/client/radar.c +++ b/src/client/radar.c @@ -2,11 +2,8 @@ #include #include -#include "main.h" #include "list.h" -#include "tux.h" #include "arena.h" - #include "interface.h" #include "image.h" #include "radar.h" @@ -14,12 +11,6 @@ static image_t *g_radar; static list_t *listRadar; -typedef struct radar_item_struct { - int id; - int x, y; - int type; -} radar_item_t; - static radar_item_t *newRadarItem(int id, int x, int y, int type) { radar_item_t *new; diff --git a/src/client/radar.h b/src/client/radar.h index 528d0da..c2b3167 100644 --- a/src/client/radar.h +++ b/src/client/radar.h @@ -13,6 +13,12 @@ #define RADAR_TYPE_TUX 1 #define RADAR_TYPE_ITEM 2 +typedef struct radar_item_struct { + int id; + int x, y; + int type; +} radar_item_t; + extern void radar_init(void); extern void radar_add(int id, int x, int y, int type); extern void radar_del(int id); diff --git a/src/client/term.c b/src/client/term.c index dc4a51b..2518bbe 100644 --- a/src/client/term.c +++ b/src/client/term.c @@ -17,7 +17,7 @@ static bool_t activeTerm; static my_time_t lastActive; static my_time_t lastRefresh; -void term_init() +void term_init(void) { listText = list_new(); @@ -26,7 +26,7 @@ void term_init() lastRefresh = lastActive; } -static char *getStrGun(int gun) +static const char *getStrGun(int gun) { switch (gun) { case GUN_SIMPLE: @@ -46,11 +46,9 @@ static char *getStrGun(int gun) default: return "none"; } - - return "gun_unknown"; } -static char *getStrBonus(int bonus) +static const char *getStrBonus(int bonus) { switch (bonus) { case BONUS_SPEED: @@ -68,8 +66,6 @@ static char *getStrBonus(int bonus) default: return "none"; } - - return "bonus_unknown"; } static void action_refreshTerm(space_t *space, tux_t *tux, void *p) @@ -89,7 +85,7 @@ static void action_refreshTerm(space_t *space, tux_t *tux, void *p) list_add(listText, strdup(str)); } -static void refreshTerm() +static void refreshTerm(void) { arena_t *arena; @@ -103,7 +99,7 @@ static void refreshTerm() /*printf("refresh term..\n");*/ } -void term_draw() +void term_draw(void) { int i; @@ -119,7 +115,7 @@ void term_draw() } } -static void switchTerm() +static void switchTerm(void) { if (activeTerm == TRUE) { activeTerm = FALSE; @@ -128,7 +124,7 @@ static void switchTerm() } } -void term_event() +void term_event(void) { my_time_t currentTime; Uint8 *mapa; @@ -150,7 +146,7 @@ void term_event() } } -void term_quit() +void term_quit(void) { assert(listText != NULL); list_destroy_item(listText, free); diff --git a/src/client/term.h b/src/client/term.h index 719df2d..2b80c2a 100644 --- a/src/client/term.h +++ b/src/client/term.h @@ -6,9 +6,9 @@ #define TERM_ACTIVE_TIME_INTERVAL 500 #define TERM_REFRESH_TIME_INTERVAL 1000 -extern void term_init(); -extern void term_draw(); -extern void term_event(); -extern void term_quit(); +extern void term_init(void); +extern void term_draw(void); +extern void term_event(void); +extern void term_quit(void); #endif /* TERM_H */ diff --git a/src/client/yes_no_dialog.c b/src/client/yes_no_dialog.c index d982933..8943487 100644 --- a/src/client/yes_no_dialog.c +++ b/src/client/yes_no_dialog.c @@ -43,7 +43,7 @@ static void eventWidget(void *p) } } -void yes_no_dialog_init() +void yes_no_dialog_init(void) { active_dialog = FALSE; @@ -63,7 +63,7 @@ void yes_no_dialog_init() eventWidget); } -static void hotkey_escape() +static void hotkey_escape(void) { yes_no_dialog_set_active(FALSE); handle_no(param); @@ -80,12 +80,12 @@ void yes_no_dialog_set_active(bool_t active) } } -bool_t yes_no_dialog_is_active() +bool_t yes_no_dialog_is_active(void) { return active_dialog; } -void yes_no_dialog_set(char *label, void *function_yes, void *function_no, void *p_param) +void yes_no_dialog_set(const char *label, void *function_yes, void *function_no, void *p_param) { label_destroy(widgetLabelMsg); @@ -98,7 +98,7 @@ void yes_no_dialog_set(char *label, void *function_yes, void *function_no, void param = p_param; } -void yes_no_dialog_draw() +void yes_no_dialog_draw(void) { if (active_dialog == FALSE) { return; @@ -116,7 +116,7 @@ void yes_no_dialog_draw() button_draw(widgetButtonNo); } -void yes_no_dialog_event() +void yes_no_dialog_event(void) { if (active_dialog == FALSE) { return; @@ -126,7 +126,7 @@ void yes_no_dialog_event() button_event(widgetButtonNo); } -void yes_no_dialog_quit() +void yes_no_dialog_quit(void) { label_destroy(widgetLabelMsg); button_destroy(widgetButtonYes); diff --git a/src/client/yes_no_dialog.h b/src/client/yes_no_dialog.h index 3cef74c..b1c8f9f 100644 --- a/src/client/yes_no_dialog.h +++ b/src/client/yes_no_dialog.h @@ -9,12 +9,12 @@ #define YES_NO_DIALOG_LOCATIN_X (WINDOW_SIZE_X / 2 - YES_NO_DIALOG_SIZE_X / 2) #define YES_NO_DIALOG_LOCATIN_Y (WINDOW_SIZE_Y / 2 - YES_NO_DIALOG_SIZE_Y / 2) -extern void yes_no_dialog_init(); +extern void yes_no_dialog_init(void); extern void yes_no_dialog_set_active(bool_t active); -extern bool_t yes_no_dialog_is_active(); -extern void yes_no_dialog_set(char *label, void *function_yes, void *function_no, void *p_param); -extern void yes_no_dialog_draw(); -extern void yes_no_dialog_event(); -extern void yes_no_dialog_quit(); +extern bool_t yes_no_dialog_is_active(void); +extern void yes_no_dialog_set(const char *label, void *function_yes, void *function_no, void *p_param); +extern void yes_no_dialog_draw(void); +extern void yes_no_dialog_event(void); +extern void yes_no_dialog_quit(void); #endif /* YES_NO_DIALOG_H */ diff --git a/src/screen/analyze.c b/src/screen/analyze.c index 450da41..7a6ee48 100644 --- a/src/screen/analyze.c +++ b/src/screen/analyze.c @@ -31,7 +31,7 @@ static widget_t *widgetLabelMsg; static widget_t *button_ok; -static analyze_t *newAnalyze(char *name, int score) +static analyze_t *newAnalyze(const char *name, int score) { analyze_t *new; @@ -48,12 +48,12 @@ static void destroyAnalyze(analyze_t *p) free(p); } -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("mainMenu"); } -void analyze_start() +void analyze_start(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -62,7 +62,7 @@ void analyze_start() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void analyze_draw() +void analyze_draw(void) { widget_t *this; int i; @@ -83,12 +83,12 @@ void analyze_draw() button_draw(button_ok); } -void analyze_event() +void analyze_event(void) { button_event(button_ok); } -void analyze_stop() +void analyze_stop(void) { label_destroy(widgetLabelMsg); widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); @@ -107,7 +107,7 @@ static void eventWidget(void *p) } } -void analyze_restart() +void analyze_restart(void) { list_destroy_item(listWidgetLabelName, label_destroy); list_destroy_item(listWidgetLabelScore, label_destroy); @@ -118,18 +118,18 @@ void analyze_restart() listAnalyze = list_new(); } -void analyze_add(char *name, int score) +void analyze_add(const char *name, int score) { list_add(listAnalyze, newAnalyze(name, score)); } -void analyze_set_msg(char *msg) +void analyze_set_msg(const char *msg) { label_destroy(widgetLabelMsg); widgetLabelMsg = label_new(msg, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } -void analyze_end() +void analyze_end(void) { int i; @@ -153,7 +153,7 @@ void analyze_end() } } -void analyze_init() +void analyze_init(void) { image_t *image; @@ -173,7 +173,7 @@ void analyze_init() widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } -void analyze_quit() +void analyze_quit(void) { wid_image_destroy(image_backgorund); diff --git a/src/screen/analyze.h b/src/screen/analyze.h index 2fc2b7b..b2fd3bf 100644 --- a/src/screen/analyze.h +++ b/src/screen/analyze.h @@ -8,15 +8,15 @@ typedef struct analyze_struct { int score; } analyze_t; -extern void analyze_start(); -extern void analyze_draw(); -extern void analyze_event(); -extern void analyze_stop(); -extern void analyze_restart(); -extern void analyze_add(char *name, int score); -extern void analyze_set_msg(char *msg); -extern void analyze_end(); -extern void analyze_init(); -extern void analyze_quit(); +extern void analyze_start(void); +extern void analyze_draw(void); +extern void analyze_event(void); +extern void analyze_stop(void); +extern void analyze_restart(void); +extern void analyze_add(const char *name, int score); +extern void analyze_set_msg(const char *msg); +extern void analyze_end(void); +extern void analyze_init(void); +extern void analyze_quit(void); #endif /* SCREEN_ANALYZE_H */ diff --git a/src/screen/browser.c b/src/screen/browser.c index c826ce2..36f557b 100644 --- a/src/screen/browser.c +++ b/src/screen/browser.c @@ -32,8 +32,6 @@ #include "udp.h" #include "dns.h" -extern int errno; - #ifndef NO_SOUND #include "music.h" #endif /* NO_SOUND */ @@ -68,17 +66,17 @@ static widget_t *select_server; static server_t server_list; /* function prototypes */ -static int LoadServers(); -static int RefreshServers(); -static server_t *server_getcurr(); -static void clear_server_list(); +static int LoadServers(void); +static int RefreshServers(void); +static server_t *server_getcurr(void); +static void clear_server_list(void); -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("gameType"); } -void browser_start() +void browser_start(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -89,7 +87,7 @@ void browser_start() LoadServers(); } -void browser_draw() +void browser_draw(void) { wid_image_draw(image_backgorund); @@ -108,7 +106,7 @@ void browser_draw() button_draw(button_reload); } -void browser_event() +void browser_event(void) { select_event(select_server); @@ -118,7 +116,7 @@ void browser_event() button_event(button_reload); } -void browser_stop() +void browser_stop(void) { select_remove_all(select_server); @@ -130,6 +128,8 @@ void browser_stop() static void eventWidget(void *p) { widget_t *button; + struct in_addr srv; + char *address; button = (widget_t *) p; @@ -145,10 +145,9 @@ static void eventWidget(void *p) return; } - struct in_addr srv; srv.s_addr = server->ip; - char *address = (char *) inet_ntoa(srv); + address = (char *) inet_ntoa(srv); setSettingGameType(NET_GAME_TYPE_CLIENT); game_type_set_ip(address); @@ -170,7 +169,7 @@ static void eventWidget(void *p) } } -server_t *server_getcurr() +server_t *server_getcurr(void) { int i = 0; server_t *server; @@ -186,22 +185,35 @@ server_t *server_getcurr() return 0; } -int server_getinfo(server_t *server) +static int server_getinfo(server_t *server) { struct sockaddr_in srv; - int mySocket; + struct timeval tv; + fd_set myset; + int mySocket, ret, r, sel; + char request[8]; + char *str; + int i = 0; + unsigned name = 0; + int len = 0; + unsigned name_len, ver_len, arena_len; +#ifndef __WIN32__ + int oldFlag; +#else /* __WIN32__ */ + unsigned long arg; +#endif /* __WIN32__ */ if ((mySocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { return -1; } #ifndef __WIN32__ /* let's make the socket non-blocking */ - int oldFlag = fcntl(mySocket, F_GETFL, 0); + oldFlag = fcntl(mySocket, F_GETFL, 0); if (fcntl(mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) { return -1; } #else /* __WIN32__ */ - unsigned long arg = 1; + arg = 1; /* Operation is FIONBIO. Parameter is pointer on non-zero number */ if (ioctlsocket(mySocket, FIONBIO, &arg) == SOCKET_ERROR) { WSACleanup(); @@ -209,9 +221,6 @@ int server_getinfo(server_t *server) } #endif /* __WIN32__ */ - struct timeval tv; - - fd_set myset; FD_ZERO(&myset); FD_SET(mySocket, &myset); @@ -235,7 +244,7 @@ int server_getinfo(server_t *server) #endif /* __WIN32__ */ } - int ret = select(mySocket + 1, NULL, &myset, NULL, &tv); + ret = select(mySocket + 1, NULL, &myset, NULL, &tv); if (ret == -1) { return 0; @@ -245,10 +254,9 @@ int server_getinfo(server_t *server) return -2; } - char request[8]; memcpy(request, "status\n", 7); - int r = send(mySocket, request, 7, 0); + r = send(mySocket, request, 7, 0); if (r == -1) { return -2; @@ -259,14 +267,14 @@ int server_getinfo(server_t *server) tv.tv_sec = 1; tv.tv_usec = 0; - char *str = (char *) malloc(sizeof(char) * 257); + str = (char *) malloc(sizeof(char) * 257); if (!str) { return -1; } while (1) { - int sel = select(mySocket + 1, &myset, NULL, NULL, &tv); + sel = select(mySocket + 1, &myset, NULL, NULL, &tv); if (sel == 0) { free(str); @@ -322,8 +330,6 @@ int server_getinfo(server_t *server) "uptime: D\n" */ - int i = 0; - while (i < ret) { if (str[i] == '\n') { str[i] = '\0'; @@ -332,19 +338,16 @@ int server_getinfo(server_t *server) i++; } - unsigned name = 0; - /* get server's name */ if (strstr(str, "name: ")) { name = 1; } - int len = 0; if (name) { len = strlen(str); if (!strncmp(str, "name: ", 6)) { - unsigned name_len = strlen(str + 6); + name_len = strlen(str + 6); server->name = (char *) malloc(sizeof(char) * (name_len + 2)); if (!server->name) { @@ -363,7 +366,7 @@ int server_getinfo(server_t *server) /* get server's version */ if (!strncmp(str + len + 1, "version: ", 9)) { - unsigned ver_len = strlen(str + len + 10); + ver_len = strlen(str + len + 10); server->version = (char *) malloc(sizeof(char) * (ver_len + 2)); if (!server->version) { @@ -399,7 +402,7 @@ int server_getinfo(server_t *server) /* get server's arena */ if (!strncmp(str + len + 1, "arena: ", 7)) { - unsigned arena_len = strlen(str + len + 9); + arena_len = strlen(str + len + 9); server->arena = (char *) malloc(sizeof(char) * (arena_len + 2)); if (!server->arena) { @@ -421,24 +424,36 @@ int server_getinfo(server_t *server) /* * Get server list */ -static int LoadServers() +static int LoadServers(void) { #ifndef __WIN32__ - int s; + int s, oldFlag; #else /* __WIN32__ */ SOCKET s; + unsigned long arg; #endif /* __WIN32__ */ - char buf[1025]; + /* TODO: TCP macro */ + struct sockaddr_in server; + struct timeval tv; + struct in_addr srv; + fd_set myset; + int ret, len; + int i = 0; + char list[256]; + char *master_server_ip; + char *address; + unsigned a_len; + + typedef struct { + unsigned port; + unsigned ip; + } response_head; /* first of all ensure the server list is empty */ clear_server_list(); select_remove_all(select_server); - /* TODO: TCP macro */ - struct sockaddr_in server; - char *master_server_ip; - master_server_ip = dns_resolv(NET_MASTER_SERVER_DOMAIN); if (master_server_ip == NULL) { @@ -459,12 +474,12 @@ static int LoadServers() /* Set to nonblocking socket mode */ #ifndef __WIN32__ - int oldFlag = fcntl(s, F_GETFL, 0); + oldFlag = fcntl(s, F_GETFL, 0); if (fcntl(s, F_SETFL, oldFlag | O_NONBLOCK) == -1) { return -1; } #else /* __WIN32__ */ - unsigned long arg = 1; + arg = 1; /* Operation is FIONBIO. Parameter is pointer on non-zero number. */ if (ioctlsocket(s, FIONBIO, &arg) == SOCKET_ERROR) { WSACleanup(); @@ -485,17 +500,13 @@ static int LoadServers() #endif /* __WIN32__ */ } - struct timeval tv; - - fd_set myset; - FD_ZERO(&myset); FD_SET(s, &myset); tv.tv_sec = 3; tv.tv_usec = 0; - int ret = select(s + 1, NULL, &myset, NULL, &tv); + ret = select(s + 1, NULL, &myset, NULL, &tv); if (ret == -1) { return 0; @@ -517,7 +528,7 @@ static int LoadServers() return -2; } - int len = recv(s, buf, 1024, 0); + len = recv(s, buf, 1024, 0); #ifndef __WIN32__ close(s); @@ -530,16 +541,6 @@ static int LoadServers() return 0; } - int i = 0; - char list[256]; - - struct in_addr srv; - - typedef struct { - unsigned port; - unsigned ip; - } response_head; - for (;;) { response_head *header = (response_head *) ((char *) buf + i); @@ -558,15 +559,12 @@ static int LoadServers() srv.s_addr = ctx->ip; - char *address = (char *) inet_ntoa(srv); + address = (char *) inet_ntoa(srv); memset(list, ' ', 254); list[255] = '\0'; if (ret == 1) { - /*sprintf (list, "%s (%s) - %s:%d - %s - %d/%d - %dms", ctx->name ? ctx->name : "Unknown", ctx->version, address, ctx->port, - ctx->arena ? ctx->arena : "Unknown", ctx->clients, ctx->maxclients, ctx->ping); */ - if (ctx->name) { memcpy(list, ctx->name, strlen(ctx->name)); } else { @@ -575,7 +573,7 @@ static int LoadServers() memcpy(list + 30, ctx->version, strlen(ctx->version)); - unsigned a_len = strlen(address); + a_len = strlen(address); memcpy(list + 38, address, a_len); memcpy(list + 38 + a_len, ":", 1); @@ -612,13 +610,18 @@ static int LoadServers() return 1; } -static int RefreshServers() +static int RefreshServers(void) { - select_remove_all(select_server); - struct in_addr srv; - server_t *server; + char list[256]; + char buf[32]; + char *address; + int ret; + unsigned a_len; + + select_remove_all(select_server); + for (server = server_list.next; server != &server_list; server = server->next) { if (server->name) { free(server->name); @@ -636,14 +639,13 @@ static int RefreshServers() server->version = 0; server->arena = 0; - char list[256]; - char buf[32]; - int ret = server_getinfo(server); + + ret = server_getinfo(server); srv.s_addr = server->ip; - char *address = (char *) inet_ntoa(srv); + address = (char *) inet_ntoa(srv); if (ret == 1) { memset(list, ' ', 254); @@ -657,7 +659,7 @@ static int RefreshServers() memcpy(list + 30, server->version, strlen(server->version)); - unsigned a_len = strlen(address); + a_len = strlen(address); memcpy(list + 38, address, a_len); memcpy(list + 38 + a_len, ":", 1); @@ -682,7 +684,7 @@ static int RefreshServers() return 1; } -void browser_init() +void browser_init(void) { image_t *image; @@ -715,7 +717,7 @@ void browser_init() server_list.prev = &server_list; } -void browser_quit() +void browser_quit(void) { wid_image_destroy(image_backgorund); @@ -734,7 +736,7 @@ void browser_quit() select_destroy(select_server); } -static void clear_server_list() +static void clear_server_list(void) { server_t *server; diff --git a/src/screen/browser.h b/src/screen/browser.h index 76c0e42..0300c65 100644 --- a/src/screen/browser.h +++ b/src/screen/browser.h @@ -20,11 +20,11 @@ typedef struct server_context { char *arena; } server_t; -extern void browser_start(); -extern void browser_draw(); -extern void browser_event(); -extern void browser_stop(); -extern void browser_init(); -extern void browser_quit(); +extern void browser_start(void); +extern void browser_draw(void); +extern void browser_event(void); +extern void browser_stop(void); +extern void browser_init(void); +extern void browser_quit(void); #endif /* SCREEN_BROWSER_H */ diff --git a/src/screen/choiceArena.c b/src/screen/choiceArena.c index d8c1a24..238b188 100644 --- a/src/screen/choiceArena.c +++ b/src/screen/choiceArena.c @@ -34,7 +34,7 @@ static widget_t *button_prev; /*static list_t *listWidgetButtonimage;*/ /* map buttons to be showed and handled - well, show_map_buttons is used instead now */ static list_t *listAllWidgetButtonimage; /* all map buttons */ static int handled_map_button_group; /* 0 - first 6 buttons, 1 - second 6 buttons, ... */ -static void activateHandledMapButtonGroup(); +static void activateHandledMapButtonGroup(void); static struct show_map_buttons { /* geez, it'd be nicer to use two lists but how the hell list_t is supposed to be used?! :-) */ @@ -45,12 +45,12 @@ static struct show_map_buttons { } show_map_buttons = { 0,0,0,0 }; static arenaFile_t *currentArena; -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("gameType"); } -void screen_startChoiceArena() +static void startScreenChoiceArena(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -59,7 +59,7 @@ void screen_startChoiceArena() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void choice_arena_draw() +void choice_arena_draw(void) { int i; @@ -75,7 +75,7 @@ void choice_arena_draw() } } -void choice_arena_event() +void choice_arena_event(void) { int i; @@ -89,7 +89,7 @@ void choice_arena_event() } } -void stopScreenChoiceArena() +static void stopScreenChoiceArena(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -115,7 +115,7 @@ static void button_eventImage(void *p) } } -arenaFile_t *choice_arena_get() +arenaFile_t *choice_arena_get(void) { return currentArena; } @@ -171,10 +171,12 @@ static void eventWidget(void *p) */ static void activateHandledMapButtonGroup(void) { - int min = handled_map_button_group * 6; + int min, max; + + min = handled_map_button_group * 6; min = min < 0 ? 0 : min; min = min <= arena_file_get_count() ? min : arena_file_get_count(); - int max = min + 6 <= arena_file_get_count() ? min + 6 : arena_file_get_count(); + max = min + 6 <= arena_file_get_count() ? min + 6 : arena_file_get_count(); if (min) { show_map_buttons.prev = 1; @@ -192,7 +194,7 @@ static void activateHandledMapButtonGroup(void) show_map_buttons.max = max; } -void choice_arena_init() +void choice_arena_init(void) { image_t *image; int i; @@ -212,7 +214,7 @@ void choice_arena_init() for (i = 0; i < arena_file_get_count(); i++) { widget_t *widget_buttonimage; arenaFile_t *arenaFile; - int x, y; + int x, y, pos; arenaFile = arena_file_get(i); /*image = image_add(arena_file_get_image(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);*/ @@ -225,7 +227,7 @@ void choice_arena_init() handled_map_button_group and activateHandledMapButtonGroup is used to choose group to be shown and handled */ - int pos = i % 6 ; + pos = i % 6 ; x = 100 + 200 * (pos - 3 * (pos / 3)); y = 150 + 200 * (pos / 3); @@ -240,14 +242,14 @@ void choice_arena_init() activateHandledMapButtonGroup(); } - screen_register(screen_new("chiceArena", screen_startChoiceArena, + screen_register(screen_new("chiceArena", startScreenChoiceArena, choice_arena_event, choice_arena_draw, stopScreenChoiceArena)); choice_arena_set(arena_file_get_file_format_net_name(config_get_str_value(CFG_ARENA))); } -void choice_arena_quit() +void choice_arena_quit(void) { if (choice_arena_get() != NULL) { config_set_str_value(CFG_ARENA, arena_file_get_net_name(choice_arena_get())); diff --git a/src/screen/choiceArena.h b/src/screen/choiceArena.h index c0adacd..6ff4381 100644 --- a/src/screen/choiceArena.h +++ b/src/screen/choiceArena.h @@ -7,11 +7,11 @@ #define SCREENSHOT_ARENA_WIDTH 160 #define SCREENSHOT_ARENA_HEIGHT 107 -extern void choice_arena_draw(); -extern void choice_arena_event(); -extern arenaFile_t *choice_arena_get(); +extern void choice_arena_draw(void); +extern void choice_arena_event(void); +extern arenaFile_t *choice_arena_get(void); extern void choice_arena_set(arenaFile_t *arenaFile); -extern void choice_arena_init(); -extern void choice_arena_quit(); +extern void choice_arena_init(void); +extern void choice_arena_quit(void); #endif /* SCREEN_CHOICE_ARENA_H */ diff --git a/src/screen/credits.c b/src/screen/credits.c index cb8704e..80de00f 100644 --- a/src/screen/credits.c +++ b/src/screen/credits.c @@ -28,12 +28,12 @@ static textFile_t *textFile; static int offset; static int creditExists; -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("mainMenu"); } -void scredits_start() +void scredits_start(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -43,7 +43,7 @@ void scredits_start() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void scredits_draw() +void scredits_draw(void) { int i; @@ -70,7 +70,7 @@ void scredits_draw() } -void scredits_event() +void scredits_event(void) { button_event(button_back); @@ -83,7 +83,7 @@ void scredits_event() /*printf("offset = %d\n", offset);*/ } -void scredits_stop() +void scredits_stop(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -99,9 +99,12 @@ static void eventWidget(void *p) } } -void scredits_init() +void scredits_init(void) { + widget_t *label; image_t *image; + char line[STR_SIZE]; + char *linepoint; int i; image = image_get(IMAGE_GROUP_BASE, "screen_main"); @@ -117,12 +120,9 @@ void scredits_init() textFile = text_file_load(PATH_DOC SCREEN_CREDITS_FILE); for (i = 0; i < textFile->text->count; i++) { - widget_t *label; - char *line; + linepoint = (char *) textFile->text->list[i]; - line = (char *) textFile->text->list[i]; - - label = label_new(line, WINDOW_SIZE_X / 3 - WINDOW_SIZE_X / 4, + label = label_new(linepoint, WINDOW_SIZE_X / 3 - WINDOW_SIZE_X / 4, (WINDOW_SIZE_Y - 100) + i * 20, WIDGET_LABEL_LEFT); @@ -131,8 +131,6 @@ void scredits_init() } else { for (i = 0; i < 5; i++) { creditExists = 0; - widget_t *label; - char line[STR_SIZE]; sprintf(line, _("[Error] Credits file not found [%s]: %s\n"), PATH_DOC, SCREEN_CREDITS_FILE); @@ -149,7 +147,7 @@ void scredits_init() scredits_draw, scredits_stop)); } -void scredits_quit() +void scredits_quit(void) { wid_image_destroy(image_backgorund); diff --git a/src/screen/credits.h b/src/screen/credits.h index 827b9c1..3069415 100644 --- a/src/screen/credits.h +++ b/src/screen/credits.h @@ -8,11 +8,11 @@ #define SCREEN_CREDITS_OFFSET_RESTART -1000 #define SCREEN_CREDITS_OFFSET_SPEED 2 -extern void scredits_start(); -extern void scredits_draw(); -extern void scredits_event(); -extern void scredits_stop(); -extern void scredits_init(); -extern void scredits_quit(); +extern void scredits_start(void); +extern void scredits_draw(void); +extern void scredits_event(void); +extern void scredits_stop(void); +extern void scredits_init(void); +extern void scredits_quit(void); #endif /* SCREEN_CREDITS_H */ diff --git a/src/screen/downArena.c b/src/screen/downArena.c index ac211a9..7586738 100644 --- a/src/screen/downArena.c +++ b/src/screen/downArena.c @@ -56,7 +56,7 @@ static void setStatusString(char *s) label_status = label_new(s, WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); } -static void connectToDownServer() +static void connectToDownServer(void) { char status[STR_SIZE]; char msg[STR_PROTO_SIZE]; @@ -89,7 +89,7 @@ static void connectToDownServer() setStatusString(status); } -static void closeConnectFromDownServer() +static void closeConnectFromDownServer(void) { sock_tcp_close(sock_server_tcp); buffer_destroy(recvBuffer); @@ -99,12 +99,12 @@ static void closeConnectFromDownServer() sendBuffer = NULL; } -static void sendStatusToGameServer() +static void sendStatusToGameServer(void) { - char *msg = "status\n"; + const char *msg = "status\n"; + char status[STR_SIZE] = ""; if (countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS) { - char status[STR_SIZE]; sprintf(status, _("Error! Game server [%s]:%d is off"), public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); @@ -116,14 +116,13 @@ static void sendStatusToGameServer() printf("countSendMsg = %d\n", countSendMsg++); if (sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) { - char status[STR_SIZE]; sprintf(status, _("Error! Unable to send message to [%s]:%d game server"), public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); } } -void down_arena_start() +void down_arena_start(void) { char status[STR_SIZE]; @@ -148,7 +147,7 @@ void down_arena_start() sendStatusToGameServer(); } -void down_arena_draw() +void down_arena_draw(void) { wid_image_draw(image_backgorund); label_draw(label_status); @@ -184,7 +183,7 @@ static void eventProto(char *line) } } -static int downArenaFile() +static int downArenaFile(void) { char status[STR_SIZE]; void *data; @@ -203,7 +202,7 @@ static int downArenaFile() return len; } -static int eventRecvBuffer() +static int eventRecvBuffer(void) { char buffer[STR_PROTO_SIZE]; char line[STR_PROTO_SIZE]; @@ -238,7 +237,7 @@ static int eventRecvBuffer() return -1; } -static int eventSendBuffer() +static int eventSendBuffer(void) { void *data; int len; @@ -262,7 +261,7 @@ static int eventSendBuffer() return res; } -static void readArenaFromStatus() +static void readArenaFromStatus(void) { const char *str_arena = "arena: "; @@ -292,19 +291,18 @@ static void readArenaFromStatus() } } -static void eventStatus() +static void eventStatus(void) { if (timer_get_current_time() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT) { sendStatusToGameServer(); } if (sock_udp_read(sock_server_udp, sock_server_udp, str_status, STR_PROTO_SIZE - 1) > 0) { - /*printf("str_status = %s\n", str_status);*/ readArenaFromStatus(); } } -void down_arena_event() +void down_arena_event(void) { int i; @@ -335,7 +333,7 @@ void down_arena_event() button_event(button_back); } -void down_arena_stop() +void down_arena_stop(void) { if (file != NULL) { unlink(path); @@ -362,7 +360,7 @@ static void eventWidget(void *p) } } -void down_arena_init() +void down_arena_init(void) { image_t *image; @@ -378,7 +376,7 @@ void down_arena_init() down_arena_draw, down_arena_stop)); } -void down_arena_quit() +void down_arena_quit(void) { wid_image_destroy(image_backgorund); button_destroy(button_back); diff --git a/src/screen/downArena.h b/src/screen/downArena.h index 444210c..0063593 100644 --- a/src/screen/downArena.h +++ b/src/screen/downArena.h @@ -10,11 +10,11 @@ #define DOWN_ARENA_MAX_TIEMOUT_LIMIT 500 #define DOWN_ARENA_COUNT_READ_SOCKET 100 -extern void down_arena_start(); -extern void down_arena_draw(); -extern void down_arena_event(); -extern void down_arena_stop(); -extern void down_arena_init(); -extern void down_arena_quit(); +extern void down_arena_start(void); +extern void down_arena_draw(void); +extern void down_arena_event(void); +extern void down_arena_stop(void); +extern void down_arena_init(void); +extern void down_arena_quit(void); #endif /* SCREEN_DOWN_ARENA_H */ diff --git a/src/screen/gameType.c b/src/screen/gameType.c index e173ab2..7882f11 100644 --- a/src/screen/gameType.c +++ b/src/screen/gameType.c @@ -83,30 +83,23 @@ static void loadSession(widget_t *p) director_destroy(director); } -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("mainMenu"); } -void screen_startGameType() +static void startScreenGameType(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); #endif /* NO_SOUND */ -/* - choiceGroup_set_status(check_none, TRUE); - choiceGroup_set_status(check_server, FALSE); - choiceGroup_set_status(check_client, FALSE); - choiceGroup_set_status(check_load_session, FALSE); -*/ - loadSession(selectSession); hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void game_type_draw() +void game_type_draw(void) { int i; @@ -135,12 +128,6 @@ void game_type_draw() label_draw(label_session); select_draw(selectSession); } -/* - if (check_server->status == TRUE) { - game_type_set_ip(getParamElse("--ip", "127.0.0.1")); - game_type_set_port(atoi(getParamElse("--port", "2200"))); - } -*/ if (choice_group_get_status(check_client) == TRUE) { button_draw(button_browser); @@ -150,7 +137,7 @@ void game_type_draw() button_draw(button_play); } -void game_type_event() +void game_type_event(void) { int i; @@ -178,7 +165,7 @@ void game_type_event() } } -void stopScreenGameType() +static void stopScreenGameType(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -219,7 +206,7 @@ static void eventWidget(void *p) } } -void game_type_init() +void game_type_init(void) { image_t *image; @@ -264,7 +251,7 @@ void game_type_init() selectSession = select_new(300, 185, eventWidget); - screen_register(screen_new("gameType", screen_startGameType, game_type_event, + screen_register(screen_new("gameType", startScreenGameType, game_type_event, game_type_draw, stopScreenGameType)); } @@ -288,7 +275,7 @@ int setSettingGameType(int status) return -1; } -int public_server_get_settingGameType() +int public_server_get_settingGameType(void) { if (choice_group_get_status(check_none) == TRUE || choice_group_get_status(check_load_session) == TRUE) { return NET_GAME_TYPE_NONE; @@ -307,7 +294,7 @@ int public_server_get_settingGameType() return -1; } -char *game_type_load_session() +char *game_type_load_session(void) { if (choice_group_get_status(check_load_session) == TRUE) { return select_get_item(selectSession); @@ -326,7 +313,7 @@ int game_type_set_ip(char *address) return 1; } -char *public_server_get_settingIP() +char *public_server_get_settingIP(void) { return text_field_get_text(textfield_ip); } @@ -341,12 +328,12 @@ int game_type_set_port(int port) return 0; } -int public_server_get_settingPort() +int public_server_get_settingPort(void) { return atoi(text_field_get_text(textfield_port)); } -int public_server_get_settingProto() +int public_server_get_settingProto(void) { if (strstr(text_field_get_text(textfield_ip), ".") != NULL) { return PROTO_UDPv4; @@ -361,7 +348,7 @@ int public_server_get_settingProto() return -1; } -static void save_config() +static void save_config(void) { if (choice_group_get_status(check_none) == TRUE) { config_set_str_value(CFG_GAME_TYPE, "none"); @@ -383,7 +370,7 @@ static void save_config() config_set_str_value(CFG_NET_PORT, text_field_get_text(textfield_port)); } -void game_type_quit() +void game_type_quit(void) { save_config(); diff --git a/src/screen/gameType.h b/src/screen/gameType.h index 49cf008..d34547e 100644 --- a/src/screen/gameType.h +++ b/src/screen/gameType.h @@ -3,17 +3,17 @@ #include "main.h" -extern void game_type_draw(); -extern void game_type_event(); -extern void game_type_init(); +extern void game_type_draw(void); +extern void game_type_event(void); +extern void game_type_init(void); extern int setSettingGameType(int status); -extern int public_server_get_settingGameType(); -extern char *game_type_load_session(); +extern int public_server_get_settingGameType(void); +extern char *game_type_load_session(void); extern int game_type_set_ip(char *address); -extern char *public_server_get_settingIP(); +extern char *public_server_get_settingIP(void); extern int game_type_set_port(int port); -extern int public_server_get_settingPort(); -extern int public_server_get_settingProto(); -extern void game_type_quit(); +extern int public_server_get_settingPort(void); +extern int public_server_get_settingProto(void); +extern void game_type_quit(void); #endif /* SCREEN_GAME_TYPE_H */ diff --git a/src/screen/mainMenu.c b/src/screen/mainMenu.c index 147ef59..e3403dd 100644 --- a/src/screen/mainMenu.c +++ b/src/screen/mainMenu.c @@ -33,12 +33,12 @@ static widget_t *button_table; static widget_t *button_credits; static widget_t *button_end; -static void hotkey_escape() +static void hotkey_escape(void) { game_quit(); } -void main_menu_start() +void main_menu_start(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -47,33 +47,19 @@ void main_menu_start() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void main_menu_draw() +void main_menu_draw(void) { wid_image_draw(image_backgorund); widget_container_draw(widget_container); -/* - button_draw(button_play); - button_draw(button_setting); - button_draw(button_table); - button_draw(button_credits); - button_draw(button_end); -*/ } -void main_menu_event() +void main_menu_event(void) { widget_container_event(widget_container); -/* - button_event(button_play); - button_event(button_setting); - button_event(button_table); - button_event(button_credits); - button_event(button_end); -*/ } -void main_menu_stop() +void main_menu_stop(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -105,7 +91,7 @@ static void eventWidget(void *p) } } -void main_menu_init() +void main_menu_init(void) { image_t *image; @@ -137,7 +123,7 @@ void main_menu_init() main_menu_draw, main_menu_stop)); } -void main_menu_quit() +void main_menu_quit(void) { wid_image_destroy(image_backgorund); diff --git a/src/screen/mainMenu.h b/src/screen/mainMenu.h index 99249b4..31c821b 100644 --- a/src/screen/mainMenu.h +++ b/src/screen/mainMenu.h @@ -3,11 +3,11 @@ #include "main.h" -extern void main_menu_start(); -extern void main_menu_draw(); -extern void main_menu_event(); -extern void main_menu_stop(); -extern void main_menu_init(); -extern void main_menu_quit(); +extern void main_menu_start(void); +extern void main_menu_draw(void); +extern void main_menu_event(void); +extern void main_menu_stop(void); +extern void main_menu_init(void); +extern void main_menu_quit(void); #endif /* SCREEN_MAIN_MENU_H */ diff --git a/src/screen/setting.c b/src/screen/setting.c index 2e1b615..f174025 100644 --- a/src/screen/setting.c +++ b/src/screen/setting.c @@ -83,12 +83,12 @@ static widget_t *check_ai; static widget_t *statusbar; -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("mainMenu"); } -void screen_startSetting() +static void startScreenSetting(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -97,7 +97,7 @@ void screen_startSetting() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void setting_draw() +void setting_draw(void) { int i; @@ -158,7 +158,7 @@ void setting_draw() button_draw(button_keys); } -void setting_event() +void setting_event(void) { int i; @@ -190,7 +190,7 @@ void setting_event() button_event(button_keys); } -void stopScreenSetting() +static void stopScreenSetting(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -222,7 +222,7 @@ static void eventWidget(void *p) #endif } -static void initSettingFile() +static void initSettingFile(void) { text_field_set_text(textfield_count_cound, get_string_static(config_get_int_value(CFG_COUNT_ROUND))); text_field_set_text(textfield_name_player1, config_get_str_value(CFG_NAME_RIGHT)); @@ -250,7 +250,7 @@ static void initSettingFile() #endif } -static void saveAndDestroyConfigFile() +static void saveAndDestroyConfigFile(void) { config_set_int_value(CFG_COUNT_ROUND, atoi(text_field_get_text(textfield_count_cound))); config_set_str_value(CFG_NAME_RIGHT, text_field_get_text(textfield_name_player1)); @@ -277,7 +277,7 @@ static void saveAndDestroyConfigFile() #endif } -void setting_init() +void setting_init(void) { image_t *image; int i; @@ -391,7 +391,7 @@ void setting_init() statusbar_add(statusbar, check[BONUS_4X], _("1 shot to 4 directions bonus")); statusbar_add(statusbar, check[BONUS_HIDDEN], _("Unvisibility bonus")); - screen_register(screen_new("setting", screen_startSetting, setting_event, + screen_register(screen_new("setting", startScreenSetting, setting_event, setting_draw, stopScreenSetting)); initSettingFile(); @@ -402,17 +402,17 @@ void setting_init() #endif } -void public_server_get_setting_name_right(char *s) +void public_server_get_setting_name_right(const char *s) { - strcpy(s, text_field_get_text(textfield_name_player1)); + strcpy((char*)s, text_field_get_text(textfield_name_player1)); } -void public_server_get_settingNameLeft(char *s) +void public_server_get_settingNameLeft(const char *s) { if (check_get_status(check_ai)) { - strcpy(s, NAME_AI); + strcpy((char*)s, NAME_AI); } else { - strcpy(s, text_field_get_text(textfield_name_player2)); + strcpy((char*)s, text_field_get_text(textfield_name_player2)); } } @@ -421,12 +421,12 @@ void public_server_get_settingCountRound(int *n) *n = atoi(text_field_get_text(textfield_count_cound)); } -bool_t setting_is_ai() +bool_t setting_is_ai(void) { return check_get_status(check_ai); } -bool_t setting_is_any_item() +bool_t setting_is_any_item(void) { int i; @@ -450,7 +450,7 @@ bool_t setting_is_item(int item) return check_get_status(check[item]); } -void setting_quit() +void setting_quit(void) { int i; diff --git a/src/screen/setting.h b/src/screen/setting.h index c29e6a9..15e1f6c 100644 --- a/src/screen/setting.h +++ b/src/screen/setting.h @@ -7,15 +7,15 @@ #define NAME_PLAYER_RIGHT "Name1" #define NAME_PLAYER_LEFT "Name2" -extern void setting_init(); -extern void setting_draw(); -extern void setting_event(); -extern void public_server_get_setting_name_right(char *s); -extern void public_server_get_settingNameLeft(char *s); +extern void setting_init(void); +extern void setting_draw(void); +extern void setting_event(void); +extern void public_server_get_setting_name_right(const char *s); +extern void public_server_get_settingNameLeft(const char *s); extern void public_server_get_settingCountRound(int *n); -extern bool_t setting_is_ai(); -extern bool_t setting_is_any_item(); +extern bool_t setting_is_ai(void); +extern bool_t setting_is_any_item(void); extern bool_t setting_is_item(int item); -extern void setting_quit(); +extern void setting_quit(void); #endif /* SCREEN_SETTING_H */ diff --git a/src/screen/settingKeys.c b/src/screen/settingKeys.c index e778615..209ce78 100644 --- a/src/screen/settingKeys.c +++ b/src/screen/settingKeys.c @@ -79,7 +79,7 @@ static void hotkey_escape(void) screen_set("setting"); } -static void screen_startSettingKeys(void) +static void startScreenSettingKeys(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -195,7 +195,7 @@ void setting_key_draw(void) catch_key_draw(tux_left_keyfire_val); } -static void refreshKeytable() +static void refreshKeytable(void) { keytable[6] = catch_key_get(tux_left_keyup_val); keytable[9] = catch_key_get(tux_left_keydown_val); @@ -266,16 +266,18 @@ void setting_key_event(void) catch_key_event(tux_left_keyfire_val); } -void stopScreenSettingKeys(void) +static void stopScreenSettingKeys(void) { hot_key_unregister(SDLK_ESCAPE); } void setting_key_int(void) { + image_t *image; + key_table_init(); - image_t *image = image_get(IMAGE_GROUP_BASE, "screen_main"); + image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); @@ -309,7 +311,7 @@ void setting_key_int(void) tux_right_keyfire_val = catch_key_new(keytable[4], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left_keyright->y + 25, eventWidget); tux_right_keyswitch_val = catch_key_new(keytable[5], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_left_keyfire->y + 25, eventWidget); - screen_register(screen_new("settingKeys", screen_startSettingKeys, setting_key_event, setting_key_draw, stopScreenSettingKeys)); + screen_register(screen_new("settingKeys", startScreenSettingKeys, setting_key_event, setting_key_draw, stopScreenSettingKeys)); } void key_table_quit(void) @@ -317,7 +319,7 @@ void key_table_quit(void) text_file_destroy(keycontrolFile); } -void saveKeyTable(textFile_t *configFile) +static void saveKeyTable(textFile_t *configFile) { char str[STR_SIZE]; diff --git a/src/screen/table.c b/src/screen/table.c index 34b4680..60f9e20 100644 --- a/src/screen/table.c +++ b/src/screen/table.c @@ -31,12 +31,12 @@ static list_t *listWidgetLabelScore; static textFile_t *textFile; -static void hotkey_escape() +static void hotkey_escape(void) { screen_set("mainMenu"); } -void table_start() +void table_start(void) { #ifndef NO_SOUND music_play("menu", MUSIC_GROUP_BASE); @@ -45,7 +45,7 @@ void table_start() hot_key_register(SDLK_ESCAPE, hotkey_escape); } -void table_draw() +void table_draw(void) { int i; @@ -72,12 +72,12 @@ void table_draw() } } -void table_event() +void table_event(void) { button_event(button_back); } -void table_stop() +void table_stop(void) { hot_key_unregister(SDLK_ESCAPE); } @@ -93,7 +93,7 @@ static void eventWidget(void *p) } } -static void setWidgetLabel() +static void setWidgetLabel(void) { int i; @@ -138,7 +138,7 @@ static void setWidgetLabel() } } -static void loadHighscoreFile() +static void loadHighscoreFile(void) { char path[STR_PATH_SIZE]; int i; @@ -166,7 +166,7 @@ static void loadHighscoreFile() text_file_save(textFile); } -int table_add(char *name, int score) +int table_add(const char *name, int score) { int i; @@ -193,7 +193,7 @@ int table_add(char *name, int score) return -1; } -void table_init() +void table_init(void) { image_t *image; @@ -212,7 +212,7 @@ void table_init() screen_register(screen_new("table", table_start, table_event, table_draw, table_stop)); } -void table_quit() +void table_quit(void) { wid_image_destroy(image_backgorund); diff --git a/src/screen/table.h b/src/screen/table.h index 7940ee9..b7d5ae1 100644 --- a/src/screen/table.h +++ b/src/screen/table.h @@ -4,12 +4,12 @@ #define SCREEN_TABLE_MAX_PLAYERS 10 #define SCREEN_TABLE_FILE_HIGHSCORE_NAME "highscore" -extern void table_start(); -extern void table_draw(); -extern void table_event(); -extern void table_stop(); -extern int table_add(char *name, int score); -extern void table_init(); -extern void table_quit(); +extern void table_start(void); +extern void table_draw(void); +extern void table_event(void); +extern void table_stop(void); +extern int table_add(const char *name, int score); +extern void table_init(void); +extern void table_quit(void); #endif /* SCREEN_TABLE_H */ diff --git a/src/screen/world.c b/src/screen/world.c index 3a5935f..d67d793 100644 --- a/src/screen/world.c +++ b/src/screen/world.c @@ -323,6 +323,9 @@ void world_set_control_tux(tux_t *tux, int control_type) ); break; + default: + fatal("Variable control_type in world has an undefined value [%d]", control_type); + break; } } @@ -350,6 +353,9 @@ void world_tux_control(tux_t *p) control_keyboard(tuxWithControlLeftKeyboard, control_tux_left); } break; + default: + fatal("Variable p->control in world has an undefined value [%d]", p->control); + break; } } @@ -390,12 +396,12 @@ void world_event(void) yes_no_dialog_event(); } -void dialog_yes(void *p) +static void dialog_yes(void *p) { world_do_end(); } -void dialog_no(void *p) +static void dialog_no(void *p) { } @@ -406,7 +412,7 @@ static void hotkey_escape(void) /*world_do_end();*/ } -void startWorld(void) +static void startWorld(void) { arena = NULL; isEndWorld = FALSE; @@ -466,7 +472,7 @@ static void setTable(void) } } -void stoptWorld(void) +static void stopWorld(void) { if (arena != NULL) { setTable(); @@ -522,7 +528,7 @@ void world_init(void) assert(panel_is_inicialized() == TRUE); assert(screen_is_inicialized() == TRUE); - screen_register(screen_new("world", startWorld, world_event, world_draw, stoptWorld)); + screen_register(screen_new("world", startWorld, world_event, world_draw, stopWorld)); #ifndef NO_SOUND sound_add("dead.ogg", "dead", SOUND_GROUP_BASE); diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c index 9d80294..ec774db 100644 --- a/src/widget/widget_button.c +++ b/src/widget/widget_button.c @@ -11,7 +11,7 @@ #include "widget.h" #include "widget_button.h" -widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *)) +widget_t *button_new(const char *text, int x, int y, void (*fce_event) (void *)) { widget_button_t *new; diff --git a/src/widget/widget_button.h b/src/widget/widget_button.h index 2ec4ae3..97c1140 100644 --- a/src/widget/widget_button.h +++ b/src/widget/widget_button.h @@ -15,7 +15,7 @@ typedef struct widget_button { void (*fce_event) (void *); } widget_button_t; -extern widget_t *button_new(char *text, int x, int y, void (*fce_event) (void *)); +extern widget_t *button_new(const char *text, int x, int y, void (*fce_event) (void *)); extern void button_draw(widget_t *widget); extern void button_event(widget_t *widget); extern void button_destroy(widget_t *widget); diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c index b696302..6142d7f 100644 --- a/src/widget/widget_label.c +++ b/src/widget/widget_label.c @@ -7,7 +7,7 @@ #include "widget_label.h" #include "widget.h" -widget_t *label_new(char *text, int x, int y, int bind) +widget_t *label_new(const char *text, int x, int y, int bind) { widget_label_t *new; diff --git a/src/widget/widget_label.h b/src/widget/widget_label.h index bd1b531..2aa8fe0 100644 --- a/src/widget/widget_label.h +++ b/src/widget/widget_label.h @@ -14,7 +14,7 @@ typedef struct widget_label { int bind; } widget_label_t; -extern widget_t *label_new(char *text, int x, int y, int bind); +extern widget_t *label_new(const char *text, int x, int y, int bind); extern void label_draw(widget_t *widget); extern void label_event(widget_t *widget); extern void label_destroy(widget_t *widget); diff --git a/src/widget/widget_statusbar.c b/src/widget/widget_statusbar.c index c2b48a4..496e45a 100644 --- a/src/widget/widget_statusbar.c +++ b/src/widget/widget_statusbar.c @@ -1,20 +1,12 @@ #include #include -#include "main.h" -#include "interface.h" #include "image.h" #include "font.h" -#include "widget_statusbar.h" -#include "widget.h" #include "mouse_buffer.h" +#include "widget_statusbar.h" -typedef struct item_struct { - widget_t *widget; - list_t *text; -} item_t; - -static item_t *item_new(widget_t *widget, char *text) +static item_t *item_new(widget_t *widget, const char *text) { item_t *item; char *copy; @@ -60,7 +52,7 @@ widget_t *statusbar_new(int x, int y) return widget_new(WIDGET_TYPE_STATUSBAR, x, y, WIDGET_STATUSBAR_WIDTH, WIDGET_STATUSBAR_HEIGHT, new); } -void statusbar_add(widget_t *widget, widget_t *widget_catch, char *text) +void statusbar_add(widget_t *widget, widget_t *widget_catch, const char *text) { widget_statusbar_t *p; diff --git a/src/widget/widget_statusbar.h b/src/widget/widget_statusbar.h index 217c1a5..f7c47cc 100644 --- a/src/widget/widget_statusbar.h +++ b/src/widget/widget_statusbar.h @@ -1,7 +1,10 @@ #ifndef WIDGET_STATUSBAR_H #define WIDGET_STATUSBAR_H -#include "main.h" +#define WIDGET_STATUSBAR_NONE_SELECT_ELEMENT -1 +#define WIDGET_STATUSBAR_WIDTH 250 +#define WIDGET_STATUSBAR_HEIGHT 65 + #include "widget.h" #include "list.h" @@ -10,13 +13,13 @@ typedef struct widget_statusbar { int selectElement; } widget_statusbar_t; -#define WIDGET_STATUSBAR_NONE_SELECT_ELEMENT -1 - -#define WIDGET_STATUSBAR_WIDTH 250 -#define WIDGET_STATUSBAR_HEIGHT 65 +typedef struct item_struct { + widget_t *widget; + list_t *text; +} item_t; extern widget_t *statusbar_new(int x, int y); -extern void statusbar_add(widget_t *widget, widget_t *widget_catch, char *text); +extern void statusbar_add(widget_t *widget, widget_t *widget_catch, const char *text); extern void statusbar_draw(widget_t *widget); extern void statusbar_event(widget_t *widget); extern void statusbar_destroy(widget_t *widget); -- 1.7.5.rc3