From 6767d6bfa0afc9e494dc98bd6273f56053a61ec9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 19 Jan 2002 20:45:45 +0000 Subject: [PATCH] win32 compile fixes --- include/compat.h | 2 ++ include/qstring.h | 5 +++++ libs/console/menu.c | 18 ++++++++++++++++++ libs/util/string.c | 11 +++++++---- libs/video/renderer/gl/gl_draw.c | 1 + libs/video/targets/joy_win.c | 1 - libs/video/targets/vid_wgl.c | 7 ++++--- nq/source/Makefile.am | 3 +-- nq/source/net_wins.c | 2 +- 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/include/compat.h b/include/compat.h index 0f4a15779..1024a5ccb 100644 --- a/include/compat.h +++ b/include/compat.h @@ -59,10 +59,12 @@ #if defined(HAVE__SNPRINTF) # undef snprintf # define snprintf Q_snprintfz +# define need_qstring_h #endif #if defined(HAVE__VSNPRINTF) # undef vsnprintf # define vsnprintf Q_vsnprintfz +# define need_qstring_h #endif #if defined(_WIN32) && !defined(__BORLANDC__) # define kbhit _kbhit diff --git a/include/qstring.h b/include/qstring.h index ee8b6f4c8..22061b5ef 100644 --- a/include/qstring.h +++ b/include/qstring.h @@ -29,7 +29,12 @@ #ifndef string_h #define string_h +#include +#include + const char * Q_strcasestr (const char *haystack, const char *needle); size_t Q_strnlen (const char *s, size_t maxlen); +size_t Q_snprintfz (char *dest, size_t size, const char *fmt, ...) __attribute__((format(printf,3,4))); +size_t Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr); #endif // string_h diff --git a/libs/console/menu.c b/libs/console/menu.c index 409feb338..2dd41ab1f 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -57,6 +57,7 @@ typedef struct menu_item_s { int x, y; func_t func; func_t cursor; + func_t keyevent; const char *text; menu_pic_t *pics; } menu_item_t; @@ -209,6 +210,14 @@ bi_Menu_Cursor (progs_t *pr) menu->cursor = func; } +static void +bi_Menu_KeyEvent (progs_t *pr) +{ + func_t func = G_FUNCTION (pr, OFS_PARM0); + + menu->keyevent = func; +} + static void bi_Menu_End (progs_t *pr) { @@ -236,6 +245,7 @@ Menu_Init (void) PR_AddBuiltin (&menu_pr_state, "Menu_CenterPic", bi_Menu_CenterPic, -1); PR_AddBuiltin (&menu_pr_state, "Menu_Item", bi_Menu_Item, -1); PR_AddBuiltin (&menu_pr_state, "Menu_Cursor", bi_Menu_Cursor, -1); + PR_AddBuiltin (&menu_pr_state, "Menu_KeyEvent", bi_Menu_KeyEvent, -1); PR_AddBuiltin (&menu_pr_state, "Menu_End", bi_Menu_End, -1); R_Progs_Init (&menu_pr_state); @@ -333,6 +343,14 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down) { if (!menu) return; + if (menu->keyevent) { + G_INT (&menu_pr_state, OFS_PARM0) = key; + G_INT (&menu_pr_state, OFS_PARM1) = unicode; + G_INT (&menu_pr_state, OFS_PARM2) = down; + PR_ExecuteProgram (&menu_pr_state, menu->keyevent); + if (G_INT (&menu_pr_state, OFS_RETURN)) + return; + } switch (key) { case QFK_DOWN: case QFM_WHEEL_DOWN: diff --git a/libs/util/string.c b/libs/util/string.c index 5ea861ad0..28afb2749 100644 --- a/libs/util/string.c +++ b/libs/util/string.c @@ -32,6 +32,7 @@ static const char rcsid[] = #endif #include +#include #include "compat.h" @@ -67,8 +68,8 @@ Q_strnlen (const char *s, size_t maxlen) } #ifdef HAVE__VSNPRINTF -void -Q_snprintfz (char *dest, size_t size, char *fmt, ...) +size_t +Q_snprintfz (char *dest, size_t size, const char *fmt, ...) { int len; va_list argptr; @@ -78,10 +79,11 @@ Q_snprintfz (char *dest, size_t size, char *fmt, ...) va_end (argptr); if (len < 0) // the string didn't fit into the buffer dest[size - 1] = 0; + return len; } -void -Q_vsnprintfz (char *dest, size_t size, va_list argptr) +size_t +Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr) { int len; @@ -89,5 +91,6 @@ Q_vsnprintfz (char *dest, size_t size, va_list argptr) if (len < 0) // the string didn't fit into the buffer dest[size - 1] = 0; + return len; } #endif diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 215a8b1cb..324915459 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -60,6 +60,7 @@ static const char rcsid[] = #include "QF/GL/qf_vid.h" #include "QF/GL/types.h" +#include "compat.h" #include "r_cvar.h" #include "r_shared.h" #include "sbar.h" diff --git a/libs/video/targets/joy_win.c b/libs/video/targets/joy_win.c index a05bde6e9..52e7b84c0 100644 --- a/libs/video/targets/joy_win.c +++ b/libs/video/targets/joy_win.c @@ -58,7 +58,6 @@ cvar_t *joy_sensitivity; // Joystick sensitivity #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, // trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V #define JOY_AXIS_X 0 #define JOY_AXIS_Y 1 #define JOY_AXIS_Z 2 diff --git a/libs/video/targets/vid_wgl.c b/libs/video/targets/vid_wgl.c index 3290d1678..d39951038 100644 --- a/libs/video/targets/vid_wgl.c +++ b/libs/video/targets/vid_wgl.c @@ -752,7 +752,7 @@ VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; snprintf (modelist[nummodes].modedesc, - sizeof (modelist[nummodes].modedesc), "%dx%dx%d", + sizeof (modelist[nummodes].modedesc), "%ldx%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel); @@ -813,7 +813,7 @@ VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; snprintf (modelist[nummodes].modedesc, - sizeof (modelist[nummodes].modedesc), "%dx%dx%d", + sizeof (modelist[nummodes].modedesc), "%ldx%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel); @@ -953,7 +953,8 @@ VID_Init (unsigned char *palette) modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = bpp; snprintf (modelist[nummodes].modedesc, - sizeof (modelist[nummodes].modedesc), "%dx%dx%d", + sizeof (modelist[nummodes].modedesc), + "%ldx%ldx%ld", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel); diff --git a/nq/source/Makefile.am b/nq/source/Makefile.am index e53bf51d1..516bae85b 100644 --- a/nq/source/Makefile.am +++ b/nq/source/Makefile.am @@ -179,8 +179,7 @@ nq_x11_DEPENDENCIES= $(nq_x11_libs) opengl_QFLIBS= \ $(top_builddir)/libs/video/renderer/libQFrenderer_gl.la \ - $(top_builddir)/libs/models/libQFmodels_gl.la \ - $(top_builddir)/libs/video/targets/libQFglx.la + $(top_builddir)/libs/models/libQFmodels_gl.la # ... Linux 3DFX nq_3dfx_libs= \ diff --git a/nq/source/net_wins.c b/nq/source/net_wins.c index a15b6d514..4a469ca8f 100644 --- a/nq/source/net_wins.c +++ b/nq/source/net_wins.c @@ -136,7 +136,7 @@ WINS_GetLocalAddress () myAddr = *(int *) local->h_addr_list[0]; addr = ntohl (myAddr); - snprintf (my_tcpip_address, sizeof (my_tcpip_address), "%d.%d.%d.%d", + snprintf (my_tcpip_address, sizeof (my_tcpip_address), "%ld.%ld.%ld.%ld", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); }