Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GigiaJ opened this issue Aug 3, 2022 · 0 comments
Open
Assignees
Labels
bug Denotes that this a bug high priority high priority, needs to be done soon

Comments

@GigiaJ
Copy link
Collaborator

GigiaJ commented Aug 3, 2022

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.

@GigiaJ GigiaJ added the bug Denotes that this a bug label Aug 3, 2022
@GigiaJ GigiaJ self-assigned this Aug 3, 2022
@GigiaJ GigiaJ added the high priority high priority, needs to be done soon label Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Denotes that this a bug high priority high priority, needs to be done soon
Projects
None yet
Development

No branches or pull requests

1 participant