Ugc: Remove async and second id usage

This commit is contained in:
David Markowitz 2023-11-06 01:41:28 -08:00
parent 797abb176a
commit f40fce7711

View File

@ -2523,15 +2523,9 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
inStream->Read(sd0Size); inStream->Read(sd0Size);
std::shared_ptr<char[]> sd0Data(new char[sd0Size]); std::shared_ptr<char[]> sd0Data(new char[sd0Size]);
if (sd0Data == nullptr) { if (sd0Data == nullptr) return;
return;
}
for (uint32_t i = 0; i < sd0Size; ++i) { inStream->ReadAlignedBytes(reinterpret_cast<unsigned char*>(sd0Data.get()), sd0Size);
uint8_t c;
inStream->Read(c);
sd0Data[i] = c;
}
uint32_t timeTaken; uint32_t timeTaken;
inStream->Read(timeTaken); inStream->Read(timeTaken);
@ -2565,7 +2559,6 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
//We runs this in async because the http library here is blocking, meaning it'll halt the thread. //We runs this in async because the http library here is blocking, meaning it'll halt the thread.
//But we don't want the server to go unresponsive, because then the client would disconnect. //But we don't want the server to go unresponsive, because then the client would disconnect.
auto returnVal = std::async(std::launch::async, [&]() {
//We need to get a new ID for our model first: //We need to get a new ID for our model first:
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) { ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) {
@ -2573,8 +2566,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
GeneralUtils::SetBit(newIDL, eObjectBits::CHARACTER); GeneralUtils::SetBit(newIDL, eObjectBits::CHARACTER);
GeneralUtils::SetBit(newIDL, eObjectBits::PERSISTENT); GeneralUtils::SetBit(newIDL, eObjectBits::PERSISTENT);
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t blueprintIDSmall) { uint32_t blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID();
blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID();
LWOOBJID blueprintID = blueprintIDSmall; LWOOBJID blueprintID = blueprintIDSmall;
GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
@ -2595,8 +2587,6 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
int templateId = result.getIntField(0); int templateId = result.getIntField(0);
result.finalize();
auto* propertyLookup = Database::CreatePreppedStmt("SELECT * FROM properties WHERE template_id = ? AND clone_id = ?;"); auto* propertyLookup = Database::CreatePreppedStmt("SELECT * FROM properties WHERE template_id = ? AND clone_id = ?;");
propertyLookup->setInt(1, templateId); propertyLookup->setInt(1, templateId);
@ -2622,7 +2612,6 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
//whacky stream biz //whacky stream biz
std::string s(sd0Data.get(), sd0Size); std::string s(sd0Data.get(), sd0Size);
std::istringstream iss(s); std::istringstream iss(s);
std::istream& stream = iss;
ugcs->setBlob(5, &iss); ugcs->setBlob(5, &iss);
ugcs->setBoolean(6, false); ugcs->setBoolean(6, false);
@ -2683,9 +2672,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
bitStream.Write<uint32_t>(sd0Size); bitStream.Write<uint32_t>(sd0Size);
for (size_t i = 0; i < sd0Size; ++i) { bitStream.WriteAlignedBytes(reinterpret_cast<unsigned char*>(sd0Data.get()), sd0Size);
bitStream.Write(sd0Data[i]);
}
SEND_PACKET; SEND_PACKET;
@ -2722,8 +2709,6 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
} }
}); });
});
});
} }
void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { void GameMessages::HandlePropertyEntranceSync(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {