Browse Source

Flight path support for transport maps issue #143

Fix #143

Adds flight_path_id, mount_id, mount_red_color, mount_green_color and mount_blue_color to transporters table

flight_path_id matches to StartAutoMount id or flight_paths id
mount_id matches to SetMount value
mount red/green/blue color are by default 255
Image 3 years ago
parent
commit
905cc8b0ba

+ 6 - 0
DB/updates/transporters_flight_path.sql

@@ -0,0 +1,6 @@
+alter table transporters add column flight_path_id int(10) unsigned not null default 0;
+alter table transporters modify column transport_type ENUM('Zone','Location','Generic Transport','Flight') default 'Zone';
+alter table transporters add column mount_id int(10) unsigned not null default 0;
+alter table transporters add column mount_red_color smallint(5) unsigned not null default 255;
+alter table transporters add column mount_green_color smallint(5) unsigned not null default 255;
+alter table transporters add column mount_blue_color smallint(5) unsigned not null default 255;

+ 15 - 3
EQ2/source/WorldServer/Entity.h

@@ -528,8 +528,10 @@ public:
 			loot_items.push_back(item);
 		}
 	}
-	void SetMount(int16 val, bool setUpdateFlags = true) {
-		if(val == 0){
+
+	void SetMount(int16 mount_id, int8 red = 0xFF, int8 green = 0xFF, int8 blue = 0xFF, bool setUpdateFlags = true)
+	{
+		if (mount_id == 0) {
 			EQ2_Color color;
 			color.red = 0;
 			color.green = 0;
@@ -537,8 +539,18 @@ public:
 			SetMountColor(&color);
 			SetMountSaddleColor(&color);
 		}
-		SetInfo(&features.mount_model_type, val, setUpdateFlags); 
+		else
+		{
+			EQ2_Color color;
+			color.red = red;
+			color.green = green;
+			color.blue = blue;
+			SetMountColor(&color);
+			SetMountSaddleColor(&color);
+		}
+		SetInfo(&features.mount_model_type, mount_id, setUpdateFlags);
 	}
+
 	void SetEquipment(Item* item, int8 slot = 255);
 	void SetEquipment(int8 slot, int16 type, int8 red, int8 green, int8 blue, int8 h_r, int8 h_g, int8 h_b){
 		SetInfo(&equipment.equip_id[slot], type);

+ 1 - 11
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -8517,17 +8517,7 @@ int EQ2Emu_lua_StartAutoMount(lua_State* state) {
 		return 0;
 	}
 
-	client->SetPendingFlightPath(path);
-
-	((Player*)player)->SetTempMount(((Entity*)player)->GetMount());
-	((Player*)player)->SetTempMountColor(((Entity*)player)->GetMountColor());
-	((Player*)player)->SetTempMountSaddleColor(((Entity*)player)->GetMountSaddleColor());
-
-	PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", client->GetVersion());
-	if (packet) {
-		client->QueuePacket(packet->serialize());
-		safe_delete(packet);
-	}
+	client->SendFlightAutoMount(path);
 
 	return 0;
 }

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

@@ -120,6 +120,13 @@ struct TransportDestination{
 	int32	expansion_flag;
 	int32	min_client_version;
 	int32	max_client_version;
+
+	int32	flight_path_id;
+
+	int16	mount_id;
+	int8	mount_red_color;
+	int8	mount_green_color;
+	int8	mount_blue_color;
 };
 
 struct LocationTransportDestination{
@@ -357,6 +364,7 @@ struct GlobalLoot {
 #define TRANSPORT_TYPE_LOCATION		0
 #define TRANSPORT_TYPE_ZONE			1
 #define TRANSPORT_TYPE_GENERIC		2
+#define TRANSPORT_TYPE_FLIGHT		3
 
 class ZoneList {
 	public:

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

@@ -4819,7 +4819,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, expansion_flag, min_client_version, max_client_version 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, flight_path_id, mount_id, mount_red_color, mount_green_color, mount_blue_color 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]);
@@ -4835,12 +4835,15 @@ void WorldDatabase::LoadTransporters(ZoneServer* zone){
 			string message = "";
 			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]), atoul(row[23]), atoul(row[24]), atoul(row[25]));
+				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]), atoul(row[26]), atoul(row[27]), atoul(row[28]), atoul(row[29]), atoul(row[30]));
+			else if (row[1] && strcmp(row[1], "Flight") == 0)
+				zone->AddTransporter(atoul(row[0]), TRANSPORT_TYPE_FLIGHT, 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]), atoul(row[26]), atoul(row[27]), atoul(row[28]), atoul(row[29]), atoul(row[30]));
 			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]), atoul(row[23]), atoul(row[24]), atoul(row[25]));
+				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]), atoul(row[26]), atoul(row[27]), atoul(row[28]), atoul(row[29]), atoul(row[30]));
 			total++;
 		}
 	}

+ 36 - 6
EQ2/source/WorldServer/client.cpp

