/Code/client/src/Games/Skyrim/TESObjectREFR.cpp

https://github.com/tiltedphoques/TiltedOnline · C++ · 90 lines · 58 code · 25 blank · 7 comment · 7 complexity · 7299598088e2d17232cd54c04a0225b0 MD5 · raw file

  1. #ifdef TP_SKYRIM
  2. #include <Games/References.h>
  3. #include <Games/Memory.h>
  4. #include <Games/Overrides.h>
  5. #include <Games/Skyrim/EquipManager.h>
  6. #include <Games/Skyrim/Misc/SkyrimVM.h>
  7. #include <World.h>
  8. #include <Services/PapyrusService.h>
  9. #ifdef SAVE_STUFF
  10. #include <Games/Skyrim/SaveLoad.h>
  11. void TESObjectREFR::Save_Reversed(const uint32_t aChangeFlags, Buffer::Writer& aWriter)
  12. {
  13. TESForm::Save_Reversed(aChangeFlags, aWriter);
  14. if(aChangeFlags & CHANGE_REFR_BASEOBJECT)
  15. {
  16. // save baseForm->formID;
  17. // we don't because each player has it's own form id system
  18. }
  19. if(aChangeFlags & CHANGE_REFR_SCALE)
  20. {
  21. // So skyrim does some weird conversion shit here, we are going to do the same for now
  22. float fScale = scale;
  23. fScale /= 100.f;
  24. aWriter.WriteBytes((uint8_t*)& fScale, 4);
  25. }
  26. // So skyrim
  27. uint32_t extraFlags = 0xA6021C40;
  28. if(formType == Character)
  29. extraFlags = 0xA6061840;
  30. if(aChangeFlags & extraFlags)
  31. {
  32. // We have flags to save
  33. }
  34. if(aChangeFlags & (CHANGE_REFR_INVENTORY | CHANGE_REFR_LEVELED_INVENTORY))
  35. {
  36. }
  37. if (aChangeFlags & CHANGE_REFR_ANIMATION)
  38. {
  39. // do something with animations
  40. // get extradata 0x41
  41. }
  42. }
  43. #endif
  44. ExtraContainerChanges::Data* TESObjectREFR::GetContainerChanges() const noexcept
  45. {
  46. TP_THIS_FUNCTION(TGetContainterChanges, ExtraContainerChanges::Data*, const TESObjectREFR);
  47. POINTER_SKYRIMSE(TGetContainterChanges, s_getContainerChangs, 0x1401D8E40 - 0x140000000);
  48. return ThisCall(s_getContainerChangs, this);
  49. }
  50. void TESObjectREFR::SaveInventory(BGSSaveFormBuffer* apBuffer) const noexcept
  51. {
  52. GetContainerChanges()->Save(apBuffer);
  53. }
  54. void TESObjectREFR::LoadInventory(BGSLoadFormBuffer* apBuffer) noexcept
  55. {
  56. GetContainerChanges()->Load(apBuffer);
  57. }
  58. void TESObjectREFR::RemoveAllItems() noexcept
  59. {
  60. using ObjectReference = TESObjectREFR;
  61. PAPYRUS_FUNCTION(void, ObjectReference, RemoveAllItems, TESObjectREFR*, bool, bool);
  62. ScopedEquipOverride equipOverride;
  63. s_pRemoveAllItems(this, nullptr, false, true);
  64. }
  65. #endif