Only in cmclient/bin/ai/regression: regression.nut
Only in cmclient/bin/ai/regression: regression.sav
Only in cmclient/bin/ai/regression: regression.txt
Only in cmclient/bin/ai/regression: require.nut
Only in cmclient/bin: data
Only in cmclient/bin/scripts: autoexec.scr
Only in cmclient/bin/scripts: on_client.scr
diff -r -B -X .diff-exclude vanilla/.changelog cmclient/.changelog
1c1
< 1.9.3-RC1 (2019-09-07)
---
> 1.9.0-beta2 (2018-02-09)
3,13c3
< - Add: Can now click industries to make orders to their neutral station (e.g. oil rig) (#7709)
< - Fix #7644: [OSX] Poor framerate on certain systems (#7721)
< - Fix #7702: Highscore screen UI scaling (#7714)
< - Fix #7704: [OSX] Handle malformed UTF8 strings, leading to crashes in server browser (#7705)
< - Fix #7188: [AI] Possible crash when reloading an AI in multiplayer games (#7701, #7725)
< - Fix: RemoveAirport function now returns 'Aircraft in the way' error message when occupied (#7690)
< - Fix: Spelling in running costs setting help text (#7686)
< - Fix #7655: 'Decrease' buttons in cheat window not working properly with UI scaling (#7669)
< - Fix: [GS] Could not create elements on Storybook pages with ID > 255 (#7657)
< - Fix #7626: Allow building road stops over town-owned one-way roads, instead of crashing (#7627)
< 
---
> - Fix: Non-Windows builds did not get correct git hash
Only in cmclient: .clang-format
Only in cmclient: cm_changelog.txt
Only in cmclient: cmclient.sublime-project
Only in cmclient: .diff-exclude
Only in cmclient/docs: Readme_Windows_MSVC.txt
Only in cmclient: gen_newgrf_revisions.py
Only in cmclient: .git
diff -r -B -X .diff-exclude vanilla/.ottdrev cmclient/.ottdrev
1c1
< 1.9.3-RC1	20190907	0	e5021a0587c504df89a3e549544f3c9b78e8a4bd	1	0
---
> 1.9.0-beta2	20190209	0	6e211908588ab5272336d0d2db3bbb4020f7004f
Only in cmclient/projects: Debug
Only in cmclient/projects: generate_vs100.vcxproj
Only in cmclient/projects: generate_vs80.vcproj
Only in cmclient/projects: generate_vs90.vcproj
Only in cmclient/projects: langs_vs100.vcxproj
Only in cmclient/projects: langs_vs100.vcxproj.filters
Only in cmclient/projects: langs_vs100.vcxproj.filters.in
Only in cmclient/projects: langs_vs100.vcxproj.in
Only in cmclient/projects: langs_vs80.vcproj
Only in cmclient/projects: langs_vs80.vcproj.in
Only in cmclient/projects: langs_vs90.vcproj
Only in cmclient/projects: langs_vs90.vcproj.in
Only in cmclient/projects: openttd_vs100.sln
Only in cmclient/projects: openttd_vs100.v11.suo
Only in cmclient/projects: openttd_vs100.vcxproj
Only in cmclient/projects: openttd_vs100.vcxproj.filters
Only in cmclient/projects: openttd_vs100.vcxproj.filters.in
Only in cmclient/projects: openttd_vs100.vcxproj.in
Only in cmclient/projects: openttd_vs100.vcxproj.my
Only in cmclient/projects: openttd_vs100.vcxproj.user
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs140.vcxproj cmclient/projects/openttd_vs140.vcxproj
450a451
>     <ClInclude Include="..\src\bitstream.h" />
452a454
>     <ClInclude Include="..\src\cargo_table_gui.h" />
699a702
>     <ClInclude Include="..\src\watch_gui.h" />
711a715
>     <ClInclude Include="..\src\zoning.h" />
747a752
>     <ClCompile Include="..\src\cargo_table_gui.cpp" />
748a754
>     <ClCompile Include="..\src\commands_gui.cpp" />
797a804
>     <ClCompile Include="..\src\watch_gui.cpp" />
799a807
>     <ClCompile Include="..\src\zoning_gui.cpp" />
805a814
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h" />
883a893,897
>     <ClCompile Include="..\src\zoning_cmd.cpp" />
>     <ClCompile Include="..\src\bitstream.cpp" />
>     <ClInclude Include="..\src\citymania\base64.h" />
>     <ClCompile Include="..\src\citymania\base64.cpp" />
>     <ClInclude Include="..\src\newgrf_revisions.hpp" />
890a905,906
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp" />
>     <ClInclude Include="..\src\saveload\citymania_sl.h" />
1201a1218
>     <ClCompile Include="..\src\blitter\base.cpp" />
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs140.vcxproj.filters cmclient/projects/openttd_vs140.vcxproj.filters
22c22
<     <Filter Include="Save/Load handlers">
---
>     <Filter Include="CityMania files">
25c25
<     <Filter Include="Tables">
---
>     <Filter Include="Save/Load handlers">
28c28
<     <Filter Include="MD5">
---
>     <Filter Include="Tables">
31c31
<     <Filter Include="Script">
---
>     <Filter Include="MD5">
34c34
<     <Filter Include="Squirrel">
---
>     <Filter Include="Script">
37c37
<     <Filter Include="Squirrel headers">
---
>     <Filter Include="Squirrel">
40c40
<     <Filter Include="AI Core">
---
>     <Filter Include="Squirrel headers">
43c43
<     <Filter Include="AI API">
---
>     <Filter Include="AI Core">
46c46
<     <Filter Include="Game API">
---
>     <Filter Include="AI API">
49c49
<     <Filter Include="Game Core">
---
>     <Filter Include="Game API">
52c52
<     <Filter Include="Script API">
---
>     <Filter Include="Game Core">
55c55
<     <Filter Include="Script API Implementation">
---
>     <Filter Include="Script API">
58c58
<     <Filter Include="Blitters">
---
>     <Filter Include="Script API Implementation">
61c61
<     <Filter Include="Drivers">
---
>     <Filter Include="Blitters">
64c64
<     <Filter Include="Sprite loaders">
---
>     <Filter Include="Drivers">
67c67
<     <Filter Include="NewGRF">
---
>     <Filter Include="Sprite loaders">
70c70
<     <Filter Include="Map Accessors">
---
>     <Filter Include="NewGRF">
73c73
<     <Filter Include="Misc">
---
>     <Filter Include="Map Accessors">
76c76
<     <Filter Include="Network Core">
---
>     <Filter Include="Misc">
79c79
<     <Filter Include="Pathfinder">
---
>     <Filter Include="Network Core">
82c82
<     <Filter Include="NPF">
---
>     <Filter Include="Pathfinder">
85c85
<     <Filter Include="YAPF">
---
>     <Filter Include="NPF">
88c88
<     <Filter Include="Video">
---
>     <Filter Include="YAPF">
91c91
<     <Filter Include="Music">
---
>     <Filter Include="Video">
94c94
<     <Filter Include="Sound">
---
>     <Filter Include="Music">
97c97
<     <Filter Include="Windows files">
---
>     <Filter Include="Sound">
100c100
<     <Filter Include="Threading">
---
>     <Filter Include="Windows files">
102a103,105
>     <Filter Include="Threading">
>       <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-000000000033}</UniqueIdentifier>
>     </Filter>
434a438,440
>     <ClInclude Include="..\src\bitstream.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
440a447,449
>     <ClInclude Include="..\src\cargo_table_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1181a1191,1193
>     <ClInclude Include="..\src\watch_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1217a1230,1232
>     <ClInclude Include="..\src\zoning.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1325a1341,1343
>     <ClCompile Include="..\src\cargo_table_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1328a1347,1349
>     <ClCompile Include="..\src\commands_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1475a1497,1499
>     <ClCompile Include="..\src\watch_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1481a1506,1508
>     <ClCompile Include="..\src\zoning_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1499a1527,1529
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h">
>       <Filter>Widgets</Filter>
>     </ClInclude>
1733a1764,1778
>     <ClCompile Include="..\src\zoning_cmd.cpp">
>       <Filter>Command handlers</Filter>
>     </ClCompile>
>     <ClCompile Include="..\src\bitstream.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\citymania\base64.h">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
>     <ClCompile Include="..\src\citymania\base64.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\newgrf_revisions.hpp">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
1754a1800,1805
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp">
>       <Filter>Save/Load handlers</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\saveload\citymania_sl.h">
>       <Filter>Save/Load handlers</Filter>
>     </ClInclude>
2687a2739,2741
>     <ClCompile Include="..\src\blitter\base.cpp">
>       <Filter>Blitters</Filter>
>     </ClCompile>
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs141.vcxproj cmclient/projects/openttd_vs141.vcxproj
450a451
>     <ClInclude Include="..\src\bitstream.h" />
452a454
>     <ClInclude Include="..\src\cargo_table_gui.h" />
699a702
>     <ClInclude Include="..\src\watch_gui.h" />
711a715
>     <ClInclude Include="..\src\zoning.h" />
747a752
>     <ClCompile Include="..\src\cargo_table_gui.cpp" />
748a754
>     <ClCompile Include="..\src\commands_gui.cpp" />
797a804
>     <ClCompile Include="..\src\watch_gui.cpp" />
799a807
>     <ClCompile Include="..\src\zoning_gui.cpp" />
805a814
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h" />
883a893,897
>     <ClCompile Include="..\src\zoning_cmd.cpp" />
>     <ClCompile Include="..\src\bitstream.cpp" />
>     <ClInclude Include="..\src\citymania\base64.h" />
>     <ClCompile Include="..\src\citymania\base64.cpp" />
>     <ClInclude Include="..\src\newgrf_revisions.hpp" />
890a905,906
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp" />
>     <ClInclude Include="..\src\saveload\citymania_sl.h" />
1201a1218
>     <ClCompile Include="..\src\blitter\base.cpp" />
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs141.vcxproj.filters cmclient/projects/openttd_vs141.vcxproj.filters
22c22
<     <Filter Include="Save/Load handlers">
---
>     <Filter Include="CityMania files">
25c25
<     <Filter Include="Tables">
---
>     <Filter Include="Save/Load handlers">
28c28
<     <Filter Include="MD5">
---
>     <Filter Include="Tables">
31c31
<     <Filter Include="Script">
---
>     <Filter Include="MD5">
34c34
<     <Filter Include="Squirrel">
---
>     <Filter Include="Script">
37c37
<     <Filter Include="Squirrel headers">
---
>     <Filter Include="Squirrel">
40c40
<     <Filter Include="AI Core">
---
>     <Filter Include="Squirrel headers">
43c43
<     <Filter Include="AI API">
---
>     <Filter Include="AI Core">
46c46
<     <Filter Include="Game API">
---
>     <Filter Include="AI API">
49c49
<     <Filter Include="Game Core">
---
>     <Filter Include="Game API">
52c52
<     <Filter Include="Script API">
---
>     <Filter Include="Game Core">
55c55
<     <Filter Include="Script API Implementation">
---
>     <Filter Include="Script API">
58c58
<     <Filter Include="Blitters">
---
>     <Filter Include="Script API Implementation">
61c61
<     <Filter Include="Drivers">
---
>     <Filter Include="Blitters">
64c64
<     <Filter Include="Sprite loaders">
---
>     <Filter Include="Drivers">
67c67
<     <Filter Include="NewGRF">
---
>     <Filter Include="Sprite loaders">
70c70
<     <Filter Include="Map Accessors">
---
>     <Filter Include="NewGRF">
73c73
<     <Filter Include="Misc">
---
>     <Filter Include="Map Accessors">
76c76
<     <Filter Include="Network Core">
---
>     <Filter Include="Misc">
79c79
<     <Filter Include="Pathfinder">
---
>     <Filter Include="Network Core">
82c82
<     <Filter Include="NPF">
---
>     <Filter Include="Pathfinder">
85c85
<     <Filter Include="YAPF">
---
>     <Filter Include="NPF">
88c88
<     <Filter Include="Video">
---
>     <Filter Include="YAPF">
91c91
<     <Filter Include="Music">
---
>     <Filter Include="Video">
94c94
<     <Filter Include="Sound">
---
>     <Filter Include="Music">
97c97
<     <Filter Include="Windows files">
---
>     <Filter Include="Sound">
100c100
<     <Filter Include="Threading">
---
>     <Filter Include="Windows files">
102a103,105
>     <Filter Include="Threading">
>       <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-000000000033}</UniqueIdentifier>
>     </Filter>
434a438,440
>     <ClInclude Include="..\src\bitstream.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
440a447,449
>     <ClInclude Include="..\src\cargo_table_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1181a1191,1193
>     <ClInclude Include="..\src\watch_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1217a1230,1232
>     <ClInclude Include="..\src\zoning.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1325a1341,1343
>     <ClCompile Include="..\src\cargo_table_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1328a1347,1349
>     <ClCompile Include="..\src\commands_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1475a1497,1499
>     <ClCompile Include="..\src\watch_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1481a1506,1508
>     <ClCompile Include="..\src\zoning_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1499a1527,1529
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h">
>       <Filter>Widgets</Filter>
>     </ClInclude>
1733a1764,1778
>     <ClCompile Include="..\src\zoning_cmd.cpp">
>       <Filter>Command handlers</Filter>
>     </ClCompile>
>     <ClCompile Include="..\src\bitstream.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\citymania\base64.h">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
>     <ClCompile Include="..\src\citymania\base64.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\newgrf_revisions.hpp">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
1754a1800,1805
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp">
>       <Filter>Save/Load handlers</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\saveload\citymania_sl.h">
>       <Filter>Save/Load handlers</Filter>
>     </ClInclude>
2687a2739,2741
>     <ClCompile Include="..\src\blitter\base.cpp">
>       <Filter>Blitters</Filter>
>     </ClCompile>
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs142.vcxproj cmclient/projects/openttd_vs142.vcxproj
450a451
>     <ClInclude Include="..\src\bitstream.h" />
452a454
>     <ClInclude Include="..\src\cargo_table_gui.h" />
699a702
>     <ClInclude Include="..\src\watch_gui.h" />
711a715
>     <ClInclude Include="..\src\zoning.h" />
747a752
>     <ClCompile Include="..\src\cargo_table_gui.cpp" />
748a754
>     <ClCompile Include="..\src\commands_gui.cpp" />
797a804
>     <ClCompile Include="..\src\watch_gui.cpp" />
799a807
>     <ClCompile Include="..\src\zoning_gui.cpp" />
805a814
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h" />
883a893,897
>     <ClCompile Include="..\src\zoning_cmd.cpp" />
>     <ClCompile Include="..\src\bitstream.cpp" />
>     <ClInclude Include="..\src\citymania\base64.h" />
>     <ClCompile Include="..\src\citymania\base64.cpp" />
>     <ClInclude Include="..\src\newgrf_revisions.hpp" />
890a905,906
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp" />
>     <ClInclude Include="..\src\saveload\citymania_sl.h" />
1201a1218
>     <ClCompile Include="..\src\blitter\base.cpp" />
diff -r -B -X .diff-exclude vanilla/projects/openttd_vs142.vcxproj.filters cmclient/projects/openttd_vs142.vcxproj.filters
22c22
<     <Filter Include="Save/Load handlers">
---
>     <Filter Include="CityMania files">
25c25
<     <Filter Include="Tables">
---
>     <Filter Include="Save/Load handlers">
28c28
<     <Filter Include="MD5">
---
>     <Filter Include="Tables">
31c31
<     <Filter Include="Script">
---
>     <Filter Include="MD5">
34c34
<     <Filter Include="Squirrel">
---
>     <Filter Include="Script">
37c37
<     <Filter Include="Squirrel headers">
---
>     <Filter Include="Squirrel">
40c40
<     <Filter Include="AI Core">
---
>     <Filter Include="Squirrel headers">
43c43
<     <Filter Include="AI API">
---
>     <Filter Include="AI Core">
46c46
<     <Filter Include="Game API">
---
>     <Filter Include="AI API">
49c49
<     <Filter Include="Game Core">
---
>     <Filter Include="Game API">
52c52
<     <Filter Include="Script API">
---
>     <Filter Include="Game Core">
55c55
<     <Filter Include="Script API Implementation">
---
>     <Filter Include="Script API">
58c58
<     <Filter Include="Blitters">
---
>     <Filter Include="Script API Implementation">
61c61
<     <Filter Include="Drivers">
---
>     <Filter Include="Blitters">
64c64
<     <Filter Include="Sprite loaders">
---
>     <Filter Include="Drivers">
67c67
<     <Filter Include="NewGRF">
---
>     <Filter Include="Sprite loaders">
70c70
<     <Filter Include="Map Accessors">
---
>     <Filter Include="NewGRF">
73c73
<     <Filter Include="Misc">
---
>     <Filter Include="Map Accessors">
76c76
<     <Filter Include="Network Core">
---
>     <Filter Include="Misc">
79c79
<     <Filter Include="Pathfinder">
---
>     <Filter Include="Network Core">
82c82
<     <Filter Include="NPF">
---
>     <Filter Include="Pathfinder">
85c85
<     <Filter Include="YAPF">
---
>     <Filter Include="NPF">
88c88
<     <Filter Include="Video">
---
>     <Filter Include="YAPF">
91c91
<     <Filter Include="Music">
---
>     <Filter Include="Video">
94c94
<     <Filter Include="Sound">
---
>     <Filter Include="Music">
97c97
<     <Filter Include="Windows files">
---
>     <Filter Include="Sound">
100c100
<     <Filter Include="Threading">
---
>     <Filter Include="Windows files">
102a103,105
>     <Filter Include="Threading">
>       <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-000000000033}</UniqueIdentifier>
>     </Filter>
434a438,440
>     <ClInclude Include="..\src\bitstream.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
440a447,449
>     <ClInclude Include="..\src\cargo_table_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1181a1191,1193
>     <ClInclude Include="..\src\watch_gui.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1217a1230,1232
>     <ClInclude Include="..\src\zoning.h">
>       <Filter>Header Files</Filter>
>     </ClInclude>
1325a1341,1343
>     <ClCompile Include="..\src\cargo_table_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1328a1347,1349
>     <ClCompile Include="..\src\commands_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1475a1497,1499
>     <ClCompile Include="..\src\watch_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1481a1506,1508
>     <ClCompile Include="..\src\zoning_gui.cpp">
>       <Filter>GUI Source Code</Filter>
>     </ClCompile>
1499a1527,1529
>     <ClInclude Include="..\src\widgets\cargo_table_widget.h">
>       <Filter>Widgets</Filter>
>     </ClInclude>
1733a1764,1778
>     <ClCompile Include="..\src\zoning_cmd.cpp">
>       <Filter>Command handlers</Filter>
>     </ClCompile>
>     <ClCompile Include="..\src\bitstream.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\citymania\base64.h">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
>     <ClCompile Include="..\src\citymania\base64.cpp">
>       <Filter>CityMania files</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\newgrf_revisions.hpp">
>       <Filter>CityMania files</Filter>
>     </ClInclude>
1754a1800,1805
>     <ClCompile Include="..\src\saveload\citymania_sl.cpp">
>       <Filter>Save/Load handlers</Filter>
>     </ClCompile>
>     <ClInclude Include="..\src\saveload\citymania_sl.h">
>       <Filter>Save/Load handlers</Filter>
>     </ClInclude>
2687a2739,2741
>     <ClCompile Include="..\src\blitter\base.cpp">
>       <Filter>Blitters</Filter>
>     </ClCompile>
Only in cmclient/projects: openttd_vs80.sln
Only in cmclient/projects: openttd_vs80.vcproj
Only in cmclient/projects: openttd_vs80.vcproj.in
Only in cmclient/projects: openttd_vs80.vcproj.user
Only in cmclient/projects: openttd_vs90.sln
Only in cmclient/projects: openttd_vs90.vcproj
Only in cmclient/projects: openttd_vs90.vcproj.in
Only in cmclient/projects: openttd_vs90.vcproj.user
Only in cmclient/projects: settingsgen_vs100.vcxproj
Only in cmclient/projects: settingsgen_vs100.vcxproj.filters
Only in cmclient/projects: settingsgen_vs80.vcproj
Only in cmclient/projects: settingsgen_vs90.vcproj
Only in cmclient/projects: settings_vs100.vcxproj
Only in cmclient/projects: settings_vs100.vcxproj.filters
Only in cmclient/projects: settings_vs100.vcxproj.filters.in
Only in cmclient/projects: settings_vs100.vcxproj.in
Only in cmclient/projects: settings_vs100.vcxproj.user
Only in cmclient/projects: settings_vs80.vcproj
Only in cmclient/projects: settings_vs80.vcproj.in
Only in cmclient/projects: settings_vs90.vcproj
Only in cmclient/projects: settings_vs90.vcproj.in
Only in cmclient/projects: strgen_vs100.vcxproj
Only in cmclient/projects: strgen_vs100.vcxproj.filters
Only in cmclient/projects: strgen_vs100.vcxproj.user
Only in cmclient/projects: strgen_vs80.vcproj
Only in cmclient/projects: strgen_vs90.vcproj
Only in cmclient/projects: version_vs100.vcxproj
Only in cmclient/projects: version_vs80.vcproj
Only in cmclient/projects: version_vs90.vcproj
Only in cmclient: readme.txt
diff -r -B -X .diff-exclude vanilla/.release_date cmclient/.release_date
1c1
< 2019-09-07 22:25 UTC
---
> 2019-02-09 21:41 UTC
Only in cmclient: release.zip
diff -r -B -X .diff-exclude vanilla/source.list cmclient/source.list
137a138
> bitstream.h
139a141
> cargo_table_gui.h
386a389
> watch_gui.h
398a402
> zoning.h
455a460
> cargo_table_gui.cpp
456a462
> commands_gui.cpp
505a512
> watch_gui.cpp
507a515
> zoning_gui.cpp
515a524
> widgets/cargo_table_widget.h
595a605,611
> zoning_cmd.cpp
> 
> # CityMania files
> bitstream.cpp
> citymania/base64.h
> citymania/base64.cpp
> newgrf_revisions.hpp
604a621,622
> saveload/citymania_sl.cpp
> saveload/citymania_sl.h
946a965
> blitter/base.cpp
Only in cmclient/src/3rdparty/squirrel: COMPILE
Only in cmclient/src/3rdparty/squirrel: doc
Only in cmclient/src/3rdparty/squirrel: etc
Only in cmclient/src/3rdparty/squirrel: HISTORY
Only in cmclient/src/3rdparty/squirrel/include: sqstdblob.h
Only in cmclient/src/3rdparty/squirrel/include: sqstdio.h
Only in cmclient/src/3rdparty/squirrel/include: sqstdsystem.h
Only in cmclient/src/3rdparty/squirrel: Makefile
Only in cmclient/src/3rdparty/squirrel: README
Only in cmclient/src/3rdparty/squirrel: samples
Only in cmclient/src/3rdparty/squirrel: sq
Only in cmclient/src/3rdparty/squirrel/sqstdlib: Makefile
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdblob.cpp
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdblobimpl.h
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdio.cpp
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdlib.dsp
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdstream.cpp
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdstream.h
Only in cmclient/src/3rdparty/squirrel/sqstdlib: sqstdsystem.cpp
Only in cmclient/src/3rdparty/squirrel/squirrel: Makefile
Only in cmclient/src/3rdparty/squirrel/squirrel: squirrel.dsp
Only in cmclient/src/3rdparty/squirrel: squirrel.dsw
diff -r -B -X .diff-exclude vanilla/src/aircraft_cmd.cpp cmclient/src/aircraft_cmd.cpp
2058c2058
< 	PerformanceAccumulator framerate(PFE_GL_AIRCRAFT);
---
> 	// PerformanceAccumulator framerate(PFE_GL_AIRCRAFT);
Only in cmclient/src: bitstream.cpp
Only in cmclient/src: bitstream.h
Only in cmclient/src/blitter: base.cpp
diff -r -B -X .diff-exclude vanilla/src/bridge_gui.cpp cmclient/src/bridge_gui.cpp
26a27
> #include "tilehighlight_func.h"
75a77,78
> 
> 	StoreRailPlacementEndpoints(p1, end_tile, (TileX(p1) == TileX(end_tile)) ? TRACK_Y : TRACK_X, false);
diff -r -B -X .diff-exclude vanilla/src/build_vehicle_gui.cpp cmclient/src/build_vehicle_gui.cpp
37c37
< 
---
> #include "hotkeys.h"
1497a1498,1510
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		if (this->owner != _local_company) return ES_NOT_HANDLED;
> 		return Window::OnHotkey(hotkey);
> 	}
> 
> 	static HotkeyList hotkeys;
> };
> 
> static Hotkey build_vehicle_hotkeys[] = {
> 	Hotkey('R', "build_vehicle", WID_BV_BUILD),
> 	HOTKEY_LIST_END
1498a1512
> HotkeyList BuildVehicleWindow::hotkeys("build_vehicle", build_vehicle_hotkeys);
1504c1518,1519
< 	_nested_build_vehicle_widgets, lengthof(_nested_build_vehicle_widgets)
---
> 	_nested_build_vehicle_widgets, lengthof(_nested_build_vehicle_widgets),
> 	&BuildVehicleWindow::hotkeys
Only in cmclient/src: cargo_table_gui.cpp
Only in cmclient/src: cargo_table_gui.h
Only in cmclient/src: citymania
diff -r -B -X .diff-exclude vanilla/src/command.cpp cmclient/src/command.cpp
28a29,32
> #include "window_func.h"
> #include "watch_gui.h"
> #include "network/network_base.h"
> #include "window_func.h"
561c565,566
< 			(cmd & CMD_ID_MASK) != CMD_PAUSE;
---
> 			(cmd & CMD_ID_MASK) != CMD_PAUSE &&
> 			!(cmd & CMD_NO_ESTIMATE);
759a765,781
> 	}
> 
> 	/* Send Tile Number to Watching Company Windows */
> 	WatchCompany *wc;
> 	for(int watching_window = 0; ; watching_window++){
> 		wc = dynamic_cast<WatchCompany*>(FindWindowById(WC_WATCH_COMPANY, watching_window));
> 		if(wc != NULL) wc->OnDoCommand(_current_company, tile);
> 		else break;
> 	}
> 
> 	NetworkClientInfo *ci;
> 	FOR_ALL_CLIENT_INFOS(ci) {
> 		if (ci->client_playas == _current_company) {
> 			wc = dynamic_cast<WatchCompany*>(FindWindowById(WC_WATCH_COMPANYA, ci->client_id));
> 			if (wc != NULL) wc->OnDoCommand(_current_company, tile);
> 			break;
> 		}
Only in cmclient/src: commands_gui.cpp
diff -r -B -X .diff-exclude vanilla/src/command_type.h cmclient/src/command_type.h
369c369
< #define CMD_MSG(x) ((x) << 16)
---
> #define CMD_MSG(x) ((uint32)((x) << 16))
377a378
> 	CMD_NO_ESTIMATE           = 0x0200, ///< execute command instead of doing estimate even if shift is pressed
diff -r -B -X .diff-exclude vanilla/src/company_base.h cmclient/src/company_base.h
19a20
> #include "cargo_type.h"
28a30
> 	Money cargo_income[NUM_CARGO]; ///< Cargo income from each cargo type	
130a133,138
> 
> 	uint32 cargo_units[NUM_CARGO];   ///< Total amount of transported cargo for each cargo ID
> 	Money cargo_income[NUM_CARGO];   ///< Total income from transported cargo for each cargo ID
> 
> 	uint32 cargo_units_period[2][NUM_CARGO];   ///< Monthly amount of transported cargo for each cargo ID 
> 	Money cargo_income_period[2][NUM_CARGO];   ///< Monthly income from transported cargo for each cargo ID
diff -r -B -X .diff-exclude vanilla/src/company_cmd.cpp cmclient/src/company_cmd.cpp
40a41
> #include "cargo_type.h"
71a73,74
> 	InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
> 	InvalidateWindowClassesData(WC_WATCH_COMPANYA, 1);
93a97,98
> 	InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
> 	InvalidateWindowClassesData(WC_WATCH_COMPANYA, 1);
587a593,600
> 	if (!is_ai) UpdateAllTownVirtCoords(); //coloured rating
> 
> 	for (uint j = 0; j < NUM_CARGO; j++) {
> 		c->cargo_income[j] = 0;
> 		c->cargo_units[j] = 0;
> 	}
> 	CargoResetPeriods(c);
> 
590a604,609
> void CargoResetPeriods(Company *c){
> 	memmove(&c->cargo_income_period[1], &c->cargo_income_period[0], sizeof(c->cargo_income_period[0]));
> 	memset(&c->cargo_income_period, 0, sizeof(c->cargo_income_period[0]));
> 	memmove(&c->cargo_units_period[1], &c->cargo_units_period[0], sizeof(c->cargo_units_period[0]));
> 	memset(&c->cargo_units_period, 0, sizeof(c->cargo_units_period[0]));
> }
1088a1108
> 		InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
diff -r -B -X .diff-exclude vanilla/src/company_func.h cmclient/src/company_func.h
33a34
> void CargoResetPeriods(Company *c);
diff -r -B -X .diff-exclude vanilla/src/company_gui.cpp cmclient/src/company_gui.cpp
2170c2170,2177
< 						NWidget(NWID_SPACER), SetFill(0, 1),
---
> 						NWidget(NWID_SELECTION, INVALID_COLOUR, WID_C_SELECT_MOD),
> 							NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
> 							NWidget(NWID_VERTICAL), SetPIP(4, 2, 4),
> 								NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_JOIN), SetFill(1, 0), SetDataTip(STR_MOD_COMPANY_JOIN_BUTTON, STR_NULL),
> 								NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_TOGGLE_LOCK), SetFill(1, 0), SetDataTip(STR_MOD_TOGGLE_LOCK_BUTTON, STR_NULL),
> 								NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_C_MOD_COMPANY_RESET), SetFill(1, 0), SetDataTip(STR_MOD_COMPANY_RESET_BUTTON, STR_NULL),
> 							EndContainer(),
> 						EndContainer(),
2239a2247,2256
> static void ResetCallback(Window *w, bool confirmed)
> {
> 	if (confirmed) {
> 		CompanyID company2 = (CompanyID)w->window_number;
> 		char msg[128];
> 		seprintf(msg, lastof(msg), "!reset %i", company2 + 1);
> 		NetworkClientSendChatToServer(msg);
> 	}
> }
> 
2260a2278,2280
> 
> 		CWP_BUTTONS_PLAYER = 0,
> 		CWP_BUTTONS_MOD,
2329a2350,2356
> 			plane = (int)(_networking && _novarole ? CWP_BUTTONS_MOD: CWP_BUTTONS_PLAYER);
> 			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_MOD);
> 			if (plane != wi->shown_plane) {
> 				wi->SetDisplayedPlane(plane);
> 				reinit = true;
> 			}
> 
2335a2363,2369
> 		// if(!_networking) {
> 		// 	this->SetWidgetDisabledState(CW_WIDGET_COMPANY_RESUME, true);
> 		// 	this->SetWidgetDisabledState(CW_WIDGET_COMPANY_SUSPEND, true);
> 		// 	this->SetWidgetDisabledState(CW_WIDGET_COMPANY_RESET, true);
> 		// 	this->SetWidgetDisabledState(CW_WIDGET_COMPANY_JOIN2, true);
> 		// }
> 
2391a2426,2434
> 			// case CW_WIDGET_COMPANY_RESUME:
> 			// case CW_WIDGET_COMPANY_SUSPEND:
> 			// case CW_WIDGET_COMPANY_RESET:
> 			// case CW_WIDGET_COMPANY_JOIN2:
> 			// 	if(!_novarole){
> 			// 		size->width = 0;
> 			// 		size->height = 0;
> 			// 	}
> 			// 	break;
2616a2660,2687
> 				MarkWholeScreenDirty();
> 				break;
> 			}
> 
> 			case WID_C_MOD_COMPANY_JOIN: {
> 				if (!_novarole) return;
> 				CompanyID company2 = (CompanyID)this->window_number;
> 				// this->query_widget = WID_C_MOD_COMPANY_JOIN;
> 				char msg[128];
> 				seprintf(msg, lastof(msg), "!move %i", company2 + 1);
> 				NetworkClientSendChatToServer(msg);
> 				MarkWholeScreenDirty();
> 				break;
> 			}
> 			case WID_C_MOD_COMPANY_RESET: {
> 				if (!_networking) return;
> 				this->query_widget = WID_C_MOD_COMPANY_RESET;
> 				ShowQuery(STR_XI_RESET_CAPTION, STR_XI_REALY_RESET, this, ResetCallback);
> 				MarkWholeScreenDirty();
> 				break;
> 			}
> 			case WID_C_MOD_COMPANY_TOGGLE_LOCK: {
> 				if (!_novarole) return;
> 				CompanyID company2 = (CompanyID)this->window_number;
> 				char msg[128];
> 				seprintf(msg, lastof(msg), "!lockp %i", company2 + 1);
> 				NetworkClientSendChatToServer(msg);
> 				MarkWholeScreenDirty();
diff -r -B -X .diff-exclude vanilla/src/crashlog.cpp cmclient/src/crashlog.cpp
122c122
< 			"OpenTTD version:\n"
---
> 			"OpenTTD version: CityMania patched client  http://citymania.org\n\n\n"
336c336
< 	buffer += seprintf(buffer, last, "*** OpenTTD Crash Report ***\n\n");
---
> 	buffer += seprintf(buffer, last, "*** OpenTTD Crash Report ***\nCityMania patched client  http://citymania.org\nPlease, unless you encounter this bug with unpatched OpenTTD version, report bug to CityMania team\n\n");
diff -r -B -X .diff-exclude vanilla/src/depot_gui.cpp cmclient/src/depot_gui.cpp
31c31
< 
---
> #include "hotkeys.h"
84,111d83
< static WindowDesc _train_depot_desc(
< 	WDP_AUTO, "depot_train", 362, 123,
< 	WC_VEHICLE_DEPOT, WC_NONE,
< 	0,
< 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
< );
< 
< static WindowDesc _road_depot_desc(
< 	WDP_AUTO, "depot_roadveh", 316, 97,
< 	WC_VEHICLE_DEPOT, WC_NONE,
< 	0,
< 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
< );
< 
< static WindowDesc _ship_depot_desc(
< 	WDP_AUTO, "depot_ship", 306, 99,
< 	WC_VEHICLE_DEPOT, WC_NONE,
< 	0,
< 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
< );
< 
< static WindowDesc _aircraft_depot_desc(
< 	WDP_AUTO, "depot_aircraft", 332, 99,
< 	WC_VEHICLE_DEPOT, WC_NONE,
< 	0,
< 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
< );
< 
333,335c305,314
< 				SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
< 				SetDParam(1, 1);
< 				DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter
---
> 				if (_settings_client.gui.old_depot_train_length_calc) {
> 					SetDParam(0, CeilDiv(u->gcache.cached_total_length, 8));
> 					SetDParam(1, 1);
> 					DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter
> 				}
> 				else {
> 					SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
> 					SetDParam(1, 1);
> 					DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter
> 				}
1082a1062,1076
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		if (this->owner != _local_company) return ES_NOT_HANDLED;
> 		return Window::OnHotkey(hotkey);
> 	}
> 
> 	static HotkeyList hotkeys;
> };
> 
> static Hotkey depot_hotkeys[] = {
> 	Hotkey(WKC_CTRL | 'F', "depot_go_all", WID_D_START_ALL),
> 	Hotkey('R', "depot_build_vehicle", WID_D_BUILD),
> 	Hotkey(WKC_NONE, "depot_clone_vehicle", WID_D_CLONE),
> 	HOTKEY_LIST_END
1083a1078
> HotkeyList DepotWindow::hotkeys("depot_gui", depot_hotkeys);
1093a1089,1120
> 
> static WindowDesc _train_depot_desc(
> 	WDP_AUTO, "depot_train", 362, 123,
> 	WC_VEHICLE_DEPOT, WC_NONE,
> 	0,
> 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets),
> 	&DepotWindow::hotkeys
> );
> 
> static WindowDesc _road_depot_desc(
> 	WDP_AUTO, "depot_roadveh", 316, 97,
> 	WC_VEHICLE_DEPOT, WC_NONE,
> 	0,
> 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets),
> 	&DepotWindow::hotkeys
> );
> 
> static WindowDesc _ship_depot_desc(
> 	WDP_AUTO, "depot_ship", 306, 99,
> 	WC_VEHICLE_DEPOT, WC_NONE,
> 	0,
> 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets),
> 	&DepotWindow::hotkeys
> );
> 
> static WindowDesc _aircraft_depot_desc(
> 	WDP_AUTO, "depot_aircraft", 332, 99,
> 	WC_VEHICLE_DEPOT, WC_NONE,
> 	0,
> 	_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets),
> 	&DepotWindow::hotkeys
> );
diff -r -B -X .diff-exclude vanilla/src/dock_gui.cpp cmclient/src/dock_gui.cpp
192a193,194
> 				if (_ctrl_pressed == _settings_client.gui.persistent_depottools)
> 					ResetObjectToPlace();
diff -r -B -X .diff-exclude vanilla/src/economy.cpp cmclient/src/economy.cpp
55a56
> #include "cargo_table_gui.h"
388a390,391
> 		ClrBit(t->advertise_regularly, old_owner);
> 		ClrBit(t->do_powerfund, old_owner);
1122a1126,1133
> 	/* Increase town's counter for all goods types only if delivered near town*/
> 	if(CB_Enabled()){
> 		if (_settings_client.gui.cb_distance_check == 0 || (DistanceManhattan(st->town->xy, st->xy) <= _settings_client.gui.cb_distance_check)) {
> 			st->town->new_act_cargo[cargo_type] += accepted_total;
> 			InvalidateWindowData(WC_CB_TOWN, st->town->index);
> 		}
> 	}
> 
1138a1150,1159
> 	company->cargo_income[cargo_type] += profit;
> 	company->cargo_units[cargo_type] += num_pieces;
> 
> 	company->cargo_income_period[0][cargo_type] += profit;
> 	company->cargo_units_period[0][cargo_type] += num_pieces;
> 
> 	company->cur_economy.cargo_income[cargo_type] += profit;
> 
> 	InvalidateCargosWindows(company->index);
> 
1974a1996,2000
> 
> 	Company *c;
> 	FOR_ALL_COMPANIES(c){
> 		CargoResetPeriods(c);
> 	}
Only in cmclient/src: endian_check.cpp
diff -r -B -X .diff-exclude vanilla/src/fontdetection.cpp cmclient/src/fontdetection.cpp
645c645
< 		FcFini();
---
> 		// FcFini();
diff -r -B -X .diff-exclude vanilla/src/framerate_gui.cpp cmclient/src/framerate_gui.cpp
308c308
< static const PerformanceElement DISPLAY_ORDER_PFE[PFE_MAX] = {
---
> static const PerformanceElement DISPLAY_ORDER_PFE[PFE_MAX - 4] = {
311,314c311,314
< 	PFE_GL_TRAINS,
< 	PFE_GL_ROADVEHS,
< 	PFE_GL_SHIPS,
< 	PFE_GL_AIRCRAFT,
---
> 	// PFE_GL_TRAINS,
> 	// PFE_GL_ROADVEHS,
> 	// PFE_GL_SHIPS,
> 	// PFE_GL_AIRCRAFT,
diff -r -B -X .diff-exclude vanilla/src/gfx.cpp cmclient/src/gfx.cpp
36a37
> bool _alt_pressed;    ///< Is Alt pressed?
diff -r -B -X .diff-exclude vanilla/src/gfx_func.h cmclient/src/gfx_func.h
57a58
> extern bool _alt_pressed;    ///< Is Alt pressed?
diff -r -B -X .diff-exclude vanilla/src/gfxinit.cpp cmclient/src/gfxinit.cpp
194a195
> 	LoadGrfFile("innerhighlight.grf", SPR_INNER_HIGHLIGHT_BASE, i++);
diff -r -B -X .diff-exclude vanilla/src/gfx_type.h cmclient/src/gfx_type.h
106a107,116
> 
> 	WKC_L_BRACE     = 154, ///< { Left brace
> 	WKC_R_BRACE     = 155, ///< } Right brace
> 	
> 	WKC_L_PAREN     = 157, ///< ( Left parentheses
> 	WKC_R_PAREN     = 158, ///< ) Right parentheses
> 	WKC_PLUS        = 159, ///< + Plus
> 	WKC_EXCLAIM     = 160, ///< ! Exclamation mark
> 	WKC_ASTERISK    = 161, ///< * Asterisk
> 	WKC_DOLLAR      = 162, ///< $ Dollar sign
diff -r -B -X .diff-exclude vanilla/src/goal_gui.cpp cmclient/src/goal_gui.cpp
187c187,195
< 		d.height *= 5;
---
> 		uint num = 0;
> 		const Goal *s;
> 		FOR_ALL_GOALS(s) {
> 			if (s->company == INVALID_COMPANY || s->company == this->window_number) {
> 				num++;
> 			}
> 		}
> 
> 		d.height *= (5 + num);
diff -r -B -X .diff-exclude vanilla/src/graph_gui.cpp cmclient/src/graph_gui.cpp
612a613,762
> struct ExcludingCargoBaseGraphWindow : BaseGraphWindow {
> 	ExcludingCargoBaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis):
> 			BaseGraphWindow(desc, widget, format_str_y_axis)
> 	{
> 	}
> 
> 	uint line_height;   ///< Pixel height of each cargo type row.
> 	uint icon_size;     ///< Size of the cargo color icon.
> 	Scrollbar *vscroll; ///< Cargo list scrollbar.
> 
> 	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
> 	{
> 		if (widget != WID_CPR_MATRIX) {
> 			BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
> 			return;
> 		}
> 
> 		Dimension max_cargo_dim = {0, 0};
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			SetDParam(0, cs->name);
> 			max_cargo_dim = maxdim(max_cargo_dim, GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO));
> 		}
> 
> 		this->icon_size = max<uint>(max_cargo_dim.height, 6);
> 		this->line_height = this->icon_size + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
> 		size->width = (max_cargo_dim.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + 1
> 		               + this->icon_size + WD_PAR_VSEP_NORMAL);
> 		// fprintf(stderr, "HEIGHT %u \n", size->height, size->height / this->line_height);
> 		// uint lines = min<uint>(max<uint>(1, size->height / this->line_height), _sorted_standard_cargo_specs_size);
> 		// fprintf(stderr, "LINES %u\n", lines);
> 		size->height = max<uint>(size->height, this->line_height * _sorted_standard_cargo_specs_size);
> 		resize->width = 0;
> 		resize->height = this->line_height;
> 		fill->width = 0;
> 		fill->height = this->line_height;
> 	}
> 
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		if (widget != WID_CPR_MATRIX) {
> 			BaseGraphWindow::DrawWidget(r, widget);
> 			return;
> 		}
> 
> 		bool rtl = _current_text_dir == TD_RTL;
> 
> 		int x = r.left + WD_FRAMERECT_LEFT;
> 		int y = r.top;
> 
> 		int pos = this->vscroll->GetPosition();
> 		int max = pos + this->vscroll->GetCapacity();
> 
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			if (pos-- > 0) continue;
> 			if (--max < 0) break;
> 
> 			bool lowered = !HasBit(_legend_excluded_cargo, cs->Index());
> 
> 			/* Redraw box if lowered */
> 			if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_ORANGE, lowered ? FR_LOWERED : FR_NONE);
> 
> 			byte clk_dif = lowered ? 1 : 0;
> 			int rect_x = clk_dif + 1 + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT);
> 
> 			GfxFillRect(rect_x, y + 1 + clk_dif, rect_x + this->icon_size - 2, y + this->icon_size - 2 + clk_dif, PC_BLACK);
> 			GfxFillRect(rect_x + 1, y + 2 + clk_dif, rect_x + this->icon_size - 3, y + this->icon_size - 3 + clk_dif, cs->legend_colour);
> 			SetDParam(0, cs->name);
> 			uint icon_offset = this->icon_size + WD_PAR_VSEP_NORMAL;
> 			DrawString(rtl ? r.left : x + icon_offset + clk_dif, (rtl ? r.right - icon_offset + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
> 
> 			y += this->line_height;
> 		}
> 	}
> 
> 	void UpdateExcludedData()
> 	{
> 		this->excluded_data = 0;
> 
> 		int i = 0;
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
> 			i++;
> 		}
> 	}
> 
> 	virtual void OnClick(Point pt, int widget, int click_count)
> 	{
> 		switch (widget) {
> 			case WID_CPR_KEY_BUTTON:
> 				ShowGraphLegend();
> 				break;
> 
> 			case WID_CPR_ENABLE_CARGOES:
> 				/* Remove all cargoes from the excluded lists. */
> 				_legend_excluded_cargo = 0;
> 				this->excluded_data = 0;
> 				this->SetDirty();
> 				break;
> 
> 			case WID_CPR_DISABLE_CARGOES: {
> 				/* Add all cargoes to the excluded lists. */
> 				int i = 0;
> 				const CargoSpec *cs;
> 				FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 					SetBit(_legend_excluded_cargo, cs->Index());
> 					SetBit(this->excluded_data, i);
> 					i++;
> 				}
> 				this->SetDirty();
> 				break;
> 			}
> 
> 			case WID_CPR_MATRIX: {
> 				uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CPR_MATRIX, 0, this->line_height);
> 				if (row >= this->vscroll->GetCount()) return;
> 
> 				const CargoSpec *cs;
> 				FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 					if (row-- > 0) continue;
> 
> 					ToggleBit(_legend_excluded_cargo, cs->Index());
> 					this->UpdateExcludedData();
> 					this->SetDirty();
> 					break;
> 				}
> 				break;
> 			}
> 		}
> 	}
> 
> 	virtual void OnResize()
> 	{
> 		this->vscroll->SetCapacityFromWidget(this, WID_CPR_MATRIX);
> 	}
> 
> 	/**
> 	 * Some data on this window has become invalid.
> 	 * @param data Information about the changed data.
> 	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
> 	 */
> 	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
> 	{
> 		if (!gui_scope) return;
> 		this->UpdateExcludedData();
> 	}
> };
> 
668c818
< struct IncomeGraphWindow : BaseGraphWindow {
---
> struct IncomeGraphWindow : ExcludingCargoBaseGraphWindow {
670c820
< 			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
---
> 			ExcludingCargoBaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
672c822,826
< 		this->InitializeWindow(window_number);
---
> 		this->CreateNestedTree();
> 		this->vscroll = this->GetScrollbar(WID_CPR_MATRIX_SCROLLBAR);
> 		this->vscroll->SetCount(_sorted_standard_cargo_specs_size);
> 		this->UpdateExcludedData();
> 		this->FinishInitNested(window_number);
676a831
> 		if(_legend_excluded_cargo == 0){
678a834,842
> 		uint total_income = 0;
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			if (!HasBit(_legend_excluded_cargo, cs->Index())){
> 				total_income += c->old_economy[j].cargo_income[cs->Index()];
> 			}
> 		}
> 		return total_income;
> 	}
685c849
< 		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
---
> 		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CPR_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
690c854
< 	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
---
> 	NWidget(WWT_PANEL, COLOUR_GREY, WID_CPR_BACKGROUND),
692c856
< 			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
---
> 			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CPR_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
694,695c858,866
< 				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
< 				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
---
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
> 				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0),
> 				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
> 				NWidget(NWID_HORIZONTAL),
> 					NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetFill(0, 2), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
> 					NWidget(NWID_VSCROLLBAR, COLOUR_ORANGE, WID_CPR_MATRIX_SCROLLBAR),
> 				EndContainer(),
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
696a868,874
> 			NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1),
> 		EndContainer(),
> 		NWidget(NWID_HORIZONTAL),
> 			NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0),
> 			NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
> 			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
> 			NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CPR_RESIZE),
717c895
< struct DeliveredCargoGraphWindow : BaseGraphWindow {
---
> struct DeliveredCargoGraphWindow : ExcludingCargoBaseGraphWindow {
719c897
< 			BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA)
---
> 			ExcludingCargoBaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
721c899,903
< 		this->InitializeWindow(window_number);
---
> 		this->CreateNestedTree();
> 		this->vscroll = this->GetScrollbar(WID_CPR_MATRIX_SCROLLBAR);
> 		this->vscroll->SetCount(_sorted_standard_cargo_specs_size);
> 		this->OnHundredthTick();
> 		this->FinishInitNested(window_number);
725a908
> 		if(_legend_excluded_cargo == 0){
727a911,919
> 		uint total_delivered = 0;
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			if (!HasBit(_legend_excluded_cargo, cs->Index())){
> 				total_delivered += c->old_economy[j].delivered_cargo[cs->Index()];
> 			}
> 		}
> 		return total_delivered;
> 	}
734c926
< 		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
---
> 		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CPR_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
739c931
< 	NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
---
> 	NWidget(WWT_PANEL, COLOUR_GREY, WID_CPR_BACKGROUND),
741c933
< 			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
---
> 			NWidget(WWT_EMPTY, COLOUR_GREY, WID_CPR_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
743,744c935,943
< 				NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
< 				NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
---
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4), SetFill(0, 0),
> 				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0),
> 				NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
> 				NWidget(NWID_HORIZONTAL),
> 					NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetFill(0, 2), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
> 					NWidget(NWID_VSCROLLBAR, COLOUR_ORANGE, WID_CPR_MATRIX_SCROLLBAR),
> 				EndContainer(),
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
745a945,951
> 			NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1),
> 		EndContainer(),
> 		NWidget(NWID_HORIZONTAL),
> 			NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0),
> 			NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
> 			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
> 			NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CPR_RESIZE),
871,874c1077
< struct PaymentRatesGraphWindow : BaseGraphWindow {
< 	uint line_height;   ///< Pixel height of each cargo type row.
< 	Scrollbar *vscroll; ///< Cargo list scrollbar.
< 
---
> struct PaymentRatesGraphWindow : ExcludingCargoBaseGraphWindow {
876c1079
< 			BaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
---
> 			ExcludingCargoBaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
894,1011d1096
< 	void UpdateExcludedData()
< 	{
< 		this->excluded_data = 0;
< 
< 		int i = 0;
< 		const CargoSpec *cs;
< 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
< 			if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
< 			i++;
< 		}
< 	}
< 
< 	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
< 	{
< 		if (widget != WID_CPR_MATRIX) {
< 			BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
< 			return;
< 		}
< 
< 		const CargoSpec *cs;
< 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
< 			SetDParam(0, cs->name);
< 			Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
< 			d.width += 14; // colour field
< 			d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
< 			d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
< 			*size = maxdim(d, *size);
< 		}
< 
< 		this->line_height = size->height;
< 		size->height = this->line_height * 11; /* Default number of cargo types in most climates. */
< 		resize->width = 0;
< 		resize->height = this->line_height;
< 	}
< 
< 	virtual void DrawWidget(const Rect &r, int widget) const
< 	{
< 		if (widget != WID_CPR_MATRIX) {
< 			BaseGraphWindow::DrawWidget(r, widget);
< 			return;
< 		}
< 
< 		bool rtl = _current_text_dir == TD_RTL;
< 
< 		int x = r.left + WD_FRAMERECT_LEFT;
< 		int y = r.top;
< 
< 		int pos = this->vscroll->GetPosition();
< 		int max = pos + this->vscroll->GetCapacity();
< 
< 		const CargoSpec *cs;
< 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
< 			if (pos-- > 0) continue;
< 			if (--max < 0) break;
< 
< 			bool lowered = !HasBit(_legend_excluded_cargo, cs->Index());
< 
< 			/* Redraw box if lowered */
< 			if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_ORANGE, lowered ? FR_LOWERED : FR_NONE);
< 
< 			byte clk_dif = lowered ? 1 : 0;
< 			int rect_x = clk_dif + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT);
< 
< 			GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, PC_BLACK);
< 			GfxFillRect(rect_x + 1, y + 1 + clk_dif, rect_x + 7, y + 4 + clk_dif, cs->legend_colour);
< 			SetDParam(0, cs->name);
< 			DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
< 
< 			y += this->line_height;
< 		}
< 	}
< 
< 	virtual void OnClick(Point pt, int widget, int click_count)
< 	{
< 		switch (widget) {
< 			case WID_CPR_ENABLE_CARGOES:
< 				/* Remove all cargoes from the excluded lists. */
< 				_legend_excluded_cargo = 0;
< 				this->excluded_data = 0;
< 				this->SetDirty();
< 				break;
< 
< 			case WID_CPR_DISABLE_CARGOES: {
< 				/* Add all cargoes to the excluded lists. */
< 				int i = 0;
< 				const CargoSpec *cs;
< 				FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
< 					SetBit(_legend_excluded_cargo, cs->Index());
< 					SetBit(this->excluded_data, i);
< 					i++;
< 				}
< 				this->SetDirty();
< 				break;
< 			}
< 
< 			case WID_CPR_MATRIX: {
< 				uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CPR_MATRIX, 0, this->line_height);
< 				if (row >= this->vscroll->GetCount()) return;
< 
< 				const CargoSpec *cs;
< 				FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
< 					if (row-- > 0) continue;
< 
< 					ToggleBit(_legend_excluded_cargo, cs->Index());
< 					this->UpdateExcludedData();
< 					this->SetDirty();
< 					break;
< 				}
< 				break;
< 			}
< 		}
< 	}
< 
< 	virtual void OnResize()
< 	{
< 		this->vscroll->SetCapacityFromWidget(this, WID_CPR_MATRIX);
< 	}
< 
1017,1027d1101
< 	/**
< 	 * Some data on this window has become invalid.
< 	 * @param data Information about the changed data.
< 	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
< 	 */
< 	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
< 	{
< 		if (!gui_scope) return;
< 		this->OnHundredthTick();
< 	}
< 
1042,1043c1116
< 	}
< };
---
> 	}};
1062c1135
< 				NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
---
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
1067c1140
< 					NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
---
> 					NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetFill(0, 2), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
1070c1143
< 				NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
---
> 				NWidget(NWID_SPACER), SetMinimalSize(0, 4),
diff -r -B -X .diff-exclude vanilla/src/gui.h cmclient/src/gui.h
41a42,45
> /* commands_gui.cpp */
> void ShowCommandsToolbar();
> void ShowLoginWindow();
> 
47c51
< void ShowLandInfo(TileIndex tile);
---
> void ShowLandInfo(TileIndex tile, TileIndex end_tile=INVALID_TILE);
diff -r -B -X .diff-exclude vanilla/src/hotkeys.cpp cmclient/src/hotkeys.cpp
64a65,80
> 
> 	{"BACKSPACE", WKC_BACKSPACE},
> 	{"SLASH", WKC_SLASH},
> 	{"SEMICOLON", WKC_SEMICOLON},
> 	{"L_BRACKET", WKC_L_BRACKET},
> 	{"BACKSLASH", WKC_BACKSLASH},
> 	{"R_BRACKET", WKC_R_BRACKET},
> 	{"SINGLEQUOTE", WKC_SINGLEQUOTE},
> 	{"PERIOD", WKC_PERIOD},
> 
> 	{"L_BRACE", WKC_L_BRACE},
> 	{"R_BRACE", WKC_R_BRACE},
> 	{"L_PAREN", WKC_L_PAREN},
> 	{"R_PAREN", WKC_R_PAREN},
> 	{"EXCLAIM", WKC_EXCLAIM},
> 	{"ASTERISK", WKC_ASTERISK},
diff -r -B -X .diff-exclude vanilla/src/industry_cmd.cpp cmclient/src/industry_cmd.cpp
1894a1895,1928
>   * Return whether industry can be built on tile or not
>   * regardless of terrain
>   */
> bool CanBuildIndustryOnTile(IndustryType type, TileIndex tile) {
> 	const IndustrySpec *indspec = GetIndustrySpec(type);
>     CommandCost ret;
> 
> 	if (HasBit(indspec->callback_mask, CBM_IND_LOCATION)) {
> 		ret = CheckIfCallBackAllowsCreation(
> 			tile, type, 0, 0, 0, _current_company,
> 			_current_company == OWNER_DEITY ? IACT_RANDOMCREATION : IACT_USERCREATION);
> 	} else {
> 		ret = _check_new_industry_procs[GetIndustrySpec(type)->check_proc](tile);
> 	}
> 	if (ret.Failed())
> 		return false;
> 
> 	ret = CheckIfFarEnoughFromConflictingIndustry(tile, type);
> 	if (ret.Failed())
> 		return false;
> 
> 	Town *t = NULL;
> 	ret = FindTownForIndustry(tile, type, &t);
> 	if (ret.Failed())
> 		return false;
> 
> 	ret = CheckIfIndustryIsAllowed(tile, type, t);
> 	if (ret.Failed())
> 		return false;
> 
> 	return true;
> }
> 
> /**
diff -r -B -X .diff-exclude vanilla/src/industry_gui.cpp cmclient/src/industry_gui.cpp
32a33
> #include "widgets/dropdown_type.h"
43a45
> #include "hotkeys.h"
254a257,271
> 	NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetResize(1, 0),
> 		NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
> 			NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(140, 14), SetDataTip(STR_FUND_INDUSTRY_FORBIDDEN_TILES_TITLE, STR_NULL),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
> 		NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DPI_FT_OFF), SetMinimalSize(60, 12),
> 											SetDataTip(STR_FUND_INDUSTRY_FORBIDDEN_TILES_OFF, STR_FUND_INDUSTRY_FORBIDDEN_TILES_OFF_TOOLTIP),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DPI_FT_ON), SetMinimalSize(60, 12),
> 											SetDataTip(STR_FUND_INDUSTRY_FORBIDDEN_TILES_ON, STR_FUND_INDUSTRY_FORBIDDEN_TILES_ON_TOOLTIP),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
> 		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 	EndContainer(),
263,270d279
< /** Window definition of the dynamic place industries gui */
< static WindowDesc _build_industry_desc(
< 	WDP_AUTO, "build_industry", 170, 212,
< 	WC_BUILD_INDUSTRY, WC_NONE,
< 	WDF_CONSTRUCTION,
< 	_nested_build_industry_widgets, lengthof(_nested_build_industry_widgets)
< );
< 
280a290
> 	bool funding_enabled;
330a341
> 			SetIndustryForbiddenTilesHighlight(this->selected_type);
333a345,346
> 
> 		this->funding_enabled = (_game_mode == GM_EDITOR || Company::IsValidID(_local_company));
339c352
< 		this->SetWidgetDisabledState(WID_DPI_FUND_WIDGET, this->selected_type != INVALID_INDUSTRYTYPE && !this->enabled[this->selected_index]);
---
> 		this->SetWidgetDisabledState(WID_DPI_FUND_WIDGET,  !this->funding_enabled || (this->selected_type != INVALID_INDUSTRYTYPE && !this->enabled[this->selected_index]));
340a354
> 		this->LowerWidget(_settings_client.gui.show_industry_forbidden_tiles + WID_DPI_FT_OFF);
391c405
< 	BuildIndustryWindow() : Window(&_build_industry_desc)
---
> 	BuildIndustryWindow(WindowDesc *desc) : Window(desc)
398a413
> 		this->funding_enabled = false;
406a422,426
> 	~BuildIndustryWindow()
> 	{
> 		SetIndustryForbiddenTilesHighlight(INVALID_INDUSTRYTYPE);
> 	}
> 
592a613
> 					SetIndustryForbiddenTilesHighlight(this->selected_type);
635a657,666
> 
> 			case WID_DPI_FT_OFF:
> 			case WID_DPI_FT_ON:
> 				this->RaiseWidget(_settings_client.gui.show_industry_forbidden_tiles + WID_DPI_FT_OFF);
> 				_settings_client.gui.show_industry_forbidden_tiles = (widget != WID_DPI_FT_OFF);
> 				this->LowerWidget(_settings_client.gui.show_industry_forbidden_tiles + WID_DPI_FT_OFF);
> 				if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
> 				this->SetDirty();
> 				MarkWholeScreenDirty();
> 				break;
703c734
< 		this->RaiseButtons();
---
> 		this->RaiseWidget(WID_DPI_FUND_WIDGET);
708c739
< 		this->RaiseButtons();
---
> 		this->RaiseWidget(WID_DPI_FUND_WIDGET);
724a756,768
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		return Window::OnHotkey(hotkey);
> 	}
> 
> 	static HotkeyList hotkeys;
> };
> 
> static Hotkey build_industry_hotkeys[] = {
> 	Hotkey((uint16)0, "display_chain", WID_DPI_DISPLAY_WIDGET),
> 	Hotkey((uint16)0, "build_button", WID_DPI_FUND_WIDGET),
> 	HOTKEY_LIST_END
726a771,782
> HotkeyList BuildIndustryWindow::hotkeys("industry_fund_gui", build_industry_hotkeys);
> 
> /** Window definition of the dynamic place industries gui */
> static WindowDesc _build_industry_desc(
> 	WDP_AUTO, "build_industry", 170, 212,
> 	WC_BUILD_INDUSTRY, WC_NONE,
> 	WDF_CONSTRUCTION,
> 	_nested_build_industry_widgets, lengthof(_nested_build_industry_widgets),
> 	&BuildIndustryWindow::hotkeys
> );
> 
> 
729d784
< 	if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
731c786
< 	new BuildIndustryWindow();
---
> 	new BuildIndustryWindow(&_build_industry_desc);
1171a1227
> 				NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_DROPDOWN_FILTER), SetDataTip(STR_BUTTON_FILTER, STR_TOOLTIP_FILTER_CRITERIA),
1198a1255,1258
> 	/* type_filter[industry_type] is set to true if player wishes that type to by displayed */
> 	static bool type_filter[NUM_INDUSTRYTYPES];
> 	static bool initialized;
> 
1210c1270,1272
< 				*this->industries.Append() = i;
---
> 				if (this->type_filter[i->type]){
> 					*this->industries.Append() = i;
> 				}
1341a1404,1410
> 	void initIndustryTypeFilter()
> 	{
> 		for (IndustryType indt = 0; indt < NUM_INDUSTRYTYPES; ++indt)
> 			this->type_filter[indt] = true;
> 			IndustryDirectoryWindow::initialized = true;
> 	}
> 
1344a1414
> 		if (IndustryDirectoryWindow::initialized == false) this->initIndustryTypeFilter();
1412a1483,1487
> 			case WID_ID_DROPDOWN_FILTER: {
> 				size->width = 65;
> 				break;
> 			}
> 
1440a1516,1531
> 			case WID_ID_DROPDOWN_FILTER: {
> 				DropDownList *list = new DropDownList();
> 				*list->Append() = new DropDownListStringItem(STR_BUTTON_FILTER_SELECT_ALL,     -2, false);
> 				*list->Append() = new DropDownListStringItem(STR_BUTTON_FILTER_SELECT_NONE,    -1, false);
> 				*list->Append() = new DropDownListItem(-3, false);
> 
> 				for (IndustryType indt = 0; indt < NUM_INDUSTRYTYPES; ++indt) {
> 					const IndustrySpec *inds = GetIndustrySpec(indt);
> 					if (inds->enabled)
> 						*list->Append() = new DropDownListCheckedItem(inds->name, indt, false, IndustryDirectoryWindow::type_filter[indt]);
> 				}
> 
> 				ShowDropDownList(this, list, -2, WID_ID_DROPDOWN_FILTER, 0, true, false);
> 				break;
> 			}
> 
1457,1459c1548,1551
< 		if (this->industries.SortType() != index) {
< 			this->industries.SetSortType(index);
< 			this->BuildSortIndustriesList();
---
> 		if (widget == WID_ID_DROPDOWN_CRITERIA) {
> 			if (this->industries.SortType() != index) {
> 				this->industries.SetSortType(index);
> 			}
1460a1553,1568
> 		else if (widget == WID_ID_DROPDOWN_FILTER) {
> 			if ( index == -1 ) { // aka SELECT NONE
> 				for (IndustryType indt = 0; indt < NUM_INDUSTRYTYPES; ++indt)
> 					IndustryDirectoryWindow::type_filter[indt] = false;
> 				// must SetDurty to force redraw of the listing widget
> 				this->SetDirty();
> 			}
> 			else if ( index == -2 ) { // aka SELECT ALL
> 				for (IndustryType indt = 0; indt < NUM_INDUSTRYTYPES; ++indt)
> 					IndustryDirectoryWindow::type_filter[indt] = true;
> 			}
> 			else
> 				IndustryDirectoryWindow::type_filter[index] = IndustryDirectoryWindow::type_filter[index] ? false: true;
> 			this->industries.ForceRebuild();
> 		}
> 		this->BuildSortIndustriesList();
1497a1606,1607
> bool IndustryDirectoryWindow::initialized = false;
> bool IndustryDirectoryWindow::type_filter[NUM_INDUSTRYTYPES];
diff -r -B -X .diff-exclude vanilla/src/industry_type.h cmclient/src/industry_type.h
14a15,16
> #include "tile_type.h"
> 
44a47
> bool CanBuildIndustryOnTile(IndustryType type, TileIndex tile);
diff -r -B -X .diff-exclude vanilla/src/lang/english_AU.txt cmclient/src/lang/english_AU.txt
249a250
> STR_TOOLTIP_DEMOLISH_TREES                                      :{BLACK}Demolish only trees on a square of land. Ctrl selects the area diagonally.
diff -r -B -X .diff-exclude vanilla/src/lang/english.txt cmclient/src/lang/english.txt
236a237,239
> STR_BUTTON_FILTER                                               :{BLACK}Filter
> STR_BUTTON_FILTER_SELECT_ALL                                    :Select All
> STR_BUTTON_FILTER_SELECT_NONE                                   :Select None
251a255
> STR_TOOLTIP_DEMOLISH_TREES                                      :{BLACK}Demolish only trees on a square of land. Ctrl selects the area diagonally.
278c282
< 
---
> STR_MEASURE_DIST_HEIGHTDIFF                                     :{BLACK}Area: {NUM} x {NUM}{}Distance: {NUM}{}Height difference: {HEIGHT}
326a331
> STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_CARGOS                      :{BLACK}Display company cargos information
329a335
> STR_TOOLBAR_TOOLTIP_DISPLAY_WATCH                               :{BLACK}Watch company's actions
380a387
> STR_SETTINGS_MENU_ZONING                                        :Zoning
404a412
> STR_MAP_MENU_WATCH_COMPANY                                      :Watch Company
474c482
< STR_ABOUT_MENU_SEPARATOR                                        :
---
> STR_ABOUT_MENU_SEPARATOR                                        :CityMania
485a494
> STR_ABOUT_MENU_LOGIN_WINDOW                                     :Login Window
1433a1443,1444
> STR_CONFIG_SETTING_PERSISTENT_DEPOTTOOLS                        :Keep depot building tools active after usage: {STRING2}
> STR_CONFIG_SETTING_PERSISTENT_DEPOTTOOLS_HELPTEXT               :Keep the building tools for road, train and ship depots (reversible by placing with Ctrl).
1727a1739,1758
> STR_CONFIG_SETTING_VEHICLES_CTRL                                :{ORANGE}Controls & Orders
> STR_CONFIG_SETTING_ORDER_SHORTCUTS                              :{ORANGE}Order's Shortcuts
> STR_CONFIG_SETTING_CTRL_ENABLE_CTRLCLICK_STARTSTOP              :Allow ctrl+left-click vehicles to start or stop them: {STRING2}
> STR_CONFIG_SETTING_AUTOSET_NOLOAD_ON_TRANSFER                   :"Transfer" orders are "No Loading" by default: {STRING2}
> STR_CONFIG_SETTING_AUTOSET_NOLOAD_ON_UNLOAD                     :"Unload all" orders are "No Loading" by default: {STRING2}
> 
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLLCLICK                 :ctrl+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLSHIFTLCLICK            :ctrl+shift+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_SHIFTLCLICK                :shift+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_ALTLCLICK                  :alt+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_ALTSHIFTCLICK              :alt+shift+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLALTLCLICK              :ctrl+alt+left-click: {STRING2}
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE                      :do nothing
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_FULL_LOAD_ANY             :Full load any cargo
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_TRANSFER_CARGO            :Transfer cargo
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_UNLOAD_ALL                :Force unload of all cargo
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_FEEDERLOAD                :Feeder Load (replace first order)
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_FEEDERDROP                :Feeder Unload (replace last order)
> STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NO_LOAD                   :Do not load any cargo
> 
2338a2370
> STR_RAIL_TOOLBAR_TOOLTIP_BUILD_POLYRAIL                         :{BLACK}Build railway track using the Polyline mode. Ctrl toggles build/remove for railway construction. Shift toggles building/showing cost estimate
2355a2388
> STR_BUILD_DEPOT_TRAIN_ORIENTATION_AUTO_TOOLTIP                  :{BLACK}Automatically select railway depot orientation based on environment
2363a2397,2398
> STR_STATION_BUILD_ORIENTATION_AUTO                              :{BLACK}Auto
> STR_STATION_BUILD_ORIENTATION_AUTO_TOOLTIP                      :{BLACK}Automatically select station orientation based on environment
2418a2454
> STR_ROAD_TOOLBAR_TOOLTIP_BUILD_FULLROAD                         :{BLACK}Build road section using the Autoroad mode with only full tile roads. Ctrl toggles build/remove for road construction. Shift toggles building/showing cost estimate
2438a2475
> STR_BUILD_DEPOT_ROAD_ORIENTATION_AUTO_TOOLTIP                   :{BLACK}Automatically select road depot orientation based on environment
4980a5018,5020
> STR_VIEWPORT_TOWN_POP_VERY_POOR_RATING                          :{WHITE}{TOWN} {RED}({COMMA})
> STR_VIEWPORT_TOWN_POP_MEDIOCRE_RATING                           :{WHITE}{TOWN} {ORANGE}({COMMA})
> STR_VIEWPORT_TOWN_POP_GOOD_RATING                               :{WHITE}{TOWN} {YELLOW}({COMMA})
4981a5022
> STR_VIEWPORT_TOWN_POP_EXCELLENT_RATING                          :{WHITE}{TOWN} {GREEN}({COMMA})
4983a5025,5027
> STR_VIEWPORT_TOWN_TINY_VERY_POOR_RATING                         :{TINY_FONT}{RED}{TOWN}
> STR_VIEWPORT_TOWN_TINY_MEDIOCRE_RATING                          :{TINY_FONT}{ORANGE}{TOWN}
> STR_VIEWPORT_TOWN_TINY_GOOD_RATING                              :{TINY_FONT}{YELLOW}{TOWN}
4984a5029
> STR_VIEWPORT_TOWN_TINY_EXCELLENT_RATING                         :{TINY_FONT}{GREEN}{TOWN}
5069a5115,5427
> 
> ### PATCH
> STR_TOWN_DIRECTORY_CAPTION_EXTRA                                :{WHITE}Towns ({YELLOW}{COMMA}{WHITE} / {ORANGE}{COMMA}{WHITE})
> STR_LOCAL_AUTHORITY_COMPANY_RATING_NUM                          :{YELLOW}{COMPANY} {COMPANY_NUM}: {ORANGE}{STRING} {BLACK}({COMMA})
> STR_TOWN_VIEW_GROWTH                                            :{BLACK}GR: {ORANGE}{COMMA}{STRING}  {BLACK}Next: {ORANGE}{COMMA}  {BLACK}RH: {ORANGE}{COMMA}  {BLACK}Flag {ORANGE}{NUM}  {BLACK}FB: {ORANGE}{NUM} {BLACK}month{P "" s}
> STR_TOWN_VIEW_GROWTH_RATE_CUSTOM                                :*
> STR_TOWN_VIEW_GROWTH_TILES                                      :{BLACK}HS: {ORANGE}{COMMA}(+{COMMA})  {BLACK}CS: {ORANGE}{COMMA}(+{COMMA})  {BLACK}HR: {ORANGE}{COMMA}(+{COMMA})
> STR_TOWN_VIEW_REALPOP_RATE                                      :{BLACK}Real Population: {YELLOW}{COMMA}  {BLACK}Rating: {YELLOW}{COMMA}
> STR_TOWN_VIEW_HOUSE_STATE                                       :{BLACK}Houses: UC {ORANGE}{COMMA}  {BLACK}RTM: {ORANGE}{COMMA}  {BLACK}DTM: {ORANGE}{COMMA}
> STR_CB_DISTANCE_CHECK                                           :CB town acceptance: {STRING2}
> 
> ###ADMIN
> STR_WATCH_WINDOW_TITLE                                          :{WHITE}Watching {RAW_STRING}.
> STR_WATCH_CLICK_TO_WATCH_COMPANY                                :{BLACK}Click here to watch company building
> STR_WATCH_CLICK_NEW_WINDOW                                      :{BLACK}Click here to open new watching window
> 
> STR_WATCH_WINDOW_TITLE_CLIENT                                   :{WHITE}{RAW_STRING} in {RAW_STRING}({NUM}).
> STR_XI_KICK                                                     :{BLACK}Kick
> STR_XI_KICKC                                                    :{BLACK}Kick from cp
> STR_XI_BAN                                                      :{BLACK}Ban
> STR_XI_BAN1                                                     :{BLACK}Ban (1 day)
> STR_XI_LOCK                                                     :{BLACK}Lock
> STR_XI_UNLOCK                                                   :{BLACK}UNLock
> STR_XI_JOIN                                                     :{BLACK}Join company
> STR_XI_RESET                                                    :{BLACK}Reset company
> STR_XI_WATCH                                                    :Watch
> STR_MOD_COMPANY_RESET_BUTTON                                    :{BLACK}Reset
> STR_MOD_COMPANY_JOIN_BUTTON                                     :{BLACK}Join as mod
> STR_MOD_TOGGLE_LOCK_BUTTON                                      :{BLACK}Lock/unlock
> STR_XI_ENABLE                                                   :{BLACK}En/Dis
> STR_XI_SIGN_TOOLTIP                                             :{BLACK}Put a sign to attract player
> STR_XI_PLAYERS_TOOLTIP                                          :{BLACK}Show clients
> STR_XI_COMPANYW_TOOLTIP                                         :{BLACK}Open Company window
> STR_XI_COMPANYHQ                                                :{BLACK}HQ
> STR_XI_COMPANYHQ_TOOLTIP                                        :{BLACK}Go to company's HQ
> STR_XI_PRIVATE_PLAYER_MESSAGE                                   :{BLACK}.{GREEN}P{BLACK}.
> STR_XI_PRIVATE_PLAYER_MESSAGE_TOOLTIP                           :{BLACK}Send a Custom private message to this player
> STR_XI_PRIVATE_COMPANY_MESSAGE                                  :{BLACK}.{GREEN}C{BLACK}.
> STR_XI_PRIVATE_COMPANY_MESSAGE_TOOLTIP                          :{BLACK}Send a Custom private message to this company
> 
> STR_XI_BAN_QUERY                                                :{WHITE}<days> <reason>
> STR_XI_BAN_DAYSDEFAULT                                          :1
> STR_XI_REALY_RESET                                              :{WHITE}Are you sure?.
> STR_XI_RESET_CAPTION                                            :{WHITE}Reset
> 
> STR_NETWORK_CLIENT_EXTRA                                        :{WHITE}(#{NUM} in c#{NUM})
> 
> ######## Zoning toolbar
> 
> STR_ZONING_TOOLBAR                                              :{WHITE}Zoning toolbar
> STR_ZONING_OUTER                                                :{BLACK}Outer tile borders:
> STR_ZONING_INNER                                                :{BLACK}Inner tile borders:
> STR_ZONING_OUTER_INFO                                           :{BLACK}Select which type of zoning you want on the outer border of a tile.
> STR_ZONING_INNER_INFO                                           :{BLACK}Select which type of zoning you want on the inner border of a tile.
> 
> STR_ZONING_NO_ZONING                                            :{BLACK}Nothing
> STR_ZONING_AUTHORITY                                            :{BLACK}Authority
> STR_ZONING_CAN_BUILD                                            :{BLACK}Where I can't build
> STR_ZONING_STA_CATCH                                            :{BLACK}Station catchment
> STR_ZONING_IND_CATCH                                            :{BLACK}Industry catchment
> STR_ZONING_BUL_CATCH                                            :{BLACK}City catchment
> STR_ZONING_BUL_UNSER                                            :{BLACK}Unserved buildings
> STR_ZONING_IND_UNSER                                            :{BLACK}Unserved industries
> STR_ZONING_TOWN_ZONES                                           :{BLACK}Town zones
> STR_ZONING_CB_TOWN_BORDERS                                      :{BLACK}CB town borders
> STR_ZONING_CB_BORDERS                                           :{BLACK}CB borders
> STR_ZONING_NEW_CB_BORDERS                                           :{BLACK}New CB borders
> STR_ZONING_ADVERTISEMENT_ZONES                                  :{BLACK}Advertisement
> STR_ZONING_TOWN_GROWTH_TILES                                    :{BLACK}Town growth tiles
> STR_ZONING_ACTIVE_STATIONS                                      :{BLACK}Active stations
> 
> # Commands toolbar
> STR_TOOLBAR_COMMANDS_CAPTION                                    :{WHITE}Commands
> STR_TOOLBAR_COMMANDS_GOAL_CAPTION                               :{BLACK}Goal
> STR_TOOLBAR_COMMANDS_GOAL_TOOLTIP                               :{BLACK}Send !goal command to server.
> STR_TOOLBAR_COMMANDS_QUEST_CAPTION                              :{BLACK}Quest list
> STR_TOOLBAR_COMMANDS_QUEST_TOOLTIP                              :{BLACK}Send !quest command to server.
> STR_TOOLBAR_COMMANDS_SCORE_CAPTION                              :{BLACK}Score
> STR_TOOLBAR_COMMANDS_SCORE_TOOLTIP                              :{BLACK}Send !score command to server.
> STR_TOOLBAR_COMMANDS_TOWN_CAPTION                               :{BLACK}Town
> STR_TOOLBAR_COMMANDS_TOWN_TOOLTIP                               :{BLACK}Send !town command to server.
> STR_TOOLBAR_COMMANDS_TOWN_ID_CAPTION                            :{BLACK}Town ID
> STR_TOOLBAR_COMMANDS_TOWN_ID_TOOLTIP                            :{BLACK}Send !town c-id command to server.
> STR_TOOLBAR_COMMANDS_HINT_CAPTION                               :{BLACK}CB Hint
> STR_TOOLBAR_COMMANDS_HINT_TOOLTIP                               :{BLACK}Send !hint command to server(Shows town demand in CB mode).
> STR_TOOLBAR_COMMANDS_LOGIN_CAPTION                              :{BLACK}Login
> STR_TOOLBAR_COMMANDS_LOGIN_TOOLTIP                              :{BLACK}Send !login command to server.
> STR_TOOLBAR_COMMANDS_TIMELEFT_CAPTION                           :{BLACK}Timeleft
> STR_TOOLBAR_COMMANDS_TIMELEFT_TOOLTIP                           :{BLACK}Send !timeleft command to server.
> STR_TOOLBAR_COMMANDS_NS_CAPTION                                 :{BLACK}CM{NUM}
> STR_TOOLBAR_COMMANDS_NS_TOOLTIP                                 :{BLACK}Join CM{NUM}
> STR_TOOLBAR_COMMANDS_RESETME_CAPTION                            :{BLACK}ResetMe
> STR_TOOLBAR_COMMANDS_RESETME_TOOLTIP                            :{BLACK}Send !resetme command to server.
> STR_TOOLBAR_COMMANDS_SAVEME_CAPTION                             :{BLACK}SaveMe
> STR_TOOLBAR_COMMANDS_SAVEME_TOOLTIP                             :{BLACK}Send !saveme command to server.
> STR_TOOLBAR_COMMANDS_NAME_CAPTION                               :{BLACK}New name
> STR_TOOLBAR_COMMANDS_NAME_TOOLTIP                               :{BLACK}Send !name command to server.
> STR_TOOLBAR_COMMANDS_INFO_CAPTION                               :{BLACK}Info
> STR_TOOLBAR_COMMANDS_INFO_TOOLTIP                               :{BLACK}Send !info command to server.
> 
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_CAPTION                       :{BLACK}Both
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_TOOLTIP                       :{BLACK}Switch cargo buttons to both amount and income
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_I_CAPTION                     :{BLACK}Income
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_A_CAPTION                     :{BLACK}Amount
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_A_TOOLTIP                     :{BLACK}Switch cargo buttons to amount
> STR_TOOLBAR_COMMANDS_OPTION_CARGO_I_TOOLTIP                     :{BLACK}Switch cargo buttons to income
> 
> 
> STR_TOOLBAR_COMMANDS_TOWN_QUERY                                 :{WHITE}Company ID:
> STR_TOOLBAR_COMMANDS_LOGIN_NAME_QUERY                           :{WHITE}<Name> <password>
> STR_TOOLBAR_COMMANDS_LOGIN_PASSWORD_QUERY                       :{WHITE}Password:
> STR_TOOLBAR_COMMANDS_NAME_NEWNAME_QUERY                         :{WHITE}New name:
> 
> STR_TOOLBAR_COMMANDS_TOPICS_CAPTION                             :{BLACK}Topics
> STR_TOOLBAR_COMMANDS_TOPICS_TOOLTIP                             :{BLACK}Display help topics
> STR_TOOLBAR_COMMANDS_TOPIC1_CAPTION                             :{BLACK}HELP Login
> STR_TOOLBAR_COMMANDS_TOPIC1_TOOLTIP                             :{BLACK}How to use login
> STR_TOOLBAR_COMMANDS_TOPIC2_CAPTION                             :{BLACK}HELP Coal Accept
> STR_TOOLBAR_COMMANDS_TOPIC2_TOOLTIP                             :{BLACK}What to do when town does not accept Coal
> STR_TOOLBAR_COMMANDS_TOPIC3_CAPTION                             :{BLACK}HELP Food accept
> STR_TOOLBAR_COMMANDS_TOPIC3_TOOLTIP                             :{BLACK}What to do when town does not accept Food
> STR_TOOLBAR_COMMANDS_TOPIC4_CAPTION                             :{BLACK}HELP energy
> STR_TOOLBAR_COMMANDS_TOPIC4_TOOLTIP                             :{BLACK}What are tourists, business mail or energy?
> STR_TOOLBAR_COMMANDS_TOPIC5_CAPTION                             :{BLACK}HELP admin
> STR_TOOLBAR_COMMANDS_TOPIC5_TOOLTIP                             :{BLACK}How to use admin command?
> STR_TOOLBAR_COMMANDS_TOPIC6_CAPTION                             :{BLACK}HELP New Comp.
> STR_TOOLBAR_COMMANDS_TOPIC6_TOOLTIP                             :{BLACK}Why new company can not be starter?
> 
> STR_TOOLBAR_COMMANDS_HELP_CAPTION                               :{BLACK}Help
> STR_TOOLBAR_COMMANDS_HELP_TOOLTIP                               :{BLACK}Display Help
> STR_TOOLBAR_COMMANDS_RULES_CAPTION                              :{BLACK}RULES
> STR_TOOLBAR_COMMANDS_RULES_TOOLTIP                              :{BLACK}Show Rules
> STR_TOOLBAR_COMMANDS_CBHINT_CAPTION                             :{BLACK}CB Hint
> STR_TOOLBAR_COMMANDS_CBHINT_TOOLTIP                             :{BLACK}Display help for City builder
> STR_TOOLBAR_COMMANDS_BEST_CAPTION                               :{BLACK}Best
> STR_TOOLBAR_COMMANDS_BEST_TOOLTIP                               :{BLACK}Show 5 best games
> STR_TOOLBAR_COMMANDS_RANK_CAPTION                               :{BLACK}Rank
> STR_TOOLBAR_COMMANDS_RANK_TOOLTIP                               :{BLACK}Show top 10 players
> STR_TOOLBAR_COMMANDS_ME_CAPTION                                 :{BLACK}My Rank
> STR_TOOLBAR_COMMANDS_ME_TOOLTIP                                 :{BLACK}Show your ranking position
> 
> #login window
> STR_LOGINWINDOW_CAPTION                                         :{WHITE}Login Window
> STR_LOGINWINDOW_CITYMANIA                                       :{BLACK}CityMania
> STR_LOGINWINDOW_NICE                                            :{BLACK}N-ice
> STR_LOGINWINDOW_BTPRO                                           :{BLACK}BTPro
> STR_LOGINERROR_NOCONNECT                                        :{WHITE}Failed to connect
> STR_LOGINERROR_BADINPUT                                         :{WHITE}Bad username or password
> STR_LOGIN_USERNAME                                              :{WHITE}Username
> STR_LOGIN_PASSWORD                                              :{WHITE}Password
> STR_LOGIN_SET                                                   :{WHITE}Set
> STR_LOGIN_NOTSET                                                :{WHITE}Not Set
> STR_LOGIN_CHANGE_USERNAME                                       :{WHITE}Change username
> STR_LOGIN_CHANGE_PASSWORD                                       :{WHITE}Change password
> STR_LOGIN_SEND_LOGIN_TT                                         :{WHITE}Send Login - you must but on the correct community server
> STR_LOGIN_USERNAME_DISPLAY                                      :{WHITE}{RAW_STRING}
> STR_LOGIN_PASSWORD_DISPLAY                                      :{WHITE}{STRING}
> 
> #cargo table
> STR_TOOLBAR_CARGOS_HEADER_CARGO                                 :{BLACK}Cargo Name
> STR_TOOLBAR_CARGOS_HEADER_AMOUNT                                :{BLACK}Amount
> STR_TOOLBAR_CARGOS_HEADER_INCOME                                :{BLACK}Income
> STR_TOOLBAR_CARGOS_HEADER_TOTAL                                 :{BLACK}Total
> STR_TOOLBAR_CARGOS_HEADER_TOTAL_MONTH                           :{BLACK}Total this Month
> 
> STR_TOOLBAR_CARGOS_UNITS                                        :{BLACK}{COMMA}
> STR_TOOLBAR_CARGOS_UNITS_TOTAL                                  :{BLACK}{COMMA}
> STR_TOOLBAR_CARGOS_CAPTION                                      :{WHITE}{COMPANY} Cargo Transported {BLACK}{COMPANY_NUM}
> STR_TOOLBAR_CARGOS_NAME                                         :{BLACK}{STRING}
> 
> #towns
> STR_TOWN_DIRECTORY_TOWN_COLOUR                                  :{ORANGE}{TOWN}{BLACK} ({COMMA}->{COMMA}) {YELLOW}{COMMA} {P "house" "houses"}
> STR_TOWN_DIRECTORY_CITY_COLOUR                                  :{YELLOW}{TOWN}{BLACK} ({COMMA}->{COMMA}) {YELLOW}{COMMA} {P "house" "houses"}
> STR_OLD_DEPOT_TRAINT_LENGTH                                     :Old depot length format: {STRING2}
> STR_SMALLMAP_TOWN_LARGE                                         :{TINY_FONT}{YELLOW}{TOWN}
> 
> STR_SORT_BY_HOUSES                                              :Houses
> STR_SORT_BY_REAL_POPULATION                                     :Real population
> STR_ORDER_DIST                                                  :{NUM}, {NUM}
> 
> #server list
> STR_NETWORK_SELECT_CITYMANIA                                    :{BLACK}CityMania
> STR_NETWORK_SELECT_NICE                                         :{BLACK}N-ice
> STR_NETWORK_SELECT_BTPRO                                        :{BLACK}BTPro
> STR_NETWORK_SELECT_REDDIT                                       :{BLACK}reddit
> STR_NETWORK_SELECT_SERVER_TOOLTIP                               :{BLACK}Filter this one
> 
> ### Town CB gui
> STR_BUTTON_CB                                                   :{STRING}
> STR_BUTTON_CB_YES                                               :{BLACK}CB
> STR_TOWN_VIEW_CB_CAPTION                                        :{WHITE}{TOWN}
> 
> STR_CB_LARGE_ADVERTISING_CAMPAIGN                               :{BLACK}Large Advertising
> STR_CB_NEW_BUILDINGS                                            :{BLACK}Fund Buildings
> STR_CB_FUND_REGULAR                                             :{BLACK}Fund Regularly
> STR_CB_FUND_REGULAR_TT                                          :{BLACK}Every time fund buildings is zero and company has enough money, buildings will be funded automatically
> STR_CB_FUNDED_REGULARLY                                         :{GREEN}Town is funded regularly
> STR_CB_ADVERT_REGULAR                                           :{BLACK}Adv. Regularly
> STR_CB_ADVERT_REGULAR_TT                                        :{BLACK}Automatically advertise town whenever stations rating drops below a certain point
> STR_CB_POWERFUND                                                :{BLACK}Powerfund
> STR_CB_ADVERT_REGULAR_RATING_TO_KEEP                            :{BLACK}Keep station rating at
> STR_CB_POWERFUND_TT                                             :{BLACK}Continiously funds town with maximum speed possible
> 
> STR_TOWN_CB_FUNDING                                             :{ORANGE}Funded for {YELLOW}{COMMA}{ORANGE} month{P "" s}
> STR_TOWN_CB_GROWING                                             :{GREEN}Town is growing!
> STR_TOWN_CB_NOT_GROWING                                         :{WHITE}Town is not growing
> STR_TOWN_CB_GROWING_DETAIL                                      :{ORANGE}1 house in {YELLOW}{COMMA} {ORANGE}days ({YELLOW}{COMMA}%{ORANGE}). Next House in {YELLOW}{COMMA} {ORANGE}days
> 
> STR_TOWN_GROWTH_HEADER_CARGO                                    :{BLACK}Cargo
> STR_TOWN_GROWTH_HEADER_AMOUNT                                   :{BLACK}Delivered
> STR_TOWN_GROWTH_HEADER_REQ                                      :{BLACK}Required
> STR_TOWN_GROWTH_HEADER_LAST                                     :{BLACK}Last Month
> STR_TOWN_GROWTH_HEADER_STORE                                    :{BLACK}Stored
> STR_TOWN_GROWTH_HEADER_STORE_PCT                                :{BLACK}Use%
> STR_TOWN_GROWTH_HEADER_FROM                                     :{BLACK}From
> 
> STR_TOWN_CB_CARGO_NAME                                          :{BLACK}{STRING}:
> 
> STR_TOWN_CB_CARGO_AMOUNT_GOOD                                   :{GREEN}{COMMA}
> STR_TOWN_CB_CARGO_AMOUNT_BAD                                    :{YELLOW}{COMMA}
> STR_TOWN_CB_CARGO_AMOUNT_NOT                                    :{SILVER}{COMMA}
> 
> STR_TOWN_CB_CARGO_REQ_YES                                       :{ORANGE}{COMMA}
> STR_TOWN_CB_CARGO_REQ_NOT                                       :{SILVER}{COMMA}
> 
> STR_TOWN_CB_CARGO_STORE_YES                                     :{LTBLUE}{COMMA}
> STR_TOWN_CB_CARGO_STORE_NOT                                     :{SILVER}{COMMA}
> STR_TOWN_CB_CARGO_STORE_DECAY                                   :{BLACK}-
> 
> STR_TOWN_CB_CARGO_STORE_PCT_YES                                 :{LTBLUE}{COMMA}%
> STR_TOWN_CB_CARGO_STORE_PCT_NOT                                 :{SILVER}{COMMA}%
> 
> STR_TOWN_CB_CARGO_PREVIOUS_YES                                  :{GREEN}{COMMA}
> STR_TOWN_CB_CARGO_PREVIOUS_EDGE                                 :{YELLOW}{COMMA}
> STR_TOWN_CB_CARGO_PREVIOUS_BAD                                  :{RED}{COMMA}
> STR_TOWN_CB_CARGO_PREVIOUS_NOT                                  :{SILVER}{COMMA}
> 
> STR_TOWN_CB_CARGO_FROM_YES                                      :{YELLOW}{COMMA}
> STR_TOWN_CB_CARGO_FROM_NOT                                      :{SILVER}{COMMA}
> 
> #polyrail double click option
> STR_CONFIG_SETTING_POLYRAIL_DOUBLECLICK_TOOLTIPS                :Enable finishing polyrail with mouse double click{STRING2}
> 
> #tooltips extra
> STR_CONFIG_SETTING_ENABLE_EXTRA_TOOLTIPS                        :Enable extra tooltips{STRING2}
> STR_TTE_HOUSE_NAME                                              :{LTBLUE}{STRING}
> STR_TTE_HOUSE                                                   :{BLACK}Population: {NUM}
> STR_TTE_INDUSTRY_NAME                                           :{LTBLUE}{INDUSTRY}
> STR_TTE_INDUSTRY                                                :{WHITE}{STRING}  {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
> STR_TTE_STATION_NAME                                            :{LTBLUE}{STATION}
> STR_TTE_STATION                                                 :{WHITE}{STRING}  {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
> STR_LAND_AREA_INFORMATION_POP                                   :{BLACK}Population: {LTBLUE}{NUM}
> 
> # Industry funding forbidden tiles
> STR_FUND_INDUSTRY_FORBIDDEN_TILES_TITLE                         :{BLACK}Forbidden areas highlight
> STR_FUND_INDUSTRY_FORBIDDEN_TILES_OFF                           :{BLACK}Off
> STR_FUND_INDUSTRY_FORBIDDEN_TILES_ON                            :{BLACK}On
> STR_FUND_INDUSTRY_FORBIDDEN_TILES_OFF_TOOLTIP                   :{BLACK}Don't highlight areas where particular industry can not be funded
> STR_FUND_INDUSTRY_FORBIDDEN_TILES_ON_TOOLTIP                    :{BLACK}Highlight areas where particular industry can not be funded
> 
> STR_CB_GUI_TOWN_VIEW_BUTTON                                     :{BLACK}Town view
> STR_CB_GUI_TOWN_VIEW_TOOLTIP                                    :{BLACK}Show information on town
> 
> STR_CONFIG_SETTING_WARN_IF_RUNWAY_IS_TOO_SHORT                  :Warn if airplane has in its orders an airport whose runway is too short
> 
> STR_CONFIG_SETTING_POWERFUND_MONEY                              :Powerfund minimum needed money for fund: {STRING2}
> STR_CONFIG_SETTING_POWERFUND_HOUSES                             :Maximum amount of houses to powerfund up to: {STRING2}
> 
> STR_STATION_RATING_TOOLTIP_RATING_DETAILS                       :{STRING} Rating Details
> STR_STATION_RATING_TOOLTIP_TOTAL_RATING                         :Total target rating: {LTBLUE}{NUM}%
> STR_STATION_RATING_TOOLTIP_NEWGRF_RATING                        :NewGRF station rating: {STRING1} {BLACK}based on
> STR_STATION_RATING_TOOLTIP_NEWGRF_RATING_0                      :{GOLD}{NUM}%
> STR_STATION_RATING_TOOLTIP_NEWGRF_RATING_1                      :{LTBLUE}+{NUM}%
> STR_STATION_RATING_TOOLTIP_NEWGRF_SPEED                         :Max speed of last vehicle: {LTBLUE}{VELOCITY}
> STR_STATION_RATING_TOOLTIP_NEWGRF_WAITUNITS                     :Units of cargo waiting: {LTBLUE}{NUM}
> STR_STATION_RATING_TOOLTIP_NEWGRF_WAITTIME                      :Time since last pickup: {LTBLUE}{NUM} days
> 
> STR_STATION_RATING_TOOLTIP_SPEED                                :Max speed of last vehicle (max 17%): {STRING2}
> STR_STATION_RATING_TOOLTIP_SPEED_MAX                            :{GREEN}{VELOCITY} or more, +{NUM}%
> STR_STATION_RATING_TOOLTIP_SPEED_ZERO                           :{RED}{VELOCITY}, {NUM}%
> STR_STATION_RATING_TOOLTIP_SPEED_0                              :{ORANGE}{VELOCITY}, +{NUM}%
> STR_STATION_RATING_TOOLTIP_SPEED_1                              :{GOLD}{VELOCITY}, +{NUM}%
> STR_STATION_RATING_TOOLTIP_SPEED_2                              :{YELLOW}{VELOCITY}, +{NUM}%
> STR_STATION_RATING_TOOLTIP_SPEED_3                              :{GREEN}{VELOCITY}, +{NUM}%
> 
> STR_STATION_RATING_TOOLTIP_AGE                                  :Age of last vehicle (max 13%): {STRING2}
> STR_STATION_RATING_TOOLTIP_AGE_0                                :{ORANGE}{NUM} years, {NUM}%
> STR_STATION_RATING_TOOLTIP_AGE_1                                :{GOLD}{NUM} years, +{NUM}%
> STR_STATION_RATING_TOOLTIP_AGE_2                                :{YELLOW}{NUM} year, +{NUM}%
> STR_STATION_RATING_TOOLTIP_AGE_3                                :{GREEN}{NUM} years, +{NUM}%
> 
> STR_STATION_RATING_TOOLTIP_WAITTIME                             :Time since last pickup (max 51%): {STRING2}
> STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP                        :Time since last pickup (max 51%): {STRING2} (by ship)
> STR_STATION_RATING_TOOLTIP_WAITTIME_0                           :{RED}{NUM} days, {NUM}%
> STR_STATION_RATING_TOOLTIP_WAITTIME_1                           :{ORANGE}{NUM} days, +{NUM}%
> STR_STATION_RATING_TOOLTIP_WAITTIME_2                           :{GOLD}{NUM} days, +{NUM}%
> STR_STATION_RATING_TOOLTIP_WAITTIME_3                           :{YELLOW}{NUM} days, +{NUM}%
> STR_STATION_RATING_TOOLTIP_WAITTIME_4                           :{GREEN}{NUM} day{P "" s}, +{NUM}%
> 
> STR_STATION_RATING_TOOLTIP_WAITUNITS                            :Units of cargo waiting (max 16%): {STRING2}
> STR_STATION_RATING_TOOLTIP_WAITUNITS_0                          :{RED}{NUM}, {NUM}%
> STR_STATION_RATING_TOOLTIP_WAITUNITS_1                          :{ORANGE}{NUM}, {NUM}%
> STR_STATION_RATING_TOOLTIP_WAITUNITS_2                          :{GOLD}{NUM}, {NUM}%
> STR_STATION_RATING_TOOLTIP_WAITUNITS_3                          :{YELLOW}{NUM}, +{NUM}%
> STR_STATION_RATING_TOOLTIP_WAITUNITS_4                          :{YELLOW}{NUM}, +{NUM}%
> STR_STATION_RATING_TOOLTIP_WAITUNITS_5                          :{GREEN}{NUM}, +{NUM}%
> 
> STR_STATION_RATING_TOOLTIP_STATUE                               :Statue in town (max 10%): {STRING}
> STR_STATION_RATING_TOOLTIP_STATUE_NO                            :{GOLD}no, 0%
> STR_STATION_RATING_TOOLTIP_STATUE_YES                           :{GREEN}yes, +10%
> 
> STR_IGNORE_VERSION_CHECK_WARNING : WARNING! You're about to join server running a different version of the game!
> STR_IGNORE_VERSION_CHECK_WARNING_DETAILS : OpenTTD was never indended to work in such way. If you're lucky you may be able to play it but most likely something is going to break sooner or later. Desyncs or crashes are to be expected. So proceed at your own risk and don't report any errors you encounter there.
diff -r -B -X .diff-exclude vanilla/src/lang/english_US.txt cmclient/src/lang/english_US.txt
251a252
> STR_TOOLTIP_DEMOLISH_TREES                                      :{BLACK}Demolish only trees on a square of land. Ctrl selects the area diagonally.
diff -r -B -X .diff-exclude vanilla/src/main_gui.cpp cmclient/src/main_gui.cpp
111c111
< 	if (w->IsWidgetLowered(widget)) {
---
> 	if (w->IsWidgetLowered(widget) && mode == _thd.place_mode) {
241a242
> 	GHK_BORROW_ALL,
409a411,414
> 			case GHK_BORROW_ALL:
> 				DoCommandP(0, 0, 1, CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY));
> 				break;
> 
481a487,491
> 	virtual void OnMouseOver(Point pt, int widget)
> 	{
> 		if (_game_mode != GM_MENU && _settings_client.gui.enable_extra_tooltips && pt.x != -1) GuiPrepareTooltipsExtra(this);
> 	}
> 
528a539
> 	Hotkey(WKC_NONE, "borrow_all", GHK_BORROW_ALL),
diff -r -B -X .diff-exclude vanilla/src/misc.cpp cmclient/src/misc.cpp
114a115
> 	ResetRailPlacementEndpoints();
diff -r -B -X .diff-exclude vanilla/src/misc_gui.cpp cmclient/src/misc_gui.cpp
27a28
> #include "newgrf_cargo.h"
34a36,41
> #include "house.h"
> #include "town_map.h"
> #include "station_base.h"
> #include "viewport_func.h"
> #include "industry.h"
> 
36a44,45
> void GuiShowTooltipsExtra(Window *parent, uint param, TooltipCloseCondition close_tooltip);
> 
47,52c56
< 	NWidget(NWID_HORIZONTAL),
< 		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
< 		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
< 		NWidget(WWT_DEBUGBOX, COLOUR_GREY),
< 	EndContainer(),
< 	NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), EndContainer(),
---
> 	NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), SetMinimalSize(64, 32),	EndContainer(),
56c60
< 	WDP_AUTO, "land_info", 0, 0,
---
> 	WDP_MANUAL, "land_info", 0, 0,
73a78,89
> 	TileIndex end_tile;  ///< For use in ruler(dragdrop) mode
> 
> 	virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
> 	{
> 		int scr_top = GetMainViewTop() + 2;
> 		int scr_bot = GetMainViewBottom() - 2;
> 		Point pt;
> 		pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
> 		if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
> 		pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
> 		return pt;
> 	}
78a95,99
> 		GfxDrawLine(r.left,  r.top,    r.right, r.top,    PC_BLACK);
> 		GfxDrawLine(r.left,  r.bottom, r.right, r.bottom, PC_BLACK);
> 		GfxDrawLine(r.left,  r.top,    r.left,  r.bottom, PC_BLACK);
> 		GfxDrawLine(r.right, r.top,    r.right, r.bottom, PC_BLACK);
> 
117c138,139
< 	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc), tile(tile)
---
> 	LandInfoWindow(TileIndex tile, TileIndex end_tile=INVALID_TILE) :
> 		Window(&_land_info_desc), tile(tile), end_tile(end_tile)
119a142
> 		CLRBITS(this->flags, WF_WHITE_BORDER);
169a193
> 		td.population = 0;
302a327,333
> 		/* House pop */
> 		if (td.population != 0) {
> 			SetDParam(0, td.population);
> 			GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_POP, lastof(this->landinfo_data[line_nr]));
> 			line_nr++;
> 		}
> 
355a387,404
> 
> 	virtual void OnMouseLoop()
> 	{
> 		/* Always close tooltips when the cursor is not in our window. */
> 		if (!_cursor.in_window) {
> 			delete this;
> 			return;
> 		}
> 		if (!_mouse_hovering) delete this;
> 
> 		/* We can show tooltips while dragging tools. These are shown as long as
> 		 * we are dragging the tool. Normal tooltips work with hover or rmb. */
> 		// switch (this->close_cond) {
> 		// 	case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
> 		// 	case TCC_LEFT_CLICK: if (!_left_button_down) delete this; break;
> 		// 	case TCC_HOVER: if (!_mouse_hovering) delete this; break;
> 		// }
> 	}
362c411
< void ShowLandInfo(TileIndex tile)
---
> void ShowLandInfo(TileIndex tile, TileIndex end_tile)
365c414
< 	new LandInfoWindow(tile);
---
> 	new LandInfoWindow(tile, end_tile);
1220a1270,1761
> }
> 
> /** Window for displaying a tooltip. */
> void GuiPrepareTooltipsExtra(Window *parent){
> 	const Point p = GetTileBelowCursor();
> 	if (p.x == -1) return;
> 	const TileIndex tile = TileVirtXY(p.x, p.y);
> 
> 	if (_cursor.sprite_seq[0].sprite == SPR_CURSOR_QUERY) {
> 		// Land info tool active
> 		ShowLandInfo(tile);
> 		return;
> 	}
> 
> 	if (!_settings_client.gui.enable_extra_tooltips)
> 		return;
> 
> 	if (tile >= MapSize()) return;
> 	uint param = 0;
> 	switch (GetTileType(tile)) {
> 		/*case MP_HOUSE: {
> 			const HouseID house = GetHouseType(tile);
> 			param = ((house & 0xFFFF) << 16) | MP_HOUSE;
> 			break;
> 		}*/
> 		case MP_INDUSTRY: {
> 			const Industry *ind = Industry::GetByTile(tile);
> 			if(ind->produced_cargo[0] == CT_INVALID && ind->produced_cargo[1] == CT_INVALID) return;
> 			param = ((ind->index & 0xFFFF) << 16) | MP_INDUSTRY;
> 			break;
> 		}
> 		case MP_STATION: {
> 			if (IsRailWaypoint(tile) || HasTileWaterGround(tile)) break;
> 			const Station *st = Station::GetByTile(tile);
> 			param |= ((st->index & 0xFFFF) << 16) | MP_STATION;
> 			break;
> 		}
> 		default:
> 			return;
> 	}
> 	if(param != 0) GuiShowTooltipsExtra(parent, param, TCC_HOVER);
> }
> 
> static const NWidgetPart _nested_tooltips_extra_widgets[] = {
> 	NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32),	EndContainer(),
> };
> 
> static WindowDesc _tool_tips_extra_desc(
> 	WDP_MANUAL, NULL, 0, 0,
> 	WC_TOOLTIPS_EXTRA, WC_NONE,
> 	0,
> 	_nested_tooltips_extra_widgets, lengthof(_nested_tooltips_extra_widgets)
> );
> 
> struct TooltipsExtraWindow : public Window
> {
> 	TileType tiletype;
> 	uint16 objIndex;
> 	TooltipCloseCondition close_cond;
> 
> 	TooltipsExtraWindow(Window *parent, uint param, TooltipCloseCondition close_tooltip) : Window(&_tool_tips_extra_desc)
> 	{
> 		this->parent = parent;
> 		this->tiletype = (TileType)(param & 0xFFFF);
> 		this->objIndex = (uint16)((param >> 16) & 0xFFFF);
> 		this->close_cond = close_tooltip;
> 		this->InitNested();
> 		CLRBITS(this->flags, WF_WHITE_BORDER);
> 	}
> 
> 	virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
> 	{
> 		int scr_top = GetMainViewTop() + 2;
> 		int scr_bot = GetMainViewBottom() - 2;
> 		Point pt;
> 		pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
> 		if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
> 		pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
> 		return pt;
> 	}
> 
> 	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
> 	{
> 		uint icon_size = ScaleGUITrad(10);
> 		uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
> 		uint icons_width = icon_size * 3 + 20;
> 		size->width = 200;
> 		size->height = FONT_HEIGHT_NORMAL + 6;
> 		switch(this->tiletype) {
> 			/*case MP_HOUSE: {
> 				size->height += LINE_HEIGHT;
> 				SetDParam(0, 1000);
> 				size->width = GetStringBoundingBox(STR_TTE_HOUSE).width;
> 				break;
> 			}*/
> 			case MP_INDUSTRY: {
> 				const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
> 				if(ind == NULL) break;
> 
> 				for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
> 					if (ind->produced_cargo[i] == CT_INVALID) continue;
> 					const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
> 					if(cs == NULL) continue;
> 					size->height += line_height;
> 					SetDParam(0, cs->name);
> 					SetDParam(1, cs->Index());
> 					SetDParam(2, ind->last_month_production[i]);
> 					SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
> 					size->width = max(GetStringBoundingBox(STR_TTE_INDUSTRY).width + icons_width, size->width);
> 				}
> 				break;
> 			}
> 			case MP_STATION: {
> 				const Station *st = Station::GetIfValid((StationID)this->objIndex);
> 				if(st == NULL) break;
> 
> 				for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
> 					const CargoSpec *cs = _sorted_cargo_specs[i];
> 					if(cs == NULL) continue;
> 					int cargoid = cs->Index();
> 					if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
> 						size->height += line_height;
> 						SetDParam(0, cs->name);
> 						SetDParam(1, cargoid);
> 						SetDParam(2, st->goods[cargoid].cargo.TotalCount());
> 						SetDParam(3, ToPercent8(st->goods[cargoid].rating));
> 						size->width = max(GetStringBoundingBox(STR_TTE_STATION).width + icons_width, size->width);
> 					}
> 				}
> 				break;
> 			}
> 			default:
> 				break;
> 		}
> 		size->width  += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
> 		size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
> 	}
> 
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		uint icon_size = ScaleGUITrad(10);
> 		uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
> 		uint icons_width = icon_size * 3 + 10;
> 		uint text_ofs = (line_height - FONT_HEIGHT_NORMAL) >> 1;
> 		uint icon_ofs = (line_height - icon_size) >> 1;
> 
> 		GfxDrawLine(r.left,  r.top,    r.right, r.top,    PC_BLACK);
> 		GfxDrawLine(r.left,  r.bottom, r.right, r.bottom, PC_BLACK);
> 		GfxDrawLine(r.left,  r.top,    r.left,  r.bottom, PC_BLACK);
> 		GfxDrawLine(r.right, r.top,    r.right, r.bottom, PC_BLACK);
> 
> 		int y = r.top + WD_FRAMERECT_TOP + 4;
> 		int left = r.left + WD_FRAMERECT_LEFT + 4;
> 
> 		switch(this->tiletype) {
> 			/*case MP_HOUSE: {
> 				const HouseID house = (HouseID)this->objIndex;
> 				const HouseSpec *hs = HouseSpec::Get(house);
> 				if(hs == NULL) break;
> 
> 				SetDParam(0, hs->building_name);
> 				DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_HOUSE_NAME, TC_BLACK, SA_CENTER);
> 				y += LINE_HEIGHT;
> 				SetDParam(0, hs->population);
> 				DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_HOUSE);
> 				break;
> 			}*/
> 			case MP_INDUSTRY: {
> 				const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
> 				if(ind == NULL) break;
> 
> 				SetDParam(0, ind->index);
> 				DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_INDUSTRY_NAME, TC_BLACK, SA_CENTER);
> 				y += FONT_HEIGHT_NORMAL + 2;
> 
> 				for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
> 					if (ind->produced_cargo[i] == CT_INVALID) continue;
> 					const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
> 					if(cs == NULL) continue;
> 					SetDParam(0, cs->name);
> 					SetDParam(1, cs->Index());
> 					SetDParam(2, ind->last_month_production[i]);
> 					SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
> 
> 					this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
> 					DrawString(left + icons_width, r.right - WD_FRAMERECT_RIGHT, y + text_ofs, STR_TTE_INDUSTRY);
> 					y += line_height;
> 				}
> 				break;
> 			}
> 			case MP_STATION: {
> 				const Station *st = Station::GetIfValid((StationID)this->objIndex);
> 				if(st == NULL) break;
> 
> 				SetDParam(0, st->index);
> 				DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_STATION_NAME, TC_BLACK, SA_CENTER);
> 				y += FONT_HEIGHT_NORMAL + 2;
> 
> 				for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
> 					const CargoSpec *cs = _sorted_cargo_specs[i];
> 					if(cs == NULL) continue;
> 					int cargoid = cs->Index();
> 					if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
> 						SetDParam(0, cs->name);
> 						SetDParam(1, cargoid);
> 						SetDParam(2, st->goods[cargoid].cargo.TotalCount());
> 						SetDParam(3, ToPercent8(st->goods[cargoid].rating));
> 
> 						this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
> 						DrawString(left + icons_width, r.right - WD_FRAMERECT_RIGHT, y + text_ofs, STR_TTE_STATION);
> 						y += line_height;
> 					}
> 				}
> 				break;
> 			}
> 			default:
> 				break;
> 		}
> 	}
> 
> 	virtual void OnMouseLoop()
> 	{
> 		if (!_cursor.in_window) {
> 			delete this;
> 			return;
> 		}
> 
> 		switch (this->close_cond) {
> 			case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
> 			case TCC_HOVER: if (!_mouse_hovering) delete this; break;
> 			case TCC_NONE: break;
> 		}
> 	}
> 
> 	void DrawSpriteIcons(SpriteID sprite, int left, int top) const
> 	{
> 		uint step = ScaleGUITrad(10);
> 		for(int i = 0; i < 3; i++) {
> 			DrawSprite(sprite, PAL_NONE, left + i * step, top);
> 		}
> 	}
> };
> 
> static const NWidgetPart _nested_station_rating_tooltip_widgets[] = {
> 	NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32),	EndContainer(),
> };
> 
> static WindowDesc _station_rating_tooltip_desc(
> 	WDP_MANUAL, NULL, 0, 0,
> 	WC_STATION_RATING_TOOLTIP, WC_NONE,
> 	0,
> 	_nested_tooltips_extra_widgets, lengthof(_nested_station_rating_tooltip_widgets)
> );
> 
> static const int STATION_RATING_AGE[] = {0, 10, 20, 33};
> static const int STATION_RATING_WAITTIME[] = {0, 25, 50, 95, 130};
> static const int STATION_RATING_WAITUNITS[] = {-90, -35, 0, 10, 30, 40};
> 
> 
> struct StationRatingTooltipWindow : public Window
> {
> 	TileType tiletype;
> 	uint16 objIndex;
> 	TooltipCloseCondition close_cond;
> 	const Station *st;
> 	const CargoSpec *cs;
> 	bool newgrf_rating_used;
> 
> 	static const uint RATING_TOOLTIP_LINE_BUFF_SIZE = 512;
> 	static const uint RATING_TOOLTIP_MAX_LINES = 8;
> 	static const uint RATING_TOOLTIP_NEWGRF_INDENT = 20;
> 
> public:
> 	char data[RATING_TOOLTIP_MAX_LINES + 1][RATING_TOOLTIP_LINE_BUFF_SIZE];
> 
> 	StationRatingTooltipWindow(Window *parent, const Station *st, const CargoSpec *cs) : Window(&_station_rating_tooltip_desc)
> 	{
> 		this->parent = parent;
> 		this->st = st;
> 		this->cs = cs;
> 		this->InitNested();
> 		CLRBITS(this->flags, WF_WHITE_BORDER);
> 	}
> 
> 	virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
> 	{
> 		int scr_top = GetMainViewTop() + 2;
> 		int scr_bot = GetMainViewBottom() - 2;
> 		Point pt;
> 		pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
> 		if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
> 		pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
> 		return pt;
> 	}
> 
> 	int RoundRating(int rating) {
> 		// if (rating >= 0) {
> 		// 	return rating * 101 +
> 		// }
> 		return RoundDivSU(rating * 101, 256);
> 	}
> 
> 	virtual void OnInit() {
> 		const GoodsEntry *ge = &this->st->goods[this->cs->Index()];
> 
> 		SetDParam(0, this->cs->name);
> 		GetString(this->data[0], STR_STATION_RATING_TOOLTIP_RATING_DETAILS, lastof(this->data[0]));
> 		if (!ge->HasRating()) {
> 			this->data[1][0] = '\0';
> 			return;
> 		}
> 
> 		uint line_nr = 1;
> 		int total_rating = 0;
> 
> 		if (HasBit(cs->callback_mask, CBM_CARGO_STATION_RATING_CALC)) {
> 			uint last_speed = ge->HasVehicleEverTriedLoading() ? ge->last_speed : 0xFF;
> 
> 			uint32 var18 = min(ge->time_since_pickup, 0xFF) | (min(ge->max_waiting_cargo, 0xFFFF) << 8) | (min(last_speed, 0xFF) << 24);
> 			uint32 var10 = (this->st->last_vehicle_type == VEH_INVALID) ? 0x0 : (this->st->last_vehicle_type + 0x10);
> 			uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, this->cs);
> 			int newgrf_rating = 0;
> 			if (callback != CALLBACK_FAILED) {
> 				newgrf_rating = GB(callback, 0, 14);
> 				if (HasBit(callback, 14)) newgrf_rating -= 0x4000;
> 
> 				this->newgrf_rating_used = true;
> 
> 				total_rating += newgrf_rating;
> 				newgrf_rating = this->RoundRating(newgrf_rating);
> 
> 				SetDParam(0, STR_STATION_RATING_TOOLTIP_NEWGRF_RATING_0 + (newgrf_rating <= 0 ? 0 : 1));
> 				SetDParam(1, newgrf_rating);
> 				GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_NEWGRF_RATING, lastof(this->data[line_nr]));
> 				line_nr++;
> 
> 				SetDParam(0, min(last_speed, 0xFF));
> 				GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_NEWGRF_SPEED, lastof(this->data[line_nr]));
> 				line_nr++;
> 
> 				SetDParam(0, min(ge->max_waiting_cargo, 0xFFFF));
> 				GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_NEWGRF_WAITUNITS, lastof(this->data[line_nr]));
> 				line_nr++;
> 
> 				SetDParam(0, (min(ge->time_since_pickup, 0xFF) * 5 + 1) / 2);
> 				GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_NEWGRF_WAITTIME, lastof(this->data[line_nr]));
> 				line_nr++;
> 			}
> 		}
> 
> 		if (!this->newgrf_rating_used) {
> 
> 			byte waittime = ge->time_since_pickup;
> 			if (this->st->last_vehicle_type == VEH_SHIP) waittime >>= 2;
> 			int waittime_stage = 0;
> 			(waittime > 21) ||
> 			(waittime_stage = 1, waittime > 12) ||
> 			(waittime_stage = 2, waittime > 6) ||
> 			(waittime_stage = 3, waittime > 3) ||
> 			(waittime_stage = 4, true);
> 			total_rating += STATION_RATING_WAITTIME[waittime_stage];
> 
> 			SetDParam(0, STR_STATION_RATING_TOOLTIP_WAITTIME_0 + waittime_stage);
> 			SetDParam(1, (ge->time_since_pickup * 5 + 1) / 2);
> 			SetDParam(2, this->RoundRating(STATION_RATING_WAITTIME[waittime_stage]));
> 			GetString(this->data[line_nr], this->st->last_vehicle_type == VEH_SHIP ? STR_STATION_RATING_TOOLTIP_WAITTIME_SHIP : STR_STATION_RATING_TOOLTIP_WAITTIME, lastof(this->data[line_nr]));
> 			line_nr++;
> 
> 			uint waitunits = ge->max_waiting_cargo;
> 			int waitunits_stage = 0;
> 			(ge->max_waiting_cargo > 1500) ||
> 			(waitunits_stage = 1, ge->max_waiting_cargo > 1000) ||
> 			(waitunits_stage = 2, ge->max_waiting_cargo > 600) ||
> 			(waitunits_stage = 3, ge->max_waiting_cargo > 300) ||
> 			(waitunits_stage = 4, ge->max_waiting_cargo > 100) ||
> 			(waitunits_stage = 5, true);
> 			total_rating += STATION_RATING_WAITUNITS[waitunits_stage];
> 
> 			SetDParam(0, STR_STATION_RATING_TOOLTIP_WAITUNITS_0 + waitunits_stage);
> 			SetDParam(1, ge->max_waiting_cargo);
> 			SetDParam(2, this->RoundRating(STATION_RATING_WAITUNITS[waitunits_stage]));
> 			GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_WAITUNITS, lastof(this->data[line_nr]));
> 			line_nr++;
> 
> 			int b = ge->last_speed - 85;
> 			int r_speed = b >= 0 ? b >> 2 : 0;
> 			int r_speed_round = this->RoundRating(r_speed);
> 			total_rating += r_speed;
> 			if (ge->last_speed == 255) {
> 				SetDParam(0, STR_STATION_RATING_TOOLTIP_SPEED_MAX);
> 			} else if (r_speed_round == 0) {
> 				SetDParam(0, STR_STATION_RATING_TOOLTIP_SPEED_ZERO);
> 			} else {
> 				SetDParam(0, STR_STATION_RATING_TOOLTIP_SPEED_0 + r_speed / 11);
> 			}
> 			SetDParam(0, ge->last_speed == 255 ? STR_STATION_RATING_TOOLTIP_SPEED_MAX : STR_STATION_RATING_TOOLTIP_SPEED_0 + r_speed / 11);
> 			SetDParam(1, ge->last_speed);
> 			SetDParam(2, r_speed_round);
> 			GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_SPEED, lastof(this->data[line_nr]));
> 			line_nr++;
> 		}
> 
> 		int age_stage = (ge->last_age >= 3 ? 0 : 3 - ge->last_age);
> 		total_rating += STATION_RATING_AGE[age_stage];
> 		SetDParam(0, STR_STATION_RATING_TOOLTIP_AGE_0 + age_stage);
> 		SetDParam(1, ge->last_age);
> 		SetDParam(2, this->RoundRating(STATION_RATING_AGE[age_stage]));
> 		GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_AGE, lastof(this->data[line_nr]));
> 		line_nr++;
> 
> 		if (Company::IsValidID(st->owner) && HasBit(st->town->statues, st->owner)) {
> 			SetDParam(0, STR_STATION_RATING_TOOLTIP_STATUE_YES);
> 			total_rating += 26;
> 		} else {
> 			SetDParam(0, STR_STATION_RATING_TOOLTIP_STATUE_NO);
> 		}
> 		GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_STATUE, lastof(this->data[line_nr]));
> 		line_nr++;
> 
> 		SetDParam(0, ToPercent8(Clamp(total_rating, 0, 255)));
> 		GetString(this->data[line_nr], STR_STATION_RATING_TOOLTIP_TOTAL_RATING, lastof(this->data[line_nr]));
> 		line_nr++;
> 
> 		this->data[line_nr][0] = '\0';
> 	}
> 
> 	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
> 	{
> 		if (widget != WID_LI_BACKGROUND) return;
> 
> 		size->height = WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + 2;
> 		for (uint i = 0; i <= RATING_TOOLTIP_MAX_LINES; i++) {
> 			if (StrEmpty(this->data[i])) break;
> 
> 			uint width = GetStringBoundingBox(this->data[i]).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT + 2;
> 			if (this->newgrf_rating_used && i >= 2 && i <= 4)
> 				width += RATING_TOOLTIP_NEWGRF_INDENT;
> 			size->width = max(size->width, width);
> 			size->height += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
> 		}
> 		size->height -= WD_PAR_VSEP_NORMAL;
> 	}
> 
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		uint icon_size = ScaleGUITrad(10);
> 		uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
> 		uint text_ofs = (line_height - FONT_HEIGHT_NORMAL) >> 1;
> 		uint icon_ofs = (line_height - icon_size) >> 1;
> 
> 		GfxDrawLine(r.left,  r.top,    r.right, r.top,    PC_BLACK);
> 		GfxDrawLine(r.left,  r.bottom, r.right, r.bottom, PC_BLACK);
> 		GfxDrawLine(r.left,  r.top,    r.left,  r.bottom, PC_BLACK);
> 		GfxDrawLine(r.right, r.top,    r.right, r.bottom, PC_BLACK);
> 
> 		int y = r.top + WD_FRAMETEXT_TOP + 1;
> 		int left0 = r.left + WD_FRAMETEXT_LEFT + 1;
> 		int right0 = r.right - WD_FRAMETEXT_RIGHT - 1;
> 		DrawString(left0, right0, y, this->data[0], TC_LIGHT_BLUE, SA_CENTER);
> 		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
> 		for (uint i = 1; i <= RATING_TOOLTIP_MAX_LINES; i++) {
> 			if (StrEmpty(this->data[i])) break;
> 			int left = left0, right = right0;
> 			if (this->newgrf_rating_used && i >= 2 && i <= 4) {
> 				if (_current_text_dir == TD_RTL) {
> 					right -= RATING_TOOLTIP_NEWGRF_INDENT;
> 				} else {
> 					left += RATING_TOOLTIP_NEWGRF_INDENT;
> 				}
> 			}
> 			DrawString(left, right, y, this->data[i], TC_BLACK);
> 			y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
> 		}
> 	}
> 
> 	virtual void OnMouseLoop()
> 	{
> 		if (!_cursor.in_window || !_mouse_hovering) {
> 			delete this;
> 		}
> 	}
> };
> 
> void GuiShowTooltipsExtra(Window *parent, uint param, TooltipCloseCondition close_tooltip)
> {
> 	DeleteWindowById(WC_TOOLTIPS_EXTRA, 0);
> 	new TooltipsExtraWindow(parent, param, close_tooltip);
> }
> 
> void GuiShowStationRatingTooltip(Window *parent, const Station *st, const CargoSpec *cs) {
> 	DeleteWindowById(WC_STATION_RATING_TOOLTIP, 0);
> 	new StationRatingTooltipWindow(parent, st, cs);
diff -r -B -X .diff-exclude vanilla/src/network/network_client.cpp cmclient/src/network/network_client.cpp
33a34
> #include "../newgrf_revisions.hpp"
37c38,39
< #include "../safeguards.h"
---
> #include "../town.h"
> #include "network_func.h"
38a41
> #include "../safeguards.h"
40a44,47
> void SyncCMUser(const char *msg);
> // extern const std::map<std::string, uint32> OPENTTD_NEWGRF_VERSIONS;
> // extern const std::map<uint32, uint32> OPENTTD_RELEASE_REVISIONS;
> static const uint32 OPENTTD_NEWGRF_REVISION_MASK = (1 << 19) - 1;
319a327,328
> /** Server revision to use when fooling revision check */
> const char *_network_join_server_revision = NULL;
349,350c358,381
< 	p->Send_string(GetNetworkRevisionString());
< 	p->Send_uint32(_openttd_newgrf_version);
---
> 	if (_network_join_server_revision) {
> 		auto r = _network_join_server_revision;
> 		p->Send_string(r);
> 		auto nr = OPENTTD_NEWGRF_VERSIONS.find(r);
> 		uint32 rev;
> 		if (nr != OPENTTD_NEWGRF_VERSIONS.end()) {
> 			p->Send_uint32(nr->second);
> 		} else if (r[0] == 'r' && r[6] == 0 && (rev = strtoul(r + 1, nullptr, 10)) > 0) {
> 			// assume it's nightly
> 			uint32 max_rev = 0;
> 			// find release closest to the nightly
> 			for (auto &kv: OPENTTD_RELEASE_REVISIONS) {
> 				if (kv.first > max_rev && kv.first <= rev)
> 					max_rev = kv.first;
> 			}
> 			p->Send_uint32(OPENTTD_RELEASE_REVISIONS.at(max_rev) |
> 			               (rev & OPENTTD_NEWGRF_REVISION_MASK));
> 		} else {
> 			p->Send_uint32(_openttd_newgrf_version);
> 		}
> 	} else {
> 		p->Send_string(GetNetworkRevisionString());
> 		p->Send_uint32(_openttd_newgrf_version);
> 	}
632a664,667
> 		InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
> 		SetWindowClassesDirty(WC_WATCH_COMPANY);
> 		InvalidateWindowData(WC_WATCH_COMPANYA, ci->client_id, 1);
> 		SetWindowClassesDirty(WC_WATCH_COMPANYA);
651a687,690
> 	InvalidateWindowClassesData(WC_WATCH_COMPANY, 0);
> 	SetWindowClassesDirty(WC_WATCH_COMPANY);
> 	InvalidateWindowData(WC_WATCH_COMPANYA, ci->client_id, 1);
> 	SetWindowClassesDirty(WC_WATCH_COMPANYA);
1007c1046,1047
< 		NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
---
> 		if (strncmp(msg, "synccmuser", 10) == 0) SyncCMUser(msg);
> 		else NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), self_send, name, msg, data);
1043a1084,1085
> 	InvalidateWindowClassesData( WC_WATCH_COMPANYA, 0 );
> 	SetWindowClassesDirty( WC_WATCH_COMPANYA );
1133a1176,1177
> 	InvalidateWindowClassesData( WC_WATCH_COMPANYA, 0 );
> 	SetWindowClassesDirty( WC_WATCH_COMPANYA );
1278a1323,1326
> void NetworkClientSendChatToServer(const char * msg)
> {
> 	NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, CLIENT_ID_SERVER, msg);
> }
1323a1372,1377
> void SyncCMUser(const char *msg) {
> 	uint user_id, role;
> 	sscanf(msg + 10, "%u %u", &user_id, &role);
> 	_novarole = (role >= 50);
> 	DEBUG(net, 1, "CityMania user synchronized: %u %u", user_id, role);
> }
diff -r -B -X .diff-exclude vanilla/src/network/network_client.h cmclient/src/network/network_client.h
119a120
> extern const char *_network_join_server_revision;
diff -r -B -X .diff-exclude vanilla/src/network/network.cpp cmclient/src/network/network.cpp
85c85
< 
---
> bool _novarole = false;
118a119
> 	InvalidateWindowData(WC_WATCH_COMPANYA, this->client_id, 2);
diff -r -B -X .diff-exclude vanilla/src/network/network_func.h cmclient/src/network/network_func.h
41c41
< 
---
> extern bool _novarole;
59a60
> void NetworkClientSendChatToServer(const char * msg);
diff -r -B -X .diff-exclude vanilla/src/network/network_gui.cpp cmclient/src/network/network_gui.cpp
42a43,46
> #include "../error.h"
> #include "../zoom_func.h"
> #include "../watch_gui.h"
> 
238a243
> 	bool UDP_CC_queried;
392a398
> 		int lock_y_offset = (this->resize.step_height - GetSpriteSize(SPR_LOCK).height) / 2;
437c443
< 			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + this->lock_offset, y + icon_y_offset - 1);
---
> 			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + this->lock_offset, y + lock_y_offset);
440c446
< 			DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset);
---
> 			DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset + 1);
443c449
< 			DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + this->flag_offset, y + icon_y_offset);
---
> 			DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + this->flag_offset, y + (this->resize.step_height - GetSpriteSize(SPR_FLAGS_BASE + cur_item->info.server_lang).height) / 2);
478a485
> 		this->UDP_CC_queried = false;
615c622
< 				!sel->info.compatible); // Revision mismatch
---
> 				(!sel->info.compatible && !_ctrl_pressed)); // Revision mismatch
773a781,791
> 					if (this->server->info.compatible) {
> 						_network_join_server_revision = NULL;
> 					} else {
> 						_network_join_server_revision = this->server->info.server_revision;
> 						ShowErrorMessage(STR_IGNORE_VERSION_CHECK_WARNING,
> 						                 STR_IGNORE_VERSION_CHECK_WARNING_DETAILS,
> 						                 WL_WARNING,
> 						                 0, 0,
> 						                 NULL, 0, NULL);
> 						// ShowGoalQuestion(0, 2 /* WARNING */, 2 /* OK */, "Full-tile autoroad tool is deprecated and will be removed in next release.\n Use regular autoroad tool instead.");
> 					}
788a807,823
> 			case WID_NG_NICE:
> 			case WID_NG_BTPRO:
> 			case WID_NG_REDDIT:
> 			case WID_NG_CITYMANIA:
> 				if(!UDP_CC_queried){
> 					NetworkUDPQueryMasterServer();
> 					UDP_CC_queried = true;
> 				}
> 				if(widget == WID_NG_NICE) this->filter_editbox.text.Assign("n-ice");
> 				else if(widget == WID_NG_BTPRO) this->filter_editbox.text.Assign("BTPro");
> 				else if(widget == WID_NG_CITYMANIA) this->filter_editbox.text.Assign("citymania");
> 				else if(widget == WID_NG_REDDIT) this->filter_editbox.text.Assign("reddit");
> 				this->servers.ForceRebuild();
> 				this->BuildGUINetworkGameList();
> 				this->ScrollToSelectedServer();
> 				this->SetDirty();
> 				break;
919c954
< Listing NetworkGameWindow::last_sorting = {false, 5};
---
> Listing NetworkGameWindow::last_sorting = {false, 0};
955a991,994
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CITYMANIA), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_CITYMANIA, STR_NETWORK_SELECT_SERVER_TOOLTIP),
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_BTPRO), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_BTPRO, STR_NETWORK_SELECT_SERVER_TOOLTIP),
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NICE), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_NICE, STR_NETWORK_SELECT_SERVER_TOOLTIP),
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_REDDIT), SetFill(1, 0), SetDataTip(STR_NETWORK_SELECT_REDDIT, STR_NETWORK_SELECT_SERVER_TOOLTIP),
1396c1435
< 				resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
---
> 				resize->height = WD_MATRIX_TOP + max(max(GetSpriteSize(SPR_LOCK).height, GetSpriteSize(SPR_PROFIT_LOT).height), (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
1397a1437
> 				size->width = ScaleGUITrad(146);
1449a1490
> 		uint text_offset = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - FONT_HEIGHT_NORMAL) / 2 + WD_MATRIX_TOP;
1453c1494
< 		int lock_y_offset   = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - lock_size.height) / 2;
---
> 		int lock_y_offset   = (this->resize.step_height - lock_size.height) / 2;
1457c1498
< 		int profit_y_offset   = (this->resize.step_height - WD_MATRIX_TOP - WD_MATRIX_BOTTOM - profit_size.height) / 2;
---
> 		int profit_y_offset   = (this->resize.step_height - profit_size.height) / 2;
1464c1505
< 		int y = r.top + WD_MATRIX_TOP;
---
> 		int y = r.top;
1471c1512
< 				GfxFillRect(r.left + 1, y - 2, r.right - 1, y + FONT_HEIGHT_NORMAL, PC_GREY); // show highlighted item with a different colour
---
> 				GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY); // show highlighted item with a different colour
1474c1515
< 			DrawString(text_left, text_right, y, this->company_info[company].company_name, TC_BLACK);
---
> 			DrawString(text_left, text_right, y + text_offset, this->company_info[company].company_name, TC_BLACK);
1700a1742,1749
> static void ClientList_Watch(const NetworkClientInfo *ci)
> {
> 	if (ci != NULL){
> 		CompanyID cid = (CompanyID)ci->client_id;
> 		ShowWatchWindow(cid, 1);
> 	}
> }
> 
1776a1826,1828
> 		if (_network_own_client_id != ci->client_id && ci->client_id != CLIENT_ID_SERVER && _novarole) {
> 			this->AddAction(STR_XI_WATCH, &ClientList_Watch);
> 		}
1921,1922c1973,1976
< 
< 		size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT;
---
> 		SetDParam(0, 0xFFFF);
> 		SetDParam(1, INVALID_COMPANY);
> 		uint width2 = GetStringBoundingBox(STR_NETWORK_CLIENT_EXTRA).width;
> 		size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT + width2;
1973a2028,2032
> 
> 			uint extra = GetStringBoundingBox(ci->client_name).width + 15;
> 			SetDParam(0, ci->client_id);
> 			SetDParam(1, ci->client_playas == INVALID_COMPANY ? ci->client_playas : ci->client_playas + 1);
> 			DrawString(rtl ? left : name_left + extra, rtl ? name_right - extra : right, y + text_offset, STR_NETWORK_CLIENT_EXTRA, TC_FROMSTRING, SA_RIGHT);
diff -r -B -X .diff-exclude vanilla/src/newgrf_debug_gui.cpp cmclient/src/newgrf_debug_gui.cpp
461a462
> 		this->DrawString(r, i++, "Industry type: %d", (int)((const Industry *)base)->type);
Only in cmclient/src: newgrf_revisions.hpp
diff -r -B -X .diff-exclude vanilla/src/newgrf_spritegroup.cpp cmclient/src/newgrf_spritegroup.cpp
168,171c168,172
< 		case DSGA_OP_SDIV: return value == 0 ? (S)last_value : (S)last_value / (S)value;
< 		case DSGA_OP_SMOD: return value == 0 ? (S)last_value : (S)last_value % (S)value;
< 		case DSGA_OP_UDIV: return value == 0 ? (U)last_value : (U)last_value / (U)value;
< 		case DSGA_OP_UMOD: return value == 0 ? (U)last_value : (U)last_value % (U)value;
---
> 		// replaced ?: with if to avoid VS2015U3 optimizator bug
> 		case DSGA_OP_SDIV: if (value == 0) return (S)last_value; else return (S)last_value / (S)value;
> 		case DSGA_OP_SMOD: if (value == 0) return (S)last_value; else return (S)last_value % (S)value;
> 		case DSGA_OP_UDIV: if (value == 0) return (U)last_value; else return (U)last_value / (U)value;
> 		case DSGA_OP_UMOD: if (value == 0) return (U)last_value; else return (U)last_value % (U)value;
diff -r -B -X .diff-exclude vanilla/src/order_cmd.cpp cmclient/src/order_cmd.cpp
1800a1801
> 							_settings_client.gui.runway_too_short_warn &&
diff -r -B -X .diff-exclude vanilla/src/order_gui.cpp cmclient/src/order_gui.cpp
27d26
< #include "industry.h"
175a175,246
> struct OrdersFromSettings
> {
> 	enum OrderUnloadFlags unload;
> 	enum OrderLoadFlags   load;
> };
> 
> typedef enum {
> 	GOFS_NONE = 0,
> 	GOFS_FULL,
> 	GOFS_XFER,
> 	GOFS_UNLOAD,
> 	GOFS_FEEDLOAD,
> 	GOFS_FEEDUNLOAD,
> 	GOFS_NOLOAD
> } GetOrderFromSettingsTypes;
> 
> static enum {
> 	GOFS_FEEDER_NULL,
> 	GOFS_FEEDER_LOAD,
> 	GOFS_FEEDER_UNLOAD
> } gofsfeeder_ordermod = GOFS_FEEDER_NULL;
> 
> #define GOFSFEEDER_ORDERMOD_RESET gofsfeeder_ordermod = GOFS_FEEDER_NULL
> 
> 
> /* fetch and compute orders set from settings */
> 
> static void GetOrdersFromSettings(const Vehicle *v, uint8 setting, struct OrdersFromSettings *rv)
> {
> 	rv->load = (enum OrderLoadFlags)-1;
> 	rv->unload = (enum OrderUnloadFlags)-1;
> 
> 	switch(setting) {
> 
> 	case GOFS_FEEDLOAD:
> 		if (v->GetNumOrders()) gofsfeeder_ordermod = GOFS_FEEDER_LOAD;
> 		rv->unload = OUFB_NO_UNLOAD;
> 		rv->load = OLF_FULL_LOAD_ANY;
> 		break;
> 	case GOFS_FULL:
> 		rv->load = OLF_FULL_LOAD_ANY;
> 		break;
> 
> 	case GOFS_UNLOAD:
> 		rv->unload = OUFB_UNLOAD;
> 		if (_settings_client.gui.auto_noload_on_unloadall)
> 			rv->load = OLFB_NO_LOAD;
> 		break;
> 
> 	case GOFS_FEEDUNLOAD:
> 		if (v->GetNumOrders()) gofsfeeder_ordermod = GOFS_FEEDER_UNLOAD;
> 		rv->unload = OUFB_TRANSFER;
> 		rv->load = OLFB_NO_LOAD;
> 		break;
> 
> 	case GOFS_XFER:
> 		rv->unload = OUFB_TRANSFER;
> 		if (_settings_client.gui.auto_noload_on_transfer)
> 			rv->load = OLFB_NO_LOAD;
> 		break;
> 
> 	case GOFS_NOLOAD:
> 		rv->load = OLFB_NO_LOAD;
> 		break;
> 
> 	case GOFS_NONE:
> 		break;
> 
> 	default: NOT_REACHED();
> 	}
> }
> 
350a422,434
> 
> 	uint order_dist_sq = 0;
> 	uint order_dist_mh = 0;
> 	const Order *next2 = order->next != NULL ? order->next : v->GetFirstOrder();
> 	TileIndex prev_tile = order->GetLocation(v, true);
> 	TileIndex cur_tile = next2->GetLocation(v, true);
> 	if (prev_tile != INVALID_TILE && cur_tile != INVALID_TILE){
> 		order_dist_sq = IntSqrt(DistanceSquare(prev_tile, cur_tile));
> 		order_dist_mh = DistanceManhattan(prev_tile, cur_tile);
> 	}
> 	SetDParam(0, order_dist_sq);
> 	SetDParam(1, order_dist_mh);
> 	DrawString(middle, right, y, STR_ORDER_DIST, TC_WHITE, SA_RIGHT);
393,395c477,479
< 	/* check for station or industry with neutral station */
< 	if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
< 		const Station *st = nullptr;
---
> 	if (IsTileType(tile, MP_STATION)) {
> 		StationID st_index = GetStationIndex(tile);
> 		const Station *st = Station::Get(st_index);
397,404c481
< 		if (IsTileType(tile, MP_INDUSTRY)) {
< 			const Industry *in = Industry::GetByTile(tile);
< 			tile = in->location.tile;
< 		}
< 
< 		if (IsTileType(tile, MP_STATION)) st = Station::GetByTile(tile);
< 
< 		if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) {
---
> 		if (st->owner == _local_company || st->owner == OWNER_NONE) {
412c489
< 				StationID st_index = GetStationIndex(st->xy);
---
> 				uint8 os = 0xff;
414c491,516
< 				if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY);
---
> 				if (_ctrl_pressed) {
> 					if (_shift_pressed)
> 						os = _settings_client.gui.goto_shortcuts_ctrlshift_lclick;
> 					else if (_alt_pressed)
> 						os = _settings_client.gui.goto_shortcuts_altctrl_lclick;
> 					else
> 						os = _settings_client.gui.goto_shortcuts_ctrl_lclick;
> 				}
> 				else if (_shift_pressed) {
> 					if (_alt_pressed)
> 						os = _settings_client.gui.goto_shortcuts_altshift_lclick;
> 					else
> 						os = _settings_client.gui.goto_shortcuts_shift_lclick;
> 				}
> 				else if (_alt_pressed)
> 					os = _settings_client.gui.goto_shortcuts_alt_lclick;
> 
> 				if (os != 0xff) {
> 					struct OrdersFromSettings ofs;
> 					GetOrdersFromSettings(v, os, &ofs);
> 					if (ofs.load != (enum OrderLoadFlags)-1)
> 						order.SetLoadType(ofs.load);
> 					if (ofs.unload != (enum OrderUnloadFlags)-1)
> 					order.SetUnloadType(ofs.unload);
> 				}
> 
439a542
> 	OHK_CLOSE,
647a751,757
> 		bool set_no_load = false;
> 		if (unload_type == OUFB_TRANSFER){
> 			set_no_load = _settings_client.gui.auto_noload_on_transfer;
> 		}
> 		else if (unload_type == OUFB_UNLOAD){
> 			set_no_load = _settings_client.gui.auto_noload_on_unloadall;
> 		}
649c759
< 		if (unload_type == OUFB_TRANSFER) {
---
> 		if (set_no_load) {
1435a1546,1550
> 		if(hotkey == OHK_GOTO && this->goto_type != OPOS_NONE){
> 			this->RaiseWidget(WID_O_GOTO);
> 			ResetObjectToPlace();
> 			return ES_NOT_HANDLED;
> 		}
1448a1564
> 			case OHK_CLOSE:          delete this; break;
1460c1576,1590
< 			if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
---
> 			if (gofsfeeder_ordermod != GOFS_FEEDER_NULL) {
> 				if (gofsfeeder_ordermod == GOFS_FEEDER_LOAD) {
> 					if (DoCommandP(this->vehicle->tile, this->vehicle->index + ((1) << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_NO_ESTIMATE | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
> 						DoCommandP(this->vehicle->tile, this->vehicle->index,  0, CMD_DELETE_ORDER |  CMD_NO_ESTIMATE | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER));
> 					}
> 
> 				}
> 				else if (gofsfeeder_ordermod == GOFS_FEEDER_UNLOAD) { // still flushes the whole order table
> 					if (DoCommandP(this->vehicle->tile, this->vehicle->index + ((this->vehicle->GetNumOrders()) << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_NO_ESTIMATE | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
> 						DoCommandP(this->vehicle->tile, this->vehicle->index, (this->vehicle->GetNumOrders()-2+(int)_networking) , CMD_DELETE_ORDER | CMD_NO_ESTIMATE | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER));
> 					}
> 				}
> 				gofsfeeder_ordermod = GOFS_FEEDER_NULL;
> 			}
> 			else if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER |  CMD_NO_ESTIMATE | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
1537a1668
> 	Hotkey('Q', "close", OHK_CLOSE),
diff -r -B -X .diff-exclude vanilla/src/os/macosx/osx_stdafx.h cmclient/src/os/macosx/osx_stdafx.h
87a88
> #include <string>
Only in cmclient/src/os/windows: ottdres.rc
diff -r -B -X .diff-exclude vanilla/src/rail_cmd.cpp cmclient/src/rail_cmd.cpp
48a49
> TileIndex _rail_track_endtile; ///< The end of a rail track; as hidden return from the rail build/remove command for GUI purposes.
451a453,454
> 	_rail_track_endtile = INVALID_TILE;
> 
468c471,474
< 			if (ret.Failed()) return ret;
---
> 			if (ret.Failed()) {
> 				if (ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) _rail_track_endtile = tile;
> 				return ret;
> 			}
558a565
> 				_rail_track_endtile = tile;
597a605
> 	_rail_track_endtile = tile;
615a624,625
> 	_rail_track_endtile = INVALID_TILE;
> 
741a752
> 	_rail_track_endtile = tile;
874a886,887
> 	_rail_track_endtile = INVALID_TILE;
> 
885a899
> 		TileIndex last_endtile = _rail_track_endtile;
889a904
> 			if (_rail_track_endtile == INVALID_TILE) _rail_track_endtile = last_endtile;
diff -r -B -X .diff-exclude vanilla/src/rail_gui.cpp cmclient/src/rail_gui.cpp
54a55,56
> extern TileIndex _rail_track_endtile; // rail_cmd.cpp
> 
57a60,64
> static const int HOTKEY_POLYRAIL     = 0x1000;
> static const int HOTKEY_NEW_POLYRAIL = 0x1001;
> static const int HOTKEY_BUILD_STATION_SIZED = 0x1010;     ///< Build a station in fixed size mode.
> static const int HOTKEY_BUILD_STATION_DRAGDROP = 0x1011;  ///< Build a station in dragdrop mode.
> 
94c101
< static void GenericPlaceRail(TileIndex tile, int cmd)
---
> static CommandContainer GenericPlaceRailCmd(TileIndex tile, Track track)
96,100c103,114
< 	DoCommandP(tile, _cur_railtype, cmd,
< 			_remove_button_clicked ?
< 			CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
< 			CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
< 			CcPlaySound_SPLAT_RAIL);
---
> 	CommandContainer ret = {
> 		tile,          // tile
> 		_cur_railtype, // p1
> 		track,         // p2
> 		_remove_button_clicked ?
> 				CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
> 				CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), // cmd
> 		CcPlaySound_SPLAT_RAIL, // callback
> 		""             // text
> 	};
> 
> 	return ret;
279a294
> 		StoreRailPlacementEndpoints(tile, _build_tunnel_endtile, TileX(tile) == TileX(_build_tunnel_endtile) ? TRACK_Y : TRACK_X, false);
309c324
< 		if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
---
> 		if ((i <= WID_RAT_POLYRAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
353c368
< static void DoRailroadTrack(int mode)
---
> static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_tile, Track track)
355,359c370,381
< 	DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 6),
< 			_remove_button_clicked ?
< 			CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
< 			CMD_BUILD_RAILROAD_TRACK  | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
< 			CcPlaySound_SPLAT_RAIL);
---
> 	CommandContainer ret = {
> 		start_tile,                             // tile
> 		end_tile,                               // p1
> 		(uint32)(_cur_railtype | (track << 6)), // p2
> 		_remove_button_clicked ?
> 				CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
> 				CMD_BUILD_RAILROAD_TRACK  | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), // cmd
> 		CcPlaySound_SPLAT_RAIL,                 // callback
> 		""                                      // text
> 	};
> 
> 	return ret;
364,368c386,408
< 	int trackstat = _thd.drawstyle & HT_DIR_MASK; // 0..5
< 
< 	if (_thd.drawstyle & HT_RAIL) { // one tile case
< 		GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
< 		return;
---
> 	Track track = (Track)(_thd.drawstyle & HT_DIR_MASK); // 0..5
> 	TileIndex start_tile = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
> 	TileIndex end_tile = TileVirtXY(_thd.selend.x, _thd.selend.y);
> 
> 	CommandContainer cmd = (_thd.drawstyle & HT_RAIL) ?
> 			GenericPlaceRailCmd(end_tile, track) : // one tile case
> 			DoRailroadTrackCmd(start_tile, end_tile, track); // multitile selection
> 
> 	/* When overbuilding existing tracks in polyline mode we want to move the
> 	 * snap point over the last overbuilt track piece. In such case we don't
> 	 * wan't to show any errors to the user. Don't execute the command right
> 	 * away, first check if overbuilding. */
> 	if (_shift_pressed || !(_thd.place_mode & HT_POLY) ||
> 			DoCommand(&cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT ||
> 			_rail_track_endtile == INVALID_TILE) {
> 		/* Execute. */
> 		if (!DoCommandP(&cmd)) return;
> 	}
> 
> 	/* Save new snap points for the polyline tool, no matter if the command
> 	 * succeeded, the snapping will be extended over overbuilt track pieces. */
> 	if (!_shift_pressed && _rail_track_endtile != INVALID_TILE) {
> 		StoreRailPlacementEndpoints(start_tile, _rail_track_endtile, track, true);
370,371d409
< 
< 	DoRailroadTrack(trackstat);
417a456,522
> // FIXME duplicate from road_gui.cpp
> static DiagDirection TileFractCoordsToDiagDir() {
> 	bool diag = (_tile_fract_coords.x + _tile_fract_coords.y) < 16;
> 	if (_tile_fract_coords.x < _tile_fract_coords.y) {
> 		return diag ? DIAGDIR_NE : DIAGDIR_SE;
> 	}
> 	return diag ? DIAGDIR_NW : DIAGDIR_SW;
> }
> 
> // FIXME duplicate from road_gui.cpp
> static DiagDirection RoadBitsToDiagDir(RoadBits bits) {
> 	if (bits < ROAD_SE) {
> 		return bits == ROAD_NW ? DIAGDIR_NW : DIAGDIR_SW;
> 	}
> 	return bits == ROAD_SE ? DIAGDIR_SE : DIAGDIR_NE;
> }
> 
> RoadBits FindRailsToConnect(TileIndex tile) {
> 	RoadBits directed = ROAD_NONE;
> 	RoadBits passing = ROAD_NONE;
> 	DiagDirection ddir;
> 	for (ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
> 		TileIndex cur_tile = TileAddByDiagDir(tile, ddir);
> 		if (HasStationTileRail(cur_tile)) {
> 			if (GetRailStationTrackBits(cur_tile) & DiagdirReachesTracks(ddir)) {
> 				directed |= DiagDirToRoadBits(ddir);
> 			}
> 			continue;
> 		}
> 		if (!IsTileType(cur_tile, MP_RAILWAY)) continue;
> 		if (!IsPlainRail(cur_tile)) continue;
> 		passing |= DiagDirToRoadBits(ddir);
> 		if (GetTrackBits(cur_tile) & DiagdirReachesTracks(ddir)) {
> 			directed |= DiagDirToRoadBits(ddir);
> 		}
> 	}
> 	// Prioritize track bits that head in this direction
> 	if (directed != ROAD_NONE) {
> 		return directed;
> 	}
> 	return passing;
> }
> 
> /*
>  * Selects orientation for rail object (depot)
>  */
> static DiagDirection AutodetectRailObjectDirection(TileIndex tile) {
> 	RoadBits bits = FindRailsToConnect(tile);
> 	// FIXME after this point repeats road autodetection
> 	if (HasExactlyOneBit(bits)) return RoadBitsToDiagDir(bits);
> 	if (bits == ROAD_NONE) bits = ROAD_ALL;
> 	RoadBits frac_bits = DiagDirToRoadBits(TileFractCoordsToDiagDir());
> 	if (HasExactlyOneBit(frac_bits & bits)) {
> 		return RoadBitsToDiagDir(frac_bits & bits);
> 	}
> 	frac_bits |= MirrorRoadBits(frac_bits);
> 	if (HasExactlyOneBit(frac_bits & bits)) {
> 		return RoadBitsToDiagDir(frac_bits & bits);
> 	}
> 	for (DiagDirection ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
> 		if (DiagDirToRoadBits(ddir) & bits) {
> 			return ddir;
> 		}
> 	}
> 	NOT_REACHED();
> }
> 
464a570
> 		this->GetWidget<NWidgetCore>(WID_RAT_POLYRAIL)->widget_data     = rti->gui_sprites.auto_rail;
492a599
> 			case WID_RAT_POLYRAIL:
523a631,639
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		if (widget == WID_RAT_POLYRAIL) {
> 			Dimension d = GetSpriteSize(SPR_BLOT);
> 			uint offset = this->IsWidgetLowered(WID_RAT_POLYRAIL) ? 1 : 0;
> 			DrawSprite(SPR_BLOT, PALETTE_TO_GREY, (r.left + r.right - d.width) / 2 + offset, (r.top + r.bottom - d.height) / 2 + offset);
> 		}
> 	}
> 
526a643
> 		bool remove_on_ctrl = true;  /* do not check ctrl for hotkeys */
554a672,703
> 			case WID_RAT_POLYRAIL: {
> 				bool was_snap = GetRailSnapMode() == RSM_SNAP_TO_RAIL;
> 				bool was_open = this->IsWidgetLowered(WID_RAT_POLYRAIL);
> 				bool do_snap;
> 				bool do_open;
> 				/* "polyrail" hotkey     - activate polyline tool in snapping mode, close the tool if snapping mode is already active
> 				 * "new_polyrail" hotkey - activate polyline tool in non-snapping (new line) mode, close the tool if non-snapping mode is already active
> 				 * button ctrl-clicking  - switch between snapping and non-snapping modes, open the tool in non-snapping mode if it is closed
> 				 * button clicking       - open the tool in non-snapping mode, close the tool if it is opened */
> 				if (this->last_user_action == HOTKEY_POLYRAIL) {
> 					do_snap = true;
> 					do_open = !was_open || !was_snap;
> 				} else if (this->last_user_action == HOTKEY_NEW_POLYRAIL) {
> 					do_snap = false;
> 					do_open = !was_open || was_snap;
> 				} else if (_ctrl_pressed) {
> 					do_snap = !was_open || !was_snap;
> 					do_open = true;
> 				} else {
> 					do_snap = false;
> 					do_open = !was_open;
> 				}
> 				/* close/open the tool */
> 				if (was_open != do_open) HandlePlacePushButton(this, WID_RAT_POLYRAIL, GetRailTypeInfo(railtype)->cursor.autorail, HT_RAIL | HT_POLY);
> 				/* set snapping mode */
> 				if (do_open) SetRailSnapMode(do_snap ? RSM_SNAP_TO_RAIL : RSM_NO_SNAP);
> 
> 				this->last_user_action = WID_RAT_POLYRAIL;
> 				if (was_open == do_open) return; // prevent switching the "remove" button state
> 				break;
> 			}
> 
575,578c724,742
< 			case WID_RAT_BUILD_STATION:
< 				if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
< 					ShowStationBuilder(this);
< 					this->last_user_action = widget;
---
> 			case WID_RAT_BUILD_STATION: {
> 				bool dragdrop = (this->last_user_action == HOTKEY_BUILD_STATION_DRAGDROP);
> 
> 				if (dragdrop || this->last_user_action == HOTKEY_BUILD_STATION_SIZED) { /* hotkey */
> 					bool was_open = this->IsWidgetLowered(WID_RAT_BUILD_STATION);
> 					/* close the tool explicitly so it can be re-opened in different snapping mode */
> 					if (was_open) ResetObjectToPlace();
> 					if (!was_open || dragdrop != _settings_client.gui.station_dragdrop) {
> 						_settings_client.gui.station_dragdrop = dragdrop;
> 						if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT))
> 							ShowStationBuilder(this);
> 					}
> 					this->last_user_action = WID_RAT_BUILD_STATION;
> 					remove_on_ctrl = false;
> 				} else { /* button */
> 					if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
> 						ShowStationBuilder(this);
> 						this->last_user_action = WID_RAT_BUILD_STATION;
> 					}
580a745
> 			}
613c778
< 		if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
---
> 		if (_ctrl_pressed && remove_on_ctrl) RailToolbar_CtrlChanged(this);
617a783
> 		// EventState es;
618a785,799
> 
> 		switch (hotkey) {
> 			/* Indicate to the OnClick that the action comes from a hotkey rather
> 			 * then from a click and that the CTRL state should be ignored. */
> 			case HOTKEY_POLYRAIL:
> 			case HOTKEY_NEW_POLYRAIL:
> 				this->last_user_action = hotkey;
> 				return this->Window::OnHotkey(WID_RAT_POLYRAIL);
> 
> 			case HOTKEY_BUILD_STATION_SIZED:
> 			case HOTKEY_BUILD_STATION_DRAGDROP:
> 				this->last_user_action = hotkey;
> 				return this->Window::OnHotkey(WID_RAT_BUILD_STATION);
> 		}
> 
623a805
> 		DiagDirection ddir;
641a824
> 			case WID_RAT_POLYRAIL:
650c833,837
< 				DoCommandP(tile, _cur_railtype, _build_depot_direction,
---
> 				ddir = _build_depot_direction;
> 				if (ddir == DIAGDIR_NW + 1) {
> 					ddir = AutodetectRailObjectDirection(tile);
> 				}
> 				DoCommandP(tile, _cur_railtype, ddir,
652a840,841
> 				if (_ctrl_pressed == _settings_client.gui.persistent_depottools)
> 					ResetObjectToPlace();
788a978,979
> const uint16 _railtoolbar_polyrail_keys[] = {'5' | WKC_CTRL, 'A' | WKC_CTRL | WKC_GLOBAL_HOTKEY, 0};
> const uint16 _railtoolbar_new_poly_keys[] = {'5' | WKC_CTRL | WKC_SHIFT, 'A' | WKC_CTRL | WKC_SHIFT | WKC_GLOBAL_HOTKEY, 0};
795a987,988
> 	Hotkey(_railtoolbar_polyrail_keys, "polyrail", HOTKEY_POLYRAIL),
> 	Hotkey(_railtoolbar_new_poly_keys, "new_polyrail", HOTKEY_NEW_POLYRAIL),
798a992,993
> 	Hotkey((uint16)0, "station_sized", HOTKEY_BUILD_STATION_SIZED),  // has to go before station hotkey to override it
> 	Hotkey((uint16)0, "station_dragdrop", HOTKEY_BUILD_STATION_DRAGDROP),
825a1021,1022
> 		NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_POLYRAIL),
> 						SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_POLYRAIL),
1707c1904,1911
< 		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
---
> 		switch (widget) {
> 			case WID_BRAD_DEPOT_NE:
> 			case WID_BRAD_DEPOT_SE:
> 			case WID_BRAD_DEPOT_SW:
> 			case WID_BRAD_DEPOT_NW:
> 				size->width  = ScaleGUITrad(64) + 2;
> 				size->height = ScaleGUITrad(48) + 2;
> 				break;
1709,1710c1913,1916
< 		size->width  = ScaleGUITrad(64) + 2;
< 		size->height = ScaleGUITrad(48) + 2;
---
> 			case WID_BRAD_DEPOT_AUTO:
> 				size->width  = ScaleGUITrad(128) + 6;
> 				break;
> 		}
1726a1933
> 			case WID_BRAD_DEPOT_AUTO:
1763a1971,1976
> 		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 		NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_AUTO), SetMinimalSize(134, 12), SetDataTip(STR_STATION_BUILD_ORIENTATION_AUTO, STR_BUILD_DEPOT_TRAIN_ORIENTATION_AUTO_TOOLTIP),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
1884c2097
< 	_build_depot_direction = DIAGDIR_NW;
---
> 	_build_depot_direction = (DiagDirection)(DIAGDIR_NW + 1);
Only in cmclient/src: rev.cpp
diff -r -B -X .diff-exclude vanilla/src/rev.cpp.in cmclient/src/rev.cpp.in
40c40
< const char _openttd_revision[] = "!!VERSION!!";
---
> const char _openttd_revision[] = "1.9.3-RC1";
53c53
< const char _openttd_revision_hash[] = "!!GITHASH!!";
---
> const char _openttd_revision_hash[] = "e5021a0587c504df89a3e549544f3c9b78e8a4bd";
63c63
< const byte _openttd_revision_modified = !!MODIFIED!!;
---
> const byte _openttd_revision_modified = 0;
70c70
< const byte _openttd_revision_tagged = !!ISTAG!!;
---
> const byte _openttd_revision_tagged = 1;
85c85
< const uint32 _openttd_newgrf_version = 1 << 28 | 9 << 24 | 3 << 20 | !!ISSTABLETAG!! << 19 | 28004;
---
> const uint32 _openttd_newgrf_version = 1 << 28 | 9 << 24 | 3 << 20 | 0 << 19 | 28004;
91c91
< extern const char morphos_versions_tag[] = "$VER: OpenTTD !!VERSION!! (!!DATE!!) OpenTTD Team [MorphOS, PowerPC]";
---
> extern const char morphos_versions_tag[] = "$VER: OpenTTD 1.9.3-RC1 (08.09.19) OpenTTD Team [MorphOS, PowerPC]";
diff -r -B -X .diff-exclude vanilla/src/road_cmd.cpp cmclient/src/road_cmd.cpp
810c810
< static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
---
> bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
diff -r -B -X .diff-exclude vanilla/src/road_func.h cmclient/src/road_func.h
183a184,185
> bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir);
> 
diff -r -B -X .diff-exclude vanilla/src/road_gui.cpp cmclient/src/road_gui.cpp
13a14
> #include "cmd_helper.h"
14a16
> #include "station_func.h"
32c34
< 
---
> #include "industry.h"
215a218,317
> 
> static RoadBits FindRoadsToConnect(TileIndex tile) {
> 	RoadBits bits = ROAD_NONE;
> 	DiagDirection ddir;
> 	// Prioritize roadbits that head in this direction
> 	for (ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
> 		TileIndex cur_tile = TileAddByDiagDir(tile, ddir);
> 		if (GetAnyRoadBits(cur_tile, _cur_roadtype, true) &
> 			DiagDirToRoadBits(ReverseDiagDir(ddir)))
> 		{
> 			bits |= DiagDirToRoadBits(ddir);
> 		}
> 	}
> 	if (bits != ROAD_NONE) {
> 		return bits;
> 	}
> 	// Try to connect to any road passing by
> 	for (ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
> 		TileIndex cur_tile = TileAddByDiagDir(tile, ddir);
> 		if (HasTileRoadType(cur_tile, _cur_roadtype) && (GetTileType(cur_tile) == MP_ROAD) &&
> 				(GetRoadTileType(cur_tile) == ROAD_TILE_NORMAL)) {
> 			bits |= DiagDirToRoadBits(ddir);
> 		}
> 	}
> 	return bits;
> }
> 
> static DiagDirection RoadBitsToDiagDir(RoadBits bits) {
> 	if (bits < ROAD_SE) {
> 		return bits == ROAD_NW ? DIAGDIR_NW : DIAGDIR_SW;
> 	}
> 	return bits == ROAD_SE ? DIAGDIR_SE : DIAGDIR_NE;
> }
> 
> static DiagDirection TileFractCoordsToDiagDir() {
> 	bool diag = (_tile_fract_coords.x + _tile_fract_coords.y) < 16;
> 	if (_tile_fract_coords.x < _tile_fract_coords.y) {
> 		return diag ? DIAGDIR_NE : DIAGDIR_SE;
> 	}
> 	return diag ? DIAGDIR_NW : DIAGDIR_SW;
> }
> /*
>  * Selects orientation for road object (depot, terminal station)
>  */
> static DiagDirection AutodetectRoadObjectDirection(TileIndex tile) {
> 	RoadBits bits = FindRoadsToConnect(tile);
> 	if (HasExactlyOneBit(bits)) {
> 		return RoadBitsToDiagDir(bits);
> 	}
> 	if (bits == ROAD_NONE){
> 		bits = ROAD_ALL;
> 	}
> 	RoadBits frac_bits = DiagDirToRoadBits(TileFractCoordsToDiagDir());
> 	if (HasExactlyOneBit(frac_bits & bits)) {
> 		return RoadBitsToDiagDir(frac_bits & bits);
> 	}
> 	frac_bits |= MirrorRoadBits(frac_bits);
> 	if (HasExactlyOneBit(frac_bits & bits)) {
> 		return RoadBitsToDiagDir(frac_bits & bits);
> 	}
> 	for (DiagDirection ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
> 		if (DiagDirToRoadBits(ddir) & bits) {
> 			return ddir;
> 		}
> 	}
> 	NOT_REACHED();
> }
> 
> static bool CheckDriveThroughRoadStopDirection(TileArea area, RoadBits r) {
> 	TILE_AREA_LOOP(tile, area) {
> 		if (GetTileType(tile) != MP_ROAD) continue;
> 		if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) continue;
> 		if (GetAllRoadBits(tile) & ~r) return false;
> 	}
> 	return true;
> }
> 
> 
> /*
>  * Automaticaly selects direction to use for road stop.
>  * @param area road stop area
>  * @return selected direction
>  */
> static DiagDirection AutodetectDriveThroughRoadStopDirection(TileArea area) {
> 	bool se_suits, ne_suits;
> 
> 	// Check which direction is available
> 	// If both are not use SE, building will fail anyway
> 	se_suits = CheckDriveThroughRoadStopDirection(area, ROAD_Y);
> 	ne_suits = CheckDriveThroughRoadStopDirection(area, ROAD_X);
> 	if (!ne_suits) return DIAGDIR_SE;
> 	if (!se_suits) return DIAGDIR_NE;
> 
> 	// Build station along the longer direction
> 	if (area.w > area.h) return DIAGDIR_NE;
> 	if (area.w < area.h) return DIAGDIR_SE;
> 
> 	return AutodetectRoadObjectDirection(area.tile);
> }
> 
229a332
> 	TileArea ta(start_tile, end_tile);
232,233c335,353
< 		SetBit(p2, 1); // It's a drive-through stop.
< 		ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
---
> 		if (ddir < DIAGDIR_END + 2) {
> 			SetBit(p2, 1); // It's a drive-through stop.
> 			ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
> 			// When placed on road autorotate anyway
> 			if (ddir == DIAGDIR_SE) {
> 				if (!CheckDriveThroughRoadStopDirection(ta, ROAD_Y))
> 					ddir = DIAGDIR_NE;
> 			} else {
> 				if (!CheckDriveThroughRoadStopDirection(ta, ROAD_X))
> 					ddir = DIAGDIR_SE;
> 			}
> 		}
> 		else if (ddir == DIAGDIR_END + 2) {
> 			ddir = AutodetectRoadObjectDirection(start_tile);
> 		}
> 		else if (ddir == DIAGDIR_END + 3) {
> 			SetBit(p2, 1); // It's a drive-through stop.
> 			ddir = AutodetectDriveThroughRoadStopDirection(ta);
> 		}
237d356
< 	TileArea ta(start_tile, end_tile);
302,303c421,422
< 	for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
< 		if (w->IsWidgetLowered(i)) {
---
> 	for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_FULLROAD; i++) {
> 		if (w->GetWidget<NWidgetCore>(i) && w->IsWidgetLowered(i)) {
386a506
> 			case WID_ROT_FULLROAD:
407a528,537
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		if (widget == WID_ROT_FULLROAD) {
> 			Dimension d = GetSpriteSize(SPR_BLOT);
> 			uint offset = this->IsWidgetLowered(WID_ROT_FULLROAD) ? 1 : 0;
> 			DrawSprite(SPR_BLOT, PALETTE_TO_GREY, (r.left + r.right - d.width) / 2 + offset, (r.top + r.bottom - d.height) / 2 + offset);
> 		}
> 	}
> 
> 
409a540
> 		static bool fullroad_warned = false;
427a559,568
> 			case WID_ROT_FULLROAD:
> 				HandlePlacePushButton(this, WID_ROT_FULLROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, HT_RECT);
> 				if (!fullroad_warned) {
> 					ShowGoalQuestion(0, 2 /* WARNING */, 2 /* OK */, "Full-tile autoroad tool is deprecated and will be removed in next release.\n Use regular autoroad tool instead.");
> 					fullroad_warned = true;
> 				}
> 
> 				this->last_started_action = widget;
> 				break;
> 
495a637
> 		DiagDirection ddir;
517a660,666
> 			case WID_ROT_FULLROAD:
> 				_place_road_flag = RF_NONE;
> 				if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
> 				if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
> 				VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_FULLROAD);
> 				break;
> 
523c672,676
< 				DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0,
---
> 				ddir = _road_depot_orientation;
> 				if (ddir == DIAGDIR_NW + 1) {
> 					ddir = AutodetectRoadObjectDirection(tile);
> 				}
> 				DoCommandP(tile, _cur_roadtype << 2 | ddir, 0,
524a678,679
> 				if (_ctrl_pressed == _settings_client.gui.persistent_depottools)
> 					ResetObjectToPlace();
582a738
> 			case DDSP_PLACE_FULLROAD:
607a764,777
> 	void TryToRemoveExtraRoadBits(TileIndex tile, RoadBits &rb) {
> 		for (DiagDirection dir = DIAGDIR_BEGIN; dir != DIAGDIR_END; dir++) {
> 			RoadBits dir_rb = DiagDirToRoadBits(dir);
> 			if (!(rb & dir_rb)) continue;
> 			if (CanConnectToRoad(tile, _cur_roadtype, dir)) continue;
> 			DoCommandP(tile, tile,
> 			    (dir_rb == ROAD_NW || dir_rb == ROAD_NE ? 0 : 3) |
> 			    (dir_rb & ROAD_X ? 0 : 4) |
> 			    (_cur_roadtype << 3),
> 			    CMD_REMOVE_LONG_ROAD);
> 			rb &= ~dir_rb;
> 		}
> 	}
> 
636a807,830
> 				case DDSP_PLACE_FULLROAD:
> 					if (start_tile == end_tile || _remove_button_clicked) {
> 						_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
> 						DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
> 							_remove_button_clicked ?
> 							CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
> 							CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound_SPLAT_OTHER);
> 					} else {
> 						_place_road_flag &= RF_DIR_Y;
> 						RoadBits road_dir = _place_road_flag ? ROAD_Y : ROAD_X;
> 						// if (start_tile > end_tile) Swap(start_tile, end_tile);
> 						RoadBits start_extra_rb = GetAnyRoadBits(start_tile, _cur_roadtype, false) & ~road_dir;
> 						RoadBits end_extra_rb = GetAnyRoadBits(end_tile, _cur_roadtype, false) & ~road_dir;
> 						this->TryToRemoveExtraRoadBits(start_tile, start_extra_rb);
> 						this->TryToRemoveExtraRoadBits(end_tile, end_extra_rb);
> 						if ((bool)start_extra_rb != (start_tile > end_tile)) _place_road_flag |= RF_START_HALFROAD_Y;
> 						if (!end_extra_rb != (start_tile > end_tile)) _place_road_flag |= RF_END_HALFROAD_Y;
> 						DoCommandP(start_tile, end_tile,
> 							_place_road_flag | (_cur_roadtype << 3) |
> 							(_one_way_button_clicked << 5) | (1 << 6),
> 							CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound_SPLAT_OTHER);
> 					}
> 					break;
> 
714a909
> 	Hotkey('9', "fullroad", WID_ROT_FULLROAD),
746a942,943
> 		NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_FULLROAD),
> 						SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_FULLROAD),
873c1070
< 			for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
---
> 			for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_AUTO; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
881,884c1078,1091
< 		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
< 
< 		size->width  = ScaleGUITrad(64) + 2;
< 		size->height = ScaleGUITrad(48) + 2;
---
> 		switch (widget) {
> 			case WID_BROD_DEPOT_NW:
> 			case WID_BROD_DEPOT_NE:
> 			case WID_BROD_DEPOT_SW:
> 			case WID_BROD_DEPOT_SE:
> 				size->width  = ScaleGUITrad(64) + 2;
> 				size->height = ScaleGUITrad(48) + 2;
> 				break;
> 			case WID_BROD_DEPOT_AUTO:
> 				size->width = ScaleGUITrad(128) + 6;
> 				break;
> 			default:
> 				break;
> 		}
900a1108
> 			case WID_BROD_DEPOT_AUTO:
939a1148,1153
> 		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 		NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_AUTO), SetMinimalSize(134, 12), SetDataTip(STR_STATION_BUILD_ORIENTATION_AUTO, STR_BUILD_DEPOT_ROAD_ORIENTATION_AUTO_TOOLTIP),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
964a1179,1181
> 		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation == (DiagDirection)(DIAGDIR_END + 2)) {
> 			_road_station_picker_orientation = (DiagDirection)(DIAGDIR_END + 3);
> 		}
967c1184
< 		for (uint i = (_cur_roadtype == ROADTYPE_TRAM ? WID_BROS_STATION_X : WID_BROS_STATION_NE); i < WID_BROS_LT_OFF; i++) {
---
> 		for (uint i = (_cur_roadtype == ROADTYPE_TRAM ? WID_BROS_STATION_X : WID_BROS_STATION_NE); i < WID_BROS_STATION_AUTO; i++) {
1013,1016c1230,1251
< 		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
< 
< 		size->width  = ScaleGUITrad(64) + 2;
< 		size->height = ScaleGUITrad(48) + 2;
---
> 		switch (widget) {
> 			case WID_BROS_STATION_NE:
> 			case WID_BROS_STATION_SE:
> 			case WID_BROS_STATION_SW:
> 			case WID_BROS_STATION_NW:
> 			case WID_BROS_STATION_X:
> 			case WID_BROS_STATION_Y:
> 				size->width  = ScaleGUITrad(64) + 2;
> 				size->height = ScaleGUITrad(48) + 2;
> 				break;
> 			case WID_BROS_STATION_AUTO:
> 				size->width  = ScaleGUITrad(128) + 6;
> 				break;
> 			case WID_BROS_STATION_XY_AUTO:
> 				if (_cur_roadtype == ROADTYPE_TRAM)
> 					size->width  = ScaleGUITrad(128) + 6;
> 				else
> 					size->width  = ScaleGUITrad(64) + 2;
> 				break;
> 			default:
> 				break;
> 		}
1035a1271,1272
> 			case WID_BROS_STATION_AUTO:
> 			case WID_BROS_STATION_XY_AUTO:
1086a1324,1330
> 		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 		NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_STATION_AUTO), SetMinimalSize(134, 12), SetDataTip(STR_STATION_BUILD_ORIENTATION_AUTO, STR_STATION_BUILD_ORIENTATION_AUTO_TOOLTIP),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_STATION_XY_AUTO), SetMinimalSize(66, 12), SetDataTip(STR_STATION_BUILD_ORIENTATION_AUTO, STR_STATION_BUILD_ORIENTATION_AUTO_TOOLTIP),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
1124a1369,1374
> 		NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 		NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 			NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_STATION_XY_AUTO), SetMinimalSize(274, 12), SetDataTip(STR_STATION_BUILD_ORIENTATION_AUTO, STR_STATION_BUILD_ORIENTATION_AUTO_TOOLTIP),
> 			NWidget(NWID_SPACER), SetFill(1, 0),
> 		EndContainer(),
1127c1377
< 			NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
---
> 			NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(134, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
1156,1157c1406,1407
< 	_road_depot_orientation = DIAGDIR_NW;
< 	_road_station_picker_orientation = DIAGDIR_NW;
---
> 	_road_depot_orientation = (DiagDirection)(DIAGDIR_NW + 1);
> 	_road_station_picker_orientation = (DiagDirection)(DIAGDIR_END + 3);
diff -r -B -X .diff-exclude vanilla/src/roadveh_cmd.cpp cmclient/src/roadveh_cmd.cpp
1591c1591
< 	PerformanceAccumulator framerate(PFE_GL_ROADVEHS);
---
> 	// PerformanceAccumulator framerate(PFE_GL_ROADVEHS);
diff -r -B -X .diff-exclude vanilla/src/saveload/afterload.cpp cmclient/src/saveload/afterload.cpp
59a60,62
> #include "../story_base.h"
> #include "../game/game_text.hpp"
> #include "../table/control_codes.h"
519a523,565
> extern GameStrings *_current_data;
> 
> void AfterLoadFindBTProCBInfo() {
> 	if (_current_data == NULL) return;
> 	StoryPageElement *se;
> 
> 	char buf[15];
> 	char *p = buf;
> 	int pn;
> 	p += Utf8Encode(p, SCC_ENCODED);
> 	for (uint i = 0; i < _current_data->raw_strings.Length(); i++) {
> 		auto ls = _current_data->raw_strings[i];
> 		if (!ls) continue;
> 		int string_id = 0;
> 		for (uint j = 0; j < ls->lines.Length(); j++) {
> 			auto s = ls->lines[j];
> 			if (!s || *s == ';' || *s == '#' || *s == ' ' || *s == '\0') continue;
> 			if (strncmp(s, "STR_TOWN_CLAIMED_CARGOS", strlen("STR_TOWN_CLAIMED_CARGOS")) == 0 ||
> 					strncmp(s, "STR_TOWN_CARGOS_NEEDED_CB", strlen("STR_TOWN_CARGOS_NEEDED_CB")) == 0) {
> 				pn = p - buf + seprintf(p, lastof(buf), "%X:", string_id);
> 				bool with_decay = (strncmp(s, "STR_TOWN_CLAIMED_CARGOS_DECAY",
> 					strlen("STR_TOWN_CLAIMED_CARGOS_DECAY")) == 0);
> 				FOR_ALL_STORY_PAGE_ELEMENTS(se) {
> 					// DEBUG(misc, 0, "SE: %s", se->text);
> 					if (!se->text || strncmp(se->text, buf, pn) != 0) continue;
> 					uint req, cargomask, from, decay=0;
> 					// DEBUG(misc, 0, "BINGO %s", se->text);
> 					if (with_decay) {
> 						sscanf(se->text + pn, "%X:%X:%X:%X", &req, &cargomask, &from, &decay);
> 				 	} else {
> 						sscanf(se->text + pn, "%X:%X:%X", &req, &cargomask, &from);
> 					}
> 					uint cargo_id = FindFirstBit(cargomask);
> 					// DEBUG(misc, 0, "PARSED %u %u %u %u", req, cargo_id, from, decay);
> 					if (!CB_Enabled()) CB_SetCB(true);
> 					CB_SetRequirements(cargo_id, req, from, decay);
> 				}
> 			}
> 			string_id++;
> 		}
> 	}
> }
> 
3117a3164
> 	AfterLoadFindBTProCBInfo();
Only in cmclient/src/saveload: citymania_sl.cpp
Only in cmclient/src/saveload: citymania_sl.h
diff -r -B -X .diff-exclude vanilla/src/saveload/storage_sl.cpp cmclient/src/saveload/storage_sl.cpp
12a13
> #include "../debug.h"
13a15
> #include "citymania_sl.h"
17a20,22
> // Luukland_Citybuilder grf id actually
> #define CITYMANIA_GRFID 0x534B0501U
> 
25a31,39
> // static void hexdump(uint8 *data) {
> // 	uint i;
> // 	for (i = 0; i < 20; i++) {
> // 		if (i) fprintf(stderr, " : ");
> // 		fprintf(stderr, "%02x", data[i]);
> // 	}
> // 	fprintf(stderr, i >= 20 ? " ...\n" : "\n");
> // }
> 
30a45,53
> 	/*
> 		CITYMANIA_GRFID is used to hide extra data in persitant storages.
> 		To save a bit of memory we only keep at most one PS with this
> 		grfid and it is later discarded on save.
> 	*/
> 	PersistentStorage *ps = NULL;
> 	u8vector cmdata;
> 	uint chunk_size = IsSavegameVersionBefore(SLV_EXTEND_PERSISTENT_STORAGE) ? 64 : 1024;
> 	DEBUG(sl, 2, "CityMania savegame data chunk size: %u", chunk_size);
32,33c55,58
< 		assert(PersistentStorage::CanAllocateItem());
< 		PersistentStorage *ps = new (index) PersistentStorage(0, 0, 0);
---
> 		if (ps == NULL) {
> 			assert(PersistentStorage::CanAllocateItem());
> 			ps = new (index) PersistentStorage(0, 0, 0);
> 		}
34a60,94
> 
> 		if (ps->grfid == CITYMANIA_GRFID) {
> 			uint8 *data = (uint8 *)(ps->storage);
> 			cmdata.insert(cmdata.end(), data, data + chunk_size);
> 		} else {
> 			ps = NULL;
> 		}
> 	}
> 
> 	CM_DecodeData(cmdata);
> }
> 
> static void Save_CMDataAsPSAC() {
> 	uint32 grfid = CITYMANIA_GRFID;
> 	u8vector data = CM_EncodeData();
> 	int n_chunks = (data.size() + 1023) / 1024;
> 	data.resize(n_chunks * 1024);
> 	uint8 *ptr = &data[0];
> 	SaveLoadGlobVarList _desc[] = {
> 		SLEG_CONDVAR(grfid, SLE_UINT32, SLV_6, SL_MAX_VERSION),
> 		SLEG_CONDARR(*ptr,  SLE_UINT32, 256, SLV_EXTEND_PERSISTENT_STORAGE, SL_MAX_VERSION),
> 		SLEG_END()
> 	};
> 
>     uint index = 0;
>     PersistentStorage *ps;
>     FOR_ALL_STORAGES(ps) {
>         if (ps->grfid != CITYMANIA_GRFID)
>             index = max(index, ps->index + 1);
>     }
> 
> 	for (int i = 0; i < n_chunks; i++, ptr += 1024) {
> 		_desc[1].address = (void *)ptr;
> 		SlSetArrayIndex(index + i);
> 		SlGlobList(_desc);
44a104,106
> 		if (ps->grfid == CITYMANIA_GRFID) {
> 			continue;
> 		}
48a111,112
> 
> 	Save_CMDataAsPSAC();
diff -r -B -X .diff-exclude vanilla/src/saveload/town_sl.cpp cmclient/src/saveload/town_sl.cpp
35a36
> 		town->cache.potential_pop = 0;
44a46,47
> 		else town->houses_construction++;
> 		town->cache.potential_pop += HouseSpec::Get(house_id)->population;
diff -r -B -X .diff-exclude vanilla/src/script/api/game/game_window.hpp.sq cmclient/src/script/api/game/game_window.hpp.sq
932a933
> 	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RAT_POLYRAIL,                          "WID_RAT_POLYRAIL");
diff -r -B -X .diff-exclude vanilla/src/script/api/script_window.hpp cmclient/src/script/api/script_window.hpp
2030a2031
> 		WID_RAT_POLYRAIL                             = ::WID_RAT_POLYRAIL,                             ///< Polyline rail tool.
diff -r -B -X .diff-exclude vanilla/src/settings_gui.cpp cmclient/src/settings_gui.cpp
38a39
> #include "hotkeys.h"
608a610,611
> 
> 	static HotkeyList hotkeys;
694a698,710
> static EventState GameOptionsWindowGlobalHotkeys(int hotkey) {
> 	if (!ToggleFullScreen(!_fullscreen)) {
> 		ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
> 	}
> 	return ES_HANDLED;
> }
> 
> static Hotkey game_options_hotkeys[] = {
> 	Hotkey((uint16)0, "toggle_fullscreen", WID_GO_FULLSCREEN_BUTTON),
> 	HOTKEY_LIST_END
> };
> HotkeyList GameOptionsWindow::hotkeys("game_options", game_options_hotkeys, GameOptionsWindowGlobalHotkeys);
> 
699c715,716
< 	_nested_game_options_widgets, lengthof(_nested_game_options_widgets)
---
> 	_nested_game_options_widgets, lengthof(_nested_game_options_widgets),
> 	&GameOptionsWindow::hotkeys
1565a1583,1586
> 				viewports->Add(new SettingEntry("gui.cb_distance_check"));
> 				viewports->Add(new SettingEntry("gui.old_depot_train_length_calc"));
> 				viewports->Add(new SettingEntry("gui.enable_extra_tooltips"));
> 				// viewports->Add(new SettingEntry("gui.polyrail_double_click"));
1572a1594
> 				construction->Add(new SettingEntry("gui.persistent_depottools"));
1585a1608,1609
> 			interface->Add(new SettingEntry("gui.powerfund_money"));
> 			interface->Add(new SettingEntry("gui.powerfund_houses"));
1601a1626
> 			advisors->Add(new SettingEntry("gui.runway_too_short_warn"));
1644a1670,1689
> 			/** Vehicle control page */
> 			SettingsPage *veh_control = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_CTRL));
> 			{
> 				veh_control->Add(new SettingEntry("gui.enable_ctrl_click_start_stop"));
> 				veh_control->Add(new SettingEntry("gui.new_nonstop"));
> 				veh_control->Add(new SettingEntry("gui.auto_noload_on_transfer"));
> 				veh_control->Add(new SettingEntry("gui.auto_noload_on_unloadall"));
> 			}
> 
> 			/** Order Shorcuts page */
> 			SettingsPage *orders = veh_control->Add(new SettingsPage(STR_CONFIG_SETTING_ORDER_SHORTCUTS));
> 			{
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_ctrl_lclick"));
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_shift_lclick"));
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_ctrlshift_lclick"));
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_alt_lclick"));
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_altshift_lclick"));
> 				orders->Add(new SettingEntry("gui.goto_shortcuts_altctrl_lclick"));
> 			}
> 
diff -r -B -X .diff-exclude vanilla/src/settings_type.h cmclient/src/settings_type.h
90a91,99
> 	bool   enable_ctrl_click_start_stop;     ///< allow ctrl+click to start or stop vehicles
> 	uint8  goto_shortcuts_ctrl_lclick;       ///< goto action shortcut CTRL+LEFT-CLICK
> 	uint8  goto_shortcuts_shift_lclick;      ///< goto action shortcut SHIFT+LEFT-CLICK
> 	uint8  goto_shortcuts_ctrlshift_lclick;  ///< goto action shortcut CTRL+SHIFT+LEFT-CLICK
> 	uint8  goto_shortcuts_alt_lclick;        ///< goto action shortcut ALT+LEFT-CLICK
> 	uint8  goto_shortcuts_altshift_lclick;   ///< goto action shortcut ALT+SHIFT+LEFT-CLICK
> 	uint8  goto_shortcuts_altctrl_lclick;    ///< goto action shortcut ALT+CTRL+LEFT-CLICK
> 	bool   auto_noload_on_transfer;          ///< automatically set no-loading when ordering to transfer all cargo
> 	bool   auto_noload_on_unloadall;         ///< automatically set no-loading when ordering to unload all cargo
143a153
> 	bool   persistent_depottools;            ///< keep the depot building tools active after usage
170a181,190
> 
> 	bool   old_depot_train_length_calc;      ///< display vehicle length in whole numbers - old style
> 	uint8  cb_distance_check;                ///< zoning cb distance
> 	bool   enable_extra_tooltips;            ///< enable extra tooltips when hovering over various elements
> 	bool   polyrail_double_click;            ///< finish polyrail with mouse double click
> 	bool   show_industry_forbidden_tiles;    ///< higlight areas where industry placement is forbidden regardless of terrain
> 	bool   runway_too_short_warn;            ///< warn about aircrafts using too short runways
> 
> 	uint32 powerfund_money;                  ///< minimum amount of money for powerfund to work
> 	uint16 powerfund_houses;                 ///< powerfunding maximum houses limit
diff -r -B -X .diff-exclude vanilla/src/ship_cmd.cpp cmclient/src/ship_cmd.cpp
796c796
< 	PerformanceAccumulator framerate(PFE_GL_SHIPS);
---
> 	// PerformanceAccumulator framerate(PFE_GL_SHIPS);
diff -r -B -X .diff-exclude vanilla/src/smallmap_gui.cpp cmclient/src/smallmap_gui.cpp
913c913
< 			DrawString(x, x + t->cache.sign.width_small, y, STR_SMALLMAP_TOWN);
---
> 			DrawString(x, x + t->cache.sign.width_small, y, t->larger_town ? STR_SMALLMAP_TOWN_LARGE : STR_SMALLMAP_TOWN);
diff -r -B -X .diff-exclude vanilla/src/station.cpp cmclient/src/station.cpp
21a22
> #include "town.h"
74a76,84
> 	Town *t;
> 	FOR_ALL_TOWNS(t) {
> 		// Using poiter comparison instead of cycling cargos
> 		if (t->ad_ref_goods_entry >= this->goods &&
> 		 	   t->ad_ref_goods_entry < this->goods + NUM_CARGO) {
> 		    t->ad_ref_goods_entry = NULL;
> 		}
> 	}
> 
diff -r -B -X .diff-exclude vanilla/src/station_gui.cpp cmclient/src/station_gui.cpp
1282a1283
> 	int ratings_list_y = 0;             ///< Y coordinate of first line in station ratings panel.
1814c1815
< 	int DrawCargoRatings(const Rect &r) const
---
> 	int DrawCargoRatings(const Rect &r)
1827a1829
> 		this->ratings_list_y = y;
2060a2063,2084
> 	virtual void OnHover(Point pt, int widget)
> 	{
> 		if (widget != WID_SV_ACCEPT_RATING_LIST ||
> 		    	this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON)
> 			Window::OnHover(pt, widget);
> 
> 		int ofs_y = pt.y - this->ratings_list_y;
> 		if (ofs_y < 0) return;
> 
> 		const Station *st = Station::Get(this->window_number);
> 		const CargoSpec *cs;
> 		FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
> 			const GoodsEntry *ge = &st->goods[cs->Index()];
> 			if (!ge->HasRating()) continue;
> 			ofs_y -= FONT_HEIGHT_NORMAL;
> 			if (ofs_y < 0) {
> 				GuiShowStationRatingTooltip(this, st, cs);
> 				break;
> 			}
> 		}
> 	}
> 
2235c2259
< struct SelectStationWindow : Window {
---
> struct SelectStationWindow : WindowPopup {
2241c2265
< 		Window(desc),
---
> 		WindowPopup(desc, WPUT_WIDGET_RELATIVE),
2244a2269
> 		this->wpu_widget = WID_JS_PANEL;
diff -r -B -X .diff-exclude vanilla/src/table/settings.ini cmclient/src/table/settings.ini
3106a3107,3114
> var      = gui.persistent_depottools
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = false
> str      = STR_CONFIG_SETTING_PERSISTENT_DEPOTTOOLS
> strhelp  = STR_CONFIG_SETTING_PERSISTENT_DEPOTTOOLS_HELPTEXT
> cat      = SC_BASIC
> 
> [SDTC_BOOL]
3963a3972,4138
> 
> ; //MODGUI *********************************
> [SDTC_BOOL]
> var      = gui.enable_ctrl_click_start_stop
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = true
> str      = STR_CONFIG_SETTING_CTRL_ENABLE_CTRLCLICK_STARTSTOP
> 
> [SDTC_BOOL]
> var      = gui.auto_noload_on_transfer
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = true
> str      = STR_CONFIG_SETTING_AUTOSET_NOLOAD_ON_TRANSFER
> 
> [SDTC_BOOL]
> var      = gui.auto_noload_on_unloadall
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = false
> str      = STR_CONFIG_SETTING_AUTOSET_NOLOAD_ON_UNLOAD
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_ctrl_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 1
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLLCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_shift_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 0
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_SHIFTLCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_ctrlshift_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 0
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLSHIFTLCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_alt_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 0
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_ALTLCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_altshift_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 0
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_ALTSHIFTCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_VAR]
> var      = gui.goto_shortcuts_altctrl_lclick
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_MULTISTRING
> def      = 0
> min      = 0
> max      = 6
> interval = 1
> str      = STR_CONFIG_SETTING_CTRL_GOTOSHORTCUT_CTRLALTLCLICK
> strval   = STR_CONFIG_SETTING_CTRL_GOTOSHORTOPTS_NONE
> proc     = RedrawScreen
> cat      = SC_BASIC
> 
> [SDTC_BOOL]
> var      = gui.old_depot_train_length_calc
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = true
> str      = STR_OLD_DEPOT_TRAINT_LENGTH
> 
> [SDTC_VAR]
> var      = gui.cb_distance_check
> type     = SLE_UINT8
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = 25
> min      = 0
> max      = 100
> interval = 5
> str      = STR_CB_DISTANCE_CHECK
> strval   = STR_JUST_COMMA
> proc     = RedrawScreen
> 
> [SDTC_BOOL]
> var      = gui.enable_extra_tooltips
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = true
> str      = STR_CONFIG_SETTING_ENABLE_EXTRA_TOOLTIPS
> 
> [SDTC_BOOL]
> var      = gui.polyrail_double_click
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = false
> str      = STR_CONFIG_SETTING_POLYRAIL_DOUBLECLICK_TOOLTIPS
> 
> [SDTC_BOOL]
> var      = gui.show_industry_forbidden_tiles
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = false
> cat      = SC_BASIC
> 
> [SDTC_BOOL]
> var      = gui.runway_too_short_warn
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = true
> str      = STR_CONFIG_SETTING_WARN_IF_RUNWAY_IS_TOO_SHORT
> 
> [SDTC_VAR]
> var      = gui.powerfund_money
> type     = SLE_UINT
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> guiflags = SGF_CURRENCY
> def      = 200000
> min      = 0
> max      = 2000000
> str      = STR_CONFIG_SETTING_POWERFUND_MONEY
> strval   = STR_JUST_CURRENCY_LONG
> 
> [SDTC_VAR]
> var      = gui.powerfund_houses
> type     = SLE_UINT16
> flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
> def      = 10000
> min      = 0
> max      = 10000
> interval = 10
> str      = STR_CONFIG_SETTING_POWERFUND_HOUSES
> strval   = STR_JUST_COMMA
diff -r -B -X .diff-exclude vanilla/src/table/sprites.h cmclient/src/table/sprites.h
303a304,317
> /* zoning stuff */
> static const SpriteID SPR_INNER_HIGHLIGHT_BASE      = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT;
> static const SpriteID SPR_IMG_COMPANY_CARGO         = SPR_INNER_HIGHLIGHT_BASE + 19;
> static const SpriteID SPR_IMG_COMPANY_GOAL          = SPR_INNER_HIGHLIGHT_BASE + 20;
> static const SpriteID SPR_PALETTE_ZONING_RED        = SPR_INNER_HIGHLIGHT_BASE + 21;
> static const SpriteID SPR_PALETTE_ZONING_GREEN      = SPR_INNER_HIGHLIGHT_BASE + 22;
> static const SpriteID SPR_PALETTE_ZONING_BLACK      = SPR_INNER_HIGHLIGHT_BASE + 23;
> static const SpriteID SPR_PALETTE_ZONING_LIGHT_BLUE = SPR_INNER_HIGHLIGHT_BASE + 24;
> static const SpriteID SPR_PALETTE_ZONING_ORANGE     = SPR_INNER_HIGHLIGHT_BASE + 25;
> static const SpriteID SPR_PALETTE_ZONING_WHITE      = SPR_INNER_HIGHLIGHT_BASE + 26;
> static const SpriteID SPR_PALETTE_ZONING_YELLOW     = SPR_INNER_HIGHLIGHT_BASE + 27;
> static const SpriteID SPR_PALETTE_ZONING_PURPLE     = SPR_INNER_HIGHLIGHT_BASE + 28;
> static const SpriteID SPR_INNER_HIGHLIGHT_COUNT     = 29;
> 
305c319
< static const SpriteID SPR_NEWGRFS_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT;
---
> static const SpriteID SPR_NEWGRFS_BASE = SPR_INNER_HIGHLIGHT_BASE + SPR_INNER_HIGHLIGHT_COUNT;
diff -r -B -X .diff-exclude vanilla/src/terraform_gui.cpp cmclient/src/terraform_gui.cpp
120a121,177
> 		case DDSP_DEMOLISH_TREES:
> 			// loop through every tile and send a demolish command for each tree
> 			// orthogonal area
> 			TileIndex tree_start_tile, tree_recent_tile, prev_tile;
> 			tree_start_tile = tree_recent_tile = prev_tile = 0;
> 			if (!_ctrl_pressed) {
> 				OrthogonalTileArea square_area = OrthogonalTileArea(start_tile, end_tile);
> 				TILE_AREA_LOOP(curr_tile, square_area) {
> 					// if we're on a non-consecutive tile or we've hit a black-marked tile
> 					// safe tiles are: TREES or non-FIELD clear tiles (because they're expensive to demolish)
> 					if (tree_start_tile != 0 &&
> 							(curr_tile != prev_tile + 1 ||
> 							(!IsTileType(curr_tile, MP_TREES) && (!IsTileType(curr_tile, MP_CLEAR) || IsClearGround(curr_tile, CLEAR_FIELDS))))) {
> 						DoCommandP(tree_start_tile, tree_recent_tile, 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION);
> 						tree_start_tile = tree_recent_tile = 0;
> 					}
> 					// if current tile is a tree
> 					if (IsTileType(curr_tile, MP_TREES)) {
> 						if (tree_start_tile == 0) {
> 							tree_start_tile = curr_tile;
> 						}
> 						tree_recent_tile = curr_tile;
> 					}
> 					prev_tile = curr_tile;
> 				}
> 				// one last ride to flavortown
> 				if (tree_start_tile != 0) {
> 					DoCommandP(tree_start_tile, tree_recent_tile, 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION);
> 				}
> 			} else {  // diagonal area
> 				DiagonalTileArea diagonal_area = DiagonalTileArea(start_tile, end_tile);
> 				DIAGONAL_TILE_AREA_LOOP(curr_tile, diagonal_area) {
> 					// same as above but with a different criteria for consecutive tiles
> 					TileIndexDiffC tile_diff = TileIndexToTileIndexDiffC(curr_tile, prev_tile);
> 					// if we're on a non-consecutive tile or we've hit a black-marked tile
> 					// safe tiles are: TREES or non-FIELD clear tiles (because they're expensive to demolish)
> 					if (tree_start_tile != 0 &&
> 							(!((tile_diff.x == 1 && tile_diff.y == 1) || (tile_diff.x == -1 && tile_diff.y == -1)) ||
> 							(!IsTileType(curr_tile, MP_TREES) && (!IsTileType(curr_tile, MP_CLEAR) || IsClearGround(curr_tile, CLEAR_FIELDS))))) {
> 						DoCommandP(tree_start_tile, tree_recent_tile, 1, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION);
> 						tree_start_tile = tree_recent_tile = 0;
> 					}
> 					// if current tile is a tree
> 					if (IsTileType(curr_tile, MP_TREES)) {
> 						if (tree_start_tile == 0) {
> 							tree_start_tile = curr_tile;
> 						}
> 						tree_recent_tile = curr_tile;
> 					}
> 					prev_tile = curr_tile;
> 				}
> 				// one last ride to flavortown
> 				if (tree_start_tile != 0) {
> 					DoCommandP(tree_start_tile, tree_recent_tile, 1, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION);
> 				}
> 			}
> 			break;
167a225,245
> 	virtual void DrawWidget(const Rect &r, int widget) const
> 	{
> 		if (widget == WID_TT_DEMOLISH_TREES) {
> 			uint offset = this->IsWidgetLowered(WID_TT_DEMOLISH_TREES) ? 1 : 0;
> 			ZoomLevelByte temp_zoom;
> 			switch (_gui_zoom) {
> 				case ZOOM_LVL_NORMAL:
> 					temp_zoom = ZOOM_LVL_OUT_2X;
> 					break;
> 				case ZOOM_LVL_OUT_2X:
> 					temp_zoom = ZOOM_LVL_OUT_4X;
> 					break;
> 				case ZOOM_LVL_OUT_4X:
> 					temp_zoom = ZOOM_LVL_OUT_8X;
> 					break;
> 			}
> 			Dimension d = GetSpriteSize(SPR_IMG_PLANTTREES, (Point *)0, temp_zoom);
> 			DrawSprite(SPR_IMG_PLANTTREES, PAL_NONE, (r.left + r.right - d.width) / 2 + offset, (r.top + r.bottom - d.height) / 2 + offset, nullptr, temp_zoom);
> 		}
> 	}
> 
199a278,282
> 			case WID_TT_DEMOLISH_TREES: // Demolish aka dynamite button
> 				HandlePlacePushButton(this, WID_TT_DEMOLISH_TREES, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
> 				this->last_user_action = widget;
> 				break;
> 
240a324,327
> 			case WID_TT_DEMOLISH_TREES: // Demolish trees only
> 				VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_TREES);
> 				break;
> 
270a358
> 				case DDSP_DEMOLISH_TREES:
305a394
> 	Hotkey('D' | WKC_CTRL | WKC_GLOBAL_HOTKEY, "treedozer", WID_TT_DEMOLISH_TREES),
331a421,422
>         NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_DEMOLISH_TREES), SetMinimalSize(22, 22),
> 								SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_TREES),
diff -r -B -X .diff-exclude vanilla/src/tilearea_type.h cmclient/src/tilearea_type.h
233a234,235
> #define DIAGONAL_TILE_AREA_LOOP(var, ta) for (DiagonalTileIterator var(ta); var != INVALID_TILE; ++var)
> 
diff -r -B -X .diff-exclude vanilla/src/tile_cmd.h cmclient/src/tile_cmd.h
67a68
> 	uint16 population;
diff -r -B -X .diff-exclude vanilla/src/tilehighlight_func.h cmclient/src/tilehighlight_func.h
15a16
> #include "tilearea_type.h"
16a18,19
> #include "track_type.h"
> #include "industry_type.h"
31a35,43
> 
> void SetIndustryForbiddenTilesHighlight(IndustryType type);
> 
> RailSnapMode GetRailSnapMode();
> void SetRailSnapMode(RailSnapMode mode);
> 
> void StoreRailPlacementEndpoints(TileIndex start_tile, TileIndex end_tile, Track start_track, bool bidirectional = true);
> void StoreRailStationPlacementEndpoints(const TileArea &ta, Axis station_axis);
> void ResetRailPlacementEndpoints();
diff -r -B -X .diff-exclude vanilla/src/tilehighlight_type.h cmclient/src/tilehighlight_type.h
30a31
> 	HT_POLY      = 0x400, ///< polyline mode; connect highlighted track with previous one
45a47,52
> /** Methods of rail track snapping. */
> enum RailSnapMode {
> 	RSM_NO_SNAP,      ///< Not snapping.
> 	RSM_SNAP_TO_TILE, ///< Snap to a tile.
> 	RSM_SNAP_TO_RAIL, ///< Snap to other rail tracks.
> };
56a64
> 	Point new_offs;      ///< New value for \a offs; used to determine whether to redraw the selection.
61a70,72
> 	Point selstart2;     ///< The location where the second segment of a polyline track starts.
> 	Point selend2;       ///< The location where the second segment of a polyline track ends.
> 	HighLightStyle dir2; ///< Direction of the second segment of a polyline track, HT_DIR_END if second segment is not selected. HT_LINE drawstyle.
diff -r -B -X .diff-exclude vanilla/src/toolbar_gui.cpp cmclient/src/toolbar_gui.cpp
57a58,61
> #include "cargo_table_gui.h"
> #include "object_type.h"
> #include "zoning.h"
> #include "watch_gui.h"
81a86
> 	CBF_BUILD_HQ,
89c94
<  */
---
>  */ /*
115c120
< };
---
> };*/
274a280,291
> /* hq hotkey */
> static CallBackFunction BuildCompanyHQ(){
> 	if (_last_started_action == CBF_BUILD_HQ) {
> 		ResetObjectToPlace();
> 		return CBF_NONE;
> 	} else {
> 		SetObjectToPlace(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, WC_MAIN_TOOLBAR, 0);
> 		SetTileSelectSize(2, 2);
> 		return CBF_BUILD_HQ;
> 	}
> }
> 
307a325
> 	OME_ZONING,
335a354
> 	*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_ZONING,                   OME_ZONING, false);
365a385
> 		case OME_ZONING:               ShowZoningToolbar();                             break;
600a621,651
> /* --- CARGOS button menu --- */
> 
> static CallBackFunction ToolbarCargosClick(Window *w)
> {
> 	PopupMainCompanyToolbMenu(w, WID_TN_CARGOS);
> 	return CBF_NONE;
> }
> 
> static CallBackFunction MenuClickCargos(int index)
> {
> 	ShowCompanyCargos((CompanyID)index);
> 	return CBF_NONE;
> }
> 
> /* --- WATCH button menu --- */
> 
> static CallBackFunction ToolbarWatchClick(Window *w)
> {
> 	PopupMainCompanyToolbMenu(w, WID_TN_WATCH);
> 	return CBF_NONE;
> }
> 
> static CallBackFunction MenuClickWatch(int index)
> {
> 	if(Company::IsValidID((CompanyID)index)){
> 		ShowWatchWindow((CompanyID)index, 0);
> 	}
> 	else ShowWatchWindow(INVALID_COMPANY, 0);
> 	return CBF_NONE;
> }
> 
1062c1113
< 	PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 13 : 10);
---
> 	PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 14 : 10);
1157c1208,1214
< 		case  0: return PlaceLandBlockInfo();
---
> 		case 0: return PlaceLandBlockInfo();
> 		case 1:
> 			extern bool _novahost;
> 			if (_networking && _novahost){
> 				ShowCommandsToolbar();
> 			}
> 			break;
1168a1226
> 		case 13: ShowLoginWindow();                break;
1301a1360
> 	MenuClickCargos,      // 8.5
1304a1364
> 	MenuClickWatch,       // 11.5
1762a1823
> 			WID_TN_CARGOS,
1765a1827
> 			WID_TN_WATCH,
1927a1990
> 	ToolbarCargosClick,
1930a1994
> 	ToolbarWatchClick,
1989a2054,2062
> 	MTHK_BUILD_HQ,
> 	MTHK_COMMANDS_GUI,
> 	MTHK_CARGOTABLE,
> 	MTHK_TREES,
> 	MTHK_ZONING,
> 	MTHK_LOGINWINDOW,
> 	MTHK_SETTINGS_ADV,
> 	MTHK_NEWGRF,
> 	MTHK_LANDINFO,
2022c2095
< 		this->SetWidgetsDisabledState(Company::GetNumItems() == 0, WID_TN_STATIONS, WID_TN_FINANCES, WID_TN_TRAINS, WID_TN_ROADVEHS, WID_TN_SHIPS, WID_TN_AIRCRAFT, WIDGET_LIST_END);
---
> 		this->SetWidgetsDisabledState(Company::GetNumItems() == 0, WID_TN_STATIONS, WID_TN_FINANCES, WID_TN_CARGOS, WID_TN_WATCH, WID_TN_TRAINS, WID_TN_ROADVEHS, WID_TN_SHIPS, WID_TN_AIRCRAFT, WIDGET_LIST_END);
2032a2106,2113
> 	virtual void DrawWidget(const Rect &r, int widget) const {
> 		if (widget == WID_TN_WATCH) {
> 			Dimension d = GetSpriteSize(SPR_CENTRE_VIEW_VEHICLE);
> 			uint offset = this->IsWidgetLowered(WID_TN_WATCH) ? 1 : 0;
> 			DrawSprite(SPR_CENTRE_VIEW_VEHICLE, PAL_NONE, (r.left + r.right - d.width) / 2 + offset, (r.top + r.bottom - d.height) / 2 + offset);
> 		}
> 	}
> 
2080c2161
< 			case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
---
> 			case MTHK_CHEATS: ShowCheatWindow(); break;
2084a2166
> 			case MTHK_COMMANDS_GUI: extern bool _novahost; if (_networking && _novahost){ ShowCommandsToolbar(); } break;
2085a2168,2170
> 			case MTHK_BUILD_HQ: if(_current_company != COMPANY_SPECTATOR){ _last_started_action = BuildCompanyHQ(); } break;
> 			case MTHK_CARGOTABLE: if(_current_company != COMPANY_SPECTATOR){ ShowCompanyCargos(_current_company); } break;
> 			case MTHK_TREES: if(_current_company != COMPANY_SPECTATOR){ BuildTreesWindow(); } break;
2086a2172,2176
> 			case MTHK_ZONING: ShowZoningToolbar(); break;
> 			case MTHK_LOGINWINDOW: ShowLoginWindow(); break;
> 			case MTHK_SETTINGS_ADV: ShowGameSettings(); break;
> 			case MTHK_NEWGRF: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); break;
> 			case MTHK_LANDINFO: _last_started_action = PlaceLandBlockInfo(); break;
2091a2182,2199
> 	virtual void BuildTreesWindow(){
> 		ShowBuildTreesToolbar();
> 		Window *w = FindWindowById(WC_BUILD_TREES, 0);
> 		if(w != NULL){
> 			if(w->IsWidgetLowered(WID_BT_TYPE_RANDOM)){
> 				w->RaiseWidget(WID_BT_TYPE_RANDOM);
> 				ResetObjectToPlace();
> 			}
> 			else{
> 				w->OnHotkey(WID_BT_TYPE_RANDOM);
> 			}
> 
> 		}
> 		/*
> 		if (!w->IsWidgetLowered(WID_BT_TYPE_RANDOM))
> 			w->OnClick(Point(), WID_BT_TYPE_RANDOM, 1);*/
> 	}
> 
2100c2208,2215
< 				ShowLandInfo(tile);
---
> 				VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_MEASURE);
> 				break;
> 
> 			case CBF_BUILD_HQ:
> 				if(DoCommandP(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS))){
> 					ResetObjectToPlace();
> 					this->RaiseButtons();
> 				}
2111a2227,2232
> 	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
> 	{
> 		VpSelectTilesWithMethod(pt.x, pt.y, select_method);
> 	}
> 
> 
2197a2319,2320
> 	Hotkey('N', "nova_commands", MTHK_COMMANDS_GUI),
> 	Hotkey(WKC_CTRL | WKC_F2, "cargo_table", MTHK_CARGOTABLE),
2198a2322,2327
> 	Hotkey(WKC_CTRL  | 'H', "build_hq", MTHK_BUILD_HQ),
> 	Hotkey('I', "trees", MTHK_TREES),
> 	Hotkey((uint16)0, "zoning", MTHK_ZONING),
> 	Hotkey((uint16)0, "login_window", MTHK_LOGINWINDOW),
> 	Hotkey((uint16)0, "settings_advanced", MTHK_SETTINGS_ADV),
> 	Hotkey((uint16)0, "newgrf_window", MTHK_NEWGRF),
2199a2329
> 	Hotkey((uint16)0, "land_info", MTHK_LANDINFO),
2216a2347
> 		SPR_IMG_COMPANY_CARGO,   // WID_TN_CARGOS
2219a2351
> 		0,                       // WID_TN_WATCH
2453c2585
< 				ShowLandInfo(tile);
---
> 				VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_MEASURE);
diff -r -B -X .diff-exclude vanilla/src/town_cmd.cpp cmclient/src/town_cmd.cpp
54a55,66
> bool _cb_enabled = false;
> uint _cb_storage = 0;
> uint CBREQ[NUM_CARGO] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//CB
> uint CBFROM[NUM_CARGO] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//CB
> uint CBDECAY[NUM_CARGO] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//CB
> uint days_in_month[] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//CB
> void CB_UpdateTownStorage(Town *t); //CB
> 
> const Money NOVAPOLIS_COMPANY_MONEY_THRESHOLD = INT64_MAX >> 4;
> TownsGrowthTilesIndex _towns_growth_tiles_last_month;
> TownsGrowthTilesIndex _towns_growth_tiles;
> 
164a177,196
>  /**
>  * Updates the town label of the town after changes in rating. The colour scheme is:
>  * Red: Appalling and Very poor ratings.
>  * Orange: Poor and mediocre ratings.
>  * Yellow: Good rating.
>  * White: Very good rating (standard).
>  * Green: Excellent and outstanding ratings.
>  */
> void Town::UpdateLabel()
> {
> 	if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
> 		int r = this->ratings[_local_company];
> 		if     (r < RATING_VERYPOOR) this->town_label = 0; // Appalling and Very Poor, RED
> 		else if(r < RATING_MEDIOCRE) this->town_label = 1; // Poor and Mediocre, ORANGE
> 		else if(r < RATING_GOOD)     this->town_label = 2; // Good, YELLOW
> 		else if(r < RATING_VERYGOOD) this->town_label = 3; // Very Good, WHITE
> 		else                         this->town_label = 4; // Excellent and Outstanding, GREEN
> 	}
> }
> 
375a408
> 	this->UpdateLabel();
383a417
> 	SetWindowDirty(WC_CB_TOWN, this->index);
402a437,438
> 	// if(mod > 0 && t->houses_construction > 0) t->houses_construction--;
> 
441c477,480
< 		ChangePopulation(Town::GetByTile(tile), HouseSpec::Get(GetHouseType(tile))->population);
---
> 		HouseID house_id = GetHouseType(tile);
> 		Town *town = Town::GetByTile(tile);
> 		const HouseSpec *hs = HouseSpec::Get(house_id);
> 		ChangePopulation(town, hs->population);
442a482,483
> 		if (hs->building_flags & BUILDING_HAS_1_TILE)
> 			town->houses_construction--;
543c584,590
< 		if (GB(r, 24, 8) >= 12) BuildTownHouse(t, tile);
---
> 		if (GB(r, 24, 8) >= 12 && BuildTownHouse(t, tile)) {
> 			t->houses_reconstruction++;
> 			UpdateTownGrowthTile(tile, TGTS_RH_REBUILT);
> 		} else {
> 			t->houses_demolished++;
> 			UpdateTownGrowthTile(tile, TGTS_RH_REMOVED);
> 		}
570a618,622
> 		if (_current_company == COMPANY_FIRST &&
> 				Company::Get(_current_company)->money > NOVAPOLIS_COMPANY_MONEY_THRESHOLD) {
> 			if (t->growing) t->cb_houses_removed++;
> 			UpdateTownGrowthTile(tile, t->growing ? TGTS_CB_HOUSE_REMOVED: TGTS_CB_HOUSE_REMOVED_NOGROW);
> 		}
660a713
> 	td->population = hs->population;
779a833,905
> static void DoRegularFunding(Town *t)
> {
> 	bool fund_regularly = HasBit(t->fund_regularly, _local_company);
> 	bool do_powerfund = HasBit(t->do_powerfund, _local_company);
> 
> 	if (do_powerfund && (_settings_client.gui.powerfund_money > Company::Get(_local_company)->money ||
> 		    _settings_client.gui.powerfund_houses < t->cache.num_houses)) {
> 	    do_powerfund = false;
> 	}
> 
> 	if (!fund_regularly && !do_powerfund)
> 		return;
> 
> 	if (_local_company == COMPANY_SPECTATOR)
> 		return;
> 
> 	if (CB_Enabled() && !t->growing)
> 		return;
> 
> 
> 	// Funding with grow_counter == 1 doesn't speed up next house building,
> 	// so trying to avoid it. This means no powerfunding with gr <= 1, and no
> 	// regular funding with grow_counter == 1 unless gr is also 1
> 	// (we need to fund anyway even if it doesn't speed up next house)
> 	// And in case town is not growing ignore grow_counter and growth_rate
> 	// completely (it will start growing once we fund it)
> 	bool is_growing = !HasBit(t->flags, TOWN_IS_GROWING);
> 	if (fund_regularly) {
> 		if (t->fund_buildings_months > 0) return;
> 		if (is_growing
> 		    && t->growth_rate > 2 * TOWN_GROWTH_TICKS
> 		    && t->grow_counter <= 2 * TOWN_GROWTH_TICKS) return;
> 	} else if (do_powerfund) {
> 		if (t->growth_rate <= 2 * TOWN_GROWTH_TICKS) return;
> 		if (t->grow_counter != t->growth_rate && is_growing) return;
> 	} else return;
> 
> 	CompanyByte old = _current_company;
> 	_current_company = _local_company;
> 	DoCommandP(t->xy, t->index, HK_FUND, CMD_DO_TOWN_ACTION | CMD_NO_ESTIMATE);
> 	_current_company = old;
> }
> 
> static void DoRegularAdvertising(Town *t) {
> 	if (!HasBit(t->advertise_regularly, _local_company))
> 		return;
> 
> 	if (t->ad_ref_goods_entry == NULL) {
> 		// Pick as ref station and cargo with min rating
> 		const Station *st;
> 		FOR_ALL_STATIONS(st) {
> 			if (st->owner == _local_company && DistanceManhattan(t->xy, st->xy) <= 20) {
> 				for (CargoID i = 0; i < NUM_CARGO; i++)
> 					if (st->goods[i].HasRating() && (t->ad_ref_goods_entry == NULL ||
> 					    	t->ad_ref_goods_entry->rating < st->goods[i].rating)) {
> 						t->ad_ref_goods_entry = &st->goods[i];
> 					}
> 			}
> 		}
> 
> 		if (t->ad_ref_goods_entry == NULL)
> 			return;
> 	}
> 
> 	if (t->ad_ref_goods_entry->rating >= t->ad_rating_goal)
> 		return;
> 
>     CompanyByte old = _current_company;
>     _current_company = _local_company;
>     DoCommandP(t->xy, t->index, HK_LADVERT, CMD_DO_TOWN_ACTION | CMD_NO_ESTIMATE);
>     _current_company = old;
> }
> 
783a910
> 		uint16 houses_prev = t->cache.num_houses;
786a914,916
> 				if (t->cache.num_houses <= houses_prev && (t->growing || !CB_Enabled())){
> 					t->houses_skipped++;
> 				}
787a918,920
> 				if (t->growing || !CB_Enabled()){
> 					t->cycles_skipped++;
> 				}
793a927,928
> 	DoRegularFunding(t);
> 	DoRegularAdvertising(t);
1378c1513
< static bool GrowTownAtRoad(Town *t, TileIndex tile)
---
> static bool GrowTownAtRoad(Town *t, TileIndex start_tile, TileIndex &tile)
1382a1518
> 	tile = start_tile;
1501c1637,1639
< 			bool success = GrowTownAtRoad(t, tile);
---
> 			uint16 houses_prev = t->cache.num_houses;
> 			TileIndex end_tile;
> 			bool success = GrowTownAtRoad(t, tile, end_tile);
1502a1641,1644
> 			if (!success)
> 				UpdateTownGrowthTile(end_tile, TGTS_CYCLE_SKIPPED);
> 			else if (t->cache.num_houses <= houses_prev)
> 				UpdateTownGrowthTile(end_tile, TGTS_HOUSE_SKIPPED);
1516a1659
> 					UpdateTownGrowthTile(tile, TGTS_HOUSE_SKIPPED);
1524a1668
> 	UpdateTownGrowthTile(tile, TGTS_CYCLE_SKIPPED);
1580a1725,1844
> //CB
> 
> bool CB_Enabled(){
> 	return _cb_enabled;
> }
> void CB_SetCB(bool cb){
> 	_cb_enabled = cb;
> 	if(!_cb_enabled){
> 		CB_ResetRequirements();
> 	}
> }
> 
> uint CB_GetStorage() {
> 	return _cb_storage;
> }
> 
> void CB_SetStorage(uint storage){
> 	_cb_storage = storage;
> }
> 
> void CB_SetRequirements(CargoID cargo, uint req, uint from, uint decay){
> 	CBREQ[cargo] = req;
> 	CBFROM[cargo] = from;
> 	CBDECAY[cargo] = decay;
> }
> void CB_ResetRequirements() {
> 	for(CargoID cargo = 0; cargo < NUM_CARGO; cargo++){
> 		CB_SetRequirements(cargo, 0, 0, 0);
> 	}
> }
> uint CB_GetReq(CargoID cargo){
> 	return CBREQ[cargo];
> }
> uint CB_GetFrom(CargoID cargo){
> 	return CBFROM[cargo];
> }
> uint CB_GetDecay(CargoID cargo){
> 	return CBDECAY[cargo];
> }
> int CB_GetTownReq(uint population, uint req, uint from, bool from_non_important, bool prev_month)
> {
> 	if (req > 0 && (population >= from || from_non_important)) {
> 		uint leap = 0;
> 		Month month = _cur_month;
> 		if (!prev_month) month++;
> 		if(month == 2){
> 			if((_cur_year % 4 == 0 && _cur_year % 100 != 0) || _cur_year % 400 == 0) leap = 1;
> 		}
> 		uint days_this_month = days_in_month[month] + leap;
> 		// x cargo for 1000 people
> 		return population * req * days_this_month / 31000; // 31 days divide by 1000 (pop)
> 	}
> 	return 0;
> }
> uint CB_GetMaxTownStorage(uint32 population, uint req)
> {
> 	return req > 0 ? (population * req * _cb_storage / 1000) : 0;
> }
> 
> uint CB_GetMaxTownStorage(Town *town, uint cargo) {
> 	return CBREQ[cargo] > 0 ? (town->cache.population * CBREQ[cargo] * _cb_storage / 1000) : 0;
> }
> 
> void CB_UpdateTownStorage(Town *t)
> {
> 	InvalidateWindowData(WC_CB_TOWN, t->index);
> 	t->growing = true;
> 	if (!HasBit(t->flags, TOWN_IS_GROWING)) { //dont grow if not funded or missing transportation
> 		t->growing = false;
> 	}
> 	for (uint i = 0; i < NUM_CARGO ; i++) {
> 		if(CBREQ[i] == 0) continue;
> 
> 		t->storage[i] += t->new_act_cargo[i]; // add accumulated last month
> 		t->storage[i] -= CB_GetTownReq(t->cache.population, CBREQ[i], CBFROM[i], false, true); //subtract monthly req
> 		t->storage[i] = min((int)CB_GetMaxTownStorage(t->cache.population, CBREQ[i]), t->storage[i]); //check max storage
> 
> 		if (t->storage[i] < 0) {
> 			t->growing = false;
> 			t->delivered_enough[i] = false;
> 			t->storage[i] = 0;
> 		}
> 		else t->delivered_enough[i] = true;
> 
> 		if (CBDECAY[i] == 100 && t->storage[i] > 0) {
> 			t->storage[i] = 0;
> 		}
> 		else {
> 			t->storage[i] *= (100 - CBDECAY[i]);
> 			t->storage[i] /= 100;
> 		}
> 		t->act_cargo[i] = t->new_act_cargo[i];
> 		t->new_act_cargo[i] = 0;
> 	}
> 
> 	if (_settings_game.game_creation.landscape == LT_TROPIC) {
> 		if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->received[TE_FOOD].old_act <= 0 || t->received[TE_WATER].old_act <= 0) && t->cache.population > 60) {
> 			t->growing = false;
> 		}
> 	}
> 	else if (_settings_game.game_creation.landscape == LT_ARCTIC) {
> 		if (TilePixelHeight(t->xy) >= GetSnowLine() && t->received[TE_FOOD].old_act <= 0 && t->cache.population > 90) {
> 			t->growing = false;
> 		}
> 	}
> }
> //CB
> 
> void UpdateTownGrowthTile(TileIndex tile, TownGrowthTileState state) {
> 	_towns_growth_tiles[tile] = max(_towns_growth_tiles[tile], state);
> }
> 
> void ResetTownsGrowthTiles() {
> 	_towns_growth_tiles_last_month.clear();
> 	_towns_growth_tiles.clear();
> }
> 
> 
> extern TileIndex _closest_cache_ref;
> 
1617a1882,1898
> 	//CB
> 	t->growing = false;
> 	for (uint i = 0; i < NUM_CARGO ; i++) {
> 		t->storage[i] = 0;
> 		t->act_cargo[i] = 0;
> 		t->new_act_cargo[i] = 0;
> 		t->delivered_enough[i] = false;
> 	}
> 	t->houses_construction = 0;
> 	t->houses_reconstruction = 0;
> 	t->houses_demolished = 0;
> 	t->fund_regularly = 0;
> 	t->do_powerfund = 0;
> 	t->advertise_regularly = 0;
> 	t->ad_rating_goal = 95;
> 	t->ad_ref_goods_entry = NULL;
> 	//CB
1637a1919
> 	t->town_label = 3;
1658a1941
> 	_closest_cache_ref = INVALID_TILE;
2402a2686,2687
> 		t->cache.potential_pop += hs->population;
> 		t->houses_construction++;
2417a2703
> 				t->houses_construction--;
2423a2710
> 		UpdateTownGrowthTile(tile, TGTS_NEW_HOUSE);
2490a2778,2779
> 	} else {
> 		t->houses_construction--;
2493a2783
> 	t->cache.potential_pop -= hs->population;
2654a2945
> 		InvalidateWindowData(WC_CB_TOWN, p1);
2952a3244
> 		SetWindowDirty(WC_CB_TOWN, t->index);
3008a3301
> 				t->UpdateVirtCoord();
3140a3434
> 	t->UpdateVirtCoord();
3225a3520
> 	t->growing_by_chance = false;
3226a3522
> 	SetWindowDirty(WC_CB_TOWN, t->index);
3249a3546
> 		SetWindowDirty(WC_CB_TOWN, t->index);
3253c3550,3553
< 	if (t->fund_buildings_months == 0 && CountActiveStations(t) == 0 && !Chance16(1, 12)) return;
---
> 	if (t->fund_buildings_months == 0 && CountActiveStations(t) == 0) {
> 		if(!Chance16(1, 12)) return;
> 		t->growing_by_chance = true;
> 	}
3256a3557
> 	SetWindowDirty(WC_CB_TOWN, t->index);
3265a3567
> 	SetWindowDirty(WC_CB_TOWN, t->index);
3433a3736
> 		t->UpdateVirtCoord();
3478a3782,3784
> 	_towns_growth_tiles_last_month = _towns_growth_tiles;
> 	_towns_growth_tiles.clear();
> 
3485a3792,3793
> 		if (CB_Enabled() && !t->larger_town) CB_UpdateTownStorage(t); //CB
> 
3490a3799,3809
> 
> 		DoRegularFunding(t);
> 
> 		t->houses_demolished = 0;
> 		t->houses_reconstruction = 0;
> 		t->houses_skipped_last_month = t->houses_skipped - t->houses_skipped_prev;
> 		t->houses_skipped_prev = t->houses_skipped;
> 		t->cycles_skipped_last_month = t->cycles_skipped - t->cycles_skipped_prev;
> 		t->cycles_skipped_prev = t->cycles_skipped;
> 		t->cb_houses_removed_last_month = t->cb_houses_removed - t->cb_houses_removed_prev;
> 		t->cb_houses_removed_prev = t->cb_houses_removed;
diff -r -B -X .diff-exclude vanilla/src/town_gui.cpp cmclient/src/town_gui.cpp
41a42,59
> #include "hotkeys.h"
> #include <list>
> #include "console_func.h"
> 
> struct CargoX {
> 	int id;
> 	int from;
> };
> void ShowCBTownWindow(uint town);
> static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bool show_house_states_info=false);
> 
> bool TownExecuteAction(const Town *town, uint action){
> 	if(!(action == HK_STATUE && HasBit(town->statues, _current_company))){ //don't built statue when there is one
> 		return DoCommandP(town->xy, town->index, action, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));
> 	}
> 	return false;
> }
> 
167a186
> 				SetDParam(3, this->town->ratings[c->index]);
172c191
< 				DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
---
> 				DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING_NUM);
284a304,311
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		TownExecuteAction(this->town, hotkey);
> 		return ES_HANDLED;
> 	}
> 
> 	static HotkeyList hotkeys;
286a314,323
> static Hotkey town_hotkeys[] = {
> 	Hotkey((uint16)0, "small_advert", HK_SADVERT),
> 	Hotkey((uint16)0, "medium_advert", HK_MADVERT),
> 	Hotkey(WKC_CTRL | 'D', "large_advert", HK_LADVERT),
> 	Hotkey(WKC_CTRL | 'S', "build_statue", HK_STATUE),
> 	Hotkey(WKC_CTRL | 'F', "fund_buildings", HK_FUND),
> 	HOTKEY_LIST_END
> };
> HotkeyList TownAuthorityWindow::hotkeys("town_gui", town_hotkeys);
> 
291c328,329
< 	_nested_town_authority_widgets, lengthof(_nested_town_authority_widgets)
---
> 	_nested_town_authority_widgets, lengthof(_nested_town_authority_widgets),
> 	&TownAuthorityWindow::hotkeys
298a337,339
> // static int TownTicksToDays(int ticks) {
> //  	return (ticks * TOWN_GROWTH_TICKS + DAY_TICKS / 2) / DAY_TICKS;
> // }
306a348
> 	bool wcb_disable;
322a365,368
> 		// extern bool _novahost;
> 		// this->wcb_disable = !_networking || !_novahost || this->town->larger_town || _game_mode == GM_EDITOR;
> 		// this->wcb_disable = (_game_mode == GM_EDITOR);
> 		this->SetWidgetDisabledState(WID_TV_CB, _game_mode == GM_EDITOR);
327c373,384
< 		if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index);
---
> 		if (widget == WID_TV_CAPTION){
> 			SetDParam(0, this->town->index);
> 		}
> 		if (widget == WID_TV_CB){
> 			// if(this->wcb_disable) SetDParam(0, STR_EMPTY);
> 			// else
> 			SetDParam(0, STR_BUTTON_CB_YES);
> 		}
> 	}
> 
> 	virtual void OnHundrethTick() {
> 		this->SetDirty();
349a407,408
> 		DrawExtraTownInfo(r, y, this->town, FONT_HEIGHT_NORMAL, true); //CB
> 
448a508,512
> 			case WID_TV_CB:
> 				// if(_networking)
> 				ShowCBTownWindow(this->window_number);
> 				break;
> 
460a525,527
> 			// case WID_TV_CB:
> 				// if(this->wcb_disable || !CB_Enabled()) size->width = 0;
> 				// break;
470c537
< 		uint aimed_height = 3 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
---
> 		uint aimed_height = 8 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
533a601,620
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		if(hotkey == WID_TV_CB) ShowCBTownWindow(this->window_number);
> 		else if (hotkey == HK_STATUE + 0x80){
> 			TownExecuteAction(this->town, HK_STATUE);
> 			return ES_NOT_HANDLED;
> 		}
> 		return Window::OnHotkey(hotkey);
> 	}
> 
> 	static HotkeyList hotkeys;
> };
> 
> static Hotkey town_window_hotkeys[] = {
> 	Hotkey((uint16)0, "location", WID_TV_CENTER_VIEW),
> 	Hotkey((uint16)0, "local_authority", WID_TV_SHOW_AUTHORITY),
> 	Hotkey((uint16)0, "cb_window", WID_TV_CB),
> 	Hotkey(WKC_CTRL | 'S', "build_statue", HK_STATUE + 0x80),
> 	HOTKEY_LIST_END
534a622
> HotkeyList TownViewWindow::hotkeys("town_window", town_window_hotkeys);
551,552c639,640
< 		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
< 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
---
> 		NWidget(NWID_HORIZONTAL), //, NC_EQUALSIZE
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(60, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
554c642,643
< 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
---
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(60, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CB), SetMinimalSize(20, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_CB, 0),
564c653,654
< 	_nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets)
---
> 	_nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets),
> 	&TownViewWindow::hotkeys
586a677
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CB), SetMinimalSize(20, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_CB, 0),
611c702
< 		NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
---
> 		NWidget(WWT_CAPTION, COLOUR_BROWN, TDW_CAPTION_TEXT), SetDataTip(STR_TOWN_DIRECTORY_CAPTION_EXTRA, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
702a794,811
> 	/** Sort by real population (default descending, as big towns are of the most interest). */
> 	static int CDECL TownRealPopulationSorter(const Town * const *a, const Town * const *b)
> 	{
> 		uint32 a_population = (*a)->cache.potential_pop;
> 		uint32 b_population = (*b)->cache.potential_pop;
> 		if (a_population == b_population) return TownDirectoryWindow::TownNameSorter(a, b);
> 		return (a_population < b_population) ? -1 : 1;
> 	}
> 
> 	/** Sort by number of houses (default descending, as big towns are of the most interest). */
> 	static int CDECL TownHousesSorter(const Town * const *a, const Town * const *b)
> 	{
> 		uint32 a_houses = (*a)->cache.num_houses;
> 		uint32 b_houses = (*b)->cache.num_houses;
> 		if (a_houses == b_houses) return TownDirectoryWindow::TownPopulationSorter(a, b);
> 		return (a_houses < b_houses) ? -1 : 1;
> 	}
> 
746a856,867
> 			case TDW_CAPTION_TEXT: {
> 				uint16 town_number = 0;
> 				uint16 city_number = 0;
> 				const Town *t;
> 				FOR_ALL_TOWNS(t){
> 					if(t->larger_town) city_number++;
> 					town_number++;
> 				}
> 				SetDParam(0, city_number);
> 				SetDParam(1, town_number);
> 				break;
> 			}
798c919,922
< 					DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
---
> 					SetDParam(2, t->cache.potential_pop);
> 					SetDParam(3, t->cache.num_houses);
> 					/* CITIES DIFFERENT COLOUR*/
> 					DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, t->larger_town ? STR_TOWN_DIRECTORY_CITY_COLOUR : STR_TOWN_DIRECTORY_TOWN_COLOUR);
837c961,962
< 					d = maxdim(d, GetStringBoundingBox(GetTownString(t)));
---
> 					SetDParamMaxDigits(2, 5);
> 					d = maxdim(d, GetStringBoundingBox(STR_TOWN_DIRECTORY_TOWN_COLOUR));
947a1073,1074
> 	STR_SORT_BY_REAL_POPULATION,
> 	STR_SORT_BY_HOUSES,
955a1083,1084
> 	&TownRealPopulationSorter,
> 	&TownHousesSorter,
1211a1341,1722
> }
> 
> //CB
> static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bool show_house_states_info) {
> 	//real pop and rating
> 	SetDParam(0, town->cache.potential_pop);
> 	SetDParam(1, town->ratings[_current_company]);
> 	DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_REALPOP_RATE);
> 	//town stats
> 	// int grow_rate = 0;
> 	// if(town->growth_rate == TOWN_GROW_RATE_CUSTOM_NONE) grow_rate = 0;
> 	// else grow_rate = TownTicksToDays((town->growth_rate & ~TOWN_GROW_RATE_CUSTOM) + 1);
> 
> 	SetDParam(0, town->growth_rate);
> 	SetDParam(1, HasBit(town->flags, TOWN_CUSTOM_GROWTH) ? STR_TOWN_VIEW_GROWTH_RATE_CUSTOM : STR_EMPTY);
> 	// SetDParam(2, town->grow_counter < 16000 ? TownTicksToDays(town->grow_counter + 1) : -1);
> 	SetDParam(2, town->grow_counter);
> 	SetDParam(3, town->time_until_rebuild);
> 	SetDParam(4, HasBit(town->flags, TOWN_IS_GROWING) ? 1 : 0);
> 	SetDParam(5, town->fund_buildings_months);
> 	DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_GROWTH);
> 
> 	if (show_house_states_info) {
> 		SetDParam(0, town->houses_construction);
> 		SetDParam(1, town->houses_reconstruction);
> 		SetDParam(2, town->houses_demolished);
> 		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_HOUSE_STATE);
> 	}
> 
> 	///houses stats
> 	SetDParam(0, town->houses_skipped);
> 	SetDParam(1, town->houses_skipped_last_month);
> 	SetDParam(2, town->cycles_skipped);
> 	SetDParam(3, town->cycles_skipped_last_month);
> 	SetDParam(4, town->cb_houses_removed);
> 	SetDParam(5, town->cb_houses_removed_last_month);
> 	DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_GROWTH_TILES);
> }
> 
> bool CB_sortCargoesByFrom(CargoX first, CargoX second){
> 	return (first.from < second.from) ? true : false;
> }
> 
> struct CBTownWindow : Window {
> private:
> 	Town *town;
> 	std::list<CargoX> cargoes;
> 
> public:
> 	CBTownWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
> 	{
> 		for (uint i = 0; i < NUM_CARGO ; i++) {
> 			CargoX c;
> 			c.id = i;
> 			c.from = CB_GetFrom(i);
> 			this->cargoes.push_back(c);
> 		}
> 		cargoes.sort(CB_sortCargoesByFrom);
> 		this->town = Town::Get(window_number);
> 		this->InitNested(window_number);
> 
> 		if(HasBit(this->town->fund_regularly, _local_company)) this->LowerWidget(WID_CB_FUND_REGULAR);
> 		if(HasBit(this->town->do_powerfund, _local_company)) this->LowerWidget(WID_CB_POWERFUND);
> 		if(HasBit(this->town->advertise_regularly, _local_company)) this->LowerWidget(WID_CB_ADVERT_REGULAR);
> 	}
> 
> 	virtual void OnClick(Point pt, int widget, int click_count)
> 	{
> 		switch (widget) {
> 			case WID_CB_LOCATION:
> 			case WID_CB_CENTER_VIEW: // scroll to location
> 				if (_ctrl_pressed) {
> 					ShowExtraViewPortWindow(this->town->xy);
> 				}
> 				else {
> 					ScrollMainWindowToTile(this->town->xy);
> 				}
> 				break;
> 			case WID_CB_ADVERT:
> 				TownExecuteAction(this->town, HK_LADVERT);
> 				break;
> 			case WID_CB_FUND:
> 				TownExecuteAction(this->town, HK_FUND);
> 				break;
> 			case WID_CB_FUND_REGULAR:
> 				ToggleBit(this->town->fund_regularly, _local_company);
> 				this->SetWidgetLoweredState(widget, HasBit(this->town->fund_regularly, _local_company));
> 				this->SetWidgetDirty(widget);
> 				break;
> 			case WID_CB_POWERFUND:
> 				ToggleBit(this->town->do_powerfund, _local_company);
> 				this->SetWidgetLoweredState(widget, HasBit(this->town->do_powerfund, _local_company));
> 				this->SetWidgetDirty(widget);
> 				break;
> 			case WID_CB_ADVERT_REGULAR:
> 				if (!this->town->advertise_regularly) {
> 					SetDParam(0, ToPercent8(this->town->ad_rating_goal));
> 					ShowQueryString(STR_JUST_INT, STR_CB_ADVERT_REGULAR_RATING_TO_KEEP,
> 					                4, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
> 				} else this->OnQueryTextFinished(NULL);
> 				break;
> 			case WID_CB_TOWN_VIEW: // Town view window
> 				ShowTownViewWindow(this->window_number);
> 				break;
> 			case WID_CB_SHOW_AUTHORITY: // town authority
> 				ShowTownAuthorityWindow(this->window_number);
> 				break;
> 		}
> 	}
> 
> 	virtual void OnQueryTextFinished(char *str)
> 	{
> 		if (str != NULL) SetBit(this->town->advertise_regularly, _local_company);
> 		else ClrBit(this->town->advertise_regularly, _local_company);
> 		this->town->ad_ref_goods_entry = NULL;
> 		this->SetWidgetLoweredState(WID_CB_ADVERT_REGULAR, HasBit(this->town->advertise_regularly, _local_company));
> 		this->SetWidgetDirty(WID_CB_ADVERT_REGULAR);
> 
> 		if (str == NULL)
> 			return;
> 		uint val = Clamp(StrEmpty(str) ? 0 : strtol(str, NULL, 10), 1, 100);
> 		this->town->ad_rating_goal = ((val << 8) + 255) / 101;
> 	}
> 
> 	virtual void SetStringParameters(int widget) const
> 	{
> 		if (widget == WID_TV_CAPTION){
> 			SetDParam(0, this->town->index);
> 		}
> 	}
> 
> 	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
> 	{
> 		static const uint EXP_TOPPADDING = 5;
> 		static const uint EXP_LINESPACE  = 2; // Amount of vertical space for a horizontal (sub-)total line.
> 
> 		switch(widget){
> 			case WID_CB_DETAILS:
> 				size->height = (FONT_HEIGHT_NORMAL + EXP_LINESPACE) * 7;
> 				break;
> 			case WID_CB_CARGO_NAME:
> 			case WID_CB_CARGO_AMOUNT:
> 			case WID_CB_CARGO_REQ:
> 			case WID_CB_CARGO_STORE:
> 			case WID_CB_CARGO_STORE_PCT:
> 			case WID_CB_CARGO_FROM:
> 			case WID_CB_CARGO_PREVIOUS:
> 				uint desired_height = 1;
> 				for(CargoID cargo = 0; cargo < NUM_CARGO; cargo++){
> 					if(CB_GetReq(cargo) > 0) desired_height++;
> 				}
> 				size->height = desired_height * (FONT_HEIGHT_NORMAL + EXP_LINESPACE) + EXP_TOPPADDING - EXP_LINESPACE;
> 				break;
> 		}
> 	}
> 
> 	void DrawWidget(const Rect &r, int widget) const
> 	{
> 		static const uint EXP_LINESPACE  = FONT_HEIGHT_NORMAL + 2;
> 		uint y = r.top + WD_FRAMERECT_TOP;
> 		switch(widget){
> 			case WID_CB_DETAILS:{
> 				//growing
> 				if(this->town->growing) DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_GROWING );
> 				else DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_NOT_GROWING );
> 				//population
> 				SetDParam(0, this->town->cache.population);
> 				SetDParam(1, this->town->cache.num_houses);
> 				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += EXP_LINESPACE, STR_TOWN_VIEW_POPULATION_HOUSES);
> 
> 				DrawExtraTownInfo(r, y, this->town, EXP_LINESPACE, false);
> 				//regular funding
> 				if(this->town->fund_regularly != 0){
> 					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += EXP_LINESPACE, STR_CB_FUNDED_REGULARLY);
> 				}
> 				break;
> 			}
> 			/* Citybuilder things*/
> 			case WID_CB_CARGO_NAME:
> 			case WID_CB_CARGO_AMOUNT:
> 			case WID_CB_CARGO_REQ:
> 			case WID_CB_CARGO_STORE:
> 			case WID_CB_CARGO_STORE_PCT:
> 			case WID_CB_CARGO_FROM:
> 			case WID_CB_CARGO_PREVIOUS: {
> 				if (!CB_Enabled() || this->town->larger_town) break;
> 
> 				uint delivered;
> 				uint requirements;
> 				uint from;
> 				StringID string_to_draw;
> 
> 				//for cycle
> 				std::list<CargoX> cargoes2 = this->cargoes;
> 				std::list<CargoX>::iterator it2;
> 				for (it2 = cargoes2.begin(); it2 != cargoes2.end(); ++it2) {
> 					CargoX cargox;
> 					cargox = *it2;
> 					if (it2 == cargoes2.begin()) { //header
> 						DrawString(r.left + WD_FRAMERECT_LEFT + 14, r.right - WD_FRAMERECT_LEFT, y,
> 							(STR_TOWN_GROWTH_HEADER_CARGO + widget - WID_CB_CARGO_NAME), TC_FROMSTRING,
> 							(widget == WID_CB_CARGO_NAME) ? SA_LEFT : SA_RIGHT);
> 
> 						y += (FONT_HEIGHT_NORMAL + 2);
> 					}
> 
> 					const CargoSpec *cargos = CargoSpec::Get(cargox.id);
> 					//cargo needed?
> 					if (!cargos->IsValid() || CB_GetReq(cargos->Index()) == 0) continue;
> 
> 					from = CB_GetFrom(cargos->Index());
> 
> 					switch(widget) {
> 						case WID_CB_CARGO_NAME: {
> 							int rect_x = (r.left + WD_FRAMERECT_LEFT);
> 							GfxFillRect(rect_x, y + 1, rect_x + 8, y + 6, 0);
> 							GfxFillRect(rect_x + 1, y + 2, rect_x + 7, y + 5, cargos->legend_colour);
> 
> 							SetDParam(0, cargos->name);
> 							DrawString(r.left + WD_FRAMERECT_LEFT + 14, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_CARGO_NAME);
> 							break;
> 						}
> 						case WID_CB_CARGO_AMOUNT: {
> 							delivered = this->town->new_act_cargo[cargos->Index()];
> 							requirements = CB_GetTownReq(this->town->cache.population, CB_GetReq(cargos->Index()), from, true);
> 							SetDParam(0, delivered);
> 
> 							//when required
> 							if (this->town->cache.population >= from) {
> 								if((delivered + (uint)this->town->storage[cargos->Index()]) >= requirements) string_to_draw = STR_TOWN_CB_CARGO_AMOUNT_GOOD;
> 								else string_to_draw = STR_TOWN_CB_CARGO_AMOUNT_BAD;
> 							}
> 							//when not required -> all faded
> 							else string_to_draw = STR_TOWN_CB_CARGO_AMOUNT_NOT;
> 
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						case WID_CB_CARGO_REQ: {
> 							requirements = CB_GetTownReq(this->town->cache.population, CB_GetReq(cargos->Index()), from, true);
> 							SetDParam(0, requirements);
> 							 //when required
> 							string_to_draw = (this->town->cache.population >= from) ? STR_TOWN_CB_CARGO_REQ_YES : STR_TOWN_CB_CARGO_REQ_NOT;
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						case WID_CB_CARGO_PREVIOUS: {
> 							requirements = CB_GetTownReq(this->town->cache.population, CB_GetReq(cargos->Index()), from, true);
> 							SetDParam(0, this->town->act_cargo[cargos->Index()]);
> 							if (this->town->cache.population >= from){
> 								if (this->town->delivered_enough[cargos->Index()]) {
> 									string_to_draw = (this->town->act_cargo[cargos->Index()] >= requirements) ? STR_TOWN_CB_CARGO_PREVIOUS_YES : STR_TOWN_CB_CARGO_PREVIOUS_EDGE;
> 								}
> 								else string_to_draw = STR_TOWN_CB_CARGO_PREVIOUS_BAD;
> 							}
> 							else string_to_draw = STR_TOWN_CB_CARGO_PREVIOUS_NOT;
> 
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						case WID_CB_CARGO_STORE: {
> 							SetDParam(0, this->town->storage[cargos->Index()]);
> 							if (CB_GetDecay(cargos->Index()) == 100) string_to_draw = STR_TOWN_CB_CARGO_STORE_DECAY;  //when 100% decay
> 							else {
> 								if (this->town->cache.population >= from) string_to_draw = STR_TOWN_CB_CARGO_STORE_YES;  //when required
> 								else string_to_draw = STR_TOWN_CB_CARGO_STORE_NOT;
> 							}
> 
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						case WID_CB_CARGO_STORE_PCT: {
> 							uint max_storage = CB_GetMaxTownStorage(this->town, cargos->Index());
> 							if (CB_GetDecay(cargos->Index()) == 100 || !max_storage) string_to_draw = STR_TOWN_CB_CARGO_STORE_DECAY;  //when 100% decay
> 							else {
> 								SetDParam(0, 100 * this->town->storage[cargos->Index()] / max_storage);
> 								if (this->town->cache.population >= from) string_to_draw = STR_TOWN_CB_CARGO_STORE_PCT_YES;  //when required
> 								else string_to_draw = STR_TOWN_CB_CARGO_STORE_PCT_NOT;
> 							}
> 
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						case WID_CB_CARGO_FROM: {
> 							SetDParam(0, from);
> 							string_to_draw = (this->town->cache.population >= from) ? STR_TOWN_CB_CARGO_FROM_YES : STR_TOWN_CB_CARGO_FROM_NOT; //when required
> 
> 							DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
> 							break;
> 						}
> 						//last case
> 					}
> 					//switch
> 					y += (FONT_HEIGHT_NORMAL + 2);
> 					//cargo needed?
> 				}
> 				//for cycle
> 			}
> 			break;
> 		}
> 		/* Citybuilder things enabled*/
> 	}
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		TownExecuteAction(this->town, hotkey);
> 		return ES_HANDLED;
> 	}
> 
> 	static HotkeyList hotkeys;
> };
> 
> HotkeyList CBTownWindow::hotkeys("town_gui", town_hotkeys);
> 
> static const NWidgetPart _nested_cb_town_widgets[] = {
> 	NWidget(NWID_HORIZONTAL),
> 		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
> 		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TV_CAPTION), SetDataTip(STR_TOWN_VIEW_CB_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
> 		NWidget(WWT_SHADEBOX, COLOUR_BROWN),
> 		NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
> 		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
> 	EndContainer(),
> 	NWidget(WWT_PANEL, COLOUR_BROWN),
> 		NWidget(NWID_VERTICAL),
> 			NWidget(NWID_SPACER), SetMinimalSize(0, 5),  SetResize(1, 0), SetFill(1, 0),
> 			NWidget(NWID_HORIZONTAL),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_DETAILS), SetMinimalSize(250, 0), SetResize(1, 0), SetFill(1, 0),
> 				NWidget(NWID_VERTICAL),
> 					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CB_ADVERT),SetMinimalSize(66, 20),SetFill(1, 0), SetDataTip(STR_CB_LARGE_ADVERTISING_CAMPAIGN, 0),
> 						NWidget(NWID_SPACER), SetMinimalSize(2, 0),
> 						NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CB_FUND),SetMinimalSize(66, 20),SetFill(1, 0), SetDataTip(STR_CB_NEW_BUILDINGS, 0),
> 						NWidget(NWID_SPACER), SetMinimalSize(4, 0),
> 					EndContainer(),
> 					NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
> 						NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_CB_ADVERT_REGULAR),SetMinimalSize(66, 20),SetFill(1, 0), SetDataTip(STR_CB_ADVERT_REGULAR, STR_CB_ADVERT_REGULAR_TT),
>  						NWidget(NWID_SPACER), SetMinimalSize(2, 0),
> 						NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_CB_FUND_REGULAR),SetMinimalSize(66, 20),SetFill(1, 0), SetDataTip(STR_CB_FUND_REGULAR, STR_CB_FUND_REGULAR_TT),
> 						NWidget(NWID_SPACER), SetMinimalSize(4, 0),
> 					EndContainer(),
> 					NWidget(NWID_SPACER), SetMinimalSize(0, 2),
> 					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
>   						NWidget(NWID_SPACER), SetMinimalSize(132, 0),
>   						NWidget(NWID_SPACER), SetMinimalSize(2, 0),
> 						NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_CB_POWERFUND),SetMinimalSize(66, 20),SetFill(1, 0), SetDataTip(STR_CB_POWERFUND, STR_CB_POWERFUND_TT),
> 						NWidget(NWID_SPACER), SetMinimalSize(4, 0),
> 					EndContainer(),
> 				EndContainer(),
> 			EndContainer(),
> 			NWidget(NWID_SPACER), SetMinimalSize(0, 5),  SetResize(1, 0), SetFill(1, 0),
> 			NWidget(NWID_HORIZONTAL),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_NAME),SetMinimalSize(100, 0), SetResize(0, 0), SetFill(1, 0),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_AMOUNT),SetMinimalSize(70, 0), SetResize(1, 0), SetFill(0, 0),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_REQ),SetMinimalSize(70, 0), SetResize(1, 0), SetFill(0, 0),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_PREVIOUS),SetMinimalSize(80, 0),  SetResize(1, 0), SetFill(0, 0),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_STORE),SetMinimalSize(70, 0), SetResize(1, 0), SetFill(0, 0),
> 				NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CB_CARGO_STORE_PCT),SetMinimalSize(60, 0), SetResize(1, 0), SetFill(0, 0),
> 			EndContainer(),
> 			NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetResize(1, 1), SetFill(1, 1),
> 		EndContainer(),
> 	EndContainer(),
> 	NWidget(NWID_HORIZONTAL),
> 		NWidget(NWID_HORIZONTAL),
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CB_CENTER_VIEW), SetMinimalSize(60, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CB_TOWN_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_CB_GUI_TOWN_VIEW_BUTTON, STR_CB_GUI_TOWN_VIEW_TOOLTIP),
> 			NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CB_SHOW_AUTHORITY), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON, STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP),
> 		EndContainer(),
> 		NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
> 	EndContainer(),
> };
> 
> static WindowDesc _cb_town_desc(
> 	WDP_AUTO, "cb_town", 320, 80,
> 	WC_CB_TOWN, WC_NONE,
> 	0,
> 	_nested_cb_town_widgets, lengthof(_nested_cb_town_widgets),
> 	&CBTownWindow::hotkeys
> );
> 
> void ShowCBTownWindow(uint town) {
> 	AllocateWindowDescFront<CBTownWindow>(&_cb_town_desc, town);
diff -r -B -X .diff-exclude vanilla/src/town.h cmclient/src/town.h
17a18,21
> #include "station_base.h"
> #include "openttd.h"
> #include "table/strings.h"
> #include "company_func.h"
21a26
> #include <map>
47a53
> 	uint32 potential_pop;                     ///< Potential population (if all houses are finished)
82a89,114
> 	StringID town_label;                ///< Label dependent on _local_company rating.
> 	bool growing;                       //CB
> 	/* amounts in storage */
> 	int storage[NUM_CARGO];             //CB stored cargo
> 	uint act_cargo[NUM_CARGO];          //CB delivered last month
> 	uint new_act_cargo[NUM_CARGO];      //CB  delivered current month
> 	bool delivered_enough[NUM_CARGO];   //CB
> 	bool growing_by_chance;             ///< town growing due to 1/12 chance?
> 	uint16 houses_skipped;              ///< number of failed house buildings with next counter reset
> 	uint16 houses_skipped_prev;         ///< house_failures on start of previous month
> 	uint16 houses_skipped_last_month;   ///< house_failures during last month
> 	uint16 cycles_skipped;              ///< number of house building cycles skipped due to placement failure
> 	uint16 cycles_skipped_prev;
> 	uint16 cycles_skipped_last_month;
> 	uint16 cb_houses_removed;            ///< houses removed by cb server (excluding ones when town is not growing)
> 	uint16 cb_houses_removed_prev;       ///< houses removed by cb server on start of previous month
> 	uint16 cb_houses_removed_last_month; ///< houses removed by cb server during last month
> 	uint houses_construction;            ///< number of houses currently being built
> 	uint houses_reconstruction;          ///< number of houses currently being rebuilt
> 	uint houses_demolished;              ///< number of houses demolished this month
> 	CompanyMask fund_regularly;          ///< funds buildings regularly when previous fund ends
> 	CompanyMask do_powerfund;            ///< funds buildings when grow counter is maximal (results in fastest funding possible)
> 	CompanyMask advertise_regularly;     ///< advertised regularly to keep stations rating on desired value
> 	uint8 ad_rating_goal;                ///< value to keep rating at (for regular advertisement) (0..255)
> 	const GoodsEntry *ad_ref_goods_entry;      ///< poiter to goods entry of some station, used to check rating for regular advertisement
> 
115a148,173
> 	void UpdateLabel();
> 
> 	/* Returns the correct town label, based on rating. */
> 	//FORCEINLINE StringID Label() const{
> 	StringID Label() const{
> 		if (!_settings_client.gui.population_in_label)
> 			return STR_VIEWPORT_TOWN;
> 		if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
> 			return STR_VIEWPORT_TOWN_POP_VERY_POOR_RATING + this->town_label;
> 		}
> 		else {
> 			return STR_VIEWPORT_TOWN_POP;
> 		}
> 	}
> 
> 	/* Returns the correct town small label, based on rating. */
> 	//FORCEINLINE StringID SmallLabel() const{
> 	StringID SmallLabel() const{
> 		if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
> 			return STR_VIEWPORT_TOWN_TINY_VERY_POOR_RATING + this->town_label;
> 		}
> 		else {
> 			return STR_VIEWPORT_TOWN_TINY_WHITE;
> 		}
> 	}
> 
196a255,285
> 
> bool CB_Enabled();
> void CB_SetCB(bool cb);
> uint CB_GetStorage();
> void CB_SetStorage(uint storage);
> void CB_SetRequirements(CargoID cargo, uint req, uint from, uint decay);
> void CB_ResetRequirements();
> uint CB_GetReq(CargoID cargo);
> uint CB_GetFrom(CargoID cargo);
> uint CB_GetDecay(CargoID cargo);
> int CB_GetTownReq(uint population, uint req, uint from, bool from_non_important, bool prev_month = false);
> uint CB_GetMaxTownStorage(Town *town, uint cargo);
> bool TownExecuteAction(const Town *town, uint action);
> 
> enum TownGrowthTileState {
> 	TGTS_NONE = 0,
> 	TGTS_RH_REMOVED,
> 	TGTS_NEW_HOUSE,
> 	TGTS_RH_REBUILT,               // rebuilt and removed houses are also
> 	TGTS_CB_HOUSE_REMOVED_NOGROW,  // new, so larger priority
> 	TGTS_CYCLE_SKIPPED,
> 	TGTS_HOUSE_SKIPPED,
> 	TGTS_CB_HOUSE_REMOVED
> };
> 
> typedef std::map<TileIndex, TownGrowthTileState> TownsGrowthTilesIndex;
> extern TownsGrowthTilesIndex _towns_growth_tiles_last_month;
> extern TownsGrowthTilesIndex _towns_growth_tiles;
> 
> void UpdateTownGrowthTile(TileIndex tile, TownGrowthTileState state);
> void ResetTownsGrowthTiles();
diff -r -B -X .diff-exclude vanilla/src/train_cmd.cpp cmclient/src/train_cmd.cpp
3904c3904
< 	PerformanceAccumulator framerate(PFE_GL_TRAINS);
---
> //	PerformanceAccumulator framerate(PFE_GL_TRAINS);
diff -r -B -X .diff-exclude vanilla/src/vehicle_gui.cpp cmclient/src/vehicle_gui.cpp
40a41
> #include "hotkeys.h"
2307,2313d2307
< /** Vehicle view window descriptor for all vehicles but trains. */
< static WindowDesc _vehicle_view_desc(
< 	WDP_AUTO, "view_vehicle", 250, 116,
< 	WC_VEHICLE_VIEW, WC_NONE,
< 	0,
< 	_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets)
< );
2315,2324d2308
< /**
<  * Vehicle view window descriptor for trains. Only minimum_height and
<  *  default_height are different for train view.
<  */
< static WindowDesc _train_view_desc(
< 	WDP_AUTO, "view_vehicle_train", 250, 134,
< 	WC_VEHICLE_VIEW, WC_NONE,
< 	0,
< 	_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets)
< );
2786a2771,2778
> 
> 	virtual EventState OnHotkey(int hotkey)
> 	{
> 		if (this->owner != _local_company) return ES_NOT_HANDLED;
> 		return Window::OnHotkey(hotkey);
> 	}
> 
> 	static HotkeyList hotkeys;
2788a2781,2809
> static Hotkey vehiclegui_hotkeys[] = {
> 	Hotkey('G', "vehicle_orders", WID_VV_SHOW_ORDERS),
> 	Hotkey('F', "vehicle_go", WID_VV_START_STOP),
> 	Hotkey((uint16)0, "vehicle_refit", WID_VV_REFIT),
> 	Hotkey((uint16)0, "vehicle_clone", WID_VV_CLONE),
> 	HOTKEY_LIST_END
> };
> HotkeyList VehicleViewWindow::hotkeys("vehiclegui", vehiclegui_hotkeys);
> 
> /** Vehicle view window descriptor for all vehicles but trains. */
> static WindowDesc _vehicle_view_desc(
> 	WDP_AUTO, "view_vehicle", 250, 116,
> 	WC_VEHICLE_VIEW, WC_NONE,
> 	0,
> 	_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets),
> 	&VehicleViewWindow::hotkeys
> );
> 
> /**
>  * Vehicle view window descriptor for trains. Only minimum_height and
>  *  default_height are different for train view.
>  */
> static WindowDesc _train_view_desc(
> 	WDP_AUTO, "view_vehicle_train", 250, 134,
> 	WC_VEHICLE_VIEW, WC_NONE,
> 	0,
> 	_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets),
> 	&VehicleViewWindow::hotkeys
> );
diff -r -B -X .diff-exclude vanilla/src/video/sdl_v.cpp cmclient/src/video/sdl_v.cpp
479c479,487
< 	AS(SDLK_PERIOD,  WKC_PERIOD)
---
> 	AS(SDLK_PERIOD,  WKC_PERIOD),
> 
> 	AS(0x7B,            WKC_L_BRACE),
> 	AS(0x7D,            WKC_R_BRACE),
> 	AS(SDLK_LEFTPAREN,  WKC_L_PAREN),
> 	AS(SDLK_RIGHTPAREN, WKC_R_PAREN),
> 	AS(SDLK_PLUS,       WKC_PLUS),
> 	AS(SDLK_EXCLAIM,    WKC_EXCLAIM),
> 	AS(SDLK_ASTERISK,   WKC_ASTERISK),
737a746
> 			_alt_pressed = !!(mod & KMOD_ALT);
diff -r -B -X .diff-exclude vanilla/src/video/win32_v.cpp cmclient/src/video/win32_v.cpp
1252a1253
> 			_alt_pressed = _wnd.has_focus && GetAsyncKeyState(VK_MENU)<0;
diff -r -B -X .diff-exclude vanilla/src/viewport.cpp cmclient/src/viewport.cpp
65a66,68
> #include "math.h"
> #include "core/math_func.hpp"
> #include "core/smallvec_type.hpp"
86c89
< #include "bridge_map.h"
---
> #include "tunnelbridge_map.h"
95a99,100
> #include "zoning.h"
> #include "industry_type.h"
155a161,182
> /**
>  * Snapping point for a track.
>  *
>  * Point where a track (rail/road/other) can be snapped to while selecting tracks with polyline
>  * tool (HT_POLY). Besides of x/y coordinates expressed in tile "units" it contains a set of
>  * allowed line directions.
>  */
> struct LineSnapPoint : Point {
> 	uint8 dirs; ///< Allowed line directions, set of #Direction bits.
> };
> 
> typedef SmallVector<LineSnapPoint, 4> LineSnapPoints; ///< Set of snapping points
> 
> /** Coordinates of a polyline track made of 2 connected line segments. */
> struct RailPolyline {
> 	Point start;           ///< The point where the first segment starts (as given in LineSnapPoint).
> 	Direction first_dir;   ///< Direction of the first line segment.
> 	uint first_len;        ///< Length of the first segment - number of track pieces.
> 	Direction second_dir;  ///< Direction of the second line segment.
> 	uint second_len;       ///< Length of the second segment - number of track pieces.
> };
> 
186a214,223
> static IndustryType _industry_forbidden_tiles = INVALID_INDUSTRYTYPE;
> 
> static RailSnapMode _rail_snap_mode = RSM_NO_SNAP; ///< Type of rail track snapping (polyline tool).
> static LineSnapPoints _tile_snap_points; ///< Tile to which a rail track will be snapped to (polyline tool).
> static LineSnapPoints _rail_snap_points; ///< Set of points where a rail track will be snapped to (polyline tool).
> static LineSnapPoint _current_snap_lock; ///< Start point and direction at which selected track is locked on currently (while dragging in polyline mode).
> 
> static TileIndex GetRailSnapTile();
> static void SetRailSnapTile(TileIndex tile);
> 
783c820
<  * Checks whether a point is inside the selected a diagonal rectangle given by _thd.size and _thd.pos
---
>  * Checks whether a point is inside the selected rectangle given by _thd.size, _thd.pos and _thd.diagonal
788c825
< bool IsInsideRotatedRectangle(int x, int y)
---
> static bool IsInsideSelectedRectangle(int x, int y)
789a827,830
> 	if (!_thd.diagonal) {
> 		return IsInsideBS(x, _thd.pos.x, _thd.size.x) && IsInsideBS(y, _thd.pos.y, _thd.size.y);
> 	}
> 
906c947
< static bool IsPartOfAutoLine(int px, int py)
---
> static HighLightStyle GetPartOfAutoLine(int px, int py, const Point &selstart, const Point &selend, HighLightStyle dir)
908,909c949,950
< 	px -= _thd.selstart.x;
< 	py -= _thd.selstart.y;
---
> 	if (!IsInRangeInclusive(selstart.x & ~TILE_UNIT_MASK, selend.x & ~TILE_UNIT_MASK, px)) return HT_DIR_END;
> 	if (!IsInRangeInclusive(selstart.y & ~TILE_UNIT_MASK, selend.y & ~TILE_UNIT_MASK, py)) return HT_DIR_END;
911c952,953
< 	if ((_thd.drawstyle & HT_DRAG_MASK) != HT_LINE) return false;
---
> 	px -= selstart.x & ~TILE_UNIT_MASK;
> 	py -= selstart.y & ~TILE_UNIT_MASK;
913,921c955,962
< 	switch (_thd.drawstyle & HT_DIR_MASK) {
< 		case HT_DIR_X:  return py == 0; // x direction
< 		case HT_DIR_Y:  return px == 0; // y direction
< 		case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
< 		case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
< 		case HT_DIR_VL: return px == py || px == py + 16; // vertical left
< 		case HT_DIR_VR: return px == py || px == py - 16; // vertical right
< 		default:
< 			NOT_REACHED();
---
> 	switch (dir) {
> 		case HT_DIR_X: return (py == 0) ? HT_DIR_X : HT_DIR_END;
> 		case HT_DIR_Y: return (px == 0) ? HT_DIR_Y : HT_DIR_END;
> 		case HT_DIR_HU: return (px == -py) ? HT_DIR_HU : (px == -py - (int)TILE_SIZE) ? HT_DIR_HL : HT_DIR_END;
> 		case HT_DIR_HL: return (px == -py) ? HT_DIR_HL : (px == -py + (int)TILE_SIZE) ? HT_DIR_HU : HT_DIR_END;
> 		case HT_DIR_VL: return (px ==  py) ? HT_DIR_VL : (px ==  py + (int)TILE_SIZE) ? HT_DIR_VR : HT_DIR_END;
> 		case HT_DIR_VR: return (px ==  py) ? HT_DIR_VR : (px ==  py - (int)TILE_SIZE) ? HT_DIR_VL : HT_DIR_END;
> 		default: NOT_REACHED(); break;
923d963
< }
925,933c965,966
< /* [direction][side] */
< static const HighLightStyle _autorail_type[6][2] = {
< 	{ HT_DIR_X,  HT_DIR_X },
< 	{ HT_DIR_Y,  HT_DIR_Y },
< 	{ HT_DIR_HU, HT_DIR_HL },
< 	{ HT_DIR_HL, HT_DIR_HU },
< 	{ HT_DIR_VL, HT_DIR_VR },
< 	{ HT_DIR_VR, HT_DIR_VL }
< };
---
> 	return HT_DIR_END;
> }
941c974,975
<  * @param autorail_type Offset into _AutorailTilehSprite[][]
---
>  * @param autorail_type \c HT_DIR_XXX, offset into _AutorailTilehSprite[][]
>  * @param pal Palette to use, -1 to autodetect
943c977
< static void DrawAutorailSelection(const TileInfo *ti, uint autorail_type)
---
> static void DrawAutorailSelection(const TileInfo *ti, HighLightStyle autorail_type, PaletteID pal = -1)
946d979
< 	PaletteID pal;
952c985
< 		static const uint _lower_rail[4] = { 5U, 2U, 4U, 3U };
---
> 		static const HighLightStyle _lower_rail[CORNER_END] = { HT_DIR_VR, HT_DIR_HU, HT_DIR_VL, HT_DIR_HL }; // CORNER_W, CORNER_S, CORNER_E, CORNER_N
960a994
> 	assert(autorail_type < HT_DIR_END);
964c998
< 		pal = PAL_NONE;
---
> 		if (pal == (PaletteID)-1) pal = _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE;
967c1001
< 		pal = PALETTE_SEL_TILE_RED;
---
> 		if (pal == (PaletteID)-1) pal = PALETTE_SEL_TILE_RED;
970c1004
< 	DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : pal, ti, 7, foundation_part);
---
> 	DrawSelectionSprite(image, pal, ti, 7, foundation_part);
983,984c1017,1018
< 	/* No tile selection active? */
< 	if ((_thd.drawstyle & HT_DRAG_MASK) == HT_NONE) return;
---
> 	switch (_thd.drawstyle & HT_DRAG_MASK) {
> 		default: break; // No tile selection active?
986,989c1020,1032
< 	if (_thd.diagonal) { // We're drawing a 45 degrees rotated (diagonal) rectangle
< 		if (IsInsideRotatedRectangle((int)ti->x, (int)ti->y)) goto draw_inner;
< 		return;
< 	}
---
> 		case HT_RECT:
> 			if (!is_redsq) {
> 				if (IsInsideSelectedRectangle(ti->x, ti->y)) {
> 					DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE);
> 				} else if (_thd.outersize.x > 0 &&
> 						/* Check if it's inside the outer area? */
> 						IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
> 						IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
> 					/* Draw a blue rect. */
> 					DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE);
> 				}
> 			}
> 			break;
991,1010c1034,1049
< 	/* Inside the inner area? */
< 	if (IsInsideBS(ti->x, _thd.pos.x, _thd.size.x) &&
< 			IsInsideBS(ti->y, _thd.pos.y, _thd.size.y)) {
< draw_inner:
< 		if (_thd.drawstyle & HT_RECT) {
< 			if (!is_redsq) DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE);
< 		} else if (_thd.drawstyle & HT_POINT) {
< 			/* Figure out the Z coordinate for the single dot. */
< 			int z = 0;
< 			FoundationPart foundation_part = FOUNDATION_PART_NORMAL;
< 			if (ti->tileh & SLOPE_N) {
< 				z += TILE_HEIGHT;
< 				if (RemoveHalftileSlope(ti->tileh) == SLOPE_STEEP_N) z += TILE_HEIGHT;
< 			}
< 			if (IsHalftileSlope(ti->tileh)) {
< 				Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh);
< 				if ((halftile_corner == CORNER_W) || (halftile_corner == CORNER_E)) z += TILE_HEIGHT;
< 				if (halftile_corner != CORNER_S) {
< 					foundation_part = FOUNDATION_PART_HALFTILE;
< 					if (IsSteepSlope(ti->tileh)) z -= TILE_HEIGHT;
---
> 		case HT_POINT:
> 			if (IsInsideSelectedRectangle(ti->x, ti->y)) {
> 				/* Figure out the Z coordinate for the single dot. */
> 				int z = 0;
> 				FoundationPart foundation_part = FOUNDATION_PART_NORMAL;
> 				if (ti->tileh & SLOPE_N) {
> 					z += TILE_HEIGHT;
> 					if (RemoveHalftileSlope(ti->tileh) == SLOPE_STEEP_N) z += TILE_HEIGHT;
> 				}
> 				if (IsHalftileSlope(ti->tileh)) {
> 					Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh);
> 					if ((halftile_corner == CORNER_W) || (halftile_corner == CORNER_E)) z += TILE_HEIGHT;
> 					if (halftile_corner != CORNER_S) {
> 						foundation_part = FOUNDATION_PART_HALFTILE;
> 						if (IsSteepSlope(ti->tileh)) z -= TILE_HEIGHT;
> 					}
1011a1051
> 				DrawSelectionSprite(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti, z, foundation_part);
1013,1022c1053
< 			DrawSelectionSprite(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti, z, foundation_part);
< 		} else if (_thd.drawstyle & HT_RAIL) {
< 			/* autorail highlight piece under cursor */
< 			HighLightStyle type = _thd.drawstyle & HT_DIR_MASK;
< 			assert(type < HT_DIR_END);
< 			DrawAutorailSelection(ti, _autorail_type[type][0]);
< 		} else if (IsPartOfAutoLine(ti->x, ti->y)) {
< 			/* autorail highlighting long line */
< 			HighLightStyle dir = _thd.drawstyle & HT_DIR_MASK;
< 			uint side;
---
> 			break;
1024,1028c1055,1058
< 			if (dir == HT_DIR_X || dir == HT_DIR_Y) {
< 				side = 0;
< 			} else {
< 				TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
< 				side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile)));
---
> 		case HT_RAIL:
> 			if (ti->tile == TileVirtXY(_thd.pos.x, _thd.pos.y)) {
> 				assert((_thd.drawstyle & HT_DIR_MASK) < HT_DIR_END);
> 				DrawAutorailSelection(ti, _thd.drawstyle & HT_DIR_MASK);
1029a1060
> 			break;
1031c1062,1070
< 			DrawAutorailSelection(ti, _autorail_type[dir][side]);
---
> 		case HT_LINE: {
> 			HighLightStyle type = GetPartOfAutoLine(ti->x, ti->y, _thd.selstart, _thd.selend, _thd.drawstyle & HT_DIR_MASK);
> 			if (type < HT_DIR_END) {
> 				DrawAutorailSelection(ti, type);
> 			} else if (_thd.dir2 < HT_DIR_END) {
> 				type = GetPartOfAutoLine(ti->x, ti->y, _thd.selstart2, _thd.selend2, _thd.dir2);
> 				if (type < HT_DIR_END) DrawAutorailSelection(ti, type, PALETTE_SEL_TILE_BLUE);
> 			}
> 			break;
1033d1071
< 		return;
1034a1073
> }
1036,1042c1075,1087
< 	/* Check if it's inside the outer area? */
< 	if (!is_redsq && _thd.outersize.x > 0 &&
< 			IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
< 			IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
< 		/* Draw a blue rect. */
< 		DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE);
< 		return;
---
> void SetIndustryForbiddenTilesHighlight(IndustryType type) {
> 	if (_settings_client.gui.show_industry_forbidden_tiles &&
> 	    	_industry_forbidden_tiles != type) {
> 		MarkWholeScreenDirty();
> 	}
> 	_industry_forbidden_tiles = type;
> }
> 
> static void DrawIndustryForbiddenTiles(const TileInfo *ti) {
> 	if (_settings_client.gui.show_industry_forbidden_tiles &&
> 			_industry_forbidden_tiles != INVALID_INDUSTRYTYPE &&
> 			!CanBuildIndustryOnTile(_industry_forbidden_tiles, ti->tile)) {
> 		DrawTileSelectionRect(ti, PALETTE_SEL_TILE_RED);
1169c1214,1218
< 				if (tile_info.tile != INVALID_TILE) DrawTileSelection(&tile_info);
---
> 				if (tile_info.tile != INVALID_TILE){
> 					DrawTileZoning(&tile_info);
> 					DrawIndustryForbiddenTiles(&tile_info);
> 					DrawTileSelection(&tile_info);
> 				}
1224,1225c1273
< 				_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN,
< 				STR_VIEWPORT_TOWN_TINY_WHITE, STR_VIEWPORT_TOWN_TINY_BLACK,
---
> 				t->Label(), t->SmallLabel(), STR_VIEWPORT_TOWN_TINY_BLACK,
1811c1859
< 		if (_thd.outersize.x != 0) {
---
> 		if (_thd.outersize.x != 0 || _thd.outersize.y != 0) {
1947c1995,1996
< 			ShowTownViewWindow(t->index);
---
>  			if (_ctrl_pressed) TownExecuteAction(t, 4); //build statue
>  			else ShowTownViewWindow(t->index);
2034c2083
< bool HandleViewportClicked(const ViewPort *vp, int x, int y)
---
> bool HandleViewportClicked(const ViewPort *vp, int x, int y, bool double_click)
2043a2093,2104
> 		if (_thd.place_mode & HT_POLY) {
> 			/* In polyline mode double-clicking on a single white line, finishes current polyline.
> 			 * If however the user double-clicks on a line that has a white and a blue section,
> 			 * both lines (white and blue) will be constructed consecutively. */
> 			static bool stop_snap_on_double_click = false;
> 			if (double_click && stop_snap_on_double_click) {
> 				SetRailSnapMode(RSM_NO_SNAP);
> 				return true;
> 			}
> 			stop_snap_on_double_click = !(_thd.drawstyle & HT_LINE) || (_thd.dir2 == HT_DIR_END);
> 		}
> 
2058c2119,2120
< 				StartStopVehicle(v, true);
---
> 				if (_settings_client.gui.enable_ctrl_click_start_stop)
> 					StartStopVehicle(v, true);
2170,2171c2232,2233
< 	_thd.offs.x = ox * TILE_SIZE;
< 	_thd.offs.y = oy * TILE_SIZE;
---
> 	_thd.new_offs.x = ox * TILE_SIZE;
> 	_thd.new_offs.y = oy * TILE_SIZE;
2210a2273
> static HighLightStyle CalcPolyrailDrawstyle(Point pt, bool dragging);
2211a2275,2303
> /** Update size of the area occupied by the blue part of rail track highlight (polyline mode). */
> static inline void CalcNewPolylineOutersize()
> {
> 	/* use the 'outersize' to mark the second (blue) part of a polyline selection */
> 	if (_thd.dir2 < HT_DIR_END) {
> 		/* get bounds of the second part */
> 		int outer_x1 = _thd.selstart2.x & ~TILE_UNIT_MASK;
> 		int outer_y1 = _thd.selstart2.y & ~TILE_UNIT_MASK;
> 		int outer_x2 = _thd.selend2.x & ~TILE_UNIT_MASK;
> 		int outer_y2 = _thd.selend2.y & ~TILE_UNIT_MASK;
> 		if (outer_x1 > outer_x2) Swap(outer_x1, outer_x2);
> 		if (outer_y1 > outer_y2) Swap(outer_y1, outer_y2);
> 		/* include the first part */
> 		outer_x1 = min<int>(outer_x1, _thd.new_pos.x);
> 		outer_y1 = min<int>(outer_y1, _thd.new_pos.y);
> 		outer_x2 = max<int>(outer_x2, _thd.new_pos.x + _thd.new_size.x - TILE_SIZE);
> 		outer_y2 = max<int>(outer_y2, _thd.new_pos.y + _thd.new_size.y - TILE_SIZE);
> 		/* write new values */
> 		_thd.new_offs.x = outer_x1 - _thd.new_pos.x;
> 		_thd.new_offs.y = outer_y1 - _thd.new_pos.y;
> 		_thd.new_outersize.x = outer_x2 - outer_x1 + TILE_SIZE - _thd.new_size.x;
> 		_thd.new_outersize.y = outer_y2 - outer_y1 + TILE_SIZE - _thd.new_size.y;
> 	} else {
> 		_thd.new_offs.x = 0;
> 		_thd.new_offs.y = 0;
> 		_thd.new_outersize.x = 0;
> 		_thd.new_outersize.y = 0;
> 	}
> }
2268,2270d2359
< 					/* Draw one highlighted tile in any direction */
< 					new_drawstyle = GetAutorailHT(pt.x, pt.y);
< 					break;
2271a2361,2395
> 					/* HT_POLY */
> 					if (_thd.place_mode & HT_POLY) {
> 						RailSnapMode snap_mode = GetRailSnapMode();
> 						if (snap_mode == RSM_NO_SNAP ||
> 								(snap_mode == RSM_SNAP_TO_TILE && GetRailSnapTile() == TileVirtXY(pt.x, pt.y))) {
> 							new_drawstyle = GetAutorailHT(pt.x, pt.y);
> 							_thd.new_offs.x = 0;
> 							_thd.new_offs.y = 0;
> 							_thd.new_outersize.x = 0;
> 							_thd.new_outersize.y = 0;
> 							_thd.dir2 = HT_DIR_END;
> 						} else {
> 							new_drawstyle = CalcPolyrailDrawstyle(pt, false);
> 							if (new_drawstyle != HT_NONE) {
> 								x1 = _thd.selstart.x & ~TILE_UNIT_MASK;
> 								y1 = _thd.selstart.y & ~TILE_UNIT_MASK;
> 								int x2 = _thd.selend.x & ~TILE_UNIT_MASK;
> 								int y2 = _thd.selend.y & ~TILE_UNIT_MASK;
> 								if (x1 > x2) Swap(x1, x2);
> 								if (y1 > y2) Swap(y1, y2);
> 								_thd.new_pos.x = x1;
> 								_thd.new_pos.y = y1;
> 								_thd.new_size.x = x2 - x1 + TILE_SIZE;
> 								_thd.new_size.y = y2 - y1 + TILE_SIZE;
> 							}
> 						}
> 						break;
> 					}
> 					/* HT_RAIL */
> 					if (_thd.place_mode & HT_RAIL) {
> 						/* Draw one highlighted tile in any direction */
> 						new_drawstyle = GetAutorailHT(pt.x, pt.y);
> 						break;
> 					}
> 					/* HT_LINE */
2289a2414,2416
> 					_thd.selend.x = x1;
> 					_thd.selend.y = y1;
> 					_thd.dir2 = HT_DIR_END;
2298a2426,2427
> 	if (new_drawstyle & HT_LINE) CalcNewPolylineOutersize();
> 
2302a2432
> 			_thd.offs.x != _thd.new_offs.x || _thd.offs.y != _thd.new_offs.y ||
2311a2442
> 		_thd.offs = _thd.new_offs;
2330d2460
< 	if (!_settings_client.gui.measure_tooltip) return;
2365a2496,2500
> 		_current_snap_lock.x = -1;
> 		if ((_thd.place_mode & HT_POLY) != 0 && GetRailSnapMode() == RSM_NO_SNAP) {
> 			SetRailSnapMode(RSM_SNAP_TO_TILE);
> 			SetRailSnapTile(tile);
> 		}
2394c2529
< 	if (distance > 1) {
---
> 	if (distance > 1  && _settings_client.gui.measure_tooltip) {
2561c2696,2728
< static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF};
---
> /**
>  * Show a tooltip indicating the length of highlighted rail track.
>  * @param style                   Style of the highlight.
>  * @param start_tile              Tile where selection starts.
>  * @param end_tile                Tile where selection ends.
>  * @param close_cond              Close condition of the tooltip.
>  * @param show_single_tile_length Show a tooltip also when the length is 1 tile.
>  */
> static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_NONE, bool show_single_tile_length = false)
> {
> 	static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF};
> 
> 	if (_settings_client.gui.measure_tooltip) {
> 		uint distance = DistanceManhattan(start_tile, end_tile) + 1;
> 		byte index = 0;
> 		uint64 params[2];
> 
> 		if (show_single_tile_length || distance != 1) {
> 			int heightdiff = CalcHeightdiff(style, distance, start_tile, end_tile);
> 			/* If we are showing a tooltip for horizontal or vertical drags,
> 			 * 2 tiles have a length of 1. To bias towards the ceiling we add
> 			 * one before division. It feels more natural to count 3 lengths as 2 */
> 			if ((style & HT_DIR_MASK) != HT_DIR_X && (style & HT_DIR_MASK) != HT_DIR_Y) {
> 				distance = CeilDiv(distance, 2);
> 			}
> 
> 			params[index++] = distance;
> 			if (heightdiff != 0) params[index++] = heightdiff;
> 		}
> 
> 		ShowMeasurementTooltips(measure_strings_length[index], index, params, close_cond);
> 	}
> }
2591a2759,2950
> static const uint X_DIRS = (1 << DIR_NE) | (1 << DIR_SW);
> static const uint Y_DIRS = (1 << DIR_SE) | (1 << DIR_NW);
> static const uint HORZ_DIRS = (1 << DIR_W) | (1 << DIR_E);
> static const uint VERT_DIRS = (1 << DIR_N) | (1 << DIR_S);
> 
> /**
>  * Convert a given point and a given #Direction to best matching #Trackdir.
>  *
>  * For example, #DIR_N will be converted to #TRACKDIR_LEFT_N if the point
>  * is on left tile half or #TRACKDIR_RIGHT_N if the point is on right half.
>  *
>  * @param pt  The point expressed in inner-tile world "units".
>  * @param dir The direction.
>  * @return The matching #Trackdir.
>  */
> Trackdir PointDirToTrackdir(const Point &pt, Direction dir)
> {
> 	Trackdir ret;
> 
> 	if (IsDiagonalDirection(dir)) {
> 		ret = DiagDirToDiagTrackdir(DirToDiagDir(dir));
> 	} else {
> 		int x = pt.x & TILE_UNIT_MASK;
> 		int y = pt.y & TILE_UNIT_MASK;
> 		int ns = x + y;
> 		int we = y - x;
> 		if (HasBit(HORZ_DIRS, dir)) {
> 			ret = TrackDirectionToTrackdir(ns < (int)TILE_SIZE ? TRACK_UPPER : TRACK_LOWER, dir);
> 		} else {
> 			ret = TrackDirectionToTrackdir(we < 0 ? TRACK_LEFT : TRACK_RIGHT, dir);
> 		}
> 	}
> 
> 	return ret;
> }
> 
> /**
>  * Try to fit a pair of rail track lines (polyline) based on a given end point
>  * (mouse cursor position) and a given snap point (begin point).
>  *
>  * @param pt       The end point expressed in inner-tile world "units".
>  * @param start    The snap point, begin of the lines.
>  * @param[out] ret Coordinates of the lines (if found).
>  * @return Whether the lines were found.
>  */
> 
> static bool FindPolyline(const Point &pt, const LineSnapPoint &start, RailPolyline *ret) {
> 	/* relative coordinates of the mouse point (offset against the snap point) */
> 	int x = pt.x - start.x;
> 	int y = pt.y - start.y;
> 	int we = y - x;
> 	int ns = x + y;
> 
> 	/* in-tile alignment of the snap point (there are two variants: [0, 8] or [8, 0]) */
> 	uint align_x = start.x & TILE_UNIT_MASK;
> 	uint align_y = start.y & TILE_UNIT_MASK;
> 	assert((align_x == TILE_SIZE / 2 && align_y == 0 && !(start.dirs & X_DIRS)) || (align_x == 0 && align_y == TILE_SIZE / 2 && !(start.dirs & Y_DIRS)));
> 
> 	/* absolute distance between points (in tiles) */
> 	uint d_x = abs(RoundDivSU(x < 0 ? x - align_y : x + align_y, TILE_SIZE));
> 	uint d_y = abs(RoundDivSU(y < 0 ? y - align_x : y + align_x, TILE_SIZE));
> 	uint d_ns = abs(RoundDivSU(ns, TILE_SIZE));
> 	uint d_we = abs(RoundDivSU(we, TILE_SIZE));
> 
> 	/* Find on which quadrant is the mouse point (relatively to the snap point).
> 	 * Numeration (clockwise like in Direction):
> 	 * ortho            diag
> 	 *   \   2   /       2 | 3
> 	 *     \   /         --+---> [we]
> 	 *  1    X    3      1 | 0
> 	 *     /   \           v
> 	 *  [x]  0  [y]       [ns]          */
> 	uint ortho_quadrant = 2 * (x < 0) + ((x < 0) != (y < 0)); // implicit cast: false/true --> 0/1
> 	uint diag_quadrant = 2 * (ns < 0) + ((ns < 0) != (we < 0));
> 
> 	/* direction from the snap point to the mouse point */
> 	Direction ortho_line_dir = ChangeDir(DIR_S, (DirDiff)(2 * ortho_quadrant)); // DIR_S is the middle of the ortho quadrant no. 0
> 	Direction diag_line_dir = ChangeDir(DIR_SE, (DirDiff)(2 * diag_quadrant));  // DIR_SE is the middle of the diag quadrant no. 0
> 	if (!HasBit(start.dirs, ortho_line_dir) && !HasBit(start.dirs, diag_line_dir)) return false;
> 
> 	/* length of booth segments of auto line (choosing orthogonal direction first) */
> 	uint ortho_len = 0, ortho_len2 = 0;
> 	if (HasBit(start.dirs, ortho_line_dir)) {
> 		bool is_len_even = (align_x != 0) ? d_x >= d_y : d_x <= d_y;
> 		ortho_len = 2 * min(d_x, d_y) - (int)is_len_even;
> 		assert((int)ortho_len >= 0);
> 		if (d_ns == 0 || d_we == 0) { // just single segment?
> 			ortho_len++;
> 		} else {
> 			ortho_len2 = abs((int)d_x - (int)d_y) + (int)is_len_even;
> 		}
> 	}
> 
> 	/* length of booth segments of auto line (choosing diagonal direction first) */
> 	uint diag_len = 0, diag_len2 = 0;
> 	if (HasBit(start.dirs, diag_line_dir)) {
> 		if (d_x == 0 || d_y == 0) { // just single segment?
> 			diag_len = d_x + d_y;
> 		} else {
> 			diag_len = min(d_ns, d_we);
> 			diag_len2 = d_x + d_y - diag_len;
> 		}
> 	}
> 
> 	/* choose the best variant */
> 	if (ortho_len != 0 && diag_len != 0) {
> 		/* in the first place, choose this line whose first segment ends up closer
> 		 * to the mouse point (thus the second segment is shorter) */
> 		int cmp = ortho_len2 - diag_len2;
> 		/* if equal, choose the shorter line */
> 		if (cmp == 0) cmp = ortho_len - diag_len;
> 		/* finally look at small "units" and choose the line which is closer to the mouse point */
> 		if (cmp == 0) cmp = min(abs(we), abs(ns)) - min(abs(x), abs(y));
> 		/* based on comparison, disable one of variants */
> 		if (cmp > 0) {
> 			ortho_len = 0;
> 		} else {
> 			diag_len = 0;
> 		}
> 	}
> 
> 	/* store results */
> 	if (ortho_len != 0) {
> 		ret->first_dir = ortho_line_dir;
> 		ret->first_len = ortho_len;
> 		ret->second_dir = (ortho_len2 != 0) ? diag_line_dir : INVALID_DIR;
> 		ret->second_len = ortho_len2;
> 	} else if (diag_len != 0) {
> 		ret->first_dir = diag_line_dir;
> 		ret->first_len = diag_len;
> 		ret->second_dir = (diag_len2 != 0) ? ortho_line_dir : INVALID_DIR;
> 		ret->second_len = diag_len2;
> 	} else {
> 		return false;
> 	}
> 
> 	ret->start = start;
> 	return true;
> }
> 
> /**
>  * Calculate squared euclidean distance between two points.
>  * @param a the first point
>  * @param b the second point
>  * @return |b - a| ^ 2
>  */
> static inline uint SqrDist(const Point &a, const Point &b)
> {
> 	return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
> }
> 
> /**
>  * Find best matching pair of lines (polyline).
>  *
>  * @param pt          The end point (mouse cursor position) expressed in inner-tile world "units".
>  * @param snap_points Array of snapping points, the best one will be chosen.
>  * @param num_points  Length of the array.
>  * @param[out] ret    Coordinates of the polyline (if found).
>  * @return The chosen snapping point or NULL if no matching line was found.
>  */
> static LineSnapPoint *FindBestPolyline(const Point &pt, LineSnapPoint *snap_points, uint num_points, RailPolyline *ret)
> {
> 	/* Find the best polyline (a pair of two lines - the white one and the blue
> 	 * one) led from any of saved snap points to the mouse cursor. */
> 
> 	LineSnapPoint *best_snap_point = NULL; // the best polyline we found so far is led from this snap point
> 
> 	for (int i = 0; i < (int)num_points; i++) {
> 		/* try to fit a polyline */
> 		RailPolyline polyline;
> 		if (!FindPolyline(pt, snap_points[i], &polyline)) continue; // skip non-matching snap points
> 		/* check whether we've found a better polyline */
> 		if (best_snap_point != NULL) {
> 			/* firstly choose shorter polyline (the one with smaller amount of
> 			 * track pieces composing booth the white and the blue line) */
> 			uint cur_len = polyline.first_len + polyline.second_len;
> 			uint best_len = ret->first_len + ret->second_len;
> 			if (cur_len > best_len) continue;
> 			/* secondly choose that polyline which has longer first (white) line */
> 			if (cur_len == best_len && polyline.first_len < ret->first_len) continue;
> 			/* finally check euclidean distance to snap points and choose the
> 			 * one which is closer */
> 			if (cur_len == best_len && polyline.first_len == ret->first_len && SqrDist(pt, snap_points[i]) >= SqrDist(pt, *best_snap_point)) continue;
> 		}
> 		/* save the found polyline */
> 		*ret = polyline;
> 		best_snap_point = &snap_points[i];
> 	}
> 
> 	return best_snap_point;
> }
> 
2778,2783c3137,3140
< 	if (_settings_client.gui.measure_tooltip) {
< 		TileIndex t0 = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
< 		TileIndex t1 = TileVirtXY(x, y);
< 		uint distance = DistanceManhattan(t0, t1) + 1;
< 		byte index = 0;
< 		uint64 params[2];
---
> 	_thd.selend.x = x;
> 	_thd.selend.y = y;
> 	_thd.dir2 = HT_DIR_END;
> 	_thd.next_drawstyle = b;
2785,2792c3142,3143
< 		if (distance != 1) {
< 			int heightdiff = CalcHeightdiff(b, distance, t0, t1);
< 			/* If we are showing a tooltip for horizontal or vertical drags,
< 			 * 2 tiles have a length of 1. To bias towards the ceiling we add
< 			 * one before division. It feels more natural to count 3 lengths as 2 */
< 			if ((b & HT_DIR_MASK) != HT_DIR_X && (b & HT_DIR_MASK) != HT_DIR_Y) {
< 				distance = CeilDiv(distance, 2);
< 			}
---
> 	ShowLengthMeasurement(b, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y));
> }
2794,2796c3145,3153
< 			params[index++] = distance;
< 			if (heightdiff != 0) params[index++] = heightdiff;
< 		}
---
> /**
>  * Calculate how tiles should be highlighted (polyline mode).
>  * @param pt       Current mouse cursor position expressed in inner-tile world "units".
>  * @param dragging Whether currently drag-dropping, in this case direction of rail track line is locked.
>  * @return New highlight style.
>  */
> static HighLightStyle CalcPolyrailDrawstyle(Point pt, bool dragging)
> {
> 	RailSnapMode snap_mode = GetRailSnapMode();
2798c3155,3159
< 		ShowMeasurementTooltips(measure_strings_length[index], index, params);
---
> 	/* are we only within one tile? */
> 	if (snap_mode == RSM_SNAP_TO_TILE && GetRailSnapTile() == TileVirtXY(pt.x, pt.y)) {
> 		_thd.selend.x = pt.x;
> 		_thd.selend.y = pt.y;
> 		return GetAutorailHT(pt.x, pt.y);
2801,2803c3162,3219
< 	_thd.selend.x = x;
< 	_thd.selend.y = y;
< 	_thd.next_drawstyle = b;
---
> 	/* find the best track */
> 	RailPolyline line;
> 
> 	bool lock_snapping = dragging && snap_mode == RSM_SNAP_TO_RAIL;
> 	if (!lock_snapping) _current_snap_lock.x = -1;
> 
> 	const LineSnapPoint *snap_point;
> 	if (_current_snap_lock.x != -1) {
> 		snap_point = FindBestPolyline(pt, &_current_snap_lock, 1, &line);
> 	} else if (snap_mode == RSM_SNAP_TO_TILE) {
> 		snap_point = FindBestPolyline(pt, _tile_snap_points.Begin(), _tile_snap_points.Length(), &line);
> 	} else {
> 		assert(snap_mode == RSM_SNAP_TO_RAIL);
> 		snap_point = FindBestPolyline(pt, _rail_snap_points.Begin(), _rail_snap_points.Length(), &line);
> 	}
> 
> 	if (snap_point == NULL) return HT_NONE; // no match
> 
> 	if (lock_snapping && _current_snap_lock.x == -1) {
> 		/* lock down the snap point */
> 		_current_snap_lock = *snap_point;
> 		_current_snap_lock.dirs &= (1 << line.first_dir) | (1 << ReverseDir(line.first_dir));
> 	}
> 
> 	TileIndexDiffC first_dir = TileIndexDiffCByDir(line.first_dir);
> 	_thd.selstart.x  = line.start.x;
> 	_thd.selstart.y  = line.start.y;
> 	_thd.selend.x    = _thd.selstart.x + line.first_len * first_dir.x * (IsDiagonalDirection(line.first_dir) ? TILE_SIZE : TILE_SIZE / 2);
> 	_thd.selend.y    = _thd.selstart.y + line.first_len * first_dir.y * (IsDiagonalDirection(line.first_dir) ? TILE_SIZE : TILE_SIZE / 2);
> 	_thd.selstart2.x = _thd.selend.x;
> 	_thd.selstart2.y = _thd.selend.y;
> 	_thd.selstart.x  += first_dir.x;
> 	_thd.selstart.y  += first_dir.y;
> 	_thd.selend.x    -= first_dir.x;
> 	_thd.selend.y    -= first_dir.y;
> 	Trackdir seldir = PointDirToTrackdir(_thd.selstart, line.first_dir);
> 	_thd.selstart.x  &= ~TILE_UNIT_MASK;
> 	_thd.selstart.y  &= ~TILE_UNIT_MASK;
> 
> 	if (line.second_len != 0) {
> 		TileIndexDiffC second_dir = TileIndexDiffCByDir(line.second_dir);
> 		_thd.selend2.x   = _thd.selstart2.x + line.second_len * second_dir.x * (IsDiagonalDirection(line.second_dir) ? TILE_SIZE : TILE_SIZE / 2);
> 		_thd.selend2.y   = _thd.selstart2.y + line.second_len * second_dir.y * (IsDiagonalDirection(line.second_dir) ? TILE_SIZE : TILE_SIZE / 2);
> 		_thd.selstart2.x += second_dir.x;
> 		_thd.selstart2.y += second_dir.y;
> 		_thd.selend2.x   -= second_dir.x;
> 		_thd.selend2.y   -= second_dir.y;
> 		Trackdir seldir2 = PointDirToTrackdir(_thd.selstart2, line.second_dir);
> 		_thd.selstart2.x &= ~TILE_UNIT_MASK;
> 		_thd.selstart2.y &= ~TILE_UNIT_MASK;
> 		_thd.dir2 = (HighLightStyle)TrackdirToTrack(seldir2);
> 	} else {
> 		_thd.dir2 = HT_DIR_END;
> 	}
> 
> 	HighLightStyle ret = HT_LINE | (HighLightStyle)TrackdirToTrack(seldir);
> 	ShowLengthMeasurement(ret, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), TCC_HOVER, true);
> 	return ret;
2822a3239,3244
> 	if ((_thd.place_mode & HT_POLY) && GetRailSnapMode() != RSM_NO_SNAP) {
> 		Point pt = { x, y };
> 		_thd.next_drawstyle = CalcPolyrailDrawstyle(pt, true);
> 		return;
> 	}
> 
2875,2895c3297,3302
< 			if (_settings_client.gui.measure_tooltip) {
< 				TileIndex t0 = TileVirtXY(sx, sy);
< 				TileIndex t1 = TileVirtXY(x, y);
< 				uint distance = DistanceManhattan(t0, t1) + 1;
< 				byte index = 0;
< 				uint64 params[2];
< 
< 				if (distance != 1) {
< 					/* With current code passing a HT_LINE style to calculate the height
< 					 * difference is enough. However if/when a point-tool is created
< 					 * with this method, function should be called with new_style (below)
< 					 * instead of HT_LINE | style case HT_POINT is handled specially
< 					 * new_style := (_thd.next_drawstyle & HT_RECT) ? HT_LINE | style : _thd.next_drawstyle; */
< 					int heightdiff = CalcHeightdiff(HT_LINE | style, 0, t0, t1);
< 
< 					params[index++] = distance;
< 					if (heightdiff != 0) params[index++] = heightdiff;
< 				}
< 
< 				ShowMeasurementTooltips(measure_strings_length[index], index, params);
< 			}
---
> 			/* With current code passing a HT_LINE style to calculate the height
> 			 * difference is enough. However if/when a point-tool is created
> 			 * with this method, function should be called with new_style (below)
> 			 * instead of HT_LINE | style case HT_POINT is handled specially
> 			 * new_style := (_thd.next_drawstyle & HT_RECT) ? HT_LINE | style : _thd.next_drawstyle; */
> 			ShowLengthMeasurement(HT_LINE | style, TileVirtXY(sx, sy), TileVirtXY(x, y));
2905c3312
< 			if (_settings_client.gui.measure_tooltip) {
---
> 			if (_settings_client.gui.measure_tooltip || _thd.select_proc == DDSP_MEASURE) {
2907c3314,3315
< 					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
---
> 					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF,
> 					STR_MEASURE_DIST_HEIGHTDIFF,
2915c3323
< 				uint64 params[3];
---
> 				uint64 params[4];
2962c3370,3376
< 					if (heightdiff != 0) params[index++] = heightdiff;
---
> 
> 					if (_thd.select_proc == DDSP_MEASURE) {
> 						params[index++] = sqrtl(dx * dx + dy * dy);
> 					}
> 
> 					if (heightdiff != 0 || index == 3)
> 						params[index++] = heightdiff;
2973a3388
> 	_thd.dir2 = HT_DIR_END;
2991,2995c3406,3409
< 	/* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */
< 	if (_left_button_down) {
< 		w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor());
< 		return ES_HANDLED;
< 	}
---
> 	/* While dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ).
> 	 * Do it even if the button is no longer pressed to make sure that OnPlaceDrag was called at least once. */
> 	w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor());
> 	if (_left_button_down) return ES_HANDLED;
3006c3420
< 		_thd.place_mode = (_thd.select_method & ~VPM_RAILDIRS) ? _thd.next_drawstyle : (HT_RAIL | others);
---
> 		_thd.place_mode = (_thd.select_method & ~VPM_RAILDIRS ? _thd.next_drawstyle : HT_RAIL) | others;
3051,3054c3464
< 		if (w != NULL) {
< 			w->OnPlaceObjectAbort();
< 			HideMeasurementTooltips();
< 		}
---
> 		if (w != NULL) w->OnPlaceObjectAbort();
3165a3576,3781
> }
> 
> /**
>  * Construct a rail snapping point based on a spot where a rail tracks segment
>  * has been placed.
>  *
>  * The snapping point will allow to stick new segment of tracks to the line that
>  * was placed before.
>  *
>  * @param tile Tile where the placed segment ended.
>  * @param exit_dir Tile side at which the segment ended.
>  * @param bidirectional Whether to allow to reverse at this point
>  *        (e.g. reversing after a bridges/tunnels is undesired).
>  * @param extended If not \c NULL, the snapping point will be extended over
>  *        a bridge/tunnel/station etc. if the last placed segment touches such
>  *        an object. Additional snapping point may be stored under \a extended
>  *        if needed, otherwise it will be set to { -1, -1, 0 }.
>  * @return New rail snapping point.
>  */
> static LineSnapPoint LineSnapPointAtRailTrackEndpoint(TileIndex tile, DiagDirection exit_dir, bool bidirectional, LineSnapPoint *extended)
> {
> 	LineSnapPoint ret;
> 	ret.x = (TILE_SIZE / 2) * (uint)(2 * TileX(tile) + TileIndexDiffCByDiagDir(exit_dir).x + 1);
> 	ret.y = (TILE_SIZE / 2) * (uint)(2 * TileY(tile) + TileIndexDiffCByDiagDir(exit_dir).y + 1);
> 	ret.dirs = 0;
> 	if (extended != NULL) {
> 		extended->x = -1;
> 		extended->y = -1;
> 		extended->dirs = 0;
> 	}
> 
> 	/* Check whether to extend the snap point over a tunnel/bridge/station etc. */
> 	tile = TileAddByDiagDir(tile, exit_dir);
> 	if (extended != NULL && !IsTileType(tile, MP_RAILWAY) && !IsTileType(tile, MP_ROAD) &&
> 			TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, INVALID_DIAGDIR)) == AxisToTrackBits(DiagDirToAxis(exit_dir)) &&
> 			IsTileOwner(tile, _local_company)) {
> 		/* Check if this is a tunnel/bridge and move the tile to the other end if so. */
> 		if (IsTileType(tile, MP_TUNNELBRIDGE)) tile = GetOtherTunnelBridgeEnd(tile);
> 		LineSnapPoint ex = LineSnapPointAtRailTrackEndpoint(tile, exit_dir, false, extended);
> 		if (!bidirectional) return ex; // if we are interested in forward direction only then return just the extended point
> 		*extended = ex; // otherwise return two points, extended with forward direction and base with reverse direction
> 	} else {
> 		/* Add forward direction. */
> 		SetBit(ret.dirs, DiagDirToDir(exit_dir));
> 	}
> 
> 	/* Add reverse direction. */
> 	if (bidirectional) SetBit(ret.dirs, ReverseDir(DiagDirToDir(exit_dir)));
> 
> 	/* Add 45 degree rotated directions. */
> 	ret.dirs |= ROR<uint8>(ret.dirs, DIRDIFF_45LEFT);
> 	ret.dirs |= ROR<uint8>(ret.dirs, DIRDIFF_45RIGHT);
> 	return ret;
> }
> 
> /**
>  * Store the position of lastly built rail track; for highlighting purposes.
>  *
>  * In "polyline" highlighting mode, the stored end point will be used as a snapping point for new
>  * tracks allowing to place multi-segment polylines.
>  *
>  * @param start_tile         tile where the track starts
>  * @param end_tile           tile where the track ends
>  * @param start_track        track piece on the start_tile
>  * @param bidirectional_exit whether to allow to highlight next track in any direction; otherwise new track will have to fallow the stored one (usefull when placing tunnels and bridges)
>  */
> void StoreRailPlacementEndpoints(TileIndex start_tile, TileIndex end_tile, Track start_track, bool bidirectional_exit)
> {
> 	if (start_tile != INVALID_TILE && end_tile != INVALID_TILE) {
> 		/* calculate trackdirs at booth ends of the track */
> 		Trackdir exit_trackdir_at_start = TrackToTrackdir(start_track);
> 		Trackdir exit_trackdir_at_end = ReverseTrackdir(TrackToTrackdir(start_track));
> 		if (start_tile != end_tile) { // multi-tile case
> 			/* determine proper direction (pointing outside of the track) */
> 			uint distance = DistanceManhattan(start_tile, end_tile);
> 			if (distance > DistanceManhattan(TileAddByDiagDir(start_tile, TrackdirToExitdir(exit_trackdir_at_start)), end_tile)) {
> 				Swap(exit_trackdir_at_start, exit_trackdir_at_end);
> 			}
> 			/* determine proper track on the end tile - switch between upper/lower or left/right based on the length */
> 			if (distance % 2 != 0) exit_trackdir_at_end = NextTrackdir(exit_trackdir_at_end);
> 		}
> 
> 		LineSnapPoint snap_start, snap_start_ex, snap_end, snap_end_ex;
> 		snap_start = LineSnapPointAtRailTrackEndpoint(start_tile, TrackdirToExitdir(exit_trackdir_at_start), bidirectional_exit, &snap_start_ex);
> 		snap_end = LineSnapPointAtRailTrackEndpoint(end_tile, TrackdirToExitdir(exit_trackdir_at_end), bidirectional_exit, &snap_end_ex);
> 		/* Find if we already had these coordinates before. */
> 		LineSnapPoint *snap;
> 		bool had_start = false;
> 		bool had_end = false;
> 		for (snap = _rail_snap_points.Begin(); snap != _rail_snap_points.End(); snap++) {
> 			had_start |= (snap->x == snap_start.x && snap->y == snap_start.y);
> 			had_end |= (snap->x == snap_end.x && snap->y == snap_end.y);
> 		}
> 		/* Create new snap point set. */
> 		if (had_start && had_end) {
> 			/* just stop snapping, don't forget snap points */
> 			SetRailSnapMode(RSM_NO_SNAP);
> 		} else {
> 			/* include only new points */
> 			_rail_snap_points.Clear();
> 			if (!had_start) {
> 				*_rail_snap_points.Append() = snap_start;
> 				if (snap_start_ex.dirs != 0) *_rail_snap_points.Append() = snap_start_ex;
> 			}
> 			if (!had_end) {
> 				*_rail_snap_points.Append() = snap_end;
> 				if (snap_end_ex.dirs != 0) *_rail_snap_points.Append() = snap_end_ex;
> 			}
> 			SetRailSnapMode(RSM_SNAP_TO_RAIL);
> 		}
> 	}
> }
> 
> /**
>  * Store the position of lastly built rail station; for highlighting purposes.
>  *
>  * In "polyline" highlighting mode, the stored end points will be used as snapping points for new tracks.
>  *
>  * @param ta           Station area.
>  * @param station_axis Station axis.
>  */
> void StoreRailStationPlacementEndpoints(const TileArea &ta, Axis station_axis)
> {
> 	uint start_x = TileX(ta.tile);
> 	uint start_y = TileY(ta.tile);
> 	uint end_x = start_x + ta.w - 1;
> 	uint end_y = start_y + ta.h - 1;
> 
> 	_rail_snap_points.Clear();
> 	if (station_axis == AXIS_X) {
> 		for (uint y = start_y; y <= end_y; y++) {
> 			*_rail_snap_points.Append() = LineSnapPointAtRailTrackEndpoint(TileXY(start_x, y), DIAGDIR_NE, false, NULL);
> 			*_rail_snap_points.Append() = LineSnapPointAtRailTrackEndpoint(TileXY(end_x, y), DIAGDIR_SW, false, NULL);
> 		}
> 	} else {
> 		for (uint x = start_x; x <= end_x; x++) {
> 			*_rail_snap_points.Append() = LineSnapPointAtRailTrackEndpoint(TileXY(x, start_y), DIAGDIR_NW, false, NULL);
> 			*_rail_snap_points.Append() = LineSnapPointAtRailTrackEndpoint(TileXY(x, end_y), DIAGDIR_SE, false, NULL);
> 		}
> 	}
> }
> 
> /**
>  * Get current rail track snapping mode.
>  * @return Current snapping mode.
>  *
>  * @note This function will return #RSM_NO_SNAP if there are no snapping points
>  *       set (yet), even thought the snapping was set to some different mode.
>  */
> RailSnapMode GetRailSnapMode()
> {
> 	if (_rail_snap_mode == RSM_SNAP_TO_TILE && _tile_snap_points.Length() == 0) return RSM_NO_SNAP;
> 	if (_rail_snap_mode == RSM_SNAP_TO_RAIL && _rail_snap_points.Length() == 0) return RSM_NO_SNAP;
> 	return _rail_snap_mode;
> }
> 
> /**
>  * Set current current rail track snapping mode.
>  * @param mode New snapping mode.
>  */
> void SetRailSnapMode(RailSnapMode mode)
> {
> 	_rail_snap_mode = mode;
> 
> 	if ((_thd.place_mode & HT_POLY) && (GetRailSnapMode() == RSM_NO_SNAP)) {
> 		SetTileSelectSize(1, 1);
> 	}
> }
> 
> /**
>  * Get the tile that is set to be a snapping point for rail tracks (used when
>  * #RSM_SNAP_TO_TILE mode is active).
>  *
>  * @return The tile.
>  */
> static TileIndex GetRailSnapTile()
> {
> 	if (_tile_snap_points.Length() == 0) return INVALID_TILE;
> 	return TileVirtXY(_tile_snap_points[DIAGDIR_NE].x, _tile_snap_points[DIAGDIR_NE].y);
> }
> 
> /**
>  * Set the tile that is meant to be a snapping point for rail tracks (used when
>  * #RSM_SNAP_TO_TILE mode is active).
>  *
>  * @param tile The tile.
>  */
> static void SetRailSnapTile(TileIndex tile)
> {
> 	_tile_snap_points.Clear();
> 	if (tile == INVALID_TILE) return;
> 
> 	for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
> 		LineSnapPoint *point = _tile_snap_points.Append();
> 		*point = LineSnapPointAtRailTrackEndpoint(tile, dir, false, NULL);
> 		point->dirs = ROR<uint8>(point->dirs, DIRDIFF_REVERSE);
> 	}
> }
> 
> /** Clear all stored rail snapping points and reset the snapping mode. */
> void ResetRailPlacementEndpoints()
> {
> 	_rail_snap_mode = RSM_NO_SNAP;
> 	_tile_snap_points.Clear();
> 	_rail_snap_points.Clear();
> 	_current_snap_lock.x = -1;
diff -r -B -X .diff-exclude vanilla/src/viewport_func.h cmclient/src/viewport_func.h
63c63
< bool HandleViewportClicked(const ViewPort *vp, int x, int y);
---
> bool HandleViewportClicked(const ViewPort *vp, int x, int y, bool double_click);
diff -r -B -X .diff-exclude vanilla/src/viewport_gui.cpp cmclient/src/viewport_gui.cpp
156a157,161
> 
> 	virtual void OnMouseOver(Point pt, int widget)
> 	{
> 		if (pt.x != -1) GuiPrepareTooltipsExtra(this);
> 	}
diff -r -B -X .diff-exclude vanilla/src/viewport_type.h cmclient/src/viewport_type.h
98a99
> 	DDSP_DEMOLISH_TREES,       ///< Clear trees
107a109
> 	DDSP_MEASURE,              ///< Measurement tool
119a122
> 	DDSP_PLACE_FULLROAD,       ///< Road placement (auto, full roads)
Only in cmclient/src: watch_gui.cpp
Only in cmclient/src: watch_gui.h
diff -r -B -X .diff-exclude vanilla/src/widget.cpp cmclient/src/widget.cpp
220c220
< 	assert(img != 0);
---
> 
221a222
> 	if (img == 0) return;
Only in cmclient/src/widgets: cargo_table_widget.h
diff -r -B -X .diff-exclude vanilla/src/widgets/company_widget.h cmclient/src/widgets/company_widget.h
54a55,60
> 
> 	WID_C_SELECT_MOD,
> 	WID_C_SELECT_MOD_JOIN,
> 	WID_C_MOD_COMPANY_JOIN,
> 	WID_C_MOD_COMPANY_RESET,
> 	WID_C_MOD_COMPANY_TOGGLE_LOCK,
diff -r -B -X .diff-exclude vanilla/src/widgets/dropdown.cpp cmclient/src/widgets/dropdown.cpp
46c46,51
< 
---
> /*
> const char * DropDownListCharStringItem::String() const
> {
> 	return this->string;
> }
> */
diff -r -B -X .diff-exclude vanilla/src/widgets/dropdown_type.h cmclient/src/widgets/dropdown_type.h
18a19,23
> #include "../stdafx.h"
> #include "../window_gui.h"
> #include "../string_func.h"
> #include "../strings_func.h"
> #include "../window_func.h"
49a55
> 	//virtual const char * String() const;
55a62,94
> /**
>  * Drop down list entry for showing a checked/unchecked toggle item. Use
>  * DropDownListCheckedItem or DropDownListCharStringCheckedItem depending of
>  * type of string used (either StringID or const char*).
>  */
> 
> template <class T, typename S>
> class DropDownListCheckedItemT : public T {
> 	uint checkmark_width;
> public:
> 	bool checked;
> 	DropDownListCheckedItemT<T,S>(S string, int result, bool masked, bool checked) : T(string, result, masked), checked(checked)
> 	{
> 		this->checkmark_width = GetStringBoundingBox(STR_JUST_CHECKMARK).width + 3;
> 	}
> 	virtual ~DropDownListCheckedItemT<T,S>() {}
> 	virtual uint Width() const
> 	{
> 		return T::Width() + this->checkmark_width;
> 	}
> 
> 	virtual void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
> 	{
> 		bool rtl = _current_text_dir == TD_RTL;
> 		if (this->checked) {
> 			DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
> 		}
> 		DrawString(left + WD_FRAMERECT_LEFT + (rtl ? 0 : this->checkmark_width), right - WD_FRAMERECT_RIGHT - (rtl ? this->checkmark_width : 0), top, this->String(), sel ? TC_WHITE : TC_BLACK);
> 	}
> };
> 
> #define DropDownListCheckedItem DropDownListCheckedItemT<DropDownListStringItem,StringID>
> #define DropDownListCharStringCheckedItem DropDownListCheckedItemT<DropDownListCharStringItem,const char*>
diff -r -B -X .diff-exclude vanilla/src/widgets/graph_widget.h cmclient/src/widgets/graph_widget.h
31a32,35
> 	WID_CPR2_FOOTER,          ///< Footer.
> 	WID_CPR2_ENABLE_CARGOES,  ///< Enable cargoes button.
> 	WID_CPR2_DISABLE_CARGOES, ///< Disable cargoes button.
> 	WID_CPR2_CARGO_FIRST,     ///< First cargo in the list.
44a49
> 	WID_CPR_KEY_BUTTON,      ///< Key button.
diff -r -B -X .diff-exclude vanilla/src/widgets/industry_widget.h cmclient/src/widgets/industry_widget.h
21a22,23
> 	WID_DPI_FT_OFF,         ///< Forbidden tiles highlight off button.
> 	WID_DPI_FT_ON,          ///< Forbidden tiles highlight on button.
36a39
> 	WID_ID_DROPDOWN_FILTER,   ///< Industry filter
diff -r -B -X .diff-exclude vanilla/src/widgets/network_widget.h cmclient/src/widgets/network_widget.h
53a54,58
> 
> 	WID_NG_CITYMANIA,          ///< filter citymania
> 	WID_NG_REDDIT,             ///< filter reddit
> 	WID_NG_NICE,               ///< filter n-ice
> 	WID_NG_BTPRO,              ///< filter btpro
diff -r -B -X .diff-exclude vanilla/src/widgets/rail_widget.h cmclient/src/widgets/rail_widget.h
23a24
> 	WID_RAT_POLYRAIL,       ///< Polyline rail tool.
102,105c103,107
< 	WID_BRAD_DEPOT_NE, ///< Build a depot with the entrance in the north east.
< 	WID_BRAD_DEPOT_SE, ///< Build a depot with the entrance in the south east.
< 	WID_BRAD_DEPOT_SW, ///< Build a depot with the entrance in the south west.
< 	WID_BRAD_DEPOT_NW, ///< Build a depot with the entrance in the north west.
---
> 	WID_BRAD_DEPOT_NE,   ///< Build a depot with the entrance in the north east.
> 	WID_BRAD_DEPOT_SE,   ///< Build a depot with the entrance in the south east.
> 	WID_BRAD_DEPOT_SW,   ///< Build a depot with the entrance in the south west.
> 	WID_BRAD_DEPOT_NW,   ///< Build a depot with the entrance in the north west.
> 	WID_BRAD_DEPOT_AUTO, ///< Build a depot, autoselect entrance.
diff -r -B -X .diff-exclude vanilla/src/widgets/road_widget.h cmclient/src/widgets/road_widget.h
20c20,21
< 	WID_ROT_AUTOROAD,       ///< Autorail.
---
> 	WID_ROT_AUTOROAD,       ///< Autoroad.
> 	WID_ROT_FULLROAD,       ///< Auto full road (no half-tiles).
34,38c35,40
< 	WID_BROD_CAPTION,   ///< Caption of the window.
< 	WID_BROD_DEPOT_NE,  ///< Depot with NE entry.
< 	WID_BROD_DEPOT_SE,  ///< Depot with SE entry.
< 	WID_BROD_DEPOT_SW,  ///< Depot with SW entry.
< 	WID_BROD_DEPOT_NW,  ///< Depot with NW entry.
---
> 	WID_BROD_CAPTION,    ///< Caption of the window.
> 	WID_BROD_DEPOT_NE,   ///< Depot with NE entry.
> 	WID_BROD_DEPOT_SE,   ///< Depot with SE entry.
> 	WID_BROD_DEPOT_SW,   ///< Depot with SW entry.
> 	WID_BROD_DEPOT_NW,   ///< Depot with NW entry.
> 	WID_BROD_DEPOT_AUTO, ///< Depot, autodetect entry.
44,54c46,58
< 	WID_BROS_CAPTION,       ///< Caption of the window.
< 	WID_BROS_BACKGROUND,    ///< Background of the window.
< 	WID_BROS_STATION_NE,    ///< Terminal station with NE entry.
< 	WID_BROS_STATION_SE,    ///< Terminal station with SE entry.
< 	WID_BROS_STATION_SW,    ///< Terminal station with SW entry.
< 	WID_BROS_STATION_NW,    ///< Terminal station with NW entry.
< 	WID_BROS_STATION_X,     ///< Drive-through station in x-direction.
< 	WID_BROS_STATION_Y,     ///< Drive-through station in y-direction.
< 	WID_BROS_LT_OFF,        ///< Turn off area highlight.
< 	WID_BROS_LT_ON,         ///< Turn on area highlight.
< 	WID_BROS_INFO,          ///< Station acceptance info.
---
> 	WID_BROS_CAPTION,          ///< Caption of the window.
> 	WID_BROS_BACKGROUND,       ///< Background of the window.
> 	WID_BROS_STATION_NE,       ///< Terminal station with NE entry.
> 	WID_BROS_STATION_SE,       ///< Terminal station with SE entry.
> 	WID_BROS_STATION_SW,       ///< Terminal station with SW entry.
> 	WID_BROS_STATION_NW,       ///< Terminal station with NW entry.
> 	WID_BROS_STATION_X,        ///< Drive-through station in x-direction.
> 	WID_BROS_STATION_Y,        ///< Drive-through station in y-direction.
> 	WID_BROS_STATION_AUTO,     ///< Terminal station, autoselect entry.
> 	WID_BROS_STATION_XY_AUTO,  ///< Drive-through station, autoselect direction.
> 	WID_BROS_LT_OFF,           ///< Turn off area highlight.
> 	WID_BROS_LT_ON,            ///< Turn on area highlight.
> 	WID_BROS_INFO,             ///< Station acceptance info.
diff -r -B -X .diff-exclude vanilla/src/widgets/terraform_widget.h cmclient/src/widgets/terraform_widget.h
22a23
> 	WID_TT_DEMOLISH_TREES,                    ///< Demolish trees only
diff -r -B -X .diff-exclude vanilla/src/widgets/toolbar_widget.h cmclient/src/widgets/toolbar_widget.h
25a26
> 	WID_TN_CARGOS,        ///< Transported cargo menu
28a30
> 	WID_TN_WATCH,         ///< Watch gui menu
diff -r -B -X .diff-exclude vanilla/src/widgets/town_widget.h cmclient/src/widgets/town_widget.h
21a22
> 	TDW_CAPTION_TEXT,
43a45
> 	WID_TV_CB,
62a65,93
> };
> 
> enum TownHK {
> 	HK_SADVERT,
> 	HK_MADVERT,
> 	HK_LADVERT,
> 	HK_ROADS,
> 	HK_STATUE,
> 	HK_FUND,
> };
> 
> enum CBTownWidgets {
> 	WID_CB_LOCATION,
> 	WID_CB_ADVERT,
> 	WID_CB_ADVERT_REGULAR,
> 	WID_CB_FUND,
> 	WID_CB_FUND_REGULAR,
> 	WID_CB_POWERFUND,
> 	WID_CB_DETAILS,
> 	WID_CB_CARGO_NAME,
> 	WID_CB_CARGO_AMOUNT,
> 	WID_CB_CARGO_REQ,
> 	WID_CB_CARGO_PREVIOUS,
> 	WID_CB_CARGO_STORE,
> 	WID_CB_CARGO_STORE_PCT,
> 	WID_CB_CARGO_FROM,
> 	WID_CB_CENTER_VIEW,
> 	WID_CB_TOWN_VIEW,
> 	WID_CB_SHOW_AUTHORITY,
diff -r -B -X .diff-exclude vanilla/src/window.cpp cmclient/src/window.cpp
13a14
> #include <limits>
35a37
> #include "window_gui.h"
1215a1218
> 			case WC_CARGOS:
1773a1777,1778
> 		pt.y = w->top + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? w->height : 10);
> 		return pt;
2906c2911
< 				if (HandleViewportClicked(vp, x, y)) return;
---
> 				if (HandleViewportClicked(vp, x, y, click == MC_DOUBLE_LEFT)) return;
3624a3630,3679
> }
> 
> /**
>  * Sets safe-initial values.
>  * @param t The type of positioning desired.
>  */
> WindowPopup::WindowPopup(WindowDesc *desc, WindowPopupType t): Window(desc)
> {
> 	this->type = t;
> 	this->wpu_mod_x = -5;
> 	this->wpu_mod_y = -5;
> 	this->wpu_widget = std::numeric_limits<uint>::max();
> }
> 
> /**
>  * Compute #WindowPopup origin Point.
>  *
>  * @param desc The window's #WindowDesc object
>  * @param sm_width Window's smallest_x.
>  * @param sm_height Window's smallest_y. Unused.
>  * @param window_number Unused.
>  * @return The origin coordinate of the window.
>  */
> /*virtual*/ Point WindowPopup::OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
> {
> 	int x, y;
> 
> 	switch (this->type) {
> 		case WPUT_CENTERED:
> 			x = _cursor.pos.x - sm_width / 2;
> 			y = _cursor.pos.y - this->window_desc->GetDefaultHeight() / 2;
> 			break;
> 		case WPUT_WIDGET_RELATIVE:
> 			if (this->wpu_widget != std::numeric_limits<uint>::max()) {
> 				NWidgetBase *wid = this->GetWidget<NWidgetBase>(this->wpu_widget);
> 				x = _cursor.pos.x - wid->pos_x + this->wpu_mod_x;
> 				y = _cursor.pos.y - wid->pos_y + this->wpu_mod_y;
> 				break;
> 			}
> 		case WPUT_ORIGIN:
> 		default:
> 			x = _cursor.pos.x + this->wpu_mod_x;
> 			y = _cursor.pos.y + this->wpu_mod_y;
> 			break;
> 	}
> 
> 	Point rv;
> 	rv.x = Clamp(x, 0, _screen.width - sm_width);
> 	rv.y = Clamp(y, GetMainViewTop(), GetMainViewBottom() - this->window_desc->GetDefaultHeight());
> 	return rv;
diff -r -B -X .diff-exclude vanilla/src/window_gui.h cmclient/src/window_gui.h
19a20
> #include "station_base.h"
888a890,891
> void GuiPrepareTooltipsExtra(Window *parent);
> void GuiShowStationRatingTooltip(Window *parent, const Station *st, const CargoSpec *cs);
919a923,949
> 
> 
> /**
>  * #WindowPopup positioning types
>  */
> enum WindowPopupType {
> 	WPUT_ORIGIN = 1,      ///< Align with the top-left corner of the window.
> 	WPUT_WIDGET_RELATIVE, ///< Align from a nested widget.
> 	WPUT_CENTERED,        ///< Center the widget under the cursor. Ignore modifiers.
> };
> 
> /**
>  * Specialized Window bound to open around the cursor's position.
>  * Its sole purpose is to provide the OnInitialPosition() method
>  * and an simple interface to control its behaviour.
>  */
> struct WindowPopup: public Window {
> public:
> 	WindowPopup(WindowDesc *desc, WindowPopupType t = WPUT_ORIGIN);
> 	virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number);
> protected:
> 	uint wpu_widget; ///< The widget to which the computation would be made from when type is #WPUT_WIDGET_RELATIVE.
> 	int wpu_mod_x;   ///< The X axis modifier. A negative value would bring the window closer to the left edge of the screen. Default value is -5.
> 	int wpu_mod_y;   ///< The Y axis modifier. A negative value would bring the window closer to the top edge of the screen. Default value is -5.
> private:
> 	WindowPopupType type;
> };
diff -r -B -X .diff-exclude vanilla/src/window_type.h cmclient/src/window_type.h
111a112,113
> 	WC_TOOLTIPS_EXTRA,
> 	WC_STATION_RATING_TOOLTIP,
372a375,380
> 	//watch company
> 	WC_WATCH_COMPANY,
> 
> 	//watch company admin version
> 	WC_WATCH_COMPANYA,
> 
518a527
> 	WC_CARGOS,
694a704,707
> 	WC_ZONING_TOOLBAR,
> 	WC_COMMAND_TOOLBAR,
> 	WC_LOGIN_WINDOW,
> 	WC_CB_TOWN,
Only in cmclient/src: zoning_cmd.cpp
Only in cmclient/src: zoning_gui.cpp
Only in cmclient/src: zoning.h
