Changeset 369 for binary-improvements/7dtd-server-fixes/src/API.cs
- Timestamp:
- Nov 9, 2021, 6:28:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/API.cs
r354 r369 1 1 using System.Collections.Generic; 2 2 using AllocsFixes.PersistentData; 3 using System;3 using Platform.Steam; 4 4 5 5 namespace AllocsFixes { 6 6 public class API : IModApi { 7 public void InitMod ( ) {7 public void InitMod (Mod _modInstance) { 8 8 ModEvents.GameStartDone.RegisterHandler (GameAwake); 9 9 ModEvents.GameShutdown.RegisterHandler (GameShutdown); … … 16 16 17 17 public void GameAwake () { 18 try { 19 PersistentContainer.Load (); 20 } catch (Exception e) { 21 Log.Out ("Error in StateManager.Awake: " + e); 22 } 18 PersistentContainer.Load (); 23 19 } 24 20 25 21 public void GameShutdown () { 26 try {27 Log.Out ("Server shutting down!");28 PersistentContainer.Instance.Save ();29 } catch (Exception e) {30 Log.Out ("Error in StateManager.Shutdown: " + e);31 }32 22 } 33 23 34 24 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 35 try { 36 PersistentContainer.Instance.Players [_cInfo.playerId, true].Update (_playerDataFile); 37 } catch (Exception e) { 38 Log.Out ("Error in GM_SavePlayerData: " + e); 39 } 25 PersistentContainer.Instance.Players [_cInfo.PlatformId, true].Update (_playerDataFile); 40 26 } 41 27 42 28 public void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { 43 try { 44 Log.Out ("Player connected" + 45 ", entityid=" + _cInfo.entityId + 46 ", name=" + _cInfo.playerName + 47 ", steamid=" + _cInfo.playerId + 48 ", steamOwner=" + _cInfo.ownerId + 49 ", ip=" + _cInfo.ip 50 ); 51 } catch (Exception e) { 52 Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e); 29 string owner = null; 30 if (_cInfo.PlatformId is UserIdentifierSteam identifierSteam) { 31 owner = identifierSteam.OwnerId.ToString (); 53 32 } 33 34 Log.Out ("Player connected" + 35 ", entityid=" + _cInfo.entityId + 36 ", name=" + _cInfo.playerName + 37 ", pltfmid=" + (_cInfo.PlatformId?.CombinedString ?? "<unknown>") + 38 ", crossid=" + (_cInfo.CrossplatformId?.CombinedString ?? "<unknown/none>") + 39 ", steamOwner=" + (owner ?? "<unknown/none>") + 40 ", ip=" + _cInfo.ip 41 ); 54 42 } 55 43 56 44 public void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) { 57 try { 58 Player p = PersistentContainer.Instance.Players [_cInfo.playerId, false]; 59 if (p != null) { 60 p.SetOffline (); 61 } else { 62 Log.Out ("Disconnected player not found in client list..."); 63 } 45 Player p = PersistentContainer.Instance.Players [_cInfo.PlatformId, false]; 46 if (p != null) { 47 p.SetOffline (); 48 } else { 49 Log.Out ("Disconnected player not found in client list..."); 50 } 64 51 65 PersistentContainer.Instance.Save (); 66 } catch (Exception e) { 67 Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e); 68 } 52 PersistentContainer.Instance.Save (); 69 53 } 70 54 71 55 public void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) { 72 try { 73 PersistentContainer.Instance.Players [_cInfo.playerId, true].SetOnline (_cInfo); 74 PersistentContainer.Instance.Save (); 75 } catch (Exception e) { 76 Log.Out ("Error in AllocsLogFunctions.PlayerSpawnedInWorld: " + e); 77 } 56 PersistentContainer.Instance.Players [_cInfo.PlatformId, true].SetOnline (_cInfo); 57 PersistentContainer.Instance.Save (); 78 58 } 79 59 … … 88 68 89 69 if (_cInfo != null) { 90 Log.Out ("Sent chat hook reply to {0}", _cInfo. playerId);70 Log.Out ("Sent chat hook reply to {0}", _cInfo.InternalId); 91 71 _cInfo.SendPackage (NetPackageManager.GetPackage<NetPackageChat> ().Setup (EChatType.Whisper, -1, ANSWER, "", false, null)); 92 72 } else {
Note:
See TracChangeset
for help on using the changeset viewer.