Remove NPFTE preprocessor stuff

This commit is contained in:
Fix 2023-07-09 20:41:24 +02:00
parent 8adffcecfa
commit a024a82b89
7 changed files with 11 additions and 172 deletions

View File

@ -1567,9 +1567,7 @@ static void VARGS png_onerror(png_structp png_ptr, png_const_charp error_msg)
static void VARGS png_onwarning(png_structp png_ptr, png_const_charp warning_msg)
{
struct pngerr *err = qpng_get_error_ptr(png_ptr);
#ifndef NPFTE
Con_DPrintf("libpng %s: %s\n", err->fname, warning_msg);
#endif
}
qbyte *ReadPNGFile(const char *fname, qbyte *buf, int length, int *width, int *height, uploadfmt_t *format, qboolean force_rgb32)
@ -1792,7 +1790,6 @@ error:
#ifndef NPFTE
int Image_WritePNG (const char *filename, enum fs_relative fsroot, int compression, void **buffers, int numbuffers, qintptr_t bufferstride, int width, int height, enum uploadfmt fmt, qboolean writemetadata)
{
char name[MAX_OSPATH];
@ -2035,7 +2032,6 @@ err:
Con_Printf("File error writing %s\n", filename);
return false;
}
#endif
#endif
@ -2453,7 +2449,6 @@ badjpeg:
}
/*end read*/
#ifndef NPFTE
/*begin write*/
@ -2664,7 +2659,6 @@ qboolean screenshotJPEG(char *filename, enum fs_relative fsroot, int compression
return ret;
}
#endif
#endif
#ifdef IMAGEFMT_PCX
/*

View File

@ -411,7 +411,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SQL
#endif
#if defined(AVAIL_GZDEC) && (!defined(AVAIL_ZLIB) || defined(NPFTE) || defined(NO_ZLIB))
#if defined(AVAIL_GZDEC) && (!defined(AVAIL_ZLIB) || defined(NO_ZLIB))
//gzip needs zlib to work (pk3s can still contain non-compressed files)
#undef AVAIL_GZDEC
#endif
@ -428,16 +428,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef PACKAGE_DZIP
#endif
//fix things a little...
#ifdef NPFTE
/*plugins require threads and stuff now, and http download support*/
#ifndef MULTITHREAD
#define MULTITHREAD
#define WEBCLIENT
#endif
#undef SUBSERVERS
#endif
#if (defined(NOLOADERTHREAD) || !defined(MULTITHREAD)) && defined(LOADERTHREAD)
#undef LOADERTHREAD
#endif
@ -459,13 +449,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
#endif
#ifdef NPFTE
#undef TEXTEDITOR
#undef WEBSERVER //http server
#undef FTPSERVER //ftp server
#undef FTPCLIENT //ftp client.
#endif
#ifndef AVAIL_ZLIB
#undef SUPPORT_ICE //depends upon zlib's crc32 for fingerprinting. I cba writing my own.
#endif

View File

@ -5529,7 +5529,7 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base
return true;
}
#if !defined(NPFTE) && defined(HAVE_CLIENT) //this is *really* unfortunate, but doing this crashes the browser
#if defined(HAVE_CLIENT) //this is *really* unfortunate, but doing this crashes the browser
if (allowprompts && poshname && *gamename && !COM_CheckParm("-manifest"))
{
if (Sys_DoDirectoryPrompt(basepath, basepathlen, poshname, gamename))
@ -5689,7 +5689,7 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base
}
}
#if !defined(NPFTE) && defined(HAVE_CLIENT) //this is *really* unfortunate, but doing this crashes the browser
#if defined(HAVE_CLIENT) //this is *really* unfortunate, but doing this crashes the browser
if (allowprompts && poshname && *gamename && !COM_CheckParm("-manifest"))
{
if (Sys_DoDirectoryPrompt(basepath, basepathlen, poshname, gamename))
@ -7610,18 +7610,11 @@ static qboolean FS_GetBestHomeDir(ftemanifest_t *manifest)
}
}
#ifdef NPFTE
if (!*com_homepath)
Q_snprintfz(com_homepath, sizeof(com_homepath), "/%s/", HOMESUBDIR);
//as a browser plugin, always use their home directory
return true;
#else
/*would it not be better to just check to see if we have write permission to the basedir?*/
if (winver >= 0x6) // Windows Vista and above
usehome = true; // always use home directory by default, as Vista+ mimics this behavior anyway
else if (winver >= 0x5) // Windows 2000/XP/2003
usehome = true; //might as well follow this logic. We use .manifest stuff to avoid getting redirected to obscure locations, so access rights is all that is relevant, not whether we're an admin or not.
#endif
if (usehome && manifest)
{

View File

@ -200,10 +200,6 @@ void *Sys_CreateMutexNamed(char *file, int line);
void Sys_Sleep(double seconds);
#ifdef NPFTE
qboolean NPQTV_Sys_Startup(int argc, char *argv[]);
void NPQTV_Sys_MainLoop(void);
#endif
#define UPD_OFF 0
#define UPD_STABLE 1

View File

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "winquake.h"
#include <conio.h>
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NPFTE)
#if (defined(_DEBUG) || defined(DEBUG))
#if !defined(_MSC_VER) || _MSC_VER > 1200
#define CATCHCRASH
#endif

