[Change] Some code quality improvements.
This commit is contained in:
parent
e9985fc8ca
commit
2cb22a8b7a
@ -109,7 +109,6 @@ int CollideLineSprite(const Vec2* ap, double ad,
|
||||
(void)bsx;
|
||||
(void)bsy;
|
||||
(void)bp;
|
||||
(void)crash;
|
||||
|
||||
}
|
||||
|
||||
|
21
src/weapon.c
21
src/weapon.c
@ -230,6 +230,8 @@ void weapons_update(const double dt) {
|
||||
static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
|
||||
Weapon** wlayer;
|
||||
int* nlayer;
|
||||
Weapon* w;
|
||||
int i;
|
||||
|
||||
switch(layer) {
|
||||
case WEAPON_LAYER_BG:
|
||||
@ -241,8 +243,7 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
|
||||
nlayer = &nwfrontLayer;
|
||||
break;
|
||||
}
|
||||
int i;
|
||||
Weapon* w;
|
||||
|
||||
for(i = 0; i < (*nlayer); i++) {
|
||||
w = wlayer[i];
|
||||
switch(wlayer[i]->outfit->type) {
|
||||
@ -365,9 +366,9 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
|
||||
static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
||||
/* Someone should let the ai know it's been attacked. */
|
||||
if(!pilot_isPlayer(p)) {
|
||||
if((player_target == p->id) || (RNG(0,2) == 0)) { /* 33% chance. */
|
||||
if((player_target == p->id) || (RNGF() > 0.33)) { /* 33% chance. */
|
||||
if((w->parent == PLAYER_ID) &&
|
||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNG(0, 1) == 0))) { /* 50% chance. */
|
||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
||||
faction_modPlayer(p->faction, -1); /* Slowly lower faction. */
|
||||
pilot_setFlag(p, PILOT_HOSTILE);
|
||||
}
|
||||
@ -497,19 +498,21 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
||||
void weapon_add(const Outfit* outfit, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, unsigned int parent, unsigned int target) {
|
||||
|
||||
WeaponLayer layer;
|
||||
Weapon* w;
|
||||
Weapon** curLayer;
|
||||
int* mLayer, *nLayer;
|
||||
|
||||
if(!outfit_isWeapon(outfit) &&
|
||||
!outfit_isAmmo(outfit) && !outfit_isTurret(outfit)) {
|
||||
ERR("Trying to create a weapon from a non-Weapon type Outfit");
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponLayer layer = (parent == PLAYER_ID) ? WEAPON_LAYER_FG : WEAPON_LAYER_BG;
|
||||
Weapon* w = weapon_create(outfit, dir, pos, vel, parent, target);
|
||||
layer = (parent == PLAYER_ID) ? WEAPON_LAYER_FG : WEAPON_LAYER_BG;
|
||||
w = weapon_create(outfit, dir, pos, vel, parent, target);
|
||||
|
||||
/* Set the propper layer. */
|
||||
Weapon** curLayer = NULL;
|
||||
int* mLayer = NULL;
|
||||
int* nLayer = NULL;
|
||||
switch(layer) {
|
||||
case WEAPON_LAYER_BG:
|
||||
curLayer = wbackLayer;
|
||||
|
@ -2,8 +2,16 @@
|
||||
#include "outfit.h"
|
||||
#include "physics.h"
|
||||
|
||||
/**
|
||||
* @enum WeaponLayer
|
||||
*
|
||||
* @brief Designates the layer the wepon is on.
|
||||
*
|
||||
* Auomatically set up on creation (player is front, rest is back).
|
||||
*/
|
||||
typedef enum { WEAPON_LAYER_BG, WEAPON_LAYER_FG } WeaponLayer;
|
||||
|
||||
/* Addition */
|
||||
void weapon_add(const Outfit* outfit, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, unsigned int parent,
|
||||
const unsigned int target);
|
||||
|
Loading…
Reference in New Issue
Block a user