[Fix] Added PLAYER_CREATING flag to fix all creation/death issues propperly.
This commit is contained in:
parent
3ff2885fd2
commit
848a5e120d
20
src/player.c
20
src/player.c
@ -154,7 +154,7 @@ void player_new(void) {
|
|||||||
int r;
|
int r;
|
||||||
// Let's not seg fault due to a lack of environment.
|
// Let's not seg fault due to a lack of environment.
|
||||||
player_flags = 0;
|
player_flags = 0;
|
||||||
player_setFlag(PLAYER_DESTROYED);
|
player_setFlag(PLAYER_CREATING);
|
||||||
vectnull(&player_cam);
|
vectnull(&player_cam);
|
||||||
gl_bindCamera(&player_cam);
|
gl_bindCamera(&player_cam);
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ static void player_newShipMake(char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In case we're respawning.
|
// In case we're respawning.
|
||||||
player_rmFlag(PLAYER_DESTROYED);
|
player_rmFlag(PLAYER_CREATING);
|
||||||
|
|
||||||
vect_cset(&vp, player_px, player_py);
|
vect_cset(&vp, player_px, player_py);
|
||||||
vect_cset(&vv, player_vx, player_vy);
|
vect_cset(&vv, player_vx, player_vy);
|
||||||
@ -456,8 +456,8 @@ void player_renderBG(void) {
|
|||||||
glColour* c;
|
glColour* c;
|
||||||
Planet* planet;
|
Planet* planet;
|
||||||
|
|
||||||
if(player_isFlag(PLAYER_DESTROYED) ||
|
if(player_isFlag(PLAYER_DESTROYED) || player_isFlag(PLAYER_CREATING) ||
|
||||||
pilot_isFlag(player, PILOT_DEAD)) return;
|
pilot_isFlag(player, PLAYER_DESTROYED)) return;
|
||||||
|
|
||||||
if(planet_target >= 0) {
|
if(planet_target >= 0) {
|
||||||
planet = &cur_system->planets[planet_target];
|
planet = &cur_system->planets[planet_target];
|
||||||
@ -489,13 +489,17 @@ void player_render(void) {
|
|||||||
glColour* c;
|
glColour* c;
|
||||||
glFont* f;
|
glFont* f;
|
||||||
|
|
||||||
// Pilot is dead, just render her and stop.
|
// Pilot is dead or being created, just render her and stop.
|
||||||
if(player_isFlag(PLAYER_DESTROYED) || pilot_isFlag(player, PILOT_DEAD)) {
|
if(player_isFlag(PLAYER_DESTROYED) || player_isFlag(PLAYER_CREATING) ||
|
||||||
|
pilot_isFlag(player, PILOT_DEAD)) {
|
||||||
|
|
||||||
if(player_isFlag(PLAYER_DESTROYED)) {
|
if(player_isFlag(PLAYER_DESTROYED)) {
|
||||||
if(!toolkit && (player != NULL) && (SDL_GetTicks() > player_timer)) {
|
if(!toolkit && !player_isFlag(PLAYER_CREATING) &&
|
||||||
|
(SDL_GetTicks() > player_timer)) {
|
||||||
menu_death();
|
menu_death();
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else if(!player_isFlag(PLAYER_CREATING))
|
||||||
pilot_render(player);
|
pilot_render(player);
|
||||||
|
|
||||||
// Fancy cinematic scene borders.
|
// Fancy cinematic scene borders.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon.
|
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon.
|
||||||
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon.
|
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon.
|
||||||
#define PLAYER_LANDACK (1<<13) // Player has permission to land.
|
#define PLAYER_LANDACK (1<<13) // Player has permission to land.
|
||||||
|
#define PLAYER_CREATING (1<<14) // Player is being created.
|
||||||
|
|
||||||
// Flag functions.
|
// Flag functions.
|
||||||
#define player_isFlag(f) (player_flags & f)
|
#define player_isFlag(f) (player_flags & f)
|
||||||
|
@ -972,7 +972,7 @@ void space_render(double dt) {
|
|||||||
glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0);
|
glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0);
|
||||||
|
|
||||||
t = SDL_GetTicks();
|
t = SDL_GetTicks();
|
||||||
if(!player_isFlag(PLAYER_DESTROYED) &&
|
if(!player_isFlag(PLAYER_DESTROYED) && !player_isFlag(PLAYER_CREATING) &&
|
||||||
pilot_isFlag(player, PILOT_HYPERSPACE) && // Hyperspace fancy effect.
|
pilot_isFlag(player, PILOT_HYPERSPACE) && // Hyperspace fancy effect.
|
||||||
!paused && (player->ptimer-HYPERSPACE_STARS_BLUR < t)) {
|
!paused && (player->ptimer-HYPERSPACE_STARS_BLUR < t)) {
|
||||||
|
|
||||||
@ -1000,7 +1000,8 @@ void space_render(double dt) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
glBegin(GL_POINTS); // Normal rendering.
|
glBegin(GL_POINTS); // Normal rendering.
|
||||||
if(!paused && !player_isFlag(PLAYER_DESTROYED)) { // Update position.
|
if(!paused && !player_isFlag(PLAYER_DESTROYED) &&
|
||||||
|
!player_isFlag(PLAYER_CREATING)) { // Update position.
|
||||||
for(i = 0; i < nstars; i++) {
|
for(i = 0; i < nstars; i++) {
|
||||||
b = 13.-10.*stars[i].brightness;
|
b = 13.-10.*stars[i].brightness;
|
||||||
stars[i].x -= player->solid->vel.x/b*dt;
|
stars[i].x -= player->solid->vel.x/b*dt;
|
||||||
|
Loading…
Reference in New Issue
Block a user