From 4007788cf152a6df2d82c3b34a091600f6d348af Mon Sep 17 00:00:00 2001 From: Tenari Date: Fri, 20 Mar 2026 08:01:59 -0500 Subject: [PATCH] more tweaks --- src/client.c | 3 ++- src/server.c | 26 ++++++++++++++++++++++++-- src/shared.h | 8 ++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/client.c b/src/client.c index e6cb0a9..ed04fdd 100644 --- a/src/client.c +++ b/src/client.c @@ -379,7 +379,8 @@ fn void handleIncomingMessage(u8* message, u32 len, SocketAddress sender, i32 so u32 planet_count = message[msg_pos++]; for (u32 i = 0; i < planet_count; i++) { for (u32 ii = 0; ii < Commodity_Count; ii++) { - parsed.sys.planets[i].commodities[ii] = message[msg_pos++]; + parsed.sys.planets[i].commodities[ii] = readU32FromBufferLE(message + msg_pos); + msg_pos += 4; } } } break; diff --git a/src/server.c b/src/server.c index a9cc386..0b78ff1 100644 --- a/src/server.c +++ b/src/server.c @@ -312,7 +312,7 @@ fn UDPMessage makeMessageSystemCommodities(StarSystem* sys) { outgoing_message.bytes[msg_i++] = (u8)planet_count; for (u32 i = 0; i < planet_count; i++) { for (u32 ii = 0; ii < Commodity_Count; ii++) { - outgoing_message.bytes[msg_i++] = sys->planets[i].commodities[ii]; + msg_i += writeU32ToBufferLE(outgoing_message.bytes + msg_i, sys->planets[i].commodities[ii]); } } outgoing_message.bytes_len = msg_i; @@ -901,7 +901,7 @@ fn void* gameLoop(void* params) { .base_cost = template.base_cost, .remaining_mortgage = template.base_cost - STARTING_DOWN_PAYMENT, .interest_rate = calcInterestRate(template.base_cost, STARTING_DOWN_PAYMENT), - .credits = 10000.0, + .credits = 2000.0, .cu_m_fuel = template.cu_m_fuel, .cu_m_o2 = template.cu_m_o2, .id = account->id, @@ -1152,11 +1152,17 @@ fn void* gameLoop(void* params) { 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); + if (t == CommodityHydrogenFuel || t == CommodityOxygen) { + p->commodities[t] = COMMODITIES[t].qty * 2; + } } fn void setLowProductionCommodity(Planet* p, CommodityType t) { p->commodities[t] = rand() % (COMMODITIES[t].qty / 2); p->production[t] = rand() % (COMMODITIES[t].consumption / 2); + if (t == CommodityHydrogenFuel || t == CommodityOxygen) { + p->commodities[t] = COMMODITIES[t].qty; + } } fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count) { @@ -1399,6 +1405,7 @@ i32 main(i32 argc, ptr argv[]) { } // now, build out the commodity info and passenger jobs for the systems + char sbuf[SBUFLEN] = {0}; for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) { u32 planet_count = rand() % MAX_PLANETS + 1; for (u32 ii = 0; ii < planet_count; ii++) { @@ -1409,6 +1416,7 @@ 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); } + // everyone starts with "a lot" of fuel and o2 p->commodities[CommodityHydrogenFuel] = COMMODITIES[CommodityHydrogenFuel].qty * 2; p->commodities[CommodityOxygen] = COMMODITIES[CommodityOxygen].qty * 2; // now, override for the "specialty" of the planet @@ -1476,6 +1484,20 @@ i32 main(i32 argc, ptr argv[]) { } } + MemoryZero(sbuf, SBUFLEN); + sprintf( + sbuf, + "%s: fuel: %d o2: %d", + STAR_NAMES[i], + state.map[i].planets[0].commodities[CommodityHydrogenFuel] + + state.map[i].planets[1].commodities[CommodityHydrogenFuel] + + state.map[i].planets[2].commodities[CommodityHydrogenFuel], + state.map[i].planets[0].commodities[CommodityOxygen] + + state.map[i].planets[1].commodities[CommodityOxygen] + + state.map[i].planets[2].commodities[CommodityOxygen] + ); + addSystemMessage((u8*)sbuf); + u32 planet_divisor = ((MAX_PLANETS - planet_count)+1); u32 offer_count = 1 + (rand() % (MAX_PASSENGER_JOB_OFFERS / planet_divisor)); for (u32 ii = 0; ii < offer_count; ii++) { diff --git a/src/shared.h b/src/shared.h index 9fe0950..8b60b1c 100644 --- a/src/shared.h +++ b/src/shared.h @@ -58,14 +58,14 @@ global ShipTemplate SHIPS[] = { .vacuum_cargo_slots = 6, .climate_cargo_slots = 0, .passenger_berths = 1, .passenger_amenities_flags = 0, .smugglers_hold_cu_m = 0, .base_cost = 150000, - .cu_m_fuel = 2000, .cu_m_o2 = 2000, + .cu_m_fuel = 2000, .cu_m_o2 = 1500, }, { .type = ShipHaulerPrimeZ1, .drive_efficiency = 5, .life_support_efficiency = 2, .vacuum_cargo_slots = 30, .climate_cargo_slots = 0, .passenger_berths = 0, .passenger_amenities_flags = 0, - .smugglers_hold_cu_m = 0, .base_cost = 250000, - .cu_m_fuel = 2500, .cu_m_o2 = 1000, + .smugglers_hold_cu_m = 0, .base_cost = 275000, + .cu_m_fuel = 2500, .cu_m_o2 = 800, }, { .type = ShipNX400, .drive_efficiency = 6, .life_support_efficiency = 5, @@ -147,7 +147,7 @@ global Commodity COMMODITIES[Commodity_Count] = { }, { .type = CommodityOxygen, .unit = StorageUnitKg, .name = "Oxygen", - .price = 5, .qty = 10000, .consumption = 100, + .price = 5, .qty = 5000, .consumption = 80, }, { .type = CommodityWater, .unit = StorageUnitContainer, .name = "Water",