#include <Windows.h>#include <Assert.h>#include <Time.h>#include "Server.h"Go to the source code of this file.
|
|
Definition at line 1456 of file Server.c. Referenced by GetPlayerSendFlags(). |
|
|
|
|
|
Definition at line 2958 of file Server.c. Referenced by Server_ActorToPlayer(). |
|
|
Value: { \
LARGE_INTEGER DeltaTick; \
float ElapsedTime, Total; \
int32 i; \
\
QueryPerformanceCounter(&g_CurTick); \
SubLarge(&g_OldTick, &g_CurTick, &DeltaTick); \
\
if (DeltaTick.LowPart > 0) \
ElapsedTime = 1.0f / (((float)g_Freq.LowPart / (float)DeltaTick.LowPart)); \
else \
ElapsedTime = 0.001f; \
\
AvgTime[CurAvg] = ElapsedTime; \
CurAvg++; \
CurAvg %= NUM_AVG; \
\
for (Total = 0.0f, i=0; i< NUM_AVG; i++) \
Total += AvgTime[i]; \
\
Total *= (1.0f/ NUM_AVG); \
\
geEngine_Printf(GameMgr_GetEngine(g), 1, 70, "Timer ms: %2.3f/%2.3f", ElapsedTime, Total); \
}
|
|
|
|
|
|
Definition at line 1459 of file Server.c. Referenced by GetPlayerSendFlags(). |
|
|
|
|
|
Definition at line 1457 of file Server.c. Referenced by GetPlayerSendFlags(). |
|
|
Definition at line 95 of file Server.c. Referenced by FillBufferWithPlayerData(), ForceServerPlayerOnLocalClient(), Server_GetPlayerTimeExtents(), Server_SendClientCurrentWorldData(), Server_SetViewPlayer(), and Server_ValidateClient(). |
|
|
Definition at line 1458 of file Server.c. Referenced by GetPlayerSendFlags(). |
|
||||||||||||
|
Definition at line 884 of file Server.c. References GPlayer::ClassData, GPlayer::DFunc, Server_Server::GenVSI, and NULL. Referenced by Server_DestroyPlayer().
|
|
||||||||||||||||
|
Definition at line 2100 of file Server.c. References GPlayer::Angles, GPlayer::Control, GenVS_Error(), Server_Server::GenVSI, geXForm3d_GetEulerAngles(), GPlayer::Pos, geXForm3d::Translation, and GPlayer::XForm. Referenced by ControlPlayers(), and ParseClientMove().
02101 {
02102 assert (Player->Control);
02103
02104 if (!Player->Control)
02105 return;
02106
02107 // Force an update now, so the player will be in the correct location for collision, etc...
02108 //ForceServerPlayerOnLocalClient(Server, Player);
02109
02110 if (!Player->Control(&Server->GenVSI, Player, Time))
02111 GenVS_Error("[SERVER] ControlPlayer: Failed.");
02112
02113 geXForm3d_GetEulerAngles(&Player->XForm, &Player->Angles);
02114 Player->Pos = Player->XForm.Translation;
02115
02116 // Force an update now, so the player will be in the correct location for collision, etc...
02117 //ForceServerPlayerOnLocalClient(Server, Player);
02118 }
|
|
||||||||||||
|
Definition at line 2123 of file Server.c. References GPlayer::Active, GPlayer::Angles, CLIENT_NULL_HANDLE, GPlayer::ClientHandle, GPlayer::Control, ControlPlayer(), ForceServerPlayerOnLocalClient(), GE_TRUE, geBoolean, geXForm3d_GetEulerAngles(), int32, NETMGR_MAX_PLAYERS, GPlayer::PingTime, GPlayer::Pos, Server_IsClientBot(), Server_Server::SvPlayers, geXForm3d::Translation, and GPlayer::XForm. Referenced by Server_Frame().
02124 {
02125 GPlayer *Player;
02126 int32 i;
02127
02128 for (i=0; i< NETMGR_MAX_PLAYERS; i++)
02129 {
02130 Player = &Server->SvPlayers[i];
02131
02132 if (!Player->Active)
02133 continue;
02134
02135 if (!Player->Control) // If no control set, then don't worry about it...
02136 continue;
02137
02138 if (Player->ClientHandle != CLIENT_NULL_HANDLE && !Server_IsClientBot(Server, Player->ClientHandle))
02139 {
02140
02141 geXForm3d_GetEulerAngles(&Player->XForm, &Player->Angles);
02142 Player->Pos = Player->XForm.Translation;
02143
02144 // Force an update now, so the player will be in the correct location for collision, etc...
02145 ForceServerPlayerOnLocalClient(Server, Player);
02146
02147 continue;
02148 }
02149
02150 // If the players ping time is greater than 0, than he got spawned from a client.
02151 // Play out all the clients ping first, so we will be in the correct location for the
02152 // client on his machine. Everyone else will suffer though...
02153 if (Player->PingTime > 0) // Guess where it will be on the poor client who created this player
02154 {
02155 float Val;
02156
02157 Val = Player->PingTime * (1.0f/20.0f); // Play through in 20 ms intervals
02158 //Val = Player->PingTime / Val;
02159
02160 // Drain all the ping time (that belonged to the client that spawned this player) out of the player
02161 while (Player->PingTime > 0.0f && Player->Active)
02162 {
02163 ControlPlayer(Server, Player, Val);
02164
02165 Player->PingTime -= Val;
02166 }
02167
02168 // Reset ping time so it won't get used unless initialized again by a move intention...
02169 Player->PingTime = -1.0f;
02170 }
02171 else
02172 ControlPlayer(Server, Player, Time);
02173
02174 // Force an update now, so the player will be in the correct location for collision, etc...
02175 ForceServerPlayerOnLocalClient(Server, Player);
02176 }
02177
02178 return GE_TRUE;
02179 }
|
|
||||||||||||||||||||
|
Definition at line 2005 of file Server.c. References DrawFace(), geFloat, geVec3d_Add(), geVec3d::X, geVec3d::Y, and geVec3d::Z.
02006 {
02007 geFloat dx;
02008 geFloat dy;
02009 geFloat dz;
02010 static geVec3d Verts[8];
02011 static geVec3d * Faces[6][4] =
02012 {
02013 { &Verts[0], &Verts[1], &Verts[2], &Verts[3] }, //Top
02014 { &Verts[4], &Verts[5], &Verts[6], &Verts[7] }, //Bottom
02015 { &Verts[3], &Verts[2], &Verts[6], &Verts[7] }, //Side
02016 { &Verts[1], &Verts[0], &Verts[4], &Verts[5] }, //Side
02017 { &Verts[0], &Verts[3], &Verts[7], &Verts[4] }, //Front
02018 { &Verts[2], &Verts[1], &Verts[5], &Verts[6] }, //Back
02019 };
02020 int i;
02021
02022 for (i = 0; i < 8; i++)
02023 geVec3d_Add(Pos, Min, &Verts[i]);
02024
02025 dx = Max->X - Min->X;
02026 dy = Max->Y - Min->Y;
02027 dz = Max->Z - Min->Z;
02028
02029 Verts[0].Y += dy;
02030 Verts[3].Y += dy;
02031 Verts[3].X += dx;
02032 Verts[7].X += dx;
02033
02034 Verts[1].Y += dy;
02035 Verts[1].Z += dz;
02036 Verts[5].Z += dz;
02037 Verts[6].Z += dz;
02038 Verts[6].X += dx;
02039
02040 Verts[2].X += dx;
02041 Verts[2].Y += dy;
02042 Verts[2].Z += dz;
02043
02044 for (i = 0; i < 6; i++)
02045 DrawFace(World, &Faces[i][0]);
02046 }
|
|
||||||||||||
|
Definition at line 1986 of file Server.c. References GE_LVertex::a, GE_LVertex::b, GE_LVertex::g, GE_GOURAUD_POLY, GE_RENDER_DO_NOT_OCCLUDE_OTHERS, geFloat, geWorld_AddPolyOnce(), NULL, GE_LVertex::r, geVec3d::X, GE_LVertex::X, geVec3d::Y, GE_LVertex::Y, geVec3d::Z, and GE_LVertex::Z.
01987 {
01988 GE_LVertex LVerts[4];
01989 int i;
01990
01991 for (i = 0; i < 4; i++)
01992 {
01993 LVerts[i].r = 40.0f;
01994 LVerts[i].g = 40.0f;
01995 LVerts[i].b = 80.0f + 20.0f * (geFloat)i;
01996 LVerts[i].a = 128.0f;
01997 LVerts[i].X = Verts[i]->X;
01998 LVerts[i].Y = Verts[i]->Y;
01999 LVerts[i].Z = Verts[i]->Z;
02000 }
02001
02002 geWorld_AddPolyOnce(World, &LVerts[0], 4, NULL, GE_GOURAUD_POLY, GE_RENDER_DO_NOT_OCCLUDE_OTHERS, 1.0f);
02003 }
|
|
||||||||||||
|
Definition at line 207 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillSLong(), Buffer_FillString(), Server_Server::Clients, GE_TRUE, geBoolean, Server_Client::Health, int32, Server_Client::Name, NETMGR_MAX_CLIENTS, NETMGR_MSG_CLIENT_ACTIVE, NETMGR_MSG_CLIENT_HEALTH, NETMGR_MSG_CLIENT_NAME, NETMGR_MSG_CLIENT_SCORE, and Server_Client::Score. Referenced by Server_SendClientStartupData().
00208 {
00209 int32 i;
00210 Server_Client *Client;
00211
00212 Client = Server->Clients;
00213
00214 for (i=0; i< NETMGR_MAX_CLIENTS; i++, Client++)
00215 {
00216 if (!Client->Active)
00217 continue;
00218
00219 Buffer_FillByte(Buffer, NETMGR_MSG_CLIENT_ACTIVE);
00220 Buffer_FillByte(Buffer, (char)i);
00221 Buffer_FillByte(Buffer, 1);
00222
00223 Buffer_FillByte(Buffer, NETMGR_MSG_CLIENT_NAME);
00224 Buffer_FillByte(Buffer, (char)i);
00225 Buffer_FillString(Buffer, Client->Name);
00226
00227 Buffer_FillByte(Buffer, NETMGR_MSG_CLIENT_SCORE);
00228 Buffer_FillByte(Buffer, (char)i);
00229 Buffer_FillSLong(Buffer, Client->Score);
00230
00231 Buffer_FillByte(Buffer, NETMGR_MSG_CLIENT_HEALTH);
00232 Buffer_FillByte(Buffer, (char)i);
00233 Buffer_FillSLong(Buffer, Client->Health);
00234 }
00235
00236 return GE_TRUE;
00237 }
|
|
||||||||||||||||||||
|
Definition at line 1582 of file Server.c. References GPlayer::Angles, GPlayer_XFormData::BoneIndex, Buffer_FillAngle(), Buffer_FillByte(), Buffer_FillFloat(), Buffer_FillFloat2(), Buffer_FillPos(), Buffer_FillShort(), GPlayer::ControlIndex, GPlayer::FrameTime, GPlayer::FxFlags, geXForm3d_GetEulerAngles(), GPLAYER_MAX_MOTION_DATA, GPLAYER_MAX_XFORM_DATA, int32, GPlayer::Maxs, GPlayer::Mins, 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, GPlayer::NumMotionData, GPlayer::NumXFormData, GPlayer::Pos, GPlayer::Scale, SERVER_GPLAYER_TO_INDEX, GPlayer::SpawnTime, GPlayer::State, geXForm3d::Translation, GPlayer::TriggerIndex, uint16, uint8, GPlayer::Velocity, VIEW_TYPE_HACK, GPlayer::ViewFlags, GPlayer::ViewIndex, GPlayer_XFormData::XForm, GPlayer::XForm, and GPlayer::XFormData. Referenced by ForceServerPlayerOnLocalClient(), SendClientPlayerData(), and SendPlayersToClients().
01583 {
01584 uint16 Index;
01585
01586 assert(Server);
01587 assert(Buffer);
01588 assert(Player);
01589
01590 Index = (uint16)SERVER_GPLAYER_TO_INDEX(Server, Player);
01591
01592 assert(Index < (65535>>1));
01593
01594 //SendFlags = 0xffff; // For debugging
01595
01596 if (SendFlags)
01597 Index |= (1<<15);
01598
01599 Buffer_FillShort(Buffer, Index);
01600
01601 if (!SendFlags)
01602 return;
01603
01604 // Write out what we are sending
01605 Buffer_FillShort(Buffer, SendFlags);
01606
01607 // Make sure Player->Pos and Angles are valid (These are temporary data that are used to send data between server and client)
01608 geXForm3d_GetEulerAngles(&Player->XForm, &Player->Angles);
01609 Player->Pos = Player->XForm.Translation;
01610
01611 // Write out the real data
01612 if (SendFlags & NETMGR_SEND_SPAWN_TIME)
01613 Buffer_FillFloat(Buffer, Player->SpawnTime);
01614
01615 if (SendFlags & NETMGR_SEND_VIEW_FLAGS)
01616 Buffer_FillShort(Buffer, Player->ViewFlags);
01617
01618 if (SendFlags & NETMGR_SEND_VIEW_INDEX)
01619 Buffer_FillShort(Buffer, Player->ViewIndex);
01620
01621 if (SendFlags & NETMGR_SEND_MOTION_INDEX)
01622 Buffer_FillByte(Buffer, Player->MotionIndex);
01623
01624 if (SendFlags & NETMGR_SEND_FX_FLAGS)
01625 Buffer_FillShort(Buffer, Player->FxFlags);
01626
01627 if (SendFlags & NETMGR_SEND_POS)
01628 //Buffer_FillPos2(Buffer, Player->Pos);
01629 Buffer_FillPos(Buffer, Player->Pos);
01630
01631 if (SendFlags & NETMGR_SEND_ANGLES)
01632 Buffer_FillAngle(Buffer, Player->Angles);
01633
01634 if (SendFlags & NETMGR_SEND_FRAME_TIME)
01635 //Buffer_FillFloat(Buffer, Player->FrameTime);
01636 Buffer_FillFloat2(Buffer, Player->FrameTime, 60.0f);
01637
01638 if (SendFlags & NETMGR_SEND_SCALE)
01639 //Buffer_FillFloat(Buffer, Player->Scale);
01640 Buffer_FillFloat2(Buffer, Player->Scale, 100.0f);
01641
01642 if (SendFlags & NETMGR_SEND_VELOCITY)
01643 Buffer_FillAngle(Buffer, Player->Velocity);
01644
01645 if (SendFlags & NETMGR_SEND_STATE)
01646 {
01647 assert(Player->State >= 0 && Player->State <= 255);
01648
01649 Buffer_FillByte(Buffer, (uint8)Player->State);
01650 }
01651
01652 if (SendFlags & NETMGR_SEND_CONTROL_INDEX)
01653 Buffer_FillShort(Buffer, Player->ControlIndex);
01654
01655 if (SendFlags & NETMGR_SEND_TRIGGER_INDEX)
01656 Buffer_FillShort(Buffer, Player->TriggerIndex);
01657
01658 if (SendFlags & NETMGR_SEND_MINS_MAXS)
01659 {
01660 Buffer_FillPos(Buffer, Player->Mins);
01661 Buffer_FillPos(Buffer, Player->Maxs);
01662 }
01663
01664 #if 0
01665 // TOTAL hack for now... (this is a way to get extra xforms to control extra bones...
01666 if (Player->ViewFlags & VIEW_TYPE_HACK)
01667 {
01668 GPlayer_XFormData *pXFormData;
01669 int32 i;
01670
01671 assert(Player->NumXFormData <= 255 && Player->NumXFormData < GPLAYER_MAX_XFORM_DATA);
01672
01673 Buffer_FillByte(Buffer, (uint8)Player->NumXFormData);
01674
01675 pXFormData = Player->XFormData;
01676
01677 for (i=0; i<Player->NumXFormData; i++, pXFormData++)
01678 {
01679 geVec3d EulerAngles;
01680
01681 geXForm3d_GetEulerAngles(&pXFormData->XForm, &EulerAngles);
01682 Buffer_FillAngle(Buffer, EulerAngles);
01683 Buffer_FillPos(Buffer, pXFormData->XForm.Translation);
01684 Buffer_FillByte(Buffer, pXFormData->BoneIndex);
01685 }
01686
01687 }
01688
01689 // TOTAL hack for now... (this is a way to get extra motions in a player for actors
01690 if (Player->ViewFlags & VIEW_TYPE_HACK)
01691 {
01692 GPlayer_MotionData *pMotionData;
01693 int32 i;
01694
01695 assert(Player->NumMotionData <= 255 && Player->NumMotionData < GPLAYER_MAX_MOTION_DATA);
01696
01697 Buffer_FillByte(Buffer, (uint8)Player->NumMotionData);
01698
01699 pMotionData = Player->MotionData;
01700
01701 for (i=0; i<Player->NumMotionData; i++, pMotionData++)
01702 {
01703 Buffer_FillFloat(Buffer, pMotionData->MotionTime);
01704 //Buffer_FillFloat2(Buffer, pMotionData->MotionTime, 60.0f);
01705 Buffer_FillByte(Buffer, pMotionData->MotionIndex);
01706 }
01707 }
01708
01709 #endif
01710
01711 }
|
|
||||||||||||
|
Definition at line 1224 of file Server.c. References Server_Client::Active, Server_Server::Clients, int32, Server_Client::NetID, NETMGR_MAX_CLIENTS, and NULL. Referenced by ParseClientMessage().
01225 {
01226 int32 i;
01227 Server_Client *Client;
01228
01229 Client = Server->Clients;
01230
01231 for (i=0; i< NETMGR_MAX_CLIENTS; i++, Client++)
01232 {
01233 if (!Client->Active)
01234 continue;
01235
01236 if (Client->NetID == ClientID)
01237 return Client;
01238 }
01239
01240 return NULL;
01241 }
|
|
||||||||||||
|
Definition at line 2052 of file Server.c. References GPlayer::Active, GPlayer::Angles, Buffer_Set(), Server_Server::Client, Client_ParsePlayerData(), Client_UpdateSinglePlayer(), FillBufferWithPlayerData(), GameMgr_GetTime(), GameMgr_GetWorld(), GE_FALSE, Server_Server::GMgr, int32, NETMGR_MAX_PLAYERS, Client_Client::Players, GPlayer::Pos, Buffer_Data::Pos, SERVER_GPLAYER_TO_INDEX, and uint8. Referenced by ControlPlayers(), ParseClientMove(), and Server_ValidateClient().
02053 {
02054 GPlayer *ClientPlayer;
02055 int32 PlayerIndex;
02056 Buffer_Data Buffer;
02057 uint8 Data[1024];
02058
02059 assert(Server);
02060 assert(Server->Client);
02061 assert(Player);
02062
02063 if (!GameMgr_GetWorld(Server->GMgr)) // Don't do nothing with genesis until world is loaded
02064 return;
02065
02066 if (!Player->Active)
02067 return;
02068
02069 PlayerIndex = (int32)SERVER_GPLAYER_TO_INDEX(Server, Player);
02070
02071 assert(PlayerIndex >= 0 && PlayerIndex < NETMGR_MAX_PLAYERS);
02072
02073 // Get a pointer to the client version of this player on the server
02074 //ClientPlayer = Client_GetPlayerForIndex(Server->Host->Client, PlayerIndex);
02075 ClientPlayer = &Server->Client->Players[PlayerIndex];
02076
02077 Buffer_Set(&Buffer, Data, 1024);
02078
02079 // Fill the buffer with the player data
02080 FillBufferWithPlayerData(Server, &Buffer, Player, 0xffff);
02081
02082 // FIXME: Call Buffer_Reset
02083 Buffer.Pos = 0;
02084
02085 Client_ParsePlayerData(Server->Client, &Buffer, GE_FALSE);
02086
02087 // Override some important ones...
02088 ClientPlayer->Pos = Player->Pos;
02089 ClientPlayer->Angles = Player->Angles;
02090
02091 // Make the client update this player NOW
02092 Client_UpdateSinglePlayer(Server->Client, ClientPlayer, 1.0f, GameMgr_GetTime(Server->GMgr), GE_FALSE);
02093
02094 }
|
|
||||||||||||
|
||||||||||||
|
||||||||||||||||||||
|
Definition at line 1331 of file Server.c. References Buffer_GetByte(), Buffer_GetSLong(), Console_Printf(), FindClient(), GameMgr_GetConsole(), GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, NETMGR_MSG_CLIENT_CONFIRM, NETMGR_MSG_CLIENT_MOVE, NetMgr_NetState, Server_Client::NetStateConfirmed, ParseClientMove(), Server_Client::Player, Buffer_Data::Pos, Buffer_Data::Size, and uint8. Referenced by ReadClientMessages().
01332 {
01333 uint8 Type;
01334 Server_Client *Client;
01335
01336 Client = FindClient(Server, ClientID);
01337
01338 if (!Client)
01339 {
01340 //GenVS_Error("Server_ParseClientMessage: FindClient failed.\n");
01341 Console_Printf(GameMgr_GetConsole(Server->GMgr), "ParseClientMessage: FindClient failed.\n");
01342 return GE_TRUE; // Ignore??
01343 }
01344
01345 if (!Client->Player)
01346 return GE_TRUE; // The client spawn function has not beed called yet in the game code...
01347
01348 Buffer->Pos = 0;
01349
01350 // Keep reading till end of buffer
01351 while (Buffer->Pos < Buffer->Size)
01352 {
01353 //geVec3d Angles;
01354
01355 Buffer_GetByte(Buffer, &Type);
01356
01357 switch(Type)
01358 {
01359 case NETMGR_MSG_CLIENT_MOVE:
01360 {
01361 ParseClientMove(Server, Buffer, Client, Time);
01362 break;
01363 }
01364
01365 case NETMGR_MSG_CLIENT_CONFIRM:
01366 {
01367 NetMgr_NetState NetState;
01368
01369 Buffer_GetSLong(Buffer, &NetState);
01370
01371 //Console_Printf(GameMgr_GetConsole(Server->GMgr), "Client %s, confirmed state: %i\n", Client->Name, NetState);
01372
01373 // This NetState has been confirmed
01374 Client->NetStateConfirmed[NetState] = GE_TRUE;
01375
01376 break;
01377 }
01378
01379 default:
01380 {
01381 GenVS_Error("Server_ParseClientMessage: Invalid msg type.\n");
01382 }
01383 }
01384 }
01385
01386 return GE_TRUE;
01387 }
|
|
||||||||||||||||||||
|
Definition at line 1246 of file Server.c. References Server_Client::Angles, Buffer_GetAngle(), Buffer_GetFloat(), Buffer_GetShort(), Server_Client::ButtonBits, ControlPlayer(), Server_Client::CurrentWeapon, ForceServerPlayerOnLocalClient(), Server_Client::ForwardSpeed, GameMgr_GetTime(), GameMgr_GetWorld(), geEngine_Printf(), GenVS_Error(), geVec3d_Compare(), geVec3d_Length(), geVec3d_Subtract(), Server_Server::GMgr, HOST_BUTTON_FIRE, Server_Client::MoveTime, Server_Client::NumPings, Server_Client::OldMoveTime, GPlayer::OldPos, Server_Client::Ping, Server_Client::Pings, GPlayer::PingTime, Server_Client::Player, Server_Client::Pos, GPlayer::SpawnTime, geXForm3d::Translation, geVec3d::X, GPlayer::XForm, and geVec3d::Y. Referenced by ParseClientMessage().
01247 {
01248 float DeltaTime, MoveTime, NetTime;
01249 geVec3d Origin = {0.0f, 0.0f, 0.0f};
01250
01251 Buffer_GetFloat(Buffer, &MoveTime);
01252 Buffer_GetFloat(Buffer, &NetTime); // For getting pings for throttling messages to this client
01253 Buffer_GetFloat(Buffer, &Client->ForwardSpeed);
01254 Buffer_GetFloat(Buffer, &Client->Angles.X);
01255 Buffer_GetFloat(Buffer, &Client->Angles.Y);
01256 Buffer_GetShort(Buffer, &Client->ButtonBits);
01257
01258 if (NetTime >= 0) // -1 represents that the client did not get an update that frame...
01259 {
01260 float Ping;
01261
01262 Ping = GameMgr_GetTime(Server->GMgr) - NetTime;
01263
01264 if (Ping >= 0)
01265 {
01266 Client->Pings[Client->NumPings%10] = Ping;
01267 Client->NumPings++;
01268 }
01269 }
01270
01271 if (Client->ButtonBits & HOST_BUTTON_FIRE)
01272 Buffer_GetShort(Buffer, &Client->CurrentWeapon); // Read Current Weapon if firing
01273
01274 #ifdef CALC_ERROR
01275 Buffer_GetAngle(Buffer, &Client->Pos);
01276 #endif
01277
01278 if (!GameMgr_GetWorld(Server->GMgr))
01279 return;
01280
01281 Client->OldMoveTime = Client->MoveTime;
01282 Client->MoveTime = MoveTime;
01283
01284 if (MoveTime <= Client->OldMoveTime)
01285 return;
01286
01287 // Since the client is going to be controlled in the main loop, pull off the amount
01288 // of time it is going to move it from this time.
01289 DeltaTime = Client->MoveTime - Client->OldMoveTime;
01290
01291 if (DeltaTime <= 0.0f) // Ignore older messages (this will lose button bits every now and then...)
01292 return;
01293
01294 if (DeltaTime > 0.1f)
01295 DeltaTime = 0.1f;
01296 else if (DeltaTime < 0.001f)
01297 DeltaTime = 0.001f;
01298
01299 #ifdef CALC_ERROR
01300 if (!geVec3d_Compare(&Client->Pos, &Origin, 0.1f))
01301 {
01302 geVec3d Vect;
01303
01304 geVec3d_Subtract(&Client->Player->XForm.Translation, &Client->Pos, &Vect);
01305
01306 if (geVec3d_Length(&Vect) > 1.0f)
01307 {
01308 Client->Player->OldPos.X = 0.0f;
01309 geEngine_Printf(Server->Host->Engine, 10, 100, "Client prediction error.");
01310 }
01311 }
01312 #endif
01313
01314 if (Client->Player) // Must control the client now, with these move intentions...
01315 {
01316 Client->Player->SpawnTime = Client->MoveTime; // Set this now, so weapons spawned by this move can
01317 Client->Player->PingTime = Client->Ping;
01318 // Be time stamped...
01319 //Client->Player->Control(&Server->GenVSI, Client->Player, DeltaTime);
01320 ControlPlayer(Server, Client->Player, DeltaTime);
01321
01322 ForceServerPlayerOnLocalClient(Server, Client->Player);
01323 }
01324 else
01325 GenVS_Error("ParseClientMove: No player for client!!!");
01326 }
|
|
||||||||||||
|
Definition at line 1392 of file Server.c. References Buffer_Data::Data, GE_TRUE, geBoolean, geCSNetMgr_NetID, geCSNetMgr_NetMsgType, GenVS_Error(), geCSNetMgr_NetClient::Id, geCSNetMgr_NetClient::Name, NET_MSG_CREATE_CLIENT, NET_MSG_DESTROY_CLIENT, NET_MSG_HOST, NET_MSG_NONE, NET_MSG_SESSIONLOST, NET_MSG_USER, NetMgr_ReceiveClientMessage(), Server_Server::NMgr, ParseClientMessage(), Server_ClientConnect(), Server_ClientDisconnect(), and Buffer_Data::Size. Referenced by Server_Frame().
01393 {
01394 Buffer_Data Buffer;
01395 geCSNetMgr_NetID ClientId;
01396 geCSNetMgr_NetMsgType MsgType;
01397 geCSNetMgr_NetClient *pGEClient;
01398
01399 while (1) // Keep reading messages till none left...
01400 {
01401 if (!NetMgr_ReceiveClientMessage(Server->NMgr, &MsgType, &ClientId, &Buffer))
01402 GenVS_Error("ReadClientMessages: NetMgr_ReceiveClientMessage failed.\n");
01403
01404 if (MsgType == NET_MSG_NONE)
01405 break;
01406
01407 assert(Buffer.Size > 0);
01408
01409 switch(MsgType)
01410 {
01411 case NET_MSG_CREATE_CLIENT:
01412 {
01413 pGEClient = (geCSNetMgr_NetClient*)Buffer.Data;
01414
01415 if (!Server_ClientConnect(Server, pGEClient))
01416 GenVS_Error("Could not add client...\n");
01417
01418 break;
01419 }
01420
01421 case NET_MSG_DESTROY_CLIENT:
01422 {
01423
01424 pGEClient = (geCSNetMgr_NetClient*)Buffer.Data;
01425
01426 Server_ClientDisconnect(Server, pGEClient->Id, pGEClient->Name);
01427 break;
01428 }
01429
01430 case NET_MSG_USER:
01431 {
01432 if (!ParseClientMessage(Server, ClientId, &Buffer, Time))
01433 GenVS_Error("ReadClientMessages: ParseClientMessage failed.\n");
01434 break;
01435 }
01436
01437 case NET_MSG_HOST:
01438 {
01439 break;
01440 }
01441
01442 case NET_MSG_SESSIONLOST:
01443 {
01444 GenVS_Error("ReadClientMessages: Session was lost.\n");
01445 }
01446
01447 default:
01448 //GenVS_Error("ReadClientMessages: Unknown msg: %i.\n", MsgType);
01449 break;
01450 }
01451 }
01452
01453 return GE_TRUE;
01454 }
|
|
||||||||||||||||
|
||||||||||||
|
Definition at line 243 of file Server.c. References GPlayer::Active, Buffer_FillByte(), Buffer_FillFloat(), Buffer_Set(), FillBufferWithPlayerData(), GameMgr_GetTime(), GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, int32, Server_Client::NetID, NETMGR_MAX_PLAYERS, NETMGR_MSG_NEW_WORLD_PLAYER_DATA, NETMGR_MSG_TIME, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_Client::Ping, and Server_Server::SvPlayers. Referenced by Server_SetupClientWithCurrentWorld().
00244 {
00245 int32 i;
00246 Buffer_Data Buffer;
00247 char Data[20000];
00248 GPlayer *Player;
00249
00250 Buffer_Set(&Buffer, Data, 20000);
00251
00252 Buffer_FillByte(&Buffer, NETMGR_MSG_TIME);
00253 Buffer_FillFloat(&Buffer, GameMgr_GetTime(Server->GMgr));
00254 Buffer_FillFloat(&Buffer, Client->Ping);
00255
00256 Player = Server->SvPlayers;
00257
00258 for (i=0; i< NETMGR_MAX_PLAYERS; i++, Player++)
00259 {
00260 if (!Player->Active)
00261 continue;
00262
00263 Buffer_FillByte(&Buffer, NETMGR_MSG_NEW_WORLD_PLAYER_DATA);
00264
00265 FillBufferWithPlayerData(Server, &Buffer, Player, 0xffff); // Send all on a force update
00266 }
00267
00268 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00269 GenVS_Error("SendClientPlayerData: NetMgr_SendClientMessage failed.\n");
00270
00271 return GE_TRUE;
00272 }
|
|
|
Definition at line 1763 of file Server.c. References GPlayer::Active, Server_Client::Active, Buffer_FillByte(), Buffer_FillFloat(), Buffer_Set(), GPlayer::ClientHandle, Server_Server::Clients, GPlayer::Control, FALSE, FillBufferWithPlayerData(), GameMgr_GetEngine(), GameMgr_GetTime(), GameMgr_GetWorld(), GE_COLLIDE_MODELS, GE_COLLIDE_NO_SUB_MODELS, GE_CONTENTS_CANNOT_OCCUPY, GE_TRUE, geBoolean, geEngine_Printf(), GenVS_Error(), GetPlayerSendFlags(), geVec3d_AddScaled(), geWorld_Collision(), geWorld_GetLeaf(), geWorld_LeafMightSeeLeaf(), geXForm3d_GetIn(), Server_Server::GMgr, Host, int32, GPlayer::Model, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MAX_PLAYERS, NETMGR_MSG_PLAYER_DATA, NETMGR_MSG_TIME, NetMgr_SendClientMessage(), Server_Client::NetState, NetState_WorldActive, Server_Client::NetStateConfirmed, Server_Server::NetStats, Server_Client::NextUpdate, Server_Server::NMgr, NULL, Server_NetStat::NumBytesToSend, NumData, Server_Client::Ping, Server_Client::Player, Buffer_Data::Pos, Pos2, Server_Client::SendFlags, Server_ClientDisconnect(), SetupClientPlayerSendFlags(), Server_Server::SvPlayers, uint16, uint8, VIEW_TYPE_LOCAL, GPlayer::ViewFlags, GPlayer::VPos, GPlayer::XForm, and geVec3d::Y. Referenced by Server_Frame().
01764 {
01765
01766 #if 1 // Optimized for internet gameplay (can use on LAN just fine too)
01767 int32 i;
01768 uint8 Data[20000];
01769 Buffer_Data Buffer;
01770 Server_Client *Client;
01771 geWorld *World;
01772
01773 World = GameMgr_GetWorld(Server->GMgr);
01774
01775 if (!World)
01776 return GE_TRUE;
01777
01778 SetupClientPlayerSendFlags(Server);
01779
01780 Client = Server->Clients;
01781
01782 // Tell the host to route this message to the clients
01783 for (i=0; i< NETMGR_MAX_CLIENTS; i++, Client++)
01784 {
01785 GPlayer *Player;
01786 int32 k;
01787 geVec3d Pos1[5];
01788 geVec3d Pos2;
01789 geVec3d In;
01790 int32 Leaf1[5], Leaf2;
01791 float NextUpdate, Ping, GTime;
01792
01793 if (!Client->Active)
01794 continue;
01795
01796 // Don't send the players to the client until he has confirmed that the world was loaded
01797 if (!(Client->NetState == NetState_WorldActive && Client->NetStateConfirmed[NetState_WorldActive]))
01798 continue;
01799
01800 // See if this client needs an update
01801 GTime = GameMgr_GetTime(Server->GMgr);
01802
01803 if (GTime < Client->NextUpdate) // Send time only
01804 continue;
01805
01806 // Setup the buffer
01807 Buffer_Set(&Buffer, Data, 20000);
01808
01809 // All player updates have the Servers current time for pings, and client side interpolation...
01810 Buffer_FillByte(&Buffer, NETMGR_MSG_TIME);
01811 Buffer_FillFloat(&Buffer, GTime);
01812 Buffer_FillFloat(&Buffer, Client->Ping);
01813
01814 Player = Server->SvPlayers;
01815
01816 // Get client position info
01817 Pos1[0] = Client->Player->VPos;
01818 Pos1[1] = Client->Player->VPos;
01819
01820 Pos1[1].Y += 120.0f;
01821
01822 geXForm3d_GetIn(&Client->Player->XForm, &In);
01823 geVec3d_AddScaled(&Pos1[1], &In, 450.0f, &Pos1[1]);
01824
01825 geWorld_GetLeaf(World, &Pos1[0], &Leaf1[0]);
01826 geWorld_GetLeaf(World, &Pos1[1], &Leaf1[1]);
01827
01828 for (k=0; k< NETMGR_MAX_PLAYERS; k++, Player++)
01829 {
01830 GE_Collision Collision;
01831
01832 if (!Player->Active)
01833 continue;
01834
01835 if (Player->ViewFlags & VIEW_TYPE_LOCAL)
01836 continue; // Only on local server, don't send data accros net
01837
01838 if (!Player->Control)
01839 continue;
01840
01841 Pos2 = Player->VPos;
01842
01843 geWorld_GetLeaf(World, &Pos2, &Leaf2);
01844
01845 #if 1
01846 //if (Client != &Server->Clients[0])
01847 //if (i != 0)
01848 if (Player != Client->Player) // Make sure we allways send the client player
01849 {
01850 if (!geWorld_LeafMightSeeLeaf(World, Leaf2, Leaf1[0], 0))
01851 if (!geWorld_LeafMightSeeLeaf(World, Leaf2, Leaf1[1], 0))
01852 {
01853 // For client 0 (the local client) keep the player alive.
01854 // For all other clients, we can destroy them while not on the screen...
01855 if (i == 0)
01856 {
01857 Buffer_FillByte(&Buffer, NETMGR_MSG_PLAYER_DATA);
01858 FillBufferWithPlayerData(Server, &Buffer, Player, 0);
01859 }
01860 else
01861 Client->SendFlags[k] = 0xffff; // Force an update w hen it comes back into view...
01862
01863 continue;
01864 }
01865
01866
01867 // Fill the buffer, with the needed data of this player on this client...
01868 if (Player->ClientHandle == -1)
01869 if (!Player->Model)
01870 if (geWorld_Collision(World, NULL, NULL, &Pos1[0], &Pos2, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS | GE_COLLIDE_NO_SUB_MODELS, 0, NULL, NULL, &Collision))
01871 if (geWorld_Collision(World, NULL, NULL, &Pos1[1], &Pos2, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS | GE_COLLIDE_NO_SUB_MODELS, 0, NULL, NULL, &Collision))
01872 {
01873 // If can't see, then don't send
01874 if (i==0)
01875 {
01876 Buffer_FillByte(&Buffer, NETMGR_MSG_PLAYER_DATA);
01877 FillBufferWithPlayerData(Server, &Buffer, Player, 0);
01878 }
01879 else
01880 Client->SendFlags[k] = 0xffff; // Force an update w hen it comes back into view...
01881
01882 continue;
01883 }
01884 }
01885 #endif
01886
01887 //geEngine_Printf(Host->Engine, 2, 20, "Bytes Received: %i", TotalMsgBytes);
01888
01889 // Send'er over...
01890 Buffer_FillByte(&Buffer, NETMGR_MSG_PLAYER_DATA);
01891 FillBufferWithPlayerData(Server, &Buffer, Player, Client->SendFlags[k]);
01892 Client->SendFlags[k] = 0; // All sent out now for this player/client...
01893 }
01894
01895 Ping = Client->Ping * 1000.0f;
01896
01897 // Based on Ping, see when this client should get another update...
01898 if (Ping < 100.0f)
01899 NextUpdate = Client->Ping*0.1f; // LAN, T3
01900 else if (Ping < 300.0f)
01901 NextUpdate = Client->Ping*0.15f; // Pretty good modem play
01902
01903 else if (Ping < 700.0f)
01904 NextUpdate = Client->Ping*0.2f; // Ok modem play
01905 else if (Ping < 1000.0f)
01906 NextUpdate = Client->Ping*0.25f; // poor modem play
01907 else if (Ping < 2500.0f)
01908 NextUpdate = Client->Ping*0.3f; // This person better log off!!!
01909 else
01910 NextUpdate = 1.0f; // Wait 1 1/2 secs for things to clear out...
01911
01912 // Store the next update time...
01913 Client->NextUpdate = GTime + NextUpdate;
01914
01915 Server->NetStats.NumBytesToSend += Buffer.Pos;
01916
01917 #if 0
01918 if (i != 0)
01919 {
01920 geEngine_Printf(GameMgr_GetEngine(Server->GMgr), 3, 65, "Sending client data: %i", NumData);
01921 NumData += Buffer.Pos;
01922 }
01923 #endif
01924
01925 // Rip out the message to this client
01926 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, FALSE))
01927 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
01928 }
01929 #else
01930 int32 i;
01931 uint8 Data[20000];
01932 Buffer_Data Buffer;
01933 GPlayer *Player;
01934 uint16 SendFlags;
01935
01936 Buffer_Set(&Buffer, Data, 20000);
01937
01938 Buffer_FillByte(&Buffer, NETMGR_MSG_TIME);
01939 Buffer_FillFloat(&Buffer, Host->Time);
01940 Buffer_FillFloat(&Buffer, 0.0f);
01941
01942 // Fill the buffer with all the players at once
01943 for (i=0; i< NETMGR_MAX_PLAYERS; i++)
01944 {
01945 Player = &Server->SvPlayers[i];
01946
01947 // Don't bother sending non active players, or players without entities...
01948 if (!Player->Active)
01949 continue;
01950
01951 if (Player->ViewFlags & VIEW_TYPE_LOCAL)
01952 continue; // Only on local server, don't send data accros net
01953
01954 if (!Player->Control)
01955 continue;
01956
01957 assert(i >=0 && i <= 65535);
01958
01959 // We must send this data
01960 Buffer_FillByte(&Buffer, NETMGR_MSG_PLAYER_DATA);
01961
01962 SendFlags = GetPlayerSendFlags(Server, Player);
01963
01964 // Fill the buffer, with the needed data...
01965 FillBufferWithPlayerData(Server, &Buffer, Player, SendFlags);
01966 }
01967
01968 // Tell the host to route this message to the clients
01969 for (i=0; i< NETMGR_MAX_CLIENTS; i++)
01970 {
01971 if (!Server->Clients[i].Active)
01972 continue;
01973
01974 if (!NetMgr_SendClientMessage(Server->NMgr, Server->Clients[i].NetID, &Buffer, FALSE))
01975 GenVS_Error("SendPlayersToClients: NetMgr_SendClientMessage failed.\n");
01976
01977 Server->NetStats.NumBytesToSend += Buffer.Pos;
01978 }
01979
01980 #endif
01981 return GE_TRUE;
01982 }
|
|
||||||||||||||||||||
|
Definition at line 2407 of file Server.c. References GAMEMGR_MAX_ACTOR_INDEX, GAMEMGR_MAX_ACTOR_NAME, GAMEMGR_MAX_GFX_PATH, GameMgr_SetActorIndex(), GenVS_Error(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02408 {
02409 assert(Server);
02410 assert(GFXPath);
02411 assert(ActorName);
02412 assert(strlen(GFXPath) < GAMEMGR_MAX_GFX_PATH);
02413 assert(strlen(ActorName) < GAMEMGR_MAX_ACTOR_NAME);
02414 assert(Index < GAMEMGR_MAX_ACTOR_INDEX);
02415
02416 if (!GameMgr_SetActorIndex(Server->GMgr, Index, ActorName))
02417 {
02418 // FIXME: Either use a better error handling convention, or bubble it out to the caller, and make them handle it.
02419 // This is ok, but I was trying to make it as easy as possible for them, and didn't want to make them handle errors.
02420 //GameMgr_Error(Server->GMgr, "...");
02421 GenVS_Error("Server_ActorIndex: GameMgr_SetActorIndex failed...");
02422 }
02423 }
|
|
||||||||||||
|
Definition at line 2963 of file Server.c. References CLIENT_TO_SERVER_PLAYER, geActor_GetUserData(), and NULL. Referenced by Server_SetupGenVSI().
02964 {
02965
02966 GPlayer *CPlayer;
02967 GPlayer *SPlayer;
02968
02969 // Convert the client player to a server player (they are the same index number so it's easy...)
02970 CPlayer = (GPlayer*)geActor_GetUserData(Actor);
02971
02972 if (!CPlayer)
02973 return NULL;
02974
02975 SPlayer = CLIENT_TO_SERVER_PLAYER(Server, CPlayer);
02976
02977 return SPlayer;
02978 }
|
|
||||||||||||||||
|
Definition at line 2439 of file Server.c. References GameMgr_SetBoneIndex(), GenVS_Error(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02440 {
02441 assert(Server);
02442
02443 if (!GameMgr_SetBoneIndex(Server->GMgr, BoneIndex, BoneName))
02444 GenVS_Error("Server_BoneIndex: Could not set Bone Index: %s.\n", BoneName);
02445 }
|
|
||||||||||||
|
Definition at line 709 of file Server.c. References Server_Client::Active, Server_Server::Clients, Console_Printf(), GameMgr_GetConsole(), GE_TRUE, Server_Server::GMgr, int32, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_SPECIAL_BOT_NETID, NULL, Server_ClientDisconnect(), Server_SendClientStartupData(), and Server_ValidateClient(). Referenced by Server_ManageBots().
00710 {
00711 int32 i;
00712 Server_Client *SClient;
00713
00714 SClient = Server->Clients;
00715
00716 for (i=0; i< NETMGR_MAX_CLIENTS; i++, SClient++)
00717 {
00718 if (!SClient->Active) // Look for a non active client slot
00719 break;
00720 }
00721
00722 if (i >= NETMGR_MAX_CLIENTS)
00723 return NULL;
00724
00725 memset(SClient, 0, sizeof(Server_Client));
00726
00727 strcpy(SClient->Name, BotName);
00728 SClient->NetID = NETMGR_SPECIAL_BOT_NETID;
00729
00730 SClient->Active = GE_TRUE;
00731
00732 // Make the client legit, create it's player, etc...
00733 Server_ValidateClient(Server, SClient);
00734
00735 if (!SClient->Active) // Client was dicconected...
00736 return SClient;
00737
00738 // Send this client the startupdata for everything at it's current state
00739 if (!Server_SendClientStartupData(Server, SClient))
00740 {
00741 Server_ClientDisconnect(Server, SClient->NetID, SClient->Name);
00742 return NULL;
00743 }
00744
00745 Console_Printf(GameMgr_GetConsole(Server->GMgr), "(Server) Client connected: %s, %i...\n", "Bot", NETMGR_SPECIAL_BOT_NETID);
00746
00747 return SClient;
00748 }
|
|
||||||||||||||||
|
Definition at line 277 of file Server.c. References Buffer_FillByte(), Buffer_FillSLong(), Buffer_Set(), GE_FALSE, GE_TRUE, geBoolean, GenVS_Error(), Server_Client::NetID, NETMGR_MSG_NET_STATE_CHANGE, NetMgr_SendClientMessage(), Server_Client::NetState, Server_Client::NetStateConfirmed, and Server_Server::NMgr. Referenced by Server_ClientConnect(), and Server_SetupClientWithCurrentWorld().
00278 {
00279 Buffer_Data Buffer;
00280 char Data[128];
00281
00282 assert(Server);
00283 assert(Client);
00284
00285 Buffer_Set(&Buffer, Data, 128);
00286
00287 Buffer_FillByte(&Buffer, NETMGR_MSG_NET_STATE_CHANGE);
00288 Buffer_FillSLong(&Buffer, NetState);
00289
00290 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00291 GenVS_Error("Server_ChangeClientState: NetMgr_SendClientMessage failed.\n");
00292
00293 Client->NetState = NetState;
00294 Client->NetStateConfirmed[NetState] = GE_FALSE;
00295
00296 return GE_TRUE;
00297 }
|
|
||||||||||||
|
Definition at line 645 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillLong(), Buffer_Set(), Server_Server::Clients, Console_Printf(), FALSE, GameMgr_GetConsole(), GE_FALSE, GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, geCSNetMgr_NetClient::Id, int32, Server_Client::Name, geCSNetMgr_NetClient::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_VERSION, NetMgr_SendClientMessage(), NETMGR_VERSION_MAJOR, NETMGR_VERSION_MINOR, NetState_Connecting, Server_Server::NMgr, Server_ChangeClientState(), Server_ClientDisconnect(), Server_SendClientStartupData(), and Server_ValidateClient(). Referenced by Host_Create(), and ReadClientMessages().
00646 {
00647 int32 i;
00648 Buffer_Data Buffer;
00649 char Data[128];
00650 Server_Client *SClient;
00651
00652 SClient = Server->Clients;
00653
00654 for (i=0; i< NETMGR_MAX_CLIENTS; i++, SClient++)
00655 {
00656 if (!SClient->Active) // Look for a non active client slot
00657 break;
00658 }
00659
00660 if (i >= NETMGR_MAX_CLIENTS)
00661 return FALSE;
00662
00663 memset(SClient, 0, sizeof(Server_Client));
00664
00665 strcpy(SClient->Name, Client->Name);
00666 SClient->NetID = Client->Id;
00667
00668 SClient->Active = GE_TRUE;
00669
00670 // Send version to client FIRST thing
00671 Buffer_Set(&Buffer, Data, 128);
00672 Buffer_FillByte(&Buffer, NETMGR_MSG_VERSION);
00673 Buffer_FillLong(&Buffer, NETMGR_VERSION_MAJOR);
00674 Buffer_FillLong(&Buffer, NETMGR_VERSION_MINOR);
00675
00676 if (!NetMgr_SendClientMessage(Server->NMgr, SClient->NetID, &Buffer, GE_TRUE))
00677 {
00678 Server_ClientDisconnect(Server, SClient->NetID, SClient->Name);
00679 return GE_TRUE;
00680 }
00681
00682 // Let the client know that it is currently connecting
00683 Server_ChangeClientState(Server, SClient, NetState_Connecting);
00684
00685 // Make the client legit, create it's player, etc...
00686 Server_ValidateClient(Server, SClient);
00687
00688 if (!SClient->Active) // Client was dicconected...
00689 return GE_TRUE;
00690
00691 // Send this client the startupdata for everything at it's current state
00692 if (!Server_SendClientStartupData(Server, SClient))
00693 {
00694 Server_ClientDisconnect(Server, SClient->NetID, SClient->Name);
00695
00696 GenVS_Error("Server_ClientConnect: Server_SendClientStartupData failed.\n");
00697 return GE_FALSE;
00698 }
00699
00700 Console_Printf(GameMgr_GetConsole(Server->GMgr), " Client connected: %s, %i...\n", Client->Name, Client->Id);
00701
00702 return GE_TRUE;
00703 }
|
|
||||||||||||||||
|
Definition at line 754 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_Set(), Server_Server::Clients, Console_Printf(), GameMgr_GetConsole(), GE_FALSE, GE_TRUE, geBoolean, Server_Server::GMgr, int32, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_CLIENT_ACTIVE, NULL, Server_Client::Player, SendAllClientsMessage(), and Server_DestroyPlayer(). Referenced by ReadClientMessages(), SendAllClientsMessage(), SendPlayersToClients(), Server_BotConnect(), Server_ClientConnect(), Server_ConsoleHeaderPrintf(), Server_PlaySound(), Server_SetClientHealth(), Server_SetClientInventory(), Server_SetClientWeapon(), Server_SetupAllClientsWithCurrentWorld(), Server_SetViewPlayer(), and Server_ValidateClient().
00755 {
00756 int32 i;
00757 Server_Client *SClient;
00758
00759 assert(Server);
00760 assert(Name);
00761
00762 for (i=0; i< NETMGR_MAX_CLIENTS; i++)
00763 {
00764 SClient = &Server->Clients[i];
00765
00766 if (!SClient->Active)
00767 continue;
00768
00769 if (SClient->NetID == Id)
00770 {
00771 Buffer_Data Buffer;
00772 char Data[512];
00773
00774 if (SClient->Player)
00775 Server_DestroyPlayer(Server, SClient->Player);
00776
00777 SClient->Player = NULL;
00778 SClient->Active = GE_FALSE;
00779
00780 // Tell all clients (execpt this one of course), that this client is not active
00781 Buffer_Set(&Buffer, Data, 512);
00782
00783 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_ACTIVE);
00784 Buffer_FillByte(&Buffer, (char)i);
00785 Buffer_FillByte(&Buffer, 0); // The client is not active anymore!!!
00786
00787 SendAllClientsMessage(Server, &Buffer, GE_TRUE);
00788
00789 Console_Printf(GameMgr_GetConsole(Server->GMgr), "[SERVER] Client disconnected: %s, %i...\n", Name, Id);
00790 return GE_TRUE;
00791 }
00792 }
00793
00794 Console_Printf(GameMgr_GetConsole(Server->GMgr), "[SERVER] Client not found for disconnect: %s, %i...\n", Name, Id);
00795
00796 return GE_FALSE;
00797 }
|
|
||||||||||||
|
Definition at line 802 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_Set(), Server_Server::Clients, GE_FALSE, GE_TRUE, geBoolean, NETMGR_MSG_CLIENT_ACTIVE, NULL, Server_Client::Player, SendAllClientsMessage(), and Server_DestroyPlayer(). Referenced by Server_ManageBots(), and Server_SetupGenVSI().
00803 {
00804 Server_Client *SClient;
00805 Buffer_Data Buffer;
00806 char Data[512];
00807
00808 assert(Server);
00809
00810 SClient = &Server->Clients[ClientHandle];
00811
00812 assert(SClient);
00813
00814 if (SClient->Player)
00815 Server_DestroyPlayer(Server, SClient->Player);
00816
00817 SClient->Player = NULL;
00818 SClient->Active = GE_FALSE;
00819
00820 // Tell all clients (execpt this one of course), that this client is not active
00821 Buffer_Set(&Buffer, Data, 512);
00822
00823 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_ACTIVE);
00824 Buffer_FillByte(&Buffer, (char)ClientHandle);
00825 Buffer_FillByte(&Buffer, 0); // The client is not active anymore!!!
00826
00827 SendAllClientsMessage(Server, &Buffer, GE_TRUE);
00828
00829 return GE_TRUE;
00830 }
|
|
||||||||||||||||||||||||
|
Definition at line 3006 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillString(), Buffer_Set(), CLIENT_NULL_HANDLE, Server_Server::Clients, GE_TRUE, Server_Client::Name, Server_Client::NetID, NETMGR_MSG_HEADER_PRINTF, NetMgr_SendClientMessage(), Server_Server::NMgr, SendAllClientsMessage(), and Server_ClientDisconnect(). Referenced by Server_SetupGenVSI().
03007 {
03008 Buffer_Data Buffer;
03009 char Data[1024];
03010 Server_Client *Client;
03011 assert(ClientHandle != CLIENT_NULL_HANDLE);
03012
03013 assert(Server);
03014 assert(Str);
03015
03016 // Set the buffer up
03017 Buffer_Set(&Buffer, Data, 1024);
03018
03019 // Fill the buffer with the message type/body...
03020 Buffer_FillByte(&Buffer, NETMGR_MSG_HEADER_PRINTF);
03021 Buffer_FillString(&Buffer, (char*)Str);
03022
03023 Client = &Server->Clients[ClientHandle];
03024
03025 assert(Client->Active);
03026
03027 if (AllClients)
03028 {
03029 SendAllClientsMessage(Server, &Buffer, GE_TRUE);
03030 }
03031 else if (Client->Active)
03032 {
03033 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
03034 {
03035 //GenVS_Error("Could not send local client message!!!");
03036
03037 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
03038 }
03039 }
03040
03041 }
|
|
||||||||||||||||
|
Definition at line 2991 of file Server.c. References Console_Printf(), GameMgr_GetConsole(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02992 {
02993 va_list ArgPtr;
02994
02995 assert(Server);
02996 assert(Str);
02997
02998 va_start (ArgPtr, Str);
02999 Console_Printf(GameMgr_GetConsole(Server->GMgr), Str, ArgPtr);
03000 va_end (ArgPtr);
03001 }
|
|
|
Definition at line 2184 of file Server.c. References GPlayer::Active, CLIENT_NULL_HANDLE, GPlayer::ClientHandle, GPlayer::Control, int32, NETMGR_MAX_PLAYERS, Server_IsClientBot(), and Server_Server::SvPlayers. Referenced by Server_ManageBots().
02185 {
02186 GPlayer *Player;
02187 int32 i, Count;
02188
02189 for (i=Count=0; i< NETMGR_MAX_PLAYERS; i++)
02190 {
02191 Player = &Server->SvPlayers[i];
02192
02193 if (!Player->Active)
02194 continue;
02195
02196 if (!Player->Control)
02197 continue;
02198
02199 if (Player->ClientHandle != CLIENT_NULL_HANDLE && Server_IsClientBot(Server, Player->ClientHandle))
02200 {
02201 Count++;
02202 }
02203 }
02204
02205 return Count;
02206 }
|
|
||||||||||||||||||||
|
Definition at line 136 of file Server.c. References Server_Server::Client, Console_Printf(), GameMgr_GetConsole(), GE_RAM_ALLOCATE_STRUCT, Server_Server::GenVSI, geRam_Free, Server_Server::GMgr, int32, NETMGR_MAX_PLAYERS, Server_Server::NMgr, NULL, Server_Server::NumClassSpawns, Server_Server::NumTotalPlayers, Server_Main(), Server_NewWorldDefaults(), Server_SetPlayerDefaults(), Server_SetupGenVSI(), ServerBotCount, and Server_Server::SvPlayers. Referenced by Host_Create().
00137 {
00138 int32 i;
00139 Server_Server *NewServer;
00140
00141 NewServer = GE_RAM_ALLOCATE_STRUCT(Server_Server);
00142
00143 assert(NewServer != NULL);
00144
00145 if (!NewServer)
00146 return NULL;
00147
00148 memset(NewServer, 0, sizeof(Server_Server));
00149
00150 // These objects CANNOT change throughout this servers life!!!
00151 NewServer->GMgr = GMgr;
00152 NewServer->NMgr = NMgr;
00153 NewServer->Client = Client;
00154
00155 Server_SetupGenVSI(NewServer);
00156
00157 if (!Server_NewWorldDefaults(NewServer))
00158 {
00159 geRam_Free(NewServer);
00160 return NULL;
00161 }
00162
00163 for (i=0; i< NETMGR_MAX_PLAYERS; i++)
00164 Server_SetPlayerDefaults(&NewServer->SvPlayers[i]);
00165
00166 // Reset the numbers of spawn callbacks
00167 NewServer->NumClassSpawns = 0;
00168 ServerBotCount = 0;
00169
00170 // Call the game main code, to initialize everything...
00171 Server_Main(&NewServer->GenVSI, LevelHack);
00172 Console_Printf(GameMgr_GetConsole(NewServer->GMgr), "Server_Create: Game_Main initialized\n");
00173 Console_Printf(GameMgr_GetConsole(NewServer->GMgr), "Server_Create: Num Main Spawned Players: %i\n", NewServer->NumTotalPlayers);
00174
00175 Console_Printf(GameMgr_GetConsole(NewServer->GMgr), "Server_Create: Server created...\n");
00176
00177 return NewServer;
00178 }
|
|
||||||||||||
|
Definition at line 836 of file Server.c. References GPlayer::Active, GPlayer::ClassName, CLIENT_NULL_HANDLE, GPlayer::ClientHandle, Console_Printf(), GPlayer::ControlIndex, GameMgr_GetConsole(), GE_TRUE, GenVS_Error(), Server_Server::GMgr, int32, MAX_CLASS_NAME_STRING, NETMGR_MAX_PLAYERS, NULL, Server_Server::NumTotalPlayers, GPlayer::OldViewFlags, GPlayer::OldViewIndex, Server_Server::SvPlayers, GPlayer::TriggerIndex, VIEW_TYPE_LOCAL, VIEW_TYPE_NONE, GPlayer::ViewFlags, and GPlayer::ViewIndex. Referenced by Server_SetupGenVSI(), Server_SpawnWorld(), and Server_ValidateClient().
00837 {
00838 int32 i, Start, End;
00839
00840 assert(strlen(ClassName) < MAX_CLASS_NAME_STRING);
00841
00842 Start = 0;
00843 End = NETMGR_MAX_PLAYERS;
00844
00845 for (i=Start; i< End; i++)
00846 {
00847 if (!Server->SvPlayers[i].Active)
00848 break;
00849 }
00850
00851 if (i >= End)
00852 {
00853 GenVS_Error("Failed to add player!!!\n");
00854
00855 Console_Printf(GameMgr_GetConsole(Server->GMgr), "Server_CreatePlayer2: Max players exceeded...\n");
00856 return NULL;
00857 }
00858
00859 assert(Server->NumTotalPlayers >= 0);
00860
00861 Server->NumTotalPlayers++;
00862
00863 assert(Server->NumTotalPlayers <= End);
00864
00865 memset(&Server->SvPlayers[i], 0, sizeof(GPlayer));
00866
00867 Server->SvPlayers[i].Active = GE_TRUE;
00868 // Default to no view index, and local only player
00869 Server->SvPlayers[i].OldViewFlags = VIEW_TYPE_NONE | VIEW_TYPE_LOCAL;
00870 Server->SvPlayers[i].ViewFlags = VIEW_TYPE_NONE | VIEW_TYPE_LOCAL;
00871 Server->SvPlayers[i].OldViewIndex = 0xffff;
00872 Server->SvPlayers[i].ViewIndex = 0xffff;
00873 Server->SvPlayers[i].ControlIndex = 0xffff;
00874 Server->SvPlayers[i].TriggerIndex = 0xffff;
00875 strcpy(Server->SvPlayers[i].ClassName, ClassName);
00876 Server->SvPlayers[i].ClientHandle = CLIENT_NULL_HANDLE;
00877
00878 return &Server->SvPlayers[i];
00879 }
|
|
|
Definition at line 183 of file Server.c. References Buffer_FillByte(), Buffer_Set(), GE_TRUE, geBoolean, geRam_Free, NETMGR_MSG_SHUTDOWN, SendAllClientsMessage(), and Server_FreeWorldData(). Referenced by Host_DestroyAllObjects().
00184 {
00185 Buffer_Data Buffer;
00186 char Data[128];
00187 geBoolean Ret;
00188
00189 assert(Server);
00190
00191 Ret = Server_FreeWorldData(Server);
00192
00193 assert(Ret == GE_TRUE);
00194
00195 // Make sure everybody knows we are quiting as the server
00196 Buffer_Set(&Buffer, Data, 128);
00197 Buffer_FillByte(&Buffer, NETMGR_MSG_SHUTDOWN);
00198
00199 SendAllClientsMessage(Server, &Buffer, GE_TRUE);
00200
00201 geRam_Free(Server);
00202 }
|
|
||||||||||||
|
Definition at line 895 of file Server.c. References GPlayer::Active, Callback_CallDestroy(), NETMGR_MAX_PLAYERS, and Server_Server::NumTotalPlayers. Referenced by Server_ClientDisconnect(), Server_ClientDisconnectByHandle(), and Server_SetupGenVSI().
00896 {
00897 assert(Server);
00898 assert(Player);
00899
00900 assert(Player->Active);
00901
00902 assert(Server->NumTotalPlayers <= NETMGR_MAX_PLAYERS);
00903
00904 Callback_CallDestroy(Server, Player);
00905
00906 Server->NumTotalPlayers--;
00907
00908 assert(Server->NumTotalPlayers >= 0);
00909
00910 memset(Player, 0, sizeof(GPlayer));
00911 }
|
|
||||||||||||||||
|
Definition at line 3068 of file Server.c. References GenVS_Error().
03069 {
03070 va_list ArgPtr;
03071
03072 assert(Server);
03073 assert(ErrorStr);
03074
03075 va_start (ArgPtr, ErrorStr);
03076 GenVS_Error(ErrorStr, ArgPtr);
03077 va_end (ArgPtr);
03078 }
|
|
||||||||||||||||
|
Definition at line 1108 of file Server.c. References Server_Client::Active, Server_Server::ChangeWorldRequest, Server_Server::Client, Client_NewWorldDefaults(), Server_Server::Clients, ControlPlayers(), Engine, GameMgr_GetEngine(), GameMgr_GetTime(), GameMgr_GetWorld(), GameMgr_SetWorld(), GE_FALSE, GE_TRUE, geBoolean, geEngine_Printf(), GenVS_Error(), Server_Server::GMgr, int32, Server_Client::Name, NETMGR_MAX_CLIENTS, Server_Server::NetStats, Client_Client::NetTime, NULL, Server_NetStat::NumAngles, Server_NetStat::NumBytesToSend, Server_NetStat::NumControlIndex, Server_NetStat::NumFrameTime, Server_NetStat::NumFxFlags, Server_NetStat::NumMinsMaxs, Server_NetStat::NumMotionIndex, Server_NetStat::NumPos, Server_NetStat::NumScale, Server_NetStat::NumSpawnTime, Server_NetStat::NumState, Server_NetStat::NumTriggerIndex, Server_NetStat::NumVelocity, Server_NetStat::NumViewFlags, Server_NetStat::NumViewIndex, Server_Client::Ping, Server_Client::Pings, ReadClientMessages(), SendPlayersToClients(), Server_FreeWorldData(), Server_ManageBots(), Server_NewWorldDefaults(), Server_SetupWorld(), ShowStats, Server_Server::ShutdownWorldCB1, Server_Server::ShutdownWorldCB2, t, and Server_Server::WorldName. Referenced by Host_Frame().
01109 {
01110 assert(Server != NULL);
01111 assert(GMgr);
01112
01113 Server->GMgr = GMgr;
01114
01115 // Make sure our local client always has the correct time!!!
01116 Server->Client->NetTime = GameMgr_GetTime(Server->GMgr);
01117
01118 if (Server->ChangeWorldRequest)
01119 {
01120 Server->ChangeWorldRequest = GE_FALSE;
01121
01122 if (!Server_FreeWorldData(Server))
01123 GenVS_Error("Server_Frame: Server_FreeWorldData failed.\n");
01124
01125 // Reset the server for a new world
01126 if (!Server_NewWorldDefaults(Server))
01127 GenVS_Error("Server_Frame: Server_NewWorldDefaults failed.\n");
01128
01129 // Reset the local client for a new world
01130 if (Server->Client)
01131 Client_NewWorldDefaults(Server->Client);
01132
01133 if (!GameMgr_SetWorld(GMgr, Server->WorldName))
01134 GenVS_Error("Server_Frame: GameMgr_SetWorld failed.\n");
01135
01136 if (!Server_SetupWorld(Server))
01137 GenVS_Error("Server_Frame: Server_SetupWorld failed.\n");
01138
01139 // Shift the Shutdown Callbacks down one in the stack
01140 Server->ShutdownWorldCB1 = Server->ShutdownWorldCB2;
01141 Server->ShutdownWorldCB2 = NULL;
01142
01143 //return GE_TRUE;
01144 }
01145
01146 if (!GameMgr_GetWorld(GMgr))
01147 return GE_TRUE;
01148
01149 //memset(&Server->NetStats, 0, sizeof(Server_NetStat));
01150
01151 if (!ReadClientMessages(Server, Time)) // Read inputs from clients to control their players
01152 GenVS_Error("Server_Frame: ReadClientMessages failed.\n");
01153
01154 if (!ControlPlayers(Server, Time)) // Apply physics and stuff to the players
01155 GenVS_Error("Server_Frame: ControlPlayers failed.\n");
01156
01157 Server_ManageBots(Server); // Add and remove bots
01158
01159 //BEGIN_TIMER();
01160 if (!SendPlayersToClients(Server)) // Send the updated players to the clients
01161 GenVS_Error("Server_Frame: SendPlayersToClients failed.\n");
01162 //END_TIMER(Server->GMgr);
01163
01164 // Print client pings
01165 {
01166 Server_Client *Client;
01167 int32 i, t;
01168
01169 Client = Server->Clients;
01170
01171 t = 0;
01172
01173 for (i = 0; i< NETMGR_MAX_CLIENTS; i++, Client++)
01174 {
01175 int32 k;
01176
01177 if (!Client->Active)
01178 continue;
01179
01180 t++;
01181
01182 Client->Ping = 0.0f;
01183
01184 for (k=0; k< 10; k++)
01185 Client->Ping += Client->Pings[k];
01186
01187 Client->Ping *= (1.0f/10.0f);
01188
01189 if (ShowStats)
01190 geEngine_Printf(GameMgr_GetEngine(Server->GMgr), 2, 140+t*15, "Client: %s, Ping: %2.2f", Client->Name, Client->Ping*1000.0f);
01191 }
01192 }
01193
01194 #if 0 // FIXME: put in Server_RenderFrame!!!
01195 {
01196 geEngine *Engine;
01197
01198 Engine = GameMgr_GetEngine(Server->GMgr);
01199
01200 geEngine_Printf(Engine, 2, 15*2 , "SpawnTime : %3i", Server->NetStats.NumSpawnTime);
01201 geEngine_Printf(Engine, 2, 15*3 , "ViewFlags : %3i", Server->NetStats.NumViewFlags);
01202 geEngine_Printf(Engine, 2, 15*4 , "ViewIndex : %3i", Server->NetStats.NumViewIndex);
01203 geEngine_Printf(Engine, 2, 15*5 , "MotionIndex : %3i", Server->NetStats.NumMotionIndex);
01204 geEngine_Printf(Engine, 2, 15*6 , "FxFlags : %3i", Server->NetStats.NumFxFlags);
01205 geEngine_Printf(Engine, 2, 15*7 , "Pos : %3i", Server->NetStats.NumPos);
01206 geEngine_Printf(Engine, 2, 15*8 , "Angles : %3i", Server->NetStats.NumAngles);
01207 geEngine_Printf(Engine, 2, 15*9 , "FrameTime : %3i", Server->NetStats.NumFrameTime);
01208 geEngine_Printf(Engine, 2, 15*10, "Scale : %3i", Server->NetStats.NumScale);
01209 geEngine_Printf(Engine, 2, 15*11, "Velocity : %3i", Server->NetStats.NumVelocity);
01210 geEngine_Printf(Engine, 2, 15*12, "State : %3i", Server->NetStats.NumState);
01211 geEngine_Printf(Engine, 2, 15*13, "ControlIndex: %3i", Server->NetStats.NumControlIndex);
01212 geEngine_Printf(Engine, 2, 15*14, "TriggerIndex: %3i", Server->NetStats.NumTriggerIndex);
01213 geEngine_Printf(Engine, 2, 15*15, "MinsMaxs : %3i", Server->NetStats.NumMinsMaxs);
01214 geEngine_Printf(Engine, 2, 15*16, "BytesToSend : %3i", Server->NetStats.NumBytesToSend);
01215 }
01216 #endif
01217
01218 return GE_TRUE;
01219 }
|
|
|
Definition at line 917 of file Server.c. References GPlayer::ClassData, GPlayer::DFunc, GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GenVSI, int32, NETMGR_MAX_PLAYERS, NULL, Server_Server::ShutdownWorldCB1, and Server_Server::SvPlayers. Referenced by Server_Destroy(), and Server_Frame().
00918 {
00919 GPlayer *Player;
00920 int32 i;
00921
00922 assert(Server);
00923
00924 // Let the Game stuff free all the data they might have allocated, etc...
00925 if (Server->ShutdownWorldCB1)
00926 {
00927 if (!Server->ShutdownWorldCB1(&Server->GenVSI))
00928 GenVS_Error("Server_FreeWorldData: ShutdownWorldCB1 failed.\n");
00929 }
00930
00931 // Free all the players data that is in the world
00932 for (Player = Server->SvPlayers, i=0; i< NETMGR_MAX_PLAYERS; i++, Player++)
00933 {
00934 if (Player->DFunc)
00935 Player->DFunc(&Server->GenVSI, Player, Player->ClassData);
00936
00937 Player->DFunc = NULL;
00938 }
00939
00940 return GE_TRUE;
00941 }
|
|
||||||||||||
|
Definition at line 2211 of file Server.c. References GPlayer::Active, CLIENT_NULL_HANDLE, GPlayer::ClientHandle, Server_Server::Clients, GPlayer::Control, GenVSI_CHandle, int32, Server_Client::Name, NETMGR_MAX_PLAYERS, Server_IsClientBot(), and Server_Server::SvPlayers. Referenced by Server_ManageBots().
02212 {
02213 GPlayer *Player;
02214 int32 i, Count;
02215 Server_Client *SClient;
02216
02217 for (i=Count=0; i< NETMGR_MAX_PLAYERS; i++)
02218 {
02219 Player = &Server->SvPlayers[i];
02220
02221 if (!Player->Active)
02222 continue;
02223
02224 if (!Player->Control)
02225 continue;
02226
02227 if (Player->ClientHandle != CLIENT_NULL_HANDLE && Server_IsClientBot(Server, Player->ClientHandle))
02228 {
02229 SClient = &Server->Clients[Player->ClientHandle];
02230
02231 if (strcmp(SClient->Name, Name) == 0)
02232 return (Player->ClientHandle);
02233 }
02234 }
02235
02236 return CLIENT_NULL_HANDLE;
02237 }
|
|
||||||||||||
|
Definition at line 2697 of file Server.c. References Server_Client::Angles, GenVSI_CMove::Angles, Server_Client::ButtonBits, GenVSI_CMove::ButtonBits, Server_Server::Clients, Server_Client::CurrentWeapon, Server_Client::ForwardSpeed, GenVSI_CMove::ForwardSpeed, Server_Client::Move, Server_Client::MoveTime, GenVSI_CMove::MoveTime, Server_Client::Pos, GenVSI_CMove::Pos, and GenVSI_CMove::Weapon. Referenced by Server_SetupGenVSI().
02698 {
02699 Server_Client *Client;
02700
02701 assert(Server);
02702
02703 Client = &Server->Clients[ClientHandle];
02704
02705 Client->Move.MoveTime = Client->MoveTime;
02706 Client->Move.ForwardSpeed = Client->ForwardSpeed;
02707 Client->Move.Angles = Client->Angles;
02708 Client->Move.ButtonBits = Client->ButtonBits;
02709 Client->Move.Pos = Client->Pos;
02710 Client->Move.Weapon = Client->CurrentWeapon;
02711
02712 return &Client->Move;
02713 }
|
|
||||||||||||||||
|
Definition at line 2758 of file Server.c. References GPlayer::Active, GPlayer::ClassName, Console_Printf(), GameMgr_GetConsole(), Server_Server::GMgr, NETMGR_MAX_PLAYERS, NULL, and Server_Server::SvPlayers. Referenced by Server_GetNextPlayerInRadius(), and Server_SetupGenVSI().
02759 {
02760 GPlayer *RealStart, *End;
02761
02762 RealStart = &Server->SvPlayers[0];
02763 End = &Server->SvPlayers[NETMGR_MAX_PLAYERS-1];
02764
02765 if (Start == End)
02766 return NULL;
02767
02768 if (!Start)
02769 Start = Server->SvPlayers;
02770 else
02771 Start++;
02772
02773 assert(Start >= RealStart && Start <= End);
02774
02775 if (Start < RealStart || Start > End)
02776 {
02777 Console_Printf(GameMgr_GetConsole(Server->GMgr), "[SERVER] Server_GetNextPlayer: Bad start.\n");
02778 return NULL; // Bad!!!
02779 }
02780
02781 for ( ; Start < End; Start++)
02782 {
02783 if (!Start->Active)
02784 continue;
02785
02786 if (!ClassName) // Just return the next one, if no classname asked for
02787 return Start;
02788
02789 if (!strcmp(Start->ClassName, ClassName)) // Found it!!
02790 return Start;
02791 }
02792
02793 return NULL;
02794 }
|
|
||||||||||||||||||||||||
|
Definition at line 2799 of file Server.c. References geVec3d_Length(), geVec3d_Subtract(), NULL, Server_GetNextPlayer(), geXForm3d::Translation, and GPlayer::XForm. Referenced by Server_SetupGenVSI().
02800 {
02801 while (1)
02802 {
02803 geVec3d Vect;
02804
02805 Start = Server_GetNextPlayer(Server, Start, ClassName);
02806
02807 if (!Start)
02808 return NULL;
02809
02810 // If start is within radius, then return it...
02811 geVec3d_Subtract(&Start->XForm.Translation, &Player->XForm.Translation, &Vect);
02812
02813 if (geVec3d_Length(&Vect) <= Radius)
02814 return Start; // Got one...
02815 }
02816
02817 return NULL;
02818 }
|
|
||||||||||||
|
Definition at line 3057 of file Server.c. References Server_Server::Clients. Referenced by Server_SetupGenVSI().
03058 {
03059 assert(Server);
03060 assert(ClientHandle >=0 && ClientHandle <= 255);
03061
03062 return &Server->Clients[ClientHandle];
03063 }
|
|
||||||||||||||||||||||||
|
Definition at line 2927 of file Server.c. References GPlayer::ActorDef, Server_Server::Client, GameMgr_GetMotionIndexDef(), GameMgr_GetWorld(), geActor_GetMotionByName(), geMotion_GetTimeExtents(), GenVS_Error(), Server_Server::GMgr, int32, GameMgr_MotionIndexDef::MotionName, Client_Client::Players, and SERVER_GPLAYER_TO_INDEX. Referenced by Server_SetupGenVSI().
02928 {
02929 geMotion *Motion;
02930 int32 Index;
02931 GameMgr_MotionIndexDef *pMotionIndex;
02932
02933 assert(Server);
02934 assert(Player);
02935 assert(Start && End);
02936 assert(GameMgr_GetWorld(Server->GMgr));
02937
02938 Index = SERVER_GPLAYER_TO_INDEX(Server, Player);
02939
02940 if (!Server->Client->Players[Index].ActorDef)
02941 {
02942 *Start = 0.0f;
02943 *End = 0.0f;
02944 return;
02945 }
02946
02947 pMotionIndex = GameMgr_GetMotionIndexDef(Server->GMgr, MotionIndex);
02948
02949 Motion = geActor_GetMotionByName(Server->Client->Players[Index].ActorDef, pMotionIndex->MotionName);
02950
02951 if (!Motion)
02952 GenVS_Error("Server_GetPlayerTimeExtents: Motion not found in actor: %s", pMotionIndex->MotionName);
02953
02954 if (!geMotion_GetTimeExtents(Motion, Start, End))
02955 GenVS_Error("Server_GetPlayerTimeExtents: geMotion_GetTimeExtents failed...\n");
02956 }
|
|
|
Definition at line 3046 of file Server.c. References GameMgr_GetTime(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
03047 {
03048 assert(Server);
03049
03050 return GameMgr_GetTime(Server->GMgr);
03051 }
|
|
|
Definition at line 2983 of file Server.c. References GameMgr_GetWorld(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02984 {
02985 return GameMgr_GetWorld(Server->GMgr);
02986 }
|
|
||||||||||||
|
Definition at line 2564 of file Server.c. References Server_Client::Active, Server_Server::Clients, GE_FALSE, GE_TRUE, geBoolean, Server_Client::NetID, NETMGR_MAX_CLIENTS, and NETMGR_SPECIAL_BOT_NETID. Referenced by ControlPlayers(), SendAllClientsMessage(), Server_CountBots(), Server_GetBotByName(), Server_SetupGenVSI(), and Server_ValidateClient().
02565 {
02566 Server_Client *Client;
02567
02568 assert(Server);
02569
02570 if (ClientHandle < 0 || ClientHandle > NETMGR_MAX_CLIENTS)
02571 return GE_FALSE;
02572
02573 Client = &Server->Clients[ClientHandle];
02574
02575 assert(Client->Active);
02576
02577 if (Client->NetID == NETMGR_SPECIAL_BOT_NETID)
02578 return GE_TRUE;
02579
02580 return GE_FALSE;
02581 }
|
|
|
Definition at line 2243 of file Server.c. References Server_Client::Active, GPlayer::Actor, GE_RGBA::b, Server_Server::Client, CLIENT_NULL_HANDLE, GE_RGBA::g, GE_FALSE, GE_TRUE, geActor_SetLightingOptions(), geBoolean, GenVS_Error(), GenVSI_CHandle, int32, MenuBotCount, NULL, Server_Client::Player, Client_Client::Players, GE_RGBA::r, Server_BotConnect(), Server_ClientDisconnectByHandle(), Server_CountBots(), Server_GetBotByName(), ServerBotCount, and Server_Server::SvPlayers. Referenced by Server_Frame().
02244 {
02245 int cnt;
02246 int i;
02247 extern int32 MenuBotCount;
02248 Server_Client *SClient;
02249 int32 Index;
02250
02251 static int32 RandomSet = -1;
02252
02253 static char *BotNames[4][4] = {
02254 {"Masque", "Velvet", "M&M", "Mellow"},
02255 {"Red Death", "Royal", "Yellow Streak", "Green Machine"},
02256 {"Anger", "Envy", "Melancholy", "Chicken"},
02257 {"Scarlet", "Violet", "Azure", "Chartreuse"},
02258 };
02259
02260 static GE_RGBA BotLight[4][4] = {
02261 {
02262 {255.0f, 050.0f, 050.0f, 0.0f}, // Red
02263 {255.0f, 050.0f, 255.0f, 0.0f}, // Purple
02264 {000.0f, 255.0f, 000.0f, 0.0f}, // Green
02265 {255.0f, 229.0f, 094.0f, 0.0f}, // Yellow
02266 },
02267 {
02268 {255.0f, 050.0f, 050.0f, 0.0f}, // Red
02269 {000.0f, 050.0f, 255.0f, 0.0f}, // Blue
02270 {255.0f, 229.0f, 094.0f, 0.0f}, // Yellow
02271 {000.0f, 255.0f, 000.0f, 0.0f}, // Green
02272 },
02273 {
02274 {255.0f, 050.0f, 050.0f, 0.0f}, // Red
02275 {000.0f, 255.0f, 000.0f, 0.0f}, // Green
02276 {000.0f, 050.0f, 255.0f, 0.0f}, // Blue
02277 {255.0f, 229.0f, 094.0f, 0.0f}, // Yellow
02278 },
02279 {
02280 {255.0f, 050.0f, 050.0f, 0.0f}, // Red
02281 {255.0f, 050.0f, 255.0f, 0.0f}, // Purple
02282 {000.0f, 050.0f, 255.0f, 0.0f}, // Blue
02283 {176.0f, 232.0f, 082.0f, 0.0f}, // Chartruese
02284 },
02285 };
02286
02287
02288 if (RandomSet == -1)
02289 {
02290 srand((unsigned)time(NULL));
02291 RandomSet = rand() % 4; // probably should be done in startup code but this
02292 // will keep it more seperated
02293 }
02294
02295 if (ServerBotCount == MenuBotCount)
02296 return GE_TRUE;
02297
02298 cnt = Server_CountBots(Server);
02299
02300 if (cnt < MenuBotCount)
02301 {
02302 for (i = cnt; i < MenuBotCount; i++)
02303 {
02304 if (!(SClient = Server_BotConnect(Server, BotNames[RandomSet][i])))
02305 {
02306 GenVS_Error("Server_ManageBots: Could not add BOT client in single player mode...\n");
02307 }
02308 else
02309 {
02310 if (!SClient->Active)
02311 continue;
02312
02313 Index = SClient->Player - Server->SvPlayers;
02314
02315 if (Server->Client->Players[Index].Actor)
02316 {
02317 geVec3d Normal = {0.0f, 1.0f, 0.0f};
02318
02319 geActor_SetLightingOptions( Server->Client->Players[Index].Actor,
02320 GE_TRUE, &Normal,
02321 BotLight[RandomSet][i].r,
02322 BotLight[RandomSet][i].g,
02323 BotLight[RandomSet][i].b,
02324 1.0f, 1.0f, 1.0f,
02325 GE_TRUE, 3, NULL, GE_FALSE);
02326 }
02327 }
02328
02329 ServerBotCount++;
02330 }
02331 }
02332 else
02333 if (cnt > MenuBotCount)
02334 {
02335 GenVSI_CHandle ClientHandle;
02336 for (i = cnt-1; i >= MenuBotCount; i--)
02337 {
02338 if ((ClientHandle = Server_GetBotByName(Server, BotNames[RandomSet][i])) != CLIENT_NULL_HANDLE)
02339 Server_ClientDisconnectByHandle(Server, ClientHandle);
02340 ServerBotCount--;
02341 }
02342 }
02343
02344 return GE_TRUE;
02345 }
|
|
||||||||||||
|
Definition at line 2718 of file Server.c. References GameMgr_GetModel(), GameMgr_GetNumModels(), GameMgr_GetWorld(), GenVS_Error(), Server_Server::GMgr, int32, and uint16. Referenced by Server_SetupGenVSI().
02719 {
02720 int32 i, NumModels;
02721
02722 assert(Server);
02723 assert(GameMgr_GetWorld(Server->GMgr));
02724
02725 NumModels = GameMgr_GetNumModels(Server->GMgr);
02726
02727 for (i=0; i< NumModels; i++)
02728 {
02729 if (Model == GameMgr_GetModel(Server->GMgr, i))
02730 break;
02731 }
02732
02733 if (i >= NumModels)
02734 {
02735 GenVS_Error("Server_ModelToViewIndex: Model not in world...");
02736 }
02737
02738 return (uint16)i;
02739 }
|
|
||||||||||||||||
|
Definition at line 2428 of file Server.c. References GameMgr_SetMotionIndexDef(), GenVS_Error(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02429 {
02430 assert(Server);
02431
02432 if (!GameMgr_SetMotionIndexDef(Server->GMgr, MotionIndex, MotionName))
02433 GenVS_Error("Server_MotionIndex: Could not set motion: %s.\n", MotionName);
02434 }
|
|
||||||||||||||||
|
Definition at line 2860 of file Server.c. References GPlayer::Active, GPlayer::Blocked, Console_Printf(), GameMgr_GetConsole(), GameMgr_GetWorld(), GE_FALSE, GE_TRUE, geBoolean, Server_Server::GenVSI, geWorld_SetModelXForm(), geWorld_TestModelMove(), Server_Server::GMgr, int32, GPlayer::Maxs, GPlayer::Mins, GPlayer::Model, NETMGR_MAX_PLAYERS, Server_Server::SvPlayers, geXForm3d::Translation, VIEW_TYPE_COLLIDEMODEL, VIEW_TYPE_MODEL, GPlayer::ViewFlags, and GPlayer::XForm. Referenced by Server_SetupGenVSI().
02861 {
02862 geBoolean CanMove;
02863 int32 i;
02864 geWorld *World;
02865
02866 assert(Server);
02867
02868 World = GameMgr_GetWorld(Server->GMgr);
02869 assert(World);
02870
02871 CanMove = GE_TRUE;
02872
02873 for (i=0; i< NETMGR_MAX_PLAYERS; i++)
02874 {
02875 geVec3d Mins, Maxs, Pos, Out;
02876 GPlayer *Target;
02877
02878 Target = &Server->SvPlayers[i];
02879
02880 if (!Target->Active) // Not an active player...
02881 continue;
02882
02883 if (Target->ViewFlags & VIEW_TYPE_MODEL) // Don't check other models, don't care...
02884 continue;
02885
02886 // Don't test against this thing unless it's got the COLLIDEMODEL flag set.
02887 if (!(Target->ViewFlags & VIEW_TYPE_COLLIDEMODEL))
02888 continue;
02889
02890 Mins = Target->Mins;
02891 Maxs = Target->Maxs;
02892
02893 Pos = Target->XForm.Translation;
02894
02895 // Test the models move intentions agianst all the players in the level
02896 if (!geWorld_TestModelMove(World, Player->Model, DestXForm, &Mins, &Maxs, &Pos, &Out))
02897 {
02898 CanMove = GE_FALSE; // Can't move, would've pushed player into world
02899
02900 // The model was blocked by player target
02901 if (Player->Blocked) // Call the blocked callback, and tell Player that Target is in the way..
02902 {
02903 Player->Blocked(&Server->GenVSI, Player, Target);
02904 }
02905
02906 }
02907 else
02908 {
02909 Target->XForm.Translation = Out;
02910 }
02911 }
02912
02913 if (CanMove)
02914 {
02915 if (World)
02916 geWorld_SetModelXForm(World, Player->Model, DestXForm);
02917 else
02918 Console_Printf(GameMgr_GetConsole(Server->GMgr), "Server_MovePlayerModel: No world!\n");
02919 }
02920
02921 return CanMove;
02922 }
|
|
|
Definition at line 946 of file Server.c. References Server_Server::Clients, GPlayer::DFunc, GE_FALSE, GE_TRUE, geBoolean, int32, Server_Client::MoveTime, NETMGR_MAX_CLIENTS, NETMGR_MAX_PLAYERS, Server_Client::NextUpdate, NULL, Server_Server::NumTotalPlayers, Server_Client::OldMoveTime, Server_Client::Player, Server_SetPlayerDefaults(), Server_Client::Spawned, and Server_Server::SvPlayers. Referenced by Server_Create(), and Server_Frame().
00947 {
00948 int32 i;
00949 GPlayer *Player;
00950 Server_Client *Client;
00951
00952 assert(Server);
00953
00954 // Free all the players that are left over (lazy garbage collection)
00955 for (Player = Server->SvPlayers, i=0; i< NETMGR_MAX_PLAYERS; i++, Player++)
00956 {
00957 assert(Player->DFunc == NULL);
00958 Server_SetPlayerDefaults(Player);
00959 }
00960
00961 // Reset the number of players, since we just freed them...
00962 Server->NumTotalPlayers = 0;;
00963
00964 // Make sure the clients don't have any players attached...
00965 for (Client = Server->Clients, i=0; i< NETMGR_MAX_CLIENTS; i++, Client++)
00966 {
00967 // FIXME: Reset more stuff?
00968 Client->Player = NULL; // Make sure the clients make new players
00969 Client->NextUpdate = 0.0f; // Reset all the timer stuff
00970 Client->OldMoveTime = 0.0f;
00971 Client->MoveTime = 0.0f;
00972 Client->Spawned = GE_FALSE; // Make sure clients are respawned in the new world
00973 }
00974
00975 return GE_TRUE;
00976 }
|
|
||||||||||||||||
|
Definition at line 2479 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillPos(), Buffer_FillShort(), Buffer_Set(), Server_Server::Clients, FALSE, int32, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_PLAY_SOUND_INDEX, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_ClientDisconnect(), uint16, and uint8. Referenced by Server_SetupGenVSI().
02480 {
02481 int32 i;
02482 uint8 Data[1000];
02483 Buffer_Data Buffer;
02484 Server_Client *Client;
02485
02486 Buffer_Set(&Buffer, Data, 1000);
02487
02488 // Fill the buffer with the message
02489 Buffer_FillByte(&Buffer, NETMGR_MSG_PLAY_SOUND_INDEX);
02490 Buffer_FillShort(&Buffer, (uint16)SoundIndex);
02491 Buffer_FillPos(&Buffer, *Pos);
02492
02493 Client = Server->Clients;
02494
02495 // Tell the host to route this message to the clients
02496 for (i=0; i< NETMGR_MAX_CLIENTS; i++, Client++)
02497 {
02498 if (!Client->Active)
02499 continue;
02500
02501 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, FALSE))
02502 {
02503 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
02504 //GenVS_Error("Server_PlaySound: Could not sent message to client.\n");
02505 }
02506 }
02507 }
|
|
||||||||||||||||
|
Definition at line 3083 of file Server.c. References Server_Server::ProcIndex, and SERVER_MAX_PROC_INDEX. Referenced by Server_SetupGenVSI().
03084 {
03085 assert(Server);
03086 assert(Index >= 0 && Index < 65535);
03087 assert(Index >= 0 && Index < SERVER_MAX_PROC_INDEX);
03088
03089 Server->ProcIndex[Index] = Proc;
03090 }
|
|
||||||||||||||||
|
Definition at line 2744 of file Server.c. References geWorld_ModelSetUserData(), and GPlayer::Model. Referenced by Server_SetupGenVSI().
02745 {
02746 assert(Server);
02747 assert(Player);
02748 assert(Model);
02749
02750 // Attach the player to the model, and the model to the player...
02751 geWorld_ModelSetUserData(Model, (void*)Player);
02752 Player->Model = Model;
02753 }
|
|
||||||||||||
|
Definition at line 434 of file Server.c. References Server_Client::Active, GameMgr_ActorIndex::Active, GameMgr_MotionIndexDef::Active, GameMgr_BoneIndex::Active, GameMgr_TextureIndex::Active, GameMgr_SoundIndex::Active, GameMgr_TextureIndex::AFileName, GameMgr_BoneIndex::BoneName, Buffer_FillByte(), Buffer_FillSLong(), Buffer_FillString(), Buffer_Set(), GameMgr_ActorIndex::FileName, GameMgr_TextureIndex::FileName, GameMgr_SoundIndex::FileName, GameMgr_GetActorIndex(), GameMgr_GetBoneIndex(), GameMgr_GetMotionIndexDef(), GameMgr_GetSoundIndex(), GameMgr_GetTextureIndex(), GameMgr_GetWorld(), GAMEMGR_MAX_ACTOR_INDEX, GAMEMGR_MAX_BONE_INDEX, GAMEMGR_MAX_MOTION_INDEX, GAMEMGR_MAX_SOUND_INDEX, GAMEMGR_MAX_TEXTURE_INDEX, GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, int32, GameMgr_MotionIndexDef::MotionName, Server_Client::NetID, NETMGR_MSG_ACTOR_INDEX, NETMGR_MSG_BONE_INDEX, NETMGR_MSG_CLIENT_PLAYER_INDEX, NETMGR_MSG_MOTION_INDEX, NETMGR_MSG_SET_WORLD, NETMGR_MSG_SOUND_INDEX, NETMGR_MSG_TEXTURE_INDEX, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_Client::Player, SERVER_GPLAYER_TO_INDEX, and Server_Server::WorldName. Referenced by Server_SetupClientWithCurrentWorld().
00435 {
00436 int32 i;
00437 Buffer_Data Buffer;
00438 char Data[20000];
00439
00440 assert(GameMgr_GetWorld(Server->GMgr));
00441 assert(Client->Active == GE_TRUE);
00442
00443 // Fill message with world data
00444 Buffer_Set(&Buffer, Data, 20000);
00445 Buffer_FillByte(&Buffer, NETMGR_MSG_SET_WORLD);
00446 Buffer_FillString(&Buffer, Server->WorldName);
00447
00448 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00449 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 1.\n");
00450
00451 // fill message with actor index data
00452 Buffer_Set(&Buffer, Data, 20000);
00453 for (i=0; i< GAMEMGR_MAX_ACTOR_INDEX; i++)
00454 {
00455 GameMgr_ActorIndex *ActorIndex;
00456
00457 ActorIndex = GameMgr_GetActorIndex(Server->GMgr, i);
00458
00459 if (!ActorIndex->Active)
00460 continue;
00461
00462 Buffer_FillByte(&Buffer, NETMGR_MSG_ACTOR_INDEX);
00463 Buffer_FillSLong(&Buffer, i);
00464 Buffer_FillString(&Buffer, ActorIndex->FileName);
00465 }
00466
00467 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00468 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 2.\n");
00469
00470 // fill message with motion index data
00471 Buffer_Set(&Buffer, Data, 20000);
00472 for (i=0; i< GAMEMGR_MAX_MOTION_INDEX; i++)
00473 {
00474 GameMgr_MotionIndexDef *MotionIndex;
00475
00476 MotionIndex = GameMgr_GetMotionIndexDef(Server->GMgr, i);
00477
00478 // Only send motion indexes that are active, or need to be shutdown
00479 if (!MotionIndex->Active)
00480 continue;
00481
00482 Buffer_FillByte(&Buffer, NETMGR_MSG_MOTION_INDEX);
00483 Buffer_FillSLong(&Buffer, i);
00484 Buffer_FillString(&Buffer, MotionIndex->MotionName);
00485 }
00486
00487 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00488 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 3.\n");
00489
00490 // fill message with bone index data
00491 Buffer_Set(&Buffer, Data, 20000);
00492 for (i=0; i< GAMEMGR_MAX_BONE_INDEX; i++)
00493 {
00494 GameMgr_BoneIndex *BoneIndex;
00495
00496 BoneIndex = GameMgr_GetBoneIndex(Server->GMgr, i);
00497
00498 // Only send motion indexes that are active, or need to be shutdown
00499 if (!BoneIndex->Active)
00500 continue;
00501
00502 Buffer_FillByte(&Buffer, NETMGR_MSG_BONE_INDEX);
00503 Buffer_FillSLong(&Buffer, i);
00504 Buffer_FillString(&Buffer, BoneIndex->BoneName);
00505 }
00506
00507 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00508 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 4.\n");
00509
00510 // Fill message with texture index data
00511 Buffer_Set(&Buffer, Data, 20000);
00512 for (i=0; i< GAMEMGR_MAX_TEXTURE_INDEX; i++)
00513 {
00514 GameMgr_TextureIndex *TextureIndex;
00515
00516 TextureIndex = GameMgr_GetTextureIndex(Server->GMgr, i);
00517
00518 // Only send motion indexes that are active, or need to be shutdown
00519 if (!TextureIndex->Active)
00520 continue;
00521
00522 Buffer_FillByte(&Buffer, NETMGR_MSG_TEXTURE_INDEX);
00523 Buffer_FillSLong(&Buffer, i);
00524 Buffer_FillString(&Buffer, TextureIndex->FileName);
00525 Buffer_FillString(&Buffer, TextureIndex->AFileName);
00526 }
00527
00528 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00529 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 5.\n");
00530
00531 // Fill message with sound index data
00532 Buffer_Set(&Buffer, Data, 20000);
00533 for (i=0; i< GAMEMGR_MAX_SOUND_INDEX; i++)
00534 {
00535 GameMgr_SoundIndex *SoundIndex;
00536
00537 SoundIndex = GameMgr_GetSoundIndex(Server->GMgr, i);
00538
00539 // Only send motion indexes that are active, or need to be shutdown
00540 if (!SoundIndex->Active)
00541 continue;
00542
00543 Buffer_FillByte(&Buffer, NETMGR_MSG_SOUND_INDEX);
00544 Buffer_FillSLong(&Buffer, i);
00545 Buffer_FillString(&Buffer, SoundIndex->FileName);
00546 }
00547
00548 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00549 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 6.\n");
00550
00551 // Tell the client what player he is
00552 {
00553 int32 PlayerIndex;
00554
00555 assert(Client->Player);
00556
00557 PlayerIndex = (int32)SERVER_GPLAYER_TO_INDEX(Server, Client->Player);
00558
00559 Buffer_Set(&Buffer, Data, 10000);
00560 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_PLAYER_INDEX);
00561 Buffer_FillSLong(&Buffer, PlayerIndex);
00562
00563 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00564 GenVS_Error("Server_SendClientCurrentWorldData: NetMgr_SendClientMessage failed 7.\n");
00565 }
00566
00567 return GE_TRUE;
00568 }
|
|
||||||||||||
|
Definition at line 358 of file Server.c. References Buffer_FillByte(), Buffer_Set(), Server_Server::Clients, FillBufferWithClientInfo(), GameMgr_GetWorld(), GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, int32, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_CLIENT_INDEX, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_Client::Player, SendAllClientsMessage(), Server_SetupClientWithCurrentWorld(), and uint8. Referenced by Server_BotConnect(), and Server_ClientConnect().
00359 {
00360
00361 uint8 Data[20000];
00362 Buffer_Data Buffer;
00363 int32 ClientIndex;
00364 geWorld *World;
00365
00366 assert(Client->Player);
00367
00368 ClientIndex = Client - Server->Clients;
00369 assert(ClientIndex >=0 && ClientIndex < NETMGR_MAX_CLIENTS);
00370
00371 // First, Tell this client what index slot he is...
00372 Buffer_Set(&Buffer, Data, 20000);
00373
00374 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_INDEX);
00375 Buffer_FillByte(&Buffer, (uint8)ClientIndex);
00376
00377 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00378 GenVS_Error("Server_SendClientStartupData: NetMgr_SendClientMessage failed.\n");
00379
00380 Buffer_Set(&Buffer, Data, 20000);
00381
00382 if (!FillBufferWithClientInfo(Server, &Buffer))
00383 GenVS_Error("Server_SendClientStartupData: FillBufferWithClientInfo failed.\n");
00384
00385 // Send everyone (even client) the info about the clients, score, health, active, etc...
00386 if (!SendAllClientsMessage(Server, &Buffer, GE_TRUE)) // Everyone needs to know about this one...
00387 GenVS_Error("Server_SendClientStartupData: SendAllClientsMessage failed.\n");
00388
00389 World = GameMgr_GetWorld(Server->GMgr);
00390
00391 if (World) // If there is a world, setup this client with it...
00392 {
00393 if (!Server_SetupClientWithCurrentWorld(Server, Client))
00394 GenVS_Error("Server_SendClientStartupData: Server_SetupClientWithCurrentWorld failed.\n");
00395 }
00396
00397 return GE_TRUE;
00398 }
|
|
||||||||||||||||||||
|
Definition at line 2356 of file Server.c. References Server_Server::ClassSpawns, Server_CSpawn::DFunc, Server_CSpawn::Func, GenVS_Error(), int32, MAX_CLASS_NAME_STRING, MAX_SERVER_CLASS_SPAWNS, Server_CSpawn::Name, and Server_Server::NumClassSpawns. Referenced by Server_SetupGenVSI().
02357 {
02358 int32 i;
02359 Server_Server *Server;
02360
02361 assert(ClassName);
02362 assert(strlen(ClassName) < MAX_CLASS_NAME_STRING);
02363 assert(Func);
02364
02365 Server = (Server_Server*)UData;
02366
02367 for (i=0; i< Server->NumClassSpawns; i++)
02368 {
02369 if (!strcmp(Server->ClassSpawns[i].Name, ClassName))
02370 return;
02371 }
02372
02373 if (i >= MAX_SERVER_CLASS_SPAWNS)
02374 {
02375 GenVS_Error("Server_SetClassSpawn: No more slots left.\n");
02376 }
02377
02378 strcpy(Server->ClassSpawns[i].Name, ClassName);
02379 Server->ClassSpawns[i].Func = Func;
02380 Server->ClassSpawns[i].DFunc = DFunc;
02381
02382 Server->NumClassSpawns++;
02383 }
|
|
||||||||||||||||
|
Definition at line 2586 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillSLong(), Buffer_Set(), Server_Server::Clients, Console_Printf(), GameMgr_GetConsole(), GE_TRUE, Server_Server::GMgr, Server_Client::Health, Server_Client::Name, Server_Client::NetID, NETMGR_MSG_CLIENT_HEALTH, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_ClientDisconnect(), and uint8. Referenced by Server_SetupGenVSI().
02587 {
02588 Buffer_Data Buffer;
02589 char Data[128];
02590 Server_Client *Client;
02591
02592 assert(Server);
02593
02594 assert(ClientHandle >= 0 && ClientHandle <= 255);
02595
02596 Client = &Server->Clients[ClientHandle];
02597
02598 if (!Client->Active)
02599 {
02600 Console_Printf(GameMgr_GetConsole(Server->GMgr), "Server_SetClientScore: Client not active!\n");
02601 return;
02602 }
02603
02604 Client->Health = Health;
02605
02606 Buffer_Set(&Buffer, Data, 128);
02607 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_HEALTH);
02608 Buffer_FillByte(&Buffer, (uint8)ClientHandle);
02609 Buffer_FillSLong(&Buffer, Client->Health);
02610
02611 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
02612 {
02613 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
02614 //GenVS_Error("Server_SetClientHealth: Could not send message.\n");
02615 }
02616 }
|
|
||||||||||||||||||||||||
|
Definition at line 2654 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillShort(), Buffer_Set(), Server_Server::Clients, GE_TRUE, GenVS_Error(), Server_Client::Inventory, Server_Client::InventoryHas, MAX_PLAYER_ITEMS, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_CLIENT_INVENTORY, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_ClientDisconnect(), uint16, and uint8. Referenced by Server_SetupGenVSI().
02655 {
02656 Buffer_Data Buffer;
02657 char Data[128];
02658 uint16 SendVal;
02659 Server_Client *Client;
02660
02661 assert(Server);
02662 assert(ClientHandle >= 0 && ClientHandle < NETMGR_MAX_CLIENTS);
02663
02664 Client = &Server->Clients[ClientHandle];
02665
02666 if (!Client->Active)
02667 GenVS_Error("Server_SetClientInventory: Client not active.");
02668
02669 assert(Slot < MAX_PLAYER_ITEMS && Slot < 256);
02670
02671 Client->Inventory[Slot] = Amount;
02672 Client->InventoryHas[Slot] = HasItem;
02673
02674 SendVal = Client->Inventory[Slot];
02675
02676 if (Client->InventoryHas[Slot])
02677 SendVal |= (1<<15);
02678
02679 assert(ClientHandle <= 255);
02680
02681 Buffer_Set(&Buffer, Data, 128);
02682 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_INVENTORY);
02683 Buffer_FillByte(&Buffer, (uint8)ClientHandle);
02684 Buffer_FillByte(&Buffer, (uint8)Slot);
02685 Buffer_FillShort(&Buffer, SendVal);
02686
02687 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
02688 {
02689 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
02690 //GenVS_Error("Server_SetClientInventory: Could not send message.\n");
02691 }
02692 }
|
|
||||||||||||||||
|
Definition at line 2532 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillSLong(), Buffer_Set(), Server_Server::Clients, Console_Printf(), GameMgr_GetConsole(), GE_TRUE, GenVS_Error(), Server_Server::GMgr, NETMGR_MSG_CLIENT_SCORE, Server_Client::Score, SendAllClientsMessage(), and uint8. Referenced by Server_SetupGenVSI().
02533 {
02534 Buffer_Data Buffer;
02535 char Data[128];
02536 Server_Client *Client;
02537
02538 assert(Server);
02539
02540 assert(ClientHandle >= 0 && ClientHandle <= 255);
02541
02542 Client = &Server->Clients[ClientHandle];
02543
02544 if (!Client->Active)
02545 {
02546 Console_Printf(GameMgr_GetConsole(Server->GMgr), "Server_SetClientScore: Client not active!\n");
02547 return;
02548 }
02549
02550 Client->Score = Score;
02551
02552 Buffer_Set(&Buffer, Data, 128);
02553 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_SCORE);
02554 Buffer_FillByte(&Buffer, (uint8)ClientHandle);
02555 Buffer_FillSLong(&Buffer, Client->Score);
02556
02557 if (!SendAllClientsMessage(Server, &Buffer, GE_TRUE))
02558 GenVS_Error("Server_SetClientScore: Could not send message.\n");
02559 }
|
|
||||||||||||||||
|
Definition at line 2621 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillShort(), Buffer_Set(), Server_Server::Clients, Server_Client::CurrentWeapon, GE_FALSE, GenVS_Error(), Server_Client::Name, Server_Client::NetID, NETMGR_MSG_CLIENT_WEAPON, NetMgr_SendClientMessage(), Server_Server::NMgr, Server_ClientDisconnect(), uint16, and uint8. Referenced by Server_SetupGenVSI().
02622 {
02623 Buffer_Data Buffer;
02624 char Data[512];
02625 Server_Client *Client;
02626
02627 assert(Server);
02628
02629 assert(ClientHandle >= 0 && ClientHandle <= 255);
02630 assert(Weapon >= 0 && Weapon <= 255);
02631
02632 Client = &Server->Clients[ClientHandle];
02633
02634 if (!Client->Active)
02635 GenVS_Error("Server_SetClientWeapon: Client not active!\n");
02636
02637 Client->CurrentWeapon = (uint16)Weapon;
02638
02639 Buffer_Set(&Buffer, Data, 512);
02640 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_WEAPON);
02641 Buffer_FillByte(&Buffer, (uint8)ClientHandle);
02642 Buffer_FillShort(&Buffer, (uint16)Client->CurrentWeapon);
02643
02644 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_FALSE))
02645 {
02646 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
02647 //GenVS_Error("Server_SetClientWeapon: Could not send message.\n");
02648 }
02649 }
|
|
|
|
Definition at line 332 of file Server.c. References Server_Client::Active, Server_Server::Clients, GE_TRUE, geBoolean, int32, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, Server_ClientDisconnect(), and Server_SetupClientWithCurrentWorld(). Referenced by Server_SetupWorld().
00333 {
00334 int32 i;
00335
00336 // Send all the clients what index slot they are in...
00337 for (i=0; i< NETMGR_MAX_CLIENTS; i++)
00338 {
00339 Server_Client *Client;
00340
00341 Client = &Server->Clients[i];
00342
00343 if (!Client->Active)
00344 continue;
00345
00346 if (!Server_SetupClientWithCurrentWorld(Server, Client))
00347 {
00348 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
00349 }
00350 }
00351
00352 return GE_TRUE;
00353 }
|
|
||||||||||||
|
Definition at line 303 of file Server.c. References GameMgr_GetWorld(), GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GMgr, NetState_WorldActive, NetState_WorldChange, NULL, SendClientPlayerData(), Server_ChangeClientState(), and Server_SendClientCurrentWorldData(). Referenced by Server_SendClientStartupData(), and Server_SetupAllClientsWithCurrentWorld().
00304 {
00305 geWorld *World;
00306
00307 World = GameMgr_GetWorld(Server->GMgr);
00308
00309 assert(World != NULL); // If we got here, there should be a world!!!
00310
00311 // Change the state of the client to NetState_WorldChange...
00312 if (!Server_ChangeClientState(Server, Client, NetState_WorldChange))
00313 GenVS_Error("Server_SetupClientWithCurrentWorld: Server_ChangeClientState failed.\n");
00314
00315 if (!Server_SendClientCurrentWorldData(Server, Client))
00316 GenVS_Error("Server_SetupClientWithCurrentWorld: Server_SendClientCurrentWorldData failed.\n");
00317
00318 if (!SendClientPlayerData(Server, Client))
00319 GenVS_Error("Server_SetupClientWithCurrentWorld: SendClientPlayerData failed.\n");
00320
00321 if (!Server_ChangeClientState(Server, Client, NetState_WorldActive))
00322 GenVS_Error("Server_SetupClientWithCurrentWorld: Server_ChangeClientState failed.\n");
00323
00324 return GE_TRUE;
00325 }
|
|
|
|
Definition at line 1074 of file Server.c. References GameMgr_GetWorld(), GE_TRUE, geBoolean, GenVS_Error(), Server_Server::GenVSI, Server_Server::GMgr, MainFS, Server_Server::NewWorldCB, Server_SetupAllClientsWithCurrentWorld(), Server_SpawnWorld(), and Server_Server::WorldName. Referenced by Server_Frame().
01075 {
01076 geWorld *World;
01077 GameMgr *GMgr;
01078
01079 assert(Server);
01080 assert(Server->NewWorldCB);
01081
01082 GMgr = Server->GMgr;
01083 World = GameMgr_GetWorld(GMgr);
01084
01085 assert(GMgr);
01086 assert(World);
01087 assert(MainFS);
01088
01089 // Call the Games NewWorld callback function to set up this world with meshes, actors, sounds, etc...
01090 if (!Server->NewWorldCB(&Server->GenVSI, Server->WorldName, MainFS))
01091 GenVS_Error("Server_SetupWorld: NewWorldCB failed.\n");
01092
01093 // Setup the new world, and spawn all connected clients...
01094 if (!Server_SpawnWorld(Server))
01095 GenVS_Error("Server_SetWorld: Failed to spawn world.\n");
01096
01097 // Send any currently connected clients all the info about this new world...
01098 if (!Server_SetupAllClientsWithCurrentWorld(Server))
01099 GenVS_Error("Server_SetWorld: Failed send all clients world data.\n");
01100
01101 //Console_Printf(GameMgr_GetConsole(Server->GMgr), "[SERVER] SetWorld: %s\n", Name);
01102 return GE_TRUE;
01103 }
|
|
||||||||||||||||
|
Definition at line 2823 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillShort(), Server_Server::Clients, Console_Printf(), Buffer_Data::Data, GameMgr_GetConsole(), GE_TRUE, Server_Server::GMgr, int32, Server_Client::Name, Server_Client::NetID, NETMGR_MAX_CLIENTS, NETMGR_MSG_VIEW_PLAYER, NetMgr_SendClientMessage(), Server_Server::NMgr, Buffer_Data::Pos, Server_ClientDisconnect(), SERVER_GPLAYER_TO_INDEX, Buffer_Data::Size, uint16, and uint8. Referenced by Server_SetupGenVSI().
02824 {
02825 int32 i;
02826 uint8 Data[1000];
02827 Buffer_Data Buffer;
02828 Server_Client *Client;
02829
02830 assert(Server);
02831 assert(ClientHandle >= 0 && ClientHandle <= NETMGR_MAX_CLIENTS);
02832 assert(Player);
02833
02834 Client = &Server->Clients[ClientHandle];
02835
02836 assert(Client->Active);
02837
02838 Buffer.Data = Data;
02839 Buffer.Size = 1000;
02840 Buffer.Pos = 0;
02841
02842 // Get player index number
02843 i = (int32)SERVER_GPLAYER_TO_INDEX(Server, Player);
02844
02845 Buffer_FillByte(&Buffer, NETMGR_MSG_VIEW_PLAYER);
02846 Buffer_FillShort(&Buffer, (uint16)i);
02847
02848 Console_Printf(GameMgr_GetConsole(Server->GMgr), "View Player sent: %i\n", i);
02849
02850 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
02851 {
02852 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
02853 //GenVS_Error("Server_SetViewPlayer: Could not send message.\n");
02854 }
02855 }
|
|
||||||||||||||||||||
|
Definition at line 2388 of file Server.c. References Server_Server::ChangeWorldRequest, GE_TRUE, Server_Server::NewWorldCB, ShutdownWorldCB(), Server_Server::ShutdownWorldCB2, and Server_Server::WorldName. Referenced by Server_SetupGenVSI().
02389 {
02390 assert(Server);
02391 assert(NewWorldCB);
02392 assert(Name);
02393
02394 strcpy(Server->WorldName, Name);
02395 Server->ChangeWorldRequest = GE_TRUE;
02396
02397 Server->NewWorldCB = NewWorldCB;
02398
02399 // When the server gets the request, it will call ShutdownWorldCB1, then set ShutdownWorldCB1 to
02400 // ShutdownWorldCB2, then NULL out ShutdownWorldCB2...
02401 Server->ShutdownWorldCB2 = ShutdownWorldCB;
02402 }
|
|
||||||||||||||||
|
Definition at line 2465 of file Server.c. References GameMgr_SetSoundIndex(), GenVS_Error(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02466 {
02467 assert(Server);
02468 assert(FileName);
02469
02470 if (!GameMgr_SetSoundIndex(Server->GMgr, Index, FileName))
02471 {
02472 GenVS_Error("Server_SoundIndex: GameMgr_SetSoundIndex failed...");
02473 }
02474 }
|
|
||||||||||||||||||||
|
Definition at line 2512 of file Server.c. References Buffer_FillByte(), Buffer_FillPos(), Buffer_Set(), GE_FALSE, GenVS_Error(), NETMGR_MSG_SPAWN_FX, and SendAllClientsMessage(). Referenced by Server_SetupGenVSI().
02513 {
02514 Buffer_Data Buffer;
02515 char Data[128];
02516
02517 assert(Server);
02518
02519 Buffer_Set(&Buffer, Data, 128);
02520 Buffer_FillByte(&Buffer, NETMGR_MSG_SPAWN_FX);
02521 Buffer_FillPos(&Buffer, *Pos);
02522 Buffer_FillByte(&Buffer, Type);
02523 Buffer_FillByte(&Buffer, Sound);
02524
02525 if (!SendAllClientsMessage(Server, &Buffer, GE_FALSE))
02526 GenVS_Error("Server_SpawnFx: Could not send mesages to clients.\n");
02527 }
|
|
|
Definition at line 983 of file Server.c. References Server_Client::Active, GPlayer::ClassData, Server_Server::ClassSpawns, Server_Server::Clients, GPlayer::DFunc, Server_CSpawn::DFunc, Server_CSpawn::Func, GameMgr_GetWorld(), GE_TRUE, geBoolean, geEntity_EntitySetGetNextEntity(), geEntity_GetName(), geEntity_GetUserData(), GenVS_Error(), Server_Server::GenVSI, geWorld_GetEntitySet(), Server_Server::GMgr, int32, GPlayer::Mode, MODE_Authoritive, Server_CSpawn::Name, NETMGR_MAX_CLIENTS, NULL, Server_Server::NumClassSpawns, Server_CreatePlayer(), and Server_ValidateClient(). Referenced by Server_SetupWorld().
00984 {
00985 int32 i;
00986 geWorld *World;
00987 Server_CSpawn *CSpawn;
00988 GPlayer *Player;
00989 void *ClassData;
00990 geEntity_EntitySet *ClassSet;
00991 geEntity *Entity;
00992
00993 assert(Server);
00994
00995 World = GameMgr_GetWorld(Server->GMgr);
00996 assert(World);
00997
00998 if (!Server->NumClassSpawns)
00999 {
01000 GenVS_Error("Server_SpawnWorld: No Class Spawns in Game code.\n");
01001 }
01002
01003 // Setup all the class callbacks...
01004 for (i=0; i < Server->NumClassSpawns; i++)
01005 {
01006 CSpawn = &Server->ClassSpawns[i];
01007
01008 // Look for the class name in the world
01009 ClassSet = geWorld_GetEntitySet(World, CSpawn->Name);
01010
01011 // If not found, just continue...
01012 if (!ClassSet)
01013 continue;
01014
01015 Entity = NULL;
01016
01017 while (1)
01018 {
01019 #define MAX_NAME 200
01020 char EntityName[MAX_NAME];
01021
01022 Entity = geEntity_EntitySetGetNextEntity(ClassSet, Entity);
01023 if (!Entity)
01024 break;
01025
01026 geEntity_GetName(Entity, EntityName, MAX_NAME-1);
01027 EntityName[MAX_NAME-1]=0;
01028
01029 ClassData = geEntity_GetUserData(Entity);
01030
01031 // Create the player for the game
01032 Player = Server_CreatePlayer(Server, CSpawn->Name);
01033
01034 Player->Mode = MODE_Authoritive;
01035 Player->ClassData = ClassData;
01036 Player->DFunc = CSpawn->DFunc;
01037
01038 assert(CSpawn->Func);
01039
01040 // Call the game spawn for the player
01041 CSpawn->Func(&Server->GenVSI, Player, ClassData, EntityName);
01042 // this better not fail!
01043 }
01044
01045 }
01046
01047 // Make sure all clients get spawned with this new world
01048 for (i=0; i< NETMGR_MAX_CLIENTS; i++)
01049 {
01050 Server_Client *Client;
01051 //int32 ClientIndex;
01052
01053 Client = &Server->Clients[i];
01054
01055 if (!Client->Active)
01056 continue;
01057
01058 // Validate the client
01059 Server_ValidateClient(Server, Client);
01060 }
01061
01062 //geRam_ReportAllocations();
01063
01064 //DebugBreak();
01065
01066 return GE_TRUE;
01067 }
|
|
||||||||||||||||||||
|
Definition at line 2450 of file Server.c. References GAMEMGR_MAX_FILENAME, GameMgr_SetTextureIndex(), GenVS_Error(), and Server_Server::GMgr. Referenced by Server_SetupGenVSI().
02451 {
02452 assert(Server);
02453 assert(FileName);
02454 assert(strlen(FileName) < GAMEMGR_MAX_FILENAME);
02455
02456 if (!GameMgr_SetTextureIndex(Server->GMgr, Index, FileName, AFileName))
02457 {
02458 GenVS_Error("Server_TextureIndex: GameMgr_SetTextureIndex failed...");
02459 }
02460 }
|
|
||||||||||||
|
Definition at line 573 of file Server.c. References Server_Client::Active, Buffer_FillByte(), Buffer_FillSLong(), Buffer_Set(), GPlayer::ClassData, GPlayer::ClientHandle, Server_Server::Clients, GPlayer::DFunc, ForceServerPlayerOnLocalClient(), Game_DestroyClient(), Game_SpawnBot(), Game_SpawnClient(), GameMgr_GetWorld(), GE_TRUE, GenVS_Error(), Server_Server::GenVSI, GenVSI_CHandle, Server_Server::GMgr, int32, Server_Client::Name, Server_Client::NetID, NETMGR_MSG_CLIENT_PLAYER_INDEX, NetMgr_SendClientMessage(), Server_Server::NMgr, NULL, Server_Client::Player, Server_ClientDisconnect(), Server_CreatePlayer(), SERVER_GPLAYER_TO_INDEX, Server_IsClientBot(), and Server_Client::Spawned. Referenced by Server_BotConnect(), Server_ClientConnect(), and Server_SpawnWorld().
00574 {
00575 GPlayer *Player;
00576 geWorld *World;
00577
00578 assert(Server);
00579 assert(Client);
00580 assert(Client->Active);
00581
00582 assert(Client->Player == NULL);
00583 //if (Client->Player) // Already has a player...
00584 // return;
00585
00586 // Create a player for the client
00587 //Player = Server_CreatePlayer(Server, "ClientPlayer");
00588 Player = Server_CreatePlayer(Server, Client->Name);
00589
00590 if (!Player)
00591 GenVS_Error("Server_ClientConnect: No more players available for client.");
00592
00593 // Connect them
00594 Client->Player = Player;
00595 Player->ClientHandle = (GenVSI_CHandle)(Client - Server->Clients);
00596
00597 World = GameMgr_GetWorld(Server->GMgr);
00598
00599 // Make sure the client is spawned if there is a world to spawn it in...
00600 if (!Client->Spawned && World)
00601 {
00602 int32 PlayerIndex;
00603 Buffer_Data Buffer;
00604 char Data[1024];
00605
00606 if (Server_IsClientBot(Server,Player->ClientHandle))
00607 {
00608 if (!Game_SpawnBot(&Server->GenVSI, World, Player, Player->ClassData))
00609 GenVS_Error("Server_ValidateClient: Game_SpawnBot failed...");
00610 }
00611 else
00612 {
00613 if (!Game_SpawnClient(&Server->GenVSI, World, Player, Player->ClassData))
00614 GenVS_Error("Server_ValidateClient: Game_SpawnClient failed...");
00615 }
00616
00617 if (!Client->Active) // Client got removed...
00618 return;
00619
00620 Client->Spawned = GE_TRUE;
00621
00622 //??bot HACK ask john if its ok
00623 if (!Player->DFunc)
00624 Player->DFunc = Game_DestroyClient;
00625
00626 PlayerIndex = (int32)SERVER_GPLAYER_TO_INDEX(Server, Client->Player);
00627
00628 Buffer_Set(&Buffer, Data, 1024);
00629
00630 Buffer_FillByte(&Buffer, NETMGR_MSG_CLIENT_PLAYER_INDEX);
00631 Buffer_FillSLong(&Buffer, PlayerIndex);
00632
00633 if (!NetMgr_SendClientMessage(Server->NMgr, Client->NetID, &Buffer, GE_TRUE))
00634 {
00635 Server_ClientDisconnect(Server, Client->NetID, Client->Name);
00636 }
00637
00638 ForceServerPlayerOnLocalClient(Server, Client->Player);
00639 }
00640 }
|
|
|
Definition at line 1719 of file Server.c. References Server_Client::Active, GPlayer::Active, Server_Server::Clients, GPlayer::Control, GetPlayerSendFlags(), int32, NETMGR_MAX_CLIENTS, NETMGR_MAX_PLAYERS, Server_Client::SendFlags, Server_Server::SvPlayers, uint16, VIEW_TYPE_LOCAL, and GPlayer::ViewFlags. Referenced by SendPlayersToClients().
01720 {
01721 GPlayer *Player;
01722 int32 i;
01723
01724 Player = Server->SvPlayers;
01725
01726 for (i=0; i< NETMGR_MAX_PLAYERS; i++, Player++)
01727 {
01728 uint16 SendFlags;
01729 int32 k;
01730 Server_Client *Client;
01731
01732 if (!Player->Active)
01733 continue;
01734
01735 if (Player->ViewFlags & VIEW_TYPE_LOCAL)
01736 continue; // Only on local server, don't send data accros net
01737
01738 if (!Player->Control)
01739 continue;
01740
01741 SendFlags = GetPlayerSendFlags(Server, Player);
01742
01743 Client = Server->Clients;
01744
01745 // Or what needs to be changed about this player into all the clients...
01746 for (k=0; k< NETMGR_MAX_CLIENTS; k++, Client++)
01747 {
01748 if (!Client->Active)
01749 continue;
01750
01751 Client->SendFlags[i] |= SendFlags;
01752 }
01753 }
01754 }
|
|
||||||||||||||||
|
Definition at line 27 of file Server.c.
00028 {
00029 _asm {
00030 mov ebx,dword ptr [start]
00031 mov esi,dword ptr [end]
00032
00033 mov eax,dword ptr [esi+0]
00034 sub eax,dword ptr [ebx+0]
00035
00036 mov edx,dword ptr [esi+4]
00037 sbb edx,dword ptr [ebx+4]
00038
00039 mov ebx,dword ptr [delta]
00040 mov dword ptr [ebx+0],eax
00041 mov dword ptr [ebx+4],edx
00042 }
00043 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1757 of file Server.c. Referenced by SendPlayersToClients(). |
|
|
Definition at line 73 of file Server.c. Referenced by Server_Create(), and Server_ManageBots(). |
|
|
Definition at line 72 of file Server.c. Referenced by GMenu_Create(), GMenu_Key(), Server_Frame(), and WinMain(). |
1.3.2