MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / LoadScripts

Method LoadScripts

Editor/Objects/EntityScript.cpp:835–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833}
834
835void CEntityScriptRegistry::LoadScripts()
836{
837 IGame *game = GetIEditor()->GetGame();
838 if (!game)
839 return;
840
841 m_scripts.Clear();
842
843 EntityClass *entCls;
844 // Enumerate entity classes inside Game.
845 game->GetClassRegistry()->MoveFirst();
846 do {
847 entCls = game->GetClassRegistry()->Next();
848 if (entCls)
849 {
850 CEntityScript *script = new CEntityScript( entCls->ClassId,entCls->strClassName.c_str(),entCls->strScriptFile.c_str() );
851 if (!entCls->strScriptFile.empty())
852 script->SetUsable( true );
853 Insert( script );
854 }
855 } while (entCls);
856
857/*
858 int lastClassId = FIRST_ENTITY_CLASS_ID;
859
860 //////////////////////////////////////////////////////////////////////////
861 // Load class registry.
862 // Enumerate all XML files in Editor\ subfolder to look for EntityRegistry.
863 //////////////////////////////////////////////////////////////////////////
864
865 CString masterCD = GetIEditor()->GetMasterCDFolder();
866 std::vector<CFileUtil::FileDesc> files;
867 CString dir = Path::AddBackslash(masterCD) + "Editor\\";
868 CFileUtil::ScanDirectory( dir,"*.xml",files,false );
869
870 XmlParser parser;
871
872 FILE *file;
873 file = fopen( "Scripts\\classreg1.lua","wt" );
874
875 for (int k = 0; k < files.size(); k++)
876 {
877 // Construct the full filepath of the current file
878 XmlNodeRef registry = parser.parse( dir + files[k].filename );
879 if (registry != 0 && registry->isTag("EntityRegistry"))
880 {
881 for (int i = 0; i < registry->getChildCount(); i++)
882 {
883 XmlNodeRef child = registry->getChild(i);
884 if (child->isTag("EntityDesc"))
885 {
886 const char *fname = child->getAttr( "File" );
887 const char *tableName = child->getAttr( "Name" );
888 // Save new format.
889 fprintf( file,"\t{ \"\",\t\"%s\",\t%.3d,\t\"%s\" },\n",tableName,i+100,fname );
890
891
892 CString file,name;

Callers 3

OnReloadScriptsMethod · 0.80
InitGameMethod · 0.80
ResetResourcesMethod · 0.80

Calls 9

GetIEditorFunction · 0.85
GetClassRegistryMethod · 0.80
SetUsableMethod · 0.80
GetGameMethod · 0.45
ClearMethod · 0.45
MoveFirstMethod · 0.45
NextMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected