Changed the name of GIB builtins from string.length to string::length, etc.

Made a few miscellaneous cleanups and enhancements to builtins and changed
all the GIB scripts in CVS to reflect the new naming conventions.
This commit is contained in:
Brian Koropoff 2002-11-11 01:57:34 +00:00
parent aa5ad0f0f9
commit 0f71b02fd7
7 changed files with 179 additions and 205 deletions

View file

@ -30,23 +30,23 @@
// otherwise it won't know what items are available and where to find // otherwise it won't know what items are available and where to find
// them on the custom menu. To use the provided prozac.menu, you would // them on the custom menu. To use the provided prozac.menu, you would
// type: // type:
// custom.load.menu prozac // custom::load::menu prozac
// //
// To load a class, get to the first page of the custom menu and use // To load a class, get to the first page of the custom menu and use
// custom.load.class to load up a class file. To use the provided // custom::load::class to load up a class file. To use the provided
// warlock.class, you would type: // warlock.class, you would type:
// custom.load.class warlock // custom::load::class warlock
// //
// To record a class, again get to the first page of the custom menu. // To record a class, again get to the first page of the custom menu.
// Now type custom.record at the menu. This will rebind all your // Now type custom::record at the menu. This will rebind all your
// number keys to keep track of what selections you have made. // number keys to keep track of what selections you have made.
// If you decide to restart building your class, you will have to // If you decide to restart building your class, you will have to
// type custom.record again. After you have built your class, // type custom::record again. After you have built your class,
// press 0 as usual. Instead of spawning, you will get a message // press 0 as usual. Instead of spawning, you will get a message
// that recording has finished. To save your class with the name // that recording has finished. To save your class with the name
// "engy" you would then type: // "engy" you would then type:
// custom.record.save engy // custom::record::save engy
// You can now use custom.load.class to reload your class at any // You can now use custom::load::class to construct your class at any
// time. // time.
global custom global custom
@ -72,8 +72,7 @@ custom.load.item_f = {
} }
custom.load.buy_f = { custom.load.buy_f = {
local i local i n
local n
ifnot ${custom.item.$1} return ifnot ${custom.item.$1} return
i = ${custom.item.$1.menu} i = ${custom.item.$1.menu}
n = ${custom.item.$1.number} n = ${custom.item.$1.number}
@ -83,58 +82,62 @@ custom.load.buy_f = {
} }
function custom.load.menu { function custom::load::menu {
local oldm local oldm oldi
local oldi oldm = `function::get menu`
oldm = `function.get menu` oldi = `function::get item`
oldi = `function.get item`
function "menu" ${custom.load.menu_f} function "menu" ${custom.load.menu_f}
function "item" ${custom.load.item_f} function "item" ${custom.load.item_f}
// Clear out old junk // Clear out old junk
global.delete custom.menu global::delete custom.menu
global.delete custom.item global::delete custom.item
custom.menu.size = 0 custom.menu.size = 0
exec "custom/", $1, ".menu" exec "custom/", $1, ".menu"
function "menu" $oldm function "menu" $oldm
function "item" $oldi function "item" $oldi
} }
function custom.load.class { function custom::load::class {
local oldb local oldb
oldb = `function.get buy` oldb = `function::get buy`
custom.menu.cur = 0 custom.menu.cur = 0
function "buy" ${custom.load.buy_f} function "buy" ${custom.load.buy_f}
exec "custom/", $1, ".class" exec "custom/", $1, ".class"
function "buy" $oldb function "buy" $oldb
} }
function custom.menu.seek { function custom::menu::seek::forward {
local fw custom.menu.cur = (${custom.menu.cur} + 1)
fw = (${custom.menu.cur} < $1) impulse 9
while (${custom.menu.cur} != $1) { wait; wait;
if $fw {
custom.menu.cur = (${custom.menu.cur} + 1)
impulse 9
wait; wait;
} else {
custom.menu.cur = (${custom.menu.cur} - 1)
impulse 8
wait; wait;
}
}
} }
function custom.record.item { function custom::menu::seek::backward {
local m custom.menu.cur = (${custom.menu.cur} - 1)
impulse 8
wait; wait;
}
function custom::menu::seek {
local func
if (${custom.menu.cur} < $1) {
func = custom::menu::seek::forward
} else {
func = custom::menu::seek::backward
}
while (${custom.menu.cur} != $1) $func
}
function custom::record::item {
local m line
m = ${custom.menu.cur} m = ${custom.menu.cur}
ifnot ($1 < ${custom.menu.$m.size}) return ifnot ($1 < ${custom.menu.$m.size}) return
local line
line = "buy \"", ${custom.menu.$m.$1}, "\"" line = "buy \"", ${custom.menu.$m.$1}, "\""
custom.recording = ${custom.recording}, "\n", $line custom.recording = ${custom.recording}, "\n", $line
impulse ($1+1) impulse ($1+1)
} }
function custom.record.seek { function custom::record::seek {
local new local new
new = (${custom.menu.cur} + $1) new = (${custom.menu.cur} + $1)
if ($new < 0 || $new >= ${custom.menu.size}) return if ($new < 0 || $new >= ${custom.menu.size}) return
@ -146,39 +149,34 @@ function custom.record.seek {
} }
} }
function custom.record.stop { function custom::record::stop {
bind "0" "impulse 10" bind "0" "impulse 10"
for i in `range 1 9` { for i in `range 1 9` {
bind $i "impulse ", $i bind $i "impulse ", $i
} }
echo "CustomBuild-> Recording finished" echo "CustomBuild-> Recording finished"
custom.recording = "// Script recorded by CustomTF class builder",${custom.recording} custom.recording = "// Script recorded by CustomTF class builder", ${custom.recording}
} }
function custom.record { function custom::record {
custom.menu.cur = 0 custom.menu.cur = 0
custom.recording = "" custom.recording = ""
bind "0" "custom.record.stop" bind "0" "custom.record.stop"
bind "8" "custom.record.seek -1" bind "8" "custom.record.seek -1"
bind "9" "custom.record.seek 1" bind "9" "custom.record.seek 1"
for i in `range 1 7` { for i in `range 1 7` {
bind $i "custom.record.item ",($i-1) bind $i "custom::record::item ",($i-1)
} }
echo "CustomBuild-> Recording class. Please build a class as usual." echo "CustomBuild-> Recording class. Please build a class as usual."
custom custom
} }
function custom.record.save { function custom::record::save {
local file local file
file = "custom/", $1, ".class" file = "custom/", $1, ".class"
echo "Saving class script to ", $file, "..." echo "Saving class script to ", $file, "..."
file.write $file ${custom.recording} file::write $file ${custom.recording}
} }
export custom.load.menu function::export custom::load::menu custom::load::class custom::record::item
export custom.load.class function::export custom::record::seek custom::record::stop custom::record custom::record::save
export custom.record.item
export custom.record.seek
export custom.record.stop
export custom.record
export custom.record.save

View file

@ -20,7 +20,7 @@ function "ln" {
export $2 export $2
} }
export ln function::export ln
// QuakeForge qwcl // QuakeForge qwcl
ln "in_mouse_amp" "sensitivity" ln "in_mouse_amp" "sensitivity"

View file

@ -26,7 +26,7 @@
global zoom global zoom
function "zoom.init" { // Initialize basic options function zoom::init { // Initialize basic options
if ($argc != 6) { if ($argc != 6) {
echo "Usage: $0 base_amp base_fov min_zoom max_zoom zoom_step" echo "Usage: $0 base_amp base_fov min_zoom max_zoom zoom_step"
return return
@ -45,7 +45,7 @@ function "zoom.init" { // Initialize basic options
// Default initial values // Default initial values
zoom.init 1 90 1 90 1.15 zoom.init 1 90 1 90 1.15
function "zoom.adjust" { // Adjust fov and sensitivity to match zoom factor function zoom::adjust { // Adjust fov and sensitivity to match zoom factor
if ${zoom.zoomed} { if ${zoom.zoomed} {
set fov (${zoom.fov}/${zoom.mult}) set fov (${zoom.fov}/${zoom.mult})
set in_amp (${zoom.amp}/${zoom.mult}) set in_amp (${zoom.amp}/${zoom.mult})
@ -56,22 +56,22 @@ function "zoom.adjust" { // Adjust fov and sensitivity to match zoom factor
} }
} }
function "zoom.in" { function zoom::in {
zoom.zoomed = 1 zoom.zoomed = 1
zoom.adjust zoom::adjust
} }
function "zoom.out" { function zoom::out {
zoom.zoomed = 0 zoom.zoomed = 0
zoom.adjust zoom::adjust
} }
function "zoom.toggle" { function zoom::toggle {
zoom.zoomed = (!${zoom.zoomed}) zoom.zoomed = (!${zoom.zoomed})
zoom.adjust zoom::adjust
} }
function "zoom.increase" { function zoom::increase {
ifnot ${zoom.zoomed} { ifnot ${zoom.zoomed} {
return return
} }
@ -79,22 +79,16 @@ function "zoom.increase" {
if (${zoom.mult} > ${zoom.mult.upper}) { if (${zoom.mult} > ${zoom.mult.upper}) {
zoom.mult = ${zoom.mult.upper} zoom.mult = ${zoom.mult.upper}
} }
zoom.adjust zoom::adjust
} }
function "zoom.decrease" { function zoom::decrease {
ifnot ${zoom.zoomed} return ifnot ${zoom.zoomed} return
zoom.mult = (${zoom.mult}/${zoom.mult.step}) zoom.mult = (${zoom.mult}/${zoom.mult.step})
if (${zoom.mult} < ${zoom.mult.lower}) { if (${zoom.mult} < ${zoom.mult.lower}) {
zoom.mult = ${zoom.mult.lower} zoom.mult = ${zoom.mult.lower}
} }
zoom.adjust zoom::adjust
} }
export zoom.init function::export zoom::init zoom::increase zoom::decrease zoom::in zoom::out zoom::toggle
export zoom.increase
export zoom.decrease
export zoom.in
export zoom.out
export zoom.toggle

View file

@ -345,8 +345,8 @@ C_GIB_Print_Center_f (void)
{ {
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"print.center: invalid syntax\n" "print::center: invalid syntax\n"
"usage: print.center text"); "usage: print::center text");
return; return;
} }
SCR_CenterPrint (GIB_Argv(1)); SCR_CenterPrint (GIB_Argv(1));
@ -409,7 +409,7 @@ C_Init (void)
"file"); "file");
// register GIB builtins // register GIB builtins
GIB_Builtin_Add ("print.center", C_GIB_Print_Center_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("print::center", C_GIB_Print_Center_f, GIB_BUILTIN_NORMAL);
con_initialized = true; con_initialized = true;
} }

