Move a city to a different plot

DutchTed

Chieftain
Joined
Feb 23, 2009
Messages
11
I've been asked to implement a civil engineer unit which can go to an existing city and move it one square in any direction but I can't see where abouts in code it is possible to do this.

I primarily use the SDK but aren't averse to using Python either. It's just as I have more experience with C++ I have tended to stick with it.

I can get hold of the relevant CvCity but am struggling on how to attach it to a different CvPlot.

Any help would be much appreciated.

Thanks in advance.
 
I don't think there is any way to take an existing cvcity and move it to a different cvplot. It should be possible to create a new city, loop over the attributes of the old city and copy them to the new one, and then delete the old city.
 
It should be possible to create a new city, loop over the attributes of the old city and copy them to the new one, and then delete the old city.
This is how city acquisition works when a city is captured. It's likely you will need to do it this way as well.
 
I tried to change the coords of a city once and I get pretty far with it but there are a few graphic details which won't update automatically and unfortunatly only few commands for the graphic engine are exposed to the dll. Unless you find a a way to deal with the graphic issues you probably need to do the create new object, copy and delete old one routine.
 
Thanks for the replies guys. I'll look into making a new CvCity and iterating through the old one's properties.
 
Look at the CvPlayer::acquireCity function. Either it's done there, or one of the functions that calls it, or that it calls does this, as this is exactly how aquiring a city from either conquest or culture flipping is done.
 
Back
Top Bottom