Try to clean up a few things in the hopes of making Eukara's efforts easier. That or just to give him conflicts.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5081 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-03-26 23:03:02 +00:00
parent e200777d6a
commit 5e58832acf
14 changed files with 360 additions and 130 deletions

View file

@ -4838,7 +4838,7 @@ void Host_DoRunFile(hrf_t *f)
qboolean Host_RunFile(const char *fname, int nlen, vfsfile_t *file)
{
hrf_t *f;
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT)
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) && !defined(_XBOX)
//win32 file urls are basically fucked, so defer to the windows api.
char utf8[MAX_OSPATH*3];
if (nlen >= 7 && !strncmp(fname, "file://", 7))
@ -5664,7 +5664,7 @@ void Host_FinishLoading(void)
"\n"
"See the GNU General Public License for more details.\n");
#if defined(_WIN32) && !defined(FTE_SDL) && defined(WEBCLIENT)
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(_XBOX) && defined(WEBCLIENT)
if (Sys_RunInstaller())
Sys_Quit();
#endif

View file

@ -562,24 +562,8 @@ void SV_Master_Shutdown (void)
//remove dead servers.
//master was polled a minute ago and server was not on list - server on multiple masters would be awkward.
#ifdef _WIN32
#include "winquake.h"
#else
typedef int SOCKET;
#endif
#include "netinc.h"
#ifdef AF_IPX
#define USEIPX
#endif
#if defined(_XBOX)
#undef TCPCONNECT
#undef IPPROTO_IPV6
#undef USEIPX
#endif
//the number of servers should be limited only by memory.
cvar_t slist_cacheinfo = CVAR("slist_cacheinfo", "0"); //this proves dangerous, memory wise.

View file

