Changeset 84 for binary-improvements


Ignore:
Timestamp:
Jul 19, 2014, 12:47:32 PM (5 years ago)
Author:
alloc
Message:

fixes

Location:
binary-improvements
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj

    r83 r84  
    3131    <Reference Include="System" />
    3232    <Reference Include="Assembly-CSharp">
    33       <HintPath>..\NamePatcher\bin\Release\Assembly-CSharp.dll</HintPath>
     33      <HintPath>..\assembly-patcher\bin\Release\Assembly-CSharp.dll</HintPath>
    3434    </Reference>
    3535    <Reference Include="UnityEngine">
     
    4646    <Compile Include="src\TelnetCommands\SayToPlayer.cs" />
    4747    <Compile Include="src\AllocsLogFunctions.cs" />
     48    <Compile Include="src\TelnetCommands\SetTimeReal.cs" />
     49    <Compile Include="src\AdminToolsStuff.cs" />
    4850  </ItemGroup>
    4951  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs

    r83 r84  
    137137                console.AddCommand(new ListPlayersExtended(console));
    138138                console.AddCommand(new SayToPlayer(console));
     139                console.AddCommand(new SetTimeReal(console));
    139140        }
    140141
  • binary-improvements/7dtd-server-fixes/src/TelnetCommands/GetTime.cs

    r77 r84  
    2626                        hour -= 24;
    2727                }
    28                 int sec = (int)(time % 1000) * 60 / 1000;
    29                 m_Console.md000a (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, sec));
     28                int min = (int)(time % 1000) * 60 / 1000;
     29                m_Console.md000a (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));
    3030        }
    3131}
  • binary-improvements/NamePatcher/NamePatcher.cs

    r83 r84  
    5858                static void applyManualPatches (ModuleDefinition mainModule)
    5959                {
     60                        foreach (FieldDefinition fd in mainModule.GetType ("AdminTools").Fields) {
     61                                TypeReference fdType = fd.FieldType;
     62                                if (fdType.FullName.Contains ("List") && fdType.FullName.Contains ("AdminToolsCommandPermissions")) {
     63                                        Console.WriteLine ("Renaming and making public admin tools field -> commandPermissions");
     64                                        fd.Attributes = fd.Attributes & (~Mono.Cecil.FieldAttributes.Private) | Mono.Cecil.FieldAttributes.Public;
     65                                        NameNormalizer.setName (fd, "commandPermissions");
     66                                }
     67                        }
     68
    6069                        foreach (FieldDefinition fd in mainModule.GetType ("World").Fields) {
    6170                                TypeReference fdType = fd.FieldType;
  • binary-improvements/NamePatcher/NamePatcher.userprefs

    r77 r84  
    33  <MonoDevelop.Ide.Workbench ActiveDocument="NamePatcher.cs">
    44    <Files>
    5       <File FileName="NamePatcher.cs" Line="165" Column="120" />
     5      <File FileName="NamePatcher.cs" Line="109" Column="57" />
    66      <File FileName="NameNormalizer.cs" Line="188" Column="1" />
    77    </Files>
  • binary-improvements/assembly-patcher/Assembly-Patcher.userprefs

    r83 r84  
    33  <MonoDevelop.Ide.Workbench ActiveDocument="Main.cs">
    44    <Files>
    5       <File FileName="Main.cs" Line="48" Column="3" />
     5      <File FileName="Main.cs" Line="29" Column="54" />
    66      <File FileName="AssemblyInfo.cs" Line="21" Column="1" />
    77    </Files>
     8    <Pads>
     9      <Pad Id="ProjectPad">
     10        <State expanded="True">
     11          <Node name="Assembly-Patcher" expanded="True">
     12            <Node name="References" expanded="True">
     13              <Node name="/home/ci/Schreibtisch/7dtd-svn/binary-improvements/7dtd-server-fixes/bin/Release/7dtd-server-fixes.dll" selected="True" />
     14            </Node>
     15          </Node>
     16        </State>
     17      </Pad>
     18    </Pads>
    819  </MonoDevelop.Ide.Workbench>
    920  <MonoDevelop.Ide.DebuggingService.Breakpoints>
  • binary-improvements/assembly-patcher/Main.cs

    r83 r84  
    1414                        connectLogPatch (module);
    1515                        executionLogPatch( module);
     16                        publicCommandPermissionsPatch (module);
    1617                        module.Write ("Assembly-CSharp.dll");
    1718                        Console.WriteLine ("Done");
     19                }
     20
     21                private static void publicCommandPermissionsPatch (ModuleDefinition module)
     22                {
     23                        TypeDefinition type = module.GetType ("AdminTools");
     24
     25                        if (isPatched (type)) {
     26                                return;
     27                        }
     28
     29                        markTypePatched (module, type);
     30                        replaceMethod (type, "GetAllowedCommandsList", true, 1, typeof(AdminToolsStuff).GetMethod ("GetAllowedCommandsList"));
    1831                }
    1932
     
    5164
    5265                        markTypePatched (module, type);
    53                         replaceMethod (type, ".ctor", 1, typeof(AllocsNetTelnetServer).GetMethod ("init"));
    54                         replaceMethod (type, "Disconnect", 0, typeof(AllocsNetTelnetServer).GetMethod ("Disconnect"));
    55                         replaceMethod (type, "SetConsole", 1, typeof(AllocsNetTelnetServer).GetMethod ("SetConsole"));
    56                         replaceMethod (type, "WriteToClient", 1, typeof(AllocsNetTelnetServer).GetMethod ("WriteToClient"));
     66                        replaceMethod (type, ".ctor", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("init"));
     67                        replaceMethod (type, "Disconnect", false, 0, typeof(AllocsNetTelnetServer).GetMethod ("Disconnect"));
     68                        replaceMethod (type, "SetConsole", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("SetConsole"));
     69                        replaceMethod (type, "WriteToClient", false, 1, typeof(AllocsNetTelnetServer).GetMethod ("WriteToClient"));
    5770                }
    5871
     
    92105                }
    93106
    94                 private static void replaceMethod (TypeDefinition type, string methodName, int opCount, MethodBase targetMethod)
     107                private static void replaceMethod (TypeDefinition type, string methodName, bool addThisRef, int opCount, MethodBase targetMethod)
    95108                {
    96109                        foreach (MethodDefinition method in type.Methods) {
     
    100113                                        var call = il.Create (OpCodes.Call, method.Module.Import (targetMethod));
    101114                                        var i = 0;
     115                                        if (addThisRef)
     116                                                il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, 0));
    102117                                        for (int op = 0; op < opCount; op++) {
    103118                                                il.InsertBefore (method.Body.Instructions [i++], il.Create (OpCodes.Ldarg, op + 1));
Note: See TracChangeset for help on using the changeset viewer.