|
mose Novice
Joined: 02 Dec 2010 Posts: 30
|
Posted: Tue Mar 08, 2011 1:12 pm
[3.33a] Bug Report CMUDPro local variable changes to random value |
This is a trigger I have that accumulates experience and counts kills. The vKillsExpPerMin calculation is working, but the vKillsCntPerMin is not. I inserted some debugging lines to print some information.
Code: |
<trigger name="tKillExp" priority="94190" id="2271">
<pattern>^You receive (%x) ~(+(%x) learn, +(%x) rp~) exp</pattern>
<value>$amount = (%replace(%1, ",", "") + %replace(%2, ",", "") + %replace(%3, ",", ""))
vKillsExp = @vKillsExp + $amount
vKillsCnt = @vKillsCnt + 1
$secs = (%ctime - @vKillsExpStart)
#win @vWinStatus 1 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs
vKillsExpPerMin = (@vKillsExp * 60 / $secs)
#win @vWinStatus 2 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs
vKillsCntPerMin = (@vKillsCnt * 60 / $secs)
#win @vWinStatus 3 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs
</value>
</trigger>
|
This is the output of the debugging statements. It appears that after calculating vKillsExpPerMin, the local variable $secs is being set to a large, random value, which causes the next calculation to be wrong.
Code: |
1 ctime 10318 vKillsExpStart 9645 secs 673
2 ctime 10318 vKillsExpStart 9645 secs 1311496470
3 ctime 10318 vKillsExpStart 9645 secs 1311496470 |
Duplicating the equation ""$secs = (%ctime - @vKillsExpStart)" just before the calculation of vKillsCntPerMin resets $secs. The calculation of vKillsCntPerMin is then correct, and $secs is still the same value after the calculation. |
|
|
|
mose Novice
Joined: 02 Dec 2010 Posts: 30
|
Posted: Wed Mar 16, 2011 11:51 am |
Please add this to the bug list.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Mar 16, 2011 4:02 pm |
Added to bug list.
|
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Wed Mar 16, 2011 4:02 pm |
I can't replicate this in an untitled offline session, I get:
1 ctime 0 vKillsExpStart 3 secs -3
2 ctime 0 vKillsExpStart 3 secs -3
3 ctime 0 vKillsExpStart 3 secs -3 |
|
_________________ Taz :) |
|
|
|
mose Novice
Joined: 02 Dec 2010 Posts: 30
|
Posted: Wed Mar 16, 2011 11:30 pm |
If this had been a simple bug, everyone would have experienced it in all of their scripts with all of their local variables. I only notice the problem in one script, which is above, and it is 100% replicable. The workaround of duplicating the assignment works 100%, as well.
As you can see, nothing tricky is being done in the script. Restarting CMUDPro consistently produces the same behavior immediately after restart. So, this isn't a situation of a session becoming corrupted after a while and then slowly deteriorating. Something is not right pretty much from the beginning. It only seems to affect the value of the local variable when used in the equation. It is like the previous assignment is being undone somehow.
There is one additional piece of information that might be remotely related. There is a button that displays the value of vKillsExpPerMin.
Code: |
<button autosize="false" width="105" height="23" stack="true" priority="67400" id="2393">
<caption>E/m: %format("&.0n", @vKillsExpPerMin)</caption>
</button>
|
I don't know when the button is refreshed, but if that happens immediately after the value is set, there might be some kind of interaction between the local variable getting clobbered and the refreshing of the button. That's a stretch, because vKillsCntPerMin is also displayed in a button, and the local variable is not changed after the calculations. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Mar 17, 2011 4:32 pm |
Hmm, Taz is correct. I cannot reproduce it either using your script above. Adding the button didn't change anything.
Can you give us a sample line from the MUD that is firing this trigger? Also give the XML for the variables being used, such as the @vKillsExpStart, @vKillsExp, etc.
Does it make any difference if you use #SHOW instead of #WIN to display the result to the main session window instead of the vWinStatus window?
I agree that the above script looks simple and should work fine. But the fact that we can't get it to fail in an untitled session means there is some interaction going on with some other script in your specific session.
Maybe you can create a second session and copy your script from the first session into the new one and then start disabling or removing other script elements to see what might be interfering with it. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Mar 17, 2011 10:07 pm |
Quote: |
So, this isn't a situation of a session becoming corrupted after a while and then slowly deteriorating. Something is not right pretty much from the beginning.
|
I also found out the hard way that just because you can reproduce something doesn't mean it's not a situation with a corrupted something-or-other. I even went the extra mile and traced down all I could about the "bug" and Zugg's first response was something along the lines of "Really? How? CMud's code doesn't even DO that, so I'm not sure how _________ could even happen..." |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
mose Novice
Joined: 02 Dec 2010 Posts: 30
|
Posted: Fri Mar 18, 2011 12:12 am |
Zugg wrote: |
Can you give us a sample line from the MUD that is firing this trigger? |
Code: |
You receive 1,500,306 (+204,186 learn, +15,157 rp) exp out of 2,286,181 total exp. |
Zugg wrote: |
Also give the XML for the variables being used, such as the @vKillsExpStart, @vKillsExp, etc. |
Code: |
<var name="vKillsExpStart">3652</var>
<var name="vKillsExpPerMin">27682547</var>
<var name="vKillsCntPerMin">17</var>
<var name="vKillsCnt">409</var> |
Zugg wrote: |
Does it make any difference if you use #SHOW instead of #WIN to display the result to the main session window instead of the vWinStatus window? |
No, it does not change anything to use #SHOW instead of #WIN (or to leave the statements out entirely).
Zugg wrote: |
But the fact that we can't get it to fail in an untitled session means there is some interaction going on with some other script in your specific session. |
I don't understand the mechanism by which code in some other script could change a local variable in this script.
If that were so, wouldn't that mean that there is some code that is being executed right after vKillsExpPerMin is assigned and before vKillsCntPerMin is assigned? Are multiple scripts in the same window actually executed simultaneously? |
|
|
|
mose Novice
Joined: 02 Dec 2010 Posts: 30
|
Posted: Fri Mar 18, 2011 12:18 am |
MattLofton wrote: |
I also found out the hard way that just because you can reproduce something doesn't mean it's not a situation with a corrupted something-or-other. |
I was very careful in my wording. I did not say that this was not due to corruption. It very well could be. What you can correctly infer from my statements is that if this is due to corruption, then it starts out corrupted, because the problem is present immediately when CMUDPro is started. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Mar 18, 2011 3:48 pm |
Nope, still doesn't fail for me here. I'll repeat advice from above:
Quote: |
Maybe you can create a second session and copy your script from the first session into the new one and then start disabling or removing other script elements to see what might be interfering with it. |
A local variable is just a memory stack location in the script execution. A corrupted script that is writing to the wrong portion of memory could certainly cause this.
So we need you to step back to a new, blank session and see if it still fails. Here is the full script that I used in a blank session:
Code: |
<window name="untitled">
<uid>{189D4896-7EAC-4B2B-A43D-3D30FD973F19}</uid>
<packages>untitled</packages>
<trigger name="tKillExp" priority="94190" id="1">
<pattern>^You receive (%x) ~(+(%x) learn, +(%x) rp~) exp</pattern>
<value>$amount = (%replace(%1, ",", "") + %replace(%2, ",", "") + %replace(%3, ",", ""))
vKillsExp = @vKillsExp + $amount
vKillsCnt = @vKillsCnt + 1
$secs = (%ctime - @vKillsExpStart)
#show @vWinStatus 1 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs
vKillsExpPerMin = (@vKillsExp * 60 / $secs)
#show @vWinStatus 2 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs
vKillsCntPerMin = (@vKillsCnt * 60 / $secs)
#show @vWinStatus 3 ctime %ctime vKillsExpStart @vKillsExpStart secs $secs</value>
</trigger>
<button autosize="false" width="105" height="23" stack="true" priority="67400" id="2">
<caption>E/m: %format("&.0n", @vKillsExpPerMin)</caption>
</button>
<var name="vKillsExpStart" id="3">3652</var>
<var name="vKillsExpPerMin" id="4">-141263</var>
<var name="vKillsCntPerMin" id="5">-6</var>
<var name="vKillsCnt" id="6">414</var>
<var name="vKillsExp" id="7">8598245</var>
</window> |
then I typed:
Code: |
#show "You receive 1,500,306 (+204,186 learn, +15,157 rp) exp out of 2,286,181 total exp." |
to fire the trigger. And I got this result:
Code: |
1 ctime 0 vKillsExpStart 3652 secs -3652
2 ctime 0 vKillsExpStart 3652 secs -3652
3 ctime 0 vKillsExpStart 3652 secs -3652 |
So you need to try this on your end in a blank session to see what you get. Assuming you don't get the random values, then you can start copying other scripts from your bugged session into the new session until you find the one that is causing the problem. Then you can post the problem script and we can try to help more. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|