@ -1,7 +1,178 @@
#include <xtl.h>
#include "quakedef.h"
#include <xtl.h>
void main( int argc, char **argv) {
/*Timers, supposedly xbox supports QueryPerformanceCounter stuff*/
double Sys_DoubleTime (void)
{
static int first = 1;
static LARGE_INTEGER qpcfreq;
LARGE_INTEGER PerformanceCount;
static LONGLONG oldcall;
static LONGLONG firsttime;
LONGLONG diff;
QueryPerformanceCounter (&PerformanceCount);
if (first)
{
first = 0;
QueryPerformanceFrequency(&qpcfreq);
firsttime = PerformanceCount.QuadPart;
diff = 0;
}
else
diff = PerformanceCount.QuadPart - oldcall;
if (diff >= 0)
oldcall = PerformanceCount.QuadPart;
return (oldcall - firsttime) / (double)qpcfreq.QuadPart;
}
unsigned int Sys_Milliseconds (void)
{
return Sys_DoubleTime()*1000;
}
NORETURN void VARGS Sys_Error (const char *error, ...)
{
//FIXME: panic! everyone panic!
//you might want to figure out some way to display the message...
for(;;)
;
}
void Sys_Sleep(double seconds)
{ //yields to other processes/threads for a bit.
}
void Sys_Quit (void)
{
#if 0
Host_Shutdown ();
//successful execution.
//should go back to the system menu or something, or possibly longjmp out of the main loop.
for (;;)
;
exit(1);
#endif
}
void Sys_Shutdown(void)
{
}
void Sys_Init(void)
{ //register system-specific cvars here
}
/*prints to dedicated server console or debug output*/
void VARGS Sys_Printf (char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_start (argptr,fmt);
_vsnprintf (msg,sizeof(msg)-1, fmt,argptr);
msg[sizeof(msg)-1] = 0; //_vsnprintf sucks.
va_end (argptr);
//no idea what the stdout is hooked up to, lets try it anyway.
printf("%s", msg);
}
/*returns the system video mode settings, ish*/
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{
//FIXME: use XGetVideoStandard or XGetVideoFlags or something
*width = 640;
*height = 480;
*bpp = 32;
*refreshrate = 60;
return true;
}
/*dedicated server type stuff*/
qboolean Sys_InitTerminal(void)
{
return false; //failure
}
void Sys_CloseTerminal (void)
{
}
char *Sys_ConsoleInput (void)
{ //returns any text typed on the stdin, when acting as a dedicated server.
//this includes debugger commands if we're integrated with fteqccgui
return NULL;
}
/*various system notifications*/
void Sys_ServerActivity(void)
{ //player joined the server or said something. would normally flash the app in the system tray.
}
/*check any system message queues here*/
void Sys_SendKeyEvents(void)
{
}
qboolean Sys_RandomBytes(qbyte *string, int len)
{
//FIXME: should return some cryptographically strong random number data from some proper crypto library. C's rand function isn't really strong enough.
return false;
}
/*filesystem stuff*/
void Sys_mkdir (char *path)
{
}
qboolean Sys_remove (char *path)
{
return false; //false for failure
}
qboolean Sys_Rename (char *oldfname, char *newfname)
{
return false; //false for failure
}
int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
{
//if func returns false, abort with false return value, otherwise return true.
//use wildcmd to compare two filenames
//note that match may contain wildcards and multiple directories with multiple wildcards all over.
return true;
}
/*consoles don't tend to need system clipboards, so this is fully internal to our engine*/
#define SYS_CLIPBOARD_SIZE 256
static char clipboard_buffer[SYS_CLIPBOARD_SIZE] = {0};
char *Sys_GetClipboard(void)
{
return clipboard_buffer;
}
void Sys_CloseClipboard(char *bf)
{
}
void Sys_SaveClipboard(char *text)
{
Q_strncpyz(clipboard_buffer, text, SYS_CLIPBOARD_SIZE);
}
/*dynamic library stubs*/
dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
{
Con_Printf("Sys_LoadLibrary: %s\n", name);
return NULL;
}
void Sys_CloseLibrary(dllhandle_t *lib)
{
}
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
{
return NULL; //unsupported
}
char *Sys_GetNameForAddress(dllhandle_t *module, void *address)
{
return NULL; //unsupported (on most platforms, actually)
}
void main( int argc, char **argv)
{
float time, lasttime;
quakeparms_t parms;
@ -23,3 +194,47 @@ void main( int argc, char **argv) {
}
}
/*input stubs
in_generic.c should make these kinda useless, but sometimes you need more than the following three functions:
void IN_JoystickAxisEvent(unsigned int devid, int axis, float value);
void IN_KeyEvent(unsigned int devid, int down, int keycode, int unicode);
void IN_MouseMove(unsigned int devid, int abs, float x, float y, float z, float size);
that said, if they're enough, then just call those in Sys_SendKeyEvents. You can also call them from other threads just fine.
their devid values should be assigned only when a button is first pressed, or something, so controllers get assigned to seats in the order that they're pressed. so player 1 always hits a button first to ensure that they are player 1.
or just hardcode those based upon usbport numbers, but that's unreliable with usb hubs.
*/
void INS_Shutdown (void)
{
}
void INS_ReInit (void)
{
}
void INS_Move(float *movements, int pnum)
{
//accululates system-specific inputs on a per-seat basis.
}
void INS_Init (void)
{
}
void INS_Accumulate(void) //input polling
{
}
void INS_Commands (void) //used to Cbuf_AddText joystick button events in windows.
{
}
void INS_EnumerateDevices(void *ctx, void(*callback)(void *ctx, const char *type, const char *devicename, unsigned int *qdevid))
{
#if 0
unsigned int i;
for (i = 0; i < MAX_JOYSTICKS; i++)
if (sdljoy[i].controller)
callback(ctx, "joy", sdljoy[i].devname, &sdljoy[i].qdevid);
#endif
}

View file

@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <WinSockX.h>
#else
#include <windows.h>
#include <winsock2.h>
#include <mmsystem.h>
#include <mmreg.h>
#endif

View file

@ -109,7 +109,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if !defined(NO_DIRECTX) && !defined(NODIRECTX) && defined(_WIN32)
#define AVAIL_DINPUT
#define AVAIL_DSOUND
#undef AVAIL_WASAPI
#define AVAIL_WASAPI
#endif
#ifdef WINRT
#define AVAIL_XAUDIO2
@ -117,7 +117,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AVAIL_XZDEC
#if !defined(MINIMAL) && !defined(NPFTE) && !defined(NPQTV)
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT)
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) && !defined(_XBOX)
#if !defined(_MSC_VER) || _MSC_VER > 1200
#define HAVE_WINSSPI //built in component, checks against windows' root ca database and revocations etc.
#endif
@ -125,9 +125,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define HAVE_GNUTLS //currently disabled as it does not validate the server's certificate, beware the mitm attack.
#endif
#endif
#if defined(HAVE_WINSSPI) || defined(HAVE_GNUTLS)
#define HAVE_SSL
#endif
//#define DYNAMIC_ZLIB
//#define DYNAMIC_LIBPNG
@ -164,6 +161,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef AVAIL_WASAPI //wasapi is available in the vista sdk, while that's compatible with earlier versions, its not really expected until 2008
#endif
#define HAVE_TCP //says we can use tcp too (either ipv4 or ipv6)
#define HAVE_PACKET //if we have the socket api at all...
//set any additional defines or libs in win32
#define LOADERTHREAD
@ -198,10 +198,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef AVAIL_JPEGLIB
#undef AVAIL_XZDEC
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(MULTITHREAD) //always thread on win32 non-minimal builds
#ifndef _XBOX
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(MULTITHREAD) && !defined(_XBOX) //always thread on win32 non-minimal builds
#define MULTITHREAD
#endif
#endif
#elif defined(MINIMAL)
#define QUAKESTATS
@ -258,10 +256,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PSKMODELS //PSK model format (ActorX stuff from UT, though not the format the game itself uses)
#define HALFLIFEMODELS //halflife model support (experimental)
#define INTERQUAKEMODELS
#ifndef _XBOX
#define RAGDOLL
#endif
#define HUFFNETWORK //huffman network compression
#define DOOMWADS //doom wad/sprite support
@ -404,7 +399,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef HAVE_SPEECHTOTEXT //windows speech-to-text thing
#endif
#if defined(_XBOX)
#undef HAVE_TCP //FIXME
#undef HAVE_PACKET //FIXME
#undef SUPPORT_ICE //screw that
#undef PLUGINS //would need LoadLibrary working properly.
#undef AVAIL_DINPUT //xbox apparently only really does controllers.
#undef AVAIL_DSOUND //FIXME
#undef TEXTEDITOR //its hard to edit text when you have just a controller (and no onscreen keyboard)
#undef RAGDOLL //needs a proper physics engine
#undef AVAIL_MP3_ACM //api not supported
#undef HAVE_SPEECHTOTEXT //api not supported
#undef MULTITHREAD //no CreateThread stuff.
#undef SUBSERVERS //single-process.
#endif
#ifdef FTE_TARGET_WEB
//sandboxing...
#undef HAVE_TCP //websockets are not real tcp.
#undef HAVE_PACKET //no udp support
//try to trim the fat
#undef VOICECHAT //too lazy to compile speex
#undef HLCLIENT //dlls...
@ -437,6 +452,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// #undef RTLIGHTS
#endif
#ifdef WINRT
//microsoft do not support winsock any more.
#undef HAVE_TCP
#undef HAVE_PACKET
#undef TCPCONNECT //err...
#undef IRCCONNECT //not happening
#undef AVAIL_DSOUND //yeah, good luck there
@ -456,6 +475,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GLESONLY //should reduce the conditions a little
#endif
#if defined(NACL)
//stuff is sandboxed.
#undef HAVE_TCP //websockets are not true tcp
#undef HAVE_PACKET //no udp support.
#undef SUPPORT_ICE
#undef CL_MASTER //no sockets support
#undef SV_MASTER //noone uses this anyway
@ -472,6 +495,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef USE_MYSQL
#endif
#if defined(HAVE_WINSSPI) || defined(HAVE_GNUTLS)
#define HAVE_SSL
#endif
#if defined(USE_SQLITE) || defined(USE_MYSQL)
#define SQL
#endif
@ -529,6 +556,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef SUPPORT_ICE //depends upon zlib's crc32 for fingerprinting. I cba writing my own.
#endif
#ifndef HAVE_TCP
#undef TCPCONNECT
#undef IRCCONNECT
#undef WEBSERVER
#undef WEBCLIENT
#endif
#ifndef HAVE_PACKET
#undef SV_MASTER
#undef CL_MASTER
#undef SUPPORT_ICE
#endif
#ifdef SERVERONLY //remove options that don't make sense on only a server
#undef Q2CLIENT
#undef Q3CLIENT

