better logging + fix re-login bug + fix some modal bugs
This commit is contained in:
+20
-6
@@ -465,6 +465,9 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
state->ship_tab_states = ShipTabStateMain;
|
||||
} break;
|
||||
case MessageTurnTick: {
|
||||
MemoryZero(sbuf, SBUFLEN);
|
||||
sprintf(sbuf,"got TurnTick message from server %lld", loop_count);
|
||||
addSystemMessage((u8*)sbuf);
|
||||
state->screen = ScreenTurnTick;
|
||||
state->turn_tick_started_on = loop_count;
|
||||
} break;
|
||||
@@ -473,6 +476,9 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
MemoryCopyStruct(&state->tx_result, &msg.tx_result);
|
||||
} break;
|
||||
case MessagePlayerDetails: {
|
||||
MemoryZero(sbuf, SBUFLEN);
|
||||
sprintf(sbuf,"got player details for: %lld (%s us)", msg.ship.id, msg.ship.id == state->me.id ? "it's" : "not");
|
||||
addSystemMessage((u8*)sbuf);
|
||||
if (msg.ship.id == state->me.id) {
|
||||
state->me.type = msg.ship.type;
|
||||
state->me.system_idx = msg.ship.system_idx;
|
||||
@@ -495,6 +501,9 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
}
|
||||
} break;
|
||||
case MessageStarPositions: {
|
||||
MemoryZero(sbuf, SBUFLEN);
|
||||
sprintf(sbuf,"got StarPositions message from server");
|
||||
addSystemMessage((u8*)sbuf);
|
||||
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||
state->map[i].name = STAR_NAMES[i];
|
||||
state->map[i].x = msg.positions[i].x;
|
||||
@@ -521,11 +530,12 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
} break;
|
||||
case MessageCharacterId: {
|
||||
state->me.id = msg.id;
|
||||
char bytes[256] = {0};
|
||||
sprintf(bytes,"got character id: %lld", msg.id);
|
||||
addSystemMessage((u8*)bytes);
|
||||
MemoryZero(sbuf, SBUFLEN);
|
||||
sprintf(sbuf,"got character id: %lld", msg.id);
|
||||
addSystemMessage((u8*)sbuf);
|
||||
state->screen = ScreenMainGame;
|
||||
state->menu.selected_index = 0;
|
||||
state->menu.selected_index = TabMap;
|
||||
state->menu.len = Tab_Count;
|
||||
state->row.selected_index = 0;
|
||||
} break;
|
||||
case Message_Count:
|
||||
@@ -572,7 +582,7 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
//// SIMULATION
|
||||
if (state->me.id != 0) {
|
||||
state->screen = ScreenMainGame;
|
||||
state->menu.selected_index = 0;
|
||||
state->menu.selected_index = TabMap;
|
||||
state->menu.len = Tab_Count;
|
||||
break;
|
||||
}
|
||||
@@ -846,11 +856,12 @@ 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);
|
||||
}
|
||||
|
||||
u32 yoff = box.y+1;
|
||||
MemoryZero(sbuf, SBUFLEN);
|
||||
@@ -933,6 +944,9 @@ fn bool updateAndRender(TuiState* tui, void* s, u8* input_buffer, u64 loop_count
|
||||
};
|
||||
u32 y_off = modal_outline.y+2;
|
||||
if (state->ship_tab_states == ShipTabStatePayoffModal) {
|
||||
if (input_buffer[0] == 'q' || user_pressed_esc) {
|
||||
state->ship_tab_states = ShipTabStateMain;
|
||||
}
|
||||
if (user_pressed_a_number) {
|
||||
String next_char = { 1, 2, (char*)input_buffer };
|
||||
stringChunkListAppend(&state->string_arena, &state->message_input, next_char);
|
||||
|
||||
+3
-3
@@ -129,12 +129,12 @@ fn void copyStr(u8* bytes, str cstring) {
|
||||
}
|
||||
|
||||
fn void clearBox(TuiState* tui, Box box) {
|
||||
for (u32 i = 0; i < box.height; i++) {
|
||||
for (u32 ii = 0; ii < box.width; ii++) {
|
||||
for (u32 i = 0; i <= box.height; i++) {
|
||||
for (u32 ii = 0; ii <= box.width; ii++) {
|
||||
u32 pos = XYToPos(box.x+ii, box.y+i, tui->screen_dimensions.width);
|
||||
tui->frame_buffer[pos].background = 0;
|
||||
tui->frame_buffer[pos].foreground = 0;
|
||||
tui->frame_buffer[pos].bytes[0] = 0;
|
||||
tui->frame_buffer[pos].bytes[0] = ' ';
|
||||
tui->frame_buffer[pos].bytes[1] = 0;
|
||||
tui->frame_buffer[pos].bytes[2] = 0;
|
||||
tui->frame_buffer[pos].bytes[3] = 0;
|
||||
|
||||
+21
-14
@@ -300,6 +300,24 @@ fn void sendMessagePayoffResult(SocketAddress addr) {
|
||||
printf("%s sent\n", MESSAGE_STRINGS[outgoing_message.bytes[0]]);
|
||||
}
|
||||
|
||||
fn void sendMessageStarPositions(SocketAddress addr) {
|
||||
UDPMessage outgoing_message = {0};
|
||||
outgoing_message.address = addr;
|
||||
// tell the client about the map
|
||||
u32 star_msg_size = 2+MAX_PLANETS;
|
||||
outgoing_message.bytes_len = 1+(star_msg_size*STAR_SYSTEM_COUNT);
|
||||
outgoing_message.bytes[0] = (u8)MessageStarPositions;
|
||||
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||
outgoing_message.bytes[1+(i*star_msg_size)] = (u8)state.map[i].x;
|
||||
outgoing_message.bytes[2+(i*star_msg_size)] = (u8)state.map[i].y;
|
||||
for (u32 ii = 0; ii < MAX_PLANETS; ii++) {
|
||||
outgoing_message.bytes[3+ii+(i*star_msg_size)] = state.map[i].planets[ii].type;
|
||||
}
|
||||
}
|
||||
outgoingMessageQueuePush(state.network_send_queue, &outgoing_message);
|
||||
printf("%s sent\n", MESSAGE_STRINGS[outgoing_message.bytes[0]]);
|
||||
}
|
||||
|
||||
fn void sendMessagePlayerDetails(PlayerShip ship, SocketAddress addr) {
|
||||
UDPMessage outgoing_message = makeMessagePlayerDetails(ship);
|
||||
outgoing_message.address = addr;
|
||||
@@ -643,6 +661,8 @@ fn void* gameLoop(void* params) {
|
||||
arenaDealloc(&permanent_arena, name.capacity);
|
||||
if (pw_matches) {
|
||||
printf(" pw matched\n");
|
||||
existing_account->changed = true;
|
||||
sendMessageStarPositions(sender);
|
||||
} else {
|
||||
// tell the client they did a bad pw
|
||||
outgoing_message.bytes[0] = (u8)MessageBadPw;
|
||||
@@ -723,20 +743,7 @@ fn void* gameLoop(void* params) {
|
||||
|
||||
sendMessagePlayerDetails(account->ship, sender);
|
||||
|
||||
// tell the client about the map
|
||||
u32 star_msg_size = 2+MAX_PLANETS;
|
||||
outgoing_message.address = sender;
|
||||
outgoing_message.bytes_len = 1+(star_msg_size*STAR_SYSTEM_COUNT);
|
||||
outgoing_message.bytes[0] = (u8)MessageStarPositions;
|
||||
for (u32 i = 0; i < STAR_SYSTEM_COUNT; i++) {
|
||||
outgoing_message.bytes[1+(i*star_msg_size)] = (u8)state.map[i].x;
|
||||
outgoing_message.bytes[2+(i*star_msg_size)] = (u8)state.map[i].y;
|
||||
for (u32 ii = 0; ii < MAX_PLANETS; ii++) {
|
||||
outgoing_message.bytes[3+ii+(i*star_msg_size)] = state.map[i].planets[ii].type;
|
||||
}
|
||||
}
|
||||
outgoingMessageQueuePush(state.network_send_queue, &outgoing_message);
|
||||
printf("%s sent\n", MESSAGE_STRINGS[outgoing_message.bytes[0]]);
|
||||
sendMessageStarPositions(sender);
|
||||
|
||||
outgoing_message = makeMessageSystemCommodities(&starting_system);
|
||||
outgoing_message.address = sender;
|
||||
|
||||
Reference in New Issue
Block a user