summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/Makefile3
-rwxr-xr-xmodules/list.c5
-rwxr-xr-xmodules/list.h1
-rwxr-xr-xmodules/modWall.c86
4 files changed, 76 insertions, 19 deletions
diff --git a/modules/Makefile b/modules/Makefile
index b8c86b8..c7eee69 100755
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -13,8 +13,9 @@ modPipe:
modWall:
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 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/list.c b/modules/list.c
index 56f7e17..27b0ed8 100755
--- a/modules/list.c
+++ b/modules/list.c
@@ -168,6 +168,11 @@ void delListItem(list_t *p, int n, void *f)
delList(p, n);
}
+void listDoEmpty(list_t *p)
+{
+ p->count = 0;
+}
+
void destroyList(list_t *p)
{
assert( p != NULL );
diff --git a/modules/list.h b/modules/list.h
index 8722baa..5a15786 100755
--- a/modules/list.h
+++ b/modules/list.h
@@ -25,6 +25,7 @@ extern int searchListItem(list_t *p, void *n);
extern void delList(list_t *p,int n);
extern void delListItem(list_t *p,int n,void *f);
+extern void listDoEmpty(list_t *p);
extern void destroyList(list_t *p);
extern void destroyListItem(list_t *p,void *f);
diff --git a/modules/modWall.c b/modules/modWall.c
index ba8593a..bd1f8b6 100755
--- a/modules/modWall.c
+++ b/modules/modWall.c
@@ -10,6 +10,7 @@
#include "shot.h"
#include "list.h"
#include "gun.h"
+#include "space.h"
#ifndef PUBLIC_SERVER
#include "interface.h"
@@ -40,6 +41,8 @@ typedef struct wall_struct
static export_fce_t *export_fce;
+static space_t *spaceWall;
+static space_t *spaceImgWall;
static list_t *listWall;
#ifndef PUBLIC_SERVER
@@ -128,17 +131,15 @@ void eventConflictShotWithWall(list_t *listShot)
tux_t *author;
int i;
- assert( listWall != NULL );
- assert( listShot != NULL );
-
for( i = 0 ; i < listShot->count ; i++ )
{
thisShot = (shot_t *)listShot->list[i];
assert( thisShot != NULL );
- if( isConflictWithListWall(listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) != NULL )
+ if( isConflictWithObjectFromSpace(spaceWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) )
{
- author = export_fce->fce_getTuxID( listShot, thisShot->author_id );
+ author = getObjectFromSpaceWithID(
+ export_fce->fce_getCurrentArena()->spaceTux, thisShot->author_id );
if( author != NULL &&
author->bonus == BONUS_GHOST &&
@@ -165,6 +166,48 @@ void destroyWall(wall_t *p)
free(p);
}
+static void getStatusWall(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ *id = -1;
+ *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)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ wall->x = x;
+ wall->y = y;
+ wall->w = w;
+ wall->h = h;
+}
+
+static void getStatusImgWall(void *p, int *id, int *x, int *y, int *w, int *h)
+{
+ wall_t *wall;
+
+ wall = p;
+
+ *id = -1;
+ *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 cmd_wall(char *line)
{
char str_x[STR_NUM_SIZE];
@@ -200,13 +243,22 @@ static void cmd_wall(char *line)
atoi(str_layer) );
#endif
- addList(listWall, new);
+ if( spaceWall == NULL )
+ {
+ spaceWall = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusWall, setStatusWall);
+
+ spaceImgWall = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h,
+ 320, 240, getStatusImgWall, setStatusImgWall);
+ }
+
+ addObjectToSpace(spaceWall, new);
+ addObjectToSpace(spaceImgWall, new);
}
int init(export_fce_t *p)
{
export_fce = p;
-
listWall = newList();
return 0;
@@ -214,12 +266,15 @@ int init(export_fce_t *p)
#ifndef PUBLIC_SERVER
-int draw()
+int draw(int x, int y, int w, int h)
{
wall_t *thisWall;
int i;
- assert( listWall != NULL );
+ assert( spaceWall != NULL );
+
+ listDoEmpty(listWall);
+ getObjectFromSpace(spaceImgWall, x, y, w, h, listWall);
for( i = 0 ; i < listWall->count ; i++ )
{
@@ -228,6 +283,8 @@ int draw()
drawWall(thisWall);
}
+ //printSpace(spaceWall);
+
return 0;
}
#endif
@@ -241,14 +298,7 @@ int event()
int isConflict(int x, int y, int w, int h)
{
- if( isConflictWithListWall(listWall, x, y, w, h) != NULL )
- {
- return 1;
- }
- else
- {
- return 0;
- }
+ return isConflictWithObjectFromSpace(spaceWall, x, y, w, h);
}
void cmd(char *line)
@@ -258,7 +308,7 @@ void cmd(char *line)
int destroy()
{
- destroyListItem(listWall, destroyWall);
+ destroyList(listWall);
return 0;
}