Esempio n. 1
0
void TESObjectARMA::GetNodeName(char * dstBuff, TESObjectREFR * refr, TESObjectARMO * armor, float weightOverride)
{
	float weight = 100.0;
	TESNPC * npc = DYNAMIC_CAST(refr->baseForm, TESForm, TESNPC);
	if(npc && npc->nextTemplate) {
		TESNPC * temp = npc->GetRootTemplate();
		if(temp) {
			weight = temp->weight;
		}
	}
	else
		weight = CALL_MEMBER_FN(refr, GetWeight)();

	weight /= 100.0;
	if(weightOverride >= 0.0) // Determines whether to factor weight into the name, -1 true, 1 false
		weight = weightOverride;

	weight *= 100.0;
	
	UInt32 sex = npc ? CALL_MEMBER_FN(npc, GetSex)() : 0;
	/*sprintf_s(dstBuff, MAX_PATH, "%s (%08X)[%d]/%s (%08X) [%2.0f%%]", 
		this->Unk_32(), // I really have no idea why they used a string here for a boolean value, probably legacy code
		this->formID,
		sex,
		armor->Unk_32(), 
		armor->formID, 
		weight);*/
	sprintf_s(dstBuff, MAX_PATH, " (%08X)[%d]/ (%08X) [%2.0f%%]", 
		this->formID,
		sex,
		armor->formID, 
		weight);
}
Esempio n. 2
0
void CPWToolBar::SetupImageList(const GuiRecord *guiInfo,
                                GuiRecordGetter GetBM, GuiRecordGetter GetDisBM,
                                const int numBMs, const int nImageList)
{
  // See http://www.parashift.com/c++-faq/macro-for-ptr-to-memfn.html
#define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))

  const COLORREF crCOLOR_3DFACE = GetSysColor(COLOR_3DFACE);

  CBitmap bmNormal, bmDisabled;

  for (int i = 0; i < numBMs; i++) {
    UINT bmID = CALL_MEMBER_FN(guiInfo[i], GetBM)();
    if (bmID == 0)
      continue; // skip over separator

    BOOL brc = bmNormal.Attach(::LoadImage(::AfxFindResourceHandle(MAKEINTRESOURCE(bmID), RT_BITMAP),
                               MAKEINTRESOURCE(bmID), IMAGE_BITMAP, 0, 0,
                               (LR_DEFAULTSIZE | LR_CREATEDIBSECTION)));
    ASSERT(brc);
    SetBitmapBackground(bmNormal, crCOLOR_3DFACE);
    m_ImageLists[nImageList].Add(&bmNormal, crCOLOR_3DFACE);
    bmNormal.DeleteObject();

    if (nImageList != 0) {
      bmID = CALL_MEMBER_FN(guiInfo[i], GetDisBM)();
      bmDisabled.Attach(::LoadImage(::AfxFindResourceHandle(MAKEINTRESOURCE(bmID), RT_BITMAP),
                                    MAKEINTRESOURCE(bmID), IMAGE_BITMAP, 0, 0,
                                    (LR_DEFAULTSIZE | LR_CREATEDIBSECTION)));
      SetBitmapBackground(bmDisabled, crCOLOR_3DFACE);
      m_DisabledImageLists[nImageList - 1].Add(&bmDisabled, crCOLOR_3DFACE);
      bmDisabled.DeleteObject();
    }
  }
}
	void UpdateItemAbility(Actor * actor, TESForm* baseForm, BaseExtraList * extraData, bool bLeftHand)
	{
		if(actor && baseForm) {
			if(baseForm->formType == TESObjectWEAP::kTypeID)
				CALL_MEMBER_FN(actor, UpdateWeaponAbility)(baseForm, extraData, bLeftHand);
			else if(baseForm->formType == TESObjectARMO::kTypeID)
				CALL_MEMBER_FN(actor, UpdateArmorAbility)(baseForm, extraData);
		}
	}
Esempio n. 4
0
void Script::RunScriptLine(const char * text, TESObjectREFR * object)
{
	ConsoleManager	* consoleManager = ConsoleManager::GetSingleton();

	UInt8	scriptBuf[sizeof(Script)];
	Script	* script = (Script *)scriptBuf;

	CALL_MEMBER_FN(script, Constructor)();
	CALL_MEMBER_FN(script, MarkAsTemporary)();
	CALL_MEMBER_FN(script, SetText)(text);
	CALL_MEMBER_FN(script, Run)(consoleManager->scriptContext, true, object);
	CALL_MEMBER_FN(script, Destructor)();
}
	void CreateEnchantment(TESForm* baseForm, BaseExtraList * extraData, float maxCharge, VMArray<EffectSetting*> effects, VMArray<float> magnitudes, VMArray<UInt32> areas, VMArray<UInt32> durations)
	{
		if(baseForm && (baseForm->formType == TESObjectWEAP::kTypeID || baseForm->formType == TESObjectARMO::kTypeID)) {
			EnchantmentItem * enchantment = NULL;
			if(effects.Length() > 0 && magnitudes.Length() == effects.Length() && areas.Length() == effects.Length() && durations.Length() == effects.Length()) {
				tArray<MagicItem::EffectItem> effectItems;
				effectItems.Allocate(effects.Length());

				UInt32 j = 0;
				for(UInt32 i = 0; i < effects.Length(); i++) {
					EffectSetting * magicEffect = NULL;
					effects.Get(&magicEffect, i);
					if(magicEffect) { // Only add effects that actually exist
						magnitudes.Get(&effectItems[j].magnitude, i);
						areas.Get(&effectItems[j].area, i);
						durations.Get(&effectItems[j].duration, i);
						effectItems[j].mgef = magicEffect;
						j++;
					}
				}
				effectItems.count = j; // Set count to existing count

				if(baseForm->formType == TESObjectWEAP::kTypeID)
					enchantment = CALL_MEMBER_FN(PersistentFormManager::GetSingleton(), CreateOffensiveEnchantment)(&effectItems);
				else
					enchantment = CALL_MEMBER_FN(PersistentFormManager::GetSingleton(), CreateDefensiveEnchantment)(&effectItems);

				FormHeap_Free(effectItems.arr.entries);
			}

			if(enchantment) {
				if(maxCharge > 0xFFFF) // Charge exceeds uint16 clip it
					maxCharge = 0xFFFF;

				ExtraEnchantment* extraEnchant = static_cast<ExtraEnchantment*>(extraData->GetByType(kExtraData_Enchantment));
				if(extraEnchant) {
					PersistentFormManager::GetSingleton()->DecRefEnchantment(extraEnchant->enchant);
					extraEnchant->enchant = enchantment;
					PersistentFormManager::GetSingleton()->IncRefEnchantment(extraEnchant->enchant);

					extraEnchant->maxCharge = (UInt16)maxCharge;
				} else {
					ExtraEnchantment* extraEnchant = ExtraEnchantment::Create();
					extraEnchant->enchant = enchantment;
					extraEnchant->maxCharge = (UInt16)maxCharge;
					extraData->Add(kExtraData_Enchantment, extraEnchant);
				}
			}
		}
	}
