Made it so that [modify_side] is able to change...

...the current_player attribute; made the Lua stuff return the
attribute in the form of t_strings.
This commit is contained in:
Steven Panek 2011-12-16 04:06:47 +00:00
parent 62d2e838c6
commit 8eaa9c2ec6
4 changed files with 14 additions and 2 deletions

View file

@ -953,6 +953,7 @@ WML_HANDLER_FUNCTION(modify_side, /*event_info*/, cfg)
std::string team_name = cfg["team_name"];
std::string user_team_name = cfg["user_team_name"];
std::string current_player = cfg["current_player"];
std::string controller = cfg["controller"];
std::string recruit_str = cfg["recruit"];
std::string shroud_data = cfg["shroud_data"];
@ -980,6 +981,10 @@ WML_HANDLER_FUNCTION(modify_side, /*event_info*/, cfg)
teams[team_index].change_team(teams[team_index].team_name(),
user_team_name);
}
if (!current_player.empty()) {
LOG_NG << "change side's current_player to '" << current_player << "'\n";
teams[team_index].set_current_player(current_player);
}
// Modify recruit list (override)
if (!recruit_str.empty()) {
std::vector<std::string> recruit = utils::split(recruit_str);

View file

@ -1552,7 +1552,7 @@ static int impl_side_get(lua_State *L)
return_string_attrib("name", t.name());
return_string_attrib("color", t.map_color_to());
return_cstring_attrib("controller", t.controller_string());
return_string_attrib("current_player", t.current_player());
return_tstring_attrib("current_player", t.current_player());
if (strcmp(m, "recruit") == 0) {
std::set<std::string> const &recruits = t.recruits();
@ -1591,7 +1591,7 @@ static int impl_side_set(lua_State *L)
modify_tstring_attrib("user_team_name", t.change_team(t.team_name(), value));
modify_string_attrib("team_name", t.change_team(value, t.user_team_name()));
modify_string_attrib("controller", t.change_controller(value));
modify_string_attrib("current_player", t.set_current_player(value));
modify_tstring_attrib("current_player", t.set_current_player(value));
if (strcmp(m, "recruit") == 0) {
t.set_recruits(std::set<std::string>());

View file

@ -495,6 +495,12 @@ void team::change_team(const std::string &name, const t_string &user_name)
clear_caches();
}
void team::set_current_player(const t_string &current_player)
{
info_.current_player = current_player;
clear_caches();
}
void team::clear_caches(){
// Reset the cache of allies for all teams
if(teams != NULL) {

View file

@ -223,6 +223,7 @@ public:
const std::string& team_name() const { return info_.team_name; }
const t_string &user_team_name() const { return info_.user_team_name; }
void change_team(const std::string &name, const t_string &user_name);
void set_current_player(const t_string &current_player);
const std::string& flag() const { return info_.flag; }
const std::string& flag_icon() const { return info_.flag_icon; }