mixins: add more clientThread checks

This commit is contained in:
MiscGamerBlue
2020-05-13 18:36:25 +02:00
committed by Owain van Brakel
parent 0d1ca5cffe
commit 06da1b8ca8
5 changed files with 63 additions and 11 deletions

View File

@@ -35,6 +35,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Named;
import net.runelite.api.ChatMessageType;
@@ -51,11 +52,14 @@ import net.runelite.api.IndexDataBase;
import net.runelite.api.IndexedSprite;
import net.runelite.api.IntegerNode;
import net.runelite.api.InventoryID;
import net.runelite.api.ItemDefinition;
import net.runelite.api.MenuEntry;
import net.runelite.api.MenuOpcode;
import net.runelite.api.MessageNode;
import net.runelite.api.NPC;
import net.runelite.api.NPCDefinition;
import net.runelite.api.Node;
import net.runelite.api.ObjectDefinition;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
@@ -498,6 +502,13 @@ public abstract class RSClientMixin implements RSClient
return totalLevel;
}
@Inject
public void addChatMessage(int type, String name, String message, String sender)
{
assert this.isClientThread() : "addChatMessage must be called on client thread";
addRSChatMessage(type, name, message, sender);
}
@Inject
@Override
public void addChatMessage(ChatMessageType type, String name, String message, String sender)
@@ -512,11 +523,19 @@ public abstract class RSClientMixin implements RSClient
return GameState.of(getRSGameState());
}
@Inject
public void setGameState(int state)
{
assert this.isClientThread() : "setGameState must be called on client thread";
client.setRSGameState(state);
}
@Inject
@Override
public void setGameState(GameState gameState)
{
client.setGameState(gameState.getState());
assert this.isClientThread();
setGameState(gameState.getState());
}
@Inject
@@ -1015,6 +1034,14 @@ public abstract class RSClientMixin implements RSClient
client.getCallbacks().post(DraggingWidgetChanged.class, draggingWidgetChanged);
}
@Inject
public RSSprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted)
{
assert isClientThread() : "createItemSprite must be called on client thread";
return createRSItemSprite(itemId, quantity, border, shadowColor, stackable, noted);
}
@Inject
@Override
public Sprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale)
@@ -1958,5 +1985,30 @@ public abstract class RSClientMixin implements RSClient
{
this.isMirrored = isMirrored;
};
@Inject
@Override
public ObjectDefinition getObjectDefinition(int objectId)
{
assert this.isClientThread() : "getObjectDefinition must be called on client thread";
return getRSObjectDefinition(objectId);
}
@Inject
@Override
@Nonnull
public ItemDefinition getItemDefinition(int id)
{
assert this.isClientThread() : "getItemDefinition must be called on client thread";
return getRSItemDefinition(id);
}
@Inject
@Override
public NPCDefinition getNpcDefinition(int id)
{
assert this.isClientThread() : "getNpcDefinition must be called on client thread";
return getRSNpcDefinition(id);
}
}

View File

@@ -87,6 +87,6 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition
return rs$getModel(quantity);
}
return client.getItemDefinition(modelOverride).getModel(quantity);
return client.getRSItemDefinition(modelOverride).getModel(quantity);
}
}

View File

@@ -58,6 +58,7 @@ public abstract class RSTextureMixin implements RSTexture
rs$animate(diff);
return;
}
assert client.getDrawCallbacks() != null;
client.getDrawCallbacks().animate(this, diff);
}

View File

@@ -145,6 +145,7 @@ public abstract class SoundEffectMixin implements RSClient
@Override
public void playSoundEffect(int id, int x, int y, int range, int delay)
{
assert this.isClientThread() : "playSoundEffect must be called on client thread!";
int position = ((x & 255) << 16) + ((y & 255) << 8) + (range & 255);
int[] queuedSoundEffectIDs = getQueuedSoundEffectIDs();
@@ -167,6 +168,7 @@ public abstract class SoundEffectMixin implements RSClient
@Override
public void playSoundEffect(int id, int volume)
{
assert client.isClientThread() : "playSoundEffect must be called on client thread";
RSSoundEffect soundEffect = getTrack(getIndexCache4(), id, 0);
if (soundEffect == null)
{