src/Network/Protocol.hh
author Tero Marttila <terom@fixme.fi>
Fri, 16 Jan 2009 22:03:49 +0200
changeset 400 d64bf28c4340
parent 334 0cf3f2be51eb
child 431 c6d7272a164b
permissions -rw-r--r--
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
#ifndef NETWORK_PROTOCOL_HH
#define NETWORK_PROTOCOL_HH

/**
 * @file
 *
 * Definitions for game network protocol
 */

/**
 * The various NetworkChannelIDs used with our NetworkSession
 */
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,
};

/**
 * Various flags used with NETMSG_PLAYER_POSITION related to PhysicsObject state
 */
enum NetworkPhysicsFlags {
    NETWORK_PHYSICS_INAIR               = 0x01,
    NETWORK_PHYSICS_FACE_RIGHT          = 0x02,
};

/**
 * Various flags used with NETMSG_PROJECTILE_* messages...
 */
enum NetworkProjectileFlags {
    /** NETMSG_PROJECTILE_DESTROY */
    NETWORK_PROJECTILE_REMOVE_GROUND    = 0x01,
};

/**
 * Various NetworkMessageIDs used with our NetworkSession's NetworkObjects.
 *
 * Message names are of the form 'NETMSG_<object type>_<action>'
 */
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
     *  uint32_t    dt
     */
    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,

    /*
     * Player has spawned somewhere
     *
     * Vector   position
     */
    NETMSG_PLAYER_SPAWN         = 0x0302,

    /*
     * Player has died
     *
     */
    NETMSG_PLAYER_DIE           = 0x0303,

    /*
     * 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
     * Object?  player
     */
    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
     */
    NETMSG_PROJECTILE_HIT_PLAYER    = 0x0421,

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

#endif