1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:45:34 +00:00

[General] Add placeholder for Variant records in RecordDynamic packet

Fix spacing and sorting for Sound custom records.
This commit is contained in:
David Cernat 2020-11-06 11:44:11 +02:00
parent 7f435ceeac
commit a43ba35790
2 changed files with 50 additions and 26 deletions

View file

@ -27,6 +27,7 @@
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/esm/loadweap.hpp> #include <components/esm/loadweap.hpp>
#include <components/esm/loadsoun.hpp> #include <components/esm/loadsoun.hpp>
#include <components/esm/variant.hpp>
#include <components/openmw-mp/Base/BaseStructs.hpp> #include <components/openmw-mp/Base/BaseStructs.hpp>
@ -56,10 +57,11 @@ namespace mwmp
PROBE, PROBE,
REPAIR, REPAIR,
SCRIPT, SCRIPT,
SOUND,
SPELL, SPELL,
STATIC, STATIC,
WEAPON, VARIANT,
SOUND WEAPON
}; };
// When using an existing record as a base, this struct tracks which changes // When using an existing record as a base, this struct tracks which changes
@ -292,6 +294,13 @@ namespace mwmp
BaseOverrides baseOverrides; BaseOverrides baseOverrides;
}; };
struct SoundRecord
{
ESM::Sound data;
std::string baseId;
BaseOverrides baseOverrides;
};
struct SpellRecord struct SpellRecord
{ {
ESM::Spell data; ESM::Spell data;
@ -306,17 +315,17 @@ namespace mwmp
BaseOverrides baseOverrides; BaseOverrides baseOverrides;
}; };
struct WeaponRecord struct VariantRecord
{ {
ESM::Weapon data; ESM::Variant data;
unsigned int quantity = 1;
std::string baseId; std::string baseId;
BaseOverrides baseOverrides; BaseOverrides baseOverrides;
}; };
struct SoundRecord struct WeaponRecord
{ {
ESM::Sound data; ESM::Weapon data;
unsigned int quantity = 1;
std::string baseId; std::string baseId;
BaseOverrides baseOverrides; BaseOverrides baseOverrides;
}; };
@ -410,6 +419,7 @@ namespace mwmp
std::vector<SoundRecord> soundRecords; std::vector<SoundRecord> soundRecords;
std::vector<SpellRecord> spellRecords; std::vector<SpellRecord> spellRecords;
std::vector<StaticRecord> staticRecords; std::vector<StaticRecord> staticRecords;
std::vector<VariantRecord> variantRecords;
std::vector<WeaponRecord> weaponRecords; std::vector<WeaponRecord> weaponRecords;
std::vector<ESM::Cell> cellsToReset; std::vector<ESM::Cell> cellsToReset;

View file

@ -70,6 +70,8 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *newBitstream, bool send)
worldstate->recordsCount = Utils::getVectorSize(worldstate->staticRecords); worldstate->recordsCount = Utils::getVectorSize(worldstate->staticRecords);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::SOUND) else if (worldstate->recordsType == mwmp::RECORD_TYPE::SOUND)
worldstate->recordsCount = Utils::getVectorSize(worldstate->soundRecords); worldstate->recordsCount = Utils::getVectorSize(worldstate->soundRecords);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::VARIANT)
worldstate->recordsCount = Utils::getVectorSize(worldstate->variantRecords);
else else
{ {
LOG_MESSAGE_SIMPLE(TimedLog::LOG_ERROR, "Processed invalid ID_RECORD_DYNAMIC packet about unimplemented recordsType %i", LOG_MESSAGE_SIMPLE(TimedLog::LOG_ERROR, "Processed invalid ID_RECORD_DYNAMIC packet about unimplemented recordsType %i",
@ -134,10 +136,12 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *newBitstream, bool send)
Utils::resetVector(worldstate->repairRecords, worldstate->recordsCount); Utils::resetVector(worldstate->repairRecords, worldstate->recordsCount);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::SCRIPT) else if (worldstate->recordsType == mwmp::RECORD_TYPE::SCRIPT)
Utils::resetVector(worldstate->scriptRecords, worldstate->recordsCount); Utils::resetVector(worldstate->scriptRecords, worldstate->recordsCount);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::STATIC)
Utils::resetVector(worldstate->staticRecords, worldstate->recordsCount);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::SOUND) else if (worldstate->recordsType == mwmp::RECORD_TYPE::SOUND)
Utils::resetVector(worldstate->soundRecords, worldstate->recordsCount); Utils::resetVector(worldstate->soundRecords, worldstate->recordsCount);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::STATIC)
Utils::resetVector(worldstate->staticRecords, worldstate->recordsCount);
else if (worldstate->recordsType == mwmp::RECORD_TYPE::VARIANT)
Utils::resetVector(worldstate->variantRecords, worldstate->recordsCount);
} }
if (worldstate->recordsType == mwmp::RECORD_TYPE::SPELL) if (worldstate->recordsType == mwmp::RECORD_TYPE::SPELL)
@ -875,6 +879,16 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *newBitstream, bool send)
} }
} }
} }
// Placeholder
else if (worldstate->recordsType == mwmp::RECORD_TYPE::VARIANT)
{
for (auto&& record : worldstate->variantRecords)
{
auto& recordData = record.data;
RW(record.baseId, send, true);
}
}
} }
void PacketRecordDynamic::ProcessEffects(ESM::EffectList &effectList, bool send) void PacketRecordDynamic::ProcessEffects(ESM::EffectList &effectList, bool send)