diff --git a/src/land.c b/src/land.c index 704fdda..60ea90a 100644 --- a/src/land.c +++ b/src/land.c @@ -719,7 +719,8 @@ static void shipyard_buy(char* str) { static void shipyard_yours_open(char* str) { (void)str; - char** ships; + char** sships; + glTexture** tships; int nships; /* Create window. */ @@ -767,19 +768,22 @@ static void shipyard_yours_open(char* str) { window_addText(terciary_wid, 40+300+40+100, -55, 130, 96, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL); - window_addText(terciary_wid, 40+200+40, -215, + window_addText(terciary_wid, 40+300+40, -215, 100, 20, 0, "txtSOutfits", &gl_smallFont, &cDConsole, "Outfits:\n"); window_addText(terciary_wid, 40+300+40, -215-gl_smallFont.h-5, - SHIPYARD_WIDTH-40-200-40-20, 200, 0, "txtDOutfits", + SHIPYARD_WIDTH-40-300-40-20, 200, 0, "txtDOutfits", &gl_smallFont, &cBlack, NULL); /* Ship list. */ - ships = player_ships(&nships); - window_addList(terciary_wid, 20, 40, - 200, SHIPYARD_HEIGHT-80, "lstYourShips", - ships, nships, 0, shipyard_yoursUpdate); + nships = MAX(1, player_nships()); + sships = malloc(sizeof(char*)*nships); + tships = malloc(sizeof(glTexture*)*nships); + player_ships(sships, tships); + window_addImageArray(terciary_wid, 20, 40, + 310, SHIPYARD_HEIGHT-80, "lstYourShips", 64./96.*128., 64., + tships, sships, nships, shipyard_yoursUpdate); shipyard_yoursUpdate(NULL); } diff --git a/src/player.c b/src/player.c index 8e0a688..0143dcd 100644 --- a/src/player.c +++ b/src/player.c @@ -1946,29 +1946,25 @@ void player_destroyed(void) { } /** - * @fn char** player_ships(int* nships) + * @fn void player_ships(char** ssships, glTexture** tships) * * @brief Return a buffer with all the players ship names * or "None" if there are no ships. - * @param nships Stores the number of ships. - * @return Freshly allocated array with allocated ship names. + * + * @param sships Fills sships with player_nships ship names. + * @param tships Fills sships with player_nships ship target textures. */ -char** player_ships(int* nships) { +void player_ships(char** sships, glTexture** tships) { int i; - char** shipnames; - if(player_nstack==0) { - (*nships) = 1; - shipnames = malloc(sizeof(char*)); - shipnames[0] = strdup("None"); + sships[0] = strdup("None"); + tships[0] = NULL; } else { - (*nships) = player_nstack; - shipnames = malloc(sizeof(char*) * player_nstack); - for(i = 0; i < player_nstack; i++) - shipnames[i] = strdup(player_stack[i]->name); + for(i = 0; i < player_nstack; i++) { + sships[i] = strdup(player_stack[i]->name); + tships[i] = player_stack[i]->ship->gfx_target; + } } - - return shipnames; } /** diff --git a/src/player.h b/src/player.h index 904e9e9..5dd8e3d 100644 --- a/src/player.h +++ b/src/player.h @@ -57,7 +57,7 @@ int player_cargoOwned(const char* commodityname); void player_rmMissionCargo(unsigned int cargo_id); /* Pilot ships. */ -char** player_ships(int* nships); +void player_ships(char** sships, glTexture** tships); int player_nships(void); Pilot* player_getShip(char* shipname); char* player_getLoc(char* shipname);