MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / execFunc

Function execFunc

TheForceEngine/TFE_ForceScript/forceScript.cpp:874–960  ·  view source on GitHub ↗

Add a script function to be executed during the update.

Source from the content-addressed store, hash-verified

872
873 // Add a script function to be executed during the update.
874 s32 execFunc(FunctionHandle funcHandle, s32 argCount, const ScriptArg* arg)
875 {
876 s32 id = -1;
877 if (!funcHandle) { return id; }
878 asIScriptFunction* func = (asIScriptFunction*)funcHandle;
879
880 // Get a free context.
881 asIScriptContext* context = s_engine->RequestContext();
882 if (!context)
883 {
884 // ERROR
885 return id;
886 }
887 // Then prepare it for execution.
888 s32 res = context->Prepare(func);
889 if (res < 0)
890 {
891 s_engine->ReturnContext(context);
892 return id;
893 }
894 // Set arguments.
895 argCount = std::min(argCount, (s32)func->GetParamCount());
896 for (s32 i = 0; i < argCount; i++)
897 {
898 switch (arg[i].type)
899 {
900 case ARG_S32:
901 {
902 context->SetArgDWord(i, *((asDWORD*)&arg[i].iValue));
903 } break;
904 case ARG_U32:
905 {
906 context->SetArgDWord(i, arg[i].uValue);
907 } break;
908 case ARG_F32:
909 {
910 context->SetArgFloat(i, arg[i].fValue);
911 } break;
912 case ARG_BOOL:
913 {
914 context->SetArgByte(i, arg[i].bValue ? 1 : 0);
915 } break;
916 case ARG_OBJECT:
917 {
918 context->SetArgObject(i, arg[i].objPtr);
919 } break;
920 case ARG_STRING:
921 {
922 context->SetArgObject(i, (void*)&arg[i].stdStr);
923 } break;
924 case ARG_FLOAT2:
925 {
926 float2 f2(arg[i].float2Value.x, arg[i].float2Value.z);
927 context->SetArgObject(i, (void*)&f2);
928 } break;
929 case ARG_FLOAT3:
930 {
931 float3 f3(arg[i].float3Value.x, arg[i].float3Value.y, arg[i].float3Value.z);

Callers 6

setAPIFunction · 0.85
updateFunction · 0.85
executeLineFunction · 0.85
inf_stopHandleScriptCallFunction · 0.85
startLevelScriptFunction · 0.85
updateLevelScriptFunction · 0.85

Calls 15

minFunction · 0.85
RequestContextMethod · 0.80
ReturnContextMethod · 0.80
GetParamCountMethod · 0.80
SetArgDWordMethod · 0.80
SetArgFloatMethod · 0.80
SetArgByteMethod · 0.80
SetArgObjectMethod · 0.80
push_backMethod · 0.80
GetModuleNameMethod · 0.80
PrepareMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected