QuakeServer.Source behaviour (quake_server v0.1.0)

Copy Markdown View Source

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

Summary

Types

A map: its world and its entity text.

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

Callbacks

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.

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

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

The model file name.

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

The game's QuakeC program.

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

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.

Types

map_file()

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

A map: its world and its entity text.

model()

@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 map_file/0) or :missing, and its box.

Callbacks

depth(t)

(optional)
@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(t)

(optional)
@callback list(String.t()) :: [String.t()]

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

map(t)

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

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

model(t)

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

The model file name.

package(t)

(optional)
@callback package(String.t()) :: String.t() | nil

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

progs()

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

The game's QuakeC program.

read(t)

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

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

replacements()

(optional)
@callback replacements() :: %{
  required(String.t()) => (QuakeServer.Server.t(), non_neg_integer() ->
                             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.