00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CEL_PL_NETWORK__
00021 #define __CEL_PL_NETWORK__
00022
00023 #include "cstypes.h"
00024 #include "csutil/scf.h"
00025 #include "csutil/strset.h"
00026
00027 struct iCelEntity;
00028 struct iCelDataBuffer;
00029 enum celNetworkGameType;
00030 enum celServerNetworkState;
00031 enum celPlayerNetworkState;
00032 struct celGame;
00033 class celGameInfo;
00034 class celPlayer;
00035 struct iCelPlayerList;
00036 class celServerEventData;
00037 class celClientEventData;
00038 class celNetworkLinkData;
00039 class celGameFactoryManager;
00040 class celGameClientManager;
00041 class celGameServerManager;
00042 struct celNetworkServerStats;
00043 struct celNetworkPlayerStats;
00044 struct celNetworkServerTotalStats;
00045
00050 struct iCelGame : public virtual iBase
00051 {
00052 SCF_INTERFACE (iCelGame, 0, 0, 1);
00053
00057 virtual celNetworkGameType GetGameType () const = 0;
00058
00062 virtual celGameInfo* GetGameInfo () = 0;
00063
00068 virtual bool IsServerAvailable () const = 0;
00069
00073 virtual iCelGameServer* GetGameServer () const = 0;
00074
00079 virtual bool IsClientAvailable () const = 0;
00080
00084 virtual iCelGameClient* GetGameClient () const = 0;
00085 };
00086
00098 struct iCelGameFactory : public virtual iBase
00099 {
00100 SCF_INTERFACE (iCelGameFactory, 1, 0, 0);
00101
00108 virtual void SetGameName (const char* game_name) = 0;
00109
00114 virtual const char* GetGameName () const = 0;
00115
00128 virtual void SetProtocolVersion (const char* protocol_version) = 0;
00129
00135 virtual const char* GetProtocolVersion () const = 0;
00136
00143 virtual void RegisterGameFactoryManager
00144 (celGameFactoryManager* manager) = 0;
00145
00155 virtual void StartSearchForGameList (celNetworkGameType game_type,
00156 celGameInfo* filter = 0) = 0;
00157
00162 virtual void StopSearchForGameList () = 0;
00163
00167 virtual iCelGame* GetCurrentGame () const = 0;
00168
00182 virtual bool CreateNewGame (celNetworkGameType game_type,
00183 celGameInfo* game_info, celPlayer* player = 0) = 0;
00184
00197 virtual bool ConnectGame (celGameInfo* game_info,
00198 celPlayer* player) = 0;
00199
00205 virtual bool CloseGame () = 0;
00206
00210 virtual void StartRecordingGame (const char* filename) = 0;
00211
00215 virtual void StopRecordingGame () = 0;
00216
00223 virtual void StartPlayBackGame (const char* filename,
00224 csTicks start_time, csTicks stop_time) = 0;
00225 };
00226
00237 class celGameFactoryManager
00238 {
00239 public:
00240 virtual ~celGameFactoryManager () {}
00241
00250 virtual void GameInfoReceived (celGameInfo* game_info,
00251 csTicks server_latency) {}
00252
00268 virtual void ServerNetworkStateChanged (celServerNetworkState new_state,
00269 celServerNetworkState previous_state, const char* reason = "") = 0;
00270
00282 virtual bool InitClient (iCelGame* game) { return true; }
00283
00291 virtual bool InitServer (iCelGame* game) { return true; }
00292
00301 virtual csPtr<iCelDataBuffer> GetClientEventBaseline (
00302 celClientEventType event_type) { return 0; }
00303
00309 virtual csPtr<iCelDataBuffer> GetServerEventBaseline (
00310 celServerEventType event_type) { return 0; }
00311
00317 virtual csPtr<iCelDataBuffer> GetNetworkLinkBaseline (
00318 celNetworkLinkType link_type) { return 0; }
00319
00320 };
00321
00335 struct iCelGameServer : public virtual iBase
00336 {
00337 SCF_INTERFACE (iCelGameServer, 1, 0, 0);
00338
00343 virtual void RegisterServerManager (celGameServerManager* manager) = 0;
00344
00349 virtual void SetAdministrator (celPlayer* new_admin) = 0;
00350
00355 virtual celPlayer* GetAdministrator () = 0;
00356
00360 virtual iCelPlayerList* GetPlayerList () = 0;
00361
00365 virtual celPlayerNetworkState GetPlayerState (celPlayer* player) = 0;
00366
00372 virtual void KickPlayer (celPlayer* player, const char* reason) = 0;
00373
00381 virtual iCelPlayerList* CreateChannel (csStringID channel_id) = 0;
00382
00387 virtual void RemoveChannel (csStringID channel_id) = 0;
00388
00392 virtual void LaunchServerEvent (celPlayer* player,
00393 celServerEventData &event_data) = 0;
00394
00398 virtual void LaunchServerEvent (csStringID channel_id,
00399 celServerEventData &event_data) = 0;
00400
00417 virtual void SetNetworkLink (celPlayer* player,
00418 celNetworkLinkData &link_data, bool player_controlled) = 0;
00419
00429 virtual void ChangeLinkControl (iCelEntity* entity, celPlayer* player,
00430 bool player_controlled) = 0;
00431
00442 virtual void SetNetworkLink (csStringID channel_id,
00443 celNetworkLinkData &link_data) = 0;
00444
00449 virtual void RemoveNetworkLink (iCelEntity* entity, celPlayer* player) = 0;
00450
00455 virtual void RemoveNetworkLink (iCelEntity* entity,
00456 csStringID channel_id) = 0;
00457
00465 virtual void ChangeLevel (celGameInfo* new_game) = 0;
00466
00472 virtual void SetNetworkPeriod (csTicks period) = 0;
00473
00478 virtual void SetMaximumBandwidth (size_t width) = 0;
00479
00485 virtual void SetClientTimeOut (csTicks timeout) = 0;
00486
00490 virtual void GetNetworkPlayerStats (celPlayer* player,
00491 celNetworkPlayerStats& stats) const = 0;
00492
00496 virtual void GetNetworkTotalStats (
00497 celNetworkPlayerTotalStats& stats) const = 0;
00498 };
00499
00512 struct iCelGameClient : public virtual iBase
00513 {
00514 SCF_INTERFACE (iCelGameClient, 0, 0, 1);
00515
00520 virtual void RegisterClientManager (celGameClientManager* manager) = 0;
00521
00525 virtual celPlayer* GetPlayer () = 0;
00526
00532 virtual void UpdatePlayer (celPlayer* player) = 0;
00533
00537 virtual csTicks ConvertServerClock (csTicks server_time) const = 0;
00538
00543 virtual uint GetMappedID (uint entity_id) const = 0;
00544
00549 virtual iCelEntity* GetMappedEntity (uint entity_id) const = 0;
00550
00554 virtual void SetReady () = 0;
00555
00559 virtual void LaunchClientEvent (celClientEventData &event_data) = 0;
00560
00564 virtual void SetNetworkPeriod (csTicks period) = 0;
00565
00570 virtual void SetMaximumBandwidth (size_t width) = 0;
00571
00576 virtual void SetServerTimeOut (csTicks timeout) = 0;
00577
00581 virtual void GetNetworkStats (celNetworkServerStats& stats) const = 0;
00582 };
00583
00595 class celGameServerManager
00596 {
00597 public:
00598 virtual ~celGameServerManager () {};
00599
00606 virtual bool AuthorizePlayer (celPlayer* player, csString& reason) = 0;
00607
00613 virtual celPlayer* ValidatePlayerUpdate (celPlayer* previous_player_data) = 0;
00614
00618 virtual void PlayerNetworkStateChanged (celPlayer* player,
00619 celPlayerNetworkState new_state,
00620 celPlayerNetworkState previous_state) = 0;
00621
00625 virtual void HandleClientEvent (celPlayer* player,
00626 celClientEventType event_type, csTicks event_time,
00627 iCelDataBuffer* event_data) = 0;
00628
00637 virtual void PersistenceProblem (celPlayer* player, iCelEntity* entity,
00638 iCelPropertyClass* pc, celPersistenceResult persist_code) = 0;
00639
00644 virtual void ServerEnd () = 0;
00645 };
00646
00657 class celGameClientManager
00658 {
00659 public:
00660 virtual ~celGameClientManager () {};
00661
00665 virtual void PlayerValidated (celPlayer* player) = 0;
00666
00670 virtual void HandleServerEvent (celServerEventType event_type,
00671 csTicks event_time, iCelDataBuffer* event_data) = 0;
00672
00688 virtual iCelEntity* CreateNetworkLinkTarget (celNetworkLinkType link_type,
00689 csTicks creation_time, iCelPersistentDataList* creation_data,
00690 bool player_controlled) = 0;
00691
00705 virtual void NetworkLinkControlChanged (iCelEntity* entity,
00706 bool player_controlled) = 0;
00707
00712 virtual void NetworkLinkRemoved (csTicks deletion_time,
00713 iCelEntity* entity) = 0;
00714
00719 virtual void LevelChanged (celGameInfo* new_game) = 0;
00720
00725 virtual void ClientEnd () = 0;
00726 };
00727
00728 #endif // __CEL_PL_NETWORK__