exploits protection bugfixes

This commit is contained in:
Robert Paciorek 2025-01-04 22:33:25 +00:00
parent 158ac4ee21
commit 783d02d4b2
3 changed files with 15 additions and 7 deletions

View File

@ -50,8 +50,13 @@ class SetPositionVariablesHandler : CommandHandler {
// user event
string? ue = spvData.Get<string>("UE");
if (ue != null)
if (ue != null) {
long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if ((time - client.PlayerData.last_ue_time) > 499 || Configuration.ServerConfiguration.AllowChaos) {
vars.Add("UE", ue);
client.PlayerData.last_ue_time = time;
}
}
// pitch
float? cup = spvData.Get<float?>("CUP");
if (cup != null)

View File

@ -43,7 +43,7 @@ class SetUserVariablesHandler : CommandHandler {
foreach (string varName in PlayerData.SupportedVariables) {
string? value = suvData.Get<string>(varName);
if (value != null) {
client.PlayerData.SetVariable(varName, value);
value = client.PlayerData.SetVariable(varName, value);
updated = true;
data.Add(varName, value);
vl.Add(NetworkArray.Param(varName, value));

View File

@ -38,6 +38,8 @@ public class PlayerData {
public string DiplayName { get; set; } = "placeholder";
public Role Role { get; set; } = Role.User;
public long last_ue_time { get; set; } = 0;
public static readonly string[] SupportedVariables = {
"A", // avatar data
"FP", // raised pet data
@ -69,18 +71,18 @@ public class PlayerData {
return variables[varName];
}
public void SetVariable(string varName, string value) {
public string SetVariable(string varName, string value) {
// do not store in variables directory
if (varName == "UID") {
return;
return value;
}
if (varName == "R") {
R = float.Parse(value, CultureInfo.InvariantCulture);
return;
return value;
}
if (varName == "F") {
F = unchecked((int)Convert.ToUInt32(value, 16));
return;
return value;
}
// fix variable value before store
@ -90,6 +92,7 @@ public class PlayerData {
// store in directory
variables[varName] = value;
return value;
}
public void InitFromNetworkData(NetworkObject suvData) {