/usr/share/games/crossfire/adm/mapslitter.pl is in crossfire-common 1.70.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | #!/usr/bin/perl
# This script will write (to stdout) all the needed exits to connect maps
# in a tiled fashion. The variables at the start will need to be set
# for things to work.
# Set these as appropriate to the maps it should connect to. If one is left
# blank, then exits for that direction will not be created.
$MAPNAME=$ARGV[0];
$XM=$ARGV[1];
$YM=$ARGV[2];
$WIDTH=$ARGV[3];
$HEIGHT=$ARGV[4];
#$SPLITMAP=$ARGV[5];
if ($MAPNAME eq "") {
die "Usage: connect.pl <basename> <x maps> <y maps> <width> <height>";
}
if ($WIDTH==0) {
$WIDTH=42;
}
if ($HEIGHT==0) {
$HEIGHT=34;
}
# DELTA What the overlap is - it should always be 5 for smooth transitions
$DELTA=5;
$xc=1;
$yc=1;
print STDOUT "Creating connection maps.\n";
while ($xc<=$XM) {
$yc=1;
while ($yc<=$YM) {
$NORTH="";
$NORTHWEST="";
$WEST="";
$SOUTHWEST="";
$SOUTH="";
$SOUTHEAST="";
$EAST="";
$NORTHEAST="";
if ($yc>1){
$NORTH=$MAPNAME."_".$xc."_".($yc-1);
}
if ($yc>1 || $xc>1) {
$NORTHWEST=$MAPNAME."_".($xc-1)."_".($yc-1);
}
if ($xc>1) {
$WEST=$MAPNAME."_".($xc-1)."_".$yc;
}
if ($xc>1 || $yc<$YM) {
$SOUTHWEST=$MAPNAME."_".($xc-1)."_".($yc+1);
}
if ($yc<$YM) {
$SOUTH=$MAPNAME."_".$xc."_".($yc+1);
}
if ($yc<$YM || $xc<$XM) {
$SOUTHEAST=$MAPNAME."_".($xc+1)."_".($yc+1);
}
if ($xc<$XM) {
$EAST=$MAPNAME."_".($xc+1)."_".$yc;
}
if ($xc<$XM || $yc>1) {
$NORTHEAST=$MAPNAME."_".($xc+1)."_".($yc-1);
}
$THISMAP=$MAPNAME."_".$xc."_".$yc;
open (MAP, ">$THISMAP") or die "unable to open mapfile.";
print MAP "arch map\n";
print MAP "name $MAPNAME\n";
print MAP "msg\n";
print MAP "Creator: splitmap.pl\n";
print MAP "Email: azzie\@tellutec.se\n";
print MAP "Date: Wed Oct 27 10:59:23 1993\n";
print MAP "endmsg\n";
print MAP "hp ".($DELTA+1)."\n";
print MAP "sp $DELTA\n";
print MAP "x $WIDTH\n";
print MAP "y $HEIGHT\n";
print MAP "end\n";
print $MAPNAME."_".$xc."_".$yc."\n";
# print "XC=".$xc."\n";
# print "YC=".$yc."\n";
#$NORTHWEST="";
#$WEST="";
#$SOUTHWEST="";
#$SOUTH="world_a3";
#$SOUTHEAST="world_b3";
#$EAST="world_b2";
#$NORTHEAST="world_b1";
# End of configurable options.
# Quick reminder - hp is the destination x, sp is the destination y
# Lets do the corners first
if ($NORTHWEST ne "") {
print MAP "arch exit\n";
print MAP "slaying $NORTHWEST\n";
print MAP "x ".($DELTA-1)."\n";
print MAP "y ".($DELTA-1)."\n";
print MAP "hp ".($WIDTH-$DELTA-1)."\n";
print MAP "sp ".($HEIGHT-$DELTA-1)."\n";
print MAP "end\n";
}
if ($SOUTHWEST ne "") {
print MAP "arch exit\n";
print MAP "slaying $SOUTHWEST\n";
print MAP "x ".($DELTA-1)."\n";
print MAP "y ".($HEIGHT-$DELTA)."\n";
print MAP "hp ".($WIDTH-$DELTA-1)."\n";
print MAP "sp ".($DELTA)."\n";
print MAP "end\n";
}
if ($SOUTHEAST ne "") {
print MAP "arch exit\n";
print MAP "slaying $SOUTHEAST\n";
print MAP "x ".($WIDTH-$DELTA)."\n";
print MAP "y ".($HEIGHT-$DELTA)."\n";
print MAP "hp ".($DELTA)."\n";
print MAP "sp ".($DELTA)."\n";
print MAP "end\n";
}
if ($NORTHEAST ne "") {
print MAP "arch exit\n";
print MAP "slaying $NORTHEAST\n";
print MAP "x ".($WIDTH-$DELTA)."\n";
print MAP "y ".($DELTA-1)."\n";
print MAP "hp ".($DELTA)."\n";
print MAP "sp ".($HEIGHT-$DELTA-1)."\n";
print MAP "end\n";
}
# Now lets do the edges.
if ($NORTH ne "") {
$x=$DELTA;
while ($x < ($WIDTH-$DELTA)) {
print MAP "arch exit\n";
print MAP "slaying $NORTH\n";
print MAP "x ".$x."\n";
print MAP "y ".($DELTA-1)."\n";
print MAP "hp ".$x."\n";
print MAP "sp ".($HEIGHT-$DELTA-1)."\n";
print MAP "end\n";
$x=$x+1;
}
}
if ($SOUTH ne "") {
$x=$DELTA;
while ($x < ($WIDTH-$DELTA)) {
print MAP "arch exit\n";
print MAP "slaying $SOUTH\n";
print MAP "x ".$x."\n";
print MAP "y ".($HEIGHT-$DELTA)."\n";
print MAP "hp ".$x."\n";
print MAP "sp ".($DELTA)."\n";
print MAP "end\n";
$x=$x+1;
}
}
if ($WEST ne "") {
$y=$DELTA;
while ($y < ($HEIGHT-$DELTA)) {
print MAP "arch exit\n";
print MAP "slaying $WEST\n";
print MAP "x ".($DELTA-1)."\n";
print MAP "y ".$y."\n";
print MAP "hp ".($WIDTH-$DELTA-1)."\n";
print MAP "sp ".$y."\n";
print MAP "end\n";
$y=$y+1;
}
}
if ($EAST ne "") {
$y=$DELTA;
while ($y < ($HEIGHT-$DELTA)) {
print MAP "arch exit\n";
print MAP "slaying $EAST\n";
print MAP "x ".($WIDTH-$DELTA)."\n";
print MAP "y ".$y."\n";
print MAP "hp ".($DELTA)."\n";
print MAP "sp ".$y."\n";
print MAP "end\n";
$y=$y+1;
}
}
close MAP;
$yc=$yc+1;
}
$xc=$xc+1;
}
# Second pass. Connected maps opened and primary map superimposed.
print STDOUT "Done with connecting, now superimposing split map.\n";
$xc=1;
$yc=1;
while ($xc<=$XM) {
$yc=1;
while ($yc<=$YM) {
$NEWMAP=$MAPNAME."_".$xc."_".$yc.".new";
$THISMAP=$MAPNAME."_".$xc."_".$yc;
open (MAP, ">>$THISMAP") or die "unable to open new mapfile.";
# open (CONMAP, "$THISMAP") or die "unable to open connected mapfile.";
open (IMPMAP, "$MAPNAME") or die "unable to open superimposed mapfile.";
$currentline=<IMPMAP>;
print STDOUT "Now superimposing on map ".$THISMAP."\n";
# Discard header
$headscan=1;
while ($headscan) {
if ($currentline=~/end\n/) {
$headscan=0;
}
$currentline=<IMPMAP>;
}
# Read rest of file
while ($currentline) {
# print STDOUT $currentline;
# Scan for and buffer archs within bounds.
while ($currentline ne "end\n" && $currentline) {
if ($currentline=~/x /) {
($florp, $px) = split //,$currentline,2;
$currentline="x ".($px-(($xc-1)*$WIDTH)+(($xc-1)*$DELTA*2))."\n";
}
if ($currentline=~/y /) {
($florp, $py)=split //,$currentline,2;
$currentline="y ".($py-(($yc-1)*$HEIGHT)+(($yc-1)*$DELTA*2))."\n";
}
if ($currentline ne "x 0\n" && $currentline ne "y 0\n"){
$buf=$buf.$currentline;
}
$currentline=<IMPMAP>;
}
$buf=$buf.$currentline;
# print STDOUT $px.$py;
if ($px >= (($xc-1)*$WIDTH)-(($xc-1)*$DELTA*2) && $px < ($xc*$WIDTH)-(($xc-1)*$DELTA*2) && $py >= (($yc-1)*$HEIGHT)-(($yc-1)*$DELTA*2) && $py < ($yc*$HEIGHT)-(($yc-1)*$DELTA*2)) {
# print STDOUT "In map: ".$THISMAP."\n";
print MAP $buf;
# print STDOUT ".";
}
# else {
# print STDOUT "-";
# }
$px=0;
$py=0;
$buf="";
$currentline=<IMPMAP>;
}
close MAP;
close CONMAP;
close IMPMAP;
$yc=$yc+1;
# print STDOUT "\n";
}
$xc=$xc+1;
}
|