remove unused functions + fix comments

This commit is contained in:
gfgtdf 2014-06-25 04:25:07 +02:00
parent 7be3abcc0a
commit 467ea33855
8 changed files with 79 additions and 82 deletions

View file

@ -15,7 +15,9 @@
namespace random_new
{
//this class does NOT give synced random results.
/**
this class does not give synced random results derived classes might do.
*/
class rng
{
public:
@ -28,9 +30,11 @@ namespace random_new
unsigned int random_calls_;
};
// this generator is autmatilcy synced during synced context.
// calling this should automaticly clear the undo stack.
//
/**
This generator is automatically synced during synced context.
Calling this rng during a synced context automatically makes undoing impossible.
Outside a synced context this has the same effect as rand()
*/
extern rng* generator;
}

View file

@ -17,11 +17,11 @@
namespace random_new
{
/*
this is the determinstic random class, it behaves similar to the old random class.
it's only application is at the very start of the scneario.
/**
This rng is used when the normal synced rng is not available
this is currently only he case at the very start of the scenario (random generation of starting units traits).
or durign the "Deterministic SP mode"
or during the "Deterministic SP mode"
*/
class rng_deterministic : public random_new::rng
{
@ -34,7 +34,9 @@ namespace random_new
rand_rng::simple_rng& generator_;
};
//RAII class
/**
RAII class to use rng_deterministic in the current scope.
*/
class set_random_determinstic
{
public:

View file

@ -19,7 +19,6 @@
#include "resources.hpp"
#include "play_controller.hpp"
//void replay::add_recruit(const std::string& type_id, const map_location& loc, const map_location& from)
config replay_helper::get_recruit(const std::string& type_id, const map_location& loc, const map_location& from)
{
config val;
@ -137,12 +136,6 @@ config replay_helper::get_init_side()
init_side["side_number"] = resources::controller->current_side();
return init_side;
}
/*
void replay::end_turn()
{
config* const cmd = add_command();
cmd->add_child("end_turn");
}*/
config replay_helper::get_event(const std::string& name, const map_location& loc, const map_location* last_select_loc)
{
@ -157,7 +150,6 @@ config replay_helper::get_event(const std::string& name, const map_location& loc
config& source = ev.add_child("last_select");
last_select_loc->write(source);
}
//(*cmd)["undo"] = false;
return ev;
}

View file

@ -416,14 +416,6 @@ const config& saved_game::get_replay_starting_pos()
return this->replay_start_.child("some_non_existet_invalid");
}
void saved_game::remove_old_scenario()
{
remove_snapshot();
carryover_sides = config();
replay_data = config();
replay_start_ = config();
}
void saved_game::convert_to_start_save()
{
assert(starting_pos_type_ == STARTINGPOS_SNAPSHOT);

View file

@ -12,9 +12,13 @@ class saved_game
{
enum STARTING_POS_TYPE
{
/// There is no scenario stating pos data.
STARTINGPOS_NONE,
/// We have a [snapshot] (mid-game-savefile).
STARTINGPOS_SNAPSHOT,
/// We have a [scenario] (start-of-scenario) savefile.
STARTINGPOS_SCENARIO,
/// We failed to get a starting pos in expand_scenario.
STARTINGPOS_INVALID
};
public:
@ -25,32 +29,30 @@ public:
~saved_game(){}
saved_game& operator=(const saved_game& state);
//write the config information into a stream (file)
/// writes the config information into a stream (file)
void write_config(config_writer& out) const;
void write_general_info(config_writer& out) const;
void write_carryover(config_writer& out) const;
void write_starting_pos(config_writer& out) const;
config to_config() const;
///Removes everything except [carryover_sides_start]
void remove_old_scenario();
game_classification& classification() { return classification_; }
const game_classification& classification() const { return classification_; }
/** Multiplayer parameters for this game */
mp_game_settings& mp_settings() { return mp_settings_; }
const mp_game_settings& mp_settings() const { return mp_settings_; }
///copies the content of a [scenario] with the correct id attribute into this object.
/// copies the content of a [scenario] with the correct id attribute from the game config into this object.
void expand_scenario();
///merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides]
///Removes [carryover_sides_start] afterwards
/// merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides]
/// Removes [carryover_sides_start] afterwards
void expand_carryover();
/// adds [event]s from [era] and [modification] into this scenario
/// does NOT expand [option]s because variables are persitent anyway to we don't need it
/// should be called after expand_scenario() but before expand_carryover()
void expand_mp_events();
/// adds values of [option]s inte [carryover_sides_start][variables] so that they are applied in the next level.
/// adds values of [option]s into [carryover_sides_start][variables] so that they are applied in the next level.
/// Note that since [variabels] are persistent we only use this once at the beginning
/// of a campaign but callings it multiple times is no harm eigher
/// of a campaign but calling it multiple times is no harm eigher
void expand_mp_options();
/// takes care of generate_map=, generate_scenario=, map= attributes
/// This should be called before expanding carryover or mp_events because this might completely replace starting_pos_.
@ -64,14 +66,14 @@ public:
{
return starting_pos_type_ == STARTINGPOS_SNAPSHOT;
}
/// converts a normal savegame form the end of a scenaio to a start-of-scenario savefiel for teh next scenaio,
/// converts a normal savegame form the end of a scenaio to a start-of-scenario savefile for the next scenaio,
/// The saved_game must contain a [snapshot] made during the linger mode of the last scenaio.
void convert_to_start_save();
/// retruns from the config from which the replay will be started. Usualy this is [replay_start] but it can also be a [scenario] if no replay_start is present
/// @return the starting pos for replays. Usualy this is [replay_start] but it can also be a [scenario] if no [replay_start] is present
const config& get_replay_starting_pos();
/// returns the id of teh curently played scenaio or the id of the next scenaio if this is a between-scenaios-save (also called start-of-scenario) save.
/// @return the id of the currently played scenario or the id of the next scenario if this is a between-scenaios-save (also called start-of-scenario-save).
std::string get_scenario_id();
/// retruns from the config from which teh game will be started. [scenario] or [snapshot] in the file
/// @return the config from which the game will be started. (this is [scenario] or [snapshot] in the savefile)
config& get_starting_pos();
config& replay_start() { return replay_start_; }
const config& replay_start() const { return replay_start_; }
@ -83,28 +85,24 @@ public:
*/
config replay_data;
/** The carryover information for all sides*/
/** The carryover information for all sides that arent used in this scenario to be carried over to the next scenario */
config carryover_sides;
/** The carryover information for all sides as it was before the scenario started*/
/** The carryover information for all sides as it was before the scenario started */
config carryover_sides_start;
private:
/** First turn snapshot for replays, contains starting position */
/** snapshot made before the start event. To be used as a starting pos for replays */
config replay_start_;
/** some general information of the game that doesn't change during the game */
game_classification classification_;
mp_game_settings mp_settings_;
/**
* Snapshot of the game's current contents.
*
* i.e. unless the player selects to view a replay, the game's settings are
* read in from this object.
*/
STARTING_POS_TYPE starting_pos_type_;
The starting pos where the (non replay) game will be started from.
This can eigher be a [scenario] for a fresh game or a [snapshot] if this is a reloaded game
*/
config starting_pos_;
STARTING_POS_TYPE starting_pos_type_;
};

View file

@ -35,7 +35,7 @@ checkup::~checkup()
{
}
#if 0
void checkup::unit_checksum(const map_location& loc, bool local)
{
unit_map::iterator u = resources::units->find(loc);
@ -71,7 +71,7 @@ void checkup::unit_checksum(const map_location& loc, bool local)
events::chat_handler::MESSAGE_PRIVATE, false);
}
}
#endif
ignored_checkup::ignored_checkup()
{

View file

@ -16,8 +16,8 @@
#include "config.hpp"
struct map_location;
/*
a class to check whether calculated ingame results match the results calculated during the original game.
/**
A class to check whether the results that were calculated in the replay match the results calculated during the original game.
note, that you shouldn't add new checkups to existent user actions or you might break replay compability by bringing the [checkups] tag of older saves in unorder.
so if you really want to add new checkups, you should wrap your checkup_instance->... call in a if(resources::state_of_game->classification.version ....) or similar.
@ -27,24 +27,25 @@ class checkup
public:
checkup();
virtual ~checkup();
/*
does only compares data in replays.
returns wether the two config objects are equal.
/**
Compares data to the results calculated during the original game.
It's undefined whether this function also compares calculated results from different clients in a mp game.
returns whether the two config objects are equal.
*/
virtual bool local_checkup(const config& expected_data, config& real_data) = 0;
/*
/**
compares data on all clients in a networked game, the disadvantage is,
that the clients have to communicate more which might be not wanted if some persons have laggy inet.
returns whether the two config objects are equal.
this is currently not used.
This is currently not used.
This is currently not implemented.
TODO: we might want to change the design to have a 'local_checkup' subclass (the normal case)
and a 'networked_checkup' subclass (for network OOS debugging) of the checkup class that then replace
the synced_checkup class. Instead of having 2 different methods local_checkup,networked_checkup.
*/
virtual bool networked_checkup(const config& expected_data, config& real_data) = 0;
/*
we cannot use the replay.add_checksum anymore without risks because we might send the unit_checksum after it has been recorded at the other client.
this is a helper function for that.
*/
void unit_checksum(const map_location& loc, bool local = true);
};
class synced_checkup : public checkup
@ -68,7 +69,13 @@ class ignored_checkup : public checkup
public:
ignored_checkup();
virtual ~ignored_checkup();
/**
always returns true
*/
virtual bool local_checkup(const config& expected_data, config& real_data);
/**
always returns true
*/
virtual bool networked_checkup(const config& expected_data, config& real_data);
};

