Appendix C. "idefs.h"

/* ALL THE DEFINITIONS HERE ARE MEANT FOR NETWORK BYTEORDER and IEEE float point numbers */

/*
************** SERVER -> CLIENT CHUNK IDs **************
*/
/* 0x000000zz - TRAVEL section */
#define IS_TRAVEL_FULL_VERSION 0x00000000
// |BASE VERSION|
// |CHAR*       |
#define IS_TRAVEL_RELEASE_VERSION 0x00000001
// |BASE VERSION|
// |CHAR*       |
#define IS_TRAVEL_BASE_VERSION 0x00000002
// |BASE VERSION|
// |CHAR*       |
#define IS_TRAVEL_MINIMAL_GENERAL_VERSION 0x00000003
// |BASE VERSION|
// |CHAR*       |
#define IS_TRAVEL_RECOMMENDED_GENERAL_VERSION 0x00000004
// |BASE VERSION|
// |CHAR*       |
#define IS_TRAVEL_JOIN_ROOM_ACCEPT 0x00000005
// ||
// ||
#define IS_TRAVEL_JOIN_ROOM_REJECT 0x00000006
// ||
// ||
#define IS_TRAVEL_RESOURCE_LIST 0x00000007
// |NAME LEN|RESOURCE NAME | (name len & resource name) x N times
// |UINT16  |CHAR[NAME LEN]|
#define IS_TRAVEL_NO_SUCH_ROOM 0x00000008
// |ROOM NAME|
// |CHAR*    |
#define IS_TRAVEL_INIT_RESOURCE_32 0x00000009
// |SIZE  |RESOURCE NAME|
// |UINT32|CHAR*        |
#define IS_TRAVEL_INIT_RESOURCE_64 0x0000000A
// |SIZE  |RESOURCE NAME|
// |UINT64|CHAR*        |
#define IS_TRAVEL_RESOURCE_CHUNK 0x0000000B
// |DATA |
// |VOID*|
#define IS_TRAVEL_RESOURCE_DONE 0x0000000C
// ||
// ||
#define IS_TRAVEL_RESOURCE_TRANSFER_DONE 0x0000000D
// ||
// ||
#define IS_TRAVEL_ABORT_RESOURCE_TRANSFER 0x0000000E
// ||
// ||
#define IS_TRAVEL_TELEPORT_DESTINATION 0x0000000F
// |ADDRESS LEN|ADDRESS|PORT  |ROOM NAME LEN|ROOM NAME|
// |UINT16     |CHAR*  |UINT16|UINT16       |CHAR*    |

/* 0x000001zz - LUA section */
#define IS_LUA_MESSAGE 0x00000100
// |SCRIPT TEXT|
// |CHAR*      |
#define IS_LUA_EXECUTE_SCRIPT_TEXT 0x00000101
// |CHUNK NAME LEN|CHUNK NAME    |SCRIPT TEXT| x N times
// |UINT16        |CHAR[NAME LEN]|CHAR*      |
#define IS_LUA_EXECUTE_SCRIPT_FILE 0x00000102
// |SCRIPT NAME|
// |CHAR*      |

/* 0x000002zz - SCENE section */
#define IS_SCENE_3D_LIST_INIT 0x00000200
// |ID    | x N times
// |UINT32|
#define IS_SCENE_2D_LIST_INIT 0x00000201
// |ID    | x N times
// |UINT32|
#define IS_SCENE_LIST_REMOVE 0x00000202
// |ID    | x N times
// |UINT32|
#define IS_SCENE_LIST_REMOVE_ALL 0x00000203
// ||
// ||
#define IS_SCENE_ACTIVATE 0x00000204
// |ID    |
// |UINT32|
#define IS_SCENE_LIST_SET_AMBIENT_LIGHT 0x00000205
// |ID    |RED  |GREEN|BLUE | x N times ((1.0, 1.0, 1.0) by default)
// |UINT32|FLOAT|FLOAT|FLOAT|

/* 0x000003zz - CAMERA section */
#define IS_CAMERA_LIST_INIT 0x00000300
// |ID    | x N times
// |UINT32|
#define IS_CAMERA_LIST_REMOVE 0x00000301
// |ID    | x N times
// |UINT32|
#define IS_CAMERA_LIST_REMOVE_ALL 0x00000302
// ||
// ||
#define IS_CAMERA_LIST_SET_SCENE 0x00000303
// |ID    |SCENE ID| x N times
// |UINT32|UINT32  |
#define IS_CAMERA_LIST_SET_POSITION 0x00000304
// |ID    |TR_X |TR_Y |TR_Z |ROT_A|ROT_B|ROT_C| x N times
// |UINT32|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|
#define IS_CAMERA_LIST_SET_FOVY 0x00000305
// |ID    |Y-DIMENSION FOV| (FOVY=PI/2 by default) x N times
// |UINT32|FLOAT          |
#define IS_CAMERA_LIST_SET_NEAR_CLIP_DISTANCE 0x00000306
// |ID    |NEAR CLIP DISTANCE| (NEAR=1.0 by default) x N times
// |UINT32|FLOAT             |
#define IS_CAMERA_LIST_SET_FAR_CLIP_DISTANCE 0x00000307
// |ID    |FAR CLIP DISTANCE| (FAR=10000.0 by default) x N times
// |UINT32|FLOAT            |

/* 0x000004zz - VIEWPORT section */
#define IS_VIEWPORT_LIST_INIT 0x00000400
// |ID    | x N times
// |UINT32|
#define IS_VIEWPORT_LIST_REMOVE 0x00000401
// |ID    | x N times
// |UINT32|
#define IS_VIEWPORT_LIST_REMOVE_ALL 0x00000402
// ||
// ||
#define IS_VIEWPORT_LIST_HIDE 0x00000403
// |ID    | x N times
// |UINT32|
#define IS_VIEWPORT_LIST_SHOW 0x00000404
// |ID    | x N times
// |UINT32|
#define IS_VIEWPORT_LIST_SET_CAMERA 0x00000405
// |VIEWPORT ID|CAMERA ID| x N times
// |UINT32     |UINT32   |
#define IS_VIEWPORT_LIST_SET_DIMENSIONS 0x00000406
// |ID    |LEFT |TOP  |WIDTH|HEIGHT| x N times
// |UINT32|FLOAT|FLOAT|FLOAT|FLOAT |
#define IS_VIEWPORT_LIST_SET_BACKGROUND_COLOR 0x00000407
// |ID    |RED  |GREEN|BLUE | x N times ((0.0, 0.0, 0.0) by default, each component specter is [0..1])
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_VIEWPORT_LIST_SET_BUFFERS_TO_CLEAR 0x00000408
// |ID    |FLAGS | x N times
// |UINT32|UINT32|

/* 0x000005zz - PLAIN MODEL section */
#define IS_PLAIN_MODEL_LIST_INIT 0x00000500
// |MODEL ID|NAME LEN|MODEL NAME    | x N times
// |UINT32  |UINT16  |CHAR[NAME LEN]|
#define IS_PLAIN_MODEL_LIST_REMOVE 0x00000501
// |ID    | x N times
// |UINT32|
#define IS_PLAIN_MODEL_LIST_REMOVE_ALL 0x00000502
// ||
// ||
#define IS_PLAIN_MODEL_LIST_SHOW 0x00000503
// |ID    | x N times (shown by default)
// |UINT32|
#define IS_PLAIN_MODEL_LIST_HIDE 0x00000504
// |ID    | x N times
// |UINT32|
#define IS_PLAIN_MODEL_LIST_SET_TRANSLATION 0x00000505
// |ID    |TR_X |TR_Y |TR_Z | x N times
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_MODEL_LIST_SET_ROTATION 0x00000506
// |ID    |ROT_X|ROT_Y|ROT_Z| x N times
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_MODEL_LIST_SET_SCALE 0x00000507
// |ID    |SC_X |SC_Y |SC_Z | x N times
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_MODEL_LIST_SET_POSITION 0x00000508
// |ID    |TR_X |TR_Y |TR_Z |ROT_A|ROT_B|ROT_C| x N times
// |UINT32|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|

