Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ******************************************************************
- PapyrusQuest.cpp (Full File)
- ******************************************************************
- */
- #include "PapyrusQuest.h"
- #include "GameForms.h"
- #include "PapyrusVM.h"
- #include "PapyrusNativeFunctions.h"
- #include <algorithm>
- namespace papyrusQuest
- {
- BSFixedString GetId(TESQuest* thisQuest)
- {
- return (thisQuest) ? thisQuest->questID.Get() : NULL;
- }
- UInt32 GetPriority(TESQuest* thisQuest)
- {
- return (thisQuest) ? thisQuest->unk07C.priority : 0;
- }
- UInt32 GetNumAliases(TESQuest* thisQuest)
- {
- return (thisQuest) ? thisQuest->aliases.count : 0;
- }
- BGSBaseAlias* GetNthAlias(TESQuest* thisQuest, UInt32 n)
- {
- if(!thisQuest || n > thisQuest->aliases.count)
- return NULL;
- BGSBaseAlias* alias = NULL;
- thisQuest->aliases.GetNthItem(n, alias);
- if(alias) {
- return alias;
- }
- return NULL;
- }
- BGSBaseAlias* GetAliasByName(TESQuest* thisQuest, BSFixedString s)
- {
- if(!thisQuest || !s.data)
- return NULL;
- // Stored name's case is ambiguous due to CK quirks, convert both to lower
- UInt32 length1 = strlen(s.data);
- std::string str1(s.data);
- std::transform(str1.begin(), str1.end(), str1.begin(), tolower);
- for(UInt32 n = 0; n < thisQuest->aliases.count; n++) {
- BGSBaseAlias* alias = NULL;
- thisQuest->aliases.GetNthItem(n, alias);
- if(alias) {
- if(length1 != strlen(alias->name.data)) // Skip if different lengths
- continue;
- std::string str2(alias->name.data);
- std::transform(str2.begin(), str2.end(), str2.begin(), tolower);
- if(strcmp(str1.c_str(), str2.c_str()) == 0) {
- return alias;
- }
- }
- }
- return NULL;
- }
- void RegisterFuncs(VMClassRegistry* registry)
- {
- registry->RegisterFunction(
- new NativeFunction0 <TESQuest, BSFixedString> ("GetId", "Quest", papyrusQuest::GetId, registry));
- registry->RegisterFunction(
- new NativeFunction0 <TESQuest, UInt32> ("GetPriority", "Quest", papyrusQuest::GetPriority, registry));
- registry->RegisterFunction(
- new NativeFunction0 <TESQuest, UInt32> ("GetNumAliases", "Quest", papyrusQuest::GetNumAliases, registry));
- registry->RegisterFunction(
- new NativeFunction1 <TESQuest, BGSBaseAlias*, UInt32> ("GetNthAlias", "Quest", papyrusQuest::GetNthAlias, registry));
- registry->RegisterFunction(
- new NativeFunction1 <TESQuest, BGSBaseAlias*, BSFixedString> ("GetAliasByName", "Quest", papyrusQuest::GetAliasByName, registry));
- }
- }
- /*
- ******************************************************************
- PapyrusAlias.cpp (Full File)
- ******************************************************************
- */
- #include "PapyrusAlias.h"
- #include "GameForms.h"
- #include "PapyrusVM.h"
- #include "PapyrusNativeFunctions.h"
- namespace papyrusAlias
- {
- BSFixedString GetName(BGSBaseAlias* thisAlias)
- {
- return (thisAlias) ? thisAlias->name.data : NULL;
- }
- UInt32 GetId(BGSBaseAlias* thisAlias)
- {
- return (thisAlias) ? thisAlias->aliasId : -1;
- }
- void RegisterFuncs(VMClassRegistry* registry)
- {
- registry->RegisterFunction(
- new NativeFunction0 <BGSBaseAlias, BSFixedString> ("GetName", "Alias", papyrusAlias::GetName, registry));
- registry->RegisterFunction(
- new NativeFunction0 <BGSBaseAlias, UInt32> ("GetId", "Alias", papyrusAlias::GetId, registry));
- }
- }
- /*
- ******************************************************************
- GameForms.h (Segment)
- ******************************************************************
- */
- class TESQuest;
- class BGSBaseAlias : public BaseFormComponent // Not actually a form, but its used like one in Papyrus
- {
- public:
- enum { kTypeID = kFormType_Alias };
- StringCache::Ref name; // 04
- TESQuest * owner; // 08
- UInt32 aliasId; // 0C
- UInt32 flags; // 10
- };
- class BGSRefAlias : public BGSBaseAlias
- {
- public:
- enum { kTypeID = kFormType_ReferenceAlias };
- UInt32 unk14[0x04]; // One of these is the filltype/filltype filter
- };
- class BGSLocAlias : public BGSBaseAlias
- {
- public:
- enum { kTypeID = kFormType_LocationAlias };
- UInt32 unk14[0x08];
- };
- // 158
- class TESQuest : public BGSStoryManagerTreeForm
- {
- public:
- enum { kTypeID = kFormType_Quest };
- // parents
- TESFullName fullName; // 18
- // members
- // 20
- struct Data03C
- {
- UInt8 data[0x20]; // ### todo
- };
- // 20
- struct Data05C
- {
- UInt8 data[0x20]; // ### todo
- };
- // 8
- struct Data07C
- {
- UInt32 unk0;
- UInt16 flags;
- UInt8 priority;
- UInt8 type;
- };
- // 8
- struct Data088
- {
- void* unk0;
- void* unk4;
- };
- // 20
- struct Data0A0
- {
- UInt8 data[0x20]; // ### todo
- };
- UnkArray unk020; // 020
- UInt32 unk02C; // 02C
- tArray<BGSBaseAlias*> aliases; // 030 - Aliases
- Data03C unk03C; // 03C
- Data05C unk05C; // 05C
- Data07C unk07C; // 07C
- UInt32 unk084; // 084
- Data088 unk088; // 088
- Data088 unk090; // 090
- void * unk098; // 098 - linked list
- void * unk09C; // 09C - linked list
- Data0A0 unk0A0[2]; // 0A0
- UnkArray unk0E0[6]; // 0E0
- UnkArray unk128; // 128
- void * unk134; // 134 - linked list
- UInt16 unk138; // 138
- UInt8 unk13A; // 13A
- UInt8 pad13B; // 13B
- BSString questID; // 13C
- UInt32 unk144; // 144
- UInt32 unk148; // 148
- UnkArray unk14C; // 14C
- };
- STATIC_ASSERT(sizeof(TESQuest) == 0x158);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement