| 852 | } |
| 853 | |
| 854 | bool 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 | |
| 893 | static 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]); |
no test coverage detected