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

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #16  
Old 10-27-2008, 10:49 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by Congdar View Post
I like the idea of making things faster, but the added problem of downloading a txt file that matches a particular servers emu code level would be a pain if you played on multiple servers with possibly different code levels(like the one you play on when your favorite is down, etc).

So there would need to be the 'default titanium spells first' list in the db that works with anybody that connects and doesn't have 'the latest custom spell list with all the fixes'.
from what I know most people who play on difirent custom servers simply have 2 or more EQ folders, rather than ever mess with continusly changing reqiured files
Reply With Quote
  #17  
Old 10-27-2008, 11:22 PM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by Congdar View Post
there would need to be the 'default titanium spells first' list in the db that works with anybody that connects and doesn't have 'the latest custom spell list with all the fixes'.
I think there must be some confusion about the spells (or I'm completely misunderstanding what you're saying), because the client & server don't handle spells differently based on the client like we do with other things (opcodes, spawn structs, player profile structs, etc).

Quote:
Originally Posted by Congdar View Post
the added problem of downloading a txt file that matches a particular servers emu code level would be a pain if you played on multiple servers with possibly different code levels(like the one you play on when your favorite is down, etc)
That's the way it currently works (which is a pita, and why most, if not all servers, use either the straight Titanium spell file or slightly modified version), and I think that's why I'm confused about where you're coming from.

Here's the current flow of how the spells are loaded:
  1. main()
  2. LoadSPDat() called in main()
  3. FileLoadSPDat() called via a callback (extFileLoadSPDat) in LoadSPDat()
  4. Read from spells_us.txt as directed by FileLoadSPDat()

All I'm doing is changing the last step to this:
  1. main()
  2. LoadSPDat() called in main()
  3. FileLoadSPDat() called via a callback (extFileLoadSPDat) in LoadSPDat()
  4. Read from database as directed by FileLoadSPDat()

