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

CLIENT.H File Reference

#include <stdio.h>
#include "VidMode.h"
#include "Genesis.h"
#include "Errorlog.h"
#include "Quatern.h"
#include "Ram.h"
#include "Game\Game.h"
#include "Game\GPlayer.h"
#include "Game\GenVSI.h"
#include "GameMgr.h"
#include "NetMgr.h"

Go to the source code of this file.

Compounds

struct  Client_Client
struct  Client_ClientInfo
struct  Client_Demo
struct  Client_Move
struct  Client_StatusBar
struct  Client_StatusElement

Defines

#define CLIENT_MAX_PROC_INDEX   512
#define CLIENT_MAX_TEMP_PLAYERS   10
#define CLIENT_DEMO_NONE   0
#define CLIENT_DEMO_PLAY   1
#define CLIENT_DEMO_RECORD   2
#define CLIENT_MAX_MOVE_STACK   256
#define CLIENT_MAX_DEMOS   10
#define CLIENT_MAX_DEMO_NAME_SIZE   64

Typedefs

typedef Client_Client Client_Client
typedef Client_Move Client_Move
typedef Client_ClientInfo Client_ClientInfo
typedef Client_StatusElement Client_StatusElement
typedef Client_StatusBar Client_StatusBar

Enumerations

enum  Client_Mode { ClientMode_Invalid = 0, ClientMode_Dumb, ClientMode_Proxy }
enum  Client_StatusState { STATE_Disable, STATE_Normal, STATE_Selected, STATE_Warning }

Functions

Client_ClientClient_Create (geEngine *Engine, Client_Mode Mode, GameMgr *GMgr, NetMgr *NMgr, VidMode VidMode, int32 DemoMode, const char *DemoName, geBoolean MultiPlayer)
void Client_Destroy (Client_Client *Client)
geBoolean Client_IsValid (const Client_Client *Client)
geBoolean Client_CreateStatusBar (Client_Client *Client, VidMode VidMode)
void Client_DestroyStatusBar (Client_Client *Client)
void Client_DestroyALLPlayers (Client_Client *Client)
void Client_FreeALLResources (Client_Client *Client)
void Client_FreeResourcesForNewWorld (Client_Client *Client)
void Client_NewWorldDefaults (Client_Client *Client)
geBoolean Client_Frame (Client_Client *Client, float Time)
geBoolean Client_RenderFrame (Client_Client *Client, float Time)
Client_MoveClient_PeekMove (Client_Client *Client)
void Client_RemoveFirstMove (Client_Client *Client)
geBoolean Client_SendMove (Client_Client *Client, float Time)
geBoolean Client_UpdateSinglePlayer (Client_Client *Client, GPlayer *Player, float Ratio, float Time, geBoolean TempPlayer)
GPlayerClient_ParsePlayerData (Client_Client *Client, Buffer_Data *Buffer, GPlayer *FakePlayer)
geBoolean Client_ChangeNetState (Client_Client *Client, NetMgr_NetState NewNetState)
geBoolean Client_SetDemo (Client_Client *Client, int32 DemoNum)
geBoolean Client_ReadServerMessages (Client_Client *Client, Buffer_Data *Buffer)
geBoolean Client_SetupDemos (Client_Client *Client, int32 Mode, const char *DemoFile)
void Client_RefreshStatusBar (int32 NumPages)
void Client_DestroyTempPlayer (Client_Client *Client, GPlayer *Player)
GPlayerClient_GetPlayer (Client_Client *Client, int32 Index)


Define Documentation

#define CLIENT_DEMO_NONE   0
 

Definition at line 46 of file CLIENT.H.

Referenced by Client_Create(), Client_ReadServerMessages(), and ReadDemoIni().

#define CLIENT_DEMO_PLAY   1
 

Definition at line 47 of file CLIENT.H.

Referenced by BuildClientViewXForm(), Client_Frame(), Client_ReadServerMessages(), Client_SetDemo(), Client_SetupDemos(), ReadServerMessages(), and UpdatePlayers().

#define CLIENT_DEMO_RECORD   2
 

Definition at line 48 of file CLIENT.H.

Referenced by Client_ReadServerMessages(), and Client_SetupDemos().

#define CLIENT_MAX_DEMO_NAME_SIZE   64
 

Definition at line 116 of file CLIENT.H.

Referenced by ParseDemoName().

#define CLIENT_MAX_DEMOS   10
 

Definition at line 115 of file CLIENT.H.

Referenced by ReadDemoIni().

#define CLIENT_MAX_MOVE_STACK   256
 

Definition at line 59 of file CLIENT.H.

#define CLIENT_MAX_PROC_INDEX   512
 

Definition at line 43 of file CLIENT.H.

Referenced by Client_GetProcIndex(), and Client_ProcIndex().

#define CLIENT_MAX_TEMP_PLAYERS   10
 

Definition at line 44 of file CLIENT.H.

Referenced by Client_DestroyALLPlayers(), Client_SpawnTempPlayer(), ControlTempPlayers(), and UpdateProxyPlayer().


Typedef Documentation

typedef struct Client_Client Client_Client
 

Definition at line 41 of file CLIENT.H.

typedef struct Client_ClientInfo Client_ClientInfo
 

typedef struct Client_Move Client_Move
 

typedef struct Client_StatusBar Client_StatusBar
 

typedef struct Client_StatusElement Client_StatusElement
 


Enumeration Type Documentation

enum Client_Mode
 

Enumeration values:
ClientMode_Invalid 
ClientMode_Dumb 
ClientMode_Proxy 

Definition at line 50 of file CLIENT.H.

Referenced by Host_Create().

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;

enum Client_StatusState
 

Enumeration values:
STATE_Disable 
STATE_Normal 
STATE_Selected 
STATE_Warning 

Definition at line 88 of file CLIENT.H.

Referenced by DrawStatusBar().

00089 {
00090         STATE_Disable,
00091         STATE_Normal,
00092         STATE_Selected,
00093         STATE_Warning,
00094 } Client_StatusState;


Function Documentation

geBoolean Client_ChangeNetState Client_Client Client,
NetMgr_NetState  NewNetState
 

Definition at line 2914 of file Client.c.

References Buffer_FillByte(), Buffer_FillSLong(), Buffer_Set(), Client_IsValid(), GE_TRUE, geBoolean, GenVS_Error(), NETMGR_MSG_CLIENT_CONFIRM, NetMgr_SendServerMessage(), Client_Client::NetState, and Client_Client::NMgr.

Referenced by ReadServerMessages().

02915 {
02916         char            Data[128];
02917         Buffer_Data     Buffer;
02918 
02919         assert(Client_IsValid(Client) == GE_TRUE);
02920 
02921         Client->NetState = NewNetState;
02922                                                                 
02923         // Send the confirm msg to the server
02924         Buffer_Set(&Buffer, Data, 128);
02925         Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_CONFIRM);
02926         Buffer_FillSLong(&Buffer, NewNetState);
02927 
02928         if (!NetMgr_SendServerMessage(Client->NMgr, &Buffer, GE_TRUE))
02929                 GenVS_Error("Client_ChangeNetState:  NetMgr_SendServerMessage failed.\n");
02930 
02931         return GE_TRUE;
02932 }

Client_Client* Client_Create geEngine Engine,
Client_Mode  Mode,
GameMgr GMgr,
NetMgr NMgr,
VidMode  VidMode,
int32  DemoMode,
const char *  DemoName,
geBoolean  MultiPlayer
 

Definition at line 184 of file Client.c.

References Buffer_Set(), Client_CreateStatusBar(), CLIENT_DEMO_NONE, Client_Destroy(), Client_FreeALLResources(), Client_Main(), Client_NewWorldDefaults(), Client_SetupDemos(), Client_SetupGenVSI(), Client_Client::ClientPlayer, Console_Printf(), Client_Client::CurrentWeapon, Client_Client::Demo, Engine, Client_Client::Engine, g_Freq, GameMgr_GetConsole(), GE_RAM_ALLOCATE_STRUCT, geErrorLog_AddString, Client_Client::GenVSI, geXForm3d_SetIdentity(), Client_Client::GMgr, Client_Demo::Mode, Client_Client::Mode, Client_Client::MultiPlayer, Client_Client::NetState, NetState_Disconnected, Client_Client::NMgr, NULL, SData, Client_Client::Self1, Client_Client::Self2, SendBuffer, Client_Client::Time, VidMode, Client_Client::VidMode, Client_Client::ViewPlayer, and Client_Client::ViewXForm.

Referenced by Host_Create().

00192 {
00193         geRect          Rect = {0, 0, 0, 0};
00194 
00195         Client_Client   *NewClient;
00196 
00197         NewClient = GE_RAM_ALLOCATE_STRUCT(Client_Client);
00198 
00199         assert(NewClient != NULL);
00200         
00201         if (!NewClient)
00202                 return NULL;
00203 
00204         // We can't clear the client array in SetDefaults.  Because (more)
00205         // Host_SetWorld calls Client_NewWorldDefaults, and that would clear some things like Camera, etc (more)
00206         // that need to hang around.
00207         memset(NewClient, 0, sizeof(Client_Client));
00208 
00209         // Set the sanity check signatures
00210         NewClient->Self1 = NewClient;
00211         NewClient->Self2 = NewClient;
00212 
00213         NewClient->MultiPlayer = MultiPlayer;
00214 
00215         // The client is current disconnected
00216         NewClient->NetState = NetState_Disconnected;
00217 
00218         // Save thes objects
00219         NewClient->GMgr = GMgr;
00220         NewClient->NMgr = NMgr;
00221 
00222         // Save the mode we will operate in...
00223         NewClient->Mode = Mode;
00224 
00225         // And the vidmode
00226         NewClient->VidMode = VidMode;
00227 
00228         // Set some defaults that won't effect anystate of the client
00229         Client_NewWorldDefaults(NewClient);
00230         
00231         // Set initial view xform and player
00232         geXForm3d_SetIdentity(&NewClient->ViewXForm);   
00233         NewClient->ViewPlayer = -1;
00234         NewClient->ClientPlayer = -1;
00235 
00236         NewClient->Engine = Engine;
00237 
00238         NewClient->Time = 0.0f; 
00239 
00240         NewClient->CurrentWeapon = 0;
00241 
00242         Buffer_Set(&SendBuffer, SData, 5000);
00243 
00244         // Setup the status bar...
00245         if (!Client_CreateStatusBar(NewClient, VidMode))
00246         {
00247                 geErrorLog_AddString(-1, "Client_Create:  Client_CreateStatusBar failed.", NULL);
00248                 goto ExitWithError;
00249         }
00250 
00251         // Setup the GenVSI interface
00252         Client_SetupGenVSI(NewClient);
00253 
00254         // Setup the demo system
00255         if (!Client_SetupDemos(NewClient, DemoMode, DemoName))
00256                 NewClient->Demo.Mode = CLIENT_DEMO_NONE;
00257 
00258         // Call the client main code in the game stuff
00259         Client_Main(&NewClient->GenVSI);
00260         Console_Printf(GameMgr_GetConsole(GMgr), "Client_Create:  Client_Main initialized...\n");
00261 
00262         QueryPerformanceFrequency(&g_Freq);
00263 
00264         return NewClient;
00265 
00266         ExitWithError:
00267         {
00268                 if (NewClient)
00269                 {
00270                         Client_FreeALLResources(NewClient);
00271                         Client_Destroy(NewClient);
00272                 }
00273 
00274                 return NULL;
00275         }
00276 }

geBoolean Client_CreateStatusBar Client_Client Client,
VidMode  VidMode
 

Definition at line 317 of file Client.c.

References Client_StatusElement::Bitmaps, Client_FreeALLResources(), Client_IsValid(), CONSOLE_HEIGHT_320, CONSOLE_HEIGHT_640, Client_StatusBar::Elements, Client_Client::Engine, GE_FALSE, GE_TRUE, geBitmap_CreateFromFileName(), geBoolean, geEngine_AddBitmap(), geErrorLog_AddString, int32, MainFS, NULL, Client_StatusElement::Print1XPos, Client_StatusElement::Print1YPos, SMALL_CONSOLE_CUTOFF_WIDTH, Client_Client::StatusBar, VidMode, VidMode_GetResolution(), Client_StatusElement::XPos, and Client_StatusElement::YPos.

Referenced by Client_Create().

00318 {
00319         int32   i, k;
00320         int     Width,Height;
00321         int     LeftElementWidth,ElementHeight,RightElementWidth,PrintOffsX,PrintOffsY,Left;
00322         char    BmpPath[MAX_PATH];
00323 
00324         assert(Client_IsValid(Client) == GE_TRUE);
00325         assert(Client->Engine);
00326 
00327         VidMode_GetResolution(VidMode,&Width,&Height);
00328         
00329         if (Width < SMALL_CONSOLE_CUTOFF_WIDTH)
00330                 {
00331                         strcpy(BmpPath,"320x240");
00332                         LeftElementWidth    = 56;
00333                         RightElementWidth   = 52;
00334                         ElementHeight       = CONSOLE_HEIGHT_320;
00335                         PrintOffsX          = 18;
00336                         PrintOffsY          = 10;
00337                         Left                            = (Width-320)/2;
00338                 }
00339         else
00340                 {
00341                         strcpy(BmpPath,"640x480");
00342                         LeftElementWidth    = 112;
00343                         RightElementWidth   = 104;
00344                         ElementHeight       = CONSOLE_HEIGHT_640;
00345                         PrintOffsX          = 36;
00346                         PrintOffsY          = 22;
00347                         Left                            = (Width-640)/2;
00348                 }
00349 
00350         for (i=0; i<6; i++)
00351                 {
00352                         if (i<2)
00353                                 {
00354                                         Client->StatusBar.Elements[i].XPos = Left + LeftElementWidth*i;
00355                                 }
00356                         else
00357                                 {
00358                                         Client->StatusBar.Elements[i].XPos = Left + LeftElementWidth*2 + RightElementWidth*(i-2);
00359                                 }
00360 
00361                         Client->StatusBar.Elements[i].YPos       = Height - 1 - ElementHeight;
00362                         Client->StatusBar.Elements[i].Print1XPos = Client->StatusBar.Elements[i].XPos + PrintOffsX;
00363                         Client->StatusBar.Elements[i].Print1YPos = Height - 1 - PrintOffsY;
00364                 }
00365 
00366 
00367         for (i=0; i<6; i++)
00368         {
00369                 for (k=0; k<3; k++)
00370                 {
00371                         char            Name[64];
00372 
00373                         sprintf(Name, "Bmp\\SBar\\%s\\SBar%i-%i.Bmp", BmpPath, i, k);
00374 
00375                         assert(Client->StatusBar.Elements[i].Bitmaps[k] == NULL);
00376                         
00377                         Client->StatusBar.Elements[i].Bitmaps[k] = geBitmap_CreateFromFileName(MainFS, Name);
00378 
00379                         if (!Client->StatusBar.Elements[i].Bitmaps[k])
00380                         {
00381                                 geErrorLog_AddString(-1, "Client_CreateStatusBar:  Could not load status bar element:", Name);
00382                                 goto ExitWithError;
00383                         }
00384 
00385                         if (!geEngine_AddBitmap(Client->Engine, Client->StatusBar.Elements[i].Bitmaps[k]))
00386                         {
00387                                 geErrorLog_AddString(-1, "Client_CreateStatusBar:  geEngine_AddBitmap failed.", NULL);
00388                                 goto ExitWithError;
00389                         }
00390 
00391                 }
00392         }
00393 
00394         return GE_TRUE;
00395 
00396         ExitWithError:
00397         {
00398                 Client_FreeALLResources(Client);
00399                 return GE_FALSE;
00400         }
00401 }

void Client_Destroy Client_Client Client  ) 
 

Definition at line 281 of file Client.c.

References Client_FreeALLResources(), Client_IsValid(), Client_Client::Demo, Client_Demo::File, GE_TRUE, geRam_Free, and NULL.

Referenced by Client_Create(), and Host_DestroyAllObjects().

00282 {
00283         assert(Client_IsValid(Client) == GE_TRUE);
00284 
00285         Client_FreeALLResources(Client);
00286 
00287         if (Client->Demo.File != NULL)
00288                 fclose (Client->Demo.File);
00289 
00290         geRam_Free(Client);
00291 }

void Client_DestroyALLPlayers Client_Client Client  ) 
 

Definition at line 471 of file Client.c.

References GPlayer::Active, Client_DestroyPlayer(), Client_DestroyTempPlayer(), Client_IsValid(), CLIENT_MAX_TEMP_PLAYERS, GE_TRUE, int32, NETMGR_MAX_PLAYERS, Client_Client::Players, and Client_Client::TempPlayers.

Referenced by Client_FreeALLResources(), and Client_FreeResourcesForNewWorld().

00472 {
00473         int32           i;
00474         GPlayer         *Player;
00475 
00476         assert(Client_IsValid(Client) == GE_TRUE);
00477 
00478         // Destroy all normal players
00479         Player = Client->Players;
00480 
00481         for (i=0; i< NETMGR_MAX_PLAYERS; i++, Player++)
00482         {
00483                 if (!Player->Active)
00484                         continue;
00485 
00486                 Client_DestroyPlayer(Client, Player);
00487         }
00488 
00489         // Now destroy all temp players (if any)
00490         Player = Client->TempPlayers;
00491 
00492         for (i=0; i< CLIENT_MAX_TEMP_PLAYERS; i++, Player++)
00493         {
00494                 if (!Player->Active)
00495                         continue;
00496 
00497                 Client_DestroyTempPlayer(Client, Player);
00498         }
00499 }

void Client_DestroyStatusBar Client_Client Client  ) 
 

Definition at line 406 of file Client.c.

References Client_StatusElement::Bitmaps, Client_IsValid(), Client_StatusBar::Elements, Client_Client::Engine, GE_TRUE, geBitmap_Destroy(), geEngine_RemoveBitmap(), geErrorLog_AddString, int32, NULL, and Client_Client::StatusBar.

Referenced by Client_FreeALLResources().

00407 {
00408         int32           i, k;
00409 
00410         assert(Client_IsValid(Client) == GE_TRUE);
00411 
00412         // Delete the status bar bitmaps bitmaps
00413         for (i=0; i<6; i++)
00414         {
00415                 for (k=0; k<3; k++)
00416                 {
00417                         if (!Client->StatusBar.Elements[i].Bitmaps[k])
00418                                 continue;
00419 
00420                         if (!geEngine_RemoveBitmap(Client->Engine, Client->StatusBar.Elements[i].Bitmaps[k]))
00421                         {
00422                                 geErrorLog_AddString(-1, "Client_DestroyConsole:  geEngine_RemoveBitmap failed.", NULL);
00423                                 assert(0);
00424                         }
00425 
00426                         geBitmap_Destroy(&Client->StatusBar.Elements[i].Bitmaps[k]);
00427                         Client->StatusBar.Elements[i].Bitmaps[k] = NULL;
00428                 }
00429         }
00430 }