View file

@ -61,13 +61,13 @@ public:
*/
static bool run_in_synced_context(const std::string& commandname,const config& data, bool use_undo = true, bool show = true , bool store_in_replay = true , synced_command::error_handler_function error_handler = default_error_function);
/*
checks whether we are currently running in a synced context, and if not we enter it.
this is nevery called from so_replay_handle.
/**
checks whether we are currently running in a synced context, and if not we enters it.
this is never called from so_replay_handle.
*/
static bool run_in_synced_context_if_not_already(const std::string& commandname,const config& data, bool use_undo = true, bool show = true , synced_command::error_handler_function error_handler = default_error_function);
/*
Returns whether we are currently executing a synced action like recruit, start, recall, disband, movement, attack, init_side, end_turn, fire_event, lua_ai, auto_shroud or similar.
/**
@return whether we are currently executing a synced action like recruit, start, recall, disband, movement, attack, init_side, end_turn, fire_event, lua_ai, auto_shroud or similar.
*/
static synced_state get_synced_state();
/*
@ -78,31 +78,33 @@ public:
Generates a new seed for a synced event, by asking the 'server'
*/
static int generate_random_seed();
/*
called from get_user_choice;
/**
called from get_user_choice while waiting for a remove user choice.
*/
static void pull_remote_user_input();
/*
called from get_user_choice;
/**
called from get_user_choice to send a recently made choice to the other clients.
Does not receive any data from the network any sends data.
*/
static void send_user_choice();
/*
/**
a function to be passed to run_in_synced_context to assert false on error (the default).
*/
static void default_error_function(const std::string& message, bool heavy);
/*
/**
a function to be passed to run_in_synced_context to log the error.
*/
static void just_log_error_function(const std::string& message, bool heavy);
/*
/**
a function to be passed to run_in_synced_context to ignore the error.
*/
static void ignore_error_function(const std::string& message, bool heavy);
/*
returns a rng_deterministic if in determinsic mode otherwise a rng_synced.
/**
@return a rng_deterministic if in determinsic mode otherwise a rng_synced.
*/
static boost::shared_ptr<random_new::rng> get_rng_for_action();
/*
/**
@return whether we already sended data about the current action to other clients. which means we cannot undo it.
returns is_simultaneously_
*/
static bool is_simultaneously();
@ -110,8 +112,8 @@ public:
sets is_simultaneously_ = false, called when entering the synced context.
*/
static void reset_is_simultaneously();
/*
whether there were recently no methods called that prevent undoing.
/**
@return whether there were recently no methods called that prevent undoing.
*/
static bool can_undo();
private:
@ -140,7 +142,7 @@ class set_scontext_synced
public:
set_scontext_synced();
/*
use this if you have multiple synced_context but only one replay entry.
use this contructor if you have multiple synced_context but only one replay entry.
*/
set_scontext_synced(int num);
~set_scontext_synced();
@ -168,7 +170,7 @@ private:
random_new::rng* old_rng_;
};
/*
/**
an object to leave the synced context during draw when we dont know whether we are in a synced context or not.
if we are in a sanced context we leave the synced context otherwise it has no effect.
we need this because we might call lua's wesnoth.theme_items during draw and we dont want to have that an effect on the gamestate in this case.