src/proto2/NetworkClient.hh
author saiam
Thu, 20 Nov 2008 22:45:10 +0000
changeset 86 ed31ece6f340
parent 66 1415a2d45686
child 89 825c4613e087
permissions -rw-r--r--
Segfault <3 (mik? oli odotettavaa)
#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH

#include "Network.hh"
#include "GameState.hh"

// forward-declare
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;

class NetworkClient : public NetworkCore {
    friend class NetworkClientLocalPlayer;
    friend class NetworkClientRemotePlayer;

    private:
        CL_NetComputer server;
        
    public:
        NetworkClient (GameState &state, const CL_IPAddress &connect_to);

    private:
        void on_create_object (CL_NetObject_Client &obj, int msg_type, CL_NetPacket &pkt);

        void on_server_hello (CL_NetObject_Client &obj, CL_NetPacket &pkt);
        void on_player_info (CL_NetObject_Client &obj, CL_NetPacket &pkt);
        void on_player_join (CL_NetObject_Client &obj, CL_NetPacket &pkt);
    
    public:
        void player_quit (NetworkClientRemotePlayer *player);
};

class NetworkClientLocalPlayer : public LocalPlayer {
    private:
        NetworkClient &client;

        CL_SlotContainer slots;

        CL_NetObject_Client obj;

    public:
        NetworkClientLocalPlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position);
        
        virtual void applyForce (Vector force, uint16_t dt);
    
    private:
        void on_position (CL_NetPacket &pkt);
};

class NetworkClientRemotePlayer : public RemotePlayer {
    private:
        NetworkClient &client;
        
        CL_SlotContainer slots;

        CL_NetObject_Client obj;

    public:
        NetworkClientRemotePlayer (NetworkClient &client, CL_NetObject_Client &obj, Vector initial_position);
    
    private:
        void on_position (CL_NetPacket &pkt);

        void on_quit (CL_NetPacket &pkt);
};

#endif