[Fix] Removed more possible seg faults.
This commit is contained in:
parent
108d4f1c72
commit
d358bff1e4
@ -142,11 +142,16 @@ static int escort_command(Pilot* parent, int cmd, int param) {
|
|||||||
*/
|
*/
|
||||||
int escorts_attack(Pilot* parent) {
|
int escorts_attack(Pilot* parent) {
|
||||||
int ret;
|
int ret;
|
||||||
|
Pilot* t;
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
if(parent->target != parent->id)
|
if(parent->target != parent->id)
|
||||||
ret = escort_command(parent, ESCORT_ATTACK, parent->target);
|
ret = escort_command(parent, ESCORT_ATTACK, parent->target);
|
||||||
if((ret == 0) && (parent == player))
|
if((ret == 0) && (parent == player)) {
|
||||||
player_message("Escorts: Attacking %s.", pilot_get(parent->target)->name);
|
t = pilot_get(parent->target);
|
||||||
|
if(t != NULL)
|
||||||
|
player_message("Escorts: Attacking %s.", t->name);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/weapon.c
10
src/weapon.c
@ -605,7 +605,7 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
|||||||
if((player != NULL) && (w->parent == player->id) &&
|
if((player != NULL) && (w->parent == player->id) &&
|
||||||
((player->target == p->id) || (RNGF() > 0.33))) { /* 33% chance. */
|
((player->target == p->id) || (RNGF() > 0.33))) { /* 33% chance. */
|
||||||
parent = pilot_get(w->parent);
|
parent = pilot_get(w->parent);
|
||||||
if((parent->faction == FACTION_PLAYER) &&
|
if((parent != NULL) && (parent->faction == FACTION_PLAYER) &&
|
||||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
||||||
faction_modPlayer(p->faction, -1.); /* Slowly lower faction. */
|
faction_modPlayer(p->faction, -1.); /* Slowly lower faction. */
|
||||||
}
|
}
|
||||||
@ -648,7 +648,7 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
if((player != NULL) && (w->parent == player->id) &&
|
if((player != NULL) && (w->parent == player->id) &&
|
||||||
((player->target == p->id) || (RNGF() < 0.30*dt))) { /* 30% chance per second. */
|
((player->target == p->id) || (RNGF() < 0.30*dt))) { /* 30% chance per second. */
|
||||||
parent = pilot_get(w->parent);
|
parent = pilot_get(w->parent);
|
||||||
if((parent->faction == FACTION_PLAYER) &&
|
if((parent != NULL) && (parent->faction == FACTION_PLAYER) &&
|
||||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
||||||
faction_modPlayer(p->faction, -1.); /* Slowly lower faction. */
|
faction_modPlayer(p->faction, -1.); /* Slowly lower faction. */
|
||||||
}
|
}
|
||||||
@ -715,7 +715,10 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
|||||||
case OUTFIT_TYPE_TURRET_BOLT:
|
case OUTFIT_TYPE_TURRET_BOLT:
|
||||||
if((outfit->type == OUTFIT_TYPE_TURRET_BEAM) && (w->parent != w->target)) {
|
if((outfit->type == OUTFIT_TYPE_TURRET_BEAM) && (w->parent != w->target)) {
|
||||||
pilot_target = pilot_get(w->target);
|
pilot_target = pilot_get(w->target);
|
||||||
|
if(pilot_target == NULL)
|
||||||
|
rdir = dir;
|
||||||
|
|
||||||
|
else {
|
||||||
/* Get the distance. */
|
/* Get the distance. */
|
||||||
dist = vect_dist(pos, &pilot_target->solid->pos);
|
dist = vect_dist(pos, &pilot_target->solid->pos);
|
||||||
|
|
||||||
@ -725,12 +728,11 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
|||||||
/* Position is calculated on where it should be. */
|
/* Position is calculated on where it should be. */
|
||||||
x = (pilot_target->solid->pos.x + pilot_target->solid->vel.x*t)
|
x = (pilot_target->solid->pos.x + pilot_target->solid->vel.x*t)
|
||||||
- (pos->x + vel->x*t);
|
- (pos->x + vel->x*t);
|
||||||
|
|
||||||
y = (pilot_target->solid->pos.y + pilot_target->solid->vel.y*t)
|
y = (pilot_target->solid->pos.y + pilot_target->solid->vel.y*t)
|
||||||
- (pos->y + vel->y*t);
|
- (pos->y + vel->y*t);
|
||||||
vect_cset(&v, x, y);
|
|
||||||
|
|
||||||
rdir = VANGLE(v);
|
rdir = VANGLE(v);
|
||||||
|
}
|
||||||
} else /* Fire straight. */
|
} else /* Fire straight. */
|
||||||
rdir = dir;
|
rdir = dir;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user