Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to write multiple configs in a network package.
It is now possible to write multiple config objects in a single package, the server reads them then as one big config. Prevoulsy if people wanted to do that they had to copy both configs into a new config which is slow, specially if those configs are very big becasue they contain a whole scenario or an era.
- Loading branch information
Showing
5 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright (C) 2014 - 2016 by David White <dave@whitevine.net> | ||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/ | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY. | ||
See the COPYING file for more details. | ||
*/ | ||
#pragma once | ||
|
||
#include <string> | ||
#include "config.hpp" | ||
#include <boost/variant.hpp> | ||
|
||
//Similar to config_of but it stores references to configs (instead of cyoping them). | ||
struct configr_of | ||
{ | ||
template <typename AT> | ||
configr_of(const std::string& attrname, AT value) | ||
{ | ||
this->operator()(attrname, value); | ||
} | ||
|
||
configr_of(const config& cfg) | ||
{ | ||
this->operator()(cfg); | ||
} | ||
|
||
configr_of& operator()(const config& cfg) | ||
{ | ||
data_ = &cfg; | ||
return *this; | ||
} | ||
|
||
configr_of& operator()(const std::string& tagname, const configr_of& child) | ||
{ | ||
subtags_.push_back(std::make_pair(&tagname, &child)); | ||
return *this; | ||
} | ||
std::vector<std::pair<const std::string*, const configr_of*>> subtags_; | ||
const config* data_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters