diff --git a/src/map.c b/src/map.c index 6117d3e..af6b75b 100644 --- a/src/map.c +++ b/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; diff --git a/src/player.c b/src/player.c index 1e5fc96..3a05da2 100644 --- a/src/player.c +++ b/src/player.c @@ -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();