| 61 | |
| 62 | |
| 63 | bool cScoreboardSerializer::Save(void) |
| 64 | { |
| 65 | cFastNBTWriter Writer; |
| 66 | |
| 67 | SaveScoreboardToNBT(Writer); |
| 68 | |
| 69 | Writer.Finish(); |
| 70 | |
| 71 | #ifdef _DEBUG |
| 72 | cParsedNBT TestParse(Writer.GetResult().data(), Writer.GetResult().size()); |
| 73 | ASSERT(TestParse.IsValid()); |
| 74 | #endif // _DEBUG |
| 75 | |
| 76 | cFile File; |
| 77 | if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) |
| 78 | { |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | AString Compressed; |
| 83 | int res = CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed); |
| 84 | |
| 85 | if (res != Z_OK) |
| 86 | { |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | File.Write(Compressed.data(), Compressed.size()); |
| 91 | File.Close(); |
| 92 | |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | |
| 97 | |