Merge branch 'Saturn-Next' into dsdacol
This commit is contained in:
commit
a9732e9564
9 files changed
+146
-1043
No files matched your search
+7
-6
@@ -1913,13 +1913,14 @@ void CV_AddValue(consvar_t *var, INT32 increment)
|
||||
max = (M_SecretUnlocked(SECRET_HARDSPEED) ? 3 : 2);
|
||||
}
|
||||
#ifdef PARANOIA
|
||||
if (currentindice == -1)
|
||||
I_Error("CV_AddValue: current value %d not found in possible value\n",
|
||||
var->value);
|
||||
if (currentindice == -1 || max == 0)
|
||||
I_Error("CV_AddValue: current value %d not found in possible value\n", var->value);
|
||||
#endif
|
||||
|
||||
newindice = (currentindice + increment + max) % max;
|
||||
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
||||
if (max > 0)
|
||||
{
|
||||
newindice = (currentindice + increment + max) % max;
|
||||
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -114,7 +114,6 @@ void UnloadModel(model_t *model)
|
||||
if (model->materials)
|
||||
Z_Free(model->materials);
|
||||
|
||||
DeleteVBOs(model);
|
||||
Z_Free(model);
|
||||
}
|
||||
|
||||
@@ -194,7 +193,6 @@ model_t *LoadModel(const char *filename, int ztag)
|
||||
strcpy(model->mdlFilename, filename);
|
||||
|
||||
Optimize(model);
|
||||
GeneratePolygonNormals(model, ztag);
|
||||
|
||||
// Default material properties
|
||||
for (i = 0 ; i < model->numMaterials; i++)
|
||||
@@ -246,13 +244,6 @@ void GenerateVertexNormals(model_t *model)
|
||||
|
||||
M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
memTag = Z_GetTag(frame->tangents);
|
||||
float *newTangents = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag);
|
||||
M_Memcpy(newTangents, frame->tangents, sizeof(float)*3*mesh->numTriangles*3);
|
||||
}*/
|
||||
|
||||
for (k = 0; k < mesh->numVertices; k++)
|
||||
{
|
||||
float x, y, z;
|
||||
@@ -288,32 +279,15 @@ void GenerateVertexNormals(model_t *model)
|
||||
|
||||
if (vCount > 1)
|
||||
{
|
||||
// Vector::Normalize(&normal);
|
||||
newNormals[3 * k + 0] = (float)normal.x;
|
||||
newNormals[3 * k + 1] = (float)normal.y;
|
||||
newNormals[3 * k + 2] = (float)normal.z;
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
Vector::vector_t tangent;
|
||||
Vector::Tangent(&normal, &tangent);
|
||||
newTangents[3 * k + 0] = tangent.x;
|
||||
newTangents[3 * k + 1] = tangent.y;
|
||||
newTangents[3 * k + 2] = tangent.z;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
oldNormals = frame->normals;
|
||||
frame->normals = newNormals;
|
||||
Z_Free(oldNormals);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
float *oldTangents = frame->tangents;
|
||||
frame->tangents = newTangents;
|
||||
Z_Free(oldTangents);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,15 +378,11 @@ void Optimize(model_t *model)
|
||||
newMesh->numTriangles = numTriangles;
|
||||
newMesh->numVertices = numTriangles * 3;
|
||||
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
|
||||
// if (node->material->lightmap)
|
||||
// newMesh->lightuvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
|
||||
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
|
||||
curFrame = &newMesh->frames[0];
|
||||
|
||||
curFrame->material = curMat;
|
||||
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
// if (!systemSucks)
|
||||
// curFrame->tangents = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
|
||||
|
||||
@@ -436,12 +406,6 @@ void Optimize(model_t *model)
|
||||
curMesh->uvs,
|
||||
sizeof(float)*2*curMesh->numTriangles*3);
|
||||
|
||||
/* if (node->material->lightmap)
|
||||
{
|
||||
M_Memcpy(&newMesh->lightuvs[uvCount],
|
||||
curMesh->lightuvs,
|
||||
sizeof(float)*2*curMesh->numTriangles*3);
|
||||
}*/
|
||||
uvCount += 2*curMesh->numTriangles*3;
|
||||
|
||||
dest = (float*)newMesh->frames[0].vertices;
|
||||
@@ -456,15 +420,6 @@ void Optimize(model_t *model)
|
||||
src,
|
||||
sizeof(float)*3*curMesh->numTriangles*3);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
dest = (float*)newMesh->frames[0].tangents;
|
||||
src = (float*)curMesh->frames[0].tangents;
|
||||
M_Memcpy(&dest[vertCount],
|
||||
src,
|
||||
sizeof(float)*3*curMesh->numTriangles*3);
|
||||
}*/
|
||||
|
||||
vertCount += 3 * curMesh->numTriangles * 3;
|
||||
|
||||
destByte = (char*)newMesh->frames[0].colors;
|
||||
@@ -494,103 +449,3 @@ void Optimize(model_t *model)
|
||||
model->meshes = newMeshes;
|
||||
model->numMeshes = numMeshes;
|
||||
}
|
||||
|
||||
void GeneratePolygonNormals(model_t *model, int ztag)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < model->numMeshes; i++)
|
||||
{
|
||||
int j;
|
||||
mesh_t *mesh = &model->meshes[i];
|
||||
|
||||
if (!mesh->frames)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
int k;
|
||||
mdlframe_t *frame = &mesh->frames[j];
|
||||
const float *vertices = frame->vertices;
|
||||
vector_t *polyNormals;
|
||||
|
||||
frame->polyNormals = (vector_t*)Z_Malloc(sizeof(vector_t) * mesh->numTriangles, ztag, 0);
|
||||
|
||||
polyNormals = frame->polyNormals;
|
||||
|
||||
for (k = 0; k < mesh->numTriangles; k++)
|
||||
{
|
||||
/// TODO: normalize vectors
|
||||
(void)vertices;
|
||||
(void)polyNormals;
|
||||
// Vector::Normal(vertices, polyNormals);
|
||||
vertices += 3 * 3;
|
||||
polyNormals++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Reload
|
||||
//
|
||||
// Reload VBOs
|
||||
//
|
||||
#if 0
|
||||
static void Reload(void)
|
||||
{
|
||||
/* model_t *node;
|
||||
for (node = modelHead; node; node = node->next)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < node->numMeshes; i++)
|
||||
{
|
||||
mesh_t *mesh = &node->meshes[i];
|
||||
|
||||
if (mesh->frames)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
CreateVBO(mesh, &mesh->frames[j]);
|
||||
}
|
||||
else if (mesh->tinyframes)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
CreateVBO(mesh, &mesh->tinyframes[j]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
void DeleteVBOs(model_t *model)
|
||||
{
|
||||
(void)model;
|
||||
/* for (int i = 0; i < model->numMeshes; i++)
|
||||
{
|
||||
mesh_t *mesh = &model->meshes[i];
|
||||
|
||||
if (mesh->frames)
|
||||
{
|
||||
for (int j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
mdlframe_t *frame = &mesh->frames[j];
|
||||
if (!frame->vboID)
|
||||
continue;
|
||||
bglDeleteBuffers(1, &frame->vboID);
|
||||
frame->vboID = 0;
|
||||
}
|
||||
}
|
||||
else if (mesh->tinyframes)
|
||||
{
|
||||
for (int j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
tinyframe_t *frame = &mesh->tinyframes[j];
|
||||
if (!frame->vboID)
|
||||
continue;
|
||||
bglDeleteBuffers(1, &frame->vboID);
|
||||
frame->vboID = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -28,8 +28,6 @@ typedef struct
|
||||
float ambient[4], diffuse[4], specular[4], emissive[4];
|
||||
float shininess;
|
||||
boolean spheremap;
|
||||
// Texture::texture_t *texture;
|
||||
// Texture::texture_t *lightmap;
|
||||
} material_t;
|
||||
|
||||
typedef struct
|
||||
@@ -40,7 +38,6 @@ typedef struct
|
||||
float *tangents;
|
||||
char *colors;
|
||||
unsigned int vboID;
|
||||
vector_t *polyNormals;
|
||||
} mdlframe_t;
|
||||
|
||||
typedef struct
|
||||
@@ -70,7 +67,6 @@ typedef struct mesh_s
|
||||
typedef struct tag_s
|
||||
{
|
||||
char name[64];
|
||||
// matrix_t transform;
|
||||
} tag_t;
|
||||
|
||||
typedef struct model_s
|
||||
@@ -96,9 +92,7 @@ model_t *LoadModel(const char *filename, int ztag);
|
||||
void UnloadModel(model_t *model);
|
||||
void Optimize(model_t *model);
|
||||
void GenerateVertexNormals(model_t *model);
|
||||
void GeneratePolygonNormals(model_t *model, int ztag);
|
||||
void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame);
|
||||
void CreateVBO(mesh_t *mesh, mdlframe_t *frame);
|
||||
void DeleteVBOs(model_t *model);
|
||||
|
||||
#endif
|
||||
@@ -253,6 +253,9 @@ HMS_connect (const char *format, ...)
|
||||
cc = curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)cv_masterserver_timeout.value);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
cc = curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 30L);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
cc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
|
||||
@@ -1,680 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_addrinfo.c
|
||||
/// \brief getaddr stubs, for lesser OSes
|
||||
///
|
||||
/// Some systems/SDKs, like PSL1GHT v2 does not have addrinfo functions
|
||||
/// So a stub is needed
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WINSOCK2
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "i_addrinfo.h"
|
||||
|
||||
/*
|
||||
* This addrinfo stub have a testcases:
|
||||
* To test the stub, use this command to compile the stub testcase:
|
||||
* gcc -g -DTESTCASE -Dtest_stub -Wall -W i_addrinfo.c -o stub
|
||||
* To test the real getaddrinfo API, use this command to get real one:
|
||||
* gcc -g -DTESTCASE -Utest_stub -Wall -W i_addrinfo.c -o real
|
||||
* For Win32,you need the WinSock library, version 1.1 or 2.2
|
||||
* for 1.1, add -lwsock32
|
||||
* i686-w64-mingw32-gcc -g -DTESTCASE -Dtest_stub -UUSE_WINSOCK2 -Wall -W i_addrinfo.c -o stub.exe -lwsock32
|
||||
* for 2.2, add -DUSE_WINSOCK2 -lws2_32
|
||||
* i686-w64-mingw32-gcc -g -DTESTCASE -Utest_stub -DUSE_WINSOCK2 -Wall -W i_addrinfo.c -o real.exe -lws2_32
|
||||
*/
|
||||
|
||||
#ifndef I_getaddrinfo
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
// it seems windows doesn't define that... maybe some other OS? OS/2
|
||||
static int inet_aton(const char *cp, struct in_addr *addr)
|
||||
{
|
||||
if( cp == NULL || addr == NULL )
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
if (strcmp(cp, "255.255.255.225") == 0)
|
||||
{
|
||||
addr->s_addr = htonl(INADDR_BROADCAST);
|
||||
return 0;
|
||||
}
|
||||
return (addr->s_addr = inet_addr(cp)) != htonl(INADDR_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
static HMODULE ipv6dll = NULL;
|
||||
typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *,
|
||||
const struct my_addrinfo *,
|
||||
struct my_addrinfo **);
|
||||
typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *);
|
||||
|
||||
static p_getaddrinfo WS_getaddrinfo = NULL;
|
||||
static p_freeaddrinfo WS_freeaddrinfo = NULL;
|
||||
|
||||
static HMODULE WS_getfunctions(HMODULE tmp)
|
||||
{
|
||||
if (tmp != NULL)
|
||||
{
|
||||
WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo");
|
||||
if (WS_getaddrinfo == NULL)
|
||||
return NULL;
|
||||
WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo");
|
||||
if (WS_freeaddrinfo == NULL)
|
||||
{
|
||||
WS_getaddrinfo = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void WS_addrinfosetup(void)
|
||||
{
|
||||
if (WS_getaddrinfo && WS_freeaddrinfo)
|
||||
return; // already have the functions
|
||||
// why not hold it into ipv6dll? becase we already link with ws2_32, silly!
|
||||
if (WS_getfunctions(GetModuleHandleA("ws2_32.dll")) == NULL)
|
||||
ipv6dll = WS_getfunctions(LoadLibraryA("wship6.dll"));
|
||||
}
|
||||
|
||||
void WS_addrinfocleanup(void)
|
||||
{
|
||||
if (ipv6dll)
|
||||
FreeLibrary(ipv6dll);
|
||||
ipv6dll = NULL;
|
||||
WS_getaddrinfo = NULL;
|
||||
WS_freeaddrinfo = NULL;
|
||||
}
|
||||
#else
|
||||
void WS_addrinfocleanup(void) {}
|
||||
#endif
|
||||
|
||||
int I_getaddrinfo(const char *node, const char *service,
|
||||
const struct my_addrinfo *hints,
|
||||
struct my_addrinfo **res)
|
||||
{
|
||||
struct hostent *nodename = NULL;
|
||||
bool hostlookup = true, passivemode = false;
|
||||
int flags = 0;
|
||||
int socktype = 0;
|
||||
int sockport = 0;
|
||||
struct my_addrinfo *ai;
|
||||
struct sockaddr_in *addr;
|
||||
struct in_addr ipv4;
|
||||
size_t addrlen = 1;
|
||||
size_t ailen = 1, i = 0, j;
|
||||
size_t famsize = sizeof(struct sockaddr_in);
|
||||
#ifdef USE_WINSOCK2
|
||||
WS_addrinfosetup();
|
||||
if (WS_getaddrinfo)
|
||||
return WS_getaddrinfo(node, service, hints, res);
|
||||
#endif
|
||||
|
||||
// param check
|
||||
if (node == NULL && service == NULL)
|
||||
return EAI_NONAME;
|
||||
//note: testcase show NULL as res crashes libc
|
||||
if (res == NULL)
|
||||
return -1;
|
||||
|
||||
// check hints
|
||||
if (hints)
|
||||
{
|
||||
// no support for IPv6
|
||||
if (hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC)
|
||||
return -1; //EAI_FAMILY
|
||||
#ifdef AI_NUMERICHOST
|
||||
// do not look up hostnames
|
||||
if ((hints->ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
|
||||
{
|
||||
hostlookup = false;
|
||||
flags |= AI_NUMERICHOST;
|
||||
}
|
||||
#endif
|
||||
#ifdef AI_PASSIVE
|
||||
// return loopback or any address?
|
||||
if ((hints->ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
||||
{
|
||||
passivemode = true;
|
||||
flags |= AI_PASSIVE;
|
||||
}
|
||||
#endif
|
||||
// why no support for canon names? lazy
|
||||
//AI_CANONNAME
|
||||
// what kind of socket?
|
||||
socktype = hints->ai_socktype;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef AI_V4MAPPED
|
||||
flags |= AI_V4MAPPED;
|
||||
#endif
|
||||
#ifdef AI_ADDRCONFIG
|
||||
flags |= AI_ADDRCONFIG;
|
||||
#endif
|
||||
}
|
||||
|
||||
// we need gethostbyname to convert numeric strings
|
||||
if (node && hostlookup)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -1;
|
||||
nodename = gethostbyname(node);
|
||||
if (nodename == NULL)
|
||||
{
|
||||
if (inet_aton(node, &ipv4) != 0)
|
||||
addrlen = 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else while (nodename->h_addr_list[addrlen] != NULL)
|
||||
addrlen++;
|
||||
}
|
||||
else if (node)
|
||||
{
|
||||
if (inet_aton(node, &ipv4) != 0)
|
||||
addrlen = 1;
|
||||
else if (!hostlookup)
|
||||
return EAI_NONAME;
|
||||
}
|
||||
else
|
||||
addrlen = 1;
|
||||
|
||||
if (service) //AI_NUMERICSERV
|
||||
sockport = atoi(service);
|
||||
|
||||
if (socktype == 0)
|
||||
ailen = addrlen*3;
|
||||
else
|
||||
ailen = addrlen;
|
||||
|
||||
ai = calloc(ailen, sizeof(struct my_addrinfo));
|
||||
if (ai == NULL)
|
||||
return -1;
|
||||
else
|
||||
*res = ai;
|
||||
|
||||
addr = calloc(ailen*2, famsize);
|
||||
if (addr == NULL)
|
||||
{
|
||||
free(ai);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
ai->ai_addr = memset(addr, 0x00, ailen*ai->ai_addrlen);
|
||||
|
||||
for (i = 0; i < ailen; i++)
|
||||
{
|
||||
ai = *res+i;
|
||||
ai->ai_flags = flags;
|
||||
ai->ai_family = AF_INET;
|
||||
ai->ai_socktype = socktype;
|
||||
switch (ai->ai_socktype)
|
||||
{
|
||||
case SOCK_STREAM:
|
||||
ai->ai_protocol = IPPROTO_TCP;
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
ai->ai_protocol = IPPROTO_UDP;
|
||||
break;
|
||||
default:
|
||||
ai->ai_protocol = 0;
|
||||
}
|
||||
ai->ai_addrlen = famsize;
|
||||
ai->ai_addr = (struct sockaddr *)&addr[i];
|
||||
//ai_cannonname
|
||||
ai->ai_next = ai+1;
|
||||
}
|
||||
ai->ai_next = NULL;
|
||||
ai = *res;
|
||||
|
||||
for (i = 0, j = 0; i < ailen; i++, j++)
|
||||
{
|
||||
ai = *res+i;
|
||||
addr[i].sin_port = htons((UINT16)sockport);
|
||||
if (nodename)
|
||||
{
|
||||
memcpy(&addr[i].sin_addr, nodename->h_addr_list[j], ai->ai_addrlen);
|
||||
addr[i].sin_family = nodename->h_addrtype;
|
||||
}
|
||||
else if (node)
|
||||
{
|
||||
memcpy(&addr[i].sin_addr, &ipv4, ai->ai_addrlen);
|
||||
addr[i].sin_family = AF_INET;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (passivemode)
|
||||
addr[i].sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
else
|
||||
addr[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr[i].sin_family = AF_INET;
|
||||
}
|
||||
if (socktype == 0)
|
||||
{
|
||||
ai->ai_socktype = SOCK_STREAM;
|
||||
ai->ai_protocol = IPPROTO_TCP;
|
||||
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
|
||||
i++; ai++;
|
||||
ai->ai_socktype = SOCK_DGRAM;
|
||||
ai->ai_protocol = IPPROTO_UDP;
|
||||
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
|
||||
i++; ai++;
|
||||
ai->ai_socktype = SOCK_RAW;
|
||||
ai->ai_protocol = IPPROTO_IP;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef I_freeaddrinfo
|
||||
void I_freeaddrinfo(struct my_addrinfo *res)
|
||||
{
|
||||
#ifdef USE_WINSOCK2
|
||||
if (WS_freeaddrinfo)
|
||||
{
|
||||
WS_freeaddrinfo(res);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!res)
|
||||
return;
|
||||
free(res->ai_addr);
|
||||
free(res);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TESTCASE
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#define inet_ntop inet_ntopA
|
||||
#define HAVE_NTOP
|
||||
static const char* inet_ntopA(int af, const void *cp, char *buf, socklen_t len)
|
||||
{
|
||||
DWORD Dlen = len, AFlen = 0;
|
||||
SOCKADDR_STORAGE any;
|
||||
LPSOCKADDR anyp = (LPSOCKADDR)&any;
|
||||
LPSOCKADDR_IN any4 = (LPSOCKADDR_IN)&any;
|
||||
LPSOCKADDR_IN6 any6 = (LPSOCKADDR_IN6)&any;
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
WSASetLastError(STATUS_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (af != AF_INET && af != AF_INET6)
|
||||
{
|
||||
WSASetLastError(WSAEAFNOSUPPORT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(&any, sizeof(SOCKADDR_STORAGE));
|
||||
any.ss_family = af;
|
||||
|
||||
switch (af)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
CopyMemory(&any4->sin_addr, cp, sizeof(IN_ADDR));
|
||||
AFlen = sizeof(SOCKADDR_IN);
|
||||
break;
|
||||
}
|
||||
case AF_INET6:
|
||||
{
|
||||
CopyMemory(&any6->sin6_addr, cp, sizeof(IN6_ADDR));
|
||||
AFlen = sizeof(SOCKADDR_IN6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (WSAAddressToStringA(anyp, AFlen, NULL, buf, &Dlen) == SOCKET_ERROR)
|
||||
return NULL;
|
||||
return buf;
|
||||
}
|
||||
#elif defined (_WIN32)
|
||||
// w32api, ws2tcpip.h, r1.12
|
||||
static inline char* gai_strerror(int ecode)
|
||||
{
|
||||
static char message[1024+1];
|
||||
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| FORMAT_MESSAGE_IGNORE_INSERTS
|
||||
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||
DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
||||
FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, message, 1024, NULL);
|
||||
return message;
|
||||
}
|
||||
#else
|
||||
#define HAVE_NTOP
|
||||
#endif
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN 16
|
||||
#endif
|
||||
|
||||
static inline void printflags(int ai_flags)
|
||||
{
|
||||
printf("flags: %x(", ai_flags);
|
||||
if (ai_flags == 0)
|
||||
printf("NONE|");
|
||||
#ifdef AI_PASSIVE
|
||||
if ((ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
||||
printf("AI_PASSIVE|");
|
||||
ai_flags &= ~AI_PASSIVE;
|
||||
#endif
|
||||
#ifdef AI_CANONNAME
|
||||
if ((ai_flags & AI_CANONNAME) == AI_CANONNAME)
|
||||
printf("AI_CANONNAME|");
|
||||
ai_flags &= ~AI_CANONNAME;
|
||||
#endif
|
||||
#ifdef AI_NUMERICHOST
|
||||
if ((ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
|
||||
printf("AI_NUMERICHOST|");
|
||||
ai_flags &= ~AI_NUMERICHOST;
|
||||
#endif
|
||||
#ifdef AI_V4MAPPED
|
||||
if ((ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
|
||||
printf("AI_V4MAPPED|");
|
||||
ai_flags &= ~AI_V4MAPPED;
|
||||
#endif
|
||||
#ifdef AI_ALL
|
||||
if ((ai_flags & AI_ALL) == AI_ALL)
|
||||
printf("AI_ALL|");
|
||||
ai_flags &= ~AI_ALL;
|
||||
#endif
|
||||
#ifdef AI_ADDRCONFIG
|
||||
if ((ai_flags & AI_ADDRCONFIG) == AI_ADDRCONFIG)
|
||||
printf("AI_ADDRCONFIG|");
|
||||
ai_flags &= ~AI_ADDRCONFIG;
|
||||
#endif
|
||||
#ifdef AI_IDN
|
||||
if ((ai_flags & AI_IDN) == AI_IDN)
|
||||
printf("AI_IDN|");
|
||||
ai_flags &= ~AI_IDN;
|
||||
#endif
|
||||
#ifdef AI_CANONIDN
|
||||
if ((ai_flags & AI_CANONIDN) == AI_CANONIDN)
|
||||
printf("AI_CANONIDN|");
|
||||
ai_flags &= ~AI_CANONIDN;
|
||||
#endif
|
||||
#ifdef AI_IDN_ALLOW_UNASSIGNED
|
||||
if ((ai_flags & AI_IDN_ALLOW_UNASSIGNED) == AI_IDN_ALLOW_UNASSIGNED)
|
||||
printf("AI_IDN_ALLOW_UNASSIGNED|");
|
||||
ai_flags &= ~AI_IDN_ALLOW_UNASSIGNED;
|
||||
#endif
|
||||
#ifdef AI_IDN_USE_STD3_ASCII_RULES
|
||||
if ((ai_flags & AI_IDN_USE_STD3_ASCII_RULES) == AI_IDN_USE_STD3_ASCII_RULES)
|
||||
printf("AI_IDN_USE_STD3_ASCII_RULES|");
|
||||
ai_flags &= ~AI_PASSIVE;
|
||||
#endif
|
||||
#ifdef AI_NUMERICSERV
|
||||
if ((ai_flags & AI_NUMERICSERV) == AI_NUMERICSERV)
|
||||
printf("AI_NUMERICSERV|");
|
||||
ai_flags &= ~AI_NUMERICSERV;
|
||||
#endif
|
||||
printf("%x", ai_flags);
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printsocktype(int ai_socktype)
|
||||
{
|
||||
printf("socktype: %d(", ai_socktype);
|
||||
switch (ai_socktype)
|
||||
{
|
||||
case 0:
|
||||
printf("SOCK_ Woe32");
|
||||
break;
|
||||
case SOCK_STREAM:
|
||||
printf("SOCK_STREAM");
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
printf("SOCK_DGRAM");
|
||||
break;
|
||||
case SOCK_RAW:
|
||||
printf("SOCK_RAW");
|
||||
break;
|
||||
default:
|
||||
printf("SOCK_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printprotocol(int ai_protocol)
|
||||
{
|
||||
printf("protocol: %d(", ai_protocol);
|
||||
switch (ai_protocol)
|
||||
{
|
||||
case IPPROTO_IP:
|
||||
printf("IPPROTO_IP");
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
printf("IPPROTO_TCP");
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
printf("IPPROTO_UDP");
|
||||
break;
|
||||
default:
|
||||
printf("IPPROTO_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printaddr(int ai_family, const struct sockaddr *ai_addr)
|
||||
{
|
||||
char str[INET_ADDRSTRLEN+1] = "FAKE";
|
||||
printf("family: %d(", ai_family);
|
||||
switch (ai_family)
|
||||
{
|
||||
case AF_UNSPEC:
|
||||
printf("AF_UNSPEC");
|
||||
break;
|
||||
case AF_INET:
|
||||
printf("AF_INET");
|
||||
break;
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
printf("AF_INET6");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printf("AF_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
if (ai_family == AF_INET && ai_addr)
|
||||
{
|
||||
const struct sockaddr_in *ip4 = (void *)ai_addr;
|
||||
#ifdef HAVE_NTOP
|
||||
inet_ntop(ai_family, &ip4->sin_addr, str, INET_ADDRSTRLEN);
|
||||
#else
|
||||
strncpy(str, inet_ntoa(ip4->sin_addr), INET_ADDRSTRLEN);
|
||||
#endif
|
||||
printf("port: %d\n", ntohs(ip4->sin_port));
|
||||
}
|
||||
printf("addr: %s\n", str);
|
||||
}
|
||||
|
||||
void printaddrinfo(const struct my_addrinfo *data)
|
||||
{
|
||||
if(data == NULL)
|
||||
{
|
||||
printf("no data\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
printf("starting addrinfo dump\n");
|
||||
while (data != NULL)
|
||||
{
|
||||
printflags(data->ai_flags);
|
||||
printsocktype(data->ai_socktype);
|
||||
printaddr(data->ai_family, data->ai_addr);
|
||||
printprotocol(data->ai_protocol);
|
||||
//addrlen
|
||||
data = data->ai_next;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct my_addrinfo *res = NULL, hints;
|
||||
int gaie;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
memset(&hints, 0x00, sizeof(struct my_addrinfo));
|
||||
hints.ai_family = AF_INET;
|
||||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
#ifdef USE_WINSOCK2
|
||||
const WORD VerNeed = MAKEWORD(2,2);
|
||||
#else
|
||||
const WORD VerNeed = MAKEWORD(1,1);
|
||||
#endif
|
||||
WSADATA WSAData;
|
||||
WSAStartup(VerNeed, &WSAData);
|
||||
}
|
||||
#endif
|
||||
printf("-----------------------------------------------------------\n");
|
||||
#ifndef _WIN32 //NULL as res crashes Win32
|
||||
gaie = I_getaddrinfo(NULL, NULL, &hints, NULL);
|
||||
if (gaie != EAI_NONAME)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
I_freeaddrinfo(res);
|
||||
#endif
|
||||
#if 0 //NULL as res crashes
|
||||
gaie = I_getaddrinfo("localhost", "5029", NULL, NULL);
|
||||
if (gaie == 0)
|
||||
printf("NULL crashes: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
I_freeaddrinfo(res);
|
||||
#endif
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
gaie = I_getaddrinfo("127.0.0.1", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("127.0.0.1", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
gaie = I_getaddrinfo("255.255.255.255", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("255.255.255.255", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
gaie = I_getaddrinfo("0.0.0.0", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("0.0.0.0", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_addrinfo.h
|
||||
/// \brief getaddrinfo stub
|
||||
|
||||
#ifndef __I_ADDRINFO__
|
||||
#define __I_ADDRINFO__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#ifndef AI_PASSIVE
|
||||
#define AI_PASSIVE 0x01
|
||||
#endif
|
||||
#ifndef AI_NUMERICHOST
|
||||
#define AI_NUMERICHOST 0x04
|
||||
#endif
|
||||
#ifndef AI_V4MAPPED
|
||||
#define AI_V4MAPPED 0x08
|
||||
#endif
|
||||
#ifndef AI_ADDRCONFIG
|
||||
#define AI_ADDRCONFIG 0x20
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef EAI_NONAME
|
||||
#define EAI_NONAME WSAHOST_NOT_FOUND
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EAI_NONAME
|
||||
#define EAI_NONAME -2
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32 // already use the stub for Win32
|
||||
// w32api, ws2tcpip.h, r1.12
|
||||
struct my_addrinfo {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
size_t ai_addrlen;
|
||||
char *ai_canonname;
|
||||
struct sockaddr *ai_addr;
|
||||
struct my_addrinfo *ai_next;
|
||||
};
|
||||
#else
|
||||
#define my_addrinfo addrinfo
|
||||
#endif
|
||||
|
||||
void WS_addrinfocleanup(void);
|
||||
|
||||
#ifndef my_addrinfo
|
||||
void I_freeaddrinfo(struct my_addrinfo *res);
|
||||
int I_getaddrinfo(const char *node, const char *service,
|
||||
const struct my_addrinfo *hints,
|
||||
struct my_addrinfo **res);
|
||||
#elif !defined (test_stub)
|
||||
#define I_getaddrinfo getaddrinfo
|
||||
#define I_freeaddrinfo freeaddrinfo
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
+44
-87
@@ -29,42 +29,36 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#define USE_WINSOCK
|
||||
#if defined (_WIN64) || defined (HAVE_IPV6)
|
||||
#define USE_WINSOCK2
|
||||
#else //_WIN64/HAVE_IPV6
|
||||
#define USE_WINSOCK1
|
||||
#endif
|
||||
#endif //WIN32 OS
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#ifdef USE_WINSOCK
|
||||
#include <ws2tcpip.h>
|
||||
#define addrinfo_t ADDRINFOA
|
||||
#else
|
||||
#define addrinfo_t struct addrinfo
|
||||
#endif
|
||||
|
||||
#include "doomdef.h"
|
||||
|
||||
#ifndef USE_WINSOCK
|
||||
#include <arpa/inet.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#ifndef _BSD_SOCKLEN_T_
|
||||
#define _BSD_SOCKLEN_T_
|
||||
#endif //_BSD_SOCKLEN_T_
|
||||
#endif //__APPLE_CC__
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif //normal BSD API
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#ifdef USE_WINSOCK1
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#ifndef USE_WINSOCK
|
||||
#include <arpa/inet.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#ifndef _BSD_SOCKLEN_T_
|
||||
#define _BSD_SOCKLEN_T_
|
||||
#endif //_BSD_SOCKLEN_T_
|
||||
#endif //__APPLE_CC__
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif //normal BSD API
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <sys/time.h>
|
||||
#endif // UNIXCOMMON
|
||||
#endif
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <sys/time.h>
|
||||
#endif // UNIXCOMMON
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
// some undefined under win32
|
||||
@@ -152,7 +146,6 @@ static UINT8 UPNP_support = TRUE;
|
||||
#define close closesocket
|
||||
#endif
|
||||
|
||||
#include "i_addrinfo.h"
|
||||
#define DEFAULTPORT "5029"
|
||||
|
||||
#if defined (USE_WINSOCK)
|
||||
@@ -169,10 +162,6 @@ typedef unsigned long SOCKET_TYPE;
|
||||
|
||||
#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12"
|
||||
|
||||
#ifdef USE_WINSOCK1
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mysockaddr_t address;
|
||||
@@ -232,9 +221,8 @@ static char *get_WSAErrorStr(int e)
|
||||
#define strerror get_WSAErrorStr
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#ifdef USE_WINSOCK
|
||||
#define inet_ntop inet_ntopA
|
||||
#define HAVE_NTOP
|
||||
static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len)
|
||||
{
|
||||
DWORD Dlen = len, AFlen = 0;
|
||||
@@ -278,8 +266,6 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
|
||||
return NULL;
|
||||
return buf;
|
||||
}
|
||||
#elif !defined (USE_WINSOCK1)
|
||||
#define HAVE_NTOP
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MINIUPNPC // based on old XChat patch
|
||||
@@ -360,7 +346,6 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
static char s[64]; // 255.255.255.255:65535 or
|
||||
// [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535
|
||||
|
||||
#ifdef HAVE_NTOP
|
||||
#ifdef HAVE_IPV6
|
||||
int v6 = (sk->any.sa_family == AF_INET6);
|
||||
#else
|
||||
@@ -398,15 +383,7 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
#endif
|
||||
else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
|
||||
strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
|
||||
#else
|
||||
if (sk->any.sa_family == AF_INET)
|
||||
{
|
||||
strcpy(s, inet_ntoa(sk->ip4.sin_addr));
|
||||
if (sk->ip4.sin_port != 0) strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
|
||||
}
|
||||
else
|
||||
sprintf(s, "Unknown type");
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -868,15 +845,11 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
{ // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up
|
||||
#ifdef USE_WINSOCK2
|
||||
DWORD dwBytesReturned = 0;
|
||||
BOOL bfalse = FALSE;
|
||||
rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse),
|
||||
NULL, 0, &dwBytesReturned, NULL, NULL);
|
||||
#else
|
||||
unsigned long falseval = false;
|
||||
rc = ioctl(s, SIO_UDP_CONNRESET, &falseval);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
e = errno;
|
||||
@@ -1046,7 +1019,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
static boolean UDP_Socket(void)
|
||||
{
|
||||
size_t s;
|
||||
struct my_addrinfo *ai, *runp, hints;
|
||||
addrinfo_t *ai, *runp, hints;
|
||||
int gaie;
|
||||
#ifdef HAVE_IPV6
|
||||
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
||||
@@ -1075,7 +1048,7 @@ static boolean UDP_Socket(void)
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1089,13 +1062,13 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||
gaie = getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1116,7 +1089,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,7 +1101,7 @@ static boolean UDP_Socket(void)
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1142,13 +1115,13 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("::", serv, &hints, &ai);
|
||||
gaie = getaddrinfo("::", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1162,7 +1135,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1216,11 +1189,7 @@ boolean I_InitTcpDriver(void)
|
||||
if (!init_tcp_driver)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
#ifdef USE_WINSOCK2
|
||||
const WORD VerNeed = MAKEWORD(2,2);
|
||||
#else
|
||||
const WORD VerNeed = MAKEWORD(1,1);
|
||||
#endif
|
||||
WSADATA WSAData;
|
||||
const int WSAresult = WSAStartup(VerNeed, &WSAData);
|
||||
if (WSAresult != 0)
|
||||
@@ -1247,21 +1216,14 @@ boolean I_InitTcpDriver(void)
|
||||
if (WSAresult != WSAVERNOTSUPPORTED)
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock(TCP/IP) error: %s\n",WSError);
|
||||
}
|
||||
#ifdef USE_WINSOCK2
|
||||
if(LOBYTE(WSAData.wVersion) != 2 ||
|
||||
|
||||
if (LOBYTE(WSAData.wVersion) != 2 ||
|
||||
HIBYTE(WSAData.wVersion) != 2)
|
||||
{
|
||||
WSACleanup();
|
||||
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 2.2 driver detected\n");
|
||||
}
|
||||
#else
|
||||
if (LOBYTE(WSAData.wVersion) != 1 ||
|
||||
HIBYTE(WSAData.wVersion) != 1)
|
||||
{
|
||||
WSACleanup();
|
||||
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 1.1 driver detected\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription);
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus);
|
||||
#endif
|
||||
@@ -1301,7 +1263,6 @@ void I_ShutdownTcpDriver(void)
|
||||
|
||||
CONS_Printf("I_ShutdownTcpDriver: ");
|
||||
#ifdef USE_WINSOCK
|
||||
WS_addrinfocleanup();
|
||||
WSACleanup();
|
||||
#endif
|
||||
CONS_Printf("shut down\n");
|
||||
@@ -1310,24 +1271,24 @@ void I_ShutdownTcpDriver(void)
|
||||
|
||||
static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const char *port, boolean test)
|
||||
{
|
||||
struct my_addrinfo *ai = NULL, *runp, hints;
|
||||
addrinfo_t *ai = NULL, *runp, hints;
|
||||
int gaie;
|
||||
size_t i;
|
||||
|
||||
if (!port || !port[0])
|
||||
port = DEFAULTPORT;
|
||||
|
||||
memset (&hints, 0x00, sizeof (hints));
|
||||
memset(&hints, 0x00, sizeof (hints));
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
gaie = I_getaddrinfo(address, port, &hints, &ai);
|
||||
gaie = getaddrinfo(address, port, &hints, &ai);
|
||||
|
||||
if (gaie != 0)
|
||||
{
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1356,7 +1317,7 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const
|
||||
if (runp != NULL)
|
||||
memcpy(sin, runp->ai_addr, runp->ai_addrlen);
|
||||
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return (runp != NULL);
|
||||
}
|
||||
@@ -1554,7 +1515,7 @@ static boolean SOCK_SetUnbanTime(time_t timestamp)
|
||||
|
||||
static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
{
|
||||
struct my_addrinfo *ai, *runp, hints;
|
||||
addrinfo_t *ai, *runp, hints;
|
||||
int gaie;
|
||||
|
||||
if (!address)
|
||||
@@ -1566,7 +1527,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
gaie = I_getaddrinfo(address, "0", &hints, &ai);
|
||||
gaie = getaddrinfo(address, "0", &hints, &ai);
|
||||
if (gaie != 0)
|
||||
return false;
|
||||
|
||||
@@ -1611,7 +1572,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1660,8 +1621,6 @@ boolean I_InitTcpNetwork(void)
|
||||
// FIXME: for dedicated server, numnodes needs to be set to 0 upon start
|
||||
if (dedicated)
|
||||
doomcom->numnodes = 0;
|
||||
/* else if (M_IsNextParm())
|
||||
doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/
|
||||
else
|
||||
doomcom->numnodes = 1;
|
||||
|
||||
@@ -1746,5 +1705,3 @@ boolean I_InitTcpNetwork(void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include "i_addrinfo.c"
|
||||
+60
-16
@@ -797,8 +797,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex));
|
||||
if (!mobj)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MOBJ);
|
||||
WRITEUINT32(*p, mobj->mobjnum);
|
||||
}
|
||||
@@ -808,8 +812,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
player_t *player = *((player_t **)lua_touserdata(gL, myindex));
|
||||
if (!player)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_PLAYER);
|
||||
WRITEUINT8(*p, player - players);
|
||||
}
|
||||
@@ -819,8 +827,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex));
|
||||
if (!mapthing)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MAPTHING);
|
||||
WRITEUINT16(*p, mapthing - mapthings);
|
||||
}
|
||||
@@ -830,8 +842,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex));
|
||||
if (!vertex)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_VERTEX);
|
||||
WRITEUINT16(*p, vertex - vertexes);
|
||||
}
|
||||
@@ -841,8 +857,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
line_t *line = *((line_t **)lua_touserdata(gL, myindex));
|
||||
if (!line)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_LINE);
|
||||
WRITEUINT16(*p, line - lines);
|
||||
}
|
||||
@@ -852,8 +872,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
side_t *side = *((side_t **)lua_touserdata(gL, myindex));
|
||||
if (!side)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SIDE);
|
||||
WRITEUINT16(*p, side - sides);
|
||||
}
|
||||
@@ -863,8 +887,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex));
|
||||
if (!subsector)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SUBSECTOR);
|
||||
WRITEUINT16(*p, subsector - subsectors);
|
||||
}
|
||||
@@ -874,8 +902,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex));
|
||||
if (!sector)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SECTOR);
|
||||
WRITEUINT16(*p, sector - sectors);
|
||||
}
|
||||
@@ -885,8 +917,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
|
||||
if (!slope)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SLOPE);
|
||||
WRITEUINT16(*p, slope->id);
|
||||
}
|
||||
@@ -896,8 +932,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
|
||||
if (!header)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MAPHEADER);
|
||||
WRITEUINT16(*p, header - *mapheaderinfo);
|
||||
}
|
||||
@@ -1003,19 +1043,23 @@ static void ArchiveTables(UINT8 **p)
|
||||
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
|
||||
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
||||
{
|
||||
lua_pushvalue(gL, -2);
|
||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i);
|
||||
lua_pop(gL, 1);
|
||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
|
||||
}
|
||||
else if (e == 3) // nil key due to invalid userdata. NOT an error.
|
||||
{
|
||||
lua_pop(gL, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write value
|
||||
e = ArchiveValue(p, TABLESINDEX, -1);
|
||||
if (e == 1)
|
||||
{
|
||||
n++; // the table contained a new table we'll have to archive. :(
|
||||
}
|
||||
else if (e == 2) // invalid value type
|
||||
{
|
||||
lua_pushvalue(gL, -2);
|
||||
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -1));
|
||||
lua_pop(gL, 1);
|
||||
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
|
||||
}
|
||||
|
||||
lua_pop(gL, 1);
|
||||
|
||||
+32
-32
@@ -61,7 +61,7 @@ typedef enum
|
||||
//
|
||||
// P_ArchivePlayer
|
||||
//
|
||||
static inline void P_ArchivePlayer(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save)
|
||||
{
|
||||
const player_t *player = &players[consoleplayer];
|
||||
INT32 pllives = player->lives;
|
||||
@@ -85,7 +85,7 @@ static inline void P_ArchivePlayer(savebuffer_t *save)
|
||||
//
|
||||
// P_UnArchivePlayer
|
||||
//
|
||||
static inline void P_UnArchivePlayer(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save)
|
||||
{
|
||||
savedata.skincolor = READUINT8(save->p);
|
||||
savedata.skin = READUINT8(save->p);
|
||||
@@ -1043,25 +1043,25 @@ typedef enum
|
||||
tc_end
|
||||
} specials_e;
|
||||
|
||||
static inline UINT32 SaveMobjnum(const mobj_t *mobj)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveMobjnum(const mobj_t *mobj)
|
||||
{
|
||||
if (mobj) return mobj->mobjnum;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline UINT32 SaveSector(const sector_t *sector)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveSector(const sector_t *sector)
|
||||
{
|
||||
if (sector) return (UINT32)(sector - sectors);
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 SaveLine(const line_t *line)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveLine(const line_t *line)
|
||||
{
|
||||
if (line) return (UINT32)(line - lines);
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 SavePlayer(const player_t *player)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SavePlayer(const player_t *player)
|
||||
{
|
||||
if (player) return (UINT32)(player - players);
|
||||
return 0xFFFFFFFF;
|
||||
@@ -1476,7 +1476,7 @@ static void SaveElevatorThinker(savebuffer_t *save, const thinker_t *th, const U
|
||||
//
|
||||
// Saves a scroll_t thinker
|
||||
//
|
||||
static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const scroll_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1497,7 +1497,7 @@ static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, co
|
||||
//
|
||||
// Saves a friction_t thinker
|
||||
//
|
||||
static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const friction_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1513,7 +1513,7 @@ static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th,
|
||||
//
|
||||
// Saves a pusher_t thinker
|
||||
//
|
||||
static inline void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const pusher_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1598,7 +1598,7 @@ static void SaveDisappearThinker(savebuffer_t *save, const thinker_t *th, const
|
||||
//
|
||||
// Saves a polyrotate_t thinker
|
||||
//
|
||||
static inline void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const polyrotate_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1935,25 +1935,25 @@ mobj_t *P_FindNewPosition(UINT32 oldposition)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline mobj_t *LoadMobj(UINT32 mobjnum)
|
||||
FUNCINLINE static ATTRINLINE mobj_t *LoadMobj(UINT32 mobjnum)
|
||||
{
|
||||
if (mobjnum == 0) return NULL;
|
||||
return (mobj_t *)(size_t)mobjnum;
|
||||
}
|
||||
|
||||
static inline sector_t *LoadSector(UINT32 sector)
|
||||
FUNCINLINE static ATTRINLINE sector_t *LoadSector(UINT32 sector)
|
||||
{
|
||||
if (sector >= numsectors) return NULL;
|
||||
return §ors[sector];
|
||||
}
|
||||
|
||||
static inline line_t *LoadLine(UINT32 line)
|
||||
FUNCINLINE static ATTRINLINE line_t *LoadLine(UINT32 line)
|
||||
{
|
||||
if (line >= numlines) return NULL;
|
||||
return &lines[line];
|
||||
}
|
||||
|
||||
static inline player_t *LoadPlayer(UINT32 player)
|
||||
FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player)
|
||||
{
|
||||
if (player >= MAXPLAYERS) return NULL;
|
||||
return &players[player];
|
||||
@@ -2529,7 +2529,7 @@ static void LoadScrollThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a friction_t from a save game
|
||||
//
|
||||
static inline void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
friction_t *ht = (friction_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2576,7 +2576,7 @@ static void LoadPusherThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a laserthink_t from a save game
|
||||
//
|
||||
static inline void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
laserthink_t *ht = (laserthink_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2621,7 +2621,7 @@ FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(savebuffer_t *save, acti
|
||||
//
|
||||
// Loads a executor_t from a save game
|
||||
//
|
||||
static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
executor_t *ht = (executor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2639,7 +2639,7 @@ static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a disappear_t thinker
|
||||
//
|
||||
static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
disappear_t *ht = (disappear_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2660,7 +2660,7 @@ static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a polyrotate_t thinker
|
||||
//
|
||||
static inline void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyrotate_t *ht = (polyrotate_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2720,7 +2720,7 @@ static void LoadPolymoveThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a polywaypoint_t thinker
|
||||
//
|
||||
static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polywaypoint_t *ht = (polywaypoint_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2776,7 +2776,7 @@ static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinke
|
||||
//
|
||||
// loads a polyslidedoor_t thinker
|
||||
//
|
||||
static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyslidedoor_t *ht = (polyslidedoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2814,7 +2814,7 @@ static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 think
|
||||
//
|
||||
// Loads a polyswingdoor_t thinker
|
||||
//
|
||||
static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyswingdoor_t *ht = (polyswingdoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2847,7 +2847,7 @@ static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 think
|
||||
//
|
||||
// Loads a polydisplace_t thinker
|
||||
//
|
||||
static inline void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polydisplace_t *ht = (polydisplace_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -3115,7 +3115,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
|
||||
#define PD_FLAGS 0x01
|
||||
#define PD_TRANS 0x02
|
||||
|
||||
static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
{
|
||||
UINT8 diff = 0;
|
||||
WRITEINT32(save->p, po->id);
|
||||
@@ -3137,7 +3137,7 @@ static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
WRITEINT32(save->p, po->translucency);
|
||||
}
|
||||
|
||||
static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
{
|
||||
INT32 id;
|
||||
UINT32 angle;
|
||||
@@ -3172,7 +3172,7 @@ static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
Polyobj_MoveOnLoad(po, angle, x, y);
|
||||
}
|
||||
|
||||
static inline void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
@@ -3185,7 +3185,7 @@ static inline void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
P_ArchivePolyObj(save, &PolyObjects[i]);
|
||||
}
|
||||
|
||||
static inline void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
{
|
||||
INT32 i, numSavedPolys;
|
||||
|
||||
@@ -3203,7 +3203,7 @@ static inline void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
//
|
||||
// P_FinishMobjs
|
||||
//
|
||||
static inline void P_FinishMobjs(void)
|
||||
FUNCINLINE static ATTRINLINE void P_FinishMobjs(void)
|
||||
{
|
||||
thinker_t *currentthinker;
|
||||
mobj_t *mobj;
|
||||
@@ -3220,7 +3220,7 @@ static inline void P_FinishMobjs(void)
|
||||
}
|
||||
}
|
||||
|
||||
static inline mobj_t *RelinkMobj(mobj_t **ptr)
|
||||
FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr)
|
||||
{
|
||||
UINT32 temp = (UINT32)(size_t)*ptr;
|
||||
*ptr = NULL;
|
||||
@@ -3269,7 +3269,7 @@ static void P_RelinkPointers(void)
|
||||
//
|
||||
// P_NetArchiveSpecials
|
||||
//
|
||||
static inline void P_NetArchiveSpecials(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_NetArchiveSpecials(savebuffer_t *save)
|
||||
{
|
||||
size_t i, z;
|
||||
|
||||
@@ -3347,7 +3347,7 @@ static void P_NetUnArchiveSpecials(savebuffer_t *save)
|
||||
// =======================================================================
|
||||
// Misc
|
||||
// =======================================================================
|
||||
static inline void P_ArchiveMisc(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save)
|
||||
{
|
||||
if (gamecomplete)
|
||||
WRITEINT16(save->p, gamemap | 8192);
|
||||
@@ -3360,7 +3360,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save)
|
||||
WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder));
|
||||
}
|
||||
|
||||
static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
{
|
||||
char testname[sizeof(timeattackfolder)];
|
||||
|
||||
|
||||
Reference in new issue
Block a user