Advertisement
expired6978

CallFunctionNoWait

Jan 24th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. // Avoid passing VMArrays as arguments, behavior may be undefined as Papyrus does not normally support multi-dimensional arrays
  2. template<typename T1>
  3. void SendPapyrusEvent1(UInt64 handle, BSFixedString eventName, T1 & t1)
  4. {
  5.     void * object = GetObjectFromHandle(handle, VMObject::kTypeID);
  6.     if(object) {
  7.         // Build the receiving VMValue from the handle
  8.         VMValue receiver;
  9.         PackHandle(&receiver, object, VMObject::kTypeID, (*g_gameVM)->m_virtualMachine);
  10.  
  11.         // Build the VM arguments for the CallFunctionNoWait
  12.         VMArray<VMVariable> arguments;
  13.         VMVariable var1, var2;
  14.         var1.Set<T1>(&t1);
  15.         arguments.Push(&var1);
  16.  
  17.         // Pack the VMArray
  18.         VMValue args;
  19.         PackValue(&args, &arguments, (*g_gameVM)->m_virtualMachine);
  20.  
  21.         // This should eventually replaced by an actual call to the Event Queue (VM+0x158), this is a workaround for now
  22.         if(receiver.IsIdentifier()) {
  23.             VMIdentifier * identifier = receiver.data.id;
  24.             if(identifier) {
  25.                 CallFunctionNoWait_Internal((*g_gameVM)->m_virtualMachine, 0, identifier, &eventName, &args);
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement