本文整理汇总了C++中SmartScriptTable::GetScriptSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartScriptTable::GetScriptSystem方法的具体用法?C++ SmartScriptTable::GetScriptSystem怎么用?C++ SmartScriptTable::GetScriptSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartScriptTable
的用法示例。
在下文中一共展示了SmartScriptTable::GetScriptSystem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPostInitClient
void CScriptRMI::OnPostInitClient( uint16 channelId, IEntity * pEntity )
{
SmartScriptTable server;
SmartScriptTable entity = pEntity->GetScriptTable();
if (!entity.GetPtr())
return;
if (!entity->GetValue( "Server", server ) || !server.GetPtr())
return;
IScriptSystem * pSystem = entity->GetScriptSystem();
if ((server->GetValueType( "OnPostInitClient" ) == svtFunction) &&
pSystem->BeginCall( server, "OnPostInitClient" ))
{
pSystem->PushFuncParam( entity );
pSystem->PushFuncParam( channelId );
pSystem->EndCall();
}
}
示例2: BuildSynchTable
// setup the meta-table for synched variables
bool CScriptRMI::BuildSynchTable( SmartScriptTable vars, SmartScriptTable cls, const char * name )
{
IScriptSystem * pSS = vars->GetScriptSystem();
SmartScriptTable synched( pSS );
SmartScriptTable defaultValues( pSS );
// TODO: Improve
IScriptTable::SUserFunctionDesc fd;
fd.pFunctor = functor_ret( SynchedNewIndexFunction );
fd.sFunctionName = "__newindex";
fd.sGlobalName = "<net-dispatch>";
fd.sFunctionParams = "(...)";
synched->AddFunction( fd );
std::vector<SSynchedPropertyInfo> properties;
IScriptTable::Iterator iter = vars->BeginIteration();
while (vars->MoveNext(iter))
{
if (iter.sKey)
{
int type;
if (!vars->GetValue(iter.sKey, type))
{
vars->EndIteration(iter);
pSS->RaiseError( "No type for %s", iter.sKey );
return false;
}
size_t len = strlen(iter.sKey);
if (len > MaxSynchedPropertyNameLength)
{
vars->EndIteration(iter);
pSS->RaiseError( "Synched var name '%s' too long (max is %d)",
iter.sKey, (int)MaxSynchedPropertyNameLength );
return false;
}
SSynchedPropertyInfo info;
strcpy( info.name, iter.sKey );
info.type = (EScriptSerializeType) type;
properties.push_back( info );
if (info.type == eSST_String)
defaultValues->SetValue( iter.sKey, "" );
else
defaultValues->SetValue( iter.sKey, 0 );
}
}
vars->EndIteration( iter );
if (properties.empty())
return true;
fd.pFunctor = NULL;
fd.pUserDataFunc = SerializeFunction;
fd.nDataSize = sizeof(SSynchedPropertyInfo) * properties.size();
fd.pDataBuffer = &properties[0];
fd.sFunctionName = SERIALIZE_FUNCTION;
fd.sFunctionParams = "(...)";
fd.sGlobalName = "<net-dispatch>";
synched->AddFunction( fd );
cls->SetValue( SERVER_SYNCHED_FIELD, synched );
cls->SetValue( "synched", defaultValues );
return true;
}
示例3: BuildDispatchTable
// build a script dispatch table - this table is the metatable for all
// dispatch proxy tables used (onClient, allClients, otherClients)
bool CScriptRMI::BuildDispatchTable(
SmartScriptTable methods,
SmartScriptTable classMethodTable,
SmartScriptTable cls,
const char * name )
{
IScriptSystem * pSS = methods->GetScriptSystem();
SmartScriptTable dispatch( pSS );
uint8 funcID = 0;
IScriptTable::SUserFunctionDesc fd;
SFunctionInfo info;
IScriptTable::Iterator iter = methods->BeginIteration();
while (methods->MoveNext(iter))
{
if (iter.sKey)
{
const char * function = iter.sKey;
if (strlen(function)>=2 && function[0] == '_' && function[1] == '_')
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: can't expose functions beginning with '__' (function was %s)",
function );
return false;
}
SmartScriptTable specTable;
if (!methods->GetValue(function, specTable))
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s entry is not a table (in %s)",
function, name );
return false;
}
// fetch format
int count = specTable->Count();
if (count < 1)
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s entry is an empty table (in %s)",
function, name );
return false;
}
else if (count-1 > MaxRMIParameters)
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s has too many parameters (%d) (in %s)",
function, count-1, name );
return false;
}
int tempReliability;
if (!specTable->GetAt(1, tempReliability) || tempReliability < 0 || tempReliability >= eNRT_NumReliabilityTypes)
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s has invalid reliability type %d (in %s)",
function, tempReliability, name );
return false;
}
ENetReliabilityType reliability = (ENetReliabilityType) tempReliability;
if (!specTable->GetAt(2, tempReliability) || tempReliability < 0 || tempReliability >= eRAT_NumAttachmentTypes)
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s has invalid attachment type %d (in %s)",
function, tempReliability, name );
}
ERMIAttachmentType attachment = (ERMIAttachmentType) tempReliability;
string format;
format.reserve(count-1);
for (int i=3; i<=count; i++)
{
int type = 666;
if (!specTable->GetAt( i, type ) || type<-128 || type>127)
{
methods->EndIteration(iter);
pSS->RaiseError( "In Net.Expose: function %s has invalid serialization policy %d at %d (in %s)",
function, type, i, name );
return false;
}
format.push_back( (char) type );
}
CRY_ASSERT( format.length() <= MaxRMIParameters );
strcpy( info.format, format.c_str() );
info.funcID = funcID;
info.reliability = reliability;
info.attachment = attachment;
fd.pUserDataFunc = ProxyFunction;
fd.sFunctionName = function;
fd.nDataSize = sizeof(SFunctionInfo);
fd.pDataBuffer = &info;
fd.sGlobalName = "<net-dispatch>";
fd.sFunctionParams = "(...)";
//.........这里部分代码省略.........