summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/Makefile6
-rwxr-xr-xmodules/Makefile-publicserver9
-rwxr-xr-xmodules/modPipe.c121
-rwxr-xr-xmodules/modTeleport.c141
-rwxr-xr-xmodules/modWall.c51
5 files changed, 180 insertions, 148 deletions
diff --git a/modules/Makefile b/modules/Makefile
index c7eee69..dcdd234 100755
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -3,13 +3,15 @@ CFLAGS = -g -O0 -I../include -Wall
modTeleport:
gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c list.c -o list.o
+ gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c space.c -o space.o
gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c modTeleport.c -o modTeleport.o
- gcc $(CFLAGS) -I../include -shared -fPIC -o modTeleport.so modTeleport.o list.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modTeleport.so modTeleport.o list.o space.o
modPipe:
gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c list.c -o list.o
+ gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c space.c -o space.o
gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c modPipe.c -o modPipe.o
- gcc $(CFLAGS) -I../include -shared -fPIC -o modPipe.so modPipe.o list.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modPipe.so modPipe.o list.o space.o
modWall:
gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c list.c -o list.o
diff --git a/modules/Makefile-publicserver b/modules/Makefile-publicserver
index 3614599..0f66a96 100755
--- a/modules/Makefile-publicserver
+++ b/modules/Makefile-publicserver
@@ -3,18 +3,21 @@ CFLAGS = -g -O0 -I../include -Wall
modTeleport:
gcc $(CFLAGS) -fPIC -I../include -c list.c -o list.o
+ gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c space.c -o space.o
gcc $(CFLAGS) -fPIC -I../include -c modTeleport.c -o modTeleport.o
- gcc $(CFLAGS) -I../include -shared -fPIC -o modTeleport.so modTeleport.o list.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modTeleport.so modTeleport.o list.o space.o
modPipe:
gcc $(CFLAGS) -fPIC -I../include -c list.c -o list.o
+ gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c space.c -o space.o
gcc $(CFLAGS) -fPIC -I../include -c modPipe.c -o modPipe.o
- gcc $(CFLAGS) -I../include -shared -fPIC -o modPipe.so modPipe.o list.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modPipe.so modPipe.o list.o space.o
modWall:
gcc $(CFLAGS) -fPIC -I../include -c list.c -o list.o
+ gcc $(CFLAGS) -fPIC -I../include `sdl-config --cflags` -c space.c -o space.o
gcc $(CFLAGS) -fPIC -I../include -c modWall.c -o modWall.o
- gcc $(CFLAGS) -I../include -shared -fPIC -o modWall.so modWall.o list.o
+ gcc $(CFLAGS) -I../include -shared -fPIC -o modWall.so modWall.o list.o space.o
clean:
rm -rf *.o
diff --git a/modules/modPipe.c b/modules/modPipe.c
index 1078948..cb369b8 100755
--- a/modules/modPipe.c
+++ b/modules/modPipe.c
@@ -10,6 +10,7 @@
#include "shot.h"
#include "list.h"
#include "gun.h"
+#include "space.h"
#ifndef PUBLIC_SERVER
#include "interface.h"
@@ -42,6 +43,7 @@ typedef struct pipe_struct
static export_fce_t *export_fce;
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, SDL_Surface *img)
@@ -75,39 +77,42 @@ static pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out
return new;
}
-#ifndef PUBLIC_SERVER
-
-static void drawPipe(pipe_t *p)
+static void setStatusPipe(void *p, int x, int y, int w, int h)
{
- assert( p != NULL );
+ pipe_t *pipe;
- export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
-}
+ pipe = p;
-#endif
+ pipe->x = x;
+ pipe->y = y;
+ pipe->w = w;
+ pipe->h = h;
+}
-static pipe_t* isConflictWithListPipe(list_t *list, 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 *thisPipe;
- int i;
+ pipe_t *pipe;
- assert( list != NULL );
+ pipe = p;
- for( i = 0 ; i < list->count ; i++ )
- {
- thisPipe = (pipe_t *)list->list[i];
- assert( thisPipe != NULL );
+ *id = pipe->id;
+ *x = pipe->x;
+ *y = pipe->y;
+ *w = pipe->w;
+ *h = pipe->h;
+}
- if( export_fce->fce_conflictSpace(x, y, w, h,
- thisPipe->x, thisPipe->y, thisPipe->w, thisPipe->h) )
- {
- return thisPipe;
- }
- }
+#ifndef PUBLIC_SERVER
+
+static void drawPipe(pipe_t *p)
+{
+ assert( p != NULL );
- return NULL;
+ 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)
{
assert( p != NULL );
@@ -151,7 +156,13 @@ static void cmd_teleport(char *line)
atoi(str_layer), atoi(str_id), atoi(str_id_out), atoi(str_position) );
#endif
- addList(listPipe, new);
+ if( spacePipe == NULL )
+ {
+ spacePipe = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusPipe, setStatusPipe);
+ }
+
+ addObjectToSpace(spacePipe, new);
}
static int myAbs(int n)
@@ -256,30 +267,11 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y,
}
-static pipe_t* getPipeId(list_t *list, int id)
-{
- int i;
-
- for( i = 0 ; i < list->count ; i++ )
- {
- pipe_t *thisPipe;
-
- thisPipe = (pipe_t *) list->list[i];
-
- if( thisPipe->id == id )
- {
- return thisPipe;
- }
- }
-
- return NULL;
-}
-
-static void moveShotFromPipe(shot_t *shot, pipe_t *pipe, list_t *list)
+static void moveShotFromPipe(shot_t *shot, pipe_t *pipe)
{
pipe_t *distPipe;
- distPipe = getPipeId(list, pipe->id_out);
+ distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out);
if( distPipe == NULL )
{
@@ -302,12 +294,19 @@ int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
-int draw()
+int draw(int x, int y, int w, int h)
{
pipe_t *thisPipe;
int i;
- assert( listPipe != NULL );
+ if( spacePipe == NULL )
+ {
+ return 0;
+ }
+
+ listDoEmpty(listPipe);
+ getObjectFromSpace(spacePipe, x, y, w, h, listPipe);
+ //printSpace(spacePipe);
for( i = 0 ; i < listPipe->count ; i++ )
{
@@ -347,6 +346,12 @@ int event()
pipe_t *thisPipe;
arena_t *arena;
int i;
+
+ if( spacePipe == NULL )
+ {
+ return 0;
+ }
+
/*
if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
{
@@ -358,16 +363,21 @@ int event()
for( i = 0 ; i < arena->listShot->count ; i++ )
{
shot_t *thisShot;
+ int j;
thisShot = (shot_t *)arena->listShot->list[i];
assert( thisShot != NULL );
- if( ( thisPipe = isConflictWithListPipe(listPipe, thisShot->x, thisShot->y,
- thisShot->w, thisShot->h) ) != NULL )
+ listDoEmpty(listPipe);
+ getObjectFromSpace(spacePipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listPipe);
+
+ for( j = 0 ; j < listPipe->count ; j++ )
{
tux_t *author;
- author = export_fce->fce_getTuxID(arena->listTux, thisShot->author_id);
+ thisPipe = (pipe_t *)listPipe->list[j];
+
+ author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id);
if( author != NULL &&
author->bonus == BONUS_GHOST &&
@@ -390,7 +400,7 @@ int event()
}
else
{
- moveShotFromPipe(thisShot, thisPipe, listPipe);
+ moveShotFromPipe(thisShot, thisPipe);
}
}
@@ -416,14 +426,12 @@ int event()
int isConflict(int x, int y, int w, int h)
{
- if( isConflictWithListPipe(listPipe, x, y, w, h) != NULL )
- {
- return 1;
- }
- else
+ if( spacePipe == NULL )
{
return 0;
}
+
+ return isConflictWithObjectFromSpace(spacePipe, x, y, w, h);
}
void cmd(char *line)
@@ -433,7 +441,8 @@ void cmd(char *line)
int destroy()
{
- destroyListItem(listPipe, destroyPipe);
+ destroySpace(spacePipe, destroyPipe);
+ destroyList(listPipe);
return 0;
}
diff --git a/modules/modTeleport.c b/modules/modTeleport.c
index 306d190..9cc5755 100755
--- a/modules/modTeleport.c
+++ b/modules/modTeleport.c
@@ -10,6 +10,7 @@
#include "shot.h"
#include "list.h"
#include "gun.h"
+#include "space.h"
#ifndef PUBLIC_SERVER
#include "interface.h"
@@ -37,6 +38,7 @@ typedef struct teleport_struct
static export_fce_t *export_fce;
+static space_t *spaceTeleport;
static list_t *listTeleport;
#ifndef PUBLIC_SERVER
@@ -68,39 +70,42 @@ teleport_t* newTeleport(int x, int y, int w, int h, int layer)
return new;
}
-#ifndef PUBLIC_SERVER
-
-static void drawTeleport(teleport_t *p)
+static void setStatusTeleport(void *p, int x, int y, int w, int h)
{
- assert( p != NULL );
+ teleport_t *teleport;
- export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
-}
+ teleport = p;
-#endif
+ teleport->x = x;
+ teleport->y = y;
+ teleport->w = w;
+ teleport->h = h;
+}
-static teleport_t* isConflictWithListTeleport(list_t *list, 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 *thisTeleport;
- int i;
+ teleport_t *teleport;
- assert( list != NULL );
+ teleport = p;
- for( i = 0 ; i < list->count ; i++ )
- {
- thisTeleport = (teleport_t *)list->list[i];
- assert( thisTeleport != NULL );
+ *id = -1;
+ *x = teleport->x;
+ *y = teleport->y;
+ *w = teleport->w;
+ *h = teleport->h;
+}
- if( export_fce->fce_conflictSpace(x, y, w, h,
- thisTeleport->x, thisTeleport->y, thisTeleport->w, thisTeleport->h) )
- {
- return thisTeleport;
- }
- }
+#ifndef PUBLIC_SERVER
+
+static void drawTeleport(teleport_t *p)
+{
+ assert( p != NULL );
- return NULL;
+ 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)
{
assert( p != NULL );
@@ -137,7 +142,13 @@ static void cmd_teleport(char *line)
atoi(str_layer) );
#endif
- addList(listTeleport, new);
+ if( spaceTeleport == NULL )
+ {
+ spaceTeleport = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusTeleport, setStatusTeleport);
+ }
+
+ addObjectToSpace(spaceTeleport, new);
}
static teleport_t* getRandomTeleportBut(list_t *list, teleport_t *teleport)
@@ -174,7 +185,6 @@ static int getRandomPosition()
static void teleportTux(tux_t *tux, teleport_t *teleport)
{
teleport_t *distTeleport;
- int current_x, current_y;
int dist_x, dist_y;
if( tux->bonus == BONUS_GHOST ||
@@ -183,9 +193,9 @@ static void teleportTux(tux_t *tux, teleport_t *teleport)
return;
}
- distTeleport = getRandomTeleportBut(listTeleport, teleport);
+ distTeleport = getRandomTeleportBut(spaceTeleport->list, teleport);
- export_fce->fce_getTuxProportion(tux, &current_x, &current_y, NULL, NULL);
+ //export_fce->fce_getTuxProportion(tux, &current_x, &current_y, NULL, NULL);
switch( tux->position )
{
@@ -215,7 +225,8 @@ static void teleportTux(tux_t *tux, teleport_t *teleport)
if( export_fce->fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) )
{
- export_fce->fce_setTuxProportion(tux, dist_x, dist_y);
+ moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceTux, tux, dist_x, dist_y);
+ //export_fce->fce_setTuxProportion(tux, dist_x, dist_y);
#ifndef PUBLIC_SERVER
//playSound("teleport", SOUND_GROUP_BASE);
#endif
@@ -373,12 +384,19 @@ int init(export_fce_t *p)
}
#ifndef PUBLIC_SERVER
-int draw()
+int draw(int x, int y, int w, int h)
{
teleport_t *thisTeleport;
int i;
- assert( listTeleport != NULL );
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
+
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport);
+ //printSpace(spaceTeleport);
for( i = 0 ; i < listTeleport->count ; i++ )
{
@@ -397,6 +415,11 @@ int event()
arena_t *arena;
int i;
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
+
if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
{
return 0;
@@ -404,16 +427,21 @@ int event()
arena = export_fce->fce_getCurrentArena();
- for( i = 0 ; i < arena->listTux->count ; i++ )
+ for( i = 0 ; i < arena->spaceTux->list->count ; i++ )
{
tux_t *thisTux;
int x, y, w, h;
+ int j;
- thisTux = (tux_t *)arena->listTux->list[i];
+ thisTux = (tux_t *)arena->spaceTux->list->list[i];
export_fce->fce_getTuxProportion(thisTux, &x, &y, &w, &h);
- if( ( thisTeleport = isConflictWithListTeleport(listTeleport, x, y, w, h) ) != NULL )
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport);
+
+ for( j = 0 ; j < listTeleport->count ; j++ )
{
+ thisTeleport = (teleport_t *)listTeleport->list[j];
teleportTux(thisTux, thisTeleport);
}
}
@@ -421,21 +449,20 @@ int event()
for( i = 0 ; i < arena->listShot->count ; i++ )
{
shot_t *thisShot;
-
+ int j;
+
thisShot = (shot_t *)arena->listShot->list[i];
assert( thisShot != NULL );
-/*
- if( thisShot->gun == GUN_LASSER )
- {
- continue;
- }
-*/
- if( ( thisTeleport = isConflictWithListTeleport(listTeleport,
- thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL )
+
+ listDoEmpty(listTeleport);
+ getObjectFromSpace(spaceTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listTeleport);
+
+ for( j = 0 ; j < listTeleport->count ; j++ )
{
tux_t *author;
- author = export_fce->fce_getTuxID(arena->listTux, thisShot->author_id);
+ thisTeleport = (teleport_t *)listTeleport->list[j];
+ author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id);
if( author != NULL &&
author->bonus == BONUS_GHOST &&
@@ -444,18 +471,7 @@ int event()
continue;
}
- moveShotFromTeleport(thisShot, thisTeleport, listTeleport);
-/*
- if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT )
- {
- delListItem(arena->listShot, i, export_fce->fce_destroyShot);
- i--;
- }
- else
- {
- moveShotFromTeleport(thisShot, thisTeleport, listTeleport);
- }
-*/
+ moveShotFromTeleport(thisShot, thisTeleport, spaceTeleport->list);
}
}
@@ -464,16 +480,12 @@ int event()
int isConflict(int x, int y, int w, int h)
{
- return 0;
-}
-
-
-void eventConflictWithTux(tux_t *tux)
-{
-}
+ if( spaceTeleport == NULL )
+ {
+ return 0;
+ }
-void eventConflictWithShot(shot_t *tux)
-{
+ return 0;
}
void cmd(char *line)
@@ -483,6 +495,7 @@ void cmd(char *line)
int destroy()
{
- destroyListItem(listTeleport, destroyTeleport);
+ destroySpace(spaceTeleport, destroyTeleport);
+ destroyList(listTeleport);
return 0;
}
diff --git a/modules/modWall.c b/modules/modWall.c
index bd1f8b6..49140b4 100755
--- a/modules/modWall.c
+++ b/modules/modWall.c
@@ -42,7 +42,11 @@ typedef struct wall_struct
static export_fce_t *export_fce;
static space_t *spaceWall;
+
+#ifndef PUBLIC_SERVER
static space_t *spaceImgWall;
+#endif
+
static list_t *listWall;
#ifndef PUBLIC_SERVER
@@ -103,28 +107,6 @@ void drawListWall(list_t *list)
#endif
-wall_t* isConflictWithListWall(list_t *list, int x, int y, int w, int h)
-{
- wall_t *thisWall;
- int i;
-
- assert( list != NULL );
-
- for( i = 0 ; i < list->count ; i++ )
- {
- thisWall = (wall_t *)list->list[i];
- assert( thisWall != NULL );
-
- if( export_fce->fce_conflictSpace(x, y, w, h,
- thisWall->x, thisWall->y, thisWall->w, thisWall->h) )
- {
- return thisWall;
- }
- }
-
- return NULL;
-}
-
void eventConflictShotWithWall(list_t *listShot)
{
shot_t *thisShot;
@@ -191,6 +173,8 @@ static void setStatusWall(void *p, int x, int y, int w, int h)
wall->h = h;
}
+#ifndef PUBLIC_SERVER
+
static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
{
wall_t *wall;
@@ -208,6 +192,8 @@ static void setStatusImgWall(void *p, int x, int y, int w, int h)
{
}
+#endif
+
static void cmd_wall(char *line)
{
char str_x[STR_NUM_SIZE];
@@ -248,12 +234,17 @@ static void cmd_wall(char *line)
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);
+#endif
}
addObjectToSpace(spaceWall, new);
+
+#ifndef PUBLIC_SERVER
addObjectToSpace(spaceImgWall, new);
+#endif
}
int init(export_fce_t *p)
@@ -271,7 +262,10 @@ int draw(int x, int y, int w, int h)
wall_t *thisWall;
int i;
- assert( spaceWall != NULL );
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
listDoEmpty(listWall);
getObjectFromSpace(spaceImgWall, x, y, w, h, listWall);
@@ -292,12 +286,22 @@ int draw(int x, int y, int w, int h)
int event()
{
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
+
eventConflictShotWithWall(export_fce->fce_getCurrentArena()->listShot);
return 0;
}
int isConflict(int x, int y, int w, int h)
{
+ if( spaceWall == NULL )
+ {
+ return 0;
+ }
+
return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
}
@@ -308,6 +312,7 @@ void cmd(char *line)
int destroy()
{
+ destroySpace(spaceWall, destroyWall);
destroyList(listWall);
return 0;