#include <Windows.h>#include "Genesis.h"#include "Errorlog.h"#include "Ram.h"#include "Game\Game.h"#include "Game\GPlayer.h"#include "Game\GenVSI.h"#include "Client.h"#include "GameMgr.h"#include "NetMgr.h"#include "Buffer.h"Go to the source code of this file.
|
|
Definition at line 43 of file Server.h. Referenced by Server_CreatePlayer(), and Server_SetClassSpawn(). |
|
|
Definition at line 42 of file Server.h. Referenced by Server_SetClassSpawn(). |
|
|
Definition at line 45 of file Server.h. Referenced by Server_ProcIndex(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
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 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, geCSNetMgr_NetClient::Name, Server_Client::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 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 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 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 434 of file Server.c. References GameMgr_SoundIndex::Active, GameMgr_TextureIndex::Active, GameMgr_BoneIndex::Active, GameMgr_MotionIndexDef::Active, GameMgr_ActorIndex::Active, Server_Client::Active, GameMgr_TextureIndex::AFileName, GameMgr_BoneIndex::BoneName, Buffer_FillByte(), Buffer_FillSLong(), Buffer_FillString(), Buffer_Set(), GameMgr_SoundIndex::FileName, GameMgr_TextureIndex::FileName, GameMgr_ActorIndex::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 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 983 of file Server.c. References Server_Client::Active, GPlayer::ClassData, Server_Server::ClassSpawns, Server_Server::Clients, Server_CSpawn::DFunc, GPlayer::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 }
|
|
|
|
1.3.2