From 0fceb1cf1ab9887040f08f0abf646ef318a65ae3 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Tue, 5 Aug 2008 21:37:33 +0000 Subject: added documentation --- docs/output/files2/docs/client_time-txt.html | 39 ++++++ docs/output/files2/docs/prediction-txt.html | 51 ++++++++ docs/output/files2/docs/server_op-txt.html | 69 ++++++++++ docs/output/files2/docs/snapshots-txt.html | 63 +++++++++ docs/output/files2/e_if_client-h.html | 127 +++++++++++++++++++ docs/output/files2/e_if_gfx-h.html | 139 ++++++++++++++++++++ docs/output/files2/e_if_inp-h.html | 73 +++++++++++ docs/output/files2/e_if_modc-h.html | 69 ++++++++++ docs/output/files2/e_if_mods-h.html | 71 +++++++++++ docs/output/files2/e_if_msg-h.html | 59 +++++++++ docs/output/files2/e_if_other-h.html | 89 +++++++++++++ docs/output/files2/e_if_server-h.html | 59 +++++++++ docs/output/files2/e_if_snd-h.html | 53 ++++++++ docs/output/files2/e_system-h.html | 183 +++++++++++++++++++++++++++ 14 files changed, 1144 insertions(+) create mode 100644 docs/output/files2/docs/client_time-txt.html create mode 100644 docs/output/files2/docs/prediction-txt.html create mode 100644 docs/output/files2/docs/server_op-txt.html create mode 100644 docs/output/files2/docs/snapshots-txt.html create mode 100644 docs/output/files2/e_if_client-h.html create mode 100644 docs/output/files2/e_if_gfx-h.html create mode 100644 docs/output/files2/e_if_inp-h.html create mode 100644 docs/output/files2/e_if_modc-h.html create mode 100644 docs/output/files2/e_if_mods-h.html create mode 100644 docs/output/files2/e_if_msg-h.html create mode 100644 docs/output/files2/e_if_other-h.html create mode 100644 docs/output/files2/e_if_server-h.html create mode 100644 docs/output/files2/e_if_snd-h.html create mode 100644 docs/output/files2/e_system-h.html (limited to 'docs/output/files2') diff --git a/docs/output/files2/docs/client_time-txt.html b/docs/output/files2/docs/client_time-txt.html new file mode 100644 index 00000000..ff97b67e --- /dev/null +++ b/docs/output/files2/docs/client_time-txt.html @@ -0,0 +1,39 @@ + + +Time on the client + + + + + + + + + +

Time on the client

tick, intratick predtick, predintratick

+ +
+ + + + + + + + + + + + + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/docs/prediction-txt.html b/docs/output/files2/docs/prediction-txt.html new file mode 100644 index 00000000..893064fa --- /dev/null +++ b/docs/output/files2/docs/prediction-txt.html @@ -0,0 +1,51 @@ + + +Prediction + + + + + + + + + +

Prediction

The engine calls modc_predict when reprediction is required.  This happens usally when new data has arrived from the server.  modc_predict should to prediction from the current snapshot and current snapshot tick (client_tick + 1) upto and including the tick returned by client_predtick.

Predicted input sent to the server can be retrived by calling client_get_input with the corresponding tick that you want the input for.  Here is a simple example of how it might look.

void modc_predict()
+{
+  int tick;
+  prediction_reset();
+
+  for(tick = client_tick()+1; tick <= client_predtick(); tick++)
+  {
+      MY_INPUT *input = (MY_INPUT *)client_get_input();
+      if(input)
+          prediction_apply_input(input);
+      prediction_tick();
+  }
+}
+ +
+ + + + + + + + + + +
void modc_predict()
TODO
int client_tick()
Returns the tick of the current snapshot.
int client_predtick()
Returns the current predicted tick.
int *client_get_input(int tick)
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/docs/server_op-txt.html b/docs/output/files2/docs/server_op-txt.html new file mode 100644 index 00000000..aa25fe67 --- /dev/null +++ b/docs/output/files2/docs/server_op-txt.html @@ -0,0 +1,69 @@ + + +Server Operation + + + + + + + + + +

Server Operation

Summary
Server Operation
Init
RunningHere is an graph over how the server operates on each refresh.
Reinit
Shutdown
+ +

Init

+ +

Running

Here is an graph over how the server operates on each refresh.

load map
+init mod
+
+while running
+    if map change then
+        load new map
+        shutdown mod <mods_shutdown>
+        reset clients to init state
+        init mod <mods_init>
+    end if
+
+    if new tick then
+        call <mods_tick>
+        for each client do
+            create snapshot <mods_snap>
+            send snapshot
+        end for
+    end
+
+    process new network messages
+end while
+
+unload map
+ +

Reinit

+ +

Shutdown

+ +
+ + + + + + + + + + + + + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/docs/snapshots-txt.html b/docs/output/files2/docs/snapshots-txt.html new file mode 100644 index 00000000..9654118a --- /dev/null +++ b/docs/output/files2/docs/snapshots-txt.html @@ -0,0 +1,63 @@ + + +Snapshots + + + + + + + + + +

Snapshots

Summary
Snapshots
Overview
Definitions
StructureA snapshot contains a series of items.
Server Side
CreatingItems can be added when mods_snap is called using the snap_new_item function to insert an item to the snapshot.
Client Side
Inspectionmodc_newsnapshot is called when a new snapshot has arrived for processing.
RenderingDOCTODO
In depth
CompressionAfter a snapshot have been created, compression is applyed to reduce the bandwidth.
IntervalThe interval for how often a client recives a snapshot changes during the course of the connection.
+ +

Overview

Summary
Definitions
StructureA snapshot contains a series of items.
+ +

Definitions

  • Snapshot.  A is a serialized game state from which a client can render the game from.  They are sent from the server at a regular interval and is created specificly for each client in order to reduce bandwidth.
  • Delta Snapshot.  A set of data that can be applied to a snapshot in order to create a new snapshot with the updated game state.
+ +

Structure

A snapshot contains a series of items.  Each item have a type, id and data.

  • Type.  Type of item.  Could be projectile or character for example.
  • Id.  A unique id so the client can identify the item between two snapshots.
  • Data.  A series of 32-bit integers that contains the per item type specific data.
+ +

Server Side

Summary
CreatingItems can be added when mods_snap is called using the snap_new_item function to insert an item to the snapshot.
+ +

Creating

Items can be added when mods_snap is called using the snap_new_item function to insert an item to the snapshot.  The server can not inspect the snapshot that is in progress of being created.

+ +

Client Side

Summary
Inspectionmodc_newsnapshot is called when a new snapshot has arrived for processing.
RenderingDOCTODO
+ +

Inspection

modc_newsnapshot is called when a new snapshot has arrived for processing.  snap_num_items, snap_get_item and snap_find_item can be used to inspect the current and previous snapshot.  This can be done anywhere while the client is running and not just in the modc_newsnapshot function.  The client can also call snap_invalidate_item if an item contains improper information that could harm the operation of the client.  This should however be done in modc_newsnapshot to assure that no bad data propagates into the rest of the client.

+ +

Rendering

DOCTODO

+ +

In depth

Summary
CompressionAfter a snapshot have been created, compression is applyed to reduce the bandwidth.
IntervalThe interval for how often a client recives a snapshot changes during the course of the connection.
+ +

Compression

After a snapshot have been created, compression is applyed to reduce the bandwidth.  There are several steps taken inorder to reduce the size of the size of the snapshot.

  • Delta.  The server looks in a clients backlog of snapshots to find a previous acked snapshot.  It then compares the two snapshots and creates a delta snapshot containing the changes from the previous acked snapshot to the new one.
  • Variable Integers.  The delta snapshot which is only consisting of 32-bit integers is then encoded into variable integers similar to UTF-8.  Each byte has a bit that tells the decoder that it needs one more byte to decode the 32-bit integer.  The first byte also contains a bit for telling the sign of the integer.
ESDDDDDD EDDDDDDD EDDDDDDD EDDDDDDD
E = extend
+S = sign
+D = data bit
  • Huffman.  The last step is to compress the buffer with a huffman encoder.  It uses a static tree that is weighted towards 0 because it’s where most of the data will be because of the delta compression.
+ +

Interval

The interval for how often a client recives a snapshot changes during the course of the connection.  There are three different snapshot rates.

  • Init.  5 snapshots per second.  Used when a client is connecting and used until the client has acknowlaged a snapshot.  This mechanism is used because the first snapshot because no delta compression can be done.
  • Full.  Snapshot for every tick or every even tick depending on server configuration.  This is used during normal gameplay and everything is running smooth.
  • Recovery.  1 snapshot each second.  A client enters recovery rate when it havn’t acknowlaged a snapshot over 1 second.  This is to let the client to beable to recover if it has a slow connection.
+ +
+ + + + + + + + + + +
void mods_snap(int cid)
Called to create the snapshot for a client.
void *snap_new_item(int type,
int id,
int size)
Creates a new item that should be sent.
void modc_newsnapshot()
Called when the client progressed to a new snapshot.
int snap_num_items(int snapid)
Check the number of items in a snapshot.
void *snap_get_item(int snapid,
int index,
SNAP_ITEM *item)
Gets an item from a snapshot.
void *snap_find_item(int snapid,
int type,
int id)
Searches a snapshot for an item.
void snap_invalidate_item(int snapid,
int index)
Marks an item as invalid byt setting type and id to 0xffffffff.
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_client-h.html b/docs/output/files2/e_if_client-h.html new file mode 100644 index 00000000..dae39f94 --- /dev/null +++ b/docs/output/files2/e_if_client-h.html @@ -0,0 +1,127 @@ + + +Client Interface + + + + + + + + + +

Client Interface

Summary
Client Interface
Constants
Constants
Client States
Image Formats
Texture Loading Flags
Server Browser Sorting
Structures
SERVER_INFO_PLAYER
SERVER_INFO
Functions
Time
client_tickReturns the tick of the current snapshot.
client_intratickReturns the current intratick.
client_predtickReturns the current predicted tick.
client_predintratickReturns the current preticted intra tick.
client_ticktimeTODO
client_tickspeedReturns how many ticks per second the client is doing.
client_frametimeReturns how long time the last frame took to process.
client_localtimeReturns the clients local time.
Server Browser
client_serverbrowse_refreshIssues a refresh of the server browser.
client_serverbrowse_sorted_getReturns server info from the sorted list.
client_serverbrowse_sorted_numReturns how many servers there are in the sorted list.
client_serverbrowse_getTODO
client_serverbrowse_numTODO
client_serverbrowse_num_requestsTODO
client_serverbrowse_updateTODO
client_serverbrowse_lanTODO
Actions
client_connectConnects to a server at the specified address.
client_disconnectDisconnects from the current server.
client_quitTells to client to shutdown.
client_rconSends a command to the server to execute on it’s console.
client_rcon_authTODO
client_rcon_authedTODO
Other
client_get_inputTODO
client_direct_inputTODO
client_error_stringTODO
client_connection_problemsReturns 1 if the client is connection problems.
client_stateReturns the state of the client.
client_mapdownload_amountTODO
client_mapdownload_totalsizeTODO
client_save_lineTODO
+ + + +

Constants

+ +

Client States

CLIENTSTATE_OFFLINEThe client is offline.
CLIENTSTATE_CONNECTINGThe client is trying to connect to a server.
CLIENTSTATE_LOADINGThe client has connected to a server and is loading resources.
CLIENTSTATE_ONLINEThe client is connected to a server and running the game.
CLIENTSTATE_QUITINGThe client is quiting.
+ +

Image Formats

IMG_AUTOLets the engine choose the format.
IMG_RGB8-Bit uncompressed RGB
IMG_RGBA8-Bit uncompressed RGBA
IMG_ALPHA8-Bit uncompressed alpha
+ +

Texture Loading Flags

TEXLOAD_NORESAMPLEPrevents the texture from any resampling
+ +

Server Browser Sorting

BROWSESORT_NAMESort by name.
BROWSESORT_PINGSort by ping.
BROWSESORT_MAPSort by map
BROWSESORT_GAMETYPESort by game type.  DM, TDM etc.
BROWSESORT_PROGRESSIONSort by progression.
BROWSESORT_NUMPLAYERSSort after how many players there are on the server.
+ +

Structures

+ +

SERVER_INFO_PLAYER

+ +

SERVER_INFO

+ +

Functions

Summary
Time
client_tickReturns the tick of the current snapshot.
client_intratickReturns the current intratick.
client_predtickReturns the current predicted tick.
client_predintratickReturns the current preticted intra tick.
client_ticktimeTODO
client_tickspeedReturns how many ticks per second the client is doing.
client_frametimeReturns how long time the last frame took to process.
client_localtimeReturns the clients local time.
Server Browser
client_serverbrowse_refreshIssues a refresh of the server browser.
client_serverbrowse_sorted_getReturns server info from the sorted list.
client_serverbrowse_sorted_numReturns how many servers there are in the sorted list.
client_serverbrowse_getTODO
client_serverbrowse_numTODO
client_serverbrowse_num_requestsTODO
client_serverbrowse_updateTODO
client_serverbrowse_lanTODO
Actions
client_connectConnects to a server at the specified address.
client_disconnectDisconnects from the current server.
client_quitTells to client to shutdown.
client_rconSends a command to the server to execute on it’s console.
client_rcon_authTODO
client_rcon_authedTODO
Other
client_get_inputTODO
client_direct_inputTODO
client_error_stringTODO
client_connection_problemsReturns 1 if the client is connection problems.
client_stateReturns the state of the client.
client_mapdownload_amountTODO
client_mapdownload_totalsizeTODO
client_save_lineTODO
+ +

Time

+ +

client_tick

int client_tick()

Returns the tick of the current snapshot.

+ +

client_intratick

float client_intratick()

Returns the current intratick.

Remarks

The intratick is how far gone the time is from the previous snapshot to the current.  0.0 means that it on the previous snapshot.  0.5 means that it’s halfway to the current, and 1.0 means that it is on the current snapshot.  It can go beyond 1.0 which means that the client has started to extrapolate due to lack of data from the server.

See Also

client_tick

+ +

client_predtick

int client_predtick()

Returns the current predicted tick.

+ +

client_predintratick

float client_predintratick()

Returns the current preticted intra tick.

Remarks

This is the same as client_intratick but for the current predicted tick and previous predicted tick.

See Also

client_intratick

+ +

client_ticktime

float client_ticktime()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_tickspeed

int client_tickspeed()

Returns how many ticks per second the client is doing.

Remarks

This will be the same as the server tick speed.

+ +

client_frametime

float client_frametime()

Returns how long time the last frame took to process.

+ +

client_localtime

float client_localtime()

Returns the clients local time.

Remarks

The local time is set to 0 when the client starts and when it connects to a server.  Can be used for client side effects.

+ +

Server Browser

+ +

client_serverbrowse_refresh

void client_serverbrowse_refresh(int lan)

Issues a refresh of the server browser.

Arguments

lanTells the function if it should do a LAN listing or an Internet listing.

Remarks

This will cause a broadcast on the local network if the lan argument is set.  Otherwise it call ask all the master servers for their servers lists.

+ +

client_serverbrowse_sorted_get

SERVER_INFO *client_serverbrowse_sorted_get(int index)

Returns server info from the sorted list.

Arguments

indexZero based index into the sorted list.

See Also

client_serverbrowse_sorted_num

+ +

client_serverbrowse_sorted_num

int client_serverbrowse_sorted_num()

Returns how many servers there are in the sorted list.

See Also

client_serverbrowse_sorted_get

+ +

client_serverbrowse_get

SERVER_INFO *client_serverbrowse_get(int index)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_serverbrowse_num

int client_serverbrowse_num()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_serverbrowse_num_requests

int client_serverbrowse_num_requests()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_serverbrowse_update

void client_serverbrowse_update()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_serverbrowse_lan

int client_serverbrowse_lan()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

Actions

+ +

client_connect

void client_connect(const char *address)

Connects to a server at the specified address.

Arguments

addressAddress of the server to connect to.

See Also

client_disconnect

+ +

client_disconnect

void client_disconnect()

Disconnects from the current server.

Remarks

Does nothing if not connected to a server.

See Also

<client_connect, client_quit>

+ +

client_quit

void client_quit()

Tells to client to shutdown.

See Also

client_disconnect

+ +

client_rcon

void client_rcon(const char *cmd)

Sends a command to the server to execute on it’s console.

Arguments

cmdThe command to send.

Remarks

The client must have the correct rcon password to connect.

See Also

<client_rcon_auth, client_rcon_authed>

+ +

client_rcon_auth

void client_rcon_auth(const char *name,
const char *password)

TODO

Arguments

arg1desc

Returns

See Also

<client_rcon, client_rcon_authed>

+ +

client_rcon_authed

int client_rcon_authed()

TODO

Arguments

arg1desc

Returns

See Also

<client_rcon, client_rcon_auth>

+ +

Other

+ +

client_get_input

int *client_get_input(int tick)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_direct_input

void client_direct_input(int *input,
int size)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_error_string

const char *client_error_string()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_connection_problems

int client_connection_problems()

Returns 1 if the client is connection problems.

Remarks

Connections problems usually means that the client havn’t recvived any data from the server in a while.

+ +

client_state

int client_state()

Returns the state of the client.

See Also

Client States

+ +

client_mapdownload_amount

int client_mapdownload_amount()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_mapdownload_totalsize

int client_mapdownload_totalsize()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_save_line

void client_save_line(const char *line)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
int client_tick()
Returns the tick of the current snapshot.
float client_intratick()
Returns the current intratick.
int client_predtick()
Returns the current predicted tick.
float client_predintratick()
Returns the current preticted intra tick.
float client_ticktime()
TODO
int client_tickspeed()
Returns how many ticks per second the client is doing.
float client_frametime()
Returns how long time the last frame took to process.
float client_localtime()
Returns the clients local time.
void client_serverbrowse_refresh(int lan)
Issues a refresh of the server browser.
SERVER_INFO *client_serverbrowse_sorted_get(int index)
Returns server info from the sorted list.
int client_serverbrowse_sorted_num()
Returns how many servers there are in the sorted list.
SERVER_INFO *client_serverbrowse_get(int index)
TODO
int client_serverbrowse_num()
TODO
int client_serverbrowse_num_requests()
TODO
void client_serverbrowse_update()
TODO
int client_serverbrowse_lan()
TODO
void client_connect(const char *address)
Connects to a server at the specified address.
void client_disconnect()
Disconnects from the current server.
void client_quit()
Tells to client to shutdown.
void client_rcon(const char *cmd)
Sends a command to the server to execute on it’s console.
void client_rcon_auth(const char *name,
const char *password)
TODO
int client_rcon_authed()
TODO
int *client_get_input(int tick)
TODO
void client_direct_input(int *input,
int size)
TODO
const char *client_error_string()
TODO
int client_connection_problems()
Returns 1 if the client is connection problems.
int client_state()
Returns the state of the client.
int client_mapdownload_amount()
TODO
int client_mapdownload_totalsize()
TODO
void client_save_line(const char *line)
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_gfx-h.html b/docs/output/files2/e_if_gfx-h.html new file mode 100644 index 00000000..70842f57 --- /dev/null +++ b/docs/output/files2/e_if_gfx-h.html @@ -0,0 +1,139 @@ + + +Graphics + + + + + + + + + +

Graphics

