2005-02-28 07:16:19 +00:00
|
|
|
#include "quakedef.h"
|
2004-08-23 01:40:25 +00:00
|
|
|
|
2017-05-28 15:42:32 +00:00
|
|
|
#if defined(WEBSERVER) || defined(FTPSERVER)
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
#include "iweb.h"
|
|
|
|
|
2017-05-28 15:42:32 +00:00
|
|
|
#if defined(CLIENTONLY) || !defined(WEBSERVER)
|
|
|
|
vfsfile_t *IWebGenerateFile(const char *name, const char *content, int contentlength)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static char lastrecordedmvd[MAX_QPATH];
|
2004-08-23 01:40:25 +00:00
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static IWeb_FileGen_t *IWeb_GenerationBuffer;
|
|
|
|
static size_t IWeb_GenerationBufferTotal;
|
2016-02-15 06:01:17 +00:00
|
|
|
/*
|
2014-12-23 15:26:42 +00:00
|
|
|
static void IWeb_MoreGeneratedResize(size_t newsize)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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);
|
2009-05-24 10:11:17 +00:00
|
|
|
memset(IWeb_GenerationBuffer, 0, sizeof(*IWeb_GenerationBuffer));
|
2006-03-04 20:43:48 +00:00
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
IWeb_GenerationBuffer->data = (char *)(IWeb_GenerationBuffer+1);
|
|
|
|
if (ob)
|
|
|
|
{
|
|
|
|
memcpy(IWeb_GenerationBuffer->data, ob->data, ob->len);
|
2009-05-24 10:11:17 +00:00
|
|
|
IWeb_GenerationBuffer->len = ob->len;
|
2009-11-04 21:16:50 +00:00
|
|
|
IWebFree(ob);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IWeb_GenerationBufferTotal = newsize;
|
|
|
|
}
|
2016-02-15 06:01:17 +00:00
|
|
|
*/
|
2014-12-23 15:26:42 +00:00
|
|
|
static void IWeb_Generate(const char *buf)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
2014-02-13 23:54:57 +00:00
|
|
|
size_t count = strlen(buf);
|
2004-08-23 01:40:25 +00:00
|
|
|
if (!IWeb_GenerationBuffer || IWeb_GenerationBuffer->len + count >= IWeb_GenerationBufferTotal)
|
2014-02-13 23:54:57 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-02-15 06:01:17 +00:00
|
|
|
/*
|
2014-12-23 15:26:42 +00:00
|
|
|
static void IWeb_ParseForm(char *info, int infolen, char *text)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static void IWeb_GenerateAdminFile(char *parms, char *content, int contentlength)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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);
|
2005-01-16 02:27:30 +00:00
|
|
|
SV_BeginRedirect(RD_OBLIVION, host_client->language);
|
2004-08-23 01:40:25 +00:00
|
|
|
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>");
|
|
|
|
}
|
2016-02-15 06:01:17 +00:00
|
|
|
*/
|
2004-08-23 01:40:25 +00:00
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static void IWeb_GenerateRankingsFileCallback(const rankinfo_t *ri)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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>");
|
|
|
|
|
2005-07-01 19:23:00 +00:00
|
|
|
IWeb_Generate("<A HREF=\""ENGINEWEBSITE"\">Engine website</A><P>");
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
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;
|
2006-03-04 20:43:48 +00:00
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
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++;
|
2006-03-04 20:43:48 +00:00
|
|
|
|
2004-08-23 01:40:25 +00:00
|
|
|
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);
|
2004-08-23 01:40:25 +00:00
|
|
|
float lastgenerationtime;
|
|
|
|
float oldbysecs;
|
|
|
|
IWeb_FileGen_t *buffer;
|
|
|
|
int genid;
|
|
|
|
} IWebFile_t;
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static IWebFile_t IWebFiles[] = {
|
2004-08-23 01:40:25 +00:00
|
|
|
{"allplayers.html", IWeb_GenerateRankingsFile},
|
|
|
|
{"index.html", IWeb_GenerateIndexFile},
|
2007-09-17 20:35:39 +00:00
|
|
|
//code is too flawed for this {"admin.html", IWeb_GenerateAdminFile}
|
2004-08-23 01:40:25 +00:00
|
|
|
};
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
typedef struct {
|
|
|
|
vfsfile_t funcs;
|
2005-12-22 02:29:11 +00:00
|
|
|
|
|
|
|
IWeb_FileGen_t *buffer;
|
2005-12-21 03:07:33 +00:00
|
|
|
int pos;
|
2005-12-22 02:29:11 +00:00
|
|
|
} vfsgen_t;
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static int QDECL VFSGen_ReadBytes(vfsfile_t *f, void *buffer, int bytes)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static int QDECL VFSGen_WriteBytes(vfsfile_t *f, const void *buffer, int bytes)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
|
|
|
Sys_Error("VFSGen_WriteBytes: Readonly\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static qboolean QDECL VFSGen_Seek(vfsfile_t *f, qofs_t newpos)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
|
|
|
vfsgen_t *g = (vfsgen_t*)f;
|
|
|
|
if (newpos < 0 || newpos >= g->buffer->len)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
g->pos = newpos;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static qofs_t QDECL VFSGen_Tell(vfsfile_t *f)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
|
|
|
vfsgen_t *g = (vfsgen_t*)f;
|
|
|
|
return g->pos;
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static qofs_t QDECL VFSGen_GetLen(vfsfile_t *f)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
|
|
|
vfsgen_t *g = (vfsgen_t*)f;
|
|
|
|
return g->buffer->len;
|
|
|
|
}
|
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static qboolean QDECL VFSGen_Close(vfsfile_t *f)
|
2005-12-22 02:29:11 +00:00
|
|
|
{
|
2009-05-24 10:11:17 +00:00
|
|
|
int fnum;
|
2005-12-22 02:29:11 +00:00
|
|
|
vfsgen_t *g = (vfsgen_t*)f;
|
|
|
|
g->buffer->references--;
|
|
|
|
if (!g->buffer->references)
|
|
|
|
{
|
|
|
|
Z_Free(g->buffer->data);
|
|
|
|
Z_Free(g->buffer);
|
2009-05-24 10:11:17 +00:00
|
|
|
|
|
|
|
for (fnum = 0; fnum < sizeof(IWebFiles) / sizeof(IWebFile_t); fnum++)
|
|
|
|
if (IWebFiles[fnum].buffer == g->buffer)
|
|
|
|
IWebFiles[fnum].buffer = NULL;
|
2005-12-22 02:29:11 +00:00
|
|
|
}
|
|
|
|
Z_Free(g);
|
2014-03-30 08:55:06 +00:00
|
|
|
return true;
|
2005-12-22 02:29:11 +00:00
|
|
|
}
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
|
2014-12-23 15:26:42 +00:00
|
|
|
static vfsfile_t *VFSGen_Create(IWeb_FileGen_t *gen)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
2005-12-22 02:29:11 +00:00
|
|
|
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;
|
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
ret->buffer = gen;
|
|
|
|
gen->references++;
|
|
|
|
|
2005-12-22 02:29:11 +00:00
|
|
|
return (vfsfile_t*)ret;
|
2005-12-21 03:07:33 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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;
|
2004-08-23 01:40:25 +00:00
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!sv.state)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (*lastrecordedmvd && !strcmp(name, "lastdemo.mvd"))
|
|
|
|
if (strcmp(name, "lastdemo.mvd")) //no infinate loops please...
|
2005-12-22 02:29:11 +00:00
|
|
|
return FS_OpenVFS(lastrecordedmvd, "rb", FS_GAME);
|
2004-08-23 01:40:25 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2007-09-17 20:35:39 +00:00
|
|
|
if (IWebFiles[fnum].lastgenerationtime < Sys_DoubleTime())
|
2004-08-23 01:40:25 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2005-12-22 02:29:11 +00:00
|
|
|
//so it can't be sent once and freed instantly.
|
2007-09-17 20:35:39 +00:00
|
|
|
if (contentlength)
|
|
|
|
IWebFiles[fnum].lastgenerationtime = Sys_DoubleTime()+10;
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
2005-12-22 02:29:11 +00:00
|
|
|
IWebFiles[fnum].buffer->references++;
|
2004-08-23 01:40:25 +00:00
|
|
|
IWeb_GenerationBuffer = NULL;
|
|
|
|
|
2005-12-22 02:29:11 +00:00
|
|
|
return VFSGen_Create(IWebFiles[fnum].buffer);
|
2004-08-23 01:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|