fteqw/engine/http/webgen.c

505 lines
12 KiB
C
Raw Normal View History

#include "quakedef.h"
#if defined(WEBSERVER) || defined(FTPSERVER)
#include "iweb.h"
#if defined(CLIENTONLY) || !defined(WEBSERVER)
vfsfile_t *IWebGenerateFile(const char *name, const char *content, int contentlength)
{
return NULL;
}
#else
static char lastrecordedmvd[MAX_QPATH];
static IWeb_FileGen_t *IWeb_GenerationBuffer;
static size_t IWeb_GenerationBufferTotal;
/*
static void IWeb_MoreGeneratedResize(size_t newsize)
{
IWeb_FileGen_t *ob;
if (IWeb_GenerationBuffer && IWeb_GenerationBufferTotal >= newsize)
return; //already big enough
ob = IWeb_GenerationBuffer;
IWeb_GenerationBuffer = BZ_Malloc(sizeof(IWeb_GenerationBuffer) + newsize);
memset(IWeb_GenerationBuffer, 0, sizeof(*IWeb_GenerationBuffer));
IWeb_GenerationBuffer->data = (char *)(IWeb_GenerationBuffer+1);
if (ob)
{
memcpy(IWeb_GenerationBuffer->data, ob->data, ob->len);
IWeb_GenerationBuffer->len = ob->len;
IWebFree(ob);
}
IWeb_GenerationBufferTotal = newsize;
}
*/
static void IWeb_Generate(const char *buf)
{
size_t count = strlen(buf);
if (!IWeb_GenerationBuffer || IWeb_GenerationBuffer->len + count >= IWeb_GenerationBufferTotal)
{
IWeb_FileGen_t *ob;
size_t newsize = IWeb_GenerationBufferTotal + count+(16*1024);
if (newsize < IWeb_GenerationBufferTotal)
{
Sys_Error("Integer overflow\n");
return; //should probably crash or something.
}
ob = IWeb_GenerationBuffer;
IWeb_GenerationBuffer = BZ_Malloc(sizeof(IWeb_GenerationBuffer) + newsize);
memset(IWeb_GenerationBuffer, 0, sizeof(*IWeb_GenerationBuffer));
IWeb_GenerationBuffer->data = (char *)(IWeb_GenerationBuffer+1);
if (ob)
{
memcpy(IWeb_GenerationBuffer->data, ob->data, ob->len);
IWeb_GenerationBuffer->len = ob->len;
IWebFree(ob);
}
IWeb_GenerationBufferTotal = newsize;
}
memcpy(&IWeb_GenerationBuffer->data[IWeb_GenerationBuffer->len], buf, count);
IWeb_GenerationBuffer->len+=count;
}
int Rank_Enumerate (unsigned int first, unsigned int last, void (*callback) (const rankinfo_t *ri)); //leader first.
/*
static void IWeb_ParseForm(char *info, int infolen, char *text)
{
char *eq, *and;
char *token, *out;
*info = '\0';
if (!text)
return;
while(*text)
{
eq = strchr(text, '=');
if (!eq)
break;
*eq = '\0';
and = strchr(eq+1, '&');
if (and)
*and = '\0';
for (out = token = eq+1; *token;)
{
if (*token == '+')
{
*out++ = ' ';
token++;
}
else if (*token == '%' && token[1] && token[2])
{
int c = 0;
if (token[1] >= '0' && token[1] <= '9')
{
c += token[1] - '0';
}
else if (token[1] >= 'a' && token[1] <= 'f')
{
c += token[1] - 'a'+10;
}
else if (token[1] >= 'A' && token[1] <= 'F')
{
c += token[1] - 'A'+10;
}
c*=16;
if (token[2] >= '0' && token[2] <= '9')
{
c += token[2] - '0';
}
else if (token[2] >= 'a' && token[2] <= 'f')
{
c += token[2] - 'a'+10;
}
else if (token[2] >= 'A' && token[2] <= 'F')
{
c += token[2] - 'A'+10;
}
*out++ = c;
token+=3;
}
else
*out++ = *token++;
}
*out = '\0';
Info_SetValueForKey(info, text, eq+1, infolen);
if (!and)
return;
text = and+1;
}
}
static void IWeb_GenerateAdminFile(char *parms, char *content, int contentlength)
{
extern char outputbuf[]; //redirected buffer - always null termed.
char info[16384];
char *pwd;
char *cmd;
char *mark, *start;
extern cvar_t rcon_password;
IWeb_Generate("<HTML><HEAD><TITLE>FTEQWSV - admin</TITLE></HEAD><BODY>");
if (*rcon_password.string)
{
IWeb_ParseForm(info, sizeof(info), content);
pwd = Info_ValueForKey(info, "pwd");
cmd = Info_ValueForKey(info, "cmd");
IWeb_Generate("<FORM action=\"admin.html\" method=\"post\">");
IWeb_Generate("<CENTER>");
IWeb_Generate("<input name=pwd value=\"");
if (!strcmp(rcon_password.string, pwd))
IWeb_Generate(rcon_password.string);
IWeb_Generate("\">");
IWeb_Generate("<BR>");
IWeb_Generate("<input name=cmd maxsize=255 size=40 value=\"\">");
IWeb_Generate("<BR>");
IWeb_Generate("<input type=submit value=\"Submit\" name=btn>");
IWeb_Generate("</CENTER>");
IWeb_Generate("</FORM>");
if (!strcmp(rcon_password.string, pwd))
{
Con_Printf("Web based rcon: %s\n", cmd);
SV_BeginRedirect(RD_OBLIVION, host_client->language);
Cmd_ExecuteString(cmd, RESTRICT_RCON);
for (mark = start = outputbuf; *mark; mark++)
{
if (*mark == '\n')
{
*mark = '\0';
IWeb_Generate(start);
IWeb_Generate("<br>");
start = mark+1;
}
}
IWeb_Generate(start);
SV_EndRedirect();
}
else if (*pwd)
IWeb_Generate("Password is incorrect.");
}
else
IWeb_Generate("<H1>Remote administration is not enabled.<H2>");
IWeb_Generate("</BODY></HTML>");
}
*/
static void IWeb_GenerateRankingsFileCallback(const rankinfo_t *ri)
{
IWeb_Generate("<TR><TD ALIGN = \"center\">");
IWeb_Generate(ri->h.name);
IWeb_Generate("</TD><TD ALIGN = \"center\">");
IWeb_Generate(va("%i", ri->s.kills));
IWeb_Generate("</TD><TD ALIGN = \"center\">");
IWeb_Generate(va("%i", ri->s.deaths));
IWeb_Generate("</TD>");
IWeb_Generate("</TR>");
}
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
static void IWeb_GenerateRankingsFile (const char *parms, const char *content, int contentlength)
{
IWeb_Generate("<HTML><HEAD></HEAD><BODY>");
if (Rank_OpenRankings())
{
IWeb_Generate("<TABLE CELLSPACING=\"1\" CELLPADDING=\"1\">");
IWeb_Generate("<CAPTION>Players</CAPTION>");
if (Rank_Enumerate(atoi(parms), atoi(parms)+20, IWeb_GenerateRankingsFileCallback) == 20)
{
IWeb_Generate("</TABLE>");
if (atoi(parms) >= 20)
IWeb_Generate(va("<A HREF=allplayers.html?%i>Less</A>", atoi(parms)-20));
else if (atoi(parms) > 0)
IWeb_Generate(va("<A HREF=allplayers.html?%i>Less</A>", 0));
IWeb_Generate(va("<A HREF=allplayers.html?%i>More</A>", atoi(parms)+20));
}
else
{
IWeb_Generate("</TABLE>");
if (atoi(parms) >= 20)
IWeb_Generate(va("<A HREF=allplayers.html?%i>Less</A>", atoi(parms)-20));
else if (atoi(parms) > 0)
IWeb_Generate(va("<A HREF=allplayers.html?%i>Less</A>", 0));
}
}
else
IWeb_Generate("<H1>Rankings are disabled. Sorry.<H2>");
IWeb_Generate("</BODY></HTML>");
}
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
static void IWeb_GenerateIndexFile (const char *parms, const char *content, int contentlength)
{
extern cvar_t rcon_password;
char *s, *o;
char key[128], value[128];
int l;
qboolean added;
client_t *cl;
IWeb_Generate("<HTML><HEAD><TITLE>FTEQWSV</TITLE></HEAD><BODY>");
IWeb_Generate("<H1>");
IWeb_Generate(hostname.string);
IWeb_Generate("</H1>");
IWeb_Generate("<A HREF=\""ENGINEWEBSITE"\">Engine website</A><P>");
if (Rank_OpenRankings())
IWeb_Generate("<A HREF=\"allplayers.html\">Click here to see ranked players.</A><P>");
if (*rcon_password.string)
IWeb_Generate("<A HREF=\"admin.html\">Admin.</A><P>");
s = svs.info;
IWeb_Generate("<TABLE CELLSPACING=\"1\" CELLPADDING=\"1\">");
IWeb_Generate("<CAPTION>Server Info</CAPTION>");
if (*s == '\\')
s++;
while (*s)
{
o = key;
while (*s && *s != '\\')
*o++ = *s++;
l = o - key;
// if (l < 20)
// {
// memset (o, ' ', 20-l);
// key[20] = 0;
// }
// else
*o = 0;
IWeb_Generate("<TR><TD ALIGN = \"center\">");
IWeb_Generate(key);
if (!*s)
{
IWeb_Generate("MISSING VALUE\n");
return;
}
o = value;
s++;
while (*s && *s != '\\')
*o++ = *s++;
*o = 0;
if (*s)
s++;
IWeb_Generate("</TD><TD ALIGN = \"center\">");
IWeb_Generate(value);
IWeb_Generate("</TD></TR>");
}
IWeb_Generate("</TABLE>");
IWeb_Generate("<P><TABLE CELLSPACING=\"1\" CELLPADDING=\"1\">");
IWeb_Generate("<CAPTION>Players</CAPTION>");
added = false;
for (l = 0, cl = svs.clients; l < sv.allocated_client_slots; l++, cl++)
{
if (cl->state <= cs_zombie)
continue;
IWeb_Generate("<TR><TD ALIGN = \"center\">");
IWeb_Generate(cl->name);
IWeb_Generate("</TD><TD ALIGN = \"center\">");
IWeb_Generate(va("%i", cl->old_frags));
IWeb_Generate("</TD></TR>");
added = true;
}
if (!added)
{
IWeb_Generate("<TR><TD ALIGN = \"center\">");
IWeb_Generate("No players on server");
IWeb_Generate("</TD><TD ALIGN = \"center\">");
}
IWeb_Generate("</TABLE>");
IWeb_Generate("</BODY></HTML>");
}
typedef struct {
char *name;
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 (*GenerationFunction) (const char *parms, const char *content, int contentlength);
float lastgenerationtime;
float oldbysecs;
IWeb_FileGen_t *buffer;
int genid;
} IWebFile_t;
static IWebFile_t IWebFiles[] = {
{"allplayers.html", IWeb_GenerateRankingsFile},
{"index.html", IWeb_GenerateIndexFile},
//code is too flawed for this {"admin.html", IWeb_GenerateAdminFile}
};
typedef struct {
vfsfile_t funcs;
IWeb_FileGen_t *buffer;
int pos;
} vfsgen_t;
static int QDECL VFSGen_ReadBytes(vfsfile_t *f, void *buffer, int bytes)
{
vfsgen_t *g = (vfsgen_t*)f;
if (bytes + g->pos >= g->buffer->len)
{
bytes = g->buffer->len - g->pos;
if (bytes <= 0)
return 0;
}
memcpy(buffer, g->buffer->data+g->pos, bytes);
g->pos += bytes;
return bytes;
}
static int QDECL VFSGen_WriteBytes(vfsfile_t *f, const void *buffer, int bytes)
{
Sys_Error("VFSGen_WriteBytes: Readonly\n");
return 0;
}
static qboolean QDECL VFSGen_Seek(vfsfile_t *f, qofs_t newpos)
{
vfsgen_t *g = (vfsgen_t*)f;
if (newpos < 0 || newpos >= g->buffer->len)
return false;
g->pos = newpos;
return true;
}
static qofs_t QDECL VFSGen_Tell(vfsfile_t *f)
{
vfsgen_t *g = (vfsgen_t*)f;
return g->pos;
}
static qofs_t QDECL VFSGen_GetLen(vfsfile_t *f)
{
vfsgen_t *g = (vfsgen_t*)f;
return g->buffer->len;
}
static qboolean QDECL VFSGen_Close(vfsfile_t *f)
{
int fnum;
vfsgen_t *g = (vfsgen_t*)f;
g->buffer->references--;
if (!g->buffer->references)
{
Z_Free(g->buffer->data);
Z_Free(g->buffer);
for (fnum = 0; fnum < sizeof(IWebFiles) / sizeof(IWebFile_t); fnum++)
if (IWebFiles[fnum].buffer == g->buffer)
IWebFiles[fnum].buffer = NULL;
}
Z_Free(g);
rewrote ban code, merging bans+nonbans+cuffs+mute+cripple+deaf+lagged+vip. added timeouts. new penalties have no dedicated command. use the addip command for it. maplist command now generates links. implemented skin objects for q3. added a csqc builtin for it. also supports compositing skins. playing demos inside zips/pk3s/paks should now work. bumped default rate cvar. added cl_transfer to attempt to connect to a new server without disconnecting first. rewrote fog command. alpha and mindist arguments are now supported. fog change also happens over a short time period. added new args to the showpic console command. can now create clickable items for touchscreen/absmouse users. fixed menus to properly support right-aligned text. this finally fixes variable-width fonts. rewrote console tab completion suggestions display. now clickable links. strings obtained from qc are now marked as const. this has required quite a few added consts all over the place. probably crappy attempt at adding joypad support to the sdl port. no idea if it works. changed key bind event code. buttons now track which event they should trigger when released, instead of being the same one the whole time. this allows +forward etc clickable buttons on screen. Also simplified modifier keys - they no longer trigger random events when pressing the modifier key itself. Right modifiers can now be bound separately from left modifiers. Right will use left's binding if not otherwise bound. Bind assumes left if there's no prefix. multiplayer->setup->network menu no longer crashes. added rgb colours to the translation view (but not to the colour-changing keys). added modelviewer command to view models. added menu_mods menu to switch mods in a more friendly way. will be shown by default if multiple manifests exist in the binarydir. clamped classic tracer density. scrag particles no longer look quite so buggy. added ifdefs to facilitate a potential winrt port. the engine should now have no extra dependencies, but still needs system code+audio drivers to be written. if it can't set a renderer, it'll now try to use *every* renderer until it finds one that works. added experimental mapcluster server mode (that console command). New maps will be started up as required. rewrote skeletal blending code a bit. added cylinder geomtypes. fix cfg_save writing to the wrong path bug. VFS_CLOSE now returns a boolean. false means there was some sort of fatal error (either crc when reading was bad, or the write got corrupted or something). Typically ignorable, depends how robust you want to be. win32 tls code now supports running as a server. added connect tls://address support, as well as equivalent sv_addport support. exposed basic model loading api to plugins. d3d11 backend now optionally supports tessellation hlsl. no suitable hlsl provided by default. !!tess to enable. attempted to add gamma ramp support for d3d11. added support for shader blobs to speed up load times. r_shaderblobs 1 to enable. almost vital for d3d11. added vid_srgb cvar. shadowless lights are no longer disabled if shadows are not supported. attempt to add support for touchscreens in win7/8. Wrote gimmicky lua support, using lua instead of ssqc. define VM_LUA to enable. updated saved game code. can again load saved games from vanilla-like engines. changed scale clamping. 0.0001 should no longer appear as 1. changed default mintic from 0.03 to 0.013 to match vanilla qw. I don't know why it was at 0.03. probably a typo. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4623 fc73d0e0-1445-4013-8a0c-d673dee63da5
2014-03-30 08:55:06 +00:00
return true;
}
static vfsfile_t *VFSGen_Create(IWeb_FileGen_t *gen)
{
vfsgen_t *ret;
ret = Z_Malloc(sizeof(vfsgen_t));
ret->funcs.ReadBytes = VFSGen_ReadBytes;
ret->funcs.WriteBytes = VFSGen_WriteBytes;
ret->funcs.Seek = VFSGen_Seek;
ret->funcs.Tell = VFSGen_Tell;
ret->funcs.GetLen = VFSGen_GetLen;
ret->funcs.Close = VFSGen_Close;
ret->buffer = gen;
gen->references++;
return (vfsfile_t*)ret;
}
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
vfsfile_t *IWebGenerateFile(const char *name, const char *content, int contentlength)
{
int fnum;
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
const char *parms;
int len;
if (!sv.state)
return NULL;
if (*lastrecordedmvd && !strcmp(name, "lastdemo.mvd"))
if (strcmp(name, "lastdemo.mvd")) //no infinate loops please...
return FS_OpenVFS(lastrecordedmvd, "rb", FS_GAME);
parms = strchr(name, '?');
if (!parms)
parms = name + strlen(name);
len = parms-name;
if (*parms)
parms++;
if (!*name)
return NULL;
for (fnum = 0; fnum < sizeof(IWebFiles) / sizeof(IWebFile_t); fnum++)
{
if (!Q_strncasecmp(name, IWebFiles[fnum].name, len+1))
{
if (IWebFiles[fnum].buffer)
{
if (IWebFiles[fnum].lastgenerationtime < Sys_DoubleTime())
{
IWebFiles[fnum].buffer->references--; //remove our reference and check free
if (IWebFiles[fnum].buffer->references<=0)
{
BZ_Free(IWebFiles[fnum].buffer);
IWebFiles[fnum].buffer = NULL;
}
}
}
if (!IWebFiles[fnum].buffer)
{
if (IWeb_GenerationBuffer!=NULL)
Sys_Error("Recursive file generation\n");
IWebFiles[fnum].GenerationFunction(parms, content, contentlength);
IWebFiles[fnum].buffer = IWeb_GenerationBuffer;
//so it can't be sent once and freed instantly.
if (contentlength)
IWebFiles[fnum].lastgenerationtime = Sys_DoubleTime()+10;
}
IWebFiles[fnum].buffer->references++;
IWeb_GenerationBuffer = NULL;
return VFSGen_Create(IWebFiles[fnum].buffer);
}
}
return NULL;
}
#endif
#endif