From bb15df3f3428df7cd2a4482adebcdaa6fc2f516e Mon Sep 17 00:00:00 2001 From: oroborus Date: Thu, 10 Jul 2008 11:28:59 +0000 Subject: - precisteny kod sietoveho multiplayera - moduly si mozu mosielat spravy cez sietovy protokol - opravy chyb v moduloch - oprava chyby, v textovych poliach sa zobrazuju znaky, ktore ste nestalcili - director_t* loadDirector(char *s) vracia NULL ak adresar neexistuje ( predtym sa proces zrutil ) git-svn-id: http://opensvn.csie.org/tuxanci_ng@126 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/modules/modAI.c | 4 ++ src/modules/modPipe.c | 64 ++++++++++++++++++++++++++++---- src/modules/modTeleport.c | 94 +++++++++++++++++++++++++++++++++++++++++------ src/modules/modWall.c | 4 ++ 4 files changed, 147 insertions(+), 19 deletions(-) (limited to 'src/modules') diff --git a/src/modules/modAI.c b/src/modules/modAI.c index 61cb23f..b137ad3 100755 --- a/src/modules/modAI.c +++ b/src/modules/modAI.c @@ -247,6 +247,10 @@ void cmdArena(char *line) if( strncmp(line, "ai", 2) == 0 )cmd_ai(line); } +void recvMsg(char *msg) +{ +} + int destroy() { return 0; diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index efe4230..4a65756 100755 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -170,7 +170,6 @@ static int myAbs(int n) return ( n > 0 ? n : -n ); } - static int getSppedShot(shot_t *shot) { return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) ); @@ -239,33 +238,38 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y, { case TUX_UP : new_x = dist_x + offset; - new_y = dist_y; + new_y = dist_y - ( shot->h + 5 ); break; case TUX_LEFT : - new_x = dist_x; + new_x = dist_x - ( shot->w + 5 ); new_y = dist_y + offset; break; case TUX_RIGHT : - new_x = dist_x + dist_w; + new_x = dist_x + dist_w + 5; new_y = dist_y + offset; break; case TUX_DOWN : new_x = dist_x + offset; - new_y = dist_y + dist_h; + new_y = dist_y + dist_h + 5; break; } - new_x += myAbs(shot->px) * shot->px; - new_y += myAbs(shot->py) * shot->py; + //new_x += myValueOperator(shot->px) * shot->w; + //new_y += myValueOperator(shot->py) * shot->h; moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, new_x, new_y); if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) { - export_fce->fce_proto_send_shot_server(PROTO_SEND_ALL, NULL, shot); + char msg[STR_PROTO_SIZE]; + + sprintf(msg, "pipe %d %d %d %d %d %d", + shot->id, shot->x, shot->y, shot->px, shot->py, shot->position); + + export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg); } } @@ -424,6 +428,50 @@ void cmdArena(char *line) if( strncmp(line, "pipe", 4) == 0 )cmd_teleport(line); } +static void proto_pipe(char *msg) +{ + char cmd[STR_PROTO_SIZE]; + int shot_id, x, y, px, py, position; + space_t *space; + shot_t *shot; + + assert( msg != NULL ); + + sscanf(msg, "%s %d %d %d %d %d %d", + cmd, &shot_id, &x, &y, &px, &py, &position); + + + space = export_fce->fce_getCurrentArena()->spaceShot; + + if( ( shot = getObjectFromSpaceWithID(space, shot_id) ) == NULL ) + { + //delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + + return; + } + + moveObjectInSpace(space, shot, x, y); + shot->isCanKillAuthor = 1; + shot->position = position; + shot->px = px; + shot->py = py; + + if( shot->gun == GUN_LASSER ) + { + transformOnlyLasser(shot); + } +} + +void recvMsg(char *msg) +{ + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + return; + } + + if( strncmp(msg, "pipe", 4) == 0 )proto_pipe(msg); +} + int destroy() { destroySpaceWithObject(spacePipe, destroyPipe); diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index d54bb4c..9d8eb70 100755 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -236,13 +236,19 @@ static void teleportTux(tux_t *tux, teleport_t *teleport) #endif if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) { + char msg[STR_PROTO_SIZE]; + + sprintf(msg, "teleporttux %d %d %d", tux->id, dist_x, dist_y); + if( tux->bonus == BONUS_HIDDEN ) { - export_fce->fce_proto_send_newtux_server(PROTO_SEND_ONE, (client_t *)tux->client, tux); + export_fce->fce_proto_send_module_server(PROTO_SEND_ONE, (client_t *)tux->client, msg); + //export_fce->fce_proto_send_newtux_server(PROTO_SEND_ONE, (client_t *)tux->client, tux); } else { - export_fce->fce_proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); + export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg); + //export_fce->fce_proto_send_newtux_server(PROTO_SEND_ALL, NULL, msg); } } } @@ -301,7 +307,7 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y, int dist_x, int dist_y, int dist_w, int dist_h) { int offset = 0; - int new_x = 0, new_y = 0; // no warnning + int new_x = 0, new_y = 0; // no warninng switch( shot->position ) { @@ -322,33 +328,35 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y, { case TUX_UP : new_x = dist_x + offset; - new_y = dist_y; + new_y = dist_y - ( shot->h + 5 ); break; case TUX_LEFT : - new_x = dist_x; + new_x = dist_x - ( shot->w + 5 ); new_y = dist_y + offset; break; case TUX_RIGHT : - new_x = dist_x + dist_w; + new_x = dist_x + dist_w + 5; new_y = dist_y + offset; break; case TUX_DOWN : new_x = dist_x + offset; - new_y = dist_y + dist_h; + new_y = dist_y + dist_h + 5; break; } - new_y += shot->px; - new_y += shot->py; - moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, new_x, new_y); if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) { - export_fce->fce_proto_send_shot_server(PROTO_SEND_ALL, NULL, shot); + char msg[STR_PROTO_SIZE]; + + sprintf(msg, "teleportshot %d %d %d %d %d %d", + shot->id, shot->x, shot->y, shot->px, shot->py, shot->position); + + export_fce->fce_proto_send_module_server(PROTO_SEND_ALL, NULL, msg); } } @@ -480,6 +488,70 @@ void cmdArena(char *line) if( strncmp(line, "teleport", 8) == 0 )cmd_teleport(line); } +static void proto_teleporttux(char *msg) +{ + char cmd[STR_PROTO_SIZE]; + int id, x, y; + space_t *space; + tux_t *tux; + + assert( msg != NULL ); + + sscanf(msg, "%s %d %d %d", + cmd, &id, &x, &y); + + space = export_fce->fce_getCurrentArena()->spaceTux; + tux = getObjectFromSpaceWithID(space, id); + + if( tux != NULL ) + { + moveObjectInSpace(space, tux, x, y); + } +} + +static void proto_teleportshot(char *msg) +{ + char cmd[STR_PROTO_SIZE]; + int shot_id, x, y, px, py, position; + space_t *space; + shot_t *shot; + + assert( msg != NULL ); + + sscanf(msg, "%s %d %d %d %d %d %d", + cmd, &shot_id, &x, &y, &px, &py, &position); + + + space = export_fce->fce_getCurrentArena()->spaceShot; + + if( ( shot = getObjectFromSpaceWithID(space, shot_id) ) == NULL ) + { + return; + } + + moveObjectInSpace(space, shot, x, y); + shot->isCanKillAuthor = 1; + shot->position = position; + shot->px = px; + shot->py = py; + + if( shot->gun == GUN_LASSER ) + { + transformOnlyLasser(shot); + } +} + +void recvMsg(char *msg) +{ + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + return; + } + + if( strncmp(msg, "teleporttux", 11) == 0 )proto_teleporttux(msg); + if( strncmp(msg, "teleportshot", 12) == 0 )proto_teleportshot(msg); +} + int destroy() { destroySpaceWithObject(spaceTeleport, destroyTeleport); diff --git a/src/modules/modWall.c b/src/modules/modWall.c index 4030795..c2cf69e 100755 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -338,6 +338,10 @@ void cmdArena(char *line) if( strncmp(line, "wall", 4) == 0 )cmd_wall(line); } +void recvMsg(char *msg) +{ +} + int destroy() { destroySpaceWithObject(spaceWall, destroyWall); -- cgit v1.2.3