So instead of parsing through this:
Code:
3^Summon Corpse^PLAYER_1^^^^^^^10000^^0^0^5000^2250^12000^0^0^0^700^70^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^2512^2106^17355^-1^-1^-1^1^1^1^1^-1^-1^-1^-1^100^100^100^100^100^100^100^100^100^100^100^100^0^1^0^0^91^254^254^254^254^254^254^254^254^254^254^254^6^20^14^-1^0^0^255^255^255^255^51^255^255^255^255^255^35^255^255^255^255^255^43^^0^4^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^100^0^109^307^0^0^0^0^0^0^0^0^0^3^125^64^^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^5^101^49^52^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^1^0^0
we're iterating through this:
Code:
mysql> SELECT * FROM spells_new LIMIT 1 OFFSET 1;
+----+---------------+----------+---------------+----------+-------------+-------------+---------------+-------------+-------+----------+----------+--------+-----------+---------------+-------------+---------------------+--------------+------------+------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+----------------------+----------------------+------+------+------+------+------+------+------+------+------+-------+-------+-------+------+---------+-------------+-------------+-------------+-------------+-------------------+-------------------+-------------------+-------------------+------------------+------------------+------------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+------------+-----------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+------------+------------+------------+------------+----------+-------+----------+-----------------+-----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-------------+------------+------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+----------+----------+----------+-----------+-----------------+------------+---------------------+------------+--------------+----------+----------+----------+----------------+---------+-------------+---------------+----------+----------+----------+----------+-----------+----------+----------+----------+-----------+-----------------+----------+----------+----------+----------+----------+-----------+-------------+----------+---------+---------------+---------------+--------------+----------------+----------+----------+----------+----------+---------+-----------+--------------+----------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+------------+----------+----------+----------+----------+----------+----------+----------+
| id | name          | player_1 | teleport_zone | you_cast | other_casts | cast_on_you | cast_on_other | spell_fades | range | aoerange | pushback | pushup | cast_time | recovery_time | recast_time | buffdurationformula | buffduration | AEDuration | mana | effect_base_value1 | effect_base_value2 | effect_base_value3 | effect_base_value4 | effect_base_value5 | effect_base_value6 | effect_base_value7 | effect_base_value8 | effect_base_value9 | effect_base_value10 | effect_base_value11 | effect_base_value12 | effect_limit_value1 | effect_limit_value2 | effect_limit_value3 | effect_limit_value4 | effect_limit_value5 | effect_limit_value6 | effect_limit_value7 | effect_limit_value8 | effect_limit_value9 | effect_limit_value10 | effect_limit_value11 | effect_limit_value12 | max1 | max2 | max3 | max4 | max5 | max6 | max7 | max8 | max9 | max10 | max11 | max12 | icon | memicon | components1 | components2 | components3 | components4 | component_counts1 | component_counts2 | component_counts3 | component_counts4 | NoexpendReagent1 | NoexpendReagent2 | NoexpendReagent3 | NoexpendReagent4 | formula1 | formula2 | formula3 | formula4 | formula5 | formula6 | formula7 | formula8 | formula9 | formula10 | formula11 | formula12 | LightType | goodEffect | Activated | resisttype | effectid1 | effectid2 | effectid3 | effectid4 | effectid5 | effectid6 | effectid7 | effectid8 | effectid9 | effectid10 | effectid11 | effectid12 | targettype | basediff | skill | zonetype | EnvironmentType | TimeOfDay | classes1 | classes2 | classes3 | classes4 | classes5 | classes6 | classes7 | classes8 | classes9 | classes10 | classes11 | classes12 | classes13 | classes14 | classes15 | classes16 | CastingAnim | TargetAnim | TravelType | SpellAffectIndex | field124 | field125 | deities1 | deities2 | deities3 | deities4 | deities5 | deities6 | deities7 | deities8 | deities9 | deities10 | deities11 | deities12 | deities13 | deities14 | deities15 | deities16 | field142 | field143 | new_icon | spellanim | uninterruptable | ResistDiff | dot_stacking_exempt | deleteable | RecourseLink | field151 | field152 | field153 | short_buff_box | descnum | typedescnum | effectdescnum | field158 | field159 | field160 | field161 | bonushate | field163 | field164 | field165 | EndurCost | EndurTimerIndex | field168 | field169 | field170 | field171 | field172 | HateAdded | EndurUpkeep | field175 | numhits | pvpresistbase | pvpresistcalc | pvpresistcap | spell_category | field181 | field182 | field183 | field184 | can_mgb | nodispell | npc_category | npc_usefulness | field189 | field190 | field191 | field192 | field193 | field194 | field195 | field196 | field197 | field198 | field199 | field200 | field201 | field202 | field203 | field204 | field205 | field206 | spellgroup | field208 | field209 | field210 | field211 | field212 | field213 | field214 |
+----+---------------+----------+---------------+----------+-------------+-------------+---------------+-------------+-------+----------+----------+--------+-----------+---------------+-------------+---------------------+--------------+------------+------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+----------------------+----------------------+------+------+------+------+------+------+------+------+------+-------+-------+-------+------+---------+-------------+-------------+-------------+-------------+-------------------+-------------------+-------------------+-------------------+------------------+------------------+------------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+------------+-----------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+------------+------------+------------+------------+----------+-------+----------+-----------------+-----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-------------+------------+------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+----------+----------+----------+-----------+-----------------+------------+---------------------+------------+--------------+----------+----------+----------+----------------+---------+-------------+---------------+----------+----------+----------+----------+-----------+----------+----------+----------+-----------+-----------------+----------+----------+----------+----------+----------+-----------+-------------+----------+---------+---------------+---------------+--------------+----------------+----------+----------+----------+----------+---------+-----------+--------------+----------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+------------+----------+----------+----------+----------+----------+----------+----------+
|  3 | Summon Corpse | PLAYER_1 |               |          |             |             |               |             | 10000 |        0 |        0 |      0 |      5000 |          2250 |       12000 |                   0 |            0 |          0 |  700 |                 70 |                  0 |                  0 |                  0 |                  0 |                  0 |                  0 |                  0 |                  0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                   0 |                    0 |                    0 |                    0 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |     0 |     0 |     0 | 2512 |    2106 |       17355 |          -1 |          -1 |          -1 |                 1 |                 1 |                 1 |                 1 |               -1 |               -1 |               -1 |               -1 |      100 |      100 |      100 |      100 |      100 |      100 |      100 |      100 |      100 |       100 |       100 |       100 |         0 |          1 |         0 |          0 |        91 |       254 |       254 |       254 |       254 |       254 |       254 |       254 |       254 |        254 |        254 |        254 |          6 |       20 |    14 |       -1 |               0 |         0 |      255 |      255 |      255 |      255 |       51 |      255 |      255 |      255 |      255 |       255 |        35 |       255 |       255 |       255 |       255 |       255 |          43 |          0 |          0 |                4 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |         0 |         0 |         0 |         0 |         0 |         0 |         0 |      100 |        0 |      109 |       307 |               0 |          0 |                   0 |          0 |            0 |        0 |        0 |        0 |              0 |       3 |         125 |            64 |        0 |        0 |        0 |        0 |         0 |      100 |        0 |        0 |         0 |               0 |        0 |        0 |        0 |        0 |        0 |         0 |           0 |        0 |       0 |             5 |           101 |           49 |             52 |        0 |        0 |        0 |        0 |       0 |         0 |            0 |              0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        1 |        0 |        0 |        0 |        0 |        0 |       -1 |          0 |        0 |        0 |        1 |        0 |        0 |        1 |        1 |
+----+---------------+----------+---------------+----------+-------------+-------------+---------------+-------------+-------+----------+----------+--------+-----------+---------------+-------------+---------------------+--------------+------------+------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------------------+----------------------+----------------------+----------------------+------+------+------+------+------+------+------+------+------+-------+-------+-------+------+---------+-------------+-------------+-------------+-------------+-------------------+-------------------+-------------------+-------------------+------------------+------------------+------------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+------------+-----------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+------------+------------+------------+------------+----------+-------+----------+-----------------+-----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-------------+------------+------------+------------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+----------+----------+----------+-----------+-----------------+------------+---------------------+------------+--------------+----------+----------+----------+----------------+---------+-------------+---------------+----------+----------+----------+----------+-----------+----------+----------+----------+-----------+-----------------+----------+----------+----------+----------+----------+-----------+-------------+----------+---------+---------------+---------------+--------------+----------------+----------+----------+----------+----------+---------+-----------+--------------+----------------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+------------+----------+----------+----------+----------+----------+----------+----------+
1 row in set (0.00 sec)
I'm not trying to reinvent the wheel, I'm just trying to make it easier to work with (especially in tools & other editors)

