diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-05-28 19:25:15 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-05-28 19:25:15 +0000 |
| commit | e5120505b21ff38dc25efcad129a440bbfa9996d (patch) | |
| tree | 583e0683fb1f71f65bb81b0fcdf2e71587e1fe46 | |
| parent | c94fd664bba352732bf0e5c9a77e709b49f1aa4f (diff) | |
- zrychlenie hry, bez toho aby sa menila rychlost hlavneho casovaca
- oprava chyby v ID managery
- ID manager spravuje ID-y pre vsetky objekty
git-svn-id: http://opensvn.csie.org/tuxanci_ng@55 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
| -rw-r--r-- | README.sk | 8 | ||||
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | include/gun.h | 2 | ||||
| -rw-r--r-- | include/idManager.h | 12 | ||||
| -rw-r--r-- | include/item.h | 2 | ||||
| -rw-r--r-- | include/modules.h | 1 | ||||
| -rw-r--r-- | include/shot.h | 1 | ||||
| -rw-r--r-- | include/tux.h | 2 | ||||
| -rwxr-xr-x | modules/modPipe.c | 5 | ||||
| -rwxr-xr-x | modules/modTeleport.c | 8 | ||||
| -rw-r--r-- | src/arena.c | 6 | ||||
| -rw-r--r-- | src/gun.c | 33 | ||||
| -rw-r--r-- | src/idManager.c | 81 | ||||
| -rwxr-xr-x | src/interface.c | 4 | ||||
| -rw-r--r-- | src/item.c | 10 | ||||
| -rwxr-xr-x | src/modules.c | 3 | ||||
| -rw-r--r-- | src/proto.c | 3 | ||||
| -rw-r--r-- | src/publicServer.c | 2 | ||||
| -rw-r--r-- | src/screen_world.c | 4 | ||||
| -rw-r--r-- | src/shot.c | 34 | ||||
| -rw-r--r-- | src/tux.c | 11 |
21 files changed, 132 insertions, 102 deletions
@@ -13,9 +13,9 @@ Pri kompilacii, hry ako grafickeho klienta sa potrebuju kniznice : (g)libc, SDL, SDL_Image, SDL_Mixer, SDL_ttf, SDL_Net - v ratatne hlavickovych suborov a konfiguracnych striptov ( sdl-config ) + v ratane hlavickovych suborov a konfiguracnych striptov ( sdl-config ) - ldd -u `which tuxanci` + ldd -u `which tuxanci-ng` Unused direct dependencies: /usr/lib/libSDL_image-1.2.so.0 /usr/lib/libSDL_mixer-1.2.so.0 @@ -26,13 +26,13 @@ make clean ---------- - pre istotu vymazame subory z predchadzajucej kompilacie + pre istotu vymazeme subory z predchadzajucej kompilacie v subore config.h do makra DESTDIR ulozime nas prefix-path, ktory sa natvrdo skompiluje do programu #define DESTDIR "/usr/local/" - Ak toto maro nebude existovat, program bude pouzivat svoje podaresare :) + Ak toto makro nebude existovat, program bude pouzivat svoje podaresare :) ( vhodne pri vyvoji, ked sa casto menia subory ) make mod @@ -6,7 +6,7 @@ #define DEBUG_CLIENT_RECV */ -#define TUXANCI_NG_VERSION "svn54" +#define TUXANCI_NG_VERSION "svn55" #define DESTDIR "/usr/local/" #define SUPPORT_NET_SDL_UDP diff --git a/include/gun.h b/include/gun.h index 7389757..4986660 100644 --- a/include/gun.h +++ b/include/gun.h @@ -8,7 +8,7 @@ #define GUN_SHOT_WIDTH 5 #define GUN_SHOT_HEIGHT 5 -#define GUN_LASSER_HORIZONTAL 20 +#define GUN_LASSER_HORIZONTAL 50 #define GUN_SHOT_VERTICAL 5 #define GUN_BOMBBALL_WIDTH 20 diff --git a/include/idManager.h b/include/idManager.h index 1684186..62e2651 100644 --- a/include/idManager.h +++ b/include/idManager.h @@ -9,11 +9,11 @@ #include "list.h" -extern list_t * newListID(); -extern int getNewID(list_t *p); -extern int isRegisterID(list_t *p, int id); -extern void delID(list_t *p, int id); -extern void replaceID(list_t *p, int old_id, int new_id); -extern void destroyListID(list_t *p); +extern void initListID(); +extern int getNewID(); +extern int isRegisterID(int id); +extern void delID(int id); +extern void replaceID(int old_id, int new_id); +extern void quitListID(); #endif diff --git a/include/item.h b/include/item.h index 7c1043a..423b813 100644 --- a/include/item.h +++ b/include/item.h @@ -36,7 +36,7 @@ typedef struct item_struct #endif } item_t; -#define ITEM_MAX_COUNT 2 +#define ITEM_MAX_COUNT 1 #define ITEM_GUN_MAX_FRAME 8 #define ITEM_MINE_MAX_FRAME 1 diff --git a/include/modules.h b/include/modules.h index 872cab7..f05234f 100644 --- a/include/modules.h +++ b/include/modules.h @@ -39,6 +39,7 @@ typedef struct export_fce_s void (*fce_destroyShot)(shot_t *p); void (*fce_boundBombBall)(shot_t *shot); + void (*fce_transformOnlyLasser)(shot_t *shot); int (*fce_pokus)(char *s); diff --git a/include/shot.h b/include/shot.h index 526727b..4ec8acf 100644 --- a/include/shot.h +++ b/include/shot.h @@ -47,6 +47,7 @@ extern int isConflictWithListShot(list_t *listShot, int x, int y, int w, int h); extern void eventMoveListShot(list_t *listShot); extern void boundBombBall(shot_t *shot); +extern void transformOnlyLasser(shot_t *shot); extern void destroyShot(shot_t *p); extern void quitShot(); diff --git a/include/tux.h b/include/tux.h index 1343274..4b655ff 100644 --- a/include/tux.h +++ b/include/tux.h @@ -6,7 +6,7 @@ #include "main.h" #include "list.h" -#define TUX_STEP 6 +#define TUX_STEP 7 #define TUX_LAYER 0 #define TUX_MAX_ANIMATION_FRAME 10 diff --git a/modules/modPipe.c b/modules/modPipe.c index 6f000d8..476d8ec 100755 --- a/modules/modPipe.c +++ b/modules/modPipe.c @@ -193,6 +193,11 @@ static void transformShot(shot_t *shot, int position) 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, diff --git a/modules/modTeleport.c b/modules/modTeleport.c index 0f0d41b..502b3ef 100755 --- a/modules/modTeleport.c +++ b/modules/modTeleport.c @@ -291,12 +291,10 @@ static void transformShot(shot_t *shot, int position) shot->position = position; shot->isCanKillAuthor = TRUE; -/* if( shot->gun == GUN_LASSER ) { - transformOnlyLasser(shot); + export_fce->fce_transformOnlyLasser(shot); } -*/ } static void moveShot(shot_t *shot, int position, int src_x, int src_y, @@ -423,12 +421,12 @@ int event() thisShot = (shot_t *)arena->listShot->list[i]; assert( thisShot != NULL ); - +/* if( thisShot->gun == GUN_LASSER ) { continue; } - +*/ if( ( thisTeleport = isConflictWithListTeleport(listTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL ) { diff --git a/src/arena.c b/src/arena.c index 1980a95..38e5319 100644 --- a/src/arena.c +++ b/src/arena.c @@ -74,7 +74,7 @@ void findFreeSpace(arena_t *arena, int *x, int *y, int w, int h) do{ z_x = random() % WINDOW_SIZE_X; - z_y = random() % (WINDOW_SIZE_Y-200); + z_y = random() % (WINDOW_SIZE_Y); }while( isFreeSpace(arena, z_x, z_y ,w ,h) == 0 ); *x = z_x; @@ -119,13 +119,15 @@ void eventArena(arena_t *arena) //eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport); eventConflictTuxWithShot(arena->listTux, arena->listShot); - for( i = 0 ; i < 4 ; i++) + for( i = 0 ; i < 8 ; i++) { eventMoveListShot(arena->listShot); //eventConflictShotWithWall(arena->listWall, arena->listShot); //eventConflictShotWithTeleport(arena->listTeleport, arena->listShot); //eventConflictShotWithPipe(arena->listPipe, arena->listShot); eventConflictShotWithItem(arena->listItem, arena->listShot); + eventConflictTuxWithShot(arena->listTux, arena->listShot); + eventModule(); } eventListItem(arena->listItem); @@ -63,21 +63,32 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) modificiationCopuse(tux->position, px, py, &dest_px, &dest_py); modificiationCopuse(tux->position, x, y, &dest_x, &dest_y); - switch( tux->position ) + if( gun == GUN_LASSER ) { - case TUX_UP : - dest_y -= TUX_WIDTH; - break; - case TUX_RIGHT : + switch( tux->position ) + { + case TUX_UP : + dest_y -= GUN_LASSER_HORIZONTAL; break; - case TUX_LEFT : - dest_x -= TUX_WIDTH; - break; - case TUX_DOWN : - break; + case TUX_RIGHT : + break; + case TUX_LEFT : + dest_x -= GUN_LASSER_HORIZONTAL; + break; + case TUX_DOWN : + break; + } } shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); + +/* + if( isFreeSpace( getCurrentArena(), shot->x, shot->y, shot->w, shot->h ) == 0 ) + { + destroyShot(shot); + return; + } +*/ addList( getCurrentArena()->listShot, shot ); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) @@ -206,7 +217,9 @@ static void timer_addLaserTimer(void *p) gun = tux->gun; tux->gun = GUN_LASSER; + addShot(tux, 0, 0, +10, 0); + tux->gun = gun; } diff --git a/src/idManager.c b/src/idManager.c index 1da30bc..ef46433 100644 --- a/src/idManager.c +++ b/src/idManager.c @@ -7,49 +7,25 @@ #include "list.h" #include "idManager.h" -list_t * newListID() -{ - return newList(); -} +static list_t *listID; -int getNewID(list_t *p) +void initListID() { - int ret; - int i; - - assert( p != NULL ); - - do{ - ret = random() % MAX_ID + 1; - - for( i = 0 ; i < p->count ; i++ ) - { - int *z; - - z = (int *) p->list[i]; - - if( *z == ret )continue; - } - - }while(0); - - addList(p, newInt(ret) ); - - //printf("new ID -> %d\n", ret); - return ret; + listID = newList(); + printf("init ID manger..\n"); } -int isRegisterID(list_t *p, int id) +int isRegisterID(int id) { int i; - assert( p != NULL ); + assert( listID != NULL ); - for( i = 0 ; i < p->count ; i++ ) + for( i = 0 ; i < listID->count ; i++ ) { int *z; - z = (int *) p->list[i]; + z = (int *) listID->list[i]; if( *z == id ) { @@ -60,13 +36,29 @@ int isRegisterID(list_t *p, int id) return -1; } -void delID(list_t *p, int id) +int getNewID() +{ + int ret; + + assert( listID != NULL ); + + do{ + ret = random() % MAX_ID + 1; + }while( isRegisterID(ret) != -1 ); + + addList(listID, newInt(ret) ); + + //printf("new ID -> %d\n", ret); + return ret; +} + +void delID(int id) { int index; - assert( p != NULL ); + assert( listID != NULL ); - index = isRegisterID(p, id); + index = isRegisterID(id); if( index == -1 ) { @@ -74,24 +66,27 @@ void delID(list_t *p, int id) return; // ha ha ha } - delListItem(p, index, free); + delListItem(listID, index, free); return; } -void replaceID(list_t *p, int old_id, int new_id) +void replaceID(int old_id, int new_id) { - delID(p, old_id); + delID(old_id); if( new_id != -1 ) { - assert( isRegisterID(p, new_id) == -1 ); - addList(p, newInt(new_id) ); + assert( isRegisterID(new_id) == -1 ); + addList(listID, newInt(new_id) ); } } -void destroyListID(list_t *p) +void quitListID() { - assert( p != NULL ); - destroyListItem(p, free); + printf("quit ID manger..\n"); + + assert( listID != NULL ); + destroyListItem(listID, free); } + diff --git a/src/interface.c b/src/interface.c index 675c4d2..0b3772e 100755 --- a/src/interface.c +++ b/src/interface.c @@ -81,13 +81,13 @@ int initSDL() SDL_Surface* getSDL_Screen() { - //return fake_screen; + //return my_surface; return screen; } void interfaceRefresh() { - //SDL_BlitSurface(fake_screen, NULL, screen, NULL); + //SDL_BlitSurface(my_surface, NULL, screen, NULL); //SDL_UpdateRect(screen, 0, 0, screen->w, screen->h); //drawImage(my_surface, 200, 100, 0, 0, 200, 200); @@ -31,7 +31,6 @@ static SDL_Surface *g_item[ITEM_COUNT]; #endif static bool_t isItemInit = FALSE; -static list_t *listID; bool_t isItemInicialized() { @@ -59,7 +58,7 @@ void initItem() g_item[BONUS_4X] = addImageData("item.bonus.4x.png", IMAGE_ALPHA, "item_4x_speed", IMAGE_GROUP_BASE); g_item[BONUS_HIDDEN] = addImageData("item.bonus.hidden.png", IMAGE_ALPHA, "item_hidden_speed", IMAGE_GROUP_BASE); #endif - listID = newListID(); + isItemInit = TRUE; } @@ -72,7 +71,7 @@ item_t* newItem(int x, int y, int type, int author_id) new->type = type; - new->id = getNewID(listID); + new->id = getNewID(); new->x = x; new->y = y; new->frame = 0; @@ -153,7 +152,7 @@ item_t* getItemID(list_t *listItem, int id) void replaceItemID(item_t *item, int id) { - replaceID(listID, item->id, id); + replaceID(item->id, id); item->id = id; } @@ -620,12 +619,11 @@ void eventGiveTuxListItem(tux_t *tux, list_t *listItem) void destroyItem(item_t *p) { assert( p != NULL ); - delID(listID, p->id); + delID(p->id); free(p); } void quitItem() { - destroyListID(listID); isItemInit = FALSE; } diff --git a/src/modules.c b/src/modules.c index 7a8f3cd..b5c87f0 100755 --- a/src/modules.c +++ b/src/modules.c @@ -47,7 +47,8 @@ static export_fce_t export_fce = .fce_proto_send_newtux_server = proto_send_newtux_server, .fce_proto_send_shot_server = proto_send_shot_server, .fce_destroyShot = destroyShot, - .fce_boundBombBall = boundBombBall + .fce_boundBombBall = boundBombBall, + .fce_transformOnlyLasser = transformOnlyLasser }; static list_t *listModule; diff --git a/src/proto.c b/src/proto.c index 4174f09..508a56c 100644 --- a/src/proto.c +++ b/src/proto.c @@ -612,12 +612,11 @@ void proto_recv_shot_client(char *msg) shot->isCanKillAuthor = isCanKillAuthor; shot->position = position; -/* if( shot->gun == GUN_LASSER ) { transformOnlyLasser(shot); } -*/ + addList(getCurrentArena()->listShot, shot); } diff --git a/src/publicServer.c b/src/publicServer.c index 6ac64c9..2b7d2cc 100644 --- a/src/publicServer.c +++ b/src/publicServer.c @@ -36,6 +36,7 @@ static char *getSetting(char *env, char *param, char *default_val) int initPublicServer() { + initListID(); initModule(); initArenaFile(); initTux(); @@ -120,6 +121,7 @@ void quitPublicServer() quitArenaFile(); quitServerConfigFile(); quitModule(); + quitListID(); exit(0); } diff --git a/src/screen_world.c b/src/screen_world.c index c90b419..c1211f3 100644 --- a/src/screen_world.c +++ b/src/screen_world.c @@ -341,7 +341,7 @@ void eventWorld() eventNetMultiplayer(); eventArena(arena); - eventModule(); + //eventModule(); eventTerm(); eventEnd(); @@ -356,6 +356,7 @@ void startWorld() count = 0; lastServerLag = LAG_SERVER_UNKNOWN; + initListID(); initModule(); setGameType(); initTerm(); @@ -421,6 +422,7 @@ void stoptWorld() delAllImageInGroup(IMAGE_GROUP_USER); delAllMusicInGroup(MUSIC_GROUP_USER); quitModule(); + quitListID(); } void initWorld() @@ -30,7 +30,6 @@ static SDL_Surface *g_shot_bombball; #endif static bool_t isShotInit = FALSE; -static list_t *listID; bool_t isShotInicialized() { @@ -52,8 +51,6 @@ void initShot() #endif - listID = newListID(); - isShotInit = TRUE; } @@ -65,7 +62,7 @@ shot_t* newShot(int x,int y, int px, int py, int gun, int author_id) new = malloc( sizeof(shot_t) ); memset(new, 0, sizeof(shot_t) ); - new->id = getNewID(listID); + new->id = getNewID(); new->x = x; new->y = y; new->px = px; @@ -156,7 +153,7 @@ shot_t* getShotID(list_t *listShot, int id) void replaceShotID(shot_t *shot, int id) { - replaceID(listID, shot->id, id); + replaceID(shot->id, id); shot->id = id; } @@ -247,6 +244,29 @@ void boundBombBall(shot_t *shot) } } +void transformOnlyLasser(shot_t *shot) +{ + switch( shot->position ) + { + case TUX_RIGHT : + case TUX_LEFT : + shot->w = GUN_LASSER_HORIZONTAL; + shot->h = GUN_SHOT_VERTICAL; +#ifndef PUBLIC_SERVER + shot->img = g_shot_lasserX; +#endif + break; + case TUX_UP : + case TUX_DOWN : + shot->w = GUN_SHOT_VERTICAL; + shot->h = GUN_LASSER_HORIZONTAL; +#ifndef PUBLIC_SERVER + shot->img = g_shot_lasserY; +#endif + break; + } +} + void eventMoveListShot(list_t *listShot) { shot_t *thisShot; @@ -411,13 +431,11 @@ void moveShot(shot_t *shot, int position, int src_x, int src_y, void destroyShot(shot_t *p) { assert( p != NULL ); - delID(listID, p->id); + delID(p->id); free(p); } void quitShot() { - destroyListID(listID); isShotInit = FALSE; } - @@ -40,8 +40,6 @@ static SDL_Surface *g_cross; #endif -static list_t *listID; - static bool_t isTuxInit = FALSE; bool_t isTuxInicialized() @@ -63,8 +61,6 @@ void initTux() g_cross = addImageData("cross.png", IMAGE_ALPHA, "cross", IMAGE_GROUP_BASE); #endif - listID = newListID(); - isTuxInit = TRUE; } @@ -78,7 +74,7 @@ tux_t* newTux() memset(new, 0, sizeof(tux_t) ); - new->id = getNewID(listID); + new->id = getNewID(); new->status = TUX_STATUS_ALIVE; new->control = TUX_CONTROL_NONE; @@ -248,7 +244,7 @@ tux_t* getTuxID(list_t *listTux, int id) void replaceTuxID(tux_t *tux, int id) { - replaceID(listID, tux->id, id); + replaceID(tux->id, id); tux->id = id; } @@ -869,12 +865,11 @@ void setTuxProportion(tux_t *tux, int x, int y) void destroyTux(tux_t *tux) { assert( tux != NULL ); - delID(listID, tux->id); + delID(tux->id); free(tux); } void quitTux() { - destroyListID(listID); isTuxInit = FALSE; } |