summaryrefslogtreecommitdiff
path: root/src/teleport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/teleport.c')
-rw-r--r--src/teleport.c242
1 files changed, 0 insertions, 242 deletions
diff --git a/src/teleport.c b/src/teleport.c
deleted file mode 100644
index d8557e3..0000000
--- a/src/teleport.c
+++ /dev/null
@@ -1,242 +0,0 @@
-
-#include <stdlib.h>
-#include <assert.h>
-
-#include "main.h"
-#include "tux.h"
-#include "teleport.h"
-#include "shot.h"
-#include "net_multiplayer.h"
-#include "proto.h"
-#include "arena.h"
-
-#ifndef PUBLIC_SERVER
-#include "layer.h"
-#include "screen_world.h"
-#include "sound.h"
-#include "fake_audio.h"
-#endif
-
-#ifdef PUBLIC_SERVER
-#include "publicServer.h"
-#endif
-
-#ifndef PUBLIC_SERVER
-teleport_t* newTeleport(int x, int y, int w, int h, int layer, SDL_Surface *img)
-#endif
-
-#ifdef PUBLIC_SERVER
-teleport_t* newTeleport(int x, int y, int w, int h, int layer)
-#endif
-{
- teleport_t *new;
-
-#ifndef PUBLIC_SERVER
- assert( img != NULL );
-#endif
-
- new = malloc( sizeof(teleport_t) );
- assert( new != NULL );
-
- new->x = x;
- new->y = y;
- new->w = w;
- new->h = h;
- new->layer = layer;
-#ifndef PUBLIC_SERVER
- new->img = img;
-#endif
- return new;
-}
-
-#ifndef PUBLIC_SERVER
-
-void drawTeleport(teleport_t *p)
-{
- assert( p != NULL );
-
- addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer);
-}
-
-void drawListTeleport(list_t *listTeleport)
-{
- teleport_t *thisTeleport;
- int i;
-
- assert( listTeleport != NULL );
-
- for( i = 0 ; i < listTeleport->count ; i++ )
- {
- thisTeleport = (teleport_t *)listTeleport->list[i];
- assert( thisTeleport != NULL );
- drawTeleport(thisTeleport);
- }
-}
-
-#endif
-
-teleport_t* isConflictWithListTeleport(list_t *listTeleport, int x, int y, int w, int h)
-{
- teleport_t *thisTeleport;
- int i;
-
- assert( listTeleport != NULL );
-
- for( i = 0 ; i < listTeleport->count ; i++ )
- {
- thisTeleport = (teleport_t *)listTeleport->list[i];
- assert( thisTeleport != NULL );
-
- if( conflictSpace(x, y, w, h,
- thisTeleport->x, thisTeleport->y, thisTeleport->w, thisTeleport->h) )
- {
- return thisTeleport;
- }
- }
-
- return NULL;
-}
-
-static teleport_t* getRandomTeleportBut(list_t *listTeleport, teleport_t *teleport)
-{
- int x;
-
- do{
- x = random() % listTeleport->count;
- }while( listTeleport->list[x] == teleport );
-
- return (teleport_t *) listTeleport->list[x];
-}
-
-static int getRandomPosition()
-{
- switch( random() % 4 )
- {
- case 0 :
- return TUX_UP;
-
- case 1 :
- return TUX_LEFT;
-
- case 2 :
- return TUX_RIGHT;
-
- case 3 :
- return TUX_DOWN;
- }
-
- assert( ! "Stupid error ! " );
-}
-
-static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *listTeleport)
-{
- teleport_t *distTeleport;
-
- distTeleport = getRandomTeleportBut(listTeleport, teleport);
-
- moveShot(shot, getRandomPosition(), teleport->x, teleport->y,
- distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h);
-}
-
-void eventConflictShotWithTeleport(list_t *listTeleport, list_t *listShot)
-{
- shot_t *thisShot;
- teleport_t *thisTeleport;
- int i;
-
- assert( listTeleport != NULL );
- assert( listShot != NULL );
-
- for( i = 0 ; i < listShot->count ; i++ )
- {
- thisShot = (shot_t *)listShot->list[i];
- assert( thisShot != NULL );
-
- if( ( thisTeleport = isConflictWithListTeleport(listTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL )
- {
- tux_t *author;
-
- author = getTuxID(getCurrentArena()->listTux, thisShot->author_id);
-
- if( author != NULL &&
- author->bonus == BONUS_GHOST &&
- author->bonus_time > 0 )
- {
- continue;
- }
-
- if( getNetTypeGame() == NET_GAME_TYPE_CLIENT )
- {
- delListItem(listShot, i, destroyShot);
- i--;
- }
- else
- {
- moveShotFromTeleport(thisShot, thisTeleport, listTeleport);
- }
- }
- }
-}
-
-void eventTeleportTux(list_t *listTeleport, teleport_t *teleport, tux_t *tux)
-{
- teleport_t *distTeleport;
- int current_x, current_y;
- int dist_x, dist_y;
-
- if( tux->bonus == BONUS_GHOST ||
- getNetTypeGame() == NET_GAME_TYPE_CLIENT )
- {
- return;
- }
-
- distTeleport = getRandomTeleportBut(listTeleport, teleport);
-
- getTuxProportion(tux, &current_x, &current_y, NULL, NULL);
-
- switch( tux->position )
- {
- case TUX_UP :
- dist_x = distTeleport->x + distTeleport->w/2;
- dist_y = distTeleport->y - ( TUX_HEIGHT + 10 );
- break;
-
- case TUX_LEFT :
- dist_y = distTeleport->y + distTeleport->h/2;
- dist_x = distTeleport->x - ( TUX_WIDTH + 10 );
- break;
-
- case TUX_RIGHT :
- dist_y = distTeleport->y + distTeleport->h/2;
- dist_x = distTeleport->x + distTeleport->w + 10;
- break;
-
- case TUX_DOWN :
- dist_x = distTeleport->x + distTeleport->w/2;
- dist_y = distTeleport->y + distTeleport->h + 10;
- break;
-
- default :
- assert( ! "premenna p->control ma zlu hodnotu !" );
- break;
- }
-
- if( isFreeSpace(getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) )
- {
- setTuxProportion(tux, dist_x, dist_y);
-#ifndef PUBLIC_SERVER
- playSound("teleport", SOUND_GROUP_BASE);
-#endif
- if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
- {
- proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
- }
- }
-}
-
-void destroyTeleport(teleport_t *p)
-{
- assert( p != NULL );
- free(p);
-}
-