Esempio n. 6
0
void UpdateItem3D(const FxDelegateArgs & params)
{
	if(params.menu) {
		UInt32 formId = (UInt32)params.args->GetNumber();
		if(formId) {
			TESForm * form = LookupFormByID(formId);
			if(form) {
				CALL_MEMBER_FN(Inventory3DManager::GetSingleton(), UpdateMagic3D)(form, 0);
			}
		} else {
			CALL_MEMBER_FN(Inventory3DManager::GetSingleton(), Clear3D)();
		}
	}
}
Esempio n. 7
0
TESForm * TESForm::CloneForm(bool persist) const
{
	TESForm	* result = CreateFormInstance(typeID);
	if(result)
	{
		result->CopyFrom(this);
		CALL_MEMBER_FN(DataHandler::Get(), DoAddForm)(result);

		if(persist)
		{
			CALL_MEMBER_FN(TESSaveLoadGame::Get(), AddCreatedForm)(result);
		}
	}

	return result;
}
Esempio n. 8
0
void
slice_set::write_general(const string& file, const string& title,
   print_fn fun, vm::all *all) const
{
   ofstream out(file.c_str(), ios_base::out | ios_base::trunc);
   
   write_header(out, title, all);
   
   vector<iter> iters(all->NUM_THREADS, iter());

	 assert(slices.size() == all->NUM_THREADS);

   for(size_t i(0); i < all->NUM_THREADS; ++i) {
		  assert(num_slices == slices[i].size());
      iters[i] = slices[i].begin();
	 }
      
   for(size_t slice(0); slice < num_slices; ++slice) {
      csv_line line;
      line << to_string<unsigned long>(slice * SLICE_PERIOD);
      for(size_t proc(0); proc < all->NUM_THREADS; ++proc) {
         assert(iters[proc] != slices[proc].end());
         const statistics::slice& sl(*iters[proc]);
         CALL_MEMBER_FN(sl, fun)(line);
         iters[proc]++;
      }
      line.print(out);
   }
}
static bool Cmd_SetCellResetHours_Execute(COMMAND_ARGS)
{
	// specifies # of hours from now until cell reset
	*result = 0;
	TESObjectCELL* cell = NULL;
	UInt32 numHours = -1;
	if (ExtractArgs(PASS_EXTRACT_ARGS, &cell, &numHours) && cell && numHours != -1)
	{
		if (cell->IsInterior() && cell != (*g_thePlayer)->parentCell)
		{
			SInt32 iHoursToRespawn = TimeGlobals::HoursToRespawnCell();
			SInt32 iHoursPassed = TimeGlobals::GameHoursPassed();
			SInt32 detachTime = iHoursPassed + numHours - iHoursToRespawn;
			if (detachTime < iHoursPassed)
			{
				*result = 1;
				CALL_MEMBER_FN(cell, SetDetachTime)(detachTime);
				if (IsConsoleMode())
					Console_Print("Current hours passed :%d Detach time: %d", iHoursPassed, detachTime);
			}
			else if (IsConsoleMode())
				Console_Print("Detach time %d cannot be greater than current hours passed %d", detachTime, iHoursPassed);
		}
	}

	return true;
}
Esempio n. 10
0
bool BGSSaveLoadManager::LoadGame_Hook(const char * saveName, bool unk1)
{
#ifdef DEBUG
	_MESSAGE("Executing BGSSaveLoadManager::LoadGame_Hook. saveName: %s", saveName);
#endif
  FriendLink::PreLoadGame();
	g_loadGameLock.Enter();
	Serialization::SetSaveName(saveName);
	PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PreLoadGame, (void*)saveName, strlen(saveName), NULL);
	
	bool result = CALL_MEMBER_FN(this, LoadGame_HookTarget)(saveName, unk1);
	PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_PostLoadGame, (void*)result, 1, NULL);
	Serialization::SetSaveName(NULL);

	g_loadGameLock.Leave();
	
	// Clear invalid handles in OnUpdate event registration list
	UInt32	enableClearRegs = 0;
	if (GetConfigOption_UInt32("General", "ClearInvalidRegistrations", &enableClearRegs))
	{
		if (enableClearRegs)
		{
			UInt32 count = (*g_skyrimVM)->ClearInvalidRegistrations();
			if (count > 0)
				_MESSAGE("ClearInvalidRegistrations: Removed %d invalid OnUpdate registration(s)", count);
		}
	}

#ifdef DEBUG
	_MESSAGE("Executed BGSSaveLoadManager::LoadGame_Hook.");
#endif
	return result;
}
	void QueueNiNodeUpdate(Actor* thisActor)
	{
		Character * pChar = DYNAMIC_CAST(thisActor, Actor, Character);
		if(pChar) {
			CALL_MEMBER_FN(pChar, QueueNiNodeUpdate)(false); // False makes this allow weapons to not be auto holstered apparently
		}
	}
