// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 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; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "stdpch.h" #include "ai_actions.h" // singleton data bool CAIActions::_init; CAIActions::IExecutor *CAIActions::_executor; void CAIActions::openFile(const std::string &fileName) { nlassert(_init==true); _executor->openFile(fileName); } void CAIActions::closeFile(const std::string &fileName) { nlassert(_init==true); _executor->closeFile(fileName); } void CAIActions::begin(uint32 contextAlias) { nlassert(_init==true); _executor->begin(contextAlias); } void CAIActions::end(uint32 contextAlias) { nlassert(_init==true); _executor->end(contextAlias); } static uint64 stringToInt64(const char *str) { uint64 id=0; uint i; for (i=0;i<8 && str[i]!=0;++i) ((char *)&id)[i]=str[i]; // the following assert ensures that we never try to cram >8 letters into an int64 nlassert(str[i]==0); return id; } using std::string; inline static uint64 stringToInt64(const string &str) { return stringToInt64(str.c_str()); } void CAIActions::execute(const string &action,const std::vector &args) { H_AUTO(CAIActions_execute); nlassert(_init==true); _executor->execute(stringToInt64(action),args); } void CAIActions::execute(const string &action,const std::vector &stringArgs) { H_AUTO(CAIActions_execute); nlassert(_init==true); // build an argument vector from the string vector std::vector args; for (uint j=0;jexecute(stringToInt64(action),args); } void CAIActions::execute(const string &action,const std::vector &rawArgs) { H_AUTO(CAIActions_execute); nlassert(_init==true); // build an argument vector from the string vector std::vector args; for (uint j=0;jexecute(stringToInt64(action),args); } void CAIActions::execute(const string &action,const std::vector &rawArgs) { H_AUTO(CAIActions_execute); nlassert(_init==true); // build an argument vector from the string vector std::vector args; for (uint j=0;jexecute(stringToInt64(action),args); } void CAIActions::execute(const string &action) { H_AUTO(CAIActions_execute); std::vector emptyVector; execute(action,emptyVector); }