comparing map data textually

General feedback and discussion of the game.

Moderators: Forum Moderators, Developers

Post Reply
Posts: 216
Joined: December 17th, 2015, 10:27 pm

comparing map data textually

Post by Can-ned_Food » August 16th, 2018, 4:10 am

So, maybe this is too simple. Maybe that's why there isn't one already posted here or included in the data/tools/ anywhere: because most developers of so–called UMC all have their own.

Well, I needed something to enable me to compare map data with small differences, and so I wrote one.
You cannot simply use Diff, because it doesn't do so well detecting differences within lines. There are some other tools which do so — WinMerge, for one, — but the simplicity of the map structure, textually, accomodates a much cleaner way to format it so that Diff can be used.

To make this a proper Bash executable, you need to change the first line:
  1. change the bash to point toward where you keep your Bash executable,
  2. remove all blankspaces,
  3. and strip off the ###.
Also, know that this program
  • requires the GNU extensions to Sed — though I doubt anyone here would be using the non-GNU version…
  • uses Perl5.
Using positional args, simply feed it the paths to two map data and let it do everything else.
You will get each tile on its own line with $x,$y prefixed.

Code: Select all

### #! bash
sini_smeared=$( mktemp )
dexe_smeared=$( mktemp )
	# use strict;
	# use warnings;
	use autodie;
	my  $x = 0;
	my  $y = 0;
	while (my $line = <STDIN>) {
		## NOTE
			##  usr/bin/perl* cannot be given name of node on commandline if -e is used
		if ($line =~ /^$/) {
			$x =  0;
			$y =  $y + 1;
		 else {
			printf  "$x,$y %s", $line;
			$x =  $x + 1;
function smear {
	cat  "$1" \
	 | \
	sed --regexp-extended --null-data \
		--expression='s/border_size=[0123456789]+\nusage=(map|mask)\n\n//;' \
	 | \
	sed --regexp-extended \
		--expression='s/$/\n/g;s/ *, +/\n/g;s/ *$//g;' \
	 | \
	perl \
		-e "$prog__perl_prefixing" \
	 >| "$2"
smear  "$sini" $sini_smeared
smear  "$dexe" $dexe_smeared
diff --speed-large-files  $sini_smeared $dexe_smeared

EDIT: now deletes any trailing spaces in lines.
Last edited by Can-ned_Food on August 31st, 2018, 4:59 pm, edited 5 times in total.

Posts: 216
Joined: December 17th, 2015, 10:27 pm

Re: comparing map data textually BUMP

Post by Can-ned_Food » August 30th, 2018, 4:12 am

I really don't like to do this, but the new edition of my handy program is a major improvement over the prior one — which probably shouldn't've been published at all. I doubt anyone made use of it.

Post Reply