EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   Fix to #zone to handle nektulos instances (https://www.eqemulator.org/forums/showthread.php?t=40520)

superemu 03-31-2016 03:47 PM

Fix to #zone to handle nektulos instances
 
Hi all. Noobie here. I posted this on the PEQ forums and figured I should post it here as well. I hope I am doing this right. :)

I noticed that with the current release of the database and the current EQEmulator code, using #zone to go to nektulos with the Underfoot client would place the player in the wrong instance of nek. The terrain would be right since the UF eqg file is the new version of the zone. However, the NPC and object placement would be all wrong. Bridge guards would be swimming in the river, the PoK book would be gone, the zones wouldn't work, etc. Doing the same zone command in the Titanium client worked properly, because it was putting the player in the old version of zone. The problem is that the EQEmulator zone command code does not account for zone instances. New nek is run as an instance (instance number 1).

I endeavored to change the code to handle the zone command to nek the same way the doors and zone-points tables handle it. I needed a mapping between instance number and client version mask for each zone that can be instanced (in this case, only nektulos). I figured that I could add a client_version_mask column to the zone table that would be used to determine which instance of the zone to zone to based on the version of the current client being run. But rather than change the structure of an existing system table I decided to add a new table called 'zone_command_instances'.

Here is the SQL to create the table and build the nektulos records and the changed version for the zone command code (in zone\command.cpp):

Code:

create table if not exists zone_command_instances
(
        zoneidnumber int(4),
        instance smallint(5) unsigned,
        client_version_mask int(10) unsigned default '4294967295',
        index zoneidnumber (zoneidnumber),
        unique index zoneinstance (zoneidnumber, instance)
);

insert into zone_command_instances
(zoneidnumber, instance, client_version_mask)
values
(25, 0, 3),
(25, 1, 4294967292)
on duplicate key update client_version_mask = values(client_version_mask);

Code:

diff --git a/zone/command.cpp b/zone/command.cpp
index dbbed07..5ec733a 100644
--- a/zone/command.cpp
+++ b/zone/command.cpp
@@ -1094,13 +1094,26 @@ void command_zone(Client *c, const Seperator *sep)
                Bot::ProcessClientZoneChange(c);
 #endif
 
+        // Yarko 3/31/2016 - Use new zone_command_instances table to determine which version of the zone to go to
+        uint32 instance = 0;
+        std::string query = StringFormat("SELECT instance FROM zone_command_instances WHERE zoneidnumber = %i AND client_version_mask & %i", zoneid, c->GetClientVersionBit());
+        auto results = database.QueryDatabase(query);
+        if (results.Success() && results.RowCount() > 0) {
+                instance = atoi(results.begin()[0]);
+        }
+        // End Yarko update
+
        if (sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4)){
                //zone to specific coords
-                c->MovePC(zoneid, (float)atof(sep->arg[2]), atof(sep->arg[3]), atof(sep->arg[4]), 0.0f, 0);
-                }
+                // Yarko 3/31/2016 - include instance number
+                //c->MovePC(zoneid, (float)atof(sep->arg[2]), atof(sep->arg[3]), atof(sep->arg[4]), 0.0f, 0);
+                c->MovePC(zoneid, instance, (float)atof(sep->arg[2]), atof(sep->arg[3]), atof(sep->arg[4]), 0.0f, 0);
+        }
        else
                //zone to safe coords
-                c->MovePC(zoneid, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords);
+                // Yarko 3/31/2016 - include instance number
+                //c->MovePC(zoneid, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords);
+                c->MovePC(zoneid, instance, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords);
 }
 
 //todo: fix this so it checks if you're in the instance set


joligario 03-31-2016 05:47 PM

I thought there was a zone instance type command.

Kingly_Krab 03-31-2016 05:50 PM

There is, #zoneinstance.

superemu 03-31-2016 07:30 PM

Ah. Thank you for pointing that out. I actually didn't see that command until after I was done with the work I did! :) It's ok, though. I wanted the #zone command to choose which version automatically based on the running client version as the PoK book does. So, I am still happy with my work.


All times are GMT -4. The time now is 05:22 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.