Summary
Graphics
Structures
IMAGE_INFO
Variables
widthContains the width of the image
heightContains the height of the image
formatContains the format of the image.
dataPointer to the image data.
VIDEO_MODE
Functions
Quads
gfx_quads_beginBegins a quad drawing session.
gfx_quads_endEnds a quad session.
gfx_quads_setrotationSets the rotation to use when drawing a quad.
gfx_quads_setsubsetSets the uv coordinates to use.
gfx_quads_setsubset_freeTODO
gfx_quads_drawTLDraws a quad by specifying the top-left point.
gfx_quads_drawDraws a quad by specifying the center point.
gfx_quads_draw_freeformDraws a quad by specifying the corner points.
gfx_quads_textTODO
Lines
gfx_lines_beginTODO
gfx_lines_drawTODO
gfx_lines_endTODO
Text
gfx_textTODO
gfx_text_widthTODO
gfx_text_colorTODO
gfx_text_set_default_fontTODO
Other
gfx_get_video_modesFetches a list of all the available video modes.
gfx_load_pngLoads a PNG image from disk.
gfx_load_textureLoads a texture from a file.
gfx_load_texture_rawLoads a texture from memory.
gfx_texture_setSets the active texture.
gfx_unload_textureUnloads a texture.
gfx_clearClears the screen with the specified color.
gfx_screenaspectReturns the aspect ratio between width and height.
gfx_screenwidthReturns the screen width.
gfx_screenheightReturns the screen height.
gfx_mapscreenSpecifies the coordinate system for the screen.
gfx_blend_normalSet the active blending mode to normal (src, 1-src).
gfx_blend_additiveSet the active blending mode to additive (src, one).
gfx_blend_noneDisables blending
gfx_setcolorvertexSets the color of a vertex.
gfx_setcolorSets the color of all the vertices.
gfx_getscreenTODO
gfx_memory_usageTODO
gfx_screenshotTODO
gfx_clip_enableTODO
gfx_clip_disableTODO
+ +

Structures

+ +

IMAGE_INFO

Summary
Variables
widthContains the width of the image
heightContains the height of the image
formatContains the format of the image.
dataPointer to the image data.
+ +

Variables

+ +

width

int width

Contains the width of the image

+ +

height

int height

Contains the height of the image

+ +

format

int format

Contains the format of the image.  See Image Formats for more information.

+ +

data

void *data

Pointer to the image data.

+ +

VIDEO_MODE

+ +

Functions

Summary
Quads
gfx_quads_beginBegins a quad drawing session.
gfx_quads_endEnds a quad session.
gfx_quads_setrotationSets the rotation to use when drawing a quad.
gfx_quads_setsubsetSets the uv coordinates to use.
gfx_quads_setsubset_freeTODO
gfx_quads_drawTLDraws a quad by specifying the top-left point.
gfx_quads_drawDraws a quad by specifying the center point.
gfx_quads_draw_freeformDraws a quad by specifying the corner points.
gfx_quads_textTODO
Lines
gfx_lines_beginTODO
gfx_lines_drawTODO
gfx_lines_endTODO
Text
gfx_textTODO
gfx_text_widthTODO
gfx_text_colorTODO
gfx_text_set_default_fontTODO
Other
gfx_get_video_modesFetches a list of all the available video modes.
gfx_load_pngLoads a PNG image from disk.
gfx_load_textureLoads a texture from a file.
gfx_load_texture_rawLoads a texture from memory.
gfx_texture_setSets the active texture.
gfx_unload_textureUnloads a texture.
gfx_clearClears the screen with the specified color.
gfx_screenaspectReturns the aspect ratio between width and height.
gfx_screenwidthReturns the screen width.
gfx_screenheightReturns the screen height.
gfx_mapscreenSpecifies the coordinate system for the screen.
gfx_blend_normalSet the active blending mode to normal (src, 1-src).
gfx_blend_additiveSet the active blending mode to additive (src, one).
gfx_blend_noneDisables blending
gfx_setcolorvertexSets the color of a vertex.
gfx_setcolorSets the color of all the vertices.
gfx_getscreenTODO
gfx_memory_usageTODO
gfx_screenshotTODO
gfx_clip_enableTODO
gfx_clip_disableTODO
+ +

Quads

+ +

gfx_quads_begin

void gfx_quads_begin()

Begins a quad drawing session.

Remarks

This functions resets the rotation, color and subset.  End the session by using gfx_quads_end.  You can’t change texture or blending mode during a session.

See Also

gfx_quads_end

+ +

gfx_quads_end

void gfx_quads_end()

Ends a quad session.

See Also

gfx_quads_begin

+ +

gfx_quads_setrotation

void gfx_quads_setrotation(float angle)

Sets the rotation to use when drawing a quad.

Arguments

angleAngle in radians.

Remarks

The angle is reset when gfx_quads_begin is called.

+ +

gfx_quads_setsubset

void gfx_quads_setsubset(float tl_u,
float tl_v,
float br_u,
float br_v)

Sets the uv coordinates to use.

Arguments

tl_uTop-left U value.
tl_vTop-left V value.
br_uBottom-right U value.
br_vBottom-right V value.

Remarks

O,0 is top-left of the texture and 1,1 is bottom-right.  The color is reset when gfx_quads_begin is called.

+ +

gfx_quads_setsubset_free

void gfx_quads_setsubset_free(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_quads_drawTL

void gfx_quads_drawTL(float x,
float y,
float width,
float height)

Draws a quad by specifying the top-left point.

Arguments

xX coordinate of the top-left corner.
yY coordinate of the top-left corner.
widthWidth of the quad.
heightHeight of the quad.

Remarks

Rotation still occurs from the center of the quad.  You must call gfx_quads_begin before calling this function.

See Also

<gfx_quads_draw, gfx_quads_draw_freeform>

+ +

gfx_quads_draw

void gfx_quads_draw(float x,
float y,
float w,
float h)

Draws a quad by specifying the center point.

Arguments

xX coordinate of the center.
yY coordinate of the center.
widthWidth of the quad.
heightHeight of the quad.

Remarks

You must call gfx_quads_begin before calling this function.

See Also

<gfx_quads_drawTL, gfx_quads_draw_freeform>

+ +

gfx_quads_draw_freeform

void gfx_quads_draw_freeform(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)

Draws a quad by specifying the corner points.

Arguments

x0, y0Coordinates of the upper left corner.
x1, y1Coordinates of the upper right corner.
x2, y2Coordinates of the lower left corner.  // TODO: DOUBLE CHECK!!!
x3, y3Coordinates of the lower right corner.  // TODO: DOUBLE CHECK!!!

See Also

<gfx_quads_draw, gfx_quads_drawTL>

+ +

gfx_quads_text

void gfx_quads_text(float x,
float y,
float size,
const char *text)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

Lines

+ +

gfx_lines_begin

void gfx_lines_begin()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_lines_draw

void gfx_lines_draw(float x0,
float y0,
float x1,
float y1)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_lines_end

void gfx_lines_end()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

Text

+ +

gfx_text

void gfx_text(void *font,
float x,
float y,
float size,
const char *text,
int max_width)

TODO

Arguments

arg1desc

Returns

returns the number of lines written See Also: <other_func>

+ +

gfx_text_width

float gfx_text_width(void *font,
float size,
const char *text,
int length)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_text_color

void gfx_text_color(float r,
float g,
float b,
float a)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_text_set_default_font

void gfx_text_set_default_font(void *font)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

Other

+ +

gfx_get_video_modes

int gfx_get_video_modes(VIDEO_MODE *list,
int maxcount)

Fetches a list of all the available video modes.

Arguments

listAn array to recive the modes.  Must be able to contain maxcount number of modes.
maxcountThe maximum number of modes to fetch.

Returns

The number of video modes that was fetched.

+ +

gfx_load_png

int gfx_load_png(IMAGE_INFO *img,
const char *filename)

Loads a PNG image from disk.

Arguments

imgPointer to an structure to be filled out with the image information.
filenameFilename of the image to load.

Returns

Returns non-zero on success and zero on error.

Remarks

The caller are responsible for cleaning up the allocated memory in the IMAGE_INFO structure.

See Also

gfx_load_texture

+ +

gfx_load_texture

int gfx_load_texture(const char *filename,
int store_format,
int flags)

Loads a texture from a file.  TGA and PNG supported.

Arguments

filenameNull terminated string to the file to load.
store_formatWhat format to store on gfx card as.
flagscontrols how the texture is uploaded

Returns

An ID to the texture.  -1 on failure.

See Also

<gfx_unload_texture, gfx_load_png>

+ +

gfx_load_texture_raw

int gfx_load_texture_raw(int w,
int h,
int format,
const void *data,
int store_format,
int flags)

Loads a texture from memory.

Arguments

wWidth of the texture.
hHeight of the texture.
dataPointer to the pixel data.
formatFormat of the pixel data.
store_formatThe format to store the texture on the graphics card.
flagscontrols how the texture is uploaded

Returns

An ID to the texture.  -1 on failure.

Remarks

The pixel data should be in RGBA format with 8 bit per component.  So the total size of the data should be w*h*4.

See Also

gfx_unload_texture

+ +

gfx_texture_set

void gfx_texture_set(int id)

Sets the active texture.

Arguments

idID to the texture to set.
+ +

gfx_unload_texture

int gfx_unload_texture(int id)

Unloads a texture.

Arguments

idID to the texture to unload.

See Also

<gfx_load_texture_tga>, gfx_load_texture_raw

Remarks

NOT IMPLEMENTED

+ +

gfx_clear

void gfx_clear(float r,
float g,
float b)

Clears the screen with the specified color.

Arguments

rRed component.
gGreen component.
bRed component.

Remarks

The value of the components are given in 0.01.0 ranges.
+ +

gfx_screenaspect

float gfx_screenaspect()

Returns the aspect ratio between width and height.

See Also

gfx_screenwidth, gfx_screenheight

+ +

gfx_screenwidth

int gfx_screenwidth()

Returns the screen width.

See Also

gfx_screenheight

+ +

gfx_screenheight

int gfx_screenheight()

Returns the screen height.

See Also

gfx_screenwidth

+ +

gfx_mapscreen

void gfx_mapscreen(float tl_x,
float tl_y,
float br_x,
float br_y)

Specifies the coordinate system for the screen.

Arguments

tl_xTop-left X
tl_yTop-left Y
br_xBottom-right X
br_yBottom-right y
+ +

gfx_blend_normal

void gfx_blend_normal()

Set the active blending mode to normal (src, 1-src).

Remarks

This must be used before calling gfx_quads_begin.  This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).

