The International Simutrans Forum

 

Author Topic: (Yet another) Attempt at a karte_t refactor  (Read 510 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 135
(Yet another) Attempt at a karte_t refactor
« on: September 25, 2019, 09:05:19 AM »
So, I have been thinking of doing yet another attempt at refactoring karte_t. My intention is to separate physical map properties like terrain, vehicles, cities etc. from the rest of the members of karte_t.
This first work-in-progress patch just moves these "physical map properties" to a separate map_t class and moves sync_list_t to separate h/cc files.

I am aware that there are now two classes named "map"; map_t seemed fitting, however renaming karte_t to world_t, or game_t as suggested in [this](https://forum.simutrans.com/index.php/topic,13960.msg138441.html#msg138441) comment is a huge task and I do not want to do it without prior discussion.

Some further things I want to do (in no particular order):
  • Move terraformer_t to its own h/cc file. terraformer_t seems to not be tightly coupled to karte_t so this should be easy to do.
  • Move terrain generation functions to map_t (e.g. create_rivers())
  • Move terraforming stuff to map_t (like raise_to, lower_to)

Since this is a rather large patch already, I created a branch to be able to view smaller individual commits:
https://github.com/aburch/simutrans/compare/master...ceeac:refactor-world

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2914
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: (Yet another) Attempt at a karte_t refactor
« Reply #1 on: September 26, 2019, 10:55:41 AM »
That's looking pretty good, I like it.

I'm just a bit puzzled on why there's now an include for cstring in macros.h. None of the changes seem to require that.

Online prissi

  • Developer
  • Administrator
  • *
  • Posts: 9990
  • Languages: De,EN,JP
Re: (Yet another) Attempt at a karte_t refactor
« Reply #2 on: September 28, 2019, 02:03:06 PM »
Maybe call the actual map information "terrain_t" and leave map_t to the actual map to orient on the terrain. I would also put all terrain related into this and not make another terraforming class.

If we do this, I am afraid almost no patch from experimental will be able to be backported and vice versa though.