summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Zima <xhire@mujmalysvet.cz>2010-06-18 13:09:40 +0200
committerMichal Zima <xhire@mujmalysvet.cz>2010-06-18 13:09:40 +0200
commite7a6a7a14aeea2ee9f2c235d0cbabf0cb3660e89 (patch)
tree4ab86d23b7470657761d754426bab3645a91bf14 /src
parent8a278016b0ebe4b2a20348f1ebb2aff3037248c3 (diff)
Wiped out all "UNUSED" stuff
Plus small code cleaning, simplifying of some statements etc.
Diffstat (limited to 'src')
-rw-r--r--src/base/arena.c39
-rw-r--r--src/base/item.c2
-rw-r--r--src/base/proto.c9
-rw-r--r--src/base/tux.c7
-rw-r--r--src/client/interface.c2
-rw-r--r--src/client/saveLoad.c6
-rw-r--r--src/client/term.c3
-rw-r--r--src/modules/modAI.c100
-rw-r--r--src/modules/modBasic.c18
-rw-r--r--src/modules/modMove.c168
-rw-r--r--src/modules/modPipe.c85
-rw-r--r--src/modules/modTeleport.c91
-rw-r--r--src/modules/modWall.c40
-rw-r--r--src/screen/world.c6
14 files changed, 212 insertions, 364 deletions
diff --git a/src/base/arena.c b/src/base/arena.c
index 89b8e05..6d883b3 100644
--- a/src/base/arena.c
+++ b/src/base/arena.c
@@ -127,27 +127,12 @@ int arena_conflict_space(int x1, int y1, int w1, int h1, int x2, int y2, int w2,
int arena_is_free_space(arena_t *arena, int x, int y, int w, int h)
{
- if (x < 0 || y < 0 || x + w > arena->w || y + h > arena->h) {
- return 0;
- }
-
- if (space_is_conflict_with_object(arena->spaceTux, x, y, w, h)) {
- return 0;
- }
-
- if (space_is_conflict_with_object(arena->spaceShot, x, y, w, h)) {
- return 0;
- }
-
- if (space_is_conflict_with_object(arena->spaceItem, x, y, w, h)) {
- return 0;
- }
-
- if (space_is_conflict_with_object(arena->spaceShot, x, y, w, h)) {
- return 0;
- }
-
- if (module_is_conflict(x, y, w, h)) {
+ if ((x < 0 || y < 0 || x + w > arena->w || y + h > arena->h) ||
+ space_is_conflict_with_object(arena->spaceTux, x, y, w, h) ||
+ space_is_conflict_with_object(arena->spaceShot, x, y, w, h) ||
+ space_is_conflict_with_object(arena->spaceItem, x, y, w, h) ||
+ space_is_conflict_with_object(arena->spaceShot, x, y, w, h) ||
+ module_is_conflict(x, y, w, h)) {
return 0;
}
@@ -223,25 +208,16 @@ static void drawBackground(arena_t *arena, int screen_x, int screen_y)
static void action_tux_draw(space_t *space, tux_t *tux, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
tux_draw(tux);
}
static void action_item_draw(space_t *space, item_t *item, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
item_draw(item);
}
static void action_shot_draw(space_t *space, shot_t *shot, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
shot_draw(shot);
}
@@ -382,9 +358,6 @@ void arena_draw(arena_t *arena)
static void action_tux(space_t *space, tux_t *tux, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
tux_event(tux);
}
diff --git a/src/base/item.c b/src/base/item.c
index 0a3a58f..66d69e2 100644
--- a/src/base/item.c
+++ b/src/base/item.c
@@ -278,8 +278,6 @@ static void action_itemevent(space_t *space, item_t *item, void *p)
{
my_time_t currentTime;
- UNUSED(p);
-
currentTime = timer_get_current_time();
item->count++;
diff --git a/src/base/proto.c b/src/base/proto.c
index f3f66ff..4a9e2bb 100644
--- a/src/base/proto.c
+++ b/src/base/proto.c
@@ -91,8 +91,6 @@ void proto_send_hello_client(char *name)
static void action_sendItem(space_t *space, item_t *item, client_t *client)
{
- UNUSED(space);
-
proto_send_additem_server(PROTO_SEND_ONE, client, item);
}
@@ -233,8 +231,6 @@ void proto_send_status_server(int type, client_t *client)
void proto_recv_status_server(client_t *client, char *msg)
{
- UNUSED(msg);
-
proto_send_status_server(PROTO_SEND_ONE, client);
}
@@ -842,8 +838,6 @@ void proto_send_module_client(char *msg)
void proto_recv_module_server(client_t *client, char *msg)
{
- UNUSED(client);
-
module_recv_msg(msg + 7);
}
@@ -878,8 +872,6 @@ void proto_send_ping_client()
void proto_recv_ping_server(client_t *client, char *msg)
{
- UNUSED(client);
- UNUSED(msg);
}
void proto_send_ping_server(int type, client_t *client)
@@ -893,7 +885,6 @@ void proto_send_ping_server(int type, client_t *client)
#ifndef PUBLIC_SERVER
void proto_recv_ping_client(char *msg)
{
- UNUSED(msg);
}
#endif /* PUBLIC_SERVER */
diff --git a/src/base/tux.c b/src/base/tux.c
index 33984f7..f88d6a4 100644
--- a/src/base/tux.c
+++ b/src/base/tux.c
@@ -405,8 +405,6 @@ static void bombBallExplosion(shot_t *shot)
static void action_tux(space_t *space, tux_t *tux, shot_t *shot)
{
- UNUSED(space);
-
if (tux->status == TUX_STATUS_ALIVE) {
if (shot->author_id == tux->id && shot->isCanKillAuthor == FALSE) {
return;
@@ -736,17 +734,12 @@ void tux_set_status(void *p, int x, int y, int w, int h)
{
tux_t *tux;
- UNUSED(w);
- UNUSED(h);
-
tux = p;
tux_set_proportion(tux, x, y);
}
static void action_checkMine(space_t *space, item_t *item, tux_t *tux)
{
- UNUSED(space);
-
if (item->type == ITEM_MINE && item->author_id == tux->id) {
item->author_id = ID_UNKNOWN;
}
diff --git a/src/client/interface.c b/src/client/interface.c
index fd11396..62d7f96 100644
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -32,8 +32,6 @@ static Uint32 TimerCallback(Uint32 interval, void *param)
{
SDL_Event event;
- UNUSED(param);
-
event.type = SDL_USEREVENT;
event.user.code = USR_EVT_TIMER;
event.user.data1 = NULL;
diff --git a/src/client/saveLoad.c b/src/client/saveLoad.c
index e131ee4..899ef25 100644
--- a/src/client/saveLoad.c
+++ b/src/client/saveLoad.c
@@ -22,8 +22,6 @@ 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,
@@ -40,8 +38,6 @@ static void action_saveShot(space_t *space, shot_t *shot, textFile_t *textFile)
{
char str[STR_PROTO_SIZE];
- UNUSED(space);
-
snprintf(str, STR_PROTO_SIZE, "SHOT %d %d %d %d %d %d %d %d %d",
shot->id, shot->x, shot->y, shot->px, shot->py,
shot->position, shot->gun, shot->author_id,
@@ -54,8 +50,6 @@ 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);
diff --git a/src/client/term.c b/src/client/term.c
index 876f303..dc4a51b 100644
--- a/src/client/term.c
+++ b/src/client/term.c
@@ -76,9 +76,6 @@ static void action_refreshTerm(space_t *space, tux_t *tux, void *p)
{
char str[STR_SIZE];
- UNUSED(space);
- UNUSED(p);
-
sprintf(str,
"name: %s "
"score: %d "
diff --git a/src/modules/modAI.c b/src/modules/modAI.c
index 5790d55..c7d2c02 100644
--- a/src/modules/modAI.c
+++ b/src/modules/modAI.c
@@ -14,9 +14,9 @@
#ifndef PUBLIC_SERVER
#include "interface.h"
#include "image.h"
-#else
+#else /* PUBLIC_SERVER */
#include "publicServer.h"
-#endif
+#endif /* PUBLIC_SERVER */
static export_fce_t *export_fce;
@@ -47,9 +47,6 @@ static alternative_t *cloneAlternative(alternative_t *p, int route, int x, int y
assert(p != NULL);
- UNUSED(x);
- UNUSED(y);
-
new = newAlternative(route, p->x, p->y);
new->first = p->first;
new->step = p->step;
@@ -68,22 +65,22 @@ static void forkAlternative(list_t *list, alternative_t *p, int w, int h)
y = p->y;
switch (p->route) {
- case TUX_UP:
- list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
- list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
- break;
- case TUX_RIGHT:
- list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
- list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
- break;
- case TUX_LEFT:
- list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
- list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
- break;
- case TUX_DOWN:
- list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
- list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
- break;
+ case TUX_UP:
+ list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
+ list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
+ break;
+ case TUX_RIGHT:
+ list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
+ list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
+ break;
+ case TUX_LEFT:
+ list_add(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
+ list_add(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
+ break;
+ case TUX_DOWN:
+ list_add(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
+ list_add(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
+ break;
}
}
@@ -97,18 +94,18 @@ static void moveAlternative(alternative_t *p, int offset)
/*printf("move %d %d %d\n", p->x, p->y, p->step);*/
switch (p->route) {
- case TUX_UP:
- p->y -= offset;
- break;
- case TUX_RIGHT:
- p->x += offset;
- break;
- case TUX_LEFT:
- p->x -= offset;
- break;
- case TUX_DOWN:
- p->y += offset;
- break;
+ case TUX_UP:
+ p->y -= offset;
+ break;
+ case TUX_RIGHT:
+ p->x += offset;
+ break;
+ case TUX_LEFT:
+ p->x -= offset;
+ break;
+ case TUX_DOWN:
+ p->y += offset;
+ break;
}
}
@@ -120,7 +117,6 @@ static void destroyAlternative(alternative_t *p)
static void cmd_ai(char *line)
{
- UNUSED(line);
}
static int init(export_fce_t *p)
@@ -133,14 +129,9 @@ static int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
static int draw(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
return 0;
}
-#endif
+#endif /* PUBLIC_SERVER */
static tux_t *findOtherTux(space_t *space)
{
@@ -166,8 +157,6 @@ static void shotTux(arena_t *arena, tux_t *tux_ai, tux_t *tux_rival)
int x_rival, y_rival;
int w, h;
- UNUSED(arena);
-
export_fce->fce_tux_get_proportion(tux_ai, &x_ai, &y_ai, &w, &h);
export_fce->fce_tux_get_proportion(tux_rival, &x_rival, &y_rival, &w, &h);
@@ -236,12 +225,11 @@ static void tux_eventAI(tux_t *tux)
list_add(listAlternative, newAlternative(TUX_DOWN, x, y + (h + 10)));
my_index = -1;
- while (1) {
+ for (;;) {
alternative_t *this;
my_index++;
if (my_index < 0 || my_index >= listAlternative->count) {
-
int j;
/*printf("listFork->count = %d\n", listFork->count);*/
@@ -261,8 +249,9 @@ static void tux_eventAI(tux_t *tux)
this = (alternative_t *) listAlternative->list[my_index];
- if (++countDo == 100)
+ if (++countDo == 100) {
break;
+ }
if (this->step > 100) {
list_del_item(listAlternative, my_index, destroyAlternative);
@@ -279,9 +268,8 @@ static void tux_eventAI(tux_t *tux)
continue;
}
- if (export_fce->
- fce_arena_conflict_space(this->x, this->y, w, h, rival_x, rival_y, w,
- h)) {
+ if (export_fce->fce_arena_conflict_space(this->x, this->y, w, h,
+ rival_x, rival_y, w, h)) {
/*printf("this->step = %d\n", this->step);*/
list_del(listAlternative, my_index);
@@ -335,9 +323,6 @@ static void tux_eventAI(tux_t *tux)
static void action_tuxAI(space_t *space, tux_t *tux, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
if (tux->control == TUX_CONTROL_AI && tux->status == TUX_STATUS_ALIVE) {
tux_eventAI(tux);
}
@@ -393,23 +378,18 @@ static int event()
static int isConflict(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
return 0;
}
static void cmdArena(char *line)
{
- if (strncmp(line, "ai", 2) == 0)
+ if (strncmp(line, "ai", 2) == 0) {
cmd_ai(line);
+ }
}
static void recvMsg(char *msg)
{
- UNUSED(msg);
}
static int destroy()
@@ -420,9 +400,9 @@ static int destroy()
mod_sym_t modai_sym = { &init,
#ifndef PUBLIC_SERVER
&draw,
-#else
+#else /* PUBLIC_SERVER */
0,
-#endif
+#endif /* PUBLIC_SERVER */
&event,
&isConflict,
&cmdArena,
diff --git a/src/modules/modBasic.c b/src/modules/modBasic.c
index d3c80da..8494916 100644
--- a/src/modules/modBasic.c
+++ b/src/modules/modBasic.c
@@ -14,9 +14,9 @@
#ifndef PUBLIC_SERVER
#include "interface.h"
#include "image.h"
-#else
+#else /* PUBLIC_SERVER */
#include "publicServer.h"
-#endif
+#endif /* PUBLIC_SERVER */
static export_fce_t *export_fce;
@@ -31,15 +31,10 @@ static int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
static int draw(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
debug("Drawing Basic module");
return 0;
}
-#endif
+#endif /* PUBLIC_SERVER */
static int event()
{
@@ -60,8 +55,9 @@ static void cmd_basic(char *line)
static void cmdArena(char *line)
{
- if (strncmp(line, "basic", 5) == 0)
+ if (strncmp(line, "basic", 5) == 0) {
cmd_basic(line);
+ }
}
static void recvMsg(char *msg)
@@ -78,9 +74,9 @@ static int destroy()
mod_sym_t modbasic_sym = { &init,
#ifndef PUBLIC_SERVER
&draw,
-#else
+#else /* PUBLIC_SERVER */
0,
-#endif
+#endif /* PUBLIC_SERVER */
&event,
&isConflict,
&cmdArena,
diff --git a/src/modules/modMove.c b/src/modules/modMove.c
index abe4179..9774170 100644
--- a/src/modules/modMove.c
+++ b/src/modules/modMove.c
@@ -13,51 +13,49 @@
#include "serverSendMsg.h"
#ifndef PUBLIC_SERVER
-# include "interface.h"
-# include "image.h"
-#endif
-
-#ifdef PUBLIC_SERVER
-# include "publicServer.h"
-#endif
+#include "interface.h"
+#include "image.h"
+#else /* PUBLIC_SERVER */
+#include "publicServer.h"
+#endif /* PUBLIC_SERVER */
static export_fce_t *export_fce;
static void move_tux(tux_t *tux, int x, int y, int w, int h)
{
- int dist_x = 0, dist_y = 0; /* no warnings */
+ int dist_x = 0, dist_y = 0;
if (tux->bonus == BONUS_GHOST || export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) {
return;
}
switch (tux->position) {
- case TUX_UP:
- dist_x = x + w / 2;
- dist_y = y - (TUX_HEIGHT + 20);
- break;
- case TUX_LEFT:
- dist_x = x - (TUX_WIDTH + 20);
- dist_y = y + h / 2;
- break;
- case TUX_RIGHT:
- dist_x = x + w + 20;
- dist_y = y + h / 2;
- break;
- case TUX_DOWN:
- dist_x = x + w / 2;
- dist_y = y + h + 20;
- break;
- default:
- fatal("Variable p->control in modMove has a really weird value.");
- break;
+ case TUX_UP:
+ dist_x = x + w / 2;
+ dist_y = y - (TUX_HEIGHT + 20);
+ break;
+ case TUX_LEFT:
+ dist_x = x - (TUX_WIDTH + 20);
+ dist_y = y + h / 2;
+ break;
+ case TUX_RIGHT:
+ dist_x = x + w + 20;
+ dist_y = y + h / 2;
+ break;
+ case TUX_DOWN:
+ dist_x = x + w / 2;
+ dist_y = y + h + 20;
+ break;
+ default:
+ fatal("Variable tux->position in modMove has an undefined value [%d]", tux->position);
+ break;
}
if (export_fce->fce_arena_is_free_space(export_fce->fce_arena_get_current(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT)) {
space_move_object(export_fce->fce_arena_get_current()->spaceTux, tux, dist_x, dist_y);
#ifndef PUBLIC_SERVER
/*sound_play("teleport", SOUND_GROUP_BASE);*/
-#endif
+#endif /* PUBLIC_SERVER */
if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) {
char msg[STR_PROTO_SIZE];
sprintf(msg, "movetux %d %d %d", tux->id, dist_x, dist_y);
@@ -87,22 +85,22 @@ static void transformShot(shot_t *shot, int position)
speed = getSppedShot(shot);
switch (position) {
- case TUX_UP:
- shot->px = 0;
- shot->py = -speed;
- break;
- case TUX_LEFT:
- shot->px = -speed;
- shot->py = 0;
- break;
- case TUX_RIGHT:
- shot->px = speed;
- shot->py = 0;
- break;
- case TUX_DOWN:
- shot->px = 0;
- shot->py = +speed;
- break;
+ case TUX_UP:
+ shot->px = 0;
+ shot->py = -speed;
+ break;
+ case TUX_LEFT:
+ shot->px = -speed;
+ shot->py = 0;
+ break;
+ case TUX_RIGHT:
+ shot->px = +speed;
+ shot->py = 0;
+ break;
+ case TUX_DOWN:
+ shot->px = 0;
+ shot->py = +speed;
+ break;
}
shot->position = position;
@@ -113,49 +111,51 @@ static void transformShot(shot_t *shot, int position)
}
}
-static void move_shot(shot_t *shot, int position, int src_x, int src_y, int dist_x, int dist_y, int dist_w, int dist_h)
+static void move_shot(shot_t *shot, int position, int src_x, int src_y,
+ int dist_x, int dist_y, int dist_w, int dist_h)
{
int offset = 0;
- int new_x = 0, new_y = 0; /* no warnings */
+ int new_x = 0, new_y = 0;
- /*printf("move_shot\n");*/
switch (shot->position) {
- case TUX_UP:
- case TUX_DOWN:
- offset = shot->x - src_x;
- break;
- case TUX_RIGHT:
- case TUX_LEFT:
- offset = shot->y - src_y;
- break;
+ case TUX_UP:
+ case TUX_DOWN:
+ offset = shot->x - src_x;
+ break;
+
+ case TUX_RIGHT:
+ case TUX_LEFT:
+ offset = shot->y - src_y;
+ break;
}
transformShot(shot, position);
switch (shot->position) {
- case TUX_UP:
- new_x = dist_x + offset;
- new_y = dist_y - (shot->h + 5);
- break;
- case TUX_LEFT:
- new_x = dist_x - (shot->w + 5);
- new_y = dist_y + offset;
- break;
- case TUX_RIGHT:
- new_x = dist_x + dist_w + 5;
- new_y = dist_y + offset;
- break;
- case TUX_DOWN:
- new_x = dist_x + offset;
- new_y = dist_y + dist_h + 5;
- break;
+ case TUX_UP:
+ new_x = dist_x + offset;
+ new_y = dist_y - (shot->h + 5);
+ break;
+ case TUX_LEFT:
+ new_x = dist_x - (shot->w + 5);
+ new_y = dist_y + offset;
+ break;
+ case TUX_RIGHT:
+ new_x = dist_x + dist_w + 5;
+ new_y = dist_y + offset;
+ break;
+ case TUX_DOWN:
+ new_x = dist_x + offset;
+ new_y = dist_y + dist_h + 5;
+ break;
}
space_move_object(export_fce->fce_arena_get_current()->spaceShot, shot, new_x, new_y);
if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) {
char msg[STR_PROTO_SIZE];
- sprintf(msg, "moveshot %d %d %d %d %d %d", shot->id, shot->x, shot->y, shot->px, shot->py, shot->position);
+ sprintf(msg, "moveshot %d %d %d %d %d %d", shot->id,
+ shot->x, shot->y, shot->px, shot->py, shot->position);
export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg);
}
}
@@ -218,14 +218,9 @@ static void proto_moveshot(char *msg)
#ifndef PUBLIC_SERVER
static int draw(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
return 0;
}
-#endif
+#endif /* PUBLIC_SERVER */
static int event()
{
@@ -234,17 +229,11 @@ static int event()
static int isConflict(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
return 0;
}
static void cmdArena(char *line)
{
- UNUSED(line);
}
static void recvMsg(char *msg)
@@ -253,10 +242,13 @@ static void recvMsg(char *msg)
return;
}
- if (strncmp(msg, "movetux", 7) == 0)
+ if (strncmp(msg, "movetux", 7) == 0) {
proto_movetux(msg);
- if (strncmp(msg, "moveshot", 8) == 0)
+ }
+
+ if (strncmp(msg, "moveshot", 8) == 0) {
proto_moveshot(msg);
+ }
}
static int destroy()
@@ -267,9 +259,9 @@ static int destroy()
mod_sym_t modmove_sym = { &init,
#ifndef PUBLIC_SERVER
&draw,
-#else
+#else /* PUBLIC_SERVER */
0,
-#endif
+#endif /* PUBLIC_SERVER */
&event,
&isConflict,
&cmdArena,
diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c
index 065df07..9319fe0 100644
--- a/src/modules/modPipe.c
+++ b/src/modules/modPipe.c
@@ -16,11 +16,9 @@
#ifndef PUBLIC_SERVER
#include "interface.h"
#include "image.h"
-#endif
-
-#ifdef PUBLIC_SERVER
+#else /* PUBLIC_SERVER */
#include "publicServer.h"
-#endif
+#endif /* PUBLIC_SERVER */
typedef struct pipe_struct {
/* position of the pipe */
@@ -41,7 +39,7 @@ typedef struct pipe_struct {
#ifndef PUBLIC_SERVER
/* its image */
image_t *img;
-#endif
+#endif /* PUBLIC_SERVER */
} pipe_t;
static void (*fce_move_shot) (shot_t *shot, int position, int src_x, int src_y, int dist_x, int dist_y, int dist_w, int dist_h);
@@ -53,15 +51,15 @@ static space_t *spacePipe;
#ifndef PUBLIC_SERVER
static pipe_t *newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position, image_t *img)
-#else
+#else /* PUBLIC_SERVER */
static pipe_t *newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position)
-#endif
+#endif /* PUBLIC_SERVER */
{
pipe_t *new;
#ifndef PUBLIC_SERVER
assert(img != NULL);
-#endif
+#endif /* PUBLIC_SERVER */
new = malloc(sizeof(pipe_t));
assert(new != NULL);
@@ -76,7 +74,7 @@ static pipe_t *newPipe(int x, int y, int w, int h, int layer, int id, int id_out
new->position = position;
#ifndef PUBLIC_SERVER
new->img = img;
-#endif
+#endif /* PUBLIC_SERVER */
return new;
}
@@ -112,7 +110,7 @@ static void drawPipe(pipe_t *p)
export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
}
-#endif
+#endif /* PUBLIC_SERVER */
static void destroyPipe(pipe_t *p)
{
@@ -133,24 +131,17 @@ static void cmd_teleport(char *line)
char str_image[STR_SIZE];
pipe_t *new;
- if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "id", str_id, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "id_out", str_id_out, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "position", str_position, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0)
+ if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "id", str_id, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "id_out", str_id_out, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "position", str_position, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0) {
return;
+ }
#ifndef PUBLIC_SERVER
new = newPipe(atoi(str_x), atoi(str_y),
@@ -158,12 +149,12 @@ static void cmd_teleport(char *line)
atoi(str_layer), atoi(str_id), atoi(str_id_out),
atoi(str_position),
export_fce->fce_image_get(IMAGE_GROUP_USER, str_image));
-#else
+#else /* PUBLIC_SERVER */
new = newPipe(atoi(str_x), atoi(str_y),
atoi(str_w), atoi(str_h),
atoi(str_layer), atoi(str_id), atoi(str_id_out),
atoi(str_position));
-#endif
+#endif /* PUBLIC_SERVER */
if (spacePipe == NULL) {
spacePipe = space_new(export_fce->fce_arena_get_current()->w,
@@ -208,9 +199,6 @@ static int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
static void action_drawpipe(space_t *space, pipe_t *pipe, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
drawPipe(pipe);
}
@@ -225,29 +213,29 @@ static int draw(int x, int y, int w, int h)
return 0;
}
-#endif
+#endif /* PUBLIC_SERVER */
static int negPosition(int n)
{
switch (n) {
- case TUX_UP:
- return TUX_DOWN;
+ case TUX_UP:
+ return TUX_DOWN;
- case TUX_LEFT:
- return TUX_RIGHT;
+ case TUX_LEFT:
+ return TUX_RIGHT;
- case TUX_RIGHT:
- return TUX_LEFT;
+ case TUX_RIGHT:
+ return TUX_LEFT;
- case TUX_DOWN:
- return TUX_UP;
+ case TUX_DOWN:
+ return TUX_UP;
- default:
- fatal("Tux is probably moving in another dimension");
- break;
+ default:
+ fatal("Tux is probably moving in another dimension");
+ break;
}
- return -1; /* no warnings */
+ return -1;
}
static void action_eventpipe(space_t *space, pipe_t *pipe, shot_t *shot)
@@ -255,8 +243,6 @@ static void action_eventpipe(space_t *space, pipe_t *pipe, shot_t *shot)
arena_t *arena;
tux_t *author;
- UNUSED(space);
-
arena = export_fce->fce_arena_get_current();
author = space_get_object_id(arena->spaceTux, shot->author_id);
@@ -323,7 +309,6 @@ static void cmdArena(char *line)
static void recvMsg(char *msg)
{
- UNUSED(msg);
}
static int destroy()
@@ -340,9 +325,9 @@ static int destroy()
mod_sym_t modpipe_sym = { &init,
#ifndef PUBLIC_SERVER
&draw,
-#else
+#else /* PUBLIC_SERVER */
0,
-#endif
+#endif /* PUBLIC_SERVER */
&event,
&isConflict,
&cmdArena,
diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c
index b7ca273..c8cf573 100644
--- a/src/modules/modTeleport.c
+++ b/src/modules/modTeleport.c
@@ -14,9 +14,9 @@
#ifndef PUBLIC_SERVER
#include "interface.h"
#include "image.h"
-#else
+#else /* PUBLIC_SERVER */
#include "publicServer.h"
-#endif
+#endif /* PUBLIC_SERVER */
typedef struct teleport_struct {
int id;
@@ -35,7 +35,7 @@ typedef struct teleport_struct {
#ifndef PUBLIC_SERVER
/* its image */
image_t *img;
-#endif
+#endif /* PUBLIC_SERVER */
} teleport_t;
static export_fce_t *export_fce;
@@ -50,9 +50,9 @@ static void (*fce_move_shot) (shot_t *shot, int position, int src_x,
#ifndef PUBLIC_SERVER
static teleport_t *newTeleport(int x, int y, int w, int h, int layer, image_t *img)
-#else
+#else /* PUBLIC_SERVER */
static teleport_t *newTeleport(int x, int y, int w, int h, int layer)
-#endif
+#endif /* PUBLIC_SERVER */
{
static int last_id = 0;
@@ -60,7 +60,7 @@ static teleport_t *newTeleport(int x, int y, int w, int h, int layer)
#ifndef PUBLIC_SERVER
assert(img != NULL);
-#endif
+#endif /* PUBLIC_SERVER */
new = malloc(sizeof(teleport_t));
assert(new != NULL);
@@ -73,7 +73,7 @@ static teleport_t *newTeleport(int x, int y, int w, int h, int layer)
new->layer = layer;
#ifndef PUBLIC_SERVER
new->img = img;
-#endif
+#endif /* PUBLIC_SERVER */
return new;
}
@@ -109,7 +109,7 @@ static void drawTeleport(teleport_t *p)
export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
}
-#endif
+#endif /* PUBLIC_SERVER */
static void destroyTeleport(teleport_t *p)
{
@@ -127,29 +127,25 @@ static void cmd_teleport(char *line)
char str_image[STR_SIZE];
teleport_t *new;
- if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0)
+ if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0) {
return;
+ }
#ifndef PUBLIC_SERVER
new = newTeleport(atoi(str_x), atoi(str_y),
atoi(str_w), atoi(str_h),
atoi(str_layer),
export_fce->fce_image_get(IMAGE_GROUP_USER, str_image));
-#else
+#else /* PUBLIC_SERVER */
new = newTeleport(atoi(str_x), atoi(str_y),
atoi(str_w), atoi(str_h),
atoi(str_layer));
-#endif
+#endif /* PUBLIC_SERVER */
if (spaceTeleport == NULL) {
spaceTeleport = space_new(export_fce->fce_arena_get_current()->w,
@@ -175,22 +171,22 @@ static teleport_t *getRandomTeleportBut(space_t *space, teleport_t *teleport)
static int getRandomPosition()
{
switch (random() % 4) {
- case 0:
- return TUX_UP;
+ case 0:
+ return TUX_UP;
- case 1:
- return TUX_LEFT;
+ case 1:
+ return TUX_LEFT;
- case 2:
- return TUX_RIGHT;
+ case 2:
+ return TUX_RIGHT;
- case 3:
- return TUX_DOWN;
+ case 3:
+ return TUX_DOWN;
}
fatal("Generated a random number which is not in range 0 to 3");
- return -1; /* no warnings */
+ return -1;
}
static void teleportTux(tux_t *tux, teleport_t *teleport)
@@ -224,15 +220,9 @@ static int init(export_fce_t *p)
listTeleport = list_new();
- if (export_fce->fce_module_load_dep("libmodMove") != 0) {
- return -1;
- }
-
- if ((fce_move_tux = export_fce->fce_share_function_get("move_tux")) == NULL) {
- return -1;
- }
-
- if ((fce_move_shot = export_fce->fce_share_function_get("move_shot")) == NULL) {
+ if (export_fce->fce_module_load_dep("libmodMove") != 0 ||
+ (fce_move_tux = export_fce->fce_share_function_get("move_tux")) == NULL ||
+ (fce_move_shot = export_fce->fce_share_function_get("move_shot")) == NULL) {
return -1;
}
@@ -242,9 +232,6 @@ static int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
static void action_drawteleport(space_t *space, teleport_t *teleport, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
drawTeleport(teleport);
}
@@ -258,15 +245,13 @@ static int draw(int x, int y, int w, int h)
return 0;
}
-#endif
+#endif /* PUBLIC_SERVER */
static void action_eventteleportshot(space_t *space, teleport_t *teleport, shot_t *shot)
{
arena_t *arena;
tux_t *author;
- UNUSED(space);
-
arena = export_fce->fce_arena_get_current();
author = space_get_object_id(arena->spaceTux, shot->author_id);
@@ -280,16 +265,12 @@ static void action_eventteleportshot(space_t *space, teleport_t *teleport, shot_
static void action_eventshot(space_t *space, shot_t *shot, space_t *p_spaceTeleport)
{
- UNUSED(space);
-
space_action_from_location(p_spaceTeleport, action_eventteleportshot,
shot, shot->x, shot->y, shot->w, shot->h);
}
static void action_eventteleporttux(space_t *space, teleport_t *teleport, tux_t *tux)
{
- UNUSED(space);
-
teleportTux(tux, teleport);
}
@@ -297,8 +278,6 @@ static void action_eventtux(space_t *space, tux_t *tux, space_t *p_spaceTeleport
{
int x, y, w, h;
- UNUSED(space);
-
export_fce->fce_tux_get_proportion(tux, &x, &y, &w, &h);
space_action_from_location(p_spaceTeleport, action_eventteleporttux, tux, x, y, w, h);
@@ -322,11 +301,6 @@ static int event()
static int isConflict(int x, int y, int w, int h)
{
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
-
if (spaceTeleport == NULL) {
return 0;
}
@@ -343,7 +317,6 @@ static void cmdArena(char *line)
static void recvMsg(char *msg)
{
- UNUSED(msg);
}
static int destroy()
@@ -360,9 +333,9 @@ static int destroy()
mod_sym_t modteleport_sym = { &init,
#ifndef PUBLIC_SERVER
&draw,
-#else
+#else /* PUBLIC_SERVER */
0,
-#endif
+#endif /* PUBLIC_SERVER */
&event,
&isConflict,
&cmdArena,
diff --git a/src/modules/modWall.c b/src/modules/modWall.c
index bacbfe8..7a1fa7a 100644
--- a/src/modules/modWall.c
+++ b/src/modules/modWall.c
@@ -138,11 +138,6 @@ static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
static void setStatusImgWall(void *p, int x, int y, int w, int h)
{
- UNUSED(p);
- UNUSED(x);
- UNUSED(y);
- UNUSED(w);
- UNUSED(h);
}
#endif /* PUBLIC_SERVER */
@@ -163,24 +158,20 @@ static void cmd_wall(char *line)
rel = 0;
- if (export_fce->fce_getValue(line, "rel", str_rel, STR_NUM_SIZE) != 0)
+ if (export_fce->fce_getValue(line, "rel", str_rel, STR_NUM_SIZE) != 0) {
strcpy(str_rel, "0");
- if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "img_x", str_img_x, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "img_y", str_img_y, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0)
- return;
- if (export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0)
+ }
+
+ if (export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "img_x", str_img_x, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "img_y", str_img_y, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 ||
+ export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0) {
return;
+ }
rel = atoi(str_rel);
x = atoi(str_x);
@@ -234,9 +225,6 @@ static int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
static void action_drawwall(space_t *space, wall_t *wall, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
drawWall(wall);
}
@@ -259,9 +247,6 @@ static void action_eventwall(space_t *space, wall_t *wall, shot_t *shot)
arena_t *arena;
tux_t *author;
- UNUSED(space);
- UNUSED(wall);
-
arena = export_fce->fce_arena_get_current();
author = space_get_object_id(arena->spaceTux, shot->author_id);
@@ -323,7 +308,6 @@ static void cmdArena(char *line)
static void recvMsg(char *msg)
{
- UNUSED(msg);
}
static int destroy()
diff --git a/src/screen/world.c b/src/screen/world.c
index 3d3214b..90d10a1 100644
--- a/src/screen/world.c
+++ b/src/screen/world.c
@@ -379,14 +379,11 @@ void world_event()
void dialog_yes(void *p)
{
- UNUSED(p);
-
world_do_end();
}
void dialog_no(void *p)
{
- UNUSED(p);
}
static void hotkey_escape()
@@ -423,9 +420,6 @@ void startWorld()
static void action_analyze(space_t *space, tux_t *tux, void *p)
{
- UNUSED(space);
- UNUSED(p);
-
analyze_add(tux->name, tux->score);
}