Esempio n. 1
0
    void Console::exec(std::string cmd)
    {
        StrVec args;

        if(cmd.find(' ') != std::string::npos)
        {
            args.push_back(cmd.substr(cmd.find(' ') + 1, cmd.size() - cmd.find(' ')));
            cmd = cmd.substr(0, cmd.find(' '));

            while(args.back().find(' ') != std::string::npos)
            {
                args.push_back(args.back().substr(args.back().find(' ') + 1 , args.size() - args.back().find(' ')));
                args.at(args.size() - 1) = args.at(args.size() - 1).substr(0, args.at(args.size() - 1).find(' ') - 1);
            }
        }

        if(commands.find(cmd) == commands.end())
        {
            addString("Command '" + cmd + "' not found");
            return;
        }

        if(!commands[cmd].exec(args)) addString("Wrong number of arguments for command '" + cmd + "'.");

    }
Esempio n. 2
0
 void Console::update()
 {
     StrVec tmpLog = Logger::getLog();
     Logger::clearLog();
     if(!tmpLog.empty() && tmpLog.at(0) != "")
     {
         for(unsigned int i = 0; i < tmpLog.size(); i++)
         {
             while(tmpLog.at(i).find("\n") != std::string::npos)
                 tmpLog.at(i).erase(tmpLog.at(i).find("\n"), 1);
             addString(tmpLog.at(i));
         }
     }
 }
Esempio n. 3
0
void MapDataLoader::parse()
{
	for (auto value : _mapVec)
	{
		if (value.first.compare("id"))
		{
			MapData data;

			StrVec vec = value.second;
			data._id = atoi(value.first.c_str());
			int lastIndex = 0;

			for (size_t i = 0; i < vec.size(); i++)
			{
				std::string value = vec.at(i);
				switch (i)
				{
				case 0: data._level = atoi(value.c_str()); break;
				case 1: data._stage = atoi(value.c_str()); break;
				case 2: data._width = atoi(value.c_str()); break;
				case 3: data._height = atoi(value.c_str()); break;
				case 4: data._bonus = stringToBonus(value); break;
				case 5: data._cheatName = value.c_str(); lastIndex = i + 1; break;
				default:
					int count = atoi(value.c_str());
					if (count != 0)
					{
						data._npcVec.push_back(std::make_pair(ID_NPC(i - lastIndex), count));
					}
					break;
				}
			}

			_maps.push_back(data);
		}
	}
}