src/Network/Client.hh
author Tero Marttila <terom@fixme.fi>
Tue, 20 Jan 2009 23:30:18 +0200
changeset 408 e6cfc44266af
parent 400 d64bf28c4340
child 431 c6d7272a164b
permissions -rw-r--r--
reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
#ifndef NETWORKCLIENT_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#define NETWORKCLIENT_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
400
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     4
/**
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     5
 * @file
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     6
 *
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     7
 * Game client implementation
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     8
 */
d64bf28c4340 more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents: 381
diff changeset
     9
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    10
// forward-declare
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
    11
class NetworkClientConnect;
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    12
class NetworkClient;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    13
class NetworkClientLocalPlayer;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    14
class NetworkClientRemotePlayer;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    15
332
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    16
#include "../GameState.hh"
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    17
#include "../Engine.hh"
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    18
#include "Session.hh"
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    19
#include "Object.hh"
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    20
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    21
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    22
 * Our specialized NetworkObject_ClientController that overrides handle_create to create the right kind of
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    23
 * object (a subclass of NetowrkClientObject).
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    24
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    25
class NetworkClientController : public NetworkObject_ClientController {
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    26
    protected:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    27
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    28
         * The NetworkClient
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    29
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    30
        NetworkClient &client;
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
    31
        
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    32
    public:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    33
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    34
         * Control objects on the given client using the client.netsession's NETCHAN_CORE channel
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    35
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    36
        NetworkClientController (NetworkClient &client);
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    37
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    38
    protected:
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    39
        /**
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    40
         * We override handle_create from NetworkObject_ClientController to call one of the on_* methods, which creates
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    41
         * a NetworkClientObject subclass
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    42
         *
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    43
         * @see NetworkObject_ClientController::handle_create
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    44
         */
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    45
        virtual void handle_create (NetworkObjectID obj_id, NetworkMessageID msg_id, NetworkPacketInput &pkt, NetworkNode *node);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    46
        
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    47
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    48
         * Handle NETMSG_SERVER_HELLO -> NetworkClientLocalPlayer
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    49
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    50
        void on_server_hello (NetworkObjectID obj_id, NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    51
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    52
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    53
         * Handle NETMSG_PLAYER_INFO -> NetworkClientRemotePlayer
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    54
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    55
        void on_player_info (NetworkObjectID obj_id, NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    56
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    57
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    58
         * Handle NETMSG_PLAYER_JOIN -> NetworkClientRemotePlayer
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    59
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    60
        void on_player_join (NetworkObjectID obj_id, NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    61
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    62
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    63
         * Handle NETMSG_PROJECTILE_PLAYER_FIRED -> NetworkClientProjectile
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    64
         */
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 274
diff changeset
    65
        void on_projectile_player_fired (NetworkObjectID obj_id, NetworkPacketInput &pkt);
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    66
};
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    67
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    68
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    69
 * Our NetworkClient, that connects to a NetworkServer. This has the GameState, NetworkSession, NetworkClientController, etc.
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    70
 */
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    71
class NetworkClient {
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    72
    friend class NetworkClientController;
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    73
    friend class NetworkClientObject;
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
    74
    friend class NetworkClientPlayerBase;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    75
    friend class NetworkClientLocalPlayer;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    76
    friend class NetworkClientRemotePlayer;
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
    77
    friend class NetworkClientProjectile;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    78
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    79
    protected:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    80
        /**
332
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    81
         * The Engine
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    82
         */
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    83
        Engine &engine;
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    84
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
    85
        /**
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    86
         * The GameState
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    87
         */
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    88
        GameState &state;
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    89
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    90
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    91
         * The connect()-mode NetworkSession
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    92
         */
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
    93
        NetworkSession &netsession;
187
f41f894213ca restructure network code a bit
terom
parents: 186
diff changeset
    94
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    95
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    96
         * The server NetworkNode from Netsession::connect
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    97
         */
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    98
        NetworkNode *server;
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
    99
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   100
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   101
         * Our specialized NetworkObject_ClientController
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   102
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   103
        NetworkClientController controller;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   104
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   105
        CL_SlotContainer slots;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   106
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   107
    public:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   108
        /**
381
9b35bc329d23 separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents: 332
diff changeset
   109
         * Create a NetworkClient with the given GameState, connecting a server on the given NetworkEndpoint
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   110
         *
332
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   111
         * @param engine the Engine we're running as
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   112
         * @param state the GameState to use
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   113
         * @param connect_to the address to connect to
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   114
         */
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   115
        NetworkClient (Engine &engine, GameState &state, NetworkSession &netsession, NetworkNode *server);
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   116
    
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   117
    public:
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   118
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   119
         * Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   120
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   121
        void player_quit (NetworkClientRemotePlayer *player);
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   122
};
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   123
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   124
/**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   125
 * This handles the actual connection process to the server, and handles the initial data from the server. Once the
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   126
 * Engine has a game running, we can create the actual NetworkClient object.
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   127
 */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   128
class NetworkClientConnect {
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   129
    protected:
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   130
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   131
         * The Engine we are running under
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   132
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   133
        Engine &engine;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   134
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   135
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   136
         * The NetworkSession we are using
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   137
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   138
        NetworkSession netsession;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   139
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   140
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   141
         * The server we've connected to
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   142
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   143
        NetworkNode *server;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   144
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   145
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   146
         * The NetworkClient that we eventually create
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   147
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   148
        NetworkClient *client;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   149
        
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   150
        CL_SlotContainer slots;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   151
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   152
    public:
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   153
        /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   154
         * Begin the connection process. Once it is complete, we will callback to Engine::networkClientConnected
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   155
         */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   156
        NetworkClientConnect (Engine &engine, const NetworkEndpoint &connect_to);
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   157
    
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   158
    protected:
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   159
        /**
332
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   160
         * We have disconnected from the server
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   161
         */
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   162
        void on_disconnected (void);
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   163
78657bf06302 handle NetworkClient server-disconnect by logging an error and stopping the engine
terom
parents: 330
diff changeset
   164
        /**
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   165
         * Receive the NETCHAN_TERRAIN_ARRAY message from the server and apply it to our GameState::world terrain
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   166
         */
203
3ec7ab40755f send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents: 200
diff changeset
   167
        void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node);
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   168
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   169
        /**
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   170
         * Finished connecting 
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   171
         */
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 400
diff changeset
   172
        void connectDone (Terrain *terrain);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   173
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   174
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   175
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   176
 * Our base NetworkObject_Client object, containing the NetworkClient and a CL_SlotContainer for conveniance
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   177
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   178
class NetworkClientObject : public NetworkObject_Client {
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   179
    protected:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   180
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   181
         * The NetworkClient
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   182
         */
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   183
        NetworkClient &client;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   184
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   185
        CL_SlotContainer slots;
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   186
        
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   187
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   188
         * Construct this using the given client and obj_id, passing the client.controller and obj_id to the
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   189
         * NetworkObject_Client's constructor
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   190
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   191
        NetworkClientObject (NetworkClient &client, NetworkObjectID obj_id);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
   192
};
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
   193
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   194
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   195
 * Our base class for NetworkClient Players, this implements most of the server -> client messages
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   196
 *
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   197
 * This inherits from NetworkClientObject and virtually from Player, as classes should inherit from both this and
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   198
 * LocalPlayer/RemotePlayer
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   199
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   200
class NetworkClientPlayerBase : public NetworkClientObject, public virtual Player {
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   201
    protected:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   202
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   203
         * Dummy-initialize Player, initialize NetworkClientObject, and hook up our signals
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   204
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   205
        NetworkClientPlayerBase (NetworkClient &client, NetworkObjectID obj_id, Vector position);
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   206
    
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   207
    protected:
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   208
        // @{
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   209
        /**
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   210
         * These should never be called directly, always via the network
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   211
         */
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   212
        virtual void spawn (Vector position);
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   213
        virtual void respawn (TimeMS dt);
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   214
        // @}
303
36a502a0023f just ignore NetworkClientPlayerBase::die
terom
parents: 302
diff changeset
   215
        
36a502a0023f just ignore NetworkClientPlayerBase::die
terom
parents: 302
diff changeset
   216
        /**
36a502a0023f just ignore NetworkClientPlayerBase::die
terom
parents: 302
diff changeset
   217
         * Ignore, the servers tells us this
36a502a0023f just ignore NetworkClientPlayerBase::die
terom
parents: 302
diff changeset
   218
         */
36a502a0023f just ignore NetworkClientPlayerBase::die
terom
parents: 302
diff changeset
   219
        virtual void die (bool start_timer = true);
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   220
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   221
    private:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   222
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   223
         * NETMSG_PLAYER_POSITION -> PhysicsObject::updatePhysics
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   224
         */
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   225
        void on_position (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   226
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   227
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   228
         * NETMSG_PLAYER_DIG -> Player::handleDig
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   229
         */
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   230
        void on_dig (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   231
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   232
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   233
         * NETMSG_PLAYER_WEAPON_CHANGE -> Player::rope.handleChangeWeapon
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   234
         */
239
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 224
diff changeset
   235
        void on_weapon_change (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   236
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   237
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   238
         * NETMSG_PLAYER_ROPE_THROW -> Player::rope.updateState(ROPE_FLYING)
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   239
         */
241
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
   240
        void on_rope_throw (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   241
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   242
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   243
         * NETMSG_PLAYER_ROPE_FIXED -> Player::rope.updateState(ROPE_FIXED)
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   244
         */
241
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
   245
        void on_rope_fixed (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   246
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   247
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   248
         * NETMSG_PLAYER_ROPE_RELEASED -> Player::rope.updateState(ROPE_FOLDED)
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   249
         */
241
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
   250
        void on_rope_released (NetworkPacketInput &pkt);
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   251
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   252
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   253
         * NETMSG_PLAYER_ROPE_LENGTH -> Player::Rope.updateLength
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   254
         */
241
e95b1602d836 implement the ROT (Rope Over TCP) protocol
terom
parents: 239
diff changeset
   255
        void on_rope_length (NetworkPacketInput &pkt);
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   256
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   257
        /**
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   258
         * NETMSG_PLAYER_SPAWN -> Player::spawn
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   259
         */
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   260
        void on_spawn (NetworkPacketInput &pkt);
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   261
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   262
        /**
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   263
         * NETMSG_PLAYER_Die -> Player::die
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   264
         */
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 296
diff changeset
   265
        void on_die (NetworkPacketInput &pkt);
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   266
};
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   267
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   268
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   269
 * Our NetworkClientPlayerBase + LocalPlayer specialization, this lets us handle local input
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   270
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   271
class NetworkClientLocalPlayer : public NetworkClientPlayerBase, public LocalPlayer {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   272
    public:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   273
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   274
         * Calls NetworkClientPlayerBase/Player constructors, calls GameState::setLocalPlayer
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   275
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   276
        NetworkClientLocalPlayer (NetworkClient &client, NetworkObjectID obj_id, Vector position);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   277
        
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   278
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   279
         * Overriden from LocalPlayer to send a NETMSG_CLIENT_INPUT message without executing LocalPlayer::handleInput
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   280
         * locally
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   281
         */
277
40f4a03917e2 fix NetworkClient handleInput
terom
parents: 276
diff changeset
   282
        virtual void handleInput (PlayerInput input, TimeMS dt);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   283
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   284
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   285
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   286
 * Our NetworkClientPlayerBase + RemotePlayer specialization, this lets us handle players quitting
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   287
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   288
class NetworkClientRemotePlayer : public NetworkClientPlayerBase, public RemotePlayer {
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   289
    public:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   290
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   291
         * Calls NetworkClientPlayerBase/Player constructors and hooks up signals
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   292
         */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   293
        NetworkClientRemotePlayer (NetworkClient &client, NetworkObjectID obj_id, Vector position);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   294
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   295
    private:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   296
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   297
         * Calls NetworkClient::player_quit, and then destroys ourselves
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   298
         */
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 187
diff changeset
   299
        void on_quit (NetworkPacketInput &pkt);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   300
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   301
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   302
/**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   303
 * A Projectile that was created on the server
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   304
 */
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 263
diff changeset
   305
class NetworkClientProjectile : public NetworkClientObject, public Projectile {
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
   306
    public:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   307
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   308
         * Call Projectile's constructor, hook up signals and call player->weaponFired
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   309
         */
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 274
diff changeset
   310
        NetworkClientProjectile (NetworkClient &client, NetworkObjectID obj_id, Player *player, Vector position, 
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 274
diff changeset
   311
                Vector velocity, Weapon *weapon);
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   312
    
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   313
    protected:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   314
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   315
         * Overrides Projectile::onDestroy to ignore this, as we must wait for the server to tell us where it impacted
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   316
         * so that we can remove the ground reliably
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   317
         */
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   318
        virtual void onDestroy (Vector position, bool removeGround);
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   319
        
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   320
        /**
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   321
         * Overrides Projectile::onHitPlayer to ignore this, as we must wait for the server to tell us if it really did
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   322
         * happen.
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   323
         */
330
dcc47278e5ab fix Network Projectile::onHitPlayer
terom
parents: 303
diff changeset
   324
        virtual void onHitPlayer (Player *player);
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   325
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   326
    private:
294
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   327
        /**
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   328
         * NETMSG_PROJECTILE_DESTROY -> Projectile::onDestory
fd58e7d01bec finish network documentation
terom
parents: 277
diff changeset
   329
         */
224
e6faefba2ec1 fixed logger, and network projectiles should work reasonably well now
terom
parents: 223
diff changeset
   330
        void on_destroy (NetworkPacketInput &pkt);
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   331
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   332
        /**
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   333
         * NETMSG_PROJECTILE_HIT_PLAYER -> Projectile::onHitPlayer
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   334
         */
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 294
diff changeset
   335
        void on_hit_player (NetworkPacketInput &pkt);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
   336
};
2fcaf54ed37b basic network-projectiles
terom
parents: 221
diff changeset
   337
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   338
#endif