diff options
57 files changed, 202 insertions, 212 deletions
diff --git a/src/audio/audio.c b/src/audio/audio.c index 9b6d9fc..8e224fd 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -25,15 +25,15 @@ void audio_init() return; } - DEBUG_MSG(_("[Debug] Initializing audio\n")); + debug("Initializing audio"); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { - fprintf(stderr, _("[Error] Unable to initialize audio: %s\n"), SDL_GetError()); + error("Unable to initialize audio: %s", SDL_GetError()); return; } if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) == -1) { - fprintf(stderr, _("[Error] Unable to create proper audio settings: %s\n"), Mix_GetError()); + error("Unable to create proper audio settings: %s", Mix_GetError()); return; } @@ -48,7 +48,7 @@ void audio_init() */ void audio_quit() { - DEBUG_MSG(_("[Debug] Shutting down audio\n")); + debug("Shutting down audio"); Mix_CloseAudio(); isAudioInit = TRUE; diff --git a/src/audio/music.c b/src/audio/music.c index 90dd321..9834630 100644 --- a/src/audio/music.c +++ b/src/audio/music.c @@ -33,7 +33,7 @@ void music_init() return; } - DEBUG_MSG(_("[Debug] Initializing music\n")); + debug("Initializing music"); listStorage = storage_new(); currentMusic = NULL; @@ -55,7 +55,7 @@ static Mix_Music *loadMixMusic(char *file) Mix_Music *mixer; char str[STR_PATH_SIZE]; - DEBUG_MSG(_("[Debug] Loading music [%s]\n"), file); + debug("Loading music [%s]", file); if (isFillPath(file)) { strcpy(str, file); @@ -68,7 +68,7 @@ static Mix_Music *loadMixMusic(char *file) mixer = Mix_LoadMUS(str); if (mixer == NULL) { - fprintf(stderr, _("[Error] Unable to load music [%s]\n"), file); + error("Unable to load music [%s]", file); return NULL; } @@ -122,7 +122,7 @@ void music_stop() } if (currentMusic != NULL) { - DEBUG_MSG(_("[Debug] Stopping playing music\n")); + debug("Stopping playing music"); Mix_HaltMusic(); currentMusic = NULL; @@ -163,7 +163,7 @@ void music_play(char *name, char *group) strcpy(currentMusic_name, name); if (currentMusic != NULL) { - DEBUG_MSG(_("[Debug] Playing music [%s]\n"), name); + debug("Playing music [%s]", name); playMixMusic(); } @@ -224,7 +224,7 @@ void music_quit() return; } - DEBUG_MSG(_("[Debug] Shutting down music\n")); + debug("Shutting down music"); music_stop(); storage_destroy(listStorage, destroyMusic); diff --git a/src/audio/sound.c b/src/audio/sound.c index f45ed80..79a152d 100644 --- a/src/audio/sound.c +++ b/src/audio/sound.c @@ -31,7 +31,7 @@ void sound_init() return; } - DEBUG_MSG(_("[Debug] Initializing sound\n")); + debug("Initializing sound"); listStorage = storage_new(); isSoundInit = TRUE; @@ -52,14 +52,14 @@ static Mix_Chunk *loadMixSound(char *file) Mix_Chunk *new; char str[STR_PATH_SIZE]; - DEBUG_MSG(_("[Debug] Loading sound [%s]\n"), file); + debug("Loading sound [%s]", file); sprintf(str, PATH_SOUND "%s", file); accessExistFile(str); new = Mix_LoadWAV(str); if (new == NULL) { - fprintf(stderr, _("[Error] Unable to load sound [%s]: %s\n"), str, Mix_GetError()); + error("Unable to load sound [%s]: %s", str, Mix_GetError()); return NULL; } @@ -72,7 +72,7 @@ static Mix_Chunk *loadMixSound(char *file) static void playMixSound(Mix_Chunk *p) { if (Mix_PlayChannel(-1, p, 0) == -1) { - fprintf(stderr, _("[Error] Unable to play sound: %s\n"), Mix_GetError()); + error("Unable to play sound: %s", Mix_GetError()); return; } } @@ -141,7 +141,7 @@ void sound_quit() return; } - DEBUG_MSG(_("[Debug] Shutting down sound\n")); + debug("Shutting down sound"); storage_destroy(listStorage, destroySound); isSoundInit = FALSE; diff --git a/src/base/archive.c b/src/base/archive.c index 30956a0..5e2c25a 100644 --- a/src/base/archive.c +++ b/src/base/archive.c @@ -29,20 +29,20 @@ char *archive_extract_file(char *archive, char *filename) zipArchive = zip_open(archive, 0, &err); if (zipArchive == NULL) { - fprintf(stderr, _("[Error] Unable to open archive [%s]\n"), archive); + error("Unable to open archive [%s]", archive); return NULL; } zipFile = zip_fopen(zipArchive, filename, ZIP_FL_UNCHANGED); if (zipFile == NULL) { - fprintf(stderr, _("[Error] Unable to extract the file [%s] from archive [%s]\n"), filename, archive); + error("Unable to extract the file [%s] from archive [%s]", filename, archive); zip_close(zipArchive); return NULL; } if ((file = fopen(name, "wb")) == NULL) { - fprintf(stderr, _("[Error] Unable to create temporary file [%s]\n"), name); + error("Unable to create temporary file [%s]", name); zip_fclose(zipFile); zip_close(zipArchive); return NULL; diff --git a/src/base/arena.c b/src/base/arena.c index e26eb6c..89b8e05 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -68,12 +68,12 @@ void arena_init() if (getParam("--split-vertical")) { splitType = SCREEN_SPLIT_VERTICAL; - printf(_("[Debug] Set vertical screen splitting\n")); + debug("Set vertical screen splitting"); } if (getParam("--split-horizontal")) { splitType = SCREEN_SPLIT_HORIZONTAL; - printf(_("[Debug] Set horizontal screen splitting\n")); + debug("Set horizontal screen splitting"); } hot_key_register(SDLK_F3, hotkey_splitArena); @@ -268,7 +268,7 @@ static void drawSplitArenaForTux(arena_t *arena, tux_t *tux, int location_x, int default: screen_x = -1; screen_y = -1; - assert(!_("[Error] Unknown method of splitting the screen")); + fatal("Unknown method of splitting the screen"); break; } @@ -285,7 +285,7 @@ static void drawSplitArenaForTux(arena_t *arena, tux_t *tux, int location_x, int default: screen_x = -1; screen_y = -1; - assert(!_("[Error] Unknown method of splitting the screen")); + fatal("Unknown method of splitting the screen"); break; } } diff --git a/src/base/arenaFile.c b/src/base/arenaFile.c index da2d09f..e5a17ae 100644 --- a/src/base/arenaFile.c +++ b/src/base/arenaFile.c @@ -128,7 +128,7 @@ static void cmd_arena(arena_t **arena, char *line) */ arena_set_current(*arena); - DEBUG_MSG(_("[Debug] Arena loaded\n")); + debug("Arena loaded"); } static void cmd_module_load(char *line) @@ -354,11 +354,11 @@ static void load_arenaFromDirector(char *director) director_t *p; int i; - DEBUG_MSG(_("[Debug] Loading arena files [%s]\n"), director); + debug("Loading arena files [%s]", director); p = director_load(director); if (p == NULL) { - fprintf(stderr, _("[Error] Directory not found [%s]\n"), director); + error("Directory not found [%s]", director); exit(-1); } @@ -376,7 +376,7 @@ static void load_arenaFromDirector(char *director) sprintf(path, "%s/%s", director, line); } - DEBUG_MSG(_("[Debug] Loading arena [%s]\n"), line); + debug("Loading arena [%s]", line); accessExistFile(path); arena_file_load(path); diff --git a/src/base/checkFront.c b/src/base/checkFront.c index a8218de..999eb58 100644 --- a/src/base/checkFront.c +++ b/src/base/checkFront.c @@ -87,7 +87,7 @@ void check_front_event(client_t *client) } break; default: - assert(!_("[Error] Wrong type of the event front")); + fatal("Wrong type of the event front"); break; } } diff --git a/src/base/downServer.c b/src/base/downServer.c index 3015214..5556fc6 100644 --- a/src/base/downServer.c +++ b/src/base/downServer.c @@ -123,7 +123,7 @@ int down_server_init(char *ip4, int port4) sock_server_tcp = sock_tcp_bind(ip4, port4); if (sock_server_tcp == NULL) { - fprintf(stderr, _("[Error] Unable to initialize download server\n")); + error("Unable to initialize download server"); return -1; } diff --git a/src/base/gun.c b/src/base/gun.c index d0bfe86..9c59662 100644 --- a/src/base/gun.c +++ b/src/base/gun.c @@ -47,7 +47,7 @@ static void modificiationCopuse(int courser, int right_x, int right_y, int *dest *dest_y = right_x; break; default: - assert(!_("[Debug] Wrong Tux course change")); + fatal("Wrong Tux course change"); break; } } diff --git a/src/base/homeDirector.c b/src/base/homeDirector.c index f0083ba..c9daf3d 100644 --- a/src/base/homeDirector.c +++ b/src/base/homeDirector.c @@ -18,21 +18,21 @@ void home_director_create() envHome = getenv("USERPROFILE"); #endif /* __WIN32__ */ if (envHome == NULL) { - fprintf(stderr, _("[Error] Environment variable HOME not found\n")); + error("Environment variable HOME not found"); exit(0); } sprintf(homeDirector, "%s/%s", envHome, HOMEDIRECTOR_NAME); if (access(homeDirector, F_OK) != 0) { - DEBUG_MSG(_("[Debug] Creating home directory [%s]\n"), homeDirector); + debug("Creating home directory [%s]", homeDirector); #ifndef __WIN32__ if (mkdir(homeDirector, 0755) != 0) { #else /* __WIN32__ */ if (mkdir(homeDirector) != 0) { #endif /* __WIN32__ */ - fprintf(stderr, _("[Error] Unable to create home directory [%s]\n"), homeDirector); + error("Unable to create home directory [%s]", homeDirector); exit(0); } } diff --git a/src/base/idManager.c b/src/base/idManager.c index dea2e95..87042bb 100644 --- a/src/base/idManager.c +++ b/src/base/idManager.c @@ -34,7 +34,7 @@ static void destroyIdItem(id_item_t *p) void id_init_list() { - DEBUG_MSG(_("[Debug] Initializing ID manager\n")); + debug("Initializing ID manager"); listID = list_new(); lastID = 0; @@ -67,7 +67,7 @@ static int findNewID() assert(listID != NULL); if (listID->count >= MAX_ID - 1) { - assert(!_("[Error] There is no free ID left")); + fatal("There is no free ID left"); } do { @@ -106,7 +106,7 @@ void id_inc(int id) index = id_is_register(id); if (index == -1) { - fprintf(stderr, _("[Error] Trying to increment counter of never registered ID [%d]"), id); + error("Trying to increment counter of never registered ID [%d]", id); assert(0); return; /* ha ha ha */ } @@ -129,7 +129,7 @@ void id_del(int id) index = id_is_register(id); if (index == -1) { - fprintf(stderr, _("[Error] Trying to delete never registered ID [%d]"), id); + error("Trying to delete never registered ID [%d]", id); assert(0); return; /* ha ha ha */ } @@ -177,21 +177,21 @@ void infoID(int id) index = id_is_register(id); if (index == -1) { - DEBUG_MSG(_("[Debug] Getting information of nonexistent ID [%d]\n"), id); + debug("Getting information of nonexistent ID [%d]", id); return; } this = listID->list[index]; - DEBUG_MSG(_("[Debug] ID information [%d]: used %d times\n"), this->id, this->count); + debug("ID information [%d]: used %d times", this->id, this->count); return; } void id_quit_list() { - DEBUG_MSG(_("[Debug] Shutting down ID manager\n")); + debug("Shutting down ID manager"); assert(listID != NULL); list_destroy_item(listID, destroyIdItem); diff --git a/src/base/index.c b/src/base/index.c index 6683ec8..1620591 100644 --- a/src/base/index.c +++ b/src/base/index.c @@ -23,14 +23,14 @@ static index_item_t *index_item_new(int key, void *data) #ifdef DEBUG_INDEX static void printIndexItem(index_item_t *p) { - printf(_("[Debug] Index [%d] contains: %p\n"), p->key, p->data); + debug("Index [%d] contains: %p", p->key, p->data); } static void printListIndexItem(list_t *list) { int i; - printf(_("List:\n")); + debug("List:"); for (i = 0; i < list->count; i++) { index_item_t *this; @@ -60,7 +60,7 @@ static void checkList(list_t *list) if (prev >= this) { printListIndexItem(list); - assert(!_("Error")); + fatal("Error in list"); } prev = this; @@ -100,10 +100,10 @@ void index_add(list_t *list, int key, void *data) #ifdef DEBUG_INDEX if (++count == len * 5) { - printf(_("[Error] Cyclic error\n")); + error("Cyclic error"); printIndexItem(item); printListIndexItem(list); - assert(0); + abort(0); } #endif /* DEBUG_INDEX */ diff --git a/src/base/main.c b/src/base/main.c index d854a33..cfd13af 100644 --- a/src/base/main.c +++ b/src/base/main.c @@ -99,8 +99,8 @@ int *newInt(int x) void accessExistFile(const char *s) { if (access(s, F_OK) != 0) { - fprintf(stderr, _("[Error] File not found [%s]\n"), s); - fprintf(stderr, _("[Error] Shutting down the game\n")); + error("File not found [%s]", s); + error("Shutting down the game"); exit(-1); } } @@ -165,8 +165,8 @@ int main(int argc, char *argv[]) /* let's initialize WinSock */ if (WSAStartup(wVersionRequested, &data) != 0) { - fprintf(stderr, _("[Error] Initialization of WinSock failed\n")); - fprintf(stderr, _("[Error] Shutting down the game\n")); + error("Initialization of WinSock failed"); + error("Shutting down the game"); exit(-1); } #endif /* __WIN32__ */ diff --git a/src/base/modules.c b/src/base/modules.c index aace319..349ca8a 100644 --- a/src/base/modules.c +++ b/src/base/modules.c @@ -67,13 +67,13 @@ static void *getFce(module_t *p, char *s) ret = dlsym(p->image, s); if ((error = dlerror()) != NULL) { - fprintf(stderr, _("[Error] Use of getFce function failed: %s\n"), error); + error("Use of getFce function failed: %s", error); return NULL; } #else /* __WIN32__ */ FARPROC ret = GetProcAddress((HMODULE) p->image, (LPCSTR) s); if (!ret) { - fprintf(stderr, _("[Error] Use of getFce function failed: %s\n"), s); + error("Use of getFce function failed: %s", s); } #endif /* __WIN32__ */ @@ -144,7 +144,7 @@ static module_t *newModule(char *name) image = mapImage(path); if (image == NULL) { - fprintf(stderr, _("[Error] Unable to map image of new module [%s]\n"), name); + error("Unable to map image of new module [%s]", name); return NULL; } @@ -161,10 +161,10 @@ static module_t *newModule(char *name) ret->fce_cmd = getFce(ret, "cmdArena"); ret->fce_recvMsg = getFce(ret, "recvMsg"); - DEBUG_MSG(_("[Debug] Loading module [%s]\n"), name); + debug("Loading module [%s]", name); if (ret->fce_init(&export_fce) != 0) { - fprintf(stderr, _("[Error] Unable to load module [%s]\n"), name); + error("Unable to load module [%s]", name); unmapImage(image); free(ret->name); free(ret); @@ -178,7 +178,7 @@ static int destroyModule(module_t *p) { assert(p != NULL); - DEBUG_MSG(_("[Debug] Unloading module [%s]\n"), p->name); + debug("Unloading module [%s]", p->name); p->fce_destroy(); unmapImage(p->image); @@ -216,14 +216,14 @@ int module_load(char *name) module_t *module; if (isModuleLoaded(name)) { - fprintf(stderr, ("[Error] Unable to load already loaded module [%s]\n"), name); + error("Unable to load already loaded module [%s]", name); return -1; } module = newModule(name); if (module == NULL) { - fprintf(stderr, _("[Error] Unable to load module [%s]\n"), name); + error("Unable to load module [%s]", name); return -1; } diff --git a/src/base/msg.h b/src/base/msg.h index a2f77e9..e9bdb3b 100644 --- a/src/base/msg.h +++ b/src/base/msg.h @@ -2,12 +2,6 @@ #define MSG_H #ifdef DEBUG -#define DEBUG_MSG(msg,arg...) printf(msg, ##arg) -#else /* DEBUG */ -#define DEBUG_MSG(msg,arg...) -#endif /* DEBUG * */ - -#ifdef DEBUG #define debug(msg,arg...) fprintf(stdout, "%s ", _("[Debug]")); fprintf(stdout, _(msg), ##arg); fprintf(stdout, "\n") #else /* DEBUG */ #define debug(msg,arg...) diff --git a/src/base/myTimer.c b/src/base/myTimer.c index e2b7fbd..5015cc6 100644 --- a/src/base/myTimer.c +++ b/src/base/myTimer.c @@ -124,7 +124,7 @@ void timer_event(list_t *listTimer) } break; default: - assert(!_("[Error] Bad setting of the timer")); + fatal("Bad setting of the timer"); break; } } @@ -146,7 +146,7 @@ void timer_del(list_t *listTimer, int id) } } - fprintf(stderr, _("[Error] Unable to delete event from the timer as it is not present in it [%d]\n"), id); + error("Unable to delete event from the timer as it is not present in it [%d]", id); assert(0); } diff --git a/src/base/net_multiplayer.c b/src/base/net_multiplayer.c index 43abf7c..fc142da 100644 --- a/src/base/net_multiplayer.c +++ b/src/base/net_multiplayer.c @@ -54,7 +54,7 @@ int net_multiplayer_init(int type, char *ip, int port, int proto) switch (proto) { case PROTO_UDPv4: if (server_init(ip, port, NULL, 0) != 1) { - fprintf(stderr, _("[Error] Unable to initialize multiplayer game\n")); + error("Unable to initialize multiplayer game"); netGameType = NET_GAME_TYPE_NONE; return -1; } @@ -62,7 +62,7 @@ int net_multiplayer_init(int type, char *ip, int port, int proto) case PROTO_UDPv6: if (server_init(NULL, 0, ip, port) != 1) { - fprintf(stderr, _("[Error] Unable to initialize multiplayer game\n")); + error("Unable to initialize multiplayer game"); netGameType = NET_GAME_TYPE_NONE; return -1; } @@ -73,7 +73,7 @@ int net_multiplayer_init(int type, char *ip, int port, int proto) #ifndef PUBLIC_SERVER case NET_GAME_TYPE_CLIENT: if (client_init(ip, port) != 0) { - fprintf(stderr, _("[Error] Unable to join multiplayer game\n")); + error("Unable to join multiplayer game"); netGameType = NET_GAME_TYPE_NONE; return -1; } @@ -81,7 +81,7 @@ int net_multiplayer_init(int type, char *ip, int port, int proto) #endif /* PUBLIC_SERVER */ default: - fprintf(stderr, _("[Error] Unknown type of the network game [%d]\n"), netGameType); + error("Unknown type of the network game [%d]", netGameType); assert(0); break; } @@ -106,7 +106,7 @@ void net_multiplayer_event() #endif /* PUBLIC_SERVER */ default: - fprintf(stderr, _("[Error] Unknown type of the network game [%d]\n"), netGameType); + error("Unknown type of the network game [%d]", netGameType); assert(0); break; } @@ -129,7 +129,7 @@ void net_multiplayer_quit() #endif /* PUBLIC_SERVER */ default: - fprintf(stderr, _("[Error] Unknown type of the network game [%d]\n"), netGameType); + error("Unknown type of the network game [%d]", netGameType); assert(0); break; } diff --git a/src/base/proto.c b/src/base/proto.c index 1c56653..f3f66ff 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -59,7 +59,7 @@ void proto_recv_error_client(char *msg) return; } - DEBUG_MSG(_("[Debug] Communication error [%d]\n"), errorcode); + debug("Communication error [%d]", errorcode); switch (errorcode) { case PROTO_ERROR_CODE_BAD_VERSION: @@ -84,7 +84,7 @@ void proto_send_hello_client(char *name) snprintf(msg, STR_PROTO_SIZE, "hello %s %s\n", getParamElse("--version", TUXANCI_VERSION), name); - printf(_("[Debug] Sending: %s\n"), msg); + debug("Sending: %s", msg); client_send(msg); } #endif /* PUBLIC_SERVER */ diff --git a/src/base/server.c b/src/base/server.c index 2b968d1..17d8abe 100644 --- a/src/base/server.c +++ b/src/base/server.c @@ -281,7 +281,7 @@ void server_send_client(client_t *p, char *msg) #ifndef PUBLIC_SERVER if (isParamFlag("--send")) { - printf(_("[Debug] Sending: %s"), msg); + debug("Sending: %s", msg); } #endif /* PUBLIC_SERVER */ @@ -308,7 +308,7 @@ static void client_eventWorkRecvList(client_t *client) #ifndef PUBLIC_SERVER if (isParamFlag("--recv")) { - printf(_("[Debug] Received: %s"), line); + debug("Received: %s", line); } #endif /* PUBLIC_SERVER */ diff --git a/src/base/serverSendMsg.c b/src/base/serverSendMsg.c index ed30020..d74103e 100644 --- a/src/base/serverSendMsg.c +++ b/src/base/serverSendMsg.c @@ -138,7 +138,7 @@ void send_msg_to_client(int type, client_t *client, char *msg, int type2, int id #endif /* PUBLIC_SERVER */ break; default: - fprintf(stderr, _("[Error] Unknown type of target group of players [%d]\n"), type); + error("Unknown type of target group of players [%d]", type); assert(0); break; } diff --git a/src/base/shareFunction.c b/src/base/shareFunction.c index 7121cfd..a9cd69d 100644 --- a/src/base/shareFunction.c +++ b/src/base/shareFunction.c @@ -37,7 +37,7 @@ void share_function_init() void share_function_add(char *name, void *function) { - DEBUG_MSG(_("[Debug] Adding new shared function [%s]\n"), name); + debug("Adding new shared function [%s]", name); list_add(listShareFce, newShareFceItem(name, function)); } diff --git a/src/base/shot.c b/src/base/shot.c index f11760a..168e889 100644 --- a/src/base/shot.c +++ b/src/base/shot.c @@ -113,7 +113,7 @@ shot_t *shot_new(int x, int y, int px, int py, int gun, int author_id) break; default: - fprintf(stderr, _("[Error] Unknown type of gun [%d]\n"), gun); + error("Unknown type of gun [%d]", gun); assert(0); break; } diff --git a/src/base/space.c b/src/base/space.c index 4f3adbe..0189186 100644 --- a/src/base/space.c +++ b/src/base/space.c @@ -273,7 +273,7 @@ void space_print(space_t *p) { int i, j; - printf(_("[Debug] Debugging space:\n")); + debug("Debugging space:"); for (i = 0; i < p->h; i++) { for (j = 0; j < p->w; j++) { diff --git a/src/base/storage.c b/src/base/storage.c index 971e576..842c560 100644 --- a/src/base/storage.c +++ b/src/base/storage.c @@ -72,7 +72,7 @@ void *storage_get(list_t *list, char *group, char *name) } } - DEBUG_MSG(_("[Error] Storage item not found [%s %s]\n"), group, name); + debug("Storage item not found [%s %s]", group, name); return NULL; } diff --git a/src/base/textFile.c b/src/base/textFile.c index 8db6713..d04d8e6 100644 --- a/src/base/textFile.c +++ b/src/base/textFile.c @@ -50,7 +50,7 @@ static void createLine(list_t *list, char *p, int len) break; } - length_line = (int) (end_line - (begin_line)); + length_line = (int) (end_line - begin_line); line = malloc((length_line + 1) * sizeof(char)); memset(line, 0, (length_line + 1) * sizeof(char)); @@ -64,7 +64,7 @@ static void createLine(list_t *list, char *p, int len) } while (begin_line != NULL); } -/* +/** * Loads file *s and returns him formatted to textFile_t* */ textFile_t *text_file_load(char *s) @@ -78,20 +78,20 @@ textFile_t *text_file_load(char *s) assert(s != NULL); if (lstat(s, &buf) < 0) { - fprintf(stderr, _("[Error] Unable to get file status [%s]\n"), s); + error("Unable to get file status [%s]", s); return NULL; } file_length = buf.st_size; if ((file = fopen(s, "rb")) == NULL) { - fprintf(stderr, _("[Error] Unable to open file for reading [%s]\n"), s); + error("Unable to open file for reading [%s]", s); return NULL; } p = malloc(file_length * sizeof(char)); if (fread(p, file_length * sizeof(char), 1, file) != 1) { - fprintf(stderr, _("[Error] Unable to read data from file [%s]\n"), s); + error("Unable to read data from file [%s]", s); fclose(file); return NULL; } @@ -106,7 +106,7 @@ textFile_t *text_file_load(char *s) return ret; } -/* +/** * Prints the text saved in *p into stdout */ void text_file_print(textFile_t *p) @@ -115,7 +115,7 @@ void text_file_print(textFile_t *p) assert(p != NULL); - printf(_("[Debug] Printing file [%s]\n\n"), p->file); + debug("Printing file [%s]", p->file); for (i = 0; i < p->text->count; i++) { printf("%3d >> %s\n", i, (char *) p->text->list[i]); @@ -138,7 +138,7 @@ void text_file_save(textFile_t *p) fclose(file); } -/* +/** * Removes text saved in *p from the memory */ void text_file_destroy(textFile_t *p) diff --git a/src/base/tux.c b/src/base/tux.c index bed47fc..33984f7 100644 --- a/src/base/tux.c +++ b/src/base/tux.c @@ -148,7 +148,7 @@ void tux_get_course(int n, int *x, int *y) break; default: - fprintf(stderr, _("[Error] Unknown direction of the tux [%d]\n"), n); + error("Unknown direction of the tux [%d]", n); assert(0); break; } @@ -185,7 +185,7 @@ void tux_draw(tux_t *tux) break; default: - fprintf(stderr, _("[Error] Unknown direction of the tux [%d]\n"), tux->position); + error("Unknown direction of the tux [%d]", tux->position); assert(0); break; } diff --git a/src/base/udp_server.c b/src/base/udp_server.c index 471c580..0e2b521 100644 --- a/src/base/udp_server.c +++ b/src/base/udp_server.c @@ -95,9 +95,9 @@ int server_udp_init(char *ip4, int port4, char *ip6, int port6) if (sock_server_udp != NULL) { ret++; - DEBUG_MSG(_("[Debug] Starting server on [%s]:%d\n"), ip4, port4); + debug("Starting server on [%s]:%d", ip4, port4); } else { - DEBUG_MSG(_("[Error] Unable to start server on [%s]:%d\n"), ip4, port4); + debug("Unable to start server on [%s]:%d", ip4, port4); } } @@ -106,9 +106,9 @@ int server_udp_init(char *ip4, int port4, char *ip6, int port6) if (sock_server_udp_second != NULL) { ret++; - DEBUG_MSG(_("[Debug] Starting server on [%s]:%d\n"), ip6, port6); + debug("Starting server on [%s]:%d", ip6, port6); } else { - DEBUG_MSG(_("[Error] Unable to start server on [%s]:%d\n"), ip6, port6); + debug("Unable to start server on [%s]:%d", ip6, port6); } } @@ -177,7 +177,7 @@ static void client_eventUdpSelect(sock_udp_t *sock_server) } if (client == NULL) { - fprintf(stderr, _("[Error] UDP client not found\n")); + error("UDP client not found"); return; } @@ -230,15 +230,15 @@ int server_udp_select_sock() void server_udp_quit() { - DEBUG_MSG(_("[Debug] Shutting down UDP\n")); + debug("Shutting down UDP"); if (sock_server_udp != NULL) { - DEBUG_MSG(_("[Debug] Closing IPv4 [port %d]\n"), sock_udp_get_port(sock_server_udp)); + debug("Closing IPv4 [port %d]", sock_udp_get_port(sock_server_udp)); sock_udp_close(sock_server_udp); } if (sock_server_udp_second != NULL) { - DEBUG_MSG(_("[Debug] Closing IPv6 [port %d]\n"), sock_udp_get_port(sock_server_udp_second)); + debug("Closing IPv6 [port %d]", sock_udp_get_port(sock_server_udp_second)); sock_udp_close(sock_server_udp_second); } } diff --git a/src/client/client.c b/src/client/client.c index 13d9964..054b3ea 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -95,7 +95,7 @@ static int initUdpClient(char *ip, int port) return -1; } - DEBUG_MSG(_("[Debug] Connected to game server [%s]:[%d]\n"), ip, port); + debug("Connected to game server [%s]:[%d]", ip, port); return 0; } @@ -132,8 +132,8 @@ int client_init(char *ip, int port) static void errorWithServer() { - fprintf(stderr, _("[Error] Game server is not responding\n")); - analyze_set_msg(_("[Error] Unable to connect to the game server")); + error("Game server is not responding"); + analyze_set_msg(_("Unable to connect to the game server")); world_do_end(); } @@ -146,7 +146,7 @@ void client_send(char *msg) ret = -1; if (isParamFlag("--send")) { - printf(_("[Debug] Sending data: %s"), msg); + debug("Sending data: %s", msg); } #ifdef SUPPORT_TRAFFIC @@ -204,7 +204,7 @@ static void client_eventWorkRecvList() protoCmd = findCmdProto(line); if (isParamFlag("--recv")) { - printf(_("[Debug] Recieved data: %s"), line); + debug("Recieved data: %s", line); } if (protoCmd != NULL) { @@ -295,7 +295,7 @@ static void eventTraffic() if (currentTime - lastTraffic > 5000) { lastTraffic = currentTime; - DEBUG_MSG(_("[Debug] Traffic: down [%d]/up [%d]\n"), traffic_down, traffic_up); + debug("Traffic: down [%d]/up [%d]", traffic_down, traffic_up); traffic_down = 0; traffic_up = 0; @@ -312,7 +312,6 @@ void client_event() eventPingServer(); selectClientSocket(); client_eventWorkRecvList(); - } static void quitUdpClient() @@ -320,7 +319,7 @@ static void quitUdpClient() assert(sock_server_udp != NULL); sock_udp_close(sock_server_udp); - DEBUG_MSG(_("[Debug] Closing connection to game server\n")); + debug("Closing connection to game server"); } void client_quit() diff --git a/src/client/config.c b/src/client/config.c index c9cb33d..48496df 100644 --- a/src/client/config.c +++ b/src/client/config.c @@ -108,14 +108,14 @@ void config_load() config_file = text_file_load(path); if (config_file == NULL) { - fprintf(stderr, _("[Error] Unable to load config file [%s]\n"), path); - fprintf(stderr, _("[Debug] Creating config file [%s]\n"), path); + error("Unable to load config file [%s]", path); + debug("Creating config file [%s]", path); config_file = text_file_new(path); } if (config_file == NULL) { - fprintf(stderr, _("[Error] Unable to create config file [%s]\n"), path); + error("Unable to create config file [%s]", path); return; } diff --git a/src/client/configFile.c b/src/client/configFile.c index 227f5d5..9d6d65b 100644 --- a/src/client/configFile.c +++ b/src/client/configFile.c @@ -147,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(_("[Debug] Expanding config file [%s]\n"), line); + debug("Expanding config file [%s]", line); } } diff --git a/src/client/font.c b/src/client/font.c index a880dab..d052cbb 100644 --- a/src/client/font.c +++ b/src/client/font.c @@ -38,7 +38,7 @@ void font_init() } */ if (font_list == NULL) { - fprintf(stderr, _("[Error] Unable to locate a font\n")); + error("Unable to locate a font"); return; } @@ -50,7 +50,7 @@ void font_init() if (TTF_Init() == -1) { free(font_file); - fprintf(stderr, "%s\n", SDL_GetError()); + error("SDL: %s", SDL_GetError()); return; } @@ -59,7 +59,7 @@ void font_init() g_font = TTF_OpenFont(font_file, fontSize); TTF_SetFontStyle(g_font, TTF_STYLE_NORMAL); - DEBUG_MSG(_("[Debug] Loading font [%s]\n"), font_file); + debug("Loading font [%s]", font_file); free(font_file); isFontInit = TRUE; @@ -150,7 +150,7 @@ void font_quit() TTF_CloseFont(g_font); TTF_Quit(); - DEBUG_MSG(_("[Debug] Unloading font\n")); + debug("Unloading font"); isFontInit = FALSE; } diff --git a/src/client/fontConfig.c b/src/client/fontConfig.c index 3b73df8..b0e0741 100644 --- a/src/client/fontConfig.c +++ b/src/client/fontConfig.c @@ -14,7 +14,7 @@ int fontconfig_init() res = FcInit(); if (res == 0) { - fprintf(stderr, _("[Error] Unable to init fontconfig library\n")); + error("Unable to init fontconfig library"); return 1; } diff --git a/src/client/game.c b/src/client/game.c index 07079b6..2481cee 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -111,7 +111,7 @@ void game_quit() audio_quit(); #endif /* NO_SOUND */ - DEBUG_MSG(_("[Debug] Shutting down the game\n")); + debug("Shutting down the game"); exit(0); } diff --git a/src/client/hotKey.c b/src/client/hotKey.c index b09b344..5471101 100644 --- a/src/client/hotKey.c +++ b/src/client/hotKey.c @@ -78,7 +78,7 @@ void hot_key_unregister(SDLKey key) hotkey = findHotkey(key); if (hotkey == NULL) { - assert(!_("[Error] Unregistering not registered hotkey")); + fatal("Unregistering not registered hotkey"); } my_index = list_search(listHotKey, hotkey); @@ -93,7 +93,7 @@ void hot_key_enable(SDLKey key) hotkey = findHotkey(key); if (hotkey == NULL) { - assert(!_("[Error] Enabling not registered hotkey")); + fatal("Enabling not registered hotkey"); } lastActive = timer_get_current_time(); @@ -107,7 +107,7 @@ void hot_key_disable(SDLKey key) hotkey = findHotkey(key); if (hotkey == NULL) { - assert(!_("[Error] Disabling not registered hotkey")); + fatal("Disabling not registered hotkey"); } lastActive = timer_get_current_time(); diff --git a/src/client/image.c b/src/client/image.c index 4fb033a..cdd7c9b 100644 --- a/src/client/image.c +++ b/src/client/image.c @@ -25,7 +25,7 @@ void image_init() { assert(interface_is_inicialized() == TRUE); - DEBUG_MSG(_("[Debug] Initializing image database\n")); + debug("Initializing image database"); listStorage = storage_new(); isImageDataInit = TRUE; @@ -47,12 +47,12 @@ static SDL_Surface *loadImage(const char *filename, int alpha) accessExistFile(str); if ((tmp = IMG_Load(str)) == NULL) { - fprintf(stderr, "%s\n", SDL_GetError()); + error("SDL: %s", SDL_GetError()); return NULL; } if ((ret = (alpha) ? SDL_DisplayFormatAlpha(tmp) : SDL_DisplayFormat(tmp)) == NULL) { - fprintf(stderr, "%s\n", SDL_GetError()); + error("SDL: %s", SDL_GetError()); SDL_FreeSurface(tmp); return NULL; } @@ -197,7 +197,7 @@ image_t *image_add(char *file, int alpha, char *name, char *group) storage_add(listStorage, group, name, new); - DEBUG_MSG(_("[Debug] Loading image [%s]\n"), file); + debug("Loading image [%s]", file); return new; } @@ -316,7 +316,7 @@ void image_draw(image_t *image, int x,int y, int px, int py, int w, int h) */ void image_quit() { - DEBUG_MSG(_("[Debug] Shutting down image database\n")); + debug("Shutting down image database"); storage_destroy(listStorage, image_destroy); isImageDataInit = FALSE; diff --git a/src/client/interface.c b/src/client/interface.c index 01fe241..59b39e0 100644 --- a/src/client/interface.c +++ b/src/client/interface.c @@ -63,21 +63,20 @@ void hotkey_screen() } if (SDL_WM_ToggleFullScreen(screen) == 0) { - fprintf(stderr, _("[Error] Unable to switch to the fullscreen mode\n")); + 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) { - fprintf(stderr, _("[Error] Unable to switch to the window mode: %s\n"), - SDL_GetError()); + 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) @@ -116,11 +115,11 @@ SDL_Surface *SetVideoMode(int width, int height, int bpp, Uint32 flags) int interface_init() { - DEBUG_MSG(_("[Debug] Initializing SDL\n")); + debug("Initializing SDL"); /* initialization of SDL */ if (SDL_Init(SDL_SUBSYSTEMS) == -1) { - fprintf(stderr, _("[Error] Unable to initialize SDL: %s\n"), SDL_GetError()); + error("Unable to initialize SDL: %s", SDL_GetError()); SDL_Quit(); return -1; } @@ -150,14 +149,14 @@ int interface_init() #endif /* SUPPORT_OPENGL */ if (screen == NULL) { - fprintf(stderr, _("[Error] Unable to create interface: %s\n"), SDL_GetError()); + error("Unable to create interface: %s", SDL_GetError()); SDL_Quit(); return -1; } - /* - * enable unicode by default for keyboard support - it is bit more + /** + * 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); @@ -212,10 +211,11 @@ int interface_is_press_any_key() mapa = SDL_GetKeyState(NULL); - for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) + for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) { if (mapa[i] == SDL_PRESSED) { return 1; } + } return 0; } @@ -227,10 +227,11 @@ void printPressAnyKey() mapa = SDL_GetKeyState(NULL); - for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) + for (i = SDLK_BACKSPACE; i < SDLK_KP9; i++) { if (mapa[i] == SDL_PRESSED) { - printf(_("[Debug] Pressed key [SDL: %d]\n"), i); + debug("Pressed key [SDL: %d]", i); } + } } @@ -318,8 +319,7 @@ int eventAction() WIN_BPP, g_win_flags); if (screen == NULL) { - fprintf(stderr, _("[Error] Unable to change resolution of the window: %s\n"), - SDL_GetError()); + error("Unable to change resolution of the window: %s", SDL_GetError()); return 0; } break; @@ -348,7 +348,7 @@ void interface_event() void interface_quit() { - DEBUG_MSG(_("[Debug] Shutting down SDL\n")); + debug("Shutting down SDL"); hot_key_quit(); keyboard_buffer_quit(); diff --git a/src/client/keyboardBuffer.c b/src/client/keyboardBuffer.c index 8849414..129389f 100644 --- a/src/client/keyboardBuffer.c +++ b/src/client/keyboardBuffer.c @@ -57,7 +57,7 @@ bool_t keyboard_buffer_push(SDL_keysym key) assert(keyboardBuffer != NULL); if (keyboardBuffer->count >= keyboardBuffer->size) { - fprintf(stderr, _("[Error] Keyboard buffer overrun - dropping the key [%02x]\n"), key.sym); + error("Keyboard buffer overrun - dropping the key [%02x]", key.sym); return FALSE; } @@ -82,7 +82,7 @@ SDL_keysym keyboard_buffer_pop() assert(keyboardBuffer != NULL); if (keyboardBuffer->count <= 0) { - fprintf(stderr, _("[Error] Keyboard buffer underrun\n")); + error("Keyboard buffer underrun"); return emptyKey; } @@ -133,7 +133,7 @@ void keyboard_buffer_quit() assert(keyboardBuffer != NULL); if (keyboardBuffer->count > 0) { - fprintf(stderr, _("[Warning] Shutting down non-empty keyboard buffer\n")); + warning("Shutting down non-empty keyboard buffer"); } free(keyboardBuffer->buff); diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c index f7970e5..5328401 100644 --- a/src/client/saveLoad.c +++ b/src/client/saveLoad.c @@ -85,7 +85,7 @@ void save_arena(char *filename, arena_t *arena) sprintf(path, "%s/%s.sav", home_director_get(), filename); - DEBUG_MSG(_("[Debug] Saving game [%s]\n"), path); + debug("Saving game [%s]", path); textFile = text_file_new(path); @@ -94,7 +94,7 @@ void save_arena(char *filename, arena_t *arena) text_file_save(textFile); text_file_destroy(textFile); } else { - fprintf(stderr, _("[Error] Unable to save game [%s]\n"), path); + error("Unable to save game [%s]", path); } } @@ -251,7 +251,7 @@ void load_arena(char *filename) sprintf(path, "%s/%s", home_director_get(), filename); - DEBUG_MSG(_("[Debug] Loading arena [%s]\n"), path); + debug("Loading arena [%s]", path); textFile = text_file_load(path); @@ -259,6 +259,6 @@ void load_arena(char *filename) loadContextArenaFromTextFile(textFile); text_file_destroy(textFile); } else { - fprintf(stderr, _("[Error] Unable to load saved game [%s]\n"), path); + error("Unable to load saved game [%s]", path); } } diff --git a/src/client/screen.c b/src/client/screen.c index 2e8822d..476cf3e 100644 --- a/src/client/screen.c +++ b/src/client/screen.c @@ -56,7 +56,7 @@ void screen_register(screen_t *p) { assert(p != NULL); - DEBUG_MSG(_("[Debug] Registering screen [%s]\n"), p->name); + debug("Registering screen [%s]", p->name); list_add(listScreen, p); } @@ -103,14 +103,14 @@ void screen_switch() layer_flush(); if (currentScreen != NULL) { - DEBUG_MSG(_("[Debug] Stopping screen [%s]\n"), currentScreen->name); + debug("Stopping screen [%s]", currentScreen->name); currentScreen->fce_stop(); } currentScreen = futureScreen; futureScreen = NULL; - DEBUG_MSG(_("[Debug] Starting screen [%s]\n"), currentScreen->name); + debug("Starting screen [%s]", currentScreen->name); currentScreen->fce_start(); } diff --git a/src/modules/modBasic.c b/src/modules/modBasic.c index 5b5e222..a91b7f6 100644 --- a/src/modules/modBasic.c +++ b/src/modules/modBasic.c @@ -24,7 +24,7 @@ int init(export_fce_t *p) { export_fce = p; - printf("[Debug] Initializing Basic module\n"); + debug("Initializing Basic module"); return 0; } @@ -37,26 +37,26 @@ int draw(int x, int y, int w, int h) UNUSED(w); UNUSED(h); - printf("[Debug] Drawing Basic module\n"); + debug("Drawing Basic module"); return 0; } #endif int event() { - printf("[Debug] Basic module catch event\n"); + debug("Basic module catch event"); return 0; } int isConflict(int x, int y, int w, int h) { - printf("[Debug] isConflict(%d, %d, %d, %d) in Basic module\n", x, y, w, h); + debug("isConflict(%d, %d, %d, %d) in Basic module", x, y, w, h); return 0; } static void cmd_basic(char *line) { - printf("[Debug] cmd_basic(%s) in Basic module\n", line); + debug("cmd_basic(%s) in Basic module", line); } void cmdArena(char *line) @@ -67,11 +67,11 @@ void cmdArena(char *line) void recvMsg(char *msg) { - printf("[Debug] recvMsg(%s) in Basic module\n", msg); + debug("recvMsg(%s) in Basic module", msg); } int destroy() { - printf("[Debug] Destroying Basic module\n"); + debug("Destroying Basic module"); return 0; } diff --git a/src/modules/modMove.c b/src/modules/modMove.c index 950995e..7c7a862 100644 --- a/src/modules/modMove.c +++ b/src/modules/modMove.c @@ -49,7 +49,7 @@ static void move_tux(tux_t *tux, int x, int y, int w, int h) dist_y = y + h + 20; break; default: - assert(!_("[Debug] Variable p->control in modMove has a really weird value.\n")); + fatal("Variable p->control in modMove has a really weird value."); break; } diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index f8d1e1a..dea5ea1 100644 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -181,7 +181,7 @@ static void moveShotFromPipe(shot_t *shot, pipe_t *pipe) distPipe = space_get_object_id(spacePipe, pipe->id_out); if (distPipe == NULL) { - fprintf(stderr, "[Error] Pipe ID was not found [%d]\n", pipe->id); + error("Pipe ID was not found [%d]", pipe->id); return; } @@ -243,7 +243,7 @@ static int negPosition(int n) return TUX_UP; default: - assert(!_("[Error] Tux is probably moving in another dimension")); + fatal("Tux is probably moving in another dimension"); break; } diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index f363923..289f553 100644 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -188,7 +188,7 @@ static int getRandomPosition() return TUX_DOWN; } - assert(!_("[Error] Generated a random number which is not in range 0 to 3")); + fatal("Generated a random number which is not in range 0 to 3"); return -1; /* no warnings */ } diff --git a/src/net/tcp.c b/src/net/tcp.c index 263901c..20ab3aa 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -47,7 +47,7 @@ static int getProto(char *str) if (strstr(str, ":") != NULL) return PROTO_TCPv6; - assert(!_("[Error] Network protocol not detected")); + fatal("Network protocol not detected"); return -1; } @@ -76,7 +76,7 @@ sock_tcp_t *sock_tcp_bind(char *address, int port) #endif if (new->sock < 0) { - fprintf(stderr, _("[Error] Unable to create TCP socket\n")); + error("Unable to create TCP socket"); sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -115,7 +115,7 @@ sock_tcp_t *sock_tcp_bind(char *address, int port) #endif /* SUPPORT_IPv6 */ if (ret < 0) { - fprintf(stderr, _("[Error] Unable to bind to TCP port [%d]\n"), port); + error("Unable to bind to TCP port [%d]", port); sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -206,7 +206,7 @@ int sock_tcp_get_port(sock_tcp_t *p) } #endif - assert(!_("[Error] Bad IP protocol")); + fatal("Bad IP protocol"); return -1; } @@ -234,7 +234,7 @@ sock_tcp_t *sock_tcp_connect(char *ip, int port) #endif if (new->sock < 0) { - fprintf(stderr, _("[Error] Unable to create TCP socket for connecting\n")); + error("Unable to create TCP socket for connecting"); sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -262,7 +262,7 @@ sock_tcp_t *sock_tcp_connect(char *ip, int port) #endif if (ret < 0) { - fprintf(stderr, "[Error] Unable to connect to [%s]:%d\n", ip, port); + error("Unable to connect to [%s]:%d", ip, port); sock_tcp_destroy(new); #ifdef __WIN32__ WSACleanup(); diff --git a/src/net/udp.c b/src/net/udp.c index 46e04b6..1771222 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -32,7 +32,7 @@ static int getProto(char *str) if (strstr(str, ":") != NULL) return PROTO_UDPv6; - assert(!_("[Error] Network protocol not detected")); + fatal("Network protocol not detected"); return -1; } @@ -74,7 +74,7 @@ sock_udp_t *sock_udp_bind(char *address, int port) #endif if (new->sock < 0) { - fprintf(stderr, _("[Error] Unable to create UDP socket\n")); + error("Unable to create UDP socket"); sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -102,7 +102,7 @@ sock_udp_t *sock_udp_bind(char *address, int port) #endif if (res < 0) { - fprintf(stderr, _("[Error] Unable to bind UDP socket to [%s]:%d\n"), address, port); + error("Unable to bind UDP socket to [%s]:%d", address, port); sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -136,7 +136,7 @@ sock_udp_t *sock_udp_connect(char *address, int port) #endif if (new->sock < 0) { - fprintf(stderr, _("[Error] Unable to create UDP socket for connecting\n")); + error("Unable to create UDP socket for connecting"); sock_udp_destroy(new); #ifdef __WIN32__ WSACleanup(); @@ -227,7 +227,7 @@ int sock_udp_read(sock_udp_t *src, sock_udp_t *dst, void *address, int len) sock_udp_get_ip(dst, str_ip, STR_IP_SIZE); - fprintf(stderr, _("[Error] Unable to read from UDP socket [%s]:%d (read %d bytes)\n"), str_ip, sock_udp_get_port(dst), size); + error("Unable to read from UDP socket [%s]:%d (read %d bytes)", str_ip, sock_udp_get_port(dst), size); #ifdef __WIN32__ WSACleanup(); @@ -265,7 +265,7 @@ int sock_udp_write(sock_udp_t *src, sock_udp_t *dst, void *address, int len) sock_udp_get_ip(dst, str_ip, STR_IP_SIZE); - fprintf(stderr, _("[Error] Unable to write to socket [%s]:%d with protocol %d (written %d bytes)\n"), str_ip, sock_udp_get_port(dst), dst->proto, size); + error("Unable to write to socket [%s]:%d with protocol %d (written %d bytes)", str_ip, sock_udp_get_port(dst), dst->proto, size); #ifdef __WIN32__ WSACleanup(); @@ -309,7 +309,7 @@ int sock_udp_get_port(sock_udp_t *p) } #endif - assert(!_("[Error] Bad IP protocol")); + fatal("Bad IP protocol"); return -1; } diff --git a/src/screen/downArena.c b/src/screen/downArena.c index e150a03..ac211a9 100644 --- a/src/screen/downArena.c +++ b/src/screen/downArena.c @@ -287,7 +287,7 @@ static void readArenaFromStatus() connectToDownServer(); - printf("[Debug] arenaNetName: %s\n", arenaNetName); + debug("arenaNetName: %s", arenaNetName); } } } diff --git a/src/screen/gameType.c b/src/screen/gameType.c index c593c4c..f570fb9 100644 --- a/src/screen/gameType.c +++ b/src/screen/gameType.c @@ -302,7 +302,7 @@ int public_server_get_settingGameType() return NET_GAME_TYPE_CLIENT; } - assert(!_("[Error] Unknown game type")); + fatal("Unknown game type"); return -1; } @@ -356,7 +356,7 @@ int public_server_get_settingProto() return PROTO_UDPv6; } - DEBUG_MSG(_("[Error] Unknown version of IP protocol\n")); + debug("Unknown version of IP protocol"); return -1; } diff --git a/src/screen/settingKeys.c b/src/screen/settingKeys.c index a1bf4ad..90a35f2 100644 --- a/src/screen/settingKeys.c +++ b/src/screen/settingKeys.c @@ -138,13 +138,13 @@ void key_table_init() keycontrolFile = text_file_load(path); if (keycontrolFile == NULL) { - fprintf(stderr, _("[Error] Unable to load config file [%s]\n"), path); - fprintf(stderr, _("[Debug] Creating config file [%s]\n"), path); + error("Unable to load config file [%s]", path); + debug("Creating config file [%s]", path); keycontrolFile = text_file_new(path); if (keycontrolFile == NULL) { - fprintf(stderr, _("[Error] Unable to create config file [%s]\n"), path); + error("Unable to create config file [%s]", path); return; } } diff --git a/src/screen/table.c b/src/screen/table.c index 993ff18..01995a4 100644 --- a/src/screen/table.c +++ b/src/screen/table.c @@ -98,7 +98,7 @@ static void setWidgetLabel() int i; if (textFile == NULL) { - fprintf(stderr, _("[Error] Didn't load the high score file [%s]"), SCREEN_TABLE_FILE_HIGHSCORE_NAME); + error("Didn't load the high score file [%s]", SCREEN_TABLE_FILE_HIGHSCORE_NAME); return; } @@ -147,15 +147,15 @@ static void loadHighscoreFile() textFile = text_file_load(path); if (textFile == NULL) { - fprintf(stderr, _("[Error] Unable to load the high score file [%s]\n"), path); - fprintf(stderr, _("[Debug] Creating the high score file [%s]\n"), path); + error("Unable to load the high score file [%s]", path); + debug("Creating the high score file [%s]", path); textFile = text_file_new(path); } else { return; } if (textFile == NULL) { - fprintf(stderr, _("[Error] Unable to create the high score file [%s]\n"), path); + error("Unable to create the high score file [%s]", path); return; } diff --git a/src/screen/world.c b/src/screen/world.c index f368c41..a37da1b 100644 --- a/src/screen/world.c +++ b/src/screen/world.c @@ -68,7 +68,7 @@ void setGameType() public_server_get_settingPort(), public_server_get_settingProto()); if (ret != 0) { - fprintf(stderr, _("[Error] Unable to initialize network\n")); + error("Unable to initialize network"); world_do_end(); } } @@ -317,7 +317,7 @@ void world_tux_control(tux_t *p) switch (p->control) { case TUX_CONTROL_NONE: - assert(!_("[Error] Controls not defined")); + fatal("Controls not defined"); break; case TUX_CONTROL_KEYBOARD_RIGHT: @@ -502,6 +502,6 @@ void world_init() void world_quit() { - DEBUG_MSG(_("[Debug] Shutting down the world screen\n")); + debug("Shutting down the world screen"); isScreenWorldInit = FALSE; } diff --git a/src/server/highScore.c b/src/server/highScore.c index 4f54b1c..75323fa 100644 --- a/src/server/highScore.c +++ b/src/server/highScore.c @@ -17,16 +17,16 @@ void high_score_init(char *file) textFile = text_file_load(file); if (textFile == NULL) { - fprintf(stderr, _("[Error] Unable to load high score [%s]\n"), file); - fprintf(stderr, _("[Debug] Creating high score file [%s]\n"), file); + error("Unable to load high score [%s]", file); + debug("Creating high score file [%s]", file); textFile = text_file_new(file); } else { - DEBUG_MSG(_("[Debug] Loading high score file [%s]\n"), file); + debug("Loading high score file [%s]", file); return; } if (textFile == NULL) { - fprintf(stderr, _("[Error] Unable to create high score file [%s]\n"), file); + error("Unable to create high score file [%s]", file); return; } diff --git a/src/server/log.c b/src/server/log.c index 0c6c319..788bbe6 100644 --- a/src/server/log.c +++ b/src/server/log.c @@ -15,11 +15,11 @@ int log_init(char *name) logFile = fopen(name, "a"); if (logFile == NULL) { - fprintf(stderr, _("[Error] Unable to open log file [%s]\n"), name); + error("Unable to open log file [%s]", name); return -1; } - DEBUG_MSG(_("[Debug] Using log file [%s]\n"), name); + debug("Using log file [%s]", name); log_add(LOG_INF, "Logging started"); @@ -54,7 +54,7 @@ void log_add(int type, char *msg) str_type = "ERROR"; break; default: - assert(!_("[Error] Unknown type of the logging string")); + fatal("Unknown type of the logging string"); break; } diff --git a/src/server/publicServer.c b/src/server/publicServer.c index cb52842..76c0443 100644 --- a/src/server/publicServer.c +++ b/src/server/publicServer.c @@ -125,7 +125,7 @@ void daemonize() /* lock the file */ if (lockf(lockfd, F_TLOCK, 0) < 0) { perror("[Error] Lock: lockf\n"); - printf("[Warning] The Tuxanci game server is already running\n"); + warning("The Tuxanci game server is already running"); exit(0); } #else /* __CYGWIN__ */ @@ -138,7 +138,7 @@ void daemonize() lock.l_len = 0; if (fcntl(lockfd, F_SETLK, &lock) < 0) { - printf("[Warning] The Tuxanci game server is already running\n"); + warning("The Tuxanci game server is already running"); exit(0); } } @@ -321,7 +321,7 @@ static void load_arena() choice_arenaFile = arena_file_get_file_format_net_name(public_server_get_setting("ARENA", "--arena", "FAGN")); if (choice_arenaFile == NULL) { - fprintf(stderr, _("[Error] Unable to load arena [%s]\n"), public_server_get_setting("ARENA", "--arena", "FAGN")); + error("Unable to load arena [%s]", public_server_get_setting("ARENA", "--arena", "FAGN")); /* TODO: Why not to log it? */ exit(-1); } @@ -364,7 +364,7 @@ int public_server_init() ret = public_server_initNetwork(); if (ret < 0) { - fprintf(stderr, _("[Error] Unable to initialize network socket\n")); + error("Unable to initialize network socket"); /* TODO: Why not to log it? */ return -1; } @@ -372,7 +372,7 @@ int public_server_init() server_set_max_clients(atoi(public_server_get_setting("MAX_CLIENTS", "--max-clients", "32"))); if (public_server_register() < 0) { - fprintf(stderr, _("[Error] Unable to contact MasterServer\n")); + error("Unable to contact MasterServer"); /* TODO: Why not to log it? */ } @@ -412,7 +412,7 @@ void public_server_event() void my_handler_quit(int n) { - DEBUG_MSG("[Debug] Received signal %d\n", n); + debug("Received signal %d", n); /* TODO: Why not to log it? */ isSignalEnd = TRUE; @@ -422,7 +422,7 @@ void my_handler_quit(int n) void public_server_quit() { - DEBUG_MSG(_("[Debug] Shutting down the Tuxanci game server\n")); + debug("Shutting down the Tuxanci game server"); /* TODO: Why not to log it? */ net_multiplayer_quit(); diff --git a/src/server/serverConfigFile.c b/src/server/serverConfigFile.c index dbf1c63..d872827 100644 --- a/src/server/serverConfigFile.c +++ b/src/server/serverConfigFile.c @@ -10,10 +10,9 @@ static textFile_t *serverTextFile; -static void prepareConfigFile(textFile_t * ts) +static void prepareConfigFile(textFile_t *ts) { - int i; - int j; + int i, j; for (i = 0; i < serverTextFile->text->count; i++) { char *line; @@ -23,8 +22,7 @@ static void prepareConfigFile(textFile_t * ts) len = strlen(line); for (j = 0; j < len; j++) { - if (line[j] == ' ') /* [TAB] */ - { + if (line[j] == ' ') { /* [TAB] */ line[j] = ' '; } } @@ -36,13 +34,12 @@ void server_configFile_init() char *configFile; configFile = getParamElse("--config-file", SERVER_CONFIG); - printf(_("[Debug] Loading configuration file [%s]\n"), - getParamElse("--config-file", SERVER_CONFIG)); + debug("Loading configuration file [%s]", getParamElse("--config-file", SERVER_CONFIG)); serverTextFile = text_file_load(configFile); if (serverTextFile == NULL) { - fprintf(stderr, _("[Warning] Unable to load config file - using defaults\n")); + warning("Unable to load config file - using defaults"); return; } @@ -51,8 +48,8 @@ void server_configFile_init() static char *findValue(char *s) { - int len; int i; + int len; len = strlen(s); diff --git a/src/widget/widget_button.c b/src/widget/widget_button.c index f30b03d..9d80294 100644 --- a/src/widget/widget_button.c +++ b/src/widget/widget_button.c @@ -79,7 +79,7 @@ void button_event(widget_t *widget) WIDGET_BUTTON_HEIGHT, MOUSE_BUF_CLICK)) { my_time = WIDGET_BUTTON_TIME; - DEBUG_MSG(_("[Debug] Caught some button event\n")); + debug("Caught some button event"); p->fce_event(widget); } diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c index 171d2e0..b696302 100644 --- a/src/widget/widget_label.c +++ b/src/widget/widget_label.c @@ -39,7 +39,7 @@ void label_draw(widget_t *widget) font_draw(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE); break; default: - assert(!_("[Error] Unknown dimension for label placement")); + fatal("Unknown dimension for label placement"); break; } } diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c index fdf4e1d..4f9dcbb 100644 --- a/src/widget/widget_textfield.c +++ b/src/widget/widget_textfield.c @@ -162,7 +162,7 @@ static void checkText(widget_textfield_t *p, unsigned len) break; default: - assert(!_("[Error] Bad text filter!")); + fatal("Bad text filter!"); break; } |