| | |
| | |
| | typedef Param2<int, string> LogoutInfo; |
| |
|
| | class MissionServer extends MissionBase |
| | { |
| | ref array<Man> m_Players; |
| | ref array<ref CorpseData> m_DeadPlayersArray; |
| | ref map<PlayerBase, ref LogoutInfo> m_LogoutPlayers; |
| | ref map<PlayerBase, ref LogoutInfo> m_NewLogoutPlayers; |
| | ref RainProcurementHandler m_RainProcHandler; |
| | const int SCHEDULER_PLAYERS_PER_TICK = 5; |
| | int m_currentPlayer; |
| | int m_RespawnMode; |
| | |
| | |
| | |
| | |
| | private float m_ArtyBarrageTimer = 0; |
| | |
| | |
| | protected bool m_PlayArty = false; |
| | protected float m_ArtyDelay = 0; |
| | protected int m_MinSimultaneousStrikes = 0; |
| | protected int m_MaxSimultaneousStrikes = 0; |
| | protected ref array<vector> m_FiringPos; |
| | |
| | |
| | protected const ref array<vector> CHERNARUS_STRIKE_POS = |
| | { |
| | "-500.00 165.00 5231.69", |
| | "-500.00 300.00 9934.41", |
| | "10406.86 192.00 15860.00", |
| | "4811.75 370.00 15860.00", |
| | "-500.00 453.00 15860.00" |
| | }; |
| | |
| | |
| | protected const ref array<vector> LIVONIA_STRIKE_POS = |
| | { |
| | "7440.00 417.00 -500.00", |
| | "-500.00 276.00 5473.00", |
| | "-500.00 265.00 9852.00", |
| | "4953.00 240.00 13300.00", |
| | "9620.00 188.00 13300.00", |
| | "13300.00 204.00 10322.00", |
| | "13300.00 288.00 6204.00", |
| | "13300.00 296.00 -500.00" |
| | }; |
| | |
| | |
| | |
| | |
| | PlayerBase m_player; |
| | MissionBase m_mission; |
| | PluginAdditionalInfo m_moduleDefaultCharacter; |
| | |
| | void MissionServer() |
| | { |
| | GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.UpdatePlayersStats, 30000, true); |
| |
|
| | m_DeadPlayersArray = new array<ref CorpseData>; |
| | UpdatePlayersStats(); |
| | m_Players = new array<Man>; |
| | |
| | m_LogoutPlayers = new map<PlayerBase, ref LogoutInfo>; |
| | m_NewLogoutPlayers = new map<PlayerBase, ref LogoutInfo>; |
| | m_RainProcHandler = new RainProcurementHandler(this); |
| | } |
| | |
| | void ~MissionServer() |
| | { |
| | GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Remove(this.UpdatePlayersStats); |
| | } |
| | |
| | override void OnInit() |
| | { |
| | super.OnInit(); |
| | CfgGameplayHandler.LoadData(); |
| | PlayerSpawnHandler.LoadData(); |
| | UndergroundAreaLoader.SpawnAllTriggerCarriers(); |
| | |
| | m_FiringPos = new array<vector>(); |
| | } |
| | |
| | override void OnMissionStart() |
| | { |
| | super.OnMissionStart(); |
| | |
| | |
| | EffectAreaLoader.CreateZones(); |
| | } |
| | |
| | override void OnUpdate(float timeslice) |
| | { |
| | UpdateDummyScheduler(); |
| | TickScheduler(timeslice); |
| | UpdateLogoutPlayers(); |
| | m_WorldData.UpdateBaseEnvTemperature(timeslice); |
| | m_RainProcHandler.Update(timeslice); |
| | |
| | RandomArtillery(timeslice); |
| | |
| | super.OnUpdate(timeslice); |
| | } |
| | |
| | override void OnGameplayDataHandlerLoad() |
| | { |
| | m_RespawnMode = CfgGameplayHandler.GetDisableRespawnDialog(); |
| | GetGame().SetDebugMonitorEnabled(GetGame().ServerConfigGetInt("enableDebugMonitor")); |
| | |
| | InitialiseWorldData(); |
| | } |
| | |
| | |
| | void RandomArtillery(float deltaTime) |
| | { |
| | |
| | if (m_PlayArty) |
| | { |
| | |
| | if (m_ArtyBarrageTimer > m_ArtyDelay) |
| | { |
| | |
| | m_MaxSimultaneousStrikes = Math.Clamp(m_MaxSimultaneousStrikes, 1, m_FiringPos.Count()); |
| | m_MinSimultaneousStrikes = Math.Clamp(m_MinSimultaneousStrikes, 1, m_MaxSimultaneousStrikes); |
| | |
| | |
| | int randPos; |
| | Param1<vector> pos; |
| | array<ref Param> params; |
| | |
| | if (m_MaxSimultaneousStrikes == 1) |
| | { |
| | |
| | randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1); |
| | pos = new Param1<vector>(m_FiringPos[randPos]); |
| | params = new array<ref Param>; |
| | params.Insert(pos); |
| | GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true); |
| | } |
| | else |
| | { |
| | |
| | |
| | |
| | |
| | |
| | array<int> usedIndices = new array<int>; |
| | |
| | |
| | int randFireNb = Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes); |
| | for (int i = 0; i < randFireNb; i++) |
| | { |
| | randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1); |
| | |
| | if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0) |
| | { |
| | |
| | pos = new Param1<vector>(m_FiringPos[randPos]); |
| | params = new array<ref Param>; |
| | |
| | |
| | params.Insert(pos); |
| | GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true); |
| | |
| | |
| | usedIndices.Insert(randPos); |
| | } |
| | } |
| | } |
| | |
| | |
| | m_ArtyBarrageTimer = 0.0; |
| | } |
| | |
| | m_ArtyBarrageTimer += deltaTime; |
| | } |
| | } |
| |
|
| | override bool IsServer() |
| | { |
| | return true; |
| | } |
| | |
| | override bool IsPlayerDisconnecting(Man player) |
| | { |
| | return (m_LogoutPlayers && m_LogoutPlayers.Contains(PlayerBase.Cast(player))) || (m_NewLogoutPlayers && m_NewLogoutPlayers.Contains(PlayerBase.Cast(player))); |
| | } |
| | |
| | void UpdatePlayersStats() |
| | { |
| | PluginLifespan moduleLifespan; |
| | Class.CastTo(moduleLifespan, GetPlugin(PluginLifespan)); |
| | array<Man> players = new array<Man>(); |
| | GetGame().GetPlayers(players); |
| | |
| | foreach (Man man : players) |
| | { |
| | PlayerBase player; |
| | if (Class.CastTo(player, man)) |
| | { |
| | player.StatUpdateByTime(AnalyticsManagerServer.STAT_PLAYTIME); |
| | player.StatUpdateByPosition(AnalyticsManagerServer.STAT_DISTANCE); |
| |
|
| | moduleLifespan.UpdateLifespan(player); |
| | } |
| | } |
| | |
| | UpdateCorpseStatesServer(); |
| | } |
| | |
| | protected void AddNewPlayerLogout(PlayerBase player, notnull LogoutInfo info) |
| | { |
| | m_LogoutPlayers.Insert(player, info); |
| | m_NewLogoutPlayers.Remove(player); |
| | } |
| | |
| | |
| | void UpdateLogoutPlayers() |
| | { |
| | for (int i = 0; i < m_LogoutPlayers.Count();) |
| | { |
| | LogoutInfo info = m_LogoutPlayers.GetElement(i); |
| | |
| | if (GetGame().GetTime() >= info.param1) |
| | { |
| | PlayerIdentity identity; |
| | PlayerBase player = m_LogoutPlayers.GetKey(i); |
| | if (player) |
| | { |
| | identity = player.GetIdentity(); |
| | m_LogoutPlayers.Remove(player); |
| | } |
| | else |
| | { |
| | m_LogoutPlayers.RemoveElement(i); |
| | } |
| | |
| | |
| | |
| | |
| | PlayerDisconnected(player, identity, info.param2); |
| | } |
| | else |
| | { |
| | ++i; |
| | } |
| | } |
| | } |
| | |
| | override void OnEvent(EventType eventTypeId, Param params) |
| | { |
| | PlayerIdentity identity; |
| | PlayerBase player; |
| | int counter = 0; |
| | |
| | switch (eventTypeId) |
| | { |
| | case ClientPrepareEventTypeID: |
| | ClientPrepareEventParams clientPrepareParams; |
| | Class.CastTo(clientPrepareParams, params); |
| | CfgGameplayHandler.SyncDataSendEx(clientPrepareParams.param1); |
| | UndergroundAreaLoader.SyncDataSend(clientPrepareParams.param1); |
| | OnClientPrepareEvent(clientPrepareParams.param1, clientPrepareParams.param2, clientPrepareParams.param3, clientPrepareParams.param4, clientPrepareParams.param5); |
| | break; |
| |
|
| | case ClientNewEventTypeID: |
| | ClientNewEventParams newParams; |
| | Class.CastTo(newParams, params); |
| | player = OnClientNewEvent(newParams.param1, newParams.param2, newParams.param3); |
| | if (!player) |
| | { |
| | Debug.Log("ClientNewEvent: Player is empty"); |
| | return; |
| | } |
| | identity = newParams.param1; |
| | InvokeOnConnect(player,identity); |
| | SyncEvents.SendPlayerList(); |
| | |
| | ControlPersonalLight(player); |
| | SyncGlobalLighting(player); |
| | |
| | break; |
| | |
| | case ClientReadyEventTypeID: |
| | ClientReadyEventParams readyParams; |
| | Class.CastTo(readyParams, params); |
| | identity = readyParams.param1; |
| | Class.CastTo(player, readyParams.param2); |
| | if (!player) |
| | { |
| | Debug.Log("ClientReadyEvent: Player is empty"); |
| | return; |
| | } |
| | |
| | OnClientReadyEvent(identity, player); |
| | InvokeOnConnect(player, identity); |
| | |
| | SyncEvents.SendPlayerList(); |
| | ControlPersonalLight(player); |
| | SyncGlobalLighting(player); |
| | break; |
| | |
| | case ClientRespawnEventTypeID: |
| | ClientRespawnEventParams respawnParams; |
| | Class.CastTo(respawnParams, params); |
| | identity = respawnParams.param1; |
| | Class.CastTo(player, respawnParams.param2); |
| | if (!player) |
| | { |
| | Debug.Log("ClientRespawnEvent: Player is empty"); |
| | return; |
| | } |
| | |
| | OnClientRespawnEvent(identity, player); |
| | break; |
| | |
| | case ClientReconnectEventTypeID: |
| | ClientReconnectEventParams reconnectParams; |
| | Class.CastTo(reconnectParams, params); |
| | |
| | identity = reconnectParams.param1; |
| | Class.CastTo(player, reconnectParams.param2); |
| | if (!player) |
| | { |
| | Debug.Log("ClientReconnectEvent: Player is empty"); |
| | return; |
| | } |
| | |
| | OnClientReconnectEvent(identity, player); |
| | break; |
| | |
| | case ClientDisconnectedEventTypeID: |
| | ClientDisconnectedEventParams discoParams; |
| | Class.CastTo(discoParams, params); |
| | |
| | identity = discoParams.param1; |
| | Class.CastTo(player, discoParams.param2); |
| | int logoutTime = discoParams.param3; |
| | bool authFailed = discoParams.param4; |
| |
|
| | if (!player) |
| | { |
| | Debug.Log("ClientDisconnectenEvent: Player is empty"); |
| | return; |
| | } |
| | |
| | OnClientDisconnectedEvent(identity, player, logoutTime, authFailed); |
| | break; |
| | |
| | case LogoutCancelEventTypeID: |
| | LogoutCancelEventParams logoutCancelParams; |
| | |
| | Class.CastTo(logoutCancelParams, params); |
| | Class.CastTo(player, logoutCancelParams.param1); |
| | identity = player.GetIdentity(); |
| | if (identity) |
| | { |
| | |
| | |
| | Print("[Logout]: Player " + identity.GetId() + " cancelled"); |
| | } |
| | else |
| | { |
| | Print("[Logout]: Player cancelled"); |
| | } |
| | m_LogoutPlayers.Remove(player); |
| | m_NewLogoutPlayers.Remove(player); |
| | break; |
| | } |
| | } |
| | |
| | void InvokeOnConnect(PlayerBase player, PlayerIdentity identity) |
| | { |
| | Debug.Log("InvokeOnConnect:"+this.ToString(),"Connect"); |
| | if (player) |
| | player.OnConnect(); |
| | } |
| |
|
| | void InvokeOnDisconnect(PlayerBase player) |
| | { |
| | Debug.Log("InvokeOnDisconnect:"+this.ToString(),"Connect"); |
| | if (player) |
| | player.OnDisconnect(); |
| | } |
| |
|
| | void OnClientPrepareEvent(PlayerIdentity identity, out bool useDB, out vector pos, out float yaw, out int preloadTimeout) |
| | { |
| | if (GetHive()) |
| | { |
| | |
| | useDB = true; |
| | } |
| | else |
| | { |
| | |
| | useDB = false; |
| | pos = "1189.3 0.0 5392.48"; |
| | yaw = 0; |
| | } |
| | } |
| | |
| | |
| | void ControlPersonalLight(PlayerBase player) |
| | { |
| | if (player) |
| | { |
| | bool is_personal_light = ! GetGame().ServerConfigGetInt("disablePersonalLight"); |
| | Param1<bool> personal_light_toggle = new Param1<bool>(is_personal_light); |
| | GetGame().RPCSingleParam(player, ERPCs.RPC_TOGGLE_PERSONAL_LIGHT, personal_light_toggle, true, player.GetIdentity()); |
| | } |
| | else |
| | { |
| | Error("Error! Player was not initialized at the right time. Thus cannot send RPC command to enable or disable personal light!"); |
| | } |
| | } |
| | |
| | |
| | void SyncGlobalLighting(PlayerBase player) |
| | { |
| | if (player) |
| | { |
| | int lightingID = GetGame().ServerConfigGetInt("lightingConfig"); |
| | Param1<int> lightID = new Param1<int>(lightingID); |
| | GetGame().RPCSingleParam(player, ERPCs.RPC_SEND_LIGHTING_SETUP, lightID, true, player.GetIdentity()); |
| | } |
| | } |
| | |
| | |
| | bool ProcessLoginData(ParamsReadContext ctx) |
| | { |
| | |
| | return GetGame().GetMenuDefaultCharacterData(false).DeserializeCharacterData(ctx); |
| | } |
| | |
| | |
| | PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName) |
| | { |
| | Entity playerEnt; |
| | playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE"); |
| | Class.CastTo(m_player, playerEnt); |
| | |
| | GetGame().SelectPlayer(identity, m_player); |
| | |
| | return m_player; |
| | } |
| | |
| | |
| | void EquipCharacter(MenuDefaultCharacterData char_data) |
| | { |
| | int slot_ID; |
| | string attachment_type; |
| | for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++) |
| | { |
| | slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i); |
| | attachment_type = ""; |
| | if (m_RespawnMode != GameConstants.RESPAWN_MODE_CUSTOM || !char_data.GetAttachmentMap().Find(slot_ID,attachment_type) || !VerifyAttachmentType(slot_ID,attachment_type)) |
| | { |
| | |
| | if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0) |
| | { |
| | attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement(); |
| | } |
| | else |
| | continue; |
| | } |
| | |
| | if (attachment_type != "") |
| | { |
| | m_player.GetInventory().CreateAttachmentEx(attachment_type,slot_ID); |
| | } |
| | } |
| | |
| | StartingEquipSetup(m_player, true); |
| | } |
| | |
| | |
| | void StartingEquipSetup(PlayerBase player, bool clothesChosen) |
| | { |
| | } |
| | |
| | bool VerifyAttachmentType(int slot_ID, string attachment_type) |
| | { |
| | return DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).Find(attachment_type) > -1; |
| | } |
| | |
| | PlayerBase OnClientNewEvent(PlayerIdentity identity, vector pos, ParamsReadContext ctx) |
| | { |
| | string characterType = GetGame().CreateRandomPlayer(); |
| | bool generateRandomEquip = false; |
| | |
| | |
| | if (ProcessLoginData(ctx) && (m_RespawnMode == GameConstants.RESPAWN_MODE_CUSTOM) && !GetGame().GetMenuDefaultCharacterData(false).IsRandomCharacterForced()) |
| | { |
| | if (GetGame().ListAvailableCharacters().Find(GetGame().GetMenuDefaultCharacterData().GetCharacterType()) > -1) |
| | characterType = GetGame().GetMenuDefaultCharacterData().GetCharacterType(); |
| | } |
| | else |
| | { |
| | generateRandomEquip = true; |
| | } |
| | |
| | if (PlayerSpawnHandler.IsInitialized()) |
| | { |
| | PlayerSpawnPreset presetData = PlayerSpawnHandler.GetRandomCharacterPreset(); |
| | if (presetData && presetData.IsValid()) |
| | { |
| | string presetCharType = presetData.GetRandomCharacterType(); |
| | if (presetCharType == string.Empty) |
| | presetCharType = characterType; |
| | if (CreateCharacter(identity, pos, ctx, presetCharType) != null) |
| | { |
| | PlayerSpawnHandler.ProcessEquipmentData(m_player,presetData); |
| | return m_player; |
| | } |
| | else |
| | { |
| | ErrorEx("Failed to create character from type: " + presetCharType + ", using default spawning method"); |
| | } |
| | } |
| | else |
| | { |
| | ErrorEx("Failed to load PlayerSpawnPreset data properly, using default spawning method"); |
| | } |
| | } |
| | |
| | if (CreateCharacter(identity, pos, ctx, characterType)) |
| | { |
| | if (generateRandomEquip) |
| | GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip(); |
| | EquipCharacter(GetGame().GetMenuDefaultCharacterData()); |
| | } |
| | |
| | return m_player; |
| | } |
| | |
| | void OnClientReadyEvent(PlayerIdentity identity, PlayerBase player) |
| | { |
| | GetGame().SelectPlayer(identity, player); |
| | |
| | #ifdef DIAG_DEVELOPER |
| | if (FeatureTimeAccel.m_CurrentTimeAccel) |
| | { |
| | GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity); |
| | } |
| | #endif |
| | } |
| | |
| | void OnClientRespawnEvent(PlayerIdentity identity, PlayerBase player) |
| | { |
| | if (player) |
| | { |
| | if (player.IsUnconscious() || player.IsRestrained()) |
| | { |
| | |
| | player.SetHealth("", "", 0.0); |
| | } |
| | } |
| | |
| | #ifdef DIAG_DEVELOPER |
| | if (FeatureTimeAccel.m_CurrentTimeAccel) |
| | { |
| | GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity); |
| | } |
| | #endif |
| | } |
| | |
| | void OnClientReconnectEvent(PlayerIdentity identity, PlayerBase player) |
| | { |
| | if (player) |
| | { |
| | player.OnReconnect(); |
| | } |
| | } |
| | |
| | void OnClientDisconnectedEvent(PlayerIdentity identity, PlayerBase player, int logoutTime, bool authFailed) |
| | { |
| | bool disconnectNow = true; |
| | |
| | |
| | |
| | if (GetHive() && !authFailed) |
| | { |
| | if (player.IsAlive()) |
| | { |
| | if (!m_LogoutPlayers.Contains(player) && !m_NewLogoutPlayers.Contains(player)) |
| | { |
| | Print("[Logout]: New player " + identity.GetId() + " with logout time " + logoutTime.ToString()); |
| | |
| | |
| | player.StatSyncToClient(); |
| | |
| | |
| | GetGame().SendLogoutTime(player, logoutTime); |
| | |
| | |
| | LogoutInfo params = new LogoutInfo(GetGame().GetTime() + logoutTime * 1000, identity.GetId()); |
| | |
| | m_NewLogoutPlayers.Insert(player, params); |
| | GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AddNewPlayerLogout, 0, false, player, params); |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | disconnectNow = false; |
| | } |
| | return; |
| | } |
| | } |
| | |
| | if (disconnectNow) |
| | { |
| | Print("[Logout]: New player " + identity.GetId() + " with instant logout"); |
| | |
| | |
| | GetGame().SendLogoutTime(player, 0); |
| | |
| | PlayerDisconnected(player, identity, identity.GetId()); |
| | } |
| | } |
| |
|
| | void PlayerDisconnected(PlayerBase player, PlayerIdentity identity, string uid) |
| | { |
| | |
| | if (!player) |
| | { |
| | Print("[Logout]: Skipping player " + uid + ", already removed"); |
| | return; |
| | } |
| | |
| | |
| | |
| |
|
| | |
| | InvokeOnDisconnect(player); |
| |
|
| | Print("[Logout]: Player " + uid + " finished"); |
| |
|
| | if (GetHive()) |
| | { |
| | |
| | player.Save(); |
| | |
| | |
| | GetHive().CharacterExit(player); |
| | } |
| | |
| | |
| | player.ReleaseNetworkControls(); |
| | HandleBody(player); |
| | |
| | |
| | GetGame().DisconnectPlayer(identity, uid); |
| | |
| | GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SyncEvents.SendPlayerList, 1000); |
| | } |
| | |
| | bool ShouldPlayerBeKilled(PlayerBase player) |
| | { |
| | if (player.IsUnconscious() || player.IsRestrained()) |
| | { |
| | switch (player.GetKickOffReason()) |
| | { |
| | case EClientKicked.SERVER_EXIT: |
| | return false; |
| | case EClientKicked.KICK_ALL_ADMIN: |
| | return false; |
| | case EClientKicked.KICK_ALL_SERVER: |
| | return false; |
| | case EClientKicked.SERVER_SHUTDOWN: |
| | return false; |
| | default: |
| | return true; |
| | } |
| | } |
| | |
| | return false; |
| | } |
| | |
| | void HandleBody(PlayerBase player) |
| | { |
| | if (player.IsAlive()) |
| | { |
| | if (ShouldPlayerBeKilled(player)) |
| | { |
| | player.SetHealth("", "", 0.0); |
| | } |
| | else |
| | { |
| | player.Delete(); |
| | } |
| | } |
| | } |
| | |
| | void TickScheduler(float timeslice) |
| | { |
| | GetGame().GetWorld().GetPlayerList(m_Players); |
| | int players_count = m_Players.Count(); |
| | int tick_count_max = Math.Min(players_count, SCHEDULER_PLAYERS_PER_TICK); |
| | |
| | for (int i = 0; i < tick_count_max; i++) |
| | { |
| | if (m_currentPlayer >= players_count) |
| | { |
| | m_currentPlayer = 0; |
| | } |
| | |
| | PlayerBase currentPlayer = PlayerBase.Cast(m_Players.Get(m_currentPlayer)); |
| | |
| | if (currentPlayer) |
| | currentPlayer.OnTick(); |
| | m_currentPlayer++; |
| | } |
| | } |
| | |
| | |
| | override bool InsertCorpse(Man player) |
| | { |
| | CorpseData corpse_data = new CorpseData(PlayerBase.Cast(player),GetGame().GetTime()); |
| | return m_DeadPlayersArray.Insert(corpse_data) >= 0; |
| | } |
| | |
| | void UpdateCorpseStatesServer() |
| | { |
| | if (m_DeadPlayersArray.Count() == 0) |
| | return; |
| | int current_time = GetGame().GetTime(); |
| | array<int> invalid_corpses = new array<int>; |
| | CorpseData corpse_data; |
| | |
| | for (int i = 0; i < m_DeadPlayersArray.Count(); i++) |
| | { |
| | corpse_data = m_DeadPlayersArray.Get(i); |
| | if (!corpse_data || (corpse_data && (!corpse_data.m_Player || !corpse_data.m_bUpdate))) |
| | { |
| | invalid_corpses.Insert(i); |
| | } |
| | else if (corpse_data.m_bUpdate && current_time - corpse_data.m_iLastUpdateTime >= 30000) |
| | { |
| | corpse_data.UpdateCorpseState(); |
| | corpse_data.m_iLastUpdateTime = current_time; |
| | } |
| | } |
| | |
| | |
| | if (invalid_corpses.Count() > 0) |
| | { |
| | for (i = invalid_corpses.Count() - 1; i > -1; i--) |
| | { |
| | m_DeadPlayersArray.Remove(invalid_corpses.Get(i)); |
| | } |
| | } |
| | } |
| | |
| | |
| | override void SyncRespawnModeInfo(PlayerIdentity identity) |
| | { |
| | ScriptRPC rpc = new ScriptRPC(); |
| | rpc.Write(m_RespawnMode); |
| | rpc.Send(null, ERPCs.RPC_SERVER_RESPAWN_MODE, true, identity); |
| | } |
| | |
| | override RainProcurementHandler GetRainProcurementHandler() |
| | { |
| | return m_RainProcHandler; |
| | } |
| | } |
| |
|
| |
|