void Client_DestroyTempPlayer Client_Client Client,
GPlayer Player
 

Definition at line 3393 of file Client.c.

References GPlayer::Active, Client_DestroyPlayerWorldObjects(), Client_IsValid(), and GE_TRUE.

Referenced by Client_DestroyALLPlayers(), Client_SetupGenVSI(), and UpdateProxyPlayer().

03394 {
03395         assert(Client_IsValid(Client) == GE_TRUE);
03396         assert(Player);
03397 
03398         assert(Player->Active);
03399 
03400         //if (!Fx_PlayerSetFxFlags(GameMgr_GetFxSystem(Client->GMgr), TEMP_PLAYER_TO_FXPLAYER(Client, Player), 0))
03401         //      GenVS_Error("[CLIENT] UpdatePlayers:  Could not set Fx_Player flags.\n");
03402 
03403         Client_DestroyPlayerWorldObjects(Client, Player);
03404 
03405         memset(Player, 0, sizeof(GPlayer));
03406 }

geBoolean Client_Frame Client_Client Client,
float  Time
 

Definition at line 876 of file Client.c.

References CLIENT_DEMO_PLAY, Client_IsValid(), Client_SendMove(), ControlTempPlayers(), Client_Client::Demo, GE_TRUE, geBoolean, GenVS_Error(), Client_Client::GMgr, Client_Demo::Mode, Client_Client::NetState, NetState_WorldActive, ReadServerMessages(), and Client_Client::Time.

Referenced by Host_Frame().

00877 {
00878         assert(Client_IsValid(Client) == GE_TRUE);
00879 
00880         Client->Time += Time;                                           // Update client time
00881 
00882         // Read and process msg's from the server
00883         if (!ReadServerMessages(Client, Client->GMgr, Time))            
00884                 GenVS_Error("Client_Frame:  ReadServerMessages failed.\n");
00885 
00886         if (Client->Demo.Mode != CLIENT_DEMO_PLAY)
00887         {
00888                 // If the world is loaded and we have the go from server, start sending move cmd's
00889                 if (Client->NetState == NetState_WorldActive)
00890                 {
00891                         if (!Client_SendMove(Client, Time))                     // Send movement commands
00892                                 GenVS_Error("Client_Frame:  Client_SendMove failed.\n");
00893                 }
00894 
00895                 ControlTempPlayers(Client, Time);
00896         }
00897 
00898         return GE_TRUE;
00899 }

void Client_FreeALLResources Client_Client Client  ) 
 

Definition at line 504 of file Client.c.

References Client_DestroyALLPlayers(), Client_DestroyStatusBar(), Client_IsValid(), Client_PeekMove(), Client_RemoveFirstMove(), GE_TRUE, and geBoolean.

Referenced by Client_Create(), Client_CreateStatusBar(), and Client_Destroy().

00505 {
00506         geBoolean       Ret;
00507 
00508         assert(Client_IsValid(Client) == GE_TRUE);
00509 
00510         Ret = GE_TRUE;
00511 
00512         // Destroy the status bar
00513         Client_DestroyStatusBar(Client);
00514 
00515         // Delete any active players that might by laying around
00516         Client_DestroyALLPlayers(Client);
00517 
00518         // Delete the move list
00519         while (Client_PeekMove(Client))
00520                 Client_RemoveFirstMove(Client);
00521 
00522         assert(Ret == GE_TRUE);
00523 }

void Client_FreeResourcesForNewWorld Client_Client Client  ) 
 

Definition at line 528 of file Client.c.

References Client_DestroyALLPlayers(), Client_PeekMove(), and Client_RemoveFirstMove().

Referenced by ReadServerMessages().

00529 {
00530         // Delete any active players that might by laying around
00531         Client_DestroyALLPlayers(Client);
00532 
00533         // Delete the move list
00534         while (Client_PeekMove(Client))
00535                 Client_RemoveFirstMove(Client);
00536 }

GPlayer* Client_GetPlayer Client_Client Client,
int32  Index
 

Definition at line 3411 of file Client.c.

References Client_IsValid(), GE_TRUE, NETMGR_MAX_PLAYERS, and Client_Client::Players.

03412 {
03413         assert(Client_IsValid(Client) == GE_TRUE);
03414         assert(Index >= 0);
03415         assert(Index < NETMGR_MAX_PLAYERS);
03416 
03417         return &Client->Players[Index];
03418 }

geBoolean Client_IsValid const Client_Client Client  ) 
 

Definition at line 297 of file Client.c.

References GE_FALSE, GE_TRUE, geBoolean, Client_Client::Self1, and Client_Client::Self2.

Referenced by BuildClientViewXForm(), CheckClientPlayerChanges(), Client_ChangeNetState(), Client_CreateStatusBar(), Client_Destroy(), Client_DestroyALLPlayers(), Client_DestroyPlayer(), Client_DestroyStatusBar(), Client_DestroyTempPlayer(), Client_Frame(), Client_FreeALLResources(), Client_GetClientMove(), Client_GetPlayer(), Client_GetProcIndex(), Client_GetTime(), Client_GetWorld(), Client_MoveClientLocally(), Client_MovePlayerModel(), Client_NewWorldDefaults(), Client_ParsePlayerData(), Client_PeekMove(), Client_ProcIndex(), Client_ReadServerMessages(), Client_RemoveFirstMove(), Client_RenderFrame(), Client_SendMove(), Client_SetDemo(), Client_SetupDemos(), Client_SetupGenVSI(), Client_SpawnTempPlayer(), Client_UpdateSinglePlayer(), Client_ValidateWeapon(), ControlTempPlayers(), DrawStatusBar(), ParsePlayerDataLocally(), PrintClientScores(), ReadDemoIni(), ReadServerMessages(), RenderWorld(), SetClientProxyPlayer(), UpdatePlayers(), UpdateProxyPlayer(), and UpdateStatusBar().

00298 {
00299         if (!Client)
00300                 return GE_FALSE;
00301 
00302         if (Client->Self1 != Client)
00303                 return GE_FALSE;
00304 
00305         if (Client->Self2 != Client)
00306                 return GE_FALSE;
00307 
00308         return GE_TRUE;
00309 }

void Client_NewWorldDefaults Client_Client Client  ) 
 

Definition at line 543 of file Client.c.

References Client_IsValid(), GE_TRUE, int32, LastPlayer, NETMGR_MAX_PLAYERS, Client_Client::NetTime, NumUpdates, Client_Client::OldNetTime, Client_Client::Players, REFRESH_TIMES, SetPlayerDefaults(), and Client_Client::Time.

Referenced by Client_Create(), ReadServerMessages(), and Server_Frame().

00544 {
00545         int32           i;
00546 
00547         assert(Client_IsValid(Client) == GE_TRUE);
00548 
00549         // Set the default on all players
00550         for (i=0; i< NETMGR_MAX_PLAYERS; i++)
00551                 SetPlayerDefaults(&Client->Players[i]);
00552 
00553         Client->Time = 0.0f;
00554         Client->NetTime = 0.0f;
00555         Client->OldNetTime = 0.0f;
00556         //Client->ClientPlayer = -1;
00557         LastPlayer = -1;
00558 
00559         // Make sure the status bar updates between world cahnges...
00560         NumUpdates = REFRESH_TIMES;             
00561 }

GPlayer* Client_ParsePlayerData Client_Client Client,
Buffer_Data Buffer,
GPlayer FakePlayer
 

Definition at line 2535 of file Client.c.

References GPlayer::Active, GPlayer::Angles, GPlayer_XFormData::BoneIndex, Buffer_GetAngle(), Buffer_GetByte(), Buffer_GetFloat(), Buffer_GetFloat2(), Buffer_GetPos(), Buffer_GetShort(), Client_IsValid(), ClientMode_Proxy, GPlayer::Control, GPlayer::ControlIndex, GPlayer::FrameTime, Fx_PlayerSetFxFlags(), GPlayer::FxFlags, GameMgr_GetFxSystem(), GE_TRUE, GenVS_Error(), geXForm3d_SetEulerAngles(), Client_Client::GMgr, GPlayer_PState, int32, GPlayer::Maxs, GPlayer::Mins, Client_Client::Mode, GPlayer::MotionData, GPlayer_MotionData::MotionIndex, GPlayer::MotionIndex, GPlayer_MotionData::MotionTime, NETMGR_SEND_ANGLES, NETMGR_SEND_CONTROL_INDEX, NETMGR_SEND_FRAME_TIME, NETMGR_SEND_FX_FLAGS, NETMGR_SEND_MINS_MAXS, NETMGR_SEND_MOTION_INDEX, NETMGR_SEND_POS, NETMGR_SEND_SCALE, NETMGR_SEND_SPAWN_TIME, NETMGR_SEND_STATE, NETMGR_SEND_TRIGGER_INDEX, NETMGR_SEND_VELOCITY, NETMGR_SEND_VIEW_FLAGS, NETMGR_SEND_VIEW_INDEX, Client_Client::NetTime, NULL, GPlayer::NumMotionData, GPlayer::NumXFormData, GPlayer::OldAngles, GPlayer::OldControlIndex, GPlayer::OldFrameTime, GPlayer::OldFxFlags, GPlayer::OldMaxs, GPlayer::OldMins, GPlayer::OldMotionIndex, GPlayer::OldPos, GPlayer::OldScale, GPlayer::OldSpawnTime, GPlayer::OldState, GPlayer::OldTriggerIndex, GPlayer::OldVelocity, GPlayer::OldViewFlags, GPlayer::OldViewIndex, PLAYER_TO_FXPLAYER, Client_Client::Players, GPlayer::Pos, Client_Client::ProcIndex, GPlayer::Scale, GPlayer::SpawnTime, GPlayer::State, geXForm3d::Translation, GPlayer::Trigger, GPlayer::TriggerIndex, uint16, uint8, GPlayer::UpdateTime, GPlayer::Velocity, VIEW_TYPE_HACK, GPlayer::ViewFlags, GPlayer::ViewIndex, GPlayer_XFormData::XForm, and GPlayer::XFormData.

