Skip to content

[BUG] VarcIntValues (and likely others) aren't entirely well-written #225

@GigiaJ

Description

@GigiaJ
int varcIntValue = methods.client.getVarcIntValue(VarcIntIndices.CURRENT_INTERFACE_TAB);
		return switch (VarcIntValues.valueOf(varcIntValue)) {
	case TAB_COMBAT_OPTIONS -> InterfaceTab.COMBAT;
	case TAB_SKILLS -> InterfaceTab.SKILLS;
	case TAB_QUEST_LIST -> InterfaceTab.QUESTS;
	case TAB_INVENTORY -> InterfaceTab.INVENTORY;
	case TAB_WORN_EQUIPMENT -> InterfaceTab.EQUIPMENT;
	case TAB_PRAYER -> InterfaceTab.PRAYER;
	case TAB_SPELLBOOK -> InterfaceTab.MAGIC;
	case TAB_FRIEND_LIST -> InterfaceTab.FRIENDS;
	case TAB_LOGOUT -> InterfaceTab.LOGOUT;
	case TAB_SETTINGS -> InterfaceTab.SETTINGS;
	case TAB_MUSIC -> InterfaceTab.MUSIC;
	case TAB_CHAT_CHANNEL -> InterfaceTab.CHAT;
	case TAB_ACC_MANAGEMENT -> InterfaceTab.ACC_MAN;
	case TAB_EMOTES -> InterfaceTab.EMOTES;
	default -> throw new IllegalStateException("Unexpected value: " + VarcIntValues.valueOf(varcIntValue));
};

This code will fail if you were to check say 0 as zero could refer to a number of enumerations and as this switch case is a check on the enumeration and not the actual value it isn't valid. This is likely an issue in a number of classes Bia revised.

Metadata

Metadata

Assignees

Labels

bugDenotes that this a bughigh priorityhigh priority, needs to be done soon

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions