void Event::load(int version, const char* agentType, const properties_t& properties) { super::load(version, agentType, properties); behaviac::string typeName; behaviac::string propertyName; behaviac::string comparatorName; for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) { const property_t& p = (*it); if (strcmp(p.name, "EventName") == 0) { //method this->m_event = Action::LoadMethod(p.value); } else if (strcmp(p.name, "ReferenceFilename") == 0) { this->m_referencedBehaviorPath = p.value; } else if (strcmp(p.name, "TriggeredOnce") == 0) { if (string_icmp(p.value, "true") == 0) { this->m_bTriggeredOnce = true; } } else if (strcmp(p.name, "TriggerMode") == 0) { if (string_icmp(p.value, "Transfer") == 0) { this->m_triggerMode = TM_Transfer; } else if (string_icmp(p.value, "Return") == 0) { this->m_triggerMode = TM_Return; } else { BEHAVIAC_ASSERT(0, "unrecognised trigger mode %s", p.value); } } else { //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name); } } }
int CScriptSystem::GetFunctionParamName(HSCRIPTFUNCTION hFunc, XmlNodeRef& funcNode) { lua_getref(m_pLS, (int)hFunc); StkId func = m_pLS->top - 1; Closure* cl; if (ttype(func) != LUA_TFUNCTION) { lua_pop(m_pLS, 1); return -1; } cl = clvalue(func); int numParams = cl->l.p->numparams; int validParams = numParams; for (int j = 0, i = 0 ; j < numParams; j++) { const char* name = luaF_getlocalname(cl->l.p, j + 1, 0); BEHAVIAC_ASSERT(name); if (!string_icmp(name, "self")) { validParams--; continue; } // There is no value for now, so store the index as the value funcNode->setAttr(name, i); ++i; } lua_pop(m_pLS, 1); // lua_getref pop return validParams; }
void DecoratorLoopUntil::load(int version, const char* agentType, const properties_t& properties) { super::load(version, agentType, properties); for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it) { const property_t& p = (*it); if (strcmp(p.name, "Until") == 0) { if (string_icmp(p.value, "true") == 0) { this->m_until = true; } else if (string_icmp(p.value, "false") == 0) { this->m_until = false; } } } }
void CPathID::SetContentPrivate(const char* content) { if (content == NULL || content[0] == '\0') { m_value = InvalidID; #if STRINGID_USESTRINGCONTENT m_content = NULL; #endif } else { m_value = CRC32::CalcCRCNoCase(content); } #if STRINGID_USESTRINGCONTENT behaviac::Mutex s_cs; behaviac::ScopedLock lock(s_cs); StringIdDictionary& dictionary = GetDictionary(); StringIdDictionary::iterator it = dictionary.find(m_value); if (it != dictionary.end()) { if (string_icmp(content, (*it).second)) { BEHAVIAC_ASSERT(0, "There is a conflict between two PathID for the CRC 0x%08X.\n%s\n%s\n\nThe result of that is unpredictable but will probably crash.", m_value, content, (*it).second); } m_content = (*it).second; } else { uint32_t len = strlen(content); char* str = (char*)BEHAVIAC_MALLOC_WITHTAG(len + 1, "PathID"); string_cpy(str, content); dictionary[m_value] = str; m_content = str; } #endif }
void CStringID::SetContent(const char* content, bool noCase, bool resolve) { BEHAVIAC_UNUSED_VAR(resolve); #ifdef BEHAVIAC_STRINGID_DEBUG_CASE m_noCase = noCase; #endif #if BEHAVIAC_STRINGID_USESTRINGCONTENT static behaviac::Mutex ms_critialsection; #ifdef BEHAVIAC_STRINGID_RESOLVE_CONTENT if (resolve) { ms_critialsection.Lock(); StringIdDictionary::iterator it = GetContentDictionary().find(m_value); if (it != GetContentDictionary().end()) { m_content = (*it).second; } ms_critialsection.Unlock(); return; } #endif #endif if (content == NULL || content[0] == '\0') { m_value = InvalidID; #if BEHAVIAC_STRINGID_USESTRINGCONTENT m_content = NULL; #endif } else { if (noCase) { BEHAVIAC_ASSERT(false); m_value = CRC32::CalcCRCNoCase(content); } else { m_value = CRC32::CalcCRC(content); } #if BEHAVIAC_STRINGID_USESTRINGCONTENT ms_critialsection.Lock(); StringIdDictionary::iterator it = GetContentDictionary().find(m_value); if (it != GetContentDictionary().end()) { if (noCase) { if (string_icmp(content, (*it).second)) { BEHAVIAC_LOG3(BEHAVIAC_LOG_INFO, "There is a conflict between two StringID for the CRC 0x%08X.\n%s\n%s\n\nThe result of that is unpredictable but will probably crash.", m_value, content, (*it).second); } } else { if (strcmp(content, (*it).second)) { BEHAVIAC_LOG3(BEHAVIAC_LOG_INFO, "There is a conflict between two StringID for the CRC 0x%08X.\n%s\n%s\n\nThe result of that is unpredictable but will probably crash.", m_value, content, (*it).second); } } m_content = (*it).second; } else { uint32_t len = strlen(content); char* str = (char*)BEHAVIAC_MALLOC(sizeof(char) * (len + 1)); string_cpy(str, content); if (noCase) { for (uint32_t i = 0; i < len; ++i) { str[i] = (char)tolower(str[i]); } } GetContentDictionary()[m_value] = str; m_content = str; } ms_critialsection.Unlock(); #endif } }