Advertisement
expired6978

Array Returning Samples

Dec 9th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1.     template<typename T>
  2.     VMResultArray<T> CreateArray(StaticFunctionTag* base, UInt32 size, T fillValue, UInt32 limit)
  3.     {
  4.         VMResultArray<T> data;
  5.         if(size > limit)
  6.             size = limit;
  7.         data.resize(size, fillValue);
  8.         return data;
  9.     }
  10.  
  11.  
  12.  
  13.     VMResultArray<TESFaction*> GetFactions(Actor* thisActor, SInt32 gte, SInt32 lte)
  14.     {
  15.         VMResultArray<TESFaction*> factions;
  16.         if(thisActor) {
  17.             if(gte > SCHAR_MAX)
  18.                 gte = SCHAR_MAX;
  19.             if(gte < SCHAR_MIN)
  20.                 gte = SCHAR_MIN;
  21.             if(lte < SCHAR_MIN)
  22.                 lte = SCHAR_MIN;
  23.             if(lte > SCHAR_MAX)
  24.                 lte = SCHAR_MAX;
  25.             FactionRankSet rankSet;
  26.             CollectUniqueFactions factionVisitor(&rankSet, gte, lte);
  27.             thisActor->VisitFactions(factionVisitor);
  28.  
  29.             for(FactionRankSet::iterator it = rankSet.begin(); it != rankSet.end(); ++it)
  30.                 factions.push_back(*it);
  31.         }
  32.  
  33.         return factions;
  34.     }
  35.  
  36.  
  37.  
  38.     VMResultArray<TESForm*> GetContainerForms(TESObjectREFR* pContainerRef)
  39.     {
  40.         VMResultArray<TESForm*> result;
  41.         if(pContainerRef) {
  42.             ExtraContainerChanges* pXContainerChanges = static_cast<ExtraContainerChanges*>(pContainerRef->extraData.GetByType(kExtraData_ContainerChanges));
  43.             if (pXContainerChanges) {
  44.                 TESContainer* pContainer = NULL;
  45.                 TESForm* pBaseForm = pContainerRef->baseForm;
  46.                 if (pBaseForm)
  47.                     pContainer = DYNAMIC_CAST(pBaseForm, TESForm, TESContainer);
  48.  
  49.                 // Declare the container to receive the forms
  50.                 ExtraContainerArray formContainer(&result);
  51.                 ExtraContainerInfo info(pXContainerChanges ? pXContainerChanges->data->objList : NULL);
  52.                 // first walk the base container
  53.                 if (pContainer) {
  54.                     // Fill the container
  55.                     ExtraContainerFiller formFiller(info, &formContainer);
  56.                     pContainer->Visit(formFiller);
  57.                 }
  58.  
  59.                 // Fill the container with remaining forms
  60.                 info.GetRemainingForms(&formContainer);
  61.             }
  62.         }
  63.  
  64.         return result;
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement