MCPcopy Create free account
hub / github.com/assaultcube/AC / SaveWPExpFile

Method SaveWPExpFile

source/src/bot/bot_waypoint.cpp:472–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470}
471
472void CWaypointClass::SaveWPExpFile()
473{
474 if (!m_iWaypointCount)
475 return;
476
477 char filename[256];
478 char mapname[64];
479 waypoint_header_s header;
480 short int num;
481
482 strcpy(header.szFileType, "cube_bot");
483
484 header.iFileVersion = EXP_WP_VERSION;
485
486 header.iFileFlags = 0; // not currently used
487
488 header.iWPCount = m_iWaypointCount;
489
490 memset(header.szMapName, 0, sizeof(header.szMapName));
491 strncpy(header.szMapName, m_szMapName, 31);
492 header.szMapName[31] = 0;
493
494 strcpy(mapname, m_szMapName);
495 strcat(mapname, ".exp");
496
497 BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename);
498
499 FILE *bfp = fopen(filename, "wb");
500
501 if (!bfp)
502 {
503 conoutf("Error writing waypoint experience file, check if the directory \"bot/waypoint\" exists and "
504 "the right permissions are set");
505 return;
506 }
507
508 // write the waypoint header to the file...
509 fwrite(&header, sizeof(header), 1, bfp);
510
511 // save the waypoint experience data...
512 loopi(MAX_MAP_GRIDS)
513 {
514 loopj(MAX_MAP_GRIDS)
515 {
516 TLinkedList<node_s *>::node_s *p = m_Waypoints[i][j].GetFirst();
517 while(p)
518 {
519 // count the number of paths from this node...
520 TLinkedList<node_s *>::node_s *p2 = p->Entry->FailedGoalList.GetFirst();
521 num = p->Entry->FailedGoalList.NodeCount();
522
523 if (!num || !p2) continue;
524
525 fwrite(&num, sizeof(num), 1, bfp); // write the count
526 fwrite(&p->Entry->v_origin, sizeof(vec), 1, bfp); // write the origin of this node
527
528 while (p2 != NULL)
529 {

Callers

nothing calls this directly

Calls 2

MakeBotFileNameMethod · 0.80
conoutfFunction · 0.50

Tested by

no test coverage detected