mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
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:
parent
aa5ad0f0f9
commit
0f71b02fd7
7 changed files with 179 additions and 205 deletions
|
@ -30,23 +30,23 @@
|
|||
// 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
|
||||
// type:
|
||||
// custom.load.menu prozac
|
||||
// custom::load::menu prozac
|
||||
//
|
||||
// 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:
|
||||
// custom.load.class warlock
|
||||
// custom::load::class warlock
|
||||
//
|
||||
// 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.
|
||||
// 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
|
||||
// that recording has finished. To save your class with the name
|
||||
// "engy" you would then type:
|
||||
// custom.record.save engy
|
||||
// You can now use custom.load.class to reload your class at any
|
||||
// custom::record::save engy
|
||||
// You can now use custom::load::class to construct your class at any
|
||||
// time.
|
||||
|
||||
global custom
|
||||
|
@ -72,8 +72,7 @@ custom.load.item_f = {
|
|||
}
|
||||
|
||||
custom.load.buy_f = {
|
||||
local i
|
||||
local n
|
||||
local i n
|
||||
ifnot ${custom.item.$1} return
|
||||
i = ${custom.item.$1.menu}
|
||||
n = ${custom.item.$1.number}
|
||||
|
@ -83,58 +82,62 @@ custom.load.buy_f = {
|
|||
}
|
||||
|
||||
|
||||
function custom.load.menu {
|
||||
local oldm
|
||||
local oldi
|
||||
oldm = `function.get menu`
|
||||
oldi = `function.get item`
|
||||
function custom::load::menu {
|
||||
local oldm oldi
|
||||
oldm = `function::get menu`
|
||||
oldi = `function::get item`
|
||||
function "menu" ${custom.load.menu_f}
|
||||
function "item" ${custom.load.item_f}
|
||||
// Clear out old junk
|
||||
global.delete custom.menu
|
||||
global.delete custom.item
|
||||
global::delete custom.menu
|
||||
global::delete custom.item
|
||||
custom.menu.size = 0
|
||||
exec "custom/", $1, ".menu"
|
||||
function "menu" $oldm
|
||||
function "item" $oldi
|
||||
}
|
||||
|
||||
function custom.load.class {
|
||||
function custom::load::class {
|
||||
local oldb
|
||||
oldb = `function.get buy`
|
||||
oldb = `function::get buy`
|
||||
custom.menu.cur = 0
|
||||
function "buy" ${custom.load.buy_f}
|
||||
exec "custom/", $1, ".class"
|
||||
function "buy" $oldb
|
||||
}
|
||||
|
||||
function custom.menu.seek {
|
||||
local fw
|
||||
fw = (${custom.menu.cur} < $1)
|
||||
while (${custom.menu.cur} != $1) {
|
||||
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::menu::seek::forward {
|
||||
custom.menu.cur = (${custom.menu.cur} + 1)
|
||||
impulse 9
|
||||
wait; wait;
|
||||
}
|
||||
|
||||
function custom.record.item {
|
||||
local m
|
||||
function custom::menu::seek::backward {
|
||||
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}
|
||||
ifnot ($1 < ${custom.menu.$m.size}) return
|
||||
local line
|
||||
line = "buy \"", ${custom.menu.$m.$1}, "\""
|
||||
custom.recording = ${custom.recording}, "\n", $line
|
||||
impulse ($1+1)
|
||||
}
|
||||
|
||||
function custom.record.seek {
|
||||
function custom::record::seek {
|
||||
local new
|
||||
new = (${custom.menu.cur} + $1)
|
||||
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"
|
||||
for i in `range 1 9` {
|
||||
bind $i "impulse ", $i
|
||||
}
|
||||
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.recording = ""
|
||||
bind "0" "custom.record.stop"
|
||||
bind "8" "custom.record.seek -1"
|
||||
bind "9" "custom.record.seek 1"
|
||||
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."
|
||||
custom
|
||||
}
|
||||
|
||||
function custom.record.save {
|
||||
function custom::record::save {
|
||||
local file
|
||||
file = "custom/", $1, ".class"
|
||||
echo "Saving class script to ", $file, "..."
|
||||
file.write $file ${custom.recording}
|
||||
file::write $file ${custom.recording}
|
||||
}
|
||||
|
||||
export custom.load.menu
|
||||
export custom.load.class
|
||||
export custom.record.item
|
||||
export custom.record.seek
|
||||
export custom.record.stop
|
||||
export custom.record
|
||||
export custom.record.save
|
||||
function::export custom::load::menu custom::load::class custom::record::item
|
||||
function::export custom::record::seek custom::record::stop custom::record custom::record::save
|
||||
|
|
|
@ -20,7 +20,7 @@ function "ln" {
|
|||
export $2
|
||||
}
|
||||
|
||||
export ln
|
||||
function::export ln
|
||||
|
||||
// QuakeForge qwcl
|
||||
ln "in_mouse_amp" "sensitivity"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
global zoom
|
||||
|
||||
function "zoom.init" { // Initialize basic options
|
||||
function zoom::init { // Initialize basic options
|
||||
if ($argc != 6) {
|
||||
echo "Usage: $0 base_amp base_fov min_zoom max_zoom zoom_step"
|
||||
return
|
||||
|
@ -45,7 +45,7 @@ function "zoom.init" { // Initialize basic options
|
|||
// Default initial values
|
||||
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} {
|
||||
set fov (${zoom.fov}/${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.adjust
|
||||
zoom::adjust
|
||||
}
|
||||
|
||||
function "zoom.out" {
|
||||
function zoom::out {
|
||||
zoom.zoomed = 0
|
||||
zoom.adjust
|
||||
zoom::adjust
|
||||
}
|
||||
|
||||
function "zoom.toggle" {
|
||||
function zoom::toggle {
|
||||
zoom.zoomed = (!${zoom.zoomed})
|
||||
zoom.adjust
|
||||
zoom::adjust
|
||||
}
|
||||
|
||||
function "zoom.increase" {
|
||||
function zoom::increase {
|
||||
ifnot ${zoom.zoomed} {
|
||||
return
|
||||
}
|
||||
|
@ -79,22 +79,16 @@ function "zoom.increase" {
|
|||
if (${zoom.mult} > ${zoom.mult.upper}) {
|
||||
zoom.mult = ${zoom.mult.upper}
|
||||
}
|
||||
zoom.adjust
|
||||
zoom::adjust
|
||||
}
|
||||
|
||||
function "zoom.decrease" {
|
||||
function zoom::decrease {
|
||||
ifnot ${zoom.zoomed} return
|
||||
zoom.mult = (${zoom.mult}/${zoom.mult.step})
|
||||
if (${zoom.mult} < ${zoom.mult.lower}) {
|
||||
zoom.mult = ${zoom.mult.lower}
|
||||
}
|
||||
zoom.adjust
|
||||
zoom::adjust
|
||||
}
|
||||
|
||||
export zoom.init
|
||||
export zoom.increase
|
||||
export zoom.decrease
|
||||
export zoom.in
|
||||
export zoom.out
|
||||
export zoom.toggle
|
||||
|
||||
function::export zoom::init zoom::increase zoom::decrease zoom::in zoom::out zoom::toggle
|
||||
|
|
|
@ -345,8 +345,8 @@ C_GIB_Print_Center_f (void)
|
|||
{
|
||||
if (GIB_Argc () != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"print.center: invalid syntax\n"
|
||||
"usage: print.center text");
|
||||
"print::center: invalid syntax\n"
|
||||
"usage: print::center text");
|
||||
return;
|
||||
}
|
||||
SCR_CenterPrint (GIB_Argv(1));
|
||||
|
@ -409,7 +409,7 @@ C_Init (void)
|
|||
"file");
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -158,12 +158,12 @@ GIB_Function_f (void)
|
|||
}
|
||||
|
||||
void
|
||||
GIB_FunctionDotGet_f (void)
|
||||
GIB_Function_Get_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"function.get: invalid syntax\n"
|
||||
"usage: function.get function_name");
|
||||
"usage: function::get function_name");
|
||||
else {
|
||||
gib_function_t *f;
|
||||
if ((f = GIB_Function_Find (GIB_Argv (1))))
|
||||
|
@ -176,26 +176,29 @@ GIB_FunctionDotGet_f (void)
|
|||
void
|
||||
GIB_Local_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2)
|
||||
int i;
|
||||
|
||||
if (GIB_Argc () < 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"lset: invalid syntax\n"
|
||||
"usage: local variable");
|
||||
"local: invalid syntax\n"
|
||||
"usage: local varname1 varname2 varname3 [...]");
|
||||
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
|
||||
GIB_Global_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2)
|
||||
int i;
|
||||
|
||||
if (GIB_Argc () < 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"global: invalid syntax\n"
|
||||
"usage: global variable");
|
||||
else {
|
||||
char *a = strdup (GIB_Argv(1));
|
||||
GIB_Var_Set_Global (a, "");
|
||||
free(a);
|
||||
}
|
||||
"usage: global varname1 varname2 varname3 [...]");
|
||||
else
|
||||
for (i = 1; i < GIB_Argc(); i++)
|
||||
GIB_Var_Set_Global (GIB_Argv(i), "");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -203,7 +206,7 @@ GIB_Global_Delete_f (void)
|
|||
{
|
||||
if (GIB_Argc () != 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"global.delete: invalid syntax\n"
|
||||
"global::delete: invalid syntax\n"
|
||||
"usage: global.delete variable");
|
||||
GIB_Var_Free_Global (GIB_Argv(1));
|
||||
}
|
||||
|
@ -299,8 +302,8 @@ GIB_Field_Get_f (void)
|
|||
const char *ifs;
|
||||
if (GIB_Argc() < 3 || GIB_Argc() > 4) {
|
||||
Cbuf_Error ("syntax",
|
||||
"field.get: invalid syntax\n"
|
||||
"usage: field.get list element [ifs]"
|
||||
"field::get: invalid syntax\n"
|
||||
"usage: field::get list element [ifs]"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -415,6 +418,7 @@ GIB_Break_f (void)
|
|||
}
|
||||
}
|
||||
|
||||
// Note: this is a standard console command, not a GIB builtin
|
||||
void
|
||||
GIB_Runexported_f (void)
|
||||
{
|
||||
|
@ -434,19 +438,22 @@ GIB_Runexported_f (void)
|
|||
}
|
||||
|
||||
void
|
||||
GIB_Export_f (void)
|
||||
GIB_Function_Export_f (void)
|
||||
{
|
||||
gib_function_t *f;
|
||||
int i;
|
||||
|
||||
if (GIB_Argc() != 2)
|
||||
if (GIB_Argc() < 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"export: invalid syntax\n"
|
||||
"usage: export function");
|
||||
else if (!(f = GIB_Function_Find (GIB_Argv (1))))
|
||||
Cbuf_Error ("existance", "export: function '%s' not found", GIB_Argv (1));
|
||||
else if (!f->exported) {
|
||||
Cmd_AddCommand (f->name->str, GIB_Runexported_f, "Exported GIB function.");
|
||||
f->exported = true;
|
||||
"function::export: invalid syntax\n"
|
||||
"usage: funciton::export function1 function2 function3 [...]");
|
||||
for (i = 1; i < GIB_Argc(); i++) {
|
||||
if (!(f = GIB_Function_Find (GIB_Argv (i))))
|
||||
Cbuf_Error ("function", "function::export: function '%s' not found", GIB_Argv (i));
|
||||
else if (!f->exported) {
|
||||
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)
|
||||
Cbuf_Error ("syntax",
|
||||
"string.length: invalid syntax\n"
|
||||
"usage: string.length string");
|
||||
"string::length: invalid syntax\n"
|
||||
"usage: string::length string");
|
||||
else
|
||||
GIB_Return (va("%i", (int) strlen(GIB_Argv(1))));
|
||||
}
|
||||
|
@ -466,8 +473,8 @@ GIB_String_Equal_f (void)
|
|||
{
|
||||
if (GIB_Argc() != 3)
|
||||
Cbuf_Error ("syntax",
|
||||
"string.length: invalid syntax\n"
|
||||
"usage: string.equal string1 string2");
|
||||
"string::equal: invalid syntax\n"
|
||||
"usage: string::equal string1 string2");
|
||||
else
|
||||
GIB_Return (va("%i", !strcmp(GIB_Argv(1), GIB_Argv(2))));
|
||||
}
|
||||
|
@ -477,8 +484,8 @@ GIB_Thread_Create_f (void)
|
|||
{
|
||||
if (GIB_Argc() != 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"thread.create: invalid syntax\n"
|
||||
"usage: thread.create program");
|
||||
"thread::create: invalid syntax\n"
|
||||
"usage: thread::create program");
|
||||
else {
|
||||
gib_thread_t *thread = GIB_Thread_New ();
|
||||
Cbuf_AddText (thread->cbuf, GIB_Argv(1));
|
||||
|
@ -492,8 +499,8 @@ GIB_Thread_Kill_f (void)
|
|||
{
|
||||
if (GIB_Argc() != 2)
|
||||
Cbuf_Error ("syntax",
|
||||
"thread.kill: invalid syntax\n"
|
||||
"usage: thread.kill id");
|
||||
"thread::kill: invalid syntax\n"
|
||||
"usage: thread::kill id");
|
||||
else {
|
||||
gib_thread_t *thread;
|
||||
cbuf_t *cur;
|
||||
|
@ -515,52 +522,6 @@ GIB_Thread_Kill_f (void)
|
|||
|
||||
/* 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
|
||||
GIB_File_Read_f (void)
|
||||
{
|
||||
|
@ -569,25 +530,31 @@ GIB_File_Read_f (void)
|
|||
|
||||
if (GIB_Argc () != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"file.read: invalid syntax\n"
|
||||
"usage: file.read path_and_filename");
|
||||
"file::read: invalid syntax\n"
|
||||
"usage: file::read path_and_filename");
|
||||
return;
|
||||
}
|
||||
path = GIB_Argv (1);
|
||||
if (!GIB_CollapsePath (path)) {
|
||||
path = COM_CompressPath (GIB_Argv (1));
|
||||
if (!path[0]) {
|
||||
Cbuf_Error ("file",
|
||||
"file::read: null filename provided");
|
||||
return;
|
||||
}
|
||||
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
|
||||
Cbuf_Error ("access",
|
||||
"file.read: access to %s denied", path);
|
||||
"file::read: access to %s denied", path);
|
||||
return;
|
||||
}
|
||||
mark = Hunk_LowMark ();
|
||||
contents = (char *) COM_LoadHunkFile (path);
|
||||
if (!contents) {
|
||||
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;
|
||||
}
|
||||
GIB_Return (contents);
|
||||
Hunk_FreeToLowMark (mark);
|
||||
free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -598,23 +565,29 @@ GIB_File_Write_f (void)
|
|||
|
||||
if (GIB_Argc () != 3) {
|
||||
Cbuf_Error ("syntax",
|
||||
"file.write: invalid syntax\n"
|
||||
"usage: file.write path_and_filename data");
|
||||
"file::write: invalid syntax\n"
|
||||
"usage: file::write path_and_filename data");
|
||||
return;
|
||||
}
|
||||
path = GIB_Argv (1);
|
||||
if (!GIB_CollapsePath (path)) {
|
||||
path = COM_CompressPath (GIB_Argv (1));
|
||||
if (!path[0]) {
|
||||
Cbuf_Error ("file",
|
||||
"file::write: null filename provided");
|
||||
return;
|
||||
}
|
||||
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
|
||||
Cbuf_Error ("access",
|
||||
"file.write: access to %s denied", path);
|
||||
"file::write: access to %s denied", path);
|
||||
return;
|
||||
}
|
||||
if (!(file = Qopen (va ("%s/%s", com_gamedir, path), "w"))) {
|
||||
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;
|
||||
}
|
||||
Qprintf (file, "%s", GIB_Argv (2));
|
||||
Qclose (file);
|
||||
free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -628,15 +601,20 @@ GIB_File_Find_f (void)
|
|||
|
||||
if (GIB_Argc () < 2 || GIB_Argc () > 3) {
|
||||
Cbuf_Error ("syntax",
|
||||
"file.find: invalid syntax\n"
|
||||
"usage: file.find glob [path]");
|
||||
"file::find: invalid syntax\n"
|
||||
"usage: file::find glob [path]");
|
||||
return;
|
||||
}
|
||||
path = GIB_Argv (2);
|
||||
path = COM_CompressPath (GIB_Argv (2));
|
||||
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",
|
||||
"file.find: access to %s denied", path);
|
||||
"file::find: access to %s denied", path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -662,6 +640,7 @@ GIB_File_Find_f (void)
|
|||
else
|
||||
GIB_Return ("");
|
||||
dstring_delete (list);
|
||||
free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -672,20 +651,20 @@ GIB_File_Move_f (void)
|
|||
|
||||
if (GIB_Argc () != 3) {
|
||||
Cbuf_Error ("syntax",
|
||||
"file.move: invalid syntax\n"
|
||||
"usage: file.move from_file to_file");
|
||||
"file::move: invalid syntax\n"
|
||||
"usage: file::move from_file to_file");
|
||||
return;
|
||||
}
|
||||
path1 = GIB_Argv (1);
|
||||
path2 = GIB_Argv (2);
|
||||
if (!GIB_CollapsePath (path1)) {
|
||||
path1 = COM_CompressPath (GIB_Argv (1));
|
||||
path2 = COM_CompressPath (GIB_Argv (2));
|
||||
if (path1[0] == '/' || (path1[0] == '.' && path1[1] == '.')) {
|
||||
Cbuf_Error ("access",
|
||||
"file.move: access to %s denied", path1);
|
||||
"file::move: access to %s denied", path1);
|
||||
return;
|
||||
}
|
||||
if (!GIB_CollapsePath (path2)) {
|
||||
if (path2[0] == '/' || (path2[0] == '.' && path2[1] == '.')) {
|
||||
Cbuf_Error ("access",
|
||||
"file.move: access to %s denied", path2);
|
||||
"file::move: access to %s denied", path2);
|
||||
return;
|
||||
}
|
||||
from = dstring_newstr ();
|
||||
|
@ -694,10 +673,12 @@ GIB_File_Move_f (void)
|
|||
dsprintf (to, "%s/%s", com_gamedir, path2);
|
||||
if (Qrename (from->str, to->str))
|
||||
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));
|
||||
dstring_delete (from);
|
||||
dstring_delete (to);
|
||||
free (path1);
|
||||
free (path2);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -707,20 +688,21 @@ GIB_File_Delete_f (void)
|
|||
|
||||
if (GIB_Argc () != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"file.delete: invalid syntax\n"
|
||||
"usage: file.delete file");
|
||||
"file::delete: invalid syntax\n"
|
||||
"usage: file::delete file");
|
||||
return;
|
||||
}
|
||||
path = GIB_Argv (1);
|
||||
if (!GIB_CollapsePath (path)) {
|
||||
path = COM_CompressPath (GIB_Argv (1));
|
||||
if (path[0] == '/' || (path[0] == '.' && path[1] == '.')) {
|
||||
Cbuf_Error ("access",
|
||||
"file.delete: access to %s denied", path);
|
||||
"file::delete: access to %s denied", path);
|
||||
return;
|
||||
}
|
||||
if (Qremove(va("%s/%s", com_gamedir, path)))
|
||||
Cbuf_Error ("file",
|
||||
"file.delete: could not delete %s/%s: %s",
|
||||
"file::delete: could not delete %s/%s: %s",
|
||||
com_gamedir, path, strerror(errno));
|
||||
free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -773,28 +755,28 @@ GIB_Builtin_Init (void)
|
|||
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.get", GIB_FunctionDotGet_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("export", GIB_Export_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("function::get", GIB_Function_Get_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 ("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 ("if", 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 ("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 ("break", GIB_Break_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 ("thread.create", GIB_Thread_Create_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.write", GIB_File_Write_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.delete", GIB_File_Delete_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 ("thread::create", GIB_Thread_Create_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::write", GIB_File_Write_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::delete", GIB_File_Delete_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("range", GIB_Range_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("print", GIB_Print_f, GIB_BUILTIN_NORMAL);
|
||||
}
|
||||
|
|
|
@ -676,8 +676,8 @@ Key_GIB_Bind_Get_f (void)
|
|||
|
||||
if (GIB_Argc() != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"bind.get: invalid syntax\n"
|
||||
"usage: bind.get key"
|
||||
"bind::get: invalid syntax\n"
|
||||
"usage: bind::get key"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -687,12 +687,12 @@ Key_GIB_Bind_Get_f (void)
|
|||
key = OK_TranslateKeyName (GIB_Argv (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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -858,7 +858,7 @@ Key_Init (cbuf_t *cb)
|
|||
"RECOGNIZED key-press. If the key pressed produces no "
|
||||
"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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -403,14 +403,14 @@ locs_loc (void)
|
|||
}
|
||||
|
||||
void
|
||||
Locs_Location_Get (void)
|
||||
Locs_Loc_Get (void)
|
||||
{
|
||||
location_t *location;
|
||||
|
||||
if (GIB_Argc() != 1)
|
||||
Cbuf_Error ("syntax",
|
||||
"location.get: invalid syntax\n"
|
||||
"usage: location.get");
|
||||
"loc::get: invalid syntax\n"
|
||||
"usage: loc::get");
|
||||
else {
|
||||
location = locs_find (cl.simorg);
|
||||
GIB_Return (location ? location->name : "unknown");
|
||||
|
@ -422,7 +422,7 @@ Locs_Init (void)
|
|||
{
|
||||
Cmd_AddCommand ("loc", locs_loc, "Location marker editing commands: 'loc "
|
||||
"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 *
|
||||
|
|
Loading…
Reference in a new issue