source: binary-improvements/7dtd-server-fixes/src/AllocsLogFunctions.cs@ 226

Last change on this file since 226 was 224, checked in by alloc, 10 years ago

A11 preps

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