diff --git a/port/include/input.h b/port/include/input.h index 4eb357a6a..8d8e63c9b 100644 --- a/port/include/input.h +++ b/port/include/input.h @@ -35,8 +35,12 @@ enum virtkey { VK_GRAVE = 53, VK_COMMA = 54, VK_PERIOD = 55, + VK_F1 = 58, + VK_F9 = 66, VK_DELETE = 76, + VK_LCTRL = 224, VK_LSHIFT = 225, + VK_RCTRL = 228, VK_RSHIFT = 229, /* same order as SDL mouse buttons */ @@ -221,6 +225,9 @@ void inputStopTextInput(void); void inputClearLastTextChar(void); char inputGetLastTextChar(void); +void inputClearClipboard(void); +const char *inputGetClipboard(void); + // get/set Input.MouseDefaultLocked s32 inputGetMouseDefaultLocked(void); void inputSetMouseDefaultLocked(s32 defaultLocked); diff --git a/port/include/net/net.h b/port/include/net/net.h index b6a513d22..b8e3258b0 100644 --- a/port/include/net/net.h +++ b/port/include/net/net.h @@ -98,10 +98,9 @@ extern s32 g_NetMode; // net frame, ticks at 60 fps, starts at 0 when the server is started extern u32 g_NetTick; - extern u32 g_NetInterpTicks; - extern u32 g_NetNextSyncId; +extern s32 g_NetDebugDraw; extern s32 g_NetMaxClients; extern s32 g_NetNumClients; @@ -131,4 +130,6 @@ void netServerStageEnd(void); void netPlayersAllocate(void); void netSyncIdsAllocate(void); +Gfx *netDebugRender(Gfx *gdl); + #endif // _IN_NET_H diff --git a/port/src/input.c b/port/src/input.c index c5c17e283..4905fa5ed 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -84,6 +84,8 @@ static s32 lastKey = 0; static char lastChar = 0; static s32 textInput = 0; +static char *clipboardText = NULL; + static const char *ckNames[CK_TOTAL_COUNT] = { "R_CBUTTONS", "L_CBUTTONS", @@ -1281,6 +1283,25 @@ char inputGetLastTextChar(void) return lastChar; } +void inputClearClipboard(void) +{ + if (clipboardText) { + SDL_free(clipboardText); + clipboardText = NULL; + } +} + +const char *inputGetClipboard(void) +{ + if (!clipboardText) { + char *text = SDL_GetClipboardText(); + if (text) { + clipboardText = text; + } + } + return clipboardText; +} + void inputStopTextInput(void) { SDL_StopTextInput(); diff --git a/port/src/net/net.c b/port/src/net/net.c index 94cf71fb2..7f86418d3 100644 --- a/port/src/net/net.c +++ b/port/src/net/net.c @@ -14,7 +14,9 @@ #include "game/hudmsg.h" #include "game/playermgr.h" #include "game/bondgun.h" +#include "game/game_1531a0.h" #include "lib/main.h" +#include "lib/vi.h" #include "config.h" #include "system.h" #include "console.h" @@ -23,13 +25,13 @@ s32 g_NetMode = NETMODE_NONE; u32 g_NetTick = 0; - u32 g_NetInterpTicks = 6; -s32 g_NetSimPacketLoss = 0; - u32 g_NetNextSyncId = 1; +s32 g_NetSimPacketLoss = 0; +s32 g_NetDebugDraw = 0; + s32 g_NetMaxClients = NET_MAX_CLIENTS; s32 g_NetNumClients = 0; struct netclient g_NetClients[NET_MAX_CLIENTS + 1]; // last is an extra temporary client @@ -760,3 +762,27 @@ void netChat(const char *text) netmsgClcChatWrite(&g_NetMsgRel, tmp); } } + +Gfx *netDebugRender(Gfx *gdl) +{ + char tmp[256]; + + if (!g_NetMode || !g_NetDebugDraw) { + return gdl; + } + + gdl = text0f153628(gdl); + gSPSetExtraGeometryModeEXT(gdl++, G_ASPECT_LEFT_EXT); + + s32 x = 2; + s32 y = viGetHeight() - 1 - 4*8; + snprintf(tmp, sizeof(tmp), "Nettick: %u\nPing: %u\nSent: %u\nRecv: %u\n", + g_NetTick, g_NetLocalClient->peer ? enet_peer_get_rtt(g_NetLocalClient->peer) : 0, + enet_host_get_bytes_sent(g_NetHost), enet_host_get_bytes_received(g_NetHost)); + gdl = textRenderProjected(gdl, &x, &y, tmp, g_CharsHandelGothicXs, g_FontHandelGothicXs, 0x00ff00ff, viGetWidth(), viGetHeight(), 0, 0); + + gSPClearExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT); + gdl = text0f153780(gdl); + + return gdl; +} diff --git a/port/src/net/netmenu.c b/port/src/net/netmenu.c index 2ad41666c..560014004 100644 --- a/port/src/net/netmenu.c +++ b/port/src/net/netmenu.c @@ -239,7 +239,15 @@ static MenuItemHandlerResult menuhandlerEnterJoinAddress(s32 operation, struct m break; } - if (chr && g_NetJoinAddrPtr < sizeof(g_NetJoinAddr) - 1) { + if (chr == 'v' && (inputKeyPressed(VK_LCTRL) || inputKeyPressed(VK_RCTRL))) { + // try to paste in from clipboard + const char *clip = inputGetClipboard(); + if (clip) { + strncpy(g_NetJoinAddr, clip, sizeof(g_NetJoinAddr) - 1); + g_NetJoinAddrPtr = strlen(g_NetJoinAddr); + inputClearClipboard(); + } + } else if (chr && g_NetJoinAddrPtr < sizeof(g_NetJoinAddr) - 1) { g_NetJoinAddr[g_NetJoinAddrPtr++] = chr; g_NetJoinAddr[g_NetJoinAddrPtr + 1] = '\0'; } diff --git a/port/src/pdmain.c b/port/src/pdmain.c index 1376df5a6..9d2812748 100644 --- a/port/src/pdmain.c +++ b/port/src/pdmain.c @@ -561,6 +561,7 @@ void mainTick(void) } gdl = conRender(gdl); + gdl = netDebugRender(gdl); gDPFullSync(gdl++); gSPEndDisplayList(gdl++); diff --git a/port/src/pdsched.c b/port/src/pdsched.c index 19f32cbd1..02c4f4240 100644 --- a/port/src/pdsched.c +++ b/port/src/pdsched.c @@ -242,7 +242,9 @@ void schedSubmitTask(OSSched *sc, OSScTask *t) void schedStartFrame(OSSched *sc) { videoStartFrame(); - netStartFrame(); + if (g_Vars.diffframe60) { + netStartFrame(); + } } void schedAudioFrame(OSSched *sc) @@ -273,6 +275,8 @@ void schedAudioFrame(OSSched *sc) */ void schedEndFrame(OSSched *sc) { + static bool netDebugKey = false; + sc->frameCount++; #if PAL @@ -294,11 +298,19 @@ void schedEndFrame(OSSched *sc) inputUpdate(); conTick(); + const bool newKey = inputKeyPressed(VK_F9); + if (!netDebugKey && newKey) { + g_NetDebugDraw = !g_NetDebugDraw; + } + netDebugKey = newKey; + joyStartReadData(&g_PiMesgQueue); joyReadData(); joy00014238(); - netEndFrame(); + if (g_Vars.diffframe60) { + netEndFrame(); + } sndHandleRetrace(); schedAudioFrame(sc); diff --git a/src/game/bondgun.c b/src/game/bondgun.c index d3c50f626..5b63db77e 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -58,7 +58,6 @@ #include "video.h" #include "net/net.h" #include "net/netmsg.h" -#include "system.h" #endif #define GUNLOADSTATE_FLUX 0 @@ -11847,8 +11846,6 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac g_Vars.currentplayer->hands[HAND_RIGHT].activatesecondary = true; } - sysLogPrintf(LOG_NOTE, "switchan %d -> %d", bgunIsUsingSecondaryFunction(), fromdedicatedbutton); - return USETIMER_STOP; case WEAPON_MAULER: case WEAPON_CMP150: