summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/chat.c38
-rw-r--r--src/client/client.c69
-rw-r--r--src/client/configFile.c34
-rw-r--r--src/client/font.c29
-rw-r--r--src/client/fontConfig.c76
-rw-r--r--src/client/game.c13
-rw-r--r--src/client/hotKey.c11
-rw-r--r--src/client/image.c141
-rw-r--r--src/client/interface.c200
-rw-r--r--src/client/keyboardBuffer.c19
-rw-r--r--src/client/layer.c37
-rw-r--r--src/client/panel.c17
-rw-r--r--src/client/pauza.c7
-rw-r--r--src/client/radar.c7
-rw-r--r--src/client/saveDialog.c41
-rw-r--r--src/client/saveLoad.c63
-rw-r--r--src/client/screen.c35
-rw-r--r--src/client/term.c25
18 files changed, 369 insertions, 493 deletions
diff --git a/src/client/chat.c b/src/client/chat.c
index b6904c9..d4bdc14 100644
--- a/src/client/chat.c
+++ b/src/client/chat.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
@@ -37,15 +36,16 @@ static void chat_eventDisable();
static void hotkey_chat_esc()
{
- //printf("*** hotkey_chat_esc\n");
- //hot_key_unregister(SDLK_ESCAPE);
+ /*
+ printf("*** hotkey_chat_esc\n");
+ hot_key_unregister(SDLK_ESCAPE);
+ */
chat_eventDisable();
}
static void hotkey_chat_enter()
{
- if( chat_active == TRUE )
- {
+ if (chat_active == TRUE) {
return;
}
@@ -68,8 +68,7 @@ void chat_init()
strcpy(line, "");
chat_active = FALSE;
- if( net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE )
- {
+ if (net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE) {
hot_key_register(SDLK_RETURN, hotkey_chat_enter);
}
@@ -89,7 +88,8 @@ void chat_draw()
}
image_draw(g_chat, CHAT_LOCATION_X, CHAT_LOCATION_Y,
- 0, 0, CHAT_SIZE_X, CHAT_SIZE_Y);
+ 0, 0,
+ CHAT_SIZE_X, CHAT_SIZE_Y);
for (i = 0; i < listText->count; i++) {
char *s;
@@ -97,7 +97,7 @@ void chat_draw()
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);
+ CHAT_SIZE_X - 10, 20, COLOR_WHITE);
}
strcpy(str, line);
@@ -132,11 +132,12 @@ static void processMessageKey(SDL_keysym keysym)
',', '<',
'.', '>',
'/', '?',
- ')', '(',
+ ')', '('
};
- if (line_atime < 100)
+ if (line_atime < 100) {
line_atime++;
+ }
len = strlen(line);
font_text_size(line, &w, &h);
@@ -148,12 +149,13 @@ static void processMessageKey(SDL_keysym keysym)
}
/* end of line */
- if (w > CHAT_SIZE_X - 20)
+ 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)) {
+ 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
*/
@@ -167,7 +169,6 @@ static void processMessageKey(SDL_keysym keysym)
}
}
}
-
line[len] = c;
return;
@@ -180,6 +181,7 @@ static void processMessageKey(SDL_keysym keysym)
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
*/
@@ -199,7 +201,8 @@ static void sendNewMessage()
char out[STR_PROTO_SIZE];
snprintf(out, STR_PROTO_SIZE, "chat %s:%s\n",
- world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)->name, line);
+ world_get_control_tux(TUX_CONTROL_KEYBOARD_RIGHT)->name,
+ line);
proto_send_chat_server(PROTO_SEND_ALL, NULL, out);
}
@@ -284,8 +287,7 @@ void chat_quit()
{
assert(listText != NULL);
- if( net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE )
- {
+ if (net_multiplayer_get_game_type() != NET_GAME_TYPE_NONE) {
hot_key_unregister(SDLK_RETURN);
}
diff --git a/src/client/client.c b/src/client/client.c
index 9d2971a..13d9964 100644
--- a/src/client/client.c
+++ b/src/client/client.c
@@ -1,4 +1,3 @@
-
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -8,13 +7,13 @@
#include <sys/time.h>
#ifndef __WIN32__
-# include <sys/ioctl.h>
-# include <sys/socket.h>
-# include <sys/select.h>
-#else
-# include <io.h>
-# include <winsock2.h>
-#endif
+#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"
@@ -43,7 +42,7 @@ static my_time_t lastPingServerAlive;
static my_time_t lastTraffic;
static int traffic_down;
static int traffic_up;
-#endif
+#endif /* SUPPORT_TRAFFIC */
typedef struct proto_cmd_client_struct {
char *name;
@@ -64,7 +63,7 @@ static proto_cmd_client_t proto_cmd_list[] = {
{.name = "chat",.len = 4,.fce_proto = proto_recv_chat_client},
{.name = "ping",.len = 4,.fce_proto = proto_recv_ping_client},
{.name = "end",.len = 3,.fce_proto = proto_recv_end_client},
- {.name = "",.len = 0,.fce_proto = NULL},
+ {.name = "",.len = 0,.fce_proto = NULL}
};
static proto_cmd_client_t *findCmdProto(char *msg)
@@ -79,8 +78,8 @@ static proto_cmd_client_t *findCmdProto(char *msg)
thisCmd = &proto_cmd_list[i];
- if (len >= thisCmd->len
- && strncmp(msg, thisCmd->name, thisCmd->len) == 0) {
+ if (len >= thisCmd->len &&
+ strncmp(msg, thisCmd->name, thisCmd->len) == 0) {
return thisCmd;
}
}
@@ -96,7 +95,7 @@ static int initUdpClient(char *ip, int port)
return -1;
}
- DEBUG_MSG(_("Connected to: %s on port: %d via UDP\n"), ip, port);
+ DEBUG_MSG(_("[Debug] Connected to game server [%s]:[%d]\n"), ip, port);
return 0;
}
@@ -114,7 +113,7 @@ int client_init(char *ip, int port)
lastTraffic = timer_get_current_time();
traffic_down = 0;
traffic_up = 0;
-#endif
+#endif /* SUPPORT_TRAFFIC */
clientRecvBuffer = buffer_new(CLIENT_BUFFER_LIMIT);
clientSendBuffer = buffer_new(CLIENT_BUFFER_LIMIT);
@@ -133,8 +132,8 @@ int client_init(char *ip, int port)
static void errorWithServer()
{
- fprintf(stderr, _("Server did not respond!\n"));
- analyze_set_msg(_("Server is not running or being blocked. I was unable to connect."));
+ fprintf(stderr, _("[Error] Game server is not responding\n"));
+ analyze_set_msg(_("[Error] Unable to connect to the game server"));
world_do_end();
}
@@ -146,15 +145,13 @@ void client_send(char *msg)
ret = -1;
-#ifndef PUBLIC_SERVER
if (isParamFlag("--send")) {
- printf(_("Sending: \"%s\""), msg);
+ printf(_("[Debug] Sending data: %s"), msg);
}
-#endif
#ifdef SUPPORT_TRAFFIC
traffic_up += strlen(msg);
-#endif
+#endif /* SUPPORT_TRAFFIC */
if (sock_server_udp != NULL) {
ret = sock_udp_write(sock_server_udp, sock_server_udp, msg, strlen(msg));
@@ -185,23 +182,10 @@ static int server_eventSelect()
#ifdef SUPPORT_TRAFFIC
traffic_down += ret;
-#endif
+#endif /* SUPPORT_TRAFFIC */
list_add(listRecvMsg, strdup(buffer));
-#if 0
- if (buffer_append(clientRecvBuffer, buffer, ret) < 0) {
- errorWithServer();
- return ret;
- }
-
- while (buffer_get_line(clientRecvBuffer, buffer, STR_PROTO_SIZE) >= 0) {
- if (strlen(buffer) > 0) {
- list_add(listRecvMsg, strdup(buffer));
- }
- }
-#endif
-
return ret;
}
@@ -211,7 +195,7 @@ static void client_eventWorkRecvList()
char *line;
int i;
- /* obsluha udalosti od servera */
+ /* processing of an event received from a game server */
assert(listRecvMsg != NULL);
@@ -219,11 +203,10 @@ static void client_eventWorkRecvList()
line = (char *) listRecvMsg->list[i];
protoCmd = findCmdProto(line);
-#ifndef PUBLIC_SERVER
if (isParamFlag("--recv")) {
- printf(_("Recieved: \"%s\""), line);
+ printf(_("[Debug] Recieved data: %s"), line);
}
-#endif
+
if (protoCmd != NULL) {
protoCmd->fce_proto(line);
lastPingServerAlive = timer_get_current_time();
@@ -303,7 +286,6 @@ static void selectClientSocket()
}
#ifdef SUPPORT_TRAFFIC
-
static void eventTraffic()
{
my_time_t currentTime;
@@ -313,20 +295,19 @@ static void eventTraffic()
if (currentTime - lastTraffic > 5000) {
lastTraffic = currentTime;
- DEBUG_MSG(_("down: %d\n") _("up : %d\n"), traffic_down, traffic_up);
+ DEBUG_MSG(_("[Debug] Traffic: down [%d]/up [%d]\n"), traffic_down, traffic_up);
traffic_down = 0;
traffic_up = 0;
}
}
-
-#endif
+#endif /* SUPPORT_TRAFFIC */
void client_event()
{
#ifdef SUPPORT_TRAFFIC
eventTraffic();
-#endif
+#endif /* SUPPORT_TRAFFIC */
eventPingServer();
selectClientSocket();
@@ -339,7 +320,7 @@ static void quitUdpClient()
assert(sock_server_udp != NULL);
sock_udp_close(sock_server_udp);
- DEBUG_MSG(_("Closing UDP connection.\n"));
+ DEBUG_MSG(_("[Debug] Closing connection to game server\n"));
}
void client_quit()
diff --git a/src/client/configFile.c b/src/client/configFile.c
index 162658b..227f5d5 100644
--- a/src/client/configFile.c
+++ b/src/client/configFile.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -9,9 +8,11 @@
int isYesOrNO(char *s)
{
- if (s[0] == 'Y' || s[0] == 'y')
+ if (s[0] == 'Y' || s[0] == 'y') {
return 1;
- return 0;
+ } else {
+ return 0;
+ }
}
char *getYesOrNo(int n)
@@ -31,23 +32,27 @@ int getValue(char *line, char *env, char *val, int len)
offset_env = strstr(line, clone_env);
- if (offset_env == NULL)
+ if (offset_env == NULL) {
return -1;
+ }
offset_val_begin = strchr(offset_env, '"');
- if (offset_val_begin == NULL)
+ if (offset_val_begin == NULL) {
return -1;
+ }
offset_val_end = strchr(offset_val_begin + 1, '"');
- if (offset_val_end == NULL)
+ if (offset_val_end == NULL) {
return -1;
+ }
val_len = (int) (offset_val_end - (offset_val_begin + 1));
- if (val_len > len - 1)
+ if (val_len > len - 1) {
val_len = len - 1;
+ }
memset(val, 0, len);
memcpy(val, offset_val_begin + 1, val_len);
@@ -63,23 +68,26 @@ char *setValue(char *line, char *env, char *val)
char clone_env[STR_SIZE];
char clone[STR_SIZE];
- //strcpy(clone_env, " ");
+ /*strcpy(clone_env, " ");*/
strcpy(clone_env, env);
offset_env = strstr(line, clone_env);
- if (offset_env == NULL)
+ if (offset_env == NULL) {
return NULL;
+ }
offset_val_begin = strchr(offset_env, '"');
- if (offset_val_begin == NULL)
+ if (offset_val_begin == NULL) {
return NULL;
+ }
offset_val_end = strchr(offset_val_begin + 1, '"');
- if (offset_val_end == NULL)
+ if (offset_val_end == NULL) {
return NULL;
+ }
memset(clone, 0, STR_SIZE);
strncpy(clone, line, (int) ((offset_val_begin - line) + 1));
@@ -97,8 +105,6 @@ int getValueInConfigFile(textFile_t * textFile, char *env, char *val, int len)
for (i = 0; i < textFile->text->count; i++) {
line = (char *) (textFile->text->list[i]);
- //printf("env = %s line = %s\n", env, line);
-
if (strncmp(line, env, strlen(env)) == 0) {
return getValue(line, env, val, len);
}
@@ -141,6 +147,6 @@ void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int le
sprintf(line, "%s=\"%s\"", env, butVal);
list_add(textFile->text, strdup(line));
- DEBUG_MSG(_("ADDING: \"%s\" into config file.\n"), line);
+ DEBUG_MSG(_("[Debug] Expanding config file [%s]\n"), line);
}
}
diff --git a/src/client/font.c b/src/client/font.c
index b64785e..a880dab 100644
--- a/src/client/font.c
+++ b/src/client/font.c
@@ -1,4 +1,3 @@
-
#include "main.h"
#include "interface.h"
#include "font.h"
@@ -26,8 +25,7 @@ void font_init()
res = fontconfig_init();
- if( res != 0 )
- {
+ if (res != 0) {
return;
}
@@ -39,9 +37,8 @@ void font_init()
printf("path[%d]=%s\nflag[%d]=%s\n\n", i, font_list[i].path, i, font_list[i].flag);
}
*/
- if( font_list == NULL )
- {
- fprintf(stderr, _("I do not find font\n"));
+ if (font_list == NULL) {
+ fprintf(stderr, _("[Error] Unable to locate a font\n"));
return;
}
@@ -62,14 +59,14 @@ void font_init()
g_font = TTF_OpenFont(font_file, fontSize);
TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL);
- DEBUG_MSG(_("Loading font: \"%s\"\n"), font_file);
+ DEBUG_MSG(_("[Debug] Loading font [%s]\n"), font_file);
free(font_file);
isFontInit = TRUE;
}
/*
- * Zobrazi text *string na suradnicu x y s farbou RGB
+ * 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)
{
@@ -77,18 +74,16 @@ void font_draw(char *string, int x, int y, int r, int g, int b)
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 ){
+ /* 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)
@@ -125,13 +120,13 @@ void font_drawMaxSize(char *s, int x, int y, int w, int h, int r, int g, int b)
i = image_new(text);
- //posibly broken
+ /* possibly broken */
image_draw(i, x, y, 0, 0, my_w, my_h);
image_destroy(i);
}
/*
- * Vrati velkost daneho fontu.
+ * Returns size of the font
*/
int font_get_size()
{
@@ -148,14 +143,14 @@ void font_text_size(char *s, int *w, int *h)
}
/*
- * Uvolni font z pamete.
+ * Frees font from memory
*/
void font_quit()
{
TTF_CloseFont(g_font);
TTF_Quit();
- DEBUG_MSG(_("Unloading font\n"));
+ DEBUG_MSG(_("[Debug] Unloading font\n"));
isFontInit = FALSE;
}
diff --git a/src/client/fontConfig.c b/src/client/fontConfig.c
index 6033287..3b73df8 100644
--- a/src/client/fontConfig.c
+++ b/src/client/fontConfig.c
@@ -1,10 +1,10 @@
-
#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()
@@ -13,16 +13,15 @@ int fontconfig_init()
res = FcInit();
- if( res == 0 )
- {
- fprintf(stderr, "Can't init font config library\n");
+ if (res == 0) {
+ fprintf(stderr, _("[Error] Unable to init fontconfig library\n"));
return 1;
}
return 0;
}
-font_config_t* fontconfig_find(char **arg)
+font_config_t *fontconfig_find(char **arg)
{
FcObjectSet *os;
FcFontSet *fs;
@@ -33,55 +32,45 @@ font_config_t* fontconfig_find(char **arg)
os = NULL;
ret = NULL;
- for( i = 0 ; arg[i] != NULL ; i++ )
- {
- //printf("arg %s\n", arg[i]);
-
- if( i == 0 )
- {
- pat = FcNameParse ((FcChar8 *) arg[i]);
+ for (i = 0; arg[i] != NULL; i++) {
+ if (i == 0) {
+ pat = FcNameParse((FcChar8 *) arg[i]);
}
- if( os == NULL )
- {
+ if (os == NULL) {
os = FcObjectSetCreate();
}
- FcObjectSetAdd (os, arg[i]);
+ FcObjectSetAdd(os, arg[i]);
}
- if( os == NULL )
- {
- os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, (char *) 0);
+ if (os == NULL) {
+ os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, (char *) 0);
}
- fs = FcFontList (0, pat, os);
+ fs = FcFontList(0, pat, os);
FcObjectSetDestroy(os);
- if( pat != NULL )
- {
+ if (pat != NULL) {
FcPatternDestroy(pat);
}
- if( fs != NULL )
- {
+ if (fs != NULL) {
int j;
- ret = malloc( (fs->nfont+1) * sizeof(font_config_t) );
+ ret = malloc((fs->nfont + 1) * sizeof(font_config_t));
- for( j = 0; j < fs->nfont ; j++ )
- {
+ 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);
+ if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
+ ret[j].path = strdup((char *) file);
}
- ret[j].flag = strdup((char *)font);
+ ret[j].flag = strdup((char *) font);
free(font);
}
@@ -98,8 +87,7 @@ void fontconfig_del_list(font_config_t *list)
{
int i;
- for( i = 0 ; list[i].path != NULL ; i++ )
- {
+ for (i = 0; list[i].path != NULL; i++) {
free(list[i].path);
free(list[i].flag);
}
@@ -112,27 +100,3 @@ int fontconfig_quit()
FcFini();
return 0;
}
-
-#ifdef TEST_FONT_CONFIG
-int fc_test_main(int argc, char **argv)
-{
- char *arg[] = {":lang=he:outline=true", "family", "style", "weight", "file", NULL};
- font_config_t *res;
- int i;
-
- fontconfig_init();
-
- res = fontconfig_find(arg);
-
- for( i = 0 ; res[i].path != NULL ; i++ )
- {
- printf("path=%s\nflag=%s\n\n", res[i].path, res[i].flag);
- }
-
- fontconfig_del_list(res);
-
- fontconfig_quit();
-
- return 0;
-}
-#endif
diff --git a/src/client/game.c b/src/client/game.c
index 8e0c30a..4ff8724 100644
--- a/src/client/game.c
+++ b/src/client/game.c
@@ -1,4 +1,3 @@
-
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
@@ -25,9 +24,9 @@
#include "radar.h"
#ifndef NO_SOUND
-# include "audio.h"
-# include "sound.h"
-# include "music.h"
+#include "audio.h"
+#include "sound.h"
+#include "music.h"
#endif
#include "world.h"
@@ -54,7 +53,7 @@ static void initGame()
audio_init();
sound_init();
music_init();
-#endif
+#endif /* NO_SOUND */
screen_init();
arena_file_init();
tux_init();
@@ -104,9 +103,9 @@ void game_quit()
sound_quit();
music_quit();
audio_quit();
-#endif
+#endif /* NO_SOUND */
- DEBUG_MSG(_("Quitting TUXANCI...\n"));
+ DEBUG_MSG(_("[Debug] Shutting down the game\n"));
exit(0);
}
diff --git a/src/client/hotKey.c b/src/client/hotKey.c
index 5b981ea..3e67edd 100644
--- a/src/client/hotKey.c
+++ b/src/client/hotKey.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -31,7 +30,7 @@ static hotKey_t *newHotKey(SDLKey key, void (*handler) ())
return new;
}
-static void destroyHotKey(hotKey_t * hotkey)
+static void destroyHotKey(hotKey_t *hotkey)
{
free(hotkey);
}
@@ -79,7 +78,7 @@ void hot_key_unregister(SDLKey key)
hotkey = findHotkey(key);
if (hotkey == NULL) {
- assert(!"This hotkey not register");
+ assert(!_("[Error] Unregisterring not registerred hotkey"));
}
my_index = list_search(listHotKey, hotkey);
@@ -94,7 +93,7 @@ void hot_key_enable(SDLKey key)
hotkey = findHotkey(key);
if (hotkey == NULL) {
- assert(!"This hotkey not register");
+ assert(!_("[Error] Enabling not registerred hotkey"));
}
lastActive = timer_get_current_time();
@@ -108,7 +107,7 @@ void hot_key_disable(SDLKey key)
hotkey = findHotkey(key);
if (hotkey == NULL) {
- assert(!"This hotkey not register");
+ assert(!_("[Error] Disabling not registerred hotkey"));
}
lastActive = timer_get_current_time();
@@ -136,7 +135,7 @@ void hot_key_event()
if (mapa[this->key] == SDL_PRESSED && this->active == TRUE) {
lastActive = timer_get_current_time();
- //printf("hotKey = %d\n", this->key);
+ /*printf("hotKey = %d\n", this->key);*/
this->handler();
return;
diff --git a/src/client/image.c b/src/client/image.c
index fa34760..4fb033a 100644
--- a/src/client/image.c
+++ b/src/client/image.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -20,13 +19,13 @@ bool_t image_is_inicialized()
}
/*
- * Inicializuje globalny zoznam obrazkov
+ * Initialization of global list of images
*/
void image_init()
{
assert(interface_is_inicialized() == TRUE);
- DEBUG_MSG(_("Initializing image database\n"));
+ DEBUG_MSG(_("[Debug] Initializing image database\n"));
listStorage = storage_new();
isImageDataInit = TRUE;
@@ -39,7 +38,6 @@ static SDL_Surface *loadImage(const char *filename, int alpha)
char str[STR_PATH_SIZE];
-
if (isFillPath(filename)) {
strcpy(str, filename);
} else {
@@ -64,7 +62,7 @@ static SDL_Surface *loadImage(const char *filename, int alpha)
}
-image_t *image_new_sdl(SDL_Surface * surface)
+image_t *image_new_sdl(SDL_Surface *surface)
{
image_t *new;
@@ -86,11 +84,11 @@ unsigned int closestpoweroftwo(unsigned int i)
{
int p;
p=0;
- while(i){
- i=i>>1;
+ while (i) {
+ i = i >> 1;
p++;
}
- return 1<<(p-0);
+ return 1 << (p - 0);
}
/* convert from SDL_Surface to image_t
@@ -98,22 +96,22 @@ unsigned int closestpoweroftwo(unsigned int i)
* surface is not needed for image_t after execution of image_new
*/
-image_t* image_new_opengl(SDL_Surface *surface)
+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
+ /* 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
+ /* we set properties of our buffer sdl_rgba_surface */
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
- bpp = 32; /*bits per pixel*/
+ bpp = 32; /* bits per pixel */
assert(surface != NULL);
@@ -121,22 +119,22 @@ image_t* image_new_opengl(SDL_Surface *surface)
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
+ /* 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_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_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
+ 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
+ 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
+ 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);
@@ -147,53 +145,43 @@ image_t* image_new_opengl(SDL_Surface *surface)
return new;
}
-#endif
+#endif /* SUPPORT_OPENGL */
-image_t* image_new(SDL_Surface *surface)
+image_t *image_new(SDL_Surface *surface)
{
#ifdef SUPPORT_OPENGL
- if( interface_is_use_open_gl() )
- {
+ if (interface_is_use_open_gl()) {
return image_new_opengl(surface);
- }
- else
- {
+ } else {
return image_new_sdl(surface);
}
-#endif
-
-#ifndef SUPPORT_OPENGL
+#else /* SUPPORT_OPENGL */
return image_new_sdl(surface);
-#endif
+#endif /* SUPPORT_OPENGL */
}
-void image_destroy(image_t * p)
+void image_destroy(image_t *p)
{
assert(p != NULL);
#ifndef SUPPORT_OPENGL
SDL_FreeSurface((SDL_Surface *) p->image);
-#endif
-
-#ifdef SUPPORT_OPENGL
- if( interface_is_use_open_gl() )
- {
+#else /* SUPPORT_OPENGL */
+ if (interface_is_use_open_gl()) {
glDeleteTextures(1, &p->tex_id);
- }
- else
- {
+ } else {
SDL_FreeSurface((SDL_Surface *) p->image);
}
-#endif
+#endif /* SUPPORT_OPENGL */
free(p);
}
/*
- * Prida obrazok do globalneho zoznamu obrazkov
- * *file - nazov suboru v ktorom je obrazok ulozeny
- * *name - nazov obrazku ( pouzije sa ako vyhadavaci retazec v zazanem )
- * alpha - 0 - nema alpha kanal | 1 - ma alpha kanal
+ * 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)
{
@@ -209,14 +197,13 @@ image_t *image_add(char *file, int alpha, char *name, char *group)
storage_add(listStorage, group, name, new);
- DEBUG_MSG(_("Loading image %s\n"), file);
+ DEBUG_MSG(_("[Debug] Loading image [%s]\n"), file);
return new;
}
/*
- * Vrati odkaz na image_data v globalnom zozname obrazkov
- * a nazvom *s
+ * Returns pointer to image with name *name in the global image list
*/
image_t *image_get(char *group, char *name)
{
@@ -241,7 +228,7 @@ void image_del_all_image_in_group(char *group)
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)
+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;
@@ -261,79 +248,75 @@ void image_draw_sdl(image_t * p, int x, int y, int px, int py, int w, int 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,
+ /* 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
+ /* 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;
+ /* 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
+ /*
+ * 2--4
+ * |\ |
+ * | \|
+ * 1--3
+ */
glBegin(GL_TRIANGLE_STRIP);
- //1
+ /* 1 */
glTexCoord2f(t_x,t_yy);
glVertex2f(d_x, d_yy);
- //2
+ /* 2 */
glTexCoord2f(t_x, t_y);
glVertex2f(d_x, d_y);
- //3
+ /* 3 */
glTexCoord2f(t_xx, t_yy);
glVertex2f(d_xx, d_yy);
- //4
+ /* 4 */
glTexCoord2f(t_xx,t_y);
glVertex2f(d_xx, d_y);
glEnd();
}
-#endif
+#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() )
- {
+ if (interface_is_use_open_gl()) {
image_draw_opengl(image, x, y, px, py, w, h);
- }
- else
- {
+ } else {
image_draw_sdl(image, x, y, px, py, w, h);
}
-#endif
-
-#ifndef SUPPORT_OPENGL
+#else /* SUPPORT_OPENGL */
image_draw_sdl(image, x, y, px, py, w, h);
-#endif
+#endif /* SUPPORT_OPENGL */
}
/*
- * Odstrani zoznam obrazkov z pamate
+ * Frees global image list
*/
void image_quit()
{
- DEBUG_MSG(_("Quitting image database\n"));
+ DEBUG_MSG(_("[Debug] Shutting down image database\n"));
storage_destroy(listStorage, image_destroy);
isImageDataInit = FALSE;
diff --git a/src/client/interface.c b/src/client/interface.c
index 53119e4..e8f1971 100644
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include "main.h"
@@ -9,20 +8,14 @@
#include "keyboardBuffer.h"
#include "hotKey.h"
-// window surface
-static SDL_Surface *screen;
-//static SDL_Surface *my_surface;
-
-// timer
-static SDL_TimerID timer;
-// window flags
-static Uint32 g_win_flags;
+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;
-
-// flag, kterym se ridi zarazovani klaves do bufferu
-static bool_t keyboardBufferEnabled = 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()
@@ -63,20 +56,21 @@ void interface_disable_keyboard_buffer()
void hotkey_screen()
{
- if (g_win_flags & SDL_FULLSCREEN)
+ if (g_win_flags & SDL_FULLSCREEN) {
g_win_flags &= ~SDL_FULLSCREEN;
- else
+ } else {
g_win_flags |= SDL_FULLSCREEN;
+ }
if (SDL_WM_ToggleFullScreen(screen) == 0) {
- fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
+ fprintf(stderr, _("[Error] Unable to switch to the fullscreen mode\n"));
SDL_FreeSurface(screen);
screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP, g_win_flags);
if (screen == NULL) {
- fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"),
- SDL_GetError());
+ fprintf(stderr, _("[Error] Unable to switch to the window mode: %s\n"),
+ SDL_GetError());
return;
}
}
@@ -86,7 +80,7 @@ void hotkey_screen()
/*
* Sets video mode and sets up OpenGL for this change
*/
-SDL_Surface * SetVideoMode(int width, int height, int bpp, Uint32 flags)
+SDL_Surface *SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
SDL_Surface *rval = 0;
@@ -102,13 +96,13 @@ SDL_Surface * SetVideoMode(int width, int height, int bpp, Uint32 flags)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifdef SDL_GL_SWAP_CONTROL
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
-#endif
+#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);
+ glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -118,16 +112,15 @@ SDL_Surface * SetVideoMode(int width, int height, int bpp, Uint32 flags)
return rval;
}
-#endif
+#endif /* SUPPORT_OPENGL */
int interface_init()
{
-#ifdef DEBUG
- DEBUG_MSG(_("Initializing SDL system\n"));
-#endif
- // initialization of SDL
+ DEBUG_MSG(_("[Debug] Initializing SDL\n"));
+
+ /* initialization of SDL */
if (SDL_Init(SDL_SUBSYSTEMS) == -1) {
- fprintf(stderr, "SDL_Init %s\n", SDL_GetError());
+ fprintf(stderr, _("[Error] Unable to initialize SDL: %s\n"), SDL_GetError());
SDL_Quit();
return -1;
}
@@ -137,42 +130,38 @@ int interface_init()
g_win_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
-#endif
-
-#ifdef SUPPORT_OPENGL
- use_open_gl = ! isParamFlag("--disable-opengl");
+#else /* SUPPORT_OPENGL */
+ use_open_gl = !isParamFlag("--disable-opengl");
- if( interface_is_use_open_gl() )
- {
+ 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 )
- {
+ 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
- {
+ } else {
g_win_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags);
}
-#endif
+#endif /* SUPPORT_OPENGL */
if (screen == NULL) {
- fprintf(stderr, "SDL_SetVideoMode %s\n", SDL_GetError());
+ fprintf(stderr, _("[Error] Unable to create interface: %s\n"), SDL_GetError());
SDL_Quit();
return -1;
}
- // Enable unicode by default for keyboard support.
- // It is bit more consuming than the nonsdl but can draw more characters.
+ /*
+ * enable unicode by default for keyboard support - it is bit more
+ * consuming than the nonsdl but can draw more characters
+ */
SDL_EnableUNICODE(1);
SDL_WM_SetCaption(WINDOW_TITLE, NULL);
- // Keyboard repeating
+ /* keyboard repeating */
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
@@ -189,7 +178,7 @@ int interface_init()
SDL_Surface *interface_get_screen()
{
- //return my_surface;
+ /*return my_surface;*/
return screen;
}
@@ -197,18 +186,13 @@ void interface_refresh()
{
#ifndef SUPPORT_OPENGL
SDL_Flip(screen);
-#endif
-
-#ifdef SUPPORT_OPENGL
- if( interface_is_use_open_gl() )
- {
+#else /* SUPPORT_OPENGL */
+ if (interface_is_use_open_gl()) {
SDL_GL_SwapBuffers();
- }
- else
- {
+ } else {
SDL_Flip(screen);
}
-#endif
+#endif /* SUPPORT_OPENGL */
}
void interface_get_mouse_position(int *x, int *y)
@@ -245,7 +229,7 @@ void printPressAnyKey()
for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++)
if (mapa[i] == SDL_PRESSED) {
- printf(_("Pressed key with SDL value: %d\n"), i);
+ printf(_("[Debug] Pressed key [SDL: %d]\n"), i);
}
}
@@ -258,33 +242,29 @@ int hack_slow()
currentTime = timer_get_current_time();
- if( lastTime == 0 )
- {
+ if (lastTime == 0) {
lastTime = currentTime;
return 0;
}
- //printf("DEBUG: time interval %d\n", currentTime - lastTime);
+ /*printf("DEBUG: time interval %d\n", currentTime - lastTime);*/
- if( isSlowHack == FALSE && currentTime - lastTime >= 100 )
- {
- //printf("start slow hack (%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);
+ 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);
+ if (isSlowHack == TRUE) {
+ /*printf("hack time interval %d\n", currentTime - lastTime);*/
}
lastTime = timer_get_current_time();
@@ -296,59 +276,56 @@ int eventAction()
{
SDL_Event event;
-
while (SDL_WaitEvent(&event)) {
switch (event.type) {
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- default:
- //neni potreba vyuzivat frontu stale
- 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;
+ 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;
}
-
- screen_draw();
- screen_event();
- hot_key_event();
- screen_switch();
break;
- default:
+ case SDL_USEREVENT:
+ switch (event.user.code) {
+ case USR_EVT_TIMER:
+ if (hack_slow()) {
+ break;
+ }
+
+ screen_draw();
+ screen_event();
+ hot_key_event();
+ screen_switch();
+ break;
+
+ default:
+ break;
+ }
break;
- }
- break;
-
- // change of window size
- case SDL_VIDEORESIZE:
- screen =
- SDL_SetVideoMode(event.resize.w, event.resize.h, WIN_BPP,
- g_win_flags);
-
- if (screen == NULL) {
- fprintf(stderr,
- _("Unable to change WINDOW resolution! Error: %s\n"),
+
+ /* change the window size */
+ case SDL_VIDEORESIZE:
+ screen = SDL_SetVideoMode(event.resize.w, event.resize.h,
+ WIN_BPP, g_win_flags);
+
+ if (screen == NULL) {
+ fprintf(stderr, _("[Error] Unable to change resolution of the window: %s\n"),
SDL_GetError());
- return 0;
- }
- break;
+ return 0;
+ }
+ break;
- // termination request
- case SDL_QUIT:
- return -1;
- break;
+ /* termination request */
+ case SDL_QUIT:
+ return -1;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -358,14 +335,15 @@ int eventAction()
void interface_event()
{
while (1) {
- if (eventAction() == -1)
+ if (eventAction() == -1) {
return;
+ }
}
}
void interface_quit()
{
- DEBUG_MSG(_("Quitting SDL\n"));
+ DEBUG_MSG(_("[Debug] Shutting down SDL\n"));
hot_key_quit();
keyboard_buffer_quit();
diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c
index 7a694f3..8849414 100644
--- a/src/client/keyboardBuffer.c
+++ b/src/client/keyboardBuffer.c
@@ -1,13 +1,3 @@
-/*
- * keyboardBuffer.c
- *
- * Created on: 1. 8. 2008
- * Author: Karel Podvolecky
- *
- * Simple front of pressed keys.
- *
- */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -21,7 +11,8 @@ static keyboardBuffer_t *keyboardBuffer = NULL;
static SDL_keysym emptyKey;
/*
- * Key buffer initializes. The parameter sets the number of keys.
+ * Key buffer initialization
+ * the parameter sets the number of keys
*/
void keyboard_buffer_init(int size)
{
@@ -66,7 +57,7 @@ bool_t keyboard_buffer_push(SDL_keysym key)
assert(keyboardBuffer != NULL);
if (keyboardBuffer->count >= keyboardBuffer->size) {
- fprintf(stderr, _("Keyboard Buffer overrun! Dropping key: %02x\n"), key.sym);
+ fprintf(stderr, _("[Error] Keyboard buffer overrun - dropping the key [%02x]\n"), key.sym);
return FALSE;
}
@@ -91,7 +82,7 @@ SDL_keysym keyboard_buffer_pop()
assert(keyboardBuffer != NULL);
if (keyboardBuffer->count <= 0) {
- fprintf(stderr, _("Keyboard Buffer underrun!\n"));
+ fprintf(stderr, _("[Error] Keyboard buffer underrun\n"));
return emptyKey;
}
@@ -142,7 +133,7 @@ void keyboard_buffer_quit()
assert(keyboardBuffer != NULL);
if (keyboardBuffer->count > 0) {
- fprintf(stderr, _("Keyboard buffer is not empty!\n"));
+ fprintf(stderr, _("[Warning] Shutting down non-empty keyboard buffer\n"));
}
free(keyboardBuffer->buff);
diff --git a/src/client/layer.c b/src/client/layer.c
index 4ec1a30..22c037d 100644
--- a/src/client/layer.c
+++ b/src/client/layer.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include <assert.h>
@@ -22,7 +21,7 @@ bool_t layer_is_inicialized()
}
/*
- * Initializes global list of the layers
+ * Initialize global list of the layers
*/
void layer_init()
{
@@ -37,9 +36,9 @@ void layer_init()
* 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 tuxanci | 1 - same as tuxanci | 2 - over tuxancami)
+ * [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)
+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;
@@ -59,19 +58,19 @@ void addLayer(image_t * img, int x, int y, int px, int py, int w, int h, int pla
new->layer = player;
new->image = img;
- new_value = player*WINDOW_SIZE_Y + y + h;
+ new_value = player * WINDOW_SIZE_Y + y + h;
- // here we are sure, that we want to insert it somewhere else than the begining
+ /* 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;
+ 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);
}
@@ -91,7 +90,7 @@ void layer_draw_all()
image_draw(this->image, this->x, this->y, this->px, this->py, this->w, this->h);
}
- //printf("listLayer->count = %d\n", listLayer->count);
+ /*printf("listLayer->count = %d\n", listLayer->count);*/
list_destroy_item(listLayer, free);
listLayer = list_new();
@@ -102,7 +101,7 @@ void layer_draw_center(int x, int y)
layer_t *this;
int screen_x, screen_y;
int i;
- //int count = 0;
+ /*int count = 0;*/
arena_get_center_screen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
@@ -115,15 +114,15 @@ void layer_draw_center(int x, int y)
this->y > screen_y + WINDOW_SIZE_Y) {
continue;
}
- //count++;
+ /*count++;*/
image_draw(this->image, this->x - screen_x, this->y - screen_y,
- this->px, this->py, this->w, this->h);
+ this->px, this->py, this->w, this->h);
- //printf("%d %d\n", this->x - screen_x, this->y - screen_y);
+ /*printf("%d %d\n", this->x - screen_x, this->y - screen_y);*/
}
- //printf("count = %d\n", count);
+ /*printf("count = %d\n", count);*/
list_destroy_item(listLayer, free);
listLayer = list_new();
@@ -133,7 +132,7 @@ 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;
+ /*int count = 0;*/
for (i = 0; i < listLayer->count; i++) {
this = (layer_t *) listLayer->list[i];
@@ -143,7 +142,7 @@ void layer_draw_slpit(int local_x, int local_y, int x, int y, int w, int h)
continue;
}
- //count++;
+ /*count++;*/
if (local_x + (this->x - x) < local_x) {
int z;
@@ -176,10 +175,10 @@ void layer_draw_slpit(int local_x, int local_y, int x, int y, int w, int 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("%d %d\n", this->x - screen_x, this->y - screen_y);*/
}
- //printf("count = %d\n", count);
+ /*printf("count = %d\n", count);*/
list_destroy_item(listLayer, free);
listLayer = list_new();
diff --git a/src/client/panel.c b/src/client/panel.c
index 634cd2d..43dab1a 100644
--- a/src/client/panel.c
+++ b/src/client/panel.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <assert.h>
@@ -71,7 +70,7 @@ 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)
+static void shot_drawInfo(tux_t *tux, int x, int y)
{
int i;
@@ -92,17 +91,17 @@ static void shot_drawInfo(tux_t * tux, int x, int y)
}
}
-static void drawGunInfo(tux_t * tux, int x, int 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)
+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)
+static void drawGrafBonus(tux_t *tux, int x, int y)
{
int offset;
@@ -111,7 +110,7 @@ static void drawGrafBonus(tux_t * tux, int x, int y)
image_draw(g_bonus, x + 1, y, 0, g_bonus->h / 2, offset, g_bonus->h / 2);
}
-static void tux_drawRight(tux_t * tux)
+static void tux_drawRight(tux_t *tux)
{
if (tux == NULL) {
return;
@@ -126,7 +125,7 @@ static void tux_drawRight(tux_t * tux)
}
}
-static void tux_drawLeft(tux_t * tux)
+static void tux_drawLeft(tux_t *tux)
{
if (tux == NULL) {
return;
@@ -141,13 +140,13 @@ static void tux_drawLeft(tux_t * tux)
}
}
-void panel_draw(tux_t * tux_right, tux_t * tux_left)
+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 msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE);
+ font_draw(_("Recived new chat message"), PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE);
}
tux_drawRight(tux_right);
diff --git a/src/client/pauza.c b/src/client/pauza.c
index 251c753..61f80ea 100644
--- a/src/client/pauza.c
+++ b/src/client/pauza.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -41,9 +40,9 @@ 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);
+ WINDOW_SIZE_X / 2 - g_pauza->w / 2,
+ WINDOW_SIZE_Y / 2 - g_pauza->h / 2,
+ 0, 0, g_pauza->w, g_pauza->h);
}
}
diff --git a/src/client/radar.c b/src/client/radar.c
index 5770cf0..e8457e9 100644
--- a/src/client/radar.c
+++ b/src/client/radar.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -34,7 +33,7 @@ static radar_item_t *newRadarItem(int id, int x, int y, int type)
return new;
}
-static void destroyRadarItem(radar_item_t * p)
+static void destroyRadarItem(radar_item_t *p)
{
assert(p != NULL);
free(p);
@@ -85,7 +84,7 @@ void radar_init()
listRadar = list_new();
}
-void radar_draw(arena_t * arena)
+void radar_draw(arena_t *arena)
{
int i;
@@ -103,7 +102,7 @@ void radar_draw(arena_t * arena)
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);
+ 2 * thisRadarItem->type, RADAR_SIZE_Y + 2, 2, 2);
}
}
}
diff --git a/src/client/saveDialog.c b/src/client/saveDialog.c
index 81133e7..b9ee758 100644
--- a/src/client/saveDialog.c
+++ b/src/client/saveDialog.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include <assert.h>
@@ -66,23 +65,22 @@ void save_dialog_init()
g_background = image_get(IMAGE_GROUP_BASE, "screen_main");
- widgetLabelMsg = label_new("name", SAVE_DIALOG_LOCATIN_X + 20,
- SAVE_DIALOG_LOCATIN_Y + 20,
- WIDGET_LABEL_LEFT);
+ widgetLabelMsg = label_new(_("Save as:"), SAVE_DIALOG_LOCATIN_X + 20,
+ SAVE_DIALOG_LOCATIN_Y + 20,
+ WIDGET_LABEL_LEFT);
- widgetTextFieldName = text_field_new("noname", WIDGET_TEXTFIELD_FILTER_ALPHANUM,
- widgetLabelMsg->x +
- widgetLabelMsg->w + 10,
- widgetLabelMsg->y);
+ 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);
+ 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);
+ 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);
}
@@ -98,13 +96,12 @@ void save_dialog_draw()
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);
+ 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);
diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c
index ccb589a..f7970e5 100644
--- a/src/client/saveLoad.c
+++ b/src/client/saveLoad.c
@@ -1,4 +1,3 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -19,25 +18,25 @@
#include "choiceArena.h"
#include "world.h"
-static void action_saveTux(space_t * space, tux_t * tux, textFile_t * textFile)
+static void action_saveTux(space_t *space, tux_t *tux, textFile_t *textFile)
{
char str[STR_PROTO_SIZE];
UNUSED(space);
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);
+ "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)
+static void action_saveShot(space_t *space, shot_t *shot, textFile_t *textFile)
{
char str[STR_PROTO_SIZE];
@@ -51,26 +50,26 @@ static void action_saveShot(space_t * space, shot_t * shot, textFile_t * textFil
list_add(textFile->text, strdup(str));
}
-static void action_saveItem(space_t * space, item_t * item, textFile_t * textFile)
+static void action_saveItem(space_t *space, item_t *item, textFile_t *textFile)
{
char str[STR_PROTO_SIZE];
UNUSED(space);
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);
+ 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)
+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);
+ arena_file_get_net_name(choice_arena_get()),
+ arena->countRound, arena->max_countRound);
list_add(textFile->text, strdup(str));
@@ -79,14 +78,14 @@ static void saveContextArenaToTextFile(textFile_t * textFile, arena_t * arena)
space_action(arena->spaceItem, action_saveItem, textFile);
}
-void save_arena(char *filename, arena_t * arena)
+void save_arena(char *filename, arena_t *arena)
{
textFile_t *textFile;
char path[STR_PATH_SIZE];
sprintf(path, "%s/%s.sav", home_director_get(), filename);
- DEBUG_MSG(_("Saving game to: \"%s\"\n"), path);
+ DEBUG_MSG(_("[Debug] Saving game [%s]\n"), path);
textFile = text_file_new(path);
@@ -95,7 +94,7 @@ void save_arena(char *filename, arena_t * arena)
text_file_save(textFile);
text_file_destroy(textFile);
} else {
- fprintf(stderr, _("I was unable to save: \"%s\"\n"), path);
+ fprintf(stderr, _("[Error] Unable to save game [%s]\n"), path);
}
}
@@ -118,7 +117,7 @@ static arena_t *load_arenaFromLine(char *line)
return arena;
}
-static void loadTuxFromLine(char *line, arena_t * arena)
+static void loadTuxFromLine(char *line, arena_t *arena)
{
char cmd[STR_PROTO_SIZE];
char name[STR_NAME_SIZE];
@@ -129,10 +128,10 @@ static void loadTuxFromLine(char *line, arena_t * arena)
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);
+ "%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);
@@ -172,15 +171,15 @@ static void loadTuxFromLine(char *line, arena_t * arena)
tux->pickup_time = time2;
}
-static void loadShotFromLine(char *line, arena_t * arena)
+static void loadShotFromLine(char *line, arena_t *arena)
{
char cmd[STR_PROTO_SIZE];
int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor;
shot_t *shot;
sscanf(line, "%s %d %d %d %d %d %d %d %d %d",
- cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id,
- &isCanKillAuthor);
+ cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id,
+ &isCanKillAuthor);
shot = shot_new(x, y, px, py, gun, author_id);
@@ -195,14 +194,14 @@ static void loadShotFromLine(char *line, arena_t * arena)
space_add(arena->spaceShot, shot);
}
-static void loadItemFromLine(char *line, arena_t * arena)
+static void loadItemFromLine(char *line, arena_t *arena)
{
char cmd[STR_PROTO_SIZE];
int id, type, x, y, count, frame, author_id, check_id;
item_t *item;
sscanf(line, "%s %d %d %d %d %d %d %d %d",
- cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
+ cmd, &id, &type, &x, &y, &count, &frame, &author_id, &check_id);
item = item_new(x, y, type, author_id);
@@ -213,7 +212,7 @@ static void loadItemFromLine(char *line, arena_t * arena)
space_add(arena->spaceItem, item);
}
-static arena_t *loadContextArenaFromTextFile(textFile_t * textFile)
+static arena_t *loadContextArenaFromTextFile(textFile_t *textFile)
{
arena_t *arena;
int i;
@@ -252,7 +251,7 @@ void load_arena(char *filename)
sprintf(path, "%s/%s", home_director_get(), filename);
- DEBUG_MSG(_("Loadig game from file: \"%s\"\n"), path);
+ DEBUG_MSG(_("[Debug] Loading arena [%s]\n"), path);
textFile = text_file_load(path);
@@ -260,6 +259,6 @@ void load_arena(char *filename)
loadContextArenaFromTextFile(textFile);
text_file_destroy(textFile);
} else {
- fprintf(stderr, _("Unable to load save: \"%s\"\n"), path);
+ fprintf(stderr, _("[Error] Unable to load saved game [%s]\n"), path);
}
}
diff --git a/src/client/screen.c b/src/client/screen.c
index d4b7289..2e8822d 100644
--- a/src/client/screen.c
+++ b/src/client/screen.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include <assert.h>
@@ -10,7 +9,7 @@
#include "layer.h"
#include "myTimer.h"
-//#define DEBUG_TIME_DRAW
+/*#define DEBUG_TIME_DRAW*/
static screen_t *currentScreen;
static screen_t *futureScreen;
@@ -25,7 +24,7 @@ bool_t screen_is_inicialized()
}
screen_t *screen_new(char *name, void (*fce_start) (), void (*fce_event) (),
- void (*fce_draw) (), void (*fce_stop) ())
+ void (*fce_draw) (), void (*fce_stop) ())
{
screen_t *new;
@@ -45,7 +44,7 @@ screen_t *screen_new(char *name, void (*fce_start) (), void (*fce_event) (),
return new;
}
-void screen_destroy(screen_t * p)
+void screen_destroy(screen_t *p)
{
assert(p != NULL);
@@ -53,11 +52,11 @@ void screen_destroy(screen_t * p)
free(p);
}
-void screen_register(screen_t * p)
+void screen_register(screen_t *p)
{
assert(p != NULL);
- DEBUG_MSG(_("Registering screen: \"%s\"\n"), p->name);
+ DEBUG_MSG(_("[Debug] Registering screen [%s]\n"), p->name);
list_add(listScreen, p);
}
@@ -78,7 +77,7 @@ static screen_t *findScreen(char *name)
int i;
for (i = 0; i < listScreen->count; i++) {
- this = (screen_t *) (listScreen->list[i]);
+ this = (screen_t *) listScreen->list[i];
assert(this != NULL);
if (strcmp(name, this->name) == 0) {
@@ -104,16 +103,14 @@ void screen_switch()
layer_flush();
if (currentScreen != NULL) {
- DEBUG_MSG(_("Stopping screen: \"%s\"\n"), currentScreen->name);
+ DEBUG_MSG(_("[Debug] Stopping screen [%s]\n"), currentScreen->name);
currentScreen->fce_stop();
}
currentScreen = futureScreen;
futureScreen = NULL;
- //printf("switch screen %s..\n", currentScreen->name);
-
- DEBUG_MSG(_("Starting screen: \"%s\"\n"), currentScreen->name);
+ DEBUG_MSG(_("[Debug] Starting screen [%s]\n"), currentScreen->name);
currentScreen->fce_start();
}
@@ -145,7 +142,7 @@ void screen_draw()
my_time_t prev;
prev = timer_get_current_timeMicro();
-#endif
+#endif /* DEBUG_TIME_DRAW */
currentScreen->fce_draw();
@@ -153,7 +150,7 @@ void screen_draw()
#ifdef DEBUG_TIME_DRAW
printf("c draw time = %d\n", timer_get_current_timeMicro() - prev);
-#endif
+#endif /* DEBUG_TIME_DRAW */
}
}
@@ -161,22 +158,12 @@ void screen_draw()
void screen_event()
{
assert(currentScreen != NULL);
-#if 0
- static my_time_t last = 0;
-
- if( last == 0 )
- {
- last = timer_get_current_time();
- }
- printf("%d\n", timer_get_current_time()-last);
- last = timer_get_current_time();
-#endif
currentScreen->fce_event();
#ifdef DEBUG_TIME_EVENT
printf("c event time = %d\n", timer_get_current_timeMicro() - prev);
-#endif
+#endif /* DEBUG_TIME_EVENT */
}
void screen_quit()
diff --git a/src/client/term.c b/src/client/term.c
index 2dd6ea5..876f303 100644
--- a/src/client/term.c
+++ b/src/client/term.c
@@ -1,4 +1,3 @@
-
#include <stdlib.h>
#include <assert.h>
@@ -48,7 +47,7 @@ static char *getStrGun(int gun)
return "none";
}
- return "gun_unknow";
+ return "gun_unknown";
}
static char *getStrBonus(int bonus)
@@ -63,17 +62,17 @@ static char *getStrBonus(int bonus)
case BONUS_GHOST:
return "ghost";
case BONUS_4X:
- return "4X";
+ return "4";
case BONUS_HIDDEN:
return "hidden";
default:
return "none";
}
- return "bonus_unknow";
+ return "bonus_unknown";
}
-static void action_refreshTerm(space_t * space, tux_t * tux, void *p)
+static void action_refreshTerm(space_t *space, tux_t *tux, void *p)
{
char str[STR_SIZE];
@@ -81,13 +80,13 @@ static void action_refreshTerm(space_t * space, tux_t * tux, void *p)
UNUSED(p);
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)
+ "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));
@@ -104,7 +103,7 @@ static void refreshTerm()
space_action(arena->spaceTux, action_refreshTerm, NULL);
- //printf("refresh term..\n");
+ /*printf("refresh term..\n");*/
}
void term_draw()