setting up the star-systems + game world
This commit is contained in:
@@ -45,6 +45,9 @@ space-trader-multiplayer-boardgame-esque:
|
|||||||
- players can trade with each other while at the same station
|
- players can trade with each other while at the same station
|
||||||
- certain stations have shipyards, with mortgages available for trade-in/upgrading ships drives/storage capacity, etc.
|
- certain stations have shipyards, with mortgages available for trade-in/upgrading ships drives/storage capacity, etc.
|
||||||
- all systems have a safety rating, indicating likelyhood of piracy. High risk systems often have higher profitablilty
|
- all systems have a safety rating, indicating likelyhood of piracy. High risk systems often have higher profitablilty
|
||||||
|
- "safe" stations have high risk of being inspected for illegal goods
|
||||||
|
- "criminal" stations have high risk of piracy
|
||||||
|
- but it's always a dice roll that some event happens at all when you arrive in system.
|
||||||
- AI station trading agent for haggling deal-making?
|
- AI station trading agent for haggling deal-making?
|
||||||
- transport contracts available at stations randomly.
|
- transport contracts available at stations randomly.
|
||||||
- in a system, you can fly out to the asteroid belt and try to buy from miners directly, but it's a gamble on even finding any of them.
|
- in a system, you can fly out to the asteroid belt and try to buy from miners directly, but it's a gamble on even finding any of them.
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ typedef struct State {
|
|||||||
StringArena string_arena;
|
StringArena string_arena;
|
||||||
ParsedClientCommandThreadQueue* network_recv_queue;
|
ParsedClientCommandThreadQueue* network_recv_queue;
|
||||||
OutgoingMessageQueue* network_send_queue;
|
OutgoingMessageQueue* network_send_queue;
|
||||||
|
StarSystem map[STAR_SYSTEM_COUNT];
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
///// Global Variables
|
///// Global Variables
|
||||||
@@ -695,6 +696,48 @@ i32 main(i32 argc, ptr argv[]) {
|
|||||||
state.clients.capacity = SERVER_MAX_CLIENTS;
|
state.clients.capacity = SERVER_MAX_CLIENTS;
|
||||||
state.clients.length = 1; // making entry 0 to be a "null" client
|
state.clients.length = 1; // making entry 0 to be a "null" client
|
||||||
state.clients.items = (Client*)arenaAllocArray(&permanent_arena, Client, SERVER_MAX_CLIENTS);
|
state.clients.items = (Client*)arenaAllocArray(&permanent_arena, Client, SERVER_MAX_CLIENTS);
|
||||||
|
// set position of all star systems
|
||||||
|
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||||
|
state.map[i].name = STAR_NAMES[i];
|
||||||
|
state.map[i].crime = rand() % 100;
|
||||||
|
state.map[i].x = rand() % MAP_WIDTH;
|
||||||
|
state.map[i].y = rand() % MAP_HEIGHT;
|
||||||
|
bool conflicting_pos = false;
|
||||||
|
for (u32 ii = 0; ii < i; ii++) {
|
||||||
|
if (state.map[ii].x == state.map[i].x && state.map[ii].y == state.map[i].y) {
|
||||||
|
conflicting_pos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conflicting_pos) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||||
|
u32 planet_count = rand() % MAX_PLANETS + 1;
|
||||||
|
for (u32 ii = 0; ii < planet_count; ii++) {
|
||||||
|
state.map[i].planets[ii].type = (PlanetType)(rand() % PlanetType_Count);
|
||||||
|
switch (state.map[i].planets[ii].type) {
|
||||||
|
case PlanetTypeEarth: {
|
||||||
|
// TODO: roll the initial commodity counts
|
||||||
|
// AND roll the initial (excess) production levels
|
||||||
|
// earth planets do a lot of food
|
||||||
|
} break;
|
||||||
|
case PlanetTypeGas: {
|
||||||
|
// a lot of fuel and chemicals
|
||||||
|
} break;
|
||||||
|
case PlanetTypeMoon: {
|
||||||
|
// a lot of manufactured goods
|
||||||
|
} break;
|
||||||
|
case PlanetTypeAsteroid: {
|
||||||
|
// a lot of raw metals
|
||||||
|
} break;
|
||||||
|
case PlanetTypeStation: {
|
||||||
|
// a lot of ??? drugs?
|
||||||
|
} break;
|
||||||
|
case PlanetType_Count: {} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. spin off sendNetworkUpdates() infinite loop thread
|
// 2. spin off sendNetworkUpdates() infinite loop thread
|
||||||
UDPServer listener = createUDPServer(SERVER_PORT);
|
UDPServer listener = createUDPServer(SERVER_PORT);
|
||||||
|
|||||||
+167
-94
@@ -6,7 +6,10 @@
|
|||||||
|
|
||||||
///// #define some game-tunable constants
|
///// #define some game-tunable constants
|
||||||
#define STARTING_DOWN_PAYMENT (10000)
|
#define STARTING_DOWN_PAYMENT (10000)
|
||||||
#define GAME_CONSTANT_TWO (2)
|
#define STAR_SYSTEM_COUNT (40)
|
||||||
|
#define MAP_WIDTH (40)
|
||||||
|
#define MAP_HEIGHT (10)
|
||||||
|
#define MAX_PLANETS (16)
|
||||||
|
|
||||||
typedef enum EntityFeature {
|
typedef enum EntityFeature {
|
||||||
FeatureWalksAround,
|
FeatureWalksAround,
|
||||||
@@ -52,6 +55,7 @@ typedef struct ShipTemplate {
|
|||||||
u16 smugglers_hold_cu_m;
|
u16 smugglers_hold_cu_m;
|
||||||
u32 base_cost;
|
u32 base_cost;
|
||||||
} ShipTemplate;
|
} ShipTemplate;
|
||||||
|
|
||||||
global ShipTemplate SHIPS[] = {
|
global ShipTemplate SHIPS[] = {
|
||||||
{
|
{
|
||||||
.type = ShipSparrow, .drive_efficiency = 1, .life_support_efficiency = 2,
|
.type = ShipSparrow, .drive_efficiency = 1, .life_support_efficiency = 2,
|
||||||
@@ -136,107 +140,121 @@ typedef struct PlayerShip {
|
|||||||
u64 id;
|
u64 id;
|
||||||
} PlayerShip;
|
} PlayerShip;
|
||||||
|
|
||||||
|
typedef enum EquipmentType {
|
||||||
|
EquipmentTypeAquaponicsSystem,
|
||||||
|
EquipmentType3DPrinter,
|
||||||
|
EquipmentTypeAutoTailor,
|
||||||
|
EquipmentType_Count,
|
||||||
|
} EquipmentType;
|
||||||
|
|
||||||
typedef enum CommodityType {
|
typedef enum CommodityType {
|
||||||
CommodityNull,
|
|
||||||
CommodityHydrogenFuel,
|
CommodityHydrogenFuel,
|
||||||
CommodityOxygen,
|
CommodityOxygen,
|
||||||
CommodityWater,
|
CommodityWater,
|
||||||
CommodityWheat,
|
CommodityGrain,
|
||||||
CommodityRice,
|
CommodityMeat,
|
||||||
CommodityCorn,
|
CommoditySpices,
|
||||||
CommodityPotatoes,
|
CommodityAlcohol,
|
||||||
CommodityBeef,
|
|
||||||
CommodityChicken,
|
|
||||||
CommodityButter,
|
|
||||||
CommodityOliveOil,
|
|
||||||
CommodityLiquor,
|
|
||||||
CommodityBeer,
|
|
||||||
CommodityFertilizer,
|
|
||||||
CommodityCleaningSupplies,
|
|
||||||
CommodityAirFilters,
|
|
||||||
CommodityIndustrialChemicals,
|
|
||||||
CommodityClothes,
|
CommodityClothes,
|
||||||
CommodityRawTextiles,
|
CommodityRawTextiles,
|
||||||
CommodityElectronics,
|
//CommodityWheat,
|
||||||
CommodityConstructionParts,
|
//CommodityRice,
|
||||||
Commodity3dPrinterParts,
|
//CommodityCorn,
|
||||||
CommodityHandTools,
|
//CommodityPotatoes,
|
||||||
CommodityCutlery,
|
//CommodityBeef,
|
||||||
CommodityRobots,
|
//CommodityChicken,
|
||||||
CommodityPlastics,
|
//CommodityButter,
|
||||||
CommodityHandWeapons,
|
//CommodityOliveOil,
|
||||||
CommodityBatteries,
|
//CommodityLiquor,
|
||||||
CommoditySolarPanels,
|
//CommodityBeer,
|
||||||
CommodityMedicines,
|
//CommodityFertilizer,
|
||||||
CommodityOpticalComponents,
|
//CommodityCleaningSupplies,
|
||||||
CommodityGlass,
|
//CommodityAirFilters,
|
||||||
CommodityLithium,
|
//CommodityIndustrialChemicals,
|
||||||
CommodityBerylium,
|
//CommodityElectronics,
|
||||||
CommodityMagnesium,
|
//CommodityConstructionParts,
|
||||||
CommodityAluminium,
|
//Commodity3dPrinterParts,
|
||||||
CommoditySilicon,
|
//CommodityHandTools,
|
||||||
CommodityScandium,
|
//CommodityCutlery,
|
||||||
CommodityTitanium,
|
//CommodityRobots,
|
||||||
CommodityVanadium,
|
//CommodityPlastics,
|
||||||
CommodityChromium,
|
//CommodityHandWeapons,
|
||||||
CommodityManganese,
|
//CommodityBatteries,
|
||||||
CommodityIron,
|
//CommoditySolarPanels,
|
||||||
CommodityCobalt,
|
//CommodityMedicines,
|
||||||
CommodityNickel,
|
//CommodityOpticalComponents,
|
||||||
CommodityCopper,
|
//CommodityGlass,
|
||||||
CommodityZinc,
|
//CommodityLithium,
|
||||||
CommoditySelenium,
|
//CommodityBerylium,
|
||||||
CommodityZirconium,
|
//CommodityMagnesium,
|
||||||
CommodityMolybdenum,
|
//CommodityAluminium,
|
||||||
CommodityRuthenium,
|
//CommoditySilicon,
|
||||||
CommodityRhodium,
|
//CommodityScandium,
|
||||||
CommodityPalladium,
|
//CommodityTitanium,
|
||||||
CommoditySilver,
|
//CommodityVanadium,
|
||||||
CommodityCadmium,
|
//CommodityChromium,
|
||||||
CommodityTin,
|
//CommodityManganese,
|
||||||
CommodityTungsten,
|
//CommodityIron,
|
||||||
CommodityRhenium,
|
//CommodityCobalt,
|
||||||
CommodityIridium,
|
//CommodityNickel,
|
||||||
CommodityPlatinum,
|
//CommodityCopper,
|
||||||
CommodityGold,
|
//CommodityZinc,
|
||||||
CommodityMercury,
|
//CommoditySelenium,
|
||||||
CommodityLead,
|
//CommodityZirconium,
|
||||||
|
//CommodityMolybdenum,
|
||||||
|
//CommodityRuthenium,
|
||||||
|
//CommodityRhodium,
|
||||||
|
//CommodityPalladium,
|
||||||
|
//CommoditySilver,
|
||||||
|
//CommodityCadmium,
|
||||||
|
//CommodityTin,
|
||||||
|
//CommodityTungsten,
|
||||||
|
//CommodityRhenium,
|
||||||
|
//CommodityIridium,
|
||||||
|
//CommodityPlatinum,
|
||||||
|
//CommodityGold,
|
||||||
|
//CommodityMercury,
|
||||||
|
//CommodityLead,
|
||||||
Commodity_Count,
|
Commodity_Count,
|
||||||
} CommodityType;
|
} CommodityType;
|
||||||
|
|
||||||
static const char* COMMODITY_STRINGS[] = {
|
static const char* COMMODITY_STRINGS[] = {
|
||||||
"NULL",
|
|
||||||
"Hydrogen Fuel",
|
"Hydrogen Fuel",
|
||||||
"Oxygen",
|
"Oxygen",
|
||||||
"Water",
|
"Water",
|
||||||
"Wheat",
|
"Grain",
|
||||||
"Rice",
|
"Meat",
|
||||||
"Corn",
|
"Spices",
|
||||||
"Potatoes",
|
"Alcohol",
|
||||||
"Beef",
|
|
||||||
"Chicken",
|
|
||||||
"Butter",
|
|
||||||
"Olive Oil",
|
|
||||||
"Liquor",
|
|
||||||
"Beer",
|
|
||||||
"Fertilizer",
|
|
||||||
"Cleaning Supplies",
|
|
||||||
"Air Filters",
|
|
||||||
"Industrial Chemicals",
|
|
||||||
"Clothes",
|
"Clothes",
|
||||||
"Raw Textiles",
|
"Raw Textiles",
|
||||||
"Electronics",
|
//"Wheat",
|
||||||
"Construction Parts",
|
//"Rice",
|
||||||
"3d Printer Parts",
|
//"Corn",
|
||||||
"Hand Tools",
|
//"Potatoes",
|
||||||
"Cutlery",
|
//"Beef",
|
||||||
"Robots",
|
//"Chicken",
|
||||||
"Plastics",
|
//"Butter",
|
||||||
"Hand Weapons",
|
//"Olive Oil",
|
||||||
"Batteries",
|
//"Liquor",
|
||||||
"Solar Panels",
|
//"Beer",
|
||||||
"Medicines",
|
//"Fertilizer",
|
||||||
"Optical Components",
|
//"Cleaning Supplies",
|
||||||
"Glass",
|
//"Air Filters",
|
||||||
|
//"Industrial Chemicals",
|
||||||
|
//"Electronics",
|
||||||
|
//"Construction Parts",
|
||||||
|
//"3d Printer Parts",
|
||||||
|
//"Hand Tools",
|
||||||
|
//"Cutlery",
|
||||||
|
//"Robots",
|
||||||
|
//"Plastics",
|
||||||
|
//"Hand Weapons",
|
||||||
|
//"Batteries",
|
||||||
|
//"Solar Panels",
|
||||||
|
//"Medicines",
|
||||||
|
//"Optical Components",
|
||||||
|
//"Glass",
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Commodity {
|
typedef struct Commodity {
|
||||||
@@ -247,17 +265,72 @@ typedef struct Commodity {
|
|||||||
u32 m3_per_kg;
|
u32 m3_per_kg;
|
||||||
} Commodity;
|
} Commodity;
|
||||||
|
|
||||||
typedef struct StarSystem {
|
typedef enum PlanetType {
|
||||||
StringChunkList name;
|
PlanetTypeEarth,
|
||||||
} StarSystem;
|
PlanetTypeGas,
|
||||||
|
PlanetTypeMoon,
|
||||||
|
PlanetTypeAsteroid,
|
||||||
|
PlanetTypeStation,
|
||||||
|
PlanetType_Count,
|
||||||
|
} PlanetType;
|
||||||
|
|
||||||
typedef struct Planet {
|
typedef struct Planet {
|
||||||
StringChunkList name;
|
PlanetType type;
|
||||||
bool habitable;
|
|
||||||
u32 population;
|
|
||||||
u32 commodities[Commodity_Count];
|
u32 commodities[Commodity_Count];
|
||||||
|
u32 production[Commodity_Count];
|
||||||
} Planet;
|
} Planet;
|
||||||
|
|
||||||
|
typedef struct StarSystem {
|
||||||
|
u32 x;
|
||||||
|
u32 y;
|
||||||
|
u32 crime;
|
||||||
|
str name;
|
||||||
|
Planet planets[MAX_PLANETS];
|
||||||
|
} StarSystem;
|
||||||
|
|
||||||
|
global str STAR_NAMES[STAR_SYSTEM_COUNT] = {
|
||||||
|
"Achernar",
|
||||||
|
"Aldebaran",
|
||||||
|
"Mining Colony 17",
|
||||||
|
"Antares",
|
||||||
|
"Arcturus",
|
||||||
|
"Barnard's Star",
|
||||||
|
"Betelgeuse",
|
||||||
|
"Canopus",
|
||||||
|
"Capella",
|
||||||
|
"Castor",
|
||||||
|
"Centauri Prime",
|
||||||
|
"Deneb",
|
||||||
|
"Epsilon Eridani",
|
||||||
|
"Fomalhaut",
|
||||||
|
"Gliese 581",
|
||||||
|
"Hadar",
|
||||||
|
"Izar",
|
||||||
|
"Kepler-186",
|
||||||
|
"Lacaille 8760",
|
||||||
|
"Lalande 21185",
|
||||||
|
"Mintaka",
|
||||||
|
"Mirach",
|
||||||
|
"Polaris",
|
||||||
|
"Pollux",
|
||||||
|
"Procyon",
|
||||||
|
"Proxima",
|
||||||
|
"Regulus",
|
||||||
|
"Rigel",
|
||||||
|
"Ross 154",
|
||||||
|
"Sirius",
|
||||||
|
"Spica",
|
||||||
|
"Tau Ceti",
|
||||||
|
"Trappist-1",
|
||||||
|
"Vega",
|
||||||
|
"Wolf 359",
|
||||||
|
"Zeta Reticuli",
|
||||||
|
"Alnitak",
|
||||||
|
"Bellatrix",
|
||||||
|
"Denebola",
|
||||||
|
"Eltanin",
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
i32 x;
|
i32 x;
|
||||||
i32 y;
|
i32 y;
|
||||||
|
|||||||
Reference in New Issue
Block a user