Merge lp:~widelands-dev/widelands/bug-988831 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7181
Proposed branch: lp:~widelands-dev/widelands/bug-988831
Merge into: lp:widelands
Diff against target: 658 lines (+48/-170)
19 files modified
src/game_io/game_loader.cc (+0/-8)
src/logic/CMakeLists.txt (+2/-2)
src/logic/building.cc (+3/-3)
src/logic/cmd_delete_message.cc (+3/-3)
src/logic/cmd_delete_message.h (+7/-7)
src/logic/cmd_luacoroutine.cc (+1/-2)
src/logic/message.h (+1/-6)
src/logic/message_queue.h (+4/-11)
src/logic/player.cc (+3/-10)
src/logic/player.h (+1/-1)
src/logic/queue_cmd_ids.h (+1/-1)
src/logic/ship.cc (+1/-2)
src/logic/soldier.cc (+2/-2)
src/logic/worker.cc (+2/-2)
src/map_io/map_message_saver.h (+2/-2)
src/map_io/map_players_messages_packet.cc (+3/-65)
src/scripting/lua_game.cc (+3/-28)
src/scripting/lua_game.h (+0/-1)
test/maps/lua_testsuite.wmf/scripting/messages.lua (+9/-14)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-988831
Reviewer Review Type Date Requested Status
SirVer Approve
GunChleoc Needs Resubmitting
Review via email: mp+233885@code.launchpad.net

Description of the change

Messages no longer expire

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

All fixed.

