diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rwxr-xr-x | conf/keytable.conf | 16 | ||||
| -rw-r--r-- | config.h | 2 | ||||
| -rwxr-xr-x | image/bombball.png | bin | 0 -> 510 bytes | |||
| -rwxr-xr-x | image/icon.gun.bombball.png | bin | 0 -> 1528 bytes | |||
| -rwxr-xr-x | image/item.bombball.png | bin | 0 -> 3788 bytes | |||
| -rw-r--r-- | image/textfield0.png | bin | 0 -> 2661 bytes | |||
| -rw-r--r-- | image/textfield1.png | bin | 0 -> 3594 bytes | |||
| -rw-r--r-- | include/gun.h | 3 | ||||
| -rwxr-xr-x | include/interface.h | 1 | ||||
| -rw-r--r-- | include/proto.h | 2 | ||||
| -rw-r--r-- | include/shot.h | 2 | ||||
| -rw-r--r-- | include/widget_textfield.h | 4 | ||||
| -rw-r--r-- | server.conf | 3 | ||||
| -rwxr-xr-x | src/Makefile | 8 | ||||
| -rw-r--r-- | src/arena.c | 11 | ||||
| -rw-r--r-- | src/client.c | 1 | ||||
| -rw-r--r-- | src/gun.c | 14 | ||||
| -rwxr-xr-x | src/interface.c | 16 | ||||
| -rw-r--r-- | src/item.c | 24 | ||||
| -rw-r--r-- | src/panel.c | 1 | ||||
| -rw-r--r-- | src/pipe.c | 21 | ||||
| -rw-r--r-- | src/proto.c | 59 | ||||
| -rw-r--r-- | src/screen_setting.c | 2 | ||||
| -rw-r--r-- | src/server.c | 13 | ||||
| -rw-r--r-- | src/shot.c | 103 | ||||
| -rw-r--r-- | src/tux.c | 61 | ||||
| -rw-r--r-- | src/wall.c | 8 |
28 files changed, 315 insertions, 61 deletions
@@ -1,4 +1,3 @@ - DESTDIR:=/usr/local all: diff --git a/conf/keytable.conf b/conf/keytable.conf index 1e349f4..236b72c 100755 --- a/conf/keytable.conf +++ b/conf/keytable.conf @@ -271,19 +271,3 @@ keycode SDLK_EURO = 321 keycode SDLK_UNDO = 322 #******************************************** - -TUX_RIGHT_MOVE_UP = SDLK_KP8 SDLK_UP -TUX_RIGHT_MOVE_RIGHT = SDLK_KP6 SDLK_RIGHT -TUX_RIGHT_MOVE_LEFT = SDLK_KP4 SDLK_LEFT -TUX_RIGHT_MOVE_DOWN = SDLK_KP5 SDLK_DOWN -TUX_RIGHT_SHOOT = SDLK_KP0 -TUX_RIGHT_SWITCH_WEAPON = SDLK_KP1 - -TUX_LEFT_MOVE_UP = SDLK_w -TUX_LEFT_MOVE_RIGHT = SDLK_d -TUX_LEFT_MOVE_LEFT = SDLK_a -TUX_LEFT_MOVE_DOWN = SDLK_s -TUX_LEFT_SHOOT = SDLK_q -TUX_LEFT_SWITCH_WEAPON = SDLK_TAB - -#******************************************** @@ -6,7 +6,7 @@ #define DEBUG_CLIENT_RECV */ -#define TUXANCI_NG_VERSION "svn43" +#define TUXANCI_NG_VERSION "svn45" #define DESTDIR "/usr/local/" #define SUPPORT_NET_SDL_UDP diff --git a/image/bombball.png b/image/bombball.png Binary files differnew file mode 100755 index 0000000..bb3cda7 --- /dev/null +++ b/image/bombball.png diff --git a/image/icon.gun.bombball.png b/image/icon.gun.bombball.png Binary files differnew file mode 100755 index 0000000..65eb972 --- /dev/null +++ b/image/icon.gun.bombball.png diff --git a/image/item.bombball.png b/image/item.bombball.png Binary files differnew file mode 100755 index 0000000..d310d8f --- /dev/null +++ b/image/item.bombball.png diff --git a/image/textfield0.png b/image/textfield0.png Binary files differnew file mode 100644 index 0000000..f6cc862 --- /dev/null +++ b/image/textfield0.png diff --git a/image/textfield1.png b/image/textfield1.png Binary files differnew file mode 100644 index 0000000..2b0aad8 --- /dev/null +++ b/image/textfield1.png diff --git a/include/gun.h b/include/gun.h index 5f443e6..7389757 100644 --- a/include/gun.h +++ b/include/gun.h @@ -11,6 +11,9 @@ #define GUN_LASSER_HORIZONTAL 20 #define GUN_SHOT_VERTICAL 5 +#define GUN_BOMBBALL_WIDTH 20 +#define GUN_BOMBBALL_HEIGHT 20 + #include "tux.h" extern void shotInGun(tux_t *p); diff --git a/include/interface.h b/include/interface.h index e0a7893..c0311ee 100755 --- a/include/interface.h +++ b/include/interface.h @@ -31,6 +31,7 @@ extern int initSDL(); extern SDL_Surface* getSDL_Screen(); extern void getMousePosition(int *x, int *y); extern int isMouseClicked(); +extern int isPessAnyKey(); extern void interfaceRefresh(); extern void eventSDL(); extern void quitSDL(); diff --git a/include/proto.h b/include/proto.h index bd5b2c0..8838a60 100644 --- a/include/proto.h +++ b/include/proto.h @@ -72,6 +72,8 @@ extern void proto_recv_additem_client(char *msg); extern void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item); extern void proto_recv_item_client(char *msg); extern void proto_send_shot_server(int type, client_t *client, shot_t *p); +extern void proto_send_delshot_server(int type, client_t *client, shot_t *p); +extern void proto_recv_delshot_client(char *msg); extern void proto_recv_shot_client(char *msg); extern void proto_send_ping_client(); extern void proto_recv_ping_server(client_t *client, char *msg); diff --git a/include/shot.h b/include/shot.h index d3e9bcc..27f05a5 100644 --- a/include/shot.h +++ b/include/shot.h @@ -37,6 +37,7 @@ typedef struct shot_struct extern bool_t isShotInicialized(); extern void initShot(); extern shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author); +extern shot_t* getShotID(list_t *listShot, int id); #ifndef PUBLIC_SERVER extern void drawShot(shot_t *p); extern void drawListShot(list_t *listShot); @@ -45,6 +46,7 @@ extern int isConflictWithListShot(list_t *listShot, int x, int y, int w, int h); extern void eventMoveListShot(list_t *listShot); extern void transformOnlyLasser(shot_t *shot); +extern void boundBombBall(shot_t *shot); extern 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); diff --git a/include/widget_textfield.h b/include/widget_textfield.h index 860eae4..af59ae8 100644 --- a/include/widget_textfield.h +++ b/include/widget_textfield.h @@ -5,7 +5,7 @@ #include "main.h" -#define WIDGET_TEXTFIELD_WIDTH 125 +#define WIDGET_TEXTFIELD_WIDTH 188 #define WIDGET_TEXTFIELD_HEIGHT 36 #define WIDGET_TEXTFIELD_TEXT_OFFSET_X 10 @@ -17,7 +17,7 @@ typedef struct widget_textfield { int x, y; int w, h; - int time; + int canWrite; int timeBlick; char text[STR_SIZE]; bool_t active; diff --git a/server.conf b/server.conf index 0d65729..135863f 100644 --- a/server.conf +++ b/server.conf @@ -1,4 +1,5 @@ IP 0.0.0.0 PORT 2200 MAX_CLIENTS 32 -ARENA FAGN +ARENA NW + diff --git a/src/Makefile b/src/Makefile index 532132a..8661603 100755 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ CC = gcc CFLAGS = -g -O0 -I../include -Wall `sdl-config --cflags` #CFLAGS = -O2 -DDESTDIR=\"$(DESTDIR)\" `sdl-config --cflags` -I../include -Wall -BUILD_DIR = ../build +BUILD_DIR = . LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o main.o \ @@ -17,11 +17,9 @@ FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o widget_buttonimage.o screen_credits.o teleport.o pipe.o homeDirector.o screen_table.o \ sdl_udp.o proto.o server.o client.o term.o keytable.o language.o -tuxanci-ng: mkdir_build $(FILES) +tuxanci-ng: $(FILES) $(CC) $(CFLAGS) $(LIBS) -o $(BUILD_DIR)/tuxanci-ng $(BUILD_DIR)/*.o -mkdir_build: - mkdir -p $(BUILD_DIR) main.o: main.c $(CC) $(CFLAGS) -o $(BUILD_DIR)/main.o -c main.c @@ -180,4 +178,4 @@ language.o: language.c ../include/language.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/language.o -c language.c clean: - rm -rf $(BUILD_DIR) *.c~ ../include/*.h~ Makefile~ + rm -rf *.o *.c~ ../include/*.h~ Makefile~ diff --git a/src/arena.c b/src/arena.c index 760c51b..b762937 100644 --- a/src/arena.c +++ b/src/arena.c @@ -139,6 +139,17 @@ void eventArena(arena_t *arena) eventTimer(arena->listTimer); } +int isConflictWithObjectInArena(arena_t *arena, int x, int y, int w, int h) +{ + if( isConflictWithListWall(arena->listWall, x, y, w, h) || + isConflictWithListPipe(arena->listPipe, x, y, w, h) ) + { + return 1; + } + + return 0; +} + void destroyArena(arena_t *p) { destroyListItem(p->listTux, destroyTux); diff --git a/src/client.c b/src/client.c index 612a5b4..a047a2a 100644 --- a/src/client.c +++ b/src/client.c @@ -154,6 +154,7 @@ void eventServerBuffer() if( strncmp(line, "additem", 7) == 0 )proto_recv_additem_client(line); if( strncmp(line, "item", 4) == 0 )proto_recv_item_client(line); if( strncmp(line, "shot", 4) == 0 )proto_recv_shot_client(line); + if( strncmp(line, "delshot", 7) == 0 )proto_recv_delshot_client(line); if( strncmp(line, "kill", 4) == 0 )proto_recv_kill_client(line); if( strncmp(line, "score", 5) == 0 )proto_recv_score_client(line); if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_client(line); @@ -96,7 +96,11 @@ static void addShot(tux_t *tux,int x, int y, int px, int py) return; } - if( tux->gun == GUN_LASSER ) + if( tux->gun == GUN_BOMBBALL ) + { + gun = GUN_BOMBBALL; + } + else if( tux->gun == GUN_LASSER ) { gun = GUN_LASSER; } @@ -269,6 +273,11 @@ static void putInGunMine(tux_t *tux) } } +static void shotInGunBombball(tux_t *tux) +{ + addShot(tux, 0, 0, +10, 0); +} + void shotInGun(tux_t *tux) { if( tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE ) @@ -308,6 +317,9 @@ void shotInGun(tux_t *tux) #endif shotInGunLasser(tux); break; + case GUN_BOMBBALL : + shotInGunBombball(tux); + break; case GUN_MINE : putInGunMine(tux); break; diff --git a/src/interface.c b/src/interface.c index d629c5b..9e0d6bf 100755 --- a/src/interface.c +++ b/src/interface.c @@ -122,6 +122,22 @@ int isMouseClicked() return SDL_GetMouseState(NULL,NULL) & SDL_BUTTON(SDL_BUTTON_LEFT); } +int isPessAnyKey() +{ + Uint8 *mapa; + int i; + + mapa = SDL_GetKeyState(NULL); + + for( i = SDLK_BACKSPACE ; i < SDLK_KP9 ; i++ ) + if( mapa[i] == SDL_PRESSED ) + { + return 1; + } + + return 0; +} + /* static void action_esc() { @@ -43,6 +43,8 @@ void initItem() g_item[GUN_SCATTER] = addImageData("item.scatter.png", IMAGE_ALPHA, "item_scatter_simple", IMAGE_GROUP_BASE); g_item[GUN_LASSER] = addImageData("item.lasser.png", IMAGE_ALPHA, "item_lasser_simple", IMAGE_GROUP_BASE); g_item[GUN_MINE] = addImageData("item.mine.png", IMAGE_ALPHA, "item_mines_simple", IMAGE_GROUP_BASE); + g_item[GUN_BOMBBALL] = addImageData("item.bombball.png", IMAGE_ALPHA, "item_bombball_simple", IMAGE_GROUP_BASE); + g_item[ITEM_MINE] = addImageData("mine.png", IMAGE_ALPHA, "item_mine_simple", IMAGE_GROUP_BASE); g_item[ITEM_EXPLOSION] = addImageData("explosion.png", IMAGE_ALPHA, "item_explosion_simple", IMAGE_GROUP_BASE); g_item[ITEM_BIG_EXPLOSION] = addImageData("big-explosion.png", IMAGE_ALPHA, "item_big-explosion_simple", IMAGE_GROUP_BASE); @@ -85,6 +87,7 @@ item_t* newItem(int x, int y, int type, tux_t *author) case GUN_TOMMY : case GUN_LASSER : case GUN_MINE : + case GUN_BOMBBALL : new->w = ITEM_GUN_WIDTH; new->h = ITEM_GUN_HEIGHT; break; @@ -171,7 +174,7 @@ void addNewItem(list_t *listItem, tux_t *author) #ifndef PUBLIC_SERVER do{ #endif - switch( random() % 11 ) + switch( random() % 12 ) { case 0 : type = GUN_DUAL_SIMPLE; break; @@ -183,21 +186,24 @@ void addNewItem(list_t *listItem, tux_t *author) break; case 4 : type = GUN_LASSER; break; - case 5 : type = BONUS_SPEED; + case 5 : type = GUN_BOMBBALL; + break; + case 6 : type = BONUS_SPEED; break; - case 6 : type = BONUS_SHOT; + case 7 : type = BONUS_SHOT; break; - case 7 : type = BONUS_TELEPORT; + case 8 : type = BONUS_TELEPORT; break; - case 8 : type = BONUS_GHOST; + case 9 : type = BONUS_GHOST; break; - case 9 : type = BONUS_4X; + case 10 : type = BONUS_4X; break; - case 10 : type = BONUS_HIDDEN; + case 11 : type = BONUS_HIDDEN; break; } #ifndef PUBLIC_SERVER - }while( isSettingItem(type) == FALSE ); + }while( isSettingItem(type) == FALSE || + (getNetTypeGame() == NET_GAME_TYPE_NONE && type == BONUS_HIDDEN) ); #endif item = newItem(new_x, new_y, type, author); @@ -281,6 +287,7 @@ void eventListItem(list_t *listItem) case GUN_SCATTER : case GUN_LASSER : case GUN_MINE : + case GUN_BOMBBALL : if( thisItem->frame == ITEM_GUN_MAX_FRAME ) { thisItem->frame = 0; @@ -494,6 +501,7 @@ int eventGiveTuxItem(tux_t *tux, list_t *listItem, item_t *item) case GUN_SCATTER : case GUN_LASSER : case GUN_MINE : + case GUN_BOMBBALL : tuxGiveGun(tux, item); delListItem(listItem, index, destroyItem); return index; diff --git a/src/panel.c b/src/panel.c index 1e93084..079d753 100644 --- a/src/panel.c +++ b/src/panel.c @@ -38,6 +38,7 @@ void initPanel() g_icon[GUN_SCATTER] = addImageData("icon.gun.scatter.png", IMAGE_ALPHA, "panel_scatter", IMAGE_GROUP_BASE); g_icon[GUN_LASSER] = addImageData("icon.gun.lasser.png", IMAGE_ALPHA, "panel_lasser", IMAGE_GROUP_BASE); g_icon[GUN_MINE] = addImageData("icon.gun.mine.png", IMAGE_ALPHA, "panel_mine", IMAGE_GROUP_BASE); + g_icon[GUN_BOMBBALL] = addImageData("icon.gun.bombball.png", IMAGE_ALPHA, "panel_bombball", IMAGE_GROUP_BASE); g_icon[BONUS_SPEED] = addImageData("icon.bonus.speed.png", IMAGE_ALPHA, "panel_speed", IMAGE_GROUP_BASE); g_icon[BONUS_SHOT] = addImageData("icon.bonus.shot.png", IMAGE_ALPHA, "panel_shot", IMAGE_GROUP_BASE); @@ -169,7 +169,7 @@ void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot) assert( thisShot != NULL ); if( ( thisPipe = isConflictWithListPipe(listPipe, thisShot->x, thisShot->y, - thisShot->w, thisShot->h) ) != NULL ) + thisShot->w, thisShot->h) ) != NULL ) { if( thisShot->author->bonus == BONUS_GHOST && thisShot->author->bonus_time > 0 ) @@ -181,8 +181,11 @@ void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot) { if( getNetTypeGame() == NET_GAME_TYPE_CLIENT ) { - delListItem(listShot, i, destroyShot); - i--; + if( thisShot->gun != GUN_BOMBBALL ) + { + delListItem(listShot, i, destroyShot); + i--; + } } else { @@ -191,8 +194,16 @@ void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot) } else { - delListItem(listShot, i, destroyShot); - i--; + if( thisShot->gun == GUN_BOMBBALL && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + boundBombBall(thisShot); + continue; + } + else + { + delListItem(listShot, i, destroyShot); + i--; + } } } } diff --git a/src/proto.c b/src/proto.c index 042ce7f..60bcf20 100644 --- a/src/proto.c +++ b/src/proto.c @@ -584,8 +584,8 @@ void proto_send_shot_server(int type, client_t *client, shot_t *p) id = p->author->id; } - sprintf(msg, "shot %d %d %d %d %d %d %d %d\n", - p->x, p->y, p->px, p->py, p->position, p->gun, id, p->isCanKillAuthor); + sprintf(msg, "shot %d %d %d %d %d %d %d %d %d\n", + p->id, p->x, p->y, p->px, p->py, p->position, p->gun, id, p->isCanKillAuthor); proto_send(type, client, msg); } @@ -595,15 +595,21 @@ void proto_send_shot_server(int type, client_t *client, shot_t *p) void proto_recv_shot_client(char *msg) { char cmd[STR_PROTO_SIZE]; - int x, y, px, py, position, gun, id, isCanKillAuthor; + int x, y, px, py, position, gun, shot_id, author_id, isCanKillAuthor; shot_t *shot; assert( msg != NULL ); - sscanf(msg, "%s %d %d %d %d %d %d %d %d", - cmd, &x, &y, &px, &py, &position, &gun, &id, &isCanKillAuthor); + sscanf(msg, "%s %d %d %d %d %d %d %d %d %d", + cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id, &isCanKillAuthor); - shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, id)); +/* + if( getShotID(getCurrentArena()->listShot, shot_id) != NULL ) + { + return; + } +*/ + shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, author_id)); shot->isCanKillAuthor = isCanKillAuthor; shot->position = position; @@ -618,6 +624,47 @@ void proto_recv_shot_client(char *msg) #endif +void proto_send_delshot_server(int type, client_t *client, shot_t *shot) +{ + char msg[STR_PROTO_SIZE]; + + assert( shot != NULL ); + + sprintf(msg, "delshot %d\n", shot->id); + + proto_send(type, client, msg); +} + +#ifndef PUBLIC_SERVER + +void proto_recv_delshot_client(char *msg) +{ + char cmd[STR_PROTO_SIZE]; + shot_t *shot; + int id; + + assert( msg != NULL ); + + sscanf(msg, "%s %d", + cmd, &id); + + shot = getShotID(getCurrentArena()->listShot, id); + + if( shot != NULL ) + { + int index; + + index = searchListItem(getCurrentArena()->listShot, shot); + + if( index >= 0 ) + { + delListItem(getCurrentArena()->listShot, index, destroyShot); + } + } +} + +#endif + #ifndef PUBLIC_SERVER void proto_send_ping_client() diff --git a/src/screen_setting.c b/src/screen_setting.c index 72368c1..82bf432 100644 --- a/src/screen_setting.c +++ b/src/screen_setting.c @@ -332,7 +332,7 @@ void initScreenSetting() image_gun_tommy = newWidgetImage(110 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_tommy")); image_gun_lasser = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_lasser")); image_gun_mine = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_mine")); - image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_dual")); + image_gun_bombball = newWidgetImage(260 + WIDGET_CHECK_WIDTH, 300, getImage(IMAGE_GROUP_BASE, "panel_bombball")); image_bonus_speed = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 200, getImage(IMAGE_GROUP_BASE, "panel_speed"));; image_bonus_shot = newWidgetImage(430 + WIDGET_CHECK_WIDTH, 250, getImage(IMAGE_GROUP_BASE, "panel_shot"));; diff --git a/src/server.c b/src/server.c index f3972d3..90a388a 100644 --- a/src/server.c +++ b/src/server.c @@ -121,6 +121,18 @@ static void eventPeriodicSyncClient(void *p_nothink) } } +static void eventPeriodicSyncSelfClient(void *p_nothink) +{ + client_t *thisClient; + int i; + + for( i = 0 ; i < listClient->count; i++) + { + thisClient = (client_t *) listClient->list[i]; + proto_send_newtux_server(PROTO_SEND_ONE, thisClient, thisClient->tux); + } +} + static void eventSendPingClients(void *p_nothink) { proto_send_ping_server(PROTO_SEND_ALL, NULL); @@ -136,6 +148,7 @@ void static initServer() addTaskToTimer(listServerTimer, TIMER_PERIODIC, delZombieCLient, NULL, SERVER_TIMEOUT); addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncClient, NULL, SERVER_TIME_SYNC); + addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncSelfClient, NULL, 5000); addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventSendPingClients, NULL, SERVER_TIME_PING); } @@ -6,6 +6,8 @@ #include "main.h" #include "shot.h" #include "gun.h" +#include "wall.h" +#include "pipe.h" #include "net_multiplayer.h" #include "proto.h" @@ -24,6 +26,7 @@ static SDL_Surface *g_shot_simple; static SDL_Surface *g_shot_lasserX; static SDL_Surface *g_shot_lasserY; +static SDL_Surface *g_shot_bombball; #endif @@ -45,6 +48,7 @@ void initShot() g_shot_simple = addImageData("shot.png", IMAGE_ALPHA, "shot", IMAGE_GROUP_BASE); g_shot_lasserX = addImageData("lasserX.png", IMAGE_NO_ALPHA, "lasserX", IMAGE_GROUP_BASE); g_shot_lasserY = addImageData("lasserY.png", IMAGE_NO_ALPHA, "lasserY", IMAGE_GROUP_BASE); + g_shot_bombball = addImageData("bombball.png", IMAGE_ALPHA, "bombball", IMAGE_GROUP_BASE); #endif @@ -103,6 +107,15 @@ shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) } break; + case GUN_BOMBBALL : + new->w = GUN_BOMBBALL_WIDTH; + new->h = GUN_BOMBBALL_HEIGHT; + +#ifndef PUBLIC_SERVER + new->img = g_shot_bombball; +#endif + break; + default : assert( ! "Premenna weapon ma zlu hodnotu !" ); break; @@ -111,6 +124,28 @@ shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) return new; } +shot_t* getShotID(list_t *listShot, int id) +{ + shot_t *thisShot; + int i; + + assert( listShot != NULL ); + + for( i = 0 ; i < listShot->count ; i++ ) + { + thisShot = (shot_t *)listShot->list[i]; + assert( thisShot != NULL ); + + if( thisShot->id == id ) + { + return thisShot; + } + } + + return NULL; +} + + #ifndef PUBLIC_SERVER void drawShot(shot_t *p) @@ -158,6 +193,51 @@ int isConflictWithListShot(list_t *listShot, int x, int y, int w, int h) return 0; } +static int myAbs(int n) +{ + return ( n > 0 ? n : -n ); +} + + +static int getRandomCourse(int x, int y) +{ + int ret; + + do{ + switch( random() % 3 ) + { + case 0 : + ret = y; + break; + case 1 : + ret = -y; + break; + case 2 : + ret = 0; + break; + } + }while( ret == x ); + + return ret; +} + +void boundBombBall(shot_t *shot) +{ + if( shot->gun != GUN_BOMBBALL ) + { + return; + } + + shot->px = getRandomCourse(shot->px, +10); + shot->py = getRandomCourse(shot->py, +10); + shot->isCanKillAuthor = 1; + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_shot_server(PROTO_SEND_ALL, NULL, shot); + } +} + void eventMoveListShot(list_t *listShot) { shot_t *thisShot; @@ -172,7 +252,23 @@ void eventMoveListShot(list_t *listShot) thisShot->x += thisShot->px; thisShot->y += thisShot->py; - +/* + if( thisShot->gun == GUN_BOMBBALL && ( + isConflictWithListWall(getCurrentArena()->listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) || + isConflictWithListPipe(getCurrentArena()->listPipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) ) + { + if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + boundBombBall(thisShot); + } + else + { + delListItem(listShot, i, destroyShot); + i--; + continue; + } + } +*/ if( thisShot->x+thisShot->w < 0 || thisShot->x > WINDOW_SIZE_X || thisShot->y+thisShot->h < 0 || thisShot->y > WINDOW_SIZE_Y ) { @@ -183,11 +279,6 @@ void eventMoveListShot(list_t *listShot) } } -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) ); @@ -292,7 +292,7 @@ int isConflictTuxWithListTux(tux_t *tux, list_t *listTux) getTuxProportion(thisTux, &thisTux_x, &thisTux_y, &thisTux_w, &thisTux_h); - if( conflictSpace(tux_x, tux_y, tux_w, tux_h, + if( thisTux->bonus != BONUS_GHOST && conflictSpace(tux_x, tux_y, tux_w, tux_h, thisTux_x, thisTux_y, thisTux_w, thisTux_h) ) { return 1; @@ -449,6 +449,24 @@ void tuxTeleport(tux_t *tux) } } +static void bombBallExplosion(shot_t *shot) +{ + item_t *item; + int x, y; + + x = ( shot->x + shot->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2; + y = ( shot->y + shot->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2; + + item = newItem(x, y, ITEM_BIG_EXPLOSION, shot->author); + addList(getCurrentArena()->listItem, item ); + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_delshot_server(PROTO_SEND_ALL, NULL, shot); + proto_send_additem_server(PROTO_SEND_ALL, NULL, item); + } +} + void eventConflictTuxWithShot(list_t *listTux, list_t *listShot) { shot_t *thisShot; @@ -481,6 +499,18 @@ void eventConflictTuxWithShot(list_t *listTux, list_t *listShot) continue; } + if( thisShot->gun == GUN_BOMBBALL ) + { + if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + bombBallExplosion(thisShot); + delListItem(listShot, i, destroyShot); + i--; + } + + continue; + } + if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { eventTuxIsDeadWIthShot(thisTux, thisShot); @@ -552,22 +582,22 @@ void moveTux(tux_t *tux, int n) return; } - if( n == TUX_LEFT && tux->x < 0 ) + if( n == TUX_LEFT && tux->x-TUX_STEP <= 0 ) { return; } - if( n == TUX_RIGHT && tux->x > WINDOW_SIZE_X ) + if( n == TUX_RIGHT && tux->x+TUX_STEP >= WINDOW_SIZE_X ) { return; } - if( n == TUX_UP && tux->y < 0 ) + if( n == TUX_UP && tux->y-TUX_STEP <= 0 ) { return; } - if( n == TUX_DOWN && tux->y > WINDOW_SIZE_Y ) + if( n == TUX_DOWN && tux->y+TUX_STEP >= WINDOW_SIZE_Y ) { return; } @@ -673,6 +703,7 @@ void shotTux(tux_t *tux) shotInGun(tux); tux->isCanShot = FALSE; + addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanShot, newInt(tux->id), TUX_TIME_CAN_SHOT ); @@ -713,9 +744,13 @@ static void pickUpGun(tux_t *tux) if( isTuxAnyGun(tux) == FALSE ) { tux->gun = GUN_SIMPLE; - tux->pickup_time++; + + if( tux->pickup_time < TUX_MAX_PICKUP ) + { + tux->pickup_time++; + } - if( tux->pickup_time == TUX_MAX_PICKUP ) + if( tux->pickup_time == TUX_MAX_PICKUP && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { #ifndef PUBLIC_SERVER char msg[STR_SIZE]; @@ -727,6 +762,11 @@ static void pickUpGun(tux_t *tux) tux->gun = GUN_SIMPLE; tux->shot[ tux->gun ] = GUN_MAX_SHOT; tux->pickup_time = 0; + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); + } } } } @@ -751,8 +791,13 @@ static void eventBonus(tux_t *tux) int x, y, w, h; getTuxProportion(tux, &x, &y, &w, &h); - if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) ) + tux->bonus = BONUS_NONE; + + if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) || + isConflictWithListPipe(getCurrentArena()->listPipe, x, y, w, h) || + isConflictTuxWithListTux(tux, getCurrentArena()->listTux) ) { + tux->bonus = BONUS_GHOST; return; } } @@ -5,6 +5,8 @@ #include "main.h" #include "wall.h" #include "shot.h" +#include "net_multiplayer.h" +#include "proto.h" #ifndef PUBLIC_SERVER #include "layer.h" @@ -116,6 +118,12 @@ void eventConflictShotWithWall(list_t *listWall, list_t *listShot) continue; } + if( thisShot->gun == GUN_BOMBBALL && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + boundBombBall(thisShot); + continue; + } + delListItem(listShot, i, destroyShot); i--; } |