/* 0x000006zz - PLAIN LIGHT section */
#define IS_PLAIN_LIGHT_LIST_INIT 0x00000600
// |LIGHT ID| x N times
// |UINT32  |
#define IS_PLAIN_LIGHT_LIST_REMOVE 0x00000601
// |ID    | x N times
// |UINT32|
#define IS_PLAIN_LIGHT_LIST_REMOVE_ALL 0x00000602
// ||
// ||
#define IS_PLAIN_LIGHT_LIST_SHOW 0x00000603
// |ID    | x N times (shown by default)
// |UINT32|
#define IS_PLAIN_LIGHT_LIST_HIDE 0x00000604
// |ID    | x N times
// |UINT32|
#define IS_PLAIN_LIGHT_LIST_SET_POSITION 0x00000605
// |ID    |TR_X |TR_Y |TR_Z |DIR_X|DIR_Y|DIR_Z| x N times ((0, 0, 0, 0, 0 -1) by default)
// |UINT32|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_LIGHT_LIST_SET_TYPE 0x00000606
// |ID    |TYPE  | x N times (POINT LIGHT is default value)
// |UINT32|UINT32|
#define IS_PLAIN_LIGHT_LIST_SET_DIFFUSE_COLOR 0x00000607
// |ID    |RED  |GREEN|BLUE | x N times
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_LIGHT_LIST_SET_SPECULAR_COLOR 0x00000608
// |ID    |RED  |GREEN|BLUE | x N times
// |UINT32|FLOAT|FLOAT|FLOAT|
#define IS_PLAIN_LIGHT_LIST_SET_ATTENUATION 0x00000609
// |ID    |RANGE|CONSTANT|LINEAR|QUADRATIC| x N times
// |UINT32|FLOAT|FLOAT   |FLOAT |FLOAT    |
#define IS_PLAIN_LIGHT_LIST_SET_SPOTLIGHT_RANGE 0x0000060A
// |ID    |INNER ANGLE|OUTER ANGLE|FALLOFF| x N times
// |UINT32|FLOAT      |FLOAT      |FLOAT  |

/*
************** CLIENT -> SERVER CHUNK IDs **************
*/
/* 0x000000zz - TRAVEL SECTION */
#define IS_TRAVEL_GET_FULL_VERSION 0x00000000
// ||
// ||
#define IS_TRAVEL_GET_RELEASE_VERSION 0x00000001
// ||
// ||
#define IS_TRAVEL_GET_BASE_VERSION 0x00000002
// ||
// ||
#define IS_TRAVEL_GET_MINIMAL_GENERAL_VERSION 0x00000003
// ||
// ||
#define IS_TRAVEL_GET_RECOMMENDED_GENERAL_VERSION 0x00000004
// ||
// ||
#define IC_TRAVEL_JOIN_ROOM_REQUEST 0x00000005
// |ROOM NAME|
// |CHAR*    |
#define IC_TRAVEL_GET_ROOM_RESOURCE_LIST 0x00000006
// |ROOM NAME|
// |CHAR*    |
#define IC_TRAVEL_REQUEST_RESOURCES 0x00000007
// |NAME LEN|RESOURCE NAME | x N times
// |UINT16  |CHAR[NAME LEN]|
#define IC_TRAVEL_ABORT_RESOURCE_TRANSFER 0x00000008
// ||
// ||

/* 0x000001zz - LUA section */
#define IC_LUA_MESSAGE 0x00000100
// |SCRIPT TEXT|
// |CHAR*      |