EDIT: The main reason I started towards this in the first place is that different utilities, including the PEQ editor, EQBrowser (Allakhazam clone), etc, usually have you source a trimmed copy of the spells file into the database anyways. However, they have a tendency to step over each others' toes, because some use fewer fields than others. This was to A) help alleviate the conflict, and B) make it easier to customize spell files, including tweaking the vanilla Titanium spell file (since we all know it's not perfect).
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki

Last edited by AndMetal; 10-28-2008 at 07:31 AM..
Reply With Quote
  #18  
Old 10-28-2008, 12:01 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

It wasnt broke, so why are you fixing it?

Youre just adding an additional level of complication IMO.

Since there already exists Spells.txt editors so loading the spells into the DB for editing isnt needed and since the client has to have the same Spells.txt file as the server for spells to work correctly for both the client and server and since this list is loaded once upon booting the world and since your still going to want to load the spells into memory no matter which method you use,for these reasons and more there doesnt seem to be any point to doing this.
Reply With Quote
  #19  
Old 10-28-2008, 12:08 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, that would definitely be useful for web-based tools. And if a tool similar to the Ailia/Bleh Spell Editor was made to edit the Table version, I think it could really make a nice option for spell file management. Plus, this would give the option to use mysql commands to mass edit the spell file if people wanted to do that for any reason.

The only thing I would recommend for this system would be a really simple way to convert the spell file to the table and then the table back into the spell file. Otherwise, custom servers might have issues when trying to make sure that their custom spell files match the custom spell files that their players downloaded for their server. If a tool was made similar to the Ailia/Bleh one for the Table version, it would be very nice if the same tool would also convert the file to table and visa versa.

Since the spell data is loaded globally when the server starts, I doubt this would be possible. But, it would be really cool if we could have a command that would let NPCs use any spell effect with custom values at any time. Essentially making a custom spell in real time via Perl. I think the command could use the fields in the table and then also set a value for it, and then just use the effects from the source for those fields. So, maybe something like quest::spelleffect(type, value), or maybe an extended version like quest::spelleffect(type, value, range, target_type, duration_ticks, pet_name, icon, "description", "msg_cast_on_you", "msg_cast_on_other") or something like that. Kinda off-topic idea, but sounds like fun to me
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #20  
Old 10-28-2008, 12:08 AM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by MNWatchdog View Post
It wasnt broke, so why are you fixing it?

Youre just adding an additional level of complication IMO.

