Changeset 76
- Timestamp:
- Jul 17, 2014, 1:46:42 AM (10 years ago)
- Location:
- binary-improvements
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/AllocsRequestToSpawnPlayer.cs
r75 r76 1 1 using System; 2 using System.Collections.Generic; 2 3 3 4 public class AllocsRequestToSpawnPlayer … … 6 7 { 7 8 string ip = manager.connectionManager.connectedClients [_clientId].networkPlayer.ipAddress; 8 Log.Out ("Player connected, clientid=" + _clientId + ", ip=" + ip); 9 string name = string.Empty; 10 int entityId = -1; 11 Dictionary<int,int> d = manager.connectionManager.mapClientToEntity; 12 if (d.ContainsKey (_clientId)) { 13 entityId = d [_clientId]; 14 World w = manager.World; 15 name = w.playerEntities.dict [entityId].EntityName; 16 } 17 18 Log.Out ("Player connected, clientid=" + _clientId + 19 ", entityid=" + entityId + 20 ", name=" + name + 21 ", steamid=" + SingletonMonoBehaviour<Authenticator>.Instance.GetPlayerId (name) + 22 ", ip=" + ip); 9 23 } 10 24 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/ListPlayersExtended.cs
r75 r76 22 22 foreach (KeyValuePair<int, EntityPlayer> current in w.playerEntities.dict) 23 23 { 24 int clientId = -1; 25 Dictionary<int,int> d = this.m_Console.gameManager.connectionManager.mapClientToEntity; 26 foreach (KeyValuePair<int, int> mapping in d) { 27 if (mapping.Value == current.Value.fd0087) { 28 clientId = mapping.Key; 29 } 30 } 31 string ip = string.Empty; 32 if (clientId >= 0) { 33 ip = this.m_Console.gameManager.connectionManager.connectedClients [clientId].networkPlayer.ipAddress; 34 } 24 35 m_Console.md000a (string.Concat (new object[] 25 36 { … … 46 57 ", score=", 47 58 current.Value.Score, 48 ", ", 49 SingletonMonoBehaviour<Authenticator>.Instance.GetPlayerId (current.Value.EntityName) 59 ", steamid=", 60 SingletonMonoBehaviour<Authenticator>.Instance.GetPlayerId (current.Value.EntityName), 61 ", ip=", 62 ip 50 63 })); 51 64 } -
binary-improvements/assembly-patcher/Main.cs
r75 r76 12 12 ModuleDefinition module = ModuleDefinition.ReadModule ("Assembly-CSharp.dll"); 13 13 telnetPatch (module); 14 connectLogPatch (module);14 connectLogPatch (module); 15 15 module.Write ("Assembly-CSharp.dll"); 16 16 Console.WriteLine ("Done"); … … 26 26 27 27 markTypePatched (module, type); 28 addHook (type, "RequestToSpawnPlayer", true, 5, t ypeof(AllocsRequestToSpawnPlayer).GetMethod ("RequestToSpawnPlayer"));28 addHook (type, "RequestToSpawnPlayer", true, 5, true, typeof(AllocsRequestToSpawnPlayer).GetMethod ("RequestToSpawnPlayer")); 29 29 } 30 30 … … 49 49 } 50 50 51 private static void addHook (TypeDefinition type, string methodName, bool addThisRef, int opCount, MethodBase targetMethod)51 private static void addHook (TypeDefinition type, string methodName, bool addThisRef, int opCount, bool atEnd, MethodBase targetMethod) 52 52 { 53 53 foreach (MethodDefinition method in type.Methods) { … … 56 56 var il = method.Body.GetILProcessor (); 57 57 var call = il.Create (OpCodes.Call, method.Module.Import (targetMethod)); 58 var i = 0; 59 if (addThisRef) 60 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, 0)); 61 for (int op = 0; op < opCount; op++) { 62 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, op + 1)); 58 if (atEnd) { 59 int insBefore = method.Body.Instructions.Count; 60 if (addThisRef) 61 il.Append (il.Create (OpCodes.Ldarg, 0)); 62 for (int op = 0; op < opCount; op++) { 63 il.Append (il.Create (OpCodes.Ldarg, op + 1)); 64 } 65 il.Append (call); 66 il.Remove (method.Body.Instructions [insBefore - 1]); 67 il.Append (il.Create (OpCodes.Ret)); 68 } else { 69 var i = 0; 70 if (addThisRef) 71 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, 0)); 72 for (int op = 0; op < opCount; op++) { 73 il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, op + 1)); 74 } 75 il.InsertBefore (method.Body.Instructions [i++], call); 63 76 } 64 il.InsertBefore (method.Body.Instructions [i++], call);65 77 } 66 78 }
Note:
See TracChangeset
for help on using the changeset viewer.