Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Map loading.



Mark Wedel writes:
 > The problem I have is that everything is close (armor shop, weapon shop,
 > gatehouse, etc..)  It loads the town map just fine, however.

reason is that mapnames changed from numbers to real names, so that
the mapindex isn't needed anymore.

 > IS there some script I need to run or something to get this working?

below is a script that may help you. (It's a quite a long time since I
used it, and I'm not sure if it works without modifications.)
There are still problems with exits, which use the feature that exit
with food = 0, leads to maplevel + 1.

	- Jarkko

8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<-
#!/usr/local/bin/perl
#
# usage: conv_exit [mapfile[s]]
#
# run in libdir!
#

$LIBDIR=".";
$MAPINDEX = "$LIBDIR/mapindex";
$ARCH = "$LIBDIR/archetypes";

open (AR, $ARCH) || die "aargh";

# first find out the archetypes, which are exits
while (<AR>) {
    if (/Object\s+(\S*)/) {
	$last = $1;
    } elsif (/^type 66$/) {
	push (@exits, $last);
    } elsif (/^type 41$/) {
	push (@telep, $last);
    }
}
close (AR);

print join (", ", @exits), "\n";
print join (", ", @telep), "\n";

# read in the mapindex file
open (BM, $MAPINDEX) || die "aargh";
while (<BM>) {
    if (/(\d+)\s*(\S*)/) {
	$map[$1] = $2;
    }
}
close (BM);

# convert a map    
while ($map = shift @ARGV) {
    open (OMAP, "<$map") || die "cannot open $map";
    open (MAP, ">$map.new") || die "cannot open $map.new";

    print "converting exits in $map\n";
    
    while (<OMAP>) {	
	print MAP $_;
	if (/arch (.*)/) {
	    #print "$1\n";
	    if (grep ($_ eq $1, @exits)) {
		#print "$1\n", grep (/^$1$/, @exits);
		while (<OMAP>) {
		    if (/^food (\d*)/) {
			if ($1 <= 0) {
			    print MAP "slaying $map[$1]\n";
			    print "slaying $map[$1] $1\n";
			} else {
			    print MAP "slaying $map[$1]\n";
			    print "slaying $map[$1] $1\n";
			}
			last;
		    }
		    print MAP $_;
		    if (/^end$/) {
			#print MAP "slaying $map[$1]\n";
			print "no exit level for $1\n";
			last;
		    }
		}
	    }
	    if (grep ($_ eq $1, @telep)) {
		#print "$1\n", grep (/^$1$/, @exits);
		while (<OMAP>) {
		    if (/^food (\d*)/) {
			print MAP "slaying $map[$1]\n";
			print "slaying $map[$1] $1\n";
			last;
		    }
		    print MAP $_;
		    if (/^end$/) {
			#print MAP "slaying $map[$1]\n";
			print "no level for $1\n";
			last;
		    }
		}
	    }
	}
    }
    if (! -s "$map.old") {
	rename ($map, "$map.old");
    }
    rename ("$map.new", $map);
}