From d2ec7ec851192fa4fdb565ed1d0a7d04b5d0635e Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 26 May 2023 13:38:03 +0300 Subject: [PATCH] Initial commit --- macro.inc.php | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 macro.inc.php diff --git a/macro.inc.php b/macro.inc.php new file mode 100644 index 0000000..460a527 --- /dev/null +++ b/macro.inc.php @@ -0,0 +1,163 @@ +y * 365 * 24 * 60 * 60) + + ($in->m * 30 * 24 * 60 * 60) + + ($in->d * 24 * 60 * 60) + + ($in->h * 60 * 60) + + ($in->i * 60) + + $in->s; + if($sec <= 0) + throw new Exception("Bad resulting interval in seconds '$sec' for spec '$spec'"); + return $sec; +} + +/** + * @global + */ +function macro_ENUM_OR($proc) +{ + global $GAME_ROOT; + + $args = func_get_args(); + array_shift($args); + + $class = array_shift($args); + + $opts = 0; + for($i=0;$i 1) + throw new Exception("Format indices gap: '{$res[0]}'"); + $prev = $idx; + } + } + + return $res; +} + +/** + * @raw_args + */ +function macro_Q($proc, $value) +{ + if(strpos(ltrim($value), '[') === 0) + return $value; + else + return "\"$value\""; +} + +/** + * @global + */ +function macro_SELF_CONF_ID($jsm) +{ + $file = $jsm->getRootFile(); + $proto_id = 0; + $alias = ""; + if(!\taskman\config_get_header($file, $proto_id, $alias)) + $proto_id = \taskman\config_get_id($file); + return $proto_id; +} + +/** + * @global + */ +function macro_SELF_SHORT_NAME($jsm) +{ + $file = $jsm->getRootFile(); + return str_replace(".conf.js", "", basename($file)); +} + +/** + * @global @raw_args + */ +function macro_BOOL($jsm, $expr) +{ + $res = jsm_eval_string_value($jsm, $expr); + + return $res == 0 ? "false" : "true"; +} + +/** + * @global + */ +function macro_IS_DEV($jsm) +{ + return taskman_propor("GAME_IS_DEV", 0); +} + +/** + * @global + */ +function macro_VCLASS($proc, $class) +{ + return '"vclass__" : ' . constant("$class::CLASS_ID"); +} + +/** + * @global + */ +function macro_ITEM($proc, $proto_id, $amount) +{ + return array('proto_id' => $proto_id, 'amount' => $amount); +} +