Esempio n. 12
0
std::vector<float> physics::K1(float t, const std::vector<float>& x)
{
  if(!RKfunc)
    throw std::logic_error("physics::K1(float, const std::vector<float>&): RKfunc is NULL");

  return CALL_MEMBER_FN(*this,RKfunc)(t,x);
}
Esempio n. 13
0
void CustomMenu::Render()
{
	if(view) {
		view->Render();
		CALL_MEMBER_FN(Inventory3DManager::GetSingleton(), Render)();
	}
}
Esempio n. 14
0
void TESForm::DoAddForm(TESForm* newForm, bool persist, bool record) const
{
	CALL_MEMBER_FN(DataHandler::Get(), DoAddForm)(newForm);

	if(persist)
	{
		// Only some forms can be safely saved as SaveForm. ie TESPackage at the moment.
		bool canSave = false;
		TESPackage* package = DYNAMIC_CAST(newForm, TESForm, TESPackage);
		if (package)
			canSave = true;
		// ... more ?

		if (canSave)
			CALL_MEMBER_FN(TESSaveLoadGame::Get(), AddCreatedForm)(newForm);
	}
}
Esempio n. 15
0
TESObjectREFR* TESObjectREFR::Create(bool bTemp)
{
	TESObjectREFR* refr = (TESObjectREFR*)FormHeap_Allocate(sizeof(TESObjectREFR));
	ThisStdCall(s_TESObject_REFR_init, refr);
	if (bTemp)
		CALL_MEMBER_FN(refr, MarkAsTemporary);
	return refr;
}
BSDismemberSkinInstance * BSDismemberSkinInstance::Create()
{
	void* memory = FormHeap_Allocate(sizeof(BSDismemberSkinInstance));
	memset(memory, 0, sizeof(BSDismemberSkinInstance));
	BSDismemberSkinInstance* xData = (BSDismemberSkinInstance*)memory;
	CALL_MEMBER_FN(xData, ctor)();
	return xData;
}
NiTriShape * NiTriShape::Create(NiTriShapeData * geometry)
{
	void* memory = FormHeap_Allocate(sizeof(NiTriShape));
	memset(memory, 0, sizeof(NiTriShape));
	NiTriShape* xData = (NiTriShape*)memory;
	CALL_MEMBER_FN(xData, ctor)(geometry);
	return xData;
}
Esempio n. 18
0
void VMClassInfo::Release(void)
{
	if(!InterlockedDecrement(&refCount))
	{
		CALL_MEMBER_FN(this, Destroy)();
		FormHeap_Free(this);
	}
}
JG_Enemy_Base* JG_AttackWave_AllLinesTogether::addEnemy()
{
	JG_Enemy_Base* tempEnemy;
	std::vector<SEnemyTypes> enemyTypes = CALL_MEMBER_FN(listenerObj, getEnemyTypesFunction)();
	tempEnemy = (JG_Enemy_Base*) enemyTypes[selectEnemyType()].factory->Create();
	CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
	tempEnemy->InitialEnemy(ccp((float)(- 20),(float) screenSize.height + 20.0), EnemyBonus_None);
	
	//mainGame->enemyArray->addObject(tempEnemy);
	CALL_MEMBER_FN(listenerObj,addEnemyFunction)(tempEnemy);
	//remember to initial enemies

	//mainGame->addChild((CCNode*) tempEnemy,50);
	pathQueue.push(pathCounter);
	enemyQueue.push(tempEnemy);
	return tempEnemy;
}
	UInt32 GetCostliestEffectIndex(MagicItem* thisMagic)
	{
		if (!thisMagic)
			return 0;

		MagicItem::EffectItem * pEI = CALL_MEMBER_FN(thisMagic, GetCostliestEffectItem)(5, false);
		return pEI ? thisMagic->effectItemList.GetItemIndex(pEI) : 0;
	}
bool Cmd_SKSETestFunc_Eval(COMMAND_ARGS_EVAL)
{
	NiNode	* node = (*g_thePlayer)->GetNiNode();

	UInt8		niStreamMemory[0x5B4];
	NiStream	* niStream = (NiStream *)niStreamMemory;
	CALL_MEMBER_FN(niStream, ctor)();

	node->IncRef();
	niStream->m_rootObjects.Append(node);

	niStream->SavePath("head.nif");

	CALL_MEMBER_FN(niStream, dtor)();

	return true;	
}
	void UpdateWeight(Actor * thisActor, float neckDelta)
	{
		BSTaskPool * taskPool = BSTaskPool::GetSingleton();
		if(taskPool) {
			CALL_MEMBER_FN(thisActor, QueueNiNodeUpdate)(true);
			taskPool->UpdateWeight(thisActor, neckDelta,  0, true);
		}
	}
