src/Network/Protocol.hh
author terom
Mon, 08 Dec 2008 17:24:40 +0000
changeset 296 4d3ebaa29430
parent 276 87434abc1ba1
child 302 e734d8e9bbb5
permissions -rw-r--r--
add separate Types.hh, and fix projectile-worm collisions on network
#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 NetworkProjectileFlags {
    NETWORK_PROJECTILE_REMOVE_GROUND    = 0x01,
};

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           = 0x0312,

    /*
     * Player changed weapon
     *
     * uint8_t  weapon_id
     */
    NETMSG_PLAYER_WEAPON_CHANGE = 0x0321,

    /*
     * Player threw the rope
     *
     * Vector   position
     * Vector   velocity
     * float    length
     */
    NETMSG_PLAYER_ROPE_THROW    = 0x0331,

    /*
     * Player rope fixed on to something
     *
     * Vector   position
     * float    length
     */
    NETMSG_PLAYER_ROPE_FIXED    = 0x0332,

    /*
     * Player rope released
     *
     */
    NETMSG_PLAYER_ROPE_RELEASED = 0x0333,
    
    /*
     * Rope length changed
     *
     * float length
     */
    NETMSG_PLAYER_ROPE_LENGTH   = 0x0334,
    
    /*
     * Player has fired a weapon, creating this projectile
     *
     * Object   player
     * Vector   position
     * Vector   velocity
     * uint8_t  weapon_id
     */
    NETMSG_PROJECTILE_PLAYER_FIRED  = 0x0411,

    /**
     * Projectile has hit a player
     *
     * Object   player
     * uint16_t damage
     */
    NETMSG_PROJECTILE_HIT_PLAYER    = 0x0421,

    /*
     * Projectile has gone away
     *
     * Vector   position
     * uint8_t  NetworkProjectileFlags (REMOVE_GROUND)
     */
    NETMSG_PROJECTILE_DESTROY       = 0x040F,
};

#endif