本文整理汇总了C++中CNavArea::Save方法的典型用法代码示例。如果您正苦于以下问题:C++ CNavArea::Save方法的具体用法?C++ CNavArea::Save怎么用?C++ CNavArea::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNavArea
的用法示例。
在下文中一共展示了CNavArea::Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveNavigationMap
/* <4f3e47> ../game_shared/bot/nav_file.cpp:702 */
bool SaveNavigationMap(const char *filename)
{
if (filename == NULL)
return false;
// Store the NAV file
COM_FixSlashes(const_cast<char *>(filename));
#ifdef WIN32
int fd = _open(filename, _O_BINARY | _O_CREAT | _O_WRONLY, _S_IREAD | _S_IWRITE);
#else
int fd = creat(filename, S_IRUSR | S_IWUSR | S_IRGRP);
#endif // WIN32
if (fd < 0)
return false;
// store "magic number" to help identify this kind of file
unsigned int magic = NAV_MAGIC_NUMBER;
Q_write(fd, &magic, sizeof(unsigned int));
// store version number of file
// 1 = hiding spots as plain vector array
// 2 = hiding spots as HidingSpot objects
// 3 = Encounter spots use HidingSpot ID's instead of storing vector again
// 4 = Includes size of source bsp file to verify nav data correlation
// ---- Beta Release at V4 -----
// 5 = Added Place info
unsigned int version = 5;
Q_write(fd, &version, sizeof(unsigned int));
// get size of source bsp file and store it in the nav file
// so we can test if the bsp changed since the nav file was made
char *bspFilename = GetBspFilename(filename);
if (bspFilename == NULL)
return false;
unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename);
CONSOLE_ECHO("Size of bsp file '%s' is %u bytes.\n", bspFilename, bspSize);
Q_write(fd, &bspSize, sizeof(unsigned int));
// Build a directory of the Places in this map
placeDirectory.Reset();
NavAreaList::iterator it;
for (it = TheNavAreaList.begin(); it != TheNavAreaList.end(); ++it)
{
CNavArea *area = *it;
Place place = area->GetPlace();
if (place)
{
placeDirectory.AddPlace(place);
}
}
placeDirectory.Save(fd);
// Store navigation areas
// store number of areas
unsigned int count = TheNavAreaList.size();
Q_write(fd, &count, sizeof(unsigned int));
// store each area
for (it = TheNavAreaList.begin(); it != TheNavAreaList.end(); ++it)
{
CNavArea *area = *it;
area->Save(fd, version);
}
Q_close(fd);
#ifdef _WIN32
// output a simple Wavefront file to visualize the generated areas in 3DSMax
FILE *fp = fopen("c:\\tmp\\nav.obj", "w");
if (fp)
{
for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter)
{
(*iter)->Save(fp);
}
fclose(fp);
}
#endif // _WIN32
return true;
}