code:
(var v (require "v"))
(var util (require "util"))
(var grid (require "grid"))
(var view (require "view"))
(var bucket (require "deps/bucket"))

;per technomancy
;(fn has? [tbl x] (accumulate [h? false _ y (ipairs tbl) :until h?] (= x y)))
(fn _has [e ks]
  (var res true)
  (each [_ n (ipairs ks)]
    (set res (and res (if (= (. e n) nil) false true))))
  (if res true false))

(fn system [ks f]
  (fn [es]
    (each [_ e (ipairs es)]
      (if (_has e ks) (f e)))))

; only need to do this once for static guys
(var stores
  (system [:pos]
    (fn [e]
      (bucket.bstore _G.view_bucket e)
      (bucket.bstore _G.collision_bucket e))))

(var sprites
  (system [:sprite :pos]
    (fn [e]
      (let [wpos (view.world->screen _G.window e.pos)
            sprite (or (if e.dead e.dead_sprite) e.sprite)
            spr-pos (v.vmul sprite 16 16)]
        (if (and e.invincible (> e.invincible 0))
          (if (< (math.cos (* _G.time 70)) 0.3)
            (draw_sprite "entities.png"
                    wpos.x wpos.y spr-pos.x spr-pos.y 16 16))
          (draw_sprite "entities.png"
                    wpos.x wpos.y spr-pos.x spr-pos.y 16 16))))))

(var gravities
  (system [:gravity :velocity]
    (fn [e]
      (set e.velocity (v.vadd e.velocity (v.v2 0 (* _G.dt 7)))) )))

(var velocities
  (system [:velocity :pos]
    (fn [e]
      (set e.last-pos (util.copy e.pos))
      (let [maxspeed (or e.maxspeed 2)
            x (math.min (math.max e.velocity.x (- maxspeed)) maxspeed)
            y (if e.gravity (math.min (math.max e.velocity.y (- 4)) 5)
                            (math.min (math.max e.velocity.y (- maxspeed)) maxspeed))]
        (set e.velocity (v.v2 x y))
        (set e.pos (v.vadd e.pos e.velocity)))
      (bucket.bstore _G.view_bucket e)
      (bucket.bstore _G.collision_bucket e))))

(fn vertical-collisions [e]
  ;floor
  (let [floor   (or (grid.point-solid-offset (v.vadd e.pos (v.v2 (- e.bounds.br.x 1) e.bounds.br.y)) e.velocity)
                    (grid.point-solid-offset (v.vadd e.pos (v.v2 (+ e.bounds.ul.x 1) e.bounds.br.y)) e.velocity))
        ceiling (or (grid.point-solid-offset (v.vadd e.pos (v.v2 (- e.bounds.br.x 1) e.bounds.ul.y)) e.velocity)
                    (grid.point-solid-offset (v.vadd e.pos (v.v2 (+ e.bounds.ul.x 1) e.bounds.ul.y)) e.velocity))]
    (if floor
      (do
        (set e.touching-floor 0.2)
        (set e.pos.y (+ e.pos.y floor.offset.y))
        (set e.velocity.y (* e.velocity.y -.1)))

      ceiling
      (do
        (set e.pos.y (- e.pos.y ceiling.offset.y))
        (set e.velocity.y (* e.velocity.y -.1))
        (set e.jumping false)))
    (or floor ceiling)))

(fn horizontal-collisions [e]
  (let [left (or (grid.point-solid-offset (v.vadd e.pos (v.v2 (- e.bounds.ul.x 1) (- e.bounds.br.y 2))) e.velocity)
                 (grid.point-solid-offset (v.vadd e.pos (v.v2 (- e.bounds.ul.x 1) (+ e.bounds.ul.y 2))) e.velocity))

        right (or (grid.point-solid-offset (v.vadd e.pos (v.v2 (+ e.bounds.br.x 1) (+ e.bounds.ul.y 2))) e.velocity)
                  (grid.point-solid-offset (v.vadd e.pos (v.v2 (+ e.bounds.br.x 1) (- e.bounds.br.y 2))) e.velocity))
        any (or left right)]
    (if
      left
      (set e.pos.x (+ e.pos.x left.offset.x))
      right
      (set e.pos.x (+ e.pos.x right.offset.x)))
    (when any
      (if any.slope
        (do
          (set e.touching-floor 0.2)
          (set e.pos.y (+ e.pos.y any.offset.y))
          (set e.velocity.y (+ e.velocity.y (* any.offset.y 1))))
        (do
          (set e.velocity.x (* e.velocity.x -.2))
          (set e.touching-wall 0.1))))
    any))

(var physics
  (system [:velocity :bounds :solid]
    (fn [e]

      (if (> (math.abs e.velocity.x) (math.abs e.velocity.y))
        (or (horizontal-collisions e)
            (vertical-collisions e))
        (or (vertical-collisions e)
            (horizontal-collisions e)))

      (when e.touching-floor
        (set e.touching-wall false)
        (set e.velocity.x (* e.velocity.x 0.8))
        (set e.touching-floor (- e.touching-floor _G.dt))
        (if (< e.touching-floor 0)
          (set e.touching-floor false)))

      (when e.touching-wall
        (if (> e.velocity.y 0) (set e.velocity.y (* e.velocity.y 0.95)))
        (set e.touching-wall (- e.touching-wall _G.dt))
        (if (< e.touching-wall 0)
          (set e.touching-wall false))))))

; record jump button time
; when on ground if time within threshold start :jumping
; while jump button down within time span add to velocity

(var controls
  (system [:velocity :pos]
    (fn [e]
      (when (not e.dead)
        (let [speed (if e.touching-floor (* 18 _G.dt) (* 8 _G.dt))]
          (if (key_down "left") (set e.velocity.x (+ e.velocity.x (- speed))))
          (if (key_down "right") (set e.velocity.x (+ e.velocity.x speed)))
          (when (> _G.jumps 0)
            (if (key_pressed "space")
              (set e.jump_pressed_at _G.time))
            (when (and
                    (not e.jumping)
                    e.touching-floor
                    e.jump_pressed_at
                    (< (- _G.time e.jump_pressed_at) 0.12))
              (set e.jumping true)
              (set e.velocity.y (* -60 _G.dt))
              (set _G.jumps (- _G.jumps 1))
              (play_sound (util.rand-nth ["audio/jump.wav" "audio/jump2.wav" "audio/jump3.wav"]) false 1)
              (when (= 0 _G.jumps)
                (view.notification [
                      (util.rand-nth ["You've run out of jumps.." "That was your last jump.." "Out of jumps.."])
                      "press 'r' when you're ready"]))))
          (if e.jumping
            (if (< (- _G.time e.jump_pressed_at) 0.15)
              (if (key_down "space")
                (set e.velocity.y (+ e.velocity.y (* -19 _G.dt)))
                (do (set e.jumping false)
                    (set e.touching-floor 0)))
              (set e.jumping false))) )))))

; honestly i think just deleting it from the stores is enough
(fn delete-entity [e]
  (bucket.bdel _G.view_bucket e)
  (bucket.bdel _G.collision_bucket e))

; player centric at the moment
(var collisions
  (system [:bounds]
    (fn [e]

      (set e.invincible (- e.invincible _G.dt))
      (when (not e.dead)
        (let [near (bucket.bget _G.collision_bucket e.pos)]
          (each [i o (pairs near)]
            (when (and (not (= o e)) o.bounds)
              (when (v.overlap
                      (v.vadd e.pos e.bounds.ul)
                      (v.vadd e.pos e.bounds.br)
                      (v.vadd o.pos o.bounds.ul)
                      (v.vadd o.pos o.bounds.br))
                (when (and o.hurt (<= e.invincible 0))
                  (set _G.health (- _G.health o.hurt))
                  (set e.invincible 1)
                  (if (= o.type :bee)
                      (play_sound "audio/buzz.wav" false 1)
                      (play_sound "audio/hurt1.wav" false 1))
                  (when (<= _G.health 0)
                    (set e.dead true)
                    (play_sound (util.rand-nth ["audio/death1.wav" "audio/death2.wav" "audio/death3.wav"]) false 0.7)
                    (view.notification [
                      (util.rand-nth ["looks like you've died" "an unfortunate end" "a fatal mistake" "you've died" "you've perished"])
                      "press 'r' to reset"])))
                (when o.pickup
                  (when (= o.type :jump-bag)
                    (play_sound "audio/pickup3.wav" false 1)
                    (set _G.jumps (+ _G.jumps 1))
                    (set _G.max_jumps (+ _G.max_jumps 1)))
                  (when (= o.type :star)
                    (play_sound "audio/pickup3.wav" false 1)
                    (play_sound "audio/pickup1.wav" false 1)
                    (set _G.stars (+ _G.stars 1))
                    (when (= _G.stars _G.max_stars)
                      (view.notification ["CONGRATULATIONS"
                      "You've Won the Game!"
                      "Thank You For Playing!"])))
                  (when (= o.type :heart)
                    (play_sound "audio/pickup2.wav" false 1)
                    (play_sound "audio/pickup1.wav" false 1)
                    (set _G.health (+ _G.health 1))
                    (set _G.max_health (+ _G.max_health 1)))
                  (delete-entity o)) ))))))))

(var ais
  (system [:ai]
    (fn [e]
      (when (= e.ai :wander)
        (set e.velocity.x (+ e.velocity.x (* (math.random -3 3) _G.dt)))
        (set e.velocity.y (+ e.velocity.y (* (math.random -3 3) _G.dt)))
        )

      )))

(var types {
  :player {
    :pos (v.v2 2048 2008)
    :velocity (v.v2 0 0)
    :gravity true
    :sprite (v.v2 0 0)
    :dead_sprite (v.v2 0 1)
    :solid true
    :bounds {:ul (v.v2 4 3) :br (v.v2 10 16)}
    :invincible 0}
  :jump-bag {
    :pos (v.v2 0 0)
    :sprite (v.v2 2 0)
    :bounds {:ul (v.v2 0 0) :br (v.v2 16 16)}
    :pickup true}
  :star {
    :pos (v.v2 0 0)
    :sprite (v.v2 3 0)
    :bounds {:ul (v.v2 0 0) :br (v.v2 16 16)}
    :pickup true}
  :heart {
    :pos (v.v2 0 0)
    :sprite (v.v2 3 1)
    :bounds {:ul (v.v2 0 0) :br (v.v2 16 16)}
    :pickup true}
  :spikes {
    :pos (v.v2 0 0)
    :sprite (v.v2 1 0)
    :bounds {:ul (v.v2 0 8) :br (v.v2 16 16)}
    :hurt 1}
  :bee {
    :pos (v.v2 0 0)
    :sprite (v.v2 6 0)
    :velocity (v.v2 0 0)
    :ai :wander
    :solid true
    :bounds {:ul (v.v2 3 5) :br (v.v2 13 13)}
    :maxspeed 1
    :hurt 1}
  })

(fn new [k]
  (let [e (util.copy (. types k))]
    (set e.initial-pos e.pos)
    (set e.type k) e))

