planet-type specialties
This commit is contained in:
+97
-9
@@ -846,6 +846,16 @@ fn void* gameLoop(void* params) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn void setHighProductionCommodity(Planet* p, CommodityType t) {
|
||||||
|
p->commodities[t] = (COMMODITIES[t].qty / 2) + (rand() % COMMODITIES[t].qty);
|
||||||
|
p->production[t] = COMMODITIES[t].consumption + (rand() % COMMODITIES[t].consumption);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn void setLowProductionCommodity(Planet* p, CommodityType t) {
|
||||||
|
p->commodities[t] = rand() % (COMMODITIES[t].qty / 2);
|
||||||
|
p->production[t] = rand() % (COMMODITIES[t].consumption / 2);
|
||||||
|
}
|
||||||
|
|
||||||
// THE SERVER
|
// THE SERVER
|
||||||
i32 main(i32 argc, ptr argv[]) {
|
i32 main(i32 argc, ptr argv[]) {
|
||||||
osInit();
|
osInit();
|
||||||
@@ -881,41 +891,119 @@ i32 main(i32 argc, ptr argv[]) {
|
|||||||
state.map[i].crime = rand() % 100;
|
state.map[i].crime = rand() % 100;
|
||||||
state.map[i].x = rand() % MAP_WIDTH;
|
state.map[i].x = rand() % MAP_WIDTH;
|
||||||
state.map[i].y = rand() % MAP_HEIGHT;
|
state.map[i].y = rand() % MAP_HEIGHT;
|
||||||
|
// ensure all the star systems are "spaced out" a bit
|
||||||
bool conflicting_pos = false;
|
bool conflicting_pos = false;
|
||||||
for (u32 ii = 0; ii < i; ii++) {
|
for (u32 ii = 0; ii < i; ii++) {
|
||||||
if (state.map[ii].x == state.map[i].x && state.map[ii].y == state.map[i].y) {
|
bool same_pos = state.map[ii].x == state.map[i].x && state.map[ii].y == state.map[i].y;
|
||||||
|
bool north_pos = state.map[ii].x == state.map[i].x && state.map[ii].y == state.map[i].y+1;
|
||||||
|
bool south_pos = state.map[ii].x == state.map[i].x && state.map[ii].y+1 == state.map[i].y;
|
||||||
|
bool west_pos = state.map[ii].x == state.map[i].x+1 && state.map[ii].y == state.map[i].y;
|
||||||
|
bool east_pos = state.map[ii].x+1 == state.map[i].x && state.map[ii].y == state.map[i].y;
|
||||||
|
if (same_pos || north_pos || south_pos || west_pos || east_pos) {
|
||||||
conflicting_pos = true;
|
conflicting_pos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (conflicting_pos) {
|
if (conflicting_pos) {
|
||||||
i--;
|
i--; // re-do the position calc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now, build out the commodity info for the systems
|
||||||
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||||
u32 planet_count = rand() % MAX_PLANETS + 1;
|
u32 planet_count = rand() % MAX_PLANETS + 1;
|
||||||
for (u32 ii = 0; ii < planet_count; ii++) {
|
for (u32 ii = 0; ii < planet_count; ii++) {
|
||||||
state.map[i].planets[ii].type = 1+(PlanetType)(rand() % (PlanetType_Count -1));
|
Planet* p = &state.map[i].planets[ii];
|
||||||
|
p->type = 1+(PlanetType)(rand() % (PlanetType_Count -1));
|
||||||
|
// default commodity + production roll
|
||||||
for (u32 iii = 0; iii < Commodity_Count; iii++) {
|
for (u32 iii = 0; iii < Commodity_Count; iii++) {
|
||||||
state.map[i].planets[ii].commodities[iii] = rand() % 1000;
|
p->commodities[iii] = (COMMODITIES[iii].qty / 5) + (rand() % COMMODITIES[iii].qty);
|
||||||
state.map[i].planets[ii].production[iii] = rand() % 10;
|
p->production[iii] = 1 + (rand() % COMMODITIES[iii].consumption);
|
||||||
}
|
}
|
||||||
switch (state.map[i].planets[ii].type) {
|
// now, override for the "specialty" of the planet
|
||||||
|
switch (p->type) {
|
||||||
case PlanetTypeEarth: {
|
case PlanetTypeEarth: {
|
||||||
// TODO: roll the initial commodity counts
|
setHighProductionCommodity(p, CommodityWater);
|
||||||
// AND roll the initial (excess) production levels
|
setHighProductionCommodity(p, CommodityFertilizer);
|
||||||
// earth planets do a lot of food
|
setHighProductionCommodity(p, CommodityGrain);
|
||||||
|
setHighProductionCommodity(p, CommodityMeat);
|
||||||
|
setHighProductionCommodity(p, CommoditySpices);
|
||||||
|
setHighProductionCommodity(p, CommodityAlcohol);
|
||||||
|
|
||||||
|
setLowProductionCommodity(p, CommodityHydrogenFuel);
|
||||||
|
setLowProductionCommodity(p, CommodityLowGradeOre);
|
||||||
|
setLowProductionCommodity(p, CommodityHighGradeOre);
|
||||||
|
setLowProductionCommodity(p, CommodityCommonMetals);
|
||||||
|
setLowProductionCommodity(p, CommodityRareMetals);
|
||||||
|
setLowProductionCommodity(p, CommodityPreciousMetals);
|
||||||
} break;
|
} break;
|
||||||
case PlanetTypeGas: {
|
case PlanetTypeGas: {
|
||||||
// a lot of fuel and chemicals
|
// a lot of fuel and chemicals
|
||||||
|
setHighProductionCommodity(p, CommodityHydrogenFuel);
|
||||||
|
setHighProductionCommodity(p, CommodityOxygen);
|
||||||
|
setHighProductionCommodity(p, CommodityWater);
|
||||||
|
setHighProductionCommodity(p, CommodityIndustrialChemicals);
|
||||||
|
setHighProductionCommodity(p, CommodityPlastics);
|
||||||
|
|
||||||
|
setLowProductionCommodity(p, CommodityLowGradeOre);
|
||||||
|
setLowProductionCommodity(p, CommodityHighGradeOre);
|
||||||
|
setLowProductionCommodity(p, CommodityCommonMetals);
|
||||||
|
setLowProductionCommodity(p, CommodityRareMetals);
|
||||||
|
setLowProductionCommodity(p, CommodityPreciousMetals);
|
||||||
|
setLowProductionCommodity(p, CommodityClothes);
|
||||||
|
setLowProductionCommodity(p, CommodityRawTextiles);
|
||||||
|
setLowProductionCommodity(p, CommodityGlass);
|
||||||
|
setLowProductionCommodity(p, CommodityPersonalSundries);
|
||||||
|
setLowProductionCommodity(p, CommodityHandTools);
|
||||||
|
setLowProductionCommodity(p, CommodityMeat);
|
||||||
} break;
|
} break;
|
||||||
case PlanetTypeMoon: {
|
case PlanetTypeMoon: {
|
||||||
// a lot of manufactured goods
|
// a lot of manufactured goods
|
||||||
|
setHighProductionCommodity(p, CommodityPersonalSundries);
|
||||||
|
setHighProductionCommodity(p, CommodityClothes);
|
||||||
|
setHighProductionCommodity(p, CommodityAlcohol);
|
||||||
|
setHighProductionCommodity(p, CommodityElectronics);
|
||||||
|
|
||||||
|
setLowProductionCommodity(p, CommodityHighGradeOre);
|
||||||
|
setLowProductionCommodity(p, CommodityHydrogenFuel);
|
||||||
|
setLowProductionCommodity(p, CommodityOxygen);
|
||||||
|
setLowProductionCommodity(p, CommodityWater);
|
||||||
|
setLowProductionCommodity(p, CommodityFertilizer);
|
||||||
} break;
|
} break;
|
||||||
case PlanetTypeAsteroid: {
|
case PlanetTypeAsteroid: {
|
||||||
// a lot of raw metals
|
// a lot of raw metals
|
||||||
|
setHighProductionCommodity(p, CommodityLowGradeOre);
|
||||||
|
setHighProductionCommodity(p, CommodityHighGradeOre);
|
||||||
|
setHighProductionCommodity(p, CommodityCommonMetals);
|
||||||
|
setHighProductionCommodity(p, CommodityRareMetals);
|
||||||
|
setHighProductionCommodity(p, CommodityPreciousMetals);
|
||||||
|
setHighProductionCommodity(p, CommoditySemiConductors);
|
||||||
|
|
||||||
|
setLowProductionCommodity(p, CommodityHydrogenFuel);
|
||||||
|
setLowProductionCommodity(p, CommodityOxygen);
|
||||||
|
setLowProductionCommodity(p, CommodityWater);
|
||||||
|
setLowProductionCommodity(p, CommodityFertilizer);
|
||||||
|
setLowProductionCommodity(p, CommodityPersonalSundries);
|
||||||
|
setLowProductionCommodity(p, CommodityClothes);
|
||||||
|
setLowProductionCommodity(p, CommodityElectronics);
|
||||||
|
setLowProductionCommodity(p, CommodityPlastics);
|
||||||
|
setLowProductionCommodity(p, CommodityHandTools);
|
||||||
} break;
|
} break;
|
||||||
case PlanetTypeStation: {
|
case PlanetTypeStation: {
|
||||||
// a lot of ??? drugs?
|
// a lot of ??? drugs?
|
||||||
|
setHighProductionCommodity(p, CommodityAlcohol);
|
||||||
|
setHighProductionCommodity(p, CommodityPersonalSundries);
|
||||||
|
setHighProductionCommodity(p, CommodityClothes);
|
||||||
|
setHighProductionCommodity(p, CommodityElectronics);
|
||||||
|
setHighProductionCommodity(p, CommodityPlastics);
|
||||||
|
setHighProductionCommodity(p, CommodityHandTools);
|
||||||
|
|
||||||
|
setLowProductionCommodity(p, CommodityHydrogenFuel);
|
||||||
|
setLowProductionCommodity(p, CommodityOxygen);
|
||||||
|
setLowProductionCommodity(p, CommodityWater);
|
||||||
|
setLowProductionCommodity(p, CommodityFertilizer);
|
||||||
|
setLowProductionCommodity(p, CommodityMeat);
|
||||||
|
setLowProductionCommodity(p, CommodityGrain);
|
||||||
|
setLowProductionCommodity(p, CommoditySpices);
|
||||||
} break;
|
} break;
|
||||||
case PlanetTypeNull:
|
case PlanetTypeNull:
|
||||||
case PlanetType_Count:
|
case PlanetType_Count:
|
||||||
|
|||||||
+19
-10
@@ -128,6 +128,7 @@ typedef enum CommodityType {
|
|||||||
CommodityAlcohol,
|
CommodityAlcohol,
|
||||||
CommodityClothes,
|
CommodityClothes,
|
||||||
CommodityPersonalSundries,
|
CommodityPersonalSundries,
|
||||||
|
CommodityIndustrialChemicals,
|
||||||
Commodity_Count,
|
Commodity_Count,
|
||||||
} CommodityType;
|
} CommodityType;
|
||||||
|
|
||||||
@@ -153,6 +154,7 @@ global str COMMODITY_STRINGS[Commodity_Count] = {
|
|||||||
"Alcohol",
|
"Alcohol",
|
||||||
"Clothes",
|
"Clothes",
|
||||||
"Personal Sundries (Cutlery, Toys, Misc)",
|
"Personal Sundries (Cutlery, Toys, Misc)",
|
||||||
|
"Industrial Chemicals",
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum StorageUnit {
|
typedef enum StorageUnit {
|
||||||
@@ -200,39 +202,39 @@ global Commodity COMMODITIES[Commodity_Count] = {
|
|||||||
},
|
},
|
||||||
{ .type = CommodityLowGradeOre, .unit = StorageUnitContainer,
|
{ .type = CommodityLowGradeOre, .unit = StorageUnitContainer,
|
||||||
.name = "Low Grade Ore",
|
.name = "Low Grade Ore",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 800, .qty = 100, .consumption = 8,
|
||||||
},
|
},
|
||||||
{ .type = CommodityHighGradeOre, .unit = StorageUnitContainer,
|
{ .type = CommodityHighGradeOre, .unit = StorageUnitContainer,
|
||||||
.name = "High Grade Ore",
|
.name = "High Grade Ore",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 1200, .qty = 10, .consumption = 2,
|
||||||
},
|
},
|
||||||
{ .type = CommodityPlastics, .unit = StorageUnitContainer,
|
{ .type = CommodityPlastics, .unit = StorageUnitContainer,
|
||||||
.name = "Plastics",
|
.name = "Plastics",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 2000, .qty = 30, .consumption = 5,
|
||||||
},
|
},
|
||||||
{ .type = CommodityGrain, .unit = StorageUnitContainer,
|
{ .type = CommodityGrain, .unit = StorageUnitContainer,
|
||||||
.name = "Grain",
|
.name = "Grain",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 1900, .qty = 200, .consumption = 30,
|
||||||
},
|
},
|
||||||
{ .type = CommodityMeat, .unit = StorageUnitContainer,
|
{ .type = CommodityMeat, .unit = StorageUnitContainer,
|
||||||
.name = "Meat",
|
.name = "Meat",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 2100, .qty = 90, .consumption = 15,
|
||||||
},
|
},
|
||||||
{ .type = CommoditySpices, .unit = StorageUnitContainer,
|
{ .type = CommoditySpices, .unit = StorageUnitContainer,
|
||||||
.name = "Spices",
|
.name = "Spices",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 3900, .qty = 6, .consumption = 1,
|
||||||
},
|
},
|
||||||
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
|
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
|
||||||
.name = "Electronics",
|
.name = "Electronics",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 9500, .qty = 40, .consumption = 6,
|
||||||
},
|
},
|
||||||
{ .type = CommodityGlass, .unit = StorageUnitContainer,
|
{ .type = CommodityGlass, .unit = StorageUnitContainer,
|
||||||
.name = "Glass",
|
.name = "Glass",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 1400, .qty = 50, .consumption = 5,
|
||||||
},
|
},
|
||||||
{ .type = CommodityHandTools, .unit = StorageUnitContainer,
|
{ .type = CommodityHandTools, .unit = StorageUnitContainer,
|
||||||
.name = "Hand Tools",
|
.name = "Hand Tools",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 5000, .qty = 5, .consumption = 1,
|
||||||
},
|
},
|
||||||
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
|
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
|
||||||
.name = "Semi-conductors (Silicon, Arsenic, Boron)",
|
.name = "Semi-conductors (Silicon, Arsenic, Boron)",
|
||||||
@@ -262,7 +264,12 @@ global Commodity COMMODITIES[Commodity_Count] = {
|
|||||||
.name = "Personal Sundries (Cutlery, Toys, Misc)",
|
.name = "Personal Sundries (Cutlery, Toys, Misc)",
|
||||||
.price = 1800, .qty = 40, .consumption = 3,
|
.price = 1800, .qty = 40, .consumption = 3,
|
||||||
},
|
},
|
||||||
|
{ .type = CommodityIndustrialChemicals, .unit = StorageUnitContainer,
|
||||||
|
.name = "Industrial Chemicals",
|
||||||
|
.price = 3800, .qty = 20, .consumption = 5,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct MarketCommodity {
|
typedef struct MarketCommodity {
|
||||||
CommodityType type;
|
CommodityType type;
|
||||||
StorageUnit unit;
|
StorageUnit unit;
|
||||||
@@ -401,7 +408,7 @@ global str STAR_NAMES[STAR_SYSTEM_COUNT] = {
|
|||||||
"Eltanin",
|
"Eltanin",
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct XYZ {
|
||||||
i32 x;
|
i32 x;
|
||||||
i32 y;
|
i32 y;
|
||||||
i32 z;
|
i32 z;
|
||||||
@@ -426,6 +433,7 @@ typedef enum CommandType {
|
|||||||
CommandTransact,
|
CommandTransact,
|
||||||
CommandType_Count,
|
CommandType_Count,
|
||||||
} CommandType;
|
} CommandType;
|
||||||
|
|
||||||
static const char* command_type_strings[] = {
|
static const char* command_type_strings[] = {
|
||||||
"Invalid",
|
"Invalid",
|
||||||
"KeepAlive",
|
"KeepAlive",
|
||||||
@@ -446,6 +454,7 @@ typedef enum Message {
|
|||||||
MessageTransactionResult,
|
MessageTransactionResult,
|
||||||
Message_Count,
|
Message_Count,
|
||||||
} Message;
|
} Message;
|
||||||
|
|
||||||
static const char* MESSAGE_STRINGS[] = {
|
static const char* MESSAGE_STRINGS[] = {
|
||||||
"Invalid",
|
"Invalid",
|
||||||
"CharacterId",
|
"CharacterId",
|
||||||
|
|||||||
Reference in New Issue
Block a user