Since there already exists Spells.txt editors so loading the spells into the DB for editing isnt needed and since the client has to have the same Spells.txt file as the server for spells to work correctly for both the client and server and since this list is loaded once upon booting the world and since your still going to want to load the spells into memory no matter which method you use,for these reasons and more there doesnt seem to be any point to doing this.
txt based editor are ULTRA slow and have ultra high tendency to break spell file complitly. I doubt that on LIVE they store server side spell data in a text file

puting them into DB will:
a) makes need of 1 spell editor LESS
b) keeps all server related things in one place
Reply With Quote
  #21  
Old 10-28-2008, 12:15 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Quote:
Originally Posted by ChaosSlayer View Post
I doubt that on LIVE they store server side spell data in a text file
Text file probably not, but data file certainly. Most professional MMOs only use a database for character and account storage. Everything else is stored in data files which gets completely loaded in the memory. Boy, I wish I had a setup that was able to do that!

That being said, what is the real advantage of this change? You do realize it will create a performance hit, right? Currently, all spells are loading into shared memory when the server first boots. I think somebody said it reloads them when a zone boots or something but that is incorrect. Spells only get loaded into memory once. If they did get loaded when a zone boots, then you would be able to edit spells on the fly, which you currently cannot. Moving this functionality to the DB is going to slow this down considerably... Having everything loaded into memory is the fastest way to do something, loading from a DB is among the slowest.

Last edited by cavedude; 10-28-2008 at 08:23 AM..
Reply With Quote
  #22  
Old 10-28-2008, 12:38 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I don't think he's talking about reloading it every time someone tries to access a spell; it will still be loaded only once.

I'd say it's pretty likely they store it in a file similar to what they put on the patcher, perhaps bundled into a data archive.

Here's my thoughts on this:

The reasons for adding it to the database aren't really all that compelling if you ask me. Assuming this went into effect right now.

-You have slightly increased load on SQL server.
-You have slightly increased load times for spells.
-You have additional complexity when it comes to actually getting the spells to the client. (Now instead of modifying the spells directly you have to edit the database and then convert it.)
-You have increased database size.
-You don't really eliminate the need for a spell editor, you just lessen it if you're trying to change something simple. It will still be quite a hassle to heavily modify spells, especially many spells without one.
-You force people who wrote their spell editors to have to rewrite them for both systems, or you can continue to use them and then convert it over to the database but then what's the point.
-You've eliminated the need for a tool to need to write a spell file parser to get spells(which is incredibly simple btw).
-In my opinion you made it harder on new users who now have to try to figure out 'hey there's two systems for spells, wait do I need them both? I can't find the db table I need anywhere help!!'.

Lots of cons, a few pros. I personally just don't think it's a worthwhile idea.
Reply With Quote
  #23  
Old 10-28-2008, 12:38 AM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

I don't think AndMetal plans to have spells to be reloaded from Db over and over again evetytime zone boots or someone zones. The spell will also only load ONCE. The reason for puting server side files in DB are for purpose to work with them
Reply With Quote
  #24  
Old 10-28-2008, 01:00 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

Quote:
Originally Posted by KLS View Post
-You have slightly increased load on SQL server.
-You have slightly increased load times for spells.
-You have additional complexity when it comes to actually getting the spells to the client. (Now instead of modifying the spells directly you have to edit the database and then convert it.)
-You have increased database size.
-You don't really eliminate the need for a spell editor, you just lessen it if you're trying to change something simple. It will still be quite a hassle to heavily modify spells, especially many spells without one.
-You force people who wrote their spell editors to have to rewrite them for both systems, or you can continue to use them and then convert it over to the database but then what's the point.
-You've eliminated the need for a tool to need to write a spell file parser to get spells(which is incredibly simple btw).
-In my opinion you made it harder on new users who now have to try to figure out 'hey there's two systems for spells, wait do I need them both? I can't find the db table I need anywhere help!!'.

Lots of cons, a few pros. I personally just don't think it's a worthwhile idea.
Theres the more I mentioned. :p
Reply With Quote
  #25  
Old 10-28-2008, 01:03 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

Im guessing if youre going to do this, just do it one way and not have both methods available. All that does is double the number of spell editors that need to be maintained.
Reply With Quote
  #26  
Old 10-28-2008, 01:43 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, they would still be loaded into shared memory the same as they are now.