{ :new new
  :types types

  :stores stores
  :sprites sprites
  :gravities gravities
  :velocities velocities
  :physics physics
  :controls controls
  :collisions collisions
  :ais ais}


code:
(var util (require "util"))
(var grid (require "grid"))

(set _G.state (or _G.state (util.read-bin "state.data") {
  :world (grid.make 256 256 -1)
  :background (grid.make 256 256 -1)
  :entities []}))

(set _G.view_bucket {:size 600 :prop "pos"})
(set _G.collision_bucket {:size 16 :prop "pos"})

(set _G.mode :menu)

(set _G.mouse_bad 0)

{:state _G.state :mode _G.mode}

license: unknown


code:
(var v (require "v"))
(var util (require "util"))

(fn make [w h fill]
  (let [res []]
    (for [y 1 h]
      (let [row []]
        (for [x 1 w]
          (tset row x fill))
        (tset res y row)))
    res))

(fn in-bounds [m v]
  (if (<= 1 v.y (# m))
    (if (<= 1 v.x (# (. m 1))) true false)
    false))

(fn in-border [m v]
  (if (<= 2 v.y (- (# m) 1))
    (if (<= 2 v.x (- (# (. m 1)) 1)) true false)
    false))

(fn gget [m v]
  (if (in-bounds m v)
    (. (. m (. v :y)) (. v :x))))

(fn gset [m v x]
  (if (in-bounds m v)
    (tset (. m (. v :y)) (. v :x) x)))

(fn p->t [p]
  (v.vadd (v.vfn (v.vmul p (/ 1 16)) math.floor) (v.v2 1 1)))

(fn t->p [t]
  (v.vmul (v.vsub t (v.v2 1 1)) 16))

(var slopes {
  12 [0 16]
  13 [1 7]
  14 [8 16]

  20 [16 8]
  21 [7 0]
  22 [16 0]})

; truthy if this point is inside a "solid"
(fn point-in-solid-tile [p]
  (let [tpos (p->t p)
        found (gget _G.state.world tpos)]
    (when (and found (> found -1))
      (let [slope (. slopes found)]
        (if slope
          (let [offset (v.vsub p (t->p tpos))
                height (util.lerp (. slope 1) (. slope 2) (/ offset.x 16))]
            (when (> offset.y height)

              [found (- offset.y height)]))
          [found nil])))))

; if p is inside a tile returns [tile offset-vector] where
; the offset is determined by the `vel`
; one one axis of offset is of interest to me
(fn point-solid-offset [p vel]
  (let [tpos (p->t p)
        found (gget _G.state.world tpos)]
    (when (and found (> found -1))
      (let [tile-pos (t->p tpos)
            slope (. slopes found)]
        (if slope ; could maybe ignore some velocity conditions for slope checking
          (let [offset (v.vsub p (t->p tpos))
                height (util.lerp (. slope 1) (. slope 2) (/ offset.x 16))]
            (when (> offset.y height)

              {:tile found :slope true :offset (v.v2 0 (- (- offset.y height)))}))
          (let [ox (if (< vel.x 0)
                       (- (+ tile-pos.x 16) p.x)
                       (- (- p.x tile-pos.x)))
                oy (if (< vel.y 0)
                       (- (- (+ tile-pos.y 16) p.y))
                       (- (- p.y tile-pos.y)))
                ; hack to prevent glitching when checking the wrong axis for an intersection
                ox (if (> ox 6) 0
                       (< ox -6) 0 ox)
                oy (if (> oy 6) 0
                       (< oy -6) 0 oy)]
            {:tile found :offset (v.v2 ox oy)} ))))))

{:make make :in-bounds in-bounds :gget gget :gset gset
 :p->t p->t
 :t->p t->p
 :point-in-solid-tile point-in-solid-tile
 :point-solid-offset point-solid-offset}


code:
(var v (require "v"))

(fn button [x y w h label f]
  (let [(mx my) (mouse_pos)
        over? (v.v_in_rect (v.v2 mx my) (v.v2 x y) (v.v2 (+ x w) (+ y h)))
        color (if over? true false)]
    (draw_rect x y w h color)
    (draw_rect_lines x y w h 1 (not color))
    (draw_text label (+ x (/ w 2) (* (/ (# label) 2) -6)) (+ y (/ h 2) 3) (not color))
    (when (and over? (mouse_pressed 1)) (play_sound "audio/blip.wav" false 0.3) (f))))

(fn checkbox [x y label checked f]
  (let [(mx my) (mouse_pos)
        width (* (# label) 10)
        over? (v.v_in_rect (v.v2 mx my) (v.v2 x y) (v.v2 (+ x width) (+ y 16)))
        ]
    (draw_rect x y 16 16 true)
    (draw_rect (+ x 1) (+ y 1) 14 14 false)
    (when checked (draw_rect (+ x 2) (+ y 2) 12 12 true))
    (draw_text label (+ x 20) (+ y 11) true)
    (when (and over? (mouse_pressed 1)) (play_sound "audio/blip.wav" false 0.3) (f))))

(fn icon-bar [cnt max x y width sprite]
  (let [spr-pos (v.vmul sprite 16)
        fill-pos (v.vadd spr-pos (v.v2 16 0))]
    (for [i 0 (- max 1)]
      (let [iy (math.floor (/ i width))
            ix (% i width)
            spr (if (< i cnt) fill-pos spr-pos)]
      (draw_sprite "entities.png"
        (+ x (* ix 12)) (+ y (* iy 12)) spr.x spr.y 16 16)))))

{:button button :checkbox checkbox :icon-bar icon-bar}


code:
(var binser (require "deps/binser"))
(var v (require "v"))

(fn write-data [path data]
  (match (io.open path "w")
    f (do (f:write (fennel.view data)) (f:close))
    (nil err-msg) (print "Could not open file:" err-msg)))

(fn read-data [path]
  (match (io.open path)
    f (let [res (fennel.eval (f:read :*all))]
          (f:close)
          res)
    (nil err-msg) nil))

(fn write-bin [path data] (binser.writeFile path data))

(fn read-bin [path]
  (match (io.open path)
    f (do (f:close) (let [[res _] (binser.readFile path)] res))
    (nil err-msg) nil))

(fn copy [o]
  (if (= (type o) "table")
    (let [t {}]
      (each [k v (pairs o)]
        (tset t k (copy v))) t)
    o))

(var _ts {})

(fn lerp [a b r] (+ a (* (- b a) r)))
(fn vlerp [a b r] (v.vadd a (v.vmul (v.vsub b a) r)))
(fn powf [n] (fn [v] (^ v n)))

(fn tween [o p v d _]
  (let [_ (or _ {})
        t {:o o :p p :v v :d d :s d
           :f _.f
           :l (or _.l lerp)
           :ei (or _.ei _.e)
           :eo (or _.eo _.e)
           :iv (or (and p (. o p)) o)}]
    (table.insert _ts t) t))

(fn wait [d f] (tween 0 nil 0 d {:f f}))

(fn update-tweens []
  (local ts {})
  (each [_ t (ipairs _ts)]
    (when t.o
      (set t.d (- t.d _G.dt))
      (var r (- 1 (/ t.d t.s)))
      (if (and t.ei t.eo)
          (set r (or (and (< r 0.5) (/ (t.ei (* r 2)) 2))
                     (- 1 (/ (t.eo (* (- 1 r) 2)) 2))))
          t.ei
          (set r (t.ei r))
          t.eo
          (set r (- 1 (t.eo (- 1 r)))))
      (var z (t.l t.iv t.v r))
      (if t.p (tset t.o t.p z)
              (set t.o z))
      (if (> t.d 0) (table.insert ts t)
          (if t.f (t.f t.o)))))
  (set _ts ts))

;(tween object prop_name target_value duration options_table)
; options are
; :e dual in+out easing fn
; :ei,:eo in,out easing fn
; :f tween callback (takes 1 argument - the object)
; :l lerping function

(fn add [m v] (table.insert m v))

(fn del [col o]
  (var found false)
  (each [i v (ipairs col)]
    (when (and (not found) (= v o))
      (table.remove col i)
      (set found true))))

(fn identity [x] x)

(fn inc [n] (+ n 1))

(fn dec [n] (- n 1))

(fn nil? [x] (= x nil))

(fn true? [x] (if x true false))

(fn empty? [x] (= 0 (# x)))

(fn first [col] (. col 1))

(fn last [col] (. col (# col)))

(fn rest [col]
  (let [a []]
    (if (< (# col) 2) a
      (do (for [i 2 (# col)]
        (tset a (dec i) (. col i))) a))))

(fn map [f col]
  (let [a []]
    (each [i v (pairs col)]
      (tset a i (f v))) a))

(fn filter [f col]
  (let [a []]
    (each [i v (pairs col)]
      (if (f v) (add a v))) a))

(fn reduce [f val col]
  (if (nil? col)
    (reduce f (first val) (rest val))
    (if (empty? col) val
      (reduce f (f val (first col)) (rest col)))))

(fn rand [n] (math.random n))

(fn rand-nth [col] (. col (rand (# col))))

{ :write-data write-data
  :read-data read-data
  :write-bin write-bin
  :read-bin read-bin
  :copy copy
  :lerp lerp
  :vlerp vlerp
  :tween tween
  :_ts _ts
  :powf powf
  :wait wait
  :update-tweens update-tweens
  :add add
  :del del
  :map map
  :filter filter
  :reduce reduce
  :rand-nth rand-nth}


code:
; vector stuff

(fn v2 [x y] {:x x :y y})
(fn v2= [a b] (and (= a.x b.x) (= a.y b.y)))

(fn vadd [a b] {:x (+ a.x b.x) :y (+ a.y b.y)})
(fn vsub [a b] {:x (- a.x b.x) :y (- a.y b.y)})
(fn vdiv [a b] {:x (/ a.x b.x) :y (/ a.y b.y)})
(fn vtimes [a b] {:x (* a.x b.x) :y (* a.y b.y)})

(fn vmul [a n] {:x (* a.x n) :y (* a.y n)})
(fn dist [a b] (math.sqrt (+ (^ (- a.x b.x) 2) (^ (- a.y b.y) 2))))
(fn vmag [v] (dist v (v2 0 0)))
(fn vnorm [v] (vmul v (/ 1 (vmag v))))
(fn vfn [v f] (v2 (f v.x) (f v.y)))
(fn vint [v] (vfn v math.floor))
(fn vlimit [v n] (if (> (vmag v) n) (vmul (vnorm v) n) v))

(fn v_in_rect [v va vb]
  (and (< va.x v.x vb.x)
       (< va.y v.y vb.y)))

(fn overlap [a1 a2 b1 b2]
  (not
    (or
      (or (> a1.x b2.x)
          (< a2.x b1.x))
      (or (> a1.y b2.y)
          (< a2.y b1.y)))))

{:v2 v2
:v2= v2=
:vadd vadd
:vsub vsub
:vdiv vdiv
:vtimes vtimes
:vmul vmul
:dist dist
:vmag vmag
:vnorm vnorm
:vfn vfn
:vint vint
:vlimit vlimit
:v_in_rect v_in_rect
:overlap overlap}


code:
(var v (require "v"))
(var util (require "util"))
(var grid (require "grid"))
(var bucket (require "deps/bucket"))

; a map drawing module
(print "view.fnl")

(fn new [x y w h]
  (let [tl (v.v2 x y)
        wh (v.v2 w h)
        br (v.vadd tl wh)
        tile-wh (v.vint (v.vdiv wh (v.v2 16 16)))]
  {:tl tl
   :wh wh
   :br br
   :tile-wh tile-wh
   :camera (v.v2 0 0)
   :camera-target (v.v2 0 0)}))

(fn screen->tile [view pos]
  (grid.p->t
    (v.vsub
      (v.vsub (v.vadd pos view.camera) view.tl)
      (v.vmul view.wh 0.5))))

(fn world->screen [view pos]
  (v.vadd
    (v.vadd (v.vsub pos view.camera) view.tl)
    (v.vmul view.wh 0.5)))

(fn tile->screen [view tpos]
  (world->screen view (grid.t->p tpos)))

(fn sprite-idx->v2 [idx size]
  (v.v2 (% idx size)
      (math.floor (/ idx size))))

(set _G.notifications [])

(fn notification [s duration]
  (let [note {:message s :y -60}]
    (util.tween note :y 0 0.8 {:e (util.powf 2) :f
      (fn [_] (util.wait (or duration 4)
        (fn [_] (util.tween note :y -60 0.8 {:e (util.powf 2) :f (fn [_] (util.del _G.notifications note))}))))})
    (table.insert _G.notifications note)))

(fn draw [view state]
  (util.update-tweens)
  (let [cam-tpos (grid.p->t view.camera)
        t-ul (v.vint (v.vsub cam-tpos (v.vmul view.tile-wh 0.5)))
        t-br (v.vadd (v.vadd t-ul view.tile-wh) (v.v2 1 1))]
    (draw_rect view.tl.x view.tl.y view.wh.x view.wh.y true)

    (for [x t-ul.x t-br.x]
      (for [y t-ul.y t-br.y]
        (let [tile (grid.gget _G.state.world (v.v2 x y))
              bgtile (grid.gget _G.state.background (v.v2 x y))
              tile (if (and tile (<= 0 tile)) tile nil)
              bgtile (if (and bgtile (<= 0 bgtile)) bgtile nil)]
          (when (or tile bgtile)

            (let [spr-pos (v.vmul (sprite-idx->v2 (or tile bgtile) 8) 16)
                  tpos (tile->screen view (v.v2 x y))]
              (when bgtile
                (draw_sprite "background_sprites.png"
                  tpos.x tpos.y spr-pos.x spr-pos.y 16 16))
              (when tile
                (draw_sprite "world_sprites.png"
                  tpos.x tpos.y spr-pos.x spr-pos.y 16 16)) )))))))

(fn draw-notifications [window]
  (each [i note (ipairs _G.notifications)]
    (let [_top (+ window.tl.y 6 note.y)
          midpoint (v.v2 (+ window.tl.x (* window.wh.x 0.5)) (math.max 0 _top))
          width 300
          height (if (< _top 0) (+ 60 _top) 60)
          mheight (* (# note.message) 12)]

      (draw_rect (- midpoint.x (* width 0.5)) midpoint.y width height true)
      (draw_rect_lines (- midpoint.x (* width 0.5)) midpoint.y width height  1 false)
      (draw_rect_lines (+ (- midpoint.x (* width 0.5)) 3) (+ midpoint.y 3) (- width 6) (- height 6)  2 false)
      (each [i line (ipairs note.message)]
        (draw_text line (- midpoint.x (* (# line) 5.3 0.5))
          (+ midpoint.y -2 (* height 0.5) (- (* mheight 0.5)) (* i 12)) false)))))

(fn mask-view [view]
  ; clip our map view with white rects
  (draw_rect  0  0 view.tl.x (+ view.tl.y view.wh.y 16) false)
  (draw_rect  0  0 (+ view.tl.x view.wh.x 100) view.tl.y  false)
  (draw_rect  (+ view.tl.x view.wh.x)  0 300 (+ view.tl.y view.wh.y 16)  false)
  (draw_rect  0  (+ view.tl.y view.wh.y) (+ view.tl.x view.wh.x 16) (+ view.tl.y view.wh.y 16)  false))

{ :new new :draw draw :screen->tile screen->tile :tile->screen tile->screen
  :world->screen world->screen :mask-view mask-view
  :notification notification :draw-notifications draw-notifications}


code:
use macroquad::prelude::*;

// binds between strings and macroquad KeyCodes
pub fn keycode(s: &str) -> KeyCode {
    match s {
        "space" => KeyCode::Space,
        "apostrophe" => KeyCode::Apostrophe,
        "comma" => KeyCode::Comma,
        "minus" => KeyCode::Minus,
        "period" => KeyCode::Period,
        "slash" => KeyCode::Slash,
        "key0" => KeyCode::Key0,
        "key1" => KeyCode::Key1,
        "key2" => KeyCode::Key2,
        "key3" => KeyCode::Key3,
        "key4" => KeyCode::Key4,
        "key5" => KeyCode::Key5,
        "key6" => KeyCode::Key6,
        "key7" => KeyCode::Key7,
        "key8" => KeyCode::Key8,
        "key9" => KeyCode::Key9,
        "semicolon" => KeyCode::Semicolon,
        "equal" => KeyCode::Equal,
        "a" => KeyCode::A,
        "b" => KeyCode::B,
        "c" => KeyCode::C,
        "d" => KeyCode::D,
        "e" => KeyCode::E,
        "f" => KeyCode::F,
        "g" => KeyCode::G,
        "h" => KeyCode::H,
        "i" => KeyCode::I,
        "j" => KeyCode::J,
        "k" => KeyCode::K,
        "l" => KeyCode::L,
        "m" => KeyCode::M,
        "n" => KeyCode::N,
        "o" => KeyCode::O,
        "p" => KeyCode::P,
        "q" => KeyCode::Q,
        "r" => KeyCode::R,
        "s" => KeyCode::S,
        "t" => KeyCode::T,
        "u" => KeyCode::U,
        "v" => KeyCode::V,
        "w" => KeyCode::W,
        "x" => KeyCode::X,
        "y" => KeyCode::Y,
        "z" => KeyCode::Z,
        "leftbracket" => KeyCode::LeftBracket,
        "backslash" => KeyCode::Backslash,
        "rightbracket" => KeyCode::RightBracket,
        "graveaccent" => KeyCode::GraveAccent,
        "world1" => KeyCode::World1,
        "world2" => KeyCode::World2,
        "escape" => KeyCode::Escape,
        "enter" => KeyCode::Enter,
        "tab" => KeyCode::Tab,
        "backspace" => KeyCode::Backspace,
        "insert" => KeyCode::Insert,
        "delete" => KeyCode::Delete,
        "right" => KeyCode::Right,
        "left" => KeyCode::Left,
        "down" => KeyCode::Down,
        "up" => KeyCode::Up,
        "pageup" => KeyCode::PageUp,
        "pagedown" => KeyCode::PageDown,
        "home" => KeyCode::Home,
        "end" => KeyCode::End,
        "capslock" => KeyCode::CapsLock,
        "scrolllock" => KeyCode::ScrollLock,
        "numlock" => KeyCode::NumLock,
        "printscreen" => KeyCode::PrintScreen,
        "pause" => KeyCode::Pause,
        "f1" => KeyCode::F1,
        "f2" => KeyCode::F2,
        "f3" => KeyCode::F3,
        "f4" => KeyCode::F4,
        "f5" => KeyCode::F5,
        "f6" => KeyCode::F6,
        "f7" => KeyCode::F7,
        "f8" => KeyCode::F8,
        "f9" => KeyCode::F9,
        "f10" => KeyCode::F10,
        "f11" => KeyCode::F11,
        "f12" => KeyCode::F12,
        "f13" => KeyCode::F13,
        "f14" => KeyCode::F14,
        "f15" => KeyCode::F15,
        "f16" => KeyCode::F16,
        "f17" => KeyCode::F17,
        "f18" => KeyCode::F18,
        "f19" => KeyCode::F19,
        "f20" => KeyCode::F20,
        "f21" => KeyCode::F21,
        "f22" => KeyCode::F22,
        "f23" => KeyCode::F23,
        "f24" => KeyCode::F24,
        "f25" => KeyCode::F25,
        "kp0" => KeyCode::Kp0,
        "kp1" => KeyCode::Kp1,
        "kp2" => KeyCode::Kp2,
        "kp3" => KeyCode::Kp3,
        "kp4" => KeyCode::Kp4,
        "kp5" => KeyCode::Kp5,
        "kp6" => KeyCode::Kp6,
        "kp7" => KeyCode::Kp7,
        "kp8" => KeyCode::Kp8,
        "kp9" => KeyCode::Kp9,
        "kpdecimal" => KeyCode::KpDecimal,
        "kpdivide" => KeyCode::KpDivide,
        "kpmultiply" => KeyCode::KpMultiply,
        "kpsubtract" => KeyCode::KpSubtract,
        "kpadd" => KeyCode::KpAdd,
        "kpenter" => KeyCode::KpEnter,
        "kpequal" => KeyCode::KpEqual,
        "leftshift" => KeyCode::LeftShift,
        "leftcontrol" => KeyCode::LeftControl,
        "leftalt" => KeyCode::LeftAlt,
        "leftsuper" => KeyCode::LeftSuper,
        "rightshift" => KeyCode::RightShift,
        "rightcontrol" => KeyCode::RightControl,
        "rightalt" => KeyCode::RightAlt,
        "rightsuper" => KeyCode::RightSuper,
        "menu" => KeyCode::Menu,
        _ => KeyCode::Unknown,
    }
}


code:
#[macro_use]
extern crate lazy_static;
use hlua::{Lua, LuaError};
use macroquad::audio::{load_sound, play_sound, play_sound_once, PlaySoundParams, Sound};
use macroquad::prelude::*;
use std::collections::{HashMap, HashSet};
use std::env;
use std::ffi::OsStr;
use std::fs::File;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Mutex;

use notify::{watcher, RecursiveMode, Watcher};
use std::sync::mpsc::channel;
use std::time::{Duration, Instant, SystemTime};

mod keys;

lazy_static! {
    static ref BASE_PATH: PathBuf = env::current_dir().unwrap();
    static ref IMAGE: Mutex<Image> = Mutex::new(Image::gen_image_color(
        screen_width() as u16,
        screen_height() as u16,
        BLACK
    ));
    static ref FONTS: Mutex<HashMap<String, Font>> = Mutex::new(HashMap::new());
    static ref TEXTURES: Mutex<HashMap<String, Texture2D>> = Mutex::new(HashMap::new());
    static ref UNLOADED_TEXTURES: Mutex<HashSet<String>> = Mutex::new(HashSet::new());
    static ref SOUNDS: Mutex<HashMap<String, Sound>> = Mutex::new(HashMap::new());
    static ref UNLOADED_SOUNDS: Mutex<HashSet<String>> = Mutex::new(HashSet::new());
}

fn window_conf() -> Conf {
    Conf {
        window_title: "FEN2".to_owned(),
        window_width: 640,
        window_height: 480,
        ..Default::default()
    }
}

// user code will load images into the TEXTURES dict by path name
async fn _preload_texture(path: String, reload: bool) -> bool {
    let mut textures = TEXTURES.lock().unwrap();

    let p = &path;
    if reload || !textures.contains_key(p) {
        match load_texture(p).await {
            Ok(t) => {
                textures.insert(path, t);
                return true;
            }
            Err(e) => {
                println!("{:?}", e);
                return false;
            }
        }
    } else {
        return true;
    }
}

async fn _handle_unloaded_textures() {
    for s in UNLOADED_TEXTURES.lock().unwrap().drain() {
        println!("loading {:?}", s);
        _preload_texture(s, false).await;
    }
}

fn _preload_texture_sync(path: String) {
    UNLOADED_TEXTURES.lock().unwrap().insert(path);
}

async fn _preload_sound(path: String, reload: bool) -> bool {
    let mut sounds = SOUNDS.lock().unwrap();

    let p = &path;
    if reload || !sounds.contains_key(p) {
        match load_sound(p).await {
            Ok(t) => {
                sounds.insert(path, t);
                return true;
            }
            Err(e) => {
                println!("{:?}", e);
                return false;
            }
        }
    } else {
        return true;
    }
}

async fn _handle_unloaded_sounds() {
    for s in UNLOADED_SOUNDS.lock().unwrap().drain() {
        println!("loading {:?}", s);
        _preload_sound(s, false).await;
    }
}

fn _preload_sound_sync(path: String) {
    UNLOADED_SOUNDS.lock().unwrap().insert(path);
}

fn _play_sound(path: String, looped: bool, volume: f32) {
    let sounds = SOUNDS.lock().unwrap();
    match sounds.get(&path) {
        Some(t) => play_sound(
            *t,
            PlaySoundParams {
                looped: looped,
                volume: volume,
            },
        ),
        None => println!("Error: no sound {}", &path),
    }
}

fn _draw_texture(path: String, x: u32, y: u32) {
    let textures = TEXTURES.lock().unwrap();
    match textures.get(&path) {
        Some(t) => draw_texture(*t, x as f32, y as f32, WHITE),
        None => println!("Error: no texture {}", &path),
    }
}

fn _draw_texture_ex(path: String, x: u32, y: u32, sx: u32, sy: u32, sw: u32, sh: u32) {
    let textures = TEXTURES.lock().unwrap();
    match textures.get(&path) {
        Some(t) => draw_texture_ex(
            *t,
            x as f32,
            y as f32,
            WHITE,
            DrawTextureParams {
                source: Some(Rect {
                    x: sx as f32,
                    y: sy as f32,
                    w: sw as f32,
                    h: sh as f32,
                }),
                ..Default::default()
            },
        ),
        None => println!("Error: no texture {}", &path),
    }
}

fn set_pixel(x: u32, y: u32, c: bool) {
    IMAGE
        .lock()
        .unwrap()
        .set_pixel(x, y, if c { BLACK } else { WHITE });
}

fn draw_text(s: String, x: u32, y: u32, c: bool) {
    let font = *FONTS
        .lock()
        .unwrap()
        .get(&String::from("HelvetiPixel"))
        .unwrap();
    draw_text_ex(
        &s,
        x as f32,
        y as f32,
        TextParams {
            font: font,
            font_size: 16,
            font_scale: 1.0,
            font_scale_aspect: 1.0,
            color: if c { BLACK } else { WHITE },
            ..Default::default()
        },
    );
}

fn _draw_rect(x: u32, y: u32, w: u32, h: u32, c: bool) {
    draw_rectangle(
        x as f32,
        y as f32,
        w as f32,
        h as f32,
        if c { BLACK } else { WHITE },
    );
}

fn _draw_rect_lines(x: u32, y: u32, w: u32, h: u32, thickness: u32, c: bool) {
    draw_rectangle_lines(
        x as f32,
        y as f32,
        w as f32,
        h as f32,
        (thickness * 2) as f32,
        if c { BLACK } else { WHITE },
    );
}

fn int_to_button(i: i32) -> MouseButton {
    match i {
        0 => MouseButton::Right,
        1 => MouseButton::Left,
        2 => MouseButton::Middle,
        _ => MouseButton::Unknown,
    }
}

fn _mouse_pos() -> (i32, i32) {
    let (x, y) = mouse_position();
    return (x as i32, y as i32);
}

fn _mouse_down(btn: i32) -> bool {
    return is_mouse_button_down(int_to_button(btn));
}

fn _mouse_pressed(btn: i32) -> bool {
    return is_mouse_button_pressed(int_to_button(btn));
}

fn _mouse_released(btn: i32) -> bool {
    return is_mouse_button_released(int_to_button(btn));
}

fn _key_down(key: String) -> bool {
    return is_key_down(keys::keycode(&key));
}

fn _key_pressed(key: String) -> bool {
    return is_key_pressed(keys::keycode(&key));
}

fn _key_released(key: String) -> bool {
    return is_key_released(keys::keycode(&key));
}

fn print_lua_error(e: &LuaError) {
    match e {
        LuaError::ExecutionError(s) => {
            for s in format!("{:?}", e).split("\\n") {
                println!("{}", s)
            }
        }
        other => println!("{:?}", other),
    }
}

struct App<'a> {
    root: &'a Path,
    lua: Lua<'a>,
}

impl<'a> App<'a> {
    fn new(root: &'a Path) -> App<'a> {
        env::set_current_dir(&root).unwrap();
        let mut lua = Lua::new();
        lua.openlibs();
        lua.set("set_pixel", hlua::function3(set_pixel));
        lua.set("draw_text", hlua::function4(draw_text));
        lua.set("load_img", hlua::function1(_preload_texture_sync));
        lua.set("draw_img", hlua::function3(_draw_texture));
        lua.set("draw_sprite", hlua::function7(_draw_texture_ex));

        lua.set("load_sound", hlua::function1(_preload_sound_sync));
        lua.set("play_sound", hlua::function3(_play_sound));

        lua.set("draw_rect", hlua::function5(_draw_rect));
        lua.set("draw_rect_lines", hlua::function6(_draw_rect_lines));

        lua.set("show_mouse", hlua::function1(show_mouse));
        lua.set("mouse_pos", hlua::function0(_mouse_pos));
        lua.set("mouse_down", hlua::function1(_mouse_down));
        lua.set("mouse_pressed", hlua::function1(_mouse_pressed));
        lua.set("mouse_released", hlua::function1(_mouse_released));
        lua.set("key_down", hlua::function1(_key_down));
        lua.set("key_pressed", hlua::function1(_key_pressed));
        lua.set("key_released", hlua::function1(_key_released));

        // both package.path and fennel.path use '?' as wildcard
        let mut base_copy = BASE_PATH.clone();
        base_copy.push("?");

        lua.execute::<()>(
            std::format!(
                "package.path = package.path .. ';{}.lua'",
                str::replace(base_copy.to_str().unwrap(), "\\", "\\\\")
            )
            .as_str(),
        )
        .unwrap();

        lua.execute::<()>("fennel = require('fennel')").unwrap();
        lua.execute::<()>("table.insert(package.loaders or package.searchers, fennel.searcher)")
            .unwrap();

        lua.execute::<()>(
            std::format!(
                "fennel.path = fennel.path .. ';{}.fnl'",
                str::replace(base_copy.to_str().unwrap(), "\\", "\\\\")
            )
            .as_str(),
        )
        .unwrap();

        lua.execute::<()>("system = require('system')").unwrap();

        match lua.execute::<()>("app = require(\"app\")") {
            Err(e) => print_lua_error(&e),
            res => res.unwrap(),
        }

        App {
            lua: lua,
            root: root,
        }
    }
    fn set_working_directory(&self) {
        env::set_current_dir(&self.root).unwrap();
    }
    async fn reload(&mut self, path: PathBuf) {
        let path_s = path.to_str().unwrap();
        let root_s = self.root.to_str().unwrap();
        let mime = path.extension().and_then(OsStr::to_str);
        // strip the app's root
        match path_s.strip_prefix(root_s) {
            Some(_s) => {
                let s = _s.strip_prefix(&"\\").unwrap_or(_s);
                println!("{:?} changed", s);
                match mime {
                    Some("png") | Some("bmp") => {
                        _preload_texture(s.to_string(), true).await;
                    }
                    Some("lua") | Some("fnl") => {
                        match &self
                            .lua
                            .execute::<()>(&format!("system.reload_path({:?})", s))
                        {
                            Err(e) => print_lua_error(e),
                            _ => (),
                        }
                        // use the normal require to update our `app` binding
                        match &self.lua.execute::<()>("app = require(\"app\")") {
                            Err(e) => print_lua_error(e),
                            _ => (),
                        }
                    }
                    _ => (),
                }
            }
            None => (),
        }
    }
    fn update(&mut self, dt: f64) {
        match &self
            .lua
            .execute::<()>(&format!("if app.update then app.update({}) end", dt))
        {
            Err(e) => print_lua_error(e),
            _ => (),
        }
    }
}

#[macroquad::main(window_conf)]
async fn main() {
    // we'll time our own delta time
    let instant = Instant::now();
    let mut elapsed = instant.elapsed().as_secs_f64();

    let (tx, rx) = channel();
    let mut watcher = watcher(tx, Duration::from_millis(100)).unwrap();
    watcher.watch("files", RecursiveMode::Recursive).unwrap();

    FONTS.lock().unwrap().insert(
        String::from("HelvetiPixel"),
        load_ttf_font("./HelvetiPixel.ttf").await.unwrap(),
    );

    let texture = Texture2D::from_image(&*IMAGE.lock().unwrap());

    // eventually we'll scan for available apps
    let mut app_root = BASE_PATH.clone();
    app_root.push("files");
    app_root.push("testapp");
    let mut app = App::new(app_root.as_path());

    loop {
        app.set_working_directory();
        _handle_unloaded_textures().await;
        _handle_unloaded_sounds().await;
        clear_background(WHITE);

        let dt = instant.elapsed().as_secs_f64() - elapsed;
        elapsed = instant.elapsed().as_secs_f64();

        app.update(dt);

        //texture.update(&*IMAGE.lock().unwrap());
        //draw_texture(texture, 0., 0., WHITE);

        match rx.try_recv() {
            Ok(notify::DebouncedEvent::NoticeWrite(path)) => {
                app.reload(path).await;
            }
            Err(e) => (),
            _ => (),
        }

        env::set_current_dir(BASE_PATH.clone()).unwrap();

        next_frame().await
    }
}


code:
(fn reload [module-name]
    (let [old (require module-name)
        _ (tset package.loaded module-name nil)
        new (require module-name)]
        ;; if the module isnt a table then we can't make
        ;; changes which affect already-loaded code, but if
        ;; it is then we should splice new values into the
        ;; existing table and remove values that are gone.
        (when (= (type new) :table)
            (each [k v (pairs new)]
                (tset old k v))
            (each [k (pairs old)]
                ;; the elisp reader is picky about where . can be
                (when (not (. new k))
                    (tset old k nil)))
            (tset package.loaded module-name old))
        (require module-name)))

; looks for packages to reload similar to the path string
; this won't work for combinations of '.' and '/'
(fn reload_path [path]
  (let [stripped (string.gsub (string.gsub (string.gsub (string.gsub path "^/" "") "^\\" "") ".fnl$" "") ".lua$" "")
        dotted (string.gsub (string.gsub stripped "\\" ".") "/" ".")
        slashed (string.gsub stripped "\\" "/")]
    (if (. package.loaded dotted)
        (reload dotted))
    (if (and (not (= dotted slashed))
             (. package.loaded slashed))
        (reload slashed))))

{:reload reload
 :reload_path reload_path}


code:
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Custom
Standard: Cpp03
BraceWrapping:
  AfterClass: true
  AfterControlStatement: false
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: false
  BeforeElse: false
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -8
ColumnLimit: 90
AllowShortFunctionsOnASingleLine: Inline
SortIncludes: false
IncludeCategories:
  - Regex:           '^".*'
    Priority:        2
  - Regex:           '^<.*'
    Priority:        1
AlignAfterOpenBracket: DontAlign
ContinuationIndentWidth: 16

repo_name: pgimeno/minetest

path: .clang-format


code:
*.cpp diff=cpp
*.h diff=cpp

path: .gitattributes


code:
## Editors and Development environments
*~
*.swp
*.bak*
*.orig
# Vim
*.vim
# Kate
.*.kate-swp
.swp.*
# KDevelop4
.kdev4/
*.kdev4
# Eclipse (CDT and LDT)
.project
.cproject
.settings/
.buildpath
.metadata
# GNU Global
tags
!tags/
gtags.files
.idea/*
# Codelite
*.project

## Files related to minetest development cycle
/*.patch
*.diff
# GNU Patch reject file
*.rej

## Non-static Minetest directories or symlinks to these
/bin/
/games/*
!/games/minimal/
/cache
/textures/*
!/textures/base/
/screenshots
/sounds
/mods/*
!/mods/minetest/
/mods/minetest/*
!/mods/minetest/mods_here.txt
/worlds
/world/
/clientmods/*
!/clientmods/preview/
/client/mod_storage/

## Configuration/log files
minetest.conf
debug.txt

## Other files generated by minetest
screenshot_*.png

## Doxygen files
doc/Doxyfile
doc/html/
doc/doxygen_*

## Build files
CMakeFiles
Makefile
!build/android/Makefile
cmake_install.cmake
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
src/android_version.h
src/android_version_githash.h
src/cmake_config.h
src/cmake_config_githash.h
src/lua/build/
locale/
.directory
*.cbp
*.layout
*.o
*.a
*.ninja
.ninja*
*.gch
cmake-build-debug/
cmake-build-release/

## Android build files
build/android/src/main/assets
build/android/build
build/android/deps
build/android/libs
build/android/jni/lib
build/android/jni/src
build/android/src/main/jniLibs
build/android/obj
build/android/local.properties
build/android/.gradle
timestamp

path: .gitignore


code:
---
# Github repository is cloned every day on Gitlab.com
# https://gitlab.com/minetest/minetest
# Pipelines URL: https://gitlab.com/minetest/minetest/pipelines

stages:
  - build
  - package
  - deploy

variables:
  MINETEST_GAME_REPO: "https://github.com/minetest/minetest_game.git"

.build_template: &build_definition
  stage: build
  script:
    - mkdir cmakebuild
    - mkdir -p artifact/minetest/usr/
    - cd cmakebuild
    - cmake -DCMAKE_INSTALL_PREFIX=../artifact/minetest/usr/ -DCMAKE_BUILD_TYPE=Release -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE -DBUILD_SERVER=TRUE ..
    - make -j2
    - make install
  artifacts:
    when: on_success
    expire_in: 1h
    paths:
      - artifact/*

.debpkg_template: &debpkg_template
  stage: package
  before_script:
    - apt-get update -y
    - apt-get install -y git
    - mkdir -p build/deb/minetest/DEBIAN/
    - cp misc/debpkg-control build/deb/minetest/DEBIAN/control
    - cp -Rp artifact/minetest/usr build/deb/minetest/
  script:
    - git clone $MINETEST_GAME_REPO build/deb/minetest/usr/share/minetest/games/minetest
    - rm -Rf build/deb/minetest/usr/share/minetest/games/minetest/.git
    - sed -i 's/DATEPLACEHOLDER/'$(date +%y.%m.%d)'/g' build/deb/minetest/DEBIAN/control
    - sed -i 's/LEVELDB_PLACEHOLDER/'$LEVELDB_PKG'/g' build/deb/minetest/DEBIAN/control
    - cd build/deb/ && dpkg-deb -b minetest/
  artifacts:
    when: on_success
    expire_in: 30 day
    paths:
      - build/deb/*.deb

.debpkg_install: &debpkg_install
  stage: deploy
  before_script:
    - apt-get update -y
    - apt-get install -y libc6 libcurl3-gnutls libfreetype6 libirrlicht1.8 $LEVELDB_PKG liblua5.1-0 libluajit-5.1-2 libopenal1 libstdc++6 libvorbisfile3 libx11-6 zlib1g
  script:
    - dpkg -i build/deb/*.deb

##
## Debian
##

# Jessie

build:debian-8:
  <<: *build_definition
  image: debian:8
  before_script:
    - apt-get update -y
    - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:debian-8:
  image: debian:8
  dependencies:
    - build:debian-8
  variables:
    LEVELDB_PKG: libleveldb1
  <<: *debpkg_template

deploy:debian-8:
  image: debian:8
  dependencies:
    - package:debian-8
  variables:
    LEVELDB_PKG: libleveldb1
  <<: *debpkg_install

# Stretch

build:debian-9:
 <<: *build_definition
 image: debian:9
 before_script:
   - apt-get update -y
   - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:debian-9:
  image: debian:9
  dependencies:
    - build:debian-9
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_template

deploy:debian-9:
  image: debian:9
  dependencies:
    - package:debian-9
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_install

##
## Ubuntu
##

# Trusty

build:ubuntu-14.04:
 <<: *build_definition
 image: ubuntu:trusty
 before_script:
   - apt-get update -y
   - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:ubuntu-14.04:
  image: ubuntu:trusty
  dependencies:
    - build:ubuntu-14.04
  variables:
    LEVELDB_PKG: libleveldb1
  <<: *debpkg_template

deploy:ubuntu-14.04:
  image: ubuntu:trusty
  dependencies:
    - package:ubuntu-14.04
  variables:
    LEVELDB_PKG: libleveldb1
  <<: *debpkg_install

# Xenial

build:ubuntu-16.04:
 <<: *build_definition
 image: ubuntu:xenial
 before_script:
   - apt-get update -y
   - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:ubuntu-16.04:
  image: ubuntu:xenial
  dependencies:
    - build:ubuntu-16.04
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_template

deploy:ubuntu-16.04:
  image: ubuntu:xenial
  dependencies:
    - package:ubuntu-16.04
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_install

# Yakkety

build:ubuntu-16.10:
 <<: *build_definition
 image: ubuntu:yakkety
 before_script:
   - apt-get update -y
   - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:ubuntu-16.10:
  image: ubuntu:yakkety
  dependencies:
    - build:ubuntu-16.10
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_template

deploy:ubuntu-16.10:
  image: ubuntu:yakkety
  dependencies:
    - package:ubuntu-16.10
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_install

# Zesty

build:ubuntu-17.04:
 <<: *build_definition
 image: ubuntu:zesty
 before_script:
   - apt-get update -y
   - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

package:ubuntu-17.04:
  image: ubuntu:zesty
  dependencies:
    - build:ubuntu-17.04
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_template

deploy:ubuntu-17.04:
  image: ubuntu:zesty
  dependencies:
    - package:ubuntu-17.04
  variables:
    LEVELDB_PKG: libleveldb1v5
  <<: *debpkg_install

##
## Fedora
##

build:fedora-24:
  <<: *build_definition
  image: fedora:24
  before_script:
    - dnf -y install make automake gcc gcc-c++ kernel-devel cmake libcurl* openal* libvorbis* libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel


code:
0gb.us <0gb.us@0gb.us> <us_0gb@laptop-0gb-us.0gb.us>
Calinou <calinou9999@gmail.com> <calinou9999spam@gmail.com>
Perttu Ahola <celeron55@gmail.com> celeron55 <celeron55@gmail.com>
Perttu Ahola <celeron55@gmail.com> celeron55 <celeron55@armada.(none)>
Craig Robbins <kde.psych@gmail.com> <crobbins@localhost.localdomain>
Diego Martínez <kaeza@users.sf.net> <lkaezadl3@gmail.com>
Ilya Zhuravlev <zhuravlevilya@ya.ru> <whatever@xyz.is>
kwolekr <kwolekr@minetest.net> <mirrorisim@gmail.com>
PilzAdam <pilzadam@minetest.net> PilzAdam <adam-k@outlook.com>
PilzAdam <pilzadam@minetest.net> Pilz Adam <PilzAdam@gmx.de>
PilzAdam <pilzadam@minetest.net> PilzAdam <PilzAdam@gmx.de>
proller <proller@github.com> <proler@github.com>
proller <proller@github.com> <proler@gmail.com>
RealBadAngel <maciej.kasatkin@o2.pl> <mk@realbadangel.pl>
RealBadAngel <maciej.kasatkin@o2.pl> <maciej.kasatkin@yahoo.com>
Selat <LongExampleTestName@gmail.com> <LongExampletestName@gmail.com>
ShadowNinja <shadowninja@minetest.net> ShadowNinja <noreply@gmail.com>
Shen Zheyu <arsdragonfly@gmail.com> arsdragonfly <arsdragonfly@gmail.com>
Pavel Elagin <elagin.pasha@gmail.com> elagin <elagin.pasha@gmail.com>
Esteban I. Ruiz Moreno <exio4.com@gmail.com> Esteban I. RM <exio4.com@gmail.com>
manuel duarte <ffrogger0@yahoo.com> manuel joaquim <ffrogger0@yahoo.com>
manuel duarte <ffrogger0@yahoo.com> sweetbomber <ffrogger _zero_ at yahoo dot com>
Diego Martínez <kaeza@users.sf.net> kaeza <kaeza@users.sf.net>
Diego Martínez <kaeza@users.sf.net> Diego Martinez <kaeza@users.sf.net>
Lord James <neftali_dtctv@hotmail.com> Lord89James <neftali_dtctv@hotmail.com>
BlockMen <nmuelll@web.de> Block Men <nmuelll@web.de>
sfan5 <sfan5@live.de> Sfan5 <sfan5@live.de>
DannyDark <the_skeleton_of_a_child@yahoo.co.uk> dannydark <the_skeleton_of_a_child@yahoo.co.uk>
Ilya Pavlov <TTChangeTheWorld@gmail.com> Ilya <TTChangeTheWorld@gmail.com>
Ilya Zhuravlev <zhuravlevilya@ya.ru> xyzz <zhuravlevilya@ya.ru>
sapier <Sapier at GMX dot net> sapier <sapier AT gmx DOT net>
sapier <Sapier at GMX dot net> sapier <sapier at gmx dot net>

path: .mailmap


code:
language: cpp
before_install: ./util/travis/before_install.sh
script: ./util/travis/script.sh
sudo: required
notifications:
  email: false
matrix:
  fast_finish: true
  include:
    - env: PLATFORM=Win32
      compiler: gcc
      os: linux
    - env: PLATFORM=Win64
      compiler: gcc
      os: linux
    - env: PLATFORM=Unix COMPILER=clang
      compiler: clang
      os: osx
    - env: PLATFORM=Unix COMPILER=g++
      compiler: gcc
      os: linux
    - env: PLATFORM=Unix COMPILER=clang
      compiler: clang
      os: linux
    - env: PLATFORM=Unix COMPILER=clang VALGRIND=1
      compiler: clang
      os: linux
      dist: trusty
    - env: COMPILER=none LINT=1
      compiler: clang
      os: linux
      dist: trusty
    - env: PLATFORM=Unix COMPILER=g++-6
      compiler: gcc
      os: linux
addons:
  apt:
    sources: &sources
      - ubuntu-toolchain-r-test


code:
cmake_minimum_required(VERSION 2.6)

if(${CMAKE_VERSION} STREQUAL "2.8.2")
	# Bug http://vtk.org/Bug/view.php?id=11020
	message(WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
endif()

# This can be read from ${PROJECT_NAME} after project() is called
project(minetest)
set(PROJECT_NAME_CAPITALIZED "Minetest")

# Works only for cmake 3.1 and greater
set(CMAKE_CXX_STANDARD 11)
set(GCC_MINIMUM_VERSION "4.8")
set(CLANG_MINIMUM_VERSION "3.4")

# Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
set(VERSION_MAJOR 0)
set(VERSION_MINOR 4)
set(VERSION_PATCH 17)
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")

# Change to false for releases
set(DEVELOPMENT_BUILD TRUE)

set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA)
	set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
elseif(DEVELOPMENT_BUILD)
	set(VERSION_STRING "${VERSION_STRING}-dev")
endif()

if (CMAKE_BUILD_TYPE STREQUAL Debug)
	# Append "-debug" to version string
	set(VERSION_STRING "${VERSION_STRING}-debug")
endif()

message(STATUS "*** Will build version ${VERSION_STRING} ***")

# Configuration options
set(DEFAULT_RUN_IN_PLACE FALSE)
if(WIN32)
	set(DEFAULT_RUN_IN_PLACE TRUE)
endif()
set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
	"Run directly in source directory structure")

set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
set(BUILD_SERVER FALSE CACHE BOOL "Build server")

set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")

if(NOT CMAKE_BUILD_TYPE)
	# Default to release
	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
endif()

# Included stuff
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

# This is done here so that relative search paths are more reasonable
find_package(Irrlicht)

# Installation

if(WIN32)
	set(SHAREDIR ".")
	set(BINDIR "bin")
	set(DOCDIR "doc")
	set(EXAMPLE_CONF_DIR ".")
	set(LOCALEDIR "locale")
elseif(APPLE)
	set(BUNDLE_NAME ${PROJECT_NAME}.app)
	set(BUNDLE_PATH "${BUNDLE_NAME}")
	set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
	set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
	set(DOCDIR "${SHAREDIR}/${PROJECT_NAME}")
	set(EXAMPLE_CONF_DIR ${DOCDIR})
	set(LOCALEDIR "${SHAREDIR}/locale")
elseif(UNIX) # Linux, BSD etc
	if(RUN_IN_PLACE)
		set(SHAREDIR ".")
		set(BINDIR "bin")
		set(DOCDIR "doc")
		set(EXAMPLE_CONF_DIR ".")
		set(MANDIR "unix/man")
		set(XDG_APPS_DIR "unix/applications")
		set(APPDATADIR "unix/metainfo")
		set(ICONDIR "unix/icons")
		set(LOCALEDIR "locale")
	else()
		set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
		set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
		set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
		set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
		set(EXAMPLE_CONF_DIR ${DOCDIR})
		set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
		set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/metainfo")
		set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
		set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/locale")
	endif()
endif()

set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
if(NOT CUSTOM_SHAREDIR STREQUAL "")
	set(SHAREDIR "${CUSTOM_SHAREDIR}")
	message(STATUS "Using SHAREDIR=${SHAREDIR}")
endif()

set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
if(NOT CUSTOM_BINDIR STREQUAL "")
	set(BINDIR "${CUSTOM_BINDIR}")
	message(STATUS "Using BINDIR=${BINDIR}")
endif()

set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
if(NOT CUSTOM_DOCDIR STREQUAL "")
	set(DOCDIR "${CUSTOM_DOCDIR}")
	if(NOT RUN_IN_PLACE)
		set(EXAMPLE_CONF_DIR ${DOCDIR})
	endif()
	message(STATUS "Using DOCDIR=${DOCDIR}")
endif()

set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
if(NOT CUSTOM_MANDIR STREQUAL "")
	set(MANDIR "${CUSTOM_MANDIR}")
	message(STATUS "Using MANDIR=${MANDIR}")
endif()

set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
	set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
	message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
endif()

set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
	set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
	message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
endif()

set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
if(NOT CUSTOM_ICONDIR STREQUAL "")
	set(ICONDIR "${CUSTOM_ICONDIR}")
	message(STATUS "Using ICONDIR=${ICONDIR}")
endif()

set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
if(NOT CUSTOM_LOCALEDIR STREQUAL "")
	set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
	message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
endif()

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/clientmods" DESTINATION "${SHAREDIR}")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games" DESTINATION "${SHAREDIR}" PATTERN ".git*" EXCLUDE)

if(BUILD_CLIENT)
	install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
endif()
if(RUN_IN_PLACE)
	install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/mods_here.txt" DESTINATION "${SHAREDIR}/mods")
	install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures")
endif()

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")

install(FILES "README.txt" DESTINATION "${DOCDIR}")
install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
install(FILES "doc/menu_lua_api.txt" DESTINATION "${DOCDIR}")
install(FILES "doc/texture_packs.txt" DESTINATION "${DOCDIR}")
install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}")
install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")

if(UNIX AND NOT APPLE)
	install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
	install(FILES "misc/net.minetest.minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
	install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}")
	install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
	install(FILES "misc/minetest-xorg-icon-128.png"
		DESTINATION "${ICONDIR}/hicolor/128x128/apps"
		RENAME "minetest.png")
endif()

if(APPLE)
	install(FILES "misc/minetest-icon.icns" DESTINATION "${SHAREDIR}")
	install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
endif()

# Library pack
find_package(GMP REQUIRED)
find_package(Json REQUIRED)
find_package(Lua REQUIRED)

# JsonCPP doesn't compile well on GCC 4.8
if(NOT ENABLE_SYSTEM_JSONCPP)
	set(GCC_MINIMUM_VERSION "4.9")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
	if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
		message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
			"Version ${GCC_MINIMUM_VERSION} or higher is required.")
	endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
	if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
		message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
			"Version ${CLANG_MINIMUM_VERSION} or higher is required.")
	endif()
endif()

# Subdirectories
# Be sure to add all relevant definitions above this

add_subdirectory(src)

# CPack

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PACKAGE_VENDOR "celeron55")
set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")

if(WIN32)
	if(CMAKE_SIZEOF_VOID_P EQUAL 8)
		set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
	else()
		set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
	endif()

	set(CPACK_GENERATOR ZIP)
elseif(APPLE)
	set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
	set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
	set(CPACK_GENERATOR ZIP)
else()
	set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
	set(CPACK_GENERATOR TGZ)
	set(CPACK_SOURCE_GENERATOR TGZ)
endif()

include(CPack)

# Add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
			${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
	add_custom_target(doc
		${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
		COMMENT "Generating API documentation with Doxygen" VERBATIM
	)
endif()


code:
# Contributing

Contributions are welcome! Here's how you can help:

- [Contributing code](#code)
- [Reporting issues](#issues)
- [Requesting features](#feature-requests)
- [Translating](#translations)
- [Donating](#donations)

## Code

If you are planning to start some significant coding, you would benefit from asking first on [our IRC channel](http://www.minetest.net/irc/) before starting.

1. [Fork](https://help.github.com/articles/fork-a-repo/) the repository and [clone](https://help.github.com/articles/cloning-a-repository/) your fork.

2. Start coding!
    - Refer to the [Lua API](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt), [Developer Wiki](http://dev.minetest.net/Main_Page) and other [documentation](https://github.com/minetest/minetest/tree/master/doc).
    - Follow the [C/C++](http://dev.minetest.net/Code_style_guidelines) and [Lua](http://dev.minetest.net/Lua_code_style_guidelines) code style guidelines.
    - Check your code works as expected and document any changes to the Lua API.

3. Commit & [push](https://help.github.com/articles/pushing-to-a-remote/) your changes to a new branch (not `master`, one change per branch)
    - Commit messages should:
        - Use the present tense
        - Have a title which begins with a capital letter
        - Be descriptive. (e.g. no `Update init.lua` or `Fix a problem`)
        - Have a first line with less than *80 characters* and have a second line that is *empty*

4. Once you are happy with your changes, submit a pull request.
     - Open the [pull-request form](https://github.com/minetest/minetest/pull/new/master)
     - Add a short description explaining briefly what you've done (or if it's a work-in-progress - what you need to do)

##### A pull-request is considered merge-able when:

1. It follows the [roadmap](https://forum.minetest.net/viewtopic.php?t=9177) in some way and fits the whole picture of the project.
2. It works.
3. It follows the code style for [C/C++](http://dev.minetest.net/Code_style_guidelines) or [Lua](http://dev.minetest.net/Lua_code_style_guidelines).
4. The code's interfaces are well designed, regardless of other aspects that might need more work in the future.
5. It uses protocols and formats which include the required compatibility.

## Issues

If you experience an issue, we would like to know the details - especially when a stable release is on the way.

1. Do a quick search on GitHub to check if the issue has already been reported.
2. Is it an issue with the Minetest *engine*? If not, report it [elsewhere](http://www.minetest.net/development/#reporting-issues).
3. [Open an issue](https://github.com/minetest/minetest/issues/new) and describe the issue you are having - you could include:
     - Error logs (check the bottom of the `debug.txt` file)
     - Screenshots
     - Ways you have tried to solve the issue, and whether they worked or not
     - Your Minetest version and the content (subgames, mods or texture packs) you have installed
     - Your platform (e.g. Windows 10 or Ubuntu 15.04 x64)

After reporting you should aim to answer questions or clarifications as this helps pinpoint the cause of the issue (if you don't do this your issue may be closed after 1 month).

## Feature requests

Feature requests are welcome but take a moment to see if your idea follows the [roadmap](https://forum.minetest.net/viewtopic.php?t=9177) in some way and fits the whole picture of the project. You should provide a clear explanation with as much detail as possible.

## Translations

Translations of Minetest are performed using Weblate. You can access the project page  with a list of current languages [here](https://hosted.weblate.org/projects/minetest/minetest/).

### Donations

If you'd like to monetarily support Minetest development, you can find donation methods on [our website](http://www.minetest.net/development/#donate).

# Maintaining

*This is a concise version of the [Rules & Guidelines](http://dev.minetest.net/Category:Rules_and_Guidelines) on the developer wiki.*

These notes are for those who have push access Minetest (core developers / maintainers).

- See the [project organisation](http://dev.minetest.net/Organisation) for the people involved.

## Reviewing pull requests

Pull requests should be reviewed and, if appropriate, checked if they achieve their intended purpose. You can show that you are in the process of, or will review the pull request by commenting *"Looks good"* or something similar.

**If the pull-request is not [merge-able](#a-pull-request-is-considered-merge-able-when):**

Submit a comment explaining to the author what they need to change to make the pull-request merge-able.

- If the author comments or makes changes to the pull-request, it can be reviewed again.
- If no response is made from the author within 1 month (when improvements are suggested or a question is asked), it can be closed.

**If the pull-request is [merge-able](#a-pull-request-is-considered-merge-able-when):**

Submit a :+1: (+1) or "Looks good" comment to show you believe the pull-request should be merged. "Looks good" comments often signify that the patch might require (more) testing.

- Two core developers must agree to the merge before it is carried out and both should +1 the pull request.
- Who intends to merge the pull-request should follow the commit rules:
    - The title should follow the commit guidelines (title starts with a capital letter, present tense, descriptive).
    - Don't modify history older than 10 minutes.
    - Use rebase, not merge to get linear history:
    - `curl https://github.com/minetest/minetest/pull/1.patch | git am`

## Reviewing issues and feature requests

- If an issue does not get a response from its author within 1 month (when requiring more details), it can be closed.
- When an issue is a duplicate, refer to the first ones and close the later ones.
- Tag issues with the appropriate [labels](https://github.com/minetest/minetest/labels) for devices, platforms etc.

## Releasing a new version

*Refer to [dev.minetest.net/Releasing_Minetest](http://dev.minetest.net/Releasing_Minetest)*


code:
Minetest
========

An InfiniMiner/Minecraft inspired game.

Copyright (c) 2010-2017 Perttu Ahola <celeron55@gmail.com>
and contributors (see source file comments and the version control log)

In case you downloaded the source code:
---------------------------------------
If you downloaded the Minetest Engine source code in which this file is
contained, you probably want to download the minetest_game project too:
  https://github.com/minetest/minetest_game/
See the README.txt in it.

Further documentation
----------------------
- Website: http://minetest.net/
- Wiki: http://wiki.minetest.net/
- Developer wiki: http://dev.minetest.net/
- Forum: http://forum.minetest.net/
- Github: https://github.com/minetest/minetest/
- doc/ directory of source distribution

This game is not finished
--------------------------
- Don't expect it to work as well as a finished game will.
- Please report any bugs. When doing that, debug.txt is useful.

Default controls
-----------------
- Move mouse: Look around
- W, A, S, D: Move
- Space: Jump/move up
- Shift: Sneak/move down
- Q: Drop itemstack
- Shift + Q: Drop single item
- Left mouse button: Dig/punch/take item
- Right mouse button: Place/use
- Shift + right mouse button: Build (without using)
- I: Inventory menu
- Mouse wheel: Select item
- 0-9: Select item
- Z: Zoom (needs zoom privilege)
- T: Chat
- /: Command

- Esc: Pause menu/abort/exit (pauses only singleplayer game)
- R: Enable/disable full range view
- +: Increase view range
- -: Decrease view range
- K: Enable/disable fly mode (needs fly privilege)
- J: Enable/disable fast mode (needs fast privilege)
- H: Enable/disable noclip mode (needs noclip privilege)

- F1:  Hide/show HUD
- F2:  Hide/show chat
- F3:  Disable/enable fog
- F4:  Disable/enable camera update (Mapblocks are not updated anymore when disabled, disabled in release builds)
- F5:  Cycle through debug info screens
- F6:  Cycle through profiler info screens
- F7:  Cycle through camera modes
- F8:  Toggle cinematic mode
- F9:  Cycle through minimap modes
- Shift + F9: Change minimap orientation
- F10: Show/hide console
- F12: Take screenshot
- P: Write stack traces into debug.txt

Most controls are settable in the configuration file, see the section below.

Paths
------
$bin   - Compiled binaries
$share - Distributed read-only data
$user  - User-created modifiable data

Windows .zip / RUN_IN_PLACE source:
$bin   = bin
$share = .
$user  = .

Linux installed:
$bin   = /usr/bin
$share = /usr/share/minetest
$user  = ~/.minetest

macOS:
$bin   = Contents/MacOS
$share = Contents/Resources
$user  = Contents/User OR ~/Library/Application Support/minetest

World directory
----------------
- Worlds can be found as separate folders in:
    $user/worlds/

Configuration file:
-------------------
- Default location:
    $user/minetest.conf
- It is created by Minetest when it is ran the first time.
- A specific file can be specified on the command line:
    --config <path-to-file>
- A run-in-place build will look for the configuration file in
    $location_of_exe/../minetest.conf and also $location_of_exe/../../minetest.conf

Command-line options:
---------------------
- Use --help

Compiling on GNU/Linux:
-----------------------

Install dependencies. Here's an example for Debian/Ubuntu:
$ sudo apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev

For Fedora users:
$ sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl* openal* libvorbis* libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel

You can install git for easily keeping your copy up to date.
If you don’t want git, read below on how to get the source without git.
This is an example for installing git on Debian/Ubuntu:
$ sudo apt-get install git

For Fedora users:
$ sudo dnf install git

Download source (this is the URL to the latest of source repository, which might not work at all times) using git:
$ git clone --depth 1 https://github.com/minetest/minetest.git
$ cd minetest

Download minetest_game (otherwise only the "Minimal development test" game is available) using git:
$ git clone --depth 1 https://github.com/minetest/minetest_game.git games/minetest_game

Download source, without using git:
$ wget https://github.com/minetest/minetest/archive/master.tar.gz
$ tar xf master.tar.gz
$ cd minetest-master

Download minetest_game, without using git:
$ cd games/
$ wget https://github.com/minetest/minetest_game/archive/master.tar.gz
$ tar xf master.tar.gz
$ mv minetest_game-master minetest_game
$ cd ..

Build a version that runs directly from the source directory:
$ cmake . -DRUN_IN_PLACE=TRUE
$ make -j <number of processors>

Run it:
$ ./bin/minetest

- Use cmake . -LH to see all CMake options and their current state
- If you want to install it system-wide (or are making a distribution package),
  you will want to use -DRUN_IN_PLACE=FALSE
- You can build a bare server by specifying -DBUILD_SERVER=TRUE
- You can disable the client build by specifying -DBUILD_CLIENT=FALSE
- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE=<Debug or Release>
  - Debug build is slower, but gives much more useful output in a debugger
- If you build a bare server, you don't need to have Irrlicht installed.
  In that case use -DIRRLICHT_SOURCE_DIR=/the/irrlicht/source

CMake options
-------------
General options:

BUILD_CLIENT        - Build Minetest client
BUILD_SERVER        - Build Minetest server
CMAKE_BUILD_TYPE    - Type of build (Release vs. Debug)
    Release         - Release build
    Debug           - Debug build
    SemiDebug       - Partially optimized debug build
    RelWithDebInfo  - Release build with Debug information
    MinSizeRel      - Release build with -Os passed to compiler to make executable as small as possible
ENABLE_CURL         - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
ENABLE_CURSES       - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
ENABLE_FREETYPE     - Build with FreeType2; Allows using TTF fonts
ENABLE_GETTEXT      - Build with Gettext; Allows using translations
ENABLE_GLES         - Search for Open GLES headers & libraries and use them
ENABLE_LEVELDB      - Build with LevelDB; Enables use of LevelDB map backend
ENABLE_POSTGRESQL   - Build with libpq; Enables use of PostgreSQL map backend (PostgreSQL 9.5 or greater recommended)
ENABLE_REDIS        - Build with libhiredis; Enables use of Redis map backend
ENABLE_SPATIAL      - Build with LibSpatial; Speeds up AreaStores
ENABLE_SOUND        - Build with OpenAL, libogg & libvorbis; in-game Sounds
ENABLE_LUAJIT       - Build with LuaJIT (much faster than non-JIT Lua)
ENABLE_SYSTEM_GMP   - Use GMP from system (much faster than bundled mini-gmp)
RUN_IN_PLACE        - Create a portable install (worlds, settings etc. in current directory)
USE_GPROF           - Enable profiling using GProf
VERSION_EXTRA       - Text to append to version (e.g. VERSION_EXTRA=foobar -> Minetest 0.4.9-foobar)

Library specific options:

BZIP2_INCLUDE_DIR               - Linux only; directory where bzlib.h is located
BZIP2_LIBRARY                   - Linux only; path to libbz2.a/libbz2.so
CURL_DLL                        - Only if building with cURL on Windows; path to libcurl.dll
CURL_INCLUDE_DIR                - Only if building with cURL; directory where curl.h is located
CURL_LIBRARY                    - Only if building with cURL; path to libcurl.a/libcurl.so/libcurl.lib
EGL_INCLUDE_DIR                 - Only if building with GLES; directory that contains egl.h
EGL_LIBRARY                     - Only if building with GLES; path to libEGL.a/libEGL.so
FREETYPE_INCLUDE_DIR_freetype2  - Only if building with Freetype2; directory that contains an freetype directory with files such as ftimage.h in it
FREETYPE_INCLUDE_DIR_ft2build   - Only if building with Freetype2; directory that contains ft2build.h
FREETYPE_LIBRARY                - Only if building with Freetype2; path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL                    - Only if building with Freetype2 on Windows; path to libfreetype.dll
GETTEXT_DLL                     - Only when building with Gettext on Windows; path to libintl3.dll
GETTEXT_ICONV_DLL               - Only when building with Gettext on Windows; path to libiconv2.dll
GETTEXT_INCLUDE_DIR             - Only when building with Gettext; directory that contains iconv.h
GETTEXT_LIBRARY                 - Only when building with Gettext on Windows; path to libintl.dll.a
GETTEXT_MSGFMT                  - Only when building with Gettext; path to msgfmt/msgfmt.exe
IRRLICHT_DLL                    - Only on Windows; path to Irrlicht.dll
IRRLICHT_INCLUDE_DIR            - Directory that contains IrrCompileConfig.h
IRRLICHT_LIBRARY                - Path to libIrrlicht.a/libIrrlicht.so/libIrrlicht.dll.a/Irrlicht.lib
LEVELDB_INCLUDE_DIR             - Only when building with LevelDB; directory that contains db.h
LEVELDB_LIBRARY                 - Only when building with LevelDB; path to libleveldb.a/libleveldb.so/libleveldb.dll.a
LEVELDB_DLL                     - Only when building with LevelDB on Windows; path to libleveldb.dll
PostgreSQL_INCLUDE_DIR          - Only when building with PostgreSQL; directory that contains libpq-fe.h
POSTGRESQL_LIBRARY              - Only when building with PostgreSQL; path to libpq.a/libpq.so
REDIS_INCLUDE_DIR               - Only when building with Redis; directory that contains hiredis.h
REDIS_LIBRARY                   - Only when building with Redis; path to libhiredis.a/libhiredis.so
SPATIAL_INCLUDE_DIR             - Only when building with LibSpatial; directory that contains spatialindex/SpatialIndex.h
SPATIAL_LIBRARY                 - Only when building with LibSpatial; path to libspatialindex_c.so/spatialindex-32.lib
LUA_INCLUDE_DIR                 - Only if you want to use LuaJIT; directory where luajit.h is located
LUA_LIBRARY                     - Only if you want to use LuaJIT; path to libluajit.a/libluajit.so
MINGWM10_DLL                    - Only if compiling with MinGW; path to mingwm10.dll
OGG_DLL                         - Only if building with sound on Windows; path to libogg.dll
OGG_INCLUDE_DIR                 - Only if building with sound; directory that contains an ogg directory which contains ogg.h
OGG_LIBRARY                     - Only if building with sound; path to libogg.a/libogg.so/libogg.dll.a
OPENAL_DLL                      - Only if building with sound on Windows; path to OpenAL32.dll
OPENAL_INCLUDE_DIR              - Only if building with sound; directory where al.h is located
OPENAL_LIBRARY                  - Only if building with sound; path to libopenal.a/libopenal.so/OpenAL32.lib
OPENGLES2_INCLUDE_DIR           - Only if building with GLES; directory that contains gl2.h
OPENGLES2_LIBRARY               - Only if building with GLES; path to libGLESv2.a/libGLESv2.so
SQLITE3_INCLUDE_DIR             - Directory that contains sqlite3.h
SQLITE3_LIBRARY                 - Path to libsqlite3.a/libsqlite3.so/sqlite3.lib
VORBISFILE_DLL                  - Only if building with sound on Windows; path to libvorbisfile-3.dll
VORBISFILE_LIBRARY              - Only if building with sound; path to libvorbisfile.a/libvorbisfile.so/libvorbisfile.dll.a
VORBIS_DLL                      - Only if building with sound on Windows; path to libvorbis-0.dll
VORBIS_INCLUDE_DIR              - Only if building with sound; directory that contains a directory vorbis with vorbisenc.h inside
VORBIS_LIBRARY                  - Only if building with sound; path to libvorbis.a/libvorbis.so/libvorbis.dll.a
XXF86VM_LIBRARY                 - Only on Linux; path to libXXf86vm.a/libXXf86vm.so
ZLIB_DLL                        - Only on Windows; path to zlib1.dll
ZLIBWAPI_DLL                    - Only on Windows; path to zlibwapi.dll
ZLIB_INCLUDE_DIR                - Directory that contains zlib.h
ZLIB_LIBRARY                    - Path to libz.a/libz.so/zlibwapi.lib

Compiling on Windows:
---------------------
- This section is outdated. In addition to what is described here:
  - In addition to minetest, you need to download minetest_game.
  - If you wish to have sound support, you need libogg, libvorbis and libopenal

- You need:
	* CMake:
		http://www.cmake.org/cmake/resources/software.html
	* MinGW or Visual Studio
		http://www.mingw.org/
		http://msdn.microsoft.com/en-us/vstudio/default
	* Irrlicht SDK 1.7:
		http://irrlicht.sourceforge.net/downloads.html
	* Zlib headers (zlib125.zip)
		http://www.winimage.com/zLibDll/index.html
	* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
		http://www.winimage.com/zLibDll/index.html
	* SQLite3 headers and library
		https://www.sqlite.org/download.html
	* Optional: gettext library and tools:
		http://gnuwin32.sourceforge.net/downlinks/gettext.php
		- This is used for other UI languages. Feel free to leave it out.
	* And, of course, Minetest:
		http://minetest.net/download
- Steps:
	- Select a directory called DIR hereafter in which you will operate.
	- Make sure you have CMake and a compiler installed.
	- Download all the other stuff to DIR and extract them into there.
	  ("extract here", not "extract to packagename/")
	  NOTE: zlib125dll.zip needs to be extracted into zlib125dll
	  NOTE: You need to extract sqlite3.h & sqlite3ext.h from sqlite3 source
	      and sqlite3.dll & sqlite3.def from sqlite3 precompiled binaries
	      into "sqlite3" directory, and generate sqlite3.lib using command
	      "LIB /DEF:sqlite3.def /OUT:sqlite3.lib"
	- All those packages contain a nice base directory in them, which
	  should end up being the direct subdirectories of DIR.
	- You will end up with a directory structure like this (+=dir, -=file):
	-----------------
	+ DIR
		- zlib-1.2.5.tar.gz
		- zlib125dll.zip
		- irrlicht-1.8.3.zip
		- sqlite-amalgamation-3130000.zip (SQLite3 headers)
		- sqlite-dll-win32-x86-3130000.zip (SQLite3 library for 32bit system)
		- 110214175330.zip (or whatever, this is the minetest source)
		+ zlib-1.2.5
			- zlib.h
			+ win32
			...
		+ zlib125dll
			- readme.txt
			+ dll32
			...
		+ irrlicht-1.8.3
			+ lib
			+ include
			...
		+ sqlite3
			sqlite3.h
			sqlite3ext.h
			sqlite3.lib
			sqlite3.dll
		+ gettext (optional)
			+bin
			+include
			+lib
		+ minetest
			+ src
			+ doc
			- CMakeLists.txt
			...
	-----------------
	- Start up the CMake GUI
	- Select "Browse Source..." and select DIR/minetest
	- Now, if using MSVC:
		- Select "Browse Build..." and select DIR/minetest-build
	- Else if using MinGW:
		- Select "Browse Build..." and select DIR/minetest
	- Select "Configure"
	- Select your compiler
	- It will warn about missing stuff, ignore that at this point. (later don't)
	- Make sure the configuration is as follows
	  (note that the versions may differ for you):
	-----------------
	BUILD_CLIENT             [X]
	BUILD_SERVER             [ ]
	CMAKE_BUILD_TYPE         Release
	CMAKE_INSTALL_PREFIX     DIR/minetest-install
	IRRLICHT_SOURCE_DIR      DIR/irrlicht-1.8.3
	RUN_IN_PLACE             [X]
	WARN_ALL                 [ ]
	ZLIB_DLL                 DIR/zlib125dll/dll32/zlibwapi.dll
	ZLIB_INCLUDE_DIR         DIR/zlib-1.2.5
	ZLIB_LIBRARIES           DIR/zlib125dll/dll32/zlibwapi.lib
	GETTEXT_BIN_DIR          DIR/gettext/bin
	GETTEXT_INCLUDE_DIR      DIR/gettext/include
	GETTEXT_LIBRARIES        DIR/gettext/lib/intl.lib
	GETTEXT_MSGFMT           DIR/gettext/bin/msgfmt
	-----------------
	- If CMake complains it couldn't find SQLITE3, choose "Advanced" box on the
	  right top corner, then specify the location of SQLITE3_INCLUDE_DIR and
	  SQLITE3_LIBRARY manually.
	- If you want to build 64-bit minetest, you will need to build 64-bit version
	  of irrlicht engine manually, as only 32-bit pre-built library is provided.
	- Hit "Configure"
	- Hit "Configure" once again 8)
	- If something is still coloured red, you have a problem.
	- Hit "Generate"
	If using MSVC:
		- Open the generated minetest.sln
		- The project defaults to the "Debug" configuration. Make very sure to
		  select "Release", unless you want to debug some stuff (it's slower
		  and might not even work at all)
		- Build the ALL_BUILD project
		- Build the INSTALL project
		- You should now have a working game with the executable in
			DIR/minetest-install/bin/minetest.exe
		- Additionally you may create a zip package by building the PACKAGE
		  project.
	If using MinGW:
		- Using the command line, browse to the build directory and run 'make'
		  (or mingw32-make or whatever it happens to be)
		- You may need to copy some of the downloaded DLLs into bin/, see what
		  running the produced executable tells you it doesn't have.
		- You should now have a working game with the executable in
			DIR/minetest/bin/minetest.exe

Windows releases of minetest are built using a bat script like this:
--------------------------------------------------------------------

set sourcedir=%CD%
set installpath="C:\tmp\minetest_install"
set irrlichtpath="C:\tmp\irrlicht-1.7.2"

set builddir=%sourcedir%\bvc10
mkdir %builddir%
pushd %builddir%
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=TRUE -DCMAKE_INSTALL_PREFIX=%installpath%
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
popd
echo Finished.
exit /b 0

:fail
popd
echo Failed.
exit /b 1

License of Minetest textures and sounds
---------------------------------------

This applies to textures and sounds contained in the main Minetest
distribution.

Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
http://creativecommons.org/licenses/by-sa/3.0/

Authors of media files
-----------------------
Everything not listed in here:
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>

ShadowNinja:
  textures/base/pack/smoke_puff.png

Paramat:
  textures/base/pack/menu_header.png

erlehmann:
  misc/minetest-icon-24x24.png
  misc/minetest-icon.ico
  misc/minetest.svg
  textures/base/pack/logo.png

License of Minetest source code
-------------------------------

Minetest
Copyright (C) 2010-2017 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Irrlicht
---------------

This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/

 The Irrlicht Engine License

Copyright © 2002-2005 Nikolaus Gebhardt

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

   1. The origin of this software must not be misrepresented; you
      must not claim that you wrote the original software. If you use
	  this software in a product, an acknowledgment in the product
	  documentation would be appreciated but is not required.
   2. Altered source versions must be plainly marked as such, and must
      not be misrepresented as being the original software.
   3. This notice may not be removed or altered from any source
      distribution.

JThread
---------------

This program uses the JThread library. License for JThread follows:

Copyright (c) 2000-2006  Jori Liesenborgs (jori.liesenborgs@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

Lua
---------------

Lua is licensed under the terms of the MIT license reproduced below.
This means that Lua is free software and can be used for both academic
and commercial purposes at absolutely no cost.

For details and rationale, see https://www.lua.org/license.html .

Copyright (C) 1994-2008 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Fonts
---------------

Bitstream Vera Fonts Copyright:

  Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
  a trademark of Bitstream, Inc.

Arimo - Apache License, version 2.0
  Digitized data copyright (c) 2010-2012 Google Corporation.

Cousine - Apache License, version 2.0
  Digitized data copyright (c) 2010-2012 Google Corporation.

DroidSansFallBackFull:

  Copyright (C) 2008 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.