summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorConnor Thomson <blumatrikz@gmail.com>2026-09-08 18:27:39 -0700
committerConnor Thomson <blumatrikz@gmail.com>2026-09-08 18:27:39 -0700
commitf1ddc12b68b4e4c8087962de25260470e6df2bea (patch)
tree7d0440a6402a9b0ef75ded23fa64b68534255bba /src/client
parent6025860a61386bf767b29c3ec5fd0d31285f1056 (diff)
Add tuxanci2 files
Diffstat (limited to 'src/client')
-rw-r--r--src/client/CMakeLists.txt7
-rw-r--r--src/client/chat.c295
-rw-r--r--src/client/chat.h23
-rw-r--r--src/client/client.c338
-rw-r--r--src/client/client.h16
-rw-r--r--src/client/config.c227
-rw-r--r--src/client/config.h42
-rw-r--r--src/client/configFile.c152
-rw-r--r--src/client/configFile.h19
-rw-r--r--src/client/control.c84
-rw-r--r--src/client/control.h27
-rw-r--r--src/client/font.c156
-rw-r--r--src/client/font.h27
-rw-r--r--src/client/fontConfig.c102
-rw-r--r--src/client/fontConfig.h14
-rw-r--r--src/client/game.c127
-rw-r--r--src/client/game.h7
-rw-r--r--src/client/hotKey.c149
-rw-r--r--src/client/hotKey.h14
-rw-r--r--src/client/image.c323
-rw-r--r--src/client/image.h55
-rw-r--r--src/client/interface.c358
-rw-r--r--src/client/interface.h48
-rw-r--r--src/client/keyboardBuffer.c142
-rw-r--r--src/client/keyboardBuffer.h24
-rw-r--r--src/client/layer.c200
-rw-r--r--src/client/layer.h42
-rw-r--r--src/client/mouse_buffer.c138
-rw-r--r--src/client/mouse_buffer.h18
-rw-r--r--src/client/panel.c159
-rw-r--r--src/client/panel.h25
-rw-r--r--src/client/pauza.c61
-rw-r--r--src/client/pauza.h14
-rw-r--r--src/client/radar.c113
-rw-r--r--src/client/radar.h22
-rw-r--r--src/client/saveDialog.c134
-rw-r--r--src/client/saveDialog.h18
-rw-r--r--src/client/saveLoad.c258
-rw-r--r--src/client/saveLoad.h10
-rw-r--r--src/client/screen.c175
-rw-r--r--src/client/screen.h32
-rw-r--r--src/client/term.c157
-rw-r--r--src/client/term.h14
-rw-r--r--src/client/yes_no_dialog.c134
-rw-r--r--src/client/yes_no_dialog.h20
45 files changed, 0 insertions, 4520 deletions
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
deleted file mode 100644
index 2e93cef..0000000
--- a/src/client/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-###############################################################################
-# tuxanci/src/*/CMakeLists.txt
-###############################################################################
-# Generate source_code files from .c files we find in directory
-###############################################################################
-MacroAddSources()
-###############################################################################
diff --git a/src/client/chat.c b/src/client/chat.c
deleted file mode 100644
index d68edb8..0000000
--- a/src/client/chat.c
+++ /dev/null
@@ -1,295 +0,0 @@
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <SDL.h>
-
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
-#include "image.h"
-#include "serverSendMsg.h"
-
-#include "net_multiplayer.h"
-#include "world.h"
-#include "proto.h"
-#include "interface.h"
-#include "chat.h"
-#include "font.h"
-#include "keyboardBuffer.h"
-#include "hotKey.h"
-
-static image_t *g_chat;
-
-static list_t *listText;
-
-static char line[STR_SIZE];
-
-static int line_time, line_atime;
-static int timeBlick;
-
-static bool_t chat_active;
-static bool_t receivedNewMsg;
-
-static void hotkey_chat_enter();
-static void hotkey_chat_enter();
-static void chat_eventDisable();
-
-static void hotkey_chat_esc()
-{
- /*
- printf("*** hotkey_chat_esc\n");
- hot_key_unregister(SDLK_ESCAPE);
- */
- chat_eventDisable();
-}
-
-static void hotkey_chat_enter()
-{
- if (chat_active == TRUE) {
- return;
- }
-
- chat_active = TRUE;
- receivedNewMsg = FALSE;
-
- hot_key_disable(SDLK_RETURN);
- hot_key_disable(SDLK_p);
- hot_key_register(SDLK_ESCAPE, hotkey_chat_esc);
-
- interface_enable_keyboard_buffer();
- keyboard_buffer_clear();
-}
-
-void chat_init()
-{
- g_chat = image_add("chat.png", IMAGE_NO_ALPHA, "chat", IMAGE_GROUP_USER);
-
- listText = list_new();
- strcpy(line, "");
- chat_active = FALSE;
-
- if (net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE) {
- hot_key_register(SDLK_RETURN, hotkey_chat_enter);
- }
-
- receivedNewMsg = FALSE;
- line_time = 0;
- line_atime = 0;
- timeBlick = 0;
-}
-
-void chat_draw()
-{
- char str[STR_SIZE];
- int i;
-
- if (chat_active == FALSE) {
- return;
- }
-
- image_draw(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;
-
- s = (char *) listText->list[i];
-
- font_drawMaxSize(s, CHAT_LOCATION_X + 5, CHAT_LOCATION_Y + 5 + i * 20,
- CHAT_SIZE_X - 10, 20, COLOR_WHITE);
- }
-
- strcpy(str, line);
-
- if (timeBlick > CHAT_TIME_BLICK_CURSOR / 2) {
- strcat(str, "\f");
- }
-
- timeBlick++;
-
- if (timeBlick == CHAT_TIME_BLICK_CURSOR) {
- timeBlick = 0;
- }
-
- font_draw(str, CHAT_LOCATION_X + 5, (CHAT_LOCATION_Y + 5) + (CHAT_MAX_LINES * 20), COLOR_WHITE);
-}
-
-static void processMessageKey(SDL_keysym keysym)
-{
- int w, h;
- int len;
- unsigned n;
-
- char shift_map[] = {
- '-', '_',
- '=', '+',
- '[', '{',
- ']', '}',
- ';', ':',
- '/', '\"',
- '\\', '|',
- ',', '<',
- '.', '>',
- '/', '?',
- ')', '('
- };
-
- if (line_atime < 100) {
- line_atime++;
- }
-
- len = strlen(line);
- font_text_size(line, &w, &h);
-
- /* processing of backspace */
- if (keysym.sym == SDLK_BACKSPACE && len > 0) {
- line[len - 1] = '\0';
- return;
- }
-
- /* end of line */
- if (w > CHAT_SIZE_X - 20) {
- 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
- */
- char c = keysym.sym;
-
- if (keysym.mod & KMOD_RSHIFT) {
- for (n = 0; n < sizeof (shift_map); n += 2) {
- if (c == shift_map[n]) {
- c = shift_map[n+1];
- break;
- }
- }
- }
-
- line[len] = c;
- return;
- }
-
- /* 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()
-{
- if (net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) {
- proto_send_chat_client(line);
- }
-
- if (net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) {
- char out[STR_PROTO_SIZE];
-
- snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n",
- world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)->name,
- line);
-
- proto_send_chat_server(PROTO_SEND_ALL, NULL, out);
- }
-}
-
-static void chat_eventDisable()
-{
- chat_active = FALSE;
- memset(line, '\0', STR_SIZE);
-
- hot_key_enable(SDLK_RETURN);
- hot_key_enable(SDLK_p);
- hot_key_unregister(SDLK_ESCAPE);
-
- interface_disable_keyboard_buffer();
- keyboard_buffer_clear();
-}
-
-static void chat_eventEnable()
-{
- /* 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 (keyboard_buffer_is_any_key() == TRUE) {
- SDL_keysym key;
- key = keyboard_buffer_pop();
-
- 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 */
- /*chat_eventDisable();*/
- /* turn off key catching into the buffer and clear the buffer */
- /*interface_disable_keyboard_buffer();*/
- /*keyboard_buffer_clear();*/
- }
- }
-
- processMessageKey(key);
- }
-}
-
-/**
- * Processing of chat 'events'
- */
-void chat_event()
-{
- if (chat_is_active()) {
- chat_eventEnable();
- }
-}
-
-bool_t chat_is_active()
-{
- return chat_active;
-}
-
-bool_t chat_is_recived_new_msg()
-{
- return receivedNewMsg;
-}
-
-void chat_add(char *s)
-{
- list_add(listText, strdup(s));
-
- if (listText->count > CHAT_MAX_LINES) {
- list_del_item(listText, 0, free);
- }
-
- if (chat_active == FALSE) {
- receivedNewMsg = TRUE;
- }
-}
-
-void chat_quit()
-{
- assert(listText != NULL);
-
- if (net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE) {
- hot_key_unregister(SDLK_RETURN);
- }
-
- list_destroy_item(listText, free);
-}
diff --git a/src/client/chat.h b/src/client/chat.h
deleted file mode 100644
index 5427f60..0000000
--- a/src/client/chat.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef 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_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)
-
-extern void chat_init();
-extern void chat_draw();
-extern void chat_event();
-extern void chat_add(char *s);
-extern bool_t chat_is_active();
-extern bool_t chat_is_recived_new_msg();
-extern void chat_quit();
-
-#endif /* CHAT_H */
diff --git a/src/client/client.c b/src/client/client.c
deleted file mode 100644
index 054b3ea..0000000
--- a/src/client/client.c
+++ /dev/null
@@ -1,338 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#ifndef __WIN32__
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#else /* __WIN32__ */
-#include <io.h>
-#include <winsock2.h>
-#endif /* __WIN32__ */
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "proto.h"
-
-#include "client.h"
-
-#include "analyze.h"
-#include "world.h"
-#include "buffer.h"
-
-#include "udp.h"
-
-static sock_udp_t *sock_server_udp;
-
-static list_t *listRecvMsg;
-
-static buffer_t *clientRecvBuffer;
-static buffer_t *clientSendBuffer;
-
-static my_time_t lastPing;
-static my_time_t lastPingServerAlive;
-
-#ifdef SUPPORT_TRAFFIC
-static my_time_t lastTraffic;
-static int traffic_down;
-static int traffic_up;
-#endif /* SUPPORT_TRAFFIC */
-
-typedef struct proto_cmd_client_struct {
- char *name;
- int len;
- void (*fce_proto) (char *msg);
-} proto_cmd_client_t;
-
-static proto_cmd_client_t proto_cmd_list[] = {
- {.name = "error",.len = 5,.fce_proto = proto_recv_error_client},
- {.name = "init",.len = 4,.fce_proto = proto_recv_init_client},
- {.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)
-{
- int len;
- int i;
-
- len = strlen(msg);
-
- for (i = 0; proto_cmd_list[i].len != 0; i++) {
- proto_cmd_client_t *thisCmd;
-
- thisCmd = &proto_cmd_list[i];
-
- if (len >= thisCmd->len &&
- strncmp(msg, thisCmd->name, thisCmd->len) == 0) {
- return thisCmd;
- }
- }
-
- return NULL;
-}
-
-static int initUdpClient(char *ip, int port)
-{
- sock_server_udp = sock_udp_connect(ip, port);
-
- if (sock_server_udp == NULL) {
- return -1;
- }
-
- debug("Connected to game server [%s]:[%d]", ip, port);
-
- return 0;
-}
-
-int client_init(char *ip, int port)
-{
- char name[STR_NAME_SIZE];
- int ret;
-
- listRecvMsg = list_new();
- lastPing = timer_get_current_time();
- lastPingServerAlive = timer_get_current_time();
-
-#ifdef SUPPORT_TRAFFIC
- lastTraffic = timer_get_current_time();
- traffic_down = 0;
- traffic_up = 0;
-#endif /* SUPPORT_TRAFFIC */
-
- clientRecvBuffer = buffer_new(CLIENT_BUFFER_LIMIT);
- clientSendBuffer = buffer_new(CLIENT_BUFFER_LIMIT);
-
- ret = initUdpClient(ip, port);
-
- if (ret < 0) {
- return -1;
- }
-
- public_server_get_setting_name_right(name);
- proto_send_hello_client(name);
-
- return 0;
-}
-
-static void errorWithServer()
-{
- error("Game server is not responding");
- analyze_set_msg(_("Unable to connect to the game server"));
- world_do_end();
-}
-
-void client_send(char *msg)
-{
- int ret;
-
- assert(msg != NULL);
-
- ret = -1;
-
- if (isParamFlag("--send")) {
- debug("Sending data: %s", msg);
- }
-
-#ifdef SUPPORT_TRAFFIC
- traffic_up += strlen(msg);
-#endif /* SUPPORT_TRAFFIC */
-
- if (sock_server_udp != NULL) {
- ret = sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg));
- }
-
- if (ret < 0) {
- errorWithServer();
- return;
- }
-}
-
-static int server_eventSelect()
-{
- char buffer[STR_PROTO_SIZE];
- int ret;
-
- memset(buffer, 0, STR_PROTO_SIZE);
- ret = -1;
-
- if (sock_server_udp != NULL) {
- ret = sock_udp_read(sock_server_udp, sock_server_udp, buffer, STR_PROTO_SIZE - 1);
- }
-
- if (ret < 0) {
- errorWithServer();
- return ret;
- }
-
-#ifdef SUPPORT_TRAFFIC
- traffic_down += ret;
-#endif /* SUPPORT_TRAFFIC */
-
- list_add(listRecvMsg, strdup(buffer));
-
- return ret;
-}
-
-static void client_eventWorkRecvList()
-{
- proto_cmd_client_t *protoCmd;
- char *line;
- int i;
-
- /* processing of an event received from a game server */
-
- assert(listRecvMsg != NULL);
-
- for (i = 0; i < listRecvMsg->count; i++) {
- line = (char *) listRecvMsg->list[i];
- protoCmd = findCmdProto(line);
-
- if (isParamFlag("--recv")) {
- debug("Recieved data: %s", line);
- }
-
- if (protoCmd != NULL) {
- protoCmd->fce_proto(line);
- lastPingServerAlive = timer_get_current_time();
- }
- }
-
- list_destroy_item(listRecvMsg, free);
- listRecvMsg = list_new();
-}
-
-static void eventPingServer()
-{
- my_time_t currentTime;
-
- currentTime = timer_get_current_time();
-
- if (currentTime - lastPing > CLIENT_TIMEOUT) {
- proto_send_ping_client();
- lastPing = timer_get_current_time();
- }
-}
-
-static bool_t isServerAlive()
-{
- my_time_t currentTime;
-
- currentTime = timer_get_current_time();
-
- if (currentTime - lastPingServerAlive > SERVER_TIMEOUT_ALIVE) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void selectClientSocket()
-{
- fd_set readfds;
- struct timeval tv;
- int max_fd;
- int sock;
- bool_t isNext;
-
- max_fd = 0;
- sock = 0;
-
- if (sock_server_udp != NULL) {
- if (isServerAlive() == FALSE) {
- errorWithServer();
- return;
- }
- }
-
- do {
- isNext = FALSE;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
-
- FD_ZERO(&readfds);
-
- 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);
-
- if (FD_ISSET(sock, &readfds)) {
- if (server_eventSelect() > 0) {
- isNext = TRUE;
- }
- }
-
- } while (isNext == TRUE);
-}
-
-#ifdef SUPPORT_TRAFFIC
-static void eventTraffic()
-{
- my_time_t currentTime;
-
- currentTime = timer_get_current_time();
-
- if (currentTime - lastTraffic > 5000) {
- lastTraffic = currentTime;
-
- debug("Traffic: down [%d]/up [%d]", traffic_down, traffic_up);
-
- traffic_down = 0;
- traffic_up = 0;
- }
-}
-#endif /* SUPPORT_TRAFFIC */
-
-void client_event()
-{
-#ifdef SUPPORT_TRAFFIC
- eventTraffic();
-#endif /* SUPPORT_TRAFFIC */
-
- eventPingServer();
- selectClientSocket();
- client_eventWorkRecvList();
-}
-
-static void quitUdpClient()
-{
- assert(sock_server_udp != NULL);
- sock_udp_close(sock_server_udp);
-
- debug("Closing connection to game server");
-}
-
-void client_quit()
-{
- proto_send_end_client();
-
- assert(listRecvMsg != NULL);
-
- list_destroy_item(listRecvMsg, free);
- buffer_destroy(clientRecvBuffer);
- buffer_destroy(clientSendBuffer);
-
- if (sock_server_udp != NULL) {
- quitUdpClient();
- }
-}
diff --git a/src/client/client.h b/src/client/client.h
deleted file mode 100644
index ce41ffb..0000000
--- a/src/client/client.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef MY_CLIENT_H
-#define MY_CLIENT_H
-
-#include "main.h"
-
-#define CLIENT_TIMEOUT 1000
-#define SERVER_TIMEOUT_ALIVE 5000
-
-#define CLIENT_BUFFER_LIMIT 4096
-
-extern int client_init(char *ip, int port);
-extern void client_send(char *msg);
-extern void client_event();
-extern void client_quit();
-
-#endif /* MY_CLIENT_H */
diff --git a/src/client/config.c b/src/client/config.c
deleted file mode 100644
index 130fcdf..0000000
--- a/src/client/config.c
+++ /dev/null
@@ -1,227 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "homeDirector.h"
-#include "textFile.h"
-#include "configFile.h"
-#include "config.h"
-
-typedef struct setting_int_struct {
- int key; /* identification key */
- char *param; /* parameter of the program */
- char *var; /* variable in the config file */
- int type; /* type of the data - string/number */
- int value_int; /* numeric data */
- char *value_str; /* textual data */
-} config_t;
-
-#define CONFIG_TYPE_INT 1
-#define CONFIG_TYPE_STR 2
-
-static config_t config_list[] =
-{
- { .key=CFG_NAME_RIGHT, .var="NAME_PLAYER_RIGHT", .param="--name-right", .type=CONFIG_TYPE_STR, .value_str="name1" },
- { .key=CFG_NAME_LEFT, .var="NAME_PLAYER_LEFT", .param="--name-left", .type=CONFIG_TYPE_STR, .value_str="name2" },
- { .key=CFG_COUNT_ROUND, .var="COUNT_ROUND", .param="--count", .type=CONFIG_TYPE_INT, .value_int=15 },
- { .key=CFG_AI, .var="AI", .param="--ai", .type=CONFIG_TYPE_INT, .value_int=0 },
- { .key=CFG_MUSIC, .var="MUSIC", .param="--music", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_SOUND, .var="SOUND", .param="--sound", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_ARENA, .var="ARENA", .param="--arena", .type=CONFIG_TYPE_STR, .value_str="FAGN" },
-
- { .key=CFG_GUN_DUAL_SIMPLE, .var="GUN_DUAL_SIMPLE", .param="--gun-dual-simple", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_GUN_SCATTER, .var="GUN_SCATTER", .param="--gun-scatter", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_GUN_TOMMY, .var="GUN_TOMMY", .param="--gun-tommy", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_GUN_LASSER, .var="GUN_LASSER", .param="--gun-lasser", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_GUN_MINE, .var="GUN_MINE", .param="--gun-mine", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_GUN_BOMBBALL, .var="GUN_BOMBBALL", .param="--gun-bombball", .type=CONFIG_TYPE_INT, .value_int=1 },
-
- { .key=CFG_BONUS_SPEED, .var="BONUS_SPEED", .param="--bonus-speed", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_BONUS_SHOT, .var="BONUS_SHOT", .param="--bonus-shot", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_BONUS_TELEPORT, .var="BONUS_TELEPORT", .param="--bonus-teleport", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_BONUS_GHOST, .var="BONUS_GHOST", .param="--bonus-ghost", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_BONUS_4X, .var="BONUS_4X", .param="--bonus-4x", .type=CONFIG_TYPE_INT, .value_int=1 },
- { .key=CFG_BONUS_HIDDEN, .var="BONUS_HIDDEN", .param="--bonus-hidden", .type=CONFIG_TYPE_INT, .value_int=1 },
-
- { .key=CFG_GAME_TYPE, .var="GAME_TYPE", .param="--game-type", .type=CONFIG_TYPE_STR, .value_str="none" },
- { .key=CFG_NET_IP, .var="NET_IP", .param="--ip", .type=CONFIG_TYPE_STR, .value_str="127.0.0.1" },
- { .key=CFG_NET_PORT, .var="NET_PORT", .param="--port", .type=CONFIG_TYPE_STR, .value_str="6800" }
-};
-
-static textFile_t *config_file;
-
-static config_t *find_config(int key)
-{
- int i;
-
- for (i = 0; i < CONFIG_LIST_COUNT; i++) {
- if (config_list[i].key == key) {
- return &config_list[i];
- }
- }
-
- return NULL;
-}
-
-static void check_param()
-{
- int i;
-
- for (i = 0; i < CONFIG_LIST_COUNT; i++) {
- char *str;
-
- str = getParam(config_list[i].param);
-
- if (str != NULL) {
- if (config_list[i].type == CONFIG_TYPE_INT) {
- config_list[i].value_int = atoi(str);
- } else {
- if (config_list[i].value_str != NULL) {
- free(config_list[i].value_str);
- }
-
- config_list[i].value_str = strdup(str);
- }
- }
- }
-}
-
-int config_init()
-{
- config_load();
- check_param();
-
- return 0;
-}
-
-void config_load()
-{
- char path[STR_PATH_SIZE];
- char val[STR_SIZE];
- int i;
-
- sprintf(path, "%s%stuxanci.conf", home_director_get(), PATH_SEPARATOR);
-
- config_file = text_file_load(path);
-
- if (config_file == NULL) {
- error("Unable to load config file [%s]", path);
- debug("Creating config file [%s]", path);
-
- config_file = text_file_new(path);
- }
-
- if (config_file == NULL) {
- error("Unable to create config file [%s]", path);
- return;
- }
-
- for (i = 0; i < CONFIG_LIST_COUNT; i++) {
- if (config_list[i].type == CONFIG_TYPE_INT) {
- char str[STR_SIZE];
-
- sprintf(str, "%d", config_list[i].value_int);
- loadValueFromConfigFile(config_file, config_list[i].var, val, STR_SIZE, str);
- config_list[i].value_int = atoi(val);
- } else {
- loadValueFromConfigFile(config_file, config_list[i].var, val, STR_SIZE, config_list[i].value_str);
- config_list[i].value_str = strdup(val);
- }
- }
-}
-
-void config_save()
-{
- int i;
-
- if (config_file == NULL) {
- return;
- }
-
- for (i = 0; i < CONFIG_LIST_COUNT; i++) {
- if (config_list[i].type == CONFIG_TYPE_INT) {
- char str[STR_SIZE];
-
- sprintf(str, "%d", config_list[i].value_int);
- setValueInConfigFile(config_file, config_list[i].var, str);
- } else {
- setValueInConfigFile(config_file, config_list[i].var, config_list[i].value_str);
- }
- }
-
- text_file_save(config_file);
-}
-
-int config_get_int_value(int key)
-{
- config_t *tmp;
-
- tmp = find_config(key);
-
- assert(tmp != NULL);
- assert(tmp->type == CONFIG_TYPE_INT);
-
- return tmp->value_int;
-}
-
-char *config_get_str_value(int key)
-{
- config_t *tmp;
-
- tmp = find_config(key);
-
- assert(tmp != NULL);
- assert(tmp->type == CONFIG_TYPE_STR);
-
- return tmp->value_str;
-}
-
-void config_set_int_value(int key, int n)
-{
- config_t *tmp;
-
- tmp = find_config(key);
-
- assert(tmp != NULL);
- assert(tmp->type == CONFIG_TYPE_INT);
-
- tmp->value_int = n;
-}
-
-void config_set_str_value(int key, char *str)
-{
- config_t *tmp;
-
- tmp = find_config(key);
-
- assert(tmp != NULL);
- assert(tmp->type == CONFIG_TYPE_STR);
-
- if (tmp->value_str != NULL) {
- free(tmp->value_str); /* has to be allocated */
- }
-
- tmp->value_str = strdup(str);
-}
-
-int config_quit()
-{
- int i;
-
- config_save();
-
- if (config_file != NULL) {
- text_file_destroy(config_file);
- }
-
- for (i = 0; i < CONFIG_LIST_COUNT; i++) {
- if (config_list[i].type == CONFIG_TYPE_STR && config_list[i].value_str != NULL) {
- free(config_list[i].value_str);
- }
- }
-
- return 0;
-}
diff --git a/src/client/config.h b/src/client/config.h
deleted file mode 100644
index 46e0da5..0000000
--- a/src/client/config.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#define CFG_NAME_RIGHT 1
-#define CFG_NAME_LEFT 2
-#define CFG_COUNT_ROUND 3
-#define CFG_AI 4
-#define CFG_MUSIC 5
-#define CFG_SOUND 6
-#define CFG_ARENA 7
-
-#define CFG_GUN_DUAL_SIMPLE 8
-#define CFG_GUN_SCATTER 9
-#define CFG_GUN_TOMMY 10
-#define CFG_GUN_LASSER 11
-#define CFG_GUN_MINE 12
-#define CFG_GUN_BOMBBALL 13
-
-
-#define CFG_BONUS_SPEED 14
-#define CFG_BONUS_SHOT 15
-#define CFG_BONUS_TELEPORT 16
-#define CFG_BONUS_GHOST 17
-#define CFG_BONUS_4X 18
-#define CFG_BONUS_HIDDEN 19
-
-#define CFG_GAME_TYPE 20
-#define CFG_NET_IP 21
-#define CFG_NET_PORT 22
-
-#define CONFIG_LIST_COUNT 22
-
-extern int config_init();
-extern void config_load();
-extern void config_save();
-extern int config_get_int_value(int key);
-extern char *config_get_str_value(int key);
-extern void config_set_int_value(int key, int n);
-extern void config_set_str_value(int key, char *str);
-extern int config_quit();
-
-#endif /* CONFIG_H */
diff --git a/src/client/configFile.c b/src/client/configFile.c
deleted file mode 100644
index 9d6d65b..0000000
--- a/src/client/configFile.c
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "main.h"
-#include "configFile.h"
-
-int isYesOrNO(char *s)
-{
- if (s[0] == 'Y' || s[0] == 'y') {
- return 1;
- } else {
- return 0;
- }
-}
-
-char *getYesOrNo(int n)
-{
- return (n != 0 ? "YES" : "NO");
-}
-
-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;
-
- strcpy(clone_env, env);
-
- 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_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;
- }
-
- memset(val, 0, len);
- memcpy(val, offset_val_begin + 1, val_len);
-
- return 0;
-}
-
-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];
-
- /*strcpy(clone_env, " ");*/
- strcpy(clone_env, env);
-
- 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_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);
-
- return strdup(clone);
-}
-
-int getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len)
-{
- int i;
- char *line;
-
- for (i = 0; i < textFile->text->count; i++) {
- line = (char *) (textFile->text->list[i]);
-
- if (strncmp(line, env, strlen(env)) == 0) {
- return getValue(line, env, val, len);
- }
- }
-
- return -1;
-}
-
-int setValueInConfigFile(textFile_t * textFile, char *env, char *val)
-{
- int i;
- char *line;
- char *ret;
-
- 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 (ret != NULL) {
- list_del_item(textFile->text, i, free);
- list_ins(textFile->text, i, ret);
-
- return 0;
- }
- }
- }
-
- return -1;
-}
-
-void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len, char *butVal)
-{
- strcpy(val, butVal);
-
- if (getValueInConfigFile(textFile, env, val, len) != 0) {
- char line[STR_SIZE];
-
- sprintf(line, "%s=\"%s\"", env, butVal);
- list_add(textFile->text, strdup(line));
-
- debug("Expanding config file [%s]", line);
- }
-}
diff --git a/src/client/configFile.h b/src/client/configFile.h
deleted file mode 100644
index fc56899..0000000
--- a/src/client/configFile.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef CONFIGFILE_H
-#define CONFIGFILE_H
-
-#include "main.h"
-#include "textFile.h"
-
-extern int isYesOrNO(char *s);
-extern char *getYesOrNo(int n);
-
-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);
-extern int setValueInConfigFile(textFile_t *textFile, char *env, char *val);
-
-extern void loadValueFromConfigFile(textFile_t *textFile, char *env, char *val,
- int len, char *butVal);
-
-#endif /* CONFIGFILE_H */
diff --git a/src/client/control.c b/src/client/control.c
deleted file mode 100644
index bfc2428..0000000
--- a/src/client/control.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <SDL.h>
-#include <limits.h>
-#include <assert.h>
-
-#include "main.h"
-#include "control.h"
-
-control_t *control_new(SDLKey arg_up, SDLKey arg_right, SDLKey arg_left,
- SDLKey arg_down, SDLKey arg_shot, SDLKey arg_switch)
-{
- control_t *tmp;
-
- tmp = malloc(sizeof(control_t));
- memset(tmp, 0, sizeof(control_t));
- tmp->key[CONTROL_UP] = arg_up;
- tmp->key[CONTROL_RIGHT] = arg_right;
- tmp->key[CONTROL_LEFT] = arg_left;
- tmp->key[CONTROL_DOWN] = arg_down;
- tmp->key[CONTROL_SHOT] = arg_shot;
- tmp->key[CONTROL_SWITCH] = arg_switch;
-
- return tmp;
-}
-
-int control_get_key_route(control_t *my_control)
-{
- Uint8 *map;
- SDLKey ret_key;
- int z;
- int i;
-
- assert(my_control != NULL);
-
- ret_key = CONTROL_NONE;
-
- map = SDL_GetKeyState(NULL);
-
- for (i = 0; i < CONTROL_KEY_COUNT_ROUTE; i++) {
- if (map[my_control->key[i]] == SDL_PRESSED) {
- my_control->count[i]++;
- } else {
- my_control->count[i] = 0;
- }
- }
-
- z = INT_MAX;
-
- for (i = 0; i < CONTROL_KEY_COUNT_ROUTE; i++) {
- if (my_control->count[i] > 0 &&
- my_control->count[i] < z &&
- map[my_control->key[i]] == SDL_PRESSED) {
- z = my_control->count[i];
- ret_key = i;
- }
- }
-
- return ret_key;
-}
-
-int control_get_key_action(control_t *my_control)
-{
- Uint8 *map;
-
- assert(my_control != NULL);
-
- map = SDL_GetKeyState(NULL);
-
- if (map[my_control->key[CONTROL_SHOT]] == SDL_PRESSED) {
- return CONTROL_SHOT;
- }
-
- if (map[my_control->key[CONTROL_SWITCH]] == SDL_PRESSED) {
- return CONTROL_SWITCH;
- }
-
- return CONTROL_NONE;
-}
-
-void control_destroy(control_t *my_control)
-{
- assert(my_control != NULL);
-
- free(my_control);
-}
diff --git a/src/client/control.h b/src/client/control.h
deleted file mode 100644
index 6b08189..0000000
--- a/src/client/control.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef CONTROL_H
-#define CONTROL_H
-
-#define CONTROL_NONE -1
-#define CONTROL_UP 0
-#define CONTROL_RIGHT 1
-#define CONTROL_LEFT 2
-#define CONTROL_DOWN 3
-#define CONTROL_SHOT 4
-#define CONTROL_SWITCH 5
-
-#define CONTROL_KEY_COUNT_ROUTE 4
-#define CONTROL_KEY_COUNT 6
-
-typedef struct control_struct {
- SDLKey key[CONTROL_KEY_COUNT];
- int count[CONTROL_KEY_COUNT];
-} control_t;
-
-extern control_t *control_new(SDLKey arg_up, SDLKey arg_right,
- SDLKey arg_left, SDLKey arg_down,
- SDLKey arg_shot, SDLKey arg_switch);
-extern int control_get_key_route(control_t *my_control);
-extern int control_get_key_action(control_t *my_control);
-extern void control_destroy(control_t *my_control);
-
-#endif /* CONTROL_H */
diff --git a/src/client/font.c b/src/client/font.c
deleted file mode 100644
index d052cbb..0000000
--- a/src/client/font.c
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "main.h"
-#include "interface.h"
-#include "font.h"
-#include "image.h"
-#include "fontConfig.h"
-
-static TTF_Font *g_font;
-static int fontSize;
-
-static bool_t isFontInit = FALSE;
-
-bool_t font_is_inicialized()
-{
- return isFontInit;
-}
-
-void font_init()
-{
- char *arg[] = {":lang=he:outline=true:style=Book", "family", "style", "weight", "file", NULL};
- char *font_file;
- font_config_t *font_list;
- int res;
-
- assert(interface_is_inicialized() == TRUE);
-
- res = fontconfig_init();
-
- if (res != 0) {
- return;
- }
-
- font_list = fontconfig_find(arg);
-/*
- int i;
- for(i = 0 ; font_list[i].path != NULL ; i++ )
- {
- printf("path[%d]=%s\nflag[%d]=%s\n\n", i, font_list[i].path, i, font_list[i].flag);
- }
-*/
- if (font_list == NULL) {
- error("Unable to locate a font");
- return;
- }
-
- font_file = strdup(font_list[0].path);
- fontSize = FONT_SIZE;
-
- fontconfig_del_list(font_list);
- fontconfig_quit();
-
- if (TTF_Init() == -1) {
- free(font_file);
- error("SDL: %s", SDL_GetError());
- return;
- }
-
- accessExistFile(font_file);
-
- g_font = TTF_OpenFont(font_file, fontSize);
- TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL);
-
- debug("Loading font [%s]", font_file);
-
- free(font_file);
- isFontInit = TRUE;
-}
-
-/*
- * Shows text *string on coordinates [x,y] with RGB color
- */
-void font_draw(char *string, int x, int y, int r, int g, int b)
-{
- SDL_Surface *text;
- image_t *image;
- SDL_Color font_color = {r, g, b, SDL_ALPHA_OPAQUE};
-
- assert( string != NULL );
-
- text = TTF_RenderUTF8_Blended(g_font, string, font_color);
-
- /* because if string=="" TTF_RenderUTF8_Blended returns NULL */
- if (text != NULL) {
- image = image_new(text);
- image_draw(image, x, y, 0, 0, image->w, image->h);
- image_destroy(image);
- }
-}
-
-void font_drawMaxSize(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;
- image_t *i;
- SDL_Color font_color = {r, g, b, SDL_ALPHA_OPAQUE};
- int my_w, my_h;
-
- assert(s != NULL);
-
- text = TTF_RenderUTF8_Blended(g_font, s, font_color);
-
- my_w = text->w;
-
- if (my_w > w) {
- my_w = w;
- }
-
- my_h = text->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;
-
- dst_rect.x = x;
- dst_rect.y = y;
-
- i = image_new(text);
-
- /* possibly broken */
- image_draw(i, x, y, 0, 0, my_w, my_h);
- image_destroy(i);
-}
-
-/*
- * Returns size of the font
- */
-int font_get_size()
-{
- return fontSize;
-}
-
-void font_text_size(char *s, int *w, int *h)
-{
- assert(s != NULL);
- assert(w != NULL);
- assert(h != NULL);
-
- TTF_SizeUTF8(g_font, s, w, h);
-}
-
-/*
- * Frees font from memory
- */
-void font_quit()
-{
- TTF_CloseFont(g_font);
- TTF_Quit();
-
- debug("Unloading font");
-
- isFontInit = FALSE;
-}
diff --git a/src/client/font.h b/src/client/font.h
deleted file mode 100644
index 8ee2cf0..0000000
--- a/src/client/font.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef FONT_H
-#define FONT_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_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
-
-extern bool_t font_is_inicialized();
-extern void font_init();
-extern void font_draw(char *s, int x, int y, int r, int g, int b);
-extern void font_drawMaxSize(char *s, int x, int y, int w, int h,
- int r, int g, int b);
-extern int font_get_size();
-extern void font_text_size(char *s, int *w, int *h);
-extern void font_quit();
-
-#endif /* FONT_H */
diff --git a/src/client/fontConfig.c b/src/client/fontConfig.c
deleted file mode 100644
index b0e0741..0000000
--- a/src/client/fontConfig.c
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fontconfig/fontconfig.h>
-
-#include "main.h"
-#include "fontConfig.h"
-
-int fontconfig_init()
-{
- int res;
-
- res = FcInit();
-
- if (res == 0) {
- error("Unable to init fontconfig library");
- return 1;
- }
-
- return 0;
-}
-
-font_config_t *fontconfig_find(char **arg)
-{
- FcObjectSet *os;
- FcFontSet *fs;
- FcPattern *pat;
- font_config_t *ret;
- int i;
-
- os = NULL;
- ret = NULL;
-
- for (i = 0; arg[i] != NULL; i++) {
- if (i == 0) {
- pat = FcNameParse((FcChar8 *) arg[i]);
- }
-
- if (os == NULL) {
- os = FcObjectSetCreate();
- }
-
- FcObjectSetAdd(os, arg[i]);
- }
-
- if (os == NULL) {
- os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, (char *) 0);
- }
-
- fs = FcFontList(0, pat, os);
- FcObjectSetDestroy(os);
-
- if (pat != NULL) {
- FcPatternDestroy(pat);
- }
-
- if (fs != NULL) {
- int j;
-
- ret = malloc((fs->nfont + 1) * sizeof(font_config_t));
-
- for (j = 0; j < fs->nfont; j++) {
- FcChar8 *font;
- FcChar8 *file;
-
- font = FcNameUnparse(fs->fonts[j]);
-
- if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
- ret[j].path = strdup((char *) file);
- }
-
- ret[j].flag = strdup((char *) font);
- free(font);
- }
-
- ret[fs->nfont].path = NULL;
- ret[fs->nfont].flag = NULL;
-
- FcFontSetDestroy(fs);
- }
-
- return ret;
-}
-
-void fontconfig_del_list(font_config_t *list)
-{
- int i;
-
- for (i = 0; list[i].path != NULL; i++) {
- free(list[i].path);
- free(list[i].flag);
- }
-
- free(list);
-}
-
-int fontconfig_quit()
-{
- FcFini();
- return 0;
-}
diff --git a/src/client/fontConfig.h b/src/client/fontConfig.h
deleted file mode 100644
index 09e75a3..0000000
--- a/src/client/fontConfig.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef FONT_CONFIG_H
-#define FONT_CONFIG_H
-
-typedef struct font_config_struct {
- char *path;
- char *flag;
-} font_config_t;
-
-extern int fontconfig_init();
-extern font_config_t *fontconfig_find(char **arg);
-extern void fontconfig_del_list(font_config_t *list);
-extern int fontconfig_quit();
-
-#endif /* FONT_CONFIG_H */
diff --git a/src/client/game.c b/src/client/game.c
deleted file mode 100644
index 2481cee..0000000
--- a/src/client/game.c
+++ /dev/null
@@ -1,127 +0,0 @@
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <assert.h>
-#include <sys/stat.h>
-
-#include "main.h"
-#include "tux.h"
-#include "homeDirector.h"
-#include "item.h"
-#include "shot.h"
-#include "arenaFile.h"
-#include "config.h"
-
-#include "image.h"
-#include "layer.h"
-#include "interface.h"
-#include "screen.h"
-#include "font.h"
-#include "settingKeys.h"
-#include "panel.h"
-#include "radar.h"
-#include "mouse_buffer.h"
-
-#ifndef NO_SOUND
-#include "audio.h"
-#include "sound.h"
-#include "music.h"
-#endif
-
-#include "world.h"
-#include "mainMenu.h"
-#include "analyze.h"
-#include "setting.h"
-#include "settingKeys.h"
-#include "gameType.h"
-#include "downArena.h"
-#include "choiceArena.h"
-#include "table.h"
-#include "credits.h"
-#include "browser.h"
-
-static void initGame()
-{
- home_director_create();
-
- mouse_buffer_init();
- interface_init();
- font_init();
- layer_init();
- image_init();
-#ifndef NO_SOUND
- audio_init();
- sound_init();
- music_init();
-#endif /* NO_SOUND */
- screen_init();
- arena_file_init();
- tux_init();
- item_init();
- shot_init();
- panel_init();
- world_init();
- config_init();
-
- main_menu_init();
- analyze_init();
- choice_arena_init();
- setting_init();
- setting_key_int();
- game_type_init();
- down_arena_init();
- scredits_init();
- table_init();
- browser_init();
-}
-
-void game_quit()
-{
- mouse_buffer_quit();
- interface_quit();
-
- main_menu_quit();
- analyze_quit();
- setting_quit();
- setting_key_quit();
- game_type_quit();
- down_arena_quit();
- choice_arena_quit();
- scredits_quit();
- table_quit();
- browser_quit();
- config_quit();
-
- layer_quit();
- font_quit();
- screen_quit();
- arena_file_quit();
- item_quiy();
- tux_quit();
- shot_quit();
- panel_quit();
- world_quit();
- image_quit();
-#ifndef NO_SOUND
- sound_quit();
- music_quit();
- audio_quit();
-#endif /* NO_SOUND */
-
- debug("Shutting down the game");
-
- exit(0);
-}
-
-void game_start()
-{
- initGame();
-
- screen_start("mainMenu");
-
- interface_event();
- game_quit();
-}
diff --git a/src/client/game.h b/src/client/game.h
deleted file mode 100644
index e5f2d86..0000000
--- a/src/client/game.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef GAME_H
-#define GAME_H
-
-extern void game_quit();
-extern void game_start();
-
-#endif /* GAME_H */
diff --git a/src/client/hotKey.c b/src/client/hotKey.c
deleted file mode 100644
index 5471101..0000000
--- a/src/client/hotKey.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
-
-#include "interface.h"
-#include "hotKey.h"
-
-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) ())
-{
- hotKey_t *new;
-
- new = malloc(sizeof(hotKey_t));
- new->key = key;
- new->active = TRUE;
- new->handler = handler;
-
- return new;
-}
-
-static void destroyHotKey(hotKey_t *hotkey)
-{
- free(hotkey);
-}
-
-static hotKey_t *findHotkey(SDLKey key)
-{
- int i;
-
- for (i = 0; i < listHotKey->count; i++) {
- hotKey_t *this;
-
- this = (hotKey_t *) listHotKey->list[i];
-
- if (this->key == key) {
- return this;
- }
- }
-
- return NULL;
-}
-
-void hot_key_init()
-{
- listHotKey = list_new();
- lastActive = timer_get_current_time();
-}
-
-void hot_key_register(SDLKey key, void (*handler) ())
-{
- hotKey_t *hotkey;
-/*
- if (findHotkey(key) != NULL) {
- assert(!"Conflict with register key");
- }
-*/
- hotkey = newHotKey(key, handler);
- list_ins(listHotKey, 0, hotkey);
-}
-
-void hot_key_unregister(SDLKey key)
-{
- hotKey_t *hotkey;
- int my_index;
-
- hotkey = findHotkey(key);
-
- if (hotkey == NULL) {
- fatal("Unregistering not registered hotkey");
- }
-
- my_index = list_search(listHotKey, hotkey);
- assert(my_index != -1);
- list_del_item(listHotKey, my_index, destroyHotKey);
-}
-
-void hot_key_enable(SDLKey key)
-{
- hotKey_t *hotkey;
-
- hotkey = findHotkey(key);
-
- if (hotkey == NULL) {
- fatal("Enabling not registered hotkey");
- }
-
- lastActive = timer_get_current_time();
- hotkey->active = TRUE;
-}
-
-void hot_key_disable(SDLKey key)
-{
- hotKey_t *hotkey;
-
- hotkey = findHotkey(key);
-
- if (hotkey == NULL) {
- fatal("Disabling not registered hotkey");
- }
-
- lastActive = timer_get_current_time();
- hotkey->active = FALSE;
-}
-
-void hot_key_event()
-{
- my_time_t currentTime;
- Uint8 *mapa;
- int i;
-
- currentTime = timer_get_current_time();
-
- if (currentTime - lastActive < HOTKEY_ACTIVE_INTERVAL) {
- return;
- }
-
- mapa = SDL_GetKeyState(NULL);
-
- for (i = 0; i < listHotKey->count; i++) {
- hotKey_t *this;
-
- this = (hotKey_t *) listHotKey->list[i];
-
- if (mapa[this->key] == SDL_PRESSED && this->active == TRUE) {
- lastActive = timer_get_current_time();
- /*printf("hotKey = %d\n", this->key);*/
- this->handler();
-
- return;
- }
- }
-}
-
-void hot_key_quit()
-{
- list_destroy_item(listHotKey, destroyHotKey);
-}
diff --git a/src/client/hotKey.h b/src/client/hotKey.h
deleted file mode 100644
index 51b027f..0000000
--- a/src/client/hotKey.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HOTKEY_H
-#define HOTKEY_H
-
-#define HOTKEY_ACTIVE_INTERVAL 500
-
-extern void hot_key_init();
-extern void hot_key_register(SDLKey key, void (*handler) ());
-extern void hot_key_unregister(SDLKey key);
-extern void hot_key_enable(SDLKey key);
-extern void hot_key_disable(SDLKey key);
-extern void hot_key_event();
-extern void hot_key_quit();
-
-#endif /* HOTKEY_H */
diff --git a/src/client/image.c b/src/client/image.c
deleted file mode 100644
index cdd7c9b..0000000
--- a/src/client/image.c
+++ /dev/null
@@ -1,323 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "storage.h"
-
-#include "interface.h"
-#include "image.h"
-
-static list_t *listStorage;
-
-static bool_t isImageDataInit = FALSE;
-
-bool_t image_is_inicialized()
-{
- return isImageDataInit;
-}
-
-/*
- * Initialization of global list of images
- */
-void image_init()
-{
- assert(interface_is_inicialized() == TRUE);
-
- debug("Initializing image database");
-
- listStorage = storage_new();
- isImageDataInit = TRUE;
-}
-
-static SDL_Surface *loadImage(const char *filename, int alpha)
-{
- SDL_Surface *tmp;
- SDL_Surface *ret;
-
- char str[STR_PATH_SIZE];
-
- if (isFillPath(filename)) {
- strcpy(str, filename);
- } else {
- sprintf(str, PATH_IMAGE "%s", filename);
- }
-
- accessExistFile(str);
-
- if ((tmp = IMG_Load(str)) == NULL) {
- error("SDL: %s", SDL_GetError());
- return NULL;
- }
-
- if ((ret = (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) == NULL) {
- error("SDL: %s", SDL_GetError());
- SDL_FreeSurface(tmp);
- return NULL;
- }
-
- SDL_FreeSurface(tmp);
- return ret;
-}
-
-
-image_t *image_new_sdl(SDL_Surface *surface)
-{
- image_t *new;
-
- assert(surface != NULL);
-
- new = malloc(sizeof(image_t));
- new->image = surface;
- new->w = surface->w;
- new->h = surface->h;
-
- return new;
-}
-
-#ifdef SUPPORT_OPENGL
-/*
- * returns closest bigger power of 2 to i
- */
-unsigned int closestpoweroftwo(unsigned int i)
-{
- int p;
- p=0;
- while (i) {
- i = i >> 1;
- p++;
- }
- return 1 << (p - 0);
-}
-
-/* convert from SDL_Surface to image_t
- * WARNING: image_new is indestructive to surface, caller is responsible for freeing surface
- * surface is not needed for image_t after execution of image_new
- */
-
-image_t *image_new_opengl(SDL_Surface *surface)
-{
- image_t *new;
- Uint32 rmask, gmask, bmask, amask;
- SDL_Surface *sdl_rgba_surface;
- unsigned int bpp;
-
- /* it is unoptimal to blit to buffer surface before actual loading to opengl texture but it is safer and simpler to implement */
- /* it is unoptimal to always use RGBA texture */
-
- /* we set properties of our buffer sdl_rgba_surface */
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
- bpp = 32; /* bits per pixel */
-
- assert(surface != NULL);
-
- new = malloc(sizeof(image_t));
- new->w = surface->w;
- new->h = surface->h;
-
- /* because some older hw is really slow when using textures with width and height which is not a power of two */
- new->tw = closestpoweroftwo(new->w);
- new->th = closestpoweroftwo(new->h);
-
- sdl_rgba_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, new->tw, new->th, bpp, rmask, gmask, bmask, amask);
-
- SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE); /* we unset SDL_SRCALPHA to preserve alpha channel of original image */
- SDL_BlitSurface(surface, 0, sdl_rgba_surface, 0);
-
- SDL_LockSurface(sdl_rgba_surface); /* we ensure that we can read pixels from sdl_rgba_surface */
-
- GLuint tid;
- glGenTextures(1, &tid); /* we ask for free texture id */
- glBindTexture(GL_TEXTURE_2D, tid);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* scale linearly when image bigger than texture */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /* scale linearly when image smalled than texture */
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, new->tw, new->th, 0, GL_RGBA, GL_UNSIGNED_BYTE, sdl_rgba_surface->pixels);
- SDL_UnlockSurface(sdl_rgba_surface);
- SDL_FreeSurface(sdl_rgba_surface);
-
- new->tex_id = tid;
-
- SDL_FreeSurface(surface);
-
- return new;
-}
-#endif /* SUPPORT_OPENGL */
-
-image_t *image_new(SDL_Surface *surface)
-{
-#ifdef SUPPORT_OPENGL
- if (interface_is_use_open_gl()) {
- return image_new_opengl(surface);
- } else {
- return image_new_sdl(surface);
- }
-#else /* SUPPORT_OPENGL */
- return image_new_sdl(surface);
-#endif /* SUPPORT_OPENGL */
-}
-
-void image_destroy(image_t *p)
-{
- assert(p != NULL);
-
-#ifndef SUPPORT_OPENGL
- SDL_FreeSurface((SDL_Surface *) p->image);
-#else /* SUPPORT_OPENGL */
- if (interface_is_use_open_gl()) {
- glDeleteTextures(1, &p->tex_id);
- } else {
- SDL_FreeSurface((SDL_Surface *) p->image);
- }
-#endif /* SUPPORT_OPENGL */
-
- free(p);
-}
-
-/*
- * Adds an image to the global image list
- * *file - name of the image file
- * *name - name of the image (is used for searching in the list)
- * alpha - [0] without alpha channel; [1] with alpha channel
- */
-image_t *image_add(char *file, int alpha, char *name, char *group)
-{
- SDL_Surface *surface;
- image_t *new;
-
- assert(file != NULL);
- assert(name != NULL);
- assert(group != NULL);
-
- surface = loadImage(file, alpha);
- new = image_new(surface);
-
- storage_add(listStorage, group, name, new);
-
- debug("Loading image [%s]", file);
-
- return new;
-}
-
-/*
- * Returns pointer to image with name *name in the global image list
- */
-image_t *image_get(char *group, char *name)
-{
- assert(group != NULL);
- assert(name != NULL);
-
- return storage_get(listStorage, group, name);
-}
-
-void image_del(char *group, char *name)
-{
- assert(group != NULL);
- assert(name != NULL);
-
- storage_del(listStorage, group, name, image_destroy);
-}
-
-void image_del_all_image_in_group(char *group)
-{
- assert(group != NULL);
-
- storage_del_all(listStorage, group, image_destroy);
-}
-
-void image_draw_sdl(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;
-
- if (screen == NULL) {
- screen = interface_get_screen();
- }
-
- dst_rect.x = x;
- dst_rect.y = y;
-
- 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);
-}
-
-#ifdef SUPPORT_OPENGL
-/*
- * Draws image on screen at [x,y], with width w and height h, top-left corner on image is at [px,py]
- */
-void image_draw_opengl(image_t *image, int x,int y, int px, int py, int w, int h)
-{
- /* x - coordinate of left border; xx - coordinate of right border
- * y - coordinate of top border; yy - coordinate of bottom border
- * t - texture space; d - screen space
- */
- float t_x, t_y, t_xx, t_yy;
- float d_x, d_y, d_xx, d_yy;
-
- /* screen space */
- d_x = x;
- d_y = y;
- d_xx = x+w;
- d_yy = y+h;
-
- /* texture space (remember that texture space is from 0.0 to 1.0) */
- t_x = px / (float) image->tw;
- t_y = py / (float) image->th;
- t_xx = (px+w) / (float) image->tw;
- t_yy = (py+h) / (float) image->th;
-
- glBindTexture(GL_TEXTURE_2D, image->tex_id);
-
- /*
- * 2--4
- * |\ |
- * | \|
- * 1--3
- */
- glBegin(GL_TRIANGLE_STRIP);
- /* 1 */
- glTexCoord2f(t_x,t_yy);
- glVertex2f(d_x, d_yy);
- /* 2 */
- glTexCoord2f(t_x, t_y);
- glVertex2f(d_x, d_y);
- /* 3 */
- glTexCoord2f(t_xx, t_yy);
- glVertex2f(d_xx, d_yy);
- /* 4 */
- glTexCoord2f(t_xx,t_y);
- glVertex2f(d_xx, d_y);
- glEnd();
-}
-#endif /* SUPPORT_OPENGL */
-
-void image_draw(image_t *image, int x,int y, int px, int py, int w, int h)
-{
-#ifdef SUPPORT_OPENGL
- if (interface_is_use_open_gl()) {
- image_draw_opengl(image, x, y, px, py, w, h);
- } else {
- image_draw_sdl(image, x, y, px, py, w, h);
- }
-#else /* SUPPORT_OPENGL */
- image_draw_sdl(image, x, y, px, py, w, h);
-#endif /* SUPPORT_OPENGL */
-}
-
-/*
- * Frees global image list
- */
-void image_quit()
-{
- debug("Shutting down image database");
-
- storage_destroy(listStorage, image_destroy);
- isImageDataInit = FALSE;
-}
diff --git a/src/client/image.h b/src/client/image.h
deleted file mode 100644
index 9f225c6..0000000
--- a/src/client/image.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef IMAGE_H
-#define IMAGE_H
-
-#include "main.h"
-#include "interface.h"
-
-#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"
-
-#ifdef SUPPORT_OPENGL
-#include <SDL_opengl.h>
-#endif
-
-/*
-typedef struct image_struct {
- char *name;
- char *group;
- SDL_Surface *image;
-} image_data_t;
-*/
-
-#ifndef SUPPORT_OPENGL
-typedef struct image_struct {
- int w;
- int h;
- SDL_Surface *image;
-} image_t;
-#else /* SUPPORT_OPENGL */
-typedef struct image_struct {
- int w; /* width of actual picture */
- int h; /* height of actual picture */
- SDL_Surface *image;
- GLuint tw; /* width of allocated texture */
- GLuint th; /* height of allocated texture */
- GLuint tex_id; /* texture id */
-} image_t;
-#endif /* SUPPORT_OPENGL */
-
-extern bool_t image_is_inicialized();
-extern void image_init();
-extern image_t *image_new(SDL_Surface *surface);
-extern void image_destroy(image_t * p);
-extern image_t *image_add(char *file, int alpha, char *name, char *group);
-extern image_t *image_get(char *group, char *name);
-extern void image_del(char *group, char *name);
-extern void image_del_all_image_in_group(char *group);
-extern void image_draw(image_t * p, int x, int y, int px, int py, int w, int h);
-extern void image_quit();
-
-#endif /* IMAGE_H */
diff --git a/src/client/interface.c b/src/client/interface.c
deleted file mode 100644
index 62d7f96..0000000
--- a/src/client/interface.c
+++ /dev/null
@@ -1,358 +0,0 @@
-#include <stdlib.h>
-
-#include "main.h"
-#include "myTimer.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "keyboardBuffer.h"
-#include "hotKey.h"
-#include "mouse_buffer.h"
-
-static SDL_Surface *screen; /* window surface */
-/*static SDL_Surface *my_surface;*/
-static SDL_TimerID timer; /* timer */
-static Uint32 g_win_flags; /* window flags */
-
-static bool_t isInterfaceInit = FALSE;
-static bool_t keyboardBufferEnabled = FALSE; /* flag that controls organising keys into the buffer */
-static bool_t use_open_gl;
-
-bool_t interface_is_use_open_gl()
-{
- return use_open_gl;
-}
-
-bool_t interface_is_inicialized()
-{
- return isInterfaceInit;
-}
-
-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_PushEvent(&event);
-
- return interval;
-}
-
-void interface_enable_keyboard_buffer()
-{
- keyboardBufferEnabled = TRUE;
-}
-
-void interface_disable_keyboard_buffer()
-{
- keyboardBufferEnabled = FALSE;
-}
-
-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) {
- error("Unable to switch to the fullscreen mode");
-
- SDL_FreeSurface(screen);
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP, g_win_flags);
-
- if (screen == NULL) {
- error("Unable to switch to the window mode: %s", SDL_GetError());
- return;
- }
- }
-}
-
-#ifdef SUPPORT_OPENGL
-/**
- * Sets video mode and sets up OpenGL for this change
- */
-SDL_Surface *SetVideoMode(int width, int height, int bpp, Uint32 flags)
-{
- SDL_Surface *rval = 0;
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- rval = SDL_SetVideoMode(width, height, bpp, flags);
-
- glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- glClearDepth(1.0);
- glDisable(GL_DEPTH_TEST);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-#ifdef SDL_GL_SWAP_CONTROL
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
-#endif /* SDL_GL_SWAP_CONTROL */
-
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glEnable(GL_TEXTURE_2D);
-
- return rval;
-}
-#endif /* SUPPORT_OPENGL */
-
-int interface_init()
-{
- debug("Initializing SDL");
-
- /* initialization of SDL */
- if (SDL_Init(SDL_SUBSYSTEMS) == -1) {
- fatal("Unable to initialize SDL: %s", SDL_GetError());
- SDL_Quit();
- exit(0);
- return -1;
- }
-
-#ifndef SUPPORT_OPENGL
- use_open_gl = FALSE;
- g_win_flags = SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
-
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
-#else /* SUPPORT_OPENGL */
- use_open_gl = !isParamFlag("--disable-opengl");
-
- if (interface_is_use_open_gl()) {
- g_win_flags = SDL_OPENGL;
- screen = SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
-
- if (screen == NULL) {
- use_open_gl = FALSE;
- g_win_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
-
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
- }
- } else {
- g_win_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
- }
-#endif /* SUPPORT_OPENGL */
-
- if (screen == NULL) {
- error("Unable to create interface: %s", SDL_GetError());
- SDL_Quit();
- return -1;
- }
- /**
- * enable unicode by default for keyboard support - it is a bit more
- * consuming than the nonsdl but can draw more characters
- */
- SDL_EnableUNICODE(1);
- SDL_WM_SetCaption(WINDOW_TITLE, NULL);
-
- /* keyboard repeating */
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
- timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
-
- keyboard_buffer_init(KEYBOARD_BUFFER_SIZE);
-
- hot_key_init();
- hot_key_register(SDLK_F1, hotkey_screen);
-
- srand((unsigned) time(NULL));
- isInterfaceInit = TRUE;
-
- return 0;
-}
-
-SDL_Surface *interface_get_screen()
-{
- /*return my_surface;*/
- return screen;
-}
-
-void interface_refresh()
-{
-#ifndef SUPPORT_OPENGL
- SDL_Flip(screen);
-#else /* SUPPORT_OPENGL */
- if (interface_is_use_open_gl()) {
- SDL_GL_SwapBuffers();
- } else {
- SDL_Flip(screen);
- }
-#endif /* SUPPORT_OPENGL */
-}
-
-void interface_get_mouse_position(int *x, int *y)
-{
- SDL_GetMouseState(x, y);
-}
-
-int interface_is_mouse_clicket()
-{
- return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT);
-}
-
-int interface_is_press_any_key()
-{
- Uint8 *mapa;
- int i;
-
- mapa = SDL_GetKeyState(NULL);
-
- for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) {
- if (mapa[i] == SDL_PRESSED) {
- return 1;
- }
- }
-
- return 0;
-}
-
-void printPressAnyKey()
-{
- Uint8 *mapa;
- int i;
-
- mapa = SDL_GetKeyState(NULL);
-
- for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) {
- if (mapa[i] == SDL_PRESSED) {
- debug("Pressed key [SDL: %d]", i);
- }
- }
-
-}
-
-int hack_slow()
-{
- static time_t lastTime = 0;
- static bool_t isSlowHack = FALSE;
- time_t currentTime;
-
- currentTime = timer_get_current_time();
-
- if (lastTime == 0) {
- lastTime = currentTime;
- return 0;
- }
-
- /*printf("DEBUG: time interval %d\n", currentTime - lastTime);*/
-
- if (isSlowHack == FALSE && currentTime - lastTime >= 100) {
- /*printf("start slow hack (%d)\n", currentTime - lastTime);*/
- isSlowHack = TRUE;
- lastTime = timer_get_current_time();
- return 1;
- }
-
- if (isSlowHack == TRUE && currentTime - lastTime >= 50) {
- /*printf("stop slow hack (%d)\n", currentTime - lastTime);*/
- isSlowHack = FALSE;
- lastTime = timer_get_current_time();
- return 0;
- }
-
- if (isSlowHack == TRUE) {
- /*printf("hack time interval %d\n", currentTime - lastTime);*/
- }
-
- lastTime = timer_get_current_time();
-
- return isSlowHack;
-}
-
-int eventAction()
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event)) {
- switch (event.type) {
- case SDL_MOUSEBUTTONDOWN:
- mouse_buffer_event(&event.button);
- break;
-
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- default:
- /* it is not necessary to always use the buffer */
- if (keyboardBufferEnabled == TRUE) {
- keyboard_buffer_push(event.key.keysym);
- }
- break;
- }
- break;
-
- case SDL_USEREVENT:
- switch (event.user.code) {
- case USR_EVT_TIMER:
- if (hack_slow()) {
- break;
- }
-
- screen_draw();
- screen_event();
- hot_key_event();
- screen_switch();
- mouse_buffer_clean();
- break;
-
- default:
- break;
- }
- break;
-
- /* change the window size */
- case SDL_VIDEORESIZE:
- screen = SDL_SetVideoMode(event.resize.w, event.resize.h,
- WIN_BPP, g_win_flags);
-
- if (screen == NULL) {
- error("Unable to change resolution of the window: %s", SDL_GetError());
- return 0;
- }
- break;
-
- /* termination request */
- case SDL_QUIT:
- return -1;
- break;
-
- default:
- break;
- }
- }
-
- return 0;
-}
-
-void interface_event()
-{
- while (1) {
- if (eventAction() == -1) {
- return;
- }
- }
-}
-
-void interface_quit()
-{
- debug("Shutting down SDL");
-
- hot_key_quit();
- keyboard_buffer_quit();
-
- SDL_Quit();
-
- isInterfaceInit = FALSE;
-}
diff --git a/src/client/interface.h b/src/client/interface.h
deleted file mode 100644
index 2fd23e9..0000000
--- a/src/client/interface.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef INTERFACE_H
-#define INTERFACE_H
-
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-#include <SDL.h>
-#include <SDL_image.h>
-#include <SDL_thread.h>
-
-#include "main.h"
-
-#ifdef SUPPORT_OPENGL
-#include <SDL_opengl.h>
-#endif
-
-/*
-#include <SDL_net.h>
-*/
-
-#define SDL_SUBSYSTEMS SDL_INIT_VIDEO|SDL_INIT_TIMER
-
-/* the window title */
-#define WINDOW_TITLE "Tuxánci " TUXANCI_VERSION
-#define WIN_BPP 0
-#define USR_EVT_TIMER 0
-
-/* timing of the timer [in ms] */
-#define INTERVAL 50
-
-/* size of the keyboard buffer (in characters) */
-#define KEYBOARD_BUFFER_SIZE 256
-
-extern bool_t interface_is_inicialized();
-extern bool_t interface_is_use_open_gl();
-extern void interface_enable_keyboard_buffer();
-extern void interface_disable_keyboard_buffer();
-extern int interface_init();
-extern SDL_Surface *interface_get_screen();
-extern void interface_get_mouse_position(int *x, int *y);
-extern int interface_is_mouse_clicket();
-extern int interface_is_press_any_key();
-extern void interface_refresh();
-extern void interface_event();
-extern void interface_quit();
-
-#endif /* INTERFACE_H */
diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c
deleted file mode 100644
index 129389f..0000000
--- a/src/client/keyboardBuffer.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <SDL.h>
-
-#include "keyboardBuffer.h"
-
-static keyboardBuffer_t *keyboardBuffer = NULL;
-
-static SDL_keysym emptyKey;
-
-/*
- * Key buffer initialization
- * the parameter sets the number of keys
- */
-void keyboard_buffer_init(int size)
-{
- assert(size > 0);
- assert(keyboardBuffer == NULL);
-
- 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->begin = 0;
- keyboardBuffer->end = 0;
- keyboardBuffer->count = 0;
- keyboardBuffer->size = size;
-
- emptyKey.sym = SDLK_UNKNOWN;
-}
-
-/*
- * Empty the buffer
- */
-void keyboard_buffer_clear()
-{
- assert(keyboardBuffer != NULL);
-
- 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 keyboard_buffer_push(SDL_keysym key)
-{
- assert(keyboardBuffer != NULL);
-
- if (keyboardBuffer->count >= keyboardBuffer->size) {
- error("Keyboard buffer overrun - dropping the key [%02x]", key.sym);
- return FALSE;
- }
-
- keyboardBuffer->buff[keyboardBuffer->end] = key;
-
- keyboardBuffer->end++;
- if (keyboardBuffer->end >= keyboardBuffer->size) {
- keyboardBuffer->end = 0;
- }
-
- keyboardBuffer->count++;
-
- 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 keyboard_buffer_pop()
-{
- assert(keyboardBuffer != NULL);
-
- if (keyboardBuffer->count <= 0) {
- error("Keyboard buffer underrun");
- return emptyKey;
- }
-
- SDL_keysym key = keyboardBuffer->buff[keyboardBuffer->begin];
- keyboardBuffer->buff[keyboardBuffer->begin] = emptyKey;
-
- keyboardBuffer->begin++;
-
- if (keyboardBuffer->begin >= keyboardBuffer->size) {
- keyboardBuffer->begin = 0;
- }
-
- keyboardBuffer->count--;
-
- return key;
-}
-
-/*
- * The buffer size
- */
-int keyboard_buffer_get_size()
-{
- assert(keyboardBuffer != NULL);
- return keyboardBuffer->size;
-}
-
-/*
- * Number of keys in the buffer
- */
-int keyboard_buffer_get_count()
-{
- assert(keyboardBuffer != NULL);
- return keyboardBuffer->count;
-}
-
-
-bool_t keyboard_buffer_is_any_key()
-{
- return keyboard_buffer_get_count() > 0 ? TRUE : FALSE;
-}
-
-/*
- * Frees the buffer. If it is not empty, information
- * about filling is prined to stderr first.
- */
-void keyboard_buffer_quit()
-{
- assert(keyboardBuffer != NULL);
-
- if (keyboardBuffer->count > 0) {
- warning("Shutting down non-empty keyboard buffer");
- }
-
- free(keyboardBuffer->buff);
- free(keyboardBuffer);
- keyboardBuffer = NULL;
-}
diff --git a/src/client/keyboardBuffer.h b/src/client/keyboardBuffer.h
deleted file mode 100644
index e3596ef..0000000
--- a/src/client/keyboardBuffer.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef KEYBOARD_BUFFER_H
-#define KEYBOARD_BUFFER_H
-
-#include <SDL.h>
-#include "main.h"
-
-typedef struct {
- SDL_keysym *buff; /* buffer of keys (code according to the SDLKey enum) */
- int size; /* up-to-date size of allocated buffer (size == number of saveable keys) */
- int count; /* up-to-date number of keys saved in the buffer */
- int begin; /* pointer to the beginning of the buffer (i.e. where to add new keys to) */
- int end; /* pointer to the end of the buffer (i.e. where to remove old keys from) */
-} keyboardBuffer_t;
-
-extern void keyboard_buffer_init(int size);
-extern void keyboard_buffer_clear();
-extern bool_t keyboard_buffer_push(SDL_keysym key);
-extern SDL_keysym keyboard_buffer_pop();
-extern int keyboard_buffer_get_size();
-extern int keyboard_buffer_get_count();
-extern bool_t keyboard_buffer_is_any_key();
-extern void keyboard_buffer_quit();
-
-#endif /* KEYBOARD_BUFFER_H */
diff --git a/src/client/layer.c b/src/client/layer.c
deleted file mode 100644
index 22c037d..0000000
--- a/src/client/layer.c
+++ /dev/null
@@ -1,200 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-
-#include "interface.h"
-#include "layer.h"
-#include "image.h"
-
-#include "world.h"
-
-static list_t *listLayer;
-
-static bool_t isLayerInit = FALSE;
-
-bool_t layer_is_inicialized()
-{
- return isLayerInit;
-}
-
-/*
- * Initialize global list of the layers
- */
-void layer_init()
-{
- listLayer = list_new();
- isLayerInit = TRUE;
-}
-
-/*
- * Add image to queue for rendering
- * *img - image to be rendered
- * x,y - coordinates where to draw the image
- * w,h - width and height of rendered part of image
- * px,py - coordinates of upper left corner of rendered part of image
- * layer - on which layer to draw
- * [0] - under Tuxanek; [1] same as Tuxanek; [2] over Tuxanek
- */
-void addLayer(image_t *img, int x, int y, int px, int py, int w, int h, int player)
-{
- layer_t *new;
- layer_t *actual;
- int actual_value;
- int new_value;
- int i;
-
- 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;
-
- new_value = player * WINDOW_SIZE_Y + y + h;
-
- /* here we are sure, that we want to insert it somewhere else than the begining */
- for (i = 0; i < listLayer->count; i++) {
- actual = list_get(listLayer, i);
-
- actual_value = actual->layer * WINDOW_SIZE_Y + actual->y + actual->h;
-
- if (actual_value > new_value) {
- list_ins(listLayer, i, new);
- return;
- }
- }
-
- list_add(listLayer, new);
-}
-
-/*
- * Draws all items onto the screen according to the layer and coordinate Y+H
- * After drawing frees the list
- */
-void layer_draw_all()
-{
- layer_t *this;
- int i;
-
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
-
- image_draw(this->image, this->x, this->y, this->px, this->py, this->w, this->h);
- }
-
- /*printf("listLayer->count = %d\n", listLayer->count);*/
-
- list_destroy_item(listLayer, free);
- listLayer = list_new();
-}
-
-void layer_draw_center(int x, int y)
-{
- layer_t *this;
- int screen_x, screen_y;
- int i;
- /*int count = 0;*/
-
- arena_get_center_screen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
-
- for (i = 0; i < listLayer->count; i++) {
- this = (layer_t *) listLayer->list[i];
-
- 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++;*/
-
- image_draw(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("count = %d\n", count);*/
-
- list_destroy_item(listLayer, free);
- listLayer = list_new();
-}
-
-void layer_draw_slpit(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];
-
- 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;
-
- z = local_x - (local_x + (this->x - x));
-
- 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_y + (this->y - y) < local_y) {
- int z;
-
- z = local_y - (local_y + (this->y - y));
-
- 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);
- }
-
- image_draw(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("count = %d\n", count);*/
-
- list_destroy_item(listLayer, free);
- listLayer = list_new();
-}
-
-void layer_flush()
-{
- list_destroy_item(listLayer, free);
- listLayer = list_new();
-}
-
-/*
- * Delete list of layers from memory
- */
-void layer_quit()
-{
- list_destroy_item(listLayer, free);
- isLayerInit = FALSE;
-}
diff --git a/src/client/layer.h b/src/client/layer.h
deleted file mode 100644
index 3642a0a..0000000
--- a/src/client/layer.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef MY_LAYER_H
-#define MY_LAYER_H
-
-#include "main.h"
-#include "image.h"
-
-typedef struct layer_str {
- /* coordinates of the image */
- int x;
- int y;
-
- /* size of the image */
- int w;
- int h;
-
- /* coordinates of a part of the surface */
- int px;
- int py;
-
- /* size of a part of the surface */
- int pw;
- int ph;
-
- /* in which layer to lay it */
- int layer;
-
- /* image of the surface */
- image_t *image;
-} layer_t;
-
-extern bool_t layer_is_inicialized();
-extern void layer_init();
-
-extern void addLayer(image_t *img, int x, int y, int px, int py, int w, int h, int player);
-
-extern void layer_draw_all();
-extern void layer_draw_center(int x, int y);
-extern void layer_draw_slpit(int local_x, int local_y, int x, int y, int w, int h);
-extern void layer_flush();
-extern void layer_quit();
-
-#endif /* MY_LAYER_H */
diff --git a/src/client/mouse_buffer.c b/src/client/mouse_buffer.c
deleted file mode 100644
index f301b28..0000000
--- a/src/client/mouse_buffer.c
+++ /dev/null
@@ -1,138 +0,0 @@
-#include <SDL.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "mouse_buffer.h"
-
-static list_t *list_event;
-
-typedef struct mouse_event_struct {
- Uint8 button;
- int x;
- int y;
-} mouse_event_t;
-
-static mouse_event_t *mouse_event_new(int x, int y, Uint8 button)
-{
- mouse_event_t *mouse_event;
-
- mouse_event = malloc(sizeof(mouse_event_t));
- mouse_event->x = x;
- mouse_event->y = y;
- mouse_event->button = button;
-
- return mouse_event;
-}
-
-static void mouse_event_destroy(mouse_event_t *mouse_event)
-{
- assert(mouse_event != NULL);
- free(mouse_event);
-}
-
-int mouse_buffer_init()
-{
- list_event = list_new();
-
- return 0;
-}
-
-int mouse_buffer_event(SDL_MouseButtonEvent *button)
-{
- assert(button != NULL);
- assert(list_event != NULL);
-
- switch (button->button) {
- case SDL_BUTTON_LEFT:
- case SDL_BUTTON_RIGHT:
- /*printf("mouse button - pos(%d,%d)\n", button->x, button->y);*/
-
- list_add(list_event, mouse_event_new(button->x, button->y, button->button));
-
- return 1;
- break;
-
- default:
- break;
- }
-
- return 0;
-}
-
-int mouse_buffer_clean()
-{
- assert(list_event != NULL);
-
- list_destroy_item(list_event, mouse_event_destroy);
- list_event = list_new();
-
- return 0;
-}
-
-bool_t mouse_buffer_is_on_area(int x, int y, int w, int h, unsigned int flag)
-{
- mouse_event_t *mouse_event;
- int i;
-
- assert(list_event != NULL);
-
- if (flag & MOUSE_BUF_MOTION) {
- int mouse_x, mouse_y;
-
- SDL_GetMouseState(&mouse_x, &mouse_y);
-
- if (mouse_x >= x && mouse_y >= y &&
- mouse_x < x+w && mouse_y < y+h) {
- return TRUE;
- }
- } else {
- for (i = 0; i < list_event->count; i++) {
- mouse_event = (mouse_event_t *) list_event->list[i];
-
- if ((mouse_event->x >= x && mouse_event->y >= y &&
- mouse_event->x < x + w && mouse_event->y < y + h) ||
- (flag & MOUSE_BUF_AREA_NONE)) {
- if (flag & MOUSE_BUF_CLICK_LEFT) {
- if (mouse_event->button == SDL_BUTTON_LEFT) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- if (flag & MOUSE_BUF_CLICK_RIGHT) {
- if (mouse_event->button == SDL_BUTTON_RIGHT) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- if (flag & MOUSE_BUF_CLICK) {
- if (mouse_event->button == SDL_BUTTON_LEFT ||
- mouse_event->button == SDL_BUTTON_RIGHT) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-int mouse_buffer_quit()
-{
- assert(list_event != NULL);
- list_destroy_item(list_event, mouse_event_destroy);
-
- return 0;
-}
diff --git a/src/client/mouse_buffer.h b/src/client/mouse_buffer.h
deleted file mode 100644
index 7cc6588..0000000
--- a/src/client/mouse_buffer.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef MOUSE_EVENT_H
-#define MOUSE_EVENT_H
-
-#include <SDL.h>
-
-#define MOUSE_BUF_MOTION 1
-#define MOUSE_BUF_CLICK_LEFT 2
-#define MOUSE_BUF_CLICK_RIGHT 4
-#define MOUSE_BUF_CLICK 8
-#define MOUSE_BUF_AREA_NONE 16
-
-extern int mouse_buffer_init();
-extern int mouse_buffer_event(SDL_MouseButtonEvent *button);
-extern int mouse_buffer_clean();
-extern bool_t mouse_buffer_is_on_area(int x, int y, int w, int h, unsigned int flag);
-extern int mouse_buffer_quit();
-
-#endif /* MOUSE_EVENT_H */
diff --git a/src/client/panel.c b/src/client/panel.c
deleted file mode 100644
index 43dab1a..0000000
--- a/src/client/panel.c
+++ /dev/null
@@ -1,159 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-
-#include "interface.h"
-#include "image.h"
-#include "panel.h"
-#include "font.h"
-#include "chat.h"
-
-static image_t *g_panel;
-static image_t *g_shot;
-static image_t *g_icon[ITEM_COUNT];
-static image_t *g_bonus;
-
-static bool_t isPanelInit = FALSE;
-
-bool_t panel_is_inicialized()
-{
- return isPanelInit;
-}
-
-void panel_init()
-{
- assert(image_is_inicialized() == TRUE);
- assert(interface_is_inicialized() == TRUE);
-
- g_panel = image_add("panel.png", IMAGE_ALPHA, "panel", IMAGE_GROUP_BASE);
- g_shot = image_add("panel_shot.png", IMAGE_ALPHA, "panel_image_shot",IMAGE_GROUP_BASE);
- g_bonus = image_add("graf.bonus.png", IMAGE_ALPHA, "panel_graf_bonus", IMAGE_GROUP_BASE);
- g_icon[GUN_SIMPLE] = image_add("icon.gun.simple.png", IMAGE_ALPHA, "panel_gun", IMAGE_GROUP_BASE);
- g_icon[GUN_DUAL_SIMPLE] = image_add("icon.gun.dual.simple.png", IMAGE_ALPHA, "panel_dual", IMAGE_GROUP_BASE);
- g_icon[GUN_TOMMY] = image_add("icon.gun.tommy.png", IMAGE_ALPHA, "panel_tommy", IMAGE_GROUP_BASE);
- g_icon[GUN_SCATTER] = image_add("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter", IMAGE_GROUP_BASE);
- g_icon[GUN_LASSER] = image_add("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser", IMAGE_GROUP_BASE);
- g_icon[GUN_MINE] = image_add("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine", IMAGE_GROUP_BASE);
- g_icon[GUN_BOMBBALL] = image_add("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball", IMAGE_GROUP_BASE);
- g_icon[BONUS_SPEED] = image_add("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed", IMAGE_GROUP_BASE);
- g_icon[BONUS_SHOT] = image_add("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot", IMAGE_GROUP_BASE);
- g_icon[BONUS_TELEPORT] = image_add("icon.bonus.teleport.png", IMAGE_ALPHA, "panel_teleport", IMAGE_GROUP_BASE);
- g_icon[BONUS_GHOST] = image_add("icon.bonus.ghost.png", IMAGE_ALPHA, "panel_ghost", IMAGE_GROUP_BASE);
- g_icon[BONUS_4X] = image_add("icon.bonus.4x.png", IMAGE_ALPHA, "panel_4x", IMAGE_GROUP_BASE);
- g_icon[BONUS_HIDDEN] = image_add("icon.bonus.hidden.png", IMAGE_ALPHA, "panel_hidden", IMAGE_GROUP_BASE);
-
- isPanelInit = TRUE;
-}
-
-static void drawScore(tux_t *tux_left, tux_t *tux_right)
-{
- 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);
- }
-
- font_text_size(strScoreLine, &w, &h);
- font_draw(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y, COLOR_WHITE);
-}
-
-static void shot_draw(int n, int x, int y)
-{
- image_draw(g_shot, x, y, n * PANEL_SHOT_WIDTH, 0, PANEL_SHOT_WIDTH, PANEL_SHOT_HEIGHT);
-}
-
-static void shot_drawInfo(tux_t *tux, int x, int y)
-{
- int i;
-
- if (tux->pickup_time > 0) {
- for (i = 0; i < tux->pickup_time / 3; i++) {
- shot_draw(PANEL_SHOT_LINE, x + i * PANEL_SHOT_WIDTH, y);
- }
-
- return;
- }
-
- for (i = 0; i < GUN_MAX_SHOT; i++) {
- if (tux->shot[tux->gun] > i) {
- shot_draw(PANEL_SHOT_FILL, x + i * (PANEL_SHOT_WIDTH + 2), y);
- } else {
- shot_draw(PANEL_SHOT_EMPTY, x + i * (PANEL_SHOT_WIDTH + 2), y);
- }
- }
-}
-
-static void drawGunInfo(tux_t *tux, int x, int y)
-{
- image_draw(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)
-{
- image_draw(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)
-{
- int offset;
-
- offset = tux->bonus_time / 5;
- image_draw(g_bonus, x, y, 0, 0, g_bonus->w, g_bonus->h / 2);
- image_draw(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2);
-}
-
-static void tux_drawRight(tux_t *tux)
-{
- if (tux == NULL) {
- return;
- }
-
- shot_drawInfo(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);
- }
-}
-
-static void tux_drawLeft(tux_t *tux)
-{
- if (tux == NULL) {
- return;
- }
-
- shot_drawInfo(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);
- }
-}
-
-void panel_draw(tux_t *tux_right, tux_t *tux_left)
-{
- image_draw(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h);
- drawScore(tux_right, tux_left);
-
- if (chat_is_recived_new_msg()) {
- font_draw(_("Recived new chat message"), PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE);
- }
-
- tux_drawRight(tux_right);
- tux_drawLeft(tux_left);
-}
-
-void panel_quit()
-{
- isPanelInit = FALSE;
-}
diff --git a/src/client/panel.h b/src/client/panel.h
deleted file mode 100644
index 8ae92b3..0000000
--- a/src/client/panel.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef PANEL_H
-#define PANEL_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_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_SHOT_FILL 0
-#define PANEL_SHOT_EMPTY 1
-#define PANEL_SHOT_LINE 2
-
-extern bool_t panel_is_inicialized();
-extern void panel_init();
-extern void panel_draw(tux_t *tux_right, tux_t *tux_left);
-extern void panel_quit();
-
-#endif /* PANEL_H */
diff --git a/src/client/pauza.c b/src/client/pauza.c
deleted file mode 100644
index 61f80ea..0000000
--- a/src/client/pauza.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
-
-#include "interface.h"
-#include "image.h"
-#include "pauza.h"
-#include "hotKey.h"
-
-static image_t *g_pauza;
-static bool_t activePauza;
-
-static void switchPauzed()
-{
- if (activePauza == TRUE) {
- activePauza = FALSE;
- } else {
- activePauza = TRUE;
- }
-}
-
-static void hotkey_pauze()
-{
- switchPauzed();
-}
-
-void pauza_init()
-{
- g_pauza = image_add("pauza.png", IMAGE_ALPHA, "pauza", IMAGE_GROUP_USER);
- activePauza = FALSE;
-
- hot_key_register(SDLK_p, hotkey_pauze);
-}
-
-void pauza_draw()
-{
- if (activePauza) {
- image_draw(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 pauza_event()
-{
-}
-
-bool_t pauza_is_active()
-{
- return activePauza;
-}
-
-void pauza_quit()
-{
- hot_key_unregister(SDLK_p);
-}
diff --git a/src/client/pauza.h b/src/client/pauza.h
deleted file mode 100644
index a432d5f..0000000
--- a/src/client/pauza.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef PAUZA_H
-#define PAUZA_H
-
-#include "main.h"
-
-#define PAUZE_ACTIVE_TIME_INTERVAL 1000
-
-extern void pauza_init();
-extern void pauza_draw();
-extern void pauza_event();
-extern bool_t pauza_is_active();
-extern void pauza_quit();
-
-#endif /* PAUZA_H */
diff --git a/src/client/radar.c b/src/client/radar.c
deleted file mode 100644
index e8457e9..0000000
--- a/src/client/radar.c
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "arena.h"
-
-#include "interface.h"
-#include "image.h"
-#include "radar.h"
-
-static image_t *g_radar;
-static list_t *listRadar;
-
-typedef struct radar_item_struct {
- int id;
- int x, y;
- int type;
-} radar_item_t;
-
-static radar_item_t *newRadarItem(int id, int x, int y, int type)
-{
- radar_item_t *new;
-
- new = malloc(sizeof(radar_item_t));
- new->id = id;
- new->x = x;
- new->y = y;
- new->type = type;
-
- return new;
-}
-
-static void destroyRadarItem(radar_item_t *p)
-{
- assert(p != NULL);
- free(p);
-}
-
-void radar_add(int id, int x, int y, int type)
-{
- int i;
-
- for (i = 0; i < listRadar->count; i++) {
- radar_item_t *thisRadarItem;
-
- thisRadarItem = (radar_item_t *) listRadar->list[i];
-
- if (thisRadarItem->id == id) {
- thisRadarItem->x = x;
- thisRadarItem->y = y;
- thisRadarItem->type = type;
- return;
- }
- }
-
- list_add(listRadar, newRadarItem(id, x, y, type));
-}
-
-void radar_del(int id)
-{
- int i;
-
- for (i = 0; i < listRadar->count; i++) {
- radar_item_t *thisRadarItem;
-
- thisRadarItem = (radar_item_t *) listRadar->list[i];
-
- if (thisRadarItem->id == id) {
- list_del_item(listRadar, i, destroyRadarItem);
- return;
- }
- }
-}
-
-void radar_init()
-{
- assert(image_is_inicialized() == TRUE);
- assert(interface_is_inicialized() == TRUE);
-
- g_radar = image_add("radar.png", IMAGE_NO_ALPHA, "radar", IMAGE_GROUP_USER);
- listRadar = list_new();
-}
-
-void radar_draw(arena_t *arena)
-{
- int i;
-
- image_draw(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;
-
- 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);
-
- if (x >= 0 && x <= RADAR_SIZE_X && y >= 0 && y <= RADAR_SIZE_Y) {
- image_draw(g_radar, RADAR_LOCATION_X + 1 + x, RADAR_LOCATION_Y + 1 + y,
- 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
- }
- }
-}
-
-void radar_quit()
-{
- list_destroy_item(listRadar, destroyRadarItem);
-}
diff --git a/src/client/radar.h b/src/client/radar.h
deleted file mode 100644
index 8bc2a01..0000000
--- a/src/client/radar.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef RADAR_H
-#define RADAR_H
-
-#include "arena.h"
-
-#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_TYPE_YOU 3
-#define RADAR_TYPE_TUX 1
-#define RADAR_TYPE_ITEM 2
-
-extern void radar_init();
-extern void radar_add(int id, int x, int y, int type);
-extern void radar_del(int id);
-extern void radar_draw(arena_t *arena);
-extern void radar_quit();
-
-#endif /* RADAR_H */
diff --git a/src/client/saveDialog.c b/src/client/saveDialog.c
deleted file mode 100644
index 7a0c316..0000000
--- a/src/client/saveDialog.c
+++ /dev/null
@@ -1,134 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "tux.h"
-#include "space.h"
-#include "arena.h"
-#include "net_multiplayer.h"
-
-#include "interface.h"
-#include "saveDialog.h"
-#include "image.h"
-#include "font.h"
-#include "saveLoad.h"
-#include "hotKey.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-#include "widget_textfield.h"
-
-static image_t *g_background;
-static bool_t activeSaveDialog;
-
-static widget_t *widgetLabelMsg;
-static widget_t *widgetTextFieldName;
-
-static widget_t *widgetButtonSave;
-static widget_t *widgetButtonBack;
-
-static void switchTerm()
-{
- if (activeSaveDialog == TRUE) {
- activeSaveDialog = FALSE;
- hot_key_unregister(SDLK_ESCAPE);
- } else {
- activeSaveDialog = TRUE;
- hot_key_register(SDLK_ESCAPE, switchTerm);
- }
-}
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- if (button == widgetButtonSave) {
- save_arena(text_field_get_text(widgetTextFieldName), arena_get_current());
- switchTerm();
- }
-
- if (button == widgetButtonBack) {
- switchTerm();
- }
-}
-
-static void hotkey_saveDialog()
-{
- switchTerm();
-}
-
-void save_dialog_init()
-{
- activeSaveDialog = FALSE;
-
- g_background = image_get(IMAGE_GROUP_BASE, "screen_main");
-
- widgetLabelMsg = label_new(_("Save as:"), SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_LEFT);
-
- widgetTextFieldName = text_field_new("", WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- widgetLabelMsg->x + widgetLabelMsg->w + 10,
- widgetLabelMsg->y);
-
- widgetButtonSave = button_new(_("Save"), SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
-
- widgetButtonBack = button_new(_("Back"), SAVE_DIALOG_LOCATIN_X + 20 +
- WIDGET_BUTTON_WIDTH + 20,
- SAVE_DIALOG_LOCATIN_Y + 60,
- eventWidget);
-
- hot_key_register(SDLK_F2, hotkey_saveDialog);
-}
-
-bool_t save_dialog_is_active()
-{
- return activeSaveDialog;
-}
-
-void save_dialog_draw()
-{
- if (activeSaveDialog == FALSE) {
- return;
- }
-
- image_draw(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);
-
- label_draw(widgetLabelMsg);
- text_field_draw(widgetTextFieldName);
- button_draw(widgetButtonSave);
- button_draw(widgetButtonBack);
-}
-
-void save_dialog_event()
-{
- if (activeSaveDialog == FALSE) {
- return;
- }
-
- text_field_event(widgetTextFieldName);
- button_event(widgetButtonSave);
- button_event(widgetButtonBack);
-
-}
-
-void save_dialog_quit()
-{
- hot_key_unregister(SDLK_F2);
-
- label_destroy(widgetLabelMsg);
- text_field_destroy(widgetTextFieldName);
- button_destroy(widgetButtonSave);
- button_destroy(widgetButtonBack);
-}
diff --git a/src/client/saveDialog.h b/src/client/saveDialog.h
deleted file mode 100644
index f5fb91f..0000000
--- a/src/client/saveDialog.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef SAVE_DIALOG_H
-#define SAVE_DIALOG_H
-
-#define SAVEDIALOG_ACTIVE_TIME_INTERVAL 500
-
-#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)
-
-extern void save_dialog_init();
-extern bool_t save_dialog_is_active();
-extern void save_dialog_draw();
-extern void save_dialog_event();
-extern void save_dialog_quit();
-
-#endif /* SAVE_DIALOG_H */
diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c
deleted file mode 100644
index 899ef25..0000000
--- a/src/client/saveLoad.c
+++ /dev/null
@@ -1,258 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "textFile.h"
-#include "homeDirector.h"
-
-#include "arena.h"
-#include "arenaFile.h"
-#include "tux.h"
-#include "shot.h"
-#include "item.h"
-#include "modules.h"
-
-#include "saveLoad.h"
-
-#include "choiceArena.h"
-#include "world.h"
-
-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);
-
- list_add(textFile->text, strdup(str));
-}
-
-static void action_saveShot(space_t *space, shot_t *shot, textFile_t *textFile)
-{
- 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);
-
- list_add(textFile->text, strdup(str));
-}
-
-static void action_saveItem(space_t *space, item_t *item, textFile_t *textFile)
-{
- 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);
-
- list_add(textFile->text, strdup(str));
-}
-
-static void saveContextArenaToTextFile(textFile_t *textFile, arena_t *arena)
-{
- char str[STR_PROTO_SIZE];
-
- sprintf(str, "ARENA %s %d %d",
- arena_file_get_net_name(choice_arena_get()),
- arena->countRound, arena->max_countRound);
-
- list_add(textFile->text, strdup(str));
-
- space_action(arena->spaceTux, action_saveTux, textFile);
- space_action(arena->spaceShot, action_saveShot, textFile);
- space_action(arena->spaceItem, action_saveItem, textFile);
-}
-
-void save_arena(char *filename, arena_t *arena)
-{
- textFile_t *textFile;
- char path[STR_PATH_SIZE];
-
- sprintf(path, "%s%s%s.sav", home_director_get(), PATH_SEPARATOR, filename);
-
- debug("Saving game [%s]", path);
-
- textFile = text_file_new(path);
-
- if (textFile != NULL) {
- saveContextArenaToTextFile(textFile, arena);
- text_file_save(textFile);
- text_file_destroy(textFile);
- } else {
- error("Unable to save game [%s]", path);
- }
-}
-
-static arena_t *load_arenaFromLine(char *line)
-{
- 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);
-
- world_set_arena(arena_file_get_file_format_net_name(name));
-
- arena = arena_get_current();
- arena->max_countRound = max_countRound;
- arena->countRound = countRound;
-
- return 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 = tux_new();
- tux_replace_id(tux, id);
- space_add(arena->spaceTux, tux);
-
- tux->control = control;
-
- if (tux->control == TUX_CONTROL_KEYBOARD_RIGHT) {
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_RIGHT);
- }
-
- if (tux->control == TUX_CONTROL_KEYBOARD_LEFT) {
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_LEFT);
- }
-
- if (tux->control == TUX_CONTROL_AI) {
- module_load("libmodAI");
- world_set_control_tux(tux, TUX_CONTROL_KEYBOARD_LEFT);
- }
-
- space_move_object(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)
-{
- 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);
-
- shot = shot_new(x, y, px, py, gun, author_id);
-
- shot_replace_id(shot, shot_id);
- shot->isCanKillAuthor = isCanKillAuthor;
- shot->position = position;
-
- if (shot->gun == GUN_LASSER) {
- shot_transform_lasser(shot);
- }
-
- space_add(arena->spaceShot, shot);
-}
-
-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;
-
- sscanf(line, "%s %d %d %d %d %d %d %d %d",
- cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
-
- item = item_new(x, y, type, author_id);
-
- item_replace_id(item, id);
- item->count = count;
- item->frame = frame;
-
- space_add(arena->spaceItem, item);
-}
-
-static arena_t *loadContextArenaFromTextFile(textFile_t *textFile)
-{
- arena_t *arena;
- int i;
-
- arena = NULL;
-
- for (i = 0; i < textFile->text->count; i++) {
- char *line;
-
- line = (char *) textFile->text->list[i];
-
- if (strncmp(line, "ARENA", 5) == 0) {
- arena = load_arenaFromLine(line);
- }
-
- if (strncmp(line, "TUX", 3) == 0) {
- loadTuxFromLine(line, arena);
- }
-
- if (strncmp(line, "SHOT", 4) == 0) {
- loadShotFromLine(line, arena);
- }
-
- if (strncmp(line, "ITEM", 4) == 0) {
- loadItemFromLine(line, arena);
- }
- }
-
- return arena;
-}
-
-void load_arena(char *filename)
-{
- textFile_t *textFile;
- char path[STR_PATH_SIZE];
-
- sprintf(path, "%s%s%s", home_director_get(), PATH_SEPARATOR, filename);
-
- debug("Loading arena [%s]", path);
-
- textFile = text_file_load(path);
-
- if (textFile != NULL) {
- loadContextArenaFromTextFile(textFile);
- text_file_destroy(textFile);
- } else {
- error("Unable to load saved game [%s]", path);
- }
-}
diff --git a/src/client/saveLoad.h b/src/client/saveLoad.h
deleted file mode 100644
index eaf27e2..0000000
--- a/src/client/saveLoad.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef SAVELOAD_H
-#define SAVELOAD_H
-
-#include "textFile.h"
-#include "arena.h"
-
-extern void save_arena(char *filename, arena_t *arena);
-extern void load_arena(char *filename);
-
-#endif /* SAVELOAD_H */
diff --git a/src/client/screen.c b/src/client/screen.c
deleted file mode 100644
index 476cf3e..0000000
--- a/src/client/screen.c
+++ /dev/null
@@ -1,175 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-
-#include "interface.h"
-#include "screen.h"
-#include "layer.h"
-#include "myTimer.h"
-
-/*#define DEBUG_TIME_DRAW*/
-
-static screen_t *currentScreen;
-static screen_t *futureScreen;
-
-static list_t *listScreen;
-
-static bool_t isScreenInit = FALSE;
-
-bool_t screen_is_inicialized()
-{
- return isScreenInit;
-}
-
-screen_t *screen_new(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;
-}
-
-void screen_destroy(screen_t *p)
-{
- assert(p != NULL);
-
- free(p->name);
- free(p);
-}
-
-void screen_register(screen_t *p)
-{
- assert(p != NULL);
-
- debug("Registering screen [%s]", p->name);
-
- list_add(listScreen, p);
-}
-
-void screen_init()
-{
- listScreen = list_new();
-
- currentScreen = NULL;
- futureScreen = NULL;
-
- isScreenInit = TRUE;
-}
-
-static screen_t *findScreen(char *name)
-{
- screen_t *this;
- int i;
-
- for (i = 0; i < listScreen->count; i++) {
- this = (screen_t *) listScreen->list[i];
- assert(this != NULL);
-
- if (strcmp(name, this->name) == 0) {
- return this;
- }
- }
-
- return NULL;
-}
-
-void screen_set(char *name)
-{
- futureScreen = findScreen(name);
- assert(futureScreen != NULL);
-}
-
-void screen_switch()
-{
- if (futureScreen == NULL) {
- return;
- }
-
- layer_flush();
-
- if (currentScreen != NULL) {
- debug("Stopping screen [%s]", currentScreen->name);
- currentScreen->fce_stop();
- }
-
- currentScreen = futureScreen;
- futureScreen = NULL;
-
- debug("Starting screen [%s]", currentScreen->name);
-
- currentScreen->fce_start();
-}
-
-void screen_start(char *name)
-{
- screen_set(name);
- screen_switch();
-}
-
-char *screen_get()
-{
- assert(currentScreen != NULL);
- return currentScreen->name;
-}
-
-void screen_draw()
-{
- static int count = 0;
-
- count++;
-
- if (count == 1) {
- count = 0;
-
- assert(currentScreen != NULL);
-
-#ifdef DEBUG_TIME_DRAW
- my_time_t prev;
-
- prev = timer_get_current_timeMicro();
-#endif /* DEBUG_TIME_DRAW */
-
- currentScreen->fce_draw();
-
- interface_refresh();
-
-#ifdef DEBUG_TIME_DRAW
- printf("c draw time = %d\n", timer_get_current_timeMicro() - prev);
-#endif /* DEBUG_TIME_DRAW */
- }
-}
-
-
-void screen_event()
-{
- assert(currentScreen != NULL);
-
- currentScreen->fce_event();
-
-#ifdef DEBUG_TIME_EVENT
- printf("c event time = %d\n", timer_get_current_timeMicro() - prev);
-#endif /* DEBUG_TIME_EVENT */
-}
-
-void screen_quit()
-{
- assert(listScreen != NULL);
-
- list_destroy_item(listScreen, screen_destroy);
- isScreenInit = FALSE;
-}
diff --git a/src/client/screen.h b/src/client/screen.h
deleted file mode 100644
index 718fb57..0000000
--- a/src/client/screen.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SCREEN_H
-#define SCREEN_H
-
-#include "main.h"
-
-typedef struct screen_struct {
- char *name;
- void (*fce_start) ();
- void (*fce_event) ();
- void (*fce_draw) ();
- void (*fce_stop) ();
-} screen_t;
-
-extern bool_t screen_is_inicialized();
-
-extern screen_t *screen_new(char *name, void (*fce_start) (),
- void (*fce_event) (),
- void (*fce_draw) (),
- void (*fce_stop) ());
-
-extern void screen_destroy(screen_t *p);
-extern void screen_register(screen_t *p);
-extern void screen_init();
-extern void screen_set(char *name);
-extern void screen_switch();
-extern void screen_start(char *name);
-extern char *screen_get();
-extern void screen_draw();
-extern void screen_event();
-extern void screen_quit();
-
-#endif /* SCREEN_H */
diff --git a/src/client/term.c b/src/client/term.c
deleted file mode 100644
index dc4a51b..0000000
--- a/src/client/term.c
+++ /dev/null
@@ -1,157 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-#include "myTimer.h"
-#include "tux.h"
-#include "space.h"
-#include "arena.h"
-
-#include "interface.h"
-#include "term.h"
-#include "font.h"
-
-static list_t *listText;
-static bool_t activeTerm;
-static my_time_t lastActive;
-static my_time_t lastRefresh;
-
-void term_init()
-{
- listText = list_new();
-
- activeTerm = FALSE;
- lastActive = timer_get_current_time();
- lastRefresh = lastActive;
-}
-
-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_unknown";
-}
-
-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 "4";
- case BONUS_HIDDEN:
- return "hidden";
- default:
- return "none";
- }
-
- return "bonus_unknown";
-}
-
-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)
- );
-
- list_add(listText, strdup(str));
-}
-
-static void refreshTerm()
-{
- arena_t *arena;
-
- arena = arena_get_current();
-
- list_destroy_item(listText, free);
- listText = list_new();
-
- space_action(arena->spaceTux, action_refreshTerm, NULL);
-
- /*printf("refresh term..\n");*/
-}
-
-void term_draw()
-{
- int i;
-
- if (activeTerm == FALSE) {
- return;
- }
-
- for (i = 0; i < listText->count; i++) {
- char *line;
-
- line = (char *) listText->list[i];
- font_draw(line, 10, 10 + i * 20, COLOR_WHITE);
- }
-}
-
-static void switchTerm()
-{
- if (activeTerm == TRUE) {
- activeTerm = FALSE;
- } else {
- activeTerm = TRUE;
- }
-}
-
-void term_event()
-{
- my_time_t currentTime;
- Uint8 *mapa;
-
- mapa = SDL_GetKeyState(NULL);
-
- currentTime = timer_get_current_time();
-
- 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();
- }
- }
-}
-
-void term_quit()
-{
- assert(listText != NULL);
- list_destroy_item(listText, free);
-}
diff --git a/src/client/term.h b/src/client/term.h
deleted file mode 100644
index 719df2d..0000000
--- a/src/client/term.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef TERM_H
-#define TERM_H
-
-#include "main.h"
-
-#define TERM_ACTIVE_TIME_INTERVAL 500
-#define TERM_REFRESH_TIME_INTERVAL 1000
-
-extern void term_init();
-extern void term_draw();
-extern void term_event();
-extern void term_quit();
-
-#endif /* TERM_H */
diff --git a/src/client/yes_no_dialog.c b/src/client/yes_no_dialog.c
deleted file mode 100644
index d982933..0000000
--- a/src/client/yes_no_dialog.c
+++ /dev/null
@@ -1,134 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "list.h"
-
-#include "interface.h"
-#include "hotKey.h"
-#include "yes_no_dialog.h"
-#include "image.h"
-#include "font.h"
-
-#include "widget.h"
-#include "widget_label.h"
-#include "widget_button.h"
-
-static image_t *g_background;
-
-static widget_t *widgetLabelMsg;
-
-static widget_t *widgetButtonYes;
-static widget_t *widgetButtonNo;
-
-static void (*handle_yes)(void *param);
-static void (*handle_no)(void *param);
-static void *param;
-static bool_t active_dialog;
-
-static void eventWidget(void *p)
-{
- widget_t *button;
-
- button = (widget_t *) p;
-
- yes_no_dialog_set_active(FALSE);
-
- if (button == widgetButtonYes) {
- handle_yes(param);
- }
-
- if (button == widgetButtonNo) {
- handle_no(param);
- }
-}
-
-void yes_no_dialog_init()
-{
- active_dialog = FALSE;
-
- g_background = image_get(IMAGE_GROUP_BASE, "screen_main");
-
- widgetLabelMsg = label_new("empty label", WINDOW_SIZE_X / 2,
- YES_NO_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_CENTER);
-
- widgetButtonYes = button_new(_("Yes"), YES_NO_DIALOG_LOCATIN_X + 20,
- YES_NO_DIALOG_LOCATIN_Y + 60,
- eventWidget);
-
- widgetButtonNo = button_new(_("No"), YES_NO_DIALOG_LOCATIN_X + 20 +
- WIDGET_BUTTON_WIDTH + 20,
- YES_NO_DIALOG_LOCATIN_Y + 60,
- eventWidget);
-}
-
-static void hotkey_escape()
-{
- yes_no_dialog_set_active(FALSE);
- handle_no(param);
-}
-
-void yes_no_dialog_set_active(bool_t active)
-{
- active_dialog = active;
-
- if (active_dialog == TRUE) {
- hot_key_register(SDLK_ESCAPE, hotkey_escape);
- } else {
- hot_key_unregister(SDLK_ESCAPE);
- }
-}
-
-bool_t yes_no_dialog_is_active()
-{
- return active_dialog;
-}
-
-void yes_no_dialog_set(char *label, void *function_yes, void *function_no, void *p_param)
-{
- label_destroy(widgetLabelMsg);
-
- widgetLabelMsg = label_new(label, WINDOW_SIZE_X / 2,
- YES_NO_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_CENTER);
-
- handle_yes = function_yes;
- handle_no = function_no;
- param = p_param;
-}
-
-void yes_no_dialog_draw()
-{
- if (active_dialog == FALSE) {
- return;
- }
-
- image_draw(g_background, YES_NO_DIALOG_LOCATIN_X,
- YES_NO_DIALOG_LOCATIN_Y,
- YES_NO_DIALOG_LOCATIN_X,
- YES_NO_DIALOG_LOCATIN_Y,
- YES_NO_DIALOG_SIZE_X,
- YES_NO_DIALOG_SIZE_Y);
-
- label_draw(widgetLabelMsg);
- button_draw(widgetButtonYes);
- button_draw(widgetButtonNo);
-}
-
-void yes_no_dialog_event()
-{
- if (active_dialog == FALSE) {
- return;
- }
-
- button_event(widgetButtonYes);
- button_event(widgetButtonNo);
-}
-
-void yes_no_dialog_quit()
-{
- label_destroy(widgetLabelMsg);
- button_destroy(widgetButtonYes);
- button_destroy(widgetButtonNo);
-}
diff --git a/src/client/yes_no_dialog.h b/src/client/yes_no_dialog.h
deleted file mode 100644
index 3cef74c..0000000
--- a/src/client/yes_no_dialog.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef YES_NO_DIALOG_H
-#define YES_NO_DIALOG_H
-
-#define YES_NO_ACTIVE_TIME_INTERVAL 500
-
-#define YES_NO_DIALOG_SIZE_X 320
-#define YES_NO_DIALOG_SIZE_Y 120
-
-#define YES_NO_DIALOG_LOCATIN_X (WINDOW_SIZE_X / 2 - YES_NO_DIALOG_SIZE_X / 2)
-#define YES_NO_DIALOG_LOCATIN_Y (WINDOW_SIZE_Y / 2 - YES_NO_DIALOG_SIZE_Y / 2)
-
-extern void yes_no_dialog_init();
-extern void yes_no_dialog_set_active(bool_t active);
-extern bool_t yes_no_dialog_is_active();
-extern void yes_no_dialog_set(char *label, void *function_yes, void *function_no, void *p_param);
-extern void yes_no_dialog_draw();
-extern void yes_no_dialog_event();
-extern void yes_no_dialog_quit();
-
-#endif /* YES_NO_DIALOG_H */