summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/arenaFile.c15
-rw-r--r--src/base/homeDirector.c6
-rw-r--r--src/base/idManager.c22
-rw-r--r--src/base/main.h9
-rw-r--r--src/base/modules.c13
-rw-r--r--src/base/proto.c4
-rw-r--r--src/base/shareFunction.c6
-rw-r--r--src/base/storage.c5
-rw-r--r--src/base/tcp_server.c36
-rw-r--r--src/base/udp_server.c29
10 files changed, 62 insertions, 83 deletions
diff --git a/src/base/arenaFile.c b/src/base/arenaFile.c
index cd76561..cb3ceb2 100644
--- a/src/base/arenaFile.c
+++ b/src/base/arenaFile.c
@@ -119,9 +119,8 @@ static void cmd_arena(arena_t ** arena, char *line)
//(*arena)->w = atoi(str_w);
//(*arena)->h = atoi(str_h);
setCurrentArena(*arena);
-#ifdef DEBUG
- printf(_("Loaded new arena...\n"));
-#endif
+
+ DEBUG_MSG(_("Loaded new arena...\n"));
}
static void cmd_loadModule(char *line)
@@ -168,10 +167,10 @@ static void cmd_loadMusic(arenaFile_t * arenaFile, char *line)
if (getArenaValue(line, "name", str_name, STR_SIZE) != 0)
return;
-# ifndef NO_SOUND
+#ifndef NO_SOUND
//addMusic(str_file, str_name, MUSIC_GROUP_USER);
loadMusicFromArena(arenaFile, str_file, MUSIC_GROUP_USER, str_name);
-# endif
+#endif
}
static void cmd_playMusic(arena_t * arena, char *line)
@@ -357,9 +356,9 @@ static void loadArenaFromDirector(char *director)
else {
sprintf(path, "%s/%s", director, line);
}
-#ifdef DEBUG
- printf(_("Loading arena: %s\n"), line);
-#endif
+
+ DEBUG_MSG(_("Loading arena: %s\n"), line);
+
accessExistFile(path);
loadArenaFile(path);
}
diff --git a/src/base/homeDirector.c b/src/base/homeDirector.c
index 1f10920..e62b7ee 100644
--- a/src/base/homeDirector.c
+++ b/src/base/homeDirector.c
@@ -26,9 +26,9 @@ void createHomeDirector()
sprintf(homeDirector, "%s/%s", envHome, HOMEDIRECTOR_NAME);
if (access(homeDirector, F_OK) != 0) {
-#ifdef DEBUG
- printf(_("Creating home directory %s.\n"), homeDirector);
-#endif
+
+ DEBUG_MSG(_("Creating home directory %s.\n"), homeDirector);
+
#ifndef __WIN32__
if (mkdir(homeDirector, 0755) != 0) {
#else
diff --git a/src/base/idManager.c b/src/base/idManager.c
index 7f82282..09d3fc9 100644
--- a/src/base/idManager.c
+++ b/src/base/idManager.c
@@ -37,9 +37,9 @@ void initListID()
{
listID = newList();
lastID = 0;
-#ifdef DEBUG
- printf(_("Starting ID manger\n"));
-#endif
+
+ DEBUG_MSG(_("Starting ID manger\n"));
+
}
int isRegisterID(int id)
@@ -176,24 +176,22 @@ void infoID(int id)
index = isRegisterID(id);
if (index == -1) {
-#ifdef DEBUG
- printf(_("ID %d does not exist\n"), id);
-#endif
+ DEBUG_MSG(_("ID %d does not exist\n"), id);
+
return;
}
this = listID->list[index];
-#ifdef DEBUG
- printf(_("ID %d (count %d)\n"), this->id, this->count);
-#endif
+
+ DEBUG_MSG(_("ID %d (count %d)\n"), this->id, this->count);
+
return;
}
void quitListID()
{
-#ifdef DEBUG
- printf(_("Quitting ID manger\n"));
-#endif
+ DEBUG_MSG(_("Quitting ID manger\n"));
+
assert(listID != NULL);
destroyListItem(listID, destroyIdItem);
}
diff --git a/src/base/main.h b/src/base/main.h
index 7ea7111..c938eb5 100644
--- a/src/base/main.h
+++ b/src/base/main.h
@@ -20,6 +20,15 @@
//#define SUPPORT_OPENGL
+#ifdef DEBUG
+#define DEBUG_MSG(msg,arg...) printf(msg, ##arg)
+#endif
+
+#ifndef DEBUG
+#define DEBUG_MSG(msg,arg...)
+#endif
+
+
extern char *getParam(char *s);
extern char *getParamElse(char *s1, char *s2);
extern bool_t isParamFlag(char *s);
diff --git a/src/base/modules.c b/src/base/modules.c
index 82b5d56..75f581e 100644
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -16,6 +16,7 @@
#include "arenaFile.h"
#include "proto.h"
#include "shareFunction.h"
+
#ifndef PUBLIC_SERVER
# include "interface.h"
# include "image.h"
@@ -158,9 +159,9 @@ static module_t *newModule(char *name)
ret->fce_isConflict = getFce(ret, "isConflict");
ret->fce_cmd = getFce(ret, "cmdArena");
ret->fce_recvMsg = getFce(ret, "recvMsg");
-#ifdef DEBUG
- printf(_("Loading module: \"%s\"\n"), name);
-#endif
+
+ DEBUG_MSG(_("Loading module: \"%s\"\n"), name);
+
if (ret->fce_init(&export_fce) != 0) {
fprintf(stderr, _("Failed initialization of module \"%s\""), name);
unmapImage(image);
@@ -179,9 +180,9 @@ static int destroyModule(module_t * p)
unmapImage(p->image);
free(p->name);
free(p);
-#ifdef DEBUG
- printf(_("Destroing module...\n"));
-#endif
+
+ DEBUG_MSG(_("Destroing module...\n"));
+
return 0;
}
diff --git a/src/base/proto.c b/src/base/proto.c
index de098ab..606dd33 100644
--- a/src/base/proto.c
+++ b/src/base/proto.c
@@ -63,9 +63,7 @@ void proto_recv_error_client(char *msg)
return;
}
-#ifdef DEBUG
- printf(_("Proto error code: \"%d\"\n"), errorcode);
-#endif
+ DEBUG_MSG(_("Proto error code: \"%d\"\n"), errorcode);
switch (errorcode) {
case PROTO_ERROR_CODE_BAD_VERSION:
diff --git a/src/base/shareFunction.c b/src/base/shareFunction.c
index f3a83d5..84250a4 100644
--- a/src/base/shareFunction.c
+++ b/src/base/shareFunction.c
@@ -38,9 +38,8 @@ void initShareFunction()
void addToShareFce(char *name, void *function)
{
-#ifdef DEBUG
- printf(_("Adding \"%s\" to share function.\n"), name);
-#endif
+ DEBUG_MSG(_("Adding \"%s\" to share function.\n"), name);
+
addList(listShareFce, newShareFceItem(name, function));
}
@@ -56,6 +55,7 @@ void *getShareFce(char *name)
if (strcmp(this->name, name) == 0)
return this->function;
}
+
return NULL;
}
diff --git a/src/base/storage.c b/src/base/storage.c
index 8307cdf..1562fd2 100644
--- a/src/base/storage.c
+++ b/src/base/storage.c
@@ -72,9 +72,8 @@ void *getItemFromStorage(list_t * list, char *group, char *name)
return this->data;
}
-#ifdef DEBUG
- printf(_("%s %s was not found in storage!\n"), group, name);
-#endif
+ DEBUG_MSG(_("%s %s was not found in storage!\n"), group, name);
+
return NULL;
}
diff --git a/src/base/tcp_server.c b/src/base/tcp_server.c
index aeb3b8c..b781fb5 100644
--- a/src/base/tcp_server.c
+++ b/src/base/tcp_server.c
@@ -130,14 +130,11 @@ int initTcpServer(char *ip4, int port4, char *ip6, int port6)
if (sock_server_tcp != NULL) {
ret++;
disableNagle(sock_server_tcp);
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\"\n"), ip4, port4);
-#endif
+
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip4, port4);
} else {
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"),
- ip4, port4);
-#endif
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip4, port4);
+
}
}
@@ -147,14 +144,11 @@ int initTcpServer(char *ip4, int port4, char *ip6, int port6)
if (sock_server_tcp_second != NULL) {
ret++;
disableNagle(sock_server_tcp_second);
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\"\n"), ip6, port6);
-#endif
+
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip6, port6);
} else {
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"),
- ip6, port6);
-#endif
+
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip6, port6);
}
}
@@ -284,20 +278,14 @@ int selectServerTcpSocket()
void quitTcpServer()
{
if (sock_server_tcp != NULL) {
-#ifdef DEBUG
- printf(_("Closing port: \"%d\"\n"), getSockTcpPort(sock_server_tcp));
-#endif
+ DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockTcpPort(sock_server_tcp));
closeTcpSocket(sock_server_tcp);
}
if (sock_server_tcp_second != NULL) {
-#ifdef DEBUG
- printf(_("Closing port: \"%d\"\n"),
- getSockTcpPort(sock_server_tcp_second));
-#endif
+ DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockTcpPort(sock_server_tcp_second));
closeTcpSocket(sock_server_tcp_second);
}
-#ifdef DEBUG
- printf("Quitting TCP\n");
-#endif
+
+ DEBUG_MSG("Quitting TCP\n");
}
diff --git a/src/base/udp_server.c b/src/base/udp_server.c
index c2d6486..a469a3a 100644
--- a/src/base/udp_server.c
+++ b/src/base/udp_server.c
@@ -97,13 +97,9 @@ int initUdpServer(char *ip4, int port4, char *ip6, int port6)
if (sock_server_udp != NULL) {
ret++;
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\"\n"), ip4, port4);
-#endif
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip4, port4);
} else {
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip4, port4);
-#endif
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip4, port4);
}
}
@@ -112,13 +108,9 @@ int initUdpServer(char *ip4, int port4, char *ip6, int port6)
if (sock_server_udp_second != NULL) {
ret++;
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\"\n"), ip6, port6);
-#endif
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\"\n"), ip6, port6);
} else {
-#ifdef DEBUG
- printf(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip6, port6);
-#endif
+ DEBUG_MSG(_("Starting server: \"%s\" on port: \"%d\" FAILED!\n"), ip6, port6);
}
}
@@ -241,19 +233,14 @@ int selectServerUdpSocket()
void quitUdpServer()
{
if (sock_server_udp != NULL) {
-#ifdef DEBUG
- printf(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp));
-#endif
+ DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp));
closeUdpSocket(sock_server_udp);
}
if (sock_server_udp_second != NULL) {
-#ifdef DEBUG
- printf(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp_second));
-#endif
+ DEBUG_MSG(_("Closing port: \"%d\"\n"), getSockUdpPort(sock_server_udp_second));
closeUdpSocket(sock_server_udp_second);
}
-#ifdef DEBUG
- printf(_("Quitting UDP\n"));
-#endif
+
+ DEBUG_MSG(_("Quitting UDP\n"));
}