Even if the table wasn't actually used to load spells from when the server starts, it still could be a very useful table to have to spell editing. You would know every field and could quickly and easily sort by them to find all spells that use that particular field or certain effect. I think it would make finding spells for custom encounters a bit easier.

Another possible bonus to using a Table would be that it would be possible to include with the PEQ DB (though I doubt Cavedude would allow it). If it was included, it would be one less step to do when setting up a server (even though it is one of the easiest steps). And more importantly, it could be updated to correct or remove certain broken spells with the default Titanium Spell file. Not only that, but it could potentially be customized to add support for higher level spells as well as every spell from live past the point of titanium (around spell ID 8400). That wouldn't be too bad IMO. Sure, an edited spell file could be distributed with it, but an edited table is a little less iffy if you know what I mean. This possible bonus is pretty unlikely to happen, but it is something to maybe consider.

I think the main use for the table would be for web-based tools like PEQ Editor and others. With a full spell table like this, it would open up alot of options for web-tools. You could have them search for spells with certain criteria, or even go as far as editing the spells directly from the web-tool. AndMetal has a good point about multiple tools using variations of spell tables. I think his idea would be a good solution to take away the need to build extra spell tables for new tools.

I don't think it would hurt in any way for him to add this as an option to the source. Where you would need to change source before compiling by defining the spell table or something. It never hurts to have more options. If it started getting popular, maybe more positive uses for it would pop up.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #27  
Old 10-28-2008, 03:03 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

Quote:
Originally Posted by trevius View Post
It never hurts to have more options.
Actually, this is often not true. Options as a rule are nice but also as a rule add complications and confusion.

This change CAN certainly be nice and allow more flexibility, but there is often a unforseen cost too.

Good example. I once wrote a macro to do some simple repetitive tasks. I enjoyed it, it did it job but I thought it could be made even more useful and I continued to develope and tweek it.

Eventually, it reached a point that I had to read my own documentation to remember how to use it as it had become so all encompasing it was no longer simple to use. Sure, it could do more, but there was a definate trade off.

PS I posted said macro after all this work and as I recall, noone seemed to use it was still to complicated and thus it was useless.
Reply With Quote
  #28  
Old 10-28-2008, 03:19 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