Referenced by ForceServerPlayerOnLocalClient(), and ParsePlayerDataLocally().

02536 {
02537         uint16                  PlayerIndex;
02538         uint16                  SendFlags, PlayerIndexFlags;
02539         GPlayer                 *pPlayer;
02540 
02541         assert(Client_IsValid(Client) == GE_TRUE);
02542 
02543         Buffer_GetShort(Buffer, &PlayerIndex);
02544 
02545         PlayerIndexFlags = (uint16)(PlayerIndex & (1<<15));
02546         PlayerIndex &= (uint16)0x7FFF;
02547         
02548         if (AuxPlayer)
02549                 pPlayer = AuxPlayer;
02550         else
02551                 pPlayer = &Client->Players[PlayerIndex];
02552 
02553         pPlayer->Active = GE_TRUE;
02554 
02555         pPlayer->UpdateTime = Client->NetTime;          // Make this player recent
02556         
02557         if (!(PlayerIndexFlags & (1<<15)) )
02558         {
02559                 // Fast update, use all old known flags
02560                 pPlayer->SpawnTime = pPlayer->OldSpawnTime;
02561                 pPlayer->ViewFlags = pPlayer->OldViewFlags;
02562                 pPlayer->ViewIndex = pPlayer->OldViewIndex;
02563                 pPlayer->MotionIndex = pPlayer->OldMotionIndex;
02564                 pPlayer->FxFlags = pPlayer->OldFxFlags;
02565 
02566                 if (!AuxPlayer)
02567                 {
02568                         if (!Fx_PlayerSetFxFlags(GameMgr_GetFxSystem(Client->GMgr), PLAYER_TO_FXPLAYER(Client, pPlayer), pPlayer->FxFlags))
02569                                 GenVS_Error("Client_ParsePlayerData:  Fx_PlayerSetFxFlags failed.\n");
02570                 }
02571 
02572                 pPlayer->Pos = pPlayer->OldPos;
02573                 pPlayer->Angles = pPlayer->OldAngles;
02574                 pPlayer->FrameTime = pPlayer->OldFrameTime;
02575                 pPlayer->Scale = pPlayer->OldScale;
02576                 pPlayer->Velocity = pPlayer->OldVelocity;
02577                 pPlayer->State = pPlayer->OldState;
02578                 pPlayer->ControlIndex = pPlayer->OldControlIndex;
02579                 pPlayer->TriggerIndex = pPlayer->OldTriggerIndex;
02580                 pPlayer->Mins = pPlayer->OldMins;
02581                 pPlayer->Maxs = pPlayer->OldMaxs;
02582 
02583                 if (Client->Mode == ClientMode_Proxy)
02584                 {
02585                         // Set the control func here
02586                         if (pPlayer->ControlIndex == 0xffff)
02587                                 pPlayer->Control = NULL;
02588                         else
02589                                 pPlayer->Control = Client->ProcIndex[pPlayer->ControlIndex];
02590 
02591                         // Set the control func here
02592                         if (pPlayer->TriggerIndex == 0xffff)
02593                                 pPlayer->Trigger = NULL;
02594                         else
02595                         {
02596                                 pPlayer->Trigger = Client->ProcIndex[pPlayer->TriggerIndex];
02597                         }
02598                 }
02599 
02600                 return pPlayer;         // Nothing to read, fast update
02601         }
02602         
02603         // See what we need to read for this player
02604         // If somthing changed, we grab it, and store it in the old variable.
02605         // If somthing did not change, we reset it back to the old one..
02606         Buffer_GetShort(Buffer, &SendFlags);
02607 
02608         // Get the data
02609         if (SendFlags & NETMGR_SEND_SPAWN_TIME)
02610         {
02611                 Buffer_GetFloat(Buffer, &pPlayer->SpawnTime);
02612                 pPlayer->OldSpawnTime = pPlayer->SpawnTime;
02613         }
02614         else
02615                 pPlayer->SpawnTime = pPlayer->OldSpawnTime;
02616 
02617         if (SendFlags & NETMGR_SEND_VIEW_FLAGS)
02618         {
02619                 Buffer_GetShort(Buffer, &pPlayer->ViewFlags);
02620                 pPlayer->OldViewFlags = pPlayer->ViewFlags;
02621         }
02622         else
02623                 pPlayer->ViewFlags = pPlayer->OldViewFlags;
02624 
02625         if (SendFlags & NETMGR_SEND_VIEW_INDEX)
02626         {
02627                 Buffer_GetShort(Buffer, &pPlayer->ViewIndex);
02628                 pPlayer->OldViewIndex = pPlayer->ViewIndex;
02629         }
02630         else
02631                 pPlayer->ViewIndex = pPlayer->OldViewIndex;
02632 
02633         if (SendFlags & NETMGR_SEND_MOTION_INDEX)
02634         {
02635                 Buffer_GetByte(Buffer, &pPlayer->MotionIndex);
02636                 pPlayer->OldMotionIndex = pPlayer->MotionIndex;
02637         }
02638         else
02639                 pPlayer->MotionIndex = pPlayer->OldMotionIndex;
02640 
02641         if (SendFlags & NETMGR_SEND_FX_FLAGS)
02642         {
02643                 Buffer_GetShort(Buffer, &pPlayer->FxFlags);
02644                 pPlayer->OldFxFlags = pPlayer->FxFlags;
02645         }
02646         else 
02647                 pPlayer->FxFlags = pPlayer->OldFxFlags;
02648 
02649         if (SendFlags & NETMGR_SEND_POS)
02650         {
02651                 Buffer_GetPos(Buffer, &pPlayer->Pos);
02652                 pPlayer->OldPos = pPlayer->Pos;
02653         }
02654         else
02655                 pPlayer->Pos = pPlayer->OldPos;
02656 
02657         if (SendFlags & NETMGR_SEND_ANGLES)
02658         {
02659                 Buffer_GetAngle(Buffer, &pPlayer->Angles);
02660                 pPlayer->OldAngles = pPlayer->Angles;
02661         }
02662         else
02663                 pPlayer->Angles = pPlayer->OldAngles;
02664 
02665         if (SendFlags & NETMGR_SEND_FRAME_TIME)
02666         {
02667                 Buffer_GetFloat2(Buffer, &pPlayer->FrameTime, 60.0f);
02668                 pPlayer->OldFrameTime = pPlayer->FrameTime;
02669         }
02670         else
02671                 pPlayer->FrameTime = pPlayer->OldFrameTime;
02672 
02673         if (SendFlags & NETMGR_SEND_SCALE)
02674         {
02675                 Buffer_GetFloat2(Buffer, &pPlayer->Scale, 100.0f);
02676                 pPlayer->OldScale = pPlayer->Scale;
02677         }
02678         else
02679                 pPlayer->Scale = pPlayer->OldScale;
02680 
02681         if (SendFlags & NETMGR_SEND_VELOCITY)
02682         {
02683                 Buffer_GetAngle(Buffer, &pPlayer->Velocity);
02684                 pPlayer->OldVelocity = pPlayer->Velocity;
02685         }
02686         else
02687                 pPlayer->Velocity = pPlayer->OldVelocity;
02688 
02689         if (SendFlags & NETMGR_SEND_STATE)
02690         {
02691                 uint8   State;
02692 
02693                 Buffer_GetByte(Buffer, &State);
02694                 pPlayer->State = (GPlayer_PState)State;
02695                 pPlayer->OldState = pPlayer->State;
02696         }
02697         else
02698                 pPlayer->State = pPlayer->OldState;
02699 
02700         if (SendFlags & NETMGR_SEND_CONTROL_INDEX)
02701         {
02702                 pPlayer->OldControlIndex = pPlayer->ControlIndex;
02703                 Buffer_GetShort(Buffer, &pPlayer->ControlIndex);
02704 
02705                 pPlayer->OldControlIndex = pPlayer->ControlIndex;
02706         }
02707         else
02708                 pPlayer->ControlIndex = pPlayer->OldControlIndex;
02709         
02710         if (SendFlags & NETMGR_SEND_TRIGGER_INDEX)
02711         {
02712                 pPlayer->OldTriggerIndex = pPlayer->TriggerIndex;
02713                 Buffer_GetShort(Buffer, &pPlayer->TriggerIndex);
02714 
02715                 pPlayer->OldTriggerIndex = pPlayer->TriggerIndex;
02716         }
02717         else
02718                 pPlayer->TriggerIndex = pPlayer->OldTriggerIndex;
02719 
02720         //      Set control/trigger functions
02721         if (Client->Mode == ClientMode_Proxy)
02722         {
02723                 // Set the control func here
02724                 if (pPlayer->ControlIndex == 0xffff)
02725                         pPlayer->Control = NULL;
02726                 else
02727                         pPlayer->Control = Client->ProcIndex[pPlayer->ControlIndex];
02728 
02729                 // Set the control func here
02730                 if (pPlayer->TriggerIndex == 0xffff)
02731                         pPlayer->Trigger = NULL;
02732                 else
02733                 {
02734                         pPlayer->Trigger = Client->ProcIndex[pPlayer->TriggerIndex];
02735                 }
02736         }
02737 
02738         // Update the players fx system 
02739         if (!AuxPlayer)
02740         {
02741                 if (!Fx_PlayerSetFxFlags(GameMgr_GetFxSystem(Client->GMgr), PLAYER_TO_FXPLAYER(Client, pPlayer), pPlayer->FxFlags))
02742                         GenVS_Error("Client_ParsePlayerData:  Fx_PlayerSetFxFlags failed.\n");
02743         }
02744 
02745         if (SendFlags & NETMGR_SEND_MINS_MAXS)
02746         {
02747                 Buffer_GetPos(Buffer, &pPlayer->Mins);
02748                 Buffer_GetPos(Buffer, &pPlayer->Maxs);
02749 
02750 
02751                 pPlayer->OldMins = pPlayer->Mins;
02752                 pPlayer->OldMaxs = pPlayer->Maxs;
02753         }
02754         else
02755         {
02756                 pPlayer->Mins = pPlayer->OldMins;
02757                 pPlayer->Maxs = pPlayer->OldMaxs;
02758         }
02759 
02760 #if 0
02761         // TOTAL hack for now... (this is a way to get extra xforms in a player for actors
02762         if (pPlayer->ViewFlags & VIEW_TYPE_HACK)
02763         {
02764                 GPlayer_XFormData       *pXFormData;
02765                 int32                           i;
02766                 uint8                           NumXFormData;
02767 
02768                 Buffer_GetByte(Buffer, &NumXFormData);
02769 
02770                 pPlayer->NumXFormData = (uint8)NumXFormData;
02771 
02772                 pXFormData = pPlayer->XFormData;
02773                 
02774                 for (i=0; i<pPlayer->NumXFormData; i++, pXFormData++)
02775                 {
02776                         geVec3d         EulerAngles;
02777 
02778                         Buffer_GetAngle(Buffer, &EulerAngles);
02779                         geXForm3d_SetEulerAngles(&pXFormData->XForm, &EulerAngles);
02780                         Buffer_GetPos(Buffer, &pXFormData->XForm.Translation);
02781                         Buffer_GetByte(Buffer, &pXFormData->BoneIndex);
02782                 }
02783         }
02784         
02785         // TOTAL hack for now... (this is a way to get extra motions in a player for actors
02786         if (pPlayer->ViewFlags & VIEW_TYPE_HACK)
02787         {
02788                 GPlayer_MotionData      *pMotionData;
02789                 int32                           i;
02790                 uint8                           NumMotionData;
02791 
02792                 Buffer_GetByte(Buffer, &NumMotionData);
02793 
02794                 pPlayer->NumMotionData = NumMotionData;
02795 
02796                 pMotionData = pPlayer->MotionData;
02797 
02798                 for (i=0; i<pPlayer->NumMotionData; i++, pMotionData++)
02799                 {
02800                         Buffer_GetFloat(Buffer, &pMotionData->MotionTime);
02801                         Buffer_GetByte(Buffer, &pMotionData->MotionIndex);
02802                 }
02803         }
02804         
02805 #endif
02806         
02807         return pPlayer;
02808 }

Client_Move* Client_PeekMove Client_Client Client  ) 
 

Definition at line 1002 of file Client.c.

References Client_IsValid(), GE_TRUE, and Client_Client::MoveStack.

Referenced by Client_FreeALLResources(), Client_FreeResourcesForNewWorld(), and UpdateProxyPlayer().

01003 {
01004         assert(Client_IsValid(Client) == GE_TRUE);
01005 
01006         return Client->MoveStack;
01007 }

geBoolean Client_ReadServerMessages Client_Client Client,
Buffer_Data Buffer
 

Definition at line 2964 of file Client.c.

References CLIENT_DEMO_NONE, CLIENT_DEMO_PLAY, CLIENT_DEMO_RECORD, Client_IsValid(), Client_SetDemo(), Client_Client::ClientInfo, Client_Demo::CurrentDemo, Buffer_Data::Data, Client_Client::Demo, DemoBuffer, Client_Demo::File, GE_FALSE, GE_TRUE, geBoolean, geCSNetMgr_NetMsgType, GenVS_Error(), int32, Client_Demo::Mode, NET_MSG_NONE, NET_MSG_SESSIONLOST, NET_MSG_USER, NETMGR_LOCAL_MSG_BUFFER_SIZE, NETMGR_MAX_CLIENTS, NetMgr_ReceiveServerMessage(), Client_Client::NetTime, Client_Client::NMgr, Client_Demo::NumDemos, Client_Demo::OriginalSpeed, Buffer_Data::Pos, Buffer_Data::Size, Client_Client::Time, and uint32.

Referenced by ReadServerMessages().

02965 {
02966         geCSNetMgr_NetMsgType   MsgType;
02967 
02968         assert(Client_IsValid(Client) == GE_TRUE);
02969 
02970         // Reset the buffer pos
02971         Buffer->Pos = 0;
02972 
02973         if (Client->Demo.Mode == CLIENT_DEMO_PLAY)              // If demo play mode, get message from file
02974         {
02975                 geBoolean       Good = GE_FALSE;
02976 
02977                 Buffer->Data = DemoBuffer;
02978 
02979                 assert(Client->Demo.File);
02980                 
02981                 // Make the demo run at it's original recorded speed...
02982                 if (Client->Demo.OriginalSpeed)
02983                         if (Client->Time <= Client->NetTime)
02984                                 return GE_FALSE;        // Wait till client catches up with the demo
02985                 
02986                 if (fread(&Buffer->Size, sizeof(int32), 1, Client->Demo.File) == 1)
02987                 {
02988                         if (Buffer->Size >= NETMGR_LOCAL_MSG_BUFFER_SIZE)
02989                                 GenVS_Error("Client_ReadServerMessages:  Demo Buffer size can't hold data.\n");
02990 
02991                         if (fread(Buffer->Data, sizeof(char), Buffer->Size, Client->Demo.File) == (uint32)Buffer->Size)
02992                                 Good = GE_TRUE;
02993                 }
02994 
02995                 if (!Good)              // End of file, try the beginning...
02996                 {
02997                         Client->Time = 0.0f;
02998                         Client->NetTime = 0.0f;
02999                         
03000                         // Reset the scoreboard between demo changes...
03001                         memset(Client->ClientInfo, 0, sizeof(Client_ClientInfo)*NETMGR_MAX_CLIENTS);
03002 
03003                         if (!Client_SetDemo(Client, (Client->Demo.CurrentDemo+1)%Client->Demo.NumDemos))
03004                         {
03005                                 Client->Demo.Mode = CLIENT_DEMO_NONE;
03006                                 return GE_TRUE;
03007                         }
03008                         
03009                         //GenVS_Error("End of demo.\n");
03010                         fseek(Client->Demo.File, 0, SEEK_SET);
03011 
03012                         if (fread(&Buffer->Size, sizeof(int32), 1, Client->Demo.File) != 1)
03013                                 GenVS_Error("Error reading the demo file.\n");
03014 
03015                         if (fread(Buffer->Data, sizeof(char), Buffer->Size, Client->Demo.File) != (uint32)Buffer->Size)
03016                                 GenVS_Error("Error reading the demo file.\n");
03017                 }
03018 
03019                 return GE_TRUE;
03020         }
03021 
03022         while (1)
03023         {
03024                 if (!NetMgr_ReceiveServerMessage(Client->NMgr, &MsgType, Buffer))
03025                         GenVS_Error("Client_ReadServerMessages:  NetMgr_ReceiveServerMessage failed.\n");
03026 
03027                 if (MsgType == NET_MSG_SESSIONLOST)
03028                         GenVS_Error("Client_ReadServerMessages:  Session was lost.\n");
03029 
03030                 if (MsgType == NET_MSG_NONE)
03031                         return GE_FALSE;
03032 
03033                 if (MsgType == NET_MSG_USER)
03034                         break;
03035         }
03036 
03037         // Check to see if the buffer has data
03038         if (!Buffer->Size)
03039                 return GE_FALSE;
03040 
03041         // Record the message
03042         if (Client->Demo.Mode == CLIENT_DEMO_RECORD)    // Record messages for DemoRecord mode
03043         {
03044                 assert(Client->Demo.File);
03045                 fwrite(&Buffer->Size, 1, sizeof(int32), Client->Demo.File);
03046                 fwrite(Buffer->Data, Buffer->Size, 1, Client->Demo.File);
03047         }
03048 
03049         return GE_TRUE;
03050 }

void Client_RefreshStatusBar int32  NumPages  ) 
 

Definition at line 771 of file Client.c.

References NumUpdates, and REFRESH_TIMES.

Referenced by Host_ClientRefreshStatusBar().

00772 {
00773         NumPages;
00774         NumUpdates = REFRESH_TIMES;
00775 }

void Client_RemoveFirstMove Client_Client Client  ) 
 

Definition at line 1012 of file Client.c.

References Client_IsValid(), GE_TRUE, GenVS_Error(), geRam_Free, Client_Client::LastMove, Client_Client::MoveStack, Client_Move::Next, NULL, and NumMoves.

Referenced by Client_FreeALLResources(), Client_FreeResourcesForNewWorld(), and UpdateProxyPlayer().

01013 {
01014         Client_Move             *Next;
01015 
01016         assert(Client_IsValid(Client) == GE_TRUE);
01017 
01018         NumMoves--;
01019 
01020         if (NumMoves < 0)
01021                 GenVS_Error("NumMove < 0.\n");
01022 
01023         if (!Client->MoveStack)
01024                 GenVS_Error("Client_RemoveFirstMove:  No more moves left...");
01025 
01026         Next = Client->MoveStack->Next;
01027 
01028         geRam_Free(Client->MoveStack);
01029         
01030         if (Next)
01031                 Client->MoveStack = Next;
01032         else
01033         {
01034                 Client->MoveStack = NULL;
01035                 Client->LastMove = NULL;
01036         }
01037 }

geBoolean Client_RenderFrame Client_Client Client,
float  Time
 

Definition at line 904 of file Client.c.

References Client_IsValid(), GE_TRUE, geBoolean, GenVS_Error(), Client_Client::GMgr, Client_Client::NetState, NetState_WorldActive, PrintClientScores(), PrintCrossHair(), RenderWorld(), and UpdateStatusBar().

Referenced by Host_RenderFrame().

00905 {
00906         assert(Client_IsValid(Client) == GE_TRUE);
00907 
00908         if (Client->NetState != NetState_WorldActive)           // If no world currently set, then return...
00909                 return GE_TRUE;
00910 
00911         if (!RenderWorld(Client, Client->GMgr, Time))
00912                 GenVS_Error("Client_RenderFrame:  RenderWorld failed.\n");
00913 
00914         //if (Client->MultiPlayer)
00915         {
00916                 if (!PrintClientScores(Client))
00917                         GenVS_Error("Client_RenderFrame:  PrintClientScores failed.\n");
00918         }
00919         
00920         PrintCrossHair(Client);
00921 
00922         UpdateStatusBar(Client);
00923 
00924         return GE_TRUE;
00925 }

geBoolean Client_SendMove Client_Client Client,
float  Time
 

Definition at line 1074 of file Client.c.

References Client_Client::Angles, Buffer_FillAngle(), Buffer_FillBuffer(), Buffer_FillByte(), Buffer_FillFloat(), Buffer_FillShort(), Buffer_Set(), Client_Move::ButtonBits, Client_Client::ButtonBits, Client_AddMove(), Client_IsValid(), Client_MoveClientLocally(), Client_ValidateWeapon(), ClientMode_Dumb, ClientMode_Proxy, Client_Client::ClientPlayer, Client_Move::CurrentWeapon, Client_Client::CurrentWeapon, Client_Move::Delta, Client_Move::ForwardSpeed, Client_Client::ForwardSpeed, GameMgr_GethWnd(), GE_FALSE, GE_TRUE, geBoolean, GenVS_Error(), GlobalMouseSpeedX, GlobalMouseSpeedY, GMenu_IsAMenuActive(), Client_Client::GMgr, HOST_BUTTON_FIRE, HOST_BUTTON_JUMP, HOST_BUTTON_LEFT, HOST_BUTTON_RIGHT, HWND, IsKeyDown(), KeyLut, Client_Client::Mode, MouseInvert, NETMGR_MSG_CLIENT_MOVE, NetMgr_SendServerMessage(), NewKeyDown(), Client_Client::NextSend, Client_Client::NMgr, Client_Move::Pitch, Client_Client::Players, Client_Move::Pos, GPlayer::Pos, SData, SendBuffer, Client_Client::ServerPingBack, Client_Move::Time, Client_Client::Time, uint16, uint8, geVec3d::X, geVec3d::Y, and Client_Move::Yaw.

Referenced by Client_Frame().

01075 {
01076         Buffer_Data             Buffer;
01077         uint8                   Data[512];
01078         uint16                  ButtonBits;
01079         HWND                    hWnd;
01080 
01081         assert(Client_IsValid(Client) == GE_TRUE);
01082 
01083         if (GMenu_IsAMenuActive() == GE_TRUE)
01084                 return GE_TRUE;
01085 
01086         hWnd = GameMgr_GethWnd(Client->GMgr);
01087         
01088         //if (Client->ClientPlayer == -1)
01089         //      return GE_TRUE;
01090 
01091         Buffer_Set(&Buffer, Data, 512);
01092 
01093         ButtonBits = 0;
01094 
01095         // Change forward/back motion
01096         if (IsKeyDown(KeyLut[VK_UP], hWnd))
01097                 Client->ForwardSpeed = 4000.0f;
01098         else if (IsKeyDown(KeyLut[VK_DOWN], hWnd))
01099                 Client->ForwardSpeed = -4000.0f;
01100         else
01101                 Client->ForwardSpeed = 0.0f;
01102 
01103         if (MouseInvert)
01104                 Client->Angles.X -= GlobalMouseSpeedY;
01105         else
01106                 Client->Angles.X += GlobalMouseSpeedY;
01107 
01108         Client->Angles.Y += GlobalMouseSpeedX;
01109 
01110         if (Client->Angles.X > 1.3f)
01111                 Client->Angles.X = 1.3f;
01112         else if (Client->Angles.X < -1.3f)
01113                 Client->Angles.X = -1.3f;
01114 
01115         GlobalMouseSpeedX = 0.0f;
01116         GlobalMouseSpeedY = 0.0f;
01117 
01118         if (IsKeyDown(KeyLut[VK_LEFT], hWnd))
01119                 ButtonBits |= HOST_BUTTON_LEFT;
01120 
01121         if (IsKeyDown(KeyLut[VK_RIGHT], hWnd))
01122                 ButtonBits |= HOST_BUTTON_RIGHT;
01123 
01124         // Do misc move actions
01125         if (NewKeyDown(KeyLut[VK_RBUTTON], hWnd))
01126                 ButtonBits |= HOST_BUTTON_JUMP;
01127 
01128         if (IsKeyDown(KeyLut[VK_LBUTTON], hWnd))
01129         {
01130                 ButtonBits |= HOST_BUTTON_FIRE;
01131         }
01132         
01133         if (IsKeyDown('1', hWnd))
01134         {
01135                 Client->CurrentWeapon = 0;
01136         }
01137         else if (IsKeyDown('2', hWnd))
01138         {
01139                 Client->CurrentWeapon = 1;
01140         }
01141         else if (IsKeyDown('3', hWnd))
01142         {
01143                 Client->CurrentWeapon = 2;
01144         }
01145         else if (IsKeyDown('4', hWnd))
01146         {
01147                 Client->CurrentWeapon = 3;
01148         }
01149         else if (NewKeyDown(KeyLut[VK_CONTROL], hWnd))
01150         {
01151                 Client->CurrentWeapon ++;
01152                 Client->CurrentWeapon %= 4;
01153                 
01154                 Client_ValidateWeapon(Client);
01155         }
01156         
01157         Client->ButtonBits = ButtonBits;
01158 
01159         Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_MOVE);                       // Let server know we're moving
01160         Buffer_FillFloat(&Buffer, Client->Time);                                // Current Time
01161         Buffer_FillFloat(&Buffer, Client->ServerPingBack);              // Current Time
01162         Buffer_FillFloat(&Buffer, Client->ForwardSpeed);                // Current Speed
01163         Buffer_FillFloat(&Buffer, Client->Angles.X);                    // Pitch
01164         Buffer_FillFloat(&Buffer, Client->Angles.Y);                    // Yaw
01165         Buffer_FillShort(&Buffer, ButtonBits);                                  // Current Buttons
01166 
01167         if (ButtonBits & HOST_BUTTON_FIRE)
01168         {
01169                 assert(Client->CurrentWeapon >= 0 && Client->CurrentWeapon <= 65535);
01170                 Buffer_FillShort(&Buffer, (uint16)Client->CurrentWeapon);               // Send Current Weapon if firing
01171         }
01172 
01173 #ifdef CALC_ERROR
01174         if (Client->ClientPlayer >= 0)
01175         {
01176                 GPlayer         *Player;
01177 
01178                 Player = &Client->Players[Client->ClientPlayer];
01179                 Buffer_FillAngle(&Buffer, Player->Pos); 
01180         }
01181         else
01182         {
01183                 geVec3d         FakePos = {0.0f, 0.0f, 0.0f};
01184 
01185                 Buffer_FillAngle(&Buffer, FakePos);     
01186         }
01187 #endif
01188 
01189 //BEGIN_TIMER();
01190 #if 1
01191         if (!NetMgr_SendServerMessage(Client->NMgr, &Buffer, GE_FALSE))
01192                 GenVS_Error("Client_SendMove:  NetMgr_SendServerMessage failed.\n");
01193 #else
01194         if (Client->Mode == ClientMode_Dumb)
01195         {
01196                 // Send the move intention to the server for processing
01197                 if (!NetMgr_SendServerMessage(Client->NMgr, &Buffer, GE_FALSE))
01198                         GenVS_Error("Client_SendMove:  NetMgr_SendServerMessage failed.\n");
01199         }
01200         else if (Client->Time >= Client->NextSend)
01201         {
01202                 Buffer_FillBuffer(&SendBuffer, &Buffer);
01203 
01204                 // Send the move intention to the server for processing
01205                 if (!NetMgr_SendServerMessage(Client->NMgr, &SendBuffer, GE_FALSE))
01206                         GenVS_Error("Client_SendMove:  NetMgr_SendServerMessage failed.\n");
01207 
01208                 Buffer_Set(&SendBuffer, SData, 5000);
01209 
01210                 //Client->NextSend = Client->Time + (float)(rand()%100) * (1/100.0f) * 0.5f + 0.25f;
01211                 //Client->NextSend = Client->Time + 0.5f;
01212                 Client->NextSend = Client->Time;
01213         }
01214 #endif
01215 //END_TIMER(Client->GMgr);
01216 
01217         // Send the message directly to our proxy player so we can begin moving NOW
01218         if (Client->Mode == ClientMode_Proxy && Client->ClientPlayer != -1)
01219         {
01220                 Client_Move             Move;
01221                 GPlayer         *Player;
01222 
01223                 Player = &Client->Players[Client->ClientPlayer];
01224 
01225                 Move.Time = Client->Time;
01226                 Move.Delta = Time;
01227                 Move.ForwardSpeed = Client->ForwardSpeed;
01228                 Move.Pitch = Client->Angles.X;
01229                 Move.Yaw = Client->Angles.Y;
01230                 Move.Pos = Player->Pos;                                                         // So we know our position at this time...
01231                 Move.ButtonBits = ButtonBits;
01232                 Move.CurrentWeapon = Client->CurrentWeapon;
01233 
01234         #ifdef PREDICT_CLIENT
01235 
01236                 Client_MoveClientLocally(Client, &Move);
01237                         
01238                 //geEngine_Printf(Host->Engine, 2, 35, "Inventory: %i, %i", Player->InventoryHas[Client->CurrentWeapon], Player->Inventory[Client->CurrentWeapon]);
01239 
01240                 // Remember this move, so when we get an update that is older then where we
01241                 // are actually at, we can replay all the moves after the update, and "catch"
01242                 // back up...
01243                 Client_AddMove(Client, &Move);
01244         #endif
01245         }
01246 
01247         return GE_TRUE;
01248 }

geBoolean Client_SetDemo Client_Client Client,
int32  DemoNum
 

Definition at line 2937 of file Client.c.

References CLIENT_DEMO_PLAY, Client_IsValid(), Client_Demo::CurrentDemo, Client_Client::Demo, Client_Demo::DemoNames, Client_Demo::File, GE_TRUE, geBoolean, GenVS_Error(), and Client_Demo::Mode.

Referenced by Client_ReadServerMessages(), and Client_SetupDemos().

02938 {
02939         assert(Client_IsValid(Client) == GE_TRUE);
02940         assert(DemoNum < Client->Demo.NumDemos);
02941         assert(Client->Demo.Mode == CLIENT_DEMO_PLAY);
02942 
02943         // Close down any old demo data files
02944         if (Client->Demo.File)
02945                 fclose(Client->Demo.File);
02946 
02947         // Store current demo num
02948         Client->Demo.CurrentDemo = DemoNum;
02949 
02950         Client->Demo.File = fopen(Client->Demo.DemoNames[Client->Demo.CurrentDemo], "rb");
02951                 
02952         if (!Client->Demo.File)
02953                 GenVS_Error("Client_SetDemo:  Failed to open demo file: %s.\n", Client->Demo.DemoNames[Client->Demo.CurrentDemo]);
02954 
02955         return GE_TRUE;
02956 }

geBoolean Client_SetupDemos Client_Client Client,
int32  Mode,
const char *  DemoFile
 

Definition at line 3155 of file Client.c.

References CLIENT_DEMO_PLAY, CLIENT_DEMO_RECORD, Client_IsValid(), Client_SetDemo(), Client_Demo::CurrentDemo, Client_Client::Demo, Client_Demo::DemoNames, Client_Demo::File, GE_FALSE, GE_TRUE, geBoolean, Client_Demo::Mode, NULL, Client_Demo::NumDemos, Client_Demo::OriginalSpeed, and ReadDemoIni().

Referenced by Client_Create().

03156 {
03157         assert(Client);
03158 
03159         assert(Client_IsValid(Client) == GE_TRUE);
03160 
03161         Client->Demo.Mode = Mode;
03162         Client->Demo.OriginalSpeed = GE_TRUE;
03163 
03164         Client->Demo.NumDemos = 0;
03165         Client->Demo.CurrentDemo = 0;
03166 
03167         Client->Demo.File = NULL;
03168         
03169         if (Client->Demo.Mode == CLIENT_DEMO_RECORD)
03170         {
03171                 assert(DemoFile && DemoFile[0]);
03172 
03173                 Client->Demo.File = fopen(DemoFile, "wb");
03174 
03175                 if (!Client->Demo.File)
03176                         return GE_FALSE;
03177 
03178                 return GE_TRUE;
03179         }
03180         else if (Client->Demo.Mode == CLIENT_DEMO_PLAY && DemoFile[0])
03181         {
03182                 Client->Demo.NumDemos = 1;
03183                 Client->Demo.CurrentDemo = 0;
03184                 strcpy(Client->Demo.DemoNames[0], DemoFile);
03185         }
03186         else if (Client->Demo.Mode == CLIENT_DEMO_PLAY && !DemoFile[0])
03187         {
03188                 if (!ReadDemoIni(Client))
03189                         return GE_FALSE;
03190         }
03191 
03192         if (Client->Demo.Mode == CLIENT_DEMO_PLAY)
03193         {
03194                 if (!Client_SetDemo(Client, Client->Demo.CurrentDemo))
03195                         return GE_FALSE;
03196         }
03197 
03198         return GE_TRUE;
03199 }

geBoolean Client_UpdateSinglePlayer Client_Client Client,
GPlayer Player,
float  Ratio,
float  Time,
geBoolean  TempPlayer
 

Definition at line 2186 of file Client.c.

References GE_LVertex::a, GameMgr_BoneIndex::Active, GameMgr_MotionIndexDef::Active, GPlayer::Actor, GPlayer::ActorDef, GPlayer::Angles, GE_LVertex::b, GPlayer_XFormData::BoneIndex, GameMgr_BoneIndex::BoneName, CheckClientPlayerChanges(), Client_IsValid(), GPlayer::FrameTime, Fx_PlayerFrame(), GE_LVertex::g, GameMgr_GetBoneIndex(), GameMgr_GetFxSystem(), GameMgr_GetMotionIndexDef(), GameMgr_GetWorld(), GAMEMGR_MOTION_INDEX_NONE, GE_FALSE, GE_TRUE, geActor_BlendPose(), geActor_GetBoneAttachment(), geActor_GetMotionByName(), geActor_SetBoneAttachment(), geActor_SetPose(), geBoolean, GenVS_Error(), gePoly_SetLVertex(), geVec3d_CrossProduct(), geVec3d_Normalize(), geVec3d_Set(), geWorld_SetLightAttributes(), geWorld_SetModelXForm(), geXForm3d_GetIn(), geXForm3d_GetLeft(), geXForm3d_Multiply(), geXForm3d_SetEulerAngles(), geXForm3d_SetFromLeftUpIn(), geXForm3d_SetXRotation(), Client_Client::GMgr, int32, GPlayer::Light, GPlayer::Mesh, GPlayer::Model, GPlayer::MotionData, GPlayer_MotionData::MotionIndex, GPlayer::MotionIndex, GameMgr_MotionIndexDef::MotionName, GPlayer_MotionData::MotionTime, NULL, GPlayer::NumMotionData, GPlayer::NumXFormData, GPlayer::OldFrameTime, PLAYER_TO_FXPLAYER, GPlayer::Poly, GPlayer::Pos, GE_LVertex::r, TEMP_PLAYER_TO_FXPLAYER, geXForm3d::Translation, GE_LVertex::u, GE_LVertex::v, VIEW_TYPE_ACTOR, VIEW_TYPE_SPRITE, VIEW_TYPE_YAW_ONLY, GPlayer::ViewFlags, geVec3d::X, GE_LVertex::X, GPlayer_XFormData::XForm, GPlayer::XForm, GPlayer::XFormData, geVec3d::Y, GE_LVertex::Y, geVec3d::Z, and GE_LVertex::Z.

Referenced by ControlTempPlayers(), ForceServerPlayerOnLocalClient(), UpdatePlayers(), and UpdateProxyPlayer().