See Also

<gfx_blend_additive,gfx_blend_none>

+ +

gfx_blend_additive

void gfx_blend_additive()

Set the active blending mode to additive (src, one).

Remarks

This must be used before calling gfx_quads_begin.  This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE).

See Also

<gfx_blend_normal,gfx_blend_none>

+ +

gfx_blend_none

void gfx_blend_none()

Disables blending

Remarks

This must be used before calling gfx_quads_begin.

See Also

<gfx_blend_normal,gfx_blend_additive>

+ +

gfx_setcolorvertex

void gfx_setcolorvertex(int i,
float r,
float g,
float b,
float a)

Sets the color of a vertex.

Arguments

iIndex to the vertex.
rRed value.
gGreen value.
bBlue value.
aAlpha value.

Remarks

The color values are from 0.0 to 1.0.  The color is reset when gfx_quads_begin is called.

+ +

gfx_setcolor

void gfx_setcolor(float r,
float g,
float b,
float a)

Sets the color of all the vertices.

Arguments

rRed value.
gGreen value.
bBlue value.
aAlpha value.

Remarks

The color values are from 0.0 to 1.0.  The color is reset when gfx_quads_begin is called.

+ +

gfx_getscreen

void gfx_getscreen(float *tl_x,
float *tl_y,
float *br_x,
float *br_y)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_memory_usage

int gfx_memory_usage()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_screenshot

void gfx_screenshot()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_clip_enable

void gfx_clip_enable(int x,
int y,
int w,
int h)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

gfx_clip_disable

