summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-12 19:27:11 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-12 19:27:11 +0000
commit652ce49bba44c885da4891bcae5fb650ef132a73 (patch)
tree227a6f37a77f4b907e457b9163a0e36a0d9af1ed
parent9751218f594526982877332d6ca0fa90b67bbb7b (diff)
- moduly pouzivaju space_t
- drobne upravy git-svn-id: http://opensvn.csie.org/tuxanci_ng@64 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
-rw-r--r--arena/night_workshift.map2
-rw-r--r--config.h2
-rw-r--r--include/item.h2
-rw-r--r--include/space.h1
-rwxr-xr-xmodules/Makefile6
-rwxr-xr-xmodules/Makefile-publicserver9
-rwxr-xr-xmodules/modPipe.c121
-rwxr-xr-xmodules/modTeleport.c141
-rwxr-xr-xmodules/modWall.c51
-rwxr-xr-xsrc/Makefile-publicServer5
-rw-r--r--src/arena.c2
-rw-r--r--src/arenaFile.c40
-rw-r--r--src/proto.c10
-rw-r--r--src/publicServer.c4
-rw-r--r--src/server.c2
-rw-r--r--src/space.c36
-rw-r--r--src/tux.c4
17 files changed, 261 insertions, 177 deletions
diff --git a/arena/night_workshift.map b/arena/night_workshift.map
index 49d637b..2211665 100644
--- a/arena/night_workshift.map
+++ b/arena/night_workshift.map
@@ -4,7 +4,7 @@ netName NW
screen night_workshift.png
loadModule file="modWall.so"
-#loadModule file="modPipe.so"
+loadModule file="modPipe.so"
loadMusic file="night_workshift.ogg" name="night_workshift"
diff --git a/config.h b/config.h
index d2de93d..07246b8 100644
--- a/config.h
+++ b/config.h
@@ -6,7 +6,7 @@
#define DEBUG_CLIENT_RECV
*/
-#define TUXANCI_NG_VERSION "svn63"
+#define TUXANCI_NG_VERSION "svn64"
#define DESTDIR "/usr/local/"
#define SUPPORT_NET_SDL_UDP
diff --git a/include/item.h b/include/item.h
index b8a9825..c23e7d7 100644
--- a/include/item.h
+++ b/include/item.h
@@ -66,8 +66,8 @@ extern void replaceItemID(item_t *item, int id);
extern void addNewItem(space_t *spaceItem, int author_id);
#ifndef PUBLIC_SERVER
extern void drawListItem(list_t *listItem);
-extern void eventListItem(space_t *listSpace);
#endif
+extern void eventListItem(space_t *listSpace);
extern void mineExplosion(space_t *spaceItem, item_t *item);
extern void eventConflictShotWithItem(arena_t *arena);
extern void eventGiveTuxItem(tux_t *tux, item_t *item, space_t *spaceItem);
diff --git a/include/space.h b/include/space.h
index 8f5ad7c..662e847 100644
--- a/include/space.h
+++ b/include/space.h
@@ -26,6 +26,7 @@ extern void addObjectToSpace(space_t *p, void *item);
extern void getObjectFromSpace(space_t *p, int x, int y, int w, int h, list_t *list);
extern void* getObjectFromSpaceWithID(space_t *p, int id);
extern int isConflictWithObjectFromSpace(space_t *p, int x, int y, int w, int h);
+extern int isConflictWithObjectFromSpaceBut(space_t *p, int x, int y, int w, int h, void *but);
extern void delObjectFromSpace(space_t *p, void *item);
extern void delObjectFromSpaceWithMem(space_t *p, void *item, void *f);
extern void moveObjectInSpace(space_t *p, void *item, int move_x, int move_y);
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;
diff --git a/src/Makefile-publicServer b/src/Makefile-publicServer
index 99f3eea..0b4f1fe 100755
--- a/src/Makefile-publicServer
+++ b/src/Makefile-publicServer
@@ -10,7 +10,7 @@ CFLAGS = -g -O0 -I../include -Wall
BUILD_DIR = ../build-server
LIBS = -ldl
-FILES = list.o heightScore.o modules.o director.o configFile.o tux.o shot.o myTimer.o \
+FILES = list.o space.o heightScore.o modules.o director.o configFile.o tux.o shot.o myTimer.o \
buffer.o arena.o arenaFile.o textFile.o gun.o item.o idManager.o checkFront.o\
udp.o proto.o server.o publicServer.o net_multiplayer.o serverConfigFile.o main.o
@@ -20,6 +20,9 @@ $(BUILD_DIR)/publicserver: mkdir_build $(FILES)
mkdir_build:
mkdir -p $(BUILD_DIR)
+space.o: space.c ../include/space.h
+ $(CC) $(CFLAGS) -o $(BUILD_DIR)/space.o -c space.c
+
heightScore.o: heightScore.c
$(CC) $(CFLAGS) -o $(BUILD_DIR)/heightScore.o -c heightScore.c
diff --git a/src/arena.c b/src/arena.c
index 5b11bcb..4b97f46 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -162,7 +162,7 @@ void drawArena(arena_t *arena)
getObjectFromSpace(arena->spaceItem, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp);
drawListItem(listHelp);
- printSpace(arena->spaceItem);
+ //printSpace(arena->spaceItem);
//drawListTux(arena->listTux);
//drawListWall(arena->listWall);
diff --git a/src/arenaFile.c b/src/arenaFile.c
index 52f31c0..a3383e4 100644
--- a/src/arenaFile.c
+++ b/src/arenaFile.c
@@ -33,6 +33,26 @@ bool_t isAreaFileInicialized()
return isArenaFileInit;
}
+static void cmd_arena(arena_t **arena, char *line)
+{
+ char str_image[STR_SIZE];
+ char str_w[STR_SIZE];
+ char str_h[STR_SIZE];
+
+ if( getValue(line, "background", str_image, STR_SIZE) != 0 )return;
+ if( getValue(line, "w", str_w, STR_SIZE) != 0 )return;
+ if( getValue(line, "h", str_h, STR_SIZE) != 0 )return;
+
+ (*arena) = newArena(atoi(str_w), atoi(str_h));
+#ifndef PUBLIC_SERVER
+ (*arena)->background = getImage(IMAGE_GROUP_USER, str_image);
+#endif
+ //(*arena)->w = atoi(str_w);
+ //(*arena)->h = atoi(str_h);
+ setCurrentArena(*arena);
+ printf("new arena\n");
+}
+
static void cmd_loadModule(char *line)
{
char str_file[STR_SIZE];
@@ -68,24 +88,6 @@ static void cmd_loadMusic(char *line)
addMusic(str_file, str_name, MUSIC_GROUP_USER);
}
-static void cmd_arena(arena_t **arena, char *line)
-{
- char str_image[STR_SIZE];
- char str_w[STR_SIZE];
- char str_h[STR_SIZE];
-
- if( getValue(line, "background", str_image, STR_SIZE) != 0 )return;
- if( getValue(line, "w", str_w, STR_SIZE) != 0 )return;
- if( getValue(line, "h", str_h, STR_SIZE) != 0 )return;
-
- (*arena) = newArena(atoi(str_w), atoi(str_h));
- (*arena)->background = getImage(IMAGE_GROUP_USER, str_image);
- //(*arena)->w = atoi(str_w);
- //(*arena)->h = atoi(str_h);
- setCurrentArena(*arena);
- printf("new arena\n");
-}
-
static void cmd_playMusic(arena_t *arena, char *line)
{
char str_music[STR_SIZE];
@@ -181,10 +183,10 @@ arena_t* getArena(int id)
#ifndef PUBLIC_SERVER
if( strncmp(line, "loadImage", 9) == 0 )cmd_loadImage(line);
if( strncmp(line, "loadMusic", 9) == 0 )cmd_loadMusic(line);
- if( strncmp(line, "arena", 5) == 0 )cmd_arena(&arena, line);
if( strncmp(line, "playMusic", 9) == 0 )cmd_playMusic(arena, line);
#endif
+ if( strncmp(line, "arena", 5) == 0 )cmd_arena(&arena, line);
if( strncmp(line, "loadModule", 10) == 0 )cmd_loadModule(line);
//if( strncmp(line, "wall", 4) == 0 )cmd_wall(arena, line);
//if( strncmp(line, "teleport", 8) == 0 )cmd_teleport(arena, line);
diff --git a/src/proto.c b/src/proto.c
index 062693e..cffde8d 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -52,6 +52,7 @@ static void proto_send(int type, client_t *client, char *msg)
sendAllClientBut(msg, client);
break;
case PROTO_SEND_ALL_SEES_TUX :
+#ifndef PUBLIC_SERVER
if( client != NULL )
{
sendAllClientSeesTux(msg, client->tux);
@@ -60,6 +61,10 @@ static void proto_send(int type, client_t *client, char *msg)
{
sendAllClientSeesTux(msg, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT));
}
+#endif
+#ifdef PUBLIC_SERVER
+ sendAllClientSeesTux(msg, client->tux);
+#endif
break;
default :
assert( ! "Premenna type ma zlu hodnotu !" );
@@ -86,6 +91,7 @@ static void proto_check(int type, client_t *client, char *msg, int id)
addMsgAllClientBut(msg, client, id);
break;
case PROTO_SEND_ALL_SEES_TUX :
+#ifndef PUBLIC_SERVER
if( client != NULL )
{
addMsgAllClientSeesTux(msg, client->tux, id);
@@ -94,6 +100,10 @@ static void proto_check(int type, client_t *client, char *msg, int id)
{
addMsgAllClientSeesTux(msg, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT), id);
}
+#endif
+#ifdef PUBLIC_SERVER
+ addMsgAllClientSeesTux(msg, client->tux, id);
+#endif
break;
default :
assert( ! "Premenna type ma zlu hodnotu !" );
diff --git a/src/publicServer.c b/src/publicServer.c
index 6d55dbb..93ed2a7 100644
--- a/src/publicServer.c
+++ b/src/publicServer.c
@@ -50,7 +50,7 @@ int initPublicServer()
arena = getArena(arenaId);
setCurrentArena(arena);
- addNewItem(arena->listItem, ID_UNKNOWN);
+ addNewItem(arena->spaceItem, ID_UNKNOWN);
isSignalEnd = FALSE;
if( initNetMuliplayer(NET_GAME_TYPE_SERVER,
@@ -100,7 +100,6 @@ void eventPublicServer()
lastActive = getMyTime();
eventArena(arena);
- eventModule();
}
void my_handler_quit(int n)
@@ -125,6 +124,7 @@ void quitPublicServer()
quitModule();
quitListID();
quitHeightScore();
+ destroyList(listHelp);
exit(0);
}
diff --git a/src/server.c b/src/server.c
index 3ca0637..9fd4b0f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -649,7 +649,7 @@ static void eventClientUdpSelect(sock_udp_t *sock_server)
if( client == NULL )
{
- if( getCurrentArena()->listTux->count+1 > maxClients )
+ if( getCurrentArena()->spaceTux->list->count+1 > maxClients )
{
destroySockUdp(sock_client);
return;
diff --git a/src/space.c b/src/space.c
index ce662f0..32f7daf 100644
--- a/src/space.c
+++ b/src/space.c
@@ -219,6 +219,42 @@ int isConflictWithObjectFromSpace(space_t *p, int x, int y, int w, int h)
return 0;
}
+int isConflictWithObjectFromSpaceBut(space_t *p, int x, int y, int w, int h, void *but)
+{
+ int segX, segY, segW, segH;
+ int id, this_x, this_y, this_w, this_h;
+ int i, j, k;
+
+ getSegment(p, x, y, w, h, &segX, &segY, &segW, &segH);
+
+ for( i = segY ; i < segY + segH ; i++ )
+ {
+ for( j = segX ; j < segX + segW ; j++ )
+ {
+ void *this;
+
+ for( k = 0 ; k < p->area[j][i]->count ; k++ )
+ {
+ this = p->area[j][i]->list[k];
+
+ if( this == but )
+ {
+ continue;
+ }
+
+ p->getStatus(this, &id, &this_x, &this_y, &this_w, &this_h);
+
+ if( my_conflictSpace(x, y, w, h, this_x, this_y, this_w, this_h) )
+ {
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
void delObjectFromSpace(space_t *p, void *item)
{
int segX, segY, segW, segH;
diff --git a/src/tux.c b/src/tux.c
index a4153c6..8dad6c4 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -644,7 +644,7 @@ void moveTux(tux_t *tux, int n)
int px, py;
int zal_x, zal_y;
int new_x, new_y;
- int x, y, w, h;
+ int w, h;
arena_t *arena;
/*
@@ -724,7 +724,7 @@ void moveTux(tux_t *tux, int n)
*/
if( tux->bonus != BONUS_GHOST && (
- /*isConflictWithObjectFromSpace(arena->spaceTux, x, y, w, h) ||*/
+ isConflictWithObjectFromSpaceBut(arena->spaceTux, new_x, new_y, w, h, tux) ||
isConflictModule(new_x, new_y, w, h) ) )
{
setTuxProportion(tux, zal_x, zal_y);