From a370d2f5860a0f89ac44af857d1059885ad1d60f Mon Sep 17 00:00:00 2001 From: oroborus Date: Thu, 19 Jun 2008 19:28:04 +0000 Subject: - upravy v kode - prepis stirel pre space_t * - v kode su dva vyhladavacie algortmy, implicitne sa pouziva ten ktory funguje :) ten co nefunguje je zamakrovany makrom SUPPORT_ERROR a este ho musim doladit git-svn-id: http://opensvn.csie.org/tuxanci_ng@66 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/space.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 16 deletions(-) (limited to 'src/space.c') diff --git a/src/space.c b/src/space.c index dfe38a7..c9688a8 100644 --- a/src/space.c +++ b/src/space.c @@ -9,7 +9,7 @@ #include "space.h" #define DEBUG_SPACE -#define ERROR_SUPPORT +//#define ERROR_SUPPORT #ifdef DEBUG_SPACE @@ -122,6 +122,49 @@ static void getSegment(space_t *p, int x, int y, int w, int h, #ifdef ERROR_SUPPORT +void printListID(space_t *space) +{ + int i; + + for( i = 0 ; i < space->list->count ; i++ ) + { + int id, x, y, w, h; + + space->getStatus(space->list->list[i], &id, &x, &y, &w, &h); + printf("%d\n", id); + } + + putchar('\n'); +} + +static void checkList(space_t *space) +{ + int id, x, y, w, h; + int thisId; + int i; + + if( space->list->count == 0 ) + { + printf("nothing\n"); + return; + } + + space->getStatus(space->list->list[0], &thisId, &x, &y, &w, &h); + + for( i = 1 ; i < space->list->count ; i++ ) + { + space->getStatus(space->list->list[i], &id, &x, &y, &w, &h); + + if( id <= thisId ) + { + printListID(space); + assert( ! "error" ); + } + + thisId = id; + } +} + static void addToList(space_t *space, void *p) { int id, point_id, inc_point_id; @@ -130,9 +173,15 @@ static void addToList(space_t *space, void *p) int min, max; int point; + len = space->list->count; space->getStatus(p, &id, &x, &y, &w, &h); +/* + printf("addToList (%d)\n", id); + printListID(space); + assert( id >= 0 ); +*/ if( len == 0 ) { @@ -175,12 +224,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); return; } @@ -188,6 +238,7 @@ static void addToList(space_t *space, void *p) { addList(space->list, p); //printf("OK height\n"); + checkList(space); return; } @@ -198,6 +249,7 @@ static void addToList(space_t *space, void *p) { //printf("OK\n"); insList(space->list, min, p); + checkList(space); return; } @@ -205,6 +257,7 @@ static void addToList(space_t *space, void *p) { //printf("OK\n"); insList(space->list, point+1, p); + checkList(space); return; } @@ -224,19 +277,6 @@ static void addToList(space_t *space, void *p) #endif -void printListID(space_t *space) -{ - int i; - - for( i = 0 ; i < space->list->count ; i++ ) - { - int id, x, y, w, h; - - space->getStatus(space->list->list[i], &id, &x, &y, &w, &h); - printf("%d\n", id); - } -} - void addObjectToSpace(space_t *p, void *item) { int segX, segY, segW, segH; @@ -301,6 +341,9 @@ 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; @@ -559,7 +602,7 @@ void test_space() addObjectToSpace(space, newRecv(3, 0, 0, 1, 1) ); addObjectToSpace(space, newRecv(4, 0, 0, 1, 1) ); - printListID(space); + //printListID(space); /* recv = getObjectFromSpaceWithID(space, 6); if( recv != NULL )printf("id = %d\n", recv->id); -- cgit v1.2.3