Merge lp:~widelands-dev/widelands/bridges into lp:widelands

Proposed by Benedikt Straub
Status: Work in progress
Proposed branch: lp:~widelands-dev/widelands/bridges
Merge into: lp:widelands
Prerequisite: lp:~widelands-dev/widelands/ferry
Diff against target: 608 lines (+284/-6)
15 files modified
data/tribes/atlanteans.lua (+32/-0)
data/tribes/barbarians.lua (+28/-0)
data/tribes/empire.lua (+28/-0)
data/tribes/frisians.lua (+28/-0)
src/economy/roadbase.cc (+79/-2)
src/economy/roadbase.h (+4/-0)
src/graphic/gl/road_program.cc (+6/-3)
src/logic/map_objects/bob.cc (+18/-0)
src/logic/map_objects/tribes/tribe_descr.cc (+23/-1)
src/logic/map_objects/tribes/tribe_descr.h (+11/-0)
src/logic/roadtype.h (+2/-0)
src/wui/interactive_base.cc (+21/-0)
src/wui/interactive_base.h (+2/-0)
src/wui/interactive_player.cc (+1/-0)
src/wui/interactive_spectator.cc (+1/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bridges
Reviewer Review Type Date Requested Status
kaputtnik (community) Needs Fixing
GunChleoc Approve
Review via email: mp+364318@code.launchpad.net

Commit message

Roads where both adjacent triangles are unwalkable are displayed as bridges

Description of the change

The current road rendering system is too inflexible for this feature. I already had to rework it in the ferry branch to make waterways possible, and I´m using these changes here. So this is a follow-up of the ferries.

Every tribe has its own images for a normal and a busy bridge. Bridges may also be animated. They have a height, which is visible when bobs walk over the bridge.

To post a comment you must log in.
lp:~widelands-dev/widelands/bridges updated
8848. By Nordfriese

Merged master

Revision history for this message
GunChleoc (gunchleoc) wrote :

Some code review comments

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Replied to diff comments

Revision history for this message
GunChleoc (gunchleoc) :
lp:~widelands-dev/widelands/bridges updated
8849. By Nordfriese

Adressed code review

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4609. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/508054226.
Appveyor build 4396. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4396.

lp:~widelands-dev/widelands/bridges updated
8850. By Nordfriese

fixed codecheck

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

you need to merge trunk to make appveyor happy and working

lp:~widelands-dev/widelands/bridges updated
8851. By Nordfriese

Merged master

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4615. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/508306031.
Appveyor build 4402. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4402.

lp:~widelands-dev/widelands/bridges updated
8852. By GunChleoc

Fixed GCC compiler warnings.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have fixed 2 compiler warnings. You need to use the PRIuS macro for logging size_t, because the exact data type depends on the operating system. Also, uint8_t will be interpreted as a character code point rather than a number, so it needs an annoying explicit cast to <unsigned int> every time you want to print it.

I am getting a failed assert:

widelands: ../src/logic/editor_game_base.cc:526: void Widelands::EditorGameBase::set_road(const Widelands::FCoords&, uint8_t, uint8_t): Assertion `roadtype == RoadType::kNone || roadtype == RoadType::kNormal || roadtype == RoadType::kBusy || roadtype == RoadType::kWaterway' failed.

This happened after starting a new game with all 4 tribes in Archipelago Sea, and the AI built something somewhere.

lp:~widelands-dev/widelands/bridges updated
8853. By Nordfriese

Fixed assert

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Fixed the assert. Thanks for taking care of the warnings :)

Revision history for this message
GunChleoc (gunchleoc) wrote :

Done a bit of testing ad it looks fine.

There is 2 small z-layering glitch for bridges going north-south: Workers walking on roads behind them to their upper flag are blitted after the bridge is, so they appear to be on top of it. It's not a biggie though and shouldn't block this branch.

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4626. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/510312899.
Appveyor build 4413. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4413.

lp:~widelands-dev/widelands/bridges updated
8854. By Nordfriese

Merged master

8855. By Nordfriese

Merged master

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4651. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/511385042.
Appveyor build 4438. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4438.

lp:~widelands-dev/widelands/bridges updated
8856. By Nordfriese

Fixed compile error

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4652. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/511593017.
Appveyor build 4439. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4439.

Revision history for this message
kaputtnik (franku) wrote :

I get an error when trying to load this savegame:
https://bugs.launchpad.net/widelands/+bug/734193/+attachment/5252593/+files/test_ferries_1.wgf

This savegame was made close before the other one. The difference is this savegame has no waterway yet. The other savegame has a waterway, which has no ferry: https://bugs.launchpad.net/widelands/+bug/734193/+attachment/5252594/+files/test_ferries.wgf

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

Forget: To reproduce

1. load 'test_ferries.wgf'
2. Build a waterway from flag 30,28 to node 31,27
3. Save the game
4. Try to load the previous saved game

lp:~widelands-dev/widelands/bridges updated
8857. By Nordfriese

Merged master

8858. By Nordfriese

Merged master

Revision history for this message
Benedikt Straub (nordfriese) wrote :

Thanks for reporting, I pushed a fix for the bug. It was a small error in the loading code; the savegame can now be loaded.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4668. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/515650670.
Appveyor build 4454. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4454.

Revision history for this message
kaputtnik (franku) wrote :

Maybe i should test the ferrys in the appropriate branch... can't get them to work...

Regarding the bridges i think having a bridge for normal roads which looks more like a wooden footbridge would be nicer.

Lifting the workers when walking over the bridge is really nice :)

lp:~widelands-dev/widelands/bridges updated
8859. By Nordfriese

Merged master

8860. By Nordfriese

Merged master

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4838. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/526055823.
Appveyor build 4619. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4619.

lp:~widelands-dev/widelands/bridges updated
8861. By Nordfriese

Fixed compile error

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4841. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/526398829.
Appveyor build 4622. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4622.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Now, can ths be merged or do we want another review?

Revision history for this message
Benedikt Straub (nordfriese) wrote :

The ferry branch needs to be merged first because this one is stacked on it.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Mhhh, We could iprove the RoadType via 4 bitflags and some inline fucntions:
 1000
 ^ Road
  ^ Bridge
   ^ Waterway
    ^ Busy

 kRoad = 1
 kNormalRoad = 1
 kBusyRoad = 9
 kBridge = 2
 kBridgeNormal = 2
 kBridgeBusy = 10
 kWaterway = 4
 kNormalWaterway = 4
 kBusyWaterway = 12
 kBusy = 8

This woud avoid a lot of if(this && that || soemthingElse) code?

Once this is in I would address SirVers TODO and extract some RoadDirection enum

Revision history for this message
Benedikt Straub (nordfriese) wrote :

I already reworked that whole stuff in a different way for the ferries. The TODO I think you´re referring to is also solved there already. I prefer my solution because it gets rid of this bitwise hacking, and there´s no need to invent the wheel twice…

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yep, let's wait for the ferry branch and do a final round of code review and testing in this branch when that's done.

lp:~widelands-dev/widelands/bridges updated
8862. By Nordfriese

Merged master

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5063. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/537402794.
Appveyor build 4843. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4843.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5186. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/544760083.
Appveyor build 4966. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bridges-4966.

lp:~widelands-dev/widelands/bridges updated
8863. By Nordfriese

Merged master

Unmerged revisions

8863. By Nordfriese

Merged master

8862. By Nordfriese

Merged master

8861. By Nordfriese

Fixed compile error

8860. By Nordfriese

Merged master

8859. By Nordfriese

Merged master

8858. By Nordfriese

Merged master

8857. By Nordfriese

Merged master

8856. By Nordfriese

Fixed compile error

8855. By Nordfriese

Merged master

8854. By Nordfriese

Merged master

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/tribes/atlanteans.lua'
2--- data/tribes/atlanteans.lua 2019-06-21 06:44:40 +0000
3+++ data/tribes/atlanteans.lua 2019-06-21 06:44:43 +0000
4@@ -17,6 +17,10 @@
5 --
6 -- **animations**: Global animations. Contains subtables for ``frontier`` and ``flag``. Each animation needs the parameters ``pictures`` (table of filenames) and ``hotspot`` (2 integer coordinates), and may also define ``fps`` (integer frames per second).
7 --
8+-- **bridges**: Contains animations for ``normal_e``, ``normal_se``, ``normal_sw``, ``busy_e``, ``busy_se`` and ``busy_sw``.
9+--
10+-- **bridge_height**: The height in pixels of each bridge at it's summit at 1x scale.
11+--
12 -- **roads**: The file paths for the tribe's road textures in 3 subtables ``busy``, ``normal`` and ``waterway``.
13 --
14 -- **resource_indicators**: The names for the resource indicators. This table contains a subtable for each resource name plus a subtable named "" for no resources. Each subtable is an array, in which the index of each entry is the highest amount of resources the indicator may indicate.
15@@ -57,6 +61,34 @@
16 name = "atlanteans",
17 animations = animations,
18
19+ bridges = {
20+ normal_e = {
21+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_normal_e_?.png"),
22+ hotspot = { -2, 11 },
23+ },
24+ normal_se = {
25+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_normal_se_?.png"),
26+ hotspot = { 5, 2 },
27+ },
28+ normal_sw = {
29+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_normal_sw_?.png"),
30+ hotspot = { 36, 3 },
31+ },
32+ busy_e = {
33+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_busy_e_?.png"),
34+ hotspot = { -2, 11 },
35+ },
36+ busy_se = {
37+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_busy_se_?.png"),
38+ hotspot = { 5, 2 },
39+ },
40+ busy_sw = {
41+ pictures = path.list_files (dirname .. "images/atlanteans/bridge_busy_sw_?.png"),
42+ hotspot = { 36, 3 },
43+ },
44+ },
45+ bridge_height = 8,
46+
47 -- Image file paths for this tribe's road and waterway textures
48 roads = {
49 busy = {
50
51=== modified file 'data/tribes/barbarians.lua'
52--- data/tribes/barbarians.lua 2019-06-21 06:44:40 +0000
53+++ data/tribes/barbarians.lua 2019-06-21 06:44:43 +0000
54@@ -8,6 +8,34 @@
55 name = "barbarians",
56 animations = animations,
57
58+ bridges = {
59+ normal_e = {
60+ pictures = path.list_files (dirname .. "images/barbarians/bridge_normal_e_?.png"),
61+ hotspot = { -1, 13 },
62+ },
63+ normal_se = {
64+ pictures = path.list_files (dirname .. "images/barbarians/bridge_normal_se_?.png"),
65+ hotspot = { 8, 3 },
66+ },
67+ normal_sw = {
68+ pictures = path.list_files (dirname .. "images/barbarians/bridge_normal_sw_?.png"),
69+ hotspot = { 41, 3 },
70+ },
71+ busy_e = {
72+ pictures = path.list_files (dirname .. "images/barbarians/bridge_busy_e_?.png"),
73+ hotspot = { -1, 13 },
74+ },
75+ busy_se = {
76+ pictures = path.list_files (dirname .. "images/barbarians/bridge_busy_se_?.png"),
77+ hotspot = { 8, 3 },
78+ },
79+ busy_sw = {
80+ pictures = path.list_files (dirname .. "images/barbarians/bridge_busy_sw_?.png"),
81+ hotspot = { 41, 3 },
82+ },
83+ },
84+ bridge_height = 8,
85+
86 -- Image file paths for this tribe's road and waterway textures
87 roads = {
88 busy = {
89
90=== modified file 'data/tribes/empire.lua'
91--- data/tribes/empire.lua 2019-06-21 06:44:40 +0000
92+++ data/tribes/empire.lua 2019-06-21 06:44:43 +0000
93@@ -8,6 +8,34 @@
94 name = "empire",
95 animations = animations,
96
97+ bridges = {
98+ normal_e = {
99+ pictures = path.list_files (dirname .. "images/empire/bridge_normal_e_?.png"),
100+ hotspot = { -2, 12 },
101+ },
102+ normal_se = {
103+ pictures = path.list_files (dirname .. "images/empire/bridge_normal_se_?.png"),
104+ hotspot = { 5, 2 },
105+ },
106+ normal_sw = {
107+ pictures = path.list_files (dirname .. "images/empire/bridge_normal_sw_?.png"),
108+ hotspot = { 36, 3 },
109+ },
110+ busy_e = {
111+ pictures = path.list_files (dirname .. "images/empire/bridge_busy_e_?.png"),
112+ hotspot = { -2, 12 },
113+ },
114+ busy_se = {
115+ pictures = path.list_files (dirname .. "images/empire/bridge_busy_se_?.png"),
116+ hotspot = { 5, 2 },
117+ },
118+ busy_sw = {
119+ pictures = path.list_files (dirname .. "images/empire/bridge_busy_sw_?.png"),
120+ hotspot = { 36, 3 },
121+ },
122+ },
123+ bridge_height = 8,
124+
125 -- Image file paths for this tribe's road and waterway textures
126 roads = {
127 busy = {
128
129=== modified file 'data/tribes/frisians.lua'
130--- data/tribes/frisians.lua 2019-06-21 06:44:40 +0000
131+++ data/tribes/frisians.lua 2019-06-21 06:44:43 +0000
132@@ -8,6 +8,34 @@
133 name = "frisians",
134 animations = animations,
135
136+ bridges = {
137+ normal_e = {
138+ pictures = path.list_files (dirname .. "images/frisians/bridge_normal_e_?.png"),
139+ hotspot = { -2, 12 },
140+ },
141+ normal_se = {
142+ pictures = path.list_files (dirname .. "images/frisians/bridge_normal_se_?.png"),
143+ hotspot = { 5, 2 },
144+ },
145+ normal_sw = {
146+ pictures = path.list_files (dirname .. "images/frisians/bridge_normal_sw_?.png"),
147+ hotspot = { 36, 3 },
148+ },
149+ busy_e = {
150+ pictures = path.list_files (dirname .. "images/frisians/bridge_busy_e_?.png"),
151+ hotspot = { -2, 12 },
152+ },
153+ busy_se = {
154+ pictures = path.list_files (dirname .. "images/frisians/bridge_busy_se_?.png"),
155+ hotspot = { 5, 2 },
156+ },
157+ busy_sw = {
158+ pictures = path.list_files (dirname .. "images/frisians/bridge_busy_sw_?.png"),
159+ hotspot = { 36, 3 },
160+ },
161+ },
162+ bridge_height = 8,
163+
164 -- Image file paths for this tribe's road and waterway textures
165 roads = {
166 busy = {
167
168=== added file 'data/tribes/images/atlanteans/bridge_busy_e_0.png'
169Binary files data/tribes/images/atlanteans/bridge_busy_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_busy_e_0.png 2019-06-21 06:44:43 +0000 differ
170=== added file 'data/tribes/images/atlanteans/bridge_busy_se_0.png'
171Binary files data/tribes/images/atlanteans/bridge_busy_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_busy_se_0.png 2019-06-21 06:44:43 +0000 differ
172=== added file 'data/tribes/images/atlanteans/bridge_busy_sw_0.png'
173Binary files data/tribes/images/atlanteans/bridge_busy_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_busy_sw_0.png 2019-06-21 06:44:43 +0000 differ
174=== added file 'data/tribes/images/atlanteans/bridge_normal_e_0.png'
175Binary files data/tribes/images/atlanteans/bridge_normal_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_normal_e_0.png 2019-06-21 06:44:43 +0000 differ
176=== added file 'data/tribes/images/atlanteans/bridge_normal_se_0.png'
177Binary files data/tribes/images/atlanteans/bridge_normal_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_normal_se_0.png 2019-06-21 06:44:43 +0000 differ
178=== added file 'data/tribes/images/atlanteans/bridge_normal_sw_0.png'
179Binary files data/tribes/images/atlanteans/bridge_normal_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/bridge_normal_sw_0.png 2019-06-21 06:44:43 +0000 differ
180=== added file 'data/tribes/images/barbarians/bridge_busy_e_0.png'
181Binary files data/tribes/images/barbarians/bridge_busy_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_busy_e_0.png 2019-06-21 06:44:43 +0000 differ
182=== added file 'data/tribes/images/barbarians/bridge_busy_se_0.png'
183Binary files data/tribes/images/barbarians/bridge_busy_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_busy_se_0.png 2019-06-21 06:44:43 +0000 differ
184=== added file 'data/tribes/images/barbarians/bridge_busy_sw_0.png'
185Binary files data/tribes/images/barbarians/bridge_busy_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_busy_sw_0.png 2019-06-21 06:44:43 +0000 differ
186=== added file 'data/tribes/images/barbarians/bridge_normal_e_0.png'
187Binary files data/tribes/images/barbarians/bridge_normal_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_normal_e_0.png 2019-06-21 06:44:43 +0000 differ
188=== added file 'data/tribes/images/barbarians/bridge_normal_se_0.png'
189Binary files data/tribes/images/barbarians/bridge_normal_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_normal_se_0.png 2019-06-21 06:44:43 +0000 differ
190=== added file 'data/tribes/images/barbarians/bridge_normal_sw_0.png'
191Binary files data/tribes/images/barbarians/bridge_normal_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/barbarians/bridge_normal_sw_0.png 2019-06-21 06:44:43 +0000 differ
192=== added file 'data/tribes/images/empire/bridge_busy_e_0.png'
193Binary files data/tribes/images/empire/bridge_busy_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_busy_e_0.png 2019-06-21 06:44:43 +0000 differ
194=== added file 'data/tribes/images/empire/bridge_busy_se_0.png'
195Binary files data/tribes/images/empire/bridge_busy_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_busy_se_0.png 2019-06-21 06:44:43 +0000 differ
196=== added file 'data/tribes/images/empire/bridge_busy_sw_0.png'
197Binary files data/tribes/images/empire/bridge_busy_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_busy_sw_0.png 2019-06-21 06:44:43 +0000 differ
198=== added file 'data/tribes/images/empire/bridge_normal_e_0.png'
199Binary files data/tribes/images/empire/bridge_normal_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_normal_e_0.png 2019-06-21 06:44:43 +0000 differ
200=== added file 'data/tribes/images/empire/bridge_normal_se_0.png'
201Binary files data/tribes/images/empire/bridge_normal_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_normal_se_0.png 2019-06-21 06:44:43 +0000 differ
202=== added file 'data/tribes/images/empire/bridge_normal_sw_0.png'
203Binary files data/tribes/images/empire/bridge_normal_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/empire/bridge_normal_sw_0.png 2019-06-21 06:44:43 +0000 differ
204=== added file 'data/tribes/images/frisians/bridge_busy_e_0.png'
205Binary files data/tribes/images/frisians/bridge_busy_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_busy_e_0.png 2019-06-21 06:44:43 +0000 differ
206=== added file 'data/tribes/images/frisians/bridge_busy_se_0.png'
207Binary files data/tribes/images/frisians/bridge_busy_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_busy_se_0.png 2019-06-21 06:44:43 +0000 differ
208=== added file 'data/tribes/images/frisians/bridge_busy_sw_0.png'
209Binary files data/tribes/images/frisians/bridge_busy_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_busy_sw_0.png 2019-06-21 06:44:43 +0000 differ
210=== added file 'data/tribes/images/frisians/bridge_normal_e_0.png'
211Binary files data/tribes/images/frisians/bridge_normal_e_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_normal_e_0.png 2019-06-21 06:44:43 +0000 differ
212=== added file 'data/tribes/images/frisians/bridge_normal_se_0.png'
213Binary files data/tribes/images/frisians/bridge_normal_se_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_normal_se_0.png 2019-06-21 06:44:43 +0000 differ
214=== added file 'data/tribes/images/frisians/bridge_normal_sw_0.png'
215Binary files data/tribes/images/frisians/bridge_normal_sw_0.png 1970-01-01 00:00:00 +0000 and data/tribes/images/frisians/bridge_normal_sw_0.png 2019-06-21 06:44:43 +0000 differ
216=== modified file 'src/economy/roadbase.cc'
217--- src/economy/roadbase.cc 2019-06-21 06:44:40 +0000
218+++ src/economy/roadbase.cc 2019-06-21 06:44:43 +0000
219@@ -28,6 +28,8 @@
220 #include "logic/map_objects/map_object.h"
221 #include "logic/map_objects/tribes/carrier.h"
222 #include "logic/map_objects/tribes/tribe_descr.h"
223+#include "logic/map_objects/world/terrain_description.h"
224+#include "logic/map_objects/world/world.h"
225 #include "logic/player.h"
226
227 namespace Widelands {
228@@ -69,6 +71,68 @@
229 return *flags_[FlagStart];
230 }
231
232+// This returns true if and only if this is a road that covers the specified edge and
233+// both triangles adjacent to that edge are unwalkable
234+bool RoadBase::is_bridge(const EditorGameBase& egbase, const FCoords& field, uint8_t dir) const {
235+ if (descr().type() != MapObjectType::ROAD) {
236+ // waterways can't be bridges...
237+ return false;
238+ }
239+
240+ const Map& map = egbase.map();
241+
242+ FCoords iterate = map.get_fcoords(path_.get_start());
243+ const Path::StepVector::size_type nr_steps = path_.get_nsteps();
244+ bool found = false;
245+ for (Path::StepVector::size_type i = 0; i <= nr_steps; ++i) {
246+ if (iterate == field) {
247+ if ((i < nr_steps && path_[i] == dir) || (i > 0 && path_[i - 1] == get_reverse_dir(dir))) {
248+ found = true;
249+ break;
250+ }
251+ return false;
252+ }
253+ if (i < nr_steps) {
254+ map.get_neighbour(iterate, path_[i], &iterate);
255+ }
256+ }
257+ if (!found) {
258+ return false;
259+ }
260+
261+ FCoords fr, fd;
262+ switch (dir) {
263+ case WALK_SW:
264+ fd = field;
265+ map.get_ln(field, &fr);
266+ break;
267+ case WALK_SE:
268+ fd = field;
269+ fr = field;
270+ break;
271+ case WALK_NW:
272+ map.get_tln(field, &fd);
273+ fr = fd;
274+ break;
275+ case WALK_NE:
276+ map.get_trn(field, &fd);
277+ map.get_tln(field, &fr);
278+ break;
279+ case WALK_W:
280+ map.get_tln(field, &fd);
281+ map.get_ln(field, &fr);
282+ break;
283+ case WALK_E:
284+ map.get_trn(field, &fd);
285+ fr = field;
286+ break;
287+ default:
288+ NEVER_HERE();
289+ }
290+ return (egbase.world().terrain_descr(fd.field->terrain_d()).get_is() & TerrainDescription::Is::kUnwalkable) &&
291+ (egbase.world().terrain_descr(fr.field->terrain_r()).get_is() & TerrainDescription::Is::kUnwalkable);
292+}
293+
294 /**
295 * Return the cost of getting from fromflag to the other flag.
296 */
297@@ -92,9 +156,22 @@
298 idle_index_ = path.get_nsteps() / 2;
299 }
300
301-static inline void set_roadtype(EditorGameBase& egbase, const FCoords curf, uint8_t dir, RoadType type) {
302- if (dir == WALK_SW || dir == WALK_SE || dir == WALK_E)
303+inline void RoadBase::set_roadtype(EditorGameBase& egbase, const FCoords curf, uint8_t dir, RoadType type) const {
304+ if (dir == WALK_SW || dir == WALK_SE || dir == WALK_E) {
305+ if (type != RoadType::kNone && is_bridge(egbase, curf, dir)) {
306+ switch (type) {
307+ case RoadType::kNormal:
308+ type = RoadType::kBridgeNormal;
309+ break;
310+ case RoadType::kBusy:
311+ type = RoadType::kBridgeBusy;
312+ break;
313+ default:
314+ NEVER_HERE();
315+ }
316+ }
317 egbase.set_road(curf, dir, type);
318+ }
319 }
320
321 /**
322
323=== modified file 'src/economy/roadbase.h'
324--- src/economy/roadbase.h 2019-06-21 06:44:40 +0000
325+++ src/economy/roadbase.h 2019-06-21 06:44:43 +0000
326@@ -68,6 +68,8 @@
327 return type_;
328 }
329
330+ bool is_bridge(const EditorGameBase&, const FCoords&, uint8_t) const;
331+
332 int32_t get_size() const override;
333 bool get_passable() const override;
334 PositionList get_positions(const EditorGameBase&) const override;
335@@ -107,6 +109,8 @@
336
337 virtual void link_into_flags(EditorGameBase&, bool = false);
338
339+ inline void set_roadtype(EditorGameBase& egbase, const FCoords curf, uint8_t dir, RoadType type) const;
340+
341 Flag* flags_[2]; ///< start and end flag
342 int32_t flagidx_[2]; ///< index of this road in the flag's road array
343
344
345=== modified file 'src/graphic/gl/road_program.cc'
346--- src/graphic/gl/road_program.cc 2019-06-21 06:44:40 +0000
347+++ src/graphic/gl/road_program.cc 2019-06-21 06:44:43 +0000
348@@ -156,7 +156,8 @@
349 // Road to right neighbor.
350 if (field.rn_index != FieldsToDraw::kInvalidIndex) {
351 const Widelands::RoadType road = static_cast<Widelands::RoadType>(field.road_e);
352- if (road != Widelands::RoadType::kNone) {
353+ if (road != Widelands::RoadType::kNone && road != Widelands::RoadType::kBridgeNormal &&
354+ road != Widelands::RoadType::kBridgeBusy) {
355 add_road(renderbuffer_width, renderbuffer_height, field,
356 fields_to_draw.at(field.rn_index), scale, road, kEast, &gl_texture);
357 }
358@@ -165,7 +166,8 @@
359 // Road to bottom right neighbor.
360 if (field.brn_index != FieldsToDraw::kInvalidIndex) {
361 const Widelands::RoadType road = static_cast<Widelands::RoadType>(field.road_se);
362- if (road != Widelands::RoadType::kNone) {
363+ if (road != Widelands::RoadType::kNone && road != Widelands::RoadType::kBridgeNormal &&
364+ road != Widelands::RoadType::kBridgeBusy) {
365 add_road(renderbuffer_width, renderbuffer_height, field,
366 fields_to_draw.at(field.brn_index), scale, road, kSouthEast, &gl_texture);
367 }
368@@ -174,7 +176,8 @@
369 // Road to bottom left neighbor.
370 if (field.bln_index != FieldsToDraw::kInvalidIndex) {
371 const Widelands::RoadType road = static_cast<Widelands::RoadType>(field.road_sw);
372- if (road != Widelands::RoadType::kNone) {
373+ if (road != Widelands::RoadType::kNone && road != Widelands::RoadType::kBridgeNormal &&
374+ road != Widelands::RoadType::kBridgeBusy) {
375 add_road(renderbuffer_width, renderbuffer_height, field,
376 fields_to_draw.at(field.bln_index), scale, road, kSouthWest, &gl_texture);
377 }
378
379=== modified file 'src/logic/map_objects/bob.cc'
380--- src/logic/map_objects/bob.cc 2019-05-11 13:48:12 +0000
381+++ src/logic/map_objects/bob.cc 2019-06-21 06:44:43 +0000
382@@ -27,6 +27,7 @@
383 #include "base/macros.h"
384 #include "base/math.h"
385 #include "base/wexception.h"
386+#include "economy/roadbase.h"
387 #include "economy/route.h"
388 #include "economy/transfer.h"
389 #include "graphic/rendertarget.h"
390@@ -705,34 +706,47 @@
391 const float triangle_w = kTriangleWidth * scale;
392 const float triangle_h = kTriangleHeight * scale;
393
394+ bool bridge = false;
395 switch (walking_) {
396 case WALK_NW:
397 map.get_brn(end, &start);
398 spos.x += triangle_w / 2.f;
399 spos.y += triangle_h;
400+ bridge = end.field->road_southeast == RoadType::kBridgeNormal ||
401+ end.field->road_southeast == RoadType::kBridgeBusy;
402 break;
403 case WALK_NE:
404 map.get_bln(end, &start);
405 spos.x -= triangle_w / 2.f;
406 spos.y += triangle_h;
407+ bridge = end.field->road_southwest == RoadType::kBridgeNormal ||
408+ end.field->road_southwest == RoadType::kBridgeBusy;
409 break;
410 case WALK_W:
411 map.get_rn(end, &start);
412 spos.x += triangle_w;
413+ bridge = end.field->road_east == RoadType::kBridgeNormal ||
414+ end.field->road_east == RoadType::kBridgeBusy;
415 break;
416 case WALK_E:
417 map.get_ln(end, &start);
418 spos.x -= triangle_w;
419+ bridge = start.field->road_east == RoadType::kBridgeNormal ||
420+ start.field->road_east == RoadType::kBridgeBusy;
421 break;
422 case WALK_SW:
423 map.get_trn(end, &start);
424 spos.x += triangle_w / 2.f;
425 spos.y -= triangle_h;
426+ bridge = start.field->road_southwest == RoadType::kBridgeNormal ||
427+ start.field->road_southwest == RoadType::kBridgeBusy;
428 break;
429 case WALK_SE:
430 map.get_tln(end, &start);
431 spos.x -= triangle_w / 2.f;
432 spos.y -= triangle_h;
433+ bridge = start.field->road_southeast == RoadType::kBridgeNormal ||
434+ start.field->road_southeast == RoadType::kBridgeBusy;
435 break;
436
437 case IDLE:
438@@ -750,6 +764,10 @@
439 static_cast<float>(game.get_gametime() - walkstart_) / (walkend_ - walkstart_), 0.f, 1.f);
440 epos.x = f * epos.x + (1.f - f) * spos.x;
441 epos.y = f * epos.y + (1.f - f) * spos.y;
442+ if (bridge) {
443+ epos.y -= game.player(end.field->get_owned_by()).tribe().bridge_height() * scale *
444+ (1 - 4 * (f - 0.5f) * (f - 0.5f));
445+ }
446 }
447 return epos;
448 }
449
450=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
451--- src/logic/map_objects/tribes/tribe_descr.cc 2019-06-21 06:44:40 +0000
452+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-06-21 06:44:43 +0000
453@@ -57,7 +57,8 @@
454 TribeDescr::TribeDescr(const LuaTable& table,
455 const Widelands::TribeBasicInfo& info,
456 const Tribes& init_tribes)
457- : name_(table.get_string("name")), descname_(info.descname), tribes_(init_tribes) {
458+ : name_(table.get_string("name")), descname_(info.descname), tribes_(init_tribes),
459+ bridge_height_(table.get_int("bridge_height")) {
460
461 try {
462 initializations_ = info.initializations;
463@@ -74,6 +75,14 @@
464 animations_table->get_string("basename"));
465 }
466
467+ items_table = table.get_table("bridges");
468+ bridge_e_animation_normal_id_ = g_gr->animations().load(*items_table->get_table("normal_e"));
469+ bridge_se_animation_normal_id_ = g_gr->animations().load(*items_table->get_table("normal_se"));
470+ bridge_sw_animation_normal_id_ = g_gr->animations().load(*items_table->get_table("normal_sw"));
471+ bridge_e_animation_busy_id_ = g_gr->animations().load(*items_table->get_table("busy_e"));
472+ bridge_se_animation_busy_id_ = g_gr->animations().load(*items_table->get_table("busy_se"));
473+ bridge_sw_animation_busy_id_ = g_gr->animations().load(*items_table->get_table("busy_sw"));
474+
475 items_table = table.get_table("roads");
476 const auto load_roads = [&items_table](
477 const std::string& road_type, std::vector<std::string>* images) {
478@@ -363,6 +372,19 @@
479 return flag_animation_id_;
480 }
481
482+uint32_t TribeDescr::bridge_animation(uint8_t dir, bool busy) const {
483+ switch (dir) {
484+ case WALK_E: return busy ? bridge_e_animation_busy_id_ : bridge_e_animation_normal_id_;
485+ case WALK_SE: return busy ? bridge_se_animation_busy_id_ : bridge_se_animation_normal_id_;
486+ case WALK_SW: return busy ? bridge_sw_animation_busy_id_ : bridge_sw_animation_normal_id_;
487+ default: NEVER_HERE();
488+ }
489+}
490+
491+uint32_t TribeDescr::bridge_height() const {
492+ return bridge_height_;
493+}
494+
495 const std::vector<std::string>& TribeDescr::normal_road_paths() const {
496 return normal_road_paths_;
497 }
498
499=== modified file 'src/logic/map_objects/tribes/tribe_descr.h'
500--- src/logic/map_objects/tribes/tribe_descr.h 2019-06-21 06:44:40 +0000
501+++ src/logic/map_objects/tribes/tribe_descr.h 2019-06-21 06:44:43 +0000
502@@ -127,6 +127,10 @@
503
504 uint32_t frontier_animation() const;
505 uint32_t flag_animation() const;
506+ uint32_t bridge_animation(uint8_t dir, bool busy) const;
507+
508+ // Bridge height in pixels at 1x scale, for drawing bobs walking over a bridge
509+ uint32_t bridge_height() const;
510
511 // A vector of all texture images that can be used for drawing a
512 // (normal|busy) road or a waterway. The images are guaranteed to exist.
513@@ -179,6 +183,13 @@
514
515 uint32_t frontier_animation_id_;
516 uint32_t flag_animation_id_;
517+ uint32_t bridge_e_animation_normal_id_;
518+ uint32_t bridge_se_animation_normal_id_;
519+ uint32_t bridge_sw_animation_normal_id_;
520+ uint32_t bridge_e_animation_busy_id_;
521+ uint32_t bridge_se_animation_busy_id_;
522+ uint32_t bridge_sw_animation_busy_id_;
523+ uint32_t bridge_height_;
524 std::vector<std::string> normal_road_paths_;
525 std::vector<std::string> busy_road_paths_;
526 std::vector<std::string> waterway_paths_;
527
528=== modified file 'src/logic/roadtype.h'
529--- src/logic/roadtype.h 2019-06-21 06:44:40 +0000
530+++ src/logic/roadtype.h 2019-06-21 06:44:43 +0000
531@@ -29,6 +29,8 @@
532 kNormal = 1,
533 kBusy = 2,
534 kWaterway = 3,
535+ kBridgeNormal = 4,
536+ kBridgeBusy = 5,
537 };
538
539 } // namespace Widelands
540
541=== modified file 'src/wui/interactive_base.cc'
542--- src/wui/interactive_base.cc 2019-06-21 06:44:40 +0000
543+++ src/wui/interactive_base.cc 2019-06-21 06:44:43 +0000
544@@ -648,6 +648,27 @@
545 blit_overlay(dst, field.rendertarget_pixel.cast<int>(), image, hotspot, scale);
546 }
547
548+void InteractiveBase::draw_bridges(RenderTarget* dst,
549+ const FieldsToDraw::Field* f,
550+ uint32_t gametime,
551+ float scale) const {
552+ if (f->road_e == Widelands::RoadType::kBridgeNormal || f->road_e == Widelands::RoadType::kBridgeBusy) {
553+ dst->blit_animation(f->rendertarget_pixel, f->fcoords, scale, f->owner->tribe().bridge_animation(
554+ Widelands::WALK_E, f->road_e == Widelands::RoadType::kBridgeBusy),
555+ gametime, &f->owner->get_playercolor());
556+ }
557+ if (f->road_sw == Widelands::RoadType::kBridgeNormal || f->road_sw == Widelands::RoadType::kBridgeBusy) {
558+ dst->blit_animation(f->rendertarget_pixel, f->fcoords, scale, f->owner->tribe().bridge_animation(
559+ Widelands::WALK_SW, f->road_sw == Widelands::RoadType::kBridgeBusy),
560+ gametime, &f->owner->get_playercolor());
561+ }
562+ if (f->road_se == Widelands::RoadType::kBridgeNormal || f->road_se == Widelands::RoadType::kBridgeBusy) {
563+ dst->blit_animation(f->rendertarget_pixel, f->fcoords, scale, f->owner->tribe().bridge_animation(
564+ Widelands::WALK_SE, f->road_se == Widelands::RoadType::kBridgeBusy),
565+ gametime, &f->owner->get_playercolor());
566+ }
567+}
568+
569 void InteractiveBase::mainview_move() {
570 if (minimap_registry_.window) {
571 minimap_->set_view(map_view_.view_area().rect());
572
573=== modified file 'src/wui/interactive_base.h'
574--- src/wui/interactive_base.h 2019-06-21 06:44:40 +0000
575+++ src/wui/interactive_base.h 2019-06-21 06:44:43 +0000
576@@ -225,6 +225,8 @@
577 const Vector2i& hotspot,
578 float scale);
579
580+ void draw_bridges(RenderTarget* dst, const FieldsToDraw::Field* f, uint32_t gametime, float scale) const;
581+
582 void unset_sel_picture();
583 void set_sel_picture(const Image* image);
584 const Image* get_sel_picture() {
585
586=== modified file 'src/wui/interactive_player.cc'
587--- src/wui/interactive_player.cc 2019-06-21 06:44:40 +0000
588+++ src/wui/interactive_player.cc 2019-06-21 06:44:43 +0000
589@@ -363,6 +363,7 @@
590 }
591 }
592
593+ draw_bridges(dst, f, f->vision > 1 ? gametime : 0, scale);
594 draw_border_markers(*f, scale, *fields_to_draw, dst);
595
596 // Render stuff that belongs to the node.
597
598=== modified file 'src/wui/interactive_spectator.cc'
599--- src/wui/interactive_spectator.cc 2019-06-21 06:44:40 +0000
600+++ src/wui/interactive_spectator.cc 2019-06-21 06:44:43 +0000
601@@ -127,6 +127,7 @@
602 for (size_t idx = 0; idx < fields_to_draw->size(); ++idx) {
603 const FieldsToDraw::Field& field = fields_to_draw->at(idx);
604
605+ draw_bridges(dst, &field, gametime, scale);
606 draw_border_markers(field, scale, *fields_to_draw, dst);
607
608 Widelands::BaseImmovable* const imm = field.fcoords.field->get_immovable();

Subscribers

People subscribed via source and target branches

to status/vote changes: