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 02-26-2004, 12:02 AM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default grids

why are they limited to 50 waypoints ?

is it possible to create for example 2 grid tables
one called "grid"
with id, type and type2
another called "waypoints"
with grid_id, number, x, y, z, heading
?

=)
__________________
Sandy
Reply With Quote
  #2  
Old 02-26-2004, 12:40 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

this sounds good idea : more functionnality as no limit to WP count, and space saved as empty WP account for nothing. Using correct indexes could keep overhead to a minimum.

Also, it relieves the error prone 'what value for an empty waypoint ? is it NULL, " ", 0 ?'

unfortunatly, this can not be done without changing the code AFAIK, as you cant retrieve multiple lines data across a single line, what would leave the code untouched (but i may need SQL lessons)

example using a wp table :
create table wp (grid_id int(11),number int(4), x, float, y float, z float);
insert into wp values (1, 1, 7,8, 34.5, -5.0);
insert into wp values (1, 1, 8,9, 21.5, -5.1);

Code:
bool Database::GetWaypoints(int16 grid, int8 num, char* data) {
    char *query = 0;
  char errbuf[MYSQL_ERRMSG_SIZE];
    MYSQL_RES *result;
    MYSQL_ROW row;
  if (RunQuery(query, MakeAnyLenString(&query,"SELECT type,type2,concat(x," ",y," ",z) from grid where id = %i and grid.id=wp.grid_id and wp.number=%i", grid,num),errbuf,&result)) {
    safe_delete_array(query);
    if (mysql_num_rows(result) == 1) {
      row = mysql_fetch_row(result);
      strcpy(data, row[2]);
      mysql_free_result(result);
      return true;
    }
    mysql_free_result(result);
  }
  else {
    cerr << "Error in GetWaypoints query '" << query << "' " << errbuf << endl;
    safe_delete_array(query);
  }
  return false;
}
did i get you right ?
Reply With Quote
  #3  
Old 02-26-2004, 06:55 PM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

