Merge remote-tracking branch 'Hanicef/add-ipv6-indicator' into IPv6

This commit is contained in:
Alam Ed Arias 2023-12-12 20:38:19 -05:00
commit fdb7c7c847
15 changed files with 198 additions and 110 deletions

View file

@ -584,10 +584,26 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
x1 = ((polyvertex_t *)line->pv1)->x;
y1 = ((polyvertex_t *)line->pv1)->y;
xd = ((polyvertex_t *)line->pv2)->x - x1;
yd = ((polyvertex_t *)line->pv2)->y - y1;
if (line->pv1)
{
x1 = ((polyvertex_t *)line->pv1)->x;
y1 = ((polyvertex_t *)line->pv1)->y;
}
else
{
x1 = FIXED_TO_FLOAT(line->v1->x);
y1 = FIXED_TO_FLOAT(line->v1->x);
}
if (line->pv2)
{
xd = ((polyvertex_t *)line->pv2)->x - x1;
yd = ((polyvertex_t *)line->pv2)->y - y1;
}
else
{
xd = FIXED_TO_FLOAT(line->v2->x) - x1;
yd = FIXED_TO_FLOAT(line->v2->y) - y1;
}
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
@ -1070,10 +1086,26 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
gl_sidedef = gl_curline->sidedef;
gl_linedef = gl_curline->linedef;
vs.x = ((polyvertex_t *)gl_curline->pv1)->x;
vs.y = ((polyvertex_t *)gl_curline->pv1)->y;
ve.x = ((polyvertex_t *)gl_curline->pv2)->x;
ve.y = ((polyvertex_t *)gl_curline->pv2)->y;
if (gl_curline->pv1)
{
vs.x = ((polyvertex_t *)gl_curline->pv1)->x;
vs.y = ((polyvertex_t *)gl_curline->pv1)->y;
}
else
{
vs.x = FIXED_TO_FLOAT(gl_curline->v1->x);
vs.y = FIXED_TO_FLOAT(gl_curline->v1->y);
}
if (gl_curline->pv2)
{
ve.x = ((polyvertex_t *)gl_curline->pv2)->x;
ve.y = ((polyvertex_t *)gl_curline->pv2)->y;
}
else
{
ve.x = FIXED_TO_FLOAT(gl_curline->v2->x);
ve.y = FIXED_TO_FLOAT(gl_curline->v2->y);
}
v1x = FLOAT_TO_FIXED(vs.x);
v1y = FLOAT_TO_FIXED(vs.y);
@ -1868,10 +1900,26 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks
if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope)
{
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
if (gl_curline->pv1)
{
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (gl_curline->pv2)
{
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
end1 = P_GetZAt(slope, v1x, v1y, normalheight); \
end2 = P_GetZAt(slope, v2x, v2y, normalheight);
@ -2244,10 +2292,26 @@ static void HWR_AddLine(seg_t * line)
gl_curline = line;
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
if (gl_curline->pv1)
{
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x);
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y);
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (gl_curline->pv2)
{
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x);
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
// OPTIMIZE: quickly reject orthogonal back sides.
angle1 = R_PointToAngle64(v1x, v1y);
@ -5258,7 +5322,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
rollangle = R_GetRollAngle(spriterotangle);
}
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
if (rotsprite != NULL)
{

View file

@ -517,7 +517,7 @@ static int libd_getSpritePatch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &spriteinfo[i], rot);
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &spriteinfo[i], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false);
lua_pushboolean(L, true);
@ -629,7 +629,7 @@ static int libd_getSprite2Patch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &skins[i].sprinfo[j], rot);
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &skins[i].sprinfo[j], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false);
lua_pushboolean(L, true);

View file

@ -11254,6 +11254,8 @@ static void M_DrawConnectMenu(void)
V_DrawSmallString(currentMenu->x+202, S_LINEY(i)+8, globalflags, "\x85" "Mod");
if (serverlist[slindex].info.cheatsenabled)
V_DrawSmallString(currentMenu->x+222, S_LINEY(i)+8, globalflags, "\x83" "Cheats");
if (Net_IsNodeIPv6(serverlist[slindex].node))
V_DrawSmallString(currentMenu->x+252, S_LINEY(i)+8, globalflags, "\x84" "IPv6");
V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags,
va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time)));

