diff options
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | deb_config.h | 2 | ||||
| -rw-r--r-- | include/item.h | 6 | ||||
| -rw-r--r-- | include/shot.h | 4 | ||||
| -rw-r--r-- | include/tux.h | 11 | ||||
| -rw-r--r-- | packaging/deb/control | 6 | ||||
| -rw-r--r-- | packaging/deb/r | 3 | ||||
| -rw-r--r-- | src/client.c | 17 | ||||
| -rw-r--r-- | src/gun.c | 4 | ||||
| -rwxr-xr-x | src/interface.c | 1 | ||||
| -rw-r--r-- | src/item.c | 54 | ||||
| -rw-r--r-- | src/logFile.c | 1 | ||||
| -rw-r--r-- | src/pipe.c | 9 | ||||
| -rw-r--r-- | src/proto.c | 36 | ||||
| -rw-r--r-- | src/publicServer.c | 2 | ||||
| -rw-r--r-- | src/screen.c | 5 | ||||
| -rw-r--r-- | src/screen_world.c | 5 | ||||
| -rw-r--r-- | src/server.c | 1 | ||||
| -rw-r--r-- | src/shot.c | 18 | ||||
| -rw-r--r-- | src/teleport.c | 9 | ||||
| -rw-r--r-- | src/tux.c | 28 | ||||
| -rw-r--r-- | src/wall.c | 8 |
22 files changed, 144 insertions, 88 deletions
@@ -6,7 +6,7 @@ #define DEBUG_CLIENT_RECV */ -#define TUXANCI_NG_VERSION "svn49" +#define TUXANCI_NG_VERSION "svn50" #define DESTDIR "/usr/local/" #define SUPPORT_NET_SDL_UDP diff --git a/deb_config.h b/deb_config.h index 9b69b81..f8448fe 100644 --- a/deb_config.h +++ b/deb_config.h @@ -1,4 +1,4 @@ -#define TUXANCI_NG_VERSION "svn49" +#define TUXANCI_NG_VERSION "svn50" #define DESTDIR "/usr/" #define SUPPORT_NET_SDL_UDP diff --git a/include/item.h b/include/item.h index ad390a1..3413452 100644 --- a/include/item.h +++ b/include/item.h @@ -30,7 +30,7 @@ typedef struct item_struct int count; my_time_t lastSync; - tux_t *author; + int author_id; #ifndef PUBLIC_SERVER SDL_Surface *img; //obrazok #endif @@ -60,9 +60,9 @@ typedef struct item_struct extern bool_t isItemInicialized(); extern void initItem(); -extern item_t* newItem(int x, int y, int type, tux_t *author); +extern item_t* newItem(int x, int y, int type, int author_id); extern item_t* getItemID(list_t *listItem, int id); -extern void addNewItem(list_t *listItem, tux_t *author); +extern void addNewItem(list_t *listItem, int author_id); #ifndef PUBLIC_SERVER extern void drawItem(item_t *p); extern void drawListItem(list_t *listItem); diff --git a/include/shot.h b/include/shot.h index 27f05a5..cc10c9a 100644 --- a/include/shot.h +++ b/include/shot.h @@ -26,7 +26,7 @@ typedef struct shot_struct int position; int gun; - tux_t *author; + int author_id; bool_t isCanKillAuthor; #ifndef PUBLIC_SERVER @@ -36,7 +36,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* newShot(int x,int y, int px, int py, int gun, int author_id); extern shot_t* getShotID(list_t *listShot, int id); #ifndef PUBLIC_SERVER extern void drawShot(shot_t *p); diff --git a/include/tux.h b/include/tux.h index fbe4ecc..05c0c8c 100644 --- a/include/tux.h +++ b/include/tux.h @@ -6,6 +6,8 @@ #include "main.h" #include "list.h" +#define ID_UNKNOWN -1 + #define TUX_STEP 6 #define TUX_LAYER 0 @@ -37,10 +39,11 @@ #define TUX_IMG_WIDTH 40 #define TUX_IMG_HEIGHT 54 -#define TUX_UP 8 -#define TUX_LEFT 4 -#define TUX_RIGHT 6 -#define TUX_DOWN 2 +#define TUX_UP 8 +#define TUX_LEFT 4 +#define TUX_RIGHT 6 +#define TUX_DOWN 2 +#define POSITION_UNKNOWN -1 #define TUX_SHOT 5 #define TUX_SWITCH_GUN 0 diff --git a/packaging/deb/control b/packaging/deb/control index 407074c..7d3dee8 100644 --- a/packaging/deb/control +++ b/packaging/deb/control @@ -1,12 +1,12 @@ Package: tuxanci-ng -Version: svn49 +Version: svn50 Section: Game Priority: optional Depends: libc6 (>= 2.2.4-4), libsdl1.2debian (>= 1.2), libsdl-image1.2 (>= 1.2), libsdl-mixer1.2 (>= 1.2), libsdl-net1.2 (>= 1.2), libsdl-ttf2.0-0 (>= 2.0) Architecture: i386 Installed-Size: 4630 Maintainer: Dušan Ďurech <dusan.d@centrum.sk> -Description: Game tuxanci next generation SVN revision 49 - Game tuxanci next generation SVN revision 49 +Description: Game tuxanci next generation SVN revision 50 + Game tuxanci next generation SVN revision 50 . http://www.tuxanci.org diff --git a/packaging/deb/r b/packaging/deb/r index 2e66562..a80efbc 100644 --- a/packaging/deb/r +++ b/packaging/deb/r @@ -1 +1,2 @@ -49
\ No newline at end of file +50 + diff --git a/src/client.c b/src/client.c index 9fc5e07..6953a7b 100644 --- a/src/client.c +++ b/src/client.c @@ -286,3 +286,20 @@ void quitSdlUdpClient() } #endif +/* +recv server msg->additem 5 7 303 421 1 0 0 +recv server msg->ping +recv server msg->shot 3 441 427 -5 0 4 0 0 0 +recv server msg->item -1 5 +recv server msg->delshot 3 +shot is not NULL +index is 0 + +recv server msg->additem 2 7 303 223 0 0 0 +recv server msg->additem 3 7 303 283 1 0 0 +recv server msg->additem 4 7 303 337 1 0 0 +recv server msg->ping +recv server msg->shot 5 144 227 5 0 6 0 1 0 +recv server msg->item -1 2 +recv server msg->delshot 5 +*/
\ No newline at end of file @@ -77,7 +77,7 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) break; } - shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux); + shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); addList( getCurrentArena()->listShot, shot ); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) @@ -261,7 +261,7 @@ static void putInGunMine(tux_t *tux) if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { - item = newItem(x, y, ITEM_MINE, tux); + item = newItem(x, y, ITEM_MINE, tux->id); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { diff --git a/src/interface.c b/src/interface.c index 1da3989..4fdf2ba 100755 --- a/src/interface.c +++ b/src/interface.c @@ -6,6 +6,7 @@ #include "screen.h" #include "myTimer.h" + //povrch okna static SDL_Surface *screen; static SDL_Surface *fake_screen; @@ -59,7 +59,7 @@ void initItem() isItemInit = TRUE; } -item_t* newItem(int x, int y, int type, tux_t *author) +item_t* newItem(int x, int y, int type, int author_id) { static unsigned int last_id = 0; item_t *new; @@ -77,7 +77,7 @@ item_t* newItem(int x, int y, int type, tux_t *author) #ifndef PUBLIC_SERVER new->img = g_item[type]; #endif - new->author = author; + new->author_id = author_id; new->lastSync = getMyTime(); switch( type ) @@ -148,7 +148,7 @@ item_t* getItemID(list_t *listItem, int id) return NULL; } -void addNewItem(list_t *listItem, tux_t *author) +void addNewItem(list_t *listItem, int author_id) { #ifndef PUBLIC_SERVER char msg[STR_SIZE]; @@ -206,7 +206,9 @@ void addNewItem(list_t *listItem, tux_t *author) (getNetTypeGame() == NET_GAME_TYPE_NONE && type == BONUS_HIDDEN) ); #endif - item = newItem(new_x, new_y, type, author); + type = GUN_MINE; + + item = newItem(new_x, new_y, type, author_id); addList(listItem, item); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) @@ -349,16 +351,35 @@ int isConflictWithListItem(list_t *listItem, int x, int y, int w, int h) void mineExplosion(list_t *listItem, item_t *item) { - int x, y; int index; index = searchListItem(listItem, item); assert( index != -1 ); +/* x = ( item->x + item->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2; y = ( item->y + item->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2; - addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, item->author) ); + addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, item->author_id) ); +*/ + + if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + int x, y; + item_t *item_explosion; + + x = ( item->x + item->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2; + y = ( item->y + item->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2; + + item_explosion = newItem(x, y, ITEM_BIG_EXPLOSION, item->author_id); + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_additem_server(PROTO_SEND_ALL, NULL, item_explosion); + } + + addList(listItem, item_explosion ); + } delListItem(listItem, index, destroyItem); } @@ -445,21 +466,20 @@ static void eventTuxIsDeadWithItem(tux_t *tux, item_t *item) return; } - if( item->author != NULL && item->author != tux ) + if( item->author_id != tux->id ) { -#ifndef PUBLIC_SERVER - char term_msg[STR_SIZE]; + tux_t *author; - sprintf(term_msg, "tux with id %d set score to %d\n", - item->author->id, item->author->score+1); - - appendTextInTerm(term_msg); -#endif - item->author->score++; + author = getTuxID(getCurrentArena()->listTux, item->author_id); - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + if( author != NULL ) { - proto_send_score_server(PROTO_SEND_ALL, NULL, item->author); + author->score++; + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_score_server(PROTO_SEND_ALL, NULL, author); + } } } diff --git a/src/logFile.c b/src/logFile.c index 7ff58c7..12a4df8 100644 --- a/src/logFile.c +++ b/src/logFile.c @@ -4,7 +4,6 @@ #include <string.h> #include <sys/stat.h> #include <assert.h> -#include "main.h" typedef struct logFile_struct { @@ -171,8 +171,13 @@ void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot) if( ( thisPipe = isConflictWithListPipe(listPipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL ) { - if( thisShot->author->bonus == BONUS_GHOST && - thisShot->author->bonus_time > 0 ) + tux_t *author; + + author = getTuxID(getCurrentArena()->listTux, thisShot->author_id); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) { continue; } diff --git a/src/proto.c b/src/proto.c index 6cb042e..db45109 100644 --- a/src/proto.c +++ b/src/proto.c @@ -307,6 +307,11 @@ void proto_recv_newtux_client(char *msg) assert( msg != NULL ); + if( getCurrentArena() == NULL ) + { + return; + } + sscanf(msg, "%s %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d", cmd, &id, &x, &y, &status, &position, &frame, &score, name, &myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6, &gun7, &time1, &time2); @@ -463,17 +468,11 @@ void proto_recv_deltux_client(char *msg) void proto_send_additem_server(int type, client_t *client, item_t *p) { char msg[STR_PROTO_SIZE]; - int id = -1; assert( p != NULL ); - if( p->author != NULL ) - { - id = p->author->id; - } - sprintf(msg, "additem %d %d %d %d %d %d %d\n", - p->id, p->type, p->x, p->y, p->count, p->frame, id); + p->id, p->type, p->x, p->y, p->count, p->frame, p->author_id); proto_send(type, client, msg); } @@ -482,13 +481,17 @@ void proto_send_additem_server(int type, client_t *client, item_t *p) void proto_recv_additem_client(char *msg) { - char term_msg[STR_SIZE]; char cmd[STR_PROTO_SIZE]; int id, type, x, y, count, frame, author_id; item_t *item; assert( msg != NULL ); + if( getCurrentArena() == NULL ) + { + return; + } + sscanf(msg, "%s %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id); if( ( item = getItemID(getCurrentArena()->listItem, id) ) != NULL ) @@ -497,7 +500,7 @@ void proto_recv_additem_client(char *msg) return; } - item = newItem(x, y, type, getTuxID(getCurrentArena()->listTux, author_id)); + item = newItem(x, y, type, author_id); /* if( isConflictWithListItem(getCurrentArena()->listItem, item->x, item->y, item->w, item->h) ) { @@ -511,10 +514,6 @@ void proto_recv_additem_client(char *msg) item->lastSync = getMyTime(); addList(getCurrentArena()->listItem, item); - - sprintf(term_msg, "in arena is new item\n"); - appendTextInTerm(term_msg); - } #endif @@ -577,17 +576,11 @@ void proto_recv_item_client(char *msg) void proto_send_shot_server(int type, client_t *client, shot_t *p) { char msg[STR_PROTO_SIZE]; - int id = -1; assert( p != NULL ); - if( p->author != NULL ) - { - id = p->author->id; - } - 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); + p->id, p->x, p->y, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor); proto_send(type, client, msg); } @@ -611,8 +604,9 @@ void proto_recv_shot_client(char *msg) return; } */ - shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, author_id)); + shot = newShot(x, y, px, py, gun, author_id); + shot->id = shot_id; shot->isCanKillAuthor = isCanKillAuthor; shot->position = position; diff --git a/src/publicServer.c b/src/publicServer.c index c539b3b..4b7774b 100644 --- a/src/publicServer.c +++ b/src/publicServer.c @@ -47,7 +47,7 @@ int initPublicServer() arena = getArena(arenaId); setCurrentArena(arena); - addNewItem(arena->listItem, NULL); + addNewItem(arena->listItem, ID_UNKNOWN); isSignalEnd = FALSE; if( initNetMuliplayer(NET_GAME_TYPE_SERVER, diff --git a/src/screen.c b/src/screen.c index 7d47645..dba91bc 100644 --- a/src/screen.c +++ b/src/screen.c @@ -109,11 +109,8 @@ char* getScreen() void drawScreen() { - static SDL_Surface *p_screen = NULL; - - if( p_screen == NULL ) p_screen = getSDL_Screen(); - assert( currentScreen != NULL ); + currentScreen->fce_draw(); interfaceRefresh(); diff --git a/src/screen_world.c b/src/screen_world.c index 589161e..bd68596 100644 --- a/src/screen_world.c +++ b/src/screen_world.c @@ -69,6 +69,7 @@ void setWorldArena(int id) void setMaxCountRound(int n) { + printf("max_count = %d\n", n); max_count = n; } @@ -135,7 +136,7 @@ void prepareArena() { case NET_GAME_TYPE_NONE : setWorldArena( getChoiceArenaId() ); - addNewItem(arena->listItem, NULL); + addNewItem(arena->listItem, ID_UNKNOWN); getSettingCountRound(&max_count); tux = newTux(); @@ -151,7 +152,7 @@ void prepareArena() case NET_GAME_TYPE_SERVER : setWorldArena( getChoiceArenaId() ); - addNewItem(arena->listItem, NULL); + addNewItem(arena->listItem, ID_UNKNOWN); getSettingCountRound(&max_count); tux = newTux(); diff --git a/src/server.c b/src/server.c index 26867a8..9086a73 100644 --- a/src/server.c +++ b/src/server.c @@ -82,6 +82,7 @@ static void delZombieCLient(void *p_nothink) delListItem(listClient, i, destroyClient); } } + } static void eventPeriodicSyncClient(void *p_nothink) @@ -55,13 +55,12 @@ void initShot() isShotInit = TRUE; } -shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) +shot_t* newShot(int x,int y, int px, int py, int gun, int author_id) { shot_t *new; + tux_t *author; static int last_id = 0; - assert( author != NULL ); - new = malloc( sizeof(shot_t) ); memset(new, 0, sizeof(shot_t) ); @@ -71,8 +70,17 @@ shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) new->px = px; new->py = py; new->gun = gun; - new->author = author; - new->position = author->position; + new->author_id = author_id; + + new->position = POSITION_UNKNOWN; + + author = getTuxID(getCurrentArena()->listTux, author_id); + + if( author != NULL ) + { + new->position = author->position; + } + new->isCanKillAuthor = FALSE; switch( gun ) diff --git a/src/teleport.c b/src/teleport.c index 6348c57..e402fcc 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -153,8 +153,13 @@ void eventConflictShotWithTeleport(list_t *listTeleport, list_t *listShot) if( ( thisTeleport = isConflictWithListTeleport(listTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL ) { - if( thisShot->author->bonus == BONUS_GHOST && - thisShot->author->bonus_time > 0 ) + tux_t *author; + + author = getTuxID(getCurrentArena()->listTux, thisShot->author_id); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) { continue; } @@ -322,7 +322,7 @@ static void timer_spawnTux(void *p) setTuxProportion(tux, x, y); tux->gun = GUN_SIMPLE; - addNewItem(arena->listItem, NULL); + addNewItem(arena->listItem, ID_UNKNOWN); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { @@ -402,22 +402,22 @@ void eventTuxIsDead(tux_t *tux) static void eventTuxIsDeadWIthShot(tux_t *tux, shot_t *shot) { - if( shot->author != NULL && shot->author != tux ) + if( shot->author_id != tux->id ) { -#ifndef PUBLIC_SERVER - char term_msg[STR_SIZE]; + tux_t *author; - sprintf(term_msg, "tux with id %d set score to %d\n", - shot->author->id, shot->author->score+1); + author = getTuxID(getCurrentArena()->listTux, shot->author_id); - appendTextInTerm(term_msg); -#endif - shot->author->score++; - - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + if( author != NULL ) { - proto_send_score_server(PROTO_SEND_ALL, NULL, shot->author); + author->score++; + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_score_server(PROTO_SEND_ALL, NULL, author); + } } + } countRoundInc(); @@ -457,7 +457,7 @@ static void bombBallExplosion(shot_t *shot) 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); + item = newItem(x, y, ITEM_BIG_EXPLOSION, shot->author_id ); addList(getCurrentArena()->listItem, item ); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) @@ -487,7 +487,7 @@ void eventConflictTuxWithShot(list_t *listTux, list_t *listShot) { if( thisTux->status == TUX_STATUS_ALIVE ) { - if( thisShot->author == thisTux && + if( thisShot->author_id == thisTux->id && thisShot->isCanKillAuthor == FALSE ) { continue; @@ -100,6 +100,7 @@ int isConflictWithListWall(list_t *listWall, int x, int y, int w, int h) void eventConflictShotWithWall(list_t *listWall, list_t *listShot) { shot_t *thisShot; + tux_t *author; int i; assert( listWall != NULL ); @@ -112,8 +113,11 @@ void eventConflictShotWithWall(list_t *listWall, list_t *listShot) if( isConflictWithListWall(listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) { - if( thisShot->author->bonus == BONUS_GHOST && - thisShot->author->bonus_time > 0 ) + author = getTuxID( getCurrentArena()->listShot, thisShot->author_id ); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) { continue; } |