review: Needs Resubmitting
Revision history for this message
SirVer (sirver) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/game_io/game_loader.cc'
2--- src/game_io/game_loader.cc 2014-09-10 16:57:31 +0000
3+++ src/game_io/game_loader.cc 2014-09-18 18:57:10 +0000
4@@ -32,7 +32,6 @@
5 #include "game_io/game_player_info_packet.h"
6 #include "game_io/game_preload_packet.h"
7 #include "io/filesystem/layered_filesystem.h"
8-#include "logic/cmd_expire_message.h"
9 #include "logic/game.h"
10 #include "logic/player.h"
11 #include "map_io/map_object_loader.h"
12@@ -103,13 +102,6 @@
13 Message* m = temp_message.second;
14 MessageId m_id = temp_message.first;
15
16- // Renew expire commands
17- Duration const duration = m->duration();
18- if (duration != Forever()) {
19- m_game.cmdqueue().enqueue
20- (new CmdExpireMessage
21- (m->sent() + duration, p, m_id));
22- }
23 // Renew MapObject connections
24 if (m->serial() > 0) {
25 MapObject* mo = m_game.objects().get_object(m->serial());
26
27=== modified file 'src/logic/CMakeLists.txt'
28--- src/logic/CMakeLists.txt 2014-09-10 10:18:46 +0000
29+++ src/logic/CMakeLists.txt 2014-09-18 18:57:10 +0000
30@@ -76,8 +76,8 @@
31 checkstep.h
32 cmd_calculate_statistics.cc
33 cmd_calculate_statistics.h
34- cmd_expire_message.cc
35- cmd_expire_message.h
36+ cmd_delete_message.cc
37+ cmd_delete_message.h
38 cmd_incorporate.cc
39 cmd_incorporate.h
40 cmd_luacoroutine.cc
41
42=== modified file 'src/logic/building.cc'
43--- src/logic/building.cc 2014-09-10 18:56:42 +0000
44+++ src/logic/building.cc 2014-09-18 18:57:10 +0000
45@@ -871,7 +871,7 @@
46 * \param title user-visible title of the message
47 * \param description user-visible message body, will be placed in an
48 * appropriate rich-text paragraph
49- * \param link_to_building_lifetime if true, the message will expire when this
50+ * \param link_to_building_lifetime if true, the message will be deleted when this
51 * building is removed from the game. Default is true
52 * \param throttle_time if non-zero, the minimum time delay in milliseconds
53 * between messages of this type (see \p msgsender) within the
54@@ -910,8 +910,8 @@
55 rt_description += "</p></rt>";
56
57 Message * msg = new Message
58- (msgsender, game.get_gametime(), 60 * 60 * 1000,
59- title, rt_description, get_position(), (link_to_building_lifetime ? m_serial : 0));
60+ (msgsender, game.get_gametime(), title, rt_description,
61+ get_position(), (link_to_building_lifetime ? m_serial : 0));
62
63 if (throttle_time)
64 owner().add_message_with_timeout
65
66=== renamed file 'src/logic/cmd_expire_message.cc' => 'src/logic/cmd_delete_message.cc'
67--- src/logic/cmd_expire_message.cc 2014-09-09 11:23:11 +0000
68+++ src/logic/cmd_delete_message.cc 2014-09-18 18:57:10 +0000
69@@ -17,15 +17,15 @@
70 *
71 */
72
73-#include "logic/cmd_expire_message.h"
74+#include "logic/cmd_delete_message.h"
75
76 #include "logic/game.h"
77 #include "logic/player.h"
78
79 namespace Widelands {
80
81-void CmdExpireMessage::execute(Game & game) {
82- game.player(player).messages().expire_message(message);
83+void CmdDeleteMessage::execute(Game & game) {
84+ game.player(player).messages().delete_message(message);
85 }
86
87 }
88
89=== renamed file 'src/logic/cmd_expire_message.h' => 'src/logic/cmd_delete_message.h'
90--- src/logic/cmd_expire_message.h 2014-09-10 13:03:40 +0000
91+++ src/logic/cmd_delete_message.h 2014-09-18 18:57:10 +0000
92@@ -17,8 +17,8 @@
93 *
94 */
95
96-#ifndef WL_LOGIC_CMD_EXPIRE_MESSAGE_H
97-#define WL_LOGIC_CMD_EXPIRE_MESSAGE_H
98+#ifndef WL_LOGIC_CMD_DELETE_MESSAGE_H
99+#define WL_LOGIC_CMD_DELETE_MESSAGE_H
100
101 #include <memory>
102
103@@ -27,7 +27,7 @@
104
105 namespace Widelands {
106
107-/// Expires the player's message.
108+/// Delete the player's message.
109 ///
110 /// \note This is not a GameLogicCommand because it should not be saved.
111 /// Instead, the commands are recreated separately on load (when both command
112@@ -35,14 +35,14 @@
113 /// command and then when loading, checking that one exists for each message
114 /// and if not, warn and recreate it. Such redundancy would also waste space in
115 /// the savegame.
116-struct CmdExpireMessage : public Command {
117- CmdExpireMessage
118+struct CmdDeleteMessage : public Command {
119+ CmdDeleteMessage
120 (int32_t const t, PlayerNumber const p, MessageId const m)
121 : Command(t), player(p), message(m)
122 {}
123
124 void execute (Game & game) override;
125- uint8_t id() const override {return QUEUE_CMD_EXPIREMESSAGE;}
126+ uint8_t id() const override {return QUEUE_CMD_DELETEMESSAGE;}
127
128 private:
129 PlayerNumber player;
130@@ -51,4 +51,4 @@
131
132 }
133
134-#endif // end of include guard: WL_LOGIC_CMD_EXPIRE_MESSAGE_H
135+#endif // end of include guard: WL_LOGIC_CMD_DELETE_MESSAGE_H
136
137=== modified file 'src/logic/cmd_luacoroutine.cc'
138--- src/logic/cmd_luacoroutine.cc 2014-09-10 08:55:04 +0000
139+++ src/logic/cmd_luacoroutine.cc 2014-09-18 18:57:10 +0000
140@@ -50,8 +50,7 @@
141 for (int i = 1; i <= game.map().get_nrplayers(); i++) {
142 Widelands::Message & msg =
143 *new Widelands::Message
144- ("Game Logic", game.get_gametime(),
145- Forever(), "Lua Coroutine Failed", e.what());
146+ ("Game Logic", game.get_gametime(), "Lua Coroutine Failed", e.what());
147 game.player(i).add_message(game, msg, true);
148 }
149 game.gameController()->setDesiredSpeed(0);
150
151=== modified file 'src/logic/message.h'
152--- src/logic/message.h 2014-07-28 14:23:03 +0000
153+++ src/logic/message.h 2014-09-18 18:57:10 +0000
154@@ -34,19 +34,17 @@
155 * A new message to be displayed to the player
156 * \param msgsender The message sender
157 * \param sent_time The (game) time at which the message is sent
158- * \param d The duration after which the message will expire
159 * \param t The message title
160 * \param b The message body
161 * \param c The message coords. The player will be able to taken there.
162 * Defaults to Coords::Null()
163- * \param ser A MapObject serial. If non null, the message will expire once
164+ * \param ser A MapObject serial. If non null, the message will be deleted once
165 * the object is removed from the game. Defaults to 0
166 * \param s The message status. Defaults to Status::New
167 */
168 Message
169 (const std::string & msgsender,
170 uint32_t sent_time,
171- Duration d,
172 const std::string & t,
173 const std::string & b,
174 Widelands::Coords const c = Coords::Null(),
175@@ -57,7 +55,6 @@
176 m_title(t),
177 m_body (b),
178 m_sent (sent_time),
179- m_duration(d),
180 m_position(c),
181 m_serial (ser),
182 m_status (s)
183@@ -65,7 +62,6 @@
184
185 const std::string & sender() const {return m_sender;}
186 uint32_t sent () const {return m_sent;}
187- Duration duration() const {return m_duration;}
188 const std::string & title() const {return m_title;}
189 const std::string & body () const {return m_body;}
190 Widelands::Coords position() const {return m_position;}
191@@ -78,7 +74,6 @@
192 std::string m_title;
193 std::string m_body;
194 uint32_t m_sent;
195- Duration m_duration; /// will expire after this duration
196 Widelands::Coords m_position;
197 Widelands::Serial m_serial; // serial to map object
198 Status m_status;
199
200=== modified file 'src/logic/message_queue.h'
201--- src/logic/message_queue.h 2014-09-14 13:53:08 +0000
202+++ src/logic/message_queue.h 2014-09-18 18:57:10 +0000
203@@ -78,13 +78,7 @@
204 ///
205 /// \returns the id of the added message.
206 ///
207- /// \Note The caller must make sure that a command is scheduled to expire
208- /// the message. Player::add_message does this and should be used for adding
209- /// messages to a player during the simulation.
210- ///
211 /// The loading code calls this function to add messages form the map file.
212- /// The commands to expire messages are not saved with the map. Therefore
213- /// the loading code must create them.
214 MessageId add_message(Message & message) {
215 assert_counts();
216 assert(message.status() < 3);
217@@ -111,16 +105,15 @@
218 assert_counts();
219 }
220
221- /// Expire the message with the given id so that it no longer exists.
222+ /// Delete the message with the given id so that it no longer exists.
223 /// Assumes that a message with the given id exists.
224- void expire_message(const MessageId& id) {
225+ void delete_message(const MessageId& id) {
226 assert_counts();
227 MessageQueue::iterator const it = find(id);
228 if (it == end()) {
229- // Messages can be expired when the timeout runs out, or when the linked
230- // MapObject is removed, or both. In this later case, two expire commands
231+ // Messages can be deleted when the linked MapObject is removed. Two delete commands
232 // will be executed, and the message will not be present for the second one.
233- // So we assume here that the message was removed from an earlier expire cmd.
234+ // So we assume here that the message was removed from an earlier delete cmd.
235 return;
236 }
237 Message & message = *it->second;
238
239=== modified file 'src/logic/player.cc'
240--- src/logic/player.cc 2014-09-14 16:08:13 +0000
241+++ src/logic/player.cc 2014-09-18 18:57:10 +0000
242@@ -36,7 +36,7 @@
243 #include "io/filewrite.h"
244 #include "logic/building.h"
245 #include "logic/checkstep.h"
246-#include "logic/cmd_expire_message.h"
247+#include "logic/cmd_delete_message.h"
248 #include "logic/cmd_luacoroutine.h"
249 #include "logic/constants.h"
250 #include "logic/constructionsite.h"
251@@ -309,14 +309,7 @@
252 MessageId Player::add_message
253 (Game & game, Message & message, bool const popup)
254 {
255- // Expire command
256 MessageId id = messages().add_message(message);
257- Duration const duration = message.duration();
258- if (duration != Forever()) {
259- game.cmdqueue().enqueue
260- (new CmdExpireMessage
261- (game.get_gametime() + duration, player_number(), id));
262- }
263
264 // MapObject connection
265 if (message.serial() > 0) {
266@@ -359,14 +352,14 @@
267
268 void Player::message_object_removed(MessageId m_id) const
269 {
270- // Send expire command
271+ // Send delete command
272 upcast(Game, game, &m_egbase);
273 if (!game) {
274 return;
275 }
276
277 game->cmdqueue().enqueue
278- (new CmdExpireMessage
279+ (new CmdDeleteMessage
280 (game->get_gametime(), m_plnum, m_id));
281 }
282
283
284=== modified file 'src/logic/player.h'
285--- src/logic/player.h 2014-09-14 11:31:58 +0000
286+++ src/logic/player.h 2014-09-18 18:57:10 +0000
287@@ -100,7 +100,7 @@
288 (Game &, Message &, uint32_t timeout, uint32_t radius);
289
290 /// Indicates that the object linked to the message has been removed
291- /// from the game. This implementation expires the message.
292+ /// from the game. This implementation deletes the message.
293 void message_object_removed(MessageId mid) const;
294
295 void set_message_status(const MessageId& id, Message::Status const status) {
296
297=== modified file 'src/logic/queue_cmd_ids.h'
298--- src/logic/queue_cmd_ids.h 2014-07-05 16:41:51 +0000
299+++ src/logic/queue_cmd_ids.h 2014-09-18 18:57:10 +0000
300@@ -82,7 +82,7 @@
301 #define QUEUE_CMD_CALCULATE_STATISTICS 133
302
303 #define QUEUE_CMD_CALL_ECONOMY_BALANCE 200
304-#define QUEUE_CMD_EXPIREMESSAGE 201
305+#define QUEUE_CMD_DELETEMESSAGE 201
306
307 #define QUEUE_CMD_NETCHECKSYNC 250
308 #define QUEUE_CMD_REPLAYSYNCWRITE 251
309
310=== modified file 'src/logic/ship.cc'
311--- src/logic/ship.cc 2014-09-10 10:18:46 +0000
312+++ src/logic/ship.cc 2014-09-18 18:57:10 +0000
313@@ -914,8 +914,7 @@
314 rt_description += "</p></rt>";
315
316 Message * msg = new Message
317- (msgsender, game.get_gametime(), 60 * 60 * 1000,
318- title, rt_description, get_position(), m_serial);
319+ (msgsender, game.get_gametime(), title, rt_description, get_position(), m_serial);
320
321 get_owner()->add_message(game, *msg);
322 }
323
324=== modified file 'src/logic/soldier.cc'
325--- src/logic/soldier.cc 2014-09-10 10:18:46 +0000
326+++ src/logic/soldier.cc 2014-09-18 18:57:10 +0000
327@@ -1571,7 +1571,7 @@
328 (game,
329 *new Message
330 ("game engine",
331- game.get_gametime(), Forever(),
332+ game.get_gametime(),
333 _("Logic error"),
334 buffer,
335 get_position(),
336@@ -1580,7 +1580,7 @@
337 (game,
338 *new Message
339 ("game engine",
340- game.get_gametime(), Forever(),
341+ game.get_gametime(),
342 _("Logic error"),
343 buffer,
344 opponent.get_position(),
345
346=== modified file 'src/logic/worker.cc'
347--- src/logic/worker.cc 2014-09-10 10:18:46 +0000
348+++ src/logic/worker.cc 2014-09-18 18:57:10 +0000
349@@ -947,7 +947,7 @@
350 (game,
351 *new Message
352 ("geologist " + rdescr->name(), // e.g. "geologist gold"
353- game.get_gametime(), 60 * 60 * 1000,
354+ game.get_gametime(),
355 rdescr->descname(),
356 message,
357 position,
358@@ -1845,7 +1845,7 @@
359 (game,
360 *new Message
361 ("game engine",
362- game.get_gametime(), Forever(),
363+ game.get_gametime(),
364 _("Worker got lost!"),
365 buffer,
366 get_position()),
367
368=== modified file 'src/map_io/map_message_saver.h'
369--- src/map_io/map_message_saver.h 2014-09-10 16:57:31 +0000
370+++ src/map_io/map_message_saver.h 2014-09-18 18:57:10 +0000
371@@ -35,8 +35,8 @@
372 /// file obviously has continuous numbers.) When the game is loaded, each
373 /// message will get its sequence number as id.
374 ///
375-/// When saving a PlayerMessageCommand (Cmd_MarkMessageAsRead or
376-/// Cmd_DeleteMessage) that refers to a message by id, use this map to
377+/// When saving a PlayerMessageCommand (CmdMarkMessageAsRead or
378+/// CmdDeleteMessage) that refers to a message by id, use this map to
379 /// translate from the id that is stored in the command to the sequence number
380 /// that will be used as the id of the message when the game is loaded.
381 struct MapMessageSaver : private std::map<MessageId, MessageId> {
382
383=== modified file 'src/map_io/map_players_messages_packet.cc'
384--- src/map_io/map_players_messages_packet.cc 2014-09-10 13:03:40 +0000
385+++ src/map_io/map_players_messages_packet.cc 2014-09-18 18:57:10 +0000
386@@ -56,7 +56,7 @@
387 if (begin != messages.end()) {
388 log
389 ("ERROR: The message queue for player %u contains a message "
390- "before any messages have been loade into it. This is a bug "
391+ "before any messages have been loaded into it. This is a bug "
392 "in the savegame loading code. It created a new message and "
393 "added it to the queue. This is only allowed during "
394 "simulation, not at load. The following messge will be "
395@@ -64,7 +64,6 @@
396 "\tsender : %s\n"
397 "\ttitle : %s\n"
398 "\tsent : %u\n"
399- "\tduration: %u\n"
400 "\tposition: (%i, %i)\n"
401 "\tstatus : %u\n"
402 "\tbody : %s\n",
403@@ -72,7 +71,6 @@
404 begin->second->sender ().c_str(),
405 begin->second->title ().c_str(),
406 begin->second->sent (),
407- begin->second->duration(),
408 begin->second->position().x, begin->second->position().y,
409 begin->second->status (),
410 begin->second->body ().c_str());
411@@ -96,30 +94,7 @@
412 "message is sent in the future: sent at %u but "
413 "gametime is only %u",
414 sent, gametime);
415- uint32_t duration = Forever(); // default duration
416- if (Section::Value const * const dv = s->get_val("duration")) {
417- duration = dv->get_positive();
418- if (duration == Forever())
419- throw GameDataError
420- (
421- "the value %u is not allowed as duration; it is "
422- "a special value meaning forever, which is the "
423- "default; omit the duration key to make the "
424- "message exist forever",
425- Forever());
426- if (sent + duration < sent)
427- throw GameDataError
428- (
429- "duration %u is too large; causes numeric "
430- "overflow when added to sent time %u",
431- duration, sent);
432- if (sent + duration < gametime)
433- throw GameDataError
434- (
435- "message should have expired at %u; sent at %u "
436- "with duration %u but gametime is already %u",
437- sent + duration, sent, duration, gametime);
438- }
439+
440 Message::Status status = Message::Archived; // default status
441 if (char const * const status_string = s->get_string("status")) {
442 try {
443@@ -147,15 +122,11 @@
444 (*new Message
445 (s->get_string ("sender", ""),
446 sent,
447- duration,
448 s->get_name (),
449 s->get_safe_string("body"),
450 get_coords("position", extent, Coords::Null(), s),
451 serial,
452 status));
453- // Expiration is scheduled for all messages (with finite
454- // duration) after the command queue has been loaded (in
455- // GameLoader::load_game).
456 previous_message_sent = sent;
457 } catch (const WException & e) {
458 throw GameDataError
459@@ -183,44 +154,11 @@
460 message_saver.add (temp_message.first);
461 const Message & message = *temp_message.second;
462 assert(message.sent() <= static_cast<uint32_t>(egbase.get_gametime()));
463- assert
464- (message.duration() == Forever() ||
465- message.sent() < message.sent() + message.duration());
466- if
467- (message.duration() != Forever() &&
468- message.sent() + message.duration()
469- <
470- static_cast<uint32_t>(egbase.get_gametime()))
471- log
472- ("ERROR: Trying to save a message that should have expired:\n"
473- "\tsent = %u, duration = %u, expiry = %u, gametime = %u\n"
474- "\tsender = \"%s\"\n"
475- "\ttitle: %s\n"
476- "\tbody: %s\n"
477- "\tposition: (%i, %i)\n"
478- "\tstatus: %s\n",
479- message.sent(), message.duration(),
480- message.sent() + message.duration(), egbase.get_gametime(),
481- message.sender().c_str(), message.title().c_str(),
482- message.body().c_str(),
483- message.position().x, message.position().y,
484- message.status() == Message::New ? "new" :
485- message.status() == Message::Read ? "read" :
486- message.status() == Message::Archived ? "archived" : "ERROR");
487- assert
488- (message.duration() == Forever() ||
489- static_cast<uint32_t>(egbase.get_gametime())
490- <=
491- message.sent() + message.duration());
492+
493 Section & s = prof.create_section_duplicate(message.title().c_str());
494 if (message.sender().size())
495 s.set_string("sender", message.sender ());
496 s.set_int ("sent", message.sent ());
497- {
498- Duration const duration = message.duration();
499- if (duration != Forever()) // The default duration. Do not write.
500- s.set_int("duration", duration);
501- }
502 s.set_string ("body", message.body ());
503 if (Coords const c = message.position())
504 set_coords("position", c, &s);
505
506=== modified file 'src/scripting/lua_game.cc'
507--- src/scripting/lua_game.cc 2014-09-10 17:52:49 +0000
508+++ src/scripting/lua_game.cc 2014-09-18 18:57:10 +0000
509@@ -269,11 +269,6 @@
510 Opts is a table of optional arguments and can be omitted. If it
511 exist it must contain string/value pairs of the following type:
512
513- :arg duration: if this is given, the message will be removed
514- from the players inbox after this many ms. Default:
515- message never expires.
516- :type duration: :class:`integer`
517-
518 :arg field: the field connected to this message. Default:
519 no field connected to message
520 :type field: :class:`wl.map.Field`
521@@ -297,18 +292,12 @@
522 std::string title = luaL_checkstring(L, 2);
523 std::string body = luaL_checkstring(L, 3);
524 Coords c = Coords::Null();
525- Duration d = Forever();
526 Message::Status st = Message::New;
527 std::string sender = "ScriptingEngine";
528 bool popup = false;
529
530 if (n == 4) {
531 // Optional arguments
532- lua_getfield(L, 4, "duration");
533- if (!lua_isnil(L, -1))
534- d = luaL_checkuint32(L, -1);
535- lua_pop(L, 1);
536-
537 lua_getfield(L, 4, "field");
538 if (!lua_isnil(L, -1))
539 c = (*get_user_class<LuaField>(L, -1))->coords();
540@@ -344,7 +333,6 @@
541 *new Message
542 (sender,
543 game.get_gametime(),
544- d,
545 title,
546 body,
547 c,
548@@ -1065,7 +1053,6 @@
549 PROP_RO(LuaMessage, title),
550 PROP_RO(LuaMessage, body),
551 PROP_RO(LuaMessage, sent),
552- PROP_RO(LuaMessage, duration),
553 PROP_RO(LuaMessage, field),
554 PROP_RW(LuaMessage, status),
555 {nullptr, nullptr, nullptr},
556@@ -1130,21 +1117,9 @@
557 return 1;
558 }
559
560-/* RST
561- .. attribute:: duration
562-
563- (RO) The time in milliseconds before this message is invalidated or nil if
564- this message has an endless duration.
565-*/
566-int LuaMessage::get_duration(lua_State * L) {
567- uint32_t d = get(L, get_game(L)).duration();
568- if (d == Forever())
569- return 0;
570- lua_pushuint32(L, d);
571- return 1;
572-}
573-
574-/* RST
575+
576+/* RST
577+>>>>>>> MERGE-SOURCE
578 .. attribute:: field
579
580 (RO) The field that corresponds to this Message.
581
582=== modified file 'src/scripting/lua_game.h'
583--- src/scripting/lua_game.h 2014-09-10 17:52:49 +0000
584+++ src/scripting/lua_game.h 2014-09-18 18:57:10 +0000
585@@ -165,7 +165,6 @@
586 int get_sent(lua_State * L);
587 int get_title(lua_State * L);
588 int get_body(lua_State * L);
589- int get_duration(lua_State * L);
590 int get_field(lua_State * L);
591 int get_status(lua_State * L);
592 int set_status(lua_State * L);
593
594=== modified file 'test/maps/lua_testsuite.wmf/scripting/messages.lua'
595--- test/maps/lua_testsuite.wmf/scripting/messages.lua 2014-01-12 19:06:22 +0000
596+++ test/maps/lua_testsuite.wmf/scripting/messages.lua 2014-09-18 18:57:10 +0000
597@@ -1,52 +1,47 @@
598 -- =======================================================================
599--- Testing Messages System
600+-- Testing Messages System
601 -- =======================================================================
602
603 messages_tests = lunit.TestCase("Messages")
604-function messages_tests:setup()
605+function messages_tests:setup()
606 for i,m in ipairs(player1.inbox) do
607 m.status = "archived"
608 end
609 end
610
611-function messages_tests:test_defaults()
612+function messages_tests:test_defaults()
613 local m = player1:send_message("Hallo", "World!")
614 assert_equal("Hallo", m.title)
615 assert_equal("World!", m.body)
616 assert_equal("ScriptingEngine", m.sender)
617 assert_equal(0, m.sent)
618 assert_equal(0, m.sent)
619- assert_equal(nil, m.duration)
620 assert_equal(nil, m.field)
621 assert_equal("new", m.status)
622 end
623-function messages_tests:test_status_read()
624+function messages_tests:test_status_read()
625 local m = player1:send_message("Hallo", "World!", {status="read"})
626 assert_equal("read", m.status)
627 end
628-function messages_tests:test_status_archived()
629+function messages_tests:test_status_archived()
630 local m = player1:send_message("Hallo", "World!", {status="archived"})
631 assert_equal("archived", m.status)
632 end
633-function messages_tests:test_status_illegal()
634+function messages_tests:test_status_illegal()
635 assert_error("Illegal status!", function()
636 player1:send_message("Hallo", "World!", {status="nono"})
637 end)
638 end
639-function messages_tests:test_sender()
640+function messages_tests:test_sender()
641 local m = player1:send_message("Hallo", "World!", {sender="i am you"})
642 assert_equal("i am you", m.sender)
643 end
644-function messages_tests:test_field()
645+function messages_tests:test_field()
646 local f = map:get_field(23,28)
647 local m = player1:send_message("Hallo", "World!", {field = f})
648 assert_equal(f, m.field)
649 end
650-function messages_tests:test_duration()
651- local m = player1:send_message("Hallo", "World!", {duration = 2000})
652- assert_equal(2000, m.duration)
653-end
654-function messages_tests:test_changing_status()
655+function messages_tests:test_changing_status()
656 local m = player1:send_message("Hallo", "World!")
657 m.status = "read"
658 assert_equal("read", m.status)

Subscribers

People subscribed via source and target branches

to status/vote changes: