;;-*-Lisp-*-
(in-package goal)

;; name: task-control-h.gc
;; name in dgo: task-control-h
;; dgos: GAME

;; +++resetter-message
(defenum resetter-message
  :type uint8
  (mission-fail 0)
  (mission-retry 1)
  (mission-fail-or-retry 2)
  )
;; ---resetter-message


;; +++resetter-flag
(defenum resetter-flag
  :type uint16
  :bitfield #t
  (auto-reset 0)
  (text-message 1)
  (no-audio 2)
  (no-slow-down 3)
  (no-message 4)
  (no-grab 5)
  (no-draw-target 6)
  (stop-sfx 7)
  (no-audio-first 8)
  )
;; ---resetter-flag


;; +++task-manager-mask
(defenum task-manager-mask
  :type uint32
  :bitfield #t
  (intro-scene)
  (resolution-scene)
  (time-limit)
  (auto-complete)
  )
;; ---task-manager-mask

(declare-type editable-player process)
(define-extern *editable* (pointer editable-player))

(declare-type mission-squad-control basic)
(declare-type cty-attack-controller mission-squad-control)
(declare-type cty-faction-manager basic)
(define-extern *cty-faction-manager* cty-faction-manager)
(define-extern *cty-attack-controller* cty-attack-controller)
(set! *cty-faction-manager* (the cty-faction-manager #f))
(set! *cty-attack-controller* (the cty-attack-controller #f))

(define-extern cty-attack-reset (function symbol symbol symbol none))
(define-extern setup-city-task-faction (function object))
(define-extern cty-faction-evaluate-commands (function pair object))

(define-extern update-task-masks (function symbol int))
(define-extern task-resolution-close! (function game-task symbol))
(define-extern task-node-closed? (function game-task-node symbol))
(define-extern task-node-open! (function game-task-node symbol int))
(define-extern task-node-reset (function symbol int))
(define-extern game-task-node->string (function game-task-node string))
(define-extern task-close! (function string symbol))
(define-extern task-node-index-by-name (function string int))
(define-extern task-node-close! (function game-task-node symbol int))
(define-extern task-node-open? (function game-task-node symbol))

(define-extern restart-mission (function int))
(define-extern play-task (function game-task symbol symbol string))
(define-extern play-clean (function symbol int))

(declare-type task-manager process)
(declare-type game-task-node-info basic)
(declare-type traffic-engine basic)
(define-extern task-manager-init-by-other (function game-task-node-info symbol object :behavior task-manager))

;; DECOMP BEGINS

;; og:preserve-this removed from debug segment
(defun game-task->string ((task game-task))
  (case task
    (((game-task sewer-hum-kg))
     "sewer-hum-kg"
     )
    (((game-task temple-defend))
     "temple-defend"
     )
    (((game-task city-port-assault))
     "city-port-assault"
     )
    (((game-task city-bbush-ring-6))
     "city-bbush-ring-6"
     )
    (((game-task city-bbush-spirit-chase-3))
     "city-bbush-spirit-chase-3"
     )
    (((game-task city-bbush-get-to-43))
     "city-bbush-get-to-43"
     )
    (((game-task desert-vehicle-training-1))
     "desert-vehicle-training-1"
     )
    (((game-task eco-red-button))
     "eco-red-button"
     )
    (((game-task city-bbush-get-to-36))
     "city-bbush-get-to-36"
     )
    (((game-task city-bbush-get-to-33))
     "city-bbush-get-to-33"
     )
    (((game-task city-bbush-get-to-29))
     "city-bbush-get-to-29"
     )
    (((game-task desert-bbush-ring-2))
     "desert-bbush-ring-2"
     )
    (((game-task palace-ruins-attack))
     "palace-ruins-attack"
     )
    (((game-task palace-ruins-patrol))
     "palace-ruins-patrol"
     )
    (((game-task desert-bbush-air-time))
     "desert-bbush-air-time"
     )
    (((game-task city-start))
     "city-start"
     )
    (((game-task desert-bbush-ring-1))
     "desert-bbush-ring-1"
     )
    (((game-task desert-bbush-get-to-1))
     "desert-bbush-get-to-1"
     )
    (((game-task wascity-bbush-get-to-20))
     "wascity-bbush-get-to-20"
     )
    (((game-task city-hijack-vehicle))
     "city-hijack-vehicle"
     )
    (((game-task city-bbush-port-attack))
     "city-bbush-port-attack"
     )
    (((game-task comb-wild-ride))
     "comb-wild-ride"
     )
    (((game-task forest-ring-chase))
     "forest-ring-chase"
     )
    (((game-task mine-explore))
     "mine-explore"
     )
    (((game-task wascity-bbush-get-to-23))
     "wascity-bbush-get-to-23"
     )
    (((game-task city-destroy-darkeco))
     "city-destroy-darkeco"
     )
    (((game-task factory-sky-battle))
     "factory-sky-battle"
     )
    (((game-task city-bbush-get-to-41))
     "city-bbush-get-to-41"
     )
    (((game-task city-bbush-get-to-34))
     "city-bbush-get-to-34"
     )
    (((game-task city-bbush-get-to-38))
     "city-bbush-get-to-38"
     )
    (((game-task wascity-chase))
     "wascity-chase"
     )
    (((game-task city-bbush-get-to-27))
     "city-bbush-get-to-27"
     )
    (((game-task desert-bbush-get-to-3))
     "desert-bbush-get-to-3"
     )
    (((game-task city-vehicle-training))
     "city-vehicle-training"
     )
    (((game-task wascity-bbush-get-to-25))
     "wascity-bbush-get-to-25"
     )
    (((game-task desert-turtle-training))
     "desert-turtle-training"
     )
    (((game-task desert-artifact-race-2))
     "desert-artifact-race-2"
     )
    (((game-task city-power-game))
     "city-power-game"
     )
    (((game-task volcano-darkeco))
     "volcano-darkeco"
     )
    (((game-task tower-destroy))
     "tower-destroy"
     )
    (((game-task city-destroy-grid))
     "city-destroy-grid"
     )
    (((game-task city-bbush-get-to-26))
     "city-bbush-get-to-26"
     )
    (((game-task city-bbush-get-to-42))
     "city-bbush-get-to-42"
     )
    (((game-task desert-bbush-get-to-11))
     "desert-bbush-get-to-11"
     )
    (((game-task desert-bbush-timer-chase-1))
     "desert-bbush-timer-chase-1"
     )
    (((game-task sewer-met-hum))
     "sewer-met-hum"
     )
    (((game-task desert-bbush-get-to-2))
     "desert-bbush-get-to-2"
     )
    (((game-task dummy0))
     "dummy0"
     )
    (((game-task city-port-attack))
     "city-port-attack"
     )
    (((game-task city-gun-course-1))
     "city-gun-course-1"
     )
    (((game-task arena-fight-2))
     "arena-fight-2"
     )
    (((game-task mine-boss))
     "mine-boss"
     )
    (((game-task arena-training-1))
     "arena-training-1"
     )
    (((game-task city-protect-hq))
     "city-protect-hq"
     )
    (((game-task sewer-kg-met))
     "sewer-kg-met"
     )
    (((game-task desert-bbush-get-to-14))
     "desert-bbush-get-to-14"
     )
    (((game-task desert-bbush-get-to-5))
     "desert-bbush-get-to-5"
     )
    (((game-task desert-bbush-total-air-time))
     "desert-bbush-total-air-time"
     )
    (((game-task desert-chase-marauders))
     "desert-chase-marauders"
     )
    (((game-task temple-tests))
     "temple-tests"
     )
    (((game-task city-bbush-get-to-28))
     "city-bbush-get-to-28"
     )
    (((game-task factory-assault))
     "factory-assault"
     )
    (((game-task desert-bbush-get-to-7))
     "desert-bbush-get-to-7"
     )
    (((game-task city-blow-barricade))
     "city-blow-barricade"
     )
    (((game-task arena-fight-1))
     "arena-fight-1"
     )
    (((game-task city-bbush-get-to-40))
     "city-bbush-get-to-40"
     )
    (((game-task max))
     "max"
     )
    (((game-task wascity-bbush-ring-3))
     "wascity-bbush-ring-3"
     )
    (((game-task city-bbush-get-to-31))
     "city-bbush-get-to-31"
     )
    (((game-task city-jetboard-bbush))
     "city-jetboard-bbush"
     )
    (((game-task desert-bbush-get-to-9))
     "desert-bbush-get-to-9"
     )
    (((game-task wascity-bbush-get-to-18))
     "wascity-bbush-get-to-18"
     )
    (((game-task city-port-fight))
     "city-port-fight"
     )
    (((game-task precursor-tour))
     "precursor-tour"
     )
    (((game-task wascity-bbush-timer-chase-2))
     "wascity-bbush-timer-chase-2"
     )
    (((game-task desert-oasis-defense))
     "desert-oasis-defense"
     )
    (((game-task desert-catch-lizards))
     "desert-catch-lizards"
     )
    (((game-task desert-bbush-get-to-4))
     "desert-bbush-get-to-4"
     )
    (((game-task city-bbush-ring-5))
     "city-bbush-ring-5"
     )
    (((game-task desert-bbush-rally))
     "desert-bbush-rally"
     )
    (((game-task desert-course-race))
     "desert-course-race"
     )
    (((game-task city-bbush-get-to-32))
     "city-bbush-get-to-32"
     )
    (((game-task desert-final-boss))
     "desert-final-boss"
     )
    (((game-task desert-bbush-roll-count))
     "desert-bbush-roll-count"
     )
    (((game-task desert-bbush-get-to-8))
     "desert-bbush-get-to-8"
     )
    (((game-task complete))
     "complete"
     )
    (((game-task desert-bbush-spirit-chase-1))
     "desert-bbush-spirit-chase-1"
     )
    (((game-task desert-bbush-get-to-12))
     "desert-bbush-get-to-12"
     )
    (((game-task wascity-bbush-get-to-21))
     "wascity-bbush-get-to-21"
     )
    (((game-task city-win))
     "city-win"
     )
    (((game-task precursor-destroy-ship))
     "precursor-destroy-ship"
     )
    (((game-task desert-bbush-get-to-6))
     "desert-bbush-get-to-6"
     )
    (((game-task desert-bbush-get-to-19))
     "wascity-bbush-get-to-19"
     )
    (((game-task forest-turn-on-machine))
     "forest-turn-on-machine"
     )
    (((game-task comb-travel))
     "comb-travel"
     )
    (((game-task temple-oracle))
     "temple-oracle"
     )
    (((game-task wascity-bbush-spirit-chase-2))
     "wascity-bbush-spirit-chase-2"
     )
    (((game-task wascity-bbush-get-to-22))
     "wascity-bbush-get-to-22"
     )
    (((game-task city-sniper-fight))
     "city-sniper-fight"
     )
    (((game-task desert-beast-battle))
     "desert-beast-battle"
     )
    (((game-task city-bbush-get-to-35))
     "city-bbush-get-to-35"
     )
    (((game-task desert-bbush-jump-distance))
     "desert-bbush-jump-distance"
     )
    (((game-task city-gun-course-play-for-fun))
     "city-gun-course-play-for-fun"
     )
    (((game-task desert-rescue-bbush))
     "desert-rescue-bbush"
     )
    (((game-task forest-kill-plants))
     "forest-kill-plants"
     )
    (((game-task arena-fight-3))
     "arena-fight-3"
     )
    (((game-task desert-bbush-get-to-17))
     "desert-bbush-get-to-17"
     )
    (((game-task nest-hunt))
     "nest-hunt"
     )
    (((game-task wascity-gungame))
     "wascity-gungame"
     )
    (((game-task desert-vehicle-training-2))
     "desert-vehicle-training-2"
     )
    (((game-task desert-glide))
     "desert-glide"
     )
    (((game-task desert-bbush-get-to-16))
     "desert-bbush-get-to-16"
     )
    (((game-task nest-eggs))
     "nest-eggs"
     )
    (((game-task desert-bbush-destroy-interceptors))
     "desert-bbush-destroy-interceptors"
     )
    (((game-task desert-artifact-race-1))
     "desert-artifact-race-1"
     )
    (((game-task wascity-bbush-get-to-24))
     "wascity-bbush-get-to-24"
     )
    (((game-task city-bbush-get-to-39))
     "city-bbush-get-to-39"
     )
    (((game-task temple-climb))
     "temple-climb"
     )
    (((game-task desert-rescue))
     "desert-rescue"
     )
    (((game-task wascity-bbush-ring-4))
     "wascity-bbush-ring-4"
     )
    (((game-task factory-boss))
     "factory-boss"
     )
    (((game-task desert-bbush-time-trial-1))
     "desert-bbush-time-trial-1"
     )
    (((game-task desert-bbush-total-jump-distance))
     "desert-bbush-total-jump-distance"
     )
    (((game-task desert-jump-mission))
     "desert-jump-mission"
     )
    (((game-task wascity-leaper-race))
     "wascity-leaper-race"
     )
    (((game-task desert-hover))
     "desert-hover"
     )
    (((game-task mine-blow))
     "mine-blow"
     )
    (((game-task city-bbush-get-to-44))
     "city-bbush-get-to-44"
     )
    (((game-task eco-yellow-button))
     "eco-yellow-button"
     )
    (((game-task desert-bbush-egg-spider-1))
     "desert-bbush-egg-spider-1"
     )
    (((game-task city-gun-course-2))
     "city-gun-course-2"
     )
    (((game-task wascity-pre-game))
     "wascity-pre-game"
     )
    (((game-task city-bbush-get-to-30))
     "city-bbush-get-to-30"
     )
    (((game-task wascity-defend))
     "wascity-defend"
     )
    (((game-task city-bbush-get-to-37))
     "city-bbush-get-to-37"
     )
    (((game-task city-blow-tower))
     "city-blow-tower"
     )
    (((game-task none))
     "none"
     )
    (((game-task eco-blue-button))
     "eco-blue-button"
     )
    (((game-task desert-interceptors))
     "desert-interceptors"
     )
    (else
      "*unknown*"
      )
    )
  )

;; og:preserve-this this function appears to have been stubbed out in jak 3
(defun c-string->game-task ((arg0 string))
  (game-task unknown)
  )

(defun-debug game-task-actor->string ((arg0 game-task-actor))
  (case arg0
    (((game-task-actor wascity-turret))
     "wascity-turret"
     )
    (((game-task-actor none))
     "none"
     )
    (((game-task-actor burning-bush-genb-2))
     "burning-bush-genb-2"
     )
    (((game-task-actor unused-slot-18))
     "unused-slot-18"
     )
    (((game-task-actor burning-bush-wasb-3))
     "burning-bush-wasb-3"
     )
    (((game-task-actor burning-bush-desd-3))
     "burning-bush-desd-3"
     )
    (((game-task-actor unused-slot-17))
     "unused-slot-17"
     )
    (((game-task-actor unused-slot-15))
     "unused-slot-15"
     )
    (((game-task-actor burning-bush-inda-1))
     "burning-bush-inda-1"
     )
    (((game-task-actor veger-ruins))
     "veger-ruins"
     )
    (((game-task-actor burning-bush-desb-2))
     "burning-bush-desb-2"
     )
    (((game-task-actor unused-slot-16))
     "unused-slot-16"
     )
    (((game-task-actor burning-bush-desf))
     "burning-bush-desf"
     )
    (((game-task-actor burning-bush-slumb-3))
     "burning-bush-slumb-3"
     )
    (((game-task-actor wascity-leaper))
     "wascity-leaper"
     )
    (((game-task-actor unused-slot-8))
     "unused-slot-8"
     )
    (((game-task-actor burning-bush-slumb-2))
     "burning-bush-slumb-2"
     )
    (((game-task-actor burning-bush-desb))
     "burning-bush-desb"
     )
    (((game-task-actor burning-bush-wasa-2))
     "burning-bush-wasa-2"
     )
    (((game-task-actor seem-wascitya))
     "seem-wascitya"
     )
    (((game-task-actor ashelin-oasis))
     "ashelin-oasis"
     )
    (((game-task-actor was-pre-game-deserte))
     "was-pre-game-deserte"
     )
    (((game-task-actor burning-bush-indb))
     "burning-bush-indb"
     )
    (((game-task-actor burning-bush-port-4))
     "burning-bush-port-4"
     )
    (((game-task-actor burning-bush-port-5))
     "burning-bush-port-5"
     )
    (((game-task-actor seem-wascity))
     "seem-wascity"
     )
    (((game-task-actor burning-bush-wasa-1))
     "burning-bush-wasa-1"
     )
    (((game-task-actor unused-slot-20))
     "unused-slot-20"
     )
    (((game-task-actor vin-vinroom))
     "vin-vinroom"
     )
    (((game-task-actor burning-bush-marka))
     "burning-bush-marka"
     )
    (((game-task-actor burning-bush-slumc-2))
     "burning-bush-slumc-2"
     )
    (((game-task-actor burning-bush-desc-5))
     "burning-bush-desc-5"
     )
    (((game-task-actor unused-slot-19))
     "unused-slot-19"
     )
    (((game-task-actor monk-mummy))
     "monk-mummy"
     )
    (((game-task-actor torn-freehq))
     "torn-freehq"
     )
    (((game-task-actor burning-bush-indb-3))
     "burning-bush-indb-3"
     )
    (((game-task-actor burning-bush-desb-4))
     "burning-bush-desb-4"
     )
    (((game-task-actor seem-temple))
     "seem-temple"
     )
    (((game-task-actor kleever-arena))
     "kleever-arena"
     )
    (((game-task-actor unused-slot-21))
     "unused-slot-21"
     )
    (((game-task-actor burning-bush-indb-2))
     "burning-bush-indb-2"
     )
    (((game-task-actor oracle-oracle))
     "oracle-oracle"
     )
    (((game-task-actor jinx-hiphog))
     "jinx-hiphog"
     )
    (((game-task-actor minimap))
     "minimap"
     )
    (((game-task-actor burning-bush-arena))
     "burning-bush-arena"
     )
    (((game-task-actor damus-wasdoors))
     "damus-wasdoors"
     )
    (((game-task-actor kleever-pen))
     "kleever-pen"
     )
    (((game-task-actor burning-bush-markb))
     "burning-bush-markb"
     )
    (((game-task-actor burning-bush-genb-4))
     "burning-bush-genb-4"
     )
    (((game-task-actor daxter))
     "daxter"
     )
    (((game-task-actor burning-bush-genb-5))
     "burning-bush-genb-5"
     )
    (((game-task-actor torn-hipbar))
     "torn-hipbar"
     )
    (((game-task-actor burning-bush-genb-1))
     "burning-bush-genb-1"
     )
    (((game-task-actor burning-bush-inda-4))
     "burning-bush-inda-4"
     )
    (((game-task-actor burning-bush-desb-3))
     "burning-bush-desb-3"
     )
    (((game-task-actor sig-nest))
     "sig-nest"
     )
    (((game-task-actor unused-slot-22))
     "unused-slot-22"
     )
    (((game-task-actor burning-bush-slumb))
     "burning-bush-slumb"
     )
    (((game-task-actor ashelin-freehq))
     "ashelin-freehq"
     )
    (((game-task-actor burning-bush-desc-2))
     "burning-bush-desc-2"
     )
    (((game-task-actor samos-onintent))
     "samos-onintent"
     )
    (((game-task-actor burning-bush-desd))
     "burning-bush-desd"
     )
    (((game-task-actor burning-bush-desg-2))
     "burning-bush-desg-2"
     )
    (((game-task-actor burning-bush-wasa-6))
     "burning-bush-wasa-6"
     )
    (((game-task-actor burning-bush-wasb-7))
     "burning-bush-wasb-7"
     )
    (((game-task-actor burning-bush-wasb-2))
     "burning-bush-wasb-2"
     )
    (((game-task-actor burning-bush-inda-5))
     "burning-bush-inda-5"
     )
    (((game-task-actor sig-talkbox))
     "sig-talkbox"
     )
    (((game-task-actor pecker-onintent))
     "pecker-onintent"
     )
    (((game-task-actor damus-arena))
     "damus-arena"
     )
    (((game-task-actor burning-bush-wasa-5))
     "burning-bush-wasa-5"
     )
    (((game-task-actor unused-slot-23))
     "unused-slot-23"
     )
    (((game-task-actor damus-wascity))
     "damus-wascity"
     )
    (((game-task-actor monk-wascity))
     "monk-wascity"
     )
    (((game-task-actor damus-desert))
     "damus-desert"
     )
    (((game-task-actor burning-bush-wasb-1))
     "burning-bush-wasb-1"
     )
    (((game-task-actor burning-bush-desc-4))
     "burning-bush-desc-4"
     )
    (((game-task-actor burning-bush-dese-5))
     "burning-bush-dese-5"
     )
    (((game-task-actor was-pre-game-wascityb))
     "was-pre-game-wascityb"
     )
    (((game-task-actor burning-bush-slumc))
     "burning-bush-slumc"
     )
    (((game-task-actor power-game-vinroom))
     "power-game-vinroom"
     )
    (((game-task-actor tess-gungame))
     "tess-gungame"
     )
    (((game-task-actor pecker))
     "pecker"
     )
    (((game-task-actor torn-hipbooth))
     "torn-hipbooth"
     )
    (((game-task-actor burning-bush-desg-4))
     "burning-bush-desg-4"
     )
    (((game-task-actor burning-bush-genc-2))
     "burning-bush-genc-2"
     )
    (((game-task-actor damus-ruins))
     "damus-ruins"
     )
    (((game-task-actor unused-slot-24))
     "unused-slot-24"
     )
    (((game-task-actor ashelin-talkbox))
     "ashelin-talkbox"
     )
    (((game-task-actor burning-bush-port-8))
     "burning-bush-port-8"
     )
    (((game-task-actor burning-bush-port-2))
     "burning-bush-port-2"
     )
    (((game-task-actor burning-bush-wasb-6))
     "burning-bush-wasb-6"
     )
    (((game-task-actor burning-bush-port-3))
     "burning-bush-port-3"
     )
    (((game-task-actor unused-slot-27))
     "unused-slot-27"
     )
    (((game-task-actor burning-bush-slumb-4))
     "burning-bush-slumb-4"
     )
    (((game-task-actor burning-bush-desg-3))
     "burning-bush-desg-3"
     )
    (((game-task-actor sig-wasdoors))
     "sig-wasdoors"
     )
    (((game-task-actor samos-freehq))
     "samos-freehq"
     )
    (((game-task-actor burning-bush-sluma-1))
     "burning-bush-sluma-1"
     )
    (((game-task-actor onin-talkbox))
     "onin-talkbox"
     )
    (((game-task-actor unused-slot-25))
     "unused-slot-25"
     )
    (((game-task-actor burning-bush-desc-3))
     "burning-bush-desc-3"
     )
    (((game-task-actor burning-bush-genb))
     "burning-bush-genb"
     )
    (((game-task-actor burning-bush-markb-2))
     "burning-bush-markb-2"
     )
    (((game-task-actor burning-bush-dese-2))
     "burning-bush-dese-2"
     )
    (((game-task-actor burning-bush-indb-1))
     "burning-bush-indb-1"
     )
    (((game-task-actor unused-slot-9))
     "unused-slot-9"
     )
    (((game-task-actor burning-bush-slumb-1))
     "burning-bush-slumb-1"
     )
    (((game-task-actor unused-slot-28))
     "unused-slot-28"
     )
    (((game-task-actor burning-bush-pal-2))
     "burning-bush-pal-2"
     )
    (((game-task-actor burning-bush-desa-2))
     "burning-bush-desa-2"
     )
    (((game-task-actor burning-bush-farma))
     "burning-bush-farma"
     )
    (((game-task-actor burning-bush-desg))
     "burning-bush-desg"
     )
    (((game-task-actor keira-freehq))
     "keira-freehq"
     )
    (((game-task-actor unused-slot-26))
     "unused-slot-26"
     )
    (((game-task-actor burning-bush-desd-5))
     "burning-bush-desd-5"
     )
    (((game-task-actor burning-bush-wasb-5))
     "burning-bush-wasb-5"
     )
    (((game-task-actor burning-bush-desc))
     "burning-bush-desc"
     )
    (((game-task-actor burning-bush-genb-3))
     "burning-bush-genb-3"
     )
    (((game-task-actor onin-onintent))
     "onin-onintent"
     )
    (((game-task-actor unused-slot-29))
     "unused-slot-29"
     )
    (((game-task-actor unused-slot-10))
     "unused-slot-10"
     )
    (((game-task-actor burning-bush-inda-2))
     "burning-bush-inda-2"
     )
    (((game-task-actor unused-slot-30))
     "unused-slot-30"
     )
    (((game-task-actor burning-bush-inda-3))
     "burning-bush-inda-3"
     )
    (((game-task-actor burning-bush-slumc-1))
     "burning-bush-slumc-1"
     )
    (((game-task-actor samos-genb))
     "samos-genb"
     )
    (((game-task-actor burning-bush-dese-4))
     "burning-bush-dese-4"
     )
    (((game-task-actor burning-bush-desh))
     "burning-bush-desh"
     )
    (((game-task-actor samos-talkbox))
     "samos-talkbox"
     )
    (((game-task-actor burning-bush-farmb))
     "burning-bush-farmb"
     )
    (((game-task-actor gun-gungame))
     "gun-gungame"
     )
    (((game-task-actor burning-bush-wasa-4))
     "burning-bush-wasa-4"
     )
    (((game-task-actor unused-slot-12))
     "unused-slot-12"
     )
    (((game-task-actor onin-freehq))
     "onin-freehq"
     )
    (((game-task-actor burning-bush-desa-3))
     "burning-bush-desa-3"
     )
    (((game-task-actor burning-bush-port-6))
     "burning-bush-port-6"
     )
    (((game-task-actor unused-slot-11))
     "unused-slot-11"
     )
    (((game-task-actor unused-slot-31))
     "unused-slot-31"
     )
    (((game-task-actor burning-bush-wasa-3))
     "burning-bush-wasa-3"
     )
    (((game-task-actor veger-cave))
     "veger-cave"
     )
    (((game-task-actor burning-bush-port-1))
     "burning-bush-port-1"
     )
    (((game-task-actor keira-genb))
     "keira-genb"
     )
    (((game-task-actor burning-bush-dese-3))
     "burning-bush-dese-3"
     )
    (((game-task-actor burning-bush-gena-2))
     "burning-bush-gena-2"
     )
    (((game-task-actor burning-bush-genc))
     "burning-bush-genc"
     )
    (((game-task-actor burning-bush-desd-2))
     "burning-bush-desd-2"
     )
    (((game-task-actor burning-bush-desa))
     "burning-bush-desa"
     )
    (((game-task-actor burning-bush-port))
     "burning-bush-port"
     )
    (((game-task-actor burning-bush-inda))
     "burning-bush-inda"
     )
    (((game-task-actor burning-bush-stadium))
     "burning-bush-stadium"
     )
    (((game-task-actor damus-waspal))
     "damus-waspal"
     )
    (((game-task-actor burning-bush-port-7))
     "burning-bush-port-7"
     )
    (((game-task-actor burning-bush-wasb-4))
     "burning-bush-wasb-4"
     )
    (((game-task-actor keira-garage))
     "keira-garage"
     )
    (((game-task-actor torn-hiptable))
     "torn-hiptable"
     )
    (((game-task-actor torn-hiphog))
     "torn-hiphog"
     )
    (((game-task-actor kleever-wasdoors))
     "kleever-wasdoors"
     )
    (((game-task-actor unused-slot-14))
     "unused-slot-14"
     )
    (((game-task-actor unused-slot-13))
     "unused-slot-13"
     )
    (((game-task-actor burning-bush-dese))
     "burning-bush-dese"
     )
    (((game-task-actor seem-leaper))
     "seem-leaper"
     )
    (((game-task-actor burning-bush-pal))
     "burning-bush-pal"
     )
    (((game-task-actor kleever-wascityb))
     "kleever-wascityb"
     )
    (((game-task-actor burning-bush-desd-4))
     "burning-bush-desd-4"
     )
    (((game-task-actor burning-bush-sluma-3))
     "burning-bush-sluma-3"
     )
    (((game-task-actor burning-bush-sluma-2))
     "burning-bush-sluma-2"
     )
    (((game-task-actor burning-bush-gena))
     "burning-bush-gena"
     )
    (((game-task-actor burning-bush-sluma))
     "burning-bush-sluma"
     )
    (else
      "*unknown*"
      )
    )
  )

(defun-debug game-task-action->string ((arg0 game-task-action))
  (case arg0
    (((game-task-action idle))
     "idle"
     )
    (((game-task-action play))
     "play"
     )
    (((game-task-action show))
     "show"
     )
    (((game-task-action talk))
     "talk"
     )
    (((game-task-action hide))
     "hide"
     )
    (((game-task-action say))
     "say"
     )
    (((game-task-action trade))
     "trade"
     )
    (((game-task-action menu))
     "menu"
     )
    (else
      "*unknown*"
      )
    )
  )

(deftype game-task-event (basic)
  ((actor     game-task-actor)
   (action    game-task-action)
   (tex       game-task-icon)
   (icon      uint16           :overlay-at tex)
   (flags     game-task-flags  :offset   7)
   (scene     string           :offset   8)
   (distance  meters)
   )
  )


(deftype resetter-spec (structure)
  ((continue    string)
   (node        game-task-node)
   (reset-mode  symbol)
   (execute     basic)
   )
  :pack-me
  )


(deftype resetter-params (structure)
  ((message       resetter-message)
   (flags         resetter-flag)
   (fail          resetter-spec  :inline)
   (retry         resetter-spec  :inline)
   (reset-delay   uint32)
   (task          game-task)
   (text-message  text-id)
   )
  )


(deftype task-manager-info (structure)
  ((mask                       task-manager-mask)
   (level                      symbol)
   (type-to-spawn              symbol)
   (time-limit                 int32)
   (manager                    handle)
   (intro-scene                object)
   (resolution-scene           object)
   (resolution-scene-continue  object)
   (final-node                 game-task-node)
   (vehicle-type               uint8)
   (sphere-count               int8)
   (index                      int8)
   (intro-delay                uint16)
   (sphere-array               (inline-array sphere))
   (on-complete                pair)
   (on-fail                    pair)
   (user-count                 int32)
   )
  )


(deftype task-reset-info (structure)
  ((restart-info  resetter-params)
   (quit-info     resetter-params)
   (fail-info     resetter-params)
   (death-info    resetter-params)
   )
  )


(defun-debug game-task-node-flag->string ((arg0 game-task-node-flag))
  (if (= (logand arg0 (game-task-node-flag clear-task-mask)) (game-task-node-flag clear-task-mask))
      (format #t "clear-task-mask ")
      )
  (if (= (logand (game-task-node-flag act3) arg0) (game-task-node-flag act3))
      (format #t "act3 ")
      )
  (if (= (logand (game-task-node-flag city-wait) arg0) (game-task-node-flag city-wait))
      (format #t "city-wait ")
      )
  (if (= (logand (game-task-node-flag act2) arg0) (game-task-node-flag act2))
      (format #t "act2 ")
      )
  (if (= (logand arg0 (game-task-node-flag intro-wait)) (game-task-node-flag intro-wait))
      (format #t "intro-wait ")
      )
  (if (= (logand arg0 (game-task-node-flag reset-on-try)) (game-task-node-flag reset-on-try))
      (format #t "reset-on-try ")
      )
  (if (= (logand (game-task-node-flag act1) arg0) (game-task-node-flag act1))
      (format #t "act1 ")
      )
  (if (= (logand arg0 (game-task-node-flag exclusive)) (game-task-node-flag exclusive))
      (format #t "exclusive ")
      )
  (if (= (logand arg0 (game-task-node-flag utility-node)) (game-task-node-flag utility-node))
      (format #t "utility-node ")
      )
  (if (= (logand (game-task-node-flag no-percent) arg0) (game-task-node-flag no-percent))
      (format #t "no-percent ")
      )
  (if (= (logand arg0 (game-task-node-flag set-task-mask)) (game-task-node-flag set-task-mask))
      (format #t "set-task-mask ")
      )
  (if (= (logand arg0 (game-task-node-flag disk-close)) (game-task-node-flag disk-close))
      (format #t "disk-close ")
      )
  (if (= (logand arg0 (game-task-node-flag closed)) (game-task-node-flag closed))
      (format #t "closed ")
      )
  (if (= (logand arg0 (game-task-node-flag data)) (game-task-node-flag data))
      (format #t "data ")
      )
  (if (= (logand arg0 (game-task-node-flag save-on-life)) (game-task-node-flag save-on-life))
      (format #t "save-on-life ")
      )
  (if (= (logand (game-task-node-flag no-hud-wait) arg0) (game-task-node-flag no-hud-wait))
      (format #t "no-hud-wait ")
      )
  (if (= (logand (game-task-node-flag bbush) arg0) (game-task-node-flag bbush))
      (format #t "bbush ")
      )
  (if (= (logand arg0 (game-task-node-flag close-task)) (game-task-node-flag close-task))
      (format #t "close-task ")
      )
  (if (= (logand arg0 (game-task-node-flag save-on-try)) (game-task-node-flag save-on-try))
      (format #t "save-on-try ")
      )
  (if (= (logand arg0 (game-task-node-flag auto-close)) (game-task-node-flag auto-close))
      (format #t "auto-close ")
      )
  (if (= (logand arg0 (game-task-node-flag abs-task-mask)) (game-task-node-flag abs-task-mask))
      (format #t "abs-task-mask ")
      )
  (if (= (logand arg0 (game-task-node-flag no-restart)) (game-task-node-flag no-restart))
      (format #t "no-restart ")
      )
  (if (= (logand arg0 (game-task-node-flag kiosk-close)) (game-task-node-flag kiosk-close))
      (format #t "kiosk-close ")
      )
  )

(defun-debug game-task-node-command->string ((arg0 game-task-node-command))
  (case arg0
    (((game-task-node-command sub-board-trail))
     "sub-board-trail"
     )
    (((game-task-node-command add-gun-yellow-1))
     "add-gun-yellow-1"
     )
    (((game-task-node-command add-gun-yellow-2))
     "add-gun-yellow-2"
     )
    (((game-task-node-command add-board-trail))
     "add-board-trail"
     )
    (((game-task-node-command add-vehicle-snake))
     "add-vehicle-snake"
     )
    (((game-task-node-command add-board-zap))
     "add-board-zap"
     )
    (((game-task-node-command add-darkjak-smack))
     "add-darkjak-smack"
     )
    (((game-task-node-command add-gun-yellow-ammo-2))
     "add-gun-yellow-ammo-2"
     )
    (((game-task-node-command add-gun-red-1))
     "add-gun-red-1"
     )
    (((game-task-node-command add-star-map))
     "add-star-map"
     )
    (((game-task-node-command add-darkeco))
     "add-darkeco"
     )
    (((game-task-node-command add-darkjak))
     "add-darkjak"
     )
    (((game-task-node-command add-light-eco-crystal))
     "add-light-eco-crystal"
     )
    (((game-task-node-command add-gun-blue-2))
     "add-gun-blue-2"
     )
    (((game-task-node-command add-gun-dark-3))
     "add-gun-dark-3"
     )
    (((game-task-node-command add-av-cube))
     "add-av-cube"
     )
    (((game-task-node-command add-board-training))
     "add-board-training"
     )
    (((game-task-node-command add-vehicle-toad))
     "add-vehicle-toad"
     )
    (((game-task-node-command add-darkjak-tracking))
     "add-darkjak-tracking"
     )
    (((game-task-node-command none))
     "none"
     )
    (((game-task-node-command add-lighteco))
     "add-lighteco"
     )
    (((game-task-node-command add-artifact-invis))
     "add-artifact-invis"
     )
    (((game-task-node-command add-seal))
     "add-seal"
     )
    (((game-task-node-command add-darkjak-bomb0))
     "add-darkjak-bomb0"
     )
    (((game-task-node-command add-amulet-1))
     "add-amulet-1"
     )
    (((game-task-node-command add-gun-red-ammo-2))
     "add-gun-red-ammo-2"
     )
    (((game-task-node-command add-vehicle-scorpion))
     "add-vehicle-scorpion"
     )
    (((game-task-node-command add-gun-blue-1))
     "add-gun-blue-1"
     )
    (((game-task-node-command sub-sidekick))
     "sub-sidekick"
     )
    (((game-task-node-command add-av-generator))
     "add-av-generator"
     )
    (((game-task-node-command add-sidekick))
     "add-sidekick"
     )
    (((game-task-node-command add-pass-indb-sluma))
     "add-pass-indb-sluma"
     )
    (((game-task-node-command add-amulet-2))
     "add-amulet-2"
     )
    (((game-task-node-command add-vehicle-turtle))
     "add-vehicle-turtle"
     )
    (((game-task-node-command add-gun-yellow-ammo-1))
     "add-gun-yellow-ammo-1"
     )
    (((game-task-node-command add-dark-eco-crystal))
     "add-dark-eco-crystal"
     )
    (((game-task-node-command add-pass-port-inda))
     "add-pass-port-inda"
     )
    (((game-task-node-command add-gun-dark-2))
     "add-gun-dark-2"
     )
    (((game-task-node-command add-av-prism))
     "add-av-prism"
     )
    (((game-task-node-command add-vehicle-rhino))
     "add-vehicle-rhino"
     )
    (((game-task-node-command add-board-launch))
     "add-board-launch"
     )
    (((game-task-node-command add-armor-3))
     "add-armor-3"
     )
    (((game-task-node-command add-cypher-gliph))
     "add-cypher-gliph"
     )
    (((game-task-node-command add-pass-port-mh))
     "add-pass-port-mh"
     )
    (((game-task-node-command add-armor-2))
     "add-armor-2"
     )
    (((game-task-node-command add-darkjak-bomb1))
     "add-darkjak-bomb1"
     )
    (((game-task-node-command add-armor-1))
     "add-armor-1"
     )
    (((game-task-node-command add-pass-front-gate))
     "add-pass-front-gate"
     )
    (((game-task-node-command add-lightjak-swoop))
     "add-lightjak-swoop"
     )
    (((game-task-node-command add-gun-blue-3))
     "add-gun-blue-3"
     )
    (((game-task-node-command add-pass-slumb-genb))
     "add-pass-slumb-genb"
     )
    (((game-task-node-command add-armor-0))
     "add-armor-0"
     )
    (((game-task-node-command add-lightjak-shield))
     "add-lightjak-shield"
     )
    (((game-task-node-command add-lightjak-regen))
     "add-lightjak-regen"
     )
    (((game-task-node-command add-gun-blue-ammo-1))
     "add-gun-blue-ammo-1"
     )
    (((game-task-node-command add-gun-blue-ammo-2))
     "add-gun-blue-ammo-2"
     )
    (((game-task-node-command add-gun-red-ammo-1))
     "add-gun-red-ammo-1"
     )
    (((game-task-node-command add-gun-red-3))
     "add-gun-red-3"
     )
    (((game-task-node-command sub-board))
     "sub-board"
     )
    (((game-task-node-command add-gun-red-2))
     "add-gun-red-2"
     )
    (((game-task-node-command add-lightjak-freeze))
     "add-lightjak-freeze"
     )
    (((game-task-node-command add-darkjak-invinc))
     "add-darkjak-invinc"
     )
    (((game-task-node-command add-board))
     "add-board"
     )
    (((game-task-node-command add-pass-inda-indb))
     "add-pass-inda-indb"
     )
    (((game-task-node-command add-gun-dark-ammo-2))
     "add-gun-dark-ammo-2"
     )
    (((game-task-node-command add-gun-dark-1))
     "add-gun-dark-1"
     )
    (((game-task-node-command add-av-map))
     "add-av-map"
     )
    (((game-task-node-command add-gun-yellow-3))
     "add-gun-yellow-3"
     )
    (((game-task-node-command add-gun-dark-ammo-1))
     "add-gun-dark-ammo-1"
     )
    (((game-task-node-command add-jakc))
     "add-jakc"
     )
    (((game-task-node-command add-amulet-3))
     "add-amulet-3"
     )
    (((game-task-node-command add-av-reflector))
     "add-av-reflector"
     )
    (((game-task-node-command add-lightjak))
     "add-lightjak"
     )
    (else
      "*unknown*"
      )
    )
  )

(deftype game-task-node-info (basic)
  ((level             symbol)
   (task              game-task)
   (name              string)
   (when-open         (array game-task-event))
   (flags             game-task-node-flag)
   (parent-node       game-task-node  4)
   (task-mask         task-mask)
   (on-open           pair)
   (manager           task-manager-info)
   (borrow            pair)
   (open?             (function game-task-node-info symbol))
   (on-close          pair)
   (close-time        uint32)
   (reset             task-reset-info)
   (gem-count         uint16)
   (skill-count       uint16)
   (death-count       uint8)
   (suck-death-count  uint8)
   (command-index     uint8)
   (command-count     uint8)
   (description       text-id)
   (faction-commands  pair)
   )
  (:methods
    (get-idx-in-task-list (_type_) int)
    (open! (_type_ symbol) int)
    (game-task-node-info-method-11 (_type_ symbol) none)
    (game-task-node-info-method-12 (_type_) symbol)
    (eval-game-task-cmd! (_type_) none)
    )
  )


(deftype game-task-info (basic)
  ((name                 string)
   (text-name            text-id)
   (pre-play-node        game-task-node)
   (kiosk-play-node      game-task-node)
   (pre-play-continue    string)
   (play-node            game-task-node)
   (play-continue        string)
   (kiosk-play-continue  object)
   )
  (:methods
    (get-play-list-idx (_type_) int)
    )
  )


(deftype game-task-control (basic)
  ((counter        uint32)
   (actor          game-task-actor)
   (current-node   game-task-node)
   (current-event  game-task-event)
   )
  (:methods
    (new (symbol type game-task-actor) _type_)
    (get-current-task-event (_type_) game-task-event)
    )
  )


(deftype task-manager (process)
  ((node-info       game-task-node-info)
   (info            task-manager-info)
   (lev-name        symbol)
   (fail-on-death?  symbol)
   (fail-now        symbol)
   (restart-now     symbol)
   (allow-fail      symbol)
   (state-time      time-frame)
   (start-time      time-frame)
   (time-limit      time-frame)
   (arrow           handle)
   (player-vehicle  handle)
   (hud             handle  4)
   (hud-timer       handle  :overlay-at (-> hud 0))
   (hud-counter     handle  :overlay-at (-> hud 1))
   (intro-time      time-frame)
   )
  (:state-methods
    wait
    active
    complete
    resolution
    (fail resetter-params)
    (restart symbol)
    )
  (:methods
    (init! (_type_) none)
    (set-time-limit (_type_) none)
    (kill-all-children (_type_) none)
    (hud-timer-handler (_type_) none)
    (ready? (_type_) object)
    (task-manager-method-25 (_type_) none)
    (task-manager-method-26 (_type_) none)
    (task-manager-method-27 (_type_) none)
    (task-manager-method-28 (_type_) none)
    (go-fail (_type_) object)
    (taskman-event-handler (_type_ process int symbol event-message-block) object)
    (on-fail (_type_ symbol) resetter-params)
    )
  )


(deftype ambient-control (structure)
  ((last-ambient-time  time-frame)
   (last-ambient       string)
   (last-ambient-id    sound-id)
   )
  :pack-me
  (:methods
    (ambient-control-method-9 () none)
    (ambient-control-method-10 () none)
    (ambient-control-method-11 () none)
    )
  )


(define *traffic-engine* (the-as traffic-engine #f))
