SInt32 BGSListForm::ReplaceForm(TESForm* pForm, TESForm* pReplaceWith) { SInt32 index = GetIndexOf(pForm); if (index >= 0) { list.ReplaceNth(index, pReplaceWith); } return index; }
SInt32 BGSListForm::RemoveForm(TESForm* pForm) { SInt32 index = GetIndexOf(pForm); if (index >= 0) { RemoveNthForm(index); } return index; }
PyView *PyView::indices(const PyView& subset) { c4_View tmp(_index); tmp.SetSize(subset.GetSize()); c4_Row row; for (int i=0; i<subset.GetSize(); ++i) { _index(row) = GetIndexOf(subset.GetAt(i)); tmp.SetAt(i, row); } return new PyView(tmp); }
void PyView::map(const PWOCallable& func, const PyView& subset) { int sz = subset.GetSize(); PWOTuple tmp(1); for (int i=0; i<sz; ++i) { PyRowRef *row = new PyRowRef(GetAt(GetIndexOf(subset.GetAt(i)))); PWOBase r2 (row); tmp.setItem(0,r2); func.call(tmp); Py_DECREF(row); } }
func FxOverallDamageStuffDamage(pTarget, iEffectNumber, iDmgEngy, iCause, iBy) { var iPlr = pTarget->GetOwner(); if(iDmgEngy < 0) { pTarget.kill_bounty = 0; if(pTarget->GetEnergy() + iDmgEngy/1000 <= 0) { var hands = [GetHandItem(0), GetHandItem(1)]; for(var obj in FindObjects(Find_Container(pTarget))) { if(GetIndexOf(hands, obj) != -1) continue; if(!obj->~NoRemove()) { AddEffect("ScheduledRemove", obj, 1, 1, nil, Clonk, pTarget); pTarget.kill_bounty += Max(1, (obj->GetValue() / 5)) * 2; } } }
const IsoFileDescriptor& IsoDirectory::GetEntry(const wxString& fileName) const { return GetEntry(GetIndexOf(fileName)); }
global func ArrayContains(array a, v) { return GetIndexOf(v, a) + 1; }
global func FindInArray(array a, v) { return GetIndexOf(v, a); }
void PrimeSwing::ParallelFactorial(Xint fact, ulong n) { if (n < THRESHOLD) { Xmath::NaiveFactorial(fact, n); return; } lmp::SetUi(fact, 1); ulong* primes; ulong piN = Xmath::PrimeSieve(&primes, n); ulong* factors = lmp::MallocUi(piN); ulong iterLen = 0; ulong i = n; slong m = n; while (m > 0) { m >>= 1; iterLen++; } ulong* iter = lmp::MallocUi(iterLen); ulong* lim = lmp::MallocUi(iterLen); m = n; i = iterLen; while (m > 0) { iter[--i] = m; m >>= 1; } Xint primorial; lmp::Init(primorial); Xint swing; lmp::Init(swing); lim[0] = 0; for (i = 1; i < iterLen; i++) lim[i] = iter[i] < SOSLEN / 2 ? 0 : GetIndexOf(primes, iter[i], lim[i-1], piN); for (i = 1; i < iterLen; i++) { ulong N = iter[i]; if (N < SOSLEN) { lmp::Pow2(fact, fact); lmp::SetUi(swing, smallOddSwing[N]); } else { std::thread pow(lmp::Pow2, fact, fact); ulong prime = 3; slong pi = 2, fi = 0; ulong max = Xmath::Sqrt(N); while (prime <= max) { ulong q = N, p = 1; while ((q /= prime) > 0) { if ((q & 1) == 1) { p *= prime; } } if (p > 1) { factors[fi++] = p; } prime = primes[pi++]; } max = N / 3; while (prime <= max) { if (((N / prime) & 1) == 1) { factors[fi++] = prime; } prime = primes[pi++]; } pi = lim[i] - lim[i-1]; memcpy(factors + fi, primes + lim[i-1], pi * sizeof(ulong)); Xmath::Product(swing, factors, 0, fi + pi); pow.join(); } lmp::Mul(fact, fact, swing); } lmp::Mul2Exp(fact, fact, n - Xmath::BitCount(n)); lmp::Clear(swing); lmp::Clear(primorial); lmp::FreeUi(primes, piN); lmp::FreeUi(factors, piN); lmp::FreeUi(iter, iterLen); lmp::FreeUi(lim, iterLen); }
void WriteJoints(const std::vector<MeshJoint> &joints, FILE *fp, float scaleFactor) { uint32_t count = joints.size(); if (count == 0) return; uint32_t size = 4 + // count ( 4 + // parent joint index (sizeof(float) * 3) + // local position (x, y, z) (sizeof(float) * 4) + // local rotation (x, y, z, w) (sizeof(float) * 3) + // offset position (x, y, z) (sizeof(float) * 4) // offset rotation (x, y, z, w) ) * count; // add up all the variable length joint names for (uint32_t i = 0; i < count; ++i) size += joints[i].name.length() + 1; // include null terminator fputs("JNT", fp); fwrite(&size, 4, 1, fp); fwrite(&count, 4, 1, fp); for (uint32_t i = 0; i < count; ++i) { const MeshJoint *j = &joints[i]; fwrite(j->name.c_str(), j->name.length(), 1, fp); char c = '\0'; fwrite(&c, 1, 1, fp); int32_t parentIndex = GetIndexOf(joints, j->parentName); fwrite(&parentIndex, 4, 1, fp); aiVector3D localPosition = j->localPosition; localPosition.x *= scaleFactor; localPosition.y *= scaleFactor; localPosition.z *= scaleFactor; aiVector3D offsetPosition = j->offsetPosition; offsetPosition.x *= scaleFactor; offsetPosition.y *= scaleFactor; offsetPosition.z *= scaleFactor; fwrite(&localPosition.x, sizeof(float), 1, fp); fwrite(&localPosition.y, sizeof(float), 1, fp); fwrite(&localPosition.z, sizeof(float), 1, fp); fwrite(&j->localRotation.x, sizeof(float), 1, fp); fwrite(&j->localRotation.y, sizeof(float), 1, fp); fwrite(&j->localRotation.z, sizeof(float), 1, fp); fwrite(&j->localRotation.w, sizeof(float), 1, fp); fwrite(&offsetPosition.x, sizeof(float), 1, fp); fwrite(&offsetPosition.y, sizeof(float), 1, fp); fwrite(&offsetPosition.z, sizeof(float), 1, fp); fwrite(&j->offsetRotation.x, sizeof(float), 1, fp); fwrite(&j->offsetRotation.y, sizeof(float), 1, fp); fwrite(&j->offsetRotation.z, sizeof(float), 1, fp); fwrite(&j->offsetRotation.w, sizeof(float), 1, fp); } }