Public EncryptedValue<ulong> userIDSuggestion

Hi everyone.

I think it’s necessary, after yesterday’s update, to add a new variable ulong userIDuL to BasePlayer. By using this variable, we will be able to call methods that expect a ulong without any issues (and without needing to use .Get()).

To achieve this, in addition to adding this variable to BasePlayer, it will be necessary to assign userIDuL = userID.Get(); right after UserIDString = userID.ToString(); in the following methods: BasePlayer.Load, BasePlayer.ServerInit, BasePlayer.PlayerInit, and Rust.Nexus.Handlers.RespawnAtBagHandler.Handle

Through the patcher, I created a new variable in BasePlayer and tried to add the line userIDuL = userID.Get();. However, I ran into an issue with configuring the constrained. It needs to be constrained. BasePlayer/EncryptedValue1 System.UInt64, but I’m getting constrained. BasePlayer/EncryptedValue1 instead.

Does anyone know how to fix this? Or am I using the wrong OpType?

4yfDtMwXAhfNi9R.png

QOwijLXkfqoUVZM.png

wLHuCkmoVD7jmez.png

 

{
  "Name": "userIDuL",
  "TargetDirectory": "C:\\rust_pr\\RustDedicated_Data\\Managed",
  "Manifests": [
    {
      "AssemblyName": "Assembly-CSharp.dll",
      "Hooks": [
        {
          "Type": "Modify",
          "Hook": {
            "InjectionIndex": 22,
            "RemoveCount": 0,
            "Instructions": [
              {
                "OpCode": "ldarg_0",
                "OpType": "None"
              },
              {
                "OpCode": "ldarg_0",
                "OpType": "None"
              },
              {
                "OpCode": "ldflda",
                "OpType": "Field",
                "Operand": "Assembly-CSharp|BasePlayer|userID"
              },
              {
                "OpCode": "constrained",
                "OpType": "Type",
                "Operand": "Assembly-CSharp|BasePlayer/EncryptedValue`1"
              },
              {
                "OpCode": "callvirt",
                "OpType": "Method",
                "Operand": "Assembly-CSharp|BasePlayer/EncryptedValue`1|Get"
              },
              {
                "OpCode": "stfld",
                "OpType": "Field",
                "Operand": "Assembly-CSharp|BasePlayer|userIDuL"
              }
            ],
            "HookTypeName": "Modify",
            "Name": "userIDuL [BasePlayer] [patch_Load]",
            "HookName": "userIDuL_0",
            "AssemblyName": "Assembly-CSharp.dll",
            "TypeName": "BasePlayer",
            "Flagged": false,
            "Signature": {
              "Exposure": 2,
              "Name": "Load",
              "ReturnType": "System.Void",
              "Parameters": [
                "BaseNetworkable/LoadInfo"
              ]
            },
            "MSILHash": "y14yo2JkZz+dAIFdLAiD4ZpjiaXs9HC8GOigSp24stE="
          }
        }
      ],
      "Modifiers": [],
      "Fields": [
        {
          "Name": "userIDuL",
          "AssemblyName": "Assembly-CSharp.dll",
          "TypeName": "BasePlayer",
          "FieldType": "mscorlib|System.UInt64",
          "Flagged": true
        }
      ]
    }
  ]
}

Or should I just take the userid value from ProtoBuf.BasePlayer?

IIIaKa

Or should I just take the userid value from ProtoBuf.BasePlayer?

Whts wrong with using get?  or ya could use the (ulong)player.userIDstring

MK3dybLN7WRwYnY.png Razor

Whts wrong with using get?  or ya could use the (ulong)player.userIDstring

If you're talking about constant use in plugins.

  1. Using userIDuL. Firstly, there will be no need to think about where to use Get and where it will work without it.
    Secondly, I consider constant access to the userID through a method to be unnecessary, as it adds small but additional overhead.
    It can be initialized in several places similarly to UserIDString: userIDuL = userID.Get(); And then use userIDuL, avoiding the excessive use of methods.
  2. I prefer to use ulong because it's lighter and more convenient to work with. Constantly converting a string to ulong is not reasonable.
IIIaKa

If you're talking about constant use in plugins.

  1. Using userIDuL. Firstly, there will be no need to think about where to use Get and where it will work without it.
    Secondly, I consider constant access to the userID through a method to be unnecessary, as it adds small but additional overhead.
    It can be initialized in several places similarly to UserIDString: userIDuL = userID.Get(); And then use userIDuL, avoiding the excessive use of methods.
  2. I prefer to use ulong because it's lighter and more convenient to work with. Constantly converting a string to ulong is not reasonable.


It seems that you are over complicating things, at least from my point of view. You will still need to use Get(), for example to know the SteamId.

Also, when you are talking about lighter version, it seems a micro performance improvement 

Maybe I am missing something