- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/CommonMappingFunctions.cs
r213 r211 20 20 public static string GetPlayerName (ClientInfo _ci) 21 21 { 22 return _ci.playerName; 22 try { 23 int entityId = GetConnectionManager ().mapClientToEntity [_ci.clientId]; 24 return GetGameManager ().World.playerEntities.dict [entityId].EntityName; 25 } catch (Exception e) { 26 Log.Out ("Error getting player name for ClientInfo: " + e); 27 } 28 return null; 23 29 } 24 30 25 31 public static EntityPlayer GetEntityPlayer (ClientInfo _ci) 26 32 { 27 return GetGameManager ().World.playerEntities.dict [_ci.entityId]; 33 try { 34 int entityId = GetConnectionManager ().mapClientToEntity [_ci.clientId]; 35 return GetGameManager ().World.playerEntities.dict [entityId]; 36 } catch (Exception e) { 37 Log.Out ("Error getting entity player for ClientInfo: " + e); 38 } 39 return null; 28 40 } 29 41 30 42 public static string GetSteamID (ClientInfo _ci) 31 43 { 32 return _ci.playerId; 44 return Steam.Authentication.Server.GetPlayerId (GetPlayerName (_ci)); 45 } 46 47 public static string GetSteamID (string _playerName) 48 { 49 return Steam.Authentication.Server.GetPlayerId (_playerName); 33 50 } 34 51 35 52 public static int GetClientID (ClientInfo _ci) 36 53 { 37 return _ci.clientId; 54 if (_ci != null) { 55 if (GetConnectionManager ().connectedClients.ContainsKey (_ci.clientId)) 56 return _ci.clientId; 57 } 58 return -1; 38 59 } 39 60 40 61 public static int GetEntityID (ClientInfo _ci) 41 62 { 42 return _ci.entityId; 63 try { 64 ConnectionManager cm = GetConnectionManager (); 65 66 if (cm.mapClientToEntity.ContainsKey (_ci.clientId)) 67 return cm.mapClientToEntity [_ci.clientId]; 68 else 69 return -1; 70 } catch (Exception e) { 71 Log.Out ("Error getting entity ID for ClientInfo: " + e); 72 } 73 return -1; 43 74 } 44 75 … … 48 79 ConnectionManager cm = GetConnectionManager (); 49 80 50 return cm.GetClientInfoForEntityId (_entityId); 81 if (cm.mapClientToEntity.ContainsValue (_entityId)) { 82 foreach (KeyValuePair<int, int> kvp in cm.mapClientToEntity) { 83 if (kvp.Value == _entityId) { 84 return cm.connectedClients [kvp.Key]; 85 } 86 } 87 } 88 89 return null; 51 90 } catch (Exception e) { 52 91 Log.Out ("Error getting ClientInfo for entity ID: " + e); … … 118 157 public static ClientInfo GetClientInfoFromSteamID (string _steamId) 119 158 { 120 return GetConnectionManager ().GetClientInfoForPlayerId (_steamId); 159 try { 160 foreach (string name in Steam.Authentication.Server.usersToIDs.Keys) { 161 string curId = string.Empty + Steam.Authentication.Server.usersToIDs[name].steamID.m_SteamID; 162 if (curId.Equals (_steamId)) { 163 return GetClientInfoFromPlayerName (name, false); 164 } 165 } 166 } catch (Exception e) { 167 Log.Out ("Error getting ClientInfo for steam ID: " + e); 168 } 169 return null; 121 170 } 122 171
Note:
See TracChangeset
for help on using the changeset viewer.