diff options
| -rw-r--r-- | src/screen/analyze.c | 29 | ||||
| -rw-r--r-- | src/screen/browser.c | 248 | ||||
| -rw-r--r-- | src/screen/choiceArena.c | 91 | ||||
| -rw-r--r-- | src/screen/credits.c | 19 | ||||
| -rw-r--r-- | src/screen/downArena.c | 71 | ||||
| -rw-r--r-- | src/screen/gameType.c | 47 | ||||
| -rw-r--r-- | src/screen/mainMenu.c | 12 | ||||
| -rw-r--r-- | src/screen/setting.c | 98 | ||||
| -rw-r--r-- | src/screen/settingKeys.c | 47 | ||||
| -rw-r--r-- | src/screen/table.c | 19 | ||||
| -rw-r--r-- | src/screen/world.c | 214 | ||||
| -rw-r--r-- | src/server/publicServer.c | 9 |
12 files changed, 475 insertions, 429 deletions
diff --git a/src/screen/analyze.c b/src/screen/analyze.c index 3b5be95..450da41 100644 --- a/src/screen/analyze.c +++ b/src/screen/analyze.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -12,7 +11,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "mainMenu.h" @@ -43,7 +42,7 @@ static analyze_t *newAnalyze(char *name, int score) return new; } -static void destroyAnalyze(analyze_t * p) +static void destroyAnalyze(analyze_t *p) { free(p->name); free(p); @@ -71,12 +70,12 @@ void analyze_draw() wid_image_draw(image_backgorund); for (i = 0; i < listWidgetLabelName->count; i++) { - this = (widget_t *) (listWidgetLabelName->list[i]); + this = (widget_t *) listWidgetLabelName->list[i]; label_draw(this); } for (i = 0; i < listWidgetLabelScore->count; i++) { - this = (widget_t *) (listWidgetLabelScore->list[i]); + this = (widget_t *) listWidgetLabelScore->list[i]; label_draw(this); } @@ -101,7 +100,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_ok) { screen_set("mainMenu"); @@ -138,15 +137,17 @@ void analyze_end() analyze_t *this; char *str; - this = (analyze_t *) (listAnalyze->list[i]); + this = (analyze_t *) listAnalyze->list[i]; - list_add(listWidgetLabelName, label_new(this->name, 100, - 200 + 20 * i, WIDGET_LABEL_LEFT)); + list_add(listWidgetLabelName, label_new(this->name, + 100, 200 + 20 * i, + WIDGET_LABEL_LEFT)); str = getString(this->score); - list_add(listWidgetLabelScore, label_new(str, WINDOW_SIZE_X - 100, - 200 + 20 * i, WIDGET_LABEL_RIGHT)); + list_add(listWidgetLabelScore, label_new(str, + WINDOW_SIZE_X - 100, 200 + 20 * i, + WIDGET_LABEL_RIGHT)); free(str); } @@ -163,10 +164,10 @@ void analyze_init() listWidgetLabelScore = list_new(); listAnalyze = list_new(); - button_ok = button_new("OK", WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, - WINDOW_SIZE_Y - 100, eventWidget); + button_ok = button_new(_("OK"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + WINDOW_SIZE_Y - 100, eventWidget); - screen_register( screen_new("analyze", analyze_start, analyze_event, + screen_register(screen_new("analyze", analyze_start, analyze_event, analyze_draw, analyze_stop)); widgetLabelMsg = label_new("", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); diff --git a/src/screen/browser.c b/src/screen/browser.c index d23b385..743a90d 100644 --- a/src/screen/browser.c +++ b/src/screen/browser.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -15,16 +14,16 @@ #include "hotKey.h" #ifndef __WIN32__ -# include <sys/socket.h> -# include <sys/select.h> -# include <sys/types.h> -# include <netinet/in.h> -# include <arpa/inet.h> -# include <netdb.h> -#else -# include <windows.h> -# include <wininet.h> -#endif +#include <sys/socket.h> +#include <sys/select.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <netdb.h> +#else /* __WIN32__ */ +#include <windows.h> +#include <wininet.h> +#endif /* __WIN32__ */ #include <unistd.h> #include <fcntl.h> @@ -36,7 +35,7 @@ extern int errno; #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "gameType.h" @@ -120,8 +119,8 @@ void browser_stop() unsigned i = 0; server_t *server; - //list_destroy_item(select_server->list, free); - //select_server->list = list_new(); + /*list_destroy_item(select_server->list, free);*/ + /*select_server->list = list_new();*/ select_remove_all(select_server); hot_key_unregister(SDLK_ESCAPE); @@ -132,14 +131,17 @@ void browser_stop() server->next->prev = server->prev; server->prev->next = server->next; - if (server->name) + if (server->name) { free(server->name); + } - if (server->version) + if (server->version) { free(server->version); + } - if (server->arena) + if (server->arena) { free(server->arena); + } free(server); @@ -147,8 +149,9 @@ void browser_stop() break; } - if (!i) + if (!i) { return; + } } } @@ -156,17 +159,19 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_play) { server_t *server = server_getcurr(); - if (!server) + if (!server) { return; + } /* server is offline */ - if (!server->state) + if (!server->state) { return; + } struct in_addr srv; srv.s_addr = server->ip; @@ -194,10 +199,10 @@ server_t *server_getcurr() int i = 0; server_t *server; - for (server = server_list.next; server != &server_list; - server = server->next) { - if (i == select_get_index(select_server)) + for (server = server_list.next; server != &server_list; server = server->next) { + if (i == select_get_index(select_server)) { return server; + } i++; } @@ -214,19 +219,19 @@ int server_getinfo(server_t *server) return -1; } #ifndef __WIN32__ - // Lets make socket non-blocking + /* let's make the socket non-blocking */ int oldFlag = fcntl(mySocket, F_GETFL, 0); if (fcntl(mySocket, F_SETFL, oldFlag | O_NONBLOCK) == -1) { return -1; } -#else +#else /* __WIN32__ */ unsigned long arg = 1; - // Operation is FIONBIO. Parameter is pointer on non-zero number. + /* Operation is FIONBIO. Parameter is pointer on non-zero number */ if (ioctlsocket(mySocket, FIONBIO, &arg) == SOCKET_ERROR) { WSACleanup(); return -1; } -#endif +#endif /* __WIN32__ */ struct timeval tv; @@ -243,31 +248,35 @@ int server_getinfo(server_t *server) if (connect(mySocket, (struct sockaddr *) &srv, sizeof(srv)) == -1) { #ifndef __WIN32__ - if (errno != EINPROGRESS) + if (errno != EINPROGRESS) { return -1; -#else + } +#else /* __WIN32__ */ if (WSAGetLastError() != WSAEWOULDBLOCK) { WSACleanup(); return -1; } -#endif +#endif /* __WIN32__ */ } int ret = select(mySocket + 1, NULL, &myset, NULL, &tv); - if (ret == -1) + if (ret == -1) { return 0; + } - if (ret == 0) + if (ret == 0) { return -2; + } char request[8]; memcpy(request, "status\n", 7); int r = send(mySocket, request, 7, 0); - if (r == -1) + if (r == -1) { return -2; + } FD_ZERO(&myset); FD_SET(mySocket, &myset); @@ -276,8 +285,9 @@ int server_getinfo(server_t *server) char *str = (char *) malloc(sizeof(char) * 257); - if (!str) + if (!str) { return -1; + } while (1) { int sel = select(mySocket + 1, &myset, NULL, NULL, &tv); @@ -286,10 +296,10 @@ int server_getinfo(server_t *server) free(str); #ifndef __WIN32__ close(mySocket); -#else +#else /* __WIN32__ */ closesocket(mySocket); WSACleanup(); -#endif +#endif /* __WIN32__ */ return -2; } @@ -297,10 +307,10 @@ int server_getinfo(server_t *server) free(str); #ifndef __WIN32__ close(mySocket); -#else +#else /* __WIN32__ */ closesocket(mySocket); WSACleanup(); -#endif +#endif /* __WIN32__ */ return -2; } @@ -308,23 +318,24 @@ int server_getinfo(server_t *server) free(str); #ifndef __WIN32__ close(mySocket); -#else +#else /* __WIN32__ */ closesocket(mySocket); WSACleanup(); -#endif +#endif /* __WIN32__ */ return -1; } - if (ret > 0) + if (ret > 0) { break; + } } #ifndef __WIN32__ close(mySocket); -#else +#else /* __WIN32__ */ closesocket(mySocket); WSACleanup(); -#endif +#endif /* __WIN32__ */ server->ping = 1000 - (tv.tv_usec / 1000); /* @@ -335,7 +346,7 @@ int server_getinfo(server_t *server) "uptime: D\n" */ - //unsigned i = 0; + /*unsigned i = 0;*/ int i = 0; while (i < ret) { @@ -347,8 +358,10 @@ int server_getinfo(server_t *server) unsigned name = 0; - if (strstr(str, "name: ")) + /* get server's name */ + if (strstr(str, "name: ")) { name = 1; + } int len = 0; @@ -358,8 +371,9 @@ int server_getinfo(server_t *server) unsigned name_len = strlen(str + 6); server->name = (char *) malloc(sizeof(char) * (name_len + 2)); - if (!server->name) + if (!server->name) { return 0; + } memcpy(server->name, str + 6, name_len + 1); server->name[name_len + 1] = '\0'; @@ -367,15 +381,18 @@ int server_getinfo(server_t *server) } /* HACK */ - if (!name) + if (!name) { len = -1; + } + /* get server's version */ if (!strncmp(str + len + 1, "version: ", 9)) { unsigned ver_len = strlen(str + len + 10); server->version = (char *) malloc(sizeof(char) * (ver_len + 2)); - if (!server->version) + if (!server->version) { return 0; + } memcpy(server->version, str + len + 10, ver_len + 1); server->version[ver_len + 1] = '\0'; @@ -383,31 +400,35 @@ int server_getinfo(server_t *server) len += strlen(str + len + 1) + 1; - - if (!strncmp(str + len + 1, "clients: ", 9)) + /* get server's connected clients count */ + if (!strncmp(str + len + 1, "clients: ", 9)) { server->clients = atoi(str + len + 10); + } len += strlen(str + len + 1) + 1; - - if (!strncmp(str + len + 1, "maxclients: ", 12)) + /* get server's maximum connected clients count */ + if (!strncmp(str + len + 1, "maxclients: ", 12)) { server->maxclients = atoi(str + len + 13); + } len += strlen(str + len + 1) + 1; - - if (!strncmp(str + len + 1, "uptime: ", 8)) + /* get server's uptime */ + if (!strncmp(str + len + 1, "uptime: ", 8)) { server->uptime = atoi(str + len + 9); + } len += strlen(str + len + 1) + 1; - + /* get server's arena */ if (!strncmp(str + len + 1, "arena: ", 7)) { unsigned arena_len = strlen(str + len + 9); server->arena = (char *) malloc(sizeof(char) * (arena_len + 2)); - if (!server->arena) + if (!server->arena) { return 0; + } memcpy(server->arena, str + len + 8, arena_len + 1); server->arena[arena_len + 1] = '\0'; @@ -421,27 +442,26 @@ int server_getinfo(server_t *server) return 1; } +/* + * Get server list + */ static int LoadServers() -// Get server list { #ifndef __WIN32__ int s; -#else +#else /* __WIN32__ */ SOCKET s; -#endif +#endif /* __WIN32__ */ char buf[1025]; - /* TODO: dodelat TCP makro */ + /* TODO: TCP macro */ struct sockaddr_in server; char *master_server_ip; master_server_ip = dns_resolv(NET_MASTER_SERVER_DOMAIN); - //printf("master_server_ip = %s\n", master_server_ip); - - if (master_server_ip == NULL) // master server is down - { + if (master_server_ip == NULL) { /* master server is down? */ return -1; } @@ -451,34 +471,36 @@ static int LoadServers() free(master_server_ip); - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return 0; + } + /* Set to nonblocking socket mode */ #ifndef __WIN32__ - // Lets make socket non-blocking int oldFlag = fcntl(s, F_GETFL, 0); if (fcntl(s, F_SETFL, oldFlag | O_NONBLOCK) == -1) { return -1; } -#else +#else /* __WIN32__ */ unsigned long arg = 1; - // Operation is FIONBIO. Parameter is pointer on non-zero number. + /* Operation is FIONBIO. Parameter is pointer on non-zero number. */ if (ioctlsocket(s, FIONBIO, &arg) == SOCKET_ERROR) { WSACleanup(); return -1; } -#endif +#endif /* __WIN32__ */ if (connect(s, (struct sockaddr *) &server, sizeof(server)) == -1) { #ifndef __WIN32__ - if (errno != EINPROGRESS) + if (errno != EINPROGRESS) { return -1; -#else + } +#else /* __WIN32__ */ if (WSAGetLastError() != WSAEWOULDBLOCK) { WSACleanup(); return -1; } -#endif +#endif /* __WIN32__ */ } struct timeval tv; @@ -493,11 +515,11 @@ static int LoadServers() int ret = select(s + 1, NULL, &myset, NULL, &tv); - if (ret == -1) + if (ret == -1) { return 0; - - if (ret == 0) + } else if (ret == 0) { return -2; + } /* send request for server list */ send(s, "l", 1, 0); @@ -507,23 +529,24 @@ static int LoadServers() ret = select(s + 1, &myset, NULL, NULL, &tv); - if (ret == -1) + if (ret == -1) { return 0; - - if (ret == 0) + } else if (ret == 0) { return -2; + } int len = recv(s, buf, 1024, 0); #ifndef __WIN32__ close(s); -#else +#else /* __WIN32__ */ closesocket(s); WSACleanup(); -#endif +#endif /* __WIN32__ */ - if (len <= 0) + if (len <= 0) { return 0; + } int i = 0; char list[256]; @@ -540,7 +563,7 @@ static int LoadServers() server_t *ctx; - // alloc and init context + /* alloc and init context */ ctx = (server_t *) malloc(sizeof(server_t)); ctx->ip = header->ip; @@ -562,10 +585,11 @@ static int LoadServers() /*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) + if (ctx->name) { memcpy(list, ctx->name, strlen(ctx->name)); - else + } else { memcpy(list, "Unknown", 7); + } memcpy(list + 30, ctx->version, strlen(ctx->version)); @@ -590,7 +614,7 @@ static int LoadServers() select_add(select_server, list); - // add into list + /* add server to server list */ ctx->next = &server_list; ctx->prev = server_list.prev; ctx->prev->next = ctx; @@ -598,8 +622,9 @@ static int LoadServers() i += sizeof(response_head) + 1; - if (buf[i - 1] != '\n' || (i + 1) > len) + if (buf[i - 1] != '\n' || (i + 1) > len) { break; + } } return 1; @@ -616,16 +641,18 @@ static int RefreshServers() struct in_addr srv; server_t *server; - for (server = server_list.next; server != &server_list; - server = server->next) { - if (server->name) + for (server = server_list.next; server != &server_list; server = server->next) { + if (server->name) { free(server->name); + } - if (server->version) + if (server->version) { free(server->version); + } - if (server->arena) + if (server->arena) { free(server->arena); + } server->name = 0; server->version = 0; @@ -644,10 +671,11 @@ static int RefreshServers() memset(list, ' ', 254); list[255] = '\0'; - if (server->name) + if (server->name) { memcpy(list, server->name, strlen(server->name)); - else + } else { memcpy(list, "Unknown", 7); + } memcpy(list + 30, server->version, strlen(server->version)); @@ -671,7 +699,6 @@ static int RefreshServers() } select_add(select_server, list); - } return 1; @@ -684,27 +711,24 @@ void browser_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = - button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); - button_play = - button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, - eventWidget); - button_refresh = - button_new(_("Refresh"), WINDOW_SIZE_X / 2 - 50, - WINDOW_SIZE_Y - 100, eventWidget); - - label_server = label_new(_("server"), 120, 145, WIDGET_LABEL_LEFT); - label_version = label_new(_("version"), 290, 145, WIDGET_LABEL_LEFT); + button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, + eventWidget); + button_refresh = button_new(_("Refresh"), + WINDOW_SIZE_X / 2 - 50, WINDOW_SIZE_Y - 100, + eventWidget); + + label_server = label_new(_("Server"), 120, 145, WIDGET_LABEL_LEFT); + label_version = label_new(_("Version"), 290, 145, WIDGET_LABEL_LEFT); label_address = label_new(_("IP"), 400, 145, WIDGET_LABEL_LEFT); - label_arena = label_new(_("arena"), 550, 145, WIDGET_LABEL_LEFT); - label_players = label_new(_("clients"), 645, 145, WIDGET_LABEL_LEFT); - label_ping = label_new(_("ping"), 720, 145, WIDGET_LABEL_LEFT); + label_arena = label_new(_("Arena"), 550, 145, WIDGET_LABEL_LEFT); + label_players = label_new(_("Clients"), 645, 145, WIDGET_LABEL_LEFT); + label_ping = label_new(_("Ping"), 720, 145, WIDGET_LABEL_LEFT); select_server = select_new(50, label_server->y + 40, eventWidget); - screen_register(screen_new - ("browser", browser_start, browser_event, - browser_draw, browser_stop)); + screen_register(screen_new("browser", browser_start, browser_event, + browser_draw, browser_stop)); server_list.next = &server_list; server_list.prev = &server_list; diff --git a/src/screen/choiceArena.c b/src/screen/choiceArena.c index 7bfee61..ea9079f 100644 --- a/src/screen/choiceArena.c +++ b/src/screen/choiceArena.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <assert.h> @@ -12,7 +11,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "mainMenu.h" @@ -31,18 +30,18 @@ static widget_t *button_back; static widget_t *button_next; static widget_t *button_prev; -//static list_t *listWidgetButtonimage; // map buttons to be showed and handled - well, show_map_buttons is used instead -static list_t *listAllWidgetButtonimage; // all map buttons -static int handled_map_button_group; // 0 - first 6 buttons, 1 - second 6 buttons, .... +/*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 struct show_map_buttons { - // geez, it'd be nicer to used two lists - // but how the hell is list_t supposed to be used?! :-) - int min; // see activateHandledMapButtonGroup for desc - int max; // - int next; // 0: max is last item+1 in listAllWidgetButtonimage, otherwise 1 - int prev; // 0: min is first item in listAllWidgetButtonimage, otherwise 1 -} show_map_buttons = { 0,0,0,0 } ; + /* geez, it'd be nicer to use two lists + but how the hell list_t is supposed to be used?! :-) */ + int min; /* see activateHandledMapButtonGroup for description */ + int max; + int next; /* 0: max is last item+1 in listAllWidgetButtonimage, otherwise 1 */ + int prev; /* 0: min is first item in listAllWidgetButtonimage, otherwise 1 */ +} show_map_buttons = { 0,0,0,0 }; static arenaFile_t *currentArena; static void hotkey_escape() @@ -71,7 +70,7 @@ void choice_arena_draw() if (show_map_buttons.prev) { button_draw(button_prev); } for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) { - button_image_draw((widget_t*)listAllWidgetButtonimage->list[i]); + button_image_draw((widget_t *) listAllWidgetButtonimage->list[i]); } } @@ -85,7 +84,7 @@ void choice_arena_event() if (show_map_buttons.prev) { button_event(button_prev); } for (i = show_map_buttons.min ; i < show_map_buttons.max; i++) { - button_image_event((widget_t*)listAllWidgetButtonimage->list[i]); + button_image_event((widget_t *) listAllWidgetButtonimage->list[i]); } } @@ -99,12 +98,12 @@ static void button_eventImage(void *p) widget_t *buttonimage; int i; - buttonimage = (widget_t *) (p); + buttonimage = (widget_t *) p; for (i = show_map_buttons.min; i < show_map_buttons.max; i++) { widget_t *this; - this = (widget_t *) (listAllWidgetButtonimage->list[i]); + this = (widget_t *) listAllWidgetButtonimage->list[i]; if (buttonimage == this) { button_image_set_active(this, TRUE); @@ -120,7 +119,7 @@ arenaFile_t *choice_arena_get() return currentArena; } -void choice_arena_set(arenaFile_t * arenaFile) +void choice_arena_set(arenaFile_t *arenaFile) { widget_t *widget_buttonimage; int id; @@ -138,7 +137,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_play) { screen_set("world"); @@ -147,12 +146,14 @@ static void eventWidget(void *p) if (button == button_back) { screen_set("gameType"); } + if (button == button_next) { if (show_map_buttons.next) { handled_map_button_group++; activateHandledMapButtonGroup(); } } + if (button == button_prev) { if (show_map_buttons.prev) { handled_map_button_group--; @@ -161,20 +162,30 @@ static void eventWidget(void *p) } } -// groups of 6 map buttons to be shown and handled -// the group is set by static global variable handled_map_button_group -// sets static global show_map_buttons.min to index of first button to be drawn in listAllButtonimage -// and show_map_buttons.max to index of last button to be drawn+1 in listAllButtonimage +/* + * groups of 6 map buttons to be shown and handled + * the group is set by static global variable handled_map_button_group + * sets static global show_map_buttons.min to index of first button to be drawn in listAllButtonimage + * and show_map_buttons.max to index of last button to be drawn+1 in listAllButtonimage + */ static void activateHandledMapButtonGroup(void) { int 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(); + int max = min + 6 <= arena_file_get_count() ? min + 6 : arena_file_get_count(); + + if (min) { + show_map_buttons.prev = 1; + } else { + show_map_buttons.prev = 0; + } + + if (max < arena_file_get_count()) { + show_map_buttons.next = 1; + } else { + show_map_buttons.next = 0; + } - if (min) { show_map_buttons.prev = 1; } - else { show_map_buttons.prev = 0; } - if (max < arena_file_get_count()) { show_map_buttons.next = 1; } - else { show_map_buttons.next = 0; } show_map_buttons.min = min; show_map_buttons.max = max; } @@ -187,11 +198,11 @@ void choice_arena_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); - button_play = button_new(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_prev = button_new(_("prev maps"), 250, WINDOW_SIZE_Y - 100, eventWidget); - button_next = button_new(_("next maps"), WINDOW_SIZE_X-350, WINDOW_SIZE_Y - 100, eventWidget); + button_prev = button_new(_("Previous maps"), 250, WINDOW_SIZE_Y - 100, eventWidget); + button_next = button_new(_("Next maps"), WINDOW_SIZE_X-350, WINDOW_SIZE_Y - 100, eventWidget); listAllWidgetButtonimage = list_new(); currentArena = NULL; @@ -202,14 +213,16 @@ void choice_arena_init() int x, y; arenaFile = arena_file_get(i); - //image = image_add(arena_file_get_image(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE); + /*image = image_add(arena_file_get_image(i), IMAGE_NO_ALPHA, "none", IMAGE_GROUP_BASE);*/ image = arena_file_load_image(arenaFile, arena_file_get_image(arenaFile), - IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA); - - // only 6 map buttons can be shown at once; - // set buttons' positions in each group to the corresponding values - // handled_map_button_group and activateHandledMapButtonGroup is used - // to choose group to be shown and handled + IMAGE_GROUP_BASE, "none", IMAGE_NO_ALPHA); + + /* + only 6 map buttons can be shown at once; + set buttons' positions in each group to the corresponding values + handled_map_button_group and activateHandledMapButtonGroup is used + to choose group to be shown and handled + */ int pos = i % 6 ; x = 100 + 200 * (pos - 3 * (pos / 3)); y = 150 + 200 * (pos / 3); @@ -226,7 +239,7 @@ void choice_arena_init() activateHandledMapButtonGroup(); } - screen_register( screen_new("chiceArena", screen_startChoiceArena, + screen_register(screen_new("chiceArena", screen_startChoiceArena, choice_arena_event, choice_arena_draw, stopScreenChoiceArena)); } diff --git a/src/screen/credits.c b/src/screen/credits.c index 8aa9734..e3ad9be 100644 --- a/src/screen/credits.c +++ b/src/screen/credits.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <assert.h> @@ -12,7 +11,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "credits.h" @@ -81,7 +80,7 @@ void scredits_event() offset = 0; } - //printf("offset = %d\n", offset); + /*printf("offset = %d\n", offset);*/ } void scredits_stop() @@ -93,7 +92,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_back) { screen_set("mainMenu"); @@ -108,8 +107,8 @@ void scredits_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, - WINDOW_SIZE_Y - 80, eventWidget); + button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + WINDOW_SIZE_Y - 80, eventWidget); listWidgetLabel = list_new(); @@ -135,8 +134,8 @@ void scredits_init() widget_t *label; char line[STR_SIZE]; - sprintf(line, _("Credit file not found... %s/%s"), PATH_DOC, - SCREEN_CREDITS_FILE); + sprintf(line, _("[Error] Credits file not found [%s]: %s\n"), + PATH_DOC, SCREEN_CREDITS_FILE); label = label_new(line, WINDOW_SIZE_X / 2, (WINDOW_SIZE_Y - 100) + i * 20, @@ -146,8 +145,8 @@ void scredits_init() } } - screen_register(screen_new ("credits", scredits_start, scredits_event, - scredits_draw, scredits_stop)); + screen_register(screen_new("credits", scredits_start, scredits_event, + scredits_draw, scredits_stop)); } void scredits_quit() diff --git a/src/screen/downArena.c b/src/screen/downArena.c index 9daf051..e150a03 100644 --- a/src/screen/downArena.c +++ b/src/screen/downArena.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -64,9 +63,9 @@ static void connectToDownServer() sock_server_tcp = sock_tcp_connect(public_server_get_settingIP(), public_server_get_settingPort()); - if( sock_server_tcp == NULL ) - { - sprintf(status, "I do not connect to %s %d TCP down server", public_server_get_settingIP(), public_server_get_settingPort()); + if (sock_server_tcp == NULL) { + sprintf(status, _("Error! Unable to connect to [%s]:%d download server"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); return; } @@ -85,7 +84,8 @@ static void connectToDownServer() buffer_append(sendBuffer, msg, strlen(msg)); - sprintf(status, "Connect to %s %d TCP down server", public_server_get_settingIP(), public_server_get_settingPort()); + sprintf(status, _("Connecting to [%s]:%d download server"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); } @@ -103,10 +103,10 @@ static void sendStatusToGameServer() { char *msg = "status\n"; - if( countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS ) - { + if (countSendMsg > DOWN_ARENA_MAX_SEND_MSG_STATUS) { char status[STR_SIZE]; - sprintf(status, "Game server %s %d is down", public_server_get_settingIP(), public_server_get_settingPort()); + sprintf(status, _("Error! Game server [%s]:%d is off"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); return; } @@ -115,10 +115,10 @@ static void sendStatusToGameServer() countSendMsg++; printf("countSendMsg = %d\n", countSendMsg++); - if( sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0 ) - { + if (sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg)) < 0) { char status[STR_SIZE]; - sprintf(status, "I do not send message to %s %d UDP game server", public_server_get_settingIP(), public_server_get_settingPort()); + sprintf(status, _("Error! Unable to send message to [%s]:%d game server"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); } } @@ -132,16 +132,17 @@ void down_arena_start() sock_server_udp = sock_udp_connect(public_server_get_settingIP(), public_server_get_settingPort()); - if (sock_server_udp == NULL) - { - sprintf(status, "I do not connect to %s %d UDP game server", public_server_get_settingIP(), public_server_get_settingPort()); + if (sock_server_udp == NULL) { + sprintf(status, _("Error! Unable to connect to [%s]:%d game server"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); return; } sock_udp_set_non_block(sock_server_udp); - sprintf(status, "Connect to %s %d UDP game server", public_server_get_settingIP(), public_server_get_settingPort()); + sprintf(status, _("Connecting to [%s]:%d game server"), + public_server_get_settingIP(), public_server_get_settingPort()); setStatusString(status); sendStatusToGameServer(); @@ -156,31 +157,29 @@ void down_arena_draw() static void proto_ok(char *line) { - //printf("line = %s\n", line); + /*printf("line = %s\n", line);*/ fileSize = atoi(line + 3); fileOffset = 0; sprintf(path, "%s/%s.zip", home_director_get(), arenaNetName); - //printf("path = %s\n", path); + /*printf("path = %s\n", path);*/ file = fopen(path, "wb"); } static void proto_err(char *line) { - //printf("line = %s\n", line); + /*printf("line = %s\n", line);*/ setStatusString(line + 4); closeConnectFromDownServer(); } static void eventProto(char *line) { - if( strncmp(line, "OK", 2) == 0 ) - { + if (strncmp(line, "OK", 2) == 0) { proto_ok(line); } - if( strncmp(line, "ERR", 3) == 0 ) - { + if (strncmp(line, "ERR", 3) == 0) { proto_err(line); } } @@ -198,7 +197,7 @@ static int downArenaFile() fwrite(data, len, 1, file); fileOffset += len; - sprintf(status, "I down %d / %d", fileOffset, fileSize); + sprintf(status, _("Downloading: %d/%d"), fileOffset, fileSize); setStatusString(status); return len; @@ -213,7 +212,7 @@ static int eventRecvBuffer() memset(buffer, 0, STR_PROTO_SIZE); ret = sock_tcp_read(sock_server_tcp, buffer, STR_PROTO_SIZE - 1); - //if (ret <= 0) printf("sock_tcp_read = %d\n", ret); + /*if (ret <= 0) printf("sock_tcp_read = %d\n", ret);*/ if (ret < 0) { return -1; @@ -221,7 +220,7 @@ static int eventRecvBuffer() if (buffer_append(recvBuffer, buffer, ret) < 0) { char status[STR_SIZE]; - sprintf(status, "Error -- recv buffer is full"); + sprintf(status, _("Error! Receiving buffer is full")); setStatusString(status); closeConnectFromDownServer(); return -1; @@ -288,21 +287,19 @@ static void readArenaFromStatus() connectToDownServer(); - printf("arenaNetName = >>%s<<\n", arenaNetName); + printf("[Debug] arenaNetName: %s\n", arenaNetName); } } } static void eventStatus() { - if( timer_get_current_time() - timeSendMsg > DOWN_ARENA_MAX_TIEMOUT_LIMIT ) - { + 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); + 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(); } } @@ -358,7 +355,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_back) { screen_set("mainMenu"); @@ -372,14 +369,12 @@ void down_arena_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = - button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, - WINDOW_SIZE_Y - 80, eventWidget); + button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + WINDOW_SIZE_Y - 80, eventWidget); - label_status = - label_new("none", WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); + label_status = label_new(_("none"), WINDOW_SIZE_X / 2, 250, WIDGET_LABEL_CENTER); - screen_register( screen_new("downArena", down_arena_start, down_arena_event, + screen_register(screen_new("downArena", down_arena_start, down_arena_event, down_arena_draw, down_arena_stop)); } diff --git a/src/screen/gameType.c b/src/screen/gameType.c index 9513c7d..4493a95 100644 --- a/src/screen/gameType.c +++ b/src/screen/gameType.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -16,7 +15,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "gameType.h" @@ -57,7 +56,7 @@ static widget_t *textfield_port; static widget_t *selectSession; -static void loadSession(widget_t * p) +static void loadSession(widget_t *p) { director_t *director; int i; @@ -133,19 +132,19 @@ void game_type_draw() label_draw(label_session); select_draw(selectSession); } -#if 0 +/* if (check_server->status == TRUE) { game_type_set_ip(getParamElse("--ip", "127.0.0.1")); game_type_set_port(atoi(getParamElse("--port", "2200"))); } -#endif +*/ - if (choice_group_get_status(check_client) == TRUE) + if (choice_group_get_status(check_client) == TRUE) { button_draw(button_browser); + } button_draw(button_back); button_draw(button_play); - } void game_type_event() @@ -171,8 +170,9 @@ void game_type_event() button_event(button_back); button_event(button_play); - if (choice_group_get_status(check_client) == TRUE) + if (choice_group_get_status(check_client) == TRUE) { button_event(button_browser); + } } void stopScreenGameType() @@ -184,7 +184,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_back) { screen_set("mainMenu"); @@ -201,10 +201,11 @@ static void eventWidget(void *p) return; } - if (public_server_get_settingGameType() == NET_GAME_TYPE_CLIENT) + if (public_server_get_settingGameType() == NET_GAME_TYPE_CLIENT) { screen_set("downArena"); - else + } else { screen_set("chiceArena"); + } return; } @@ -222,9 +223,9 @@ void game_type_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = button_new(_("back"), 100, WINDOW_SIZE_Y - 100, eventWidget); - button_play = button_new(_("play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_browser = button_new(_("browser"), 300, 345, eventWidget); + button_back = button_new(_("Back"), 100, WINDOW_SIZE_Y - 100, eventWidget); + button_play = button_new(_("Play"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_browser = button_new(_("Browser"), 300, 345, eventWidget); listChoiceGroup = list_new(); check_none = choice_group_new(100, 150, FALSE, listChoiceGroup, eventWidget); @@ -243,22 +244,22 @@ void game_type_init() label_none = label_new(_("Local game"), 130, 145, WIDGET_LABEL_LEFT); label_server = label_new(_("Set up a server"), 130, 195, WIDGET_LABEL_LEFT); label_client = label_new(_("Network game"), 130, 245, WIDGET_LABEL_LEFT); - label_load_session = label_new("load session", 130, 295, WIDGET_LABEL_LEFT); + label_load_session = label_new(_("Load saved game"), 130, 295, WIDGET_LABEL_LEFT); label_ip = label_new(_("IP"), 300, 145, WIDGET_LABEL_LEFT); - label_port = label_new(_("port"), 300, 245, WIDGET_LABEL_LEFT); - label_session = label_new("load session :", 300, 145, WIDGET_LABEL_LEFT); + label_port = label_new(_("Port"), 300, 245, WIDGET_LABEL_LEFT); + label_session = label_new(_("Load saved game:"), 300, 145, WIDGET_LABEL_LEFT); textfield_ip = text_field_new(getParamElse("--ip", "127.0.0.1"), - WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN, - 300, 180); + WIDGET_TEXTFIELD_FILTER_IP_OR_DOMAIN, + 300, 180); textfield_port = text_field_new(getParamElse("--port", "6800"), - WIDGET_TEXTFIELD_FILTER_NUM, 300, 280); + WIDGET_TEXTFIELD_FILTER_NUM, 300, 280); selectSession = select_new(300, 185, eventWidget); - screen_register( screen_new("gameType", screen_startGameType, game_type_event, + screen_register(screen_new("gameType", screen_startGameType, game_type_event, game_type_draw, stopScreenGameType)); } @@ -296,7 +297,7 @@ int public_server_get_settingGameType() return NET_GAME_TYPE_CLIENT; } - assert(!_("Unknown game type!")); + assert(!_("[Error] Unknown game type")); return -1; } @@ -350,7 +351,7 @@ int public_server_get_settingProto() return PROTO_UDPv6; } - DEBUG_MSG(_("Unknown IP protocol!\n")); + DEBUG_MSG(_("[Error] Unknown version of IP protocol\n")); return -1; } diff --git a/src/screen/mainMenu.c b/src/screen/mainMenu.c index d196b08..7cc2228 100644 --- a/src/screen/mainMenu.c +++ b/src/screen/mainMenu.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <assert.h> @@ -11,7 +10,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "mainMenu.h" @@ -75,7 +74,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_play) { screen_set("gameType"); @@ -102,9 +101,8 @@ void main_menu_init() { image_t *image; - image = - image_add("screen_main.png", IMAGE_NO_ALPHA, "screen_main", - IMAGE_GROUP_BASE); + image = image_add("screen_main.png", IMAGE_NO_ALPHA, + "screen_main", IMAGE_GROUP_BASE); image_backgorund = wid_image_new(0, 0, image); button_play = button_new(_("Start game"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, 200, eventWidget); @@ -117,7 +115,7 @@ void main_menu_init() music_add("menu.ogg", "menu", MUSIC_GROUP_BASE); #endif - screen_register( screen_new("mainMenu", main_menu_start, main_menu_event, + screen_register(screen_new("mainMenu", main_menu_start, main_menu_event, main_menu_draw, main_menu_stop)); } diff --git a/src/screen/setting.c b/src/screen/setting.c index 34e067a..fb88da4 100644 --- a/src/screen/setting.c +++ b/src/screen/setting.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -18,8 +17,8 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" -# include "sound.h" +#include "music.h" +#include "sound.h" #endif #include "mainMenu.h" @@ -40,7 +39,7 @@ static widget_t *image_backgorund; static widget_t *button_back; -static widget_t *button_keys; // setting of keycontrols +static widget_t *button_keys; /* setting of keycontrols */ static widget_t *label_count_round; static widget_t *label_name_player1; @@ -196,8 +195,8 @@ static void eventWidget(void *p) widget_t *my_button; widget_t *my_check; - my_button = (widget_t *) (p); - my_check = (widget_t *) (p); + my_button = (widget_t *) p; + my_check = (widget_t *) p; if (my_button == button_back) { screen_set("mainMenu"); @@ -228,30 +227,27 @@ static void initSettingFile() configFile = text_file_load(path); if (configFile == NULL) { - fprintf(stderr, _("I am unable to load: \"%s\"!\n"), path); - fprintf(stderr, _("Creating: \"%s\"\n"), path); + fprintf(stderr, _("[Error] Unable to load config file [%s]\n"), path); + fprintf(stderr, _("[Debug] Creating config file [%s]\n"), path); configFile = text_file_new(path); } if (configFile == NULL) { - fprintf(stderr, _("I was unable to create: \"%s\"!\n"), path); + fprintf(stderr, _("[Error] Unable to create config file [%s]\n"), path); return; } loadValueFromConfigFile(configFile, "COUNT_ROUND", val, STR_SIZE, "15"); text_field_set_text(textfield_count_cound, val); - loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, - NAME_PLAYER_RIGHT); + loadValueFromConfigFile(configFile, "NAME_PLAYER_RIGHT", val, STR_SIZE, NAME_PLAYER_RIGHT); text_field_set_text(textfield_name_player1, val); - loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, - NAME_PLAYER_LEFT); + loadValueFromConfigFile(configFile, "NAME_PLAYER_LEFT", val, STR_SIZE, NAME_PLAYER_LEFT); text_field_set_text(textfield_name_player2, val); - loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, - "YES"); + loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES"); check_set_status(check[GUN_DUAL_SIMPLE], isYesOrNO(val)); loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES"); check_set_status(check[GUN_SCATTER], isYesOrNO(val)); @@ -268,8 +264,7 @@ static void initSettingFile() check_set_status(check[BONUS_SPEED], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_SHOT", val, STR_SIZE, "YES"); check_set_status(check[BONUS_SHOT], isYesOrNO(val)); - loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, - "YES"); + loadValueFromConfigFile(configFile, "BONUS_TELEPORT", val, STR_SIZE, "YES"); check_set_status(check[BONUS_TELEPORT], isYesOrNO(val)); loadValueFromConfigFile(configFile, "BONUS_GHOST", val, STR_SIZE, "YES"); check_set_status(check[BONUS_GHOST], isYesOrNO(val)); @@ -298,7 +293,7 @@ static void initSettingFile() static void saveAndDestroyConfigFile() { if (configFile == NULL) { - fprintf(stderr, _("I am unable to save configure file, because config file was not initialised!\n")); + fprintf(stderr, _("[Error] Unable to save config file - not initialized\n")); return; } @@ -324,11 +319,10 @@ static void saveAndDestroyConfigFile() setValueInConfigFile(configFile, "SOUND", getYesOrNo(check_get_status(check_sound))); #endif - if( choice_arena_get() != NULL ) - { + if (choice_arena_get() != NULL) { setValueInConfigFile(configFile, "ARENA", arena_file_get_net_name(choice_arena_get())); } - //TODO + /* TODO */ text_file_save(configFile); text_file_destroy(configFile); @@ -342,24 +336,24 @@ void setting_init() image = image_get(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = wid_image_new(0, 0, image); - button_back = button_new(_("back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); + button_back = button_new(_("Back"), WINDOW_SIZE_X - 200, WINDOW_SIZE_Y - 100, eventWidget); - button_keys = button_new(_("controls"), WINDOW_SIZE_X - 200, - button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget); + button_keys = button_new(_("Controls"), WINDOW_SIZE_X - 200, + button_back->y - WIDGET_BUTTON_HEIGHT - 10, eventWidget); #ifndef NO_SOUND label_music = label_new(_("Music:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); - check_music = check_new(label_music->x + label_music->w + 10, - WINDOW_SIZE_Y - 80, music_is_active(), eventWidget); + check_music = check_new(label_music->x + label_music->w + 10, WINDOW_SIZE_Y - 80, + music_is_active(), eventWidget); label_sound = label_new(_("Sound:"), check_music->x + WIDGET_CHECK_WIDTH + 10, - WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); + WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); - check_sound = check_new(label_sound->x + label_sound->w + 10, - WINDOW_SIZE_Y - 80, sound_is_active(), eventWidget); + check_sound = check_new(label_sound->x + label_sound->w + 10, WINDOW_SIZE_Y - 80, + sound_is_active(), eventWidget); label_ai = label_new(_("AI:"), check_sound->x + WIDGET_CHECK_WIDTH + 10, - WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); + WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); #else label_ai = label_new(_("AI:"), 100, WINDOW_SIZE_Y - 85, WIDGET_LABEL_LEFT); #endif @@ -371,17 +365,17 @@ void setting_init() label_name_player2 = label_new(_("Player 2:"), 100, WINDOW_SIZE_Y - 120, WIDGET_LABEL_LEFT); textfield_count_cound = text_field_new(getParamElse("--count", "15"), - WIDGET_TEXTFIELD_FILTER_NUM, - 110 + label_count_round->w, - WINDOW_SIZE_Y - 200); + WIDGET_TEXTFIELD_FILTER_NUM, + 110 + label_count_round->w, + WINDOW_SIZE_Y - 200); textfield_name_player1 = text_field_new(getParamElse("--name1", NAME_PLAYER_RIGHT), - WIDGET_TEXTFIELD_FILTER_ALPHANUM, - 110 + label_count_round->w, WINDOW_SIZE_Y - 160); + WIDGET_TEXTFIELD_FILTER_ALPHANUM, + 110 + label_count_round->w, WINDOW_SIZE_Y - 160); textfield_name_player2 = text_field_new(getParamElse("--name2", NAME_PLAYER_LEFT), - WIDGET_TEXTFIELD_FILTER_ALPHANUM, - 110 + label_count_round->w, WINDOW_SIZE_Y - 120); + WIDGET_TEXTFIELD_FILTER_ALPHANUM, + 110 + label_count_round->w, WINDOW_SIZE_Y - 120); for (i = GUN_DUAL_SIMPLE; i <= GUN_BOMBBALL; i++) { int x = 0; @@ -431,21 +425,21 @@ void setting_init() image_bonus_hidden = wid_image_new(580 + WIDGET_CHECK_WIDTH, 300, image_get(IMAGE_GROUP_BASE, "panel_hidden"));; statusbar = statusbar_new(400, 350); - statusbar_add(statusbar, check[GUN_DUAL_SIMPLE], "abc\n123\nkoniec"); - statusbar_add(statusbar, check[GUN_SCATTER], "check 1"); - statusbar_add(statusbar, check[GUN_TOMMY], "check 2"); - statusbar_add(statusbar, check[GUN_LASSER], "check 3"); - statusbar_add(statusbar, check[GUN_MINE], "check 4"); - statusbar_add(statusbar, check[GUN_BOMBBALL], "check 5"); - - statusbar_add(statusbar, check[BONUS_SPEED], "check 6"); - statusbar_add(statusbar, check[BONUS_SHOT], "check 7"); - statusbar_add(statusbar, check[BONUS_TELEPORT], "check 8"); - statusbar_add(statusbar, check[BONUS_GHOST], "check 9"); - statusbar_add(statusbar, check[BONUS_4X], "check 10"); - statusbar_add(statusbar, check[BONUS_HIDDEN], "check 11"); - - screen_register( screen_new("setting", screen_startSetting, setting_event, + statusbar_add(statusbar, check[GUN_DUAL_SIMPLE], _("Dual simple gun")); + statusbar_add(statusbar, check[GUN_SCATTER], _("Scatter")); + statusbar_add(statusbar, check[GUN_TOMMY], _("Tommy")); + statusbar_add(statusbar, check[GUN_LASSER], _("Laser beam")); + statusbar_add(statusbar, check[GUN_MINE], _("Mine")); + statusbar_add(statusbar, check[GUN_BOMBBALL], _("Bomb ball")); + + statusbar_add(statusbar, check[BONUS_SPEED], _("Speed bonus")); + statusbar_add(statusbar, check[BONUS_SHOT], _("Unfinite ammo")); + statusbar_add(statusbar, check[BONUS_TELEPORT], _("Unkillable bonus")); + statusbar_add(statusbar, check[BONUS_GHOST], _("No-walls bonus")); + 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, setting_draw, stopScreenSetting)); initSettingFile(); diff --git a/src/screen/settingKeys.c b/src/screen/settingKeys.c index f4338ab..a1bf4ad 100644 --- a/src/screen/settingKeys.c +++ b/src/screen/settingKeys.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -17,8 +16,8 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" -# include "sound.h" +#include "music.h" +#include "sound.h" #endif #include "mainMenu.h" @@ -70,9 +69,10 @@ static widget_t *tux_left_keyswitch_val; static widget_t *tux_left_keyfire_val; -/* TODO: add key images - * possible variant will be reusing widget_image for current widget_label so there wont - * be key names but only images */ +/* TODO: add key images + * possible variant will be reusing widget_image for current widget_label so there won't + * be key names but only images + */ static void hotkey_escape() { @@ -107,7 +107,7 @@ static void setKeytableFromConfigFile(textFile_t *configFile) loadValueFromConfigFile(configFile, "TUX_RIGHT_SHOOT", val, STR_SIZE, "48"); keytable[KEY_TUX_RIGHT_SHOOT] = atoi(val); - loadValueFromConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", val, STR_SIZE, "49"); + loadValueFromConfigFile(configFile, "TUX_RIGHT_SWITCH_WEAPON", val, STR_SIZE, "49"); keytable[KEY_TUX_RIGHT_SWITCH_WEAPON] = atoi(val); loadValueFromConfigFile(configFile, "TUX_LEFT_MOVE_UP", val, STR_SIZE, "119"); @@ -125,7 +125,7 @@ static void setKeytableFromConfigFile(textFile_t *configFile) loadValueFromConfigFile(configFile, "TUX_LEFT_SHOOT", val, STR_SIZE, "113"); keytable[KEY_TUX_LEFT_SHOOT] = atoi(val); - loadValueFromConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", val, STR_SIZE, "9"); + loadValueFromConfigFile(configFile, "TUX_LEFT_SWITCH_WEAPON", val, STR_SIZE, "9"); keytable[KEY_TUX_LEFT_SWITCH_WEAPON] = atoi(val); } @@ -138,13 +138,13 @@ void key_table_init() keycontrolFile = text_file_load(path); if (keycontrolFile == NULL) { - fprintf(stderr, _("I was unable to load file: %s\n"), path); - fprintf(stderr, _("I try to create file: %s\n"), path); + fprintf(stderr, _("[Error] Unable to load config file [%s]\n"), path); + fprintf(stderr, _("[Debug] Creating config file [%s]\n"), path); keycontrolFile = text_file_new(path); if (keycontrolFile == NULL) { - fprintf(stderr, _("I was unable to create file: %s\n"), path); + fprintf(stderr, _("[Error] Unable to create config file [%s]\n"), path); return; } } @@ -154,7 +154,7 @@ void key_table_init() int key_table_get_key(int n) { -// printf("keytable[n] = %d\n", keytable[n]); + /*printf("keytable[n] = %d\n", keytable[n]);*/ return keytable[n]; } @@ -217,13 +217,14 @@ static void eventWidget(void *p) widget_t *button; widget_t *catcher; - button = (widget_t *) (p); - catcher = (widget_t *) (p); + button = (widget_t *) p; + catcher = (widget_t *) p; - if (button == button_back) + if (button == button_back) { screen_set("setting"); + } - //events on value + /* events on value */ if ((catcher == tux_left_keyup_val) || (catcher == tux_left_keydown_val) || (catcher == tux_left_keyleft_val) || @@ -237,8 +238,9 @@ static void eventWidget(void *p) (catcher == tux_right_keyswitch_val) || (catcher == tux_right_keyfire_val)) { /* draw press any key picture - this will be done by widget catchkey - check if there is no other key with new value (what to revert if yes?) */ + this will be done by widget catchkey + check if there is no other key with new value (what to revert if yes?) + */ refreshKeytable(); } @@ -284,14 +286,14 @@ void setting_key_int() tux_left_keydown = label_new(_("Down:"), tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT); tux_left_keyleft = label_new(_("Left:"), tux_left_keyup->x, tux_left_keydown->y + 20, WIDGET_LABEL_LEFT); tux_left_keyright = label_new(_("Right:"), tux_left_keyup->x, tux_left_keyleft->y + 20, WIDGET_LABEL_LEFT); - tux_left_keyfire = label_new(_("Fire gun:"), tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT); + tux_left_keyfire = label_new(_("Fire:"), tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT); tux_left_keyswitch = label_new(_("Switch gun:"), tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT); tux_right = label_new(_("Player 1"), WINDOW_SIZE_X / 2 + WINDOW_SIZE_X / 4, tux_left->y, WIDGET_LABEL_CENTER); tux_right_keyup = label_new(_("Up:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left->y + 50, WIDGET_LABEL_LEFT); tux_right_keydown = label_new(_("Down:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyup->y + 20, WIDGET_LABEL_LEFT); tux_right_keyleft = label_new(_("Left:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_right_keydown->y + 20, WIDGET_LABEL_LEFT); tux_right_keyright = label_new(_("Right:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_right_keyleft->y + 20, WIDGET_LABEL_LEFT); - tux_right_keyfire = label_new(_("Fire gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT); + tux_right_keyfire = label_new(_("Fire:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyright->y + 20, WIDGET_LABEL_LEFT); tux_right_keyswitch = label_new(_("Switch gun:"), WINDOW_SIZE_X / 2 + tux_left_keyup->x, tux_left_keyfire->y + 20, WIDGET_LABEL_LEFT); tux_left_keyup_val = catch_key_new(keytable[6], tux_left_keyup->x + 200, tux_left->y + 55, eventWidget); @@ -306,8 +308,8 @@ void setting_key_int() tux_right_keyright_val = catch_key_new(keytable[1], WINDOW_SIZE_X / 2 + tux_left_keyup_val->x, tux_right_keyleft->y + 25, eventWidget); 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", screen_startSettingKeys, setting_key_event, setting_key_draw, stopScreenSettingKeys)); } void key_table_quit() @@ -388,4 +390,3 @@ void setting_key_quit() button_destroy(button_back); } - diff --git a/src/screen/table.c b/src/screen/table.c index ad7232f..993ff18 100644 --- a/src/screen/table.c +++ b/src/screen/table.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -14,7 +13,7 @@ #include "hotKey.h" #ifndef NO_SOUND -# include "music.h" +#include "music.h" #endif #include "table.h" @@ -87,7 +86,7 @@ static void eventWidget(void *p) { widget_t *button; - button = (widget_t *) (p); + button = (widget_t *) p; if (button == button_back) { screen_set("mainMenu"); @@ -99,7 +98,7 @@ static void setWidgetLabel() int i; if (textFile == NULL) { - fprintf(stderr, _("Highscore file: \"%s\" was not loaded!"), SCREEN_TABLE_FILE_HIGHSCORE_NAME); + fprintf(stderr, _("[Error] Didn't load the high score file [%s]"), SCREEN_TABLE_FILE_HIGHSCORE_NAME); return; } @@ -148,20 +147,20 @@ static void loadHighscoreFile() textFile = text_file_load(path); if (textFile == NULL) { - fprintf(stderr, _("I am unable to load: \"%s\"!\n"), path); - fprintf(stderr, _("Creating: \"%s\"\n"), path); + fprintf(stderr, _("[Error] Unable to load the high score file [%s]\n"), path); + fprintf(stderr, _("[Debug] Creating the high score file [%s]\n"), path); textFile = text_file_new(path); } else { return; } if (textFile == NULL) { - fprintf(stderr, _("I was unable to create: \"%s\"!\n"), path); + fprintf(stderr, _("[Error] Unable to create the high score file [%s]\n"), path); return; } for (i = 0; i < SCREEN_TABLE_MAX_PLAYERS; i++) { - list_add(textFile->text, strdup("no_name 0")); + list_add(textFile->text, strdup("--- 0")); } text_file_save(textFile); @@ -201,8 +200,8 @@ void table_init() image = image_add("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE); image_backgorund = wid_image_new(0, 0, image); - button_back = button_new(_("back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, - WINDOW_SIZE_Y - 100, eventWidget); + button_back = button_new(_("Back"), WINDOW_SIZE_X / 2 - WIDGET_BUTTON_WIDTH / 2, + WINDOW_SIZE_Y - 100, eventWidget); loadHighscoreFile(); listWidgetLabelNumer = NULL; diff --git a/src/screen/world.c b/src/screen/world.c index 8bb7215..d573448 100644 --- a/src/screen/world.c +++ b/src/screen/world.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <assert.h> @@ -32,8 +31,8 @@ #include "saveLoad.h" #ifndef NO_SOUND -# include "music.h" -# include "sound.h" +#include "music.h" +#include "sound.h" #endif #include "screen.h" @@ -63,10 +62,10 @@ void setGameType() int ret = 0; ret = net_multiplayer_init(public_server_get_settingGameType(), public_server_get_settingIP(), - public_server_get_settingPort(), public_server_get_settingProto()); + public_server_get_settingPort(), public_server_get_settingProto()); if (ret != 0) { - fprintf(stderr, _("Network initialization error!\n")); + fprintf(stderr, _("[Error] Unable to initialize network\n")); world_do_end(); } } @@ -96,15 +95,15 @@ static void timer_endArena() void world_inc_round() { if (arena->max_countRound == WORLD_COUNT_ROUND_UNLIMITED || - arena->countRound >= arena->max_countRound) { + arena->countRound >= arena->max_countRound) { return; } arena->countRound++; - //printf("count %d/%d\n", count, max_count); + /*printf("count %d/%d\n", count, max_count);*/ if (arena->countRound >= arena->max_countRound) { - //printf("count %d ending\n", count); + /*printf("count %d ending\n", count);*/ #ifndef NO_SOUND sound_play("end", SOUND_GROUP_BASE); #endif @@ -117,7 +116,7 @@ void prepareArena() tux_t *tux; char name[STR_NAME_SIZE]; - //printf("public_server_get_settingAI = %s\n", public_server_get_settingAI()); + /*printf("public_server_get_settingAI = %s\n", public_server_get_settingAI());*/ arena_set_current(NULL); tuxWithControlRightKeyboard = NULL; tuxWithControlLeftKeyboard = NULL; @@ -128,51 +127,51 @@ void prepareArena() } switch (net_multiplayer_get_game_type()) { - case NET_GAME_TYPE_NONE: - world_set_arena(choice_arena_get()); - item_add_new_item(arena->spaceItem, ID_UNKNOWN); - public_server_get_settingCountRound(&arena->max_countRound); - - tux = tux_new(); - tux->control = TUX_CONTROL_KEYBOARD_RIGHT; - tuxWithControlRightKeyboard = tux; - public_server_get_setting_name_right(name); - tux_set_name(tux, name); - space_add(arena->spaceTux, tux); - - tux = tux_new(); - tux->control = TUX_CONTROL_KEYBOARD_LEFT; - tuxWithControlLeftKeyboard = tux; - public_server_get_settingNameLeft(name); - tux_set_name(tux, name); - space_add(arena->spaceTux, tux); - - if (setting_is_ai()) { - tux->control = TUX_CONTROL_AI; - - if (module_load("libmodAI") != 0) { - tux->control = TUX_CONTROL_KEYBOARD_LEFT; + case NET_GAME_TYPE_NONE: + world_set_arena(choice_arena_get()); + item_add_new_item(arena->spaceItem, ID_UNKNOWN); + public_server_get_settingCountRound(&arena->max_countRound); + + tux = tux_new(); + tux->control = TUX_CONTROL_KEYBOARD_RIGHT; + tuxWithControlRightKeyboard = tux; + public_server_get_setting_name_right(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); + + tux = tux_new(); + tux->control = TUX_CONTROL_KEYBOARD_LEFT; + tuxWithControlLeftKeyboard = tux; + public_server_get_settingNameLeft(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); + + if (setting_is_ai()) { + tux->control = TUX_CONTROL_AI; + + if (module_load("libmodAI") != 0) { + tux->control = TUX_CONTROL_KEYBOARD_LEFT; + } } - } - //printf("game_type_load_session = %s\n", game_type_load_session()); + /*printf("game_type_load_session = %s\n", game_type_load_session());*/ - break; + break; - case NET_GAME_TYPE_SERVER: - world_set_arena(choice_arena_get()); - item_add_new_item(arena->spaceItem, ID_UNKNOWN); - public_server_get_settingCountRound(&arena->max_countRound); + case NET_GAME_TYPE_SERVER: + world_set_arena(choice_arena_get()); + item_add_new_item(arena->spaceItem, ID_UNKNOWN); + public_server_get_settingCountRound(&arena->max_countRound); - tux = tux_new(); - tux->control = TUX_CONTROL_KEYBOARD_RIGHT; - tuxWithControlRightKeyboard = tux; - public_server_get_setting_name_right(name); - tux_set_name(tux, name); - space_add(arena->spaceTux, tux); - break; + tux = tux_new(); + tux->control = TUX_CONTROL_KEYBOARD_RIGHT; + tuxWithControlRightKeyboard = tux; + public_server_get_setting_name_right(name); + tux_set_name(tux, name); + space_add(arena->spaceTux, tux); + break; - case NET_GAME_TYPE_CLIENT: - break; + case NET_GAME_TYPE_CLIENT: + break; } } @@ -216,80 +215,92 @@ static void control_keyboard_right(tux_t *tux) countKey = 0; - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) { countKey++; +} - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED - && tux->isCanSwitchGun == TRUE) { + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_SWITCH_WEAPON)] == SDL_PRESSED && + tux->isCanSwitchGun == TRUE) { netAction(tux, TUX_SWITCH_GUN); tux_action(tux, TUX_SWITCH_GUN); } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED - && tux->isCanShot == TRUE) { + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_SHOOT)] == SDL_PRESSED && + tux->isCanShot == TRUE) { netAction(tux, TUX_SHOT); tux_action(tux, TUX_SHOT); } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_UP)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_UP)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_UP)) { goto tuUp; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_RIGHT_MOVE_UP); + } netAction(tux, TUX_UP); tux_action(tux, TUX_UP); - tuUp:; + tuUp:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT)) { goto tuRight; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_RIGHT_MOVE_RIGHT); + } netAction(tux, TUX_RIGHT); tux_action(tux, TUX_RIGHT); - tuRight:; + tuRight:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT)) { goto tuLeft; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_RIGHT_MOVE_LEFT); + } netAction(tux, TUX_LEFT); tux_action(tux, TUX_LEFT); - tuLeft:; + tuLeft:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN)) { goto tuDown; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_RIGHT_MOVE_DOWN); + } netAction(tux, TUX_DOWN); tux_action(tux, TUX_DOWN); - tuDown:; + tuDown:; } } @@ -305,17 +316,21 @@ static void control_keyboard_left(tux_t *tux) countKey = 0; - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) { countKey++; + } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) { countKey++; + } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_SWITCH_WEAPON)] == SDL_PRESSED) { if (tux->isCanSwitchGun == TRUE) { @@ -323,58 +338,65 @@ static void control_keyboard_left(tux_t *tux) } } - if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED - && tux->isCanShot == TRUE) { + if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_SHOOT)] == SDL_PRESSED && + tux->isCanShot == TRUE) { tux_action(tux, TUX_SHOT); } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_UP)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_UP)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_UP)) { goto tuUp; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_LEFT_MOVE_UP); + } tux_action(tux, TUX_UP); - tuUp:; + tuUp:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT)) { goto tuRight; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_LEFT_MOVE_RIGHT); + } tux_action(tux, TUX_RIGHT); - tuRight:; - + tuRight:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT)) { goto tuLeft; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_LEFT_MOVE_LEFT); + } tux_action(tux, TUX_LEFT); - tuLeft:; + tuLeft:; } if (mapa[(SDLKey) key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN)] == SDL_PRESSED) { - if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN)) + if (countKey > 1 && lastKey == key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN)) { goto tuDown; + } - if (countKey == 1) + if (countKey == 1) { lastKey = key_table_get_key(KEY_TUX_LEFT_MOVE_DOWN); + } tux_action(tux, TUX_DOWN); - tuDown:; + tuDown:; } } @@ -400,7 +422,7 @@ tux_t *world_get_control_tux(int control_type) return NULL; } -void world_set_control_tux(tux_t * tux, int control_type) +void world_set_control_tux(tux_t *tux, int control_type) { switch (control_type) { case TUX_CONTROL_KEYBOARD_RIGHT: @@ -412,7 +434,7 @@ void world_set_control_tux(tux_t * tux, int control_type) } } -void world_tux_control(tux_t * p) +void world_tux_control(tux_t *p) { assert(p != NULL); @@ -422,15 +444,15 @@ void world_tux_control(tux_t * p) switch (p->control) { case TUX_CONTROL_NONE: - assert(!_("Tux has not defined controls!")); + assert(!_("[Error] Controls not defined")); break; - + case TUX_CONTROL_KEYBOARD_LEFT: if (chat_is_active() == FALSE) { control_keyboard_left(p); } break; - + case TUX_CONTROL_KEYBOARD_RIGHT: if (chat_is_active() == FALSE) { control_keyboard_right(p); @@ -453,7 +475,7 @@ void world_event() if (pauza_is_active() == FALSE && save_dialog_is_active() == FALSE) { arena_event(arena); - //module_event(); + /*module_event();*/ } thisTux = world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT); @@ -471,7 +493,6 @@ void world_event() pauza_event(); term_event(); save_dialog_event(); - } static void hotkey_escape() @@ -557,7 +578,6 @@ void stoptWorld() term_quit(); save_dialog_quit(); - #ifndef NO_SOUND music_stop(); #endif @@ -601,6 +621,6 @@ void world_init() void world_quit() { - DEBUG_MSG(_("Quitting screen world\n")); + DEBUG_MSG(_("[Debug] Shutting down the world screen\n")); isScreenWorldInit = FALSE; } diff --git a/src/server/publicServer.c b/src/server/publicServer.c index 2ac3ec1..6ba7e86 100644 --- a/src/server/publicServer.c +++ b/src/server/publicServer.c @@ -83,8 +83,8 @@ void daemonize() ipid = getpid() + 1; printf("The Tuxanci game server started with PID %d\n", ipid); - /* fork again so we become process group leader - * and cannot regain a controlling tty + /* fork again so we become process group leader + * and cannot regain a controlling tty */ i = fork(); @@ -189,7 +189,7 @@ static int public_server_register() } #else /* __WIN32__ */ unsigned long arg = 1; - // Operation is FIONBIO. Parameter is pointer on non-zero number. + /* Operation is FIONBIO. Parameter is pointer on non-zero number */ if (ioctlsocket(s, FIONBIO, &arg) == SOCKET_ERROR) { WSACleanup(); return -1; @@ -198,8 +198,9 @@ static int public_server_register() if (connect(s, (struct sockaddr *) &server, sizeof(server)) == -1) { #ifndef __WIN32__ - if (errno != EINPROGRESS) + if (errno != EINPROGRESS) { return -1; + } #else /* __WIN32__ */ if (WSAGetLastError() != WSAEWOULDBLOCK) { WSACleanup(); |