コード例 #1
0
bool ArchiveManager::ExtractArchiveFile( const char* InPath, const char* OutPath, bool AppendFilePath /*= false*/ )
{
	bool Result = false;

	if (InPath)
	{
		std::string Path(InPath); 
		SME::StringHelpers::MakeLower(Path);

		if (Path.find("data\\") != -1)
			Path = Path.substr(Path.find("data\\") + 5);

		if (_FILEFINDER->FindFile(Path.c_str()) == 2)
		{
			ArchiveFile* ArchiveFileStream = CS_CAST(_FILEFINDER->GetFileStream(Path.c_str(), false, 0x50000), NiBinaryStream, ArchiveFile);
			if (ArchiveFileStream)
			{
				UInt32 FileSize = ArchiveFileStream->GetFileSize();
				std::string ArchiveFilePath = ArchiveFileStream->fileName;
				std::string ArchiveFileName = ArchiveFilePath.substr(ArchiveFilePath.rfind("\\") + 1);
				std::string FileOut = OutPath;

				if (AppendFilePath)
					FileOut += "\\" + ArchiveFilePath;

				DeleteFile(FileOut.c_str());		// delete file as BSFile::Ctor doesn't create it anew

				BSFile* TempFile = BSFile::CreateInstance(FileOut.c_str(), NiFile::kFileMode_WriteOnly, FileSize);
				SME_ASSERT(TempFile);

				void* Buffer = FormHeap_Allocate(FileSize);
				ZeroMemory(Buffer, FileSize);

				if (!ArchiveFileStream->DirectRead(Buffer, FileSize))
				{
					BGSEECONSOLE_MESSAGE("ArchiveManager::ExtractArchiveFile - Couldn't read file %s from archive %s", ArchiveFileStream->fileName, ArchiveFileStream->parentArchive->fileName);
				}
				else
				{
					if (!TempFile->DirectWrite(Buffer, FileSize))
					{
						BGSEECONSOLE_MESSAGE("ArchiveManager::ExtractArchiveFile - Couldn't write to file %s", TempFile->fileName);
					}
					else
						Result = true;
				}

				TempFile->Flush();
				TempFile->DeleteInstance();
				ArchiveFileStream->DeleteInstance();
				FormHeap_Free(Buffer);
			}
		}
	}

	return Result;
}
コード例 #2
0
		void CSEHallOfFameFemaleNPC::Initialize( UInt32 FormID )
		{
			CSEHallOfFameEntry::Initialize(FormID);

			TESNPC* NPC = CS_CAST(Instance, TESForm, TESNPC);
			SME_ASSERT(NPC);

			SME::MiscGunk::ToggleFlag(&NPC->actorFlags, TESActorBaseData::kNPCFlag_Female, true);
		}
コード例 #3
0
		void CSEHallOfFameStaff::Initialize( UInt32 FormID )
		{
			CSEHallOfFameEntry::Initialize(FormID);

			TESObjectWEAP* Weapon = CS_CAST(Instance, TESForm, TESObjectWEAP);
			SME_ASSERT(Weapon);

			Weapon->weaponType = TESObjectWEAP::kWeaponType_Staff;
		}
コード例 #4
0
		void CSEHallOfFameEntry::Initialize( UInt32 FormID )
		{
			Instance = TESForm::CreateInstance(FormType);
			Instance->SetFormID(FormID);
			Instance->SetEditorID(Name);

			TESFullName* Name = CS_CAST(Instance, TESForm, TESFullName);
			if (Name)
			{
				Name->name.Set(Title);
			}

			TESObject* Object = CS_CAST(Instance, TESForm, TESObject);
			SME_ASSERT(Object);

			_DATAHANDLER->AddTESObject(Object);
			Instance->SetFromActiveFile(false);
		}
コード例 #5
0
		void CSEHallOfFameScript::Initialize( UInt32 FormID )
		{
			Script* Form = CS_CAST(TESForm::CreateInstance(FormType), TESForm, Script);

			Form->SetFormID(FormID);
			Form->SetEditorID(Name);
			Form->SetFromActiveFile(false);
			Form->SetText(Title);

			_DATAHANDLER->scripts.AddAt(Form, eListEnd);
		}
コード例 #6
0
bool TESLeveledList::WalkForCircularPath( std::string& Output, TESLeveledList* Check, TESLeveledList* Against )
{
	bool Result = true;
	
	TESForm* CheckBase = CS_CAST(Check, TESLeveledList, TESForm);
	TESForm* CheckAgainstBase = CS_CAST(Against, TESLeveledList, TESForm);
	SME_ASSERT(CheckBase && CheckAgainstBase);	

	for (TESLeveledList::LevListT::Iterator Itr = Check->levList.Begin(); Itr.Get() && Itr.End() == false; ++Itr)
	{
		TESForm* Item = Itr->form;
		TESLeveledList* Inner = CS_CAST(Item, TESForm, TESLeveledList);

		if (Item->formID == CheckAgainstBase->formID)
		{
			// the source lev list is an item
			Output += CheckBase->GetEditorID();
			Output += " >";
			Output += CheckAgainstBase->GetEditorID();

			Result = false;
			break;
		}
		else if (Inner)
		{
			std::string TempStr = Output + CheckBase->GetEditorID();
			TempStr += " >";
			
			// recurse
			if (WalkForCircularPath(TempStr, Inner, Against) == false)
			{
				Output = TempStr;
				Result = false;
				break;
			}
		}
	}

	return Result;
}
コード例 #7
0
		void CSEHallOfFameShadeMe::Initialize( UInt32 FormID )
		{
			CSEHallOfFameEntry::Initialize(FormID);

			TESObjectREFR* shadeMeRef = CS_CAST(TESForm::CreateInstance(TESForm::kFormType_REFR), TESForm, TESObjectREFR);
			TheGreatEye = shadeMeRef;

			shadeMeRef->SetBaseForm(TESForm::LookupByEditorID(Name));
			shadeMeRef->SetFormID(0x99);
			shadeMeRef->SetEditorID("TheShadeMeRef");
			shadeMeRef->SetFromActiveFile(false);
			shadeMeRef->SetPersistent(true);
		}
コード例 #8
0
		bool IRenderWindowOSDLayer::Helpers::ResolveReference(UInt32 FormID, TESObjectREFR*& OutRef)
		{
			TESForm* Form = TESForm::LookupByFormID(FormID);

			if (Form)
			{
				SME_ASSERT(Form->formType == TESForm::kFormType_ACHR || Form->formType == TESForm::kFormType_ACRE || Form->formType == TESForm::kFormType_REFR);

				OutRef = CS_CAST(Form, TESForm, TESObjectREFR);
				return (Form->IsDeleted() == false);
			}
			else
				return false;
		}
コード例 #9
0
		void GlobalCopyBuffer::Add(TESForm* Form)
		{
			SME_ASSERT(Form);

			if (Form->IsReference())
			{
				TESObjectREFR* Ref = CS_CAST(Form, TESForm, TESObjectREFR);
				if (Ref->baseForm)
				{
					if (Ref->baseForm->formType == TESForm::kFormType_Door ||
						Ref->baseForm == TESForm::LookupByEditorID("DoorMarker"))
					{
						return;
					}
				}
			}

			FormList.push_back(new TESFormWrapper(Form));
		}