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
1=== modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua'
2--- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 07:52:43 +0000
3+++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 16:18:46 +0000
4@@ -332,8 +332,18 @@
5 -- Remove all rocks
6 remove_all_rocks(first_quarry_field:region(6))
7
8+ function count_quarry_messages()
9+ local count = 0
10+ for i, msg in ipairs(plr.messages) do
11+ if (msg.field == first_quarry_field or msg.field == second_quarry_field) then
12+ count = count + 1
13+ end
14+ end
15+ return count
16+ end
17+
18 -- Wait for messages to arrive
19- while #plr.inbox < 1 do sleep(300) end
20+ while count_quarry_messages() < 2 do sleep(300) end
21
22 local o = message_box_objective(plr, destroy_quarries_message)
23
24
25=== modified file 'src/scripting/lua_game.cc'
26--- src/scripting/lua_game.cc 2016-03-14 19:56:14 +0000
27+++ src/scripting/lua_game.cc 2016-05-14 16:18:46 +0000
28@@ -108,6 +108,7 @@
29 PROP_RO(LuaPlayer, allowed_buildings),
30 PROP_RO(LuaPlayer, objectives),
31 PROP_RO(LuaPlayer, defeated),
32+ PROP_RO(LuaPlayer, messages),
33 PROP_RO(LuaPlayer, inbox),
34 PROP_RW(LuaPlayer, team),
35 PROP_RO(LuaPlayer, tribe),
36@@ -192,9 +193,29 @@
37 }
38
39 /* RST
40+ .. attribute:: messages
41+
42+ (RO) An array of all the messages sent to the player. Note that you
43+ can't add messages to this array, use :meth:`send_message` for that.
44+*/
45+int LuaPlayer::get_messages(lua_State * L) {
46+ Player & p = get(L, get_egbase(L));
47+
48+ lua_newtable(L);
49+ uint32_t cidx = 1;
50+ for (const auto& temp_message : p.messages()) {
51+ lua_pushuint32(L, cidx ++);
52+ to_lua<LuaMessage>(L, new LuaMessage(player_number(), temp_message.first));
53+ lua_rawset(L, -3);
54+ }
55+
56+ return 1;
57+}
58+
59+/* RST
60 .. attribute:: inbox
61
62- (RO) An array of the message that are either read or new. Note that you
63+ (RO) An array of the messages that are either read or new. Note that you
64 can't add messages to this array, use :meth:`send_message` for that.
65 */
66 int LuaPlayer::get_inbox(lua_State * L) {
67
68=== modified file 'src/scripting/lua_game.h'
69--- src/scripting/lua_game.h 2016-04-03 08:01:49 +0000
70+++ src/scripting/lua_game.h 2016-05-14 16:18:46 +0000
71@@ -63,6 +63,7 @@
72 int get_allowed_buildings(lua_State * L);
73 int get_objectives(lua_State * L);
74 int get_defeated(lua_State * L);
75+ int get_messages(lua_State * L);
76 int get_inbox(lua_State * L);
77 int get_team(lua_State * L);
78 int get_tribe(lua_State * L);

Subscribers

People subscribed via source and target branches

to status/vote changes: