|
|
@ -257,6 +257,9 @@ |
|
|
|
(when (or (= ' ' (deref end-char)) |
|
|
|
(= '\n' (deref end-char))) |
|
|
|
(break))) |
|
|
|
;; The very last character of the string needs a special case to pull it in |
|
|
|
(unless (at 1 argument-end) |
|
|
|
(incr argument-end)) |
|
|
|
(each-item-addr-in-array readers i reader (* operation-reader) |
|
|
|
(when (= 0 (strncmp (path reader > keyword) current-char (- argument-end current-char))) |
|
|
|
(preslog "Found keyword %s\n" (path reader > keyword)) |
|
|
@ -280,6 +283,9 @@ |
|
|
|
(when (or (= ' ' (deref end-char)) |
|
|
|
(= '\n' (deref end-char))) |
|
|
|
(break))) |
|
|
|
;; The very last character of the string needs a special case to pull it in |
|
|
|
(unless (at 1 argument-end) |
|
|
|
(incr argument-end)) |
|
|
|
(preslog "Argument [%d] found: " argument-index) |
|
|
|
(fwrite current-char (sizeof char) (- argument-end current-char) stderr) |
|
|
|
(preslog "\n") |
|
|
@ -448,6 +454,39 @@ |
|
|
|
(return current-effect))) |
|
|
|
(return null)) |
|
|
|
|
|
|
|
(defstruct-local power-context |
|
|
|
effect-data (* effect)) |
|
|
|
|
|
|
|
(defun-local resolve-value-from-name (context (* power-context) |
|
|
|
name (* (const char)) |
|
|
|
&return (* int)) |
|
|
|
(defstruct name-value-pair |
|
|
|
name (* (const char)) |
|
|
|
value (* int)) |
|
|
|
(var name-values ([] name-value-pair) |
|
|
|
(array |
|
|
|
(array "positionX" (addr (path context > effect-data > x))) |
|
|
|
(array "positionY" (addr (path context > effect-data > y))) |
|
|
|
(array "velocityX" (addr (path context > effect-data > velocity-x))) |
|
|
|
(array "velocityY" (addr (path context > effect-data > velocity-y))))) |
|
|
|
(each-item-addr-in-array name-values i pair (* name-value-pair) |
|
|
|
(unless (= 0 (strcmp (path pair > name) name)) |
|
|
|
(continue)) |
|
|
|
(return (path pair > value))) |
|
|
|
;; (preslog "No value %s bound to context\n" name) |
|
|
|
(return null)) |
|
|
|
|
|
|
|
;; Literals are static, i.e. don't call from multiple threads or expect to stick around |
|
|
|
(defun-local resolve-value-or-literal-from-string (context (* power-context) |
|
|
|
name-or-literal (* (const char)) |
|
|
|
&return (* int)) |
|
|
|
(var-static literal-value int 0) |
|
|
|
(var value-out (* int) (resolve-value-from-name context name-or-literal)) |
|
|
|
(unless value-out |
|
|
|
(set literal-value (strtol name-or-literal null 10)) |
|
|
|
(set value-out (addr literal-value))) |
|
|
|
(return value-out)) |
|
|
|
|
|
|
|
(defun-local activate-power (id (* (const char))) |
|
|
|
(var power-to-activate (* power) null) |
|
|
|
(each-item-addr-in-array (field s-power-system powers) power-index current-power (* power) |
|
|
@ -460,6 +499,8 @@ |
|
|
|
(preslog "Could not find power %s to activate\n" id) |
|
|
|
(return)) |
|
|
|
|
|
|
|
(var context power-context (array 0)) |
|
|
|
|
|
|
|
(each-item-addr-in-dynarray (path power-to-activate > parsed-on-create-operations) |
|
|
|
operation-index op (* operation) |
|
|
|
(cond |
|
|
@ -481,10 +522,21 @@ |
|
|
|
(continue)) |
|
|
|
(set (path new-effect > anim) (path anim-data > runtime-anim)) |
|
|
|
(break)) |
|
|
|
(unless (and (path new-effect > anim) |
|
|
|
(path new-effect > sprite)) |
|
|
|
(set (path new-effect > sprite) null) |
|
|
|
(preslog "Could not create effect: missing sprite or animation\n")))))) |
|
|
|
(if (and (path new-effect > anim) |
|
|
|
(path new-effect > sprite)) |
|
|
|
(scope |
|
|
|
(set (field context effect-data) new-effect)) |
|
|
|
(scope |
|
|
|
(set (path new-effect > sprite) null) |
|
|
|
(preslog "Could not create effect: missing sprite or animation\n")))) |
|
|
|
((= (path op > type) operation-type-set-value) |
|
|
|
(var value-out (* int) (resolve-value-from-name |
|
|
|
(addr context) (path op > string-a))) |
|
|
|
(var set-value-to (* int) (resolve-value-or-literal-from-string |
|
|
|
(addr context) (path op > string-b))) |
|
|
|
(when (and value-out set-value-to) |
|
|
|
;; (preslog "Setting %s to %s\n" (path op > string-a) (path op > string-b)) |
|
|
|
(set (deref value-out) (deref set-value-to))))))) |
|
|
|
|
|
|
|
;; |
|
|
|
;; Text rendering |
|
|
|