Browse Source

Support for expansion_flag, min and max client version for transporters table (zone and generic transport type)

Fix #141
Image 3 years ago
parent
commit
8c7da8e039

+ 3 - 0
DB/updates/transporters_table_updates.sql

@@ -0,0 +1,3 @@
+alter table transporters add column expansion_flag int(10) unsigned not null default 0;
+alter table transporters add column min_client_version int(10) unsigned not null default 0;
+alter table transporters add column max_client_version int(10) unsigned not null default 0;

+ 4 - 4
EQ2/source/WorldServer/Object.cpp

@@ -45,11 +45,11 @@ EQ2Packet* Object::serialize(Player* player, int16 version){
 }
 
 void Object::HandleUse(Client* client, string command){
-	vector<TransportDestination*>* destinations = 0;
+	vector<TransportDestination*> destinations;
 	if(GetTransporterID() > 0)
-		destinations = GetZone()->GetTransporters(GetTransporterID());
-	if(destinations)
-		client->ProcessTeleport(this, destinations, GetTransporterID());
+		GetZone()->GetTransporters(&destinations, client, GetTransporterID());
+	if(destinations.size())
+		client->ProcessTeleport(this, &destinations, GetTransporterID());
 	else if (client && command.length() > 0 && appearance.show_command_icon == 1 && MeetsSpawnAccessRequirements(client->GetPlayer())){
 		EntityCommand* entity_command = FindEntityCommand(command);
 		if (entity_command)

+ 4 - 4
EQ2/source/WorldServer/Sign.cpp

@@ -221,7 +221,7 @@ void Sign::SetSignDistance(float val){
 }
 void Sign::HandleUse(Client* client, string command)
 {
-	vector<TransportDestination*>* destinations = 0;
+	vector<TransportDestination*> destinations;
 
 	//The following check disables the use of doors and other widgets if the player does not meet the quest requirements
 	//If this is from a script ignore this check (client will be null)
@@ -234,11 +234,11 @@ void Sign::HandleUse(Client* client, string command)
 	}
 
 	if( GetTransporterID() > 0 )
-		destinations = GetZone()->GetTransporters(GetTransporterID());
+		GetZone()->GetTransporters(&destinations, client, GetTransporterID());
 
-	if( destinations )
+	if( destinations.size() )
 	{
-		client->ProcessTeleport(this, destinations, GetTransporterID());
+		client->ProcessTeleport(this, &destinations, GetTransporterID());
 	}
 	else if( sign_type == SIGN_TYPE_ZONE && GetSignZoneID() > 0 )
 	{

+ 4 - 4
EQ2/source/WorldServer/Widget.cpp

@@ -333,7 +333,7 @@ void Widget::ProcessUse(){
 }
 
 void Widget::HandleUse(Client* client, string command, int8 overrideWidgetType){
-	vector<TransportDestination*>* destinations = 0;
+	vector<TransportDestination*> destinations;
 	//The following check disables the use of doors and other widgets if the player does not meet the quest requirements
 	//If this is from a script ignore this check (client will be null)
 
@@ -349,9 +349,9 @@ void Widget::HandleUse(Client* client, string command, int8 overrideWidgetType){
 	}
 
 	if (client && GetTransporterID() > 0)
-		destinations = GetZone()->GetTransporters(GetTransporterID());
-	if (destinations)
-		client->ProcessTeleport(this, destinations, GetTransporterID());
+		GetZone()->GetTransporters(&destinations, client, GetTransporterID());
+	if (destinations.size())
+		client->ProcessTeleport(this, &destinations, GetTransporterID());
 	else if (overrideWidgetType == WIDGET_TYPE_DOOR || overrideWidgetType == WIDGET_TYPE_LIFT){
 		Widget* widget = this;
 		if (!action_spawn && action_spawn_id > 0){

+ 4 - 0
EQ2/source/WorldServer/World.h

@@ -116,6 +116,10 @@ struct TransportDestination{
 	int32	map_y;
 	int32	faction_id;
 	int32	faction_value;
+
+	int32	expansion_flag;
+	int32	min_client_version;
+	int32	max_client_version;
 };
 
 struct LocationTransportDestination{

+ 3 - 3
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -4811,7 +4811,7 @@ void WorldDatabase::LoadTransporters(ZoneServer* zone){
 	zone->DeleteGlobalTransporters();
 	Query query;
 	MYSQL_ROW row;
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT transport_id, transport_type, display_name, message, destination_zone_id, destination_x, destination_y, destination_z, destination_heading, trigger_location_zone_id, trigger_location_x, trigger_location_y, trigger_location_z, trigger_radius, cost, id, min_level, max_level, quest_req, quest_step_req, quest_completed, map_x, map_y FROM transporters ORDER BY transport_id");
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT transport_id, transport_type, display_name, message, destination_zone_id, destination_x, destination_y, destination_z, destination_heading, trigger_location_zone_id, trigger_location_x, trigger_location_y, trigger_location_z, trigger_radius, cost, id, min_level, max_level, quest_req, quest_step_req, quest_completed, map_x, map_y, expansion_flag, min_client_version, max_client_version FROM transporters ORDER BY transport_id");
 	if(result){
 		while(result && (row = mysql_fetch_row(result))){
 			LogWrite(TRANSPORT__DEBUG, 5, "Transport", "---Loading Transporter ID: %u, transport_type: %s", row[0], row[1]);
@@ -4828,11 +4828,11 @@ void WorldDatabase::LoadTransporters(ZoneServer* zone){
 			if(row[3])
 				message = string(row[3]);
 			if(row[1] && strcmp(row[1], "Zone") == 0)
-				zone->AddTransporter(atoul(row[0]), TRANSPORT_TYPE_ZONE, name, message, atoul(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atof(row[8]), atoul(row[14]), atoul(row[15]), atoi(row[16]), atoi(row[17]), atoul(row[18]), atoi(row[19]), atoul(row[20]), atoul(row[21]), atoul(row[22]));
+				zone->AddTransporter(atoul(row[0]), TRANSPORT_TYPE_ZONE, name, message, atoul(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atof(row[8]), atoul(row[14]), atoul(row[15]), atoi(row[16]), atoi(row[17]), atoul(row[18]), atoi(row[19]), atoul(row[20]), atoul(row[21]), atoul(row[22]), atoul(row[23]), atoul(row[24]), atoul(row[25]));
 			else if(row[1] && strcmp(row[1], "Location") == 0)
 				zone->AddLocationTransporter(atoul(row[9]), message, atof(row[10]), atof(row[11]), atof(row[12]), atof(row[13]), atoul(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atof(row[8]), atoul(row[14]), atoul(row[15]));
 			else
-				zone->AddTransporter(atoul(row[0]), TRANSPORT_TYPE_GENERIC, "", message, atoul(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atof(row[8]), atoul(row[14]), atoul(row[15]), atoi(row[16]), atoi(row[17]), atoul(row[18]), atoi(row[19]), atoul(row[20]), atoul(row[21]), atoul(row[22]));
+				zone->AddTransporter(atoul(row[0]), TRANSPORT_TYPE_GENERIC, "", message, atoul(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atof(row[8]), atoul(row[14]), atoul(row[15]), atoi(row[16]), atoi(row[17]), atoul(row[18]), atoi(row[19]), atoul(row[20]), atoul(row[21]), atoul(row[22]), atoul(row[23]), atoul(row[24]), atoul(row[25]));
 			total++;
 		}
 	}

+ 7 - 9
EQ2/source/WorldServer/client.cpp

@@ -7160,17 +7160,15 @@ void Client::ProcessTeleportLocation(EQApplicationPacket* app) {
 			int32 unique_id = packet->getType_int32_ByName("unique_id");
 			string zone_name = packet->getType_EQ2_16BitString_ByName("zone_name").data;
 			int32 cost = packet->getType_int32_ByName("cost");
-			vector<TransportDestination*>* destinations = 0;
+			vector<TransportDestination*> destinations;
 			TransportDestination* destination = 0;
 			if (spawn && spawn == transport_spawn && spawn->GetTransporterID() > 0)
-				destinations = GetCurrentZone()->GetTransporters(spawn->GetTransporterID());
-			if (destinations) {
-				vector<TransportDestination*>::iterator itr;
-				for (itr = destinations->begin(); itr != destinations->end(); itr++) {
-					if ((*itr)->unique_id == unique_id && (*itr)->display_name == zone_name && (*itr)->cost == cost) {
-						destination = *itr;
-						break;
-					}
+				GetCurrentZone()->GetTransporters(&destinations, this, spawn->GetTransporterID());
+			vector<TransportDestination*>::iterator itr;
+			for (itr = destinations.begin(); itr != destinations.end(); itr++) {
+				if ((*itr)->unique_id == unique_id && (*itr)->display_name == zone_name && (*itr)->cost == cost) {
+					destination = *itr;
+					break;
 				}
 			}
 			if (!destination)

+ 25 - 6
EQ2/source/WorldServer/zoneserver.cpp

@@ -6963,7 +6963,7 @@ void ZoneServer::AddLocationTransporter(int32 zone_id, string message, float tri
 	MTransporters.unlock();
 }
 
-void ZoneServer::AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y){
+void ZoneServer::AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y, int32 expansion_flag, int32 min_client_version, int32 max_client_version){
 	TransportDestination* transport = new TransportDestination;
 	transport->type = type;
 	transport->display_name = name;
@@ -6985,18 +6985,37 @@ void ZoneServer::AddTransporter(int32 transport_id, int8 type, string name, stri
 	transport->map_x = map_x;
 	transport->map_y = map_y;
 
+	transport->expansion_flag = expansion_flag;
+	transport->min_client_version = min_client_version;
+	transport->max_client_version = max_client_version;
+
 	MTransporters.lock();
 	transporters[transport_id].push_back(transport);
 	MTransporters.unlock();
 }
 
-vector<TransportDestination*>* ZoneServer::GetTransporters(int32 transport_id){
-	vector<TransportDestination*>* ret = 0;
+void ZoneServer::GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id){
+	if (!returnList)
+		return;
+
 	MTransporters.lock();
-	if(transporters.count(transport_id) > 0)
-		ret = &transporters[transport_id];
+	if (transporters.count(transport_id) > 0)
+	{
+		vector<TransportDestination*> list;
+		for (int i = 0; i < transporters[transport_id].size(); i++)
+		{
+			if (transporters[transport_id][i]->min_client_version && client->GetVersion() < transporters[transport_id][i]->min_client_version)
+				continue;
+			else if (transporters[transport_id][i]->max_client_version && client->GetVersion() > transporters[transport_id][i]->max_client_version)
+				continue;
+
+			if (database.CheckExpansionFlags(this, transporters[transport_id][i]->expansion_flag))
+			{
+				returnList->push_back(transporters[transport_id][i]);
+			}
+		}
+	}
 	MTransporters.unlock();
-	return ret;
 }
 
 MutexList<LocationTransportDestination*>* ZoneServer::GetLocationTransporters(int32 zone_id){

+ 2 - 2
EQ2/source/WorldServer/zoneserver.h

@@ -1012,8 +1012,8 @@ public:
 
 	/* Transporters */
 	void AddLocationTransporter(int32 zone_id, string message, float trigger_x, float trigger_y, float trigger_z, float trigger_radius, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id);
-	void AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y);
-	vector<TransportDestination*>* GetTransporters(int32 transport_id);
+	void AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y, int32 expansion_flag, int32 min_client_version, int32 max_client_version);
+	void GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id);
 	MutexList<LocationTransportDestination*>* GetLocationTransporters(int32 zone_id);
 	void DeleteGlobalTransporters();
 	///<summary></summary>