modifying a map / cutting portions off?

m9x

Warlord
Joined
Jul 27, 2007
Messages
169
hey. i've downloaded a great custom made map from the community, however it's a bit too large for what i want to play.

what would be the easiest way to cut a certain selection of the map off? it's simple stuff like the left part of it would have to go. so only the outer regions really.

thanks
 
I've never tried this so I don't know for sure if it will work, but you could try manually editing the values in the WBSave file. If you open it in notepad and search for "BeginMap", the map size will be listed below that. You would probably need to delete any plot statements that fall outside of the new map size also. Like I said above, I'm not sure if this will work, so make sure that you backup the file first.

You would probabably need to change the value of "num plots written" in the map section also.

On a related subject -does anyone know how to change the map size while the game is running?
 
I wrote a perl program to modify a map. I needed to chop the 4 left-most columns, and the top 2 rows.
Code:
#!perl
#
# civIV map parser
###################################################

# $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;
}

If that doesn't make any sense then just post the map and what you want done. I probably won't be able to get to it till Monday though.

Editing the RHS is easy, just chop those plots and adjust the map info (eg num plots written). If you can make sense of the program you'll see that chopping from the left requires adjusting every remaining plot! Maps are rectangular and start at x=0,y=0. Chopping all x=0 plots is easy, but now plot x=0,y=0, etc.. is missing, and I'm pretty sure that is a CTD.
 
thanks so much guys - @primordial stew: i'm a c++ programmer myself so i can understand some perl and work my way into it. i'll put this script to good use! thanks a million :)
 
Top Bottom