src/proto2/NetworkClient.hh
author terom
Mon, 24 Nov 2008 17:14:29 +0000
changeset 96 4a801210096c
parent 89 825c4613e087
permissions -rw-r--r--
fix movement physics+network code to some degree, jumping is now buggy?
#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH

#include "Network.hh"
#include "GameState.hh"
#include "NetworkSession.hh"
#include "NetworkObject.hh"

// forward-declare
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;

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

    private:
        NetworkSession netsession;
        NetworkNode *server;

        NetworkObject_ClientController netobjs;
        
    public:
        NetworkClient (GameState &state, const NetworkAddress &connect_to);

    private:
        void on_create (NetworkObject_Client *obj, NetworkMessageID msg_id, NetworkPacket &pkt);

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

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

        CL_SlotContainer slots;
        
        NetworkObject_Client *obj;

    public:
        NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
        
        virtual void handleMove (PlayerInput_Move input);
    
    private:
        void on_position (NetworkPacket &pkt);
};

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

        NetworkObject_Client *obj;

    public:
        NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
    
    private:
        void on_position (NetworkPacket &pkt);

        void on_quit (NetworkPacket &pkt);
};

#endif