Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Dec 16, 2007 5:11 am   

CMUD [2.18] Public %dbkeys Stops working for variables.
 
I have yet to reduce this down to a procedure but here is what is happening.

I am using a heavily modified version of Larkin's Acropolis where I'm keeping track of what classes are enabled or disabled via a database variable.
I've done away with the string list with a key name of keys and a string list of the other keys. It used to look like this.

    keys=monk|priest|paladin
    monk=1
    priest=1
    paladin=1

And now it looks like this.
    monk=1
    priest=1
    paladin=1

Ok so the new functions are wonderful but %dbkeys is getting out of sync with the actual values. When this happens it fails to return anything.
If I delete all of the keys from the variable %dbkeys gets back into sync and starts working again.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sun Dec 16, 2007 6:58 am   
 
Cmud doesn't work with string lists like Zmud did. You can' t put something like monk|priest|paladin as a value for a key. Create a variable of it's own and separate it out for Cmud.

On second thought, if all the keys key is going to contain is a list of all the keys then just leave it out and use %dbkeys anytime you would have needed it.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sun Dec 16, 2007 1:27 pm   
 
That's what he's saying he did, ReedN. He's gotten rid of the "keys" string list and is now relying on %dbkeys, which isn't working 100% of the time.

And, I see no reason why you can't use a string list as a value in a data record variable in CMUD, either. It works just fine, as it should.
Reply with quote
Malach
Apprentice


Joined: 03 Nov 2007
Posts: 132

PostPosted: Sun Dec 16, 2007 1:46 pm   
 
Zugg explains here why in some instances various string list syntax won't be supported at all if they're nexted inside a db record and if you can get the syntax to work and get them in there, it's going to affect performance. So I'm pretty sure you CAN do it. But the question is do you really want to do it if it's going to hurt performance.

http://forums.zuggsoft.com/forums/viewtopic.php?t=29105

Arminas, I can't replicate a problem with the %dbkeys. When it stops working for you, is the data still showing up right in you db record?
_________________
Intel Core2 Quad CPU @ 2.4 GHZ with Windows Vista Home Premium and 2 GB Ram
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Dec 16, 2007 3:32 pm   
 
I got it to stop happening so far. I think I was causing a race condition at some point that was buggering it.

There were two things that I fixed and one of them must have been the culprit.

First I had a function that I replaced i_del with. Keep in mind that it still may not be an optimal replacement, I like to play with the code but I do not yet understand how it all interacts. That and at various times I was working around bugs that may not exist anymore.

When %dbkeys stopped working I could view the variables contents by typing '#show @fighting' or by going to the variable and highlighting it in the editor.

If I once it was NOT working deleted the remaining records using the package editor and hit SAVE I would get a index out of bounds error. '[Whatever the last thing I deleted] was not found'. If however I used the @del function to delete the remaining items %dbkeys would resume working correctly.

Here is what the function looks like now.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <func name="del">
    <value>#section add_del {
$key=%lower($key)
$var=%lower($var)
#forall $key {
  #if (%iskey(@{$var},%i)) {#delkey %quote($var) %i}
  }
$allo=%if(!%null(@fighting),  "NONE",  "ALL")
$allc=%if(!%null(@auto),"NONE","ALL")
#var AllOpponents 1
#var AllControls 1
#var AllOpponents $allo
#var AllControls $allc
#if ($var == afflictions) {#delkey flags failsafe}
#Return @{%quote($var)}
}</value>
    <arglist>$var,$key</arglist>
  </func>
</cmud>

These are the changes that I made to this function.

#if ($var == afflictions) {#delkey flags failsafe}
#Return @{%quote($var)}

Was outside of the section because this function IS the @del() function and it was calling itself. The return obviously needed to be AFTER this occurred.

#if ($var == afflictions) {#call @del(flags,failsafe)}
#Return @{%quote($var)}

The other thing that I fixed was either when I imported from Zmud or when I imported the acropolis text, it has been so long ago now I forget which, the class_skills variable got scrambled.

The class_skills variable is supposed to be a database record with string lists for the values as follows.
    Runewarden="csChivalry|csRunelore"
    Sentinel="csMetamorphosis|csWoodlore"
    Monk="csKaido|csTekura|csTelepathy"
    Occultist="csDomination|csOccultism|csTarot"
    Magi="csCrystalism|csElementalism"
    Serpent="csHypnosis|csSubterfuge|csVenom"
    Jester="csPranks|csTarot|csVodun_Puppetry"
    Infernal="csChivalry|csNecromancy"
    Priest="csDevotion|csHealing|csSpirituality"
    Druid="csGroves|csMetamorphosis"
    Shaman="csCurses|csRunelore|csVodun_Puppetry"
    Bard="csHarmonics|csSwashbuckling|csVoicecraft"
    Paladin="csChivalry|csDevotion"
    Sylvan="csElementalism|csGroves"
    Apostate="csApostasy|csEvileye|csNecromancy"

Instead of the nice pretty structure above I had what is below.
    Runewarden=csChivalry
    csDevotion
    csMetamorphosis
    Sentinel=csMetamorphosis
    csTelepathy
    csHealing
    csSubterfuge
    Monk=csKaido
    Occultist=csDomination
    csVoicecraft
    Magi=csCrystalism
    csWoodlore
    csRunelore
    csSpirituality
    csVenom
    csTarot
    Serpent=csHypnosis
    csOccultism
    Jester=csPranks
    Infernal=csChivalry
    Priest=csDevotion
    Druid=csGroves
    Shaman=csCurses
    Bard=csHarmonics
    Paladin=csChivalry
    Sylvan=csElementalism
    Apostate=csApostasy
    csTekura
    csNecromancy
    csEvileye
    csVodun_Puppetry
    csSwashbuckling
    csGroves
    csElementalism

When I looked at the underlying code I realized that there was a problem with the variable and retrieved a clean copy.

Between the two changes I've not had any more problems with %dbkeys failing. I don't fight other than hunting in Achaea as of yet and I am woefully inept at the skills system so before when I clicked the all button I was unaware that there were FAR to many things being listed as enabled or disabled. I was using these buttons to stress test the add and del functions I had made when I ran into the problem with %dbkeys not working.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Vesence
Beginner


Joined: 12 Mar 2006
Posts: 22

PostPosted: Sun Dec 16, 2007 6:36 pm   
 
Oddly enough I've gotten string lists to be values is database variables...
_________________
Achaea
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Dec 16, 2007 6:41 pm   
 
It isn't a matter of being able to get them to be values, it can and does work.

Zuggs objection is that it is slower than having them as separate lists.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net