for (i = 0; i < 100; i++)
remap[i] = i;
- cdaudioinitialized = true;
+ Cvar_RegisterVariable(&cdaudioinitialized);
+ Cvar_SetValueQuick(&cdaudioinitialized, true);
enabled = true;
return 0;
extern HWND mainwindow;
-qboolean cdaudioinitialized = false;
+cvar_t cdaudioinitialized = {CVAR_READONLY,"cdaudioinitialized","0"};
static qboolean cdValid = false;
static qboolean playing = false;
static qboolean wasPlaying = false;
for (n = 0; n < 100; n++)
remap[n] = n;
- cdaudioinitialized = true;
+
+ Cvar_RegisterVariable(&cdaudioinitialized);
+ Cvar_SetValueQuick(&cdaudioinitialized, true);
enabled = true;
Cmd_AddCommand("cd", CD_f);
char pattern[MAX_OSPATH];
if (Cmd_Argc() > 3)
{
- Con_Printf("usage:\ndir [path/pattern]\n");
+ Con_Printf("usage:\nls [path/pattern]\n");
return;
}
if (Cmd_Argc() == 2)
{
GL_ActiveTexture(i);
unit->combinergb = combinergb;
- if (gl_combine.integer)
+ if (gl_combine.integer)
{
qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, unit->combinergb);CHECKGLERROR
}
M_Options_PrintCheckbox("Delay gfx (faster)", true, gl_delayfinish.integer);
M_Options_PrintSlider( "Anisotropic Filter", gl_support_anisotropy, gl_texture_anisotropy.value, 0, 8);
M_Options_PrintSlider( " Game Speed", sv.active, slowmo.value, 0, 5);
- M_Options_PrintSlider( " CD Music Volume", cdaudioinitialized, bgmvolume.value, 0, 1);
- M_Options_PrintSlider( " Sound Volume", snd_initialized, volume.value, 0, 1);
- M_Options_PrintSlider(gamemode == GAME_GOODVSBAD2 ? " Music Volume" : " Ambient Volume", snd_initialized, snd_staticvolume.value, 0, 1);
+ M_Options_PrintSlider( " CD Music Volume", cdaudioinitialized.integer, bgmvolume.value, 0, 1);
+ M_Options_PrintSlider( " Sound Volume", snd_initialized.integer, volume.value, 0, 1);
+ M_Options_PrintSlider(gamemode == GAME_GOODVSBAD2 ? " Music Volume" : " Ambient Volume", snd_initialized.integer, snd_staticvolume.value, 0, 1);
M_Options_PrintSlider( " Crosshair", true, crosshair.value, 0, 5);
M_Options_PrintSlider( " Crosshair Size", true, crosshair_size.value, 1, 5);
M_Options_PrintCheckbox(" Static Crosshair", true, crosshair_static.integer);
"NEH_CMD_PLAY2 "
"NEH_RESTOREGAME "
"TW_SV_STEPCONTROL "
+"DP_QC_FS_SEARCH " // Black: same as in the menu qc
;
qboolean checkextension(char *name)
}
+/////////////////////////////////////////
+// DP_QC_FS_SEARCH extension
+
+// qc fs search handling
+#define MAX_SEARCHES 128
+
+fssearch_t *pr_fssearchlist[MAX_SEARCHES];
+
+void PR_Search_Init(void)
+{
+ memset(pr_fssearchlist,0,sizeof(pr_fssearchlist));
+}
+
+void PR_Search_Reset(void)
+{
+ int i;
+ // reset the fssearch list
+ for(i = 0; i < MAX_SEARCHES; i++)
+ if(pr_fssearchlist[i])
+ FS_FreeSearch(pr_fssearchlist[i]);
+ memset(pr_fssearchlist,0,sizeof(pr_fssearchlist));
+}
+
+/*
+=========
+PF_search_begin
+
+float search_begin(string pattern, float caseinsensitive, float quiet)
+=========
+*/
+void PF_search_begin(void)
+{
+ int handle;
+ char *pattern;
+ int caseinsens, quiet;
+
+ pattern = G_STRING(OFS_PARM0);
+
+ PR_CheckEmptyString(pattern);
+
+ caseinsens = G_FLOAT(OFS_PARM1);
+ quiet = G_FLOAT(OFS_PARM2);
+
+ for(handle = 0; handle < MAX_SEARCHES; handle++)
+ if(!pr_fssearchlist[handle])
+ break;
+
+ if(handle >= MAX_SEARCHES)
+ {
+ Con_Printf("PR_search_begin: ran out of search handles (%i)\n", MAX_SEARCHES);
+ G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(!(pr_fssearchlist[handle] = FS_Search(pattern,caseinsens, quiet)))
+ G_FLOAT(OFS_RETURN) = -1;
+ else
+ G_FLOAT(OFS_RETURN) = handle;
+}
+
+/*
+=========
+VM_search_end
+
+void search_end(float handle)
+=========
+*/
+void PF_search_end(void)
+{
+ int handle;
+
+ handle = G_FLOAT(OFS_PARM0);
+
+ if(handle < 0 || handle >= MAX_SEARCHES)
+ {
+ Con_Printf("PF_search_end: invalid handle %i\n", handle);
+ return;
+ }
+ if(pr_fssearchlist[handle] == NULL)
+ {
+ Con_Printf("PF_search_end: no such handle %i\n", handle);
+ return;
+ }
+
+ FS_FreeSearch(pr_fssearchlist[handle]);
+ pr_fssearchlist[handle] = NULL;
+}
+
+/*
+=========
+VM_search_getsize
+
+float search_getsize(float handle)
+=========
+*/
+void PF_search_getsize(void)
+{
+ int handle;
+
+ handle = G_FLOAT(OFS_PARM0);
+
+ if(handle < 0 || handle >= MAX_SEARCHES)
+ {
+ Con_Printf("PF_search_getsize: invalid handle %i\n", handle);
+ return;
+ }
+ if(pr_fssearchlist[handle] == NULL)
+ {
+ Con_Printf("PF_search_getsize: no such handle %i\n", handle);
+ return;
+ }
+
+ G_FLOAT(OFS_RETURN) = pr_fssearchlist[handle]->numfilenames;
+}
+
+/*
+=========
+VM_search_getfilename
+
+string search_getfilename(float handle, float num)
+=========
+*/
+void PF_search_getfilename(void)
+{
+ int handle, filenum;
+ char *tmp;
+
+ handle = G_FLOAT(OFS_PARM0);
+ filenum = G_FLOAT(OFS_PARM1);
+
+ if(handle < 0 || handle >= MAX_SEARCHES)
+ {
+ Con_Printf("PF_search_getfilename: invalid handle %i\n", handle);
+ return;
+ }
+ if(pr_fssearchlist[handle] == NULL)
+ {
+ Con_Printf("PF_search_getfilename: no such handle %i\n", handle);
+ return;
+ }
+ if(filenum < 0 || filenum >= pr_fssearchlist[handle]->numfilenames)
+ {
+ Con_Printf("PF_search_getfilename: invalid filenum %i\n", filenum);
+ return;
+ }
+
+ tmp = PR_GetTempString();
+ strcpy(tmp, pr_fssearchlist[handle]->filenames[filenum]);
+
+ G_INT(OFS_RETURN) = PR_SetString(tmp);
+}
+
+
builtin_t pr_builtin[] =
{
NULL, // #0
PF_tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND)
PF_argv, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND)
PF_setattachment, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS)
-NULL, // #444
-NULL, // #445
-NULL, // #446
-NULL, // #447
+PF_search_begin, // #444
+PF_search_end, // #445
+PF_search_getsize, // #446
+PF_search_getfilename, // #447
NULL, // #448
NULL, // #449
a a a a a // #450-499 (LordHavoc)
{
pr_strings_mempool = Mem_AllocPool("pr_stringszone");
PR_Files_Init();
+ PR_Search_Init();
}
void PR_Cmd_Reset(void)
{
Mem_EmptyPool(pr_strings_mempool);
+ PR_Search_Reset();
PR_Files_CloseAll();
}
// AK
// Basically every vm builtin cmd should be in here.
-// All 3 builtin list and extension lists can be found here
-// cause large (I think they will) are from pr_cmds the same copyright like in pr_cms
+// All 3 builtin and extension lists can be found here
+// cause large (I think they will) parts are from pr_cmds the same copyright like in pr_cmds
// also applies here
crash()
stackdump()
+float search_begin(string pattern, float caseinsensitive, float quiet)
+void search_end(float handle)
+float search_getsize(float handle)
+string search_getfilename(float handle, float num)
+
perhaps only : Menu : WriteMsg
===============================
writetofile(float fhandle, entity ent)
float isfunction(string function_name)
vector getresolution(float number)
+string keynumtostring(float keynum)
+
*/
#include "quakedef.h"
qfile_t *vm_files[MAX_PRVMFILES];
+// qc fs search handling
+#define MAX_VMSEARCHES 128
+#define TOTAL_VMSEARCHES MAX_VMSEARCHES * PRVM_MAXPROGS
+#define VM_SEARCHLIST ((fssearch_t**)(vm_fssearchlist + PRVM_GetProgNr() * MAX_VMSEARCHES))
+
+fssearch_t *vm_fssearchlist[TOTAL_VMSEARCHES];
+
static char *VM_GetTempString(void)
{
char *s;
PRVM_G_FLOAT(OFS_RETURN) = (float) (val % m);
}
+void VM_Search_Init(void)
+{
+ memset(VM_SEARCHLIST,0,sizeof(fssearch_t*[MAX_VMSEARCHES]));
+}
+
+void VM_Search_Reset(void)
+{
+ int i;
+ // reset the fssearch list
+ for(i = 0; i < MAX_VMSEARCHES; i++)
+ if(VM_SEARCHLIST[i])
+ FS_FreeSearch(VM_SEARCHLIST[i]);
+ memset(VM_SEARCHLIST,0,sizeof(fssearch_t*[MAX_VMSEARCHES]));
+}
+
+/*
+=========
+VM_search_begin
+
+float search_begin(string pattern, float caseinsensitive, float quiet)
+=========
+*/
+void VM_search_begin(void)
+{
+ int handle;
+ char *pattern;
+ int caseinsens, quiet;
+
+ VM_SAFEPARMCOUNT(3, VM_search_begin);
+
+ pattern = PRVM_G_STRING(OFS_PARM0);
+
+ VM_CheckEmptyString(pattern);
+
+ caseinsens = PRVM_G_FLOAT(OFS_PARM1);
+ quiet = PRVM_G_FLOAT(OFS_PARM2);
+
+ for(handle = 0; handle < MAX_VMSEARCHES; handle++)
+ if(!VM_SEARCHLIST[handle])
+ break;
+
+ if(handle >= MAX_VMSEARCHES)
+ {
+ Con_Printf("VM_search_begin: %s ran out of search handles (%i)\n", PRVM_NAME, MAX_VMSEARCHES);
+ PRVM_G_FLOAT(OFS_RETURN) = -2;
+ return;
+ }
+
+ if(!(VM_SEARCHLIST[handle] = FS_Search(pattern,caseinsens, quiet)))
+ PRVM_G_FLOAT(OFS_RETURN) = -1;
+ else
+ PRVM_G_FLOAT(OFS_RETURN) = handle;
+}
+
+/*
+=========
+VM_search_end
+
+void search_end(float handle)
+=========
+*/
+void VM_search_end(void)
+{
+ int handle;
+ VM_SAFEPARMCOUNT(1, VM_search_end);
+
+ handle = PRVM_G_FLOAT(OFS_PARM0);
+
+ if(handle < 0 || handle >= MAX_VMSEARCHES)
+ {
+ Con_Printf("VM_search_end: invalid handle %i used in %s\n", handle, PRVM_NAME);
+ return;
+ }
+ if(VM_SEARCHLIST[handle] == NULL)
+ {
+ Con_Printf("VM_search_end: no such handle %i in %s\n", handle, PRVM_NAME);
+ return;
+ }
+
+ FS_FreeSearch(VM_SEARCHLIST[handle]);
+ VM_SEARCHLIST[handle] = NULL;
+}
+
+/*
+=========
+VM_search_getsize
+
+float search_getsize(float handle)
+=========
+*/
+void VM_search_getsize(void)
+{
+ int handle;
+ VM_SAFEPARMCOUNT(1, VM_M_search_getsize);
+
+ handle = PRVM_G_FLOAT(OFS_PARM0);
+
+ if(handle < 0 || handle >= MAX_VMSEARCHES)
+ {
+ Con_Printf("VM_search_getsize: invalid handle %i used in %s\n", handle, PRVM_NAME);
+ return;
+ }
+ if(VM_SEARCHLIST[handle] == NULL)
+ {
+ Con_Printf("VM_search_getsize: no such handle %i in %s\n", handle, PRVM_NAME);
+ return;
+ }
+
+ PRVM_G_FLOAT(OFS_RETURN) = VM_SEARCHLIST[handle]->numfilenames;
+}
+
+/*
+=========
+VM_search_getfilename
+
+string search_getfilename(float handle, float num)
+=========
+*/
+void VM_search_getfilename(void)
+{
+ int handle, filenum;
+ char *tmp;
+ VM_SAFEPARMCOUNT(2, VM_search_getfilename);
+
+ handle = PRVM_G_FLOAT(OFS_PARM0);
+ filenum = PRVM_G_FLOAT(OFS_PARM1);
+
+ if(handle < 0 || handle >= MAX_VMSEARCHES)
+ {
+ Con_Printf("VM_search_getfilename: invalid handle %i used in %s\n", handle, PRVM_NAME);
+ return;
+ }
+ if(VM_SEARCHLIST[handle] == NULL)
+ {
+ Con_Printf("VM_search_getfilename: no such handle %i in %s\n", handle, PRVM_NAME);
+ return;
+ }
+ if(filenum < 0 || filenum >= VM_SEARCHLIST[handle]->numfilenames)
+ {
+ Con_Printf("VM_search_getfilename: invalid filenum %i in %s\n", filenum, PRVM_NAME);
+ return;
+ }
+
+ tmp = VM_GetTempString();
+ strcpy(tmp, VM_SEARCHLIST[handle]->filenames[filenum]);
+
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetString(tmp);
+}
+
//=============================================================================
// Draw builtins (client & menu)
{
// only init the stuff for the current prog
VM_STRINGS_MEMPOOL = Mem_AllocPool(va("vm_stringsmempool[%s]",PRVM_NAME));
- VM_Files_Init();
+ VM_Files_Init();
+ VM_Search_Init();
}
void VM_Cmd_Reset(void)
{
//Mem_EmptyPool(VM_STRINGS_MEMPOOL);
Mem_FreePool(&VM_STRINGS_MEMPOOL);
+ VM_Search_Reset();
VM_Files_CloseAll();
}
PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
}
+/*
+=========
+VM_M_keynumtostring
+
+string keynumtostring(float keynum)
+=========
+*/
+void VM_M_keynumtostring(void)
+{
+ int keynum;
+ char *tmp;
+ VM_SAFEPARMCOUNT(1, VM_M_keynumtostring);
+
+ keynum = PRVM_G_FLOAT(OFS_PARM0);
+
+ tmp = VM_GetTempString();
+
+ strcpy(tmp, Key_KeynumToString(keynum));
+
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetString(tmp);
+}
+
prvm_builtin_t vm_m_builtins[] = {
0, // to be consistent with the old vm
// common builtings (mostly)
VM_str_cvar,
VM_crash,
VM_stackdump, // 73
- 0,0,0,0,0,0,0,// 80
+ VM_search_begin,
+ VM_search_end,
+ VM_search_getsize,
+ VM_search_getfilename, // 77
+ 0,0,0,// 80
e10, // 90
e10, // 100
e100, // 200
VM_M_callfunction,
VM_M_writetofile,
VM_M_isfunction,
- VM_M_getresolution // 608
+ VM_M_getresolution,
+ VM_M_keynumtostring // 609
};
const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
{
//VM_Cmd_Init();
VM_Cmd_Reset();
-}
-
+}
\ No newline at end of file
int snd_blocked = 0;
static qboolean snd_ambient = 1;
-qboolean snd_initialized = false;
+//qboolean snd_initialized = false;
+cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0"};
// pointer should go away
volatile dma_t *shm = 0;
void S_Startup(void)
{
- if (!snd_initialized)
+ if (!snd_initialized.integer)
return;
shm = &sn;
Cvar_RegisterVariable(&nosound);
Cvar_RegisterVariable(&snd_precache);
+ Cvar_RegisterVariable(&snd_initialized);
Cvar_RegisterVariable(&bgmbuffer);
Cvar_RegisterVariable(&ambient_level);
Cvar_RegisterVariable(&ambient_fade);
Cvar_RegisterVariable(&_snd_mixahead);
Cvar_RegisterVariable(&snd_swapstereo); // LordHavoc: for people with backwards sound wiring
- snd_initialized = true;
+ Cvar_SetValueQuick(&snd_initialized, true);
known_sfx = Mem_Alloc(snd_mempool, MAX_SFX*sizeof(sfx_t));
num_sfx = 0;
{
int i;
- if (!snd_initialized)
+ if (!snd_initialized.integer)
return NULL;
if (!name)
int i;
sfx_t *sfx;
- if (!snd_initialized)
+ if (!snd_initialized.integer)
return NULL;
if (!name)
{
sfx_t *sfx;
- if (!snd_initialized)
+ if (!snd_initialized.integer)
return NULL;
sfx = S_FindName(name);
channel_t *ch;
channel_t *combine;
- if (!snd_initialized || (snd_blocked > 0))
+ if (!snd_initialized.integer || (snd_blocked > 0))
return;
VectorCopy(origin, listener_vieworigin);
{
sfx_t *sfx;
- if (!snd_initialized || nosound.integer)
+ if (!snd_initialized.integer || nosound.integer)
return;
sfx = S_PrecacheSound (sound, true);
extern cvar_t volume;
extern cvar_t snd_swapstereo;
-extern qboolean cdaudioinitialized;
-extern qboolean snd_initialized;
+extern cvar_t cdaudioinitialized;
+extern cvar_t snd_initialized;
extern int snd_blocked;