From ae84dcf911a48093ff568877a6c405e20b70cc7c Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Wed, 27 Feb 2013 15:12:59 +0000
Subject: [PATCH] [Add] outfits and ships now have a price tag.

---
 dat/outfit.xml | 3 +++
 dat/ship.xml   | 3 +++
 src/outfit.c   | 8 +++++---
 src/outfit.h   | 1 +
 src/ship.c     | 6 +++++-
 src/ship.h     | 2 ++
 6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dat/outfit.xml b/dat/outfit.xml
index 8e9db07..95eb030 100644
--- a/dat/outfit.xml
+++ b/dat/outfit.xml
@@ -5,6 +5,7 @@
 			<max>5</max>
 			<tech>2</tech>
       <mass>0</mass>
+			<price>5000</price>
 		</general>
     <specific type="1">
       <gfx>lasergreen</gfx>
@@ -25,6 +26,7 @@
 			<max>2</max>
 			<tech>4</tech>
       <mass>10</mass>
+			<price>25000</price>
 		</general>
     <specific type="5" secondary="1">
       <ammo>Missile</ammo>
@@ -36,6 +38,7 @@
 			<max>60</max>
 			<tech>2</tech>
       <mass>1</mass>
+			<price>800</price>
 		</general>
     <specific type="6">
       <gfx>missile</gfx>
diff --git a/dat/ship.xml b/dat/ship.xml
index 0121e95..d178302 100644
--- a/dat/ship.xml
+++ b/dat/ship.xml
@@ -5,6 +5,7 @@
     <GUI>minimal</GUI>
 		<sound>engine</sound>
 		<class>1</class>
+		<price>120000</price>
 		<movement>
 			<thrust>320</thrust>
 			<turn>150</turn>
@@ -33,6 +34,7 @@
     <GUI>minimal</GUI>
 		<sound>engine</sound>
     <class>1</class>
+		<price>180000</price>
     <movement>
       <thrust>400</thrust>
       <turn>180</turn>
@@ -61,6 +63,7 @@
     <GUI>minimal</GUI>
 		<sound>engine</sound>
 		<class>2</class>
+		<price>600000</price>
 		<movement>
 			<thrust>320</thrust>
 			<turn>150</turn>
diff --git a/src/outfit.c b/src/outfit.c
index 318888a..7c810f4 100644
--- a/src/outfit.c
+++ b/src/outfit.c
@@ -242,8 +242,9 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
       cur = node->children;
       do {
         if(xml_isNode(cur, "max")) tmp->max = xml_getInt(cur);
-        else if(xml_isNode(cur, "tech")) tmp->tech = xml_getInt(cur);
-        else if(xml_isNode(cur, "mass")) tmp->mass = xml_getInt(cur);
+        else if(xml_isNode(cur, "tech")) 	tmp->tech = xml_getInt(cur);
+        else if(xml_isNode(cur, "mass")) 	tmp->mass = xml_getInt(cur);
+				else if(xml_isNode(cur, "price")) tmp->price = xml_getInt(cur);
       } while((cur = cur->next));
     }
     else if(xml_isNode(node, "specific")) {
@@ -276,8 +277,9 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
 	MELEMENT(tmp->name==NULL, 	"name");
   MELEMENT(tmp->max==0,  			"max");
   MELEMENT(tmp->tech==0, 			"tech");
- // MELEMENT(tmp->mass==0, 			"mass");
+ 	//MELEMENT(tmp->mass==0, 			"mass");
   MELEMENT(tmp->type==0, 			"type");
+	MELEMENT(tmp->price==0,			"price");
 #undef MELEMENT
 
   return tmp;
diff --git a/src/outfit.h b/src/outfit.h
index a65822d..7978acc 100644
--- a/src/outfit.h
+++ b/src/outfit.h
@@ -31,6 +31,7 @@ typedef struct Outfit_ {
   int max;
   int tech;
   int mass;
+	unsigned int price;
 
   glTexture gfx_store; // Store graphic.
 
diff --git a/src/ship.c b/src/ship.c
index a83e934..81cd53c 100644
--- a/src/ship.c
+++ b/src/ship.c
@@ -80,7 +80,9 @@ static Ship* ship_parse(xmlNodePtr parent) {
 		else if(xml_isNode(node, "sound"))
 			tmp->sound = sound_get(xml_get(node));
     else if(xml_isNode(node, "class"))
-      tmp->class = atoi(xml_get(node));
+      tmp->class = xml_getInt(node);
+		else if(xml_isNode(node, "price"))
+			tmp->price = xml_getInt(node);
     else if(xml_isNode(node, "movement")) {
       cur = node->children;
       do {
@@ -151,6 +153,8 @@ static Ship* ship_parse(xmlNodePtr parent) {
   MELEMENT(tmp->name == NULL, "name");
   MELEMENT(tmp->gfx_space == NULL, 	"GFX");
 	MELEMENT(tmp->gui == NULL, 				"GUI");
+	MELEMENT(tmp->class==0,						"class");
+	MELEMENT(tmp->price==0,						"price");
   MELEMENT(tmp->thrust==0,       		"thrust");
   MELEMENT(tmp->turn==0,         		"turn");
   MELEMENT(tmp->speed==0,        		"speed");
diff --git a/src/ship.h b/src/ship.h
index 8c71d22..c6d1778 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -27,6 +27,8 @@ typedef struct Ship_ {
   char* name; // Ship name.
   ShipClass class; // Ship class.
 
+	unsigned int price; // Price!
+
   // Movement.
   double thrust, turn, speed;