[Add] Preliminary tech support. (only raw, no special tech yet).

This commit is contained in:
Allanis 2013-03-16 18:44:06 +00:00
parent 7db2ae019d
commit 6802c39eec
9 changed files with 84 additions and 33 deletions

View File

@ -83,7 +83,7 @@
<outfit name="Headhunter Launcher"> <outfit name="Headhunter Launcher">
<general> <general>
<max>2</max> <max>2</max>
<tech>8</tech> <tech>5</tech>
<mass>12</mass> <mass>12</mass>
<price>40000</price> <price>40000</price>
<description>The Headhunter Launcher is one of the most used missile launcher by the security companies. Much more reliable then the regular missiles, Headhunters feature more sensors and an advanced tracking system making them much better at hitting their targets.</description> <description>The Headhunter Launcher is one of the most used missile launcher by the security companies. Much more reliable then the regular missiles, Headhunters feature more sensors and an advanced tracking system making them much better at hitting their targets.</description>
@ -96,7 +96,7 @@
<outfit name="Headhunter"> <outfit name="Headhunter">
<general> <general>
<max>40</max> <max>40</max>
<tech>4</tech> <tech>5</tech>
<mass>1</mass> <mass>1</mass>
<price>2000</price> <price>2000</price>
<description>Headhunters first gained fame in the crush of the Vroen, a fearsome battle against a pirate stronghold where the Empire crushed the pirates thanks to the advanced guidance system on the Headhunter. Now used by mercenaries and bounty hunters all over.</description> <description>Headhunters first gained fame in the crush of the Vroen, a fearsome battle against a pirate stronghold where the Empire crushed the pirates thanks to the advanced guidance system on the Headhunter. Now used by mercenaries and bounty hunters all over.</description>
@ -119,7 +119,7 @@
<outfit name="Neutron Disruptor"> <outfit name="Neutron Disruptor">
<general> <general>
<max>3</max> <max>3</max>
<tech>12</tech> <tech>99</tech>
<mass>8</mass> <mass>8</mass>
<price>25000</price> <price>25000</price>
<description>Neutron Disruptor.</description> <description>Neutron Disruptor.</description>

View File

@ -11,7 +11,9 @@
<bar>The bar is just off the starport with a fantastic view of the harbour. You could watch the fishermen run frantically about attending their duties for hours.</bar> <bar>The bar is just off the starport with a fantastic view of the harbour. You could watch the fishermen run frantically about attending their duties for hours.</bar>
<faction>Independent</faction> <faction>Independent</faction>
<services>31</services> <services>31</services>
<tech>0</tech> <tech>
<main>3</main>
</tech>
<commodities>1</commodities> <commodities>1</commodities>
</general> </general>
<GFX> <GFX>
@ -30,7 +32,9 @@
<bar>The SaraCraft canteen is a shady place. Many scoundrels and lowlifes make this thier home to avoid notice from the universal police.</bar> <bar>The SaraCraft canteen is a shady place. Many scoundrels and lowlifes make this thier home to avoid notice from the universal police.</bar>
<faction>Independent</faction> <faction>Independent</faction>
<services>7</services> <services>7</services>
<tech>0</tech> <tech>
<main>4</main>
</tech>
<commodities>1</commodities> <commodities>1</commodities>
</general> </general>
<GFX> <GFX>
@ -49,7 +53,9 @@
<bar>The Omega Canteen is a dark place that seems calm, although everytime a robotic drone approaches, an alarm is sounded, sending pilots to man their ships to fight off the menace.</bar> <bar>The Omega Canteen is a dark place that seems calm, although everytime a robotic drone approaches, an alarm is sounded, sending pilots to man their ships to fight off the menace.</bar>
<faction>Empire</faction> <faction>Empire</faction>
<services>15</services> <services>15</services>
<tech>0</tech> <tech>
<main>5</main>
</tech>
<commodities>1</commodities> <commodities>1</commodities>
</general> </general>
<GFX> <GFX>
@ -64,12 +70,8 @@
</pos> </pos>
<general> <general>
<class>0</class> <class>0</class>
<description>You should not be here! There is no life support module!</description>
<bar>The Omega Canteen is a dark place that seems calm, although everytime a robotic drone approaches, an alarm is sounded, sending pilots to man their ships to fight off the menace.</bar>
<faction>Collective</faction> <faction>Collective</faction>
<services>0</services> <services>0</services>
<tech>0</tech>
<commodities>0</commodities>
</general> </general>
<GFX> <GFX>
<space>station01.png</space> <space>station01.png</space>

View File

