diff options
| author | xHire <xhire@tuxportal.cz> | 2009-04-25 23:48:25 +0200 |
|---|---|---|
| committer | xHire <xhire@tuxportal.cz> | 2009-05-26 01:09:22 +0200 |
| commit | a1d6339b26fc38d374cd400481a8703ba3199596 (patch) | |
| tree | 9474350b12eea123bc2b87087fe78560a7feeef1 /src | |
| parent | d7c19720ba9a3739f6a3e91a47a8cd6ad0429669 (diff) | |
Rewritten messages/comments in code of modules
Rectified the coding style in code of modules
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/modAI.c | 47 | ||||
| -rw-r--r-- | src/modules/modBasic.c | 27 | ||||
| -rw-r--r-- | src/modules/modMove.c | 78 | ||||
| -rw-r--r-- | src/modules/modPipe.c | 143 | ||||
| -rw-r--r-- | src/modules/modTeleport.c | 118 | ||||
| -rw-r--r-- | src/modules/modWall.c | 101 |
6 files changed, 219 insertions, 295 deletions
diff --git a/src/modules/modAI.c b/src/modules/modAI.c index b987f20..57fe96d 100644 --- a/src/modules/modAI.c +++ b/src/modules/modAI.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -13,10 +12,10 @@ #include "space.h" #ifndef PUBLIC_SERVER -# include "interface.h" -# include "image.h" +#include "interface.h" +#include "image.h" #else -# include "publicServer.h" +#include "publicServer.h" #endif static export_fce_t *export_fce; @@ -42,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) +alternative_t *cloneAlternative(alternative_t *p, int route, int x, int y) { alternative_t *new; @@ -58,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) +void forkAlternative(list_t *list, alternative_t *p, int w, int h) { int x, y; @@ -89,13 +88,13 @@ void forkAlternative(list_t * list, alternative_t * p, int w, int h) } -void moveAlternative(alternative_t * p, int offset) +void moveAlternative(alternative_t *p, int offset) { assert(p != NULL); p->step++; - //printf("move %d %d %d\n", p->x, p->y, p->step); + /*printf("move %d %d %d\n", p->x, p->y, p->step);*/ switch (p->route) { case TUX_UP: @@ -113,7 +112,7 @@ void moveAlternative(alternative_t * p, int offset) } } -void destroyAlternative(alternative_t * p) +void destroyAlternative(alternative_t *p) { assert(p != NULL); free(p); @@ -124,7 +123,7 @@ static void cmd_ai(char *line) UNUSED(line); } -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; @@ -143,7 +142,7 @@ int draw(int x, int y, int w, int h) } #endif -tux_t *findOtherTux(space_t * space) +tux_t *findOtherTux(space_t *space) { int i; @@ -160,7 +159,7 @@ tux_t *findOtherTux(space_t * space) return NULL; } -static void shotTux(arena_t * arena, tux_t * tux_ai, tux_t * tux_rival) +static void shotTux(arena_t *arena, tux_t *tux_ai, tux_t *tux_rival) { const int limit = 20; int x_ai, y_ai; @@ -193,7 +192,7 @@ static void shotTux(arena_t * arena, tux_t * tux_ai, tux_t * tux_rival) } } -static void tux_eventAI(tux_t * tux) +static void tux_eventAI(tux_t *tux) { arena_t *arena; tux_t *rivalTux; @@ -212,7 +211,7 @@ static void tux_eventAI(tux_t * tux) int countDo = 0; export_fce->fce_tux_get_proportion(tux, &x, &y, &w, &h); - //printf("tux AI %d %d\n", x, y); + /*printf("tux AI %d %d\n", x, y);*/ arena = export_fce->fce_arena_get_current(); @@ -229,7 +228,7 @@ static void tux_eventAI(tux_t * tux) shotTux(arena, tux, rivalTux); export_fce->fce_tux_get_proportion(rivalTux, &rival_x, &rival_y, NULL, NULL); - //printf("tux rival %d %d\n", rival_x, rival_y); + /*printf("tux rival %d %d\n", rival_x, rival_y);*/ list_add(listAlternative, newAlternative(TUX_UP, x, y - (h + 10))); list_add(listAlternative, newAlternative(TUX_RIGHT, x + (w + 10), y)); @@ -245,7 +244,7 @@ static void tux_eventAI(tux_t * tux) int j; - //printf("listFork->count = %d\n", listFork->count); + /*printf("listFork->count = %d\n", listFork->count);*/ for (j = 0; j < listFork->count; j++) { list_add(listAlternative, listFork->list[j]); @@ -283,17 +282,17 @@ static void tux_eventAI(tux_t * tux) 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); + /*printf("this->step = %d\n", this->step);*/ list_del(listAlternative, my_index); list_add(listDst, this); my_index--; - //continue; + /*continue;*/ break; } if (export_fce->fce_arena_is_free_space(arena, this->x, this->y, w, h) == 0) { - //forkAlternative(listFork, this, w*2, h*2); + /*forkAlternative(listFork, this, w*2, h*2);*/ list_del_item(listAlternative, my_index, destroyAlternative); my_index--; countDel++; @@ -306,13 +305,13 @@ static void tux_eventAI(tux_t * tux) int minStep = 1000; int recRoute = 0; - //printf("------------\n"); + /*printf("------------\n");*/ for (i = 0; i < listDst->count; i++) { alternative_t *this; this = (alternative_t *) listDst->list[i]; - //printf("XXX step %d route = %d\n", this->step, this->first); + /*printf("XXX step %d route = %d\n", this->step, this->first);*/ if (this->step < minStep) { minStep = this->step; recRoute = this->first; @@ -334,7 +333,7 @@ static void tux_eventAI(tux_t * tux) */ } -static void action_tuxAI(space_t * space, tux_t * tux, void *p) +static void action_tuxAI(space_t *space, tux_t *tux, void *p) { UNUSED(space); UNUSED(p); @@ -350,7 +349,7 @@ int event() my_time_t curentTime; arena_t *arena; int countTuxAI; - //int i; + /*int i;*/ if (lastEvent == 0) { lastEvent = export_fce->fce_timer_get_current_time(); @@ -363,7 +362,7 @@ int event() } lastEvent = export_fce->fce_timer_get_current_time(); - //printf("event AI\n"); + /*printf("event AI\n");*/ arena = export_fce->fce_arena_get_current(); diff --git a/src/modules/modBasic.c b/src/modules/modBasic.c index 3b0f9b3..5b5e222 100644 --- a/src/modules/modBasic.c +++ b/src/modules/modBasic.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -13,21 +12,19 @@ #include "space.h" #ifndef PUBLIC_SERVER -# include "interface.h" -# include "image.h" -#endif - -#ifdef PUBLIC_SERVER -# include "publicServer.h" +#include "interface.h" +#include "image.h" +#else +#include "publicServer.h" #endif static export_fce_t *export_fce; -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; - printf("Initializing Basic module.\n"); + printf("[Debug] Initializing Basic module\n"); return 0; } @@ -40,26 +37,26 @@ int draw(int x, int y, int w, int h) UNUSED(w); UNUSED(h); - printf("Drawing Basic module.\n"); + printf("[Debug] Drawing Basic module\n"); return 0; } #endif int event() { - printf("Basic module catch event.\n"); + printf("[Debug] Basic module catch event\n"); return 0; } int isConflict(int x, int y, int w, int h) { - printf("isConflict(%d, %d, %d, %d) in Basic module.\n", x, y, w, h); + printf("[Debug] isConflict(%d, %d, %d, %d) in Basic module\n", x, y, w, h); return 0; } static void cmd_basic(char *line) { - printf("cmd_basic(%s) in Basic module.\n", line); + printf("[Debug] cmd_basic(%s) in Basic module\n", line); } void cmdArena(char *line) @@ -70,11 +67,11 @@ void cmdArena(char *line) void recvMsg(char *msg) { - printf("recvMsg(%s) in Basic module.\n", msg); + printf("[Debug] recvMsg(%s) in Basic module\n", msg); } int destroy() { - printf("Destroying Basic module.\n"); + printf("[Debug] Destroying Basic module\n"); return 0; } diff --git a/src/modules/modMove.c b/src/modules/modMove.c index fc616a7..950995e 100644 --- a/src/modules/modMove.c +++ b/src/modules/modMove.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -24,13 +23,14 @@ static export_fce_t *export_fce; -static void move_tux(tux_t * tux, int x, int y, int w, int h) +static void move_tux(tux_t *tux, int x, int y, int w, int h) { - int dist_x = 0, dist_y = 0; // no warnning + int dist_x = 0, dist_y = 0; /* no warnings */ - if (tux->bonus == BONUS_GHOST || - export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) + 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; @@ -49,27 +49,23 @@ static void move_tux(tux_t * tux, int x, int y, int w, int h) dist_y = y + h + 20; break; default: - assert(!"Variable p->control has a really wierd value!"); + assert(!_("[Debug] Variable p->control in modMove has a really weird value.\n")); 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); + + 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); + /*sound_play("teleport", SOUND_GROUP_BASE);*/ #endif 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); - if (tux->bonus == BONUS_HIDDEN) - export_fce->fce_proto_send_module_server(PROTO_SEND_ONE, - (client_t *) tux-> - client, msg); - else - export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, - msg); + if (tux->bonus == BONUS_HIDDEN) { + export_fce->fce_proto_send_module_server(PROTO_SEND_ONE, (client_t *) tux->client, msg); + } else { + export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg); + } } } } @@ -80,13 +76,12 @@ static int myAbs(int n) } -static int getSppedShot(shot_t * shot) +static int getSppedShot(shot_t *shot) { - return (myAbs(shot->px) > - myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py)); + return (myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py)); } -static void transformShot(shot_t * shot, int position) +static void transformShot(shot_t *shot, int position) { int speed; @@ -113,18 +108,17 @@ static void transformShot(shot_t * shot, int position) shot->position = position; shot->isCanKillAuthor = TRUE; - if (shot->gun == GUN_LASSER) + if (shot->gun == GUN_LASSER) { export_fce->fce_shot_transform_lasser(shot); + } } -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 warninng + int new_x = 0, new_y = 0; /* no warnings */ - //printf("move_shot\n"); + /*printf("move_shot\n");*/ switch (shot->position) { case TUX_UP: case TUX_DOWN: @@ -157,19 +151,16 @@ move_shot(shot_t * shot, int position, int src_x, int src_y, break; } - space_move_object(export_fce->fce_arena_get_current()->spaceShot, shot, - new_x, new_y); + 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); } } -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; export_fce->fce_share_function_add("move_tux", (void *) move_tux); @@ -191,8 +182,9 @@ static void proto_movetux(char *msg) space = export_fce->fce_arena_get_current()->spaceTux; tux = space_get_object_id(space, id); - if (tux != NULL) + if (tux != NULL) { space_move_object(space, tux, x, y); + } } static void proto_moveshot(char *msg) @@ -204,13 +196,13 @@ static void proto_moveshot(char *msg) assert(msg != NULL); - sscanf(msg, "%s %d %d %d %d %d %d", - cmd, &shot_id, &x, &y, &px, &py, &position); + sscanf(msg, "%s %d %d %d %d %d %d", cmd, &shot_id, &x, &y, &px, &py, &position); space = export_fce->fce_arena_get_current()->spaceShot; - if ((shot = space_get_object_id(space, shot_id)) == NULL) + if ((shot = space_get_object_id(space, shot_id)) == NULL) { return; + } space_move_object(space, shot, x, y); shot->isCanKillAuthor = 1; @@ -218,12 +210,12 @@ static void proto_moveshot(char *msg) shot->px = px; shot->py = py; - if (shot->gun == GUN_LASSER) + if (shot->gun == GUN_LASSER) { export_fce->fce_shot_transform_lasser(shot); + } } #ifndef PUBLIC_SERVER - int draw(int x, int y, int w, int h) { UNUSED(x); @@ -233,7 +225,6 @@ int draw(int x, int y, int w, int h) return 0; } - #endif int event() @@ -258,8 +249,9 @@ void cmdArena(char *line) void recvMsg(char *msg) { - if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) + if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { return; + } if (strncmp(msg, "movetux", 7) == 0) proto_movetux(msg); diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index ee7e10d..adf542c 100644 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -15,35 +14,37 @@ #include "serverSendMsg.h" #ifndef PUBLIC_SERVER -# include "interface.h" -# include "image.h" +#include "interface.h" +#include "image.h" #endif #ifdef PUBLIC_SERVER -# include "publicServer.h" +#include "publicServer.h" #endif typedef struct pipe_struct { - int x; // poloha steny + /* position of the pipe */ + int x; int y; - int w; // rozmery steny + /* size of the pipe */ + int w; int h; int id; int id_out; int position; - int layer; // vrstva + /* layer in the arena where the pipe lies */ + int layer; #ifndef PUBLIC_SERVER - image_t *img; //obrazok + /* its image */ + image_t *img; #endif } 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); +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); static export_fce_t *export_fce; @@ -51,12 +52,9 @@ static list_t *listPipe; 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) -#endif -#ifdef PUBLIC_SERVER - static pipe_t *newPipe(int x, int y, int w, int h, int layer, int id, - int id_out, int position) +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 +static pipe_t *newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position) #endif { pipe_t *new; @@ -108,24 +106,20 @@ static void getStatusPipe(void *p, int *id, int *x, int *y, int *w, int *h) } #ifndef PUBLIC_SERVER - -static void drawPipe(pipe_t * p) +static void drawPipe(pipe_t *p) { assert(p != NULL); - export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, - p->layer); + export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); } - #endif -static void destroyPipe(pipe_t * p) +static void destroyPipe(pipe_t *p) { assert(p != NULL); free(p); } - static void cmd_teleport(char *line) { char str_x[STR_NUM_SIZE]; @@ -149,11 +143,9 @@ static void cmd_teleport(char *line) 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) + 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) + 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; @@ -162,45 +154,41 @@ static void cmd_teleport(char *line) #ifndef 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), - export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); -#endif - -#ifdef PUBLIC_SERVER + atoi(str_w), atoi(str_h), + atoi(str_layer), atoi(str_id), atoi(str_id_out), + atoi(str_position), + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); +#else 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)); + atoi(str_w), atoi(str_h), + atoi(str_layer), atoi(str_id), atoi(str_id_out), + atoi(str_position)); #endif if (spacePipe == NULL) { - spacePipe = - space_new(export_fce->fce_arena_get_current()->w, - export_fce->fce_arena_get_current()->h, 320, 240, - getStatusPipe, setStatusPipe); + spacePipe = space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, 320, 240, + etStatusPipe, setStatusPipe); } space_add(spacePipe, new); } -static void moveShotFromPipe(shot_t * shot, pipe_t * pipe) +static void moveShotFromPipe(shot_t *shot, pipe_t *pipe) { pipe_t *distPipe; distPipe = space_get_object_id(spacePipe, pipe->id_out); if (distPipe == NULL) { - fprintf(stderr, "Pipe ID for pipe \"%d\" was not found\n", pipe->id); + fprintf(stderr, "[Error] Pipe ID was not found [%d]\n", pipe->id); return; } - fce_move_shot(shot, distPipe->position, pipe->x, pipe->y, - distPipe->x, distPipe->y, distPipe->w, distPipe->h); + fce_move_shot(shot, distPipe->position, pipe->x, pipe->y, distPipe->x, distPipe->y, distPipe->w, distPipe->h); } -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; @@ -218,8 +206,7 @@ int init(export_fce_t * p) } #ifndef PUBLIC_SERVER - -static void action_drawpipe(space_t * space, pipe_t * pipe, void *p) +static void action_drawpipe(space_t *space, pipe_t *pipe, void *p) { UNUSED(space); UNUSED(p); @@ -234,7 +221,7 @@ int draw(int x, int y, int w, int h) } space_action_from_location(spacePipe, action_drawpipe, NULL, x, y, w, h); - //space_print(spacePipe); + /*space_print(spacePipe);*/ return 0; } @@ -256,45 +243,14 @@ static int negPosition(int n) return TUX_UP; default: - assert(!"Tux is moving in another dimension maybe!"); + assert(!_("[Error] Tux is probably moving in another dimension")); break; } - return -1; // no warnning + return -1; /* no warnings */ } - -#if 0 //zaloha -static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) -{ - arena_t *arena; - tux_t *author; - - arena = export_fce->fce_arena_get_current(); - - author = space_get_object_id(arena->spaceTux, shot->author_id); - - if (author != NULL && - author->bonus == BONUS_GHOST && author->bonus_time > 0) { - return; - } - - if (negPosition(shot->position) == pipe->position && - export_fce->fce_net_multiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { - moveShotFromPipe(shot, pipe); - } else { - if (shot->gun == GUN_BOMBBALL && - export_fce->fce_net_multiplayer_get_game_type() != NET_GAME_TYPE_CLIENT) { - export_fce->fce_shot_bound_bombBall(shot); - } else { - //space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy); - shot->del = TRUE; - } - } -} -#endif - -static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) +static void action_eventpipe(space_t *space, pipe_t *pipe, shot_t *shot) { arena_t *arena; tux_t *author; @@ -305,12 +261,11 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) author = space_get_object_id(arena->spaceTux, shot->author_id); - if (author != NULL && - author->bonus == BONUS_GHOST && author->bonus_time > 0) { + if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { return; } - if (negPosition(shot->position) == pipe->position ) { + if (negPosition(shot->position) == pipe->position) { moveShotFromPipe(shot, pipe); } else { if (shot->gun == GUN_BOMBBALL) { @@ -321,11 +276,9 @@ static void action_eventpipe(space_t * space, pipe_t * pipe, shot_t * shot) } } -static void -action_eventshot(space_t * space, shot_t * shot, space_t * p_spacePipe) +static void action_eventshot(space_t *space, shot_t *shot, space_t *p_spacePipe) { - space_action_from_location(p_spacePipe, action_eventpipe, shot, shot->x, - shot->y, shot->w, shot->h); + space_action_from_location(p_spacePipe, action_eventpipe, shot, shot->x, shot->y, shot->w, shot->h); if (shot->del == TRUE) { if (net_multiplayer_get_game_type() == NET_GAME_TYPE_SERVER) { @@ -342,13 +295,12 @@ int event() return 0; } - // na skusku + /* just for a test */ if (export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return 0; } - space_action(export_fce->fce_arena_get_current()->spaceShot, - action_eventshot, spacePipe); + space_action(export_fce->fce_arena_get_current()->spaceShot, action_eventshot, spacePipe); return 0; } @@ -364,8 +316,9 @@ int isConflict(int x, int y, int w, int h) void cmdArena(char *line) { - if (strncmp(line, "pipe", 4) == 0) + if (strncmp(line, "pipe", 4) == 0) { cmd_teleport(line); + } } void recvMsg(char *msg) diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index c8cfda4..f363923 100644 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -13,27 +12,29 @@ #include "space.h" #ifndef PUBLIC_SERVER -# include "interface.h" -# include "image.h" -#endif - -#ifdef PUBLIC_SERVER -# include "publicServer.h" +#include "interface.h" +#include "image.h" +#else +#include "publicServer.h" #endif typedef struct teleport_struct { int id; - int x; // poloha steny + /* position of the teleport */ + int x; int y; - int w; // rozmery steny + /* size of the teleport */ + int w; int h; - int layer; // vrstva + /* layer in the arena where the teleport lies */ + int layer; #ifndef PUBLIC_SERVER - image_t *img; //obrazok + /* its image */ + image_t *img; #endif } teleport_t; @@ -42,16 +43,15 @@ static export_fce_t *export_fce; static space_t *spaceTeleport; static list_t *listTeleport; -static void (*fce_move_tux) (tux_t * tux, int x, int y, int w, int h); -static void (*fce_move_shot) (shot_t * shot, int position, int src_x, +static void (*fce_move_tux) (tux_t *tux, int x, int y, int w, int h); +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); #ifndef PUBLIC_SERVER -teleport_t *newTeleport(int x, int y, int w, int h, int layer, image_t * img) -#endif -#ifdef PUBLIC_SERVER - teleport_t *newTeleport(int x, int y, int w, int h, int layer) +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) #endif { static int last_id = 0; @@ -103,24 +103,20 @@ static void getStatusTeleport(void *p, int *id, int *x, int *y, int *w, int *h) } #ifndef PUBLIC_SERVER - -static void drawTeleport(teleport_t * p) +static void drawTeleport(teleport_t *p) { assert(p != NULL); - export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, - p->layer); + export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); } - #endif -static void destroyTeleport(teleport_t * p) +static void destroyTeleport(teleport_t *p) { assert(p != NULL); free(p); } - static void cmd_teleport(char *line) { char str_x[STR_NUM_SIZE]; @@ -146,27 +142,26 @@ static void cmd_teleport(char *line) #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)); -#endif - -#ifdef PUBLIC_SERVER + atoi(str_w), atoi(str_h), + atoi(str_layer), + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); +#else new = newTeleport(atoi(str_x), atoi(str_y), - atoi(str_w), atoi(str_h), atoi(str_layer)); + atoi(str_w), atoi(str_h), + atoi(str_layer)); #endif if (spaceTeleport == NULL) { - spaceTeleport = - space_new(export_fce->fce_arena_get_current()->w, - export_fce->fce_arena_get_current()->h, 320, 240, - getStatusTeleport, setStatusTeleport); + spaceTeleport = space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, + 320, 240, + getStatusTeleport, setStatusTeleport); } space_add(spaceTeleport, new); } -static teleport_t *getRandomTeleportBut(space_t * space, teleport_t * teleport) +static teleport_t *getRandomTeleportBut(space_t *space, teleport_t *teleport) { int my_index; @@ -193,40 +188,37 @@ static int getRandomPosition() return TUX_DOWN; } - assert - (!"When generating random value in range 0 to 3 i got some other value?!"); + assert(!_("[Error] Generated a random number which is not in range 0 to 3")); - return -1; // no warnning + return -1; /* no warnings */ } -static void teleportTux(tux_t * tux, teleport_t * teleport) +static void teleportTux(tux_t *tux, teleport_t *teleport) { teleport_t *distTeleport; if (tux->bonus == BONUS_GHOST || - export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { + export_fce->fce_net_multiplayer_get_game_type() == NET_GAME_TYPE_CLIENT) { return; } distTeleport = getRandomTeleportBut(spaceTeleport, teleport); - fce_move_tux(tux, distTeleport->x, distTeleport->y, distTeleport->w, - distTeleport->h); + fce_move_tux(tux, distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h); } -static void -moveShotFromTeleport(shot_t * shot, teleport_t * teleport, space_t * space) +static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, space_t *space) { teleport_t *distTeleport; distTeleport = getRandomTeleportBut(space, teleport); fce_move_shot(shot, getRandomPosition(), teleport->x, teleport->y, - distTeleport->x, distTeleport->y, distTeleport->w, - distTeleport->h); + distTeleport->x, distTeleport->y, distTeleport->w, + distTeleport->h); } -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; @@ -248,8 +240,7 @@ int init(export_fce_t * p) } #ifndef PUBLIC_SERVER - -static void action_drawteleport(space_t * space, teleport_t * teleport, void *p) +static void action_drawteleport(space_t *space, teleport_t *teleport, void *p) { UNUSED(space); UNUSED(p); @@ -263,14 +254,13 @@ int draw(int x, int y, int w, int h) return 0; } - space_action_from_location(spaceTeleport, action_drawteleport, NULL, x, y, w, - h); + space_action_from_location(spaceTeleport, action_drawteleport, NULL, x, y, w, h); return 0; } #endif -static void action_eventteleportshot(space_t * space, teleport_t * teleport, shot_t * shot) +static void action_eventteleportshot(space_t *space, teleport_t *teleport, shot_t *shot) { arena_t *arena; tux_t *author; @@ -281,30 +271,29 @@ static void action_eventteleportshot(space_t * space, teleport_t * teleport, sho author = space_get_object_id(arena->spaceTux, shot->author_id); - if (author != NULL && - author->bonus == BONUS_GHOST && author->bonus_time > 0) { + if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { return; } moveShotFromTeleport(shot, teleport, spaceTeleport); } -static void action_eventshot(space_t * space, shot_t * shot, space_t * p_spaceTeleport) +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); + 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) +static void action_eventteleporttux(space_t *space, teleport_t *teleport, tux_t *tux) { UNUSED(space); teleportTux(tux, teleport); } -static void action_eventtux(space_t * space, tux_t * tux, space_t * p_spaceTeleport) +static void action_eventtux(space_t *space, tux_t *tux, space_t *p_spaceTeleport) { int x, y, w, h; @@ -312,8 +301,7 @@ static void action_eventtux(space_t * space, tux_t * tux, space_t * p_spaceTelep export_fce->fce_tux_get_proportion(tux, &x, &y, &w, &h); - space_action_from_location(p_spaceTeleport, action_eventteleporttux, tux, x, y, - w, h); + space_action_from_location(p_spaceTeleport, action_eventteleporttux, tux, x, y, w, h); } int event() @@ -326,10 +314,8 @@ int event() return 0; } - space_action(export_fce->fce_arena_get_current()->spaceShot, - action_eventshot, spaceTeleport); - space_action(export_fce->fce_arena_get_current()->spaceTux, action_eventtux, - spaceTeleport); + space_action(export_fce->fce_arena_get_current()->spaceShot, action_eventshot, spaceTeleport); + space_action(export_fce->fce_arena_get_current()->spaceTux, action_eventtux, spaceTeleport); return 0; } diff --git a/src/modules/modWall.c b/src/modules/modWall.c index 4facf20..67a63c1 100644 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -13,30 +12,33 @@ #include "space.h" #ifndef PUBLIC_SERVER -# include "interface.h" -# include "image.h" -#endif - -#ifdef PUBLIC_SERVER -# include "publicServer.h" +#include "interface.h" +#include "image.h" +#else +#include "publicServer.h" #endif +#ifndef PUBLIC_SERVER typedef struct wall_struct { int id; - int x; // poloha steny + /* position of the teleport */ + int x; int y; - int w; // rozmery steny + /* size of the teleport */ + int w; int h; - int img_x; // poloha obrazka + int img_x; int img_y; - int layer; // vrstva + /* layer in the arena where the teleport lies */ + int layer; #ifndef PUBLIC_SERVER - image_t *img; //obrazok + /* its image */ + image_t *img; #endif } wall_t; @@ -51,12 +53,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) -#endif -#ifdef PUBLIC_SERVER - wall_t *newWall(int x, int y, int w, int h, - int img_x, int img_y, int layer) +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) #endif { static int last_id = 0; @@ -85,15 +84,18 @@ wall_t *newWall(int x, int y, int w, int h, #ifndef PUBLIC_SERVER -void drawWall(wall_t * p) +void drawWall(wall_t *p) { assert(p != NULL); - export_fce->fce_addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, - p->img->h, p->layer); + export_fce->fce_addLayer(p->img, + p->img_x, p->img_y, + 0, 0, + p->img->w, p->img->h, + p->layer); } -void drawListWall(list_t * list) +void drawListWall(list_t *list) { wall_t *thisWall; int i; @@ -109,7 +111,7 @@ void drawListWall(list_t * list) #endif -void destroyWall(wall_t * p) +void destroyWall(wall_t *p) { assert(p != NULL); free(p); @@ -141,7 +143,6 @@ static void setStatusWall(void *p, int x, int y, int w, int h) } #ifndef PUBLIC_SERVER - static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h) { wall_t *wall; @@ -163,7 +164,6 @@ static void setStatusImgWall(void *p, int x, int y, int w, int h) UNUSED(w); UNUSED(h); } - #endif static void cmd_wall(char *line) @@ -216,25 +216,22 @@ static void cmd_wall(char *line) img_y += y; } #ifndef PUBLIC_SERVER - new = - newWall(x, y, w, h, img_x, img_y, layer, - export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); -#endif - -#ifdef PUBLIC_SERVER + new = newWall(x, y, w, h, img_x, img_y, layer, + export_fce->fce_image_get(IMAGE_GROUP_USER, str_image)); +#else new = newWall(x, y, w, h, img_x, img_y, layer); #endif if (spaceWall == NULL) { - spaceWall = - space_new(export_fce->fce_arena_get_current()->w, - export_fce->fce_arena_get_current()->h, 320, 240, - getStatusWall, setStatusWall); + spaceWall = space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, + 320, 240, + getStatusWall, setStatusWall); #ifndef PUBLIC_SERVER - spaceImgWall = - space_new(export_fce->fce_arena_get_current()->w, - export_fce->fce_arena_get_current()->h, 320, 240, + spaceImgWall = space_new(export_fce->fce_arena_get_current()->w, + export_fce->fce_arena_get_current()->h, + 320, 240, getStatusImgWall, setStatusImgWall); #endif } @@ -246,7 +243,7 @@ static void cmd_wall(char *line) #endif } -int init(export_fce_t * p) +int init(export_fce_t *p) { export_fce = p; listWall = list_new(); @@ -255,8 +252,7 @@ int init(export_fce_t * p) } #ifndef PUBLIC_SERVER - -static void action_drawwall(space_t * space, wall_t * wall, void *p) +static void action_drawwall(space_t *space, wall_t *wall, void *p) { UNUSED(space); UNUSED(p); @@ -272,13 +268,13 @@ int draw(int x, int y, int w, int h) space_action_from_location(spaceImgWall, action_drawwall, NULL, x, y, w, h); - //space_print(spaceWall); + /*space_print(spaceWall);*/ return 0; } #endif -static void action_eventwall(space_t * space, wall_t * wall, shot_t * shot) +static void action_eventwall(space_t *space, wall_t *wall, shot_t *shot) { arena_t *arena; tux_t *author; @@ -290,8 +286,7 @@ static void action_eventwall(space_t * space, wall_t * wall, shot_t * shot) author = space_get_object_id(arena->spaceTux, shot->author_id); - if (author != NULL && - author->bonus == BONUS_GHOST && author->bonus_time > 0) { + if (author != NULL && author->bonus == BONUS_GHOST && author->bonus_time > 0) { return; } @@ -302,15 +297,16 @@ static void action_eventwall(space_t * space, wall_t * wall, shot_t * shot) return; } - //space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy); + + /*space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy);*/ shot->del = TRUE; } -static void -action_eventshot(space_t * space, shot_t * shot, space_t * p_spaceWall) +static void action_eventshot(space_t *space, shot_t *shot, space_t *p_spaceWall) { - space_action_from_location(p_spaceWall, action_eventwall, shot, shot->x, - shot->y, shot->w, shot->h); + space_action_from_location(p_spaceWall, action_eventwall, + shot, shot->x, shot->y, + shot->w, shot->h); if (shot->del == TRUE) { space_del_with_item(space, shot, export_fce->fce_shot_destroy); @@ -324,7 +320,7 @@ int event() } space_action(export_fce->fce_arena_get_current()->spaceShot, - action_eventshot, spaceWall); + action_eventshot, spaceWall); return 0; } @@ -340,8 +336,9 @@ int isConflict(int x, int y, int w, int h) void cmdArena(char *line) { - if (strncmp(line, "wall", 4) == 0) + if (strncmp(line, "wall", 4) == 0) { cmd_wall(line); + } } void recvMsg(char *msg) |