[144] | 1 | using AllocsFixes.PersistentData;
|
---|
[83] | 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using UnityEngine;
|
---|
| 5 |
|
---|
[130] | 6 | namespace AllocsFixes
|
---|
[83] | 7 | {
|
---|
[130] | 8 | public class AllocsLogFunctions
|
---|
[83] | 9 | {
|
---|
[203] | 10 | public static void RequestToSpawnPlayer (GameManager manager, int _clientId, string _name, int _chunkViewDim, PlayerProfile _playerProfile)
|
---|
[130] | 11 | {
|
---|
| 12 | try {
|
---|
| 13 | ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId);
|
---|
| 14 | int entityId = CommonMappingFunctions.GetEntityID (ci);
|
---|
| 15 | EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci);
|
---|
[144] | 16 | string steamId = CommonMappingFunctions.GetSteamID (ci);
|
---|
[103] | 17 |
|
---|
[130] | 18 | string ip = ci.networkPlayer.ipAddress;
|
---|
| 19 | string name = string.Empty;
|
---|
[103] | 20 |
|
---|
[130] | 21 | if (ep != null)
|
---|
| 22 | name = ep.EntityName;
|
---|
[103] | 23 |
|
---|
[130] | 24 | Log.Out ("Player connected, clientid=" + _clientId +
|
---|
| 25 | ", entityid=" + entityId +
|
---|
| 26 | ", name=" + name +
|
---|
[144] | 27 | ", steamid=" + steamId +
|
---|
[130] | 28 | ", ip=" + ip
|
---|
| 29 | );
|
---|
[144] | 30 |
|
---|
[159] | 31 | PersistentContainer.Instance.Players [steamId].SetOnline (ci);
|
---|
[146] | 32 | PersistentData.PersistentContainer.Instance.Save ();
|
---|
[224] | 33 |
|
---|
| 34 | Mods.CallRequestToSpawnPlayer (_clientId, _name, _chunkViewDim, _playerProfile);
|
---|
[130] | 35 | } catch (Exception e) {
|
---|
[144] | 36 | Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e);
|
---|
[130] | 37 | }
|
---|
[83] | 38 | }
|
---|
[144] | 39 |
|
---|
[224] | 40 | public static void PlayerDisconnected (ConnectionManager manager, ClientInfo _cInfo, bool _bShutdown)
|
---|
[159] | 41 | {
|
---|
[144] | 42 | try {
|
---|
[224] | 43 | Player p = PersistentContainer.Instance.Players [_cInfo.playerId];
|
---|
[156] | 44 | if (p != null) {
|
---|
[159] | 45 | p.SetOffline ();
|
---|
[198] | 46 | } else {
|
---|
| 47 | Log.Out ("Disconnected player not found in client list...");
|
---|
[156] | 48 | }
|
---|
[146] | 49 | PersistentData.PersistentContainer.Instance.Save ();
|
---|
[224] | 50 |
|
---|
| 51 | Mods.CallPlayerDisconnected (_cInfo, _bShutdown);
|
---|
[144] | 52 | } catch (Exception e) {
|
---|
| 53 | Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e);
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
[83] | 56 | }
|
---|
| 57 | }
|
---|