mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Merge branch 'kartport_misc-changes' into 'master'
Kart ports: misc changes See merge request STJr/SRB2Internal!380
This commit is contained in:
commit
f1a7a3b4de
4 changed files with 48 additions and 19 deletions
36
src/i_tcp.c
36
src/i_tcp.c
|
@ -776,6 +776,8 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
mysockaddr_t straddr;
|
mysockaddr_t straddr;
|
||||||
|
struct sockaddr_in sin;
|
||||||
|
socklen_t len = sizeof(sin);
|
||||||
|
|
||||||
if (s == (SOCKET_TYPE)ERRSOCKET)
|
if (s == (SOCKET_TYPE)ERRSOCKET)
|
||||||
return (SOCKET_TYPE)ERRSOCKET;
|
return (SOCKET_TYPE)ERRSOCKET;
|
||||||
|
@ -869,12 +871,16 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||||
CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10);
|
CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getsockname(s, (struct sockaddr *)&sin, &len) == -1)
|
||||||
|
CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n"));
|
||||||
|
else
|
||||||
|
current_port = (UINT16)ntohs(sin.sin_port);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean UDP_Socket(void)
|
static boolean UDP_Socket(void)
|
||||||
{
|
{
|
||||||
const char *sock_port = NULL;
|
|
||||||
size_t s;
|
size_t s;
|
||||||
struct my_addrinfo *ai, *runp, hints;
|
struct my_addrinfo *ai, *runp, hints;
|
||||||
int gaie;
|
int gaie;
|
||||||
|
@ -896,20 +902,11 @@ static boolean UDP_Socket(void)
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
hints.ai_protocol = IPPROTO_UDP;
|
hints.ai_protocol = IPPROTO_UDP;
|
||||||
|
|
||||||
if (M_CheckParm("-clientport"))
|
|
||||||
{
|
|
||||||
if (!M_IsNextParm())
|
|
||||||
I_Error("syntax: -clientport <portnum>");
|
|
||||||
sock_port = M_GetNextParm();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sock_port = port_name;
|
|
||||||
|
|
||||||
if (M_CheckParm("-bindaddr"))
|
if (M_CheckParm("-bindaddr"))
|
||||||
{
|
{
|
||||||
while (M_IsNextParm())
|
while (M_IsNextParm())
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo(M_GetNextParm(), sock_port, &hints, &ai);
|
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -930,7 +927,7 @@ static boolean UDP_Socket(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo("0.0.0.0", sock_port, &hints, &ai);
|
gaie = I_getaddrinfo("0.0.0.0", port_name, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -945,8 +942,8 @@ static boolean UDP_Socket(void)
|
||||||
#ifdef HAVE_MINIUPNPC
|
#ifdef HAVE_MINIUPNPC
|
||||||
if (UPNP_support)
|
if (UPNP_support)
|
||||||
{
|
{
|
||||||
I_UPnP_rem(sock_port, "UDP");
|
I_UPnP_rem(port_name, "UDP");
|
||||||
I_UPnP_add(NULL, sock_port, "UDP");
|
I_UPnP_add(NULL, port_name, "UDP");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -963,7 +960,7 @@ static boolean UDP_Socket(void)
|
||||||
{
|
{
|
||||||
while (M_IsNextParm())
|
while (M_IsNextParm())
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo(M_GetNextParm(), sock_port, &hints, &ai);
|
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -984,7 +981,7 @@ static boolean UDP_Socket(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo("::", sock_port, &hints, &ai);
|
gaie = I_getaddrinfo("::", port_name, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -1260,7 +1257,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
||||||
int gaie;
|
int gaie;
|
||||||
|
|
||||||
if (!port || !port[0])
|
if (!port || !port[0])
|
||||||
port = port_name;
|
port = DEFAULTPORT;
|
||||||
|
|
||||||
DEBFILE(va("Creating new node: %s@%s\n", address, port));
|
DEBFILE(va("Creating new node: %s@%s\n", address, port));
|
||||||
|
|
||||||
|
@ -1424,14 +1421,15 @@ boolean I_InitTcpNetwork(void)
|
||||||
if (!I_InitTcpDriver())
|
if (!I_InitTcpDriver())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (M_CheckParm("-udpport"))
|
if (M_CheckParm("-port"))
|
||||||
|
// Combined -udpport and -clientport into -port
|
||||||
|
// As it was really redundant having two seperate parms that does the same thing
|
||||||
{
|
{
|
||||||
if (M_IsNextParm())
|
if (M_IsNextParm())
|
||||||
strcpy(port_name, M_GetNextParm());
|
strcpy(port_name, M_GetNextParm());
|
||||||
else
|
else
|
||||||
strcpy(port_name, "0");
|
strcpy(port_name, "0");
|
||||||
}
|
}
|
||||||
current_port = (UINT16)atoi(port_name);
|
|
||||||
|
|
||||||
// parse network game options,
|
// parse network game options,
|
||||||
if (M_CheckParm("-server") || dedicated)
|
if (M_CheckParm("-server") || dedicated)
|
||||||
|
|
|
@ -50,6 +50,7 @@ enum hook {
|
||||||
hook_FollowMobj,
|
hook_FollowMobj,
|
||||||
hook_PlayerCanDamage,
|
hook_PlayerCanDamage,
|
||||||
hook_PlayerQuit,
|
hook_PlayerQuit,
|
||||||
|
hook_IntermissionThinker,
|
||||||
|
|
||||||
hook_MAX // last hook
|
hook_MAX // last hook
|
||||||
};
|
};
|
||||||
|
@ -91,5 +92,6 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnM
|
||||||
boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following
|
boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following
|
||||||
UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage
|
UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage
|
||||||
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
||||||
|
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,6 +61,7 @@ const char *const hookNames[hook_MAX+1] = {
|
||||||
"FollowMobj",
|
"FollowMobj",
|
||||||
"PlayerCanDamage",
|
"PlayerCanDamage",
|
||||||
"PlayerQuit",
|
"PlayerQuit",
|
||||||
|
"IntermissionThinker",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1322,4 +1323,27 @@ void LUAh_PlayerQuit(player_t *plr, int reason)
|
||||||
lua_settop(gL, 0);
|
lua_settop(gL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hook for Y_Ticker
|
||||||
|
void LUAh_IntermissionThinker(void)
|
||||||
|
{
|
||||||
|
hook_p hookp;
|
||||||
|
if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8))))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (hookp = roothook; hookp; hookp = hookp->next)
|
||||||
|
{
|
||||||
|
if (hookp->type != hook_IntermissionThinker)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
|
||||||
|
lua_gettable(gL, LUA_REGISTRYINDEX);
|
||||||
|
if (lua_pcall(gL, 0, 0, 0)) {
|
||||||
|
if (!hookp->error || cv_debug & DBG_LUA)
|
||||||
|
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
|
||||||
|
lua_pop(gL, 1);
|
||||||
|
hookp->error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
|
|
||||||
#include "m_cond.h" // condition sets
|
#include "m_cond.h" // condition sets
|
||||||
|
#include "lua_hook.h" // IntermissionThinker hook
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
#include "hardware/hw_main.h"
|
#include "hardware/hw_main.h"
|
||||||
|
@ -802,6 +803,10 @@ void Y_Ticker(void)
|
||||||
if (paused || P_AutoPause())
|
if (paused || P_AutoPause())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef HAVE_BLUA
|
||||||
|
LUAh_IntermissionThinker();
|
||||||
|
#endif
|
||||||
|
|
||||||
intertic++;
|
intertic++;
|
||||||
|
|
||||||
// Team scramble code for team match and CTF.
|
// Team scramble code for team match and CTF.
|
||||||
|
|
Loading…
Reference in a new issue