Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: Rust.Steam.Server
  3. // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: A19F68F2-120B-446D-8122-2A833E59C2DD
  5. // Assembly location: C:\Users\luke\Desktop\oxide2\rust_server_Data\Managed\Assembly-CSharp.dll
  6.  
  7. using Oxide.Core;
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using UnityEngine;
  11.  
  12. namespace Rust.Steam
  13. {
  14. public static class Server
  15. {
  16. public static GCHandle UserAuthGC;
  17. public static GCHandle UserGroupGC;
  18. public static bool Modded;
  19. public static bool Official;
  20. public static ulong SteamID;
  21. public static uint IPAddress;
  22. public static ulong SteamGroup;
  23.  
  24. public static void Init()
  25. {
  26. if (!Server.Steam_ServerStartup(NetCull.listenPort, 1069))
  27. {
  28. Application.Quit();
  29. }
  30. else
  31. {
  32. Server.funcUserAuth fnc1 = new Server.funcUserAuth(Server.OnUserAuth);
  33. Server.UserAuthGC = GCHandle.Alloc((object) fnc1);
  34. Server.SteamServer_SetCallback_UserAuth(fnc1);
  35. Server.funcUserGroup fnc2 = new Server.funcUserGroup(Server.OnUserGroup);
  36. Server.UserGroupGC = GCHandle.Alloc((object) fnc2);
  37. Server.SteamServer_SetCallback_UserGroup(fnc2);
  38. Server.SteamID = Server.SteamServer_GetSteamID();
  39. Server.IPAddress = Server.SteamServer_GetPublicIP();
  40. }
  41. }
  42.  
  43. public static void Shutdown()
  44. {
  45. Server.Steam_ServerShutdown();
  46. }
  47.  
  48. public static void OnUserAuth(ulong iUserID, [MarshalAs(UnmanagedType.LPStr), In] string strStatus)
  49. {
  50. ConnectionAcceptor.OnSteamAuthorization(iUserID, strStatus);
  51. }
  52.  
  53. public static void OnUserGroup(ulong iUserID, ulong iGroupID, [MarshalAs(UnmanagedType.LPStr), In] string strStatus)
  54. {
  55. ConnectionAcceptor.OnSteamOnUserGroup(iUserID, iGroupID, strStatus);
  56. }
  57.  
  58. public static bool StartUserAuth(ulong iUserID, byte[] data)
  59. {
  60. // ISSUE: unable to decompile the method.
  61. }
  62.  
  63. public static void OnUserLeave(ulong iUserID)
  64. {
  65. Server.SteamServer_UserLeave(iUserID);
  66. Server.OnPlayerCountChanged();
  67. }
  68.  
  69. public static void UpdateServerTitle()
  70. {
  71. Server.SetTitleOfConsole(NetCull.connections.Length.ToString() + " | " + server.hostname);
  72. }
  73.  
  74. public static void OnPlayerCountChanged()
  75. {
  76. Server.Steam_UpdateServer(NetCull.maxConnections, NetCull.connections.Length, server.hostname, server.map, Server.GetTags());
  77. Server.UpdateServerTitle();
  78. }
  79.  
  80. public static string GetTags()
  81. {
  82. string str = "rust";
  83. if (Server.Modded)
  84. str += ",modded";
  85. if (Server.Official)
  86. str += ",official";
  87. if ((long) Server.SteamGroup != 0L)
  88. str = str + ",sg:" + Server.SteamGroup.ToString("X");
  89. object obj = Interface.CallHook("ModifyTags", (object) str);
  90. if (obj is string)
  91. str = (string) obj;
  92. return str;
  93. }
  94.  
  95. public static void SetModded()
  96. {
  97. Server.Modded = false;
  98. }
  99.  
  100. public static void SetOfficial()
  101. {
  102. Server.Official = true;
  103. }
  104.  
  105. [DllImport("librust")]
  106. public static extern IntPtr SteamServer_BeginAuthSession(IntPtr pData, int iDataSize, ulong iUserID);
  107.  
  108. [DllImport("librust")]
  109. public static extern bool SteamServer_UserGroupStatus(ulong iUserID, ulong iGroupID);
  110.  
  111. [DllImport("librust")]
  112. public static extern void SteamServer_UserLeave(ulong iUserID);
  113.  
  114. [DllImport("librust")]
  115. public static extern void SteamServer_SetCallback_UserAuth(Server.funcUserAuth fnc);
  116.  
  117. [DllImport("librust")]
  118. public static extern void SteamServer_SetCallback_UserGroup(Server.funcUserGroup fnc);
  119.  
  120. [DllImport("librust")]
  121. public static extern bool Steam_ServerStartup(int port, int protocol);
  122.  
  123. [DllImport("librust")]
  124. public static extern void Steam_ServerShutdown();
  125.  
  126. [DllImport("librust")]
  127. public static extern void SetTitleOfConsole(string log);
  128.  
  129. [DllImport("librust")]
  130. public static extern void Steam_UpdateServer(int maxplayers, int icurrentplayers, string strServerName, string strMapName, string strTags);
  131.  
  132. [DllImport("librust")]
  133. public static extern ulong SteamServer_GetSteamID();
  134.  
  135. [DllImport("librust")]
  136. public static extern uint SteamServer_GetPublicIP();
  137.  
  138. public delegate void funcUserAuth(ulong iUserID, [MarshalAs(UnmanagedType.LPStr), In] string strStatus);
  139.  
  140. public delegate void funcUserGroup(ulong iUserID, ulong iGroupID, [MarshalAs(UnmanagedType.LPStr), In] string strStatus);
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement