From f1ebdbfdbe4d3ce7fc6eaa6a164134b06cfb9603 Mon Sep 17 00:00:00 2001 From: Tomas 'ZeXx86' Jedrzejek Date: Thu, 10 Dec 2009 17:38:09 +0100 Subject: Total conversion of the shared modules to static, fix warning in arenaFile.c, improvements in some areas of a code --- src/modules/modAI.c | 34 +++++++++++++++++++++------------- src/modules/modBasic.c | 23 +++++++++++++++-------- src/modules/modMove.c | 22 +++++++++++++++------- src/modules/modPipe.c | 22 +++++++++++++++------- src/modules/modTeleport.c | 26 +++++++++++++++++--------- src/modules/modWall.c | 32 ++++++++++++++++++++------------ 6 files changed, 103 insertions(+), 56 deletions(-) (limited to 'src/modules') diff --git a/src/modules/modAI.c b/src/modules/modAI.c index 57fe96d..13d1419 100644 --- a/src/modules/modAI.c +++ b/src/modules/modAI.c @@ -27,7 +27,7 @@ typedef struct alternative_struct { int x, y; } alternative_t; -alternative_t *newAlternative(int route, int x, int y) +static alternative_t *newAlternative(int route, int x, int y) { alternative_t *new; @@ -41,7 +41,7 @@ alternative_t *newAlternative(int route, int x, int y) return new; } -alternative_t *cloneAlternative(alternative_t *p, int route, int x, int y) +static alternative_t *cloneAlternative(alternative_t *p, int route, int x, int y) { alternative_t *new; @@ -57,7 +57,7 @@ alternative_t *cloneAlternative(alternative_t *p, int route, int x, int y) return new; } -void forkAlternative(list_t *list, alternative_t *p, int w, int h) +static void forkAlternative(list_t *list, alternative_t *p, int w, int h) { int x, y; @@ -88,7 +88,7 @@ void forkAlternative(list_t *list, alternative_t *p, int w, int h) } -void moveAlternative(alternative_t *p, int offset) +static void moveAlternative(alternative_t *p, int offset) { assert(p != NULL); @@ -112,7 +112,7 @@ void moveAlternative(alternative_t *p, int offset) } } -void destroyAlternative(alternative_t *p) +static void destroyAlternative(alternative_t *p) { assert(p != NULL); free(p); @@ -123,7 +123,7 @@ static void cmd_ai(char *line) UNUSED(line); } -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; @@ -131,7 +131,7 @@ int init(export_fce_t *p) } #ifndef PUBLIC_SERVER -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -142,7 +142,7 @@ int draw(int x, int y, int w, int h) } #endif -tux_t *findOtherTux(space_t *space) +static tux_t *findOtherTux(space_t *space) { int i; @@ -343,7 +343,7 @@ static void action_tuxAI(space_t *space, tux_t *tux, void *p) } } -int event() +static int event() { static my_time_t lastEvent = 0; my_time_t curentTime; @@ -391,7 +391,7 @@ int event() return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -401,18 +401,26 @@ int isConflict(int x, int y, int w, int h) return 0; } -void cmdArena(char *line) +static void cmdArena(char *line) { if (strncmp(line, "ai", 2) == 0) cmd_ai(line); } -void recvMsg(char *msg) +static void recvMsg(char *msg) { UNUSED(msg); } -int destroy() +static int destroy() { return 0; } + +mod_sym_t modai_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; \ No newline at end of file diff --git a/src/modules/modBasic.c b/src/modules/modBasic.c index a91b7f6..1b5aa41 100644 --- a/src/modules/modBasic.c +++ b/src/modules/modBasic.c @@ -20,7 +20,7 @@ static export_fce_t *export_fce; -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; @@ -29,8 +29,7 @@ int init(export_fce_t *p) } #ifndef PUBLIC_SERVER - -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -42,13 +41,13 @@ int draw(int x, int y, int w, int h) } #endif -int event() +static int event() { debug("Basic module catch event"); return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { debug("isConflict(%d, %d, %d, %d) in Basic module", x, y, w, h); return 0; @@ -59,19 +58,27 @@ static void cmd_basic(char *line) debug("cmd_basic(%s) in Basic module", line); } -void cmdArena(char *line) +static void cmdArena(char *line) { if (strncmp(line, "basic", 5) == 0) cmd_basic(line); } -void recvMsg(char *msg) +static void recvMsg(char *msg) { debug("recvMsg(%s) in Basic module", msg); } -int destroy() +static int destroy() { debug("Destroying Basic module"); return 0; } + +mod_sym_t modbasic_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; diff --git a/src/modules/modMove.c b/src/modules/modMove.c index 7c7a862..95157f9 100644 --- a/src/modules/modMove.c +++ b/src/modules/modMove.c @@ -160,7 +160,7 @@ static void move_shot(shot_t *shot, int position, int src_x, int src_y, int dist } } -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; export_fce->fce_share_function_add("move_tux", (void *) move_tux); @@ -216,7 +216,7 @@ static void proto_moveshot(char *msg) } #ifndef PUBLIC_SERVER -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -227,12 +227,12 @@ int draw(int x, int y, int w, int h) } #endif -int event() +static int event() { return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -242,12 +242,12 @@ int isConflict(int x, int y, int w, int h) return 0; } -void cmdArena(char *line) +static void cmdArena(char *line) { UNUSED(line); } -void recvMsg(char *msg) +static void recvMsg(char *msg) { if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { return; @@ -259,7 +259,15 @@ void recvMsg(char *msg) proto_moveshot(msg); } -int destroy() +static int destroy() { return 0; } + +mod_sym_t modmove_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index dea5ea1..d2e9fec 100644 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -188,7 +188,7 @@ static void moveShotFromPipe(shot_t *shot, pipe_t *pipe) fce_move_shot(shot, distPipe->position, pipe->x, pipe->y, distPipe->x, distPipe->y, distPipe->w, distPipe->h); } -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; @@ -214,7 +214,7 @@ static void action_drawpipe(space_t *space, pipe_t *pipe, void *p) drawPipe(pipe); } -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { if (spacePipe == NULL) { return 0; @@ -289,7 +289,7 @@ static void action_eventshot(space_t *space, shot_t *shot, space_t *p_spacePipe) } } -int event() +static int event() { if (spacePipe == NULL) { return 0; @@ -305,7 +305,7 @@ int event() return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { if (spacePipe == NULL) { return 0; @@ -314,22 +314,30 @@ int isConflict(int x, int y, int w, int h) return space_is_conflict_with_object(spacePipe, x, y, w, h); } -void cmdArena(char *line) +static void cmdArena(char *line) { if (strncmp(line, "pipe", 4) == 0) { cmd_teleport(line); } } -void recvMsg(char *msg) +static void recvMsg(char *msg) { UNUSED(msg); } -int destroy() +static int destroy() { space_destroy_with_item(spacePipe, destroyPipe); list_destroy(listPipe); return 0; } + +mod_sym_t modpipe_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; \ No newline at end of file diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index 289f553..0285ca0 100644 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -49,9 +49,9 @@ static void (*fce_move_shot) (shot_t *shot, int position, int src_x, int dist_h); #ifndef PUBLIC_SERVER -teleport_t *newTeleport(int x, int y, int w, int h, int layer, image_t *img) +static teleport_t *newTeleport(int x, int y, int w, int h, int layer, image_t *img) #else -teleport_t *newTeleport(int x, int y, int w, int h, int layer) +static teleport_t *newTeleport(int x, int y, int w, int h, int layer) #endif { static int last_id = 0; @@ -218,7 +218,7 @@ static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, space_t *sp distTeleport->h); } -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; @@ -248,7 +248,7 @@ static void action_drawteleport(space_t *space, teleport_t *teleport, void *p) drawTeleport(teleport); } -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { if (spaceTeleport == NULL) { return 0; @@ -304,7 +304,7 @@ static void action_eventtux(space_t *space, tux_t *tux, space_t *p_spaceTeleport space_action_from_location(p_spaceTeleport, action_eventteleporttux, tux, x, y, w, h); } -int event() +static int event() { if (spaceTeleport == NULL) { return 0; @@ -320,7 +320,7 @@ int event() return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { UNUSED(x); UNUSED(y); @@ -334,20 +334,28 @@ int isConflict(int x, int y, int w, int h) return 0; } -void cmdArena(char *line) +static void cmdArena(char *line) { if (strncmp(line, "teleport", 8) == 0) cmd_teleport(line); } -void recvMsg(char *msg) +static void recvMsg(char *msg) { UNUSED(msg); } -int destroy() +static int destroy() { space_destroy_with_item(spaceTeleport, destroyTeleport); list_destroy(listTeleport); return 0; } + +mod_sym_t modteleport_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; \ No newline at end of file diff --git a/src/modules/modWall.c b/src/modules/modWall.c index bb451e0..2091c5e 100644 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -52,9 +52,9 @@ static space_t *spaceImgWall; static list_t *listWall; #ifndef PUBLIC_SERVER -wall_t *newWall(int x, int y, int w, int h, int img_x, int img_y, int layer, image_t *img) +static wall_t *newWall(int x, int y, int w, int h, int img_x, int img_y, int layer, image_t *img) #else -wall_t *newWall(int x, int y, int w, int h, int img_x, int img_y, int layer) +static wall_t *newWall(int x, int y, int w, int h, int img_x, int img_y, int layer) #endif { static int last_id = 0; @@ -83,7 +83,7 @@ wall_t *newWall(int x, int y, int w, int h, int img_x, int img_y, int layer) #ifndef PUBLIC_SERVER -void drawWall(wall_t *p) +static void drawWall(wall_t *p) { assert(p != NULL); @@ -94,7 +94,7 @@ void drawWall(wall_t *p) p->layer); } -void drawListWall(list_t *list) +static void drawListWall(list_t *list) { wall_t *thisWall; int i; @@ -110,7 +110,7 @@ void drawListWall(list_t *list) #endif -void destroyWall(wall_t *p) +static void destroyWall(wall_t *p) { assert(p != NULL); free(p); @@ -242,7 +242,7 @@ static void cmd_wall(char *line) #endif } -int init(export_fce_t *p) +static int init(export_fce_t *p) { export_fce = p; listWall = list_new(); @@ -259,7 +259,7 @@ static void action_drawwall(space_t *space, wall_t *wall, void *p) drawWall(wall); } -int draw(int x, int y, int w, int h) +static int draw(int x, int y, int w, int h) { if (spaceWall == NULL) { return 0; @@ -312,7 +312,7 @@ static void action_eventshot(space_t *space, shot_t *shot, space_t *p_spaceWall) } } -int event() +static int event() { if (spaceWall == NULL) { return 0; @@ -324,7 +324,7 @@ int event() return 0; } -int isConflict(int x, int y, int w, int h) +static int isConflict(int x, int y, int w, int h) { if (spaceWall == NULL) { return 0; @@ -333,19 +333,19 @@ int isConflict(int x, int y, int w, int h) return space_is_conflict_with_object(spaceWall, x, y, w, h); } -void cmdArena(char *line) +static void cmdArena(char *line) { if (strncmp(line, "wall", 4) == 0) { cmd_wall(line); } } -void recvMsg(char *msg) +static void recvMsg(char *msg) { UNUSED(msg); } -int destroy() +static int destroy() { space_destroy_with_item(spaceWall, destroyWall); #ifndef PUBLIC_SERVER @@ -354,3 +354,11 @@ int destroy() list_destroy(listWall); return 0; } + +mod_sym_t modwall_sym = { &init, + &draw, + &event, + &isConflict, + &cmdArena, + &recvMsg, + &destroy }; \ No newline at end of file -- cgit v1.2.3