From 9699b0ed102c1b9bb1d567d3e6f9c2867b1e2c72 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Mon, 28 Oct 2013 14:53:05 +0000
Subject: [PATCH] [Add] Players shipyard now follows same style as noraml
 shipyard.

---
 src/land.c   | 18 +++++++++++-------
 src/player.c | 26 +++++++++++---------------
 src/player.h |  2 +-
 3 files changed, 23 insertions(+), 23 deletions(-)

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);