| 249 | static bool AssertAIValid() |
| 250 | { |
| 251 | for (int side = 0; side < TSideUnknown; side++) |
| 252 | { |
| 253 | AICenter* center = GWorld->GetCenter((TargetSide)side); |
| 254 | if (!center) |
| 255 | { |
| 256 | continue; |
| 257 | } |
| 258 | if (!center->AssertValid()) |
| 259 | { |
| 260 | return false; |
| 261 | } |
| 262 | } |
| 263 | return true; |
| 264 | } |
| 265 | |
| 266 | bool CheckMissionFile(RString fileName, MissionHeader& header) |
| 267 | { |
| 268 | RString fileNameExt = fileName + RString(".pbo"); |
| 269 | |
| 270 | std::error_code ec; |
| 271 | auto fileSize = std::filesystem::file_size(std::string(fileNameExt), ec); |
| 272 | if (ec) |
| 273 | return false; |
| 274 | |
| 275 | if (header.fileSizeL != static_cast<DWORD>(fileSize & 0xffffffff) || |
| 276 | header.fileSizeH != static_cast<DWORD>(fileSize >> 32)) |
| 277 | { |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | QIFStream f; |
| 282 | f.open(fileNameExt); |
| 283 | Poseidon::Foundation::CRCCalculator crc; |
| 284 | if (crc.CRC(f.act(), f.rest()) != header.fileCRC) |
| 285 | { |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | CreateMPMissionBank(fileName, header.island); |
| 290 | return true; |
| 291 | } |
| 292 | |
| 293 | // client-side settings: |
| 294 | // custom face file bigger than given limit is ignored |
| 295 | int MaxCustomFaceSize = 100 * 1024; |
| 296 | // custom sound file bigger than given limit is ignored |
| 297 | int MaxCustomSoundSize = 50 * 1024; |
| 298 | // server-side setting: |
| 299 | // client attemping to transfer more than given limit will be kicked |
| 300 | |
| 301 | int MaxCustomFileSize = 128 * 1024; |
| 302 | |
| 303 | static int FileSize(const char* name) |
| 304 | { |
| 305 | HANDLE file = OpenFileForRead(name); |
| 306 | if (file == INVALID_HANDLE_VALUE) |
| 307 | return INT_MAX; |
| 308 |
nothing calls this directly
no test coverage detected