src/Network/Protocol.hh
author terom
Thu, 04 Dec 2008 22:33:43 +0000
changeset 203 3ec7ab40755f
parent 200 2dbf40661580
child 223 2fcaf54ed37b
permissions -rw-r--r--
send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
#ifndef NETWORK_PROTOCOL_HH
#define NETWORK_PROTOCOL_HH

/*
 * The network protocol is defined here :o
 */

enum NetworkChannel {
    /*
     * Core channel used for NetworkSession
     */
    NETCHAN_CORE            = 0x0001,

    /*
     * Channel used to send initial terrain array
     *
     * uint32_t                 map_w
     * uint32_t                 map_h
     * uint8_t[map_w][map_h]    terrain
     */
    NETCHAN_TERRAIN_ARRAY   = 0x0010,
};

enum NetworkPhysicsFlags {
    NETWORK_PHYSICS_INAIR      = 0x01,
    NETWORK_PHYSICS_FACE_RIGHT = 0x02,
};

enum NetworkMessage {
    NETMSG_PACKET_INVALID   = 0x0000,

    /*
     * You have joined the game:
     *
     *  Vector      initial_position
     */
    NETMSG_SERVER_HELLO     = 0x0100,

    /*
     * New client has connected to server:
     *  
     *  Vector      initial_position
     */
    NETMSG_PLAYER_JOIN      = 0x0101,

    /*
     * Client has left server:
     *
     */
    NETMSG_PLAYER_QUIT      = 0x0102,

    /*
     * Client has moved
     *
     *  uint16_t    PlayerInput_Move
     */
    NETMSG_CLIENT_MOVE      = 0x0201,
    
    /*
     * Initial player info
     *
     *  Vector      initial_position
     */
    NETMSG_PLAYER_INFO      = 0x0300,

    /*
     * Player position update
     *
     * Vector   position
     * Vector   velocity
     * uint8_t  NetworkPhysicsFlags
     * float32  aim
     */
    NETMSG_PLAYER_POSITION  = 0x0301,

    /*
     * Terrain update, removeGround
     *
     * Vector   position 
     * float32  radius          
     */
    NETMSG_PLAYER_DIG       = 0x0302,
};

#endif