# `QuakeServer.Source`
[🔗](https://github.com/jaman/quake_server/blob/v0.1.0/lib/quake_server/source.ex#L1)

Where a server finds its game: the compiled QuakeC program, the maps and the model
files. A game names a module with these callbacks as `QuakeServer.Server.start/2`'s
`:source`.

    defmodule MyGame.Source do
      @behaviour QuakeServer.Source

      def progs, do: MyGame.Assets.progs()
      def map(name), do: MyGame.Assets.map(name)
      def model(name), do: MyGame.Assets.model(name)
    end

# `map_file`

```elixir
@type map_file() :: %{bsp: Cauldron3D.Bsp.t(), entities: String.t()}
```

A map: its world and its entity text.

# `model`

```elixir
@type model() :: %{
  kind: :alias | :sprite | :brush | :missing,
  data: term(),
  mins: Cauldron3D.Vec.t(),
  maxs: Cauldron3D.Vec.t()
}
```

A model file: `kind` `:alias`, `:sprite`, `:brush` (with `data` a `t:map_file/0`) or
`:missing`, and its box.

# `depth`
*optional* 

```elixir
@callback depth(String.t()) :: integer() | nil
```

Where game file `name` is found in the game's search order, as FTE's
`COM_FDepthFile`: lower is searched first; `nil` when there is no such file. The
console's `exec` compares `default.cfg`'s depth with a config's.

# `list`
*optional* 

```elixir
@callback list(String.t()) :: [String.t()]
```

The names of the game's files beginning with `prefix`, lower case.

# `map`

```elixir
@callback map(String.t()) :: map_file() | nil
```

The map `name` (without `maps/` or `.bsp`), or `nil` when there is none.

# `model`

```elixir
@callback model(String.t()) :: model()
```

The model file `name`.

# `package`
*optional* 

```elixir
@callback package(String.t()) :: String.t() | nil
```

The package game file `name` comes from, or `nil` when there is no such file.

# `progs`

```elixir
@callback progs() :: QuakeC.Progs.t()
```

The game's QuakeC program.

# `read`
*optional* 

```elixir
@callback read(String.t()) :: binary() | nil
```

The bytes of game file `name`, or `nil`; the files the program's file builtins read.

# `replacements`
*optional* 

```elixir
@callback replacements() :: %{
  required(String.t()) =&gt; (QuakeServer.Server.t(), non_neg_integer() -&gt;
                             QuakeServer.Server.t())
}
```

The program's functions the game runs itself, by name: each runs in place of the
QuakeC function of that name (`QuakeC.Progs.replace/2`) as `fun.(server, argc)`,
reading its arguments from the parameter slots and returning the server with any
return value in the return slots, as a builtin does. A name the program lacks is
passed over.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