View file

@ -70,6 +70,7 @@ boolean HGetPacket(void);
void D_SetDoomcom(void);
boolean D_CheckNetGame(void);
void D_CloseConnection(void);
boolean Net_IsNodeIPv6(INT32 node);
void Net_UnAcknowledgePacket(INT32 node);
void Net_CloseConnection(INT32 node);
void Net_ConnectionTimeout(INT32 node);

View file

@ -154,6 +154,8 @@ typedef union
#define ERRSOCKET (-1)
#endif
#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12"
// define socklen_t in DOS/Windows if it is not already defined
#ifdef USE_WINSOCK1
typedef int socklen_t;
@ -621,6 +623,7 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6);
#endif
socklen_t d, da = (socklen_t)sizeof(mysockaddr_t);
ssize_t status;
switch (sockaddr->any.sa_family)
{
@ -631,7 +634,12 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
default: d = da; break;
}
return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d);
status = sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d);
if (status == -1)
{
CONS_Alert(CONS_WARNING, "Unable to send packet to %s: %s\n", SOCK_AddrToStr(sockaddr), strerror(errno));
}
return status;
}
static void SOCK_Send(void)
@ -770,6 +778,24 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
return (SOCKET_TYPE)ERRSOCKET;
}
#ifdef HAVE_IPV6
if (family == AF_INET6)
{
// we need to set all of this *after* binding to an address!
if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
{
struct ipv6_mreq maddr;
inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr);
maddr.ipv6mr_interface = 0;
if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr)) != 0)
{
CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n"));
}
}
}
#endif
#ifdef FIONBIO
// make it non blocking
opt = true;
@ -950,65 +976,28 @@ static boolean UDP_Socket(void)
// ip + udp
packetheaderlength = 20 + 8; // for stats
hints.ai_family = AF_INET;
gaie = I_getaddrinfo("127.0.0.1", "0", &hints, &ai);
if (gaie == 0)
{
runp = ai;
while (runp != NULL && s < MAXNETNODES+1)
{
memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
else
{
clientaddress[s].any.sa_family = AF_INET;
clientaddress[s].ip4.sin_port = htons(0);
clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip
s++;
}
clientaddress[s].any.sa_family = AF_INET;
clientaddress[s].ip4.sin_port = htons(0);
clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip
s++;
s = 0;
// setup broadcast adress to BROADCASTADDR entry
gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai);
if (gaie == 0)
{
runp = ai;
while (runp != NULL && s < MAXNETNODES+1)
{
memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
else
{
broadcastaddress[s].any.sa_family = AF_INET;
broadcastaddress[s].ip4.sin_port = htons(0);
broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST);
s++;
}
broadcastaddress[s].any.sa_family = AF_INET;
broadcastaddress[s].ip4.sin_port = htons(atoi(DEFAULTPORT));
broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST);
s++;
#ifdef HAVE_IPV6
if (b_ipv6)
{
hints.ai_family = AF_INET6;
gaie = I_getaddrinfo("ff02::1", "0", &hints, &ai);
if (gaie == 0)
{
runp = ai;
while (runp != NULL && s < MAXNETNODES+1)
{
memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen);
s++;
runp = runp->ai_next;
}
I_freeaddrinfo(ai);
}
broadcastaddress[s].any.sa_family = AF_INET6;
broadcastaddress[s].ip6.sin6_port = htons(atoi(DEFAULTPORT));
broadcastaddress[s].ip6.sin6_flowinfo = 0;
inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &broadcastaddress[s].ip6.sin6_addr);
broadcastaddress[s].ip6.sin6_scope_id = 0;
s++;
}
#endif
@ -1373,4 +1362,13 @@ boolean I_InitTcpNetwork(void)
return ret;
}
boolean Net_IsNodeIPv6(INT32 node)
{
#ifdef NO_IPV6
return false;
#else
return clientaddress[node].any.sa_family == AF_INET6;
#endif
}
#include "i_addrinfo.c"

View file

