summaryrefslogtreecommitdiff
path: root/src/modules/modPipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/modPipe.c')
-rwxr-xr-xsrc/modules/modPipe.c104
1 files changed, 43 insertions, 61 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;
}