Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

CLIENT.H

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  Client.h                                                                            */
00003 /*                                                                                      */
00004 /*  Author: John Pollard                                                                */
00005 /*  Description:                                                                        */
00006 /*                                                                                      */
00007 /*  Copyright (c) 1997, 1999, Eclipse Entertainment; All rights reserved.               */
00008 /*                                                                                      */
00009 /*  See the accompanying file LICENSE.TXT for terms on the use of this library.         */
00010 /*  This library is distributed in the hope that it will be useful but WITHOUT          */
00011 /*  ANY WARRANTY OF ANY KIND and without any implied warranty of MERCHANTABILITY        */
00012 /*  or FITNESS FOR ANY PURPOSE.  Refer to LICENSE.TXT for more details.                 */
00013 /*                                                                                      */
00014 /****************************************************************************************/
00015 #ifndef CLIENT_H
00016 #define CLIENT_H
00017 
00018 //#include <Windows.h>
00019 #include <stdio.h>
00020 
00021 #include "VidMode.h"
00022 
00023 #include "Genesis.h"
00024 #include "Errorlog.h"
00025 #include "Quatern.h"
00026 #include "Ram.h"
00027 
00028 #include "Game\Game.h"
00029 #include "Game\GPlayer.h"
00030 #include "Game\GenVSI.h"
00031 
00032 #include "GameMgr.h"
00033 #include "NetMgr.h"
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 //================================================================================================
00040 //================================================================================================
00041 typedef struct  Client_Client           Client_Client;
00042 
00043 #define CLIENT_MAX_PROC_INDEX                   512
00044 #define CLIENT_MAX_TEMP_PLAYERS                 10
00045 
00046 #define CLIENT_DEMO_NONE                                0
00047 #define CLIENT_DEMO_PLAY                                1
00048 #define CLIENT_DEMO_RECORD                              2
00049 
00050 typedef enum
00051 {
00052         ClientMode_Invalid = 0,
00053         ClientMode_Dumb,                                                // Client does nothing but what server says to do...(a local client with a server)
00054         ClientMode_Proxy,                                               // Client predicts while waiting for server updates (a client without a server)
00055 } Client_Mode;
00056 
00057 //================================================================================================
00058 //================================================================================================
00059 #define CLIENT_MAX_MOVE_STACK   256
00060 
00061 typedef struct Client_Move
00062 {
00063         float                   Time;
00064         float                   Delta;
00065         float                   ForwardSpeed;
00066         float                   Pitch;
00067         float                   Yaw;
00068         geVec3d                 Pos;
00069         uint16                  ButtonBits;
00070         uint16                  CurrentWeapon;
00071 
00072         struct Client_Move      *Next;
00073 } Client_Move;
00074 
00075 // Info about the clients connected to the server
00076 typedef struct Client_ClientInfo
00077 {
00078         geBoolean       Active;                 // == GE_TRUE if this client is active on the server
00079         char            Name[64];
00080         int32           Score;
00081         int32           Health;
00082 
00083         int32           OldScore;
00084         int32           OldHealth;
00085 
00086 } Client_ClientInfo;
00087 
00088 typedef enum
00089 {
00090         STATE_Disable,
00091         STATE_Normal,
00092         STATE_Selected,
00093         STATE_Warning,
00094 } Client_StatusState;
00095 
00096 // 6 menu elements, with 3 states (normal/selected/inactive)
00097 typedef struct Client_StatusElement
00098 {
00099         geBitmap                        *Bitmaps[4];
00100         int32                           XPos;
00101         int32                           YPos;
00102         int32                           Print1XPos;
00103         int32                           Print1YPos;
00104         int32                           Low;                                            // Display warning, when amount gets lower than this number
00105         Client_StatusState      State;
00106 
00107 } Client_StatusElement;
00108 
00109 typedef struct Client_StatusBar
00110 {
00111         Client_StatusElement    Elements[6];
00112 
00113 } Client_StatusBar;
00114 
00115 #define CLIENT_MAX_DEMOS                        10
00116 #define CLIENT_MAX_DEMO_NAME_SIZE       64
00117 
00118 typedef struct
00119 {
00120         int32           Mode;
00121 
00122         int32           NumDemos;       
00123         char            DemoNames[CLIENT_MAX_DEMOS][CLIENT_MAX_DEMO_NAME_SIZE];
00124         int32           CurrentDemo;
00125 
00126         FILE            *File;                                                  // Current demo file opened (only one at a time)
00127 
00128         geBoolean       OriginalSpeed;                                  // Demo should run at original speed
00129 } Client_Demo;
00130 
00131 typedef struct Client_Client
00132 {
00133         Client_Client           *Self1;
00134         HWND                            hWnd;
00135 
00136         VidMode                         VidMode;
00137         Client_Mode                     Mode;
00138         geEngine                        *Engine;
00139         NetMgr                          *NMgr;
00140         GameMgr                         *GMgr;
00141 
00142         Client_StatusBar        StatusBar;
00143 
00144         NetMgr_NetState         NetState;
00145         geBoolean                       MultiPlayer;                    // == GE_TEUE if the client is in a multi player game
00146 
00147         geCSNetMgr_NetClient    geClient;                       // Info about us as a client (NetId, Name, etc...)
00148 
00149         int32                           ViewPlayer;
00150         geXForm3d                       ViewXForm;
00151 
00152         float                           Time;
00153         float                           Ping;                                           // Current ping info from server
00154         float                           NetTime;
00155         geBoolean                       NetTimeGood;                            // Last net time was recent...
00156         float                           OldNetTime;
00157         float                           TempTime;
00158         float                           ServerPingBack;                         // Time stamp from server, -1 if no time from server this frame
00159 
00160         GenVSI_CMove            Move;                                           // Current move intentions
00161 
00162         float                           ForwardSpeed;                           // Forward/Back speed
00163         float                           UpwardSpeed;                            // Forward/Back speed
00164         geVec3d                         Angles;                                         // Orientation
00165         uint16                          ButtonBits;                                     // Current pressed buttons...
00166 
00167         Client_Move                     *LastMove;
00168         Client_Move                     *MoveStack;
00169 
00170         GPlayer                         Players[NETMGR_MAX_PLAYERS];
00171         GPlayer                         TempPlayers[CLIENT_MAX_TEMP_PLAYERS];           // For pre-prediction
00172         Fx_Player                       TempFxPlayers[CLIENT_MAX_TEMP_PLAYERS];
00173 
00174         // Fx Players NOTE - That Players index into FxPlayers using there index nbumber (Player - Client->Players)
00175         Fx_Player                       FxPlayers[NETMGR_MAX_PLAYERS];
00176 
00177         // Proc adresses
00178         void                            *ProcIndex[CLIENT_MAX_PROC_INDEX];
00179 
00180         // Scores, Health, etc about all clients connected from server
00181         Client_ClientInfo       ClientInfo[NETMGR_MAX_CLIENTS];
00182         int32                           ClientIndex;    // Index in list above where our info is stored...
00183 
00184         uint16                          Inventory[MAX_PLAYER_ITEMS];
00185         uint16                          CurrentWeapon;
00186         uint16                          OldWeapon;
00187 
00188         uint16                          OldInventory[MAX_PLAYER_ITEMS];
00189 
00190         //Server_Client         ServerClient;
00191         int32                           ClientPlayer;
00192 
00193         Client_Demo                     Demo;                                   // Demo related info
00194 
00195         float                           NextSend;
00196 
00197         GenVSI                          GenVSI;
00198 
00199         Client_Client           *Self2;
00200 } Client_Client;
00201 
00202 
00203 //================================================================================================
00204 //================================================================================================
00205 Client_Client           *Client_Create( geEngine        *Engine, 
00206                                                                         Client_Mode Mode, 
00207                                                                         GameMgr         *GMgr, 
00208                                                                         NetMgr          *NMgr, 
00209                                                                         VidMode         VidMode,
00210                                                                         int32           DemoMode,
00211                                                                         const char      *DemoName,
00212                                                                         geBoolean       MultiPlayer);
00213 
00214 void                            Client_Destroy(Client_Client *Client);
00215 geBoolean                       Client_IsValid(const Client_Client *Client);
00216 geBoolean                       Client_CreateStatusBar(Client_Client *Client, VidMode VidMode);
00217 void                            Client_DestroyStatusBar(Client_Client *Client);
00218 void                            Client_DestroyALLPlayers(Client_Client *Client);
00219 void                            Client_FreeALLResources(Client_Client *Client);
00220 void                            Client_FreeResourcesForNewWorld(Client_Client *Client);
00221 void                            Client_NewWorldDefaults(Client_Client *Client);
00222 geBoolean                       Client_Frame(Client_Client *Client, float Time);
00223 geBoolean                       Client_RenderFrame(Client_Client *Client, float Time);
00224                                         
00225 Client_Move                     *Client_PeekMove(Client_Client *Client);
00226 void                            Client_RemoveFirstMove(Client_Client *Client);
00227 
00228 geBoolean                       Client_SendMove(Client_Client *Client, float Time);
00229 
00230 geBoolean                       Client_UpdateSinglePlayer(Client_Client *Client, GPlayer *Player, float Ratio, float Time, geBoolean TempPlayer);
00231 GPlayer                         *Client_ParsePlayerData(Client_Client *Client, Buffer_Data *Buffer, GPlayer *FakePlayer);
00232 
00233 geBoolean                       Client_ChangeNetState(Client_Client *Client, NetMgr_NetState NewNetState);
00234 
00235 geBoolean                       Client_SetDemo(Client_Client *Client, int32 DemoNum);
00236 geBoolean                       Client_ReadServerMessages(Client_Client *Client, Buffer_Data *Buffer);
00237 geBoolean                       Client_SetupDemos(Client_Client *Client, int32 Mode, const char *DemoFile);
00238 void                            Client_RefreshStatusBar(int32 NumPages);
00239 
00240 void                            Client_DestroyTempPlayer(Client_Client *Client, GPlayer *Player);
00241 GPlayer                         *Client_GetPlayer(Client_Client *Client, int32 Index);
00242 
00243 #ifdef __cplusplus
00244 }
00245 #endif
00246 
00247 #endif

Generated on Tue Sep 30 12:35:25 2003 for GTestAndEngine by doxygen 1.3.2