View file

@ -1,9 +1,6 @@
#ifndef NETINC_INCLUDED
#define NETINC_INCLUDED
#if !defined(NACL) && !defined(FTE_TARGET_WEB) && !defined(WINRT)
#define HAVE_IPV4 //says we can send and receive AF_INET ipv4 udp packets.
#define HAVE_TCP //says we can use tcp too (either ipv4 or ipv6)
#define HAVE_PACKET //if we have the socket api at all...
#endif
#ifndef HAVE_PACKET
@ -36,26 +33,23 @@
#define ntohl BigLong
#elif defined(_WIN32)
#ifdef _XBOX
#include <xtl.h>
#include <WinSockX.h>
#else
#ifdef _MSC_VER
#define USEIPX
#endif
#define WIN32_LEAN_AND_MEAN
#ifdef _XBOX
#include <xtl.h>
#include <WinSockX.h>
#else
#include <windows.h>
#include <winsock2.h>
#endif
// #include "winquake.h"
#ifndef _XBOX
#ifdef USEIPX
#include "wsipx.h"
#endif
#include <ws2tcpip.h>
#endif
#endif
#include <errno.h>
#ifndef IPPROTO_IPV6
#if !defined(IPPROTO_IPV6) && !defined(_XBOX)
/*for msvc6*/
#define IPPROTO_IPV6 41
@ -110,6 +104,11 @@
#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27
#endif
#define HAVE_IPV4
#ifdef IPPROTO_IPV6
#define HAVE_IPV6
#endif
#else
#include <sys/time.h>
#include <sys/types.h>
@ -141,7 +140,14 @@
#endif
#if defined(AF_INET6) && !defined(IPPROTO_IPV6)
#define IPPROTO_IPV6 IPPROTO_IPV6
#define IPPROTO_IPV6 IPPROTO_IPV6 //fte often just checks to see if IPPROTO_IPV6 is defined or not, which doesn't work if its an enum value or somesuch...
#endif
#if defined(AF_INET)
#define HAVE_IPV4
#endif
#ifdef IPPROTO_IPV6
#define HAVE_IPV6
#endif
#define SOCKET int
@ -314,3 +320,5 @@ vfsfile_t *FS_OpenTCP(const char *name, int defaultport);
#ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0
#endif
#endif //NETINC_INCLUDED

