#19 Merged at f70d559
  1. Enthalpy
  • Restructuring of converters to a template model.

  • Corrected the constants for "detention center ahead."

There are two “parts” to this commit. First, a rework of the converters to reduce redundancy. Secondly, various small glitch fixes necessary for the test cases to work on my version of PHP’s more stringent settings. I’ve tested all of this very, very extensively, with five test cases and repeated comparison of all original functions. Upon merge, Issue 125 can be marked as resolved.

Due to the extensive nature of this change, a comprehensive changelog is below.


__construct is invariant across the converters EXCEPT THAT FormattingDef1 sets profile_start to 0 initially, while the others initialize it at 1, AND if FormattingDef1 encounters a line starting with //Definition//, it sets profile_start to 1. Because the other definitions are guaranteed to have a line starting with //Definition// by TrialFileConverter, they use the same logic, but it simplifies for the non-Def1 versions. All converters now share the "expanded" form.

decodeDef#Strings has been renamed to decode. The old decodeDef4Strings and decodeDef5Strings were identical.

convertColourTags is invariant across the converters.

getFrame, getPlace, getEvidence, and getProfile were all removed, as was all_frames_fetched, frame_mode, and last_statement_with_press.

getProfleByLineNb is almost invariant between Def4 and Def5, but Def5 has an extra check for if images_externes_id exists in $line, which Def4 could use just as well, and they have different logic for selecting the voice. Def4’s check has been added to Def5, and an in isset check on $line[‘auto_voice’] determines which logic to use.

getEvidenceByLineNb is equivalent between Def4 and Def5.

getFrameByLineNb is also similar enough between Def4 and Def5 that a comparison can be made... They have different speaker_name, speaker_use_name, and speaker_id logic. Def5 has a check on $line[‘fond’][‘banc’], which Def4 can never have. The conversion is natural. Some values in Def4 were made key-value pairs of Def5’s infos_auteur. This has been accounted for. Def5 allows variable sync modes, while Def4 does not. This comes through $line[‘perso’][‘mode_animation’]. Startup mode is also different because ‘mode_animation’.

fetchAllFrames is invariant across the three converters.

FormattingDef1, Def4, and Def5 all have highly similar getTrialData functions, but with the following differences:

  • In Def1, scenes is set to 0 at the beginning of the function. In the others, it is set to this->scenes at the end. If the Def1 class has a scenes object that hashes 0 to 0, Def1's behavior is invariant under the current system, and Def4 and Def5's.

  • Def1 needs all_profiles_fetched set to true after handling profiles. Def4 and Def5 have no dependence on this variable, so they can share in this setting.

With some changes that don't impact performance, the three have identical getTrialData functions. Combined.

Many private functions are now protected.


The constants for legacy place conversion have been fixed.

External sprites that aren’t set custom sprites are now set to be no sprite in Def1.

Def2-4 trials now have popups.

Blank trials no longer no longer call non-existent delimiter indices.

Def5 corrected photographs to img instead of image for evidence_type. Fixed.

Comments (3)

  1. Arnaud Vié

    How exactly did you validate the result of your 5 test cases ? Did you do an exact diff between the output of the original converters and that of yours ? :-)

  2. Enthalpy author

    Exactly. I used Ferdielance's trial data extraction tool to get the trial data of the test cases under the current converters and my converters, ran those through diffchecker, and fixed my converter logic until the only differences in the trial code were due to bugs I had fixed in Part Two. For example, one test case had characters with a null profile id field, but that character was removed entirely from my converters. One test case had an extra place in the original trial because convertLegacyPlaces didn't handle the detention center properly, which was fixed in my version and also changed the place IDs between the two trials.

    In hindsight, a JSON diff checker would have been quicker than a string diff checker, but the accuracy of the two methods are the same.

  3. Enthalpy author

    That last update was a change that should have been made in the original version - following up on that note to myself to add in the abstract functions getProfileByLineNb, getEvidenceByLineNb, and getFrameByLineNb!