src/Network/Server.hh
author saiam
Mon, 08 Dec 2008 00:05:45 +0000
changeset 273 eeb699e1d908
parent 263 8c999cf4c182
child 274 c35307e8645c
permissions -rw-r--r--
Made forceq to contain time again.
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
#ifndef NETWORKSERVER_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#define NETWORKSERVER_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
186
0738f2949a2b move src/Network% to src/Network/%
terom
parents: 185
diff changeset
     4
#include "../GameState.hh"
0738f2949a2b move src/Network% to src/Network/%
terom
parents: 185
diff changeset
     5
#include "Session.hh"
0738f2949a2b move src/Network% to src/Network/%
terom
parents: 185
diff changeset
     6
#include "Object.hh"
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     7
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     8
#include <list>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     9
#include <map>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    10
#include <ClanLib/core.h>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    11
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    12
// forward-declare
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    13
class NetworkServerPlayer;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    14
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    15
class NetworkServer {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    16
    friend class NetworkServerPlayer;
223
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    17
    friend class NetworkServerProjectile;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    18
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    19
    protected:
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    20
        GameState &state;
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    21
        CL_SlotContainer slots;
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    22
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    23
        NetworkSession netsession;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    24
        NetworkObject_ServerController netobjs;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    25
        std::list<NetworkServerPlayer *> players;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    26
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    27
    public:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    28
        NetworkServer (GameState &state, const NetworkAddress &listen_addr);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    29
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    30
    protected:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    31
        void handle_disconnect (NetworkServerPlayer *player);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    32
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    33
    private:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    34
        void on_node_connected (NetworkNode *node);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    35
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    36
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 203
diff changeset
    37
class NetworkServerPlayer : public LocalPlayer {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    38
    private:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    39
        NetworkServer &server;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    40
        NetworkObject_Server obj;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    41
        NetworkNode *node;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    42
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    43
        CL_SlotContainer slots;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    44
        
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    45
    public:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    46
        NetworkServerPlayer (NetworkServer &server, NetworkNode *node);
239
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 224
diff changeset
    47
    
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 224
diff changeset
    48
    protected:    
223
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    49
        // override from Player to replicate side effects of events to clients
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
    50
        virtual void handleDig (Vector position, float radius);
239
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 224
diff changeset
    51
        virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity);
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 224
diff changeset
    52
        virtual void handleChangeWeapon (unsigned int weaponIndex);
241
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
    53
        virtual void handleRopeState (RopeState state);
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
    54
        virtual void handleRopeLength (float length);
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
    55
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    56
    private:
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    57
        void on_disconnected (void);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    58
        void on_input (NetworkNode *node, NetworkPacketInput &pkt);
203
3ec7ab40755f send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents: 200
diff changeset
    59
        
3ec7ab40755f send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents: 200
diff changeset
    60
        void send_terrain_data (void);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    61
        void send_position_update (void);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    62
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    63
223
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    64
class NetworkServerProjectile : public Projectile {
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    65
    private:
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    66
        NetworkServer &server;
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    67
        NetworkObject_Server obj;
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    68
    
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    69
    public:
263
8c999cf4c182 weapon projectile radiuses and fix network play (local_player == NULL, Rope releasing upon being hit
terom
parents: 241
diff changeset
    70
        NetworkServerProjectile (NetworkServer &server, Vector position, Vector velocity, float explosionRadius, float radius, TickCount age);
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    71
    
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    72
    protected:
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
    73
        virtual void onDestroy (Vector position, bool removeGround);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    74
};
2fcaf54ed37b basic network-projectiles
terom
parents: 209
diff changeset
    75
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    76
#endif