|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc. |
 |
|
 |

07-06-2009, 12:51 AM
|
Dragon
|
|
Join Date: Apr 2009
Location: California
Posts: 814
|
|
Technically, the best thing to do to utilize this availability without cluttering up the doors table with non-door objects would be to create a new table:
Code:
CREATE TABLE `static_objects` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`zoneid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`version` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`x` FLOAT NOT NULL DEFAULT 0,
`y` FLOAT NOT NULL DEFAULT 0,
`z` FLOAT NOT NULL DEFAULT 0,
`heading` FLOAT NOT NULL DEFAULT 0,
`size` SMALLINT UNSIGNED NOT NULL DEFAULT 100,
`incline` INTEGER NOT NULL DEFAULT 0,
`model` VARCHAR(32) NOT NULL,
`solid` TINYINT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
INDEX `idx_staticobjects_zoneid`(`zoneid`),
INDEX `idx_staticobjects_version`(`version`)
)
ENGINE = InnoDB;
Then piggy-back static object loading in the door spawns of the entity_list.
File: zone.h, Line 111 - Class Zone
Code:
...
void LoadZoneDoors(const char* zone, int16 version);
+ void LoadZoneStaticObjects(int32 zoneid, const char* shortname, int16 version);
bool LoadZoneObjects();
...
File: zone.cpp, Line 698 - new function Zone::LoadZoneStaticObjects()
Code:
void Zone::LoadZoneStaticObjects(int32 zoneid, const char* shortname, int16 version)
{
if ((!zoneid) || (!shortname))
{
return;
}
LogFile->write(EQEMuLog::Status, "Loading static objects for %s ...", shortname);
int32 maxdoorid = 1; // If there aren't any doors for this zone, start with #1
int32 maxid = 2000000000; // Way out of range of normal use
char errbuf[MYSQL_ERRMSG_SIZE];
char query[256];
MYSQL_RES *result;
MYSQL_ROW row;
sprintf(query, "SELECT MAX(doorid) FROM doors WHERE zone='%s' AND version=%u", shortname, version);
if (database.RunQuery(query, strlen(query), errbuf, &result))
{
if (row = mysql_fetch_row(result))
{
maxdoorid = atoi(row[0]) + 1;
}
mysql_free_result(result);
}
sprintf(query, "SELECT MAX(id) FROM doors");
if (database.RunQuery(query, strlen(query), errbuf, &result))
{
if (row = mysql_fetch_row(result))
{
maxid = atoi(row[0]) + 1;
}
mysql_free_result(result);
}
sprintf(query, "SELECT x, y, z, heading, size, incline, model, solid FROM static_objects WHERE zoneid=%d AND version=%d", zoneid, version);
if (database.RunQuery(query, strlen(query), errbuf, &result))
{
Door newdoor;
Doors* door;
memset(&newdoor, 0, sizeof(Door));
int32 r = 0;
int32 c;
strncpy(newdoor.zone_name, shortname, 16);
memcpy(newdoor.dest_zone, "NONE", 5);
for (r = 0; row = mysql_fetch_row(result); r++)
{
c = 0;
newdoor.db_id = maxid + r;
newdoor.door_id = maxdoorid + r;
newdoor.pos_x = atof(row[c++]);
newdoor.pos_y = atof(row[c++]);
newdoor.pos_z = atof(row[c++]);
newdoor.heading = atof(row[c++]);
newdoor.size = atoi(row[c++]);
newdoor.incline = atoi(row[c++]);
strncpy(newdoor.door_name, row[c++], 32);
switch (newdoor.opentype = atoi(row[c++]))
{
case 0:
newdoor.opentype = 9;
break;
case 1:
newdoor.opentype = 31;
break;
}
door = new Doors(&newdoor);
entity_list.AddDoor(door);
}
mysql_free_result(result);
}
}
File: zone.cpp, Line 954 - Zone::Init()
Code:
...
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
+ zone->LoadZoneStaticObjects(zone->GetZoneID(), zone->GetShortName(), zone->GetInstanceVersion());
zone->LoadBlockedSpells(zone->GetZoneID());
...
And it works!
If you're wondering why I'm sticking it in doors, instead of the zone objects table, it's because I couldn't figure out any way to use the zone objects system that didn't involve an openable tradeskill container or pickable ground spawn item.
Anyway, forget adding records to the doors table. Much better to use this new static_objects table!
|
 |
|
 |

07-06-2009, 08:38 AM
|
Dragon
|
|
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
|
|
Another stunning customization miracle you've worked up! Bravo! I can definitely see some potential in using this to help build future zones as well, marvelous.
|

07-06-2009, 01:07 PM
|
Discordant
|
|
Join Date: Apr 2004
Location: 127.0.0.1
Posts: 402
|
|
I played with static objects back in March and had very good luck with them as well. There we're a few instances where models took extra modifications to get working, as they created invisible walls of death.
I definitely don't recommend using the doors table however.
|

07-06-2009, 01:25 PM
|
Dragon
|
|
Join Date: Apr 2009
Location: California
Posts: 814
|
|
Yeah, using a different table is definitely the way to go.
What methods were you using to play with static objects?
|

07-06-2009, 01:45 PM
|
Developer
|
|
Join Date: Mar 2009
Location: -
Posts: 228
|
|
I have used this method in the past to add objects to zones. Has always worked well, just a pita searching through the files and figuring out what everything is.
|

07-06-2009, 02:52 PM
|
Forum Guide
|
|
Join Date: Sep 2003
Location: California
Posts: 1,474
|
|
Shendare, this is brilliant!
I am playing with this now, and I'll see what I can do with this.
GeorgeS
|
 |
|
 |

07-07-2009, 05:03 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Instead of having a 3rd table for objects in zones, couldn't we just add 1 more field to the current zone objects table that would let us toggle if we want it to be sent as a normal object or as a non-clickable door? Then, just adjust the object code to send those type of objects as a door instead with some default values? The zone objects table is already under-utilized due to this limitation, so it would be nice to have the option for this without having to use the misleading doors table for it. For the cases of static objects like this, you should just need the name, the zone, the loc and then set the toggle field to 0 or 1 (whichever means non-clickable) to finalize it and the rest would get ignored. Instead of adding a new field for it, we could even define a certain setting in one of the existing fields to cause it to make the switch. Something like setting the type to 999 should work fine.
I think the reason why that stuff is currently done in the doors table is because that is how they send it on Live. So, we try to duplicate that as close as possible. For the purpose of the packet collectors, it is easiest to handle the DB the same way that Live sends the information. It wouldn't be bad to have another table for it for adding custom stuff in and making it a little easier, but the existing tables already work for that so it isn't really a requirement. If you really wanted to make adding static objects easier, you could make a command that lets you add them in-game by simply typing something like "#objectadd static|door|tradeskill <Object Name>" at the location you want to add the item. Then, after re-zoning, you just adjust the table as needed to make sure it is placed exactly how you wanted it. I am not really apposed to another table for it, though.
Last edited by trevius; 07-07-2009 at 01:18 PM..
|
 |
|
 |
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 10:42 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |