summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/chat.c317
-rw-r--r--src/client/chat.h18
-rw-r--r--src/client/client.c434
-rw-r--r--src/client/client.h10
-rw-r--r--src/client/configFile.c176
-rw-r--r--src/client/configFile.h10
-rw-r--r--src/client/font.c143
-rw-r--r--src/client/font.h24
-rw-r--r--src/client/game.c125
-rw-r--r--src/client/game.h2
-rw-r--r--src/client/hotKey.c169
-rw-r--r--src/client/hotKey.h4
-rw-r--r--src/client/image.c174
-rw-r--r--src/client/image.h28
-rw-r--r--src/client/interface.c326
-rw-r--r--src/client/interface.h28
-rw-r--r--src/client/keyboardBuffer.c137
-rw-r--r--src/client/keyboardBuffer.h21
-rw-r--r--src/client/layer.c242
-rw-r--r--src/client/layer.h33
-rw-r--r--src/client/panel.c287
-rw-r--r--src/client/panel.h24
-rw-r--r--src/client/pauza.c58
-rw-r--r--src/client/pauza.h6
-rw-r--r--src/client/radar.c136
-rw-r--r--src/client/radar.h18
-rw-r--r--src/client/saveDialog.c151
-rw-r--r--src/client/saveDialog.h12
-rw-r--r--src/client/saveLoad.c351
-rw-r--r--src/client/saveLoad.h6
-rw-r--r--src/client/screen.c193
-rw-r--r--src/client/screen.h21
-rw-r--r--src/client/term.c210
-rw-r--r--src/client/term.h8
34 files changed, 1859 insertions, 2043 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
index c6d0325..ceb4796 100644
--- a/src/client/chat.c
+++ b/src/client/chat.c
@@ -33,226 +33,213 @@ static bool_t receivedNewMsg;
static void hotkey_chat();
-static void
-hotkey_chat()
+static void hotkey_chat()
{
- chat_active = TRUE;
- receivedNewMsg = FALSE;
+ chat_active = TRUE;
+ receivedNewMsg = FALSE;
- disableHotKey(SDLK_RETURN);
- disableHotKey(SDLK_p);
+ disableHotKey(SDLK_RETURN);
+ disableHotKey(SDLK_p);
- enableKeyboardBuffer();
- clearKeyboardBuffer();
+ enableKeyboardBuffer();
+ clearKeyboardBuffer();
}
-void
-initChat()
+void initChat()
{
- g_chat =
- addImageData("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER);
-
- listText = newList();
- strcpy(line, "");
- chat_active = FALSE;
- registerHotKey(SDLK_RETURN, hotkey_chat);
-
- receivedNewMsg = FALSE;
- line_time = 0;
- line_atime = 0;
- timeBlick = 0;
+ g_chat =
+ addImageData("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER);
+
+ listText = newList();
+ strcpy(line, "");
+ chat_active = FALSE;
+ registerHotKey(SDLK_RETURN, hotkey_chat);
+
+ receivedNewMsg = FALSE;
+ line_time = 0;
+ line_atime = 0;
+ timeBlick = 0;
}
-void
-drawChat()
+void drawChat()
{
- char str[STR_SIZE];
- int i;
+ char str[STR_SIZE];
+ int i;
- if (chat_active == FALSE) {
- return;
- }
+ if (chat_active == FALSE) {
+ return;
+ }
- drawImage(g_chat,
- CHAT_LOCATION_X, CHAT_LOCATION_Y,
- 0, 0, CHAT_SIZE_X, CHAT_SIZE_Y);
+ drawImage(g_chat,
+ CHAT_LOCATION_X, CHAT_LOCATION_Y,
+ 0, 0, CHAT_SIZE_X, CHAT_SIZE_Y);
- for (i = 0; i < listText->count; i++) {
- char *s;
+ for (i = 0; i < listText->count; i++) {
+ char *s;
- s = (char *) listText->list[i];
+ s = (char *) listText->list[i];
- drawFontMaxSize(s,
- CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20,
- CHAT_SIZE_X - 10, 20, COLOR_WHITE);
- }
+ drawFontMaxSize(s,
+ CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20,
+ CHAT_SIZE_X - 10, 20, COLOR_WHITE);
+ }
- strcpy(str, line);
+ strcpy(str, line);
- if (timeBlick > CHAT_TIME_BLICK_CURSOR / 2) {
- strcat(str, "\f");
- }
+ if (timeBlick > CHAT_TIME_BLICK_CURSOR / 2) {
+ strcat(str, "\f");
+ }
- timeBlick++;
+ timeBlick++;
- if (timeBlick == CHAT_TIME_BLICK_CURSOR) {
- timeBlick = 0;
- }
+ if (timeBlick == CHAT_TIME_BLICK_CURSOR) {
+ timeBlick = 0;
+ }
- drawFont(str, CHAT_LOCATION_X + 5,
- (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE);
+ drawFont(str, CHAT_LOCATION_X + 5,
+ (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE);
}
-static void
-processMessageKey(SDL_keysym keysym)
+static void processMessageKey(SDL_keysym keysym)
{
- int w, h;
- int len;
- //int i;
-
- if (line_atime < 100)
- line_atime++;
-
- len = strlen(line);
- getTextSize(line, &w, &h);
-
- if (w > CHAT_SIZE_X - 40) {
- return;
- }
-
- /* processing of backspace */
- if (keysym.sym == SDLK_BACKSPACE && len > 0) {
- line[len - 1] = '\0';
- return;
- }
-
- /* processing of printable chars but not letters */
- if ((keysym.sym >= SDLK_SPACE && keysym.sym <= SDLK_AT)
- || (keysym.sym >= SDLK_LEFTBRACKET && keysym.sym <= SDLK_BACKQUOTE)) {
- /* here would be much better to put 'strcat' as 'line' is expected
- * to be full of '0' up to its end
- */
- line[len] = keysym.sym;
- }
-
- /* processing of letters */
- if (keysym.sym >= SDLK_a && keysym.sym <= SDLK_z) {
- char c = keysym.sym;
- if (keysym.mod == KMOD_SHIFT) {
- c = toupper(c);
- }
- /* here would be much better to put 'strcat' as 'line' is expected
- * to be full of '0' up to its end
- */
- line[len] = c;
- }
-
- return;
+ int w, h;
+ int len;
+ //int i;
+
+ if (line_atime < 100)
+ line_atime++;
+
+ len = strlen(line);
+ getTextSize(line, &w, &h);
+
+ if (w > CHAT_SIZE_X - 40) {
+ return;
+ }
+
+ /* processing of backspace */
+ if (keysym.sym == SDLK_BACKSPACE && len > 0) {
+ line[len - 1] = '\0';
+ return;
+ }
+
+ /* processing of printable chars but not letters */
+ if ((keysym.sym >= SDLK_SPACE && keysym.sym <= SDLK_AT)
+ || (keysym.sym >= SDLK_LEFTBRACKET && keysym.sym <= SDLK_BACKQUOTE)) {
+ /* here would be much better to put 'strcat' as 'line' is expected
+ * to be full of '0' up to its end
+ */
+ line[len] = keysym.sym;
+ }
+
+ /* processing of letters */
+ if (keysym.sym >= SDLK_a && keysym.sym <= SDLK_z) {
+ char c = keysym.sym;
+ if (keysym.mod == KMOD_SHIFT) {
+ c = toupper(c);
+ }
+ /* here would be much better to put 'strcat' as 'line' is expected
+ * to be full of '0' up to its end
+ */
+ line[len] = c;
+ }
+
+ return;
}
-static void
-sendNewMessage()
+static void sendNewMessage()
{
- if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
- proto_send_chat_client(line);
- }
+ if (getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
+ proto_send_chat_client(line);
+ }
- if (getNetTypeGame() == NET_GAME_TYPE_SERVER) {
- char out[STR_PROTO_SIZE];
+ if (getNetTypeGame() == NET_GAME_TYPE_SERVER) {
+ char out[STR_PROTO_SIZE];
- snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n",
- getControlTux(TUX_CONTROL_KEYBOARD_RIGHT)->name, line);
+ snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n",
+ getControlTux(TUX_CONTROL_KEYBOARD_RIGHT)->name, line);
- proto_send_chat_server(PROTO_SEND_ALL, NULL, out);
- }
+ proto_send_chat_server(PROTO_SEND_ALL, NULL, out);
+ }
}
-static void
-eventChatDisable()
+static void eventChatDisable()
{
- chat_active = FALSE;
- memset(line, '\0', STR_SIZE);
+ chat_active = FALSE;
+ memset(line, '\0', STR_SIZE);
- enableHotKey(SDLK_RETURN);
- enableHotKey(SDLK_p);
+ enableHotKey(SDLK_RETURN);
+ enableHotKey(SDLK_p);
- disableKeyboardBuffer();
- clearKeyboardBuffer();
+ disableKeyboardBuffer();
+ clearKeyboardBuffer();
}
-static void
-eventChatEnable()
+static void eventChatEnable()
{
- /* The chat window is displayed. It is needed to process all keys in the buffer
- * but when ENTER is pressed the chat row is sent to the server
- */
-
- while (isAnyKeyInKeyboardBuffer() == TRUE) {
- SDL_keysym key;
- key = popKeyFromKeyboardBuffer();
-
- if (key.sym == SDLK_RETURN) {
- if (strcmp(line, "") != 0) {
- /* the chat row is already written - it is needed to send it */
- sendNewMessage();
- memset(line, '\0', STR_SIZE);
- continue; /* continue with other keys */
- }
- else {
- /* the chat row is empty - it is needed to turn off the chat window */
- eventChatDisable();
- /* turn off key catching into the buffer and clear the buffer */
- //disableKeyboardBuffer();
- //clearKeyboardBuffer();
- }
- }
-
- processMessageKey(key);
- }
+ /* The chat window is displayed. It is needed to process all keys in the buffer
+ * but when ENTER is pressed the chat row is sent to the server
+ */
+
+ while (isAnyKeyInKeyboardBuffer() == TRUE) {
+ SDL_keysym key;
+ key = popKeyFromKeyboardBuffer();
+
+ if (key.sym == SDLK_RETURN) {
+ if (strcmp(line, "") != 0) {
+ /* the chat row is already written - it is needed to send it */
+ sendNewMessage();
+ memset(line, '\0', STR_SIZE);
+ continue; /* continue with other keys */
+ } else {
+ /* the chat row is empty - it is needed to turn off the chat window */
+ eventChatDisable();
+ /* turn off key catching into the buffer and clear the buffer */
+ //disableKeyboardBuffer();
+ //clearKeyboardBuffer();
+ }
+ }
+
+ processMessageKey(key);
+ }
}
/**
* Processing of chat 'events'
*/
-void
-eventChat()
+void eventChat()
{
- if (isChatActive()) {
- eventChatEnable();
- }
+ if (isChatActive()) {
+ eventChatEnable();
+ }
}
-bool_t
-isChatActive()
+bool_t isChatActive()
{
- return chat_active;
+ return chat_active;
}
-bool_t
-isRecivedNewMsg()
+bool_t isRecivedNewMsg()
{
- return receivedNewMsg;
+ return receivedNewMsg;
}
-void
-addToChat(char *s)
+void addToChat(char *s)
{
- addList(listText, strdup(s));
+ addList(listText, strdup(s));
- if (listText->count > CHAT_MAX_LINES) {
- delListItem(listText, 0, free);
- }
+ if (listText->count > CHAT_MAX_LINES) {
+ delListItem(listText, 0, free);
+ }
- if (chat_active == FALSE) {
- receivedNewMsg = TRUE;
- }
+ if (chat_active == FALSE) {
+ receivedNewMsg = TRUE;
+ }
}
-void
-quitChat()
+void quitChat()
{
- assert(listText != NULL);
+ assert(listText != NULL);
- unregisterHotKey(SDLK_RETURN);
- destroyListItem(listText, free);
+ unregisterHotKey(SDLK_RETURN);
+ destroyListItem(listText, free);
}
diff --git a/src/client/chat.h b/src/client/chat.h
index fc6abc3..9022466 100644
--- a/src/client/chat.h
+++ b/src/client/chat.h
@@ -1,18 +1,18 @@
#ifndef CHAT_H
-#define CHAT_H
+# define CHAT_H
-#define CHAT_MAX_LINES 10
-#define CHAT_TIME_MULTIPLE 10
-#define CHAT_TIME_BLICK_CURSOR 20
-#define CHAT_LINE_WIDTH 320
+# define CHAT_MAX_LINES 10
+# define CHAT_TIME_MULTIPLE 10
+# define CHAT_TIME_BLICK_CURSOR 20
+# define CHAT_LINE_WIDTH 320
-#define CHAT_SIZE_X 320
-#define CHAT_SIZE_Y 240
+# define CHAT_SIZE_X 320
+# define CHAT_SIZE_Y 240
-#define CHAT_LOCATION_X (WINDOW_SIZE_X/2 - CHAT_SIZE_X/2)
-#define CHAT_LOCATION_Y (WINDOW_SIZE_Y/2 - CHAT_SIZE_Y/2)
+# define CHAT_LOCATION_X (WINDOW_SIZE_X/2 - CHAT_SIZE_X/2)
+# define CHAT_LOCATION_Y (WINDOW_SIZE_Y/2 - CHAT_SIZE_Y/2)
extern void initChat();
extern void drawChat();
diff --git a/src/client/client.c b/src/client/client.c
index 7ff9257..1f309fa 100644
--- a/src/client/client.c
+++ b/src/client/client.c
@@ -8,12 +8,12 @@
#include <sys/time.h>
#ifndef __WIN32__
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/select.h>
+# include <sys/ioctl.h>
+# include <sys/socket.h>
+# include <sys/select.h>
#else
-#include <io.h>
-#include <winsock2.h>
+# include <io.h>
+# include <winsock2.h>
#endif
#include "main.h"
@@ -45,337 +45,319 @@ static int traffic_down;
static int traffic_up;
#endif
-typedef struct proto_cmd_client_struct
-{
- char *name;
- int len;
- void (*fce_proto) (char *msg);
+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},
- {.name = "event",.len = 5,.fce_proto = proto_recv_event_client},
- {.name = "newtux",.len = 6,.fce_proto = proto_recv_newtux_client},
- {.name = "del",.len = 3,.fce_proto = proto_recv_del_client},
- {.name = "additem",.len = 7,.fce_proto = proto_recv_additem_client},
- {.name = "shot",.len = 4,.fce_proto = proto_recv_shot_client},
- {.name = "kill",.len = 4,.fce_proto = proto_recv_kill_client},
- {.name = "module",.len = 6,.fce_proto = proto_recv_module_client},
- {.name = "chat",.len = 4,.fce_proto = proto_recv_chat_client},
- {.name = "ping",.len = 4,.fce_proto = proto_recv_ping_client},
- {.name = "end",.len = 3,.fce_proto = proto_recv_end_client},
- {.name = "",.len = 0,.fce_proto = NULL},
+ {.name = "error",.len = 5,.fce_proto = proto_recv_error_client},
+ {.name = "init",.len = 4,.fce_proto = proto_recv_init_client},
+ {.name = "event",.len = 5,.fce_proto = proto_recv_event_client},
+ {.name = "newtux",.len = 6,.fce_proto = proto_recv_newtux_client},
+ {.name = "del",.len = 3,.fce_proto = proto_recv_del_client},
+ {.name = "additem",.len = 7,.fce_proto = proto_recv_additem_client},
+ {.name = "shot",.len = 4,.fce_proto = proto_recv_shot_client},
+ {.name = "kill",.len = 4,.fce_proto = proto_recv_kill_client},
+ {.name = "module",.len = 6,.fce_proto = proto_recv_module_client},
+ {.name = "chat",.len = 4,.fce_proto = proto_recv_chat_client},
+ {.name = "ping",.len = 4,.fce_proto = proto_recv_ping_client},
+ {.name = "end",.len = 3,.fce_proto = proto_recv_end_client},
+ {.name = "",.len = 0,.fce_proto = NULL},
};
-static proto_cmd_client_t *
-findCmdProto(char *msg)
+static proto_cmd_client_t *findCmdProto(char *msg)
{
- int len;
- int i;
+ int len;
+ int i;
- len = strlen(msg);
+ len = strlen(msg);
- for (i = 0; proto_cmd_list[i].len != 0; i++) {
- proto_cmd_client_t *thisCmd;
+ for (i = 0; proto_cmd_list[i].len != 0; i++) {
+ proto_cmd_client_t *thisCmd;
- thisCmd = &proto_cmd_list[i];
+ thisCmd = &proto_cmd_list[i];
- if (len >= thisCmd->len
- && strncmp(msg, thisCmd->name, thisCmd->len) == 0) {
- return thisCmd;
- }
- }
+ if (len >= thisCmd->len
+ && strncmp(msg, thisCmd->name, thisCmd->len) == 0) {
+ return thisCmd;
+ }
+ }
- return NULL;
+ return NULL;
}
-static int
-initUdpClient(char *ip, int port, int proto)
+static int initUdpClient(char *ip, int port, int proto)
{
- sock_server_udp = connectUdpSocket(ip, port, proto);
+ sock_server_udp = connectUdpSocket(ip, port, proto);
- if (sock_server_udp == NULL) {
- return -1;
- }
+ if (sock_server_udp == NULL) {
+ return -1;
+ }
#ifdef DEBUG
- printf(_("Connected to: %s on port: %d via UDP\n"), ip, port);
+ printf(_("Connected to: %s on port: %d via UDP\n"), ip, port);
#endif
- return 0;
+ return 0;
}
-int
-initClient(char *ip, int port, int proto)
+int initClient(char *ip, int port, int proto)
{
- char name[STR_NAME_SIZE];
- int ret;
+ char name[STR_NAME_SIZE];
+ int ret;
- listRecvMsg = newList();
- lastPing = getMyTime();
- lastPingServerAlive = getMyTime();
+ listRecvMsg = newList();
+ lastPing = getMyTime();
+ lastPingServerAlive = getMyTime();
#ifdef SUPPORT_TRAFFIC
- lastTraffic = getMyTime();
- traffic_down = 0;
- traffic_up = 0;
+ lastTraffic = getMyTime();
+ traffic_down = 0;
+ traffic_up = 0;
#endif
- clientRecvBuffer = newBuffer(CLIENT_BUFFER_LIMIT);
- clientSendBuffer = newBuffer(CLIENT_BUFFER_LIMIT);
+ clientRecvBuffer = newBuffer(CLIENT_BUFFER_LIMIT);
+ clientSendBuffer = newBuffer(CLIENT_BUFFER_LIMIT);
- ret = initUdpClient(ip, port, proto);
+ ret = initUdpClient(ip, port, proto);
- if (ret < 0) {
- return -1;
- }
+ if (ret < 0) {
+ return -1;
+ }
- getSettingNameRight(name);
- proto_send_hello_client(name);
+ getSettingNameRight(name);
+ proto_send_hello_client(name);
- return 0;
+ return 0;
}
-static void
-errorWithServer()
+static void errorWithServer()
{
- fprintf(stderr, _("Server did not respond!\n"));
- setMsgToAnalyze(_
- ("Server is not running or being blocked. I was unable to connect."));
- setWorldEnd();
+ fprintf(stderr, _("Server did not respond!\n"));
+ setMsgToAnalyze(_
+ ("Server is not running or being blocked. I was unable to connect."));
+ setWorldEnd();
}
-void
-sendServer(char *msg)
+void sendServer(char *msg)
{
- int ret;
+ int ret;
- assert(msg != NULL);
+ assert(msg != NULL);
- ret = -1;
+ ret = -1;
#ifndef PUBLIC_SERVER
- if (isParamFlag("--send")) {
- printf(_("Sending: \"%s\""), msg);
- }
-
+ if (isParamFlag("--send")) {
+ printf(_("Sending: \"%s\""), msg);
+ }
#endif
#ifdef SUPPORT_TRAFFIC
- traffic_up += strlen(msg);
+ traffic_up += strlen(msg);
#endif
- if (sock_server_udp != NULL) {
- ret =
- writeUdpSocket(sock_server_udp, sock_server_udp, msg,
- strlen(msg));
- }
+ if (sock_server_udp != NULL) {
+ ret =
+ writeUdpSocket(sock_server_udp, sock_server_udp, msg, strlen(msg));
+ }
- if (ret < 0) {
- errorWithServer();
- return;
- }
+ if (ret < 0) {
+ errorWithServer();
+ return;
+ }
}
-static int
-eventServerSelect()
+static int eventServerSelect()
{
- char buffer[STR_PROTO_SIZE];
- int ret;
-
- memset(buffer, 0, STR_PROTO_SIZE);
- ret = -1;
-
- if (sock_server_udp != NULL) {
- ret =
- readUdpSocket(sock_server_udp, sock_server_udp, buffer,
- STR_PROTO_SIZE - 1);
- }
-
- if (ret < 0) {
- errorWithServer();
- return ret;
- }
-
+ char buffer[STR_PROTO_SIZE];
+ int ret;
+
+ memset(buffer, 0, STR_PROTO_SIZE);
+ ret = -1;
+
+ if (sock_server_udp != NULL) {
+ ret =
+ readUdpSocket(sock_server_udp, sock_server_udp, buffer,
+ STR_PROTO_SIZE - 1);
+ }
+
+ if (ret < 0) {
+ errorWithServer();
+ return ret;
+ }
#ifdef SUPPORT_TRAFFIC
- traffic_down += ret;
+ traffic_down += ret;
#endif
- addList(listRecvMsg, strdup(buffer));
+ addList(listRecvMsg, strdup(buffer));
#if 0
- if (addBuffer(clientRecvBuffer, buffer, ret) < 0) {
- errorWithServer();
- return ret;
- }
-
- while (getBufferLine(clientRecvBuffer, buffer, STR_PROTO_SIZE) >= 0) {
- if (strlen(buffer) > 0) {
- addList(listRecvMsg, strdup(buffer));
- }
- }
+ if (addBuffer(clientRecvBuffer, buffer, ret) < 0) {
+ errorWithServer();
+ return ret;
+ }
+
+ while (getBufferLine(clientRecvBuffer, buffer, STR_PROTO_SIZE) >= 0) {
+ if (strlen(buffer) > 0) {
+ addList(listRecvMsg, strdup(buffer));
+ }
+ }
#endif
- return ret;
+ return ret;
}
-static void
-eventClientWorkRecvList()
+static void eventClientWorkRecvList()
{
- proto_cmd_client_t *protoCmd;
- char *line;
- int i;
+ proto_cmd_client_t *protoCmd;
+ char *line;
+ int i;
- /* obsluha udalosti od servera */
+ /* obsluha udalosti od servera */
- assert(listRecvMsg != NULL);
+ assert(listRecvMsg != NULL);
- for (i = 0; i < listRecvMsg->count; i++) {
- line = (char *) listRecvMsg->list[i];
- protoCmd = findCmdProto(line);
+ for (i = 0; i < listRecvMsg->count; i++) {
+ line = (char *) listRecvMsg->list[i];
+ protoCmd = findCmdProto(line);
#ifndef PUBLIC_SERVER
- if (isParamFlag("--recv")) {
- printf(_("Recieved: \"%s\""), line);
- }
+ if (isParamFlag("--recv")) {
+ printf(_("Recieved: \"%s\""), line);
+ }
#endif
- if (protoCmd != NULL) {
- protoCmd->fce_proto(line);
- lastPingServerAlive = getMyTime();
- }
- }
-
- destroyListItem(listRecvMsg, free);
- listRecvMsg = newList();
+ if (protoCmd != NULL) {
+ protoCmd->fce_proto(line);
+ lastPingServerAlive = getMyTime();
+ }
+ }
+
+ destroyListItem(listRecvMsg, free);
+ listRecvMsg = newList();
}
-static void
-eventPingServer()
+static void eventPingServer()
{
- my_time_t currentTime;
+ my_time_t currentTime;
- currentTime = getMyTime();
+ currentTime = getMyTime();
- if (currentTime - lastPing > CLIENT_TIMEOUT) {
- proto_send_ping_client();
- lastPing = getMyTime();
- }
+ if (currentTime - lastPing > CLIENT_TIMEOUT) {
+ proto_send_ping_client();
+ lastPing = getMyTime();
+ }
}
-static bool_t
-isServerAlive()
+static bool_t isServerAlive()
{
- my_time_t currentTime;
+ my_time_t currentTime;
- currentTime = getMyTime();
+ currentTime = getMyTime();
- if (currentTime - lastPingServerAlive > SERVER_TIMEOUT_ALIVE) {
- return FALSE;
- }
+ if (currentTime - lastPingServerAlive > SERVER_TIMEOUT_ALIVE) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-static void
-selectClientSocket()
+static void selectClientSocket()
{
- fd_set readfds;
- struct timeval tv;
- int max_fd;
- int sock;
- bool_t isNext;
+ fd_set readfds;
+ struct timeval tv;
+ int max_fd;
+ int sock;
+ bool_t isNext;
- max_fd = 0;
- sock = 0;
+ max_fd = 0;
+ sock = 0;
- if (sock_server_udp != NULL) {
- if (isServerAlive() == FALSE) {
- errorWithServer();
- return;
- }
- }
+ if (sock_server_udp != NULL) {
+ if (isServerAlive() == FALSE) {
+ errorWithServer();
+ return;
+ }
+ }
- do {
- isNext = FALSE;
+ do {
+ isNext = FALSE;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
- FD_ZERO(&readfds);
+ FD_ZERO(&readfds);
- if (sock_server_udp != NULL) {
- sock = sock_server_udp->sock;
- }
+ if (sock_server_udp != NULL) {
+ sock = sock_server_udp->sock;
+ }
- FD_SET(sock, &readfds);
- max_fd = sock;
- select(max_fd + 1, &readfds, (fd_set *) NULL, (fd_set *) NULL, &tv);
+ FD_SET(sock, &readfds);
+ max_fd = sock;
+ select(max_fd + 1, &readfds, (fd_set *) NULL, (fd_set *) NULL, &tv);
- if (FD_ISSET(sock, &readfds)) {
- if (eventServerSelect() > 0) {
- isNext = TRUE;
- }
- }
+ if (FD_ISSET(sock, &readfds)) {
+ if (eventServerSelect() > 0) {
+ isNext = TRUE;
+ }
+ }
- } while (isNext == TRUE);
+ } while (isNext == TRUE);
}
#ifdef SUPPORT_TRAFFIC
-static void
-eventTraffic()
+static void eventTraffic()
{
- my_time_t currentTime;
-
- currentTime = getMyTime();
-
- if (currentTime - lastTraffic > 5000) {
- lastTraffic = currentTime;
-#ifdef DEBUG
- printf(_("down: %d\n")
- _("up : %d\n"), traffic_down, traffic_up);
-#endif
- traffic_down = 0;
- traffic_up = 0;
- }
+ my_time_t currentTime;
+
+ currentTime = getMyTime();
+
+ if (currentTime - lastTraffic > 5000) {
+ lastTraffic = currentTime;
+# ifdef DEBUG
+ printf(_("down: %d\n")
+ _("up : %d\n"), traffic_down, traffic_up);
+# endif
+ traffic_down = 0;
+ traffic_up = 0;
+ }
}
#endif
-void
-eventClient()
+void eventClient()
{
#ifdef SUPPORT_TRAFFIC
- eventTraffic();
+ eventTraffic();
#endif
- eventPingServer();
- selectClientSocket();
- eventClientWorkRecvList();
+ eventPingServer();
+ selectClientSocket();
+ eventClientWorkRecvList();
}
-static void
-quitUdpClient()
+static void quitUdpClient()
{
- assert(sock_server_udp != NULL);
- closeUdpSocket(sock_server_udp);
+ assert(sock_server_udp != NULL);
+ closeUdpSocket(sock_server_udp);
#ifdef DEBUG
- printf(_("Closing UDP connection.\n"));
+ printf(_("Closing UDP connection.\n"));
#endif
}
-void
-quitClient()
+void quitClient()
{
- proto_send_end_client();
+ proto_send_end_client();
- assert(listRecvMsg != NULL);
+ assert(listRecvMsg != NULL);
- destroyListItem(listRecvMsg, free);
- destroyBuffer(clientRecvBuffer);
- destroyBuffer(clientSendBuffer);
+ destroyListItem(listRecvMsg, free);
+ destroyBuffer(clientRecvBuffer);
+ destroyBuffer(clientSendBuffer);
- if (sock_server_udp != NULL) {
- quitUdpClient();
- }
+ if (sock_server_udp != NULL) {
+ quitUdpClient();
+ }
}
diff --git a/src/client/client.h b/src/client/client.h
index bfde073..6795c92 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -1,15 +1,15 @@
#ifndef MY_CLIENT
-#define MY_CLIENT
+# define MY_CLIENT
-#include "main.h"
+# include "main.h"
-#define CLIENT_TIMEOUT 1000
-#define SERVER_TIMEOUT_ALIVE 5000
+# define CLIENT_TIMEOUT 1000
+# define SERVER_TIMEOUT_ALIVE 5000
-#define CLIENT_BUFFER_LIMIT 4096
+# define CLIENT_BUFFER_LIMIT 4096
extern int initClient(char *ip, int port, int proto);
extern void sendServer(char *msg);
diff --git a/src/client/configFile.c b/src/client/configFile.c
index 4df4d6e..71f4237 100644
--- a/src/client/configFile.c
+++ b/src/client/configFile.c
@@ -7,142 +7,136 @@
#include "main.h"
#include "configFile.h"
-int
-isYesOrNO(char *s)
+int isYesOrNO(char *s)
{
- if (s[0] == 'Y' || s[0] == 'y')
- return 1;
- return 0;
+ if (s[0] == 'Y' || s[0] == 'y')
+ return 1;
+ return 0;
}
-char *
-getYesOrNo(int n)
+char *getYesOrNo(int n)
{
- return (n != 0 ? "YES" : "NO");
+ return (n != 0 ? "YES" : "NO");
}
-int
-getValue(char *line, char *env, char *val, int len)
+int getValue(char *line, char *env, char *val, int len)
{
- char *offset_env;
- char *offset_val_begin;
- char *offset_val_end;
- char clone_env[STR_SIZE];
- int val_len;
+ char *offset_env;
+ char *offset_val_begin;
+ char *offset_val_end;
+ char clone_env[STR_SIZE];
+ int val_len;
- strcpy(clone_env, env);
+ strcpy(clone_env, env);
- offset_env = strstr(line, clone_env);
- if (offset_env == NULL)
- return -1;
+ offset_env = strstr(line, clone_env);
+ if (offset_env == NULL)
+ return -1;
- offset_val_begin = strchr(offset_env, '"');
- if (offset_val_begin == NULL)
- return -1;
+ offset_val_begin = strchr(offset_env, '"');
+ if (offset_val_begin == NULL)
+ return -1;
- offset_val_end = strchr(offset_val_begin + 1, '"');
- if (offset_val_end == NULL)
- return -1;
+ offset_val_end = strchr(offset_val_begin + 1, '"');
+ if (offset_val_end == NULL)
+ return -1;
- val_len = (int) (offset_val_end - (offset_val_begin + 1));
- if (val_len > len - 1)
- val_len = len - 1;
+ val_len = (int) (offset_val_end - (offset_val_begin + 1));
+ if (val_len > len - 1)
+ val_len = len - 1;
- memset(val, 0, len);
- memcpy(val, offset_val_begin + 1, val_len);
+ memset(val, 0, len);
+ memcpy(val, offset_val_begin + 1, val_len);
- return 0;
+ return 0;
}
-char *
-setValue(char *line, char *env, char *val)
+char *setValue(char *line, char *env, char *val)
{
- char *offset_env;
- char *offset_val_begin;
- char *offset_val_end;
- char clone_env[STR_SIZE];
- char clone[STR_SIZE];
+ char *offset_env;
+ char *offset_val_begin;
+ char *offset_val_end;
+ char clone_env[STR_SIZE];
+ char clone[STR_SIZE];
- //strcpy(clone_env, " ");
- strcpy(clone_env, env);
+ //strcpy(clone_env, " ");
+ strcpy(clone_env, env);
- offset_env = strstr(line, clone_env);
- if (offset_env == NULL)
- return NULL;
+ offset_env = strstr(line, clone_env);
+ if (offset_env == NULL)
+ return NULL;
- offset_val_begin = strchr(offset_env, '"');
- if (offset_val_begin == NULL)
- return NULL;
+ offset_val_begin = strchr(offset_env, '"');
+ if (offset_val_begin == NULL)
+ return NULL;
- offset_val_end = strchr(offset_val_begin + 1, '"');
- if (offset_val_end == NULL)
- return NULL;
+ offset_val_end = strchr(offset_val_begin + 1, '"');
+ if (offset_val_end == NULL)
+ return NULL;
- memset(clone, 0, STR_SIZE);
- strncpy(clone, line, (int) ((offset_val_begin - line) + 1));
- strcat(clone, val);
- strcat(clone, offset_val_end);
+ memset(clone, 0, STR_SIZE);
+ strncpy(clone, line, (int) ((offset_val_begin - line) + 1));
+ strcat(clone, val);
+ strcat(clone, offset_val_end);
- return strdup(clone);
+ return strdup(clone);
}
-int
-getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len)
+int getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len)
{
- int i;
- char *line;
+ int i;
+ char *line;
- for (i = 0; i < textFile->text->count; i++) {
- line = (char *) (textFile->text->list[i]);
+ for (i = 0; i < textFile->text->count; i++) {
+ line = (char *) (textFile->text->list[i]);
- //printf("env = %s line = %s\n", env, line);
+ //printf("env = %s line = %s\n", env, line);
- if (strncmp(line, env, strlen(env)) == 0) {
- return getValue(line, env, val, len);
- }
- }
+ if (strncmp(line, env, strlen(env)) == 0) {
+ return getValue(line, env, val, len);
+ }
+ }
- return -1;
+ return -1;
}
-int
-setValueInConfigFile(textFile_t * textFile, char *env, char *val)
+int setValueInConfigFile(textFile_t * textFile, char *env, char *val)
{
- int i;
- char *line;
- char *ret;
+ int i;
+ char *line;
+ char *ret;
- for (i = 0; i < textFile->text->count; i++) {
- line = (char *) (textFile->text->list[i]);
+ for (i = 0; i < textFile->text->count; i++) {
+ line = (char *) (textFile->text->list[i]);
- if (strncmp(line, env, strlen(env)) == 0) {
- ret = setValue(line, env, val);
+ if (strncmp(line, env, strlen(env)) == 0) {
+ ret = setValue(line, env, val);
- if (ret != NULL) {
- delListItem(textFile->text, i, free);
- insList(textFile->text, i, ret);
+ if (ret != NULL) {
+ delListItem(textFile->text, i, free);
+ insList(textFile->text, i, ret);
- return 0;
- }
- }
- }
+ return 0;
+ }
+ }
+ }
- return -1;
+ return -1;
}
void
loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len,
- char *butVal)
+ char *butVal)
{
- strcpy(val, butVal);
+ strcpy(val, butVal);
- if (getValueInConfigFile(textFile, env, val, len) != 0) {
- char line[STR_SIZE];
+ if (getValueInConfigFile(textFile, env, val, len) != 0) {
+ char line[STR_SIZE];
- sprintf(line, "%s=\"%s\"", env, butVal);
- addList(textFile->text, strdup(line));
+ sprintf(line, "%s=\"%s\"", env, butVal);
+ addList(textFile->text, strdup(line));
#ifdef DEBUG
- printf(_("ADDING: \"%s\" into config file.\n"), line);
+ printf(_("ADDING: \"%s\" into config file.\n"), line);
#endif
- }
+ }
}
diff --git a/src/client/configFile.h b/src/client/configFile.h
index f7f16fc..67dad48 100644
--- a/src/client/configFile.h
+++ b/src/client/configFile.h
@@ -1,10 +1,10 @@
#ifndef CONFIGFILE_H
-#define CONFIGFILE_H
+# define CONFIGFILE_H
-#include "main.h"
-#include "textFile.h"
+# include "main.h"
+# include "textFile.h"
extern int isYesOrNO(char *s);
extern char *getYesOrNo(int n);
@@ -13,10 +13,10 @@ extern int getValue(char *line, char *env, char *val, int len);
extern char *setValue(char *line, char *env, char *val);
extern int getValueInConfigFile(textFile_t * textFile, char *env, char *val,
- int len);
+ int len);
extern int setValueInConfigFile(textFile_t * textFile, char *env, char *val);
extern void loadValueFromConfigFile(textFile_t * textFile, char *env,
- char *val, int len, char *butVal);
+ char *val, int len, char *butVal);
#endif
diff --git a/src/client/font.c b/src/client/font.c
index faf46ea..282b3d9 100644
--- a/src/client/font.c
+++ b/src/client/font.c
@@ -7,136 +7,129 @@ static int fontSize;
static bool_t isFontInit = FALSE;
-bool_t
-isFontInicialized()
+bool_t isFontInicialized()
{
- return isFontInit;
+ return isFontInit;
}
-void
-initFont(char *file, int size)
+void initFont(char *file, int size)
{
- char str[STR_PATH_SIZE];
+ char str[STR_PATH_SIZE];
- assert(file != NULL);
- assert(size > 0);
+ assert(file != NULL);
+ assert(size > 0);
- assert(isInterfaceInicialized() == TRUE);
+ assert(isInterfaceInicialized() == TRUE);
- sprintf(str, "%s", file);
+ sprintf(str, "%s", file);
- if (TTF_Init() == -1) {
- fprintf(stderr, "%s\n", SDL_GetError());
- return;
- }
+ if (TTF_Init() == -1) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ return;
+ }
- accessExistFile(str);
+ accessExistFile(str);
- g_font = TTF_OpenFont(str, size);
- TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL);
+ g_font = TTF_OpenFont(str, size);
+ TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL);
- fontSize = size;
+ fontSize = size;
#ifdef DEBUG
- printf(_("Loading font: \"%s\"\n"), file);
+ printf(_("Loading font: \"%s\"\n"), file);
#endif
- isFontInit = TRUE;
+ isFontInit = TRUE;
}
/*
* Zobrazi text *s na suradnicu x y s farbou RGB
*/
-void
-drawFont(char *s, int x, int y, int r, int g, int b)
+void drawFont(char *s, int x, int y, int r, int g, int b)
{
- SDL_Rect dst_rect;
- SDL_Surface *text;
- SDL_Surface *p;
- SDL_Color farba_pisma = { r, g, b, 0 };
+ SDL_Rect dst_rect;
+ SDL_Surface *text;
+ SDL_Surface *p;
+ SDL_Color farba_pisma = { r, g, b, 0 };
- //printf("drawFont %s\n", s);
+ //printf("drawFont %s\n", s);
- assert(s != NULL);
+ assert(s != NULL);
- p = getSDL_Screen();
+ p = getSDL_Screen();
- text = TTF_RenderUTF8_Blended(g_font, s, farba_pisma);
+ text = TTF_RenderUTF8_Blended(g_font, s, farba_pisma);
- dst_rect.x = x;
- dst_rect.y = y;
+ dst_rect.x = x;
+ dst_rect.y = y;
- SDL_BlitSurface(text, NULL, p, &dst_rect);
- SDL_FreeSurface(text);
+ SDL_BlitSurface(text, NULL, p, &dst_rect);
+ SDL_FreeSurface(text);
}
-void
-drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b)
+void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b)
{
- SDL_Rect src_rect, dst_rect;
- SDL_Surface *text;
- SDL_Surface *p;
- SDL_Color farba_pisma = { r, g, b, 0 };
- int my_w, my_h;
+ SDL_Rect src_rect, dst_rect;
+ SDL_Surface *text;
+ SDL_Surface *p;
+ SDL_Color farba_pisma = { r, g, b, 0 };
+ int my_w, my_h;
- assert(s != NULL);
+ assert(s != NULL);
- p = getSDL_Screen();
+ p = getSDL_Screen();
- text = TTF_RenderUTF8_Blended(g_font, s, farba_pisma);
+ text = TTF_RenderUTF8_Blended(g_font, s, farba_pisma);
- my_w = text->w;
+ my_w = text->w;
- if (my_w > w) {
- my_w = w;
- }
+ if (my_w > w) {
+ my_w = w;
+ }
- my_h = text->h;
+ my_h = text->h;
- if (my_w > w) {
- my_h = h;
- }
+ if (my_w > w) {
+ my_h = h;
+ }
- src_rect.x = 0;
- src_rect.y = 0;
- src_rect.w = my_w;
- src_rect.h = my_h;
+ src_rect.x = 0;
+ src_rect.y = 0;
+ src_rect.w = my_w;
+ src_rect.h = my_h;
- dst_rect.x = x;
- dst_rect.y = y;
+ dst_rect.x = x;
+ dst_rect.y = y;
- SDL_BlitSurface(text, &src_rect, p, &dst_rect);
- SDL_FreeSurface(text);
+ SDL_BlitSurface(text, &src_rect, p, &dst_rect);
+ SDL_FreeSurface(text);
}
/*
* Vrati velkost daneho fontu.
*/
-int
-getFontSize()
+int getFontSize()
{
- return fontSize;
+ return fontSize;
}
-void
-getTextSize(char *s, int *w, int *h)
+void getTextSize(char *s, int *w, int *h)
{
- assert(s != NULL);
- assert(w != NULL);
- assert(h != NULL);
+ assert(s != NULL);
+ assert(w != NULL);
+ assert(h != NULL);
- TTF_SizeUTF8(g_font, s, w, h);
+ TTF_SizeUTF8(g_font, s, w, h);
}
/*
* Uvolni font z pamete.
*/
-void
-quitFont()
+void quitFont()
{
- TTF_CloseFont(g_font);
- TTF_Quit();
+ TTF_CloseFont(g_font);
+ TTF_Quit();
#ifdef DEBUG
- printf(_("Unloading font\n"));
+ printf(_("Unloading font\n"));
#endif
- isFontInit = FALSE;
+ isFontInit = FALSE;
}
diff --git a/src/client/font.h b/src/client/font.h
index 28f7373..f728e86 100644
--- a/src/client/font.h
+++ b/src/client/font.h
@@ -1,27 +1,27 @@
#ifndef FONT_H
-#define FONT_H
+# define FONT_H
-#include <SDL_ttf.h>
-#include <assert.h>
-#include "main.h"
+# include <SDL_ttf.h>
+# include <assert.h>
+# include "main.h"
-#define COLOR_WHITE 255, 255, 255
-#define COLOR_BLACK 0, 0, 0
+# define COLOR_WHITE 255, 255, 255
+# define COLOR_BLACK 0, 0, 0
-#define COLOR_RED 255, 0, 0
-#define COLOR_GREEN 0, 255, 0
-#define COLOR_BLUE 0, 0, 255
+# define COLOR_RED 255, 0, 0
+# define COLOR_GREEN 0, 255, 0
+# define COLOR_BLUE 0, 0, 255
-#define COLOR_YELLOW 255, 255, 0
-#define FONT_SIZE 16
+# define COLOR_YELLOW 255, 255, 0
+# define FONT_SIZE 16
extern bool_t isFontInicialized();
extern void initFont(char *file, int size);
extern void drawFont(char *s, int x, int y, int r, int g, int b);
extern void drawFontMaxSize(char *s, int x, int y, int w, int h, int r, int g,
- int b);
+ int b);
extern int getFontSize();
extern void getTextSize(char *s, int *w, int *h);
extern void quitFont();
diff --git a/src/client/game.c b/src/client/game.c
index 2f90216..d0773a4 100644
--- a/src/client/game.c
+++ b/src/client/game.c
@@ -25,9 +25,9 @@
#include "radar.h"
#ifndef NO_SOUND
-#include "audio.h"
-#include "sound.h"
-#include "music.h"
+# include "audio.h"
+# include "sound.h"
+# include "music.h"
#endif
#include "screen_world.h"
@@ -42,84 +42,81 @@
#include "screen_credits.h"
#include "screen_browser.h"
-static void
-initGame()
+static void initGame()
{
- createHomeDirector();
+ createHomeDirector();
- initSDL();
- initFont(FONT_FILE, FONT_SIZE);
- initLayer();
- initImageData();
+ initSDL();
+ initFont(FONT_FILE, FONT_SIZE);
+ initLayer();
+ initImageData();
#ifndef NO_SOUND
- initAudio();
- initSound();
- initMusic();
+ initAudio();
+ initSound();
+ initMusic();
#endif
- initScreen();
- initArenaFile();
- initTux();
- initItem();
- initShot();
- initPanel();
- initWorld();
+ initScreen();
+ initArenaFile();
+ initTux();
+ initItem();
+ initShot();
+ initPanel();
+ initWorld();
- initScreenMainMenu();
- initScreenAnalyze();
- initScreenChoiceArena();
- initScreenSetting();
- initScreenSettingKeys();
- initScreenGameType();
- initScreenDownArena();
- initScreenCredits();
- initScreenTable();
- initScreenBrowser();
+ initScreenMainMenu();
+ initScreenAnalyze();
+ initScreenChoiceArena();
+ initScreenSetting();
+ initScreenSettingKeys();
+ initScreenGameType();
+ initScreenDownArena();
+ initScreenCredits();
+ initScreenTable();
+ initScreenBrowser();
}
-void
-quitGame()
+void quitGame()
{
- quitSDL();
+ quitSDL();
- quitScreenMainMenu();
- quitScreenAnalyze();
- quitScreenSetting();
- quitScreenSettingKeys();
- quitScreenGameType();
- quitScreenDownArena();
- quitScreenChoiceArena();
- quitScreenCredits();
- quitScreenTable();
- quitScreenBrowser();
+ quitScreenMainMenu();
+ quitScreenAnalyze();
+ quitScreenSetting();
+ quitScreenSettingKeys();
+ quitScreenGameType();
+ quitScreenDownArena();
+ quitScreenChoiceArena();
+ quitScreenCredits();
+ quitScreenTable();
+ quitScreenBrowser();
- quitLayer();
- quitFont();
- quitScreen();
- quitArenaFile();
- quitItem();
- quitTux();
- quitShot();
- quitPanel();
- quitWorld();
- quitImageData();
+ quitLayer();
+ quitFont();
+ quitScreen();
+ quitArenaFile();
+ quitItem();
+ quitTux();
+ quitShot();
+ quitPanel();
+ quitWorld();
+ quitImageData();
#ifndef NO_SOUND
- quitSound();
- quitMusic();
- quitAudio();
+ quitSound();
+ quitMusic();
+ quitAudio();
#endif
#ifdef DEBUG
- printf(_("Quitting TUXANCI...\n"));
+ printf(_("Quitting TUXANCI...\n"));
#endif
- exit(0);
+ exit(0);
}
-void
-startGame()
+void startGame()
{
- initGame();
+ initGame();
- startScreen("mainMenu");
+ startScreen("mainMenu");
- eventSDL();
- quitGame();
+ eventSDL();
+ quitGame();
}
diff --git a/src/client/game.h b/src/client/game.h
index 6ce694d..981e975 100644
--- a/src/client/game.h
+++ b/src/client/game.h
@@ -1,7 +1,7 @@
#ifndef GAME_H
-#define GAME_H
+# define GAME_H
extern void quitGame();
extern void startGame();
diff --git a/src/client/hotKey.c b/src/client/hotKey.c
index ebbfdef..2462140 100644
--- a/src/client/hotKey.c
+++ b/src/client/hotKey.c
@@ -10,150 +10,139 @@
#include "interface.h"
#include "hotKey.h"
-typedef struct hotKey_struct
-{
- SDLKey key;
- bool_t active;
- void (*handler) ();
+typedef struct hotKey_struct {
+ SDLKey key;
+ bool_t active;
+ void (*handler) ();
} hotKey_t;
static list_t *listHotKey;
static my_time_t lastActive;
-static hotKey_t *
-newHotKey(SDLKey key, void (*handler) ())
+static hotKey_t *newHotKey(SDLKey key, void (*handler) ())
{
- hotKey_t *new;
+ hotKey_t *new;
- new = malloc(sizeof(hotKey_t));
- new->key = key;
- new->active = TRUE;
- new->handler = handler;
+ new = malloc(sizeof(hotKey_t));
+ new->key = key;
+ new->active = TRUE;
+ new->handler = handler;
- return new;
+ return new;
}
-static void
-destroyHotKey(hotKey_t * hotkey)
+static void destroyHotKey(hotKey_t * hotkey)
{
- free(hotkey);
+ free(hotkey);
}
-static hotKey_t *
-findHotkey(SDLKey key)
+static hotKey_t *findHotkey(SDLKey key)
{
- int i;
+ int i;
- for (i = 0; i < listHotKey->count; i++) {
- hotKey_t *this;
+ for (i = 0; i < listHotKey->count; i++) {
+ hotKey_t *this;
- this = (hotKey_t *) listHotKey->list[i];
+ this = (hotKey_t *) listHotKey->list[i];
- if (this->key == key) {
- return this;
- }
- }
+ if (this->key == key) {
+ return this;
+ }
+ }
- return NULL;
+ return NULL;
}
-void
-initHotKey()
+void initHotKey()
{
- listHotKey = newList();
- lastActive = getMyTime();
+ listHotKey = newList();
+ lastActive = getMyTime();
}
-void
-registerHotKey(SDLKey key, void (*handler) ())
+void registerHotKey(SDLKey key, void (*handler) ())
{
- hotKey_t *hotkey;
+ hotKey_t *hotkey;
- if (findHotkey(key) != NULL) {
- assert(!"Conflict with register key");
- }
+ if (findHotkey(key) != NULL) {
+ assert(!"Conflict with register key");
+ }
- hotkey = newHotKey(key, handler);
- addList(listHotKey, hotkey);
+ hotkey = newHotKey(key, handler);
+ addList(listHotKey, hotkey);
}
-void
-unregisterHotKey(SDLKey key)
+void unregisterHotKey(SDLKey key)
{
- hotKey_t *hotkey;
- int index;
+ hotKey_t *hotkey;
+ int index;
- hotkey = findHotkey(key);
+ hotkey = findHotkey(key);
- if (hotkey == NULL) {
- assert(!"This hotkey not register");
- }
+ if (hotkey == NULL) {
+ assert(!"This hotkey not register");
+ }
- index = searchListItem(listHotKey, hotkey);
- assert(index != -1);
- delListItem(listHotKey, index, destroyHotKey);
+ index = searchListItem(listHotKey, hotkey);
+ assert(index != -1);
+ delListItem(listHotKey, index, destroyHotKey);
}
-void
-enableHotKey(SDLKey key)
+void enableHotKey(SDLKey key)
{
- hotKey_t *hotkey;
+ hotKey_t *hotkey;
- hotkey = findHotkey(key);
+ hotkey = findHotkey(key);
- if (hotkey == NULL) {
- assert(!"This hotkey not register");
- }
+ if (hotkey == NULL) {
+ assert(!"This hotkey not register");
+ }
- lastActive = getMyTime();
- hotkey->active = TRUE;
+ lastActive = getMyTime();
+ hotkey->active = TRUE;
}
-void
-disableHotKey(SDLKey key)
+void disableHotKey(SDLKey key)
{
- hotKey_t *hotkey;
+ hotKey_t *hotkey;
- hotkey = findHotkey(key);
+ hotkey = findHotkey(key);
- if (hotkey == NULL) {
- assert(!"This hotkey not register");
- }
+ if (hotkey == NULL) {
+ assert(!"This hotkey not register");
+ }
- lastActive = getMyTime();
- hotkey->active = FALSE;
+ lastActive = getMyTime();
+ hotkey->active = FALSE;
}
-void
-eventHotKey()
+void eventHotKey()
{
- my_time_t currentTime;
- Uint8 *mapa;
- int i;
+ my_time_t currentTime;
+ Uint8 *mapa;
+ int i;
- currentTime = getMyTime();
+ currentTime = getMyTime();
- if (currentTime - lastActive < HOTKEY_ACTIVE_INTERVAL) {
- return;
- }
+ if (currentTime - lastActive < HOTKEY_ACTIVE_INTERVAL) {
+ return;
+ }
- mapa = SDL_GetKeyState(NULL);
+ mapa = SDL_GetKeyState(NULL);
- for (i = 0; i < listHotKey->count; i++) {
- hotKey_t *this;
+ for (i = 0; i < listHotKey->count; i++) {
+ hotKey_t *this;
- this = (hotKey_t *) listHotKey->list[i];
+ this = (hotKey_t *) listHotKey->list[i];
- if (mapa[this->key] == SDL_PRESSED && this->active == TRUE) {
- lastActive = getMyTime();
- //printf("hotKey = %d\n", this->key);
- this->handler();
- }
- }
+ if (mapa[this->key] == SDL_PRESSED && this->active == TRUE) {
+ lastActive = getMyTime();
+ //printf("hotKey = %d\n", this->key);
+ this->handler();
+ }
+ }
}
-void
-quitHotKey()
+void quitHotKey()
{
- destroyListItem(listHotKey, destroyHotKey);
+ destroyListItem(listHotKey, destroyHotKey);
}
diff --git a/src/client/hotKey.h b/src/client/hotKey.h
index 383033d..1cdf647 100644
--- a/src/client/hotKey.h
+++ b/src/client/hotKey.h
@@ -1,9 +1,9 @@
#ifndef HOTKEY_H
-#define HOTKEY_H
+# define HOTKEY_H
-#define HOTKEY_ACTIVE_INTERVAL 500
+# define HOTKEY_ACTIVE_INTERVAL 500
extern void initHotKey();
extern void registerHotKey(SDLKey key, void (*handler) ());
diff --git a/src/client/image.c b/src/client/image.c
index 3ed4403..6046732 100644
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -14,82 +14,76 @@ static list_t *listStorage;
static bool_t isImageDataInit = FALSE;
-bool_t
-isImageInicialized()
+bool_t isImageInicialized()
{
- return isImageDataInit;
+ return isImageDataInit;
}
/*
* Inicializuje globalny zoznam obrazkov
*/
-void
-initImageData()
+void initImageData()
{
- assert(isInterfaceInicialized() == TRUE);
+ assert(isInterfaceInicialized() == TRUE);
#ifdef DEBUG
- printf(_("Initializing image database\n"));
+ printf(_("Initializing image database\n"));
#endif
- listStorage = newStorage();
- isImageDataInit = TRUE;
+ listStorage = newStorage();
+ isImageDataInit = TRUE;
}
-static SDL_Surface *
-loadImage(const char *filename, int alpha)
+static SDL_Surface *loadImage(const char *filename, int alpha)
{
- SDL_Surface *tmp;
- SDL_Surface *ret;
+ SDL_Surface *tmp;
+ SDL_Surface *ret;
- char str[STR_PATH_SIZE];
+ char str[STR_PATH_SIZE];
- if (isFillPath(filename)) {
- strcpy(str, filename);
- }
- else {
- sprintf(str, PATH_IMAGE "%s", filename);
- }
+ if (isFillPath(filename)) {
+ strcpy(str, filename);
+ } else {
+ sprintf(str, PATH_IMAGE "%s", filename);
+ }
- accessExistFile(str);
+ accessExistFile(str);
- if ((tmp = IMG_Load(str)) == NULL) {
- fprintf(stderr, "%s\n", SDL_GetError());
- return NULL;
- }
+ if ((tmp = IMG_Load(str)) == NULL) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ return NULL;
+ }
- if ((ret =
- (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) ==
- NULL) {
- fprintf(stderr, "%s\n", SDL_GetError());
- SDL_FreeSurface(tmp);
- return NULL;
- }
+ if ((ret =
+ (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) ==
+ NULL) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ SDL_FreeSurface(tmp);
+ return NULL;
+ }
- SDL_FreeSurface(tmp);
- return ret;
+ SDL_FreeSurface(tmp);
+ return ret;
}
-image_t *
-newImage(SDL_Surface * surface)
+image_t *newImage(SDL_Surface * surface)
{
- image_t *new;
+ image_t *new;
- assert(surface != NULL);
+ assert(surface != NULL);
- new = malloc(sizeof(image_t));
- new->image = surface;
- new->w = surface->w;
- new->h = surface->h;
+ new = malloc(sizeof(image_t));
+ new->image = surface;
+ new->w = surface->w;
+ new->h = surface->h;
- return new;
+ return new;
}
-static void
-destroyImage(image_t * p)
+static void destroyImage(image_t * p)
{
- assert(p != NULL);
- SDL_FreeSurface((SDL_Surface *) p->image);
- free(p);
+ assert(p != NULL);
+ SDL_FreeSurface((SDL_Surface *) p->image);
+ free(p);
}
/*
@@ -98,86 +92,80 @@ destroyImage(image_t * p)
* *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem )
* alpha - 0 - nema alpha kanal | 1 - ma alpha kanal
*/
-image_t *
-addImageData(char *file, int alpha, char *name, char *group)
+image_t *addImageData(char *file, int alpha, char *name, char *group)
{
- SDL_Surface *surface;
- image_t *new;
+ SDL_Surface *surface;
+ image_t *new;
- assert(file != NULL);
- assert(name != NULL);
- assert(group != NULL);
+ assert(file != NULL);
+ assert(name != NULL);
+ assert(group != NULL);
- surface = loadImage(file, alpha);
- new = newImage(surface);
+ surface = loadImage(file, alpha);
+ new = newImage(surface);
- addItemToStorage(listStorage, group, name, new);
+ addItemToStorage(listStorage, group, name, new);
#ifdef DEBUG
- printf(_("Loading image %s\n"), file);
+ printf(_("Loading image %s\n"), file);
#endif
- return new;
+ return new;
}
/*
* Vrati odkaz na image_data v globalnom zozname obrazkov
* a nazvom *s
*/
-image_t *
-getImage(char *group, char *name)
+image_t *getImage(char *group, char *name)
{
- assert(group != NULL);
- assert(name != NULL);
+ assert(group != NULL);
+ assert(name != NULL);
- return getItemFromStorage(listStorage, group, name);
+ return getItemFromStorage(listStorage, group, name);
}
-void
-delImage(char *group, char *name)
+void delImage(char *group, char *name)
{
- assert(group != NULL);
- assert(name != NULL);
+ assert(group != NULL);
+ assert(name != NULL);
- delItemFromStorage(listStorage, group, name, destroyImage);
+ delItemFromStorage(listStorage, group, name, destroyImage);
}
-void
-delAllImageInGroup(char *group)
+void delAllImageInGroup(char *group)
{
- assert(group != NULL);
+ assert(group != NULL);
- delAllItemFromStorage(listStorage, group, destroyImage);
+ delAllItemFromStorage(listStorage, group, destroyImage);
}
-void
-drawImage(image_t * p, int x, int y, int px, int py, int w, int h)
+void drawImage(image_t * p, int x, int y, int px, int py, int w, int h)
{
- static SDL_Surface *screen = NULL;
- SDL_Rect dst_rect, src_rect;
+ static SDL_Surface *screen = NULL;
+ SDL_Rect dst_rect, src_rect;
- if (screen == NULL) {
- screen = getSDL_Screen();
- }
+ if (screen == NULL) {
+ screen = getSDL_Screen();
+ }
- dst_rect.x = x;
- dst_rect.y = y;
+ dst_rect.x = x;
+ dst_rect.y = y;
- src_rect.x = px;
- src_rect.y = py;
- src_rect.w = w;
- src_rect.h = h;
+ src_rect.x = px;
+ src_rect.y = py;
+ src_rect.w = w;
+ src_rect.h = h;
- SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
+ SDL_BlitSurface(p->image, &src_rect, screen, &dst_rect);
}
/*
* Odstrani zoznam obrazkov z pamate
*/
-void
-quitImageData()
+void quitImageData()
{
#ifdef DEBUG
- printf(_("Quitting image database\n"));
+ printf(_("Quitting image database\n"));
#endif
- destroyStorage(listStorage, destroyImage);
- isImageDataInit = FALSE;
+ destroyStorage(listStorage, destroyImage);
+ isImageDataInit = FALSE;
}
diff --git a/src/client/image.h b/src/client/image.h
index 5b637b2..015c0d2 100644
--- a/src/client/image.h
+++ b/src/client/image.h
@@ -1,18 +1,18 @@
#ifndef IMAGE_H
-#define IMAGE_H
+# define IMAGE_H
//#include "image.h"
-#include "interface.h"
+# include "interface.h"
-#define IMAGE_NO_ALPHA 0
-#define IMAGE_ALPHA 1
+# define IMAGE_NO_ALPHA 0
+# define IMAGE_ALPHA 1
-#define IMAGE_GROUP_BASE "base"
-#define IMAGE_GROUP_EXTENDSIO "extension"
-#define IMAGE_GROUP_USER "user"
-#define IMAGE_GROUP_OTHER "other"
+# define IMAGE_GROUP_BASE "base"
+# define IMAGE_GROUP_EXTENDSIO "extension"
+# define IMAGE_GROUP_USER "user"
+# define IMAGE_GROUP_OTHER "other"
/*
typedef struct image_struct
@@ -23,11 +23,10 @@ typedef struct image_struct
} image_data_t;
*/
-typedef struct image_struct
-{
- int w;
- int h;
- SDL_Surface *image;
+typedef struct image_struct {
+ int w;
+ int h;
+ SDL_Surface *image;
} image_t;
extern bool_t isImageInicialized();
@@ -36,8 +35,7 @@ extern image_t *addImageData(char *file, int alpha, char *name, char *group);
extern image_t *getImage(char *group, char *name);
extern void delImage(char *group, char *name);
extern void delAllImageInGroup(char *group);
-extern void drawImage(image_t * p, int x, int y, int px, int py, int w,
- int h);
+extern void drawImage(image_t * p, int x, int y, int px, int py, int w, int h);
extern void quitImageData();
#endif
diff --git a/src/client/interface.c b/src/client/interface.c
index 94a9fdb..d2f99fb 100644
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -24,78 +24,71 @@ static bool_t isInterfaceInit = FALSE;
// flag, kterym se ridi zarazovani klaves do bufferu
bool_t keyboardBufferEnabled = FALSE;
-bool_t
-isInterfaceInicialized()
+bool_t isInterfaceInicialized()
{
- return isInterfaceInit;
+ return isInterfaceInit;
}
-static Uint32
-TimerCallback(Uint32 interval, void *param)
+static Uint32 TimerCallback(Uint32 interval, void *param)
{
- SDL_Event event;
- event.type = SDL_USEREVENT;
- event.user.code = USR_EVT_TIMER;
- event.user.data1 = NULL;
- event.user.data2 = NULL;
+ SDL_Event event;
+ event.type = SDL_USEREVENT;
+ event.user.code = USR_EVT_TIMER;
+ event.user.data1 = NULL;
+ event.user.data2 = NULL;
- SDL_PushEvent(&event);
+ SDL_PushEvent(&event);
- return interval;
+ return interval;
}
-void
-enableKeyboardBuffer()
+void enableKeyboardBuffer()
{
- keyboardBufferEnabled = TRUE;
+ keyboardBufferEnabled = TRUE;
}
-void
-disableKeyboardBuffer()
+void disableKeyboardBuffer()
{
- keyboardBufferEnabled = FALSE;
+ keyboardBufferEnabled = FALSE;
}
-void
-hotkey_screen()
+void hotkey_screen()
{
- if (g_win_flags & SDL_FULLSCREEN)
- g_win_flags &= ~SDL_FULLSCREEN;
- else
- g_win_flags |= SDL_FULLSCREEN;
-
- if (SDL_WM_ToggleFullScreen(screen) == 0) {
- fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
-
- SDL_FreeSurface(screen);
- screen =
- SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP,
- g_win_flags);
-
- if (screen == NULL) {
- fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"),
- SDL_GetError());
- return;
- }
- }
+ if (g_win_flags & SDL_FULLSCREEN)
+ g_win_flags &= ~SDL_FULLSCREEN;
+ else
+ g_win_flags |= SDL_FULLSCREEN;
+
+ if (SDL_WM_ToggleFullScreen(screen) == 0) {
+ fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
+
+ SDL_FreeSurface(screen);
+ screen =
+ SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP,
+ g_win_flags);
+
+ if (screen == NULL) {
+ fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"),
+ SDL_GetError());
+ return;
+ }
+ }
}
-int
-initSDL()
+int initSDL()
{
#ifdef DEBUG
- printf(_("Initializing SDL system\n"));
+ printf(_("Initializing SDL system\n"));
#endif
- // initialization of SDL
- if (SDL_Init(SDL_SUBSYSTEMS) == -1) {
- fprintf(stderr, "%s\n", SDL_GetError());
- SDL_Quit();
- return -1;
- }
-
- // initialization of SDL
- //screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
+ // initialization of SDL
+ if (SDL_Init(SDL_SUBSYSTEMS) == -1) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ SDL_Quit();
+ return -1;
+ }
+ // initialization of SDL
+ //screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
+ screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
/*
my_surface = SDL_CreateRGBSurface(screen->flags, WINDOW_SIZE_X, WINDOW_SIZE_Y,
@@ -103,88 +96,82 @@ initSDL()
screen->format->Rmask, screen->format->Gmask,
screen->format->Bmask, screen->format->Amask);
*/
- //memset(my_surface->pixels, 128, 200);
+ //memset(my_surface->pixels, 128, 200);
- if (screen == NULL) {
- fprintf(stderr, "%s\n", SDL_GetError());
- SDL_Quit();
- return -1;
- }
+ if (screen == NULL) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ SDL_Quit();
+ return -1;
+ }
- SDL_WM_SetCaption(WINDOW_TITLE, NULL);
- //SDL_ShowCursor(0);
- SDL_EnableKeyRepeat(0, 1);
- timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
+ SDL_WM_SetCaption(WINDOW_TITLE, NULL);
+ //SDL_ShowCursor(0);
+ SDL_EnableKeyRepeat(0, 1);
+ timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
- initKeyboardBuffer(KEYBOARD_BUFFER_SIZE);
+ initKeyboardBuffer(KEYBOARD_BUFFER_SIZE);
- initHotKey();
- registerHotKey(SDLK_F1, hotkey_screen);
+ initHotKey();
+ registerHotKey(SDLK_F1, hotkey_screen);
- srand((unsigned) time(NULL));
- isInterfaceInit = TRUE;
+ srand((unsigned) time(NULL));
+ isInterfaceInit = TRUE;
- return 0;
+ return 0;
}
-SDL_Surface *
-getSDL_Screen()
+SDL_Surface *getSDL_Screen()
{
- //return my_surface;
- return screen;
+ //return my_surface;
+ return screen;
}
-void
-interfaceRefresh()
+void interfaceRefresh()
{
- //SDL_BlitSurface(my_surface, NULL, screen, NULL);
- //SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
+ //SDL_BlitSurface(my_surface, NULL, screen, NULL);
+ //SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
- //drawImage(my_surface, 200, 100, 0, 0, 200, 200);
- SDL_Flip(screen);
- //SDL_UpdateRect(screen, 400, 0, 400, 600);
+ //drawImage(my_surface, 200, 100, 0, 0, 200, 200);
+ SDL_Flip(screen);
+ //SDL_UpdateRect(screen, 400, 0, 400, 600);
}
-void
-getMousePosition(int *x, int *y)
+void getMousePosition(int *x, int *y)
{
- SDL_GetMouseState(x, y);
+ SDL_GetMouseState(x, y);
}
-int
-isMouseClicked()
+int isMouseClicked()
{
- return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT);
+ return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT);
}
-int
-isPressAnyKey()
+int isPressAnyKey()
{
- Uint8 *mapa;
- int i;
+ Uint8 *mapa;
+ int i;
- mapa = SDL_GetKeyState(NULL);
+ mapa = SDL_GetKeyState(NULL);
- for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++)
- if (mapa[i] == SDL_PRESSED) {
- return 1;
- }
+ for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++)
+ if (mapa[i] == SDL_PRESSED) {
+ return 1;
+ }
- return 0;
+ return 0;
}
-void
-printPressAnyKey()
+void printPressAnyKey()
{
- Uint8 *mapa;
- int i;
+ Uint8 *mapa;
+ int i;
- mapa = SDL_GetKeyState(NULL);
+ mapa = SDL_GetKeyState(NULL);
- for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++)
- if (mapa[i] == SDL_PRESSED) {
- printf(_("Pressed key with SDL value: %d\n"), i);
- }
+ for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++)
+ if (mapa[i] == SDL_PRESSED) {
+ printf(_("Pressed key with SDL value: %d\n"), i);
+ }
}
@@ -205,16 +192,15 @@ static void action_esc()
}
*/
-int
-eventAction()
+int eventAction()
{
- SDL_Event event;
+ SDL_Event event;
- while (SDL_WaitEvent(&event)) {
- switch (event.type) {
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
+ while (SDL_WaitEvent(&event)) {
+ switch (event.type) {
+ case SDL_KEYDOWN:
+ switch (event.key.keysym.sym) {
/*
case SDLK_ESCAPE:
action_esc();
@@ -226,74 +212,72 @@ eventAction()
if(!toggleFullscreen())return 0;
break;
*/
- default:
- //neni potreba vyuzivat frontu stale
- if (keyboardBufferEnabled == TRUE)
- pushKeyToKeyboardBuffer(event.key.keysym);
- break;
- }
- break;
-
- case SDL_USEREVENT:
- switch (event.user.code) {
- case USR_EVT_TIMER:
- drawScreen();
- eventScreen();
- eventHotKey();
- switchScreen();
- break;
-
- default:
- break;
- }
- break;
-
- // change of window size
- case SDL_VIDEORESIZE:
- screen =
- SDL_SetVideoMode(event.resize.w, event.resize.h, WIN_BPP,
- g_win_flags);
-
- if (screen == NULL) {
- fprintf(stderr,
- _("Unable to change WINDOW resolution! Error: %s\n"),
- SDL_GetError());
- return 0;
- }
- break;
-
- // termination request
- case SDL_QUIT:
- return -1;
- break;
-
- default:
- break;
- }
- }
-
- return 0;
+ default:
+ //neni potreba vyuzivat frontu stale
+ if (keyboardBufferEnabled == TRUE)
+ pushKeyToKeyboardBuffer(event.key.keysym);
+ break;
+ }
+ break;
+
+ case SDL_USEREVENT:
+ switch (event.user.code) {
+ case USR_EVT_TIMER:
+ drawScreen();
+ eventScreen();
+ eventHotKey();
+ switchScreen();
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ // change of window size
+ case SDL_VIDEORESIZE:
+ screen =
+ SDL_SetVideoMode(event.resize.w, event.resize.h, WIN_BPP,
+ g_win_flags);
+
+ if (screen == NULL) {
+ fprintf(stderr,
+ _("Unable to change WINDOW resolution! Error: %s\n"),
+ SDL_GetError());
+ return 0;
+ }
+ break;
+
+ // termination request
+ case SDL_QUIT:
+ return -1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return 0;
}
-void
-eventSDL()
+void eventSDL()
{
- while (1) {
- if (eventAction() == -1)
- return;
- }
+ while (1) {
+ if (eventAction() == -1)
+ return;
+ }
}
-void
-quitSDL()
+void quitSDL()
{
#ifdef DEBUG
- printf(_("Quitting SDL\n"));
+ printf(_("Quitting SDL\n"));
#endif
- quitHotKey();
- quitKeyboardBuffer();
+ quitHotKey();
+ quitKeyboardBuffer();
- SDL_Quit();
+ SDL_Quit();
- isInterfaceInit = FALSE;
+ isInterfaceInit = FALSE;
}
diff --git a/src/client/interface.h b/src/client/interface.h
index 95bef25..b5df62a 100644
--- a/src/client/interface.h
+++ b/src/client/interface.h
@@ -1,33 +1,33 @@
#ifndef INTERFACE_H
-#define INTERFACE_H
+# define INTERFACE_H
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
+# include <stdio.h>
+# include <string.h>
+# include <time.h>
-#include <SDL.h>
-#include <SDL_image.h>
-#include <SDL_thread.h>
-#include "main.h"
+# include <SDL.h>
+# include <SDL_image.h>
+# include <SDL_thread.h>
+# include "main.h"
/*
#include <SDL_net.h>
*/
-#define SDL_SUBSYSTEMS SDL_INIT_VIDEO|SDL_INIT_TIMER
+# define SDL_SUBSYSTEMS SDL_INIT_VIDEO|SDL_INIT_TIMER
// windows title
-#define WINDOW_TITLE "Tuxánci " TUXANCI_VERSION
-#define WIN_BPP 0
-#define USR_EVT_TIMER 0
+# define WINDOW_TITLE "Tuxánci " TUXANCI_VERSION
+# define WIN_BPP 0
+# define USR_EVT_TIMER 0
// interval (in ms) of triggering akcia();
-#define INTERVAL 50
+# define INTERVAL 50
// velikost klavesoveho bufferu (ve znacich)
-#define KEYBOARD_BUFFER_SIZE 256
+# define KEYBOARD_BUFFER_SIZE 256
extern bool_t isInterfaceInicialized();
extern void enableKeyboardBuffer();
diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c
index c135822..4c24e9b 100644
--- a/src/client/keyboardBuffer.c
+++ b/src/client/keyboardBuffer.c
@@ -23,138 +23,129 @@ static SDL_keysym emptyKey;
/*
* Key buffer initializes. The parameter sets the number of keys.
*/
-void
-initKeyboardBuffer(int size)
+void initKeyboardBuffer(int size)
{
- assert(size > 0);
- assert(keyboardBuffer == NULL);
+ assert(size > 0);
+ assert(keyboardBuffer == NULL);
- keyboardBuffer = malloc(sizeof(keyboardBuffer_t));
- assert(keyboardBuffer != NULL);
- memset(keyboardBuffer, 0, sizeof(keyboardBuffer_t));
+ keyboardBuffer = malloc(sizeof(keyboardBuffer_t));
+ assert(keyboardBuffer != NULL);
+ memset(keyboardBuffer, 0, sizeof(keyboardBuffer_t));
- keyboardBuffer->buff = malloc(size * sizeof(SDL_keysym));
- assert(keyboardBuffer->buff != NULL);
- memset(keyboardBuffer->buff, 0, size * sizeof(SDL_keysym));
+ keyboardBuffer->buff = malloc(size * sizeof(SDL_keysym));
+ assert(keyboardBuffer->buff != NULL);
+ memset(keyboardBuffer->buff, 0, size * sizeof(SDL_keysym));
- keyboardBuffer->begin = 0;
- keyboardBuffer->end = 0;
- keyboardBuffer->count = 0;
- keyboardBuffer->size = size;
+ keyboardBuffer->begin = 0;
+ keyboardBuffer->end = 0;
+ keyboardBuffer->count = 0;
+ keyboardBuffer->size = size;
- emptyKey.sym = SDLK_UNKNOWN;
+ emptyKey.sym = SDLK_UNKNOWN;
}
/*
* Empty the buffer
*/
-void
-clearKeyboardBuffer()
+void clearKeyboardBuffer()
{
- assert(keyboardBuffer != NULL);
+ assert(keyboardBuffer != NULL);
- keyboardBuffer->begin = 0;
- keyboardBuffer->end = 0;
- keyboardBuffer->count = 0;
- memset(keyboardBuffer->buff, 0,
- keyboardBuffer->size * sizeof(SDL_keysym));
+ keyboardBuffer->begin = 0;
+ keyboardBuffer->end = 0;
+ keyboardBuffer->count = 0;
+ memset(keyboardBuffer->buff, 0, keyboardBuffer->size * sizeof(SDL_keysym));
}
/*
* Adds key to the end of the buffer. If the buffer is overrun,
* an error is printed to stderr and the key is dropped.
*/
-bool_t
-pushKeyToKeyboardBuffer(SDL_keysym key)
+bool_t pushKeyToKeyboardBuffer(SDL_keysym key)
{
- assert(keyboardBuffer != NULL);
+ assert(keyboardBuffer != NULL);
- if (keyboardBuffer->count >= keyboardBuffer->size) {
- fprintf(stderr, _("Keyboard Buffer overrun! Dropping key: %02x\n"),
- key.sym);
- return FALSE;
- }
+ if (keyboardBuffer->count >= keyboardBuffer->size) {
+ fprintf(stderr, _("Keyboard Buffer overrun! Dropping key: %02x\n"),
+ key.sym);
+ return FALSE;
+ }
- keyboardBuffer->buff[keyboardBuffer->end] = key;
+ keyboardBuffer->buff[keyboardBuffer->end] = key;
- keyboardBuffer->end++;
- if (keyboardBuffer->end >= keyboardBuffer->size) {
- keyboardBuffer->end = 0;
- }
+ keyboardBuffer->end++;
+ if (keyboardBuffer->end >= keyboardBuffer->size) {
+ keyboardBuffer->end = 0;
+ }
- keyboardBuffer->count++;
+ keyboardBuffer->count++;
- return TRUE;
+ return TRUE;
}
/*
* Takes out first key from the buffer and returns it. If the buffer is empty,
* an error is printed to stderr and SDLK_UNKNOWN is returned.
*/
-SDL_keysym
-popKeyFromKeyboardBuffer()
+SDL_keysym popKeyFromKeyboardBuffer()
{
- assert(keyboardBuffer != NULL);
+ assert(keyboardBuffer != NULL);
- if (keyboardBuffer->count <= 0) {
- fprintf(stderr, _("Keyboard Buffer underrun!\n"));
- return emptyKey;
- }
+ if (keyboardBuffer->count <= 0) {
+ fprintf(stderr, _("Keyboard Buffer underrun!\n"));
+ return emptyKey;
+ }
- SDL_keysym key = keyboardBuffer->buff[keyboardBuffer->begin];
- keyboardBuffer->buff[keyboardBuffer->begin] = emptyKey;
+ SDL_keysym key = keyboardBuffer->buff[keyboardBuffer->begin];
+ keyboardBuffer->buff[keyboardBuffer->begin] = emptyKey;
- keyboardBuffer->begin++;
- if (keyboardBuffer->begin >= keyboardBuffer->size) {
- keyboardBuffer->begin = 0;
- }
+ keyboardBuffer->begin++;
+ if (keyboardBuffer->begin >= keyboardBuffer->size) {
+ keyboardBuffer->begin = 0;
+ }
- keyboardBuffer->count--;
+ keyboardBuffer->count--;
- return key;
+ return key;
}
/*
* The buffer size
*/
-int
-getKeyboardBufferSize()
+int getKeyboardBufferSize()
{
- assert(keyboardBuffer != NULL);
- return keyboardBuffer->size;
+ assert(keyboardBuffer != NULL);
+ return keyboardBuffer->size;
}
/*
* Number of keys in the buffer
*/
-int
-KeyboardBufferCount()
+int KeyboardBufferCount()
{
- assert(keyboardBuffer != NULL);
- return keyboardBuffer->count;
+ assert(keyboardBuffer != NULL);
+ return keyboardBuffer->count;
}
-bool_t
-isAnyKeyInKeyboardBuffer()
+bool_t isAnyKeyInKeyboardBuffer()
{
- return KeyboardBufferCount() > 0 ? TRUE : FALSE;
+ return KeyboardBufferCount() > 0 ? TRUE : FALSE;
}
/*
* Frees the buffer. If it is not empty, information
* about filling is prined to stderr first.
*/
-void
-quitKeyboardBuffer()
+void quitKeyboardBuffer()
{
- assert(keyboardBuffer != NULL);
+ assert(keyboardBuffer != NULL);
- if (keyboardBuffer->count > 0) {
- fprintf(stderr, _("Keyboard buffer is not empty!\n"));
- }
+ if (keyboardBuffer->count > 0) {
+ fprintf(stderr, _("Keyboard buffer is not empty!\n"));
+ }
- free(keyboardBuffer->buff);
- free(keyboardBuffer);
- keyboardBuffer = NULL;
+ free(keyboardBuffer->buff);
+ free(keyboardBuffer);
+ keyboardBuffer = NULL;
}
diff --git a/src/client/keyboardBuffer.h b/src/client/keyboardBuffer.h
index 81f183b..c3c40af 100644
--- a/src/client/keyboardBuffer.h
+++ b/src/client/keyboardBuffer.h
@@ -9,18 +9,17 @@
#ifndef KEYBOARD_BUFFER_H
-#define KEYBOARD_BUFFER_H
+# define KEYBOARD_BUFFER_H
-#include <SDL.h>
-#include "main.h"
+# include <SDL.h>
+# include "main.h"
-typedef struct
-{
- SDL_keysym *buff; /* buffer klaves (kod dle SDLKey enumu) */
- int size; /* aktualni velikost alokovaneho bufferu (v poctu uchovatelnych klaves) */
- int count; /* pocet klaves aktualne v bufferu */
- int begin; /* ukazatel na zacatek bufferu (tj. kam se pridavaji klavesy) */
- int end; /* ukazatel na konec bufferu (tj. odkud se odebiraji klavesy) */
+typedef struct {
+ SDL_keysym *buff; /* buffer klaves (kod dle SDLKey enumu) */
+ int size; /* aktualni velikost alokovaneho bufferu (v poctu uchovatelnych klaves) */
+ int count; /* pocet klaves aktualne v bufferu */
+ int begin; /* ukazatel na zacatek bufferu (tj. kam se pridavaji klavesy) */
+ int end; /* ukazatel na konec bufferu (tj. odkud se odebiraji klavesy) */
} keyboardBuffer_t;
extern void initKeyboardBuffer(int size);
@@ -32,4 +31,4 @@ extern int KeyboardBufferCount();
extern bool_t isAnyKeyInKeyboardBuffer();
extern void quitKeyboardBuffer();
-#endif /* KEYBOARDBUFFER_H_ */
+#endif /* KEYBOARDBUFFER_H_ */
diff --git a/src/client/layer.c b/src/client/layer.c
index 1c8e8d1..d06c92a 100644
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -16,20 +16,18 @@ static list_t *listLayer;
static bool_t isLayerInit = FALSE;
-bool_t
-isLayerInicialized()
+bool_t isLayerInicialized()
{
- return isLayerInit;
+ return isLayerInit;
}
/*
* Inicializuje globalny zoznam vsrtiev
*/
-void
-initLayer()
+void initLayer()
{
- listLayer = newList();
- isLayerInit = TRUE;
+ listLayer = newList();
+ isLayerInit = TRUE;
}
/*
@@ -40,41 +38,40 @@ initLayer()
* layer - vrstva na ktorej sa zobrazi obrazok
*/
void
-addLayer(image_t * img,
- int x, int y, int px, int py, int w, int h, int player)
+addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int player)
{
- layer_t *new;
- layer_t *this;
- int i, j;
-
- assert(img != NULL);
-
- new = malloc(sizeof(layer_t));
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->px = px;
- new->py = py;
- new->layer = player;
- new->image = img;
-
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
-
- if (this->layer == new->layer) {
- for (j = i; j < listLayer->count; j++) {
- this = (layer_t *) listLayer->list[j];
-
- if (this->y + this->h > new->y + new->h) {
- insList(listLayer, j, new);
- return;
- }
- }
- }
- }
-
- addList(listLayer, new);
+ layer_t *new;
+ layer_t *this;
+ int i, j;
+
+ assert(img != NULL);
+
+ new = malloc(sizeof(layer_t));
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->px = px;
+ new->py = py;
+ new->layer = player;
+ new->image = img;
+
+ for (i = 0; i < listLayer->count; i++) {
+ this = (layer_t *) listLayer->list[i];
+
+ if (this->layer == new->layer) {
+ for (j = i; j < listLayer->count; j++) {
+ this = (layer_t *) listLayer->list[j];
+
+ if (this->y + this->h > new->y + new->h) {
+ insList(listLayer, j, new);
+ return;
+ }
+ }
+ }
+ }
+
+ addList(listLayer, new);
}
/*
@@ -82,130 +79,123 @@ addLayer(image_t * img,
* poukadane podla vrstvy a suradnice Y+H
* po dokresleni sa zoznam uvolni.
*/
-void
-drawLayer()
+void drawLayer()
{
- layer_t *this;
- int i;
+ layer_t *this;
+ int i;
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
+ for (i = 0; i < listLayer->count; i++) {
+ this = (layer_t *) listLayer->list[i];
- drawImage(this->image,
- this->x, this->y, this->px, this->py, this->w, this->h);
- }
+ drawImage(this->image,
+ this->x, this->y, this->px, this->py, this->w, this->h);
+ }
- //printf("listLayer->count = %d\n", listLayer->count);
+ //printf("listLayer->count = %d\n", listLayer->count);
- destroyListItem(listLayer, free);
- listLayer = newList();
+ destroyListItem(listLayer, free);
+ listLayer = newList();
}
-void
-drawLayerCenter(int x, int y)
+void drawLayerCenter(int x, int y)
{
- layer_t *this;
- int screen_x, screen_y;
- int i;
- //int count = 0;
-
- getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
+ layer_t *this;
+ int screen_x, screen_y;
+ int i;
+ //int count = 0;
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
+ getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
- if (this->x + this->w < screen_x || this->x > screen_x + WINDOW_SIZE_X
- || this->y + this->h < screen_y
- || this->y > screen_y + WINDOW_SIZE_Y) {
- continue;
- }
+ for (i = 0; i < listLayer->count; i++) {
+ this = (layer_t *) listLayer->list[i];
- //count++;
+ if (this->x + this->w < screen_x || this->x > screen_x + WINDOW_SIZE_X
+ || this->y + this->h < screen_y
+ || this->y > screen_y + WINDOW_SIZE_Y) {
+ continue;
+ }
+ //count++;
- drawImage(this->image,
- this->x - screen_x, this->y - screen_y,
- this->px, this->py, this->w, this->h);
+ drawImage(this->image,
+ this->x - screen_x, this->y - screen_y,
+ this->px, this->py, this->w, this->h);
- //printf("%d %d\n", this->x - screen_x, this->y - screen_y);
- }
+ //printf("%d %d\n", this->x - screen_x, this->y - screen_y);
+ }
- //printf("count = %d\n", count);
+ //printf("count = %d\n", count);
- destroyListItem(listLayer, free);
- listLayer = newList();
+ destroyListItem(listLayer, free);
+ listLayer = newList();
}
-void
-drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h)
+void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h)
{
- layer_t *this;
- int i;
- //int count = 0;
-
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
+ layer_t *this;
+ int i;
+ //int count = 0;
- if (this->x + this->w < x || this->x > x + w ||
- this->y + this->h < y || this->y > y + h) {
- continue;
- }
+ for (i = 0; i < listLayer->count; i++) {
+ this = (layer_t *) listLayer->list[i];
- //count++;
+ if (this->x + this->w < x || this->x > x + w ||
+ this->y + this->h < y || this->y > y + h) {
+ continue;
+ }
+ //count++;
- if (local_x + (this->x - x) < local_x) {
- int z;
+ if (local_x + (this->x - x) < local_x) {
+ int z;
- z = local_x - (local_x + (this->x - x));
+ z = local_x - (local_x + (this->x - x));
- this->x += z;
- this->px += z;
- this->w -= z;
- }
+ this->x += z;
+ this->px += z;
+ this->w -= z;
+ }
- if (local_x + (this->x - x) + this->w > local_x + w) {
- this->w -= (local_x + (this->x - x) + this->w) - (local_x + w);
- }
+ if (local_x + (this->x - x) + this->w > local_x + w) {
+ this->w -= (local_x + (this->x - x) + this->w) - (local_x + w);
+ }
- if (local_y + (this->y - y) < local_y) {
- int z;
+ if (local_y + (this->y - y) < local_y) {
+ int z;
- z = local_y - (local_y + (this->y - y));
+ z = local_y - (local_y + (this->y - y));
- this->y += z;
- this->py += z;
- this->h -= z;
- }
+ this->y += z;
+ this->py += z;
+ this->h -= z;
+ }
- if (local_y + (this->y - y) + this->h > local_y + h) {
- this->h -= (local_y + (this->y - y) + this->h) - (local_y + h);
- }
+ if (local_y + (this->y - y) + this->h > local_y + h) {
+ this->h -= (local_y + (this->y - y) + this->h) - (local_y + h);
+ }
- drawImage(this->image,
- local_x + (this->x - x), local_y + (this->y - y),
- this->px, this->py, this->w, this->h);
+ drawImage(this->image,
+ local_x + (this->x - x), local_y + (this->y - y),
+ this->px, this->py, this->w, this->h);
- //printf("%d %d\n", this->x - screen_x, this->y - screen_y);
- }
+ //printf("%d %d\n", this->x - screen_x, this->y - screen_y);
+ }
- //printf("count = %d\n", count);
+ //printf("count = %d\n", count);
- destroyListItem(listLayer, free);
- listLayer = newList();
+ destroyListItem(listLayer, free);
+ listLayer = newList();
}
-void
-flushLayer()
+void flushLayer()
{
- destroyListItem(listLayer, free);
- listLayer = newList();
+ destroyListItem(listLayer, free);
+ listLayer = newList();
}
/*
* Odstrani zoznam vrtsiev z pamete.
*/
-void
-quitLayer()
+void quitLayer()
{
- destroyListItem(listLayer, free);
- isLayerInit = FALSE;
+ destroyListItem(listLayer, free);
+ isLayerInit = FALSE;
}
diff --git a/src/client/layer.h b/src/client/layer.h
index ece1d01..fc17a23 100644
--- a/src/client/layer.h
+++ b/src/client/layer.h
@@ -1,28 +1,27 @@
#ifndef MY_LAYER_H
-#define MY_LAYER_H
+# define MY_LAYER_H
-#include "main.h"
-#include "image.h"
+# include "main.h"
+# include "image.h"
-typedef struct layer_str
-{
- int x; //suradnice obrazka na obrazovke
- int y;
+typedef struct layer_str {
+ int x; //suradnice obrazka na obrazovke
+ int y;
- int w; //rozmery obrazka na obrazovke
- int h;
+ int w; //rozmery obrazka na obrazovke
+ int h;
- int px; //suradnice casti surfrace
- int py;
+ int px; //suradnice casti surfrace
+ int py;
- int pw; //rozmeri casti surfrace
- int ph;
+ int pw; //rozmeri casti surfrace
+ int ph;
- int layer;
+ int layer;
- image_t *image; //dane surfrace
+ image_t *image; //dane surfrace
} layer_t;
extern bool_t isLayerInicialized();
@@ -40,7 +39,7 @@ extern void initLayer();
*/
extern void addLayer(image_t * img,
- int x, int y, int px, int py, int w, int h, int player);
+ int x, int y, int px, int py, int w, int h, int player);
/*
* Vykresli zoznam na obrazovku
@@ -48,7 +47,7 @@ extern void addLayer(image_t * img,
extern void drawLayer();
extern void drawLayerCenter(int x, int y);
extern void drawLayerSplit(int local_x, int local_y, int x, int y, int w,
- int h);
+ int h);
extern void flushLayer();
extern void quitLayer();
diff --git a/src/client/panel.c b/src/client/panel.c
index 70a7de5..ea87c1a 100644
--- a/src/client/panel.c
+++ b/src/client/panel.c
@@ -19,196 +19,181 @@ static image_t *g_bonus;
static bool_t isPanelInit = FALSE;
-bool_t
-isPanelInicialized()
+bool_t isPanelInicialized()
{
- return isPanelInit;
+ return isPanelInit;
}
-void
-initPanel()
+void initPanel()
{
- assert(isImageInicialized() == TRUE);
- assert(isInterfaceInicialized() == TRUE);
-
- g_panel =
- addImageData("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE);
- g_shot =
- addImageData("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",
- IMAGE_GROUP_BASE);
- g_bonus =
- addImageData("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus",
- IMAGE_GROUP_BASE);
-
- g_icon[GUN_SIMPLE] =
- addImageData("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun",
- IMAGE_GROUP_BASE);
- g_icon[GUN_DUAL_SIMPLE] =
- addImageData("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual",
- IMAGE_GROUP_BASE);
- g_icon[GUN_TOMMY] =
- addImageData("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy",
- IMAGE_GROUP_BASE);
- g_icon[GUN_SCATTER] =
- addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter",
- IMAGE_GROUP_BASE);
- g_icon[GUN_LASSER] =
- addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser",
- IMAGE_GROUP_BASE);
- g_icon[GUN_MINE] =
- addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine",
- IMAGE_GROUP_BASE);
- g_icon[GUN_BOMBBALL] =
- addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball",
- IMAGE_GROUP_BASE);
-
- g_icon[BONUS_SPEED] =
- addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_SHOT] =
- addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_TELEPORT] =
- addImageData("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_GHOST] =
- addImageData("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_4X] =
- addImageData("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x",
- IMAGE_GROUP_BASE);
- g_icon[BONUS_HIDDEN] =
- addImageData("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden",
- IMAGE_GROUP_BASE);
-
- isPanelInit = TRUE;
+ assert(isImageInicialized() == TRUE);
+ assert(isInterfaceInicialized() == TRUE);
+
+ g_panel =
+ addImageData("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE);
+ g_shot =
+ addImageData("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",
+ IMAGE_GROUP_BASE);
+ g_bonus =
+ addImageData("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus",
+ IMAGE_GROUP_BASE);
+
+ g_icon[GUN_SIMPLE] =
+ addImageData("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_DUAL_SIMPLE] =
+ addImageData("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_TOMMY] =
+ addImageData("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_SCATTER] =
+ addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_LASSER] =
+ addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_MINE] =
+ addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine",
+ IMAGE_GROUP_BASE);
+ g_icon[GUN_BOMBBALL] =
+ addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball",
+ IMAGE_GROUP_BASE);
+
+ g_icon[BONUS_SPEED] =
+ addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed",
+ IMAGE_GROUP_BASE);
+ g_icon[BONUS_SHOT] =
+ addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot",
+ IMAGE_GROUP_BASE);
+ g_icon[BONUS_TELEPORT] =
+ addImageData("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport",
+ IMAGE_GROUP_BASE);
+ g_icon[BONUS_GHOST] =
+ addImageData("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost",
+ IMAGE_GROUP_BASE);
+ g_icon[BONUS_4X] =
+ addImageData("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x",
+ IMAGE_GROUP_BASE);
+ g_icon[BONUS_HIDDEN] =
+ addImageData("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden",
+ IMAGE_GROUP_BASE);
+
+ isPanelInit = TRUE;
}
-static void
-drawScore(tux_t * tux_right, tux_t * tux_left)
+static void drawScore(tux_t * tux_right, tux_t * tux_left)
{
- char strScoreLine[STR_SIZE];
- int w, h;
-
- if (tux_right != NULL && tux_left != NULL) {
- sprintf(strScoreLine, "%d : %d", tux_right->score, tux_left->score);
- }
- else if (tux_right != NULL) {
- sprintf(strScoreLine, "%d", tux_right->score);
- }
- else if (tux_left != NULL) {
- sprintf(strScoreLine, "%d", tux_left->score);
- }
-
- getTextSize(strScoreLine, &w, &h);
- drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y,
- COLOR_WHITE);
+ char strScoreLine[STR_SIZE];
+ int w, h;
+
+ if (tux_right != NULL && tux_left != NULL) {
+ sprintf(strScoreLine, "%d : %d", tux_right->score, tux_left->score);
+ } else if (tux_right != NULL) {
+ sprintf(strScoreLine, "%d", tux_right->score);
+ } else if (tux_left != NULL) {
+ sprintf(strScoreLine, "%d", tux_left->score);
+ }
+
+ getTextSize(strScoreLine, &w, &h);
+ drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y,
+ COLOR_WHITE);
}
-static void
-drawShot(int n, int x, int y)
+static void drawShot(int n, int x, int y)
{
- drawImage(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH,
- PANEL_SHOT_HEIGHT);
+ drawImage(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH,
+ PANEL_SHOT_HEIGHT);
}
-static void
-drawShotInfo(tux_t * tux, int x, int y)
+static void drawShotInfo(tux_t * tux, int x, int y)
{
- int i;
-
- if (tux->pickup_time > 0) {
- for (i = 0; i < tux->pickup_time / 3; i++) {
- drawShot(PANEL_SHOT_LINE, x + i * PANEL_SHOT_WIDTH, y);
- }
-
- return;
- }
-
- for (i = 0; i < GUN_MAX_SHOT; i++) {
- if (tux->shot[tux->gun] > i) {
- drawShot(PANEL_SHOT_FILL, x + i * (PANEL_SHOT_WIDTH + 2), y);
- }
- else {
- drawShot(PANEL_SHOT_EMPTY, x + i * (PANEL_SHOT_WIDTH + 2), y);
- }
- }
+ int i;
+
+ if (tux->pickup_time > 0) {
+ for (i = 0; i < tux->pickup_time / 3; i++) {
+ drawShot(PANEL_SHOT_LINE, x + i * PANEL_SHOT_WIDTH, y);
+ }
+
+ return;
+ }
+
+ for (i = 0; i < GUN_MAX_SHOT; i++) {
+ if (tux->shot[tux->gun] > i) {
+ drawShot(PANEL_SHOT_FILL, x + i * (PANEL_SHOT_WIDTH + 2), y);
+ } else {
+ drawShot(PANEL_SHOT_EMPTY, x + i * (PANEL_SHOT_WIDTH + 2), y);
+ }
+ }
}
-static void
-drawGunInfo(tux_t * tux, int x, int y)
+static void drawGunInfo(tux_t * tux, int x, int y)
{
- drawImage(g_icon[tux->gun], x, y, 0, 0,
- g_icon[tux->gun]->w, g_icon[tux->gun]->h);
+ drawImage(g_icon[tux->gun], x, y, 0, 0,
+ g_icon[tux->gun]->w, g_icon[tux->gun]->h);
}
-static void
-drawBonusInfo(tux_t * tux, int x, int y)
+static void drawBonusInfo(tux_t * tux, int x, int y)
{
- drawImage(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w,
- g_icon[tux->bonus]->h);
+ drawImage(g_icon[tux->bonus], x, y, 0, 0, g_icon[tux->bonus]->w,
+ g_icon[tux->bonus]->h);
}
-static void
-drawGrafBonus(tux_t * tux, int x, int y)
+static void drawGrafBonus(tux_t * tux, int x, int y)
{
- int offset;
+ int offset;
- offset = tux->bonus_time / 5;
- drawImage(g_bonus, x, y, 0, 0, g_bonus->w, g_bonus->h / 2);
- drawImage(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2);
+ offset = tux->bonus_time / 5;
+ drawImage(g_bonus, x, y, 0, 0, g_bonus->w, g_bonus->h / 2);
+ drawImage(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2);
}
-static void
-drawTuxRight(tux_t * tux)
+static void drawTuxRight(tux_t * tux)
{
- if (tux == NULL) {
- return;
- }
+ if (tux == NULL) {
+ return;
+ }
- drawShotInfo(tux, PANEL_LOCATION_X + 740, PANEL_LOCATION_Y + 34);
- drawGunInfo(tux, PANEL_LOCATION_X + 620, PANEL_LOCATION_Y + 30);
+ drawShotInfo(tux, PANEL_LOCATION_X + 740, PANEL_LOCATION_Y + 34);
+ drawGunInfo(tux, PANEL_LOCATION_X + 620, PANEL_LOCATION_Y + 30);
- if (tux->bonus != BONUS_NONE) {
- drawGrafBonus(tux, PANEL_LOCATION_X + 460, PANEL_LOCATION_Y + 50);
- drawBonusInfo(tux, PANEL_LOCATION_X + 460, PANEL_LOCATION_Y + 30);
- }
+ if (tux->bonus != BONUS_NONE) {
+ drawGrafBonus(tux, PANEL_LOCATION_X + 460, PANEL_LOCATION_Y + 50);
+ drawBonusInfo(tux, PANEL_LOCATION_X + 460, PANEL_LOCATION_Y + 30);
+ }
}
-static void
-drawTuxLeft(tux_t * tux)
+static void drawTuxLeft(tux_t * tux)
{
- if (tux == NULL) {
- return;
- }
+ if (tux == NULL) {
+ return;
+ }
- drawShotInfo(tux, PANEL_LOCATION_X + 8, PANEL_LOCATION_Y + 34);
- drawGunInfo(tux, PANEL_LOCATION_X + 130, PANEL_LOCATION_Y + 30);
+ drawShotInfo(tux, PANEL_LOCATION_X + 8, PANEL_LOCATION_Y + 34);
+ drawGunInfo(tux, PANEL_LOCATION_X + 130, PANEL_LOCATION_Y + 30);
- if (tux->bonus != BONUS_NONE) {
- drawGrafBonus(tux, PANEL_LOCATION_X + 200, PANEL_LOCATION_Y + 50);
- drawBonusInfo(tux, PANEL_LOCATION_X + 200, PANEL_LOCATION_Y + 30);
- }
+ if (tux->bonus != BONUS_NONE) {
+ drawGrafBonus(tux, PANEL_LOCATION_X + 200, PANEL_LOCATION_Y + 50);
+ drawBonusInfo(tux, PANEL_LOCATION_X + 200, PANEL_LOCATION_Y + 30);
+ }
}
-void
-drawPanel(tux_t * tux_right, tux_t * tux_left)
+void drawPanel(tux_t * tux_right, tux_t * tux_left)
{
- drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w,
- g_panel->h);
- drawScore(tux_right, tux_left);
+ drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w,
+ g_panel->h);
+ drawScore(tux_right, tux_left);
- if (isRecivedNewMsg()) {
- drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y,
- COLOR_WHITE);
- }
+ if (isRecivedNewMsg()) {
+ drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y,
+ COLOR_WHITE);
+ }
- drawTuxRight(tux_right);
- drawTuxLeft(tux_left);
+ drawTuxRight(tux_right);
+ drawTuxLeft(tux_left);
}
-void
-quitPanel()
+void quitPanel()
{
- isPanelInit = FALSE;
+ isPanelInit = FALSE;
}
diff --git a/src/client/panel.h b/src/client/panel.h
index cfc0b5e..6478f3b 100644
--- a/src/client/panel.h
+++ b/src/client/panel.h
@@ -1,23 +1,23 @@
#ifndef PANEL_H
-#define PANEL_H
+# define PANEL_H
-#include "main.h"
-#include "list.h"
+# include "main.h"
+# include "list.h"
-#define PANEL_SCORE_LOCATION_X ( WINDOW_SIZE_X / 2 - w / 2 )
-#define PANEL_SCORE_LOCATION_Y ( WINDOW_SIZE_Y - 40 )
+# define PANEL_SCORE_LOCATION_X ( WINDOW_SIZE_X / 2 - w / 2 )
+# define PANEL_SCORE_LOCATION_Y ( WINDOW_SIZE_Y - 40 )
-#define PANEL_SHOT_WIDTH 4
-#define PANEL_SHOT_HEIGHT 8
+# define PANEL_SHOT_WIDTH 4
+# define PANEL_SHOT_HEIGHT 8
-#define PANEL_LOCATION_X 0
-#define PANEL_LOCATION_Y (WINDOW_SIZE_Y-g_panel->h)
+# define PANEL_LOCATION_X 0
+# define PANEL_LOCATION_Y (WINDOW_SIZE_Y-g_panel->h)
-#define PANEL_SHOT_FILL 0
-#define PANEL_SHOT_EMPTY 1
-#define PANEL_SHOT_LINE 2
+# define PANEL_SHOT_FILL 0
+# define PANEL_SHOT_EMPTY 1
+# define PANEL_SHOT_LINE 2
extern bool_t isPanelInicialized();
extern void initPanel();
diff --git a/src/client/pauza.c b/src/client/pauza.c
index f520660..6003d51 100644
--- a/src/client/pauza.c
+++ b/src/client/pauza.c
@@ -15,57 +15,49 @@
static image_t *g_pauza;
static bool_t activePauza;
-static void
-switchPauzed()
+static void switchPauzed()
{
- if (activePauza == TRUE) {
- activePauza = FALSE;
- }
- else {
- activePauza = TRUE;
- }
+ if (activePauza == TRUE) {
+ activePauza = FALSE;
+ } else {
+ activePauza = TRUE;
+ }
}
-static void
-hotkey_pauze()
+static void hotkey_pauze()
{
- switchPauzed();
+ switchPauzed();
}
-void
-initPauza()
+void initPauza()
{
- g_pauza =
- addImageData("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER);
- activePauza = FALSE;
+ g_pauza =
+ addImageData("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER);
+ activePauza = FALSE;
- registerHotKey(SDLK_p, hotkey_pauze);
+ registerHotKey(SDLK_p, hotkey_pauze);
}
-void
-drawPauza()
+void drawPauza()
{
- if (activePauza) {
- drawImage(g_pauza,
- WINDOW_SIZE_X / 2 - g_pauza->w / 2,
- WINDOW_SIZE_Y / 2 - g_pauza->h / 2,
- 0, 0, g_pauza->w, g_pauza->h);
- }
+ if (activePauza) {
+ drawImage(g_pauza,
+ WINDOW_SIZE_X / 2 - g_pauza->w / 2,
+ WINDOW_SIZE_Y / 2 - g_pauza->h / 2,
+ 0, 0, g_pauza->w, g_pauza->h);
+ }
}
-void
-eventPauza()
+void eventPauza()
{
}
-bool_t
-isPauzeActive()
+bool_t isPauzeActive()
{
- return activePauza;
+ return activePauza;
}
-void
-quitPauza()
+void quitPauza()
{
- unregisterHotKey(SDLK_p);
+ unregisterHotKey(SDLK_p);
}
diff --git a/src/client/pauza.h b/src/client/pauza.h
index b5eb58e..8ddd1f8 100644
--- a/src/client/pauza.h
+++ b/src/client/pauza.h
@@ -1,11 +1,11 @@
#ifndef PAUZA_H
-#define PAUZA_H
+# define PAUZA_H
-#define PAUZE_ACTIVE_TIME_INTERVAL 1000
+# define PAUZE_ACTIVE_TIME_INTERVAL 1000
-#include "main.h"
+# include "main.h"
extern void initPauza();
extern void drawPauza();
diff --git a/src/client/radar.c b/src/client/radar.c
index ade5599..990f8cb 100644
--- a/src/client/radar.c
+++ b/src/client/radar.c
@@ -15,112 +15,104 @@
static image_t *g_radar;
static list_t *listRadar;
-typedef struct radar_item_struct
-{
- int id;
- int x, y;
- int type;
+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)
+static radar_item_t *newRadarItem(int id, int x, int y, int type)
{
- radar_item_t *new;
+ radar_item_t *new;
- new = malloc(sizeof(radar_item_t));
- new->id = id;
- new->x = x;
- new->y = y;
- new->type = type;
+ new = malloc(sizeof(radar_item_t));
+ new->id = id;
+ new->x = x;
+ new->y = y;
+ new->type = type;
- return new;
+ return new;
}
-static void
-destroyRadarItem(radar_item_t * p)
+static void destroyRadarItem(radar_item_t * p)
{
- assert(p != NULL);
- free(p);
+ assert(p != NULL);
+ free(p);
}
-void
-addToRadar(int id, int x, int y, int type)
+void addToRadar(int id, int x, int y, int type)
{
- int i;
+ int i;
- for (i = 0; i < listRadar->count; i++) {
- radar_item_t *thisRadarItem;
+ for (i = 0; i < listRadar->count; i++) {
+ radar_item_t *thisRadarItem;
- thisRadarItem = (radar_item_t *) listRadar->list[i];
+ thisRadarItem = (radar_item_t *) listRadar->list[i];
- if (thisRadarItem->id == id) {
- thisRadarItem->x = x;
- thisRadarItem->y = y;
- thisRadarItem->type = type;
- return;
- }
- }
+ if (thisRadarItem->id == id) {
+ thisRadarItem->x = x;
+ thisRadarItem->y = y;
+ thisRadarItem->type = type;
+ return;
+ }
+ }
- addList(listRadar, newRadarItem(id, x, y, type));
+ addList(listRadar, newRadarItem(id, x, y, type));
}
-void
-delFromRadar(int id)
+void delFromRadar(int id)
{
- int i;
+ int i;
- for (i = 0; i < listRadar->count; i++) {
- radar_item_t *thisRadarItem;
+ for (i = 0; i < listRadar->count; i++) {
+ radar_item_t *thisRadarItem;
- thisRadarItem = (radar_item_t *) listRadar->list[i];
+ thisRadarItem = (radar_item_t *) listRadar->list[i];
- if (thisRadarItem->id == id) {
- delListItem(listRadar, i, destroyRadarItem);
- return;
- }
- }
+ if (thisRadarItem->id == id) {
+ delListItem(listRadar, i, destroyRadarItem);
+ return;
+ }
+ }
}
-void
-initRadar()
+void initRadar()
{
- assert(isImageInicialized() == TRUE);
- assert(isInterfaceInicialized() == TRUE);
+ assert(isImageInicialized() == TRUE);
+ assert(isInterfaceInicialized() == TRUE);
- g_radar =
- addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER);
- listRadar = newList();
+ g_radar =
+ addImageData("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER);
+ listRadar = newList();
}
-void
-drawRadar(arena_t * arena)
+void drawRadar(arena_t * arena)
{
- int i;
+ int i;
- drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0,
- RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2);
+ drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0,
+ RADAR_SIZE_X + 2, RADAR_SIZE_Y + 2);
- for (i = 0; i < listRadar->count; i++) {
- radar_item_t *thisRadarItem;
- int x, y;
+ for (i = 0; i < listRadar->count; i++) {
+ radar_item_t *thisRadarItem;
+ int x, y;
- thisRadarItem = (radar_item_t *) listRadar->list[i];
+ thisRadarItem = (radar_item_t *) listRadar->list[i];
- x = (((float) RADAR_SIZE_X) / ((float) arena->w)) *
- ((float) thisRadarItem->x);
- y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) *
- ((float) thisRadarItem->y);
+ x = (((float) RADAR_SIZE_X) / ((float) arena->w)) *
+ ((float) thisRadarItem->x);
+ y = (((float) RADAR_SIZE_Y) / ((float) arena->h)) *
+ ((float) thisRadarItem->y);
- if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) {
- drawImage(g_radar,
- RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y,
- 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
- }
- }
+ if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) {
+ drawImage(g_radar,
+ RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y,
+ 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
+ }
+ }
}
-void
-quitRadar()
+void quitRadar()
{
- destroyListItem(listRadar, destroyRadarItem);
+ destroyListItem(listRadar, destroyRadarItem);
}
diff --git a/src/client/radar.h b/src/client/radar.h
index a3f7b69..0092055 100644
--- a/src/client/radar.h
+++ b/src/client/radar.h
@@ -1,19 +1,19 @@
#ifndef RADAR_H
-#define RADAR_H
+# define RADAR_H
-#include "arena.h"
+# include "arena.h"
-#define RADAR_LOCATION_X (WINDOW_SIZE_X-110)
-#define RADAR_LOCATION_Y (10)
+# define RADAR_LOCATION_X (WINDOW_SIZE_X-110)
+# define RADAR_LOCATION_Y (10)
-#define RADAR_SIZE_X 100
-#define RADAR_SIZE_Y 100
+# define RADAR_SIZE_X 100
+# define RADAR_SIZE_Y 100
-#define RADAR_TYPE_YOU 3
-#define RADAR_TYPE_TUX 1
-#define RADAR_TYPE_ITEM 2
+# define RADAR_TYPE_YOU 3
+# define RADAR_TYPE_TUX 1
+# define RADAR_TYPE_ITEM 2
extern void initRadar();
extern void addToRadar(int id, int x, int y, int type);
diff --git a/src/client/saveDialog.c b/src/client/saveDialog.c
index 39343db..d154791 100644
--- a/src/client/saveDialog.c
+++ b/src/client/saveDialog.c
@@ -30,118 +30,109 @@ static widget_t *widgetTextFieldName;
static widget_t *widgetButtonSave;
static widget_t *widgetButtonBack;
-static void
-switchTerm()
+static void switchTerm()
{
- if (activeSaveDialog == TRUE) {
- activeSaveDialog = FALSE;
- }
- else {
- activeSaveDialog = TRUE;
- }
+ if (activeSaveDialog == TRUE) {
+ activeSaveDialog = FALSE;
+ } else {
+ activeSaveDialog = TRUE;
+ }
}
-static void
-eventWidget(void *p)
+static void eventWidget(void *p)
{
- widget_t *button;
+ widget_t *button;
- button = (widget_t *) p;
+ button = (widget_t *) p;
- if (button == widgetButtonSave) {
- saveArena(getTextFromWidgetTextfield(widgetTextFieldName),
- getCurrentArena());
- switchTerm();
- }
+ if (button == widgetButtonSave) {
+ saveArena(getTextFromWidgetTextfield(widgetTextFieldName),
+ getCurrentArena());
+ switchTerm();
+ }
- if (button == widgetButtonBack) {
- switchTerm();
- }
+ if (button == widgetButtonBack) {
+ switchTerm();
+ }
}
-static void
-hotkey_saveDialog()
+static void hotkey_saveDialog()
{
- switchTerm();
+ switchTerm();
}
-void
-initSaveDialog()
+void initSaveDialog()
{
- activeSaveDialog = FALSE;
+ activeSaveDialog = FALSE;
- g_background = getImage(IMAGE_GROUP_BASE, "screen_main");
+ g_background = getImage(IMAGE_GROUP_BASE, "screen_main");
- widgetLabelMsg = newWidgetLabel("name",
- SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_LEFT);
+ widgetLabelMsg = newWidgetLabel("name",
+ SAVE_DIALOG_LOCATIN_X + 20,
+ SAVE_DIALOG_LOCATIN_Y + 20,
+ WIDGET_LABEL_LEFT);
- widgetTextFieldName = newWidgetTextfield("noname",
- WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- widgetLabelMsg->x +
- widgetLabelMsg->w + 10,
- widgetLabelMsg->y);
+ widgetTextFieldName = newWidgetTextfield("noname",
+ WIDGET_TEXTFIELD_FILTER_ALPHANUM,
+ widgetLabelMsg->x +
+ widgetLabelMsg->w + 10,
+ widgetLabelMsg->y);
- widgetButtonSave = newWidgetButton("Save",
- SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
+ widgetButtonSave = newWidgetButton("Save",
+ SAVE_DIALOG_LOCATIN_X + 20,
+ SAVE_DIALOG_LOCATIN_Y + 60,
+ eventWidget);
- widgetButtonBack = newWidgetButton("Back",
- SAVE_DIALOG_LOCATIN_X + 20 +
- WIDGET_BUTTON_WIDTH + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
+ widgetButtonBack = newWidgetButton("Back",
+ SAVE_DIALOG_LOCATIN_X + 20 +
+ WIDGET_BUTTON_WIDTH + 20,
+ SAVE_DIALOG_LOCATIN_Y + 60,
+ eventWidget);
- registerHotKey(SDLK_F2, hotkey_saveDialog);
+ registerHotKey(SDLK_F2, hotkey_saveDialog);
}
-bool_t
-isSaveDialogActive()
+bool_t isSaveDialogActive()
{
- return activeSaveDialog;
+ return activeSaveDialog;
}
-void
-drawSaveDialog()
+void drawSaveDialog()
{
- if (activeSaveDialog == FALSE) {
- return;
- }
-
- drawImage(g_background,
- SAVE_DIALOG_LOCATIN_X,
- SAVE_DIALOG_LOCATIN_Y,
- SAVE_DIALOG_LOCATIN_X,
- SAVE_DIALOG_LOCATIN_Y, SAVE_DIALOG_SIZE_X, SAVE_DIALOG_SIZE_Y);
-
- drawWidgetLabel(widgetLabelMsg);
- drawWidgetTextfield(widgetTextFieldName);
- drawWidgetButton(widgetButtonSave);
- drawWidgetButton(widgetButtonBack);
+ if (activeSaveDialog == FALSE) {
+ return;
+ }
+
+ drawImage(g_background,
+ SAVE_DIALOG_LOCATIN_X,
+ SAVE_DIALOG_LOCATIN_Y,
+ SAVE_DIALOG_LOCATIN_X,
+ SAVE_DIALOG_LOCATIN_Y, SAVE_DIALOG_SIZE_X, SAVE_DIALOG_SIZE_Y);
+
+ drawWidgetLabel(widgetLabelMsg);
+ drawWidgetTextfield(widgetTextFieldName);
+ drawWidgetButton(widgetButtonSave);
+ drawWidgetButton(widgetButtonBack);
}
-void
-eventSaveDialog()
+void eventSaveDialog()
{
- if (activeSaveDialog == FALSE) {
- return;
- }
+ if (activeSaveDialog == FALSE) {
+ return;
+ }
- eventWidgetTextfield(widgetTextFieldName);
- eventWidgetButton(widgetButtonSave);
- eventWidgetButton(widgetButtonBack);
+ eventWidgetTextfield(widgetTextFieldName);
+ eventWidgetButton(widgetButtonSave);
+ eventWidgetButton(widgetButtonBack);
}
-void
-quitSaveDialog()
+void quitSaveDialog()
{
- unregisterHotKey(SDLK_F2);
+ unregisterHotKey(SDLK_F2);
- destroyWidgetLabel(widgetLabelMsg);
- destroyWidgetTextfield(widgetTextFieldName);
- destroyWidgetButton(widgetButtonSave);
- destroyWidgetButton(widgetButtonBack);
+ destroyWidgetLabel(widgetLabelMsg);
+ destroyWidgetTextfield(widgetTextFieldName);
+ destroyWidgetButton(widgetButtonSave);
+ destroyWidgetButton(widgetButtonBack);
}
diff --git a/src/client/saveDialog.h b/src/client/saveDialog.h
index 0849bdb..d96a252 100644
--- a/src/client/saveDialog.h
+++ b/src/client/saveDialog.h
@@ -1,15 +1,15 @@
#ifndef SAVE_DIALOG_H
-#define SAVE_DIALOG_H
+# define SAVE_DIALOG_H
-#define SAVEDIALOG_ACTIVE_TIME_INTERVAL 500
+# define SAVEDIALOG_ACTIVE_TIME_INTERVAL 500
-#define SAVE_DIALOG_SIZE_X 320
-#define SAVE_DIALOG_SIZE_Y 120
+# define SAVE_DIALOG_SIZE_X 320
+# define SAVE_DIALOG_SIZE_Y 120
-#define SAVE_DIALOG_LOCATIN_X (WINDOW_SIZE_X/2 - SAVE_DIALOG_SIZE_X/2)
-#define SAVE_DIALOG_LOCATIN_Y (WINDOW_SIZE_Y/2 - SAVE_DIALOG_SIZE_Y/2)
+# define SAVE_DIALOG_LOCATIN_X (WINDOW_SIZE_X/2 - SAVE_DIALOG_SIZE_X/2)
+# define SAVE_DIALOG_LOCATIN_Y (WINDOW_SIZE_Y/2 - SAVE_DIALOG_SIZE_Y/2)
extern void initSaveDialog();
diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c
index c49245f..01f6ea1 100644
--- a/src/client/saveLoad.c
+++ b/src/client/saveLoad.c
@@ -19,254 +19,243 @@
#include "screen_choiceArena.h"
#include "screen_world.h"
-static void
-action_saveTux(space_t * space, tux_t * tux, textFile_t * textFile)
+static void action_saveTux(space_t * space, tux_t * tux, textFile_t * textFile)
{
- char str[STR_PROTO_SIZE];
-
- snprintf(str, STR_PROTO_SIZE,
- "TUX %d %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
- tux->id, tux->x, tux->y, tux->status, tux->position,
- tux->control, tux->frame, tux->score, tux->name, tux->gun,
- tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE],
- tux->shot[GUN_SCATTER], tux->shot[GUN_TOMMY],
- tux->shot[GUN_LASSER], tux->shot[GUN_MINE],
- tux->shot[GUN_BOMBBALL], tux->bonus_time, tux->pickup_time);
-
- addList(textFile->text, strdup(str));
+ char str[STR_PROTO_SIZE];
+
+ snprintf(str, STR_PROTO_SIZE,
+ "TUX %d %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
+ tux->id, tux->x, tux->y, tux->status, tux->position,
+ tux->control, tux->frame, tux->score, tux->name, tux->gun,
+ tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE],
+ tux->shot[GUN_SCATTER], tux->shot[GUN_TOMMY],
+ tux->shot[GUN_LASSER], tux->shot[GUN_MINE],
+ tux->shot[GUN_BOMBBALL], tux->bonus_time, tux->pickup_time);
+
+ addList(textFile->text, strdup(str));
}
static void
action_saveShot(space_t * space, shot_t * shot, textFile_t * textFile)
{
- char str[STR_PROTO_SIZE];
+ char str[STR_PROTO_SIZE];
- snprintf(str, STR_PROTO_SIZE, "SHOT %d %d %d %d %d %d %d %d %d",
- shot->id, shot->x, shot->y, shot->px, shot->py,
- shot->position, shot->gun, shot->author_id,
- shot->isCanKillAuthor);
+ snprintf(str, STR_PROTO_SIZE, "SHOT %d %d %d %d %d %d %d %d %d",
+ shot->id, shot->x, shot->y, shot->px, shot->py,
+ shot->position, shot->gun, shot->author_id,
+ shot->isCanKillAuthor);
- addList(textFile->text, strdup(str));
+ addList(textFile->text, strdup(str));
}
static void
action_saveItem(space_t * space, item_t * item, textFile_t * textFile)
{
- char str[STR_PROTO_SIZE];
+ char str[STR_PROTO_SIZE];
- snprintf(str, STR_PROTO_SIZE, "ITEM %d %d %d %d %d %d %d",
- item->id, item->type, item->x, item->y,
- item->count, item->frame, item->author_id);
+ snprintf(str, STR_PROTO_SIZE, "ITEM %d %d %d %d %d %d %d",
+ item->id, item->type, item->x, item->y,
+ item->count, item->frame, item->author_id);
- addList(textFile->text, strdup(str));
+ addList(textFile->text, strdup(str));
}
-static void
-saveContextArenaToTextFile(textFile_t * textFile, arena_t * arena)
+static void saveContextArenaToTextFile(textFile_t * textFile, arena_t * arena)
{
- char str[STR_PROTO_SIZE];
+ char str[STR_PROTO_SIZE];
- sprintf(str, "ARENA %s %d %d",
- getArenaNetName(getChoiceArena()),
- arena->countRound, arena->max_countRound);
+ sprintf(str, "ARENA %s %d %d",
+ getArenaNetName(getChoiceArena()),
+ arena->countRound, arena->max_countRound);
- addList(textFile->text, strdup(str));
+ addList(textFile->text, strdup(str));
- actionSpace(arena->spaceTux, action_saveTux, textFile);
- actionSpace(arena->spaceShot, action_saveShot, textFile);
- actionSpace(arena->spaceItem, action_saveItem, textFile);
+ actionSpace(arena->spaceTux, action_saveTux, textFile);
+ actionSpace(arena->spaceShot, action_saveShot, textFile);
+ actionSpace(arena->spaceItem, action_saveItem, textFile);
}
-void
-saveArena(char *filename, arena_t * arena)
+void saveArena(char *filename, arena_t * arena)
{
- textFile_t *textFile;
- char path[STR_PATH_SIZE];
+ textFile_t *textFile;
+ char path[STR_PATH_SIZE];
- sprintf(path, "%s/%s.sav", getHomeDirector(), filename);
+ sprintf(path, "%s/%s.sav", getHomeDirector(), filename);
#ifdef DEBUG
- printf(_("Saving game to: \"%s\"\n"), path);
+ printf(_("Saving game to: \"%s\"\n"), path);
#endif
- textFile = newTextFile(path);
-
- if (textFile != NULL) {
- saveContextArenaToTextFile(textFile, arena);
- saveTextFile(textFile);
- destroyTextFile(textFile);
- }
- else {
- fprintf(stderr, _("I was unable to save: \"%s\"\n"), path);
- }
+ textFile = newTextFile(path);
+
+ if (textFile != NULL) {
+ saveContextArenaToTextFile(textFile, arena);
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ } else {
+ fprintf(stderr, _("I was unable to save: \"%s\"\n"), path);
+ }
}
-static arena_t *
-loadArenaFromLine(char *line)
+static arena_t *loadArenaFromLine(char *line)
{
- char cmd[STR_SIZE];
- char name[STR_SIZE];
- int countRound;
- int max_countRound;
- arena_t *arena;
+ char cmd[STR_SIZE];
+ char name[STR_SIZE];
+ int countRound;
+ int max_countRound;
+ arena_t *arena;
- sscanf(line, "%s %s %d %d", cmd, name, &countRound, &max_countRound);
+ sscanf(line, "%s %s %d %d", cmd, name, &countRound, &max_countRound);
- setWorldArena(getArenaFileFormNetName(name));
+ setWorldArena(getArenaFileFormNetName(name));
- arena = getCurrentArena();
- arena->max_countRound = max_countRound;
- arena->countRound = countRound;
+ arena = getCurrentArena();
+ arena->max_countRound = max_countRound;
+ arena->countRound = countRound;
- return arena;
+ return arena;
}
-static void
-loadTuxFromLine(char *line, arena_t * arena)
+static void loadTuxFromLine(char *line, arena_t * arena)
{
- char cmd[STR_PROTO_SIZE];
- char name[STR_NAME_SIZE];
- int id, x, y, status, position, frame, score, control;
- int myGun, myBonus;
- int gun1, gun2, gun3, gun4, gun5, gun6, gun7;
- int time1, time2;
- tux_t *tux;
-
- sscanf(line,
- "%s %d %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
- cmd, &id, &x, &y, &status, &position, &control, &frame, &score,
- name, &myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6,
- &gun7, &time1, &time2);
-
- tux = newTux();
- replaceTuxID(tux, id);
- addObjectToSpace(arena->spaceTux, tux);
-
- tux->control = control;
-
- if (tux->control == TUX_CONTROL_KEYBOARD_RIGHT) {
- setControlTux(tux, TUX_CONTROL_KEYBOARD_RIGHT);
- }
-
- if (tux->control == TUX_CONTROL_KEYBOARD_LEFT) {
- setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT);
- }
-
- if (tux->control == TUX_CONTROL_AI) {
- loadModule("libmodAI");
- setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT);
- }
-
- moveObjectInSpace(arena->spaceTux, tux, x, y);
- tux->status = status;
- tux->position = position;
- tux->frame = frame;
- tux->score = score;
- strcpy(tux->name, name);
- tux->gun = myGun;
- tux->bonus = myBonus;
- tux->shot[GUN_SIMPLE] = gun1;
- tux->shot[GUN_DUAL_SIMPLE] = gun2;
- tux->shot[GUN_SCATTER] = gun3;
- tux->shot[GUN_TOMMY] = gun4;
- tux->shot[GUN_LASSER] = gun5;
- tux->shot[GUN_MINE] = gun6;
- tux->shot[GUN_BOMBBALL] = gun7;
- tux->bonus_time = time1;
- tux->pickup_time = time2;
+ char cmd[STR_PROTO_SIZE];
+ char name[STR_NAME_SIZE];
+ int id, x, y, status, position, frame, score, control;
+ int myGun, myBonus;
+ int gun1, gun2, gun3, gun4, gun5, gun6, gun7;
+ int time1, time2;
+ tux_t *tux;
+
+ sscanf(line,
+ "%s %d %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
+ cmd, &id, &x, &y, &status, &position, &control, &frame, &score,
+ name, &myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6,
+ &gun7, &time1, &time2);
+
+ tux = newTux();
+ replaceTuxID(tux, id);
+ addObjectToSpace(arena->spaceTux, tux);
+
+ tux->control = control;
+
+ if (tux->control == TUX_CONTROL_KEYBOARD_RIGHT) {
+ setControlTux(tux, TUX_CONTROL_KEYBOARD_RIGHT);
+ }
+
+ if (tux->control == TUX_CONTROL_KEYBOARD_LEFT) {
+ setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT);
+ }
+
+ if (tux->control == TUX_CONTROL_AI) {
+ loadModule("libmodAI");
+ setControlTux(tux, TUX_CONTROL_KEYBOARD_LEFT);
+ }
+
+ moveObjectInSpace(arena->spaceTux, tux, x, y);
+ tux->status = status;
+ tux->position = position;
+ tux->frame = frame;
+ tux->score = score;
+ strcpy(tux->name, name);
+ tux->gun = myGun;
+ tux->bonus = myBonus;
+ tux->shot[GUN_SIMPLE] = gun1;
+ tux->shot[GUN_DUAL_SIMPLE] = gun2;
+ tux->shot[GUN_SCATTER] = gun3;
+ tux->shot[GUN_TOMMY] = gun4;
+ tux->shot[GUN_LASSER] = gun5;
+ tux->shot[GUN_MINE] = gun6;
+ tux->shot[GUN_BOMBBALL] = gun7;
+ tux->bonus_time = time1;
+ tux->pickup_time = time2;
}
-static void
-loadShotFromLine(char *line, arena_t * arena)
+static void loadShotFromLine(char *line, arena_t * arena)
{
- char cmd[STR_PROTO_SIZE];
- int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor;
- shot_t *shot;
+ char cmd[STR_PROTO_SIZE];
+ int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor;
+ shot_t *shot;
- sscanf(line, "%s %d %d %d %d %d %d %d %d %d",
- cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id,
- &isCanKillAuthor);
+ sscanf(line, "%s %d %d %d %d %d %d %d %d %d",
+ cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id,
+ &isCanKillAuthor);
- shot = newShot(x, y, px, py, gun, author_id);
+ shot = newShot(x, y, px, py, gun, author_id);
- replaceShotID(shot, shot_id);
- shot->isCanKillAuthor = isCanKillAuthor;
- shot->position = position;
+ replaceShotID(shot, shot_id);
+ shot->isCanKillAuthor = isCanKillAuthor;
+ shot->position = position;
- if (shot->gun == GUN_LASSER) {
- transformOnlyLasser(shot);
- }
+ if (shot->gun == GUN_LASSER) {
+ transformOnlyLasser(shot);
+ }
- addObjectToSpace(arena->spaceShot, shot);
+ addObjectToSpace(arena->spaceShot, shot);
}
-static void
-loadItemFromLine(char *line, arena_t * arena)
+static void loadItemFromLine(char *line, arena_t * arena)
{
- char cmd[STR_PROTO_SIZE];
- int id, type, x, y, count, frame, author_id, check_id;
- item_t *item;
+ char cmd[STR_PROTO_SIZE];
+ int id, type, x, y, count, frame, author_id, check_id;
+ item_t *item;
- sscanf(line, "%s %d %d %d %d %d %d %d %d",
- cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
+ sscanf(line, "%s %d %d %d %d %d %d %d %d",
+ cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
- item = newItem(x, y, type, author_id);
+ item = newItem(x, y, type, author_id);
- replaceItemID(item, id);
- item->count = count;
- item->frame = frame;
+ replaceItemID(item, id);
+ item->count = count;
+ item->frame = frame;
- addObjectToSpace(arena->spaceItem, item);
+ addObjectToSpace(arena->spaceItem, item);
}
-static arena_t *
-loadContextArenaFromTextFile(textFile_t * textFile)
+static arena_t *loadContextArenaFromTextFile(textFile_t * textFile)
{
- arena_t *arena;
- int i;
+ arena_t *arena;
+ int i;
- arena = NULL;
+ arena = NULL;
- for (i = 0; i < textFile->text->count; i++) {
- char *line;
+ for (i = 0; i < textFile->text->count; i++) {
+ char *line;
- line = (char *) textFile->text->list[i];
+ line = (char *) textFile->text->list[i];
- if (strncmp(line, "ARENA", 5) == 0) {
- arena = loadArenaFromLine(line);
- }
+ if (strncmp(line, "ARENA", 5) == 0) {
+ arena = loadArenaFromLine(line);
+ }
- if (strncmp(line, "TUX", 3) == 0) {
- loadTuxFromLine(line, arena);
- }
+ if (strncmp(line, "TUX", 3) == 0) {
+ loadTuxFromLine(line, arena);
+ }
- if (strncmp(line, "SHOT", 4) == 0) {
- loadShotFromLine(line, arena);
- }
+ if (strncmp(line, "SHOT", 4) == 0) {
+ loadShotFromLine(line, arena);
+ }
- if (strncmp(line, "ITEM", 4) == 0) {
- loadItemFromLine(line, arena);
- }
- }
+ if (strncmp(line, "ITEM", 4) == 0) {
+ loadItemFromLine(line, arena);
+ }
+ }
- return arena;
+ return arena;
}
-void
-loadArena(char *filename)
+void loadArena(char *filename)
{
- textFile_t *textFile;
- char path[STR_PATH_SIZE];
+ textFile_t *textFile;
+ char path[STR_PATH_SIZE];
- sprintf(path, "%s/%s", getHomeDirector(), filename);
+ sprintf(path, "%s/%s", getHomeDirector(), filename);
#ifdef DEBUG
- printf(_("Loadig game from file: \"%s\"\n"), path);
+ printf(_("Loadig game from file: \"%s\"\n"), path);
#endif
- textFile = loadTextFile(path);
-
- if (textFile != NULL) {
- loadContextArenaFromTextFile(textFile);
- destroyTextFile(textFile);
- }
- else {
- fprintf(stderr, _("Unable to load save: \"%s\"\n"), path);
- }
+ textFile = loadTextFile(path);
+
+ if (textFile != NULL) {
+ loadContextArenaFromTextFile(textFile);
+ destroyTextFile(textFile);
+ } else {
+ fprintf(stderr, _("Unable to load save: \"%s\"\n"), path);
+ }
}
diff --git a/src/client/saveLoad.h b/src/client/saveLoad.h
index 2860408..f62e293 100644
--- a/src/client/saveLoad.h
+++ b/src/client/saveLoad.h
@@ -1,10 +1,10 @@
#ifndef SAVELOAD_H
-#define SAVELOAD_H
+# define SAVELOAD_H
-#include "textFile.h"
-#include "arena.h"
+# include "textFile.h"
+# include "arena.h"
extern void saveArena(char *filename, arena_t * arena);
extern void loadArena(char *filename);
diff --git a/src/client/screen.c b/src/client/screen.c
index f9f1f2f..b5264bd 100644
--- a/src/client/screen.c
+++ b/src/client/screen.c
@@ -19,182 +19,169 @@ static list_t *listScreen;
static bool_t isScreenInit = FALSE;
-bool_t
-isScreenInicialized()
+bool_t isScreenInicialized()
{
- return isScreenInit;
+ return isScreenInit;
}
-screen_t *
-newScreen(char *name,
- void (*fce_start) (), void (*fce_event) (),
- void (*fce_draw) (), void (*fce_stop) ())
+screen_t *newScreen(char *name,
+ void (*fce_start) (), void (*fce_event) (),
+ void (*fce_draw) (), void (*fce_stop) ())
{
- screen_t *new;
-
- assert(name != NULL);
- assert(fce_start != NULL);
- assert(fce_event != NULL);
- assert(fce_draw != NULL);
- assert(fce_stop != NULL);
-
- new = malloc(sizeof(screen_t));
- new->name = strdup(name);
- new->fce_start = fce_start;
- new->fce_event = fce_event;
- new->fce_draw = fce_draw;
- new->fce_stop = fce_stop;
-
- return new;
+ screen_t *new;
+
+ assert(name != NULL);
+ assert(fce_start != NULL);
+ assert(fce_event != NULL);
+ assert(fce_draw != NULL);
+ assert(fce_stop != NULL);
+
+ new = malloc(sizeof(screen_t));
+ new->name = strdup(name);
+ new->fce_start = fce_start;
+ new->fce_event = fce_event;
+ new->fce_draw = fce_draw;
+ new->fce_stop = fce_stop;
+
+ return new;
}
-void
-destroyScreen(screen_t * p)
+void destroyScreen(screen_t * p)
{
- assert(p != NULL);
+ assert(p != NULL);
- free(p->name);
- free(p);
+ free(p->name);
+ free(p);
}
-void
-registerScreen(screen_t * p)
+void registerScreen(screen_t * p)
{
- assert(p != NULL);
+ assert(p != NULL);
#ifdef DEBUG
- printf(_("Registering screen: \"%s\"\n"), p->name);
+ printf(_("Registering screen: \"%s\"\n"), p->name);
#endif
- addList(listScreen, p);
+ addList(listScreen, p);
}
-void
-initScreen()
+void initScreen()
{
- listScreen = newList();
+ listScreen = newList();
- currentScreen = NULL;
- futureScreen = NULL;
+ currentScreen = NULL;
+ futureScreen = NULL;
- isScreenInit = TRUE;
+ isScreenInit = TRUE;
}
-static screen_t *
-findScreen(char *name)
+static screen_t *findScreen(char *name)
{
- screen_t *this;
- int i;
+ screen_t *this;
+ int i;
- for (i = 0; i < listScreen->count; i++) {
- this = (screen_t *) (listScreen->list[i]);
- assert(this != NULL);
+ for (i = 0; i < listScreen->count; i++) {
+ this = (screen_t *) (listScreen->list[i]);
+ assert(this != NULL);
- if (strcmp(name, this->name) == 0) {
- return this;
- }
- }
+ if (strcmp(name, this->name) == 0) {
+ return this;
+ }
+ }
- return NULL;
+ return NULL;
}
-void
-setScreen(char *name)
+void setScreen(char *name)
{
- futureScreen = findScreen(name);
- assert(futureScreen != NULL);
+ futureScreen = findScreen(name);
+ assert(futureScreen != NULL);
}
-void
-switchScreen()
+void switchScreen()
{
- if (futureScreen == NULL) {
- return;
- }
+ if (futureScreen == NULL) {
+ return;
+ }
- flushLayer();
+ flushLayer();
- if (currentScreen != NULL) {
+ if (currentScreen != NULL) {
#ifdef DEBUG
- printf(_("Stopping screen: \"%s\"\n"), currentScreen->name);
+ printf(_("Stopping screen: \"%s\"\n"), currentScreen->name);
#endif
- currentScreen->fce_stop();
- }
+ currentScreen->fce_stop();
+ }
- currentScreen = futureScreen;
- futureScreen = NULL;
+ currentScreen = futureScreen;
+ futureScreen = NULL;
- //printf("switch screen %s..\n", currentScreen->name);
+ //printf("switch screen %s..\n", currentScreen->name);
#ifdef DEBUG
- printf(_("Starting screen: \"%s\"\n"), currentScreen->name);
+ printf(_("Starting screen: \"%s\"\n"), currentScreen->name);
#endif
- currentScreen->fce_start();
+ currentScreen->fce_start();
}
-void
-startScreen(char *name)
+void startScreen(char *name)
{
- setScreen(name);
- switchScreen();
+ setScreen(name);
+ switchScreen();
}
-char *
-getScreen()
+char *getScreen()
{
- assert(currentScreen != NULL);
- return currentScreen->name;
+ assert(currentScreen != NULL);
+ return currentScreen->name;
}
-void
-drawScreen()
+void drawScreen()
{
- static int count = 0;
+ static int count = 0;
- count++;
+ count++;
- if (count == 1) {
- count = 0;
+ if (count == 1) {
+ count = 0;
- assert(currentScreen != NULL);
+ assert(currentScreen != NULL);
#ifdef DEBUG_TIME_DRAW
- my_time_t prev;
+ my_time_t prev;
- prev = getMyTimeMicro();
+ prev = getMyTimeMicro();
#endif
- currentScreen->fce_draw();
+ currentScreen->fce_draw();
- interfaceRefresh();
+ interfaceRefresh();
#ifdef DEBUG_TIME_DRAW
- printf("c draw time = %d\n", getMyTimeMicro() - prev);
+ printf("c draw time = %d\n", getMyTimeMicro() - prev);
#endif
- }
+ }
}
-void
-eventScreen()
+void eventScreen()
{
- assert(currentScreen != NULL);
+ assert(currentScreen != NULL);
#ifdef DEBUG_TIME_EVENT
- my_time_t prev;
+ my_time_t prev;
- prev = getMyTimeMicro();
+ prev = getMyTimeMicro();
#endif
- currentScreen->fce_event();
+ currentScreen->fce_event();
#ifdef DEBUG_TIME_EVENT
- printf("c event time = %d\n", getMyTimeMicro() - prev);
+ printf("c event time = %d\n", getMyTimeMicro() - prev);
#endif
}
-void
-quitScreen()
+void quitScreen()
{
- assert(listScreen != NULL);
+ assert(listScreen != NULL);
- destroyListItem(listScreen, destroyScreen);
- isScreenInit = FALSE;
+ destroyListItem(listScreen, destroyScreen);
+ isScreenInit = FALSE;
}
diff --git a/src/client/screen.h b/src/client/screen.h
index b0bdca3..3227bfe 100644
--- a/src/client/screen.h
+++ b/src/client/screen.h
@@ -1,24 +1,23 @@
#ifndef SCREEN_H
-#define SCREEN_H
+# define SCREEN_H
-#include "main.h"
+# include "main.h"
-typedef struct screen_struct
-{
- char *name;
- void (*fce_start) ();
- void (*fce_event) ();
- void (*fce_draw) ();
- void (*fce_stop) ();
+typedef struct screen_struct {
+ char *name;
+ void (*fce_start) ();
+ void (*fce_event) ();
+ void (*fce_draw) ();
+ void (*fce_stop) ();
} screen_t;
extern bool_t isScreenInicialized();
extern screen_t *newScreen(char *name,
- void (*fce_start) (), void (*fce_event) (),
- void (*fce_draw) (), void (*fce_stop) ());
+ void (*fce_start) (), void (*fce_event) (),
+ void (*fce_draw) (), void (*fce_stop) ());
extern void destroyScreen(screen_t * p);
extern void registerScreen(screen_t * p);
diff --git a/src/client/term.c b/src/client/term.c
index e0eb939..5266c53 100644
--- a/src/client/term.c
+++ b/src/client/term.c
@@ -18,151 +18,141 @@ static bool_t activeTerm;
static my_time_t lastActive;
static my_time_t lastRefresh;
-void
-initTerm()
+void initTerm()
{
- listText = newList();
+ listText = newList();
- activeTerm = FALSE;
- lastActive = getMyTime();
- lastRefresh = lastActive;
+ activeTerm = FALSE;
+ lastActive = getMyTime();
+ lastRefresh = lastActive;
}
-static char *
-getStrGun(int gun)
+static char *getStrGun(int gun)
{
- switch (gun) {
- case GUN_SIMPLE:
- return "revolver";
- case GUN_DUAL_SIMPLE:
- return "dual revolver";
- case GUN_SCATTER:
- return "scatter";
- case GUN_TOMMY:
- return "tommy";
- case GUN_LASSER:
- return "lasser";
- case GUN_MINE:
- return "mine";
- case GUN_BOMBBALL:
- return "bombball";
- default:
- return "none";
- }
-
- return "gun_unknow";
+ switch (gun) {
+ case GUN_SIMPLE:
+ return "revolver";
+ case GUN_DUAL_SIMPLE:
+ return "dual revolver";
+ case GUN_SCATTER:
+ return "scatter";
+ case GUN_TOMMY:
+ return "tommy";
+ case GUN_LASSER:
+ return "lasser";
+ case GUN_MINE:
+ return "mine";
+ case GUN_BOMBBALL:
+ return "bombball";
+ default:
+ return "none";
+ }
+
+ return "gun_unknow";
}
-static char *
-getStrBonus(int bonus)
+static char *getStrBonus(int bonus)
{
- switch (bonus) {
- case BONUS_SPEED:
- return "speed";
- case BONUS_SHOT:
- return "shot";
- case BONUS_TELEPORT:
- return "teleport";
- case BONUS_GHOST:
- return "ghost";
- case BONUS_4X:
- return "4X";
- case BONUS_HIDDEN:
- return "hidden";
- default:
- return "none";
- }
-
- return "bonus_unknow";
+ switch (bonus) {
+ case BONUS_SPEED:
+ return "speed";
+ case BONUS_SHOT:
+ return "shot";
+ case BONUS_TELEPORT:
+ return "teleport";
+ case BONUS_GHOST:
+ return "ghost";
+ case BONUS_4X:
+ return "4X";
+ case BONUS_HIDDEN:
+ return "hidden";
+ default:
+ return "none";
+ }
+
+ return "bonus_unknow";
}
-static void
-action_refreshTerm(space_t * space, tux_t * tux, void *p)
+static void action_refreshTerm(space_t * space, tux_t * tux, void *p)
{
- char str[STR_SIZE];
-
- sprintf(str,
- "name: %s "
- "score: %d "
- "gun: %s "
- "shot: %d "
- "bonus: %s",
- tux->name, tux->score,
- getStrGun(tux->gun), tux->shot[tux->gun], getStrBonus(tux->bonus)
- );
-
- addList(listText, strdup(str));
+ char str[STR_SIZE];
+
+ sprintf(str,
+ "name: %s "
+ "score: %d "
+ "gun: %s "
+ "shot: %d "
+ "bonus: %s",
+ tux->name, tux->score,
+ getStrGun(tux->gun), tux->shot[tux->gun], getStrBonus(tux->bonus)
+ );
+
+ addList(listText, strdup(str));
}
-static void
-refreshTerm()
+static void refreshTerm()
{
- arena_t *arena;
+ arena_t *arena;
- arena = getCurrentArena();
+ arena = getCurrentArena();
- destroyListItem(listText, free);
- listText = newList();
+ destroyListItem(listText, free);
+ listText = newList();
- actionSpace(arena->spaceTux, action_refreshTerm, NULL);
+ actionSpace(arena->spaceTux, action_refreshTerm, NULL);
- //printf("refresh term..\n");
+ //printf("refresh term..\n");
}
-void
-drawTerm()
+void drawTerm()
{
- int i;
+ int i;
- if (activeTerm == FALSE) {
- return;
- }
+ if (activeTerm == FALSE) {
+ return;
+ }
- for (i = 0; i < listText->count; i++) {
- char *line;
+ for (i = 0; i < listText->count; i++) {
+ char *line;
- line = (char *) listText->list[i];
- drawFont(line, 10, 10 + i * 20, COLOR_WHITE);
- }
+ line = (char *) listText->list[i];
+ drawFont(line, 10, 10 + i * 20, COLOR_WHITE);
+ }
}
-static void
-switchTerm()
+static void switchTerm()
{
- if (activeTerm == TRUE) {
- activeTerm = FALSE;
- }
- else {
- activeTerm = TRUE;
- }
+ if (activeTerm == TRUE) {
+ activeTerm = FALSE;
+ } else {
+ activeTerm = TRUE;
+ }
}
-void
-eventTerm()
+void eventTerm()
{
- my_time_t currentTime;
- Uint8 *mapa;
+ my_time_t currentTime;
+ Uint8 *mapa;
- mapa = SDL_GetKeyState(NULL);
+ mapa = SDL_GetKeyState(NULL);
- currentTime = getMyTime();
+ currentTime = getMyTime();
- if (currentTime - lastRefresh > TERM_REFRESH_TIME_INTERVAL) {
- lastRefresh = currentTime;
- refreshTerm();
- }
+ if (currentTime - lastRefresh > TERM_REFRESH_TIME_INTERVAL) {
+ lastRefresh = currentTime;
+ refreshTerm();
+ }
- if (mapa[SDLK_TAB] == SDL_PRESSED) {
- if (currentTime - lastActive > TERM_ACTIVE_TIME_INTERVAL) {
- lastActive = currentTime;
- switchTerm();
- }
- }
+ if (mapa[SDLK_TAB] == SDL_PRESSED) {
+ if (currentTime - lastActive > TERM_ACTIVE_TIME_INTERVAL) {
+ lastActive = currentTime;
+ switchTerm();
+ }
+ }
}
-void
-quitTerm()
+void quitTerm()
{
- assert(listText != NULL);
- destroyListItem(listText, free);
+ assert(listText != NULL);
+ destroyListItem(listText, free);
}
diff --git a/src/client/term.h b/src/client/term.h
index 99dbf79..ffc0e14 100644
--- a/src/client/term.h
+++ b/src/client/term.h
@@ -1,12 +1,12 @@
#ifndef TERM_H
-#define TERM_H
+# define TERM_H
-#include "main.h"
+# include "main.h"
-#define TERM_ACTIVE_TIME_INTERVAL 500
-#define TERM_REFRESH_TIME_INTERVAL 1000
+# define TERM_ACTIVE_TIME_INTERVAL 500
+# define TERM_REFRESH_TIME_INTERVAL 1000
extern void initTerm();
extern void drawTerm();