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

Method SaveWaypoints

source/src/bot/bot_waypoint.cpp:281–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281void CWaypointClass::SaveWaypoints()
282{
283 char filename[256];
284 char mapname[64];
285 waypoint_header_s header;
286 short int num;
287 TLinkedList<node_s *>::node_s *pPath;
288
289 strcpy(header.szFileType, "cube_bot");
290
291 header.iFileVersion = WAYPOINT_VERSION;
292
293 header.iFileFlags = 0; // not currently used
294
295 header.iWPCount = m_iWaypointCount;
296
297 memset(header.szMapName, 0, sizeof(header.szMapName));
298 strncpy(header.szMapName, m_szMapName, sizeof(header.szMapName)-1);
299 header.szMapName[sizeof(header.szMapName)-1] = 0;
300
301 strcpy(mapname, m_szMapName);
302 strcat(mapname, ".wpt");
303
304 BotManager.MakeBotFileName(mapname, "waypoints", NULL, filename);
305
306 stream *bfp = openfile(filename, "wb");
307
308 if (!bfp)
309 {
310 conoutf("Error writing waypoint file, check if the directory \"bot/waypoint\" exists and "
311 "the right permissions are set");
312 return;
313 }
314
315 // write the waypoint header to the file...
316 bfp->write(&header, sizeof(header));
317
318 // write the waypoint data to the file...
319 loopi(MAX_MAP_GRIDS)
320 {
321 loopj(MAX_MAP_GRIDS)
322 {
323 TLinkedList<node_s *>::node_s *p = m_Waypoints[i][j].GetFirst();
324 while(p)
325 {
326 bfp->write(&p->Entry->v_origin, sizeof(p->Entry->v_origin)); // Write origin
327 bfp->write(&p->Entry->iFlags, sizeof(p->Entry->iFlags)); // Write waypoint flags
328 bfp->write(&p->Entry->sTriggerNr, sizeof(p->Entry->sTriggerNr)); // Write trigger nr
329 bfp->write(&p->Entry->sYaw, sizeof(p->Entry->sYaw)); // Write target yaw
330
331 p = p->next;
332 }
333 }
334 }
335
336 loopi(MAX_MAP_GRIDS)
337 {
338 loopj(MAX_MAP_GRIDS)

Callers 1

wpsaveFunction · 0.80

Calls 4

openfileFunction · 0.85
MakeBotFileNameMethod · 0.80
conoutfFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected