src/proto2/Network.hh
author ekku
Mon, 24 Nov 2008 21:48:21 +0000
changeset 102 11e9d02af7a6
parent 96 4a801210096c
child 107 505bfa531496
permissions -rw-r--r--
pomppii
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
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    32
enum NetworkMessage {
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    33
    NETMSG_PACKET_INVALID   = 0x00,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    34
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    35
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    36
     * You have joined the game:
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    37
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    38
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    39
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    40
    NETMSG_SERVER_HELLO = 0x0100,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    41
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    42
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    43
     * New client has connected to server:
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    44
     *  
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    45
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    46
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    47
    NETMSG_PLAYER_JOIN  = 0x0101,
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    48
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    49
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    50
     * Client has left server:
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    51
     *
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    52
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    53
    NETMSG_PLAYER_QUIT  = 0x0102,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    54
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    55
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    56
     * Client has moved
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    57
     *
96
4a801210096c fix movement physics+network code to some degree, jumping is now buggy?
terom
parents: 89
diff changeset
    58
     *  uint16_t    PlayerInput_Move
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    59
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    60
    NETMSG_CLIENT_MOVE  = 0x0201,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    61
    
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    62
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    63
     * Initial player info
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    64
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    65
     *  Vector      initial_position
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    66
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    67
    NETMSG_PLAYER_INFO  = 0x0300,
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    68
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    69
    /*
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    70
     * Player position update
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    71
     *
66
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    72
     * Vector   position
1415a2d45686 working simple network-physics code
terom
parents: 25
diff changeset
    73
     * Vector   velocity
24
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    74
     */
b81cb670e6b2 the great :retab
terom
parents: 22
diff changeset
    75
    NETMSG_PLAYER_POSITION  = 0x0301,
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    76
};
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    77
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    78
#endif