[mw-devel] MW3 r915 - branches/jscript/src
arthur at sucs.org
arthur at sucs.org
Wed Mar 14 21:55:31 GMT 2007
Author: arthur
Date: 2007-03-14 21:55:30 +0000 (Wed, 14 Mar 2007)
New Revision: 915
Modified:
branches/jscript/src/script.c
Log:
have to follow binds when naming jscripts on commandline, refs #13
Modified: branches/jscript/src/script.c
===================================================================
--- branches/jscript/src/script.c 2007-03-11 22:11:32 UTC (rev 914)
+++ branches/jscript/src/script.c 2007-03-14 21:55:30 UTC (rev 915)
@@ -657,9 +657,19 @@
var_list_t args;
int num;
int i;
+ char *fish;
if ((num=ParseLine(line, bits))<1) return;
+ if ((fish = FindLinks(bind_list, bits[0])) == NULL) {
+ printf("Script bind '%s' not found.\n", bits[0]);
+ return;
+ }
+
+ if (is_js(fish)) {
+ js_exec(fish, num, bits);
+ return;
+ }
runaway=0;
flood=0;
script_terminate=0;
@@ -759,47 +769,6 @@
if (script==NULL)
{
/* okay, so its not a mwscript function */
- if (is_js(fish)) {
- /* it is a jscript one */
- int js_argc=0;
- char **js_argv;
- int i;
- var_op_t iter, item;
-
- /* count how many items */
- VAR_LIST_ITERATE(&iter, vars);
- while (VAR_FOUND(&iter)) {
- char *key = VAR_STR_KEY(&iter);
- VAR_OP_INIT(&item, vars);
- VAR_SEARCH(&item, key);
- if (VAR_FOUND(&item)) {
- if (VAR_TYPE_STR(&item)) {
- js_argc++;
- }
- }
- VAR_LIST_NEXT(&iter);
- }
- /* convert vars into an argv type */
- js_argv = calloc(js_argc, sizeof(char *));
- i=0;
- VAR_LIST_ITERATE(&iter, vars);
- while (VAR_FOUND(&iter)) {
- char *key = VAR_STR_KEY(&iter);
- VAR_OP_INIT(&item, vars);
- VAR_SEARCH(&item, key);
- if (VAR_FOUND(&item)) {
- if (VAR_TYPE_STR(&item)) {
- js_argv[i++]=strdup(var_str_val(&item));
- }
- }
- VAR_LIST_NEXT(&iter);
- }
- js_exec(fish, js_argc, js_argv);
- for (i=0;i<js_argc;i++) free(js_argv[i]);
- free(js_argv);
- free(fish);
- return(0);
- }
free(fish);
return(1);
}
@@ -868,6 +837,14 @@
int retval;
var_list_t args;
+ if (is_js(script)) {
+ char *argv[4];
+ argv[0]=event;
+ argv[1]=who;
+ argv[2]=text;
+ argv[3]=text+pre;
+ return js_exec(script, 4, argv);
+ }
runaway=0;
if (!script_running) { flood=0;}
script_terminate=0;
@@ -909,6 +886,17 @@
var_list_t args;
int retval, index;
+ if (is_js(script)) {
+ char **argv;
+ argv = calloc(numargs+2,sizeof(char *));
+ argv[0]=event;
+ argv[1]=who;
+ for (index=0;index<numargs;index++)
+ argv[index+2]=aargs[index];
+ retval = js_exec(script, numargs+2, argv);
+ free(argv);
+ return retval;
+ }
runaway=0;
if (!script_running) { flood=0;}
script_terminate=0;
More information about the mw-devel
mailing list