本文整理汇总了C++中CNavArea::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ CNavArea::Load方法的具体用法?C++ CNavArea::Load怎么用?C++ CNavArea::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNavArea
的用法示例。
在下文中一共展示了CNavArea::Load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadNavigationMap
/* <4f19c7> ../game_shared/bot/nav_file.cpp:947 */
NavErrorType LoadNavigationMap()
{
// since the navigation map is destroyed on map change,
// if it exists it has already been loaded for this map
if (!TheNavAreaList.empty())
return NAV_OK;
// nav filename is derived from map filename
char filename[256];
Q_sprintf(filename, "maps\\%s.nav", STRING(gpGlobals->mapname));
// free previous navigation map data
DestroyNavigationMap();
placeDirectory.Reset();
IMPL_CLASS(CNavArea, m_nextID) = 1;
SteamFile navFile(filename);
if (!navFile.IsValid())
return NAV_CANT_ACCESS_FILE;
// check magic number
bool result;
unsigned int magic;
result = navFile.Read(&magic, sizeof(unsigned int));
if (!result || magic != NAV_MAGIC_NUMBER)
{
CONSOLE_ECHO("ERROR: Invalid navigation file '%s'.\n", filename);
return NAV_INVALID_FILE;
}
// read file version number
unsigned int version;
result = navFile.Read(&version, sizeof(unsigned int));
if (!result || version > 5)
{
CONSOLE_ECHO("ERROR: Unknown navigation file version.\n");
return NAV_BAD_FILE_VERSION;
}
if (version >= 4)
{
// get size of source bsp file and verify that the bsp hasn't changed
unsigned int saveBspSize;
navFile.Read(&saveBspSize, sizeof(unsigned int));
// verify size
char *bspFilename = GetBspFilename(filename);
if (bspFilename == NULL)
return NAV_INVALID_FILE;
unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename);
if (bspSize != saveBspSize)
{
// this nav file is out of date for this bsp file
char *msg = "*** WARNING ***\nThe AI navigation data is from a different version of this map.\nThe CPU players will likely not perform well.\n";
HintMessageToAllPlayers(msg);
CONSOLE_ECHO("\n-----------------\n");
CONSOLE_ECHO(msg);
CONSOLE_ECHO("-----------------\n\n");
}
}
// load Place directory
if (version >= 5)
{
placeDirectory.Load(&navFile);
}
// get number of areas
unsigned int count;
result = navFile.Read(&count, sizeof(unsigned int));
Extent extent;
extent.lo.x = 9999999999.9f;
extent.lo.y = 9999999999.9f;
extent.hi.x = -9999999999.9f;
extent.hi.y = -9999999999.9f;
// load the areas and compute total extent
for (unsigned int i = 0; i < count; ++i)
{
CNavArea *area = new CNavArea;
area->Load(&navFile, version);
TheNavAreaList.push_back(area);
const Extent *areaExtent = area->GetExtent();
// check validity of nav area
if (areaExtent->lo.x >= areaExtent->hi.x || areaExtent->lo.y >= areaExtent->hi.y)
CONSOLE_ECHO("WARNING: Degenerate Navigation Area #%d at ( %g, %g, %g )\n",
area->GetID(), area->m_center.x, area->m_center.y, area->m_center.z);
if (areaExtent->lo.x < extent.lo.x)
extent.lo.x = areaExtent->lo.x;
if (areaExtent->lo.y < extent.lo.y)
//.........这里部分代码省略.........