forked from Ports/perfect_dark
port: net: add net debug info, add copypaste support to IP input
This commit is contained in:
1 parent
02329b64a1
commit
d2ffd73dea
8 files changed
+84
-11
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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();
|
||||
|
||||
+29
-3
@@ -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;
|
||||
}
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -561,6 +561,7 @@ void mainTick(void)
|
||||
}
|
||||
|
||||
gdl = conRender(gdl);
|
||||
gdl = netDebugRender(gdl);
|
||||
|
||||
gDPFullSync(gdl++);
|
||||
gSPEndDisplayList(gdl++);
|
||||
|
||||
+14
-2
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user