minor cleanup from playtest

This commit is contained in:
Tenari
2026-03-20 07:29:27 -05:00
parent 711a812145
commit b84a120d70
3 changed files with 72 additions and 159 deletions
+9 -20
View File
@@ -284,6 +284,7 @@ fn void renderStaticAssetToPixelBuffer(TuiState* tui, u8* asset, u32 len, u16 x,
fn void resetTabRow(Tab tab) {
if (state.menu.selected_index == TabMarket) {
state.market_tab_state = MarketTabStateTable;
state.row.len = Commodity_Count;
state.row.selected_index = 0;
state.modal_choice.selected_index = 0;
@@ -875,9 +876,6 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
renderStrToBuffer(tui->frame_buffer, box.x+2, box.y+1, "You haven't heard anything interesting lately...", screen_dimensions);
} break;*/
case TabMap: {
if (input_buffer[0] == 'q' || user_pressed_esc) {
should_quit = true;
}
if (user_pressed_up) {
state->pos.y -= 1;
} else if (user_pressed_down) {
@@ -1053,9 +1051,6 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
} break;
case TabShip: {
if (state->ship_tab_states == ShipTabStateMain) {
if (input_buffer[0] == 'q' || user_pressed_esc) {
should_quit = true;
}
moveRowUpDown(user_pressed_up, user_pressed_down);
}
@@ -1141,9 +1136,11 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
}
for (u32 i = 0; i < Commodity_Count; i++) {
MemoryZero(sbuf, SBUFLEN);
sprintf(sbuf, "%-42s %d", COMMODITIES[i].name, state->me.commodities[i]);
renderStrToBuffer(tui->frame_buffer, box.x+4, yoff+3+i, sbuf, screen_dimensions);
if (i == CommodityOxygen || i == CommodityHydrogenFuel || state->me.commodities[i] > 0) {
MemoryZero(sbuf, SBUFLEN);
sprintf(sbuf, "%-42s %d", COMMODITIES[i].name, state->me.commodities[i]);
renderStrToBuffer(tui->frame_buffer, box.x+4, yoff+3+i, sbuf, screen_dimensions);
}
}
Box modal_outline = defaultModal(tui);
@@ -1211,11 +1208,7 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
} break;
case TabMarket: {
if (input_buffer[0] == 'q' || user_pressed_esc) {
if (state->market_tab_state == MarketTabStateTable) {
should_quit = true;
} else {
state->market_tab_state = MarketTabStateTable;
}
state->market_tab_state = MarketTabStateTable;
}
u32 line = box.y + 1;
@@ -1422,12 +1415,8 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
} break;
case TabPassengers: {
if (input_buffer[0] == 'q' || user_pressed_esc) {
if (state->passenger_tab_state == PassengersTabStateTable) {
should_quit = true;
} else {
state->passenger_tab_state = PassengersTabStateTable;
}
if (input_buffer[0] == 'q' || user_pressed_esc || user_pressed_backspace) {
state->passenger_tab_state = PassengersTabStateTable;
}
u32 line = box.y + 1;
+32 -41
View File
@@ -32,7 +32,7 @@
#define CHUNK_SIZE 64
#define ACCOUNT_LEN (16)
#define PARSED_CLIENT_COMMAND_THREAD_QUEUE_LEN 64
#define SYSTEM_MESSAGES_LEN 32
#define SYSTEM_MESSAGES_LEN 40
#define MAX_SYSTEM_MESSAGE_LEN 512
#define SBUFLEN (512)
@@ -106,6 +106,7 @@ typedef struct State {
u64 frame;
Arena game_scratch;
StringArena string_arena;
String server_ip_address;
ParsedClientCommandThreadQueue* network_recv_queue;
OutgoingMessageQueue* network_send_queue;
StarSystem map[STAR_SYSTEM_COUNT];
@@ -1185,8 +1186,11 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
state->tab = state->tab == TabDebug ? TabMap : TabDebug;
}
// show what ip to connect to
renderStrToBuffer(tui->frame_buffer, screen_dimensions.width - 18, 1, state->server_ip_address.bytes, screen_dimensions);
// draw the tabs box
u32 tabs_y = 1;
u32 tabs_y = 0;
u32 box_y = tabs_y + 2;
Box box = {
.x = 1,
@@ -1355,6 +1359,18 @@ i32 main(i32 argc, ptr argv[]) {
system_messages[i].length = 0;
system_messages[i].items = arenaAllocArraySized(&permanent_arena, sizeof(u8), MAX_SYSTEM_MESSAGE_LEN);
}
state.server_ip_address.bytes = arenaAllocArraySized(&permanent_arena, sizeof(u8), 16);
state.server_ip_address.capacity = 16;
{
struct ifaddrs* ifaddr, *ifa;
getifaddrs(&ifaddr);
for (ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_INET) continue;
if (strcmp(ifa->ifa_name, "en0") != 0) continue;
inet_ntop(AF_INET, &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr, state.server_ip_address.bytes, 16);
}
freeifaddrs(ifaddr);
}
// GAME LOGIC SETUP
@@ -1393,80 +1409,58 @@ i32 main(i32 argc, ptr argv[]) {
p->commodities[iii] = (COMMODITIES[iii].qty / 5) + (rand() % COMMODITIES[iii].qty);
p->production[iii] = 1 + (rand() % COMMODITIES[iii].consumption);
}
p->commodities[CommodityHydrogenFuel] = COMMODITIES[CommodityHydrogenFuel].qty * 2;
p->commodities[CommodityOxygen] = COMMODITIES[CommodityOxygen].qty * 2;
// now, override for the "specialty" of the planet
switch (p->type) {
case PlanetTypeEarth: {
setHighProductionCommodity(p, CommodityWater);
setHighProductionCommodity(p, CommodityFertilizer);
setHighProductionCommodity(p, CommodityGrain);
setHighProductionCommodity(p, CommodityMeat);
setHighProductionCommodity(p, CommoditySpices);
setHighProductionCommodity(p, CommodityAlcohol);
setHighProductionCommodity(p, CommodityFood);
setLowProductionCommodity(p, CommodityHydrogenFuel);
setLowProductionCommodity(p, CommodityLowGradeOre);
setLowProductionCommodity(p, CommodityHighGradeOre);
setLowProductionCommodity(p, CommodityCommonMetals);
setLowProductionCommodity(p, CommodityRareMetals);
//setLowProductionCommodity(p, CommodityPreciousMetals);
setLowProductionCommodity(p, CommodityOre);
setLowProductionCommodity(p, CommodityMetals);
} break;
case PlanetTypeGas: {
// 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, CommodityOre);
setLowProductionCommodity(p, CommodityMetals);
setLowProductionCommodity(p, CommodityRawTextiles);
setLowProductionCommodity(p, CommodityGlass);
setLowProductionCommodity(p, CommodityPersonalSundries);
setLowProductionCommodity(p, CommodityHandTools);
setLowProductionCommodity(p, CommodityMeat);
} break;
case PlanetTypeMoon: {
// a lot of manufactured goods
setHighProductionCommodity(p, CommodityPersonalSundries);
setHighProductionCommodity(p, CommodityClothes);
setHighProductionCommodity(p, CommodityAlcohol);
setHighProductionCommodity(p, CommodityElectronics);
setHighProductionCommodity(p, CommodityGlass);
setLowProductionCommodity(p, CommodityHighGradeOre);
setLowProductionCommodity(p, CommodityOre);
setLowProductionCommodity(p, CommodityHydrogenFuel);
setLowProductionCommodity(p, CommodityOxygen);
setLowProductionCommodity(p, CommodityWater);
setLowProductionCommodity(p, CommodityFertilizer);
setLowProductionCommodity(p, CommodityFood);
} break;
case PlanetTypeAsteroid: {
// a lot of raw metals
setHighProductionCommodity(p, CommodityLowGradeOre);
setHighProductionCommodity(p, CommodityHighGradeOre);
setHighProductionCommodity(p, CommodityCommonMetals);
setHighProductionCommodity(p, CommodityRareMetals);
//setHighProductionCommodity(p, CommodityPreciousMetals);
setHighProductionCommodity(p, CommodityOre);
setHighProductionCommodity(p, CommodityMetals);
setHighProductionCommodity(p, CommoditySemiConductors);
setLowProductionCommodity(p, CommodityHydrogenFuel);
setLowProductionCommodity(p, CommodityOxygen);
setLowProductionCommodity(p, CommodityWater);
setLowProductionCommodity(p, CommodityFertilizer);
setLowProductionCommodity(p, CommodityPersonalSundries);
setLowProductionCommodity(p, CommodityClothes);
setLowProductionCommodity(p, CommodityFood);
setLowProductionCommodity(p, CommodityElectronics);
setLowProductionCommodity(p, CommodityPlastics);
setLowProductionCommodity(p, CommodityHandTools);
} break;
case PlanetTypeStation: {
// a lot of ??? drugs?
setHighProductionCommodity(p, CommodityAlcohol);
setHighProductionCommodity(p, CommodityPersonalSundries);
setHighProductionCommodity(p, CommodityClothes);
setHighProductionCommodity(p, CommodityElectronics);
setHighProductionCommodity(p, CommodityPlastics);
setHighProductionCommodity(p, CommodityHandTools);
@@ -1474,10 +1468,7 @@ i32 main(i32 argc, ptr argv[]) {
setLowProductionCommodity(p, CommodityHydrogenFuel);
setLowProductionCommodity(p, CommodityOxygen);
setLowProductionCommodity(p, CommodityWater);
setLowProductionCommodity(p, CommodityFertilizer);
setLowProductionCommodity(p, CommodityMeat);
setLowProductionCommodity(p, CommodityGrain);
setLowProductionCommodity(p, CommoditySpices);
setLowProductionCommodity(p, CommodityFood);
} break;
case PlanetTypeNull:
case PlanetType_Count:
+31 -98
View File
@@ -8,7 +8,7 @@
#define STARTING_DOWN_PAYMENT (10000)
#define SHIP_DETAIL_COUNT (8)
#define STAR_SYSTEM_COUNT (16)
#define MAP_WIDTH (36)
#define MAP_WIDTH (32)
#define MAP_HEIGHT (12)
#define MAX_PLANETS (3)
#define MAX_PASSENGER_JOB_OFFERS (16)
@@ -87,36 +87,19 @@ global FieldDescriptor SHIP_FIELDS[SHIP_DETAIL_COUNT] = {
{ "O2 Tank", FieldTypeU32, offsetof(ShipTemplate, cu_m_o2), 8 },
};
typedef enum EquipmentType {
EquipmentTypeAquaponicsSystem,
EquipmentType3DPrinter,
EquipmentTypeAutoTailor,
EquipmentType_Count,
} EquipmentType;
typedef enum CommodityType {
CommodityHydrogenFuel,
CommodityOxygen,
CommodityWater,
CommodityFertilizer,
CommodityFood,
CommodityRawTextiles,
CommodityLowGradeOre,
CommodityHighGradeOre,
CommodityOre,
CommodityPlastics,
CommodityGrain,
CommodityMeat,
CommoditySpices,
CommodityElectronics,
CommoditySemiConductors,
CommodityMetals,
CommodityGlass,
CommodityHandTools,
CommoditySemiConductors,
CommodityCommonMetals,
CommodityRareMetals,
// CommodityPreciousMetals,
CommodityAlcohol,
CommodityClothes,
CommodityPersonalSundries,
CommodityIndustrialChemicals,
CommodityElectronics,
Commodity_Count,
} CommodityType;
@@ -124,25 +107,15 @@ global str COMMODITY_STRINGS[Commodity_Count] = {
"Hydrogen Fuel",
"Oxygen",
"Water",
"Fertilizer",
"Food",
"Raw Textiles",
"Low Grade Ore",
"High Grade Ore",
"Ore",
"Plastics",
"Grain",
"Meat",
"Spices",
"Electronics",
"Semi-conductors",
"Metals",
"Glass",
"Hand Tools",
"Semi-conductors",//"Semi-conductors (Silicon, Arsenic, Boron)",
"Common Metals",//"Common Metals (Iron, Nickel, Zinc)",
"Rare Metals",//"Rare Metals (Titanium, Chromium)",
// "Precious Metals (Silver, Gold, Platinum)",
"Alcohol",
"Clothes",
"Personal Sundries",//"Personal Sundries (Cutlery, Toys, Misc)",
"Industrial Chemicals",
"Electronics",
};
typedef enum StorageUnit {
@@ -178,83 +151,43 @@ global Commodity COMMODITIES[Commodity_Count] = {
},
{ .type = CommodityWater, .unit = StorageUnitContainer,
.name = "Water",
.price = 700, .qty = 100, .consumption = 10,
.price = 100, .qty = 100, .consumption = 10,
},
{ .type = CommodityFertilizer, .unit = StorageUnitContainer,
.name = "Fertilizer",
.price = 1200, .qty = 70, .consumption = 10,
{ .type = CommodityFood, .unit = StorageUnitContainer,
.name = "Food",
.price = 200, .qty = 70, .consumption = 10,
},
{ .type = CommodityRawTextiles, .unit = StorageUnitContainer,
.name = "Raw Textiles",
.price = 1800, .qty = 40, .consumption = 3,
.price = 500, .qty = 40, .consumption = 3,
},
{ .type = CommodityLowGradeOre, .unit = StorageUnitContainer,
.name = "Low Grade Ore",
.price = 800, .qty = 100, .consumption = 8,
},
{ .type = CommodityHighGradeOre, .unit = StorageUnitContainer,
.name = "High Grade Ore",
.price = 1200, .qty = 10, .consumption = 2,
{ .type = CommodityOre, .unit = StorageUnitContainer,
.name = "Ore",
.price = 1000, .qty = 100, .consumption = 8,
},
{ .type = CommodityPlastics, .unit = StorageUnitContainer,
.name = "Plastics",
.price = 2000, .qty = 30, .consumption = 5,
},
{ .type = CommodityGrain, .unit = StorageUnitContainer,
.name = "Grain",
.price = 1900, .qty = 200, .consumption = 30,
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
.name = "Semi-conductors",
.price = 4000, .qty = 40, .consumption = 3,
},
{ .type = CommodityMeat, .unit = StorageUnitContainer,
.name = "Meat",
.price = 2100, .qty = 90, .consumption = 15,
},
{ .type = CommoditySpices, .unit = StorageUnitContainer,
.name = "Spices",
.price = 3900, .qty = 6, .consumption = 1,
},
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
.name = "Electronics",
.price = 9500, .qty = 40, .consumption = 6,
{ .type = CommodityMetals, .unit = StorageUnitContainer,
.name = "Metals",
.price = 5000, .qty = 40, .consumption = 3,
},
{ .type = CommodityGlass, .unit = StorageUnitContainer,
.name = "Glass",
.price = 1400, .qty = 50, .consumption = 5,
.price = 9200, .qty = 50, .consumption = 5,
},
{ .type = CommodityHandTools, .unit = StorageUnitContainer,
.name = "Hand Tools",
.price = 5000, .qty = 5, .consumption = 1,
.price = 20000, .qty = 5, .consumption = 1,
},
{ .type = CommoditySemiConductors, .unit = StorageUnitContainer,
.name = "Semi-conductors",//"Semi-conductors (Silicon, Arsenic, Boron)",
.price = 1800, .qty = 40, .consumption = 3,
},
{ .type = CommodityCommonMetals, .unit = StorageUnitContainer,
.name = "Common Metals",//"Common Metals (Iron, Nickel, Zinc)",
.price = 1800, .qty = 40, .consumption = 3,
},
{ .type = CommodityRareMetals, .unit = StorageUnitContainer,
.name = "Rare Metals",//"Rare Metals (Titanium, Chromium)",
.price = 1800, .qty = 40, .consumption = 3,
},
/* { .type = CommodityPreciousMetals, .unit = StorageUnitKg,
.name = "Precious Metals (Silver, Gold, Platinum)",
.price = 1800, .qty = 40, .consumption = 3,
},*/
{ .type = CommodityAlcohol, .unit = StorageUnitContainer,
.name = "Alcohol",
.price = 1800, .qty = 40, .consumption = 3,
},
{ .type = CommodityClothes, .unit = StorageUnitContainer,
.name = "Clothes",
.price = 1800, .qty = 40, .consumption = 3,
},
{ .type = CommodityPersonalSundries, .unit = StorageUnitContainer,
.name = "Personal Sundries",//"Personal Sundries (Cutlery, Toys, Misc)",
.price = 1800, .qty = 40, .consumption = 3,
},
{ .type = CommodityIndustrialChemicals, .unit = StorageUnitContainer,
.name = "Industrial Chemicals",
.price = 3800, .qty = 20, .consumption = 5,
{ .type = CommodityElectronics, .unit = StorageUnitContainer,
.name = "Electronics",
.price = 40000, .qty = 40, .consumption = 6,
},
};
@@ -471,7 +404,7 @@ static const char* MESSAGE_STRINGS[] = {
fn u32 fuelCostForTravel(u32 drive_efficiency, Pos2 current, Pos2 dest) {
u32 x_distance = Max(current.x, dest.x) - Min(current.x, dest.x);
u32 y_distance = Max(current.y, dest.y) - Min(current.y, dest.y);
u32 fuel_per_dist = 100 - drive_efficiency;
u32 fuel_per_dist = 100 - drive_efficiency*10;
return (x_distance + y_distance) * fuel_per_dist;
}