View File

@ -1440,9 +1440,7 @@ static int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
{
int temp;
qboolean stat;
#ifndef NPFTE
MSG msg;
#endif
// HDC hdc;
vrsetup_t setup = {sizeof(setup)};
@ -1623,7 +1621,6 @@ static int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
// Who knows if it helps, but it probably doesn't hurt
SetForegroundWindow (mainwindow);
#ifndef NPFTE
/*I don't like this, but if we */
Sleep (100);
while (PeekMessage (&msg, mainwindow, 0, 0, PM_REMOVE))
@ -1632,7 +1629,6 @@ static int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
DispatchMessage (&msg);
}
Sleep (100);
#endif
SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0,
SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW |

View File

@ -6,9 +6,7 @@
#include "fs.h"
#if defined(WEBCLIENT)
#ifndef NPFTE
static struct dl_download *activedownloads;
#endif
#if defined(FTE_TARGET_WEB)
@ -148,10 +146,6 @@ typedef struct cookie_s
} cookie_t;
cookie_t *cookies;
#ifdef NPFTE
#define Z_Malloc malloc
#define Z_Free free
#endif
//set a specific cookie.
void Cookie_Feed(char *domain, int secure, char *name, char *value)
@ -284,12 +278,8 @@ void Cookie_Regurgitate(char *domain, int secure, char *buffer, size_t buffersiz
struct http_dl_ctx_s {
// struct dl_download *dlctx;
#ifndef NPFTE
vfsfile_t *stream;
SOCKET sock; //so we can wait on it when multithreaded.
#else
SOCKET sock; //FIXME: support https.
#endif
char *buffer;
@ -317,15 +307,9 @@ void HTTP_Cleanup(struct dl_download *dl)
struct http_dl_ctx_s *con = dl->ctx;
dl->ctx = NULL;
#ifndef NPFTE
if (con->stream)
VFS_CLOSE(con->stream);
con->stream = NULL;
#else
if (con->sock != INVALID_SOCKET)
closesocket(con->sock);
con->sock = INVALID_SOCKET;
#endif
free(con->buffer);
free(con);
@ -413,7 +397,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
switch(con->state)
{
case HC_REQUESTING:
#ifndef NPFTE
ammount = VFS_WRITE(con->stream, con->buffer, con->bufferused);
if (!ammount)
return true;
@ -423,19 +407,6 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
dl->replycode = VFSError_To_HTTP(ammount);
return false;
}
#else
ammount = send(con->sock, con->buffer, con->bufferused, 0);
if (!ammount)
return false;
if (ammount < 0)
{
if (neterrno() != NET_EWOULDBLOCK)
return false;
return true;
}
#endif
con->bufferused -= ammount;
memmove(con->buffer, con->buffer+ammount, con->bufferused);
@ -447,7 +418,6 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
if (con->bufferlen - con->bufferused < 1530)
ExpandBuffer(con, 1530);
#ifndef NPFTE
ammount = VFS_READ(con->stream, con->buffer+con->bufferused, con->bufferlen-con->bufferused-15);
if (!ammount)
return true;
@ -457,17 +427,6 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
dl->replycode = VFSError_To_HTTP(ammount);
return false;
}
#else
ammount = recv(con->sock, con->buffer+con->bufferused, con->bufferlen-con->bufferused-15, 0);
if (!ammount)
return false;
if (ammount < 0)
{
if (neterrno() != NET_EWOULDBLOCK)
return false;
return true;
}
#endif
con->bufferused+=ammount;
con->buffer[con->bufferused] = '\0';
@ -686,7 +645,6 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
if (!dl->file)
{
#ifndef NPFTE
if (*dl->localname)
{
FS_CreatePath(dl->localname, dl->fsroot);
@ -694,7 +652,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
}
else
dl->file = FS_OpenTemp();
#endif
if (!dl->file)
{
if (*dl->localname)
@ -725,21 +683,11 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
if (con->bufferlen - con->bufferused < 1530)
ExpandBuffer(con, 1530);
#ifndef NPFTE
ammount = VFS_READ(con->stream, con->buffer+con->bufferused, con->bufferlen-con->bufferused-1);
if (ammount == 0)
return true; //no data yet
else if (ammount < 0)
ammount = 0; //error (EOF?)
#else
ammount = recv(con->sock, con->buffer+con->bufferused, con->bufferlen-con->bufferused-1, 0);
if (ammount < 0)
{
if (neterrno() != NET_EWOULDBLOCK)
return false;
return true;
}
#endif
con->bufferused+=ammount;
@ -886,12 +834,6 @@ firstread:
void HTTPDL_Establish(struct dl_download *dl)
{
#ifdef NPFTE
unsigned long _true = true;
struct sockaddr_qstorage serveraddr;
int addressfamily;
int addresssize;
#endif
struct http_dl_ctx_s *con;
qboolean https = false;
@ -935,7 +877,6 @@ void HTTPDL_Establish(struct dl_download *dl)
dl->status = DL_RESOLVING;
#ifndef NPFTE
con->sock = INVALID_SOCKET;
con->stream = NULL;
con->secure = false;
@ -968,53 +909,6 @@ void HTTPDL_Establish(struct dl_download *dl)
dl->status = DL_FAILED;
return;
}
#else
con->secure = false;
if (https || !NET_StringToSockaddr(con->server, 80, &serveraddr, &addressfamily, &addresssize))
{
dl->status = DL_FAILED;
return;
}
dl->status = DL_QUERY;
if ((con->sock = socket (addressfamily, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
dl->status = DL_FAILED;
return;
}
//don't bother binding. its optional.
//FIXME: make the connect call with a non-blocking socket.
//FIXME: use a vfsfile_t instead of a direct socket to support https
//not yet blocking.
if (connect(con->sock, (struct sockaddr *)&serveraddr, addresssize) == -1)
{
int err = neterrno();
switch(err)
{
case NET_EACCES:
Con_Printf("HTTP: connect(%s): access denied. Check firewall.\n", con->server);
break;
case NET_ETIMEDOUT:
Con_Printf("HTTP: connect(%s): timed out.\n", con->server);
break;
default:
Con_Printf("HTTP: connect(%s): %s", con->server, strerror(neterrno()));
break;
}
dl->status = DL_FAILED;
return;
}
if (ioctlsocket (con->sock, FIONBIO, &_true) == -1) //now make it non blocking.
{
dl->status = DL_FAILED;
return;
}
#endif
#ifdef COOKIECOOKIECOOKIE
Cookie_Regurgitate(con->server, con->secure, cookies, sizeof(cookies));
#endif
@ -1227,7 +1121,6 @@ qboolean DataScheme_Decode(struct dl_download *dl)
if (!dl->file)
{
#ifndef NPFTE
if (*dl->localname)
{
FS_CreatePath(dl->localname, dl->fsroot);
@ -1235,7 +1128,6 @@ qboolean DataScheme_Decode(struct dl_download *dl)
}
else
dl->file = FS_OpenTemp();
#endif
if (!dl->file)
{
if (*dl->localname)
@ -1290,7 +1182,7 @@ qboolean DL_Decide(struct dl_download *dl)
#ifdef MULTITHREAD
static unsigned int dlthreads = 0;
#define MAXDOWNLOADTHREADS 4
#if defined(LOADERTHREAD) && !defined(NPFTE)
#if defined(LOADERTHREAD)
static void HTTP_Wake_Think(void *ctx, void *data, size_t a, size_t b)
{
dlthreads--;
@ -1305,25 +1197,14 @@ static int DL_Thread_Work(void *arg)
{
if (!dl->poll(dl))
{
#ifdef NPFTE
//the plugin doesn't have a download loop
if (dl->notifycomplete)
{
dl->notifycomplete(dl);
dl->notifycomplete = NULL;
}
if (dl->file)
VFS_CLOSE(dl->file);
#else
if (dl->status != DL_FAILED && dl->status != DL_FINISHED)
dl->status = DL_FAILED;
#endif
break;
}
}
dl->threadenable = false;
#if defined(LOADERTHREAD) && !defined(NPFTE)
#if defined(LOADERTHREAD)
COM_AddWork(WG_MAIN, HTTP_Wake_Think, NULL, NULL, 0, 0);
#endif
return 0;
@ -1345,7 +1226,7 @@ qboolean DL_CreateThread(struct dl_download *dl, vfsfile_t *file, void (*NotifyF
dl->notifycomplete = NotifyFunction;
dl->threadenable = true;
#if defined(LOADERTHREAD) && !defined(NPFTE)
#if defined(LOADERTHREAD)
if (dlthreads < 4)
#endif
{
@ -1385,7 +1266,7 @@ struct dl_download *DL_Create(const char *url)
newdl->poll = DL_Decide;
newdl->fsroot = FS_GAMEONLY;
newdl->sizelimit = 0x80000000u; //some sanity limit.
#if !defined(NPFTE) && !defined(SERVERONLY)
#if !defined(SERVERONLY)
newdl->qdownload.method = DL_HTTP;
#endif
@ -1403,7 +1284,6 @@ void DL_Close(struct dl_download *dl)
{
struct dl_download **link = NULL;
#ifndef NPFTE
for (link = &activedownloads; *link; link = &(*link)->next)
{
if (*link == dl)
@ -1412,9 +1292,8 @@ void DL_Close(struct dl_download *dl)
break;
}
}
#endif
#if !defined(NPFTE) && !defined(SERVERONLY)
#if !defined(SERVERONLY)
if (cls.download == &dl->qdownload)
cls.download = NULL;
#endif
@ -1440,7 +1319,6 @@ void DL_Close(struct dl_download *dl)
free(dl);
}
#ifndef NPFTE
void DL_DeThread(void)
{
#ifdef MULTITHREAD
@ -1639,7 +1517,6 @@ void HTTP_CL_Terminate(void)
Cookie_Monster();
#endif
}
#endif
#endif /*WEBCLIENT*/