First, I would like to clarify, I have been talking about loading the spells into shared memory, not loading info on the fly from the database (that's just resource suicide).

Quote:
Originally Posted by KLS View Post
-You have slightly increased load times for spells.
I know PHP isn't the best "language" for speed, but according to preliminary testing, it actually IS faster to calculate the max spell ID & load the spells from the database than the spells_us.txt file WITHOUT caching (SQL_NO_CACHE):

PHP Code:
<?php

class Database
{
    private 
$connectoid false//Used to track this specific database connection so we don't mess with the other connections, also can be used to determine the state of the connection
    
private static $user "username";    //Username to access the Database
    
private static $pass "password";    //Password to access the Database
    
private static $host "localhost";        //IP address or hostname
    
protected $db "peq";    //Name of the Database we're accessing, can be changed if needed
    
    
protected $benchmarks = Array();
    
    public function 
__construct() {
        if (
$this->connectoid mysql_connect(Database::$hostDatabase::$userDatabase::$pass)) {
            
mysql_select_db($this->db$this->connectoid);
        }
    }
    
    public function 
__toString() {
        return 
"Database " . ($this->IsConnected() ? "" "not ") . "connected";
    }
    
    public function 
IsConnected() {
        return (
$this->connectoid true false);
    }
    
    
//test function, we don't want to be broadcasting our login info to everyone irl
    
public function ReturnLoginInfo() {
        return 
"Host: " Database::$host "<br>\nUser: " Database::$user "<br>\nPass: " Database::$pass "<br>\nDB: " $this->db;
    }
    
    public function 
Query($q) {
        
$this->benchmarks[Query][result][start] = microtime(true);
        
$res mysql_query($q$this->connectoid);    //results
        
$this->benchmarks[Query][result][end] = microtime(true);
        
$this->benchmarks[Query][row][start] = microtime(true);
        if (
$row mysql_fetch_array($resMYSQL_ASSOC)) {    //single row of data
            
$this->benchmarks[Query][row][end] = microtime(true);
            
$i 0;    //iterator
            
$ret = array();
            do {
                
$ret[++$i] = $row;
            } while (
$row mysql_fetch_array($resMYSQL_ASSOC));
            if (
is_array($ret))    //Only return data in an array, otherwise it's an error
                
return $ret;
        } else {
            return 
$this->GetErrorNum($this->connectoid);
        }
    }
    
    public function 
GetBenchmarks() {
        
$this->TotalBenchmarks();
        return 
$this->benchmarks;
    }
    
    private function 
TotalBenchmarks() {
        
$this->benchmarks[Query][result][total] = $this->benchmarks[Query][result][end] - $this->benchmarks[Query][result][start];
        
$this->benchmarks[Query][row][total] = $this->benchmarks[Query][row][end] - $this->benchmarks[Query][row][start];
    }
    
    protected function 
GetErrorNum($c) {
        return 
mysql_errno($c);
    }
    
    public function 
__destruct() {
        if (
$this->IsConnected())
            
mysql_close($this->connectoid);
    }
}

?>
PHP Code:
<html>

<?php

ini_set
("memory_limit","256M");
ini_set("max_execution_time","600");

//Automagically load Classes where needed from ../includes/ClassName.class.php
function __autoload($class_name) {
    require_once 
'../includes/' $class_name '.class.php';
}

function 
DatabaseGetMax() {

    
$db_time_start microtime(true);
    
$db = new Database;
    
$db_time_query microtime(true);
    
$db_spells $db->Query("SELECT SQL_NO_CACHE MAX(id) FROM spells_new");
    
$db_time_end microtime(true);
    
    
$db_time_total_overhead $db_time_query $db_time_start;
    
$db_time_total_query $db_time_end $db_time_query;
    
$db_time_total_mysql $db->GetBenchmarks();
    
$db_time_total $db_time_end $db_time_start;
    echo 
"Result: " $db_spells[1]["MAX(id)"] . "<br>\n";
    echo 
"Class Time: " $db_time_total_overhead " seconds<br>\n";
    echo 
"Query Time: " $db_time_total_query " seconds (MySQL Time: " $db_time_total_mysql[Query][result][total] . " seconds)<br>\n";
    echo 
"Total Time: " $db_time_total " seconds<br>\n";

}

function 
DatabaseLoad() {

    
$db_time_start microtime(true);
    
$db = new Database;
    
$db_time_query microtime(true);
    
$db_spells $db->Query("SELECT SQL_NO_CACHE * FROM spells_new");
    
$db_time_end microtime(true);
    
    
$db_time_total_overhead $db_time_query $db_time_start;
    
$db_time_total_query $db_time_end $db_time_query;
    
$db_time_total_mysql $db->GetBenchmarks();
    
$db_time_total $db_time_end $db_time_start;
    echo 
"Spells Loaded: " count($db_spells) . "<br>\n";
    echo 
"Class Time: " $db_time_total_overhead " seconds<br>\n";
    echo 
"Query Time: " $db_time_total_query " seconds (MySQL Time: " $db_time_total_mysql[Query][result][total] . " seconds)<br>\n";
    echo 
"Total Time: " $db_time_total " seconds<br>\n";

}

function 
FileGetMax() {

    
$file_dir "";    // needs / at the end if anything other than the current directory
    
$file_name "spells_us.txt";
    
    
$file_time_start microtime(true);
    if (
file_exists($file_dir $file_name) && is_readable($file_dir $file_name)) {

        
$file_time_load microtime(true);
        
$Lines file($file_dir $file_name);
        
        
$file_time_parse microtime(true);
        foreach(
$Lines as $key => $value) {
            
$Data[$key] = explode("^"$value);
        }

        
$file_time_end microtime(true);

    } else {
        echo 
"Unable to read: " $file_dir $file_name "<br>\n";
    }
    
    if (!
$file_time_end)
        
$file_time_end microtime(true);
    
    
$file_time_total_open $file_time_load $file_time_start;
    
$file_time_total_load $file_time_parse $file_time_load;
    
$file_time_total_parse $file_time_end $file_time_parse;
    
$file_time_total $file_time_end $file_time_start;
    echo 
"Result: " $Data[count($Data)-1][0] . "<br>\n";
    echo 
"Open Time: " $file_time_total_open " seconds<br>\n";
    echo 
"Load Time: " $file_time_total_load " seconds<br>\n";
    echo 
"Parse Time: " $file_time_total_parse " seconds<br>\n";
    echo 
"Total Time: " $file_time_total " seconds<br>\n";


}

function 
FileLoad() {

    
$file_dir "";    // needs / at the end if anything other than the current directory
    
$file_name "spells_us.txt";
    
    
$file_time_start microtime(true);
    if (
file_exists($file_dir $file_name) && is_readable($file_dir $file_name)) {

        
$file_time_load microtime(true);
        
$Lines file($file_dir $file_name);
        
        
$file_time_parse microtime(true);
        foreach(
$Lines as $key => $value) {
            
$Data[$key] = explode("^"$value);
        }

        
$file_time_end microtime(true);

    } else {
        echo 
"Unable to read: " $file_dir $file_name "<br>\n";
    }
    
    if (!
$file_time_end)
        
$file_time_end microtime(true);
    
    
$file_time_total_open $file_time_load $file_time_start;
    
$file_time_total_load $file_time_parse $file_time_load;
    
$file_time_total_parse $file_time_end $file_time_parse;
    
$file_time_total $file_time_end $file_time_start;
    echo 
"Spells Loaded: " count($Lines) . "<br>\n";
    echo 
"Open Time: " $file_time_total_open " seconds<br>\n";
    echo 
"Load Time: " $file_time_total_load " seconds<br>\n";
    echo 
"Parse Time: " $file_time_total_parse " seconds<br>\n";
    echo 
"Total Time: " $file_time_total " seconds<br>\n";
    
}

echo 
"<b>DatabaseGetMax()</b><br>\n";
DatabaseGetMax();
echo 
"<br>\n";
echo 
"<b>DatabaseLoad()</b><br>\n";
DatabaseLoad();
echo 
"<br>\n";
echo 
"<b>FileGetMax()</b><br>\n";
FileGetMax();
echo 
"<br>\n";
echo 
"<b>FileLoad()</b><br>\n";
FileLoad();

?>

</html>
Code:
DatabaseGetMax()
Result: 11999
Class Time: 0.000842094421387 seconds
Query Time: 0.000253915786743 seconds (MySQL Time: 0.000201940536499 seconds)
Total Time: 0.00109601020813 seconds

DatabaseLoad()
Spells Loaded: 11540
Class Time: 0.000181913375854 seconds
Query Time: 1.7691822052 seconds (MySQL Time: 0.547831058502 seconds)
Total Time: 1.76936411858 seconds

FileGetMax()
Result: 11999
Open Time: 3.50475311279E-05 seconds
Load Time: 0.0381419658661 seconds
Parse Time: 0.978446960449 seconds
Total Time: 1.01662397385 seconds

FileLoad()
Spells Loaded: 11540
Open Time: 3.38554382324E-05 seconds
Load Time: 0.0379700660706 seconds
Parse Time: 0.978180885315 seconds
Total Time: 1.01618480682 seconds
However, if we are talking about JUST loading the spells (which can't be done, since we need to know what the highest spell ID is before we load them into shared memory), loading from a file is considerably faster.

Quote:
Originally Posted by KLS View Post
-In my opinion you made it harder on new users who now have to try to figure out 'hey there's two systems for spells, wait do I need them both? I can't find the db table I need anywhere help!!'.
That's why I'm not sure if it would be better to give the option or to shove it down everyone's throat (I prefer the former). I guess the expectation would be to switch it over to completely DB. Giving the options would just give an "easier" transition in the short term.

Quote:
Originally Posted by MNWatchdog View Post
It wasnt broke, so why are you fixing it?

Youre just adding an additional level of complication IMO.
Why have a database if we're not going to take advantage of it? Yes, we can have the spells stored in a file, but we could also have items, spawns, NPC types, merchant lists, spell lists, AAs, zones, zone servers, etc all in files. But that's just crazy. That's why we have a variables system & a rules system instead of config files like with the MaNGOS emulator (for WoW).
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #29  
Old 10-28-2008, 03:28 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I think it's a good idea as a supplement to tools but again I'm not sure it's the greatest idea for the base server. I don't want to discourage you if you really want to put forth the effort to not only create the database but create the tools to input and extract spells from it.

However I don't see much reason to actually put it in the server standalone is what I was trying to say, having a unified standard for tools would simplify their design considerably.
Reply With Quote
  #30  
Old 10-28-2008, 03:34 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

Theres a millions ways to trap a mouse, but the snap trap works with 95% efficiency.

Personally, I think you should change to the DB method and it only with a importer and exporter app for the spells.txt file.
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 11:14 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3