[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_mouse(SDL_Event* event, double mx, double my);
|
||||
static void map_buttonZoom(char* str);
|
||||
static void map_selectCur(void);
|
||||
|
||||
// Open the map window.
|
||||
void map_open(void) {
|
||||
@ -304,8 +305,6 @@ static void map_buttonZoom(char* str) {
|
||||
|
||||
// Set the map to sane defaults.
|
||||
void map_clear(void) {
|
||||
int i;
|
||||
|
||||
map_zoom = 1.;
|
||||
if(cur_system != NULL) {
|
||||
map_xpos = cur_system->pos.x;
|
||||
@ -321,21 +320,31 @@ void map_clear(void) {
|
||||
}
|
||||
|
||||
// Default system is current system.
|
||||
if(cur_system != NULL)
|
||||
for(i = 0; i < systems_nstack; i++)
|
||||
map_selectCur();
|
||||
}
|
||||
|
||||
static void map_selectCur(void) {
|
||||
int i;
|
||||
if(cur_system != NULL) {
|
||||
for(i = 0; i < systems_nstack; i++) {
|
||||
if(&systems_stack[i] == cur_system) {
|
||||
map_selected = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
map_selected = 0;
|
||||
}
|
||||
} else {
|
||||
// Probably going to seg fault now..
|
||||
map_selected = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the map after a jump.
|
||||
void map_jump(void) {
|
||||
int j;
|
||||
|
||||
map_selected = -1;
|
||||
// Set selected system to self.
|
||||
map_selectCur();
|
||||
|
||||
map_xpos = cur_system->pos.x;
|
||||
map_ypos = cur_system->pos.y;
|
||||
|
||||
|
@ -255,6 +255,7 @@ static void player_newMake(void) {
|
||||
// Create the player and start the game.
|
||||
player_newShip(ship, x, y, 0., 0., RNG(0, 359)/180.*M_PI);
|
||||
space_init(system);
|
||||
map_clear(); // Set the map up.
|
||||
|
||||
// Clear the map.
|
||||
map_clear();
|
||||
|
Loading…
Reference in New Issue
Block a user