collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
872 stars 99 forks source link

Excel serializing rows out of order #87

Closed collinsmith closed 4 years ago

collinsmith commented 4 years ago

Excel is serializing table rows out of the natural order. This is causing issues with Excel#index(String) when loading the serialized data. This is a critical bug which breaks code that relies on this being consistent with the internal constants.


I noticed other deficiencies which may cause issues down the line and should be addressed. Namely that custom rows are being serialized with the original data. The serialized data should only include the data loaded from the txt and that data should be serialized in the same order as it is read. I may have to do something like generate an array consisting of the entries as they are created so they are serialized in the correct order, as well as prepend the index of the row within the bin to make sure it loads into the correct index.

collinsmith commented 4 years ago

Resolving this bug will require adding an additional check to the validation tests in BinGenerationTool to make sure that the binned indexes match the text indexes.

collinsmith commented 4 years ago

I decided to take the route of keeping an array that has the entries inserted as they are created. This should bypass any custom stuff that the implementations do, so when the bin is loaded, I think it will read it like the normal txt (without any riiablo-specific data) and do whatever it needs to do after. The bin entries do not have an index prepended, I'm hoping that it's sufficient that they will be read like a txt in the same order.

I'm closing the issue for now, but I would really like to come back and create a validation test to validate that the indexes loaded from the bin matches that of the data loaded from the excel. This will be tricky though and require adding a way to apply some sort of general key to the data structs (maybe something like put the entries in an array and validate that every index Object#equals in both arrays -- assuming they are in the same order in the map).