@@ -7062,9 +7062,15 @@ void Client::ProcessTeleport(Spawn* spawn, vector<TransportDestination*>* destin
 	}
 	if (transport_list.size() == 0 && destination) {
 		if (destination->destination_zone_id == 0 || destination->destination_zone_id == GetCurrentZone()->GetZoneID()) {
-			EQ2Packet* app = GetPlayer()->Move(destination->destination_x, destination->destination_y, destination->destination_z, GetVersion());
-			if (app)
-				QueuePacket(app);
+
+			if (destination->type == TRANSPORT_TYPE_FLIGHT)
+				SendFlightAutoMount(destination->flight_path_id, destination->mount_id, destination->mount_red_color, destination->mount_green_color, destination->mount_blue_color);
+			else
+			{
+				EQ2Packet* app = GetPlayer()->Move(destination->destination_x, destination->destination_y, destination->destination_z, GetVersion());
+				if (app)
+					QueuePacket(app);
+			}
 		}
 		else {
 			ZoneServer* new_zone = zone_list.Get(destination->destination_zone_id);
@@ -7180,9 +7186,15 @@ void Client::ProcessTeleportLocation(EQApplicationPacket* app) {
 			else {
 				if (cost == 0 || player->RemoveCoins(cost)) {
 					if (destination->destination_zone_id == 0 || destination->destination_zone_id == GetCurrentZone()->GetZoneID()) {
-						EQ2Packet* outapp = GetPlayer()->Move(destination->destination_x, destination->destination_y, destination->destination_z, GetVersion());
-						if (outapp)
-							QueuePacket(outapp);
+
+						if (destination->type == TRANSPORT_TYPE_FLIGHT)
+							SendFlightAutoMount(destination->flight_path_id, destination->mount_id, destination->mount_red_color, destination->mount_green_color, destination->mount_blue_color);
+						else
+						{
+							EQ2Packet* outapp = GetPlayer()->Move(destination->destination_x, destination->destination_y, destination->destination_z, GetVersion());
+							if (outapp)
+								QueuePacket(outapp);
+						}
 					}
 					else {
 						GetPlayer()->SetX(destination->destination_x);
@@ -8824,4 +8836,22 @@ void Client::SendMoveObjectMode(Spawn* spawn, uint8 placementMode, float unknown
 	packet->setDataByName("CoEunknown", 0xFFFFFFFF);
 	QueuePacket(packet->serialize());
 	safe_delete(packet);
+}
+
+void Client::SendFlightAutoMount(int32 path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color)
+{
+	SetPendingFlightPath(path_id);
+
+	((Player*)player)->SetTempMount(((Entity*)player)->GetMount());
+	((Player*)player)->SetTempMountColor(((Entity*)player)->GetMountColor());
+	((Player*)player)->SetTempMountSaddleColor(((Entity*)player)->GetMountSaddleColor());
+
+	PacketStruct* packet = configReader.getStruct("WS_ReadyForTakeOff", GetVersion());
+	if (packet) {
+		QueuePacket(packet->serialize());
+		safe_delete(packet);
+	}
+
+	if (mount_id)
+		((Entity*)GetPlayer())->SetMount(mount_id, mount_red_color, mount_green_color, mount_blue_color);
 }

+ 2 - 0
EQ2/source/WorldServer/client.h

@@ -423,6 +423,8 @@ public:
 
 	void SendMoveObjectMode(Spawn* spawn, uint8 placementMode, float unknown2_3=0.0f);
 
+	void SendFlightAutoMount(int32 path_id, int16 mount_id = 0, int8 mount_red_color = 0xFF, int8 mount_green_color = 0xFF, int8 mount_blue_color=0xFF);
+
 	void SetTemporaryTransportID(int32 id) { temporary_transport_id = id; }
 	int32 GetTemporaryTransportID() { return temporary_transport_id; }
 private:

+ 10 - 1
EQ2/source/WorldServer/zoneserver.cpp

@@ -6963,7 +6963,9 @@ 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, int32 expansion_flag, int32 min_client_version, int32 max_client_version){
+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, int32 flight_path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color){
 	TransportDestination* transport = new TransportDestination;
 	transport->type = type;
 	transport->display_name = name;
@@ -6989,6 +6991,13 @@ void ZoneServer::AddTransporter(int32 transport_id, int8 type, string name, stri
 	transport->min_client_version = min_client_version;
 	transport->max_client_version = max_client_version;
 
+	transport->flight_path_id = flight_path_id;
+
+	transport->mount_id = mount_id;
+	transport->mount_red_color = mount_red_color;
+	transport->mount_green_color = mount_green_color;
+	transport->mount_blue_color = mount_blue_color;
+
 	MTransporters.lock();
 	transporters[transport_id].push_back(transport);
 	MTransporters.unlock();

+ 3 - 1
EQ2/source/WorldServer/zoneserver.h

@@ -1012,7 +1012,9 @@ 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, int32 expansion_flag, int32 min_client_version, int32 max_client_version);
+	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, int32 flight_path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color);
 	void GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id);
 	MutexList<LocationTransportDestination*>* GetLocationTransporters(int32 zone_id);
 	void DeleteGlobalTransporters();