[Fix] Seg fault with map.
This commit is contained in:
parent
709c611a20
commit
d2da1f6df3
23
src/map.c
23
src/map.c
@ -38,6 +38,7 @@ static int map_inPath(StarSystem* sys);
|
|||||||
static void map_render(double bx, double by, double w, double h);
|
static void map_render(double bx, double by, double w, double h);
|
||||||
static void map_mouse(SDL_Event* event, double mx, double my);
|
static void map_mouse(SDL_Event* event, double mx, double my);
|
||||||
static void map_buttonZoom(char* str);
|
static void map_buttonZoom(char* str);
|
||||||
|
static void map_selectCur(void);
|
||||||
|
|
||||||
// Open the map window.
|
// Open the map window.
|
||||||
void map_open(void) {
|
void map_open(void) {
|
||||||
@ -304,8 +305,6 @@ static void map_buttonZoom(char* str) {
|
|||||||
|
|
||||||
// Set the map to sane defaults.
|
// Set the map to sane defaults.
|
||||||
void map_clear(void) {
|
void map_clear(void) {
|
||||||
int i;
|
|
||||||
|
|
||||||
map_zoom = 1.;
|
map_zoom = 1.;
|
||||||
if(cur_system != NULL) {
|
if(cur_system != NULL) {
|
||||||
map_xpos = cur_system->pos.x;
|
map_xpos = cur_system->pos.x;
|
||||||
@ -321,21 +320,31 @@ void map_clear(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default system is current system.
|
// Default system is current system.
|
||||||
if(cur_system != NULL)
|
map_selectCur();
|
||||||
for(i = 0; i < systems_nstack; i++)
|
}
|
||||||
|
|
||||||
|
static void map_selectCur(void) {
|
||||||
|
int i;
|
||||||
|
if(cur_system != NULL) {
|
||||||
|
for(i = 0; i < systems_nstack; i++) {
|
||||||
if(&systems_stack[i] == cur_system) {
|
if(&systems_stack[i] == cur_system) {
|
||||||
map_selected = i;
|
map_selected = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
map_selected = 0;
|
} else {
|
||||||
|
// Probably going to seg fault now..
|
||||||
|
map_selected = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the map after a jump.
|
// Update the map after a jump.
|
||||||
void map_jump(void) {
|
void map_jump(void) {
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
map_selected = -1;
|
// Set selected system to self.
|
||||||
|
map_selectCur();
|
||||||
|
|
||||||
map_xpos = cur_system->pos.x;
|
map_xpos = cur_system->pos.x;
|
||||||
map_ypos = cur_system->pos.y;
|
map_ypos = cur_system->pos.y;
|
||||||
|
|
||||||
|
@ -255,6 +255,7 @@ static void player_newMake(void) {
|
|||||||
// Create the player and start the game.
|
// Create the player and start the game.
|
||||||
player_newShip(ship, x, y, 0., 0., RNG(0, 359)/180.*M_PI);
|
player_newShip(ship, x, y, 0., 0., RNG(0, 359)/180.*M_PI);
|
||||||
space_init(system);
|
space_init(system);
|
||||||
|
map_clear(); // Set the map up.
|
||||||
|
|
||||||
// Clear the map.
|
// Clear the map.
|
||||||
map_clear();
|
map_clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user