| 364 | } |
| 365 | |
| 366 | bool CWaypointClass::LoadWPExpFile() |
| 367 | { |
| 368 | FILE *bfp; |
| 369 | char szWPFileName[64]; |
| 370 | char filename[256]; |
| 371 | waypoint_header_s header; |
| 372 | short int num; |
| 373 | int i, j; |
| 374 | vec from, to; |
| 375 | |
| 376 | if (m_iWaypointCount == 0) |
| 377 | return false; |
| 378 | |
| 379 | strcpy(szWPFileName, m_szMapName); |
| 380 | strcat(szWPFileName, ".exp"); |
| 381 | |
| 382 | BotManager.MakeBotFileName(szWPFileName, "waypoints", NULL, filename); |
| 383 | |
| 384 | bfp = fopen(filename, "rb"); |
| 385 | |
| 386 | // if file exists, read the waypoint structure from it |
| 387 | if (bfp != NULL) |
| 388 | { |
| 389 | fread(&header, sizeof(header), 1, bfp); |
| 390 | |
| 391 | header.szFileType[sizeof(header.szFileType)-1] = 0; |
| 392 | if (strcmp(header.szFileType, "cube_bot") == 0) |
| 393 | { |
| 394 | header.szMapName[sizeof(header.szMapName)-1] = 0; |
| 395 | |
| 396 | if (strcmp(header.szMapName, m_szMapName) == 0) |
| 397 | { |
| 398 | // Check which waypoint file version this is, handle each of them different |
| 399 | if (header.iFileVersion == 1) |
| 400 | { |
| 401 | for (i=0; i < header.iWPCount; i++) |
| 402 | { |
| 403 | // read the number of paths from this node... |
| 404 | fread(&num, sizeof(num), 1, bfp); |
| 405 | fread(&from, sizeof(vec), 1, bfp); |
| 406 | |
| 407 | if (!num) continue; |
| 408 | |
| 409 | node_s *pCurrent = GetWaypointFromVec(from); |
| 410 | |
| 411 | if (!pCurrent) |
| 412 | { |
| 413 | conoutf("Error: NULL node in waypoint experience file"); |
| 414 | continue; |
| 415 | } |
| 416 | |
| 417 | for (j=0; j < num; j++) |
| 418 | { |
| 419 | fread(&to, sizeof(vec), 1, bfp); |
| 420 | node_s *p = GetWaypointFromVec(to); |
| 421 | if (p) |
| 422 | { |
| 423 | pCurrent->FailedGoalList.AddNode(p); |
nothing calls this directly
no test coverage detected