1
0
Fork 0
forked from fte/fteqw

Allow menuqc to access the clipboard. Fix some c++ish warnings. Fix SDL build linker issues.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5728 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2020-07-14 00:48:56 +00:00
parent d654854953
commit 6bea300f30
25 changed files with 240 additions and 48 deletions

View file

@ -163,7 +163,7 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith") #void* stuff
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla") #msvc doesn't support vla
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement") #msvc doesn't allow defs after statements, and they're so very tempting...
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc++-compat") #lul
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-truncation=1")
#TODO SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes") #for finding missing statics.
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") #
@ -175,7 +175,7 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
ENDIF()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--warn-common")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-truncation=1")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc++-compat") #lul, thousands of errors!
ENDIF()
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
@ -253,9 +253,10 @@ ELSEIF(${UNIX}) #linux(ish)
ENDIF()
FIND_PACKAGE(ALSA)
IF(NOT ALSA_FOUND)
IF(ALSA_FOUND)
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};AUDIO_ALSA;AUDIO_PULSE)
ELSE()
MESSAGE(WARNING "asound (alsa) library NOT available.")
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ALSA)
ENDIF()
FIND_PACKAGE(X11)

View file

@ -1418,7 +1418,7 @@ ifeq ($(FTE_TARGET),bsd)
GL_EXE_NAME=../$(EXE_NAME)-gl
GLCL_EXE_NAME=../$(EXE_NAME)-glcl
GL_LDFLAGS= -L/usr/local/lib $(GLLDFLAGS) $(XLDFLAGS) -lpthread
GL_CFLAGS=$(GLCFLAGS) -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/freetype2
GL_CFLAGS=$(GLCFLAGS) -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -DAUDIO_OSS
GLB_DIR=gl_bsd
GLCL_DIR=glcl_bsd
@ -1426,7 +1426,7 @@ ifeq ($(FTE_TARGET),bsd)
M_EXE_NAME=../$(EXE_NAME)
MCL_EXE_NAME=../$(EXE_NAME)-cl
M_LDFLAGS= -L/usr/local/lib -L/usr/X11R6/lib $(GLLDFLAGS) $(XLDFLAGS) -lpthread
M_CFLAGS=$(VKCFLAGS) $(GLCFLAGS) -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -DMULTITHREAD
M_CFLAGS=$(VKCFLAGS) $(GLCFLAGS) -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -DMULTITHREAD -DAUDIO_OSS
MB_DIR=m_bsd
MCL_DIR=mcl_bsd
@ -1467,7 +1467,7 @@ ifneq (,$(findstring linux,$(FTE_TARGET)))
HAVE_EGL=
endif
CL_CFLAGS=-DMULTITHREAD -DDYNAMIC_SDL $(HAVE_EGL) $(HAVE_WAYLAND) -DX11QUAKE
CL_CFLAGS=-DMULTITHREAD -DDYNAMIC_SDL $(HAVE_EGL) $(HAVE_WAYLAND) -DX11QUAKE -DAUDIO_PULSE -DAUDIO_ALSA -DAUDIO_OSS -DAUDIO_SDL
BASELDFLAGS+=-Wl,--warn-common
QCC_DIR=linqcc$(BITS)
@ -1633,7 +1633,7 @@ ifeq ($(FTE_TARGET),cyg)
GL_EXE_NAME=../$(EXE_NAME)-cyg-gl$(EXEPOSTFIX)
GLCL_EXE_NAME=../$(EXE_NAME)-cyg-glcl$(EXEPOSTFIX)
GL_LDFLAGS=$(GLLDFLAGS) $(XLDFLAGS) -lz -lltdl
GL_CFLAGS=$(GLCFLAGS) -I/usr/X11R6/include $(CLIENTLIBFLAGS) -DUSE_LIBTOOL
GL_CFLAGS=$(GLCFLAGS) -I/usr/X11R6/include $(CLIENTLIBFLAGS) -DUSE_LIBTOOL -DAUDIO_OSS
GLB_DIR=gl_cygwin
GLCL_DIR=glcl_cygwin
@ -1641,7 +1641,7 @@ ifeq ($(FTE_TARGET),cyg)
M_EXE_NAME=../$(EXE_NAME)-cyg$(EXEPOSTFIX)
MCL_EXE_NAME=../$(EXE_NAME)-cyg-cl$(EXEPOSTFIX)
M_LDFLAGS=$(GLLDFLAGS) $(XLDFLAGS) -lz -lltdl
M_CFLAGS=$(GLCFLAGS) $(CLIENTLIBFLAGS) -DUSE_LIBTOOL
M_CFLAGS=$(GLCFLAGS) $(CLIENTLIBFLAGS) -DUSE_LIBTOOL -DAUDIO_OSS
MB_DIR=m_cygwin
MCL_DIR=mcl_cygwin

View file

@ -190,7 +190,7 @@ qboolean AAS_EntityCollision(int entnum,
//===========================================================================
qboolean AAS_inPVS(vec3_t p1, vec3_t p2)
{
return botimport.inPVS(p1, p2);
return botimport.inPVS(p1, p2)?qtrue:qfalse;
} //end of the function AAS_InPVS
//===========================================================================
// returns true if in Potentially Visible Set

View file

@ -893,7 +893,7 @@ static cvar_t *Cvar_Q3FindVar (const char *var_name)
return NULL;
}
static void UI_SimulateTextEntry(void *cb, char *utf8)
static void UI_SimulateTextEntry(void *cb, const char *utf8)
{
const char *line = utf8;
unsigned int unicode;

View file

@ -13815,7 +13815,7 @@ static texmode_t texmodes[] = {
{"nl", "GL_NEAREST_MIPMAP_LINEAR", 0, 1, 0},
{"ll", "GL_LINEAR_MIPMAP_LINEAR", 1, 1, 1},
//more explicit names
//more explicit names (dupes of the above)
{"n.n", NULL, 0, -1, 0},
{"l.l", NULL, 1, -1, 1},
{"nnn", NULL, 0, 0, 0},

View file

@ -1566,7 +1566,7 @@ static unsigned char *utf_right(unsigned char *start, unsigned char *cursor, qbo
return cursor;
}
void Key_EntryInsert(unsigned char **line, int *linepos, char *instext)
void Key_EntryInsert(unsigned char **line, int *linepos, const char *instext)
{
int i;
int len, olen;
@ -1593,7 +1593,7 @@ void Key_EntryInsert(unsigned char **line, int *linepos, char *instext)
*linepos += len;
}
static void Key_ConsolePaste(void *ctx, char *utf8)
static void Key_ConsolePaste(void *ctx, const char *utf8)
{
unsigned char **line = ctx;
int *linepos = ((line == &chat_buffer)?&chat_bufferpos:&key_linepos);

View file

@ -2970,7 +2970,7 @@ void M_Menu_Video_f (void)
MB_COMBOCVAR("Renderer", vid_renderer, rendererops, renderervalues, NULL),
MB_COMBOCVARRETURN("Display Mode", vid_fullscreen, fullscreenopts, fullscreenvalues, info->dispmode, vid_fullscreen.description),
#endif
MB_COMBOCVAR("Anti-aliasing", vid_multisample, aaopts, aavalues, NULL),
MB_COMBOCVAR("MSAA", vid_multisample, aaopts, aavalues, NULL),
MB_REDTEXT(current3dres, true),
MB_COMBORETURN("Aspect", resmodeopts, resmodechoice, info->resmode, "Select method for determining or configuring display options. The desktop option will attempt to use the width, height, color depth, and refresh from your operating system's desktop environment."),
// aspect entries

View file

@ -1000,6 +1000,22 @@ void QCBUILTIN PF_cl_clientcount (pubprogfuncs_t *prinst, struct globalvars_s *p
#endif
}
/*static void PF_cl_clipboard_got(void *ctx, char *utf8)
{
if (
}
void QCBUILTIN PF_cl_clipboard_get(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
clipboardtype_t cliptype = G_FLOAT(OFS_PARM0);
Sys_Clipboard_PasteText(cliptype, PF_cl_clipboard_got, prinst);
}*/
void QCBUILTIN PF_cl_clipboard_set(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
clipboardtype_t cliptype = G_FLOAT(OFS_PARM0);
const char *str = PR_GetStringOfs(prinst, OFS_PARM1);
Sys_SaveClipboard(cliptype, str);
}
void QCBUILTIN PF_cl_localsound(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char * s = PR_GetStringOfs(prinst, OFS_PARM0);

View file

@ -2950,7 +2950,7 @@ static void QCBUILTIN PF_cs_getstats(pubprogfuncs_t *prinst, struct globalvars_s
((unsigned int*)out)[1] = LittleLong(csqc_playerview->stats[stnum+1]);
((unsigned int*)out)[2] = LittleLong(csqc_playerview->stats[stnum+2]);
((unsigned int*)out)[3] = LittleLong(csqc_playerview->stats[stnum+3]);
((unsigned int*)out)[4] = 0; //make sure it's null terminated
out[sizeof(out)-1] = 0; //make sure it's null terminated
RETURN_TSTRING(out);
}
@ -6609,6 +6609,44 @@ static void QCBUILTIN PF_resourcestatus(pubprogfuncs_t *prinst, struct globalvar
}
}
/*static void PF_cs_clipboard_got(void *ctx, const char *utf8)
{
void *pr_globals;
unsigned int unicode;
int error;
while (*utf8)
{
unicode = utf8_decode(&error, utf8, &utf8);
if (error)
unicode = 0xfffdu;
if (!csqcprogs || !csqcg.input_event || CSIE_PASTE >= dpcompat_csqcinputeventtypes.ival)
return;
#ifdef TEXTEDITOR
if (editormodal)
return;
#endif
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
G_FLOAT(OFS_PARM0) = CSIE_PASTE;
G_FLOAT(OFS_PARM1) = 0;
G_FLOAT(OFS_PARM2) = unicode;
G_FLOAT(OFS_PARM3) = 0;
qcinput_scan = G_FLOAT(OFS_PARM1);
qcinput_unicode = G_FLOAT(OFS_PARM2);
PR_ExecuteProgram (csqcprogs, csqcg.input_event);
qcinput_scan = 0; //and stop replay attacks
qcinput_unicode = 0;
}
}
static void QCBUILTIN PF_cs_clipboard_get(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
clipboardtype_t cliptype = G_FLOAT(OFS_PARM0);
Sys_Clipboard_PasteText(cliptype, PF_cs_clipboard_got, prinst);
}*/
void QCBUILTIN PF_CL_DrawTextField (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
//prefixes:
@ -6989,6 +7027,9 @@ static struct {
{"setmousepos", PF_cl_setmousepos, 0}, //
{"getmousepos", PF_cl_getmousepos, 344}, // #344 This is a DP extension
// {"clipboard_get", PF_cs_clipboard_get, 0}, //don't let csqc read the clipboard right now. its too risky.
{"clipboard_set", PF_cl_clipboard_set, 0}, //it can change it though, no real problem there. just kill the program if its filling it with crap.
{"getinputstate", PF_cs_getinputstate, 345}, // #345 float(float framenum) getinputstate (EXT_CSQC)
{"setsensitivityscaler", PF_cs_setsensitivityscaler, 346}, // #346 void(float sens) setsensitivityscaler (EXT_CSQC)
@ -7277,7 +7318,7 @@ static struct {
{"soundlength", PF_soundlength, 534},
{"buf_loadfile", PF_buf_loadfile, 535},
{"buf_writefile", PF_buf_writefile, 536},
// {"bufstr_find", PF_Fixme, 537},
{"bufstr_find", PF_bufstr_find, 537},
// {"matchpattern", PF_Fixme, 538},
// {"undefined", PF_Fixme, 539},

View file

@ -2243,6 +2243,43 @@ static void QCBUILTIN PF_menu_registercommand (pubprogfuncs_t *prinst, struct gl
Cmd_AddCommand(str, MP_ConsoleCommand_f);
}
static void PF_m_clipboard_got(void *ctx, const char *utf8)
{
void *pr_globals;
unsigned int unicode;
int error;
while (*utf8)
{
unicode = utf8_decode(&error, utf8, &utf8);
if (error)
unicode = 0xfffdu;
if (!menu_world.progs || !mpfuncs.inputevent)
return;
#ifdef TEXTEDITOR
if (editormodal)
return;
#endif
pr_globals = PR_globals(menu_world.progs, PR_CURRENT);
G_FLOAT(OFS_PARM0) = CSIE_PASTE;
G_FLOAT(OFS_PARM1) = 0;
G_FLOAT(OFS_PARM2) = unicode;
G_FLOAT(OFS_PARM3) = 0;
qcinput_scan = G_FLOAT(OFS_PARM1);
qcinput_unicode = G_FLOAT(OFS_PARM2);
PR_ExecuteProgram (menu_world.progs, mpfuncs.inputevent);
qcinput_scan = 0; //and stop replay attacks
qcinput_unicode = 0;
}
}
static void QCBUILTIN PF_m_clipboard_get(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
clipboardtype_t cliptype = G_FLOAT(OFS_PARM0);
Sys_Clipboard_PasteText(cliptype, PF_m_clipboard_got, prinst);
}
static struct {
char *name;
@ -2426,6 +2463,11 @@ static struct {
{"setcursormode", PF_cl_setcursormode, 343},
{"getcursormode", PF_cl_getcursormode, 0},
{"setmousepos", PF_cl_setmousepos, 0},
{"clipboard_get", PF_m_clipboard_get, 0},
{"clipboard_set", PF_cl_clipboard_set, 0},
// {NULL, PF_Fixme, 344},
// {NULL, PF_Fixme, 345},
// {NULL, PF_Fixme, 346},
@ -2568,7 +2610,7 @@ static struct {
{"soundlength", PF_soundlength, 534},
{"buf_loadfile", PF_buf_loadfile, 535},
{"buf_writefile", PF_buf_writefile, 536},
// {"bufstr_find", PF_Fixme, 537},
{"bufstr_find", PF_bufstr_find, 537},
// {"matchpattern", PF_Fixme, 538},
//gap
{"setkeydest", PF_cl_setkeydest, 601},
@ -2699,7 +2741,6 @@ static int PDECL PR_Menu_MapNamedBuiltin(pubprogfuncs_t *progfuncs, int headercr
return 0;
}
static qboolean MP_MouseMove(menu_t *menu, qboolean isabs, unsigned int devid, float xdelta, float ydelta)
{
void *pr_globals;
@ -3313,13 +3354,22 @@ void MP_Draw(void)
if (mpfuncs.fuckeddrawsizes)
{ //pass useless sizes in two args if its a dp menu
((float *)pr_globals)[OFS_PARM0] = vid.pixelwidth;
((float *)pr_globals)[OFS_PARM0+1] = 0; //make sure its set, just in case...
((float *)pr_globals)[OFS_PARM0+2] = 0;
((float *)pr_globals)[OFS_PARM1] = vid.pixelheight;
((float *)pr_globals)[OFS_PARM1+1] = 0;
((float *)pr_globals)[OFS_PARM1+2] = 0;
}
else
{ //pass useful sizes in a 1-arg vector if its an fte menu.
((float *)pr_globals)[OFS_PARM0+0] = vid.width;
((float *)pr_globals)[OFS_PARM0+1] = vid.height;
((float *)pr_globals)[OFS_PARM0+2] = 0;
//make physical pixel counts available too, because we can.
((float *)pr_globals)[OFS_PARM1+0] = vid.pixelwidth;
((float *)pr_globals)[OFS_PARM1+1] = vid.pixelheight;
((float *)pr_globals)[OFS_PARM1+2] = 0;
}
PR_ExecuteProgram(menu_world.progs, mpfuncs.draw);

View file

@ -29,11 +29,11 @@
//I guess noone can be arsed to write it themselves. :/
//
//This file is otherwise known as 'will the linux jokers please stop fucking over the open sound system please'
#ifndef NO_ALSA
#include <alsa/asoundlib.h>
#include "quakedef.h"
#ifdef HAVE_MIXER
#ifdef AUDIO_ALSA
#include <alsa/asoundlib.h>
#include <dlfcn.h>
static void *alsasharedobject;
@ -563,4 +563,3 @@ sounddriver_t ALSA_Output =
ALSA_Enumerate
};
#endif
#endif

View file

@ -1883,11 +1883,15 @@ static sounddriver_t *outputdrivers[] =
#endif
&SDL_Output, //prefered on linux. distros can ensure that its configured correctly.
#ifdef __linux__
#ifdef AUDIO_PULSE
&Pulse_Output, //wasteful, and availability generally means Alsa is broken/defective.
#endif
#ifdef AUDIO_ALSA
&ALSA_Output, //pure shite, and availability generally means OSS is broken/defective.
#endif
#ifdef AUDIO_OSS
&OSS_Output, //good for low latency audio, but not likely to work any more on linux (unlike every other unix system with a decent opengl driver)
#endif
#ifdef __DJGPP__
&SBLASTER_Output, //zomgwtfdos?
#endif

View file

@ -1,5 +1,5 @@
#include "quakedef.h"
#if defined(HAVE_MIXER) && defined(MULTITHREAD)
#ifdef AUDIO_PULSE
#if 0
#include <pulse/simple.h>

View file

@ -918,7 +918,7 @@ qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refres
#if SDL_MAJOR_VERSION >= 2 //probably could include 1.3
#include <SDL_clipboard.h>
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, char *utf8), void *ctx)
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, const char *utf8), void *ctx)
{
callback(ctx, SDL_GetClipboardText());
}
@ -928,7 +928,7 @@ void Sys_SaveClipboard(clipboardtype_t cbt, const char *text)
}
#else
static char *clipboard_buffer;
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, char *utf8), void *ctx)
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, const char *utf8), void *ctx)
{
callback(ctx, clipboard_buffer);
}

View file

@ -1866,7 +1866,7 @@ double Sys_DoubleTime (void)
/////////////////////////////////////////////////////////////
//clipboard
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, char *utf8), void *ctx)
void Sys_Clipboard_PasteText(clipboardtype_t cbt, void (*callback)(void *cb, const char *utf8), void *ctx)
{
HANDLE clipboardhandle;
char *cliputf8;

View file

@ -236,13 +236,14 @@ static void Con_Editor_DeleteSelection(console_t *con)
con->useroffset = con->selstartoffset;
}
}
static void Con_Editor_DoPaste(void *ctx, char *utf8)
static void Con_Editor_DoPaste(void *ctx, const char *utf8)
{
console_t *con = ctx;
if (utf8)
{
conchar_t buffer[8192], *end;
char *s, *nl;
const char *s;
char *nl;
if (*utf8 && (con->flags & CONF_KEEPSELECTION))
Con_Editor_DeleteSelection(con);
for(s = utf8; ; )

View file

@ -204,6 +204,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef AVAIL_DSOUND
#undef AVAIL_XAUDIO2
#undef AVAIL_WASAPI
#undef AUDIO_ALSA
#undef AUDIO_PULSE
#endif
@ -366,6 +369,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//database code requires threads to do stuff async.
#undef USE_SQLITE
#undef USE_MYSQL
#undef AUDIO_PULSE
#endif
#ifdef NO_LIBRARIES //catch-all...
#define NO_DIRECTX

View file

@ -90,6 +90,11 @@ cvar_t registered = CVARD("registered","0","Set if quake's pak1.pak is availa
cvar_t gameversion = CVARFD("gameversion","", CVAR_SERVERINFO, "gamecode version for server browsers");
cvar_t gameversion_min = CVARD("gameversion_min","", "gamecode version for server browsers");
cvar_t gameversion_max = CVARD("gameversion_max","", "gamecode version for server browsers");
#ifndef SVNREVISION
static cvar_t pr_engine = CVARFD("pr_engine",DISTRIBUTION" -", CVAR_NOSAVE, "This cvar exists so that the menuqc is able to determine which engine-specific settings/values to list/suggest. It must not be used to detect formal QC extensions/builtins. Use checkextension/checkbuiltin/checkcommand for that.");
#else
static cvar_t pr_engine = CVARFD("pr_engine",DISTRIBUTION" "STRINGIFY(SVNREVISION), CVAR_NOSAVE, "This cvar exists so that the menuqc is able to determine which engine-specific settings/values to list/suggest. It must not be used to detect formal QC extensions/builtins. Use checkextension/checkbuiltin/checkcommand for that.");
#endif
cvar_t fs_gamename = CVARAD("com_fullgamename", NULL, "fs_gamename", "The filesystem is trying to run this game");
cvar_t com_protocolname = CVARAD("com_protocolname", NULL, "com_gamename", "The protocol game name used for dpmaster queries. For compatibility with DP, you can set this to 'DarkPlaces-Quake' in order to be listed in DP's master server, and to list DP servers.");
cvar_t com_protocolversion = CVARAD("com_protocolversion", "3", NULL, "The protocol version used for dpmaster queries."); //3 by default, for compat with DP/NQ, even if our QW protocol uses different versions entirely. really it only matters for master servers.
@ -5846,6 +5851,7 @@ void COM_Init (void)
Cvar_Register (&host_mapname, "Scripting");
Cvar_Register (&developer, "Debugging");
Cvar_Register (&sys_platform, "Gamecode");
Cvar_Register (&pr_engine, "Gamecode");
Cvar_Register (&registered, "Copy protection");
Cvar_Register (&gameversion, "Gamecode");
Cvar_Register (&gameversion_min, "Gamecode");

View file

@ -1737,7 +1737,7 @@ void QCBUILTIN PF_memptradd (pubprogfuncs_t *prinst, struct globalvars_s *pr_glo
}
void QCBUILTIN PF_memstrsize(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
{ //explicitly returns bytes, not chars.
G_FLOAT(OFS_RETURN) = strlen(PR_GetStringOfs(prinst, OFS_PARM0));
}
@ -4905,6 +4905,69 @@ void QCBUILTIN PF_buf_cvarlist (pubprogfuncs_t *prinst, struct globalvars_s *pr
qsort(strbuflist[bufno].strings, strbuflist[bufno].used, sizeof(char*), PF_buf_sort_ascending);
}
enum matchmethod_e
{
MATCH_AUTO=0,
MATCH_EXACT=1,
MATCH_LEFT=2,
MATCH_RIGHT=3,
MATCH_MIDDLE=4,
MATCH_PATTERN=5,
};
static qboolean domatch(const char *str, const char *pattern, enum matchmethod_e method)
{
switch(method)
{
case MATCH_EXACT:
return !strcmp(str, pattern);
case MATCH_LEFT:
return !strncmp(str, pattern, strlen(pattern));
case MATCH_RIGHT:
{
size_t slen = strlen(str);
size_t plen = strlen(pattern);
if (plen > slen)
return false;
return !strcmp(str + slen-plen, pattern);
}
case MATCH_MIDDLE:
return !!strstr(str, pattern);
case MATCH_AUTO: //just treat as MATCH_PATTERN. we could optimise it a bit, but mneh
case MATCH_PATTERN:
default:
return wildcmp(pattern, str);
}
}
void QCBUILTIN PF_bufstr_find (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
size_t bufno = G_FLOAT(OFS_PARM0)-BUFSTRBASE;
const char *pattern = PR_GetStringOfs(prinst, OFS_PARM1);
enum matchmethod_e matchmethod = G_FLOAT(OFS_PARM2);
int idx = (prinst->callargc > 3)?G_FLOAT(OFS_PARM3):0;
int step = (prinst->callargc > 4)?G_FLOAT(OFS_PARM4):1;
const char *s;
G_FLOAT(OFS_RETURN) = -1; //assume the worst
if (bufno >= strbufmax)
return;
if (strbuflist[bufno].prinst != prinst)
return;
if (idx < 0 || step <= 0)
return;
for (; idx < strbuflist[bufno].used; idx += step)
{
s = strbuflist[bufno].strings[idx];
if (!s) continue;
if (domatch(s, pattern, matchmethod))
{
G_FLOAT(OFS_RETURN) = idx;
break;
}
}
}
//directly reads a file into a stringbuffer
void QCBUILTIN PF_buf_loadfile (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
@ -6615,22 +6678,22 @@ nolength:
break;
case 'S':
{
const char *quotedarg = GETARG_STRING(thisarg);
char quotedbuf[65536]; //FIXME: no idea how big this actually needs to be.
const char *s = GETARG_STRING(thisarg);
s = COM_QuotedString(s, quotedbuf, sizeof(quotedbuf), false);
quotedarg = COM_QuotedString(quotedarg, quotedbuf, sizeof(quotedbuf), false);
if((flags & PRINTF_ALTERNATE) || !VMUTF8)
{ //precision+width are in bytes
if(precision < 0) // not set
Q_snprintfz(o, end - o, formatbuf, width, s);
Q_snprintfz(o, end - o, formatbuf, width, quotedarg);
else
Q_snprintfz(o, end - o, formatbuf, width, precision, s);
Q_snprintfz(o, end - o, formatbuf, width, precision, quotedarg);
o += strlen(o);
}
else
{ //precision+width are in chars
if(precision < 0) // not set
precision = end - o - 1;
unicode_strpad(o, end - o, s, (flags & PRINTF_LEFT) != 0, width, precision, VMUTF8MARKUP);
unicode_strpad(o, end - o, quotedarg, (flags & PRINTF_LEFT) != 0, width, precision, VMUTF8MARKUP);
o += strlen(o);
}
}

View file

@ -461,6 +461,7 @@ void QCBUILTIN PF_cl_getmousetarget (pubprogfuncs_t *prinst, struct globalvars_s
void QCBUILTIN PF_cl_setmousepos (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_setcursormode (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_getcursormode (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_clipboard_set(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_setwindowcaption (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_playingdemo (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_runningserver (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -513,6 +514,7 @@ void QCBUILTIN PF_bufstr_get (pubprogfuncs_t *prinst, struct globalvars_s *pr_g
void QCBUILTIN PF_bufstr_set (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_bufstr_add (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_bufstr_free (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_bufstr_find (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_buf_cvarlist (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_buf_loadfile (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_buf_writefile (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -837,6 +839,7 @@ enum csqc_input_event
CSIE_FOCUS = 5, /*mouse, key, devid. if has, the game window has focus. (true/false/-1)*/
CSIE_JOYAXIS = 6, /*axis, value, devid*/
CSIE_GYROSCOPE = 7, /*x, y, z rotational acceleration*/
CSIE_PASTE = 8, /*syscode, unicode, devid like keydown, but no scancodes*/
};
enum getgamedirinfo_e

View file

@ -78,10 +78,10 @@ char *Sys_ConsoleInput (void);
typedef enum
{
CBT_CLIPBOARD, //ctrl+c, ctrl+v
CBT_SELECTION, //select-to-copy, middle-to-paste
CBT_CLIPBOARD //ctrl+c, ctrl+v
} clipboardtype_t;
void Sys_Clipboard_PasteText(clipboardtype_t clipboardtype, void (*callback)(void *cb, char *utf8), void *ctx); //calls the callback once the text is available (maybe instantly). utf8 arg may be NULL if the clipboard was unavailable.
void Sys_Clipboard_PasteText(clipboardtype_t clipboardtype, void (*callback)(void *ctx, const char *utf8), void *ctx); //calls the callback once the text is available (maybe instantly). utf8 arg may be NULL if the clipboard was unavailable.
void Sys_SaveClipboard(clipboardtype_t clipboardtype, const char *text); //a stub would do nothing.
//stuff for dynamic dedicated console -> gfx and back.
@ -159,13 +159,13 @@ void *Sys_CreateMutexNamed(char *file, int line);
#define Sys_LockMutex(m) Sys_MutexStub()
#define Sys_UnlockMutex(m) Sys_MutexStub()
#ifndef __cplusplus
static inline qboolean Sys_IsThread(void *thread) {return !thread;}
static inline qboolean Sys_IsThread(void *thread) {return (!thread)?qtrue:qfalse;}
#endif
#else
#define Sys_IsMainThread() (qboolean)(true)
#define Sys_IsMainThread() (qboolean)(qtrue)
#define Sys_CreateMutex() (void*)(NULL)
#define Sys_LockMutex(m) (qboolean)(true)
#define Sys_UnlockMutex(m) (qboolean)(true)
#define Sys_LockMutex(m) (qboolean)(qtrue)
#define Sys_UnlockMutex(m) (qboolean)(qtrue)
#define Sys_DestroyMutex(m) (void)0
#define Sys_IsThread(t) (!t)
#endif

View file

@ -4580,14 +4580,14 @@ rendererinfo_t vkrendererinfo =
#endif
#if 1
static void (*paste_callback)(void *cb, char *utf8);
static void (*paste_callback)(void *cb, const char *utf8);
static void *pastectx;
static struct {
Atom clipboard;
Atom prop;
Atom owner;
} x11paste;
void Sys_Clipboard_PasteText(clipboardtype_t clipboardtype, void (*callback)(void *cb, char *utf8), void *ctx)
void Sys_Clipboard_PasteText(clipboardtype_t clipboardtype, void (*callback)(void *ctx, const char *utf8), void *ctx)
{
//if there's a paste already pending, cancel the callback to ensure it always gets called.
if (paste_callback)

View file

@ -262,7 +262,7 @@ reeval:
OPC->_int = (float)(OPA->_int == OPB->_float);
break;
case OP_EQ_FI:
OPC->_float = (float)(OPA->_float == OPB->_int);
OPC->_int = (float)(OPA->_float == OPB->_int);
break;

View file

@ -11150,6 +11150,9 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"entityprotection",PF_entityprotection,0, 0, 0, 0, D("float(entity e, float nowreadonly)", "Changes the protection on the specified entity to protect it from further edits from QC. The return value is the previous setting. Note that this can be used to unprotect the world, but doing so long term is not advised as you will no longer be able to detect invalid entity references. Also, world is not networked, so results might not be seen by clients (or in other words, world.avelocity_y=64 is a bad idea).")},
{"getlocationname", PF_Fixme, 0, 0, 0, 0, D("string(vector pos)", "Looks up the specified position in the current map's .loc file and reports the nearest marked name.")},
{"clipboard_get", PF_Fixme, 0, 0, 0, 0, D("void(int cliptype)", "Attempts to query the system clipboard. Any pasted text will be returned via Menu_InputEvent")},
{"clipboard_set", PF_Fixme, 0, 0, 0, 0, D("void(int cliptype, string text)", "Changes the system clipboard to the specified text.")},
//end fte extras
//DP extras
@ -11369,7 +11372,7 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"soundlength", PF_Ignore, 0, 0, 0, 534, D("float(string sample)", "Provides a way to query the duration of a sound sample, allowing you to set up a timer to chain samples.")},
{"buf_loadfile", PF_buf_loadfile, 0, 0, 0, 535, D("float(string filename, strbuf bufhandle)", "Appends the named file into a string buffer (which must have been created in advance). The return value merely says whether the file was readable.")},
{"buf_writefile", PF_buf_writefile, 0, 0, 0, 536, D("float(filestream filehandle, strbuf bufhandle, optional float startpos, optional float numstrings)", "Writes the contents of a string buffer onto the end of the supplied filehandle (you must have already used fopen). Additional optional arguments permit you to constrain the writes to a subsection of the stringbuffer.")},
// {"bufstr_find", PF_Fixme, 0, 0, 0, 537, "float(float bufhandle, string match, float matchrule, float startpos)"},
{"bufstr_find", PF_bufstr_find, 0, 0, 0, 537, D("float(float bufhandle, string match, float matchrule, float startpos, float step)", "Looks for the first occurence of the specified string in the buffer, returning its index or -1 on failure.")},
// {"matchpattern", PF_Fixme, 0, 0, 0, 538, "float(string s, string pattern, float matchrule)"},
// {"undefined", PF_Fixme, 0, 0, 0, 539, ""},

View file

@ -5689,6 +5689,7 @@ void SV_ExtractFromUserinfo (client_t *cl, qboolean verbose)
}
if (i != svs.allocated_client_slots)
{ // dup name
char tmpname[80];
if (strlen(newname) > sizeof(cl->namebuf) - 1)
newname[sizeof(cl->namebuf) - 4] = 0;
p = newname;
@ -5701,9 +5702,9 @@ void SV_ExtractFromUserinfo (client_t *cl, qboolean verbose)
p = newname + 4;
}
memmove(newname+10, p, strlen(p)+1);
memcpy(tmpname, p, strlen(p)+1);
sprintf(newname, "(%d)%-.40s", dupc++, newname+10);
sprintf(newname, "(%d)%-.40s", dupc++, tmpname);
}
else
break;