scripthook.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <precomp.h>
  2. #include <api/script/scriptobj.h>
  3. #include <api/script/objcontroller.h>
  4. #include "scripthook.h"
  5. #define CBCLASS ScriptHookI
  6. START_DISPATCH;
  7. CB(EVENTCALLBACK, eventCallback);
  8. END_DISPATCH;
  9. ScriptHookI::ScriptHookI() {
  10. }
  11. ScriptHookI::~ScriptHookI() {
  12. WASABI_API_MAKI->maki_remDlfRef(this);
  13. foreach(controllers)
  14. controllers.getfor()->removeHooks(this);
  15. endfor
  16. }
  17. void ScriptHookI::addMonitorObject(ScriptObject *o, const GUID *hookedclass) {
  18. WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this);
  19. ScriptObjectController *cont = o->vcpu_getController();
  20. if (hookedclass == NULL) {
  21. cont->addObjectHook(this, o);
  22. } else {
  23. while (cont) {
  24. if (cont->getClassGuid() == *hookedclass) {
  25. cont->addObjectHook(this, o);
  26. break;
  27. }
  28. cont = cont->getAncestorController();
  29. }
  30. }
  31. if (cont == NULL) // guid not found
  32. return;
  33. controllers.addItem(cont);
  34. }
  35. void ScriptHookI::addMonitorClass(ScriptObject *o) {
  36. WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this);
  37. o->vcpu_getController()->addClassHook(this);
  38. controllers.addItem(o->vcpu_getController());
  39. }