summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
committerxHire <xhire@tuxportal.cz>2008-10-25 14:11:06 +0200
commitc8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch)
tree6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/modules
parentcb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff)
Changed style of the code to the K&R standard
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/modAI.c521
-rw-r--r--src/modules/modBasic.c60
-rw-r--r--src/modules/modMove.c363
-rw-r--r--src/modules/modPipe.c415
-rw-r--r--src/modules/modTeleport.c382
-rw-r--r--src/modules/modWall.c408
6 files changed, 1024 insertions, 1125 deletions
diff --git a/src/modules/modAI.c b/src/modules/modAI.c
index b29e141..003c65e 100644
--- a/src/modules/modAI.c
+++ b/src/modules/modAI.c
@@ -13,321 +13,308 @@
#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;
-typedef struct alternative_struct
-{
- int first;
- int route;
- int step;
- int x, y;
+typedef struct alternative_struct {
+ int first;
+ int route;
+ int step;
+ int x, y;
} alternative_t;
-alternative_t *
-newAlternative(int route, int x, int y)
+alternative_t *newAlternative(int route, int x, int y)
{
- alternative_t *new;
+ alternative_t *new;
- new = malloc(sizeof(alternative_t));
- new->first = route;
- new->route = route;
- new->x = x;
- new->y = y;
- new->step = 0;
+ new = malloc(sizeof(alternative_t));
+ new->first = route;
+ new->route = route;
+ new->x = x;
+ new->y = y;
+ new->step = 0;
- return new;
+ 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;
+ alternative_t *new;
- assert(p != NULL);
+ assert(p != NULL);
- new = newAlternative(route, p->x, p->y);
- new->first = p->first;
- new->step = p->step;
+ new = newAlternative(route, p->x, p->y);
+ new->first = p->first;
+ new->step = p->step;
- return new;
+ 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;
-
- assert(list != NULL);
- assert(p != NULL);
-
- x = p->x;
- y = p->y;
-
- switch (p->route) {
- case TUX_UP:
- addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
- addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
- break;
- case TUX_RIGHT:
- addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
- addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
- break;
- case TUX_LEFT:
- addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
- addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
- break;
- case TUX_DOWN:
- addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
- addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
- break;
- }
+ int x, y;
+
+ assert(list != NULL);
+ assert(p != NULL);
+
+ x = p->x;
+ y = p->y;
+
+ switch (p->route) {
+ case TUX_UP:
+ addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
+ addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
+ break;
+ case TUX_RIGHT:
+ addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
+ addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
+ break;
+ case TUX_LEFT:
+ addList(list, cloneAlternative(p, TUX_UP, x, y - (h + 5)));
+ addList(list, cloneAlternative(p, TUX_DOWN, x, y + (h + 5)));
+ break;
+ case TUX_DOWN:
+ addList(list, cloneAlternative(p, TUX_RIGHT, x + (w + 5), y));
+ addList(list, cloneAlternative(p, TUX_LEFT, x - (w + 5), y));
+ break;
+ }
}
-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);
-
- 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;
- }
+ assert(p != NULL);
+
+ p->step++;
+
+ //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;
+ }
}
-void
-destroyAlternative(alternative_t * p)
+void destroyAlternative(alternative_t * p)
{
- assert(p != NULL);
- free(p);
+ assert(p != NULL);
+ free(p);
}
-static void
-cmd_ai(char *line)
+static void cmd_ai(char *line)
{
}
-int
-init(export_fce_t * p)
+int init(export_fce_t * p)
{
- export_fce = p;
+ export_fce = p;
- return 0;
+ return 0;
}
#ifndef PUBLIC_SERVER
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- return 0;
+ return 0;
}
#endif
-tux_t *
-findOtherTux(space_t * space)
+tux_t *findOtherTux(space_t * space)
{
- int i;
+ int i;
- for (i = 0; i < getSpaceCount(space); i++) {
- tux_t *thisTux;
+ for (i = 0; i < getSpaceCount(space); i++) {
+ tux_t *thisTux;
- thisTux = getItemFromSpace(space, i);
+ thisTux = getItemFromSpace(space, i);
- if (thisTux->control != TUX_CONTROL_AI) {
- return thisTux;
- }
- }
+ if (thisTux->control != TUX_CONTROL_AI) {
+ return thisTux;
+ }
+ }
- return NULL;
+ 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;
- int x_rival, y_rival;
- int w, h;
-
- export_fce->fce_getTuxProportion(tux_ai, &x_ai, &y_ai, &w, &h);
- export_fce->fce_getTuxProportion(tux_rival, &x_rival, &y_rival, &w, &h);
-
- if (y_rival < y_ai && x_rival > x_ai && x_rival < x_ai + limit) {
- export_fce->fce_actionTux(tux_ai, TUX_UP);
- export_fce->fce_actionTux(tux_ai, TUX_SHOT);
- }
-
- if (x_rival > x_ai && y_rival > y_ai && y_rival < y_ai + limit) {
- export_fce->fce_actionTux(tux_ai, TUX_RIGHT);
- export_fce->fce_actionTux(tux_ai, TUX_SHOT);
- }
-
- if (x_rival < x_ai && y_rival > y_ai && y_rival < y_ai + limit) {
- export_fce->fce_actionTux(tux_ai, TUX_LEFT);
- export_fce->fce_actionTux(tux_ai, TUX_SHOT);
- }
-
- if (y_rival > y_ai && x_rival > x_ai && x_rival < x_ai + limit) {
- export_fce->fce_actionTux(tux_ai, TUX_DOWN);
- export_fce->fce_actionTux(tux_ai, TUX_SHOT);
- }
+ const int limit = 20;
+ int x_ai, y_ai;
+ int x_rival, y_rival;
+ int w, h;
+
+ export_fce->fce_getTuxProportion(tux_ai, &x_ai, &y_ai, &w, &h);
+ export_fce->fce_getTuxProportion(tux_rival, &x_rival, &y_rival, &w, &h);
+
+ if (y_rival < y_ai && x_rival > x_ai && x_rival < x_ai + limit) {
+ export_fce->fce_actionTux(tux_ai, TUX_UP);
+ export_fce->fce_actionTux(tux_ai, TUX_SHOT);
+ }
+
+ if (x_rival > x_ai && y_rival > y_ai && y_rival < y_ai + limit) {
+ export_fce->fce_actionTux(tux_ai, TUX_RIGHT);
+ export_fce->fce_actionTux(tux_ai, TUX_SHOT);
+ }
+
+ if (x_rival < x_ai && y_rival > y_ai && y_rival < y_ai + limit) {
+ export_fce->fce_actionTux(tux_ai, TUX_LEFT);
+ export_fce->fce_actionTux(tux_ai, TUX_SHOT);
+ }
+
+ if (y_rival > y_ai && x_rival > x_ai && x_rival < x_ai + limit) {
+ export_fce->fce_actionTux(tux_ai, TUX_DOWN);
+ export_fce->fce_actionTux(tux_ai, TUX_SHOT);
+ }
}
-static void
-eventTuxAI(tux_t * tux)
+static void eventTuxAI(tux_t * tux)
{
- arena_t *arena;
- tux_t *rivalTux;
+ arena_t *arena;
+ tux_t *rivalTux;
- list_t *listAlternative;
- list_t *listDst;
- list_t *listFork;
+ list_t *listAlternative;
+ list_t *listDst;
+ list_t *listFork;
- int x, y, w, h;
- int rival_x, rival_y;
- int i, index;
+ int x, y, w, h;
+ int rival_x, rival_y;
+ int i, index;
- int countFork = 0;
- int countDel = 0;
- int countLimit = 0;
- int countDo = 0;
+ int countFork = 0;
+ int countDel = 0;
+ int countLimit = 0;
+ int countDo = 0;
- export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h);
- //printf("tux AI %d %d\n", x, y);
+ export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h);
+ //printf("tux AI %d %d\n", x, y);
- arena = export_fce->fce_getCurrentArena();
+ arena = export_fce->fce_getCurrentArena();
- rivalTux = findOtherTux(arena->spaceTux);
+ rivalTux = findOtherTux(arena->spaceTux);
- if (rivalTux == NULL || rivalTux->status != TUX_STATUS_ALIVE) {
- return;
- }
+ if (rivalTux == NULL || rivalTux->status != TUX_STATUS_ALIVE) {
+ return;
+ }
- listAlternative = newList();
- listDst = newList();
- listFork = newList();
+ listAlternative = newList();
+ listDst = newList();
+ listFork = newList();
- shotTux(arena, tux, rivalTux);
+ shotTux(arena, tux, rivalTux);
- export_fce->fce_getTuxProportion(rivalTux, &rival_x, &rival_y, NULL,
- NULL);
- //printf("tux rival %d %d\n", rival_x, rival_y);
+ export_fce->fce_getTuxProportion(rivalTux, &rival_x, &rival_y, NULL, NULL);
+ //printf("tux rival %d %d\n", rival_x, rival_y);
- addList(listAlternative, newAlternative(TUX_UP, x, y - (h + 10)));
- addList(listAlternative, newAlternative(TUX_RIGHT, x + (w + 10), y));
- addList(listAlternative, newAlternative(TUX_LEFT, x - (w + 10), y));
- addList(listAlternative, newAlternative(TUX_DOWN, x, y + (h + 10)));
+ addList(listAlternative, newAlternative(TUX_UP, x, y - (h + 10)));
+ addList(listAlternative, newAlternative(TUX_RIGHT, x + (w + 10), y));
+ addList(listAlternative, newAlternative(TUX_LEFT, x - (w + 10), y));
+ addList(listAlternative, newAlternative(TUX_DOWN, x, y + (h + 10)));
- index = -1;
- while (1) {
- alternative_t *this;
+ index = -1;
+ while (1) {
+ alternative_t *this;
- index++;
- if (index < 0 || index >= listAlternative->count) {
+ index++;
+ if (index < 0 || index >= listAlternative->count) {
- int j;
+ int j;
- //printf("listFork->count = %d\n", listFork->count);
+ //printf("listFork->count = %d\n", listFork->count);
- for (j = 0; j < listFork->count; j++) {
- addList(listAlternative, listFork->list[j]);
- }
+ for (j = 0; j < listFork->count; j++) {
+ addList(listAlternative, listFork->list[j]);
+ }
- listDoEmpty(listFork);
+ listDoEmpty(listFork);
- index = 0;
- }
+ index = 0;
+ }
- if (listAlternative->count == 0) {
- break;
- }
+ if (listAlternative->count == 0) {
+ break;
+ }
- this = (alternative_t *) listAlternative->list[index];
+ this = (alternative_t *) listAlternative->list[index];
- if (++countDo == 100)
- break;
+ if (++countDo == 100)
+ break;
- if (this->step > 100) {
- delListItem(listAlternative, index, destroyAlternative);
- countLimit++;
- index--;
- continue;
- }
+ if (this->step > 100) {
+ delListItem(listAlternative, index, destroyAlternative);
+ countLimit++;
+ index--;
+ continue;
+ }
- moveAlternative(this, w * 2);
+ moveAlternative(this, w * 2);
- if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 1) {
- forkAlternative(listFork, this, 2 * w, 2 * h);
- countFork++;
- continue;
- }
+ if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 1) {
+ forkAlternative(listFork, this, 2 * w, 2 * h);
+ countFork++;
+ continue;
+ }
- if (export_fce->
- fce_conflictSpace(this->x, this->y, w, h, rival_x, rival_y, w,
- h)) {
- //printf("this->step = %d\n", this->step);
+ if (export_fce->
+ fce_conflictSpace(this->x, this->y, w, h, rival_x, rival_y, w,
+ h)) {
+ //printf("this->step = %d\n", this->step);
- delList(listAlternative, index);
- addList(listDst, this);
- index--;
- //continue;
- break;
- }
+ delList(listAlternative, index);
+ addList(listDst, this);
+ index--;
+ //continue;
+ break;
+ }
- if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 0) {
- //forkAlternative(listFork, this, w*2, h*2);
- delListItem(listAlternative, index, destroyAlternative);
- index--;
- countDel++;
+ if (export_fce->fce_isFreeSpace(arena, this->x, this->y, w, h) == 0) {
+ //forkAlternative(listFork, this, w*2, h*2);
+ delListItem(listAlternative, index, destroyAlternative);
+ index--;
+ countDel++;
- continue;
- }
+ continue;
+ }
- }
+ }
- int minStep = 1000;
- int recRoute = 0;
+ int minStep = 1000;
+ int recRoute = 0;
- //printf("------------\n");
- for (i = 0; i < listDst->count; i++) {
- alternative_t *this;
+ //printf("------------\n");
+ for (i = 0; i < listDst->count; i++) {
+ alternative_t *this;
- this = (alternative_t *) listDst->list[i];
+ this = (alternative_t *) listDst->list[i];
- //printf("XXX step %d route = %d\n", this->step, this->first);
- if (this->step < minStep) {
- minStep = this->step;
- recRoute = this->first;
- }
- }
+ //printf("XXX step %d route = %d\n", this->step, this->first);
+ if (this->step < minStep) {
+ minStep = this->step;
+ recRoute = this->first;
+ }
+ }
- if (recRoute != 0) {
- export_fce->fce_actionTux(tux, recRoute);
- }
+ if (recRoute != 0) {
+ export_fce->fce_actionTux(tux, recRoute);
+ }
- destroyListItem(listFork, destroyAlternative);
- destroyListItem(listAlternative, destroyAlternative);
- destroyListItem(listDst, destroyAlternative);
+ destroyListItem(listFork, destroyAlternative);
+ destroyListItem(listAlternative, destroyAlternative);
+ destroyListItem(listDst, destroyAlternative);
/*
printf("countFork = %d\n", countFork);
printf("countDel = %d\n", countDel);
@@ -336,45 +323,43 @@ eventTuxAI(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)
{
- if (tux->control == TUX_CONTROL_AI && tux->status == TUX_STATUS_ALIVE) {
- eventTuxAI(tux);
- }
+ if (tux->control == TUX_CONTROL_AI && tux->status == TUX_STATUS_ALIVE) {
+ eventTuxAI(tux);
+ }
}
-int
-event()
+int event()
{
- static my_time_t lastEvent = 0;
- my_time_t curentTime;
- arena_t *arena;
- int countTuxAI;
- //int i;
-
- if (lastEvent == 0) {
- lastEvent = export_fce->fce_getMyTime();
- }
+ static my_time_t lastEvent = 0;
+ my_time_t curentTime;
+ arena_t *arena;
+ int countTuxAI;
+ //int i;
+
+ if (lastEvent == 0) {
+ lastEvent = export_fce->fce_getMyTime();
+ }
- curentTime = export_fce->fce_getMyTime();
+ curentTime = export_fce->fce_getMyTime();
- if (curentTime - lastEvent < 25) {
- return 0;
- }
+ if (curentTime - lastEvent < 25) {
+ return 0;
+ }
- lastEvent = export_fce->fce_getMyTime();
- //printf("event AI\n");
+ lastEvent = export_fce->fce_getMyTime();
+ //printf("event AI\n");
- arena = export_fce->fce_getCurrentArena();
+ arena = export_fce->fce_getCurrentArena();
- if (arena == NULL) {
- return 0;
- }
+ if (arena == NULL) {
+ return 0;
+ }
- countTuxAI = 0;
+ countTuxAI = 0;
- actionSpace(arena->spaceTux, action_tuxAI, NULL);
+ actionSpace(arena->spaceTux, action_tuxAI, NULL);
/*
for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
{
@@ -390,29 +375,25 @@ event()
}
}
*/
- return 0;
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- return 0;
+ return 0;
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
- if (strncmp(line, "ai", 2) == 0)
- cmd_ai(line);
+ if (strncmp(line, "ai", 2) == 0)
+ cmd_ai(line);
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
}
-int
-destroy()
+int destroy()
{
- return 0;
+ return 0;
}
diff --git a/src/modules/modBasic.c b/src/modules/modBasic.c
index bf37fcb..7bddd7a 100644
--- a/src/modules/modBasic.c
+++ b/src/modules/modBasic.c
@@ -13,71 +13,63 @@
#include "space.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
static export_fce_t *export_fce;
-int
-init(export_fce_t * p)
+int init(export_fce_t * p)
{
- export_fce = p;
+ export_fce = p;
- printf("Initializing Basic module.\n");
- return 0;
+ printf("Initializing Basic module.\n");
+ return 0;
}
#ifndef PUBLIC_SERVER
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- printf("Drawing Basic module.\n");
- return 0;
+ printf("Drawing Basic module.\n");
+ return 0;
}
#endif
-int
-event()
+int event()
{
- printf("Basic module catch event.\n");
- return 0;
+ printf("Basic module catch event.\n");
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- printf("isConflict(%d, %d, %d, %d) in Basic module.\n", x, y, w, h);
- return 0;
+ printf("isConflict(%d, %d, %d, %d) in Basic module.\n", x, y, w, h);
+ return 0;
}
-static void
-cmd_basic(char *line)
+static void cmd_basic(char *line)
{
- printf("cmd_basic(%s) in Basic module.\n", line);
+ printf("cmd_basic(%s) in Basic module.\n", line);
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
- if (strncmp(line, "basic", 5) == 0)
- cmd_basic(line);
+ if (strncmp(line, "basic", 5) == 0)
+ cmd_basic(line);
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
- printf("recvMsg(%s) in Basic module.\n", msg);
+ printf("recvMsg(%s) in Basic module.\n", msg);
}
-int
-destroy()
+int destroy()
{
- printf("Destroying Basic module.\n");
- return 0;
+ printf("Destroying Basic module.\n");
+ return 0;
}
diff --git a/src/modules/modMove.c b/src/modules/modMove.c
index 854b5bb..55366ff 100644
--- a/src/modules/modMove.c
+++ b/src/modules/modMove.c
@@ -14,248 +14,235 @@
#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
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
-
- if (tux->bonus == BONUS_GHOST ||
- export_fce->fce_getNetTypeGame() == 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:
- assert(!"Variable p->control has a really wierd value!");
- break;
- }
- if (export_fce->
- fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y,
- TUX_WIDTH, TUX_HEIGHT)) {
- moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceTux, tux,
- dist_x, dist_y);
+ int dist_x = 0, dist_y = 0; // no warnning
+
+ if (tux->bonus == BONUS_GHOST ||
+ export_fce->fce_getNetTypeGame() == 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:
+ assert(!"Variable p->control has a really wierd value!");
+ break;
+ }
+ if (export_fce->
+ fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y,
+ TUX_WIDTH, TUX_HEIGHT)) {
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceTux, tux,
+ dist_x, dist_y);
#ifndef PUBLIC_SERVER
- //playSound("teleport", SOUND_GROUP_BASE);
+ //playSound("teleport", SOUND_GROUP_BASE);
#endif
- if (export_fce->fce_getNetTypeGame() == 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 (export_fce->fce_getNetTypeGame() == 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);
+ }
+ }
}
-static int
-myAbs(int n)
+static int myAbs(int n)
{
- return (n > 0 ? n : -n);
+ return (n > 0 ? n : -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;
-
- 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;
- }
- shot->position = position;
- shot->isCanKillAuthor = TRUE;
- if (shot->gun == GUN_LASSER)
- export_fce->fce_transformOnlyLasser(shot);
+ int speed;
+
+ 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;
+ }
+ shot->position = position;
+ shot->isCanKillAuthor = TRUE;
+ if (shot->gun == GUN_LASSER)
+ export_fce->fce_transformOnlyLasser(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)
+ int dist_x, int dist_y, int dist_w, int dist_h)
{
- int offset = 0;
- int new_x = 0, new_y = 0; // no warninng
-
- //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;
- }
- 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;
- }
- moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot,
- new_x, new_y);
- if (export_fce->fce_getNetTypeGame() == 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);
- export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg);
- }
+ int offset = 0;
+ int new_x = 0, new_y = 0; // no warninng
+
+ //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;
+ }
+ 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;
+ }
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot,
+ new_x, new_y);
+ if (export_fce->fce_getNetTypeGame() == 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);
+ 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_addToShareFce("move_tux", (void *) move_tux);
- export_fce->fce_addToShareFce("move_shot", (void *) move_shot);
- return 0;
+ export_fce = p;
+ export_fce->fce_addToShareFce("move_tux", (void *) move_tux);
+ export_fce->fce_addToShareFce("move_shot", (void *) move_shot);
+ return 0;
}
-static void
-proto_movetux(char *msg)
+static void proto_movetux(char *msg)
{
- char cmd[STR_PROTO_SIZE];
- int id, x, y;
- space_t *space;
- tux_t *tux;
-
- assert(msg != NULL);
- sscanf(msg, "%s %d %d %d", cmd, &id, &x, &y);
- space = export_fce->fce_getCurrentArena()->spaceTux;
- tux = getObjectFromSpaceWithID(space, id);
- if (tux != NULL)
- moveObjectInSpace(space, tux, x, y);
+ char cmd[STR_PROTO_SIZE];
+ int id, x, y;
+ space_t *space;
+ tux_t *tux;
+
+ assert(msg != NULL);
+ sscanf(msg, "%s %d %d %d", cmd, &id, &x, &y);
+ space = export_fce->fce_getCurrentArena()->spaceTux;
+ tux = getObjectFromSpaceWithID(space, id);
+ if (tux != NULL)
+ moveObjectInSpace(space, tux, x, y);
}
-static void
-proto_moveshot(char *msg)
+static void proto_moveshot(char *msg)
{
- char cmd[STR_PROTO_SIZE];
- int shot_id, x, y, px, py, position;
- space_t *space;
- shot_t *shot;
-
- assert(msg != NULL);
- sscanf(msg, "%s %d %d %d %d %d %d",
- cmd, &shot_id, &x, &y, &px, &py, &position);
- space = export_fce->fce_getCurrentArena()->spaceShot;
- if ((shot = getObjectFromSpaceWithID(space, shot_id)) == NULL)
- return;
- moveObjectInSpace(space, shot, x, y);
- shot->isCanKillAuthor = 1;
- shot->position = position;
- shot->px = px;
- shot->py = py;
- if (shot->gun == GUN_LASSER)
- export_fce->fce_transformOnlyLasser(shot);
+ char cmd[STR_PROTO_SIZE];
+ int shot_id, x, y, px, py, position;
+ space_t *space;
+ shot_t *shot;
+
+ assert(msg != NULL);
+ sscanf(msg, "%s %d %d %d %d %d %d",
+ cmd, &shot_id, &x, &y, &px, &py, &position);
+ space = export_fce->fce_getCurrentArena()->spaceShot;
+ if ((shot = getObjectFromSpaceWithID(space, shot_id)) == NULL)
+ return;
+ moveObjectInSpace(space, shot, x, y);
+ shot->isCanKillAuthor = 1;
+ shot->position = position;
+ shot->px = px;
+ shot->py = py;
+ if (shot->gun == GUN_LASSER)
+ export_fce->fce_transformOnlyLasser(shot);
}
#ifndef PUBLIC_SERVER
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- return 0;
+ return 0;
}
#endif
-int
-event()
+int event()
{
- return 0;
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- return 0;
+ return 0;
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
- if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER)
- return;
- if (strncmp(msg, "movetux", 7) == 0)
- proto_movetux(msg);
- if (strncmp(msg, "moveshot", 8) == 0)
- proto_moveshot(msg);
+ if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER)
+ return;
+ if (strncmp(msg, "movetux", 7) == 0)
+ proto_movetux(msg);
+ if (strncmp(msg, "moveshot", 8) == 0)
+ proto_moveshot(msg);
}
-int
-destroy()
+int destroy()
{
- return 0;
+ return 0;
}
diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c
index fef68a1..9049731 100644
--- a/src/modules/modPipe.c
+++ b/src/modules/modPipe.c
@@ -13,36 +13,35 @@
#include "space.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
- int y;
+typedef struct pipe_struct {
+ int x; // poloha steny
+ int y;
- int w; // rozmery steny
- int h;
+ int w; // rozmery steny
+ int h;
- int id;
- int id_out;
- int position;
+ int id;
+ int id_out;
+ int position;
- int layer; // vrstva
+ int layer; // vrstva
#ifndef PUBLIC_SERVER
- image_t *img; //obrazok
+ image_t *img; //obrazok
#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);
+ int src_y, int dist_x, int dist_y, int dist_w,
+ int dist_h);
static export_fce_t *export_fce;
@@ -50,310 +49,290 @@ 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)
+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)
#endif
{
- pipe_t *new;
+ pipe_t *new;
#ifndef PUBLIC_SERVER
- assert(img != NULL);
+ assert(img != NULL);
#endif
- new = malloc(sizeof(pipe_t));
- assert(new != NULL);
-
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->layer = layer;
- new->id = id;
- new->id_out = id_out;
- new->position = position;
+ new = malloc(sizeof(pipe_t));
+ assert(new != NULL);
+
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->layer = layer;
+ new->id = id;
+ new->id_out = id_out;
+ new->position = position;
#ifndef PUBLIC_SERVER
- new->img = img;
+ new->img = img;
#endif
- return new;
+ return new;
}
-static void
-setStatusPipe(void *p, int x, int y, int w, int h)
+static void setStatusPipe(void *p, int x, int y, int w, int h)
{
- pipe_t *pipe;
+ pipe_t *pipe;
- pipe = p;
+ pipe = p;
- pipe->x = x;
- pipe->y = y;
- pipe->w = w;
- pipe->h = h;
+ pipe->x = x;
+ pipe->y = y;
+ pipe->w = w;
+ pipe->h = h;
}
-static void
-getStatusPipe(void *p, int *id, int *x, int *y, int *w, int *h)
+static void getStatusPipe(void *p, int *id, int *x, int *y, int *w, int *h)
{
- pipe_t *pipe;
+ pipe_t *pipe;
- pipe = p;
+ pipe = p;
- *id = pipe->id;
- *x = pipe->x;
- *y = pipe->y;
- *w = pipe->w;
- *h = pipe->h;
+ *id = pipe->id;
+ *x = pipe->x;
+ *y = pipe->y;
+ *w = pipe->w;
+ *h = pipe->h;
}
#ifndef PUBLIC_SERVER
-static void
-drawPipe(pipe_t * p)
+static void drawPipe(pipe_t * p)
{
- assert(p != NULL);
+ 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);
+ assert(p != NULL);
+ free(p);
}
-static void
-cmd_teleport(char *line)
+static void cmd_teleport(char *line)
{
- char str_x[STR_NUM_SIZE];
- char str_y[STR_NUM_SIZE];
- char str_w[STR_NUM_SIZE];
- char str_h[STR_NUM_SIZE];
- char str_id[STR_NUM_SIZE];
- char str_id_out[STR_NUM_SIZE];
- char str_position[STR_NUM_SIZE];
- char str_layer[STR_NUM_SIZE];
- 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)
- return;
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_id[STR_NUM_SIZE];
+ char str_id_out[STR_NUM_SIZE];
+ char str_position[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ 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)
+ return;
#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_getImage(IMAGE_GROUP_USER, str_image));
+ 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_getImage(IMAGE_GROUP_USER, str_image));
#endif
#ifdef 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));
+ 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
- if (spacePipe == NULL) {
- spacePipe =
- newSpace(export_fce->fce_getCurrentArena()->w,
- export_fce->fce_getCurrentArena()->h, 320, 240,
- getStatusPipe, setStatusPipe);
- }
+ if (spacePipe == NULL) {
+ spacePipe =
+ newSpace(export_fce->fce_getCurrentArena()->w,
+ export_fce->fce_getCurrentArena()->h, 320, 240,
+ getStatusPipe, setStatusPipe);
+ }
- addObjectToSpace(spacePipe, new);
+ addObjectToSpace(spacePipe, new);
}
-static void
-moveShotFromPipe(shot_t * shot, pipe_t * pipe)
+static void moveShotFromPipe(shot_t * shot, pipe_t * pipe)
{
- pipe_t *distPipe;
+ pipe_t *distPipe;
- distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out);
+ distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out);
- if (distPipe == NULL) {
- fprintf(stderr, "Pipe ID for pipe \"%d\" was not found\n", pipe->id);
- return;
- }
+ if (distPipe == NULL) {
+ fprintf(stderr, "Pipe ID for pipe \"%d\" was not found\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;
+ export_fce = p;
- listPipe = newList();
+ listPipe = newList();
- if (export_fce->fce_loadDepModule("libmodMove") != 0) {
- return -1;
- }
+ if (export_fce->fce_loadDepModule("libmodMove") != 0) {
+ return -1;
+ }
- if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) {
- return -1;
- }
+ if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) {
+ return -1;
+ }
- return 0;
+ return 0;
}
#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)
{
- drawPipe(pipe);
+ drawPipe(pipe);
}
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- if (spacePipe == NULL) {
- return 0;
- }
+ if (spacePipe == NULL) {
+ return 0;
+ }
- actionSpaceFromLocation(spacePipe, action_drawpipe, NULL, x, y, w, h);
- //printSpace(spacePipe);
+ actionSpaceFromLocation(spacePipe, action_drawpipe, NULL, x, y, w, h);
+ //printSpace(spacePipe);
- return 0;
+ return 0;
}
#endif
-static int
-negPosition(int n)
+static int negPosition(int n)
{
- switch (n) {
- case TUX_UP:
- return TUX_DOWN;
+ switch (n) {
+ 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:
- assert(!"Tux is moving in another dimension maybe!");
- break;
- }
+ default:
+ assert(!"Tux is moving in another dimension maybe!");
+ break;
+ }
- return -1; // no warnning
+ return -1; // no warnning
}
-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;
-
- arena = export_fce->fce_getCurrentArena();
-
- author = getObjectFromSpaceWithID(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_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
- moveShotFromPipe(shot, pipe);
- }
- else {
- if (shot->gun == GUN_BOMBBALL &&
- export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
- export_fce->fce_boundBombBall(shot);
- }
- else {
- //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot);
- shot->del = TRUE;
- }
- }
+ arena_t *arena;
+ tux_t *author;
+
+ arena = export_fce->fce_getCurrentArena();
+
+ author = getObjectFromSpaceWithID(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_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
+ moveShotFromPipe(shot, pipe);
+ } else {
+ if (shot->gun == GUN_BOMBBALL &&
+ export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
+ export_fce->fce_boundBombBall(shot);
+ } else {
+ //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot);
+ shot->del = TRUE;
+ }
+ }
}
static void
action_eventshot(space_t * space, shot_t * shot, space_t * spacePipe)
{
- actionSpaceFromLocation(spacePipe, action_eventpipe, shot, shot->x,
- shot->y, shot->w, shot->h);
+ actionSpaceFromLocation(spacePipe, action_eventpipe, shot, shot->x,
+ shot->y, shot->w, shot->h);
- if (shot->del == TRUE) {
- delObjectFromSpaceWithObject(space, shot,
- export_fce->fce_destroyShot);
- }
+ if (shot->del == TRUE) {
+ delObjectFromSpaceWithObject(space, shot, export_fce->fce_destroyShot);
+ }
}
-int
-event()
+int event()
{
- if (spacePipe == NULL) {
- return 0;
- }
+ if (spacePipe == NULL) {
+ return 0;
+ }
- actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
- action_eventshot, spacePipe);
+ actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
+ action_eventshot, spacePipe);
- return 0;
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- if (spacePipe == NULL) {
- return 0;
- }
+ if (spacePipe == NULL) {
+ return 0;
+ }
- return isConflictWithObjectFromSpace(spacePipe, x, y, w, h);
+ return isConflictWithObjectFromSpace(spacePipe, x, y, w, h);
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
- if (strncmp(line, "pipe", 4) == 0)
- cmd_teleport(line);
+ if (strncmp(line, "pipe", 4) == 0)
+ cmd_teleport(line);
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
}
-int
-destroy()
+int destroy()
{
- destroySpaceWithObject(spacePipe, destroyPipe);
- destroyList(listPipe);
+ destroySpaceWithObject(spacePipe, destroyPipe);
+ destroyList(listPipe);
- return 0;
+ return 0;
}
diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c
index 3c136cb..492de5b 100644
--- a/src/modules/modTeleport.c
+++ b/src/modules/modTeleport.c
@@ -13,28 +13,27 @@
#include "space.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 teleport_struct
-{
- int id;
+typedef struct teleport_struct {
+ int id;
- int x; // poloha steny
- int y;
+ int x; // poloha steny
+ int y;
- int w; // rozmery steny
- int h;
+ int w; // rozmery steny
+ int h;
- int layer; // vrstva
+ int layer; // vrstva
#ifndef PUBLIC_SERVER
- image_t *img; //obrazok
+ image_t *img; //obrazok
#endif
} teleport_t;
@@ -45,217 +44,207 @@ 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,
- int src_y, int dist_x, int dist_y, int dist_w,
- int dist_h);
+ 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)
+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)
#endif
{
- static int last_id = 0;
+ static int last_id = 0;
- teleport_t *new;
+ teleport_t *new;
#ifndef PUBLIC_SERVER
- assert(img != NULL);
+ assert(img != NULL);
#endif
- new = malloc(sizeof(teleport_t));
- assert(new != NULL);
+ new = malloc(sizeof(teleport_t));
+ assert(new != NULL);
- new->id = ++last_id;
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->layer = layer;
+ new->id = ++last_id;
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->layer = layer;
#ifndef PUBLIC_SERVER
- new->img = img;
+ new->img = img;
#endif
- return new;
+ return new;
}
-static void
-setStatusTeleport(void *p, int x, int y, int w, int h)
+static void setStatusTeleport(void *p, int x, int y, int w, int h)
{
- teleport_t *teleport;
+ teleport_t *teleport;
- teleport = p;
+ teleport = p;
- teleport->x = x;
- teleport->y = y;
- teleport->w = w;
- teleport->h = h;
+ teleport->x = x;
+ teleport->y = y;
+ teleport->w = w;
+ teleport->h = h;
}
-static void
-getStatusTeleport(void *p, int *id, int *x, int *y, int *w, int *h)
+static void getStatusTeleport(void *p, int *id, int *x, int *y, int *w, int *h)
{
- teleport_t *teleport;
- teleport = p;
-
- *id = teleport->id;
- *x = teleport->x;
- *y = teleport->y;
- *w = teleport->w;
- *h = teleport->h;
+ teleport_t *teleport;
+ teleport = p;
+
+ *id = teleport->id;
+ *x = teleport->x;
+ *y = teleport->y;
+ *w = teleport->w;
+ *h = teleport->h;
}
#ifndef PUBLIC_SERVER
-static void
-drawTeleport(teleport_t * p)
+static void drawTeleport(teleport_t * p)
{
- assert(p != NULL);
+ 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);
+ assert(p != NULL);
+ free(p);
}
-static void
-cmd_teleport(char *line)
+static void cmd_teleport(char *line)
{
- char str_x[STR_NUM_SIZE];
- char str_y[STR_NUM_SIZE];
- char str_w[STR_NUM_SIZE];
- char str_h[STR_NUM_SIZE];
- char str_layer[STR_NUM_SIZE];
- 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)
- return;
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ 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)
+ return;
#ifndef PUBLIC_SERVER
- new = newTeleport(atoi(str_x), atoi(str_y),
- atoi(str_w), atoi(str_h),
- atoi(str_layer),
- export_fce->fce_getImage(IMAGE_GROUP_USER, str_image));
+ new = newTeleport(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h),
+ atoi(str_layer),
+ export_fce->fce_getImage(IMAGE_GROUP_USER, str_image));
#endif
#ifdef PUBLIC_SERVER
- new = newTeleport(atoi(str_x), atoi(str_y),
- atoi(str_w), atoi(str_h), atoi(str_layer));
+ new = newTeleport(atoi(str_x), atoi(str_y),
+ atoi(str_w), atoi(str_h), atoi(str_layer));
#endif
- if (spaceTeleport == NULL) {
- spaceTeleport =
- newSpace(export_fce->fce_getCurrentArena()->w,
- export_fce->fce_getCurrentArena()->h, 320, 240,
- getStatusTeleport, setStatusTeleport);
- }
+ if (spaceTeleport == NULL) {
+ spaceTeleport =
+ newSpace(export_fce->fce_getCurrentArena()->w,
+ export_fce->fce_getCurrentArena()->h, 320, 240,
+ getStatusTeleport, setStatusTeleport);
+ }
- addObjectToSpace(spaceTeleport, new);
+ addObjectToSpace(spaceTeleport, new);
}
-static teleport_t *
-getRandomTeleportBut(space_t * space, teleport_t * teleport)
+static teleport_t *getRandomTeleportBut(space_t * space, teleport_t * teleport)
{
- int index;
+ int index;
- do {
- index = random() % getSpaceCount(space);
- } while (getItemFromSpace(space, index) == teleport);
+ do {
+ index = random() % getSpaceCount(space);
+ } while (getItemFromSpace(space, index) == teleport);
- return (teleport_t *) getItemFromSpace(space, index);
+ return (teleport_t *) getItemFromSpace(space, index);
}
-static int
-getRandomPosition()
+static int getRandomPosition()
{
- switch (random() % 4) {
- case 0:
- return TUX_UP;
+ switch (random() % 4) {
+ 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;
+ }
- assert
- (!"When generating random value in range 0 to 3 i got some other value?!");
+ assert
+ (!"When generating random value in range 0 to 3 i got some other value?!");
- return -1; // no warnning
+ return -1; // no warnning
}
-static void
-teleportTux(tux_t * tux, teleport_t * teleport)
+static void teleportTux(tux_t * tux, teleport_t * teleport)
{
- teleport_t *distTeleport;
+ teleport_t *distTeleport;
- if (tux->bonus == BONUS_GHOST ||
- export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
- return;
- }
+ if (tux->bonus == BONUS_GHOST ||
+ export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
+ return;
+ }
- distTeleport = getRandomTeleportBut(spaceTeleport, teleport);
+ 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)
{
- teleport_t *distTeleport;
+ teleport_t *distTeleport;
- distTeleport = getRandomTeleportBut(space, teleport);
+ distTeleport = getRandomTeleportBut(space, teleport);
- fce_move_shot(shot, getRandomPosition(), teleport->x, teleport->y,
- distTeleport->x, distTeleport->y, distTeleport->w,
- distTeleport->h);
+ fce_move_shot(shot, getRandomPosition(), teleport->x, teleport->y,
+ distTeleport->x, distTeleport->y, distTeleport->w,
+ distTeleport->h);
}
-int
-init(export_fce_t * p)
+int init(export_fce_t * p)
{
- export_fce = p;
+ export_fce = p;
- listTeleport = newList();
+ listTeleport = newList();
- if (export_fce->fce_loadDepModule("libmodMove") != 0) {
- return -1;
- }
+ if (export_fce->fce_loadDepModule("libmodMove") != 0) {
+ return -1;
+ }
- if ((fce_move_tux = export_fce->fce_getShareFce("move_tux")) == NULL) {
- return -1;
- }
+ if ((fce_move_tux = export_fce->fce_getShareFce("move_tux")) == NULL) {
+ return -1;
+ }
- if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) {
- return -1;
- }
+ if ((fce_move_shot = export_fce->fce_getShareFce("move_shot")) == NULL) {
+ return -1;
+ }
- return 0;
+ return 0;
}
#ifndef PUBLIC_SERVER
@@ -263,111 +252,104 @@ init(export_fce_t * p)
static void
action_drawteleport(space_t * space, teleport_t * teleport, void *p)
{
- drawTeleport(teleport);
+ drawTeleport(teleport);
}
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- if (spaceTeleport == NULL) {
- return 0;
- }
+ if (spaceTeleport == NULL) {
+ return 0;
+ }
- actionSpaceFromLocation(spaceTeleport, action_drawteleport, NULL, x, y, w,
- h);
+ actionSpaceFromLocation(spaceTeleport, action_drawteleport, NULL, x, y, w,
+ h);
- return 0;
+ return 0;
}
#endif
static void
-action_eventteleportshot(space_t * space, teleport_t * teleport,
- shot_t * shot)
+action_eventteleportshot(space_t * space, teleport_t * teleport, shot_t * shot)
{
- arena_t *arena;
- tux_t *author;
+ arena_t *arena;
+ tux_t *author;
- arena = export_fce->fce_getCurrentArena();
+ arena = export_fce->fce_getCurrentArena();
- author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id);
+ author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id);
- if (author != NULL &&
- author->bonus == BONUS_GHOST && author->bonus_time > 0) {
- return;
- }
+ if (author != NULL &&
+ author->bonus == BONUS_GHOST && author->bonus_time > 0) {
+ return;
+ }
- moveShotFromTeleport(shot, teleport, spaceTeleport);
+ moveShotFromTeleport(shot, teleport, spaceTeleport);
}
static void
action_eventshot(space_t * space, shot_t * shot, space_t * spaceTeleport)
{
- actionSpaceFromLocation(spaceTeleport, action_eventteleportshot, shot,
- shot->x, shot->y, shot->w, shot->h);
+ actionSpaceFromLocation(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)
{
- teleportTux(tux, teleport);
+ teleportTux(tux, teleport);
}
static void
action_eventtux(space_t * space, tux_t * tux, space_t * spaceTeleport)
{
- int x, y, w, h;
+ int x, y, w, h;
- export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h);
+ export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h);
- actionSpaceFromLocation(spaceTeleport, action_eventteleporttux, tux, x, y,
- w, h);
+ actionSpaceFromLocation(spaceTeleport, action_eventteleporttux, tux, x, y,
+ w, h);
}
-int
-event()
+int event()
{
- if (spaceTeleport == NULL) {
- return 0;
- }
+ if (spaceTeleport == NULL) {
+ return 0;
+ }
- if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
- return 0;
- }
+ if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) {
+ return 0;
+ }
- actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
- action_eventshot, spaceTeleport);
- actionSpace(export_fce->fce_getCurrentArena()->spaceTux, action_eventtux,
- spaceTeleport);
+ actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
+ action_eventshot, spaceTeleport);
+ actionSpace(export_fce->fce_getCurrentArena()->spaceTux, action_eventtux,
+ spaceTeleport);
- return 0;
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- if (spaceTeleport == NULL) {
- return 0;
- }
+ if (spaceTeleport == NULL) {
+ return 0;
+ }
- return 0;
+ return 0;
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
- if (strncmp(line, "teleport", 8) == 0)
- cmd_teleport(line);
+ if (strncmp(line, "teleport", 8) == 0)
+ cmd_teleport(line);
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
}
-int
-destroy()
+int destroy()
{
- destroySpaceWithObject(spaceTeleport, destroyTeleport);
- destroyList(listTeleport);
- return 0;
+ destroySpaceWithObject(spaceTeleport, destroyTeleport);
+ destroyList(listTeleport);
+ return 0;
}
diff --git a/src/modules/modWall.c b/src/modules/modWall.c
index 66954d9..41b7e04 100644
--- a/src/modules/modWall.c
+++ b/src/modules/modWall.c
@@ -13,31 +13,30 @@
#include "space.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 wall_struct
-{
- int id;
+typedef struct wall_struct {
+ int id;
- int x; // poloha steny
- int y;
+ int x; // poloha steny
+ int y;
- int w; // rozmery steny
- int h;
+ int w; // rozmery steny
+ int h;
- int img_x; // poloha obrazka
- int img_y;
+ int img_x; // poloha obrazka
+ int img_y;
- int layer; // vrstva
+ int layer; // vrstva
#ifndef PUBLIC_SERVER
- image_t *img; //obrazok
+ image_t *img; //obrazok
#endif
} wall_t;
@@ -52,319 +51,298 @@ 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)
+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)
#endif
{
- static int last_id = 0;
- wall_t *new;
+ static int last_id = 0;
+ wall_t *new;
#ifndef PUBLIC_SERVER
- assert(img != NULL);
+ assert(img != NULL);
#endif
- new = malloc(sizeof(wall_t));
- assert(new != NULL);
-
- new->id = ++last_id;
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->img_x = img_x;
- new->img_y = img_y;
- new->layer = layer;
+ new = malloc(sizeof(wall_t));
+ assert(new != NULL);
+
+ new->id = ++last_id;
+ new->x = x;
+ new->y = y;
+ new->w = w;
+ new->h = h;
+ new->img_x = img_x;
+ new->img_y = img_y;
+ new->layer = layer;
#ifndef PUBLIC_SERVER
- new->img = img;
+ new->img = img;
#endif
- return new;
+ return new;
}
#ifndef PUBLIC_SERVER
-void
-drawWall(wall_t * p)
+void drawWall(wall_t * p)
{
- assert(p != NULL);
+ 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;
+ wall_t *thisWall;
+ int i;
- assert(list != NULL);
+ assert(list != NULL);
- for (i = 0; i < list->count; i++) {
- thisWall = (wall_t *) list->list[i];
- assert(thisWall != NULL);
- drawWall(thisWall);
- }
+ for (i = 0; i < list->count; i++) {
+ thisWall = (wall_t *) list->list[i];
+ assert(thisWall != NULL);
+ drawWall(thisWall);
+ }
}
#endif
-void
-destroyWall(wall_t * p)
+void destroyWall(wall_t * p)
{
- assert(p != NULL);
- free(p);
+ assert(p != NULL);
+ free(p);
}
-static void
-getStatusWall(void *p, int *id, int *x, int *y, int *w, int *h)
+static void getStatusWall(void *p, int *id, int *x, int *y, int *w, int *h)
{
- wall_t *wall;
+ wall_t *wall;
- wall = p;
+ wall = p;
- *id = wall->id;
- *x = wall->x;
- *y = wall->y;
- *w = wall->w;
- *h = wall->h;
+ *id = wall->id;
+ *x = wall->x;
+ *y = wall->y;
+ *w = wall->w;
+ *h = wall->h;
}
-static void
-setStatusWall(void *p, int x, int y, int w, int h)
+static void setStatusWall(void *p, int x, int y, int w, int h)
{
- wall_t *wall;
+ wall_t *wall;
- wall = p;
+ wall = p;
- wall->x = x;
- wall->y = y;
- wall->w = w;
- wall->h = h;
+ wall->x = x;
+ wall->y = y;
+ wall->w = w;
+ wall->h = h;
}
#ifndef PUBLIC_SERVER
-static void
-getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
+static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
{
- wall_t *wall;
+ wall_t *wall;
- wall = p;
+ wall = p;
- *id = wall->id;
- *x = wall->img_x;
- *y = wall->img_y;
- *w = wall->img->w;
- *h = wall->img->h;
+ *id = wall->id;
+ *x = wall->img_x;
+ *y = wall->img_y;
+ *w = wall->img->w;
+ *h = wall->img->h;
}
-static void
-setStatusImgWall(void *p, int x, int y, int w, int h)
+static void setStatusImgWall(void *p, int x, int y, int w, int h)
{
}
#endif
-static void
-cmd_wall(char *line)
+static void cmd_wall(char *line)
{
- char str_x[STR_NUM_SIZE];
- char str_y[STR_NUM_SIZE];
- char str_img_x[STR_NUM_SIZE];
- char str_img_y[STR_NUM_SIZE];
- char str_w[STR_NUM_SIZE];
- char str_h[STR_NUM_SIZE];
- char str_layer[STR_NUM_SIZE];
- char str_image[STR_SIZE];
- char str_rel[STR_SIZE];
- int x, y, w, h, img_x, img_y, layer;
- int rel;
- wall_t *new;
-
- rel = 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)
- return;
-
- rel = atoi(str_rel);
- x = atoi(str_x);
- y = atoi(str_y);
- w = atoi(str_w);
- h = atoi(str_h);
- img_x = atoi(str_img_x);
- img_y = atoi(str_img_y);
- layer = atoi(str_layer);
-
- if (rel == 1) {
- img_x += x;
- img_y += y;
- }
-
+ char str_x[STR_NUM_SIZE];
+ char str_y[STR_NUM_SIZE];
+ char str_img_x[STR_NUM_SIZE];
+ char str_img_y[STR_NUM_SIZE];
+ char str_w[STR_NUM_SIZE];
+ char str_h[STR_NUM_SIZE];
+ char str_layer[STR_NUM_SIZE];
+ char str_image[STR_SIZE];
+ char str_rel[STR_SIZE];
+ int x, y, w, h, img_x, img_y, layer;
+ int rel;
+ wall_t *new;
+
+ rel = 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)
+ return;
+
+ rel = atoi(str_rel);
+ x = atoi(str_x);
+ y = atoi(str_y);
+ w = atoi(str_w);
+ h = atoi(str_h);
+ img_x = atoi(str_img_x);
+ img_y = atoi(str_img_y);
+ layer = atoi(str_layer);
+
+ if (rel == 1) {
+ img_x += x;
+ img_y += y;
+ }
#ifndef PUBLIC_SERVER
- new =
- newWall(x, y, w, h, img_x, img_y, layer,
- export_fce->fce_getImage(IMAGE_GROUP_USER, str_image));
+ new =
+ newWall(x, y, w, h, img_x, img_y, layer,
+ export_fce->fce_getImage(IMAGE_GROUP_USER, str_image));
#endif
#ifdef PUBLIC_SERVER
- new = newWall(x, y, w, h, img_x, img_y, layer);
+ new = newWall(x, y, w, h, img_x, img_y, layer);
#endif
- if (spaceWall == NULL) {
- spaceWall =
- newSpace(export_fce->fce_getCurrentArena()->w,
- export_fce->fce_getCurrentArena()->h, 320, 240,
- getStatusWall, setStatusWall);
+ if (spaceWall == NULL) {
+ spaceWall =
+ newSpace(export_fce->fce_getCurrentArena()->w,
+ export_fce->fce_getCurrentArena()->h, 320, 240,
+ getStatusWall, setStatusWall);
#ifndef PUBLIC_SERVER
- spaceImgWall =
- newSpace(export_fce->fce_getCurrentArena()->w,
- export_fce->fce_getCurrentArena()->h, 320, 240,
- getStatusImgWall, setStatusImgWall);
+ spaceImgWall =
+ newSpace(export_fce->fce_getCurrentArena()->w,
+ export_fce->fce_getCurrentArena()->h, 320, 240,
+ getStatusImgWall, setStatusImgWall);
#endif
- }
+ }
- addObjectToSpace(spaceWall, new);
+ addObjectToSpace(spaceWall, new);
#ifndef PUBLIC_SERVER
- addObjectToSpace(spaceImgWall, new);
+ addObjectToSpace(spaceImgWall, new);
#endif
}
-int
-init(export_fce_t * p)
+int init(export_fce_t * p)
{
- export_fce = p;
- listWall = newList();
+ export_fce = p;
+ listWall = newList();
- return 0;
+ return 0;
}
#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)
{
- drawWall(wall);
+ drawWall(wall);
}
-int
-draw(int x, int y, int w, int h)
+int draw(int x, int y, int w, int h)
{
- if (spaceWall == NULL) {
- return 0;
- }
+ if (spaceWall == NULL) {
+ return 0;
+ }
- actionSpaceFromLocation(spaceImgWall, action_drawwall, NULL, x, y, w, h);
+ actionSpaceFromLocation(spaceImgWall, action_drawwall, NULL, x, y, w, h);
- //printSpace(spaceWall);
+ //printSpace(spaceWall);
- return 0;
+ 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;
-
- arena = export_fce->fce_getCurrentArena();
+ arena_t *arena;
+ tux_t *author;
- author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id);
+ arena = export_fce->fce_getCurrentArena();
- if (author != NULL &&
- author->bonus == BONUS_GHOST && author->bonus_time > 0) {
- return;
- }
+ author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id);
- if (shot->gun == GUN_BOMBBALL) {
- if (export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
- export_fce->fce_boundBombBall(shot);
- }
+ if (author != NULL &&
+ author->bonus == BONUS_GHOST && author->bonus_time > 0) {
+ return;
+ }
- return;
- }
+ if (shot->gun == GUN_BOMBBALL) {
+ if (export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
+ export_fce->fce_boundBombBall(shot);
+ }
- //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot);
- shot->del = TRUE;
+ return;
+ }
+ //delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot);
+ shot->del = TRUE;
}
static void
action_eventshot(space_t * space, shot_t * shot, space_t * spaceWall)
{
- actionSpaceFromLocation(spaceWall, action_eventwall, shot, shot->x,
- shot->y, shot->w, shot->h);
+ actionSpaceFromLocation(spaceWall, action_eventwall, shot, shot->x,
+ shot->y, shot->w, shot->h);
- if (shot->del == TRUE) {
- delObjectFromSpaceWithObject(space, shot,
- export_fce->fce_destroyShot);
- }
+ if (shot->del == TRUE) {
+ delObjectFromSpaceWithObject(space, shot, export_fce->fce_destroyShot);
+ }
}
-int
-event()
+int event()
{
- if (spaceWall == NULL) {
- return 0;
- }
+ if (spaceWall == NULL) {
+ return 0;
+ }
- actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
- action_eventshot, spaceWall);
+ actionSpace(export_fce->fce_getCurrentArena()->spaceShot,
+ action_eventshot, spaceWall);
- return 0;
+ return 0;
}
-int
-isConflict(int x, int y, int w, int h)
+int isConflict(int x, int y, int w, int h)
{
- if (spaceWall == NULL) {
- return 0;
- }
+ if (spaceWall == NULL) {
+ return 0;
+ }
- return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
+ return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
}
-void
-cmdArena(char *line)
+void cmdArena(char *line)
{
- if (strncmp(line, "wall", 4) == 0)
- cmd_wall(line);
+ if (strncmp(line, "wall", 4) == 0)
+ cmd_wall(line);
}
-void
-recvMsg(char *msg)
+void recvMsg(char *msg)
{
}
-int
-destroy()
+int destroy()
{
- destroySpaceWithObject(spaceWall, destroyWall);
+ destroySpaceWithObject(spaceWall, destroyWall);
#ifndef PUBLIC_SERVER
- destroySpace(spaceImgWall);
+ destroySpace(spaceImgWall);
#endif
- destroyList(listWall);
- return 0;
+ destroyList(listWall);
+ return 0;
}