|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Mon Aug 11, 2008 3:04 pm
[2.35] Bug - CMUD evaluates starting number at cmdline |
May be this already is on the list.
Enter at the command line: 12345678901234567890
The result will be 9223372036854775807.
Looks like instead of send text verbatim CMUD tries to evaluate a number and hit the 32-bit limit. Since there is no expressions on the command line, evaluation of a single number is quite pointless.
Type: 12345678901234567890
Result: 9223372036854775807 {wrong)
Type: 12345678901234567890 abc
Result: 9223372036854775807 abc (wrong)
Type: 12345678901234567890 12345678901234567890
Result: 9223372036854775807 12345678901234567890 (wrong)
Type: abc 12345678901234567890
Result: abc 12345678901234567890 (correct) |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Aug 11, 2008 4:16 pm |
Generated from an alias, MapRock didn't get set properly but regardless watch MapWater
#var MapRock
Variable: + MapRock (Auto) 9223372036854775807
#var MapWater
Variable: + MapWater (Auto) 0124231433331401122410102
#var mapkinds
Variable: + MapKinds (Auto) Water|Rock
#forall @mapkinds {#SHow %i @{Map%i}}
Water 9223372036854775807
Rock 9223372036854775807
// CMUD 2.35 |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 11, 2008 5:57 pm |
I've added Arde's bug to the bug list. I'm not sure I understand TonDeining's reply.
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Aug 11, 2008 7:02 pm |
The variable MapWater is set to the following:
#var MapWater
Variable: + MapWater (Auto) 0124231433331401122410102
#SH @mapwater
9223372036854775807
Seems to be an issue with the "Auto" variable type.
So we set the variable to a String Literal:
#CALL %vartype(mapwater,3)
#var MapWater
Variable: + MapWater (Literal) 1422324204334444220141223
#SH @mapwater
1422324204334444220141223
Hope that is clearer. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Aug 12, 2008 12:44 pm |
That's what I'd expect, TonDiening. If you put a number like that in an auto variable, it will interpret it as a number, and the number overflows because it is larger the maximum allowed. To be sure of interpreting it as a string you need to explicitly declare it to be a string.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Aug 12, 2008 4:52 pm |
Rahab is correct. If a variable is marked as "Auto" and it looks like a number, then CMUD will try to convert it (and it will overflow). If you want CMUD to treat the value as a string, then it needs to be marked as a string literal as you mentioned.
If you assign the value with " quotes around it, then CMUD will mark it as a string properly. So you can do this:
#VAR MapWater "0124231433331401122410102"
and it will work properly. But without the " quotes, CMUD will interpret the value as a number and will have trouble with it.
That part isn't going to change. The only part that I plan to fix is to allow a large number entered into the command line to be sent to the MUD verbatim without having overflow issues. This is because of the Smart Command Line code which allows me to make exceptions for stuff like this. When you start using these things in a script, then you just need to be more careful about the variable type. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Aug 13, 2008 10:35 pm |
OK, I changed my mind on this and decided to fix it in the parser where it belongs instead of messing with the command line. When the parser encounters something that looks like a number, it is now only stored as an Integer value if there is no overflow. If the number is too large, then it is handled as a string value. So in 2.36 all of the examples at the beginning of this post will work correctly. You'll only get incorrect values if you start trying to perform math (like adding 1 to the large number).
|
|
|
|
|
|