Guest User

Untitled

a guest
Jan 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include "AGSDelegate.h"
  2. #include <string>
  3.  
  4.  
  5. AGSDelegate::AGSDelegate(IAGSEngine *engine)
  6. {
  7.     _engine = engine;
  8. }
  9.  
  10. AGSDelegate::AGSDelegate(IAGSEngine *engine, const char* name)
  11. {
  12.     _engine = engine;
  13.     _functionName = name;
  14. }
  15.  
  16. AGSDelegate::~AGSDelegate(void)
  17. {
  18.     if (_functionName) delete _functionName;
  19. }
  20.  
  21. void AGSDelegate::Run()
  22. {
  23.     if (_functionName != 0)_engine->QueueGameScriptFunction(_functionName, 1, 0);
  24. }
  25.  
  26.  
  27. int AGSDelegate::Serialize(char *buffer)
  28. {
  29.     size_t length = strlen(_functionName) + 1;
  30.     memcpy(buffer, _functionName, length);
  31.     return length;
  32. }
  33.  
  34. ManagedAGSDelegateInterface::ManagedAGSDelegateInterface(void)
  35. {
  36. }
  37.  
  38. int ManagedAGSDelegateInterface::Dispose(const char *address, bool force)
  39. {
  40.     delete address; // free the memory and return 1 to tell AGS we did.
  41.     return 1;
  42. }
  43. const char *ManagedAGSDelegateInterface::GetType()
  44. {
  45.     return typeName;
  46. }
  47. int ManagedAGSDelegateInterface::Serialize(const char *address, char *buffer, int bufsize)
  48. {
  49.     AGSDelegate *del = (AGSDelegate *)address;
  50.     return del->Serialize(buffer);
  51.    
  52. }
  53.  
  54. const char* ManagedAGSDelegateInterface::typeName = "Delegate";
  55.  
  56. ManagedAGSDelegateReader::ManagedAGSDelegateReader(IAGSEngine *engine, ManagedAGSDelegateInterface *theInterface)
  57. {
  58.     _engine = engine;
  59.     _interface = theInterface;
  60. }
  61.  
  62. void ManagedAGSDelegateReader::Unserialize(int key, const char *serializedData, int dataSize)
  63. {
  64.    
  65.         AGSDelegate *del = new AGSDelegate(_engine, serializedData);
  66.         _engine->RegisterUnserializedObject(key, del, _interface);
  67. }
Add Comment
Please, Sign In to add comment