summaryrefslogtreecommitdiff
path: root/src/base/gun.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/gun.c')
-rw-r--r--src/base/gun.c172
1 files changed, 63 insertions, 109 deletions
diff --git a/src/base/gun.c b/src/base/gun.c
index 8befcbb..7198a1e 100644
--- a/src/base/gun.c
+++ b/src/base/gun.c
@@ -17,42 +17,38 @@
#ifndef NO_SOUND
#include "sound.h"
#endif
-
#ifndef PUBLIC_SERVER
#include "interface.h"
#include "screen_world.h"
#endif
-
#ifdef PUBLIC_SERVER
#include "publicServer.h"
#endif
static void modificiationCopuse(int courser, int right_x, int right_y, int *dest_x, int *dest_y)
{
- assert( dest_x != NULL );
- assert( dest_y != NULL );
-
- switch( courser )
- {
+ assert(dest_x != NULL);
+ assert(dest_y != NULL);
+ switch (courser) {
case TUX_UP :
*dest_x = right_y;
*dest_y = -right_x;
- break;
+ break;
case TUX_RIGHT :
*dest_x = right_x;
*dest_y = right_y;
- break;
+ break;
case TUX_LEFT :
*dest_x = -right_x;
*dest_y = right_y;
- break;
+ break;
case TUX_DOWN :
*dest_x = right_y;
*dest_y = right_x;
- break;
+ break;
default :
- assert( ! "V premennej courser je zly smer !" );
- break;
+ assert(! _("There is wrong value in course variable!"));
+ break;
}
}
@@ -64,26 +60,20 @@ 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);
-
- if( gun == GUN_LASSER )
- {
- switch( tux->position )
- {
+ if (gun == GUN_LASSER)
+ switch (tux->position) {
case TUX_UP :
dest_y -= GUN_LASSER_HORIZONTAL;
- break;
+ break;
case TUX_RIGHT :
break;
case TUX_LEFT :
dest_x -= GUN_LASSER_HORIZONTAL;
- break;
- case TUX_DOWN :
- break;
+ break;
+ case TUX_DOWN :
+ break;
}
- }
-
shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id);
-
addObjectToSpace(getCurrentArena()->spaceShot, shot);
}
@@ -91,48 +81,39 @@ static void addShot(tux_t *tux,int x, int y, int px, int py)
{
int gun;
- if( getNetTypeGame() == NET_GAME_TYPE_CLIENT )
- {
+ if (getNetTypeGame() == NET_GAME_TYPE_CLIENT)
return;
- }
-
- if( tux->gun == GUN_BOMBBALL )
- {
+ if (tux->gun == GUN_BOMBBALL)
gun = GUN_BOMBBALL;
- }
- else if( tux->gun == GUN_LASSER )
- {
+ else if (tux->gun == GUN_LASSER)
gun = GUN_LASSER;
- }
else
- {
gun = GUN_SIMPLE;
- }
- if( tux->bonus == BONUS_4X )
- {
+ if (tux->bonus == BONUS_4X) {
int zal;
int i;
zal = tux->position;
-
- for( i = 0 ; i < 4 ; i++ )
- {
- switch( i )
- {
- case 0 : tux->position = TUX_UP; break;
- case 1 : tux->position = TUX_RIGHT; break;
- case 2 : tux->position = TUX_LEFT; break;
- case 3 : tux->position = TUX_DOWN; break;
+ for (i = 0; i < 4; i++) {
+ switch (i) {
+ case 0 :
+ tux->position = TUX_UP;
+ break;
+ case 1 :
+ tux->position = TUX_RIGHT;
+ break;
+ case 2 :
+ tux->position = TUX_LEFT;
+ break;
+ case 3 :
+ tux->position = TUX_DOWN;
+ break;
}
-
addShotTrivial(tux, x, y, px, py, gun);
}
-
tux->position = zal;
- }
- else
- {
+ }else{
addShotTrivial(tux, x, y, px, py, gun);
}
}
@@ -152,10 +133,8 @@ static void shotInGunScatter(tux_t *tux)
{
int i;
- for( i = -2 ; i <= +2 ; i++ )
- {
+ for (i = -2 ; i <= +2 ; i++)
addShot(tux, 0, 0, +8, i);
- }
}
static void timer_addShotTimer(void *p)
@@ -166,13 +145,11 @@ static void timer_addShotTimer(void *p)
id = * ((int *)p);
free(p);
-
tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id);
-
- if( tux == NULL )return;
-
- if( tux->status != TUX_STATUS_ALIVE )return;
-
+ if (tux == NULL)
+ return;
+ if (tux->status != TUX_STATUS_ALIVE)
+ return;
gun = tux->gun;
tux->gun = GUN_SIMPLE;
addShot(tux, 0, 0, +6, 0);
@@ -183,10 +160,8 @@ static void shotInGunTommy(tux_t *tux)
{
int i;
- for( i = 0 ; i < 10 ; i++ )
- {
- addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_addShotTimer, newInt(tux->id), i * 100 );
- }
+ for (i = 0; i < 10; i++)
+ addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_addShotTimer, newInt(tux->id), i * 100);
}
static void timer_addLaserTimer(void *p)
@@ -197,21 +172,16 @@ static void timer_addLaserTimer(void *p)
id = * ((int *)p);
free(p);
-
tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id);
-
- if( tux == NULL )return;
-
- if( tux->status != TUX_STATUS_ALIVE )return;
-
+ if (tux == NULL)
+ return;
+ if (tux->status != TUX_STATUS_ALIVE)
+ return;
gun = tux->gun;
tux->gun = GUN_LASSER;
-
-
addShot(tux, 0, 0, +10, 0);
addShot(tux, +40, 0, +10, 0);
//addShot(tux, +40, 0, +10, 0);
-
tux->gun = gun;
}
@@ -219,10 +189,8 @@ static void shotInGunLasser(tux_t *tux)
{
int i;
- for( i = 0 ; i < 50 ; i++ )
- {
+ for (i = 0; i < 50; i++)
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_addLaserTimer, newInt(tux->id), i * 10 );
- }
}
static void putInGunMine(tux_t *tux)
@@ -232,43 +200,31 @@ static void putInGunMine(tux_t *tux)
x = tux->x;
y = tux->y;
-
- switch( tux->position )
- {
+ switch (tux->position) {
case TUX_UP :
y += TUX_HEIGHT;
- break;
+ break;
case TUX_RIGHT :
x -= TUX_WIDTH;
- break;
+ break;
case TUX_LEFT :
x += TUX_WIDTH;
- break;
+ break;
case TUX_DOWN :
y -= TUX_HEIGHT;
- break;
+ break;
}
-
arena = getCurrentArena();
-
- if( isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) )
- {
+ if (isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT)) {
item_t *item;
#ifndef NO_SOUND
playSound("put_mine", SOUND_GROUP_BASE);
#endif
-
tux->shot[tux->gun]--;
-
- if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
- {
+ if (getNetTypeGame() != NET_GAME_TYPE_CLIENT) {
item = newItem(x, y, ITEM_MINE, tux->id);
-
- if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
- {
+ if (getNetTypeGame() == NET_GAME_TYPE_SERVER)
proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
- }
-
addObjectToSpace(arena->spaceItem, item );
}
}
@@ -281,10 +237,8 @@ static void shotInGunBombball(tux_t *tux)
void shotInGun(tux_t *tux)
{
- if( tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE )
- {
+ if (tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE)
tux->shot[tux->gun]--;
- }
switch( tux->gun )
{
@@ -293,36 +247,36 @@ void shotInGun(tux_t *tux)
playSound("gun_revolver", SOUND_GROUP_BASE);
#endif
shotInGunSimpe(tux);
- break;
+ break;
case GUN_DUAL_SIMPLE :
#ifndef NO_SOUND
playSound("gun_revolver", SOUND_GROUP_BASE);
#endif
shotInGunDualSimpe(tux);
- break;
+ break;
case GUN_SCATTER :
#ifndef NO_SOUND
- playSound("gun_scatter", SOUND_GROUP_BASE);
+ playSound("gun_scatter", SOUND_GROUP_BASE);
#endif
shotInGunScatter(tux);
- break;
+ break;
case GUN_TOMMY :
#ifndef NO_SOUND
playSound("gun_tommy", SOUND_GROUP_BASE);
#endif
shotInGunTommy(tux);
- break;
+ break;
case GUN_LASSER :
#ifndef NO_SOUND
playSound("gun_lasser", SOUND_GROUP_BASE);
#endif
shotInGunLasser(tux);
- break;
+ break;
case GUN_BOMBBALL :
shotInGunBombball(tux);
- break;
+ break;
case GUN_MINE :
putInGunMine(tux);
- break;
+ break;
}
}