summaryrefslogtreecommitdiff
path: root/src/base/gun.c
diff options
context:
space:
mode:
authorDusan Durech <dusan@debian.(none)>2008-11-11 23:39:21 +0100
committerDusan Durech <dusan@debian.(none)>2008-11-11 23:39:21 +0100
commit957f3411170ca1d5f30ee2e2c4e25393195cce75 (patch)
tree18567d663d6d759d447b65458a410f426dae9044 /src/base/gun.c
parentde05256afe45ad24cda83ed1e2cf873c97de132c (diff)
modification coding stile :)
Diffstat (limited to 'src/base/gun.c')
-rw-r--r--src/base/gun.c191
1 files changed, 104 insertions, 87 deletions
diff --git a/src/base/gun.c b/src/base/gun.c
index 408233e..27f88bd 100644
--- a/src/base/gun.c
+++ b/src/base/gun.c
@@ -25,32 +25,31 @@
# include "publicServer.h"
#endif
-static void
-modificiationCopuse(int courser, int right_x, int right_y, int *dest_x,
- int *dest_y)
+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) {
- case TUX_UP:
- *dest_x = right_y;
- *dest_y = -right_x;
- break;
- case TUX_RIGHT:
- *dest_x = right_x;
- *dest_y = right_y;
- break;
- case TUX_LEFT:
- *dest_x = -right_x;
- *dest_y = right_y;
- break;
- case TUX_DOWN:
- *dest_x = right_y;
- *dest_y = right_x;
- break;
- default:
- assert(!_("There is wrong value in course variable!"));
- break;
+ case TUX_UP:
+ *dest_x = right_y;
+ *dest_y = -right_x;
+ break;
+ case TUX_RIGHT:
+ *dest_x = right_x;
+ *dest_y = right_y;
+ break;
+ case TUX_LEFT:
+ *dest_x = -right_x;
+ *dest_y = right_y;
+ break;
+ case TUX_DOWN:
+ *dest_x = right_y;
+ *dest_y = right_x;
+ break;
+ default:
+ assert(!_("There is wrong value in course variable!"));
+ break;
}
}
@@ -62,22 +61,22 @@ 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) {
- case TUX_UP:
- dest_y -= GUN_LASSER_HORIZONTAL;
- break;
- case TUX_RIGHT:
- break;
- case TUX_LEFT:
- dest_x -= GUN_LASSER_HORIZONTAL;
- break;
- case TUX_DOWN:
- break;
+ case TUX_UP:
+ dest_y -= GUN_LASSER_HORIZONTAL;
+ break;
+ case TUX_RIGHT:
+ break;
+ case TUX_LEFT:
+ dest_x -= GUN_LASSER_HORIZONTAL;
+ break;
+ case TUX_DOWN:
+ break;
}
- shot =
- newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun,
- tux->id);
+
+ shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id);
addObjectToSpace(getCurrentArena()->spaceShot, shot);
}
@@ -87,6 +86,7 @@ static void addShot(tux_t * tux, int x, int y, int px, int py)
if (getNetTypeGame() == NET_GAME_TYPE_CLIENT)
return;
+
if (tux->gun == GUN_BOMBBALL)
gun = GUN_BOMBBALL;
else if (tux->gun == GUN_LASSER)
@@ -99,6 +99,7 @@ static void addShot(tux_t * tux, int x, int y, int px, int py)
int i;
zal = tux->position;
+
for (i = 0; i < 4; i++) {
switch (i) {
case 0:
@@ -114,8 +115,10 @@ static void addShot(tux_t * tux, int x, int y, int px, int py)
tux->position = TUX_DOWN;
break;
}
+
addShotTrivial(tux, x, y, px, py, gun);
}
+
tux->position = zal;
} else {
addShotTrivial(tux, x, y, px, py, gun);
@@ -149,11 +152,15 @@ 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;
+
gun = tux->gun;
tux->gun = GUN_SIMPLE;
addShot(tux, 0, 0, +6, 0);
@@ -166,7 +173,7 @@ static void shotInGunTommy(tux_t * tux)
for (i = 0; i < 10; i++)
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE,
- timer_addShotTimer, newInt(tux->id), i * 100);
+ timer_addShotTimer, newInt(tux->id), i * 100);
}
static void timer_addLaserTimer(void *p)
@@ -177,13 +184,18 @@ 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;
+
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);
@@ -196,7 +208,7 @@ static void shotInGunLasser(tux_t * tux)
for (i = 0; i < 50; i++)
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE,
- timer_addLaserTimer, newInt(tux->id), i * 10);
+ timer_addLaserTimer, newInt(tux->id), i * 10);
}
static void putInGunMine(tux_t * tux)
@@ -206,32 +218,37 @@ static void putInGunMine(tux_t * tux)
x = tux->x;
y = tux->y;
+
switch (tux->position) {
- case TUX_UP:
- y += TUX_HEIGHT;
- break;
- case TUX_RIGHT:
- x -= TUX_WIDTH;
- break;
- case TUX_LEFT:
- x += TUX_WIDTH;
- break;
- case TUX_DOWN:
- y -= TUX_HEIGHT;
- break;
+ case TUX_UP:
+ y += TUX_HEIGHT;
+ break;
+ case TUX_RIGHT:
+ x -= TUX_WIDTH;
+ break;
+ case TUX_LEFT:
+ x += TUX_WIDTH;
+ break;
+ case TUX_DOWN:
+ y -= TUX_HEIGHT;
+ 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) {
item = newItem(x, y, ITEM_MINE, tux->id);
+
if (getNetTypeGame() == NET_GAME_TYPE_SERVER)
proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
+
addObjectToSpace(arena->spaceItem, item);
}
}
@@ -248,41 +265,41 @@ void shotInGun(tux_t * tux)
tux->shot[tux->gun]--;
switch (tux->gun) {
- case GUN_SIMPLE:
-#ifndef NO_SOUND
- playSound("gun_revolver", SOUND_GROUP_BASE);
-#endif
- shotInGunSimpe(tux);
- break;
- case GUN_DUAL_SIMPLE:
-#ifndef NO_SOUND
- playSound("gun_revolver", SOUND_GROUP_BASE);
-#endif
- shotInGunDualSimpe(tux);
- break;
- case GUN_SCATTER:
-#ifndef NO_SOUND
- playSound("gun_scatter", SOUND_GROUP_BASE);
-#endif
- shotInGunScatter(tux);
- break;
- case GUN_TOMMY:
-#ifndef NO_SOUND
- playSound("gun_tommy", SOUND_GROUP_BASE);
-#endif
- shotInGunTommy(tux);
- break;
- case GUN_LASSER:
-#ifndef NO_SOUND
- playSound("gun_lasser", SOUND_GROUP_BASE);
-#endif
- shotInGunLasser(tux);
- break;
- case GUN_BOMBBALL:
- shotInGunBombball(tux);
- break;
- case GUN_MINE:
- putInGunMine(tux);
- break;
+ case GUN_SIMPLE:
+ #ifndef NO_SOUND
+ playSound("gun_revolver", SOUND_GROUP_BASE);
+ #endif
+ shotInGunSimpe(tux);
+ break;
+ case GUN_DUAL_SIMPLE:
+ #ifndef NO_SOUND
+ playSound("gun_revolver", SOUND_GROUP_BASE);
+ #endif
+ shotInGunDualSimpe(tux);
+ break;
+ case GUN_SCATTER:
+ #ifndef NO_SOUND
+ playSound("gun_scatter", SOUND_GROUP_BASE);
+ #endif
+ shotInGunScatter(tux);
+ break;
+ case GUN_TOMMY:
+ #ifndef NO_SOUND
+ playSound("gun_tommy", SOUND_GROUP_BASE);
+ #endif
+ shotInGunTommy(tux);
+ break;
+ case GUN_LASSER:
+ #ifndef NO_SOUND
+ playSound("gun_lasser", SOUND_GROUP_BASE);
+ #endif
+ shotInGunLasser(tux);
+ break;
+ case GUN_BOMBBALL:
+ shotInGunBombball(tux);
+ break;
+ case GUN_MINE:
+ putInGunMine(tux);
+ break;
}
}