02187 {
02188         geXForm3d               XForm;
02189         geWorld                 *World;
02190 
02191         assert(Client_IsValid(Client) == GE_TRUE);
02192 
02193         World = GameMgr_GetWorld(Client->GMgr);
02194 
02195         // Can't mess with hardly anything if the world is not loaded
02196         // so just return and wait for the world to be loaded...
02197         if (!World)
02198                 return GE_TRUE;
02199 
02200         // Took this out because it was preventing my bots from getting an actor
02201         //if (Client->ViewPlayer == -1)         // Don't do nothing till we know who represents our view
02202         //      return GE_TRUE;
02203         
02204         geXForm3d_SetEulerAngles(&XForm, &Player->Angles);
02205         XForm.Translation = Player->Pos;
02206 
02207         // Save the transform
02208         Player->XForm = XForm;
02209 
02210         // See what has changed recently about the players ViewFlags, ViewIndex, etc...
02211         CheckClientPlayerChanges(Client, Player, TempPlayer);
02212 
02213         // Update any valid world entities that may be attached to this player
02214         if (Player->Light)
02215         {
02216                 GE_RGBA RGBA = {255.0f, 55.0f, 15.0f, 255.0f};
02217                 geWorld_SetLightAttributes(World, Player->Light, 
02218                                                                    &Player->Pos, &RGBA, 320.0f, GE_FALSE);
02219         }
02220 
02221         if (Player->Mesh)
02222         {
02223                 geXForm3d       TXForm;
02224                 geVec3d         In, Up, Lf, Pos;
02225 
02226                 Pos = Player->XForm.Translation;
02227 
02228                 if (Player->ViewFlags & VIEW_TYPE_YAW_ONLY)
02229                 {
02230                         geVec3d_Set(&Up, 0.0f, 1.0f, 0.0f);
02231 
02232                         geXForm3d_GetIn(&Player->XForm, &In);
02233                         geXForm3d_GetLeft(&Player->XForm, &Lf);
02234 
02235                         geVec3d_CrossProduct(&In, &Up, &Lf);
02236                         geVec3d_CrossProduct(&Lf, &Up, &In);
02237 
02238                         geVec3d_Normalize(&Lf);
02239                         geVec3d_Normalize(&In);
02240                 
02241                         geXForm3d_SetFromLeftUpIn(&TXForm, &Lf, &Up, &In);
02242                 }
02243                 else
02244                 {
02245                         TXForm = Player->XForm;
02246                 }
02247 
02248                 TXForm.Translation = Pos;
02249 
02250 #if 0
02251                 geWorld_SetMeshXForm(World, Player->Mesh, &TXForm);
02252                 geWorld_SetMeshFrame(World, Player->Mesh, (int32)Player->FrameTime);
02253 #endif
02254         }
02255 
02256         if (Player->Actor)
02257         {
02258                 geXForm3d                               XForm;
02259                 geVec3d                                 In, Up, Lf, Pos;
02260                 geMotion                                *Motion;
02261                 char                                    *MotionName;
02262                 GameMgr_MotionIndexDef  *MotionIndex;
02263                 
02264                 assert((Player->ViewFlags & VIEW_TYPE_ACTOR));
02265 
02266                 Pos = Player->XForm.Translation;
02267 
02268                 if (Player->ViewFlags & VIEW_TYPE_YAW_ONLY)
02269                 {
02270                         geVec3d_Set(&Up, 0.0f, 1.0f, 0.0f);
02271 
02272                         geXForm3d_GetIn(&Player->XForm, &In);
02273                         geXForm3d_GetLeft(&Player->XForm, &Lf);
02274 
02275                         geVec3d_CrossProduct(&In, &Up, &Lf);
02276                         geVec3d_CrossProduct(&Lf, &Up, &In);
02277 
02278                         geVec3d_Normalize(&Lf);
02279                         geVec3d_Normalize(&In);
02280                 
02281                         geXForm3d_SetFromLeftUpIn(&XForm, &Lf, &Up, &In);
02282                 }
02283                 else
02284                 {
02285                         XForm = Player->XForm;
02286                 }
02287                 
02288                 if (Player->ViewFlags & VIEW_TYPE_ACTOR)
02289                 {
02290                         
02291                         geXForm3d       RXForm;
02292                         geXForm3d_SetXRotation(&RXForm, -(3.14159f/2.0f));
02293                         geXForm3d_Multiply(&XForm, &RXForm, &XForm);
02294                 }
02295                 
02296                 XForm.Translation = Pos;
02297 
02298                 if (Player->MotionIndex == GAMEMGR_MOTION_INDEX_NONE)
02299                 {
02300                         if (!geActor_SetBoneAttachment(Player->Actor, NULL, &XForm))
02301                         {
02302                                 GenVS_Error("Client_UpdateSinglePlayer:  geActor_SetBoneAttachment failed...");
02303                         }
02304                 }
02305                 else
02306                 {
02307                         MotionIndex = GameMgr_GetMotionIndexDef(Client->GMgr, Player->MotionIndex);
02308 
02309                         assert(MotionIndex);
02310                         assert(MotionIndex->Active == GE_TRUE);
02311 
02312                         // Set the base motion and transform
02313                         if (MotionIndex->Active)
02314                         {
02315                                 float FrameTime;
02316                                                         
02317                                 if (Player->FrameTime > Player->OldFrameTime)
02318                                         FrameTime = Player->OldFrameTime + (Player->FrameTime - Player->OldFrameTime) * Ratio;
02319                                 else
02320                                         FrameTime = Player->FrameTime;
02321 
02322                                 MotionName = MotionIndex->MotionName;
02323                         
02324                                 Motion = geActor_GetMotionByName(Player->ActorDef, MotionName);
02325                                 
02326                                 if (!Motion)
02327                                         GenVS_Error("Client_UpdateSinglePlayer:  geActor_GetMotionByName1 failed...");
02328 
02329                                 geActor_SetPose(Player->Actor, Motion, FrameTime, &XForm);
02330                         }
02331                 }
02332 
02333                 // Go through and blend in all the motion hacks...
02334                 {
02335                         int32                           i;
02336                         GPlayer_MotionData      *pMotionData;
02337 
02338                         pMotionData = Player->MotionData;
02339 
02340                         for (i=0; i< Player->NumMotionData; i++, pMotionData++)
02341                         {
02342                                 MotionIndex = GameMgr_GetMotionIndexDef(Client->GMgr, pMotionData->MotionIndex);
02343 
02344                                 assert(MotionIndex->Active == GE_TRUE);
02345 
02346                                 if (!MotionIndex->Active)
02347                                         continue;
02348 
02349                                 Motion = geActor_GetMotionByName(Player->ActorDef, MotionIndex->MotionName);
02350 
02351                                 if (!Motion)
02352                                         GenVS_Error("Client_UpdateSinglePlayer:  geActor_GetMotionByName2 failed...");
02353 
02354                                 geActor_BlendPose(Player->Actor, Motion, pMotionData->MotionTime, &XForm, 1.0f);
02355                         }
02356                 }
02357 
02358                 // Go through and set all the xform hacks for the bones...
02359                 {
02360                         int32                           i;
02361                         GPlayer_XFormData       *pXFormData;
02362                         GameMgr_BoneIndex       *pBoneIndex;
02363                         geXForm3d                       BoneXForm;
02364 
02365                         pXFormData = Player->XFormData;
02366 
02367                         for (i=0; i< Player->NumXFormData; i++, pXFormData++)
02368                         {
02369                                 pBoneIndex = GameMgr_GetBoneIndex(Client->GMgr, pXFormData->BoneIndex);
02370 
02371                                 assert(pBoneIndex->Active == GE_TRUE);
02372 
02373                                 if (!pBoneIndex->Active)
02374                                         continue;
02375 
02376                                 geActor_GetBoneAttachment(Player->Actor, pBoneIndex->BoneName, &BoneXForm);
02377 
02378                                 pXFormData->XForm.Translation = BoneXForm.Translation;
02379 
02380                                 geActor_SetBoneAttachment(Player->Actor, pBoneIndex->BoneName, &pXFormData->XForm);
02381                         }
02382                 }
02383                                 
02384         }
02385 
02386         if (Player->Model)// && !Host->Server)
02387         {
02388                 geWorld_SetModelXForm(World, Player->Model, &XForm);
02389         }
02390 
02391         if (Player->Poly && Player->ViewFlags & VIEW_TYPE_SPRITE)
02392         {
02393                 GE_LVertex      Vert;
02394 
02395                 Vert.X = Player->Pos.X;
02396                 Vert.Y = Player->Pos.Y;
02397                 Vert.Z = Player->Pos.Z;
02398                 Vert.u = 0.0f;
02399                 Vert.v = 0.0f;
02400                 Vert.r = Vert.a = 255.0f;
02401                 Vert.g = Vert.b = 255.0f;
02402 
02403                 gePoly_SetLVertex(Player->Poly, 0, &Vert);
02404         }
02405                         
02406         // Run this players effects
02407         if (TempPlayer)
02408         {
02409                 if (!Fx_PlayerFrame(GameMgr_GetFxSystem(Client->GMgr), TEMP_PLAYER_TO_FXPLAYER(Client, Player), &Player->XForm, Time))
02410                         GenVS_Error("[CLIENT] UpdateSinglePlayer:  Could not run Fx_Player frame.\n");
02411         }
02412         else
02413         {
02414                 if (!Fx_PlayerFrame(GameMgr_GetFxSystem(Client->GMgr), PLAYER_TO_FXPLAYER(Client, Player), &Player->XForm, Time))
02415                         GenVS_Error("[CLIENT] UpdateSinglePlayer:  Could not run Fx_Player frame.\n");
02416         }
02417 
02418         return GE_TRUE;
02419 }


Generated on Tue Sep 30 12:37:13 2003 for GTestAndEngine by doxygen 1.3.2