[1.3.b56] Vision Opacity can go beyond 100, throws error

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

[1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

I was messing with the Vision Opacity setting in MapTool Preferences, and found a bug, I think.

I assumed that vision opacity was a percentage (i.e., the default value of 60 was "60% opaque" or "60% transparent"). However, I noticed that you can increase vision opacity beyond 100, so I thought, "Okay, maybe it's not. Wonder how high it goes?"

Somewhere north of 200, MapTool threw the following infinitely-looping error:

"java.lang.IllegalArgumentException: alpha value out of range"


I killed Java, but - unfortunately - on a restart, the error persists. I'm going to nuke the .maptool directory, see if that brings it back (I should hope so), but this strikes me as a bug (possibly a known one).

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

Nope. Nuking the .maptool directory does not fix the error. Will try a fresh install from the zip file.

Edit: Hm. Not even that fixed it.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

Okay. I can no longer run maptool on this computer. I have deleted .maptool, downloaded a new copy of the software, and rebooted my computer even. I get the same error when restarting maptool.

Now, I realize I'm using a way-old java (1.5.0_15), because this is my work machine and I can't update it, so this error may be specific to Java so old nobody but me will run into it.

However...anybody have any suggestions on how to get that opacity setting straightened out so I can restart MapTool?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Azhrei »

Look for a registry entry. Isn't that where preferences are saved on Windows machines?

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

Azhrei wrote:Look for a registry entry. Isn't that where preferences are saved on Windows machines?
Aha! That did it. Thank you!

Okay, and as a quick note: the vision opacity was set at 842, according to the Windows Registry. I assume it should probably only go up to 100, but I don't know. I certainly won't mess with it again. :D

SCPRedMage
Kobold
Posts: 3
Joined: Mon Jun 08, 2009 12:21 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by SCPRedMage »

I reply to the thread in the in the main MT forum, but I figure I should put it here, too. The error pops up when the value is set above 255, which is the maximum value of an unsigned byte. The setting needs to be properly validated.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

SCPRedMage wrote:I reply to the thread in the in the main MT forum, but I figure I should put it here, too. The error pops up when the value is set above 255, which is the maximum value of an unsigned byte. The setting needs to be properly validated.
Ah, I forgot about that other thread (heh) when it went from "what's the max?" to "whoa, my MapTool broke!"

I figured it was a validation error, although I wouldn't have come up with unsigned byte or anything of that nature. Given that, I wonder if it's supposed to be 0 - 100, or 0 - 255. But anyway, a bug, something to fix when convenient.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by aku »

well, i'm trying to hunt this down, for fun and profit, well, mostly fun... since theres no profit in it for me :D

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Rumble »

aku wrote:well, i'm trying to hunt this down, for fun and profit, well, mostly fun... since theres no profit in it for me :D

If my experience is representativee, the controls being used are sometimes the default "standard constructors" provided by the Abeille dialog editor. You can customize them by applying models (SpinnerModel, TableModel, etc.) to them to set certain characteristics.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by aku »

well, you lost me there rumble :D (remember, you're dealing with the Theorist here :D)

but so far, i found where it's setting the preference (surprisingly, in appPreferences.java!), and i found this chunk

Code: Select all

}

	public static void setVisionOverlayOpacity(int size) {
		prefs.putInt(KEY_VISION_OVERLAY_OPACITY, size);
	}

	public static int getVisionOverlayOpacity() {
		return prefs.getInt(KEY_VISION_OVERLAY_OPACITY,
				DEFAULT_VISION_OVERLAY_OPACITY);
	}
So, i'm thinking i add an if statement to verify that KEY_VISION_OVERLAY_OPACITY is <256 and then find some nifty error dialog to toss if it isnt... (since i dont like things not working for no apparent reason... or i could just append some text to it indicating that fact :D )

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Azhrei »

aku wrote:So, i'm thinking i add an if statement to verify that KEY_VISION_OVERLAY_OPACITY is <256 and then find some nifty error dialog to toss if it isnt... (since i dont like things not working for no apparent reason... or i could just append some text to it indicating that fact :D )
The KEY_* variables are static final String members of the class, not numbers.

It'll be the size parameter in the set method that you want to validate. And it's probably a good idea to also constrain the return value of the get method as well. Something like... if (size < 0) size = 0; if (size > 255) size = 255; to ensure it stays within a valid range.

As Rumble pointed out, the form that is displayed on the screen probably has the capability of attaching a validator to it so that it automatically prevents the value from going out of range. Check out the docs for the JSpinner constructor and the SpinnerModel interface for examples of how this works.

Also, for the purposes of displaying a message, check in MapTool.java for methods named showError, showConfirm, and so on. They display a message with an OK button and such and wait for a response. You can hard-code the string you give them during testing, but really you should add a new entry to i18n.properties and pass the string of the key instead. Check the AppActions.java and other places to see how the "show" methods are invoked.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by aku »

Azhrei wrote:
aku wrote:So, i'm thinking i add an if statement to verify that KEY_VISION_OVERLAY_OPACITY is <256 and then find some nifty error dialog to toss if it isnt... (since i dont like things not working for no apparent reason... or i could just append some text to it indicating that fact :D )
The KEY_* variables are static final String members of the class, not numbers.

It'll be the size parameter in the set method that you want to validate. And it's probably a good idea to also constrain the return value of the get method as well. Something like... if (size < 0) size = 0; if (size > 255) size = 255; to ensure it stays within a valid range.
This i realized, when eclipe started to puke an error message about < not being aw valid opperator for strings :D
As Rumble pointed out, the form that is displayed on the screen probably has the capability of attaching a validator to it so that it automatically prevents the value from going out of range. Check out the docs for the JSpinner constructor and the SpinnerModel interface for examples of how this works.
:?
/scratches head
/talksToSelf
Also, for the purposes of displaying a message, check in MapTool.java for methods named showError, showConfirm, and so on. They display a message with an OK button and such and wait for a response. You can hard-code the string you give them during testing, but really you should add a new entry to i18n.properties and pass the string of the key instead. Check the AppActions.java and other places to see how the "show" methods are invoked.
i knew i saw that, somewhere

:D

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Phergus »

Aku - look at PreferencesDialog.java. Line 443.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by aku »

thanks for the nudge phergus! not sure what i'll find there but i'll find out when i get home tonight

Edit: shh, be wery, wery, quiet, i's be <kaboom!> er, dont worry bout this bug no more :D :twisted:

now if only i can find the how to send trevor patches post... i guess i could go on another bug hunt, kinda pointless to just send one lousy patch with ~3 lines of code, heh

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: [1.3.b56] Vision Opacity can go beyond 100, throws error

Post by Azhrei »

Have you found this one yet? Be sure to read the whole thing, as the Source -> Format requires the proper settings in the Eclipse preferences to work properly.

Post Reply

Return to “Resolved”