int MPLSensor::readEvents(sensors_event_t* data, int count)
{
    //VFUNC_LOG;
    int i;
    bool irq_set[5] = { false, false, false, false, false };
    inv_error_t rv;
    if (count < 1)
        return -EINVAL;
    int numEventReceived = 0;

    clearIrqData(irq_set);

    pthread_mutex_lock(&mMplMutex);
    if (mDmpStarted) {
        //ALOGV_IF(EXTRA_VERBOSE, "Update Data");
        rv = inv_update_data();
        ALOGE_IF(rv != INV_SUCCESS, "inv_update_data error (code %d)", (int) rv);
    }

    else {
        //probably just one extra read after shutting down
        ALOGV_IF(EXTRA_VERBOSE,
                "MPLSensor::readEvents called, but there's nothing to do.");
    }

    pthread_mutex_unlock(&mMplMutex);

    if (!mNewData) {
        ALOGV_IF(EXTRA_VERBOSE, "no new data");
        return 0;
    }
    mNewData = 0;
    
    /* google timestamp */
    pthread_mutex_lock(&mMplMutex);
    for (int i = 0; i < numSensors; i++) {
        if (mEnabled & (1 << i)) {
            CALL_MEMBER_FN(this,mHandlers[i])(mPendingEvents + i,
                                              &mPendingMask, i);
	    mPendingEvents[i].timestamp = irq_timestamp;
        }
    }

    for (int j = 0; count && mPendingMask && j < numSensors; j++) {
        if (mPendingMask & (1 << j)) {
            mPendingMask &= ~(1 << j);
            if (mEnabled & (1 << j)) {
                *data++ = mPendingEvents[j];
                count--;
                numEventReceived++;
            }
        }

    }

    pthread_mutex_unlock(&mMplMutex);
    return numEventReceived;
}
Esempio n. 24
0
bool Script::RunScriptLine2(const char * text, TESObjectREFR* object, bool bSuppressOutput)
{
    //ToggleConsoleOutput(!bSuppressOutput);

    ConsoleManager	* consoleManager = ConsoleManager::GetSingleton();

    UInt8	scriptBuf[sizeof(Script)];
    Script	* script = (Script *)scriptBuf;

    CALL_MEMBER_FN(script, Constructor)();
    CALL_MEMBER_FN(script, MarkAsTemporary)();
    CALL_MEMBER_FN(script, SetText)(text);
    bool bResult = CALL_MEMBER_FN(script, Run)(consoleManager->scriptContext, true, object);
    CALL_MEMBER_FN(script, Destructor)();

    //ToggleConsoleOutput(true);
    return bResult;
}
Esempio n. 25
0
// Parses the handle again for some unknown reason
bool IObjectHandlePolicy::Unk_02_Hook(UInt64 handle)
{
	PlayerCharacter* pPC = (*g_thePlayer);
	if(pPC) {
		return ((handle & 0x0000AA0000000000) == 0x0000AA0000000000) && ((handle & 0xFFFFFFFF) == pPC->formID);
	}

	return CALL_MEMBER_FN(this, Unk_02_Origin)(handle);
}
Esempio n. 26
0
void BGSSaveLoadManager::DeleteSavegame_Hook(const char * saveNameIn, UInt32 unk1)

{
	std::string saveName = saveNameIn;

	PluginManager::Dispatch_Message(0, SKSEMessagingInterface::kMessage_DeleteGame, (void*)saveName.c_str(), strlen(saveName.c_str()), NULL);
	CALL_MEMBER_FN(this, DeleteSavegame)(saveNameIn, unk1);
	Serialization::HandleDeleteSave(saveName);
}
void SkyrimVM::RevertGlobalData_Hook(void)
{
	CALL_MEMBER_FN(this, RevertGlobalData_Internal)();

	Serialization::HandleRevertGlobalData();

	papyrusUICallback::RevertGlobalData();
	papyrusModEvent::RevertGlobalData();
}
Esempio n. 28
0
void test_reshape_algorithm() {

	int num1 = tidfa_num;
	
	reshape();
	
	int num2 = tidfa_num;
	
	printf("%d new states are needed!\n", num2 - num1);

	int p = 0;
	int i = 0;
	bool http_accept = false;
	for (; i < strlen(indata); i++) {
		p = tidfa_newtr[p][indata[i]];
		if (new_tidfa_accept[p] != -1) {
			http_accept = true;
			break;
		}
	}
	if (http_accept) i++;
	printf("Tidfa accept state = %d\n", p);
	printf("Character consump = %d\n", i);
	
	tsNode *t = tidfaState[getfa(p)];
	while(t != NULL) {
		if (t->tidfa_q == p) break;
		t = t->next;
	}

	matches = t->matches;
	run_string(indata + i, t->x);

	printState(t->x);
	printf("matches=%d\n", matches);
	
	printf("----------------run all character all once---------------\n");
	state st;
	matches = 0;
	st.flow_data_length = strlen(indata);
	st.flow_data = (const u_char*)indata;
  	while (st.fdpos < st.flow_data_length && st.q != NULL)
		CALL_MEMBER_FN(st, st.q)();
	printState(st);
	printf("matches=%d\n", matches);

	printf("---------------run_fs function---------\n");
	matches = 0;
	state st1;
	for (int j = 0; j < strlen(indata); j++)
		run_fs(indata[j], st1);
	printState(st1);
	
	printf("matches=%d\n", matches);
	
	return ;
}
	bool Accept(TESContainer::Entry* pEntry)
	{
		SInt32 numObjects = 0;
		if (m_info.IsValidEntry(pEntry, numObjects)) {
			CALL_MEMBER_FN(m_formList, AddFormToList)(pEntry->form);
		}

		return true;
	}
bool VMClassLoader::Load_Hook(const char * name, VMClass * out)
{
	bool	result = CALL_MEMBER_FN(this, Load_Impl)(name, out);
	if(result)
	{
		_MESSAGE("%s", out->objectName.data);
	}

	return result;
}