@ -7,6 +7,7 @@
<class>1</class> <class>1</class>
<price>120000</price> <price>120000</price>
<fabricator>KonoGroup</fabricator> <fabricator>KonoGroup</fabricator>
<tech>2</tech>
<description>One of the most widely used ships in the galaxy. Reknown for it's stability and stubborness. The design hasn't been modified much since it's creation many years ago. It was one of the first civilian used spacecrafts, first used by the aristocracy and now used by everyone who cannot afford better.</description> <description>One of the most widely used ships in the galaxy. Reknown for it's stability and stubborness. The design hasn't been modified much since it's creation many years ago. It was one of the first civilian used spacecrafts, first used by the aristocracy and now used by everyone who cannot afford better.</description>
<movement> <movement>
<thrust>320</thrust> <thrust>320</thrust>
@ -38,6 +39,7 @@
<class>1</class> <class>1</class>
<price>180000</price> <price>180000</price>
<fabricator>SaraCraft</fabricator> <fabricator>SaraCraft</fabricator>
<tech>2</tech>
<description>The star product of SaraCraft, the leapard has quickly become a favourite of pirates far and wide. Not much of a fighter, nor does it pack too much of a punch, but they like to come in swarms to overcome their enemies. While the SaraCraft official stance doesn't sell them to shady characters, it's widely known that they do as it seems there's a countless amount in the hands of pirates. </description> <description>The star product of SaraCraft, the leapard has quickly become a favourite of pirates far and wide. Not much of a fighter, nor does it pack too much of a punch, but they like to come in swarms to overcome their enemies. While the SaraCraft official stance doesn't sell them to shady characters, it's widely known that they do as it seems there's a countless amount in the hands of pirates. </description>
<movement> <movement>
<thrust>400</thrust> <thrust>400</thrust>
@ -69,6 +71,7 @@
<class>3</class> <class>3</class>
<price>7500000</price> <price>7500000</price>
<fabricator>VLSoft</fabricator> <fabricator>VLSoft</fabricator>
<tech>9</tech>
<description>A heavy frigate designed for heavy combat. Used widely by the Empire to esablish control on it's territory. The Hawking has more than enough firepower to not be taken lightly.</description> <description>A heavy frigate designed for heavy combat. Used widely by the Empire to esablish control on it's territory. The Hawking has more than enough firepower to not be taken lightly.</description>
<movement> <movement>
<thrust>200</thrust> <thrust>200</thrust>
@ -102,7 +105,8 @@
<class>2</class> <class>2</class>
<price>700000</price> <price>700000</price>
<fabricator>VLSoft</fabricator> <fabricator>VLSoft</fabricator>
<description>On of VLSoft's prize heavey fighters. Was originally a secret design for the Empire military, but then disclosed. Now a modified version is available for civilians, although it doesn't meet up to the original specifications. Used by security agencies all over the universe for it's reliability and availability. Proudly enforcing your security since STARDATE.</description> <tech>7</tech>
<description>One of VLSoft's prize heavey fighters. Was originally a secret design for the Empire military, but then disclosed. Now a modified version is available for civilians, although it doesn't meet up to the original specifications. Used by security agencies all over the universe for it's reliability and availability. Proudly enforcing your security since STARDATE.</description>
<movement> <movement>
<thrust>280</thrust> <thrust>280</thrust>
<turn>135</turn> <turn>135</turn>
@ -135,6 +139,7 @@
<class>2</class> <class>2</class>
<price>900000</price> <price>900000</price>
<fabricator>VLSoft</fabricator> <fabricator>VLSoft</fabricator>
<tech>5</tech>
<description>A heavy liner specialized in freighting cargo all over the universe. Also has good accomodations for passengers depending on the model, allowing for enjoyable curises. Was a favourite target of pirates until they added stick turrets to the new models which can now defend themselves effectively.</description> <description>A heavy liner specialized in freighting cargo all over the universe. Also has good accomodations for passengers depending on the model, allowing for enjoyable curises. Was a favourite target of pirates until they added stick turrets to the new models which can now defend themselves effectively.</description>
<movement> <movement>
<thrust>180</thrust> <thrust>180</thrust>
@ -166,6 +171,7 @@
<class>1</class> <class>1</class>
<price>300000</price> <price>300000</price>
<fabricator>RoboSys</fabricator> <fabricator>RoboSys</fabricator>
<tech>99</tech>
<description>A robot drone.</description> <description>A robot drone.</description>
<movement> <movement>
<thrust>450</thrust> <thrust>450</thrust>

View File

@ -137,7 +137,7 @@ static void outfits(void) {
&gl_smallFont, NULL, NULL); &gl_smallFont, NULL, NULL);
// Set up the outfits to buy/sell. // Set up the outfits to buy/sell.
outfits = outfit_getAll(&noutfits); outfits = outfit_getTech(&noutfits, planet->tech[0]); // TODO: Special tech.
window_addList(secondary_wid, 20, 40, window_addList(secondary_wid, 20, 40,
200, OUTFITS_HEIGHT-80, "lstOutfits", 200, OUTFITS_HEIGHT-80, "lstOutfits",
outfits, noutfits, 0, outfits_update); outfits, noutfits, 0, outfits_update);
@ -310,7 +310,7 @@ static void shipyard(void) {
&gl_smallFont, NULL, NULL); &gl_smallFont, NULL, NULL);
// Setup the ships to buy/sell. // Setup the ships to buy/sell.
ships = ship_getAll(&nships); ships = ship_getTech(&nships, planet->tech[0]);
window_addList(secondary_wid, 20, 40, window_addList(secondary_wid, 20, 40,
200, SHIPYARD_HEIGHT-80, "lstShipyard", 200, SHIPYARD_HEIGHT-80, "lstShipyard",
ships, nships, 0, shipyard_update); ships, nships, 0, shipyard_update);

View File

@ -39,12 +39,18 @@ Outfit* outfit_get(const char* name) {
} }
// Return all the outfits. // Return all the outfits.
char** outfit_getAll(int* n) { char** outfit_getTech(int* n, const int tech) {
int i;
char** outfitnames = malloc(sizeof(Outfit*) * outfits); char** outfitnames = malloc(sizeof(Outfit*) * outfits);
for((*n) = 0; (*n) < outfits; (*n)++) *n = 0;
outfitnames[*n] = strdup(outfit_stack[*n].name); for(i = 0; i < outfits; i++)
if(outfit_stack[i].tech <= tech) {
outfitnames[*n] = strdup(outfit_stack[i].name);
(*n)++;
}
// Actual size is bigger, but it'll just get freed ;).
return outfitnames; return outfitnames;
} }

View File

@ -83,7 +83,7 @@ typedef struct Outfit_ {
// Get. // Get.
Outfit* outfit_get(const char* name); Outfit* outfit_get(const char* name);
char** outfit_getAll(int* n); char** outfit_getTech(int* n, const int tech);
// Outfit types. // Outfit types.
int outfit_isWeapon(const Outfit* o); int outfit_isWeapon(const Outfit* o);
int outfit_isLauncher(const Outfit* o); int outfit_isLauncher(const Outfit* o);

View File

@ -46,11 +46,16 @@ static char* ship_classes[] = {
}; };
// Return all the ships in text form. // Return all the ships in text form.
char** ship_getAll(int* n) { char** ship_getTech(int* n, const int tech) {
int i;
char** shipnames = malloc(sizeof(Ship*) * ships); char** shipnames = malloc(sizeof(Ship*) * ships);
for((*n)=0; (*n) < ships; (*n)++) *n = 0;
shipnames[*n] = strdup(ship_stack[*n].name); for(i = 0; i < ships; i++)
if(ship_stack[i].tech <= tech) {
shipnames[*n] = strdup(ship_stack[i].name);
(*n)++;
}
return shipnames; return shipnames;
} }
@ -94,6 +99,8 @@ static Ship* ship_parse(xmlNodePtr parent) {
tmp->class = xml_getInt(node); tmp->class = xml_getInt(node);
else if(xml_isNode(node, "price")) else if(xml_isNode(node, "price"))
tmp->price = xml_getInt(node); tmp->price = xml_getInt(node);
else if(xml_isNode(node, "tech"))
tmp->tech = xml_getInt(node);
else if(xml_isNode(node, "fabricator")) else if(xml_isNode(node, "fabricator"))
tmp->fabricator = strdup(xml_get(node)); tmp->fabricator = strdup(xml_get(node));
else if(xml_isNode(node, "description")) else if(xml_isNode(node, "description"))
@ -171,6 +178,7 @@ static Ship* ship_parse(xmlNodePtr parent) {
MELEMENT(tmp->gui == NULL, "GUI"); MELEMENT(tmp->gui == NULL, "GUI");
MELEMENT(tmp->class==0, "class"); MELEMENT(tmp->class==0, "class");
MELEMENT(tmp->price==0, "price"); MELEMENT(tmp->price==0, "price");
MELEMENT(tmp->tech==0, "tech");
MELEMENT(tmp->fabricator==0, "fabricator"); MELEMENT(tmp->fabricator==0, "fabricator");
MELEMENT(tmp->description==0, "description"); MELEMENT(tmp->description==0, "description");
MELEMENT(tmp->thrust==0, "thrust"); MELEMENT(tmp->thrust==0, "thrust");

View File

@ -28,7 +28,8 @@ typedef struct Ship_ {
ShipClass class; // Ship class. ShipClass class; // Ship class.
// Store stuff. // Store stuff.
unsigned int price; // Price! int price; // Price!
int tech;
char* fabricator; // Manufacturer. char* fabricator; // Manufacturer.
char* description; // Sales pitch. char* description; // Sales pitch.
@ -62,7 +63,7 @@ typedef struct Ship_ {
// Get. // Get.
Ship* ship_get(const char* name); Ship* ship_get(const char* name);
char** ship_getAll(int* n); char** ship_getTech(int* n, const int tech);
char* ship_class(Ship* p); char* ship_class(Ship* p);
// Load/quit. // Load/quit.

View File

@ -35,6 +35,8 @@
#define FLAG_YSET (1<<1) #define FLAG_YSET (1<<1)
#define FLAG_ASTEROIDSSET (1<<2) #define FLAG_ASTEROIDSSET (1<<2)
#define FLAG_INTEFERENCESET (1<<3) #define FLAG_INTEFERENCESET (1<<3)
#define FLAG_SERVICESET (1<<4)
#define FLAG_TECHSET (1<<5)
// Star system stack and co. // Star system stack and co.
StarSystem* systems_stack = NULL; // Star system stack. StarSystem* systems_stack = NULL; // Star system stack.
@ -289,6 +291,8 @@ void space_init(const char* sysname) {
// Load the planets of name 'name'. // Load the planets of name 'name'.
static Planet* planet_get(const char* name) { static Planet* planet_get(const char* name) {
int i;
Planet* tmp = NULL; Planet* tmp = NULL;
char str[PATH_MAX] = "\0"; char str[PATH_MAX] = "\0";
@ -299,7 +303,7 @@ static Planet* planet_get(const char* name) {
uint32_t bufsize; uint32_t bufsize;
char* buf = pack_readfile(DATA, PLANET_DATA, &bufsize); char* buf = pack_readfile(DATA, PLANET_DATA, &bufsize);
xmlNodePtr node, cur; xmlNodePtr node, cur, ccur;
xmlDocPtr doc = xmlParseMemory(buf, bufsize); xmlDocPtr doc = xmlParseMemory(buf, bufsize);
node = doc->xmlChildrenNode; node = doc->xmlChildrenNode;
@ -365,8 +369,28 @@ static Planet* planet_get(const char* name) {
tmp->description = strdup(xml_get(cur)); tmp->description = strdup(xml_get(cur));
else if(xml_isNode(cur, "bar")) else if(xml_isNode(cur, "bar"))
tmp->bar_description = strdup(xml_get(cur)); tmp->bar_description = strdup(xml_get(cur));
else if(xml_isNode(cur, "services")) else if(xml_isNode(cur, "services")) {
flags |= FLAG_SERVICESET;
tmp->services = xml_getInt(cur); tmp->services = xml_getInt(cur);
}
else if(xml_isNode(cur, "tech")) {
ccur = cur->children;
do {
if(xml_isNode(ccur, "main")) {
flags |= FLAG_TECHSET;
tmp->tech[0] = xml_getInt(ccur);
}
else if(xml_isNode(ccur, "special")) {
for(i = 1; i < 8; i++)
if(tmp->tech[i]==0) {
tmp->tech[i] = xml_getInt(ccur);
break;
}
if(i == 8) WARN("Planet '%s' has tooo many"
"'special tech' entries", tmp->name);
}
} while((ccur = ccur->next));
}
} while((cur = cur->next)); } while((cur = cur->next));
} }
} while((node = node->next)); } while((node = node->next));
@ -382,14 +406,18 @@ static Planet* planet_get(const char* name) {
// Check elements. // Check elements.
if(tmp) { if(tmp) {
#define MELEMENT(o,s) if((o) == 0) WARN("Planet '%s' missing '"s"' element", \ #define MELEMENT(o,s) if(o) WARN("Planet '%s' missing '"s"' element", tmp->name)
tmp->name) MELEMENT(tmp->gfx_space==NULL, "GFX_space");
MELEMENT(tmp->gfx_space, "GFX_space"); MELEMENT(tmp->gfx_exterior==NULL, "GFX_exterior");
MELEMENT(tmp->gfx_exterior, "GFX_exterior"); MELEMENT((flags&FLAG_XSET)==0, "x");
MELEMENT(flags&FLAG_XSET, "x"); MELEMENT((flags&FLAG_YSET)==0, "y");
MELEMENT(flags&FLAG_YSET, "y"); MELEMENT(tmp->class==PLANET_CLASS_NULL, "class");
MELEMENT(tmp->class, "class"); MELEMENT(tmp->faction==NULL, "faction");
MELEMENT(tmp->faction, "faction"); MELEMENT((flags&FLAG_SERVICESET)==0, "services");
MELEMENT((planet_hasService(tmp, PLANET_SERVICE_OUTFITS) ||
planet_hasService(tmp, PLANET_SERVICE_SHIPYARD)) &&
(flags&FLAG_TECHSET)==0, "tech");
#undef MELEMENT #undef MELEMENT
} else } else
WARN("No planet found matching name '%s'", name); WARN("No planet found matching name '%s'", name);