mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-10-31 12:41:55 +00:00 
			
		
		
		
	Merge pull request #557 optimized LUP Component
Optimized LUP Component to not use a query to build its list of worlds
This commit is contained in:
		| @@ -1,21 +1,17 @@ | ||||
| #include "RocketLaunchLupComponent.h" | ||||
| #include "CDClientDatabase.h" | ||||
| #include "RocketLaunchpadControlComponent.h" | ||||
| #include "InventoryComponent.h" | ||||
| #include "CharacterComponent.h" | ||||
|  | ||||
| RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(parent) { | ||||
| 	m_Parent = parent; | ||||
|  | ||||
| 	// get the lup worlds from the cdclient | ||||
| 	std::string query = "SELECT * FROM LUPZoneIDs;"; | ||||
| 	auto results = CDClientDatabase::ExecuteQuery(query); | ||||
| 	while (!results.eof()) { | ||||
| 		// fallback to 1600 incase there is an issue | ||||
| 		m_LUPWorlds.push_back(results.getIntField(0, 1600)); | ||||
| 		results.nextRow(); | ||||
| 	std::string zoneString = GeneralUtils::UTF16ToWTF8(m_Parent->GetVar<std::u16string>(u"MultiZoneIDs")); | ||||
| 	std::stringstream ss(zoneString); | ||||
| 	for (int i; ss >> i;) { | ||||
| 		m_LUPWorlds.push_back(i); | ||||
| 		if (ss.peek() == ';') | ||||
| 			ss.ignore(); | ||||
| 	} | ||||
| 	results.finalize(); | ||||
| } | ||||
|  | ||||
| RocketLaunchLupComponent::~RocketLaunchLupComponent() {} | ||||
| @@ -29,11 +25,7 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) { | ||||
| } | ||||
|  | ||||
| void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) { | ||||
| 	// Add one to index because the actual LUP worlds start at index 1. | ||||
| 	index++; | ||||
|  | ||||
| 	auto* rocketLaunchpadControlComponent = m_Parent->GetComponent<RocketLaunchpadControlComponent>(); | ||||
|  | ||||
| 	if (!rocketLaunchpadControlComponent) return; | ||||
|  | ||||
| 	rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Markowitz
					David Markowitz