Added a way to debug sync object tables through chat

This commit is contained in:
MysterD 2020-10-14 20:33:23 -07:00
parent 08183e3712
commit 8f59d20024
1 changed files with 25 additions and 0 deletions

View File

@ -1,6 +1,21 @@
#include <stdio.h> #include <stdio.h>
#include "../network.h" #include "../network.h"
#include "game/chat.h" #include "game/chat.h"
#include "pc/debuglog.h"
#ifdef DEVELOPMENT
#include "behavior_table.h"
static void print_sync_object_table(void) {
LOG_INFO("Sync Object Table");
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
if (gSyncObjects[i].o == NULL) { continue; }
u16 behaviorId = get_id_from_behavior(gSyncObjects[i].behavior);
LOG_INFO("%03d: %04X", i, behaviorId);
}
LOG_INFO(" ");
}
#endif
void network_send_chat(char* message) { void network_send_chat(char* message) {
u16 messageLength = strlen(message); u16 messageLength = strlen(message);
@ -9,6 +24,11 @@ void network_send_chat(char* message) {
packet_write(&p, &messageLength, sizeof(u16)); packet_write(&p, &messageLength, sizeof(u16));
packet_write(&p, message, messageLength * sizeof(u8)); packet_write(&p, message, messageLength * sizeof(u8));
network_send(&p); network_send(&p);
LOG_INFO("tx chat: %s", message);
#ifdef DEVELOPMENT
print_sync_object_table();
#endif
} }
void network_receive_chat(struct Packet* p) { void network_receive_chat(struct Packet* p) {
@ -21,4 +41,9 @@ void network_receive_chat(struct Packet* p) {
// add the message // add the message
chat_add_message(remoteMessage, CMT_REMOTE); chat_add_message(remoteMessage, CMT_REMOTE);
LOG_INFO("rx chat: %s", remoteMessage);
#ifdef DEVELOPMENT
print_sync_object_table();
#endif
} }