MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / Load

Method Load

Source/Runtime/Private/Render/ParticleSystem.cpp:854–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854bool ParticleSystem::Load(const char *filename) {
855 Purge();
856
857 Str prtSysFilename = filename;
858 if (!Str::CheckExtension(filename, ".prts")) {
859 prtSysFilename.SetFileExtension(".prts");
860 }
861
862 BE_LOG("Loading particle system '%s'...\n", filename);
863
864 char *data;
865 int size = (int)fileSystem.LoadFile(filename, true, (void **)&data);
866 if (!data) {
867 return false;
868 }
869
870 Lexer lexer;
871 lexer.Init(Lexer::Flag::NoErrors);
872 lexer.Load(data, size, hashName);
873
874 if (!lexer.ExpectTokenString("particleSystem")) {
875 fileSystem.FreeFile(data);
876 return false;
877 }
878
879 int version = lexer.ParseInt();
880 if (version != PRTS_VERSION) {
881 lexer.Error("ParticleSystem::Load: Invalid version %d\n", version);
882 fileSystem.FreeFile(data);
883 return false;
884 }
885
886 Create(data + lexer.GetCurrentOffset());
887
888 fileSystem.FreeFile(data);
889
890 return true;
891}
892
893static void WriteMinMaxCurve(File *fp, const Str &name, const MinMaxCurve &var, Str &indentSpace) {
894 fp->Printf("%s%s \"%s\" {\n", indentSpace.c_str(), name.c_str(), timedMinMaxVarTypeNames[var.type]);

Callers 1

CreateMethod · 0.45

Calls 8

ExpectTokenStringMethod · 0.80
FreeFileMethod · 0.80
ParseIntMethod · 0.80
CreateFunction · 0.50
LoadFileMethod · 0.45
InitMethod · 0.45
ErrorMethod · 0.45
GetCurrentOffsetMethod · 0.45

Tested by

no test coverage detected