mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-28 15:09:40 +00:00
[Server] Don't crash when adding a requiredDataFile w/ no checksum twice
This commit is contained in:
parent
02e646e838
commit
3805edaf78
1 changed files with 11 additions and 4 deletions
|
@ -189,11 +189,17 @@ void ServerFunctions::SetRuleValue(const char *key, double value) noexcept
|
|||
void ServerFunctions::AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept
|
||||
{
|
||||
auto &samples = mwmp::Networking::getPtr()->getSamples();
|
||||
|
||||
auto it = std::find_if(samples.begin(), samples.end(), [&dataFilename](mwmp::PacketPreInit::PluginPair &item) {
|
||||
return item.first == dataFilename;
|
||||
});
|
||||
|
||||
if (it != samples.end())
|
||||
it->second.push_back((unsigned) std::stoul(checksumString));
|
||||
{
|
||||
// If this is a filename we've added before, ensure our new checksumString for it isn't empty
|
||||
if (strlen(checksumString) != 0)
|
||||
it->second.push_back((unsigned)std::stoul(checksumString));
|
||||
}
|
||||
else
|
||||
{
|
||||
mwmp::PacketPreInit::HashList checksumList;
|
||||
|
@ -207,9 +213,10 @@ void ServerFunctions::AddDataFileRequirement(const char *dataFilename, const cha
|
|||
}
|
||||
samples.emplace_back(dataFilename, checksumList);
|
||||
|
||||
auto mclient = mwmp::Networking::getPtr()->getMasterClient();
|
||||
if (mclient)
|
||||
mclient->PushPlugin({dataFilename, checksum});
|
||||
auto masterClient = mwmp::Networking::getPtr()->getMasterClient();
|
||||
|
||||
if (masterClient)
|
||||
masterClient->PushPlugin({dataFilename, checksum});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue