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/modules | |
| 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/modules')
| -rwxr-xr-x | src/modules/modPipe.c | 104 | ||||
| -rwxr-xr-x | src/modules/modTeleport.c | 106 | ||||
| -rwxr-xr-x | src/modules/modWall.c | 99 |
3 files changed, 128 insertions, 181 deletions
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; } |