[Fix] No longer seg fault when player dies and enemies keep on kicking each others ass.
This commit is contained in:
parent
19292edd68
commit
fadd885c80
@ -48,13 +48,13 @@ int joystick_use(int indjoystick) {
|
|||||||
/* Might as well close it if it is open already. */
|
/* Might as well close it if it is open already. */
|
||||||
SDL_JoystickClose(joystick);
|
SDL_JoystickClose(joystick);
|
||||||
/* Start using the joystick. */
|
/* Start using the joystick. */
|
||||||
LOG("Using joystick %d", indjoystick);
|
|
||||||
joystick = SDL_JoystickOpen(indjoystick);
|
joystick = SDL_JoystickOpen(indjoystick);
|
||||||
if(joystick == NULL) {
|
if(joystick == NULL) {
|
||||||
WARN("Error opening joystick %d [%s]",
|
WARN("Error opening joystick %d [%s]",
|
||||||
indjoystick, SDL_JoystickName(indjoystick));
|
indjoystick, SDL_JoystickName(indjoystick));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
LOG("Using joystick %d - %s", indjoystick, SDL_JoystickName(indjoystick));
|
||||||
DEBUG("\t\tWith %d axes, %d buttons, %d balls, and %d hats",
|
DEBUG("\t\tWith %d axes, %d buttons, %d balls, and %d hats",
|
||||||
SDL_JoystickNumAxes(joystick), SDL_JoystickNumButtons(joystick),
|
SDL_JoystickNumAxes(joystick), SDL_JoystickNumButtons(joystick),
|
||||||
SDL_JoystickNumBalls(joystick), SDL_JoystickNumHats(joystick));
|
SDL_JoystickNumBalls(joystick), SDL_JoystickNumHats(joystick));
|
||||||
@ -81,7 +81,7 @@ int joystick_init(void) {
|
|||||||
numjoysticks = SDL_NumJoysticks();
|
numjoysticks = SDL_NumJoysticks();
|
||||||
LOG("%d joystick%s detected", numjoysticks, (numjoysticks==1)?"":"s");
|
LOG("%d joystick%s detected", numjoysticks, (numjoysticks==1)?"":"s");
|
||||||
for(i = 0; i < numjoysticks; i++)
|
for(i = 0; i < numjoysticks; i++)
|
||||||
LOG("\t\t%d. %s", i, SDL_JoystickName(i));
|
DEBUG(" %d. %s", i, SDL_JoystickName(i));
|
||||||
|
|
||||||
/* Enable joystick events. */
|
/* Enable joystick events. */
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
|
@ -597,7 +597,8 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
|||||||
|
|
||||||
/* Someone should let the ai know it's been attacked. */
|
/* Someone should let the ai know it's been attacked. */
|
||||||
if(!pilot_isPlayer(p)) {
|
if(!pilot_isPlayer(p)) {
|
||||||
if((player->target == p->id) || (RNGF() > 0.33)) { /* 33% chance. */
|
if((player != NULL) &&
|
||||||
|
((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->faction == FACTION_PLAYER) &&
|
||||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
||||||
@ -638,7 +639,8 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
|
|
||||||
/* Inform the ai it has been attacked, useless if player. */
|
/* Inform the ai it has been attacked, useless if player. */
|
||||||
if(!pilot_isPlayer(p)) {
|
if(!pilot_isPlayer(p)) {
|
||||||
if((player->target == p->id) || (RNGF() < 0.30*dt)) { /* 30% chance per second. */
|
if((player != NULL) &&
|
||||||
|
((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->faction == FACTION_PLAYER) &&
|
||||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNGF() < 0.5))) { /* 50% chance. */
|
||||||
|
Loading…
Reference in New Issue
Block a user