one-time validation of entity tables
| 600 | |
| 601 | // one-time validation of entity tables |
| 602 | bool CScriptRMI::ValidateDispatchTable(const char* clazz, SmartScriptTable dispatch, SmartScriptTable methods, bool bServerTable) |
| 603 | { |
| 604 | CryAutoCriticalSection lkDispatch(m_dispatchMutex); |
| 605 | |
| 606 | std::map<string, size_t>::iterator iterN = m_entityClassToEntityTypeID.lower_bound(clazz); |
| 607 | if (iterN == m_entityClassToEntityTypeID.end() || iterN->first != clazz) |
| 608 | { |
| 609 | iterN = m_entityClassToEntityTypeID.insert(iterN, std::make_pair(clazz, m_entityClassToEntityTypeID.size())); |
| 610 | CRY_ASSERT(iterN->second == m_dispatch.size()); |
| 611 | m_dispatch.push_back(SDispatch()); |
| 612 | } |
| 613 | SDispatch& dispatchTblCont = m_dispatch[iterN->second]; |
| 614 | SFunctionDispatchTable& dispatchTbl = bServerTable ? dispatchTblCont.server : dispatchTblCont.client; |
| 615 | |
| 616 | IScriptTable::Iterator iter = dispatch->BeginIteration(); |
| 617 | while (dispatch->MoveNext(iter)) |
| 618 | { |
| 619 | if (iter.sKey) |
| 620 | { |
| 621 | if (iter.sKey[0] == '_' && iter.sKey[1] == '_') |
| 622 | continue; |
| 623 | |
| 624 | ScriptVarType type = methods->GetValueType(iter.sKey); |
| 625 | if (type != svtFunction) |
| 626 | { |
| 627 | GameWarning("In class %s: function %s is exposed but not defined", |
| 628 | clazz, iter.sKey); |
| 629 | dispatch->EndIteration(iter); |
| 630 | return false; |
| 631 | } |
| 632 | } |
| 633 | else |
| 634 | { |
| 635 | int id = iter.nKey; |
| 636 | CRY_ASSERT(id > 0); |
| 637 | id--; |
| 638 | |
| 639 | if (id >= dispatchTbl.size()) |
| 640 | dispatchTbl.resize(id + 1); |
| 641 | SFunctionDispatch& dt = dispatchTbl[id]; |
| 642 | if (iter.value.GetVarType() != svtString) |
| 643 | { |
| 644 | GameWarning("Expected a string in dispatch table, got type %d", iter.value.GetVarType()); |
| 645 | dispatch->EndIteration(iter); |
| 646 | return false; |
| 647 | } |
| 648 | |
| 649 | const char* funcData = iter.value.str; |
| 650 | const char* colon = strchr(funcData, ':'); |
| 651 | if (colon == NULL) |
| 652 | { |
| 653 | dispatch->EndIteration(iter); |
| 654 | return false; |
| 655 | } |
| 656 | if (colon - funcData > MaxSynchedPropertyNameLength) |
| 657 | { |
| 658 | dispatch->EndIteration(iter); |
| 659 | return false; |
nothing calls this directly
no test coverage detected