Bit of zone code
Sorry if this is the wrong place to post this, I couldn't see a better place.
Please note the code below is not fully functional. It requires manual entries in the database and does not really do anything yet. I am posting this code incase someone else has a use for pieces of it, even though it is probably terrible code. I would also appreciate comments on what I should change, etc. After messing around with zone instancing I have finally come to a road block. Basically the problem I have run into is the current code seems to be setup to use the zone short name as the unique id. This causes a problem since that short_name can not be changed on a copied zone entry because the short name is also used to pull the map data (please correct me if I am wrong) So anyhow, below is the code I have written so far. It basically only copies the zone information into a new zone table entry. When the server tries to load that new entry it crashes. The crash seems to be caused by two entries with the same short_name since in multiple places in the code the short name is used as the unique id instead of the zoneidnumber. To get the code to semi function the instZflagNum and instZorgID must be manually filled along with the zone.insttype. Character_.instZflagNum – pick any number higher then 1000 Zone.insttype – pick the zone you want to be instanced then set this to 1 or greater Character_.instZflagNum – use the zoneidnumber of the zone you set insttype on. Sorry my SQL and C++ are bad but here is an attempted diff. If someone is willing to write the true SQL commands for the below database changes I would be very grateful. Required SQL Zone table: ADD insttype column: tinyint(1) unsigned zerofill NOT NULL default '0', Change PRIMARY KEY to zoneidnumber Change UNIQUE KEY to zoneidnumber Character_ table: ADD instZflagNum column int(10) unsigned NOT NULL default '0' ADD instZOrgID column int(11) NOT NULL default '0' Variables table Insert into `variables`(`varname`,`value`,`information`,`ts`) values (curInstFlagNum','1000','Character:curInstFlagNum' ,'2008-09-05 04:46:47'); Rules_values table: insert into `rule_values`(`ruleset_id`,`rule_name`,`rule_value `) values (0,'World:dfltInstZflag','1000') Code changes (written on 7.0-1128 source) Zonedb.h Line 171 to Line 176 Code:
int8 GetInstType(int32 zoneid); Line 1381 to line 1521 (basically append to the end of zonedb.cpp) Code:
int8 ZoneDatabase::GetInstType(int32 zoneid) { zoning.cpp Line 123 to line 157 Code:
//Prelim Instance zone code |
The way you zone into an instance is to use the instance ID, instead of the short zonename. Each instance is tagged as zoneshortname_zoneid_instanceid. The /zone command accepts the zone shortname, zone id, or instance id as parameters.
I'm not sure how the instance ID is calculated. But using '/zone instanceid' allows you to zone into an instance that you're not assigned to. This is where the /adventure command came into play; it listed all of the LDON adventures that were active on the server, the time the instance started, how many seconds until it shut down, the owner of the instance, and the other members that were in the group at the time the instance was requested. Later instancing may be using another method though and is not tracked by /adventure. |
Steve,
Sorry if this comes across rude, I honestly don’t mean it rudely. I don’t think I understand your post. Are you saying there is code already written that allows for instancing? Or is this a way you think instancing would work? On a different note. Can someone move this post? The more I think about the less I think it belongs in Server Code Submissions. Development:Development or Development::Feature Requests are probable better places. Also, can someone point me to where the code loads the map data and where the code sends the zonename to the client? The reason I am wanting those is because I think the shortname problem may be solved by: Adding the zoneidnumber or access flag number onto the shortname for any instances zones Then temporarily removing the zoneidnumber from the shortname when it is passed to the function that loads map data. The same would probably need done to the function that sends the zonename to the client. Actually anytime the shortname is called to reference other data this would need done. But the map data and client packet would be a good start. Another thing is LoadZoneNames() in database.cpp will need reran each time a instanced zone is added/removed to/from the database. Any thoughts? |
No worries, I don't think I was clear what I was getting at. I was pointing out how instancing worked on Live, not the emulator. Right now, the emulator has no instancing of any kind.
I was getting at how you might be able to go about getting the client to zone into an instanced zone, once instancing is up and operational. If the way this is done is deciphered, it might make custom zones possible via the /zone command, via /zone instanceid... My comment was more of a side note, and I apologize I wasn't more clear. |
Well I have zone instancing semi functional. I say semi because it needs tested. I only had a few minutes at lunch to test it but I was able to zone into different instances of the same zone. I will try to get a diff posted tonight. Though it may take awhile to complete the diff. Unless does anyone know an easy way to get a code diff aside from copy/paste?
I probably should have kept track of my changes but alot of them were trial and error. |
This code enables zone instancing (still needs work though)
Though it still requires a sql command to copy the zone information over, if you don't want to crash your server each time a zone gets added. So here is how it works (run required SQL commands before doing this :)) Select a zone you want to instance Set that zone's insttype to 1 Select a character you want to access that zone Set that character's instZflagNum to a number greater than 1000 instZOrgID to the zoneID of the zone you picked Run the following query Code:
INSERT INTO zone (short_name, file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, zoneidnumber, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer) SELECT NEWZONESHORTNAME, file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, instFlagNum, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer FROM zone WHERE zoneidnumber = target_zone_ID) replace instFlagNum with the instflagnum you chose replace target_zone_id with the zone you chose to instance zone character into the zone you picked. rinse and repeat with second character changing the instZflagNum K, here is my example I want to instance blackburrow (has a zoneid of 17 I set blackburrow's insttype to 1 in the zone table I want my toon MonkGod to access an instance of blackburrow I set MonkGod's instZflagNum to 1001 instZOrgID to 17 Run the following query Code:
INSERT INTO zone (short_name, file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, zoneidnumber, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer) SELECT 1001blackburrow, file_name, long_name, safe_x, safe_y, safe_z, graveyard_id, min_level, min_status, 1001, timezone, maxclients, weather, note, underworld, minclip, maxclip, fog_minclip, fog_maxclip, fog_blue, fog_red, fog_green, sky, ztype, zone_exp_multiplier, walkspeed, time_type, fog_red1, fog_green1, fog_blue1, fog_minclip1, fog_maxclip1, fog_red2, fog_green2, fog_blue2, fog_minclip2, fog_maxclip2, fog_red3, fog_green3, fog_blue3, fog_minclip3, fog_maxclip3, fog_red4, fog_green4, fog_blue4, fog_minclip4, fog_maxclip4, flag_needed, canbind, cancombat, canlevitate, castoutdoor, insttype, insttimer FROM zone WHERE zoneidnumber = 17) I replaced NEWZONESHORTNAME with 1001blackburrow I replaced instFlagNum 1001 I replaced target_zone_id 17 I then repeat these step with Aries, my other character. changing the instZflagNum to 1002 I doubt that made any sense but hopefully we can get the zone to be copied when the toon zones without it crashing the server. Currently the zone info gets copied to the database but the server crashes. With some tweaking all that would be required is a quest command that sets a characters InstZflagNum and instZOrgID. Anyhow here is the required changes. This was done against 1129 using PEQ database. Please let me know what bugs you notice. Required SQL Code:
ALTER TABLE `zone` ADD column `insttype` tinyint (1) zerofill unsigned NOT NULL default '0'; Near Line 482 Code:
if(GetZoneID() == ztz->current_zone_id) // this is a request from the egress zone Line 644 EnterWorld(bool TryBootup) Code:
void Client::EnterWorld(bool TryBootup) { Please note this code will crash your server if the zone is not already in your database Line 125 Code:
//Checks if the zone can be instanced, character has a instance flag, and Near Line 181 Code:
int32 GetDfltInstZFlag(); Code:
int32 GetInstZoneID(int32 zoneID, const char* charName); Code:
int32 GetCharInstFlagNum(int32 charID); Code:
int32 GetCharInstZOrgID(int32 charID); Line 1173 Replace Database::GetZoneName with Code:
const char* Database::GetZoneName(int32 zoneID, bool ErrorUnknown) { Code:
int32 Database::GetDfltInstZFlag(){ Code:
#include <string> Code:
int32 ZoneDatabase::GetInstType(int32 zoneid) { Line 169 at the end of Zone Related Code:
int32 GetInstType(int32 zoneid); |
All times are GMT -4. The time now is 10:34 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.