/* 0x000002zz - INPUT section */
#define IC_INPUT_BROAD_ACTION 0x00000200
// |ACTION ID|
// |UINT32   |
#define IC_INPUT_BROAD_FLOAT_LOOK_EVENT 0x00000201
// |X OFFSET|Y OFFSET|
// |FLOAT   |FLOAT   |
#define IC_INPUT_UNI_ACTION 0x00000280
// |ACTION ID|
// |UINT32   |
#define IC_INPUT_UNI_POINTER_EVENT 0x00000281
// |POINTER ID|ANY POINTER VALUE(S)| (x N times)
// |UINT16    |FLOAT or DOUBLE     |

/*
  ================= THE REST OF STORY =================
*/
#define DEFAULT_ROOM "MAIN"


/* BROAD ACTION IDs */
#define I_BROAD_ACTION_DOWN_MOVE_FORWARD 0x00000000
#define I_BROAD_ACTION_UP_MOVE_FORWARD 0x00000001
#define I_BROAD_ACTION_DOWN_MOVE_BACK 0x00000002
#define I_BROAD_ACTION_UP_MOVE_BACK 0x00000003
#define I_BROAD_ACTION_DOWN_MOVE_LEFT 0x00000004
#define I_BROAD_ACTION_UP_MOVE_LEFT 0x00000005
#define I_BROAD_ACTION_DOWN_MOVE_RIGHT 0x00000006
#define I_BROAD_ACTION_UP_MOVE_RIGHT 0x00000007
#define I_BROAD_ACTION_DOWN_MOVE_UP 0x00000008
#define I_BROAD_ACTION_UP_MOVE_UP 0x00000009
#define I_BROAD_ACTION_DOWN_MOVE_DOWN 0x0000000A
#define I_BROAD_ACTION_UP_MOVE_DOWN 0x0000000B
#define I_BROAD_ACTION_DOWN_ROTATE_LEFT 0x0000000C
#define I_BROAD_ACTION_UP_ROTATE_LEFT 0x0000000D
#define I_BROAD_ACTION_DOWN_ROTATE_RIGHT 0x0000000E
#define I_BROAD_ACTION_UP_ROTATE_RIGHT 0x0000000F

/* PLAIN LIGHT TYPES */
#define I_PLAIN_LIGHT_TYPE_POINT 0x00000000
#define I_PLAIN_LIGHT_TYPE_DIRECTIONAL 0x00000001
#define I_PLAIN_LIGHT_TYPE_SPOTLIGHT 0x00000002

/* BUFFERS TO CLEAR FLAGS */
#define I_BUFFER_TO_CLEAR_COLOR 0x00000001
#define I_BUFFER_TO_CLEAR_DEPTH 0x00000002
#define I_BUFFER_TO_CLEAR_STENCIL 0x00000004

/*
  ================= SOME DOCUMENTATION ================
*/
/*
  [VERSIONS]
  The first 3 numbers of version (also called 'general version') are important about network protocol.
  If general version of client and server matches, they are completely network compaitable
  and even look the same (or almost the same) way.
  The first 2 numbers of version are called 'base version'.
  Versions with same base version and greater 3rd number of general version are backward compaitable with
  versions with smaller 3rd number.
  If base version doesn't match, versions are completely incompaitable.
  So if you want to have all servers compaitable client, you should have
  all base versions with latest general versions.
  All versions are stored in single executable, which means dynamic linking
  only with system-stored libraries (if dynamic version), so they are
  independent from $LD_LIBRARY_PATH, $PWD, etc.
  Such a versioning system makes update-in-place possible.
  This is done by calling exec () to up-to-date binary with
  command line args specifying previous server and room if needed.
  'Release version' contains 4 digits.
  'Full version' containts 4 digits and (possibly) some textual suffix describing sub-release.
  If current dump is release version (not 'pre', 'rc', etc.) then 'Full version' == 'Release version'.
*/