Monday, January 8, 2018

Civil: Getting the game to run

Getting a game that saw last development many years ago to run is a hard task. It used Python 2, I wanted to use Python 3. It used PyGame 1.5.3, now the actual version is 1.9.3. And because there was no ' binary distribution' I cannot be sure if ever it run. And there are parts written in C which I would like to avoid. Python is still there and even more popular now, but being a weakly typed language, makes it harder to refactor or detect unused code.

In the end I managed (and could restructure the project too) by

  • Repeatedly (many, many times) starting the game, letting errors happen, looking at the stack trace, setting breakpoints, inspecting variables, fixing code.
  • Replacing old  code with fixed code in multiple location simultaneously using regular expressions and project wide find&replace in PyCharm
  • Using PyCharms refactoring capabilities
  • Using the 2to3 script to update Python 2 to Python 3 code
A mixture of all these methods finally made Civil run for me on a modern system with the limitation, that units do not move on the battle field. I'm not sure, if the original developers actually fixed that.

Civil seems to be free of obvious bugs.

No comments:

Post a Comment