src/proto2/NetworkClient.hh
author terom
Tue, 18 Nov 2008 22:58:50 +0000
branchno-netsession
changeset 35 e21cfda0edde
parent 26 5685602aeb9c
child 36 785d220fc6b7
permissions -rw-r--r--
Merge from at r31:36
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"
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
     6
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
     7
// forward-declare
26
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
     8
class NetworkClientLocalPlayer;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
     9
class NetworkClientRemotePlayer;
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    10
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
    11
class NetworkClient : public NetworkCore {
26
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    12
    friend class NetworkClientLocalPlayer;
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    13
    friend class NetworkClientRemotePlayer;
5685602aeb9c it works \o/
terom
parents: 25
diff changeset
    14
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    15
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    16
        CL_NetComputer server;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    17
        
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    18
    public:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    19
        NetworkClient (GameState &state, const CL_IPAddress &connect_to);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    20
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    21
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    22
        void on_create_object (CL_NetObject_Client &obj, int msg_type, CL_NetPacket &pkt);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    23
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    24
        void on_server_hello (CL_NetObject_Client &obj, CL_NetPacket &pkt);
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    25
        void on_player_info (CL_NetObject_Client &obj, CL_NetPacket &pkt);
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    26
        void on_player_join (CL_NetObject_Client &obj, CL_NetPacket &pkt);
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    27
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    28
    public:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    29
        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
    30
};
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    31
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    32
class NetworkClientLocalPlayer : public LocalPlayer {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    33
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    34
        NetworkClient &client;
21
32c6cc55256a change proto2 network code to use CL_NetSession
terom
parents: 5
diff changeset
    35
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    36
        CL_SlotContainer slots;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    37
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    38
        CL_NetObject_Client obj;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    39
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    40
    public:
35
e21cfda0edde Merge from at r31:36
terom
parents: 26
diff changeset
    41
        NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    42
        
35
e21cfda0edde Merge from at r31:36
terom
parents: 26
diff changeset
    43
        virtual void applyForce (Vector force, uint16_t dt);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    44
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    45
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    46
        void on_position (CL_NetPacket &pkt);
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    47
};
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    48
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    49
class NetworkClientRemotePlayer : public RemotePlayer {
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    50
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    51
        NetworkClient &client;
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    52
        
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    53
        CL_SlotContainer slots;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    54
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    55
        CL_NetObject_Client obj;
22
b70d30e1b0fe all the network code is now there, although it doesn't quite work
terom
parents: 21
diff changeset
    56
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    57
    public:
35
e21cfda0edde Merge from at r31:36
terom
parents: 26
diff changeset
    58
        NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position);
24
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    59
    
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    60
    private:
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    61
        void on_position (CL_NetPacket &pkt);
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    62
b81cb670e6b2 the great :retab
terom
parents: 23
diff changeset
    63
        void on_quit (CL_NetPacket &pkt);
5
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    64
};
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    65
617813994ab1 move proto/p2 -> src/proto2
terom
parents:
diff changeset
    66
#endif