diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-18 19:19:10 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-18 19:19:10 +0000 |
| commit | 8b93dd8dac51e28bb25ad341f594d21a955c3adb (patch) | |
| tree | e04e9ea1d2d9b57c77617614283fc8756c96d53c /src | |
| parent | a5a03e684b5ed3e8781ce30e5ffd4f73b59c3e97 (diff) | |
- bezpecnejsie prepiannie screenov ( uz sa to nedeje v event() daneho screenu aj ked to on vyvolal )
- do laveho horneho rohu s nevypisuju blbiny
- moduly pouzivaju funkcie actionSpace a actionSpaceFromLocation
- dane funkcie sa pouzivaju aj pri vykreslovani objektov
- btw. je jedno kolko zeru tuxanci top, na kerneli-2.6.25.* to zralo X a na kerneli 2.6.26 to zere 2*X
git-svn-id: http://opensvn.csie.org/tuxanci_ng@159 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
| -rw-r--r-- | src/base/arena.c | 30 | ||||
| -rw-r--r-- | src/base/gun.c | 16 | ||||
| -rw-r--r-- | src/base/item.c | 27 | ||||
| -rw-r--r-- | src/base/item.h | 3 | ||||
| -rw-r--r-- | src/base/main.c | 6 | ||||
| -rw-r--r-- | src/base/main.h | 4 | ||||
| -rw-r--r-- | src/base/proto.c | 17 | ||||
| -rw-r--r-- | src/base/server.c | 7 | ||||
| -rw-r--r-- | src/base/tux.c | 41 | ||||
| -rw-r--r-- | src/client/game.c | 4 | ||||
| -rwxr-xr-x | src/client/interface.c | 1 | ||||
| -rw-r--r-- | src/client/screen.c | 67 | ||||
| -rw-r--r-- | src/client/screen.h | 2 | ||||
| -rwxr-xr-x | src/modules/modPipe.c | 104 | ||||
| -rwxr-xr-x | src/modules/modTeleport.c | 106 | ||||
| -rwxr-xr-x | src/modules/modWall.c | 99 | ||||
| -rw-r--r-- | src/screen/screen_world.c | 9 | ||||
| -rw-r--r-- | src/server/publicServer.c | 1 |
18 files changed, 208 insertions, 336 deletions
diff --git a/src/base/arena.c b/src/base/arena.c index 5b069f1..4abf1f7 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -135,6 +135,21 @@ void getCenterScreen(int *screen_x, int *screen_y, int x, int y) #ifndef PUBLIC_SERVER +static void action_drawTux(space_t *space, tux_t *tux, void *p) +{ + drawTux(tux); +} + +static void action_drawItem(space_t *space, item_t *item, void *p) +{ + drawItem(item); +} + +static void action_drawShot(space_t *space, shot_t *shot, void *p) +{ + drawShot(shot); +} + void drawArena(arena_t *arena) { int screen_x, screen_y; @@ -168,17 +183,14 @@ void drawArena(arena_t *arena) } - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceTux, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp); - drawListTux(listHelp); + actionSpaceFromLocation(arena->spaceTux, action_drawTux, NULL, + screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceItem, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp); - drawListItem(listHelp); + actionSpaceFromLocation(arena->spaceItem, action_drawItem, NULL, + screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceShot, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp); - drawListShot(listHelp); + actionSpaceFromLocation(arena->spaceShot, action_drawShot, NULL, + screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); //printSpace(arena->spaceShot); diff --git a/src/base/gun.c b/src/base/gun.c index aeb2478..45234af 100644 --- a/src/base/gun.c +++ b/src/base/gun.c @@ -19,8 +19,6 @@ #ifndef PUBLIC_SERVER #include "interface.h" -#include "term.h" - #include "screen_world.h" #endif @@ -85,13 +83,7 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); - if(1)// isFreeSpace(getCurrentArena(), shot->x, shot->y, shot->w, shot->h) ) - { - addObjectToSpace(getCurrentArena()->spaceShot, shot); - return; - } - - destroyShot(shot); + addObjectToSpace(getCurrentArena()->spaceShot, shot); } static void addShot(tux_t *tux,int x, int y, int px, int py) @@ -261,15 +253,9 @@ static void putInGunMine(tux_t *tux) if( isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) ) { item_t *item; - -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; #ifndef NO_SOUND playSound("put_mine", SOUND_GROUP_BASE); #endif - sprintf(msg, "tux with id %d pu mine\n", tux->id); - appendTextInTerm(msg); -#endif tux->shot[tux->gun]--; diff --git a/src/base/item.c b/src/base/item.c index c341754..2cbae3f 100644 --- a/src/base/item.c +++ b/src/base/item.c @@ -16,7 +16,6 @@ #include "interface.h" #include "image.h" #include "layer.h" -#include "term.h" #include "screen_world.h" #include "screen_setting.h" @@ -29,7 +28,6 @@ #ifdef PUBLIC_SERVER #include "publicServer.h" -#include "publicServer.h" #endif #ifndef PUBLIC_SERVER @@ -166,9 +164,6 @@ void replaceItemID(item_t *item, int id) void addNewItem(space_t *spaceItem, int author_id) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; -#endif arena_t *arena; item_t *item; int new_x, new_y; @@ -237,12 +232,6 @@ void addNewItem(space_t *spaceItem, int author_id) { proto_send_additem_server(PROTO_SEND_ALL, NULL, item); } - -#ifndef PUBLIC_SERVER - sprintf(msg, "in arena is new item\n"); - appendTextInTerm(msg); -#endif - } #ifndef PUBLIC_SERVER @@ -449,21 +438,13 @@ static void eventTuxIsDeadWithItem(tux_t *tux, item_t *item) static void tuxGiveBonus(tux_t *tux, item_t *item) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; #ifndef NO_SOUND playSound("item_bonus", SOUND_GROUP_BASE); #endif -#endif tux->bonus = item->type; tux->bonus_time = TUX_MAX_BONUS; -#ifndef PUBLIC_SERVER - sprintf(msg, "tux with id %d bonus enabled\n", tux->id); - appendTextInTerm(msg); -#endif - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); @@ -472,22 +453,14 @@ static void tuxGiveBonus(tux_t *tux, item_t *item) static void tuxGiveGun(tux_t *tux, item_t *item) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; #ifndef NO_SOUND playSound("item_gun", SOUND_GROUP_BASE); #endif -#endif tux->pickup_time = 0; tux->shot[ item->type ] += GUN_MAX_SHOT; tux->gun = item->type; -#ifndef PUBLIC_SERVER - sprintf(msg, "tux with id %d has new gun\n", tux->id); - appendTextInTerm(msg); -#endif - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); diff --git a/src/base/item.h b/src/base/item.h index 9dcb678..822283e 100644 --- a/src/base/item.h +++ b/src/base/item.h @@ -68,7 +68,8 @@ extern void getStatusItem(void *p, int *id, int *x, int *y ,int *w, int *h); extern void setStatusItem(void *p, int x, int y, int w, int h); extern void replaceItemID(item_t *item, int id); extern void addNewItem(space_t *spaceItem, int author_id); -#ifndef PUBLIC_SERVER +#ifndef PUBLIC_SERVER +extern void drawItem(item_t *p); extern void drawListItem(list_t *listItem); #endif extern void eventListItem(space_t *listSpace); diff --git a/src/base/main.c b/src/base/main.c index cc9330f..93a65b4 100644 --- a/src/base/main.c +++ b/src/base/main.c @@ -27,8 +27,6 @@ static int my_argc; static char **my_argv; -list_t *listHelp; - char* getParam(char *s) { int i; @@ -113,6 +111,7 @@ int tryExistFile (const char *s) else return 0; } + #ifdef __WIN32__ int WINAPI WinMain( HINSTANCE hInstance, @@ -124,9 +123,8 @@ int WINAPI WinMain( int main(int argc, char *argv[]) #endif { - listHelp = newList(); - srand( (unsigned) time(NULL) ); + #ifndef __WIN32__ my_argc = argc; my_argv = argv; diff --git a/src/base/main.h b/src/base/main.h index d0b11e6..5fbd81a 100644 --- a/src/base/main.h +++ b/src/base/main.h @@ -13,10 +13,6 @@ #define WINDOW_SIZE_X 800 #define WINDOW_SIZE_Y 600 -#include "list.h" - -extern list_t *listHelp; - extern char* getParam(char *s); extern char* getParamElse(char *s1, char *s2); extern bool_t isParamFlag(char *s); diff --git a/src/base/proto.c b/src/base/proto.c index e42e4d9..453398f 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -386,13 +386,6 @@ void proto_send_newtux_server(int type, client_t *client, tux_t *tux) getTuxProportion(tux, &x, &y, NULL, NULL); } - if( type == PROTO_SEND_ONE && - tux->bonus == BONUS_HIDDEN && - client->tux == tux ) - { - getTuxProportion(tux, &x, &y, NULL, NULL); - } - sprintf(msg, "newtux %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d\n", tux->id ,x, y, tux->status, tux->position ,tux->frame, tux->score, tux->name, tux->gun, tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE], @@ -436,10 +429,6 @@ void proto_recv_newtux_client(char *msg) if( tux == NULL ) { - char term_msg[STR_SIZE]; - sprintf(term_msg, "connect new client( id = %d)\n", id); - appendTextInTerm(term_msg); - tux = newTux(); replaceTuxID(tux, id); tux->control = TUX_CONTROL_NET; @@ -549,12 +538,6 @@ void proto_recv_del_client(char *msg) if( tux != NULL ) { - char term_msg[STR_SIZE]; - - //printf("delete tux..\n"); - sprintf(term_msg, "tux with id %d is disconnect\n", tux->id); - appendTextInTerm(term_msg); - delFromRadar(id); delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux); return; diff --git a/src/base/server.c b/src/base/server.c index cf1f70f..ce4f848 100644 --- a/src/base/server.c +++ b/src/base/server.c @@ -364,6 +364,7 @@ static void addMsgAllClient(char *msg, int type, int id) static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) { + list_t *listHelp; arena_t *arena; space_t *space; int x, y, w, h; @@ -371,8 +372,6 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) assert( msg != NULL ); - listDoEmpty(listHelp); - arena = getCurrentArena(); space = arena->spaceTux; @@ -387,6 +386,8 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) if( w+x >= arena->w )w = arena->w - (x+1); if( h+y >= arena->h )h = arena->h - (y+1); + listHelp = newList(); + getObjectFromSpace(space, x, y, w, h, listHelp); //printf("%d %d %d %d %d\n", x, y, w, h, listHelp->count); @@ -409,6 +410,8 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) addMsgClient(thisClient, msg, type, id); } } + + destroyList(listHelp); } void protoSendClient(int type, client_t *client, char *msg, int type2, int id) diff --git a/src/base/tux.c b/src/base/tux.c index bbc63e0..6823452 100644 --- a/src/base/tux.c +++ b/src/base/tux.c @@ -21,7 +21,6 @@ #include "font.h" #include "image.h" #include "layer.h" -#include "term.h" #include "radar.h" #ifndef NO_SOUND @@ -309,22 +308,14 @@ static void timer_tuxCanSwitchGun(void *p) void eventTuxIsDead(tux_t *tux) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; -#endif - if( tux->status == TUX_STATUS_DEAD ) { return; } -#ifndef PUBLIC_SERVER - sprintf(msg, "tux with id %d is dead\n", tux->id); #ifndef NO_SOUND playSound("dead", SOUND_GROUP_BASE); #endif - appendTextInTerm(msg); -#endif tux->status = TUX_STATUS_DEAD; memset(tux->shot, 0, sizeof(int) * GUN_COUNT); @@ -376,17 +367,10 @@ static void eventTuxIsDeadWIthShot(tux_t *tux, shot_t *shot) void tuxTeleport(tux_t *tux) { int x, y; -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; -#endif -#ifndef PUBLIC_SERVER - sprintf(msg, "tux with id %d teleporting\n", tux->id); #ifndef NO_SOUND playSound("teleport", SOUND_GROUP_BASE); #endif - appendTextInTerm(msg); -#endif if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { @@ -532,9 +516,6 @@ void moveTux(tux_t *tux, int n) void switchTuxGun(tux_t *tux) { int i; -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; -#endif if( tux->control != TUX_CONTROL_NET && tux->isCanSwitchGun == FALSE ) @@ -550,13 +531,9 @@ void switchTuxGun(tux_t *tux) tux->isCanSwitchGun = FALSE; addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN ); -#ifndef PUBLIC_SERVER #ifndef NO_SOUND playSound("switch_gun", SOUND_GROUP_BASE); #endif - sprintf(msg, "tux with id %d switch gun\n", tux->id); - appendTextInTerm(msg); -#endif return; } } @@ -570,13 +547,9 @@ void switchTuxGun(tux_t *tux) addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun, newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN ); -#ifndef PUBLIC_SERVER #ifndef NO_SOUND playSound("switch_gun", SOUND_GROUP_BASE); #endif - sprintf(msg, "tux with id %d switch gun\n", tux->id); - appendTextInTerm(msg); -#endif return; } @@ -649,14 +622,9 @@ static void pickUpGun(tux_t *tux) if( tux->pickup_time == TUX_MAX_PICKUP && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; #ifndef NO_SOUND playSound("switch_gun", SOUND_GROUP_BASE); #endif - sprintf(msg, "tux with id %d pickup\n", tux->id); - appendTextInTerm(msg); -#endif tux->gun = GUN_SIMPLE; tux->shot[ tux->gun ] = GUN_MAX_SHOT; @@ -681,10 +649,6 @@ static void eventBonus(tux_t *tux) if( tux->bonus_time == 0 && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; -#endif - if( tux->bonus == BONUS_GHOST ) { int x, y, w, h; @@ -702,11 +666,6 @@ static void eventBonus(tux_t *tux) tux->bonus = BONUS_NONE; -#ifndef PUBLIC_SERVER - sprintf(msg, "tux with id %d bonus disabled\n", tux->id); - appendTextInTerm(msg); -#endif - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); diff --git a/src/client/game.c b/src/client/game.c index a20e3fa..7eaab20 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -108,8 +108,6 @@ void quitGame() quitScreenTable(); quitScreenBrowser(); - destroyList(listHelp); - printf("quit..\n"); exit(0); @@ -119,7 +117,7 @@ void startGame() { initGame(); - setScreen("mainMenu"); + startScreen("mainMenu"); eventSDL(); quitGame(); diff --git a/src/client/interface.c b/src/client/interface.c index 5b4b6b4..3ae6121 100755 --- a/src/client/interface.c +++ b/src/client/interface.c @@ -209,6 +209,7 @@ int eventAction() case USR_EVT_TIMER: drawScreen(); eventScreen(); + switchScreen(); break; default: diff --git a/src/client/screen.c b/src/client/screen.c index a96dd9e..f08d89a 100644 --- a/src/client/screen.c +++ b/src/client/screen.c @@ -13,6 +13,8 @@ //#define DEBUG_TIME_DRAW static screen_t *currentScreen; +static screen_t *futureScreen; + static list_t *listScreen; static bool_t isScreenInit = FALSE; @@ -63,24 +65,17 @@ void registerScreen(screen_t *p) void initScreen() { listScreen = newList(); + currentScreen = NULL; + futureScreen = NULL; + isScreenInit = TRUE; } -void setScreen(char *name) +static screen_t* findScreen(char *name) { - int i; screen_t *this; - - assert( name != NULL ); - - if( currentScreen != NULL && - strcmp(currentScreen->name, name) == 0 ) - { - return; - } - - printf("switch screen %s..\n", name); + int i; for( i = 0 ; i < listScreen->count ; i++ ) { @@ -89,23 +84,47 @@ void setScreen(char *name) if( strcmp(name, this->name) == 0 ) { - flushLayer(); + return this; + } + } + + return NULL; +} + +void setScreen(char *name) +{ + futureScreen = findScreen(name); + assert( futureScreen != NULL ); +} - if( currentScreen != NULL ) - { - printf("stop screen %s..\n", currentScreen->name); - currentScreen->fce_stop(); - } +void switchScreen() +{ + if( futureScreen == NULL ) + { + return; + } - currentScreen = this; - printf("start screen %s..\n", currentScreen->name); - currentScreen->fce_start(); + flushLayer(); - return; - } + if( currentScreen != NULL ) + { + printf("stop screen %s..\n", currentScreen->name); + currentScreen->fce_stop(); } - assert( ! "screen sa nenasiel !" ); + currentScreen = futureScreen; + futureScreen = NULL; + + //printf("switch screen %s..\n", currentScreen->name); + + printf("start screen %s..\n", currentScreen->name); + currentScreen->fce_start(); +} + +void startScreen(char *name) +{ + setScreen(name); + switchScreen(); } char* getScreen() diff --git a/src/client/screen.h b/src/client/screen.h index b0d1593..55e5bb6 100644 --- a/src/client/screen.h +++ b/src/client/screen.h @@ -24,6 +24,8 @@ extern void destroyScreen(screen_t *p); extern void registerScreen(screen_t *p); extern void initScreen(); extern void setScreen(char *name); +extern void switchScreen(); +extern void startScreen(char *name); extern char* getScreen(); extern void drawScreen(); extern void eventScreen(); diff --git a/src/modules/modPipe.c b/src/modules/modPipe.c index b0516c8..1e6fe0a 100755 --- a/src/modules/modPipe.c +++ b/src/modules/modPipe.c @@ -300,27 +300,21 @@ int init(export_fce_t *p) #ifndef PUBLIC_SERVER -int draw(int x, int y, int w, int h) +static void action_drawpipe(space_t *space, pipe_t *pipe, void *p) { - pipe_t *thisPipe; - int i; + drawPipe(pipe); +} +int draw(int x, int y, int w, int h) +{ if( spacePipe == NULL ) { return 0; } - listDoEmpty(listPipe); - getObjectFromSpace(spacePipe, x, y, w, h, listPipe); + actionSpaceFromLocation(spacePipe, action_drawpipe, NULL, x, y, w, h); //printSpace(spacePipe); - for( i = 0 ; i < listPipe->count ; i++ ) - { - thisPipe = (pipe_t *)listPipe->list[i]; - assert( thisPipe != NULL ); - drawPipe(thisPipe); - } - return 0; } #endif @@ -349,67 +343,55 @@ static int negPosition(int n) return -1; // no warnning } -int event() +static void action_eventpipe(space_t *space, pipe_t *pipe, shot_t *shot) { - pipe_t *thisPipe; arena_t *arena; - int i; - - if( spacePipe == NULL ) - { - return 0; - } + tux_t *author; arena = export_fce->fce_getCurrentArena(); - for( i = 0 ; i < arena->spaceShot->list->count ; i++ ) + author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) { - 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); + return; + } - for( j = 0 ; j < listPipe->count ; j++ ) + if( negPosition( shot->position ) == pipe->position && + export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + moveShotFromPipe(shot, pipe); + } + else + { + if( shot->gun == GUN_BOMBBALL && + export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + export_fce->fce_boundBombBall(shot); + } + else { - tux_t *author; + delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot); + } + } +} - thisPipe = (pipe_t *)listPipe->list[j]; +static void action_eventshot(space_t *space, shot_t *shot, space_t *spacePipe) +{ + actionSpaceFromLocation(spacePipe, action_eventpipe, shot, shot->x, shot->y, shot->w, shot->h); +} - 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 && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - moveShotFromPipe(thisShot, thisPipe); - } - else - { - if( thisShot->gun == GUN_BOMBBALL && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - export_fce->fce_boundBombBall(thisShot); - } - else - { - delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot, - thisShot, export_fce->fce_destroyShot); - i--; - } - } - } +int event() +{ + if( spacePipe == NULL ) + { + return 0; } + actionSpace(export_fce->fce_getCurrentArena()->spaceShot, action_eventshot, spacePipe); + return 0; } diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index 1411b88..28ebeb6 100755 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -380,96 +380,78 @@ int init(export_fce_t *p) } #ifndef PUBLIC_SERVER -int draw(int x, int y, int w, int h) + +static void action_drawteleport(space_t *space, teleport_t *teleport, void *p) { - teleport_t *thisTeleport; - int i; + drawTeleport(teleport); +} +int draw(int x, int y, int w, int h) +{ if( spaceTeleport == NULL ) { return 0; } - listDoEmpty(listTeleport); - getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport); - - for( i = 0 ; i < listTeleport->count ; i++ ) - { - thisTeleport = (teleport_t *)listTeleport->list[i]; - assert( thisTeleport != NULL ); - drawTeleport(thisTeleport); - } + actionSpaceFromLocation(spaceTeleport, action_drawteleport, NULL, x, y, w, h); return 0; } #endif -int event() +static void action_eventteleportshot(space_t *space, teleport_t *teleport, shot_t *shot) { - teleport_t *thisTeleport; arena_t *arena; - int i; - - if( spaceTeleport == NULL ) - { - return 0; - } - - if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - return 0; - } + tux_t *author; arena = export_fce->fce_getCurrentArena(); - for( i = 0 ; i < arena->spaceTux->list->count ; i++ ) + author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) { - tux_t *thisTux; - int x, y, w, h; - int j; + return; + } - thisTux = (tux_t *)arena->spaceTux->list->list[i]; - export_fce->fce_getTuxProportion(thisTux, &x, &y, &w, &h); + moveShotFromTeleport(shot, teleport, spaceTeleport->list); +} - listDoEmpty(listTeleport); - getObjectFromSpace(spaceTeleport, x, y, w, h, listTeleport); +static void action_eventshot(space_t *space, shot_t *shot, space_t *spaceTeleport) +{ + actionSpaceFromLocation(spaceTeleport, action_eventteleportshot, shot, shot->x, shot->y, shot->w, shot->h); +} - for( j = 0 ; j < listTeleport->count ; j++ ) - { - thisTeleport = (teleport_t *)listTeleport->list[j]; - teleportTux(thisTux, thisTeleport); - } - } - - for( i = 0 ; i < arena->spaceShot->list->count ; i++ ) - { - shot_t *thisShot; - int j; +static void action_eventteleporttux(space_t *space, teleport_t *teleport, tux_t *tux) +{ + teleportTux(tux, teleport); +} - thisShot = (shot_t *)arena->spaceShot->list->list[i]; - assert( thisShot != NULL ); +static void action_eventtux(space_t *space, tux_t *tux, space_t *spaceTeleport) +{ + int x, y, w, h; - listDoEmpty(listTeleport); - getObjectFromSpace(spaceTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h, listTeleport); + export_fce->fce_getTuxProportion(tux, &x, &y, &w, &h); - for( j = 0 ; j < listTeleport->count ; j++ ) - { - tux_t *author; + actionSpaceFromLocation(spaceTeleport, action_eventteleporttux, tux, x, y, w, h); +} - thisTeleport = (teleport_t *)listTeleport->list[j]; - author = getObjectFromSpaceWithID(arena->spaceTux, thisShot->author_id); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } +int event() +{ + if( spaceTeleport == NULL ) + { + return 0; + } - moveShotFromTeleport(thisShot, thisTeleport, spaceTeleport->list); - } + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) + { + return 0; } + actionSpace(export_fce->fce_getCurrentArena()->spaceShot, action_eventshot, spaceTeleport); + actionSpace(export_fce->fce_getCurrentArena()->spaceTux, action_eventtux, spaceTeleport); + return 0; } diff --git a/src/modules/modWall.c b/src/modules/modWall.c index 0422bbe..8376e29 100755 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -110,51 +110,6 @@ void drawListWall(list_t *list) #endif -void eventConflictShotWithWall() -{ - arena_t *arena; - shot_t *thisShot; - tux_t *author; - int i; - - arena = export_fce->fce_getCurrentArena(); - - for( i = 0 ; i < arena->spaceShot->list->count ; i++ ) - { - thisShot = (shot_t *)arena->spaceShot->list->list[i]; - assert( thisShot != NULL ); - - if( isConflictWithObjectFromSpace(spaceWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) - { - author = getObjectFromSpaceWithID( - export_fce->fce_getCurrentArena()->spaceTux, thisShot->author_id ); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } - - if( thisShot->gun == GUN_BOMBBALL) - { - if( export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - export_fce->fce_boundBombBall(thisShot); - } - - continue; - } - - delObjectFromSpaceWithObject(export_fce->fce_getCurrentArena()->spaceShot, - thisShot, export_fce->fce_destroyShot); - - //delListItem(listShot, i, export_fce->fce_destroyShot); - i--; - } - } -} - void destroyWall(wall_t *p) { assert( p != NULL ); @@ -285,25 +240,19 @@ int init(export_fce_t *p) #ifndef PUBLIC_SERVER -int draw(int x, int y, int w, int h) +static void action_drawwall(space_t *space, wall_t *wall, void *p) { - wall_t *thisWall; - int i; + drawWall(wall); +} +int draw(int x, int y, int w, int h) +{ if( spaceWall == NULL ) { return 0; } - listDoEmpty(listWall); - getObjectFromSpace(spaceImgWall, x, y, w, h, listWall); - - for( i = 0 ; i < listWall->count ; i++ ) - { - thisWall = (wall_t *)listWall->list[i]; - assert( thisWall != NULL ); - drawWall(thisWall); - } + actionSpaceFromLocation(spaceImgWall, action_drawwall, NULL, x, y, w, h); //printSpace(spaceWall); @@ -311,6 +260,39 @@ int draw(int x, int y, int w, int h) } #endif +static void action_eventwall(space_t *space, wall_t *wall, shot_t *shot) +{ + arena_t *arena; + tux_t *author; + + arena = export_fce->fce_getCurrentArena(); + + author = getObjectFromSpaceWithID(arena->spaceTux, shot->author_id ); + + if( author != NULL && + author->bonus == BONUS_GHOST && + author->bonus_time > 0 ) + { + return; + } + + if( shot->gun == GUN_BOMBBALL) + { + if( export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + export_fce->fce_boundBombBall(shot); + } + + return; + } + + delObjectFromSpaceWithObject(arena->spaceShot, shot, export_fce->fce_destroyShot); +} + +static void action_eventshot(space_t *space, shot_t *shot, space_t *spaceWall) +{ + actionSpaceFromLocation(spaceWall, action_eventwall, shot, shot->x, shot->y, shot->w, shot->h); +} int event() { @@ -319,7 +301,8 @@ int event() return 0; } - eventConflictShotWithWall(export_fce->fce_getCurrentArena()->spaceShot->list); + actionSpace(export_fce->fce_getCurrentArena()->spaceShot, action_eventshot, spaceWall); + return 0; } diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c index cbd5400..045adc2 100644 --- a/src/screen/screen_world.c +++ b/src/screen/screen_world.c @@ -20,7 +20,6 @@ #include "keytable.h" #include "layer.h" #include "image.h" -#include "term.h" #include "font.h" #include "panel.h" #include "radar.h" @@ -108,7 +107,7 @@ void countRoundInc() if( count >= max_count ) { - printf("count %d ending\n", count); + //printf("count %d ending\n", count); #ifndef NO_SOUND playSound("end", SOUND_GROUP_BASE); #endif @@ -185,7 +184,6 @@ void drawWorld() } } - drawTerm(); drawChat(); } @@ -478,10 +476,9 @@ void eventWorld() RADAR_TYPE_TUX); } - eventTerm(); eventEnd(); - eventEsc(); eventChat(); + eventEsc(); } void startWorld() @@ -495,7 +492,6 @@ void startWorld() initRadar(); initModule(); setGameType(); - initTerm(); initChat(); prepareArena(); } @@ -566,7 +562,6 @@ void stoptWorld() delAllMusicInGroup(MUSIC_GROUP_USER); #endif quitModule(); - quitTerm(); quitChat(); quitListID(); } diff --git a/src/server/publicServer.c b/src/server/publicServer.c index e3c0212..e24e1a8 100644 --- a/src/server/publicServer.c +++ b/src/server/publicServer.c @@ -334,7 +334,6 @@ void quitPublicServer() quitModule(); quitListID(); quitHeightScore(); - destroyList(listHelp); exit(0); } |