forked from Ports/perfect_dark
port: net: add command line arguments for quick hosting and joining
This commit is contained in:
1 parent
c2d09135f7
commit
33f6d643be
4 files changed
+45
-4
No files matched your search
@@ -105,6 +105,9 @@ struct netclient {
|
|||||||
|
|
||||||
extern s32 g_NetMode;
|
extern s32 g_NetMode;
|
||||||
|
|
||||||
|
extern s32 g_NetJoinLatch;
|
||||||
|
extern s32 g_NetHostLatch;
|
||||||
|
|
||||||
// net frame, ticks at 60 fps, starts at 0 when the server is started
|
// net frame, ticks at 60 fps, starts at 0 when the server is started
|
||||||
extern u32 g_NetTick;
|
extern u32 g_NetTick;
|
||||||
extern u32 g_NetNextSyncId;
|
extern u32 g_NetNextSyncId;
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
s32 g_NetMode = NETMODE_NONE;
|
s32 g_NetMode = NETMODE_NONE;
|
||||||
|
|
||||||
|
s32 g_NetHostLatch = false;
|
||||||
|
s32 g_NetJoinLatch = false;
|
||||||
|
|
||||||
u32 g_NetServerUpdateRate = 1;
|
u32 g_NetServerUpdateRate = 1;
|
||||||
u32 g_NetServerInRate = 128 * 1024;
|
u32 g_NetServerInRate = 128 * 1024;
|
||||||
u32 g_NetServerOutRate = 128 * 1024;
|
u32 g_NetServerOutRate = 128 * 1024;
|
||||||
@@ -334,6 +337,26 @@ void netInit(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const s32 argmaxclients = sysArgGetInt("--maxclients", -1);
|
||||||
|
if (argmaxclients > 0) {
|
||||||
|
g_NetMaxClients = argmaxclients;
|
||||||
|
}
|
||||||
|
|
||||||
|
const s32 argport = sysArgGetInt("--port", -1);
|
||||||
|
if (argport > 0 && argport < 0x10000) {
|
||||||
|
g_NetServerPort = argport;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *argjoin = sysArgGetString("--connect");
|
||||||
|
if (argjoin) {
|
||||||
|
strncpy(g_NetLastJoinAddr, argjoin, sizeof(g_NetLastJoinAddr) - 1);
|
||||||
|
g_NetJoinLatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysArgCheck("--host")) {
|
||||||
|
g_NetHostLatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
g_NetInit = true;
|
g_NetInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ static char *menuhandlerHostPortValue(struct menuitem *item)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MenuItemHandlerResult menuhandlerHostStart(s32 operation, struct menuitem *item, union handlerdata *data)
|
MenuItemHandlerResult menuhandlerHostStart(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||||
{
|
{
|
||||||
if (operation == MENUOP_SET) {
|
if (operation == MENUOP_SET) {
|
||||||
if (netStartServer(g_NetMenuPort, g_NetMenuMaxPlayers) == 0) {
|
if (netStartServer(g_NetMenuPort, g_NetMenuMaxPlayers) == 0) {
|
||||||
@@ -292,7 +292,7 @@ static MenuItemHandlerResult menuhandlerJoinAddress(s32 operation, struct menuit
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MenuItemHandlerResult menuhandlerJoinStart(s32 operation, struct menuitem *item, union handlerdata *data)
|
MenuItemHandlerResult menuhandlerJoinStart(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||||
{
|
{
|
||||||
if (operation == MENUOP_SET) {
|
if (operation == MENUOP_SET) {
|
||||||
if (netStartClient(g_NetJoinAddr) == 0) {
|
if (netStartClient(g_NetJoinAddr) == 0) {
|
||||||
@@ -350,7 +350,7 @@ struct menudialogdef g_NetJoinMenuDialog = {
|
|||||||
|
|
||||||
/* main */
|
/* main */
|
||||||
|
|
||||||
static MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem *item, union handlerdata *data)
|
MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||||
{
|
{
|
||||||
if (operation == MENUOP_SET) {
|
if (operation == MENUOP_SET) {
|
||||||
g_NetMenuPort = g_NetServerPort;
|
g_NetMenuPort = g_NetServerPort;
|
||||||
@@ -360,7 +360,7 @@ static MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MenuItemHandlerResult menuhandlerJoinGame(s32 operation, struct menuitem *item, union handlerdata *data)
|
MenuItemHandlerResult menuhandlerJoinGame(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||||
{
|
{
|
||||||
if (operation == MENUOP_SET) {
|
if (operation == MENUOP_SET) {
|
||||||
if (g_NetJoinAddr[0] == '\0') {
|
if (g_NetJoinAddr[0] == '\0') {
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ struct menudialogdef g_CinemaMenuDialog;
|
|||||||
#ifndef PLATFORM_N64
|
#ifndef PLATFORM_N64
|
||||||
extern struct menudialogdef g_ExtendedMenuDialog;
|
extern struct menudialogdef g_ExtendedMenuDialog;
|
||||||
extern struct menudialogdef g_NetMenuDialog;
|
extern struct menudialogdef g_NetMenuDialog;
|
||||||
|
extern MenuItemHandlerResult menuhandlerJoinGame(s32 operation, struct menuitem *item, union handlerdata *data);
|
||||||
|
extern MenuItemHandlerResult menuhandlerJoinStart(s32 operation, struct menuitem *item, union handlerdata *data);
|
||||||
|
extern MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem *item, union handlerdata *data);
|
||||||
|
extern MenuItemHandlerResult menuhandlerHostStart(s32 operation, struct menuitem *item, union handlerdata *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *menuTextCurrentStageName(struct menuitem *item)
|
char *menuTextCurrentStageName(struct menuitem *item)
|
||||||
@@ -4881,6 +4885,17 @@ MenuDialogHandlerResult menudialogMainMenu(s32 operation, struct menudialogdef *
|
|||||||
g_MissionConfig.iscoop = false;
|
g_MissionConfig.iscoop = false;
|
||||||
g_MissionConfig.isanti = false;
|
g_MissionConfig.isanti = false;
|
||||||
}
|
}
|
||||||
|
#ifndef PLATFORM_N64
|
||||||
|
if (g_NetJoinLatch) {
|
||||||
|
menuhandlerJoinGame(MENUOP_SET, NULL, NULL);
|
||||||
|
menuhandlerJoinStart(MENUOP_SET, NULL, NULL);
|
||||||
|
g_NetJoinLatch = false;
|
||||||
|
} else if (g_NetHostLatch) {
|
||||||
|
menuhandlerHostGame(MENUOP_SET, NULL, NULL);
|
||||||
|
menuhandlerHostStart(MENUOP_SET, NULL, NULL);
|
||||||
|
g_NetHostLatch = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user