This is perl. It runs on the cmd line like:
myperlscipt myoldmap.whatevertheextensionis
The output is always newmap.Civ4WarlordsWBSave. If there is any problem just diff the maps.
Basically, to chop from the top is just deleting plots where y > Ytotal - #chops. Adding to the right is just a loop from 0 to Xmax. Just add in tundra, and then fix in WB. Adding/deleting to/from the left is the most complicated since all of the existing plots need x adjusted to x +/- $NumNewColumns.
And the only other detail is to adjust the "num plots written" entry to be the new total, as well as "grid width=" and "grid height =".
The lines on the bottom starting with # are comments in perl. Those really belong in a different script. All those lines do is output the new plots, so then you'll have to paste those into the new map at the right location in the file (ie just after the last plot).
Code:
# $extra_width = 5;
$off{top} = 2;
$off{left} = 4;
$/ = "Begin";
open(NEWMAP,">newmap.Civ4WarlordsWBSave") || die "$! tyring to create newmap\n";
select NEWMAP;
while(<>){
if ( /^(\S+)/ ){
$type = $1;
if ( $type eq "Plot" ){
if ( /x=(\d+)\s*,y=(\d+)/ ){
$x_coord = $1;
$y_coord = $2;
}
if ($x_coord < $off{left} ){
next;
} else {
$new_x_coord = $x_coord - $off{left}; # move all plots left 1
$_ =~s/x=$x_coord/x=$new_x_coord/;
}
next if ( $y_coord >= $newMapHeight ); # skip top plots
}
if ( $type eq "Map" ){
if ( /grid width=(\d+)/ ){
$map_width = $1;
if ( $extra_width ) {
$new_map_width = $map_width + $extra_width;
} elsif ( exists $off{left} ) {
$new_map_width = $map_width - $off{left};
} else {
$new_map_width = $map_width;
}
$_ =~s/grid width=$map_width/grid width=$new_map_width/;
}
if ( /grid height=(\d+)/ ){
$map_height = $1;
$newMapHeight = $map_height - $off{top};
# $new_map_height = $map_height -1; # remove original bottom row
$_ =~s/grid height=$map_height/grid height=$newMapHeight/;
}
if ( /num plots written=(\d+)/ ){
$new_num_plots = $new_map_width * $newMapHeight;
$_ =~s/num plots written=\d+/num plots written=$new_num_plots/;
}
}
}
print;
}
# # extend map east
# $extra_width--;
# foreach $i ( 0 .. $extra_width ){
# $new_x = $map_width + $i;
# foreach $new_y ( 1 .. $new_map_height ){
# $new_y--;
# print <<"EOP";
# BeginPlot
# x=${new_x},y=$new_y
# TerrainType=TERRAIN_TUNDRA
# PlotType=2
# EndPlot
#
# EOP
# }
# }
After validating in civ4 WB, the final step now is to use civV WB to import into civV. This works very well so long as the civs, etc... match. Anything that doesn't (eg culture) is dropped.
If this is all too much I can probably do it for you sometime this week. I just need a map and what chops/adds are desired.