H-uru / libhsplasma

Cross-platform Plasma data and network library
GNU General Public License v3.0
32 stars 30 forks source link

Fix `plArmatureLODMod` writing PRC `Meshes` tag twice #285

Closed dgelessus closed 8 months ago

dgelessus commented 8 months ago

The base class plArmatureModBase already writes the Meshes tag, so plArmatureLODMod shouldn't write it a second time.

dgelessus commented 8 months ago

These appear to be duplicated because the stream I/O also has duplicate readers and writers for them...

Actually, nothing is duplicated in the stream data either - but the code is really wacky here. There are two places that read the meshes (plArmatureModBase::read and plArmatureLODMod::read), but only the latter is actually executed. Note that (for Uru PRPs) plArmatureMod::read doesn't call the base class method plArmatureModBase::read, but instead skips one class up the chain to plAGMasterMod::read. So one of the two places where the meshes are read is always skipped. The same thing happens when writing.

The trouble was that the PRC read/write code replicated one half of this wacky logic (two classes reading/writing the same field), but not the other half (skipping one of those two implementations).