mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
Add packet debug sync to make debugging sync ids easier
This commit is contained in:
parent
d6150c0b0d
commit
a081327ef1
6 changed files with 84 additions and 2 deletions
|
@ -4009,6 +4009,7 @@
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_area.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_area.c" />
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_area_request.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_area_request.c" />
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_change_area.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_change_area.c" />
|
||||||
|
<ClCompile Include="..\src\pc\network\packets\packet_debug_sync.c" />
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_level.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_level.c" />
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_level_area_inform.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_level_area_inform.c" />
|
||||||
<ClCompile Include="..\src\pc\network\packets\packet_level_request.c" />
|
<ClCompile Include="..\src\pc\network\packets\packet_level_request.c" />
|
||||||
|
|
|
@ -15285,6 +15285,9 @@
|
||||||
<ClCompile Include="..\actors\custom0_geo.c">
|
<ClCompile Include="..\actors\custom0_geo.c">
|
||||||
<Filter>Source Files\actors</Filter>
|
<Filter>Source Files\actors</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\pc\network\packets\packet_debug_sync.c">
|
||||||
|
<Filter>Source Files\src\pc\network\packets</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\actors\common0.h">
|
<ClCompile Include="..\actors\common0.h">
|
||||||
|
|
|
@ -45,7 +45,7 @@ void packet_process(struct Packet* p) {
|
||||||
case PACKET_COLLECT_COIN: network_receive_collect_coin(p); break;
|
case PACKET_COLLECT_COIN: network_receive_collect_coin(p); break;
|
||||||
case PACKET_COLLECT_ITEM: network_receive_collect_item(p); break;
|
case PACKET_COLLECT_ITEM: network_receive_collect_item(p); break;
|
||||||
case PACKET_UNUSED1: break;
|
case PACKET_UNUSED1: break;
|
||||||
case PACKET_UNUSED2: break;
|
case PACKET_DEBUG_SYNC: network_receive_debug_sync(p); break;
|
||||||
case PACKET_JOIN_REQUEST: network_receive_join_request(p); break;
|
case PACKET_JOIN_REQUEST: network_receive_join_request(p); break;
|
||||||
case PACKET_JOIN: network_receive_join(p); break;
|
case PACKET_JOIN: network_receive_join(p); break;
|
||||||
case PACKET_CHAT: network_receive_chat(p); break;
|
case PACKET_CHAT: network_receive_chat(p); break;
|
||||||
|
|
|
@ -23,7 +23,7 @@ enum PacketType {
|
||||||
PACKET_COLLECT_COIN,
|
PACKET_COLLECT_COIN,
|
||||||
PACKET_COLLECT_ITEM,
|
PACKET_COLLECT_ITEM,
|
||||||
PACKET_UNUSED1,
|
PACKET_UNUSED1,
|
||||||
PACKET_UNUSED2,
|
PACKET_DEBUG_SYNC,
|
||||||
PACKET_JOIN_REQUEST,
|
PACKET_JOIN_REQUEST,
|
||||||
PACKET_JOIN,
|
PACKET_JOIN,
|
||||||
PACKET_CHAT,
|
PACKET_CHAT,
|
||||||
|
@ -271,4 +271,8 @@ void network_receive_reservation_use(struct Packet* p);
|
||||||
void network_send_reservation_release(u8 syncId);
|
void network_send_reservation_release(u8 syncId);
|
||||||
void network_receive_reservation_release(struct Packet* p);
|
void network_receive_reservation_release(struct Packet* p);
|
||||||
|
|
||||||
|
// packet_debug_sync.c
|
||||||
|
void network_send_debug_sync(void);
|
||||||
|
void network_receive_debug_sync(struct Packet* p);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
66
src/pc/network/packets/packet_debug_sync.c
Normal file
66
src/pc/network/packets/packet_debug_sync.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#include "../network.h"
|
||||||
|
#include "behavior_table.h"
|
||||||
|
#include "pc/debuglog.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(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_send_debug_sync(void) {
|
||||||
|
u8 objectCount = 0;
|
||||||
|
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
|
if (gSyncObjects[i].o == NULL) { continue; }
|
||||||
|
objectCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Packet p;
|
||||||
|
packet_init(&p, PACKET_DEBUG_SYNC, true, PLMT_AREA);
|
||||||
|
packet_write(&p, &objectCount, sizeof(u8));
|
||||||
|
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
|
if (gSyncObjects[i].o == NULL) { continue; }
|
||||||
|
u16 behaviorId = get_id_from_behavior(gSyncObjects[i].behavior);
|
||||||
|
packet_write(&p, &i, sizeof(u8));
|
||||||
|
packet_write(&p, &behaviorId, sizeof(u16));
|
||||||
|
}
|
||||||
|
network_send(&p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_receive_debug_sync(struct Packet* p) {
|
||||||
|
u8 objectCount = 0;
|
||||||
|
u16 remoteBehaviorIds[MAX_SYNC_OBJECTS] = { 0 };
|
||||||
|
|
||||||
|
packet_read(p, &objectCount, sizeof(u8));
|
||||||
|
for (int i = 0; i < objectCount; i++) {
|
||||||
|
u8 j;
|
||||||
|
u16 behaviorId;
|
||||||
|
packet_read(p, &j, sizeof(u8));
|
||||||
|
packet_read(p, &behaviorId, sizeof(u16));
|
||||||
|
remoteBehaviorIds[j] = behaviorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasMismatch = false;
|
||||||
|
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
|
u16 localBehaviorId = (gSyncObjects[i].o == NULL) ? 0 : get_id_from_behavior(gSyncObjects[i].behavior);
|
||||||
|
u16 remoteBehaviorId = remoteBehaviorIds[i];
|
||||||
|
if (localBehaviorId != remoteBehaviorId) {
|
||||||
|
hasMismatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasMismatch) { return; }
|
||||||
|
|
||||||
|
LOG_INFO(" ");
|
||||||
|
LOG_INFO("Sync Object Table Mismatch");
|
||||||
|
for (int i = 0; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
|
u16 localBehaviorId = (gSyncObjects[i].o == NULL) ? 0 : get_id_from_behavior(gSyncObjects[i].behavior);
|
||||||
|
u16 remoteBehaviorId = remoteBehaviorIds[i];
|
||||||
|
if (localBehaviorId == 0 && remoteBehaviorId == 0) { continue; }
|
||||||
|
LOG_INFO("%03d: %04X %04X %s", i, localBehaviorId, remoteBehaviorId, (localBehaviorId == remoteBehaviorId) ? " " : "<<<");
|
||||||
|
}
|
||||||
|
}
|
|
@ -630,6 +630,14 @@ void network_update_objects(void) {
|
||||||
network_delayed_packet_object_execute();
|
network_delayed_packet_object_execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEVELOPMENT
|
||||||
|
static f32 lastDebugSync = 0;
|
||||||
|
if (clock_elapsed() - lastDebugSync >= 1) {
|
||||||
|
network_send_debug_sync();
|
||||||
|
lastDebugSync = clock_elapsed();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (u32 i = 1; i < MAX_SYNC_OBJECTS; i++) {
|
for (u32 i = 1; i < MAX_SYNC_OBJECTS; i++) {
|
||||||
struct SyncObject* so = &gSyncObjects[i];
|
struct SyncObject* so = &gSyncObjects[i];
|
||||||
if (so->o == NULL) { continue; }
|
if (so->o == NULL) { continue; }
|
||||||
|
|
Loading…
Reference in a new issue