Skip to content

Commit 5fdbfcd

Browse files
committed
Small OnEntityBuilt optimizations
1 parent 1c014f5 commit 5fdbfcd

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

plugins/rust/RustApp.cs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
namespace Oxide.Plugins
2929
{
30-
[Info("RustApp", "RustApp.io", "2.1.6")]
30+
[Info("RustApp", "RustApp.io", "2.1.8")]
3131
public class RustApp : RustPlugin
3232
{
3333
#region Variables
@@ -1623,7 +1623,7 @@ public void SignageCreate(BaseImageUpdate update)
16231623
{
16241624
var obj = new CourtApi.PluginSignageCreateDto
16251625
{
1626-
steam_id = update.PlayerId.ToString(),
1626+
steam_id = update.PlayerId,
16271627
net_id = update.Entity.net.ID.Value,
16281628

16291629
base64_image = Convert.ToBase64String(update.GetImage()),
@@ -3891,7 +3891,7 @@ private string UICommand<T>(Action<BasePlayer, T, string> callback, T arg, strin
38913891
public abstract class BaseImageUpdate
38923892
{
38933893
public BasePlayer Player { get; }
3894-
public ulong PlayerId { get; }
3894+
public string PlayerId { get; }
38953895
public string DisplayName { get; }
38963896
public BaseEntity Entity { get; }
38973897
public int ItemId { get; protected set; }
@@ -3903,7 +3903,7 @@ protected BaseImageUpdate(BasePlayer player, BaseEntity entity)
39033903
{
39043904
Player = player;
39053905
DisplayName = player.displayName;
3906-
PlayerId = player.userID;
3906+
PlayerId = player.UserIDString;
39073907
Entity = entity;
39083908
}
39093909

@@ -3976,7 +3976,7 @@ private byte[] GetImageBytes(Bitmap image)
39763976
MemoryStream stream = Facepunch.Pool.Get<MemoryStream>();
39773977
image.Save(stream, ImageFormat.Png);
39783978
byte[] bytes = stream.ToArray();
3979-
Facepunch.Pool.FreeMemoryStream(ref stream);
3979+
Facepunch.Pool.FreeUnmanaged(ref stream);
39803980
return bytes;
39813981
}
39823982
}
@@ -4061,27 +4061,14 @@ private void OnFireworkDesignChanged(PatternFirework firework, ProtoBuf.PatternF
40614061

40624062
private void OnEntityBuilt(Planner plan, GameObject go)
40634063
{
4064-
var player = plan.GetOwnerPlayer();
4065-
var ent = go.ToBaseEntity();
4066-
4067-
if (player == null || ent == null) return;
4068-
4069-
string shortName = go.ToBaseEntity().ShortPrefabName;
4070-
if (!shortName.Contains("sign"))
4064+
if (plan.GetOwnerPlayer() is not BasePlayer player || go.ToBaseEntity() is not Signage signage)
40714065
{
40724066
return;
40734067
}
40744068

4075-
var signage = go.ToBaseEntity().GetComponent<Signage>();
4076-
40774069
NextTick(() =>
40784070
{
4079-
if (signage == null)
4080-
{
4081-
return;
4082-
}
4083-
4084-
if (signage.GetTextureCRCs()[0] == 0)
4071+
if (signage.IsDestroyed || signage.GetTextureCRCs()[0] == 0)
40854072
{
40864073
return;
40874074
}

0 commit comments

Comments
 (0)