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

Proposed by Miroslav Remák
Status: Merged
Merged at revision: 8002
Proposed branch: lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2
Merge into: lp:widelands
Diff against target: 78 lines (+34/-2)
3 files modified
data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua (+11/-1)
src/scripting/lua_game.cc (+22/-1)
src/scripting/lua_game.h (+1/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+294713@code.launchpad.net

Description of the change

The 'destroy_quarries_message' message box which is displayed after a quarry sends an "Out of rocks" message mentions receiving multiple messages.

This merge request prevents triggering destroy_quarries_message immediately after the stones are taken away if the player had previously restored any archived message.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Excellent :)

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua'
--- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 07:52:43 +0000
+++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 16:18:46 +0000
@@ -332,8 +332,18 @@
332 -- Remove all rocks332 -- Remove all rocks
333 remove_all_rocks(first_quarry_field:region(6))333 remove_all_rocks(first_quarry_field:region(6))
334334
335 function count_quarry_messages()
336 local count = 0
337 for i, msg in ipairs(plr.messages) do
338 if (msg.field == first_quarry_field or msg.field == second_quarry_field) then
339 count = count + 1
340 end
341 end
342 return count
343 end
344
335 -- Wait for messages to arrive345 -- Wait for messages to arrive
336 while #plr.inbox < 1 do sleep(300) end346 while count_quarry_messages() < 2 do sleep(300) end
337347
338 local o = message_box_objective(plr, destroy_quarries_message)348 local o = message_box_objective(plr, destroy_quarries_message)
339349
340350
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2016-03-14 19:56:14 +0000
+++ src/scripting/lua_game.cc 2016-05-14 16:18:46 +0000
@@ -108,6 +108,7 @@
108 PROP_RO(LuaPlayer, allowed_buildings),108 PROP_RO(LuaPlayer, allowed_buildings),
109 PROP_RO(LuaPlayer, objectives),109 PROP_RO(LuaPlayer, objectives),
110 PROP_RO(LuaPlayer, defeated),110 PROP_RO(LuaPlayer, defeated),
111 PROP_RO(LuaPlayer, messages),
111 PROP_RO(LuaPlayer, inbox),112 PROP_RO(LuaPlayer, inbox),
112 PROP_RW(LuaPlayer, team),113 PROP_RW(LuaPlayer, team),
113 PROP_RO(LuaPlayer, tribe),114 PROP_RO(LuaPlayer, tribe),
@@ -192,9 +193,29 @@
192}193}
193194
194/* RST195/* RST
196 .. attribute:: messages
197
198 (RO) An array of all the messages sent to the player. Note that you
199 can't add messages to this array, use :meth:`send_message` for that.
200*/
201int LuaPlayer::get_messages(lua_State * L) {
202 Player & p = get(L, get_egbase(L));
203
204 lua_newtable(L);
205 uint32_t cidx = 1;
206 for (const auto& temp_message : p.messages()) {
207 lua_pushuint32(L, cidx ++);
208 to_lua<LuaMessage>(L, new LuaMessage(player_number(), temp_message.first));
209 lua_rawset(L, -3);
210 }
211
212 return 1;
213}
214
215/* RST
195 .. attribute:: inbox216 .. attribute:: inbox
196217
197 (RO) An array of the message that are either read or new. Note that you218 (RO) An array of the messages that are either read or new. Note that you
198 can't add messages to this array, use :meth:`send_message` for that.219 can't add messages to this array, use :meth:`send_message` for that.
199*/220*/
200int LuaPlayer::get_inbox(lua_State * L) {221int LuaPlayer::get_inbox(lua_State * L) {
201222
=== modified file 'src/scripting/lua_game.h'
--- src/scripting/lua_game.h 2016-04-03 08:01:49 +0000
+++ src/scripting/lua_game.h 2016-05-14 16:18:46 +0000
@@ -63,6 +63,7 @@
63 int get_allowed_buildings(lua_State * L);63 int get_allowed_buildings(lua_State * L);
64 int get_objectives(lua_State * L);64 int get_objectives(lua_State * L);
65 int get_defeated(lua_State * L);65 int get_defeated(lua_State * L);
66 int get_messages(lua_State * L);
66 int get_inbox(lua_State * L);67 int get_inbox(lua_State * L);
67 int get_team(lua_State * L);68 int get_team(lua_State * L);
68 int get_tribe(lua_State * L);69 int get_tribe(lua_State * L);

Subscribers

People subscribed via source and target branches

to status/vote changes: