Author: jamit
Date: Mon Dec 31 23:40:05 2012
New Revision: 55976

URL: http://svn.gna.org/viewcvs/wesnoth?rev=55976&view=rev
Log:
Store DSU toggles and manual shroud updates in replays.

This should resolve the remaining reported bugs with sighted events.

Modified:
    trunk/changelog
    trunk/src/actions/undo.cpp
    trunk/src/actions/undo.hpp
    trunk/src/menu_events.cpp
    trunk/src/replay.cpp
    trunk/src/replay.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Dec 31 23:40:05 2012
@@ -36,6 +36,7 @@
      cleaner WML when the unit type is not necessarily known in advance.
    * Split the 'not_living' unit status into 'unpoisonable', 'undrainable' and
      'unplagueable'. 'not_living' now acts on the whole group
+   * The bugs with sighted events have been resolved.
  * Miscellaneous and bug fixes:
    * The undo stack is preserved across a save-reload.
    * Removed several unused private member variables.

Modified: trunk/src/actions/undo.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions/undo.cpp?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/src/actions/undo.cpp (original)
+++ trunk/src/actions/undo.cpp Mon Dec 31 23:40:05 2012
@@ -209,9 +209,14 @@
  * Updates fog/shroud based on the undo stack, then updates stack as needed.
  * Call this when "updating shroud now".
  * This may fire events and change the game state.
- */
-void undo_list::commit_vision()
-{
+ * @param[in]  is_replay  Set to true when this is called during a replay.
+ */
+void undo_list::commit_vision(bool is_replay)
+{
+       if ( !is_replay )
+               // Record this.
+               recorder.update_shroud();
+
        // Update fog/shroud.
        size_t erase_to = apply_shroud_changes();
 
@@ -413,16 +418,20 @@
        else if ( action.is_auto_shroud() ) {
                // This does not count as an undoable action, so undo the next
                // action instead.
+               recorder.undo();
                undo();
                // Now keep the auto-shroud toggle at the top of the undo stack.
+               recorder.add_auto_shroud(action.active);
                add_auto_shroud(action.active);
                return;
        }
        else if ( action.is_update_shroud() ) {
                // This does not count as an undoable action, so undo the next
                // action instead.
+               recorder.undo();
                undo();
                // Now keep the shroud update at the top of the undo stack.
+               recorder.update_shroud();
                add_update_shroud();
                return;
        }

Modified: trunk/src/actions/undo.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions/undo.hpp?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/src/actions/undo.hpp (original)
+++ trunk/src/actions/undo.hpp Mon Dec 31 23:40:05 2012
@@ -171,7 +171,7 @@
        /// Clears the stack of undoable (and redoable) actions.
        void clear();
        /// Updates fog/shroud based on the undo stack, then updates stack as 
needed.
-       void commit_vision();
+       void commit_vision(bool is_replay=false);
        /// Performs some initializations and error checks when starting a new
        /// side-turn.
        void new_side_turn(int side);

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Mon Dec 31 23:40:05 2012
@@ -1103,6 +1103,9 @@
        bool auto_shroud = current_team.auto_shroud_updates();
        // If we're turning automatic shroud updates on, then commit all moves
        if (!auto_shroud) update_shroud_now(side_num);
+
+       // Toggle the setting and record this.
+       recorder.add_auto_shroud(!auto_shroud);
        current_team.set_auto_shroud_updates(!auto_shroud);
        resources::undo_stack->add_auto_shroud(!auto_shroud);
 }

Modified: trunk/src/replay.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.cpp?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/src/replay.cpp (original)
+++ trunk/src/replay.cpp Mon Dec 31 23:40:05 2012
@@ -342,6 +342,25 @@
        add_unit_checksum(b,current_);
 }
 
+/**
+ * Records that the player has toggled automatic shroud updates.
+ */
+void replay::add_auto_shroud(bool turned_on)
+{
+       config* cmd = add_command(false);
+       config& child = cmd->add_child("auto_shroud");
+       child["active"] = turned_on;
+}
+
+/**
+ * Records that the player has manually updated fog/shroud.
+ */
+void replay::update_shroud()
+{
+       config* cmd = add_command(false);
+       cmd->add_child("update_shroud");
+}
+
 void replay::add_seed(const char* child_name, int seed)
 {
        LOG_REPLAY << "Setting seed for child type " << child_name << ": " << 
seed << "\n";
@@ -1219,7 +1238,22 @@
                        get_replay_source().add_expected_advancement(loc);
                        DBG_REPLAY << "got an explicit advance\n";
 
-               } else if (cfg->child("global_variable")) {
+               }
+               else if (cfg->child("global_variable"))
+               {
+               }
+               else if (const config &child = cfg->child("auto_shroud"))
+               {
+                       bool active = child["active"].to_bool();
+                       // Turning on automatic shroud causes vision to be 
updated.
+                       if ( active )
+                               resources::undo_stack->commit_vision(true);
+ 
+                       current_team.set_auto_shroud_updates(active);
+               }
+               else if ( cfg->child("update_shroud") )
+               {
+                       resources::undo_stack->commit_vision(true);
                }
                else  if ( cfg->child("checksum") )
                {
@@ -1227,6 +1261,7 @@
                }
                else
                {
+                       // End of the if-else chain: unrecognized action.
                        replay::process_error("unrecognized action:\n" + 
cfg->debug());
                }
 

Modified: trunk/src/replay.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.hpp?rev=55976&r1=55975&r2=55976&view=diff
==============================================================================
--- trunk/src/replay.hpp (original)
+++ trunk/src/replay.hpp Mon Dec 31 23:40:05 2012
@@ -71,6 +71,8 @@
                int att_weapon, int def_weapon, const std::string& 
attacker_type_id,
                const std::string& defender_type_id, int attacker_lvl,
                int defender_lvl, const size_t turn, const time_of_day &t);
+       void add_auto_shroud(bool turned_on);
+       void update_shroud();
        void add_seed(const char* child_name, int seed);
        void user_input(const std::string &, const config &);
        void add_label(const terrain_label*);


_______________________________________________
Wesnoth-commits mailing list
Wesnoth-commits@gna.org
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to