src/proto2/Network.hh
author saiam
Fri, 28 Nov 2008 22:26:23 +0000
changeset 128 890ac82cdcc0
parent 107 505bfa531496
permissions -rw-r--r--
Documenting more, cleaning variables. This code needs some serious
rewriting. (And we havent too many features either)
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     1
#ifndef NETWORK_HH
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     2
#define NETWORK_HH
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     3
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 15
diff changeset
     4
#include "NetworkConfig.hh"
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 15
diff changeset
     5
#include "GameState.hh"
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 15
diff changeset
     6
13
3fbb927c6a27 fix broken includes
terom
parents: 8
diff changeset
     7
#include <ClanLib/network.h>
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     8
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
     9
const int32_t COORDINATE_MAX = 1 << 30;
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    10
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 15
diff changeset
    11
class NetworkCore {
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    12
    protected:
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    13
        GameState &state;
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    14
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    15
        CL_SlotContainer slots;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    16
89
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    17
        // constructor
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    18
        NetworkCore (GameState &state) : state(state) { }
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    19
89
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    20
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    21
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    22
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    23
};
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    24
89
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    25
enum NetworkChannel {
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    26
    /*
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    27
     * Core channel used for NetworkSession
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    28
     */
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    29
    NETCHAN_CORE            = 0x01,
825c4613e087 merge branches/no-netsession@89 into trunk
terom
parents: 66
diff changeset
    30
};
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    31
107
505bfa531496 send inAir attribute as part of NETWORK_PLAYER_POSITION...
terom
parents: 96
diff changeset
    32
enum NetworkPhysicsFlags {
505bfa531496 send inAir attribute as part of NETWORK_PLAYER_POSITION...
terom
parents: 96
diff changeset
    33
    NETWORK_PHYSICS_INAIR      = 0x01,
505bfa531496 send inAir attribute as part of NETWORK_PLAYER_POSITION...
terom
parents: 96
diff changeset
    34
};
505bfa531496 send inAir attribute as part of NETWORK_PLAYER_POSITION...
terom
parents: 96
diff changeset
    35
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    36
enum NetworkMessage {
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    37
    NETMSG_PACKET_INVALID   = 0x00,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    38
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    39
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    40
     * You have joined the game:
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    41
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    42
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    43
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    44
    NETMSG_SERVER_HELLO = 0x0100,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    45
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    46
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    47
     * New client has connected to server:
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    48
     *  
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    49
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    50
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    51
    NETMSG_PLAYER_JOIN  = 0x0101,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    52
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    53
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    54
     * Client has left server:
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    55
     *
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    56
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    57
    NETMSG_PLAYER_QUIT  = 0x0102,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    58
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    59
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    60
     * Client has moved
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    61
     *
96
4a801210096c fix movement physics+network code to some degree, jumping is now buggy?
terom
parents: 89
diff changeset
    62
     *  uint16_t    PlayerInput_Move
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    63
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    64
    NETMSG_CLIENT_MOVE  = 0x0201,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    65
    
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    66
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    67
     * Initial player info
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    68
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    69
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    70
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    71
    NETMSG_PLAYER_INFO  = 0x0300,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    72
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    73
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    74
     * Player position update
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    75
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    76
     * Vector   position
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    77
     * Vector   velocity
107
505bfa531496 send inAir attribute as part of NETWORK_PLAYER_POSITION...
terom
parents: 96
diff changeset
    78
     * uint8_t  NetworkPhysicsFlags
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    79
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    80
    NETMSG_PLAYER_POSITION  = 0x0301,
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    81
};
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    82
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    83
#endif