@ -3073,11 +3073,14 @@ static boolean P_ThingHeightClip(mobj_t *thing)
if (!rover || ((rover->fofflags & FOF_EXISTS) && (rover->fofflags & FOF_SOLID)))
{
hitfloor = bouncing;
if (thing->eflags & MFE_VERTICALFLIP)
thing->pmomz = thing->ceilingz - (thing->z + thing->height);
else
thing->pmomz = thing->floorz - thing->z;
thing->eflags |= MFE_APPLYPMOMZ;
if (!(thing->player) || !(thing->player->pflags & PF_JUMPED || bouncing))
{
if (thing->eflags & MFE_VERTICALFLIP)
thing->pmomz = thing->ceilingz - (thing->z + thing->height);
else
thing->pmomz = thing->floorz - thing->z;
thing->eflags |= MFE_APPLYPMOMZ;
}
if (thing->eflags & MFE_VERTICALFLIP)
thing->z = thing->ceilingz - thing->height;

View file

@ -843,16 +843,7 @@ void P_Ticker(boolean run)
countdown2--;
if (quake.time)
{
fixed_t ir = quake.intensity>>1;
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
quake.x = M_RandomRange(-ir,ir);
quake.y = M_RandomRange(-ir,ir);
quake.z = M_RandomRange(-ir,ir);
--quake.time;
}
else
quake.x = quake.y = quake.z = 0;
if (metalplayback)
G_ReadMetalTic(metalplayback);

View file

@ -922,7 +922,7 @@ typedef struct
UINT16 flip;
#ifdef ROTSPRITE
rotsprite_t *rotated[2][16]; // Rotated patches
rotsprite_t *rotated[16]; // Rotated patches
#endif
} spriteframe_t;

View file

@ -1085,6 +1085,7 @@ void R_SetupFrame(player_t *player)
{
camera_t *thiscam;
boolean chasecam = R_ViewpointHasChasecam(player);
boolean ispaused = paused || P_AutoPause();
if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer])
thiscam = &camera2;
@ -1135,6 +1136,30 @@ void R_SetupFrame(player_t *player)
}
}
}
if (quake.time && !ispaused)
{
fixed_t ir = quake.intensity>>1;
if (quake.epicenter) {
// Calculate 3D distance from epicenter, using the camera.
fixed_t xydist = R_PointToDist2(thiscam->x, thiscam->y, quake.epicenter->x, quake.epicenter->y);
fixed_t dist = R_PointToDist2(0, thiscam->z, xydist, quake.epicenter->z);
// More effect closer to epicenter, outside of radius = no effect
if (!quake.radius || dist > quake.radius)
ir = 0;
else
ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius));
}
quake.x = M_RandomRange(-ir,ir);
quake.y = M_RandomRange(-ir,ir);
quake.z = M_RandomRange(-ir,ir);
}
else if (!ispaused)
quake.x = quake.y = quake.z = 0;
newview->z += quake.z;
newview->player = player;

View file

@ -37,7 +37,7 @@ patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip);
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
boolean flip,
void *info, INT32 rotationangle);
angle_t R_ModelRotationAngle(interpmobjstate_t *interp);
angle_t R_SpriteRotationAngle(interpmobjstate_t *interp);

View file

