User Tools

Site Tools


dev_todo:mapdiff

Diff/Patch for Crossfire maps

Reason

Currently diff does a reasonable job at creating patches for maps, however these patches are not reliable imperfect patching. This is because for imperfect patching relies on the context in the patch containing sufficient information to find where the change should happen. This situation is even worse for objects in inventories, where there will be no x or y coords in the context. This could make patching player unique files much more practical.

Proposed system

  • Make a diff variant which for the context on each side of the changes, instead of being a fixed amount, will be from the start of the object till the end of the object. This will make the standard GNU patch do much more accurate imperfect patching from these diff files.
    • The context will include the objects around it when:
      • When the object is being inserted or removed (or moved, which is both operations)
      • The object is in the inventory of another object
  • Insert extra metadata in the diff file, and create a custom patch variant, which would allow the custom patch variant to do an even better job.
    • Include data such as, when the object is in another object, what it's container object is.
  • Report all ambiguities both when making the diff and applying the patch.
    • As a warning when doing the diff
    • Allow the user to resolve when applying a patch, perhaps make it a friendly semi-automated map-format-aware menu to resolve the ambiguity, as opposed to the not-as-smart text based manual conflict resolving methods.

Issues with the proposed system

  • It is not clear if the proposed system offers significant advantages over diff with extended context (e.g., using “diff -u 20” instead of “diff -u”).

    Even if there is a theoretical risk for rejected patches due to conflicts in the extended context, this may not be a problem in practice. Also, the fuzz factor in patch can be increased (e.g., “patch -F 15”) in order to reduce the risk of conflicts. So if the map or player object has not been modified, there will be a perfect match and the patch will be applied without problems. If there some differences in the 20 lines of context, then patch will report that the hunk has been applied with some fuzziness. In the end, it is very likely that diff and patch will do exactly what we expect them to do, without having to implement our own tools.
    • Discussed with the one who wrote this comment on IRC. Consensus seems to be that it's low priority, but may be useful to some degree. — Alex Schultz 2006/09/29 18:38
dev_todo/mapdiff.txt · Last modified: 2006/09/29 18:43 (external edit)