View file

@ -158,12 +158,12 @@ GIB_Function_f (void)
} }
void void
GIB_FunctionDotGet_f (void) GIB_Function_Get_f (void)
{ {
if (GIB_Argc () != 2) if (GIB_Argc () != 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"function.get: invalid syntax\n" "function.get: invalid syntax\n"
"usage: function.get function_name"); "usage: function::get function_name");
else { else {
gib_function_t *f; gib_function_t *f;
if ((f = GIB_Function_Find (GIB_Argv (1)))) if ((f = GIB_Function_Find (GIB_Argv (1))))
@ -176,26 +176,29 @@ GIB_FunctionDotGet_f (void)
void void
GIB_Local_f (void) GIB_Local_f (void)
{ {
if (GIB_Argc () != 2) int i;
if (GIB_Argc () < 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"lset: invalid syntax\n" "local: invalid syntax\n"
"usage: local variable"); "usage: local varname1 varname2 varname3 [...]");
else else
GIB_Var_Set_Local (cbuf_active, GIB_Argv(1), ""); for (i = 1; i < GIB_Argc(); i++)
GIB_Var_Set_Local (cbuf_active, GIB_Argv(i), "");
} }
void void
GIB_Global_f (void) GIB_Global_f (void)
{ {
if (GIB_Argc () != 2) int i;
if (GIB_Argc () < 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"global: invalid syntax\n" "global: invalid syntax\n"
"usage: global variable"); "usage: global varname1 varname2 varname3 [...]");
else { else
char *a = strdup (GIB_Argv(1)); for (i = 1; i < GIB_Argc(); i++)
GIB_Var_Set_Global (a, ""); GIB_Var_Set_Global (GIB_Argv(i), "");
free(a);
}
} }
void void
@ -203,7 +206,7 @@ GIB_Global_Delete_f (void)
{ {
if (GIB_Argc () != 2) if (GIB_Argc () != 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"global.delete: invalid syntax\n" "global::delete: invalid syntax\n"
"usage: global.delete variable"); "usage: global.delete variable");
GIB_Var_Free_Global (GIB_Argv(1)); GIB_Var_Free_Global (GIB_Argv(1));
} }
@ -299,8 +302,8 @@ GIB_Field_Get_f (void)
const char *ifs; const char *ifs;
if (GIB_Argc() < 3 || GIB_Argc() > 4) { if (GIB_Argc() < 3 || GIB_Argc() > 4) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"field.get: invalid syntax\n" "field::get: invalid syntax\n"
"usage: field.get list element [ifs]" "usage: field::get list element [ifs]"
); );
return; return;
} }
@ -415,6 +418,7 @@ GIB_Break_f (void)
} }
} }
// Note: this is a standard console command, not a GIB builtin
void void
GIB_Runexported_f (void) GIB_Runexported_f (void)
{ {
@ -434,19 +438,22 @@ GIB_Runexported_f (void)
} }
void void
GIB_Export_f (void) GIB_Function_Export_f (void)
{ {
gib_function_t *f; gib_function_t *f;
int i;
if (GIB_Argc() != 2) if (GIB_Argc() < 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"export: invalid syntax\n" "function::export: invalid syntax\n"
"usage: export function"); "usage: funciton::export function1 function2 function3 [...]");
else if (!(f = GIB_Function_Find (GIB_Argv (1)))) for (i = 1; i < GIB_Argc(); i++) {
Cbuf_Error ("existance", "export: function '%s' not found", GIB_Argv (1)); if (!(f = GIB_Function_Find (GIB_Argv (i))))
else if (!f->exported) { Cbuf_Error ("function", "function::export: function '%s' not found", GIB_Argv (i));
Cmd_AddCommand (f->name->str, GIB_Runexported_f, "Exported GIB function."); else if (!f->exported) {
f->exported = true; Cmd_AddCommand (f->name->str, GIB_Runexported_f, "Exported GIB function.");
f->exported = true;
}
} }
} }
@ -455,8 +462,8 @@ GIB_String_Length_f (void)
{ {
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"string.length: invalid syntax\n" "string::length: invalid syntax\n"
"usage: string.length string"); "usage: string::length string");
else else
GIB_Return (va("%i", (int) strlen(GIB_Argv(1)))); GIB_Return (va("%i", (int) strlen(GIB_Argv(1))));
} }
@ -466,8 +473,8 @@ GIB_String_Equal_f (void)
{ {
if (GIB_Argc() != 3) if (GIB_Argc() != 3)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"string.length: invalid syntax\n" "string::equal: invalid syntax\n"
"usage: string.equal string1 string2"); "usage: string::equal string1 string2");
else else
GIB_Return (va("%i", !strcmp(GIB_Argv(1), GIB_Argv(2)))); GIB_Return (va("%i", !strcmp(GIB_Argv(1), GIB_Argv(2))));
} }
@ -477,8 +484,8 @@ GIB_Thread_Create_f (void)
{ {
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"thread.create: invalid syntax\n" "thread::create: invalid syntax\n"
"usage: thread.create program"); "usage: thread::create program");
else { else {
gib_thread_t *thread = GIB_Thread_New (); gib_thread_t *thread = GIB_Thread_New ();
Cbuf_AddText (thread->cbuf, GIB_Argv(1)); Cbuf_AddText (thread->cbuf, GIB_Argv(1));
@ -492,8 +499,8 @@ GIB_Thread_Kill_f (void)
{ {
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"thread.kill: invalid syntax\n" "thread::kill: invalid syntax\n"
"usage: thread.kill id"); "usage: thread::kill id");
else { else {
gib_thread_t *thread; gib_thread_t *thread;
cbuf_t *cur; cbuf_t *cur;
@ -515,52 +522,6 @@ GIB_Thread_Kill_f (void)
/* File access */ /* File access */
int
GIB_CollapsePath (char *str)
{
char *d, *p, *path;
p = path = str;
while (*p) {
if (p[0] == '.') {
if (p[1] == '.') {
if (p[2] == '/' || p[2] == 0) {
d = p;
if (d > path)
d--;
while (d > path && d[-1] != '/')
d--;
if (d == path
&& d[0] == '.' && d[1] == '.'
&& (d[2] == '/' || d[2] == '0')) {
p += 2 + (p[2] == '/');
continue;
}
strcpy (d, p + 2 + (p[2] == '/'));
p = d + (d != path);
}
} else if (p[1] == '/') {
strcpy (p, p + 2);
continue;
} else if (p[1] == 0) {
p[0] = 0;
}
}
while (*p && *p != '/')
p++;
if (*p == '/')
p++;
}
if ((!path[0])
|| (path[0] == '.' && path[1] == '.'
&& (path[2] == '/' || path[2] == 0))
|| (path[strlen (path) - 1] == '/')
|| path[0] == '~') {
return 0;
}
return 1;
}
void void
GIB_File_Read_f (void) GIB_File_Read_f (void)
{ {
@ -569,25 +530,31 @@ GIB_File_Read_f (void)
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"file.read: invalid syntax\n" "file::read: invalid syntax\n"
"usage: file.read path_and_filename"); "usage: file::read path_and_filename");
return; return;
} }
path = GIB_Argv (1); path = COM_CompressPath (GIB_Argv (1));
if (!GIB_CollapsePath (path)) { if (!path[0]) {
Cbuf_Error ("file",
"file::read: null filename provided");
return;
}
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.read: access to %s denied", path); "file::read: access to %s denied", path);
return; return;
} }
mark = Hunk_LowMark (); mark = Hunk_LowMark ();
contents = (char *) COM_LoadHunkFile (path); contents = (char *) COM_LoadHunkFile (path);
if (!contents) { if (!contents) {
Cbuf_Error ("file", Cbuf_Error ("file",
"file.read: could not open %s/%s for reading: %s", com_gamedir, path, strerror (errno)); "file::read: could not open %s/%s for reading: %s", com_gamedir, path, strerror (errno));
return; return;
} }
GIB_Return (contents); GIB_Return (contents);
Hunk_FreeToLowMark (mark); Hunk_FreeToLowMark (mark);
free (path);
} }
void void
@ -598,23 +565,29 @@ GIB_File_Write_f (void)
if (GIB_Argc () != 3) { if (GIB_Argc () != 3) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"file.write: invalid syntax\n" "file::write: invalid syntax\n"
"usage: file.write path_and_filename data"); "usage: file::write path_and_filename data");
return; return;
} }
path = GIB_Argv (1); path = COM_CompressPath (GIB_Argv (1));
if (!GIB_CollapsePath (path)) { if (!path[0]) {
Cbuf_Error ("file",
"file::write: null filename provided");
return;
}
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.write: access to %s denied", path); "file::write: access to %s denied", path);
return; return;
} }
if (!(file = Qopen (va ("%s/%s", com_gamedir, path), "w"))) { if (!(file = Qopen (va ("%s/%s", com_gamedir, path), "w"))) {
Cbuf_Error ("file", Cbuf_Error ("file",
"file.write: could not open %s/%s for writing: %s", com_gamedir, path, strerror (errno)); "file::write: could not open %s/%s for writing: %s", com_gamedir, path, strerror (errno));
return; return;
} }
Qprintf (file, "%s", GIB_Argv (2)); Qprintf (file, "%s", GIB_Argv (2));
Qclose (file); Qclose (file);
free (path);
} }
void void
@ -628,15 +601,20 @@ GIB_File_Find_f (void)
if (GIB_Argc () < 2 || GIB_Argc () > 3) { if (GIB_Argc () < 2 || GIB_Argc () > 3) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"file.find: invalid syntax\n" "file::find: invalid syntax\n"
"usage: file.find glob [path]"); "usage: file::find glob [path]");
return; return;
} }
path = GIB_Argv (2); path = COM_CompressPath (GIB_Argv (2));
if (GIB_Argc () == 3) { if (GIB_Argc () == 3) {
if (!GIB_CollapsePath (path)) { if (!path[0]) {
Cbuf_Error ("file",
"file::find: null path provided");
return;
}
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.find: access to %s denied", path); "file::find: access to %s denied", path);
return; return;
} }
} }
@ -662,6 +640,7 @@ GIB_File_Find_f (void)
else else
GIB_Return (""); GIB_Return ("");
dstring_delete (list); dstring_delete (list);
free (path);
} }
void void
@ -672,20 +651,20 @@ GIB_File_Move_f (void)
if (GIB_Argc () != 3) { if (GIB_Argc () != 3) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"file.move: invalid syntax\n" "file::move: invalid syntax\n"
"usage: file.move from_file to_file"); "usage: file::move from_file to_file");
return; return;
} }
path1 = GIB_Argv (1); path1 = COM_CompressPath (GIB_Argv (1));
path2 = GIB_Argv (2); path2 = COM_CompressPath (GIB_Argv (2));
if (!GIB_CollapsePath (path1)) { if (path1[0] == '/' || (path1[0] == '.' && path1[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.move: access to %s denied", path1); "file::move: access to %s denied", path1);
return; return;
} }
if (!GIB_CollapsePath (path2)) { if (path2[0] == '/' || (path2[0] == '.' && path2[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.move: access to %s denied", path2); "file::move: access to %s denied", path2);
return; return;
} }
from = dstring_newstr (); from = dstring_newstr ();
@ -694,10 +673,12 @@ GIB_File_Move_f (void)
dsprintf (to, "%s/%s", com_gamedir, path2); dsprintf (to, "%s/%s", com_gamedir, path2);
if (Qrename (from->str, to->str)) if (Qrename (from->str, to->str))
Cbuf_Error ("file", Cbuf_Error ("file",
"file.move: could not move %s to %s: %s", "file::move: could not move %s to %s: %s",
from->str, to->str, strerror(errno)); from->str, to->str, strerror(errno));
dstring_delete (from); dstring_delete (from);
dstring_delete (to); dstring_delete (to);
free (path1);
free (path2);
} }
void void
@ -707,20 +688,21 @@ GIB_File_Delete_f (void)
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"file.delete: invalid syntax\n" "file::delete: invalid syntax\n"
"usage: file.delete file"); "usage: file::delete file");
return; return;
} }
path = GIB_Argv (1); path = COM_CompressPath (GIB_Argv (1));
if (!GIB_CollapsePath (path)) { if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
Cbuf_Error ("access", Cbuf_Error ("access",
"file.delete: access to %s denied", path); "file::delete: access to %s denied", path);
return; return;
} }
if (Qremove(va("%s/%s", com_gamedir, path))) if (Qremove(va("%s/%s", com_gamedir, path)))
Cbuf_Error ("file", Cbuf_Error ("file",
"file.delete: could not delete %s/%s: %s", "file::delete: could not delete %s/%s: %s",
com_gamedir, path, strerror(errno)); com_gamedir, path, strerror(errno));
free (path);
} }
void void
@ -773,28 +755,28 @@ GIB_Builtin_Init (void)
gib_globals = Hash_NewTable (512, GIB_Var_Get_Key, GIB_Var_Free, 0); gib_globals = Hash_NewTable (512, GIB_Var_Get_Key, GIB_Var_Free, 0);
GIB_Builtin_Add ("function", GIB_Function_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("function", GIB_Function_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("function.get", GIB_FunctionDotGet_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("function::get", GIB_Function_Get_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("export", GIB_Export_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("function::export", GIB_Function_Export_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("local", GIB_Local_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("local", GIB_Local_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("global", GIB_Global_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("global", GIB_Global_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("global.delete", GIB_Global_Delete_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("global::delete", GIB_Global_Delete_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("return", GIB_Return_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("return", GIB_Return_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("if", GIB_If_f, GIB_BUILTIN_FIRSTONLY); GIB_Builtin_Add ("if", GIB_If_f, GIB_BUILTIN_FIRSTONLY);
GIB_Builtin_Add ("ifnot", GIB_If_f, GIB_BUILTIN_FIRSTONLY); GIB_Builtin_Add ("ifnot", GIB_If_f, GIB_BUILTIN_FIRSTONLY);
GIB_Builtin_Add ("while", GIB_While_f, GIB_BUILTIN_NOPROCESS); GIB_Builtin_Add ("while", GIB_While_f, GIB_BUILTIN_NOPROCESS);
GIB_Builtin_Add ("field.get", GIB_Field_Get_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("field::get", GIB_Field_Get_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("for", GIB_For_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("for", GIB_For_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("__for", GIB___For_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("__for", GIB___For_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("break", GIB_Break_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("break", GIB_Break_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("string.length", GIB_String_Length_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("string::length", GIB_String_Length_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("string.equal", GIB_String_Equal_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("string::equal", GIB_String_Equal_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("thread.create", GIB_Thread_Create_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("thread::create", GIB_Thread_Create_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("thread.kill", GIB_Thread_Kill_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("thread::kill", GIB_Thread_Kill_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("file.read", GIB_File_Read_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("file::read", GIB_File_Read_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("file.write", GIB_File_Write_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("file::write", GIB_File_Write_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("file.find", GIB_File_Find_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("file::find", GIB_File_Find_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("file.move", GIB_File_Move_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("file::move", GIB_File_Move_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("file.delete", GIB_File_Delete_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("file::delete", GIB_File_Delete_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("range", GIB_Range_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("range", GIB_Range_f, GIB_BUILTIN_NORMAL);
GIB_Builtin_Add ("print", GIB_Print_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("print", GIB_Print_f, GIB_BUILTIN_NORMAL);
} }

View file

@ -676,8 +676,8 @@ Key_GIB_Bind_Get_f (void)
if (GIB_Argc() != 2) { if (GIB_Argc() != 2) {
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"bind.get: invalid syntax\n" "bind::get: invalid syntax\n"
"usage: bind.get key" "usage: bind::get key"
); );
return; return;
} }
@ -687,12 +687,12 @@ Key_GIB_Bind_Get_f (void)
key = OK_TranslateKeyName (GIB_Argv (1)); key = OK_TranslateKeyName (GIB_Argv (1));
if ((t = Key_StringToIMTnum (imt)) == -1) { if ((t = Key_StringToIMTnum (imt)) == -1) {
Cbuf_Error ("bind", "bind.get: invalid imt %s", imt); Cbuf_Error ("bind", "bind::get: invalid imt %s", imt);
return; return;
} }
if ((k = Key_StringToKeynum (key)) == -1) { if ((k = Key_StringToKeynum (key)) == -1) {
Cbuf_Error ("bind", "bind.get: invalid key %s", key); Cbuf_Error ("bind", "bind::get: invalid key %s", key);
return; return;
} }
@ -858,7 +858,7 @@ Key_Init (cbuf_t *cb)
"RECOGNIZED key-press. If the key pressed produces no " "RECOGNIZED key-press. If the key pressed produces no "
"output, " PROGRAM " does not recognise that key."); "output, " PROGRAM " does not recognise that key.");
GIB_Builtin_Add ("bind.get", Key_GIB_Bind_Get_f, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("bind::get", Key_GIB_Bind_Get_f, GIB_BUILTIN_NORMAL);
} }

View file

@ -403,14 +403,14 @@ locs_loc (void)
} }
void void
Locs_Location_Get (void) Locs_Loc_Get (void)
{ {
location_t *location; location_t *location;
if (GIB_Argc() != 1) if (GIB_Argc() != 1)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"location.get: invalid syntax\n" "loc::get: invalid syntax\n"
"usage: location.get"); "usage: loc::get");
else { else {
location = locs_find (cl.simorg); location = locs_find (cl.simorg);
GIB_Return (location ? location->name : "unknown"); GIB_Return (location ? location->name : "unknown");
@ -422,7 +422,7 @@ Locs_Init (void)
{ {
Cmd_AddCommand ("loc", locs_loc, "Location marker editing commands: 'loc " Cmd_AddCommand ("loc", locs_loc, "Location marker editing commands: 'loc "
"help' for more"); "help' for more");
GIB_Builtin_Add ("location.get", Locs_Location_Get, GIB_BUILTIN_NORMAL); GIB_Builtin_Add ("loc::get", Locs_Loc_Get, GIB_BUILTIN_NORMAL);
} }
char * char *