src/proto2/NetworkClient.hh
author terom
Thu, 20 Nov 2008 19:25:56 +0000
branchno-netsession
changeset 36 785d220fc6b7
parent 35 e21cfda0edde
permissions -rw-r--r--
...
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     1
#ifndef NETWORKCLIENT_HH
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     2
#define NETWORKCLIENT_HH
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
     3
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
     4
#include "Network.hh"
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
     5
#include "GameState.hh"
36
terom
parents: 35
diff changeset
     6
#include "NetworkSession.hh"
terom
parents: 35
diff changeset
     7
#include "NetworkObject.hh"
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
     8
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
     9
// forward-declare
26
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    10
class NetworkClientLocalPlayer;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    11
class NetworkClientRemotePlayer;
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    12
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
    13
class NetworkClient : public NetworkCore {
26
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    14
    friend class NetworkClientLocalPlayer;
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    15
    friend class NetworkClientRemotePlayer;
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    16
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    17
    private:
36
terom
parents: 35
diff changeset
    18
        NetworkSession netsession;
terom
parents: 35
diff changeset
    19
        NetworkNode *server;
terom
parents: 35
diff changeset
    20
terom
parents: 35
diff changeset
    21
        NetworkObject_ClientController netobjs;
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    22
        
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    23
    public:
36
terom
parents: 35
diff changeset
    24
        NetworkClient (GameState &state, const NetworkAddress &connect_to);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    25
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    26
    private:
36
terom
parents: 35
diff changeset
    27
        void on_create (NetworkObject_Client *obj, NetworkMessageID msg_id, NetworkPacket &pkt);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    28
36
terom
parents: 35
diff changeset
    29
        void on_server_hello (NetworkObject_Client *obj, NetworkPacket &pkt);
terom
parents: 35
diff changeset
    30
        void on_player_info (NetworkObject_Client *obj, NetworkPacket &pkt);
terom
parents: 35
diff changeset
    31
        void on_player_join (NetworkObject_Client *obj, NetworkPacket &pkt);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    32
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    33
    public:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    34
        void player_quit (NetworkClientRemotePlayer *player);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    35
};
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    36
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    37
class NetworkClientLocalPlayer : public LocalPlayer {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    38
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    39
        NetworkClient &client;
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
    40
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    41
        CL_SlotContainer slots;
36
terom
parents: 35
diff changeset
    42
        
terom
parents: 35
diff changeset
    43
        NetworkObject_Client *obj;
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    44
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    45
    public:
36
terom
parents: 35
diff changeset
    46
        NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    47
        
35
e21cfda0edde Merge from at r31:36
terom
parents: 26
diff changeset
    48
        virtual void applyForce (Vector force, uint16_t dt);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    49
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    50
    private:
36
terom
parents: 35
diff changeset
    51
        void on_position (NetworkPacket &pkt);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    52
};
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    53
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    54
class NetworkClientRemotePlayer : public RemotePlayer {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    55
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    56
        NetworkClient &client;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    57
        
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    58
        CL_SlotContainer slots;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    59
36
terom
parents: 35
diff changeset
    60
        NetworkObject_Client *obj;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    61
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    62
    public:
36
terom
parents: 35
diff changeset
    63
        NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    64
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    65
    private:
36
terom
parents: 35
diff changeset
    66
        void on_position (NetworkPacket &pkt);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    67
36
terom
parents: 35
diff changeset
    68
        void on_quit (NetworkPacket &pkt);
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    69
};
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    70
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    71
#endif