void gfx_clip_disable()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
int width
Contains the width of the image
int height
Contains the height of the image
int format
Contains the format of the image.
void *data
Pointer to the image data.
void gfx_quads_begin()
Begins a quad drawing session.
void gfx_quads_end()
Ends a quad session.
void gfx_quads_setrotation(float angle)
Sets the rotation to use when drawing a quad.
void gfx_quads_setsubset(float tl_u,
float tl_v,
float br_u,
float br_v)
Sets the uv coordinates to use.
void gfx_quads_setsubset_free(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
TODO
void gfx_quads_drawTL(float x,
float y,
float width,
float height)
Draws a quad by specifying the top-left point.
void gfx_quads_draw(float x,
float y,
float w,
float h)
Draws a quad by specifying the center point.
void gfx_quads_draw_freeform(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Draws a quad by specifying the corner points.
void gfx_quads_text(float x,
float y,
float size,
const char *text)
TODO
void gfx_lines_begin()
TODO
void gfx_lines_draw(float x0,
float y0,
float x1,
float y1)
TODO
void gfx_lines_end()
TODO
void gfx_text(void *font,
float x,
float y,
float size,
const char *text,
int max_width)
TODO
float gfx_text_width(void *font,
float size,
const char *text,
int length)
TODO
void gfx_text_color(float r,
float g,
float b,
float a)
TODO
void gfx_text_set_default_font(void *font)
TODO
int gfx_get_video_modes(VIDEO_MODE *list,
int maxcount)
Fetches a list of all the available video modes.
int gfx_load_png(IMAGE_INFO *img,
const char *filename)
Loads a PNG image from disk.
int gfx_load_texture(const char *filename,
int store_format,
int flags)
Loads a texture from a file.
int gfx_load_texture_raw(int w,
int h,
int format,
const void *data,
int store_format,
int flags)
Loads a texture from memory.
void gfx_texture_set(int id)
Sets the active texture.
int gfx_unload_texture(int id)
Unloads a texture.
void gfx_clear(float r,
float g,
float b)
Clears the screen with the specified color.
float gfx_screenaspect()
Returns the aspect ratio between width and height.
int gfx_screenwidth()
Returns the screen width.
int gfx_screenheight()
Returns the screen height.
void gfx_mapscreen(float tl_x,
float tl_y,
float br_x,
float br_y)
Specifies the coordinate system for the screen.
void gfx_blend_normal()
Set the active blending mode to normal (src, 1-src).
void gfx_blend_additive()
Set the active blending mode to additive (src, one).
void gfx_blend_none()
Disables blending
void gfx_setcolorvertex(int i,
float r,
float g,
float b,
float a)
Sets the color of a vertex.
void gfx_setcolor(float r,
float g,
float b,
float a)
Sets the color of all the vertices.
void gfx_getscreen(float *tl_x,
float *tl_y,
float *br_x,
float *br_y)
TODO
int gfx_memory_usage()
TODO
void gfx_screenshot()
TODO
void gfx_clip_enable(int x,
int y,
int w,
int h)
TODO
void gfx_clip_disable()
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_inp-h.html b/docs/output/files2/e_if_inp-h.html new file mode 100644 index 00000000..91ac5b99 --- /dev/null +++ b/docs/output/files2/e_if_inp-h.html @@ -0,0 +1,73 @@ + + +Input + + + + + + + + + +
+ + + +

Functions

+ +

inp_mouse_relative

void inp_mouse_relative(int *x,
int *y)

Fetches the mouse movements.

Arguments

xPointer to the variable that should get the X movement.
yPointer to the variable that should get the Y movement.
+ +

inp_mouse_scroll

int inp_mouse_scroll()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_pressed

int inp_key_pressed(int key)

Checks if a key is pressed.

Arguments

keyIndex to the key to check

Returns

Returns 1 if the button is pressed, otherwise 0.

Remarks

Check keys.h for the keys.

+ +

inp_key_was_pressed

int inp_key_was_pressed(int key)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_down

int inp_key_down(int key)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_num_events

int inp_num_events()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_get_event

INPUT_EVENT inp_get_event(int index)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_clear_events

void inp_clear_events()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_mouse_doubleclick

int inp_mouse_doubleclick()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_presses

int inp_key_presses(int key)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_releases

int inp_key_releases(int key)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_state

int inp_key_state(int key)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_name

const char *inp_key_name(int k)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_key_code

int inp_key_code(const char *key_name)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

inp_clear_key_states

void inp_clear_key_states()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
void inp_mouse_relative(int *x,
int *y)
Fetches the mouse movements.
int inp_mouse_scroll()
TODO
int inp_key_pressed(int key)
Checks if a key is pressed.
int inp_key_was_pressed(int key)
TODO
int inp_key_down(int key)
TODO
int inp_num_events()
TODO
INPUT_EVENT inp_get_event(int index)
TODO
void inp_clear_events()
TODO
int inp_mouse_doubleclick()
TODO
int inp_key_presses(int key)
TODO
int inp_key_releases(int key)
TODO
int inp_key_state(int key)
TODO
const char *inp_key_name(int k)
TODO
int inp_key_code(const char *key_name)
TODO
void inp_clear_key_states()
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_modc-h.html b/docs/output/files2/e_if_modc-h.html new file mode 100644 index 00000000..f75e3aee --- /dev/null +++ b/docs/output/files2/e_if_modc-h.html @@ -0,0 +1,69 @@ + + +Client Hooks + + + + + + + + + +

Client Hooks

Summary
Client Hooks
Functions
modc_console_initTODO
modc_rcon_lineTODO
modc_save_configTODO
modc_initCalled when the client starts.
modc_newsnapshotCalled when the client progressed to a new snapshot.
modc_entergameCalled when the client has successfully connect to a server and loaded a map.
modc_shutdownCalled when the client closes down.
modc_renderCalled every frame to let the game render it self.
modc_statechangeCalled every time client changes state.
modc_connectedTODO
modc_messageTODO
modc_predictTODO
modc_snap_inputTODO
modc_net_versionTODO
+ +

Functions

+ +

modc_console_init

void modc_console_init()

TODO

+ +

modc_rcon_line

void modc_rcon_line(const char *line)

TODO

+ +

modc_save_config

void modc_save_config()

TODO

+ +

modc_init

void modc_init()

Called when the client starts.

Remarks

The game should load resources that are used during the entire time of the game.  No map is loaded.

+ +

modc_newsnapshot

void modc_newsnapshot()

Called when the client progressed to a new snapshot.

Remarks

The client can check for items in the snapshot and perform one time events like playing sounds, spawning client side effects etc.

+ +

modc_entergame

void modc_entergame()

Called when the client has successfully connect to a server and loaded a map.

Remarks

The client can check for items in the map and load them.

+ +

modc_shutdown

void modc_shutdown()

Called when the client closes down.

+ +

modc_render

void modc_render()

Called every frame to let the game render it self.

+ +

modc_statechange

void modc_statechange(int new_state,
int old_state)

Called every time client changes state.

+ +

modc_connected

void modc_connected()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

modc_message

void modc_message(int msg)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

modc_predict

void modc_predict()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

modc_snap_input

int modc_snap_input(int *data)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

modc_net_version

const char *modc_net_version()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
void modc_console_init()
TODO
void modc_rcon_line(const char *line)
TODO
void modc_save_config()
TODO
void modc_init()
Called when the client starts.
void modc_newsnapshot()
Called when the client progressed to a new snapshot.
void modc_entergame()
Called when the client has successfully connect to a server and loaded a map.
void modc_shutdown()
Called when the client closes down.
void modc_render()
Called every frame to let the game render it self.
void modc_statechange(int new_state,
int old_state)
Called every time client changes state.
void modc_connected()
TODO
void modc_message(int msg)
TODO
void modc_predict()
TODO
int modc_snap_input(int *data)
TODO
const char *modc_net_version()
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_mods-h.html b/docs/output/files2/e_if_mods-h.html new file mode 100644 index 00000000..3929a2d8 --- /dev/null +++ b/docs/output/files2/e_if_mods-h.html @@ -0,0 +1,71 @@ + + +Server Hooks + + + + + + + + + +

Server Hooks

Summary
Server Hooks
Functions
mods_console_initTODO
mods_initCalled when the server is started.
mods_shutdownCalled when the server quits.
mods_client_enterCalled when a client has joined the game.
mods_client_dropCalled when a client drops from the server.
mods_client_direct_inputCalled when the server recives new input from a client.
mods_client_predicted_inputCalled when the server applys the predicted input on the client.
mods_tickCalled with a regular interval to progress the gameplay.
mods_presnapCalled before the server starts to construct snapshots for the clients.
mods_snapCalled to create the snapshot for a client.
mods_postsnapCalled after the server is done sending the snapshots.
mods_connectedTODO
mods_net_versionTODO
mods_versionTODO
mods_messageTODO
+ +

Functions

+ +

mods_console_init

void mods_console_init()

TODO

+ +

mods_init

void mods_init()

Called when the server is started.

Remarks

It’s called after the map is loaded so all map items are available.

+ +

mods_shutdown

void mods_shutdown()

Called when the server quits.

Remarks

Should be used to clean up all resources used.

+ +

mods_client_enter

void mods_client_enter(int cid)

Called when a client has joined the game.

Arguments

cidClient ID.  Is 0 - MAX_CLIENTS.

Remarks

It’s called when the client is finished loading and should enter gameplay.

+ +

mods_client_drop

void mods_client_drop(int cid)

Called when a client drops from the server.

Arguments

cidClient ID.  Is 0 - MAX_CLIENTS
+ +

mods_client_direct_input

void mods_client_direct_input(int cid,
void *input)

Called when the server recives new input from a client.

Arguments

cidClient ID.  Is 0 - MAX_CLIENTS.
inputPointer to the input data.
sizeSize of the data.  (NOT IMPLEMENTED YET)
+ +

mods_client_predicted_input

void mods_client_predicted_input(int cid,
void *input)

Called when the server applys the predicted input on the client.

Arguments

cidClient ID.  Is 0 - MAX_CLIENTS.
inputPointer to the input data.
sizeSize of the data.  (NOT IMPLEMENTED YET)
+ +

mods_tick

void mods_tick()

Called with a regular interval to progress the gameplay.

Remarks

The SERVER_TICK_SPEED tells the number of ticks per second.

+ +

mods_presnap

void mods_presnap()

Called before the server starts to construct snapshots for the clients.

+ +

mods_snap

void mods_snap(int cid)

Called to create the snapshot for a client.

Arguments

cidClient ID.  Is 0 - MAX_CLIENTS.

Remarks

The game should make a series of calls to snap_new_item to construct the snapshot for the client.

+ +

mods_postsnap

void mods_postsnap()

Called after the server is done sending the snapshots.

+ +

mods_connected

void mods_connected(int client_id)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

mods_net_version

const char *mods_net_version()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

mods_version

const char *mods_version()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

mods_message

void mods_message(int msg,
int client_id)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
void mods_console_init()
TODO
void mods_init()
Called when the server is started.
void mods_shutdown()
Called when the server quits.
void mods_client_enter(int cid)
Called when a client has joined the game.
void mods_client_drop(int cid)
Called when a client drops from the server.
void mods_client_direct_input(int cid,
void *input)
Called when the server recives new input from a client.
void mods_client_predicted_input(int cid,
void *input)
Called when the server applys the predicted input on the client.
void mods_tick()
Called with a regular interval to progress the gameplay.
void mods_presnap()
Called before the server starts to construct snapshots for the clients.
void mods_snap(int cid)
Called to create the snapshot for a client.
void mods_postsnap()
Called after the server is done sending the snapshots.
void mods_connected(int client_id)
TODO
const char *mods_net_version()
TODO
const char *mods_version()
TODO
void mods_message(int msg,
int client_id)
TODO
void *snap_new_item(int type,
int id,
int size)
Creates a new item that should be sent.
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_msg-h.html b/docs/output/files2/e_if_msg-h.html new file mode 100644 index 00000000..f46cc24e --- /dev/null +++ b/docs/output/files2/e_if_msg-h.html @@ -0,0 +1,59 @@ + + +Messaging + + + + + + + + + +
+ +

Functions

+ +

msg_pack_start

void msg_pack_start(int msg,
int flags)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_pack_int

void msg_pack_int(int i)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_pack_string

void msg_pack_string(const char *p,
int limit)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_pack_raw

void msg_pack_raw(const void *data,
int size)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_pack_end

void msg_pack_end()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_unpack_int

int msg_unpack_int()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_unpack_string

const char *msg_unpack_string()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_unpack_raw

const unsigned char *msg_unpack_raw(int size)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

msg_unpack_error

int msg_unpack_error()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
void msg_pack_start(int msg,
int flags)
TODO
void msg_pack_int(int i)
TODO
void msg_pack_string(const char *p,
int limit)
TODO
void msg_pack_raw(const void *data,
int size)
TODO
void msg_pack_end()
TODO
int msg_unpack_int()
TODO
const char *msg_unpack_string()
TODO
const unsigned char *msg_unpack_raw(int size)
TODO
int msg_unpack_error()
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_other-h.html b/docs/output/files2/e_if_other-h.html new file mode 100644 index 00000000..23d4a2c0 --- /dev/null +++ b/docs/output/files2/e_if_other-h.html @@ -0,0 +1,89 @@ + + +Engine Interface + + + + + + + + + +

Engine Interface

Summary
Engine Interface
SNAP_ITEM
CLIENT_INFO
Map
Functions
map_is_loadedChecks if a map is loaded.
map_num_itemsChecks the number of items in the loaded map.
map_find_itemSearches the map for an item.
map_get_itemGets an item from the loaded map from index.
map_get_typeGets the index range of an item type.
map_get_dataFetches a pointer to a raw data chunk in the map.
map_get_data_swappedTODO
Network (Server)
Functions
snap_new_itemCreates a new item that should be sent.
snap_num_itemsCheck the number of items in a snapshot.
snap_get_itemGets an item from a snapshot.
snap_find_itemSearches a snapshot for an item.
snap_invalidate_itemMarks an item as invalid byt setting type and id to 0xffffffff.
snap_inputSets the input data to send to the server.
snap_set_staticsizeTells the engine how big a specific item always will be.
server_send_msgTODO
client_send_msgTODO
snap_new_idTODO
snap_free_idTODO
map_unload_dataTODO
+ +

SNAP_ITEM

+ +

CLIENT_INFO

+ +

Map

Summary
Functions
map_is_loadedChecks if a map is loaded.
map_num_itemsChecks the number of items in the loaded map.
map_find_itemSearches the map for an item.
map_get_itemGets an item from the loaded map from index.
map_get_typeGets the index range of an item type.
map_get_dataFetches a pointer to a raw data chunk in the map.
map_get_data_swappedTODO
+ +

Functions

+ +

map_is_loaded

int map_is_loaded()

Checks if a map is loaded.

Returns

Returns 1 if the button is pressed, otherwise 0.

+ +

map_num_items

int map_num_items()

Checks the number of items in the loaded map.

Returns

Returns the number of items.  0 if no map is loaded.

+ +

map_find_item

void *map_find_item(int type,
int id)

Searches the map for an item.

Arguments

typeItem type.
idItem ID.

Returns

Returns a pointer to the item if it exists, otherwise it returns NULL.

+ +

map_get_item

void *map_get_item(int index,
int *type,
int *id)

Gets an item from the loaded map from index.

Arguments

indexItem index.
typePointer that recives the item type (can be NULL).
idPointer that recives the item id (can be NULL).

Returns

Returns a pointer to the item if it exists, otherwise it returns NULL.

+ +

map_get_type

void map_get_type(int type,
int *start,
int *num)

Gets the index range of an item type.

Arguments

typeItem type to search for.
startPointer that recives the starting index.
numPointer that recives the number of items.

Returns

If the item type is not in the map, start and num will be set to 0.

+ +

map_get_data

void *map_get_data(int index)

Fetches a pointer to a raw data chunk in the map.

Arguments

indexIndex to the data to fetch.

Returns

A pointer to the raw data, otherwise 0.

+ +

map_get_data_swapped

void *map_get_data_swapped(int index)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

Network (Server)

Summary
Functions
snap_new_itemCreates a new item that should be sent.
snap_num_itemsCheck the number of items in a snapshot.
snap_get_itemGets an item from a snapshot.
snap_find_itemSearches a snapshot for an item.
snap_invalidate_itemMarks an item as invalid byt setting type and id to 0xffffffff.
snap_inputSets the input data to send to the server.
snap_set_staticsizeTells the engine how big a specific item always will be.
server_send_msgTODO
client_send_msgTODO
snap_new_idTODO
snap_free_idTODO
map_unload_dataTODO
+ +

Functions

+ +

snap_new_item

void *snap_new_item(int type,
int id,
int size)

Creates a new item that should be sent.

Arguments

typeType of the item.
idID of the item.
sizeSize of the item.

Returns

A pointer to the item data, otherwise 0.

Remarks

The item data should only consist pf 4 byte integers as they are subject to byte swapping.  This means that the size argument should be dividable by 4.

+ +

snap_num_items

int snap_num_items(int snapid)

Check the number of items in a snapshot.

Arguments

snapidSnapshot ID to the data to fetch.
  • SNAP_PREV for previous snapshot.
  • SNAP_CUR for current snapshot.

Returns

The number of items in the snapshot.

+ +

snap_get_item

void *snap_get_item(int snapid,
int index,
SNAP_ITEM *item)

Gets an item from a snapshot.

Arguments

snapidSnapshot ID to the data to fetch.
  • SNAP_PREV for previous snapshot.
  • SNAP_CUR for current snapshot.
indexIndex of the item.
itemPointer that recives the item info.

Returns

Returns a pointer to the item if it exists, otherwise NULL.

+ +

snap_find_item

void *snap_find_item(int snapid,
int type,
int id)

Searches a snapshot for an item.

Arguments

snapidSnapshot ID to the data to fetch.
  • SNAP_PREV for previous snapshot.
  • SNAP_CUR for current snapshot.
typeType of the item.
idID of the item.

Returns

Returns a pointer to the item if it exists, otherwise NULL.

+ +

snap_invalidate_item

void snap_invalidate_item(int snapid,
int index)

Marks an item as invalid byt setting type and id to 0xffffffff.

Arguments

snapidSnapshot ID to the data to fetch.
  • SNAP_PREV for previous snapshot.
  • SNAP_CUR for current snapshot.
indexIndex of the item.
+ +

snap_input

void snap_input(void *data,
int size)

Sets the input data to send to the server.

Arguments

dataPointer to the data.
sizeSize of the data.

Remarks

The data should only consist of 4 bytes integer as they are subject to byte swapping.

+ +

snap_set_staticsize

void snap_set_staticsize(int type,
int size)

Tells the engine how big a specific item always will be.  This helps the engine to compress snapshots better.

Arguments

typeItem type
sizeSize of the data.

Remarks

Size must be in a multiple of 4.

+ +

server_send_msg

int server_send_msg(int client_id)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

client_send_msg

int client_send_msg()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

snap_new_id

int snap_new_id()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

snap_free_id

void snap_free_id(int id)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

map_unload_data

void map_unload_data(int index)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
int map_is_loaded()
Checks if a map is loaded.
int map_num_items()
Checks the number of items in the loaded map.
void *map_find_item(int type,
int id)
Searches the map for an item.
void *map_get_item(int index,
int *type,
int *id)
Gets an item from the loaded map from index.
void map_get_type(int type,
int *start,
int *num)
Gets the index range of an item type.
void *map_get_data(int index)
Fetches a pointer to a raw data chunk in the map.
void *map_get_data_swapped(int index)
TODO
void *snap_new_item(int type,
int id,
int size)
Creates a new item that should be sent.
int snap_num_items(int snapid)
Check the number of items in a snapshot.
void *snap_get_item(int snapid,
int index,
SNAP_ITEM *item)
Gets an item from a snapshot.
void *snap_find_item(int snapid,
int type,
int id)
Searches a snapshot for an item.
void snap_invalidate_item(int snapid,
int index)
Marks an item as invalid byt setting type and id to 0xffffffff.
void snap_input(void *data,
int size)
Sets the input data to send to the server.
void snap_set_staticsize(int type,
int size)
Tells the engine how big a specific item always will be.
int server_send_msg(int client_id)
TODO
int client_send_msg()
TODO
int snap_new_id()
TODO
void snap_free_id(int id)
TODO
void map_unload_data(int index)
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_server-h.html b/docs/output/files2/e_if_server-h.html new file mode 100644 index 00000000..b4fa723b --- /dev/null +++ b/docs/output/files2/e_if_server-h.html @@ -0,0 +1,59 @@ + + +Server Interface + + + + + + + + + +
+ +

Functions

+ +

server_getclientinfo

int server_getclientinfo(int client_id,
CLIENT_INFO *info)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_clientname

const char *server_clientname(int client_id)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_latestinput

int *server_latestinput(int client_id,
int *size)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_setclientname

void server_setclientname(int client_id,
const char *name)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_setclientscore

void server_setclientscore(int client_id,
int score)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_setbrowseinfo

void server_setbrowseinfo(int game_type,
int progression)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_kick

void server_kick(int client_id,
const char *reason)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_tick

int server_tick()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +

server_tickspeed

int server_tickspeed()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

+ +
+ + + + + + + + + + +
int server_getclientinfo(int client_id,
CLIENT_INFO *info)
TODO
const char *server_clientname(int client_id)
TODO
int *server_latestinput(int client_id,
int *size)
TODO
void server_setclientname(int client_id,
const char *name)
TODO
void server_setclientscore(int client_id,
int score)
TODO
void server_setbrowseinfo(int game_type,
int progression)
TODO
void server_kick(int client_id,
const char *reason)
TODO
int server_tick()
TODO
int server_tickspeed()
TODO
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_if_snd-h.html b/docs/output/files2/e_if_snd-h.html new file mode 100644 index 00000000..5cc729f7 --- /dev/null +++ b/docs/output/files2/e_if_snd-h.html @@ -0,0 +1,53 @@ + + +Sound + + + + + + + + + +

Sound

Summary
Sound
Functions
snd_set_channelSets the parameters for a sound channel.
snd_load_wvLoads a wavpack compressed sound.
snd_play_atPlays a sound at a specified postition.
snd_playPlays a sound.
snd_stopStops a currenly playing sound.
snd_set_listener_posSets the listener posititon.
+ +

Functions

+ +

snd_set_channel

void snd_set_channel(int cid,
float vol,
float pan)

Sets the parameters for a sound channel.

Arguments

cidChannel ID
volVolume for the channel.  0.0 to 1.0.
panPanning for the channel.  -1.0 is all left.  0.0 is equal distribution.  1.0 is all right.
+ +

snd_load_wv

int snd_load_wv(const char *filename)

Loads a wavpack compressed sound.

Arguments

filenameFilename of the file to load

Returns

The id of the loaded sound.  -1 on failure.

+ +

snd_play_at

int snd_play_at(int cid,
int sid,
int flags,
float x,
float y)

Plays a sound at a specified postition.

Arguments

cidChannel id of the channel to use.
sidSound id of the sound to play.
flagsTODO
xTODO
yTODO

Returns

An id to the voice.  -1 on failure.

See Also

<snd_play, snd_stop>

+ +

snd_play

int snd_play(int cid,
int sid,
int flags)

Plays a sound.

Arguments

Arguments: cid - Channel id of the channel to use. sid - Sound id of the sound to play. flags - TODO

Returns

An id to the voice.  -1 on failure.

See Also

<snd_play_at, snd_stop>

+ +

snd_stop

void snd_stop(int id)

Stops a currenly playing sound.

Arguments

idThe ID of the voice to stop.

See Also

<snd_play, snd_play_at>

+ +

snd_set_listener_pos

void snd_set_listener_pos(float x,
float y)

Sets the listener posititon.

Arguments

xTODO
yTODO
+ +
+ + + + + + + + + + +
void snd_set_channel(int cid,
float vol,
float pan)
Sets the parameters for a sound channel.
int snd_load_wv(const char *filename)
Loads a wavpack compressed sound.
int snd_play_at(int cid,
int sid,
int flags,
float x,
float y)
Plays a sound at a specified postition.
int snd_play(int cid,
int sid,
int flags)
Plays a sound.
void snd_stop(int id)
Stops a currenly playing sound.
void snd_set_listener_pos(float x,
float y)
Sets the listener posititon.
+ + + + +
Close
+ + + \ No newline at end of file diff --git a/docs/output/files2/e_system-h.html b/docs/output/files2/e_system-h.html new file mode 100644 index 00000000..9333e410 --- /dev/null +++ b/docs/output/files2/e_system-h.html @@ -0,0 +1,183 @@ + + +OS Abstraction + + + + + + + + + +

OS Abstraction

Summary
OS Abstraction
Debug
dbg_assertBreaks into the debugger based on a test.
dbg_breakBreaks into the debugger.
dbg_msgPrints a debug message.
Memory
mem_allocAllocates memory.
mem_freeFrees a block allocated through mem_alloc.
mem_copyCopies a a memory block.
mem_moveCopies a a memory block
mem_zeroSets a complete memory block to 0
mem_compCompares two blocks of memory
File IO
io_openOpens a file.
io_readReads data into a buffer from a file.
io_skipSkips data in a file.
io_writeWrites data from a buffer to file.
io_seekSeeks to a specified offset in the file.
io_tellGets the current position in the file.
io_lengthGets the total length of the file.
io_closeCloses a file.
io_flushEmpties all buffers and writes all pending data.
io_stdinReturns an <IOHANDLE> to the standard input.
io_stdoutReturns an <IOHANDLE> to the standard output.
io_stderrReturns an <IOHANDLE> to the standard error.
Threads
thread_sleepSuspends the current thread for a given period.
thread_createCreates a new thread.
thread_waitWaits for a thread to be done or destroyed.
thread_destoyDestroys a thread.
thread_yeildYeild the current threads execution slice.
Locks
Timer
time_getFetches a sample from a high resolution timer.
time_freqReturns the frequency of the high resolution timer.
time_timestampRetrives the current time as a UNIX timestamp
Network General
net_initInitiates network functionallity.
net_host_lookupDoes a hostname lookup by name and fills out the passed NETADDR struct with the recieved details.
net_addr_compCompares two network addresses.
net_addr_strTurns a network address into a representive string.
Network UDP
net_udp_createCreates a UDP socket and binds it to a port.
net_udp_sendSends a packet over an UDP socket.
net_udp_recvRecives a packet over an UDP socket.
net_udp_closeCloses an UDP socket.
Network TCP
net_tcp_createCreates a TCP socket.
net_tcp_listenMakes the socket start listening for new connections.
net_tcp_acceptPolls a listning socket for a new connection.
net_tcp_connectConnects one socket to another.
net_tcp_sendSends data to a TCP stream.
net_tcp_recvRecvives data from a TCP stream.
net_tcp_closeCloses a TCP socket.
Strings
str_appendAppends a string to another.
str_copyCopies a string to another.
str_formatPerforms printf formating into a buffer.
str_sanitize_strongReplaces all characters below 32 and above 127 with whitespace.
str_sanitizeReplaces all characters below 32 and above 127 with whitespace with exception to \r, \n and \r.
str_comp_nocaseCompares to strings case insensitive.
str_find_nocaseFinds a string inside another string case insensitive.
str_hexTakes a datablock and generates a hexstring of it.
Filesystem
fs_listdirLists the files in a directory
fs_makedirCreates a directory
fs_storage_pathFetches per user configuration directory.
Undocumented
net_tcp_connect_non_blockingDOCTODO: serp
net_tcp_set_non_blockingDOCTODO: serp
net_tcp_set_non_blockingDOCTODO: serp
net_errnoDOCTODO: serp
net_would_blockDOCTODO: serp
+ +

Debug

+ +

dbg_assert

void dbg_assert(int test,
const char *msg)

Breaks into the debugger based on a test.

Parameters

testResult of the test.
msgMessage that should be printed if the test fails.

Remarks

Does nothing in release version of the library.

See Also

dbg_break

+ +

dbg_break

void dbg_break()

Breaks into the debugger.

Remarks

Does nothing in release version of the library.

See Also

dbg_assert

+ +

dbg_msg

void dbg_msg(const char *sys,
const char *fmt,
 ...)

Prints a debug message.

Parameters

sysA string that describes what system the message belongs to
fmtA printf styled format string.

Remarks

Does nothing in relase version of the library.

See Also

dbg_assert

+ +

Memory

+ +

mem_alloc

void *mem_alloc_debug(const char *filename,
int line,
unsigned size,
unsigned alignment)

Allocates memory.

Parameters

sizeSize of the needed block.
alignmentAlignment for the block.

Returns

Returns a pointer to the newly allocated block.  Returns a null pointer if the memory couldn’t be allocated.

Remarks

  • Passing 0 to size will allocated the smallest amount possible and return a unique pointer.

See Also

mem_free

+ +

mem_free

void mem_free(void *block)

Frees a block allocated through mem_alloc.

Remarks

  • In the debug version of the library the function will assert if a non-valid block is passed, like a null pointer or a block that isn’t allocated.

See Also

mem_alloc

+ +

mem_copy

void mem_copy(void *dest,
const void *source,
unsigned size)

Copies a a memory block.

Parameters

destDestination.
sourceSource to copy.
sizeSize of the block to copy.

Remarks

  • This functions DOES NOT handles cases where source and destination is overlapping.

See Also

mem_move

+ +

mem_move

void mem_move(void *dest,
const void *source,
unsigned size)

Copies a a memory block

Parameters

destDestination
sourceSource to copy
sizeSize of the block to copy

Remarks

  • This functions handles cases where source and destination is overlapping

See Also

mem_copy

+ +

mem_zero

void mem_zero(void *block,
unsigned size)

Sets a complete memory block to 0

Parameters

blockPointer to the block to zero out
sizeSize of the block
+ +

mem_comp

int mem_comp(const void *a,
const void *b,
int size)

Compares two blocks of memory

Parameters

aFirst block of data
bSecond block of data
sizeSize of the data to compare

Returns

<0Block a is lesser then block b
0Block a is equal to block b
0 - Block a is greater then block b
+ +

File IO

+ +

io_open

IOHANDLE io_open(const char *filename,
int flags)

Opens a file.

Parameters

filenameFile to open.
flagsA set of flags.  IOFLAG_READ, IOFLAG_WRITE, IOFLAG_RANDOM.

Returns

Returns a handle to the file on success and 0 on failure.

+ +

io_read

unsigned io_read(IOHANDLE io,
void *buffer,
unsigned size)

Reads data into a buffer from a file.

Parameters

ioHandle to the file to read data from.
bufferPointer to the buffer that will recive the data.
sizeNumber of bytes to read from the file.

Returns

Number of bytes read.

+ +

io_skip

unsigned io_skip(IOHANDLE io,
unsigned size)

Skips data in a file.

Parameters

ioHandle to the file.
sizeNumber of bytes to skip.

Returns

Number of bytes skipped.

+ +

io_write

unsigned io_write(IOHANDLE io,
const void *buffer,
unsigned size)

Writes data from a buffer to file.

Parameters

ioHandle to the file.
bufferPointer to the data that should be written.
sizeNumber of bytes to write.

Returns

Number of bytes written.

+ +

io_seek

int io_seek(IOHANDLE io,
int offset,
int origin)

Seeks to a specified offset in the file.

Parameters

ioHandle to the file.
offsetOffset from pos to stop.
originPosition to start searching from.

Returns

Returns 0 on success.

+ +

io_tell

long int io_tell(IOHANDLE io)

Gets the current position in the file.

Parameters

ioHandle to the file.

Returns

Returns the current position.  -1L if an error occured.

+ +

io_length

long int io_length(IOHANDLE io)

Gets the total length of the file.  Resetting cursor to the beginning

Parameters

ioHandle to the file.

Returns

Returns the total size.  -1L if an error occured.

+ +

io_close

int io_close(IOHANDLE io)

Closes a file.

Parameters

ioHandle to the file.

Returns

Returns 0 on success.

+ +

io_flush

int io_flush(IOHANDLE io)

Empties all buffers and writes all pending data.

Parameters

ioHandle to the file.

Returns

Returns 0 on success.

+ +

io_stdin

IOHANDLE io_stdin()

Returns an <IOHANDLE> to the standard input.

+ +

io_stdout

IOHANDLE io_stdout()

Returns an <IOHANDLE> to the standard output.

+ +

io_stderr

IOHANDLE io_stderr()

Returns an <IOHANDLE> to the standard error.

+ +

Threads

+ +

thread_sleep

void thread_sleep(int milliseconds)

Suspends the current thread for a given period.

Parameters

millisecondsNumber of milliseconds to sleep.
+ +

thread_create

void *thread_create(void (*threadfunc)(void *),
void *user)

Creates a new thread.

Parameters

threadfuncEntry point for the new thread.
userPointer to pass to the thread.
+ +

thread_wait

void thread_wait(void *thread)

Waits for a thread to be done or destroyed.

Parameters

threadThread to wait for.
+ +

thread_destoy

Destroys a thread.

Parameters

threadThread to destroy.
+ +

thread_yeild

Yeild the current threads execution slice.

+ +

Locks

+ +

Timer

+ +

time_get

int64 time_get()

Fetches a sample from a high resolution timer.

Returns

Current value of the timer.

Remarks

To know how fast the timer is ticking, see time_freq.

+ +

time_freq

int64 time_freq()

Returns the frequency of the high resolution timer.

Returns

Returns the frequency of the high resolution timer.

+ +

time_timestamp

unsigned time_timestamp()

Retrives the current time as a UNIX timestamp

Returns

The time as a UNIX timestamp

+ +

Network General

+ +

net_init

int net_init()

Initiates network functionallity.

Returns

Returns 0 on success,

Remarks

You must call this function before using any other network functions.

+ +

net_host_lookup

int net_host_lookup(const char *hostname,
NETADDR *addr,
int types)

Does a hostname lookup by name and fills out the passed NETADDR struct with the recieved details.

Returns

0 on success.

+ +

net_addr_comp

int net_addr_comp(const NETADDR *a,
const NETADDR *b)

Compares two network addresses.

Parameters

aAddress to compare
bAddress to compare to.

Returns

<0Address a is lesser then address b
0Address a is equal to address b
0 - Address a is greater then address b
+ +

net_addr_str

int net_addr_str(const NETADDR *addr,
char *string,
int max_length)

Turns a network address into a representive string.

Parameters

addrAddress to turn into a string.
stringBuffer to fill with the string.
max_lengthMaximum size of the string.

Remarks

  • The string will always be zero terminated
+ +

Network UDP

+ +

net_udp_create

NETSOCKET net_udp_create(NETADDR bindaddr)

Creates a UDP socket and binds it to a port.

Parameters

bindaddrAddress to bind the socket to.

Returns

On success it returns an handle to the socket.  On failure it returns NETSOCKET_INVALID.

+ +

net_udp_send

int net_udp_send(NETSOCKET sock,
const NETADDR *addr,
const void *data,
int size)

Sends a packet over an UDP socket.

Parameters

sockSocket to use.
addrWhere to send the packet.
dataPointer to the packet data to send.
sizeSize of the packet.

Returns

On success it returns the number of bytes sent.  Returns -1 on error.

+ +

net_udp_recv

int net_udp_recv(NETSOCKET sock,
NETADDR *addr,
void *data,
int maxsize)

Recives a packet over an UDP socket.

Parameters

sockSocket to use.
addrPointer to an NETADDR that will recive the address.
dataPointer to a buffer that will recive the data.
maxsizeMaximum size to recive.

Returns

On success it returns the number of bytes recived.  Returns -1 on error.

+ +

net_udp_close

int net_udp_close(NETSOCKET sock)

Closes an UDP socket.

Parameters

sockSocket to close.

Returns

Returns 0 on success.  -1 on error.

+ +

Network TCP

+ +

net_tcp_create

NETSOCKET net_tcp_create(const NETADDR *a)

Creates a TCP socket.

Parameters

bindaddrAddress to bind the socket to.

Returns

On success it returns an handle to the socket.  On failure it returns NETSOCKET_INVALID.

+ +

net_tcp_listen

int net_tcp_listen(NETSOCKET sock,
int backlog)

Makes the socket start listening for new connections.

Parameters

sockSocket to start listen to.
backlogSize of the queue of incomming connections to keep.

Returns

Returns 0 on success.

+ +

net_tcp_accept

int net_tcp_accept(NETSOCKET sock,
NETSOCKET *new_sock,
NETADDR *addr)

Polls a listning socket for a new connection.

Parameters

sockListning socket to poll.
new_sockPointer to a socket to fill in with the new socket.
addrPointer to an address that will be filled in the remote address (optional, can be NULL).

Returns

Returns a non-negative integer on success.  Negative integer on failure.

+ +

net_tcp_connect

int net_tcp_connect(NETSOCKET sock,
const NETADDR *addr)

Connects one socket to another.

Parameters

sockSocket to connect.
addrAddress to connect to.

Returns

Returns 0 on success.

+ +

net_tcp_send

int net_tcp_send(NETSOCKET sock,
const void *data,
int size)

Sends data to a TCP stream.

Parameters

sockSocket to send data to.
dataPointer to the data to send.
sizeSize of the data to send.

Returns

Number of bytes sent.  Negative value on failure.

+ +

net_tcp_recv

int net_tcp_recv(NETSOCKET sock,
void *data,
int maxsize)

Recvives data from a TCP stream.

Parameters

sockSocket to recvive data from.
dataPointer to a buffer to write the data to
max_sizeMaximum of data to write to the buffer.

Returns

Number of bytes recvived.  Negative value on failure.

+ +

net_tcp_close

int net_tcp_close(NETSOCKET sock)

Closes a TCP socket.

Parameters

sockSocket to close.

Returns

Returns 0 on success.  Negative value on failure.

+ +

Strings

+ +

str_append

void str_append(char *dst,
const char *src,
int dst_size)

Appends a string to another.

Parameters

dstPointer to a buffer that contains a string.
srcString to append.
dst_sizeSize of the buffer of the dst string.

Remarks

  • The strings are treated as zero-termineted strings.
  • Garantees that dst string will contain zero-termination.
+ +

str_copy

void str_copy(char *dst,
const char *src,
int dst_size)

Copies a string to another.

Parameters

dstPointer to a buffer that shall recive the string.
srcString to be copied.
dst_sizeSize of the buffer dst.

Remarks

  • The strings are treated as zero-termineted strings.
  • Garantees that dst string will contain zero-termination.
+ +

str_format

void str_format(char *buffer,
int buffer_size,
const char *format,
 ...)

Performs printf formating into a buffer.

Parameters

bufferPointer to the buffer to recive the formated string.
buffer_sizeSize of the buffer.
formatprintf formating string.
...Parameters for the formating.

Remarks

  • See the C manual for syntax for the printf formating string.
  • The strings are treated as zero-termineted strings.
  • Garantees that dst string will contain zero-termination.
+ +

str_sanitize_strong

void str_sanitize_strong(char *str)

Replaces all characters below 32 and above 127 with whitespace.

Parameters

strString to sanitize.

Remarks

  • The strings are treated as zero-termineted strings.
+ +

str_sanitize

void str_sanitize(char *str)

Replaces all characters below 32 and above 127 with whitespace with exception to \r, \n and \r.

Parameters

strString to sanitize.

Remarks

  • The strings are treated as zero-termineted strings.
+ +

str_comp_nocase

int str_comp_nocase(const char *a,
const char *b)

Compares to strings case insensitive.

Parameters

aString to compare.
bString to compare.

Returns

<0String a is lesser then string b
0String a is equal to string b
0 - String a is greater then string b

Remarks

  • Only garanted to work with a-z/A-Z.
  • The strings are treated as zero-termineted strings.
+ +

str_find_nocase

const char *str_find_nocase(const char *haystack,
const char *needle)

Finds a string inside another string case insensitive.

Parameters

haystackString to search in
needleString to search for

Returns

A pointer into haystack where the needle was found.  Returns NULL of needle could not be found.

Remarks

  • Only garanted to work with a-z/A-Z.
  • The strings are treated as zero-termineted strings.
+ +

str_hex

void str_hex(char *dst,
int dst_size,
const void *data,
int data_size)

Takes a datablock and generates a hexstring of it.

Parameters

dstBuffer to fill with hex data
dst_sizesize of the buffer
dataData to turn into hex
dataSize of the data

Remarks

  • The desination buffer will be zero-terminated
+ +

Filesystem

+ +

fs_listdir

typedef void (*fs_listdir_callback)(const char *name, int is_dir, void *user)

Lists the files in a directory

Parameters

dirDirectory to list
cbCallback function to call for each entry
userPointer to give to the callback

Returns

Always returns 0.

+ +

fs_makedir

int fs_makedir(const char *path)

Creates a directory

Parameters

pathDirectory to create

Returns

Returns 0 on success.  Negative value on failure.

Remarks

Does not create several directories if needed.  “a/b/c” will result in a failure if b or a does not exist.

+ +

fs_storage_path

int fs_storage_path(const char *appname,
char *path,
int max)

Fetches per user configuration directory.

Returns

Returns 0 on success.  Negative value on failure.

Remarks

  • Returns ~/.appname on UNIX based systems
  • Returns ~/Library/Applications Support/appname on Mac OS X
  • Returns %APPDATA%/Appname on Windows based systems
+ +

Undocumented

+ +

net_tcp_connect_non_blocking

int net_tcp_connect_non_blocking(NETSOCKET sock,
const NETADDR *a)

DOCTODO: serp

+ +

net_tcp_set_non_blocking

int net_tcp_set_non_blocking(NETSOCKET sock)

DOCTODO: serp

+ +

net_tcp_set_non_blocking

DOCTODO: serp

+ +

net_errno

int net_errno()

DOCTODO: serp

+ +

net_would_block

int net_would_block()

DOCTODO: serp

+ +
+ + + + + + + + + + +
void dbg_assert(int test,
const char *msg)
Breaks into the debugger based on a test.
void dbg_break()
Breaks into the debugger.
void dbg_msg(const char *sys,
const char *fmt,
 ...)
Prints a debug message.
void *mem_alloc_debug(const char *filename,
int line,
unsigned size,
unsigned alignment)
Allocates memory.
void mem_free(void *block)
Frees a block allocated through mem_alloc.
void mem_copy(void *dest,
const void *source,
unsigned size)
Copies a a memory block.
void mem_move(void *dest,
const void *source,
unsigned size)
Copies a a memory block
void mem_zero(void *block,
unsigned size)
Sets a complete memory block to 0
int mem_comp(const void *a,
const void *b,
int size)
Compares two blocks of memory
IOHANDLE io_open(const char *filename,
int flags)
Opens a file.
unsigned io_read(IOHANDLE io,
void *buffer,
unsigned size)
Reads data into a buffer from a file.
unsigned io_skip(IOHANDLE io,
unsigned size)
Skips data in a file.
unsigned io_write(IOHANDLE io,
const void *buffer,
unsigned size)
Writes data from a buffer to file.
int io_seek(IOHANDLE io,
int offset,
int origin)
Seeks to a specified offset in the file.
long int io_tell(IOHANDLE io)
Gets the current position in the file.
long int io_length(IOHANDLE io)
Gets the total length of the file.
int io_close(IOHANDLE io)
Closes a file.
int io_flush(IOHANDLE io)
Empties all buffers and writes all pending data.
IOHANDLE io_stdin()
Returns an IOHANDLE to the standard input.
IOHANDLE io_stdout()
Returns an IOHANDLE to the standard output.
IOHANDLE io_stderr()
Returns an IOHANDLE to the standard error.
void thread_sleep(int milliseconds)
Suspends the current thread for a given period.
void *thread_create(void (*threadfunc)(void *),
void *user)
Creates a new thread.
void thread_wait(void *thread)
Waits for a thread to be done or destroyed.
int64 time_get()
Fetches a sample from a high resolution timer.
int64 time_freq()
Returns the frequency of the high resolution timer.
unsigned time_timestamp()
Retrives the current time as a UNIX timestamp
int net_init()
Initiates network functionallity.
int net_host_lookup(const char *hostname,
NETADDR *addr,
int types)
Does a hostname lookup by name and fills out the passed NETADDR struct with the recieved details.
int net_addr_comp(const NETADDR *a,
const NETADDR *b)
Compares two network addresses.
int net_addr_str(const NETADDR *addr,
char *string,
int max_length)
Turns a network address into a representive string.
NETSOCKET net_udp_create(NETADDR bindaddr)
Creates a UDP socket and binds it to a port.
int net_udp_send(NETSOCKET sock,
const NETADDR *addr,
const void *data,
int size)
Sends a packet over an UDP socket.
int net_udp_recv(NETSOCKET sock,
NETADDR *addr,
void *data,
int maxsize)
Recives a packet over an UDP socket.
int net_udp_close(NETSOCKET sock)
Closes an UDP socket.
NETSOCKET net_tcp_create(const NETADDR *a)
Creates a TCP socket.
int net_tcp_listen(NETSOCKET sock,
int backlog)
Makes the socket start listening for new connections.
int net_tcp_accept(NETSOCKET sock,
NETSOCKET *new_sock,
NETADDR *addr)
Polls a listning socket for a new connection.
int net_tcp_connect(NETSOCKET sock,
const NETADDR *addr)
Connects one socket to another.
int net_tcp_send(NETSOCKET sock,
const void *data,
int size)
Sends data to a TCP stream.
int net_tcp_recv(NETSOCKET sock,
void *data,
int maxsize)
Recvives data from a TCP stream.
int net_tcp_close(NETSOCKET sock)
Closes a TCP socket.
void str_append(char *dst,
const char *src,
int dst_size)
Appends a string to another.
void str_copy(char *dst,
const char *src,
int dst_size)
Copies a string to another.
void str_format(char *buffer,
int buffer_size,
const char *format,
 ...)
Performs printf formating into a buffer.
void str_sanitize_strong(char *str)
Replaces all characters below 32 and above 127 with whitespace.
void str_sanitize(char *str)
Replaces all characters below 32 and above 127 with whitespace with exception to \r, \n and \r.
int str_comp_nocase(const char *a,
const char *b)
Compares to strings case insensitive.
const char *str_find_nocase(const char *haystack,
const char *needle)
Finds a string inside another string case insensitive.
void str_hex(char *dst,
int dst_size,
const void *data,
int data_size)
Takes a datablock and generates a hexstring of it.
typedef void (*fs_listdir_callback)(const char *name, int is_dir, void *user)
Lists the files in a directory
int fs_makedir(const char *path)
Creates a directory
int fs_storage_path(const char *appname,
char *path,
int max)
Fetches per user configuration directory.
int net_tcp_connect_non_blocking(NETSOCKET sock,
const NETADDR *a)
DOCTODO: serp
int net_tcp_set_non_blocking(NETSOCKET sock)
DOCTODO: serp
int net_errno()
DOCTODO: serp
int net_would_block()
DOCTODO: serp
+ + + + +
Close
+ + + \ No newline at end of file -- cgit 1.4.1