diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-16 19:51:46 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-16 19:51:46 +0000 |
| commit | d5ae032d2b251a1604042f68a9cd3215c233792e (patch) | |
| tree | 65ede336c208aa594f5afa38f22b5f108886e56d /src/base/shot.c | |
| parent | 6b22698fec26e427d0edaf9e4e55a35b28f9ab93 (diff) | |
nove funkcie :
extern void actionSpace(space_t *space, void *f, void *p);
extern void actionSpaceFromLocation(space_t *space, void *f, void *p, int x, int y, int w, int h);
casti kodu ktore tieto funkcie potrebovali boli prepisane tak aby ich pouzivali.
( moduly tak prepisem zajtra )
git-svn-id: http://opensvn.csie.org/tuxanci_ng@150 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/base/shot.c')
| -rw-r--r-- | src/base/shot.c | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/src/base/shot.c b/src/base/shot.c index 6911d1a..1b657c2 100644 --- a/src/base/shot.c +++ b/src/base/shot.c @@ -272,33 +272,30 @@ void transformOnlyLasser(shot_t *shot) } } -void eventMoveListShot(arena_t *arena) +static void action_moveShot(space_t *space, shot_t *shot, void *p) { - shot_t *thisShot; int new_x, new_y; - int i; + arena_t *arena; - for( i = 0 ; i < arena->spaceShot->list->count ; i++ ) - { - thisShot = (shot_t *) arena->spaceShot->list->list[i]; - assert( thisShot != NULL ); + arena = getCurrentArena(); - new_x = thisShot->x + thisShot->px; - new_y = thisShot->y + thisShot->py; + new_x = shot->x + shot->px; + new_y = shot->y + shot->py; - moveObjectInSpace(getCurrentArena()->spaceShot, thisShot, new_x, new_y); + moveObjectInSpace(space, shot, new_x, new_y); - if( thisShot->x+thisShot->w < 0 || thisShot->x > arena->w || - thisShot->y+thisShot->h < 0 || thisShot->y > arena->h ) - { - delObjectFromSpaceWithObject(arena->spaceShot, - thisShot, destroyShot); - i--; - continue; - } + if( shot->x+shot->w < 0 || shot->x > arena->w || + shot->y+shot->h < 0 || shot->y > arena->h ) + { + delObjectFromSpaceWithObject(space, shot, destroyShot); } } +void eventMoveListShot(arena_t *arena) +{ + actionSpace(arena->spaceShot, action_moveShot, NULL); +} + static int isValueInList(list_t *list, int x) { int i; @@ -314,14 +311,22 @@ static int isValueInList(list_t *list, int x) return 0; } +static void action_check(space_t *space, shot_t *shot, client_t *client) +{ + if( isValueInList(client->listSeesShot, shot->id) == 0 ) + { + addList(client->listSeesShot, newInt(shot->id) ); + proto_send_shot_server(PROTO_SEND_ONE, client, shot); + } +} + void checkShotIsInTuxScreen(arena_t *arena) { int screen_x, screen_y; - shot_t *thisShot; tux_t *thisTux; client_t *thisClient; list_t *listClient; - int i, j; + int i; if( getNetTypeGame() != NET_GAME_TYPE_SERVER ) { @@ -342,20 +347,8 @@ void checkShotIsInTuxScreen(arena_t *arena) getCenterScreen(&screen_x, &screen_y, thisTux->x, thisTux->y); - listDoEmpty(listHelp); - - getObjectFromSpace(arena->spaceShot, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp); - - for( j = 0 ; j <listHelp->count ; j++ ) - { - thisShot = (shot_t *)listHelp->list[j]; - - if( isValueInList(thisClient->listSeesShot, thisShot->id) == 0 ) - { - addList(thisClient->listSeesShot, newInt(thisShot->id) ); - proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); - } - } + actionSpaceFromLocation(arena->spaceShot, action_check, + thisClient, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y); while( thisClient->listSeesShot->count > 100 ) { |