From 0e1af9def9004ee7718543898b8f831d2688b299 Mon Sep 17 00:00:00 2001 From: scarab Date: Sun, 24 Aug 2008 09:52:41 +0000 Subject: - modMove -> K&R git-svn-id: http://opensvn.csie.org/tuxanci_ng@246 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/modules/modMove.c | 127 +++++++++++++------------------------------------- 1 file changed, 33 insertions(+), 94 deletions(-) (limited to 'src/modules/modMove.c') diff --git a/src/modules/modMove.c b/src/modules/modMove.c index 69af165..34222a6 100755 --- a/src/modules/modMove.c +++ b/src/modules/modMove.c @@ -28,63 +28,42 @@ static void move_tux(tux_t *tux, int x, int y, int w, int h) { int dist_x = 0, dist_y = 0; // no warnning - //printf("move_tux\n"); - - if( tux->bonus == BONUS_GHOST || - export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { + if (tux->bonus == BONUS_GHOST || + export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT) return; - } - - switch( tux->position ) - { + switch (tux->position) { case TUX_UP : dist_x = x + w/2; dist_y = y - ( TUX_HEIGHT + 20 ); - break; + break; case TUX_LEFT : dist_x = x - ( TUX_WIDTH + 20 ); dist_y = y + h/2; - break; - + break; case TUX_RIGHT : dist_x = x + w + 20; dist_y = y + h/2; - break; - + break; case TUX_DOWN : dist_x = x + w/2; dist_y = y + h + 20; - break; - + break; default : assert( ! "Variable p->control has a really wierd value!" ); - break; + break; } - - if( export_fce->fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) ) - { + if (export_fce->fce_isFreeSpace(export_fce->fce_getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT)) { 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 - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { + if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) { char msg[STR_PROTO_SIZE]; - sprintf(msg, "movetux %d %d %d", tux->id, dist_x, dist_y); - if( tux->bonus == BONUS_HIDDEN ) - { 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_module_server(PROTO_SEND_ALL, NULL, msg); - //export_fce->fce_proto_send_newtux_server(PROTO_SEND_ALL, NULL, msg); - } } } } @@ -105,37 +84,28 @@ static void transformShot(shot_t *shot, int position) int speed; speed = getSppedShot(shot); - - switch( position ) - { + switch (position) { case TUX_UP : shot->px = 0; shot->py = -speed; - break; - + break; case TUX_LEFT : shot->px = -speed; shot->py = 0; - break; - + break; case TUX_RIGHT : shot->px = speed; shot->py = 0; - break; - + break; case TUX_DOWN : shot->px = 0; shot->py = +speed; - break; + break; } - - shot->position = position; + shot->position = position; shot->isCanKillAuthor = TRUE; - if( shot->gun == GUN_LASSER ) - { export_fce->fce_transformOnlyLasser(shot); - } } static void move_shot(shot_t *shot, int position, int src_x, int src_y, @@ -145,54 +115,41 @@ static void move_shot(shot_t *shot, int position, int src_x, int src_y, int new_x = 0, new_y = 0; // no warninng //printf("move_shot\n"); - - switch( shot->position ) - { + switch (shot->position) { case TUX_UP : case TUX_DOWN : offset = shot->x - src_x; - break; - + break; case TUX_RIGHT : case TUX_LEFT : offset = shot->y - src_y; - break; + break; } - transformShot(shot, position); - - switch( shot->position ) - { + switch (shot->position) { case TUX_UP : new_x = dist_x + offset; new_y = dist_y - ( shot->h + 5 ); - break; - + break; case TUX_LEFT : new_x = dist_x - ( shot->w + 5 ); new_y = dist_y + offset; - break; - + break; case TUX_RIGHT : new_x = dist_x + dist_w + 5; new_y = dist_y + offset; - break; - + break; case TUX_DOWN : new_x = dist_x + offset; new_y = dist_y + dist_h + 5; - break; + break; } - moveObjectInSpace(export_fce->fce_getCurrentArena()->spaceShot, shot, new_x, new_y); - - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { + if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) { char msg[STR_PROTO_SIZE]; sprintf(msg, "moveshot %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); } } @@ -200,10 +157,8 @@ static void move_shot(shot_t *shot, int position, int src_x, int src_y, int init(export_fce_t *p) { export_fce = p; - export_fce->fce_addToShareFce("move_tux", (void *)move_tux); export_fce->fce_addToShareFce("move_shot", (void *)move_shot); - return 0; } @@ -215,17 +170,12 @@ static void proto_movetux(char *msg) 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 ) - { + if (tux != NULL) moveObjectInSpace(space, tux, x, y); - } } static void proto_moveshot(char *msg) @@ -236,28 +186,18 @@ static void proto_moveshot(char *msg) 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 ) - { + 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 ) - { + if (shot->gun == GUN_LASSER) export_fce->fce_transformOnlyLasser(shot); - } } #ifndef PUBLIC_SERVER @@ -285,13 +225,12 @@ void cmdArena(char *line) void recvMsg(char *msg) { - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { + if (export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_SERVER) return; - } - - if( strncmp(msg, "movetux", 7) == 0 )proto_movetux(msg); - if( strncmp(msg, "moveshot", 8) == 0 )proto_moveshot(msg); + if (strncmp(msg, "movetux", 7) == 0) + proto_movetux(msg); + if (strncmp(msg, "moveshot", 8) == 0) + proto_moveshot(msg); } int destroy() -- cgit v1.2.3