Changeset 345 for binary-improvements/7dtd-server-fixes
- Timestamp:
- Jan 5, 2019, 3:21:40 PM (6 years ago)
- Location:
- binary-improvements/7dtd-server-fixes
- Files:
-
- 4 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj
r330 r345 39 39 <DefineConstants>ENABLE_PROFILER</DefineConstants> 40 40 <Optimize>true</Optimize> 41 <WarningLevel>4</WarningLevel> 41 42 </PropertyGroup> 42 43 <ItemGroup> … … 76 77 <ItemGroup> 77 78 <Compile Include="src\AssemblyInfo.cs" /> 78 <Compile Include="src\AllocsLogFunctions.cs" />79 79 <Compile Include="src\LiveData\Animals.cs" /> 80 80 <Compile Include="src\LiveData\Hostiles.cs" /> 81 <Compile Include="src\PlayerDataStuff.cs" />82 81 <Compile Include="src\PersistentData\PersistentContainer.cs" /> 83 <Compile Include="src\StateManager.cs" />84 82 <Compile Include="src\PersistentData\InvItem.cs" /> 85 83 <Compile Include="src\PersistentData\Inventory.cs" /> … … 101 99 <Compile Include="src\FileCache\MapTileCache.cs" /> 102 100 <Compile Include="src\API.cs" /> 103 <Compile Include="src\ChatHookExample.cs" />104 101 <Compile Include="src\AllocsUtils.cs" /> 105 102 <Compile Include="src\LandClaimList.cs" /> -
binary-improvements/7dtd-server-fixes/ModInfo.xml
r341 r345 5 5 <Description value="Common functions" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 0" />7 <Version value="21" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/7dtd-server-fixes/src/API.cs
r337 r345 1 1 using System.Collections.Generic; 2 using AllocsFixes.PersistentData; 3 using System; 2 4 3 5 namespace AllocsFixes { … … 9 11 ModEvents.PlayerSpawning.RegisterHandler (PlayerSpawning); 10 12 ModEvents.PlayerDisconnected.RegisterHandler (PlayerDisconnected); 13 ModEvents.PlayerSpawnedInWorld.RegisterHandler (PlayerSpawned); 11 14 ModEvents.ChatMessage.RegisterHandler (ChatMessage); 12 15 } 13 16 14 17 public void GameAwake () { 15 StateManager.Awake (); 18 try { 19 PersistentContainer.Load (); 20 } catch (Exception e) { 21 Log.Out ("Error in StateManager.Awake: " + e); 22 } 16 23 } 17 24 18 25 public void GameShutdown () { 19 StateManager.Shutdown (); 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 } 20 32 } 21 33 22 34 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 23 PlayerDataStuff.GM_SavePlayerData (_cInfo, _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 } 24 40 } 25 41 26 42 public void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { 27 AllocsLogFunctions.RequestToSpawnPlayer (_cInfo, _chunkViewDim, _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); 53 } 28 54 } 29 55 30 56 public void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) { 31 AllocsLogFunctions.PlayerDisconnected (_cInfo, _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 } 64 65 PersistentContainer.Instance.Save (); 66 } catch (Exception e) { 67 Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e); 68 } 32 69 } 70 71 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 } 78 } 79 80 private const string ANSWER = 81 " [ff0000]I[-] [ff7f00]W[-][ffff00]A[-][80ff00]S[-] [00ffff]H[-][0080ff]E[-][0000ff]R[-][8b00ff]E[-]"; 33 82 34 83 public bool ChatMessage (ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName, 35 84 bool _localizeMain, List<int> _recipientEntityIds) { 36 return ChatHookExample.Hook (_cInfo, _type, _msg, _mainName); 85 if (string.IsNullOrEmpty (_msg) || !_msg.EqualsCaseInsensitive ("/alloc")) { 86 return true; 87 } 88 89 if (_cInfo != null) { 90 Log.Out ("Sent chat hook reply to {0}", _cInfo.playerId); 91 _cInfo.SendPackage (new NetPackageChat (EChatType.Whisper, -1, ANSWER, "", false, null)); 92 } else { 93 Log.Error ("ChatHookExample: Argument _cInfo null on message: {0}", _msg); 94 } 95 96 return false; 37 97 } 38 98 }
Note:
See TracChangeset
for help on using the changeset viewer.