src/Network/Protocol.hh
author terom
Sat, 06 Dec 2008 18:49:51 +0000
changeset 223 2fcaf54ed37b
parent 203 3ec7ab40755f
child 224 e6faefba2ec1
permissions -rw-r--r--
basic network-projectiles
#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 input to process
     *
     *  uint16_t    PlayerInput
     */
    NETMSG_CLIENT_INPUT         = 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,

    /*
     * New projectile spawned
     *
     * Vector   position
     * Vector   velocity
     * float    explosionRadius
     */
    NETMSG_PROJECTILE_CREATE    = 0x0401,
};

#endif