From 6c4fe3323d79253af707df90623e433ce12c35f2 Mon Sep 17 00:00:00 2001 From: scarab Date: Sat, 5 Jul 2008 16:43:55 +0000 Subject: * Prechod na novou verzi instalace pseudoautotools -> cmake * Odstraneni bordelu kterej tu byl (pokud vam neco chybi brecte na me ja to zkusim najit v zaloze) * TODO instalace: SEPSAT AUTORY, IKONKU VYROBIT git-svn-id: http://opensvn.csie.org/tuxanci_ng@94 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- modules/modPipe.c | 453 ------------------------------------------------------ 1 file changed, 453 deletions(-) delete mode 100755 modules/modPipe.c (limited to 'modules/modPipe.c') diff --git a/modules/modPipe.c b/modules/modPipe.c deleted file mode 100755 index 2c1a6e5..0000000 --- a/modules/modPipe.c +++ /dev/null @@ -1,453 +0,0 @@ - -#include -#include -#include -#include - -#include "main.h" -#include "modules.h" -#include "tux.h" -#include "shot.h" -#include "list.h" -#include "gun.h" -#include "space.h" - -#ifndef PUBLIC_SERVER -#include "interface.h" -#include "image.h" -#endif - -#ifdef PUBLIC_SERVER -#include "publicServer.h" -#endif - -typedef struct pipe_struct -{ - int x; // poloha steny - int y; - - int w; // rozmery steny - int h; - - int id; - int id_out; - int position; - - int layer; // vrstva - -#ifndef PUBLIC_SERVER - SDL_Surface *img; //obrazok -#endif -} pipe_t; - -static export_fce_t *export_fce; - -static list_t *listPipe; -static space_t *spacePipe; - -#ifndef PUBLIC_SERVER -static pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position, SDL_Surface *img) -#endif - -#ifdef PUBLIC_SERVER -static pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position) -#endif - -{ - pipe_t *new; - -#ifndef PUBLIC_SERVER - assert( img != NULL ); -#endif - - new = malloc( sizeof(pipe_t) ); - assert( new != NULL ); - - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->layer = layer; - new->id = id; - new->id_out = id_out; - new->position = position; -#ifndef PUBLIC_SERVER - new->img = img; -#endif - return new; -} - -static void setStatusPipe(void *p, int x, int y, int w, int h) -{ - pipe_t *pipe; - - pipe = p; - - pipe->x = x; - pipe->y = y; - pipe->w = w; - pipe->h = h; -} - -static void getStatusPipe(void *p, int *id, int *x, int *y, int *w, int *h) -{ - pipe_t *pipe; - - pipe = p; - - *id = pipe->id; - *x = pipe->x; - *y = pipe->y; - *w = pipe->w; - *h = pipe->h; -} - -#ifndef PUBLIC_SERVER - -static void drawPipe(pipe_t *p) -{ - assert( p != NULL ); - - export_fce->fce_addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); -} - -#endif - -static void destroyPipe(pipe_t *p) -{ - assert( p != NULL ); - free(p); -} - - -static void cmd_teleport(char *line) -{ - char str_x[STR_NUM_SIZE]; - char str_y[STR_NUM_SIZE]; - char str_w[STR_NUM_SIZE]; - char str_h[STR_NUM_SIZE]; - char str_id[STR_NUM_SIZE]; - char str_id_out[STR_NUM_SIZE]; - char str_position[STR_NUM_SIZE]; - char str_layer[STR_NUM_SIZE]; - char str_image[STR_SIZE]; - pipe_t *new; - - if( export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "h", str_h, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "id", str_id, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "id_out", str_id_out, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "position", str_position, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 )return; - if( export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0 )return; - -#ifndef PUBLIC_SERVER - new = newPipe(atoi(str_x), atoi(str_y), - atoi(str_w), atoi(str_h), - atoi(str_layer), atoi(str_id), atoi(str_id_out), atoi(str_position), - export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) ); -#endif - -#ifdef PUBLIC_SERVER - new = newPipe(atoi(str_x), atoi(str_y), - atoi(str_w), atoi(str_h), - atoi(str_layer), atoi(str_id), atoi(str_id_out), atoi(str_position) ); -#endif - - if( spacePipe == NULL ) - { - spacePipe = newSpace(export_fce->fce_getCurrentArena()->w, export_fce->fce_getCurrentArena()->h, - 320, 240, getStatusPipe, setStatusPipe); - } - - addObjectToSpace(spacePipe, new); -} - -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) ); -} - -static void transformShot(shot_t *shot, int position) -{ - int speed; - - speed = getSppedShot(shot); - - switch( position ) - { - case TUX_UP : - shot->px = 0; - shot->py = -speed; - break; - - case TUX_LEFT : - shot->px = -speed; - shot->py = 0; - break; - - case TUX_RIGHT : - shot->px = speed; - shot->py = 0; - break; - - case TUX_DOWN : - shot->px = 0; - shot->py = +speed; - break; - } - - shot->position = position; - shot->isCanKillAuthor = TRUE; - - if( shot->gun == GUN_LASSER ) - { - export_fce->fce_transformOnlyLasser(shot); - } -} - -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, new_y; - - switch( shot->position ) - { - case TUX_UP : - case TUX_DOWN : - offset = shot->x - src_x; - break; - - case TUX_RIGHT : - case TUX_LEFT : - offset = shot->y - src_y; - break; - } - - transformShot(shot, position); - - switch( shot->position ) - { - case TUX_UP : - new_x = dist_x + offset; - new_y = dist_y; - break; - - case TUX_LEFT : - new_x = dist_x; - new_y = dist_y + offset; - break; - - case TUX_RIGHT : - new_x = dist_x + dist_w; - new_y = dist_y + offset; - break; - - case TUX_DOWN : - new_x = dist_x + offset; - new_y = dist_y + dist_h; - 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); - } -} - -static void moveShotFromPipe(shot_t *shot, pipe_t *pipe) -{ - pipe_t *distPipe; - - distPipe = getObjectFromSpaceWithID(spacePipe, pipe->id_out); - - if( distPipe == NULL ) - { - fprintf(stderr, "Pipe %d ID not found\n", pipe->id); - return; - } - - moveShot(shot, distPipe->position, pipe->x, pipe->y, - distPipe->x, distPipe->y, distPipe->w, distPipe->h); -} - -int init(export_fce_t *p) -{ - export_fce = p; - - listPipe = newList(); - - return 0; -} - -#ifndef PUBLIC_SERVER - -int draw(int x, int y, int w, int h) -{ - pipe_t *thisPipe; - int i; - - if( spacePipe == NULL ) - { - return 0; - } - - listDoEmpty(listPipe); - getObjectFromSpace(spacePipe, x, y, w, h, listPipe); - //printSpace(spacePipe); - - for( i = 0 ; i < listPipe->count ; i++ ) - { - thisPipe = (pipe_t *)listPipe->list[i]; - assert( thisPipe != NULL ); - drawPipe(thisPipe); - } - - return 0; -} -#endif - -static int negPosition(int n) -{ - switch( n ) - { - case TUX_UP : - return TUX_DOWN; - - case TUX_LEFT : - return TUX_RIGHT; - - case TUX_RIGHT : - return TUX_LEFT; - - case TUX_DOWN : - return TUX_UP; - - default : - assert( ! "premenna n ma zlu hodnotu !" ); - break; - } -} - -int event() -{ - pipe_t *thisPipe; - arena_t *arena; - int i; - - if( spacePipe == NULL ) - { - return 0; - } - -/* - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - return; - } -*/ - arena = export_fce->fce_getCurrentArena(); - - for( i = 0 ; i < arena->spaceShot->list->count ; i++ ) - { - shot_t *thisShot; - int j; - - thisShot = (shot_t *) arena->spaceShot->list->list[i]; - assert( thisShot != NULL ); - - listDoEmpty(listPipe); - getObjectFromSpace(spacePipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listPipe); - - for( j = 0 ; j < listPipe->count ; j++ ) - { - tux_t *author; - - thisPipe = (pipe_t *)listPipe->list[j]; - - author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } - - if( negPosition( thisShot->position ) == thisPipe->position ) - { - //moveShotFromPipe(thisShot, thisPipe, listPipe); - - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - if( thisShot->gun != GUN_BOMBBALL ) - { - delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot, - thisShot, export_fce->fce_destroyShot); - //delListItem(arena->listShot, i, export_fce->fce_destroyShot); - i--; - } - } - else - { - moveShotFromPipe(thisShot, thisPipe); - } - - } - else - { - if( thisShot->gun == GUN_BOMBBALL && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - export_fce->fce_boundBombBall(thisShot); - continue; - } - else - { - delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot, - thisShot, export_fce->fce_destroyShot); - i--; - } - } - } - } - - return 0; -} - -int isConflict(int x, int y, int w, int h) -{ - if( spacePipe == NULL ) - { - return 0; - } - - return isConflictWithObjectFromSpace(spacePipe, x, y, w, h); -} - -void cmd(char *line) -{ - if( strncmp(line, "pipe", 4) == 0 )cmd_teleport(line); -} - -int destroy() -{ - destroySpaceWithObject(spacePipe, destroyPipe); - destroyList(listPipe); - - return 0; -} -- cgit v1.2.3