View file

@ -940,12 +940,6 @@ static int Plug_NewStreamHandle(plugstream_e type)
return i;
}
#if defined(_XBOX)
#undef TCPCONNECT
#undef IPPROTO_IPV6
#undef USEIPX
#endif
#ifdef HAVE_PACKET
//EBUILTIN(int, NET_TCPListen, (char *ip, int port, int maxcount));
//returns a new socket with listen enabled.

View file

@ -111,13 +111,11 @@ extern int isPlugin; //if 2, we were invoked by a debugger, and we need to give
static int debuggerstacky;
#endif
#if defined(_WIN32) && !defined(FTE_SDL)
#ifndef _XBOX
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(_XBOX)
#include <windows.h>
void INS_UpdateGrabs(int fullscreen, int activeapp);
#endif
void INS_UpdateGrabs(int fullscreen, int activeapp);
#endif
int QCLibEditor(pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *error, pbool fatal);
void QCLoadBreakpoints(const char *vmname, const char *progsname)
{ //this asks the gui to reapply any active breakpoints and waits for them so that any spawn functions can be breakpointed properly.
@ -307,7 +305,8 @@ qboolean QCExternalDebuggerCommand(char *text)
int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *reason, pbool fatal)
{
#if defined(_WIN32) && !defined(SERVERONLY) && !defined(FTE_SDL) && !defined(_XBOX)
#ifndef SERVERONLY
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(_XBOX)
if (isPlugin >= 2)
{
if (wantquit)
@ -368,6 +367,7 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int
return debuggerresume;
}
#endif
#endif
#ifdef TEXTEDITOR
return QCLibEditor(prinst, filename, line, statement, reason, fatal);

View file

@ -172,7 +172,7 @@ void NPQTV_Sys_MainLoop(void);
#define UPD_STABLE 1
#define UPD_TESTING 2
#if defined(WEBCLIENT) && defined(_WIN32) && !defined(SERVERONLY)
#if defined(WEBCLIENT) && defined(_WIN32) && !defined(SERVERONLY) && !defined(_XBOX)
int StartLocalServer(int close);
#define HAVEAUTOUPDATE

View file

@ -28,27 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma warning(disable : 4051) // ALPHA
#endif
#ifdef _WIN32
#ifndef WIN32_BLOATED
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef _XBOX
#include <windows.h>
#endif
#if defined(WINAPI_FAMILY) && !defined(WINRT)
#if WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
//don't just define it. things that don't #include winquake.h / glquake.h need it too.
#error "WINRT needs to be defined for non-desktop"
#endif
#endif
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
qboolean BoundsIntersect (vec3_t mins1, vec3_t maxs1, vec3_t mins2, vec3_t maxs2);
void ClearBounds (vec3_t mins, vec3_t maxs);
@ -102,14 +81,25 @@ void Mod_LightmapAllocBlock(lmalloc_t *lmallocator, int w, int h, unsigned short
#define GLclampd GLclampf
#define GLdouble GLfloat
#else
#ifdef _WIN32 //windows might use the standard header filename, but it still requires that we manually include windows.h first.
#ifndef WIN32_BLOATED
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#include <GL/gl.h>
#ifdef GL_STATIC
#define GL_GLEXT_PROTOTYPES
#include <GL/glext.h>
#endif
#endif
//#include <GL/glu.h>
#include "glsupp.h"
// #include <GL/glu.h>
#ifndef APIENTRY
#define APIENTRY //our code decorates function pointers with this for windows, so make sure it exists on systems that don't need it.
#endif
#include "glsupp.h"

View file

@ -6,9 +6,6 @@
#ifdef WEBSVONLY
#include "quakedef.h"
#ifdef _WIN32
#include "winquake.h"
#endif
#define Con_TPrintf IWebPrintf
#define IWebPrintf printf
@ -33,10 +30,6 @@ qboolean SV_AllowDownload (const char *name);
typedef qboolean iwboolean;
#ifndef _WIN32
#define INVALID_SOCKET ~0
#endif
//it's not allowed to error.
#ifndef WEBSVONLY
void VARGS IWebDPrintf(char *fmt, ...) LIKEPRINTF(1);

View file

@ -3,6 +3,7 @@
#ifdef WEBSERVER
#include "iweb.h"
#include "netinc.h"
#ifdef WEBSVONLY //we need some functions from quake

View file

@ -1709,7 +1709,9 @@ struct
{"SetExtField", QVM_SetExtField},
{"GetExtField", QVM_GetExtField},
{"ChangeLevel2", QVM_ChangeLevel2}, //with start spot
{"URI_Query", QVM_uri_query}, //with start spot
#ifdef WEBCLIENT
{"URI_Query", QVM_uri_query},
#endif
{"particleeffectnum", QVM_particleeffectnum},
{"trailparticles", QVM_trailparticles},
{"pointparticles", QVM_pointparticles},

View file

@ -236,8 +236,8 @@ char *JCL_Info_ValueForKey (char *s, const char *key, char *valuebuf, int valuel
}
}
#ifdef _WIN32
#include "windns.h"
#if defined(_WIN32) && defined(HAVE_PACKET)
#include <windns.h>
static DNS_STATUS (WINAPI *pDnsQuery_UTF8) (PCSTR pszName, WORD wType, DWORD Options, PIP4_ARRAY aipServers, PDNS_RECORD *ppQueryResults, PVOID *pReserved);
static VOID (WINAPI *pDnsRecordListFree)(PDNS_RECORD pRecordList, DNS_FREE_TYPE FreeType);
static HMODULE dnsapi_lib;
@ -263,7 +263,7 @@ qboolean NET_DNSLookup_SRV(char *host, char *out, int outlen)
}
return false;
}
#else
#elif defined(__unix__) || defined(ANDROID) || defined(__MACH__) || defined(__linux__)
#include <resolv.h>
#include <arpa/nameser.h>
qboolean NET_DNSLookup_SRV(char *host, char *out, int outlen)
@ -352,6 +352,11 @@ qboolean NET_DNSLookup_SRV(char *host, char *out, int outlen)
return false;
return true;
}
#else
qboolean NET_DNSLookup_SRV(char *host, char *out, int outlen)
{
return false;
}
#endif