mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 16:10:02 +00:00
now allow configs to be streamed directly to an ostream
remove an iterator redefinition remove a pointless debug calculation that was not being output anywhere
This commit is contained in:
parent
04f6d19d1e
commit
9f72c5331a
@ -202,7 +202,7 @@ std::string recruit_unit(const gamemap& map, const int side, unit_map& units,
|
||||
|
||||
config cfg_unit1;
|
||||
new_unit.write(cfg_unit1);
|
||||
DBG_NG << cfg_unit1.debug();
|
||||
DBG_NG << cfg_unit1;
|
||||
if (!game_config::ignore_replay_errors) {
|
||||
throw replay::error("OOS while recruiting.");
|
||||
}
|
||||
|
@ -688,22 +688,26 @@ void config::reset_translation() const
|
||||
std::string config::debug() const
|
||||
{
|
||||
std::ostringstream outstream;
|
||||
outstream << *this;
|
||||
return outstream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& outstream, const config& cfg) {
|
||||
static int i = 0;
|
||||
i++;
|
||||
for(string_map::const_iterator val = values.begin(); val != values.end(); ++val) {
|
||||
for(string_map::const_iterator val = cfg.values.begin(); val != cfg.values.end(); ++val) {
|
||||
for (int j = 0; j < i; j++){ outstream << char(9); }
|
||||
outstream << val->first << " = " << val->second << "\n";
|
||||
}
|
||||
|
||||
for(all_children_iterator list = ordered_begin(); list != ordered_end(); ++list) {
|
||||
for(config::all_children_iterator list = cfg.ordered_begin(); list != cfg.ordered_end(); ++list) {
|
||||
{ for (int j = 0; j < i-1; j++){ outstream << char(9); } }
|
||||
outstream << "[" << *(*list).first << "]\n";
|
||||
outstream << (*list).second->debug();
|
||||
outstream << (*list).second;
|
||||
{ for (int j = 0; j < i-1; j++){ outstream << char(9); } }
|
||||
outstream << "[/" << *(*list).first << "]\n";
|
||||
}
|
||||
i--;
|
||||
return outstream.str();
|
||||
return outstream;
|
||||
}
|
||||
|
||||
std::string config::hash() const
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "tstring.hpp"
|
||||
@ -179,5 +179,6 @@ private:
|
||||
|
||||
bool operator==(const config& a, const config& b);
|
||||
bool operator!=(const config& a, const config& b);
|
||||
std::ostream& operator << (std::ostream& os, const config& cfg);
|
||||
|
||||
#endif
|
||||
|
@ -2514,7 +2514,7 @@ static void commit_wmi_commands() {
|
||||
mref->command.add_child("allow_undo");
|
||||
}
|
||||
LOG_NG << "setting command for " << mref->name << "\n";
|
||||
LOG_NG << wcc.second->debug();
|
||||
LOG_NG << *wcc.second;
|
||||
delete wcc.second;
|
||||
wmi_command_changes.pop_back();
|
||||
}
|
||||
|
@ -1237,7 +1237,7 @@ game_state::~game_state() {
|
||||
void game_state::set_variables(const config& vars) {
|
||||
if(!variables.empty()) {
|
||||
WRN_NG << "clobbering the game_state variables\n";
|
||||
WRN_NG << variables.debug();
|
||||
WRN_NG << variables;
|
||||
}
|
||||
variables = vars;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void level_to_gamestate(config& level, game_state& state, bool saved_game)
|
||||
LOG_NG << "No variables were found for the game_state." << std::endl;
|
||||
} else {
|
||||
LOG_NG << "Variables found and loaded into game_state:" << std::endl;
|
||||
LOG_NG << state.get_variables().debug();
|
||||
LOG_NG << state.get_variables();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,7 +687,7 @@ connection receive_data(config& cfg, connection connection_num)
|
||||
}
|
||||
}
|
||||
if(!cfg.empty()) {
|
||||
DBG_NW << "RECEIVED from: " << result << ": " << cfg.debug();
|
||||
DBG_NW << "RECEIVED from: " << result << ": " << cfg;
|
||||
}
|
||||
|
||||
assert(result != 0);
|
||||
@ -738,7 +738,7 @@ void send_data(const config& cfg, connection connection_num, const bool gzipped)
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_NW << "SENDING to: " << connection_num << ": " << cfg.debug();
|
||||
LOG_NW << "SENDING to: " << connection_num << ": " << cfg;
|
||||
network_worker_pool::queue_data(info->second.sock, cfg, gzipped);
|
||||
}
|
||||
|
||||
|
@ -511,7 +511,6 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
||||
// Sends scenario data
|
||||
config cfg;
|
||||
cfg.add_child("store_next_scenario", *scenario);
|
||||
(*scenario).debug();
|
||||
|
||||
// Adds player information, and other state
|
||||
// information, to the configuration object
|
||||
|
@ -746,7 +746,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map, const game_data& g
|
||||
bool fix_shroud = false;
|
||||
if (cfg)
|
||||
{
|
||||
DBG_REPLAY << "Replay data:\n" << cfg->debug() << "\n";
|
||||
DBG_REPLAY << "Replay data:\n" << *cfg << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ void game::update_side_data() {
|
||||
const config::child_itors level_sides = level_.child_range("side");
|
||||
/* for (config::child_iterator side = level_sides.first;
|
||||
side != level_sides.second; ++side)
|
||||
DBG_GAME << (*side)->debug();*/
|
||||
DBG_GAME << (**side);*/
|
||||
// For each user:
|
||||
// * Find the username.
|
||||
// * Find the side this username corresponds to.
|
||||
@ -756,7 +756,7 @@ void game::filter_commands(const network::connection member, config& cfg) {
|
||||
const config& server_msg = construct_server_message(msg.str());
|
||||
send_data(server_msg);
|
||||
record_data(server_msg);
|
||||
DBG_GAME << (*i)->debug();
|
||||
DBG_GAME << (**i);
|
||||
marked.push_back(index - marked.size());
|
||||
}
|
||||
++index;
|
||||
@ -768,7 +768,7 @@ void game::filter_commands(const network::connection member, config& cfg) {
|
||||
}
|
||||
|
||||
bool game::process_commands(const config& cfg) {
|
||||
//DBG_GAME << "processing commands: '" << cfg.debug() << "'\n";
|
||||
//DBG_GAME << "processing commands: '" << cfg << "'\n";
|
||||
bool res = false;
|
||||
const config::child_list& cmd = cfg.get_children("command");
|
||||
for(config::child_list::const_iterator i = cmd.begin(); i != cmd.end(); ++i) {
|
||||
|
@ -1244,7 +1244,7 @@ void server::process_data_game(const network::connection sock, const config& dat
|
||||
// FIXME: Relaying arbitrary data that possibly didn't get handled at all
|
||||
// seems like a bad idea.
|
||||
DBG_SERVER << "Relaying data RECEIVED from: " << sock
|
||||
<< " to all other players: " << data.debug();
|
||||
<< " to all other players: " << data;
|
||||
g->send_data(data, sock);
|
||||
if (g->started()) {
|
||||
g->record_data(data);
|
||||
|
@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE( test_send_client )
|
||||
|
||||
BOOST_CHECK_MESSAGE( receive_from == server_client1, "Received data is not from test client 1" );
|
||||
|
||||
BOOST_CHECK_MESSAGE(cfg_send == received, "send is not same as received\n" << cfg_send.debug() << "\n" << received.debug() );
|
||||
BOOST_CHECK_MESSAGE(cfg_send == received, "send is not same as received\n" << cfg_send << "\n" << received.debug() );
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,11 +86,12 @@ static void move_unit_between(const gamemap::location& a, const gamemap::locatio
|
||||
animator.wait_until(target_time);
|
||||
gamemap::location arr[6];
|
||||
get_adjacent_tiles(a, arr);
|
||||
for (unsigned int i = 0; i < 6; i++) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < 6; i++) {
|
||||
disp->invalidate(arr[i]);
|
||||
}
|
||||
get_adjacent_tiles(b, arr);
|
||||
for (unsigned int i = 0; i < 6; i++) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
disp->invalidate(arr[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user