Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2004, 03:27 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default quest global vars : wildcards behavior

i was a bit worried about the way the global variables are organized :

whenever you set a variable 'name' to 'value', the code checks for var with such name that already applies, and removes them. e.g you can't have a (charid, name) variable if (otherchar, name), or (anychar, name). Such variables would apply, you would retrieve them, and the code prevents ambigous cases where you get 2 values for a name (as charid is one of anychar)

Code:
// clean up expired vars and get rid of the one we're going to set if there
        database.RunQuery(query, MakeAnyLenString(&query,
          "DELETE FROM quest_globals WHERE expdate < %i || (name='%s' && (npcid=0 || charid=0 || zoneid=0 || (npcid=%i && charid=%i && zoneid=%i)))"
          ,Timer::GetCurrentTime(),arglist[0],qgNpcid,qgCharid,qgZoneid), errbuf, &result);
However it means you can't have a global var 'name ' for a NPC that is 'charid=0' set to 'value1', and a player specific value 'value2'. Put it in other words, you can't have a default value. The same applies to zone, though i can think any usefull situation atm.
e.g. try targlobal a variable for a (player,npc,zone), you will delete all vars with the same name that are anyzone, any player, or anynpc, no matter if they apply to this player or not.


i suggest changing this. The deletion query would be :
Code:
DELETE FROM quest_globals WHERE expdate < %li || (name='%s' && ((npcid=0 || npcid=%i ) && ( charid=0 || charid=%i) && (zoneid=0 ||zoneid=%i)))
or even more
Code:
DELETE FROM quest_globals WHERE expdate < %li || (name='%s' && (npcid=%i ) && (charid=%i) && (zoneid=%i)))
This will preserve wildcard variables.

This will however give several variables with same name in the Embparser::Event process. But, simply by changing the query to sort results, you can apply precedence of more-specific over less-specific, saying :

Code:
 database.RunQuery(query, MakeAnyLenString(&query,
      "SELECT name,value FROM quest_globals WHERE (npcid=%i || npcid=0) && (charid=%i || charid=0) && (zoneid=%i || zoneid=0) && expdate >= unix_timestamp(now()) order by charid , npcid, zoneid ",
         npcmob->GetNPCTypeID(),charid,zone->GetZoneID()), errbuf, &result);
     if (result)
    {
      printf("Loading global variables for %s\n",npcmob->GetName());
      while (row = mysql_fetch_row(result))
      {
        printf("$%s = %s\n",row[0],row[1]);
        ExportVar(packagename.c_str(), row[0], row[1]);
      }
      mysql_free_result(result);
    }
if var exists, you will get 1 or more rows, matching specific (charid, npcid, zoneid) or wildcard (0,0,0), or any combiantion. Sorting makes precedence of nnnn over 0, as in the while loop the variable is exported as many times as needed, but only the last value remains set, others will have been overriden.

The results are more conform to what i thought wildcards should be.

I'd like to know what you think.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:42 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3