2004-12-09 23:38:11 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
|
2004-12-10 21:31:53 +00:00
|
|
|
#include <SDL.h>
|
2007-12-30 00:09:34 +00:00
|
|
|
#ifdef MULTITHREAD
|
|
|
|
#include <SDL_thread.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
#include <SDL_loadso.h>
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
#include <fcntl.h>
|
2013-04-08 09:45:26 +00:00
|
|
|
#include <sys/stat.h>
|
2010-08-11 23:55:35 +00:00
|
|
|
#else
|
|
|
|
#include <direct.h>
|
2004-12-09 23:38:11 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-11 05:03:07 +00:00
|
|
|
#ifdef FTE_TARGET_WEB
|
|
|
|
#include <emscripten/emscripten.h>
|
|
|
|
#endif
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
|
|
|
SDL_Window *sdlwindow;
|
|
|
|
#endif
|
|
|
|
|
2005-11-29 23:14:45 +00:00
|
|
|
#ifndef isDedicated
|
2004-12-09 23:38:11 +00:00
|
|
|
qboolean isDedicated;
|
2005-11-29 23:14:45 +00:00
|
|
|
#endif
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
void Sys_Error (const char *error, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char string[1024];
|
|
|
|
|
|
|
|
va_start (argptr,error);
|
|
|
|
vsnprintf (string, sizeof (string), error, argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
fprintf(stderr, "Error: %s\n", string);
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
Sys_Printf ("Quake Error: %s\n", string);
|
|
|
|
|
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Sys_Error", string, sdlwindow);
|
|
|
|
#endif
|
2004-12-09 23:38:11 +00:00
|
|
|
|
2005-01-12 08:38:31 +00:00
|
|
|
if (COM_CheckParm("-crashonerror"))
|
|
|
|
*(int*)-3 = 0;
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
Host_Shutdown ();
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2010-12-05 02:52:41 +00:00
|
|
|
void Sys_RecentServer(char *command, char *target, char *title, char *desc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-28 15:15:35 +00:00
|
|
|
qboolean Sys_RandomBytes(qbyte *string, int len)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
//print into stdout
|
|
|
|
void Sys_Printf (char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
|
|
|
|
va_start (argptr,fmt);
|
|
|
|
vprintf (fmt,argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
}
|
|
|
|
|
2007-07-23 12:05:41 +00:00
|
|
|
unsigned int Sys_Milliseconds(void)
|
|
|
|
{
|
|
|
|
static int first = true;
|
2015-09-18 20:30:10 +00:00
|
|
|
static unsigned long starttime = 0;
|
|
|
|
unsigned long now;
|
2007-07-23 12:05:41 +00:00
|
|
|
|
2015-09-18 20:30:10 +00:00
|
|
|
now = SDL_GetTicks();
|
2007-07-23 12:05:41 +00:00
|
|
|
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
first = false;
|
2015-09-18 20:30:10 +00:00
|
|
|
starttime = now;
|
2007-07-23 12:05:41 +00:00
|
|
|
}
|
2015-09-18 20:30:10 +00:00
|
|
|
|
|
|
|
return now - starttime;
|
2007-07-23 12:05:41 +00:00
|
|
|
}
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
//return the current time, in the form of a double
|
|
|
|
double Sys_DoubleTime (void)
|
|
|
|
{
|
2013-04-04 08:08:49 +00:00
|
|
|
return Sys_Milliseconds() / 1000.0;
|
|
|
|
/*
|
2004-12-09 23:38:11 +00:00
|
|
|
static int first = true;
|
|
|
|
static double oldtime = 0.0, curtime = 0.0;
|
|
|
|
double newtime;
|
|
|
|
|
|
|
|
newtime = (double) SDL_GetTicks() / 1000.0;
|
|
|
|
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
first = false;
|
|
|
|
oldtime = newtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newtime < oldtime)
|
|
|
|
{
|
|
|
|
// warn if it's significant
|
|
|
|
if (newtime - oldtime < -0.01)
|
|
|
|
Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
curtime += newtime - oldtime;
|
|
|
|
oldtime = newtime;
|
|
|
|
|
|
|
|
return curtime;
|
2013-04-04 08:08:49 +00:00
|
|
|
*/
|
2004-12-09 23:38:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//create a directory
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
void Sys_mkdir (const char *path)
|
2004-12-09 23:38:11 +00:00
|
|
|
{
|
|
|
|
#if WIN32
|
|
|
|
_mkdir (path);
|
|
|
|
#else
|
2014-02-07 08:38:40 +00:00
|
|
|
//user, group, others
|
|
|
|
mkdir (path, 0755); //WARNING: DO NOT RUN AS ROOT!
|
2004-12-09 23:38:11 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
qboolean Sys_rmdir (const char *path)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
#if WIN32
|
|
|
|
ret = _rmdir (path);
|
|
|
|
#else
|
2017-05-18 10:24:09 +00:00
|
|
|
ret = rmdir (path);
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
#endif
|
|
|
|
if (ret == 0)
|
|
|
|
return true;
|
2017-05-18 10:24:09 +00:00
|
|
|
// if (errno == ENOENT)
|
|
|
|
// return true;
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
//unlink a file
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
qboolean Sys_remove (const char *path)
|
2004-12-09 23:38:11 +00:00
|
|
|
{
|
|
|
|
remove(path);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
qboolean Sys_Rename (const char *oldfname, const char *newfname)
|
2012-04-24 07:59:11 +00:00
|
|
|
{
|
|
|
|
return !rename(oldfname, newfname);
|
|
|
|
}
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
//someone used the 'quit' command
|
|
|
|
void Sys_Quit (void)
|
|
|
|
{
|
|
|
|
Host_Shutdown();
|
|
|
|
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//enumerate the files in a directory (of both gpath and match - match may not contain ..)
|
|
|
|
//calls the callback for each one until the callback returns 0
|
|
|
|
//SDL provides no file enumeration facilities.
|
2010-08-11 23:55:35 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <windows.h>
|
2015-02-02 08:01:53 +00:00
|
|
|
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
|
2010-08-11 23:55:35 +00:00
|
|
|
{
|
|
|
|
HANDLE r;
|
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
char apath[MAX_OSPATH];
|
|
|
|
char apath2[MAX_OSPATH];
|
|
|
|
char file[MAX_OSPATH];
|
|
|
|
char *s;
|
|
|
|
int go;
|
|
|
|
if (!gpath)
|
|
|
|
return 0;
|
|
|
|
// strcpy(apath, match);
|
|
|
|
Q_snprintfz(apath, sizeof(apath), "%s/%s", gpath, match);
|
|
|
|
for (s = apath+strlen(apath)-1; s> apath; s--)
|
|
|
|
{
|
|
|
|
if (*s == '/')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*s = '\0';
|
|
|
|
|
|
|
|
//this is what we ask windows for.
|
|
|
|
Q_snprintfz(file, sizeof(file), "%s/*.*", apath);
|
|
|
|
|
|
|
|
//we need to make apath contain the path in match but not gpath
|
|
|
|
Q_strncpyz(apath2, match, sizeof(apath));
|
|
|
|
match = s+1;
|
|
|
|
for (s = apath2+strlen(apath2)-1; s> apath2; s--)
|
|
|
|
{
|
|
|
|
if (*s == '/')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*s = '\0';
|
|
|
|
if (s != apath2)
|
|
|
|
strcat(apath2, "/");
|
|
|
|
|
|
|
|
r = FindFirstFile(file, &fd);
|
|
|
|
if (r==(HANDLE)-1)
|
|
|
|
return 1;
|
|
|
|
go = true;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*fd.cFileName == '.'); //don't ever find files with a name starting with '.'
|
|
|
|
else if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //is a directory
|
|
|
|
{
|
|
|
|
if (wildcmp(match, fd.cFileName))
|
|
|
|
{
|
|
|
|
Q_snprintfz(file, sizeof(file), "%s%s/", apath2, fd.cFileName);
|
2015-02-02 08:01:53 +00:00
|
|
|
go = func(file, fd.nFileSizeLow, 0, parm, spath);
|
2010-08-11 23:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wildcmp(match, fd.cFileName))
|
|
|
|
{
|
|
|
|
Q_snprintfz(file, sizeof(file), "%s%s", apath2, fd.cFileName);
|
2015-02-02 08:01:53 +00:00
|
|
|
go = func(file, fd.nFileSizeLow, 0, parm, spath);
|
2010-08-11 23:55:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while(FindNextFile(r, &fd) && go);
|
|
|
|
FindClose(r);
|
|
|
|
|
|
|
|
return go;
|
|
|
|
}
|
2013-04-08 09:31:59 +00:00
|
|
|
#elif defined(linux) || defined(__unix__) || defined(__MACH__)
|
2010-08-11 23:55:35 +00:00
|
|
|
#include <dirent.h>
|
2015-02-02 08:01:53 +00:00
|
|
|
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
|
2004-12-09 23:38:11 +00:00
|
|
|
{
|
2010-08-11 23:55:35 +00:00
|
|
|
DIR *dir;
|
|
|
|
char apath[MAX_OSPATH];
|
|
|
|
char file[MAX_OSPATH];
|
|
|
|
char truepath[MAX_OSPATH];
|
|
|
|
char *s;
|
|
|
|
struct dirent *ent;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
//printf("path = %s\n", gpath);
|
|
|
|
//printf("match = %s\n", match);
|
|
|
|
|
|
|
|
if (!gpath)
|
|
|
|
gpath = "";
|
|
|
|
*apath = '\0';
|
|
|
|
|
|
|
|
Q_strncpyz(apath, match, sizeof(apath));
|
|
|
|
for (s = apath+strlen(apath)-1; s >= apath; s--)
|
|
|
|
{
|
|
|
|
if (*s == '/')
|
|
|
|
{
|
|
|
|
s[1] = '\0';
|
|
|
|
match += s - apath+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s < apath) //didn't find a '/'
|
|
|
|
*apath = '\0';
|
|
|
|
|
|
|
|
Q_snprintfz(truepath, sizeof(truepath), "%s/%s", gpath, apath);
|
|
|
|
|
|
|
|
|
|
|
|
//printf("truepath = %s\n", truepath);
|
|
|
|
//printf("gamepath = %s\n", gpath);
|
|
|
|
//printf("apppath = %s\n", apath);
|
|
|
|
//printf("match = %s\n", match);
|
|
|
|
dir = opendir(truepath);
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
Con_DPrintf("Failed to open dir %s\n", truepath);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ent = readdir(dir);
|
|
|
|
if (!ent)
|
|
|
|
break;
|
|
|
|
if (*ent->d_name != '.')
|
|
|
|
{
|
|
|
|
if (wildcmp(match, ent->d_name))
|
|
|
|
{
|
|
|
|
Q_snprintfz(file, sizeof(file), "%s/%s", truepath, ent->d_name);
|
|
|
|
|
|
|
|
if (stat(file, &st) == 0)
|
|
|
|
{
|
|
|
|
Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
|
|
|
|
|
2015-02-02 08:01:53 +00:00
|
|
|
if (!func(file, st.st_size, st.st_mtime, parm, spath))
|
2010-08-11 23:55:35 +00:00
|
|
|
{
|
|
|
|
closedir(dir);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("Stat failed for \"%s\"\n", file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(1);
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#else
|
2015-02-02 08:01:53 +00:00
|
|
|
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, void *), void *parm, void *spath)
|
2010-08-11 23:55:35 +00:00
|
|
|
{
|
|
|
|
Con_Printf("Warning: Sys_EnumerateFiles not implemented\n");
|
|
|
|
return false;
|
2004-12-09 23:38:11 +00:00
|
|
|
}
|
2010-08-11 23:55:35 +00:00
|
|
|
#endif
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
//blink window if possible (it's not)
|
|
|
|
void Sys_ServerActivity(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
void Sys_CloseLibrary(dllhandle_t *lib)
|
|
|
|
{
|
2008-11-12 04:19:22 +00:00
|
|
|
SDL_UnloadObject((void*)lib);
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
2009-11-15 10:22:26 +00:00
|
|
|
dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
|
2008-11-09 22:29:28 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
void *lib;
|
|
|
|
|
|
|
|
lib = SDL_LoadObject(name);
|
|
|
|
if (!lib)
|
|
|
|
return NULL;
|
|
|
|
|
2011-05-30 21:48:32 +00:00
|
|
|
if (funcs)
|
2008-11-09 22:29:28 +00:00
|
|
|
{
|
2011-05-30 21:48:32 +00:00
|
|
|
for (i = 0; funcs[i].name; i++)
|
|
|
|
{
|
|
|
|
*funcs[i].funcptr = SDL_LoadFunction(lib, funcs[i].name);
|
|
|
|
if (!*funcs[i].funcptr)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (funcs[i].name)
|
|
|
|
{
|
|
|
|
Sys_CloseLibrary((dllhandle_t*)lib);
|
|
|
|
lib = NULL;
|
|
|
|
}
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (dllhandle_t*)lib;
|
|
|
|
}
|
2011-05-30 21:48:32 +00:00
|
|
|
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
|
|
|
|
{
|
|
|
|
if (!module)
|
|
|
|
return NULL;
|
|
|
|
return SDL_LoadFunction((void *)module, exportname);
|
|
|
|
}
|
2004-12-09 23:38:11 +00:00
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-10 21:31:53 +00:00
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
//used to see if a file exists or not.
|
|
|
|
int Sys_FileTime (char *path)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
f = fopen(path, "rb");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_Init(void)
|
|
|
|
{
|
2013-04-02 05:18:17 +00:00
|
|
|
SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
|
2004-12-09 23:38:11 +00:00
|
|
|
}
|
2011-04-30 17:21:10 +00:00
|
|
|
void Sys_Shutdown(void)
|
|
|
|
{
|
|
|
|
SDL_Quit();
|
|
|
|
}
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-12-05 16:47:29 +00:00
|
|
|
int VARGS Sys_DebugLog(char *file, char *fmt, ...)
|
2004-12-09 23:38:11 +00:00
|
|
|
{
|
|
|
|
FILE *fd;
|
|
|
|
va_list argptr;
|
|
|
|
static char data[1024];
|
|
|
|
|
|
|
|
va_start(argptr, fmt);
|
2010-08-11 23:55:35 +00:00
|
|
|
vsnprintf(data, sizeof(data)-1, fmt, argptr);
|
2004-12-09 23:38:11 +00:00
|
|
|
va_end(argptr);
|
|
|
|
|
|
|
|
#if defined(CRAZYDEBUGGING) && CRAZYDEBUGGING > 1
|
|
|
|
{
|
|
|
|
static int sock;
|
|
|
|
if (!sock)
|
|
|
|
{
|
|
|
|
struct sockaddr_in sa;
|
|
|
|
netadr_t na;
|
|
|
|
int _true = true;
|
|
|
|
int listip;
|
|
|
|
listip = COM_CheckParm("-debugip");
|
|
|
|
NET_StringToAdr(listip?com_argv[listip+1]:"127.0.0.1", &na);
|
|
|
|
NetadrToSockadr(&na, (struct sockaddr_qstorage*)&sa);
|
|
|
|
sa.sin_port = htons(10000);
|
|
|
|
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
|
|
if (-1==connect(sock, (struct sockaddr*)&sa, sizeof(sa)))
|
|
|
|
Sys_Error("Couldn't send debug log lines\n");
|
|
|
|
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&_true, sizeof(_true));
|
|
|
|
}
|
|
|
|
send(sock, data, strlen(data), 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
fd = fopen(file, "wt");
|
2005-12-05 16:47:29 +00:00
|
|
|
if (fd)
|
|
|
|
{
|
|
|
|
fwrite(data, 1, strlen(data), fd);
|
|
|
|
fclose(fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2004-12-09 23:38:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qboolean Sys_InitTerminal(void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
char *Sys_ConsoleInput(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
void Sys_CloseTerminal (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2006-04-02 03:47:06 +00:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2013-04-02 05:18:17 +00:00
|
|
|
|
|
|
|
#ifdef FTE_TARGET_WEB
|
|
|
|
void Sys_MainLoop(void)
|
|
|
|
{
|
|
|
|
static float oldtime;
|
|
|
|
float newtime, time;
|
|
|
|
newtime = Sys_DoubleTime ();
|
|
|
|
if (!oldtime)
|
|
|
|
oldtime = newtime;
|
|
|
|
time = newtime - oldtime;
|
|
|
|
Host_Frame (time);
|
|
|
|
oldtime = newtime;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-14 09:00:49 +00:00
|
|
|
int QDECL main(int argc, char **argv)
|
2004-12-09 23:38:11 +00:00
|
|
|
{
|
|
|
|
float time, newtime, oldtime;
|
|
|
|
quakeparms_t parms;
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
memset(&parms, 0, sizeof(parms));
|
|
|
|
|
2013-11-21 23:02:28 +00:00
|
|
|
parms.basedir = "./";
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
parms.argc = argc;
|
2013-04-04 08:08:49 +00:00
|
|
|
parms.argv = (const char**)argv;
|
2017-04-18 11:12:17 +00:00
|
|
|
#ifdef CONFIG_MANIFEST_TEXT
|
|
|
|
parms.manifest = CONFIG_MANIFEST_TEXT;
|
|
|
|
#endif
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
#ifndef WIN32
|
|
|
|
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
COM_InitArgv (parms.argc, parms.argv);
|
|
|
|
|
2015-05-03 19:57:46 +00:00
|
|
|
TL_InitLanguages(parms.basedir);
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
Sys_Printf ("Host_Init\n");
|
|
|
|
Host_Init (&parms);
|
|
|
|
|
|
|
|
oldtime = Sys_DoubleTime ();
|
|
|
|
|
|
|
|
//client console should now be initialized.
|
|
|
|
|
|
|
|
/* main window message loop */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
#ifndef CLIENTONLY
|
|
|
|
if (isDedicated)
|
|
|
|
{
|
2016-07-15 12:26:24 +00:00
|
|
|
float delay;
|
2004-12-09 23:38:11 +00:00
|
|
|
// find time passed since last cycle
|
|
|
|
newtime = Sys_DoubleTime ();
|
|
|
|
time = newtime - oldtime;
|
|
|
|
oldtime = newtime;
|
|
|
|
|
2014-07-02 03:20:40 +00:00
|
|
|
delay = SV_Frame();
|
2016-07-15 12:26:24 +00:00
|
|
|
NET_Sleep(delay, false);
|
2004-12-09 23:38:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2011-07-06 01:01:13 +00:00
|
|
|
double sleeptime;
|
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
// yield the CPU for a little while when paused, minimized, or not the focus
|
2014-02-07 08:38:40 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
2016-02-10 23:23:43 +00:00
|
|
|
if (!vid.activeapp)
|
2009-04-07 03:41:24 +00:00
|
|
|
SDL_Delay(1);
|
2014-02-07 08:38:40 +00:00
|
|
|
#else
|
|
|
|
if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS))
|
|
|
|
SDL_Delay(1);
|
|
|
|
#endif
|
2004-12-09 23:38:11 +00:00
|
|
|
|
|
|
|
newtime = Sys_DoubleTime ();
|
|
|
|
time = newtime - oldtime;
|
2011-07-06 01:01:13 +00:00
|
|
|
sleeptime = Host_Frame (time);
|
2004-12-09 23:38:11 +00:00
|
|
|
oldtime = newtime;
|
2011-07-06 01:01:13 +00:00
|
|
|
|
|
|
|
Sys_Sleep(sleeptime);
|
2004-12-09 23:38:11 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-08 14:28:11 +00:00
|
|
|
|
2004-12-09 23:38:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-08 09:31:59 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
//our version of sdl_main.lib, which doesn't fight c runtimes.
|
|
|
|
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
|
|
|
{
|
|
|
|
int argc;
|
|
|
|
int i, l, c;
|
|
|
|
LPWSTR *argvw;
|
|
|
|
char **argv;
|
|
|
|
char utf8arg[1024];
|
|
|
|
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
|
|
|
argv = malloc(argc * sizeof(char*));
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
for(l = 0, c = 0; argvw[i][l]; l++)
|
2013-04-08 09:31:59 +00:00
|
|
|
c += utf8_encode(utf8arg+c, argvw[i][l], sizeof(utf8arg) - c-1);
|
|
|
|
utf8arg[c] = 0;
|
|
|
|
argv[i] = strdup(utf8arg);
|
|
|
|
}
|
|
|
|
return main(argc, argv);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-04-15 03:31:23 +00:00
|
|
|
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
|
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
if (!SDL_GetDesktopDisplayMode(0, &mode))
|
|
|
|
{
|
|
|
|
*width = mode.w;
|
|
|
|
*height = mode.h;
|
|
|
|
*bpp = (SDL_PIXELTYPE(mode.format) == SDL_PIXELTYPE_PACKED32)?32:16;
|
|
|
|
*refreshrate = mode.refresh_rate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2006-04-15 03:31:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-01 22:36:12 +00:00
|
|
|
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2 //probably could include 1.3
|
2013-04-13 08:15:18 +00:00
|
|
|
#include <SDL_clipboard.h>
|
2006-02-01 22:36:12 +00:00
|
|
|
char *Sys_GetClipboard(void)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
return SDL_GetClipboardText();
|
2006-02-01 22:36:12 +00:00
|
|
|
}
|
|
|
|
void Sys_CloseClipboard(char *bf)
|
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
SDL_free(bf);
|
2006-02-01 22:36:12 +00:00
|
|
|
}
|
|
|
|
void Sys_SaveClipboard(char *text)
|
|
|
|
{
|
2013-04-13 08:15:18 +00:00
|
|
|
SDL_SetClipboardText(text);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static char *clipboard_buffer;
|
|
|
|
char *Sys_GetClipboard(void)
|
|
|
|
{
|
|
|
|
return clipboard_buffer;
|
2007-07-23 12:05:41 +00:00
|
|
|
}
|
2007-12-30 00:09:34 +00:00
|
|
|
|
2013-04-13 08:15:18 +00:00
|
|
|
void Sys_CloseClipboard(char *bf)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_SaveClipboard(char *text)
|
|
|
|
{
|
|
|
|
free(clipboard_buffer);
|
|
|
|
clipboard_buffer = strdup(text);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-30 00:09:34 +00:00
|
|
|
#ifdef MULTITHREAD
|
|
|
|
/* Thread creation calls */
|
2012-11-29 13:37:48 +00:00
|
|
|
void *Sys_CreateThread(char *name, int (*func)(void *), void *args, int priority, int stacksize)
|
2007-12-30 00:09:34 +00:00
|
|
|
{
|
|
|
|
// SDL threads do not support setting thread stack size
|
2014-02-07 08:38:40 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
|
|
|
return (void *)SDL_CreateThread(func, name, args);
|
|
|
|
#else
|
2007-12-30 20:05:49 +00:00
|
|
|
return (void *)SDL_CreateThread(func, args);
|
2014-02-07 08:38:40 +00:00
|
|
|
#endif
|
2007-12-30 00:09:34 +00:00
|
|
|
}
|
|
|
|
|
2007-12-30 20:05:49 +00:00
|
|
|
void Sys_WaitOnThread(void *thread)
|
|
|
|
{
|
|
|
|
SDL_WaitThread((SDL_Thread *)thread, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-30 00:09:34 +00:00
|
|
|
/* Mutex calls */
|
|
|
|
// SDL mutexes don't have try-locks for mutexes in the spec so we stick with 1-value semaphores
|
2008-06-01 05:42:23 +00:00
|
|
|
void *Sys_CreateMutex(void)
|
2007-12-30 00:09:34 +00:00
|
|
|
{
|
|
|
|
return (void *)SDL_CreateSemaphore(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_TryLockMutex(void *mutex)
|
|
|
|
{
|
|
|
|
return !SDL_SemTryWait(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_LockMutex(void *mutex)
|
|
|
|
{
|
|
|
|
return !SDL_SemWait(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_UnlockMutex(void *mutex)
|
|
|
|
{
|
|
|
|
return !SDL_SemPost(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_DestroyMutex(void *mutex)
|
|
|
|
{
|
2008-06-01 05:42:23 +00:00
|
|
|
SDL_DestroySemaphore(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Conditional wait calls */
|
|
|
|
typedef struct condvar_s
|
|
|
|
{
|
|
|
|
SDL_mutex *mutex;
|
|
|
|
SDL_cond *cond;
|
|
|
|
} condvar_t;
|
|
|
|
|
|
|
|
void *Sys_CreateConditional(void)
|
|
|
|
{
|
|
|
|
condvar_t *condv;
|
|
|
|
SDL_mutex *mutex;
|
|
|
|
SDL_cond *cond;
|
|
|
|
|
|
|
|
condv = (condvar_t *)malloc(sizeof(condvar_t));
|
|
|
|
if (!condv)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mutex = SDL_CreateMutex();
|
|
|
|
cond = SDL_CreateCond();
|
|
|
|
|
|
|
|
if (mutex)
|
|
|
|
{
|
|
|
|
if (cond)
|
|
|
|
{
|
|
|
|
condv->cond = cond;
|
|
|
|
condv->mutex = mutex;
|
|
|
|
|
|
|
|
return (void *)condv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SDL_DestroyMutex(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(condv);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_LockConditional(void *condv)
|
|
|
|
{
|
|
|
|
return !SDL_mutexP(((condvar_t *)condv)->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_UnlockConditional(void *condv)
|
|
|
|
{
|
|
|
|
return !SDL_mutexV(((condvar_t *)condv)->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_ConditionWait(void *condv)
|
|
|
|
{
|
|
|
|
return !SDL_CondWait(((condvar_t *)condv)->cond, ((condvar_t *)condv)->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_ConditionSignal(void *condv)
|
|
|
|
{
|
|
|
|
return !SDL_CondSignal(((condvar_t *)condv)->cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean Sys_ConditionBroadcast(void *condv)
|
|
|
|
{
|
|
|
|
return !SDL_CondBroadcast(((condvar_t *)condv)->cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sys_DestroyConditional(void *condv)
|
|
|
|
{
|
|
|
|
condvar_t *cv = (condvar_t *)condv;
|
|
|
|
|
|
|
|
SDL_DestroyCond(cv->cond);
|
|
|
|
SDL_DestroyMutex(cv->mutex);
|
|
|
|
free(cv);
|
2007-12-30 00:09:34 +00:00
|
|
|
}
|
2011-07-06 06:02:12 +00:00
|
|
|
#endif
|
2011-07-03 16:24:53 +00:00
|
|
|
|
2011-07-06 01:01:13 +00:00
|
|
|
void Sys_Sleep (double seconds)
|
2011-07-03 16:24:53 +00:00
|
|
|
{
|
2011-07-06 01:01:13 +00:00
|
|
|
SDL_Delay(seconds * 1000);
|
2011-07-03 16:24:53 +00:00
|
|
|
}
|
2007-12-30 00:09:34 +00:00
|
|
|
|
2013-04-02 05:18:17 +00:00
|
|
|
|
2015-01-21 18:18:37 +00:00
|
|
|
#ifdef HAVEAUTOUPDATE
|
2017-01-24 20:15:14 +00:00
|
|
|
//legacy, so old build can still deal with updates properly
|
|
|
|
void Sys_SetUpdatedBinary(const char *fname)
|
2015-01-21 18:18:37 +00:00
|
|
|
{
|
|
|
|
}
|
2017-01-24 20:15:14 +00:00
|
|
|
//says whether the system code is able to invoke new binaries properly
|
|
|
|
qboolean Sys_EngineCanUpdate(void)
|
2015-01-21 18:18:37 +00:00
|
|
|
{
|
2017-01-24 20:15:14 +00:00
|
|
|
return false; //nope, nothing here
|
2015-01-21 18:18:37 +00:00
|
|
|
}
|
2017-01-24 20:15:14 +00:00
|
|
|
//invoke the given system-path binary
|
|
|
|
qboolean Sys_EngineWasUpdated(char *newbinary)
|
2016-09-09 18:46:08 +00:00
|
|
|
{
|
2017-01-24 20:15:14 +00:00
|
|
|
return false; //sorry
|
2016-09-09 18:46:08 +00:00
|
|
|
}
|
2015-01-21 18:18:37 +00:00
|
|
|
#endif
|