Moving cities around

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Posts: 13
Joined: Thu Dec 28, 2017 11:23 am

Moving cities around

Postby nctrd » Fri Nov 23, 2018 11:38 pm

I got inspired by Dracula's moving castle from Castlevania, and I wonder how would the game change if there was an option to teleport a city to a whole new location (with regular restrictions, e.g. not right next to another city and not into other nation's territory).

I see that a technology, a special building or a wonder allowing it can be created using rulesets. But, what about the movement itself? It must be a feature more special than destroy-and-create city, not leave ruins behind, tile use and borders must be updated etc.
Also, the question of roads arises. With all that in mind, how can that be coded?

Posts: 360
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia

Re: Moving cities around

Postby Ignatus » Sat Nov 24, 2018 7:49 pm

As defined in common/city.h in the source, a city is just a record which among other data contains a pointer (struct tile *tile) to the tile it stands on. This field probably will cause bugs if just reassigned, so the straightforward method to reallocate a city is just destroying it in one place and creating in the another (in the reverse order), with transferring all the units, rebuilding all the improvements and setting properly production counters etc. Currently, this in general case can't be done by Lua script, but coding it on C seems rather simple (just hardly will happen soon). I have thought about flying cities; if the game will ever be rewritten in OO code, maybe it would be efficient to base a unit and a city on the same class "game piece" with some actions and properties just blocked to one or another, or not.