Changed action::from_config() to do what its comment says it should do.

This commit is contained in:
Tommy Schmitz 2011-08-18 23:39:04 +00:00
parent ccaa6c64be
commit 093ab10fa0
2 changed files with 16 additions and 15 deletions

View File

@ -59,18 +59,20 @@ action_ptr action::from_config(config const& cfg, bool hidden)
{
std::string type = cfg["type"];
if(type=="move")
return action_ptr(new move(cfg,hidden));
else if(type=="attack")
return action_ptr(new attack(cfg,hidden));
else if(type=="recruit")
return action_ptr(new recruit(cfg,hidden));
else if(type=="recall")
return action_ptr(new recall(cfg,hidden));
else if(type=="suppose_dead")
return action_ptr(new suppose_dead(cfg,hidden));
try {
if(type=="move")
return action_ptr(new move(cfg,hidden));
else if(type=="attack")
return action_ptr(new attack(cfg,hidden));
else if(type=="recruit")
return action_ptr(new recruit(cfg,hidden));
else if(type=="recall")
return action_ptr(new recall(cfg,hidden));
else if(type=="suppose_dead")
return action_ptr(new suppose_dead(cfg,hidden));
} catch(action::ctor_err const&) {}
throw ctor_err("action: Invalid type");
return action_ptr();
}
void action::hide()

View File

@ -654,10 +654,9 @@ void side_actions::execute_net_cmd(net_cmd const& cmd)
{
size_t turn = cmd["turn"].to_int();
size_t pos = cmd["pos"].to_int();
action_ptr act;
try {
act = action::from_config(cmd.child("action"),hidden_);
} catch(action::ctor_err const&) {
action_ptr act = action::from_config(cmd.child("action"),hidden_);
if(!act)
{
ERR_WB << "side_actions::execute_network_command(): received invalid action data!\n";
return;
}