ebfs.txt
来自「quake1 dos源代码最新版本」· 文本 代码 · 共 895 行 · 第 1/3 页
TXT
895 行
{ 117, "stov", PF_stov },
{ 118, "strzone", PF_strzone },
{ 119, "strunzone", PF_strunzone },
{ 0, "zone", PF_strzone }, // 0 indicates that this entry is just for remapping (because of name and number change)
{ 0, "unzone", PF_strunzone },
*/
// 2001-09-20 QuakeC string manipulation by FrikaC/Maddes end
// 2001-11-15 DarkPlaces general builtin functions by Lord Havoc start
// not implemented yet
/*
{ 400, "copyentity", PF_... },
{ 401, "setcolor", PF_... },
{ 402, "findchain", PF_... },
{ 403, "findchainfloat", PF_... },
{ 404, "effect", PF_... },
{ 405, "te_blood", PF_... },
{ 406, "te_bloodshower", PF_... },
{ 407, "te_explosionrgb", PF_... },
{ 408, "te_particlecube", PF_... },
{ 409, "te_particlerain", PF_... },
{ 410, "te_particlesnow", PF_... },
{ 411, "te_spark", PF_... },
{ 412, "te_gunshotquad", PF_... },
{ 413, "te_spikequad", PF_... },
{ 414, "te_superspikequad", PF_... },
{ 415, "te_explosionquad", PF_... },
{ 416, "te_smallflash", PF_... },
{ 417, "te_customflash", PF_... },
{ 418, "te_gunshot", PF_... },
{ 419, "te_spike", PF_... },
{ 420, "te_superspike", PF_... },
{ 421, "te_explosion", PF_... },
{ 422, "te_tarexplosion", PF_... },
{ 423, "te_wizspike", PF_... },
{ 424, "te_knightspike", PF_... },
{ 425, "te_lavasplash", PF_... },
{ 426, "te_teleport", PF_... },
{ 427, "te_explosion2", PF_... },
{ 428, "te_lightning1", PF_... },
{ 429, "te_lightning2", PF_... },
{ 430, "te_lightning3", PF_... },
{ 431, "te_beam", PF_... },
{ 432, "vectorvectors", PF_... },
*/
// 2001-11-15 DarkPlaces general builtin functions by Lord Havoc end
};
int pr_ebfs_numbuiltins = sizeof(pr_ebfs_builtins)/sizeof(pr_ebfs_builtins[0]);
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end
I already added all registered functions (outcommented) including FrikaC's
file access QSG tutorial, Dark Places 1.05 functions and more.
The function "builtin_find", which we will implement later, is already active in
the list.
You also see that you can have different names for the same builtin function for
remapping reasons. Note that the right name must have a default function
number and all extra names must use the default function number zero (0).
As we disabled/removed the old pr_builtin array, we have to rebuild it
dynamically when a PROGS.DAT is loaded. This will be done by allocating enough
memory for it and putting the function pointer of all assigned functions into
the slot of their actual function number.
But before we can do this we have to check what numbers the functions are
assigned to, if no remapping has to be done then the default numbers are used.
When remapping is requested, then first the engine has to search all defined
builtin functions of the PROGS.DAT in the EBFS data array by name and if found,
assign the number used in the PROGS.DAT. Then all unassigned functions are tried
to assign their default number, if not already occupied by a remapped function.
All this has to be done in PR_EDICT.C where the PROGS.DAT is loaded, so we add
the new cvars at the top of it first...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start
cvar_t pr_builtin_find = {"pr_builtin_find", "0", false, false};
cvar_t pr_builtin_remap = {"pr_builtin_remap", "0", false, false};
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end
... and add some more variables to the top of the PR_LoadProgs function ...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm start
int j;
int funcno;
char *funcname;
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm end
... search for the following code in PR_LoadProgs ...
for (i=0 ; i<progs->numfunctions; i++)
{
pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement);
pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start);
pr_functions[i].s_name = LittleLong (pr_functions[i].s_name);
pr_functions[i].s_file = LittleLong (pr_functions[i].s_file);
pr_functions[i].numparms = LittleLong (pr_functions[i].numparms);
pr_functions[i].locals = LittleLong (pr_functions[i].locals);
}
... and replace it with this code ...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm start
// initialize function numbers for PROGS.DAT
pr_numbuiltins = 0;
pr_builtins = NULL;
if (pr_builtin_remap.value)
{
// remove all previous assigned function numbers
for ( j=1 ; j < pr_ebfs_numbuiltins; j++)
{
pr_ebfs_builtins[j].funcno = 0;
}
}
else
{
// use default function numbers
for ( j=1 ; j < pr_ebfs_numbuiltins; j++)
{
pr_ebfs_builtins[j].funcno = pr_ebfs_builtins[j].default_funcno;
// determine highest builtin number (when NOT remapped)
if (pr_ebfs_builtins[j].funcno > pr_numbuiltins)
{
pr_numbuiltins = pr_ebfs_builtins[j].funcno;
}
}
}
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm end
for (i=0 ; i<progs->numfunctions; i++)
{
pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement);
pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start);
pr_functions[i].s_name = LittleLong (pr_functions[i].s_name);
pr_functions[i].s_file = LittleLong (pr_functions[i].s_file);
pr_functions[i].numparms = LittleLong (pr_functions[i].numparms);
pr_functions[i].locals = LittleLong (pr_functions[i].locals);
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm start
if (pr_builtin_remap.value)
{
if (pr_functions[i].first_statement < 0) // builtin function
{
funcno = -pr_functions[i].first_statement;
funcname = pr_strings + pr_functions[i].s_name;
// search function name
for ( j=1 ; j < pr_ebfs_numbuiltins ; j++)
{
if (!(Q_strcasecmp(funcname, pr_ebfs_builtins[j].funcname)))
{
break; // found
}
}
if (j < pr_ebfs_numbuiltins) // found
{
pr_ebfs_builtins[j].funcno = funcno;
}
else
{
Con_DPrintf("Can not assign builtin number #%i to %s - function unknown\n", funcno, funcname);
}
}
}
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm end
}
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm start
if (pr_builtin_remap.value)
{
// check for unassigned functions and try to assign their default function number
for ( i=1 ; i < pr_ebfs_numbuiltins; i++)
{
if ((!pr_ebfs_builtins[i].funcno) && (pr_ebfs_builtins[i].default_funcno)) // unassigned and has a default number
{
// check if default number is already assigned to another function
for ( j=1 ; j < pr_ebfs_numbuiltins; j++)
{
if (pr_ebfs_builtins[j].funcno == pr_ebfs_builtins[i].default_funcno)
{
break; // number already assigned to another builtin function
}
}
if (j < pr_ebfs_numbuiltins) // already assigned
{
Con_DPrintf("Can not assign default builtin number #%i to %s - number is already assigned to %s\n", pr_ebfs_builtins[i].default_funcno, pr_ebfs_builtins[i].funcname, pr_ebfs_builtins[j].funcname);
}
else
{
pr_ebfs_builtins[i].funcno = pr_ebfs_builtins[i].default_funcno;
}
}
// determine highest builtin number (when remapped)
if (pr_ebfs_builtins[i].funcno > pr_numbuiltins)
{
pr_numbuiltins = pr_ebfs_builtins[i].funcno;
}
}
}
pr_numbuiltins++;
// allocate and initialize builtin list for execution time
pr_builtins = Hunk_AllocName (pr_numbuiltins*sizeof(builtin_t), "builtins");
for ( i=0 ; i < pr_numbuiltins ; i++)
{
pr_builtins[i] = pr_ebfs_builtins[0].function;
}
// create builtin list for execution time and set cvars accordingly
Cvar_Set("pr_builtin_find", "0");
// Cvar_Set("pr_checkextension", "0"); // 2001-10-20 Extension System by Lord Havoc/Maddes (DP compatibility)
for ( j=1 ; j < pr_ebfs_numbuiltins ; j++)
{
if (pr_ebfs_builtins[j].funcno) // only put assigned functions into builtin list
{
pr_builtins[pr_ebfs_builtins[j].funcno] = pr_ebfs_builtins[j].function;
}
if (pr_ebfs_builtins[j].default_funcno == PR_DEFAULT_FUNCNO_BUILTIN_FIND)
{
Cvar_SetValue("pr_builtin_find", pr_ebfs_builtins[j].funcno);
}
// 2001-10-20 Extension System by Lord Havoc/Maddes (DP compatibility) start
// not implemented yet
/*
if (pr_ebfs_builtins[j].default_funcno == PR_DEFAULT_FUNCNO_EXTENSION_FIND)
{
Cvar_SetValue("pr_checkextension", pr_ebfs_builtins[j].funcno);
}
*/
// 2001-10-20 Extension System by Lord Havoc/Maddes (DP compatibility) end
}
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes/Firestorm end
... in PR_Init add the following lines ...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start
Cvar_RegisterVariable (&pr_builtin_find);
Cvar_RegisterVariable (&pr_builtin_remap);
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end
You also have to implement the new builtin function "builtin_find".
Back in PR_CMDS.C add the following code anywhere before the builtin variables...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start
/*
=================
PF_builtin_find
float builtin_find (string)
=================
*/
void PF_builtin_find (void)
{
int j;
float funcno;
char *funcname;
funcno = 0;
funcname = G_STRING(OFS_PARM0);
// search function name
for ( j=1 ; j < pr_ebfs_numbuiltins ; j++)
{
if ((pr_ebfs_builtins[j].funcname) && (!(Q_strcasecmp(funcname,pr_ebfs_builtins[j].funcname))))
{
break; // found
}
}
if (j < pr_ebfs_numbuiltins)
{
funcno = pr_ebfs_builtins[j].funcno;
}
G_FLOAT(OFS_RETURN) = funcno;
}
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end
The function searches for the given function name, and if it finds the function
it returns the corresponding function number.
As some function numbers and names have changed when cleaning up the known
functions for the QSG registry, it is useful to point out the remapping
functionality to the user, when a builtin function wasn't found during execution
time.
Go into PR_EXEC.C to PR_ExecuteProgram and add the following variables to it...
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes start
char *funcname;
char *remaphint;
// 2001-09-14 Enhanced BuiltIn Function System (EBFS) by Maddes end
... and change ...
if (newf->first_statement < 0)
{ // negative statements are built in functions
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?