@ -10,7 +10,7 @@
/// \brief Patch rotation.
#include "r_patchrotation.h"
#include "r_things.h" // FEETADJUST
#include "r_things.h" // FEETADJUST (todo: is this needed anymore? -- Monster Iestyn 21 Sep 2023 )
#include "z_zone.h"
#include "w_wad.h"
#include "r_main.h" // R_PointToAngle
@ -66,23 +66,20 @@ patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip)
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
boolean flip,
void *info, INT32 rotationangle)
{
rotsprite_t *rotsprite;
rotsprite_t *rotsprite = sprite->rotated[spriteangle];
spriteinfo_t *sprinfo = (spriteinfo_t *)info;
INT32 idx = rotationangle;
UINT8 type = (adjustfeet ? 1 : 0);
if (rotationangle < 1 || rotationangle >= ROTANGLES)
return NULL;
rotsprite = sprite->rotated[type][spriteangle];
if (rotsprite == NULL)
{
rotsprite = RotatedPatch_Create(ROTANGLES);
sprite->rotated[type][spriteangle] = rotsprite;
sprite->rotated[spriteangle] = rotsprite;
}
if (flip)
@ -111,10 +108,6 @@ patch_t *Patch_GetRotatedSprite(
}
RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip);
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
if (adjustfeet)
((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS;
}
return rotsprite->patches[idx];

View file

@ -138,8 +138,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
#ifdef ROTSPRITE
for (r = 0; r < 16; r++)
{
sprtemp[frame].rotated[0][r] = NULL;
sprtemp[frame].rotated[1][r] = NULL;
sprtemp[frame].rotated[r] = NULL;
}
#endif
@ -337,6 +336,11 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
spritecachedinfo[numspritelumps].height = height<<FRACBITS;
// BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
// Monster Iestyn (21 Sep 2023): the above comment no longer makes sense in context!!! So I give an explanation here!
// FEETADJUST was originally an OpenGL-exclusive hack from Doom Legacy to avoid the player's feet being clipped as
// a result of rendering partially under the ground, but sometime before SRB2 2.1's release this was changed to apply
// to the software renderer as well.
// TODO: kill FEETADJUST altogether somehow and somehow fix OpenGL not to clip sprites that are partially underground (if possible)?
spritecachedinfo[numspritelumps].topoffset += FEETADJUST;
//----------------------------------------------------
@ -1794,7 +1798,7 @@ static void R_ProjectSprite(mobj_t *thing)
rollangle = R_GetRollAngle(spriterotangle);
}
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
if (rotsprite != NULL)
{

View file

@ -513,7 +513,7 @@ void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan)
closedcaptions[set].c = ((cnum == -1) ? NULL : &channels[cnum]);
closedcaptions[set].s = sfx;
closedcaptions[set].t = lifespan;
closedcaptions[set].b = 2; // bob
closedcaptions[set].b = 3; // bob
}
void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)

View file

@ -552,7 +552,7 @@ void SCR_ClosedCaptions(void)
{
UINT8 i;
boolean gamestopped = (paused || P_AutoPause());
INT32 basey = BASEVIDHEIGHT;
INT32 basey = BASEVIDHEIGHT - 20;
if (gamestate != wipegamestate)
return;
@ -572,7 +572,8 @@ void SCR_ClosedCaptions(void)
for (i = 0; i < NUMCAPTIONS; i++)
{
INT32 flags, y;
INT32 flags;
fixed_t y;
char dot;
boolean music;
@ -585,14 +586,19 @@ void SCR_ClosedCaptions(void)
continue;
flags = V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_ALLOWLOWERCASE;
y = basey-((i + 2)*10);
y = (basey-(i*10)) * FRACUNIT;
if (closedcaptions[i].b)
{
y -= closedcaptions[i].b * vid.dup;
if (renderisnewtic)
{
closedcaptions[i].b--;
if (closedcaptions[i].b) // If the caption hasn't reached its final destination...
{
y -= closedcaptions[i].b * 4 * FRACUNIT; // ...move it per tic...
y += (rendertimefrac % FRACUNIT) * 4; // ...and interpolate it per frame
// We have to modulo it by FRACUNIT, so that it won't be a tic ahead with interpolation disabled
// Unlike everything else, captions are (intentionally) interpolated from T to T+1 instead of T-1 to T
}
}
@ -606,7 +612,7 @@ void SCR_ClosedCaptions(void)
else
dot = ' ';
V_DrawRightAlignedString(BASEVIDWIDTH - 20, y, flags,
V_DrawRightAlignedStringAtFixed((BASEVIDWIDTH-20) * FRACUNIT, y, flags,
va("%c [%s]", dot, (closedcaptions[i].s->caption[0] ? closedcaptions[i].s->caption : closedcaptions[i].s->name)));
}
}

View file

@ -608,6 +608,7 @@ void I_GetConsoleEvents(void)
return;
ev.type = ev_console;
ev.key = 0;
if (read(STDIN_FILENO, &key, 1) == -1 || !key)
return;
@ -634,7 +635,7 @@ void I_GetConsoleEvents(void)
}
else return;
}
else
else if (tty_con.cursor < sizeof (tty_con.buffer))
{
// push regular character
ev.key = tty_con.buffer[tty_con.cursor] = key;