scummvm/scummvm — pull request #284 by digitall (2012-10-02 05:07:23+00:00)
Title: Refactoring Work on Teenagent Engine

This work comprimises various refactoring and minor fixes to the Teenagent Engine.

While not "complete", the current state is a large improvement over the current master version, and this pull request is to merge this before further work to prevent significant code divergence causing merge problems. This should not exhibit any gameplay regressions as it has been extensively playtested and in fact should fix a number of minor bugs and memory leaks.

The main aim of the refactoring was to cleanup the code and improve it's readability for maintenance, fix memory leaks and reduce memory usage.

The main fixes are:
1. Rewrite the create_teenagent tool to use static headers for teenagent.dat generation, rather than reading an executable which is not available, partly as it requires unpacking and the unpacker is not stable to produce the same result on successive runs.

2. This was done by using the existing teenagent.dat as a data source, and has allowed the exact format of this to be determined and the static headers converted from byte array into string data. This is pre-condition for looking at supporting the non-english versions of the game as the current data file only contains english texts.

3. Removed over half of the hardcoded "address" values which are used as offsets into the loaded resource data segments from the dat file. The remaining ones have been replaced by readable symbols, rather than obscure hexadecimal values.

4. Removed various unused code, updated various code with the latest cleanest engine API calls i.e. ConfMan and other singletons, and modified code to more closely conform with the project coding conventions.

5. All callbacks should now be implemented explicitly in code, rather than using the cseg (Code Segment) lookup in the data file. This and other fixes have increased the engine code usage by around 8K, but since the resource class no longer has to load the cseg data which is ~45K, the overall saving of 35Kb+ should not create issues on embedded targets... which also benefit from the engine memory leak fixes.

Once merged, it should allow the removal of cseg from the datafile, but this is currently just skipped to remove the need to change dat file format more than necessary i.e. get everything done and do a final version.

Overall, I think this should be fairly obviously fine to merge and I would like to do so without too much argument... though if there are any obvious mistakes or bugs, please point them out.