qbool CL_VM_ConsoleCommand (const char *text)
{
prvm_prog_t *prog = CLVM_prog;
- int restorevm_tempstringsbuf_cursize;
- qbool r = false;
- if(!cl.csqc_loaded)
- return false;
- CSQC_BEGIN
- if (PRVM_clientfunction(CSQC_ConsoleCommand))
- {
- PRVM_clientglobalfloat(time) = cl.time;
- PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
- restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
- PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, text);
- prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_ConsoleCommand), "QC function CSQC_ConsoleCommand is missing");
- prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
- r = CSQC_RETURNVAL != 0;
- }
- CSQC_END
- return r;
+ return PRVM_ConsoleCommand(prog, text, &prog->funcoffsets.CSQC_ConsoleCommand, false, cl.csqc_server2csqcentitynumber[cl.playerentity], cl.time, cl.csqc_loaded, "QC function CSQC_ConsoleCommand is missing");
}
qbool CL_VM_Parse_TempEntity (void)
prog->error_cmd("%s: Bad string", prog->name);
}
+qbool PRVM_ConsoleCommand (prvm_prog_t *prog, const char *text, int *func, qbool preserve_self, int curself, double ptime, qbool prog_loaded, const char *error_message)
+{
+ int restorevm_tempstringsbuf_cursize;
+ int save_self;
+ qbool r = false;
+
+ if(!prog_loaded)
+ return false;
+
+ if(func)
+ {
+ if(preserve_self)
+ save_self = PRVM_gameglobaledict(self);
+ if(ptime)
+ PRVM_gameglobalfloat(time) = ptime;
+ PRVM_gameglobaledict(self) = curself;
+ restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
+ PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, text);
+ prog->ExecuteProgram(prog, *func, error_message);
+ prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
+ if(preserve_self)
+ PRVM_gameglobaledict(self) = save_self;
+ r = (int) PRVM_G_FLOAT(OFS_RETURN) != 0;
+ }
+
+ return r;
+}
+
void VM_GenerateFrameGroupBlend(prvm_prog_t *prog, framegroupblend_t *framegroupblend, const prvm_edict_t *ed)
{
// self.frame is the interpolation target (new frame)
// general functions
void VM_CheckEmptyString (prvm_prog_t *prog, const char *s);
void VM_VarString(prvm_prog_t *prog, int first, char *out, int outlength);
+qbool PRVM_ConsoleCommand (prvm_prog_t *prog, const char *text, int *func, qbool preserve_self, int curself, double ptime, qbool prog_loaded, const char *error_message);
prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, int flags, const char *format);
void BufStr_Set(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer, int strindex, const char *str);
void BufStr_Del(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer);
qbool SV_VM_ConsoleCommand (const char *text)
{
prvm_prog_t *prog = SVVM_prog;
- int restorevm_tempstringsbuf_cursize;
- int save_self;
- qbool r = false;
-
- if(!sv.active || !prog || !prog->loaded)
- return false;
-
- if (PRVM_serverfunction(ConsoleCmd))
- {
- save_self = PRVM_serverglobaledict(self);
- PRVM_serverglobalfloat(time) = sv.time;
- restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
- PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(sv.world.prog->edicts);
- PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, text);
- prog->ExecuteProgram(prog, PRVM_serverfunction(ConsoleCmd), "QC function ConsoleCmd is missing");
- prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
- PRVM_serverglobaledict(self) = save_self;
- r = (int) PRVM_G_FLOAT(OFS_RETURN) != 0;
- }
- return r;
+ return PRVM_ConsoleCommand(prog, text, &prog->funcoffsets.ConsoleCmd, true, PRVM_EDICT_TO_PROG(sv.world.prog->edicts), sv.time, !(!sv.active || !prog || !prog->loaded), "QC function ConsoleCmd is missing");
}
// #352 void(string cmdname) registercommand (EXT_CSQC)