Page MenuHomeWildfire Games

introduce subfolders for geology templates
ClosedPublic

Authored by Nescio on Nov 3 2017, 11:53 PM.

Details

Summary

This patch is a follow-up to D2991/rP24044. It introduces gaia/ore/ and gaia/rock/ subfolders for geology templates and moves and renames the following:

  • geology_metal_*.xmlore/*_small.xml
  • geology_metal_*_slabs.xmlore/*_large.xml
  • geology_stone_*.xmlrock/*_small.xml
  • geology_stonemine_*_quarry.xmlrock/*_large.xml

ore and rock are chosen instead of metal and stone for consistency with their generic template_gaia_*.xml parent templates and the already existing fish/, ruins/, and treasure/ subfolders.
The advantages of this patch include a more organized gaia/ folder and shorter and clearer file names, making it easier for map makers to figure out which entity they want, without actually having to open the files in question. The disadvantage is that it breaks all maps in mods, however, that's easy to fix.

To correct the maps/ files, run this command in your 0ad/ repository:

find binaries/data/mods/public/maps/ \( -name '*.js' -o -name '*.json' -o -name '*.xml' \) -print0 | xargs -0 sed -i \
  -e 's,gaia/geology_metal_alpine_slabs,gaia/ore/alpine_large,g' \
  -e 's,gaia/geology_metal_alpine,gaia/ore/alpine_small,g' \
  -e 's,gaia/geology_metal_desert_badlands_slabs,gaia/ore/badlands_large,g' \
  -e 's,gaia/geology_metal_desert_slabs,gaia/ore/desert_large,g' \
  -e 's,gaia/geology_metal_desert_small,gaia/ore/desert_small,g' \
  -e 's,gaia/geology_metal_greek,gaia/ore/greece_small,g' \
  -e 's,gaia/geology_metal_mediterranean_slabs,gaia/ore/mediterranean_large,g' \
  -e 's,gaia/geology_metal_mediterranean,gaia/ore/mediterranean_small,g' \
  -e 's,gaia/geology_metal_savanna_slabs,gaia/ore/savanna_large,g' \
  -e 's,gaia/geology_metal_temperate_slabs,gaia/ore/temperate_large,g' \
  -e 's,gaia/geology_metal_temperate,gaia/ore/temperate_small,g' \
  -e 's,gaia/geology_metal_tropic_slabs,gaia/ore/tropical_large,g' \
  -e 's,gaia/geology_metal_tropic,gaia/ore/tropical_small,g' \
  -e 's,gaia/geology_stone_alpine_a,gaia/rock/alpine_small,g' \
  -e 's,gaia/geology_stone_desert_quarried,gaia/rock/desert_cut,g' \
  -e 's,gaia/geology_stone_desert_small,gaia/rock/desert_small,g' \
  -e 's,gaia/geology_stone_greek,gaia/rock/greece_small,g' \
  -e 's,gaia/geology_stone_mediterranean,gaia/rock/mediterranean_small,g' \
  -e 's,gaia/geology_stone_savanna_quarried,gaia/rock/savanna_cut,g' \
  -e 's,gaia/geology_stone_savanna_small,gaia/rock/savanna_small,g' \
  -e 's,gaia/geology_stone_temperate,gaia/rock/temperate_small,g' \
  -e 's,gaia/geology_stone_tropic_a,gaia/rock/tropical_small,g' \
  -e 's,gaia/geology_stonemine_alpine_quarry,gaia/rock/alpine_large,g' \
  -e 's,gaia/geology_stonemine_desert_badlands_quarry,gaia/rock/badlands_large,g' \
  -e 's,gaia/geology_stonemine_desert_quarry,gaia/rock/desert_large,g' \
  -e 's,gaia/geology_stonemine_medit_quarry,gaia/rock/mediterranean_large,g' \
  -e 's,gaia/geology_stonemine_savanna_quarry,gaia/rock/savanna_large,g' \
  -e 's,gaia/geology_stonemine_temperate_formation,gaia/rock/temperate_large_02,g' \
  -e 's,gaia/geology_stonemine_temperate_granite_quarry,gaia/rock/temperate_large_03,g' \
  -e 's,gaia/geology_stonemine_temperate_quarry,gaia/rock/temperate_large,g' \
  -e 's,gaia/geology_stonemine_tropic_quarry,gaia/rock/tropical_large,g'

Similar patches include:

Test Plan

Apply the patch, run the sed script, check for mistakes and omissions, verify everything works as before, agree the changes are an improvement.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Nescio created this revision.Nov 3 2017, 11:53 PM
Owners added a subscriber: Restricted Owners Package.Nov 3 2017, 11:53 PM

NB It appears the sed script can't read map files which contain spaces (" ") in their name. Any suggestions on how to solve this?

Vulcan added a subscriber: Vulcan.Nov 3 2017, 11:57 PM

Successful build - Chance fights ever on the side of the prudent.

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (307 tests)...................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (307 tests)...................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...
Nescio edited the summary of this revision. (Show Details)Nov 4 2017, 1:45 PM

The following commands should work:

find binaries/data/mods/public/maps/ \( -name '*.js' -o -name '*.xml' \) -print0 | xargs -0 sed -i \
    -e 's,gaia/geology_metal_desert_small,gaia/geology/metal_desert,g' \
    -e 's,gaia/geology_metal_,gaia/geology/metal_,g' \
    -e 's,gaia/geology_stone_alpine_a,gaia/geology/stone_,g' \
    -e 's,gaia/geology_stone_desert_small,gaia/geology/stone_desert,g' \
    -e 's,gaia/geology_stone_greek,gaia/geology/stone_greek,g' \
    -e 's,gaia/geology_stone_mediterranean,gaia/geology/stone_mediterranean,g' \
    -e 's,gaia/geology_stone_savanna_small,gaia/geology/stone_savanna,g' \
    -e 's,gaia/geology_stone_temperate,gaia/geology/stone_temperate,g' \
    -e 's,gaia/geology_stone_tropic_a,gaia/geology/stone_tropic,g' \
    -e 's,gaia/geology_stonemine_alpine_quarry,gaia/geology/stone_alpine_slabs,g' \
    -e 's,gaia/geology_stonemine_desert_badlands_quarry,gaia/geology/stone_dessert_badlands_slabs,g' \
    -e 's,gaia/geology_stonemine_desert_quarry,gaia/geology/stone_dessert_slabs,g' \
    -e 's,gaia/geology_stonemine_medit_quarry,gaia/geology/stone_mediterranean_slabs,g' \
    -e 's,gaia/geology_stonemine_temperate_formation,gaia/geology/stone_temperate_formation,g' \
    -e 's,gaia/geology_stonemine_temperate_quarry,gaia/geology/stone_temperate_slabs,g' \
    -e 's,gaia/geology_stonemine_tropic_quarry,gaia/geology/stone_tropic_slabs,g'


grep -Ri "gaia/geology_metal" binaries/data/mods/public/maps/
grep -Ri "gaia/geology_stone" binaries/data/mods/public/maps/

What I immediately noticed is that there are some *.json files containing the search strings as well. Not sure if they should be changed as well.

Stan requested changes to this revision.Dec 29 2018, 1:15 PM
This revision now requires changes to proceed.Dec 29 2018, 1:15 PM
Nescio updated this revision to Diff 13506.Sep 19 2020, 10:41 AM
Nescio retitled this revision from Template organization: geology to introduce subfolders for geology templates.
Nescio edited the summary of this revision. (Show Details)
Nescio edited the test plan for this revision. (Show Details)
Nescio edited reviewers, added: Restricted Owners Package; removed: Stan.
Nescio edited subscribers, added: Freagarach; removed: Vulcan.
  • redone from scratch
Nescio edited the summary of this revision. (Show Details)Sep 19 2020, 11:01 AM
Freagarach edited reviewers, added: Freagarach; removed: Restricted Owners Package.Sep 20 2020, 7:54 AM
Freagarach requested changes to this revision.Sep 21 2020, 12:09 PM

Your script needs some fixes.
E.g.

-e 's,geology_metal_alpine,alpine_small,g' \
-e 's,geology_metal_alpine_slabs,alpine_large,g' \

means that first geology_metal_alpine_slabs is replaced with alpine_small_slabs.
Also the gaia-folder is missing in the replacement strings.

This revision now requires changes to proceed.Sep 21 2020, 12:09 PM
Nescio edited the summary of this revision. (Show Details)Sep 21 2020, 12:27 PM

Good points! I wrote and ran the script, but didn't validate it afterwards to verify the replacements were correct; I should have.
Anyway, I've now updated the sed script. Could you try and check again?

  • Checkrefs passes.
  • Playtesting reveals no errors.
  • Change is good.
Freagarach accepted this revision.Sep 22 2020, 8:49 PM
This revision is now accepted and ready to land.Sep 22 2020, 8:49 PM
This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Sep 25 2020, 11:08 AM
nani added a subscriber: nani.Mar 11 2021, 9:52 PM
nani removed a subscriber: nani.