summaryrefslogtreecommitdiff
path: root/src
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 /src
parent9751218f594526982877332d6ca0fa90b67bbb7b (diff)
- moduly pouzivaju space_t
- drobne upravy git-svn-id: http://opensvn.csie.org/tuxanci_ng@64 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
-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
8 files changed, 77 insertions, 26 deletions
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);