does ID's have a max value to make grids working ? i tried 107042 for a grid it didn't work, i tried 50 for the same grid it worked =(
__________________
Sandy
Reply With Quote
  #4  
Old 02-27-2004, 12:42 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

there are several max defines in the EMuShareMem stuff, but none seems related to grids, at first glance.

The field size spawn2.gridpath and grid.id in the DB is int(10), so there should be no pb. Is it this ID, or another ID ?

Or maybe, simply in the spawn command:
Code:
else if (!strcmp(command,"spawn")) {
                                //char tempa[100];
                                const NPCType* tmp = 0;
                                int16 grid = atoi(arglist[1]);
                                int8 guildwarset = atoi(arglist[2]);
Reply With Quote
  #5  
Old 02-27-2004, 12:05 PM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

it's the int16 that limits it =(

i have other suggestions =)

2 tables then :

table : grid
fields : zone, id, type, type2

table : waypoints
fields : grid_id, number, x, y, z, heading, pause

table : spawn2
fields : need to add a starting_waypoint, and path_reverse

at this moment
waypoints are limited to 50, with a waypoints table they won't be limited
waypoints have no heading data =(

with zone, we will be able to start grids ids at 1 for each zone ( i don't know if it's better or not than autoincrements )

with starting_waypoint, we'll then be able to share grids with different monsters and they'll start at different grid waypoints ( no more trains ! =)
path_reverse would be nice if we want to make monsters start their patrol in different directions

=)
__________________
Sandy
Reply With Quote
  #6  
Old 02-27-2004, 02:20 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

k, don't blame me, i'm just playing the bad guy here

Quote:
with zone, we will be able to start grids ids at 1 for each zone ( i don't know if it's better or not than autoincrements )
if the int16 is annoying you, then it's much better to make it an int32 (i.e. an int, in normal programming language :lol. Adding zone to waypoint is does not add to fucntionnality, and you'd have to create 2 indexes (one for zone, one for number) in case perf becomes an issue.

Quote:
with starting_waypoint, we'll then be able to share grids with different monsters and they'll start at different grid waypoints ( no more trains ! =)
atm, very few grids are shared; One effect is cause of the other, but yet :
Code:
mysql> select count(distinct spawngroupID) as nombre, pathgrid from spawn2 group by pathgrid order by nombre desc limit 100;
+--------+----------+
| nombre | pathgrid |
+--------+----------+
|  53265 |        0 |
|      2 |     9073 |
|      2 |     5022 |
|      2 |        1 |
|      2 |        2 |
|      2 |        3 |
|      2 |     5032 |
|      2 |        4 |
|      2 |     5034 |
|      2 |     5170 |
|      2 |     9071 |
|      1 |     1003 |
|      1 |     1019 |
only 10 grids shared, out of 382. A few duplicates would not harm. Well, this DB may not be representative.

reverse_path and starting_waypoint are not usefull if pathgrid is unique to each mob, else anywway starting_waypoint must be close to spawn point, so that's little change if any, and reverse_order is much like the patrol wandering option

Sorry, that was the bad guy part.

On the normal guy part :

- i'd like to know of efficiency on real servers for the normalized (duno if it's the english word, that means table splitted) version of pathgrid. This should be little overhead (grids are loaded boot time, or spawn time, aren't they ?). If devs think this can be interesting, we could work on spawn 2 functions.

- i believe this is a good idea.

- Let's go a bit further : waypoints are 'you can be here' points, and path ordering is 'there is direct way from wp N to wp N+1'. One could define wp a b c d e f and say :
grid #1 is 1:a 2:b 3:e 4:f
grid #2 is 1:d 2:c
and even : grid #3=#1 then #2

- there have been threads about wp design (i came across an old one like Nov 2002 today) dealing with grids. Recently, we discussed the matter of mobs fleeing, still to be done. Maybe changes to the grid system should now start thinking of the map and its usages (wandering, but also fleeing, whatever ...)

imho
- perf can be adressed fairly easily, so build clean.
- there should be no limit to grid number
- there should be no limit to wp in a grid
- the easier for the world builder to define a grid, the better.
Reply With Quote
  #7  
Old 02-27-2004, 02:53 PM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

for shared grids
if you look carefully at eqlive pathing, you'll see that a lot of monsters are sharing exactly the same path
if you didn't find shared grids in your database it's because the actual system make us to create a grid for each monster else monsters will roam like trains =)

for starting position it's needed when grids are shared because a monster won't always spawn close to the waypoint we want him to go at first

reverse path is needed too for shared grids
if the 2 monsters spawn at the 2 ends of the path, patrol will do its job, but if the 2 monsters spawn in the middle of the path and we want them to go in different directions and do a cycle it could be usefull ? =)
__________________
Sandy
Reply With Quote
  #8  
Old 02-27-2004, 03:15 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

That was clear from your post, and i didn't disagree.


What i meant is that pathing is a solution for mob displacement, that we experience the limits of.
Let's change it, fine.
So we must try to think of everything involved.

http://www.eqemulator.net/forums/vie...highlight=path
http://www.eqemulator.net/forums/vie...highlight=path
http://www.eqemulator.net/forums/vie...highlight=path
to mention only a few threads already discussed.

*** added ***
i was curious about tweaking the code. Below are changes according to the discussion. It may work (i need to sleep now, so just made the changes, compiled, but no testing whatsoever, not even running). It may not work.

- did not update the commands, you must edit the DB by hand.
- no starting point stuff. There is still something i can't figure out : how does the mob get from spawn point to the first waypoint ? There more to discuss about this.

below are the diffs as of feb 23 cvs

Code:
--- ./../common/_database.cpp   2004-02-28 04:51:14.000000000 +0000
+++ ../common/database.cpp      2004-02-28 06:08:24.000000000 +0000
@@ -4875,14 +4875,23 @@

 bool Database::GetWaypoints(int16 grid, int8 num, char* data) {
     char *query = 0;
+               char *qstr = 0;
        char errbuf[MYSQL_ERRMSG_SIZE];
     MYSQL_RES *result;
     MYSQL_ROW row;
-       if (RunQuery(query, MakeAnyLenString(&query,"SELECT type,type2,wp1,wp2,w
p3,wp4,wp5,wp6,wp7,wp8,wp9,wp10,wp11,wp12,wp13,wp14,wp15,wp16,wp17,wp18,wp19,wp2
0,wp21,wp22,wp23,wp24,wp25,wp26,wp27,wp28,wp29,wp30,wp31,wp32,wp33,wp34,wp35,wp3
6,wp37,wp38,wp39,wp40,wp41,wp42,wp43,wp44,wp45,wp46,wp47,wp48,wp49,wp50 from gri
d where id = %i",grid),errbuf,&result)) {
+               switch( num ){
+                       case 0:
+                               qstr="select type from grid where id=%i";
+                       case 1:
+                               qstr="select type2 from grid where id=%i";
+                       default:
+                               qstr="select concat(x," ",y," ",z," ",pause) fro
m waypoints where grid_id=%i and num=%i";
+               }
+       if (RunQuery(query, MakeAnyLenString(&query,qstr,grid,num-1),errbuf,&res
ult)) {
                safe_delete_array(query);
                if (mysql_num_rows(result) == 1) {
                        row = mysql_fetch_row(result);
-                       strcpy(data, row[num]);
+                       strcpy(data, row[0]);
                        mysql_free_result(result);
                        return true;
                }
Code:
--- _MobAI.cpp  2004-02-28 04:51:44.000000000 +0000
+++ MobAI.cpp   2004-02-28 06:13:12.000000000 +0000
@@ -1203,6 +1203,16 @@
                        cur_wp = cur_wp + 1;
                break;
 // end Myra
+// KD reverse
+    case 5:
+                 if(reached_beginning){
+                               cur_wp = max_wp;
+                       }else{
+                               cur_wp = cur_wp - 1;
+                       }
+               break;
+// end KD
+
        }
        // Check to see if we need to update the waypoint. - Wes
        if (cur_wp != old_wp)
@@ -1430,18 +1440,20 @@
        adverrorinfo = 7561;
        this->CastToNPC()->SetGrid(grid); //Assign grid number
        roamer = true; //This is a roamer
-       for (int i=0; i < 52; i++) {
+       for (int i=0; i >=0; i++) {
                adverrorinfo = 7562;
                char wpstruct[100];
                if (!database.GetWaypoints(grid, i, wpstruct))
-                       i=53;
+                       i=-1;
                else {
-                       if (i < 2) {
-                               adverrorinfo = 7563;
-                               //wp_a[i+1] = atoi(wpstruct); //Assign wandering
 type and pause type
-                               ((i==0) ? wandertype : pausetype) = atoi(wpstruc
t);
+                       switch (i){
+                               case 0:{
+                                 wandertype = atoi(wpstruct); break;
                        }
-                       else { //Retrieve a waypoint
+                               case 1:{
+                                 pausetype = atoi(wpstruct); break;
+                               }
+                               default:{
                                wplist * newwp = new wplist;
                                adverrorinfo = 7564;
                                Seperator sep(wpstruct, ' ', 4);
@@ -1456,6 +1468,7 @@
                                        Waypoints.AddItem(newwp);
                                }
                        }
+               }

                 UpdateWaypoint(0);
          SetWaypointPause();
plus some stuff to the DB
Code:
-- create waypoints table
-- no index defined (should be on grid_id and num presumbly)
create table waypoints (
  grid_id int(10),
  num int(10),
  x float,
  y float,
  z float,
  pause int(10));
-- extra columns not dropped


insert into waypoints values(1064 , 1 , -324.0 ,-987.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -710.0 ,-883.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -899.0 ,-1308.0 , -54.0 , 5);
insert into waypoints values(1064 , 1 , -159.0 ,-1658.0 , -54.0 , 5);

-- wandertype
update grid set type=5 where grid_id=1064;
the waypoints are valid for freporte.Wandertype 5 is new reverse mode.

If you want to give it a try...
Reply With Quote
  #9  
Old 03-20-2004, 06:24 AM
sandy
Hill Giant
 
Join Date: Oct 2002
Posts: 212
Default

any news about grids ?
=)
__________________
Sandy
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 10:31 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3