From 68bc3e753af19234160b95ec7ba782df40a42710 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 2 Jan 2015 05:57:14 +0000 Subject: [PATCH] fix npfte. fix autoupdate+debugging conflict bug git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4816 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_plugfte.c | 14 ++++++++------ engine/client/sys_win.c | 9 +++++---- engine/common/bothdefs.h | 2 +- engine/common/net_ssl_gnutls.c | 2 ++ engine/common/net_ssl_winsspi.c | 3 ++- engine/common/sys_win_threads.c | 2 +- engine/http/httpclient.c | 31 +++++++++++++++++++++---------- engine/qclib/qccgui.c | 4 ++-- 8 files changed, 42 insertions(+), 25 deletions(-) diff --git a/engine/client/sys_plugfte.c b/engine/client/sys_plugfte.c index 027fdf56c..ecfd7166b 100644 --- a/engine/client/sys_plugfte.c +++ b/engine/client/sys_plugfte.c @@ -125,14 +125,14 @@ void VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...) Q_vsnprintfz(dest, size, fmt, argptr); va_end (argptr); } -char *COM_TrimString(char *str) + +char *COM_TrimString(char *str, char *buffer, int buffersize) { int i; - static char buffer[256]; while (*str <= ' ' && *str>'\0') str++; - for (i = 0; i < 255; i++) + for (i = 0; i < buffersize-1; i++) { if (*str <= ' ') break; @@ -228,7 +228,7 @@ int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ... #include #endif #endif -qboolean NET_StringToSockaddr (const char *s, int defaultport, struct sockaddr_qstorage *sadr, int *addrfamily, int *addrsize) +qboolean NET_StringToSockaddr2 (const char *s, int defaultport, struct sockaddr_qstorage *sadr, int *addrfamily, int *addrsize, size_t addrcount) { struct addrinfo *addrinfo = NULL; struct addrinfo *pos; @@ -243,6 +243,8 @@ qboolean NET_StringToSockaddr (const char *s, int defaultport, struct sockaddr_q void *lib = LoadLibrary("ws2_32.dll"); if (!lib) return false; + if (addrcount != 1) + return false; pgetaddrinfo = (void*)GetProcAddress(lib, "getaddrinfo"); pfreeaddrinfo = (void*)GetProcAddress(lib, "freeaddrinfo"); if (!pgetaddrinfo || !pfreeaddrinfo) @@ -348,8 +350,8 @@ char *COM_ParseOut (const char *data, char *out, int outlen) int c; int len; - if (out == com_token) - COM_AssertMainThread("COM_ParseOut: com_token"); +// if (out == com_token) +// COM_AssertMainThread("COM_ParseOut: com_token"); len = 0; out[0] = 0; diff --git a/engine/client/sys_win.c b/engine/client/sys_win.c index 8bff7b1be..13f8146f2 100644 --- a/engine/client/sys_win.c +++ b/engine/client/sys_win.c @@ -2726,7 +2726,7 @@ qboolean Sys_CheckUpdated(void) return false; else if (!COM_CheckParm("-autoupdate") && !COM_CheckParm("--autoupdate")) return false; - else if (COM_CheckParm("-plugin")) + else if (isPlugin == 1) { //download, but don't invoke. the caller is expected to start us up properly (once installed). } @@ -2737,6 +2737,7 @@ qboolean Sys_CheckUpdated(void) char pendingpath[MAX_OSPATH]; char updatedpath[MAX_OSPATH]; + //FIXME: store versions instead of names MyRegGetStringValue(HKEY_CURRENT_USER, "Software\\"FULLENGINENAME, "pending" UPD_BUILDTYPE EXETYPE, pendingpath, sizeof(pendingpath)); if (*pendingpath) { @@ -3121,9 +3122,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin host_parms.binarydir = bindir; COM_InitArgv (parms.argc, parms.argv); - if (Sys_CheckUpdated()) - return true; - c = COM_CheckParm("-plugin"); if (c) { @@ -3135,6 +3133,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin else isPlugin = 0; + if (Sys_CheckUpdated()) + return true; + if (COM_CheckParm("-register_types")) { Sys_DoFileAssociations(1); diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index 8f3a5a065..d9c285c04 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -97,7 +97,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define AVAIL_D3D #endif -#ifndef MINIMAL +#if !defined(MINIMAL) && !defined(NPFTE) && !defined(NPQTV) #if defined(_WIN32) && !defined(FTE_SDL) && !defined(WINRT) #define HAVE_WINSSPI //built in component, checks against windows' root ca database and revocations etc. #elif defined(__linux__) || defined(__CYGWIN__) diff --git a/engine/common/net_ssl_gnutls.c b/engine/common/net_ssl_gnutls.c index e9396f8d0..00059e2b8 100644 --- a/engine/common/net_ssl_gnutls.c +++ b/engine/common/net_ssl_gnutls.c @@ -444,6 +444,8 @@ vfsfile_t *FS_OpenSSL(const char *hostname, vfsfile_t *source, qboolean server) const int kx_prio[] = {GNUTLS_KX_ANON_DH, 0}; const int cert_type_priority[3] = {GNUTLS_CRT_X509, 0}; + if (!source) + return NULL; { static qboolean needinit = true; diff --git a/engine/common/net_ssl_winsspi.c b/engine/common/net_ssl_winsspi.c index 328ec61d5..1e81c1537 100644 --- a/engine/common/net_ssl_winsspi.c +++ b/engine/common/net_ssl_winsspi.c @@ -790,7 +790,8 @@ vfsfile_t *FS_OpenSSL(const char *hostname, vfsfile_t *source, qboolean server) if (!source || !SSL_Inited()) { - VFS_CLOSE(source); + if (source) + VFS_CLOSE(source); return NULL; } if (!hostname) diff --git a/engine/common/sys_win_threads.c b/engine/common/sys_win_threads.c index 2bf6001af..0c97d8e28 100644 --- a/engine/common/sys_win_threads.c +++ b/engine/common/sys_win_threads.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "winquake.h" #include -#if (defined(_DEBUG) || defined(DEBUG)) +#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NPFTE) #define CATCHCRASH LONG CALLBACK nonmsvc_CrashExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo); diff --git a/engine/http/httpclient.c b/engine/http/httpclient.c index 578fa6d8a..fc1792c9a 100644 --- a/engine/http/httpclient.c +++ b/engine/http/httpclient.c @@ -279,7 +279,7 @@ It doesn't use persistant connections. struct http_dl_ctx_s { // struct dl_download *dlctx; -#if 1 +#ifndef NPFTE vfsfile_t *sock; #else SOCKET sock; //FIXME: support https. @@ -308,7 +308,7 @@ void HTTP_Cleanup(struct dl_download *dl) struct http_dl_ctx_s *con = dl->ctx; dl->ctx = NULL; -#if 1 +#ifndef NPFTE if (con->sock) VFS_CLOSE(con->sock); con->sock = NULL; @@ -346,7 +346,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl) switch(con->state) { case HC_REQUESTING: -#if 1 +#ifndef NPFTE ammount = VFS_WRITE(con->sock, con->buffer, con->bufferused); if (!ammount) return true; @@ -376,7 +376,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl) if (con->bufferlen - con->bufferused < 1530) ExpandBuffer(con, 1530); -#if 1 +#ifndef NPFTE ammount = VFS_READ(con->sock, con->buffer+con->bufferused, con->bufferlen-con->bufferused-15); if (!ammount) return true; @@ -583,7 +583,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl) if (con->bufferlen - con->bufferused < 1530) ExpandBuffer(con, 1530); -#if 1 +#ifndef NPFTE ammount = VFS_READ(con->sock, con->buffer+con->bufferused, con->bufferlen-con->bufferused-1); if (ammount == 0) return true; //no data yet @@ -699,10 +699,12 @@ static qboolean HTTP_DL_Work(struct dl_download *dl) void HTTPDL_Establish(struct dl_download *dl) { -// unsigned long _true = true; -// struct sockaddr_qstorage serveraddr; -// int addressfamily; -// int addresssize; +#ifdef NPFTE + unsigned long _true = true; + struct sockaddr_qstorage serveraddr; + int addressfamily; + int addresssize; +#endif struct http_dl_ctx_s *con; qboolean https = false; @@ -741,18 +743,27 @@ void HTTPDL_Establish(struct dl_download *dl) dl->status = DL_RESOLVING; -#if 1 +#ifndef NPFTE if (https) { +#ifdef HAVE_SSL //https uses port 443 instead of 80 by default con->sock = FS_OpenTCP(server, 443); //and with an extra ssl/tls layer between tcp and http. con->sock = FS_OpenSSL(server, con->sock, false); +#else + con->sock = NULL; +#endif } else { con->sock = FS_OpenTCP(server, 80); } + if (!con->sock) + { + dl->status = DL_FAILED; + return; + } #else if (!NET_StringToSockaddr(server, 80, &serveraddr, &addressfamily, &addresssize)) { diff --git a/engine/qclib/qccgui.c b/engine/qclib/qccgui.c index 708143d4e..d80078882 100644 --- a/engine/qclib/qccgui.c +++ b/engine/qclib/qccgui.c @@ -982,7 +982,7 @@ char *WordUnderCursor(editor_t *editor, char *word, int wordsize, char *term, in (linebuf[charidx-1] >= 'a' && linebuf[charidx-1] <= 'z') || (linebuf[charidx-1] >= 'A' && linebuf[charidx-1] <= 'Z') || (linebuf[charidx-1] >= '0' && linebuf[charidx-1] <= '9') || - linebuf[charidx-1] == '_' || linebuf[charidx-1] == ':' || || linebuf[charidx-1] == '.' || + linebuf[charidx-1] == '_' || linebuf[charidx-1] == ':' || linebuf[charidx-1] == '.' || linebuf[charidx-1] == '[' || linebuf[charidx-1] == ']' || linebuf[charidx-1] >= 128 )) @@ -2423,7 +2423,7 @@ static LRESULT CALLBACK EngineWndProc(HWND hWnd,UINT message, SendMessage(tooltip_editor->editpane, SCI_CALLTIPSHOW, (WPARAM)tooltip_position, (LPARAM)tip); } - free(lParam); + free((char*)lParam); } break;