summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-20 20:16:44 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-06-20 20:16:44 +0000
commit7af32f143eb8615163e1bc78a417434e18da0e71 (patch)
tree815f50fe8d0a5f1296436509d5d9f7b9bd7be094 /modules
parenta370d2f5860a0f89ac44af857d1059885ad1d60f (diff)
- oprava chyb s pamatov
- vyhladavanie objetku podla jeho ID ma konecne casovu narocnost log(2,n) git-svn-id: http://opensvn.csie.org/tuxanci_ng@67 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/Makefile-publicserver4
-rwxr-xr-xmodules/modWall.c4
-rw-r--r--modules/space.c87
3 files changed, 23 insertions, 72 deletions
diff --git a/modules/Makefile-publicserver b/modules/Makefile-publicserver
index 0f66a96..6766ae8 100755
--- a/modules/Makefile-publicserver
+++ b/modules/Makefile-publicserver
@@ -3,13 +3,13 @@ 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 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 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 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 space.o
diff --git a/modules/modWall.c b/modules/modWall.c
index 2bed2ef..056bb5c 100755
--- a/modules/modWall.c
+++ b/modules/modWall.c
@@ -322,10 +322,10 @@ void cmd(char *line)
int destroy()
{
- destroySpace(spaceWall);
+ destroySpaceWithObject(spaceWall, destroyWall);
#ifndef PUBLIC_SERVER
destroySpace(spaceImgWall);
#endif
- destroyListItem(listWall, destroyWall);
+ destroyList(listWall);
return 0;
}
diff --git a/modules/space.c b/modules/space.c
index c9688a8..96ac81b 100644
--- a/modules/space.c
+++ b/modules/space.c
@@ -9,7 +9,7 @@
#include "space.h"
#define DEBUG_SPACE
-//#define ERROR_SUPPORT
+#define ERROR_SUPPORT
#ifdef DEBUG_SPACE
@@ -165,7 +165,7 @@ static void checkList(space_t *space)
}
}
-static void addToList(space_t *space, void *p)
+static void addToListOnTheBaseIndex(space_t *space, void *p)
{
int id, point_id, inc_point_id;
int x, y, w, h;
@@ -178,11 +178,10 @@ static void addToList(space_t *space, void *p)
space->getStatus(p, &id, &x, &y, &w, &h);
/*
- printf("addToList (%d)\n", id);
+ printf("addToListOnTheBaseIndex (%d)\n", id);
printListID(space);
assert( id >= 0 );
*/
-
if( len == 0 )
{
//printf("OK first\n");
@@ -224,13 +223,13 @@ static void addToList(space_t *space, void *p)
space->getStatus(space->list->list[min], &id_min, &x, &y, &w, &h);
space->getStatus(space->list->list[max], &id_max, &x, &y, &w, &h);
*/
- printf("min = %d max = %d point = %d len = %d id = %d\n", min, max, point, len, id);
+ //printf("min = %d max = %d point = %d len = %d id = %d\n", min, max, point, len, id);
if( max < 0 )
{
//printf("OK first\n");
insList(space->list, 0, p);
- checkList(space);
+ //checkList(space);
return;
}
@@ -238,13 +237,13 @@ static void addToList(space_t *space, void *p)
{
addList(space->list, p);
//printf("OK height\n");
- checkList(space);
+ //checkList(space);
return;
}
space->getStatus(space->list->list[point], &point_id, &x, &y, &w, &h);
space->getStatus(space->list->list[point+1], &inc_point_id, &x, &y, &w, &h);
-
+/*
if( min == max )
{
//printf("OK\n");
@@ -252,12 +251,12 @@ static void addToList(space_t *space, void *p)
checkList(space);
return;
}
-
+*/
if( point_id < id && id < inc_point_id )
{
//printf("OK\n");
insList(space->list, point+1, p);
- checkList(space);
+ //checkList(space);
return;
}
@@ -295,7 +294,7 @@ void addObjectToSpace(space_t *p, void *item)
}
#ifdef ERROR_SUPPORT
- addToList(p, item);
+ addToListOnTheBaseIndex(p, item);
#endif
#ifndef ERROR_SUPPORT
@@ -341,9 +340,10 @@ void* getObjectFromSpaceWithID(space_t *space, int id)
int min, max;
int point;
+/*
printf("getObjectFromSpaceWithID %d\n", id);
printListID(space);
-
+*/
len = space->list->count;
min = 0;
@@ -592,72 +592,23 @@ void destroySpaceWithObject(space_t *p, void *f)
#ifdef DEBUG_SPACE
void test_space()
-{
+{/*
space_t *space;
recv_t *recv;
space = newSpace(5000, 2500, 320, 240, getStatus, setStatus);
+ addObjectToSpace(space, newRecv(5, 0, 0, 1, 1) );
+ addObjectToSpace(space, newRecv(7, 0, 0, 1, 1) );
+ addObjectToSpace(space, newRecv(8, 0, 0, 1, 1) );
+ addObjectToSpace(space, newRecv(9, 0, 0, 1, 1) );
addObjectToSpace(space, newRecv(6, 0, 0, 1, 1) );
- addObjectToSpace(space, newRecv(3, 0, 0, 1, 1) );
- addObjectToSpace(space, newRecv(4, 0, 0, 1, 1) );
-
- //printListID(space);
-/*
- recv = getObjectFromSpaceWithID(space, 6);
- if( recv != NULL )printf("id = %d\n", recv->id);
*/
- recv = getObjectFromSpaceWithID(space, 3);
-
- if( recv != NULL )
- {
- printf("id = %d\n", recv->id);
- }
- else
- {
- printf("recv = %p\n", recv);
- }
-
/*
- recv = getObjectFromSpaceWithID(space, 4);
- if( recv != NULL )printf("id = %d\n", recv->id);
- recv = getObjectFromSpaceWithID(space, 1);
+ recv = getObjectFromSpaceWithID(space, 6);
if( recv != NULL )printf("id = %d\n", recv->id);
*/
-
-#if 0
- for( i = 1 ; i < 16 ; i++ )
- for( j = 1 ; j < 16 ; j++ )
- {
- recv_t *this;
-
- this = newRecv(j*160, i*120, 32, 32);
- //addToSpace(space, newRecv(j*550, i*550, 1, 1) );
- addObjectToSpace(space, this );
- delObjectFromSpaceWithMem(space, this, destroyRecv);
- }
-#endif
-/*
- list = newList();
- getObjectFromSpace(space, 640, 480, 800 , 600, list);
-
- printf("list->count = %d\n", list->count);
-
- for( i = 0 ; i < list->count ; i++ )
- {
- recv_t *recv;
- recv = list->list[i];
-
- printf("%3d %3d %3d %3d\n", recv->x, recv->y, recv->w, recv->h);
- }
-*/
-/*
- destroyList(list);
-
- printSpace(space);
-
- destroySpace(space);
-*/
+// printListID(space);
}
#endif