|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Mar 19, 2008 7:56 pm
[2.20] Data record variable corruption again |
I entered this on the command line:
Code: |
#VAR deaths {Pentu=3|Diamante=5|Sipelus=1|Shamarah=11|Narsrim=2|Kurama=1|Niente=1|Livictus=1|Marlucia=1|Loyen=1|Hraddon=1|Shiroii=1|Thoros=2|Ekard=2|Hyrtakos=4|Forren=1|Iasmos=1|Synl=2} |
I looked at the variable in the PE, and it looked okay to me. But, then I did a #SHOWDB @deaths on the command line, and I got unexpected results that appear to have cross-linked my keys with my values:
Code: |
Diamante: 11
Shamarah: 1
Pentu: 5
Iasmos: 1
Livictus: 1
Shiroii: 2
Narsrim: 1
Kurama: 1
Sipelus: 3
Loyen: 1
Ekard: 1
Thoros: 1
Hraddon: 2
Niente: 2
Synl: 4
Forren: 1
Marlucia: 1
Hyrtakos: 2
|
The %db function works fine, but others are not pulling the values correctly (#SHOWDB, #LOOPDB, %expanddb). |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Mar 19, 2008 8:03 pm |
Ouch, that's definitely bad. I'm not in front of my development computer at the moment, but if you do the #SHOWDB right after creating the variable, does it work then? In other words, is it the display in the Package Editor that is then causing the corruption?
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Mar 19, 2008 9:01 pm |
Nope. It seems to be just faulty logic in the commands that aren't working. So, I guess "corruption" may not be the proper term in this case...
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Thu Mar 20, 2008 6:16 pm |
I'll confirm this too. I noticed it wasn't on Taz's list. Makes using #loopdb and #showdb useless.
By the way, if you check the sorted box or uncheck sorted after checking it, then #loopdb and #showdb work
#showdb after pasting into command line.
Quote: |
Diamante: 11
Shamarah: 1
Pentu: 5
Iasmos: 1
Livictus: 1
Shiroii: 2
Narsrim: 1
Kurama: 1
Sipelus: 3
Loyen: 1
Ekard: 1
Thoros: 1
Hraddon: 2
Niente: 2
Synl: 4
Forren: 1
Marlucia: 1
Hyrtakos: 2 |
#showdb after checking sorted and clicking refresh.
Quote: |
Diamante: 5
Shamarah: 11
Pentu: 3
Iasmos: 1
Livictus: 1
Shiroii: 1
Narsrim: 2
Kurama: 1
Sipelus: 1
Loyen: 1
Ekard: 2
Thoros: 2
Hraddon: 1
Niente: 1
Synl: 2
Forren: 1
Marlucia: 1
Hyrtakos: 4 |
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Mar 21, 2008 5:15 pm |
OK, added to the bug list.
|
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Wed Apr 09, 2008 12:30 am |
[2.22] I just want to confirm that this bug still exists. I've experienced this slightly differently, though.
The following is how the #showdb should look (I had to cut/paste the scrambled order to get it right).
I created the variable by typing all this into the package editor, in this order.
Quote: |
indifference:
impatience:
vlock: 010_anorexia
focusCured_priority: 030_stupidity|010_anorexia
paralysis: 040_paralysis
herbCured: 040_paralysis|030_stupidity|070_weariness
salveCured: 010_anorexia
smokeCured:
focusCured_all: 010_anorexia|030_stupidity|070_weariness
treeCured: all |
I then looked at the xml, and got the following:
<class name="Test" id="2">
<var name="afflictions" type="Record" id="1">impatience|treeCured=etc|paralysis=040_paralysis|smokeCured|vlock=010_anorexia|indifference|focusCured_all="010_anorexia|
030_stupidity|070_weariness"|salveCured=010_anorexia|focusCured_priority="030_stupidity|010_anorexia"|herbCured="040_paralysis|
030_stupidity|070_weariness"</var>
</class>
I didn't look at it closely though, so I missed the fact that the order was changed around.
I tried a #showdb on it, and noticed the corrupted order. Went back to the PE and noticed
that the order had shuffled around in there too, and then finally noticed the change in the xml output.
In the examples by others above, there is focus on the fact that the values don't match the correct keys.
In my case I keep seeing the values being correct, but the physical order of keys seems to get randomly shuffled.
I'm not sure if that changes anything, just making sure this is still on the buglist. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Apr 09, 2008 10:40 am |
The behavior you are describing sounds correct. Record variables are stored to a hash table. When a string version of them is needed
the string is built from that hash table. This makes the all the commands and functions for them slightly faster.
If you need to maintain a specific order there are a few different methods available. First is use a string list to specify your look up order
Code: |
#FORALL @list {#SHOW {%i %db(@record,%i)}} |
Second is to preface your keys with an ordering sequence, and set the sort flag.
Which method is best really depends on what you are using the record for, and how you are using it. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Wed Apr 09, 2008 2:32 pm |
I won't pretend that makes much sense to me, but I guess I can stick a numeric prefix to my keys, clunky as it seems.
two: 002
one: 001
three: 003
four: 004
five: 005
1_one: 001
2_two: 002
3_three: 003
4_four: 004
5_five: 005 |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Apr 09, 2008 2:58 pm |
What Vijilante is saying is that your keys stuck with the same values, just the ordering of the keys changed, and that's normal. If you want the order to remain fixed, you tell CMUD to sort your variable with the checkbox option in the PE and then use keys that can be sorted the way you want, hence the need for numbering the keys instead of just the string list values.
Seems like you're going about the whole prioritization thing in a very roundabout way. There must be an easier way to accomplish what you're doing. To each his own, though. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 09, 2008 3:11 pm |
At the risk of derailing this thread (if you want to discuss it more, give me a PM and I'll split these posts into a new one), if I were going to use a priority queue, I'd use a sorted stringlist. Since you're going to sort the dbvar anyway, I doubt it'll have much speed impact. You pop off the first item of the list that can be cured with the balances you currently have and cure it with the first available method. Then update the balances and try again until you can't get anything out of the list. There's a thread knocking around called "Generic Priority Queue" that deals with some of these issues; there're two of them, and you'll want the CMUD one.
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Thu May 08, 2008 2:38 am |
Ok, this is fixed in 2.24 I don't know how long it has been fixed but I'm going to mark it as fixed in Taz's list
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
|
|