[Add] "special" techs. Basically finished tech stuff.

This commit is contained in:
Allanis 2013-03-16 19:04:19 +00:00
parent 875b6be208
commit 6c50e56894
8 changed files with 28 additions and 15 deletions

1
TODO
View File

@ -2,7 +2,6 @@ Vital:
-- Missions
-- Save
-- Allow multiple ships in storage.
-- Tech system.
-- Commodities.
-- Main Menu.

View File

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

View File

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

View File

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

View File

@ -46,15 +46,21 @@ static char* ship_classes[] = {
};
// Return all the ships in text form.
char** ship_getTech(int* n, const int tech) {
int i;
char** ship_getTech(int* n, const int* tech, const int techmax) {
int i, j;
char** shipnames = malloc(sizeof(Ship*) * ships);
*n = 0;
for(i = 0; i < ships; i++)
if(ship_stack[i].tech <= tech) {
if(ship_stack[i].tech <= tech[0]) {
shipnames[*n] = strdup(ship_stack[i].name);
(*n)++;
} else {
for(j = 0; j < techmax; j++)
if(tech[j] == ship_stack[i].tech) {
shipnames[*n] = strdup(ship_stack[i].name);
(*n)++;
}
}
return shipnames;

View File

@ -63,7 +63,7 @@ typedef struct Ship_ {
// Get.
Ship* ship_get(const char* name);
char** ship_getTech(int* n, const int tech);
char** ship_getTech(int* n, const int* tech, const int techmax);
char* ship_class(Ship* p);
// Load/quit.

View File

@ -381,12 +381,12 @@ static Planet* planet_get(const char* name) {
tmp->tech[0] = xml_getInt(ccur);
}
else if(xml_isNode(ccur, "special")) {
for(i = 1; i < 8; i++)
for(i = 1; i < PLANET_TECH_MAX; i++)
if(tmp->tech[i]==0) {
tmp->tech[i] = xml_getInt(ccur);
break;
}
if(i == 8) WARN("Planet '%s' has tooo many"
if(i == PLANET_TECH_MAX) WARN("Planet '%s' has tooo many"
"'special tech' entries", tmp->name);
}
} while((ccur = ccur->next));

View File

@ -6,6 +6,8 @@
#define MIN_HYPERSPACE_DIST 1500
#define MAX_HYPERSPACE_VEL 25
#define PLANET_TECH_MAX 8
// Planet types. I didn't take them from Star Trek, I promise.
typedef enum PlanetClass_ {
PLANET_CLASS_NULL = 0,
@ -55,8 +57,8 @@ typedef struct Planet_ {
unsigned int services; // Offered services.
// tech[0] stores global tech level (everything that and below) while
// tech[1-7] stores the unique tech levels.
int tech[8];
// tech[1-PLANET_TECH_MAX] stores the unique tech levels.
int tech[PLANET_TECH_MAX];
glTexture* gfx_space; // Graphics in space.
glTexture* gfx_exterior; // Graphics in the exterior.