84 /** |
85 /** |
85 * The GameState |
86 * The GameState |
86 */ |
87 */ |
87 GameState &state; |
88 GameState &state; |
88 |
89 |
|
90 /** |
|
91 * The connect()-mode NetworkSession |
|
92 */ |
|
93 NetworkSession &netsession; |
|
94 |
|
95 /** |
|
96 * The server NetworkNode from Netsession::connect |
|
97 */ |
|
98 NetworkNode *server; |
|
99 |
|
100 /** |
|
101 * Our specialized NetworkObject_ClientController |
|
102 */ |
|
103 NetworkClientController controller; |
|
104 |
89 CL_SlotContainer slots; |
105 CL_SlotContainer slots; |
90 |
|
91 /** |
|
92 * The connect()-mode NetworkSession |
|
93 */ |
|
94 NetworkSession netsession; |
|
95 |
|
96 /** |
|
97 * The server NetworkNode from Netsession::connect |
|
98 */ |
|
99 NetworkNode *server; |
|
100 |
|
101 /** |
|
102 * Our specialized NetworkObject_ClientController |
|
103 */ |
|
104 NetworkClientController controller; |
|
105 |
106 |
106 public: |
107 public: |
107 /** |
108 /** |
108 * Create a NetworkClient with the given GameState, connecting a server on the given NetworkEndpoint |
109 * Create a NetworkClient with the given GameState, connecting a server on the given NetworkEndpoint |
109 * |
110 * |
110 * @param engine the Engine we're running as |
111 * @param engine the Engine we're running as |
111 * @param state the GameState to use |
112 * @param state the GameState to use |
112 * @param connect_to the address to connect to |
113 * @param connect_to the address to connect to |
113 */ |
114 */ |
114 NetworkClient (Engine &engine, GameState &state, const NetworkEndpoint &connect_to); |
115 NetworkClient (Engine &engine, GameState &state, NetworkSession &netsession, NetworkNode *server); |
|
116 |
|
117 public: |
|
118 /** |
|
119 * Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently |
|
120 */ |
|
121 void player_quit (NetworkClientRemotePlayer *player); |
|
122 }; |
|
123 |
|
124 /** |
|
125 * This handles the actual connection process to the server, and handles the initial data from the server. Once the |
|
126 * Engine has a game running, we can create the actual NetworkClient object. |
|
127 */ |
|
128 class NetworkClientConnect { |
|
129 protected: |
|
130 /** |
|
131 * The Engine we are running under |
|
132 */ |
|
133 Engine &engine; |
|
134 |
|
135 /** |
|
136 * The NetworkSession we are using |
|
137 */ |
|
138 NetworkSession netsession; |
|
139 |
|
140 /** |
|
141 * The server we've connected to |
|
142 */ |
|
143 NetworkNode *server; |
|
144 |
|
145 /** |
|
146 * The NetworkClient that we eventually create |
|
147 */ |
|
148 NetworkClient *client; |
|
149 |
|
150 CL_SlotContainer slots; |
|
151 |
|
152 public: |
|
153 /** |
|
154 * Begin the connection process. Once it is complete, we will callback to Engine::networkClientConnected |
|
155 */ |
|
156 NetworkClientConnect (Engine &engine, const NetworkEndpoint &connect_to); |
115 |
157 |
116 protected: |
158 protected: |
117 /** |
159 /** |
118 * We have disconnected from the server |
160 * We have disconnected from the server |
119 */ |
161 */ |
121 |
163 |
122 /** |
164 /** |
123 * Receive the NETCHAN_TERRAIN_ARRAY message from the server and apply it to our GameState::world terrain |
165 * Receive the NETCHAN_TERRAIN_ARRAY message from the server and apply it to our GameState::world terrain |
124 */ |
166 */ |
125 void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node); |
167 void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node); |
126 |
168 |
127 public: |
169 /** |
128 /** |
170 * Finished connecting |
129 * Called by NetworkClientRemotePlayer when they get disconnected. Doesn't do anything currently |
171 */ |
130 */ |
172 void connectDone (Terrain *terrain); |
131 void player_quit (NetworkClientRemotePlayer *player); |
|
132 }; |
173 }; |
133 |
174 |
134 /** |
175 /** |
135 * Our base NetworkObject_Client object, containing the NetworkClient and a CL_SlotContainer for conveniance |
176 * Our base NetworkObject_Client object, containing the NetworkClient and a CL_SlotContainer for conveniance |
136 */ |
177 */ |