4
Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [PTB] in the subject of your mails.
25
* \file frame_password.tpp
26
* \brief Implementation of the template methods of the ptb::frame_password
28
* \author Julien Jorge
31
#include "engine/game.hpp"
33
#include <claw/string_algorithm.hpp>
35
/*----------------------------------------------------------------------------*/
37
* \brief Execute a 'gamevar' command.
38
* \param command The tokens read on the command line.
41
void ptb::frame_password::command_game_variable
42
( const std::string& var_value ) const
44
const std::size_t equal( var_value.find_first_of('=') );
46
if ( equal == std::string::npos )
47
claw::logger << claw::log_warning
48
<< "gamevar: bad format."
49
<< " Must be 'gamevar type name=value'."
53
std::string name( var_value.substr(0, equal) );
54
std::string value( var_value.substr(equal+1) );
56
if ( !claw::text::is_of_type<T>(value) )
57
claw::logger << claw::log_warning << "gamevar: incorrect value."
61
std::istringstream iss(value);
65
bear::engine::game::get_instance()
66
.get_game_variables().template set<T>(name, v);
69
} // frame_password::command_game_variable()