本文整理汇总了C++中Map::CanFree方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::CanFree方法的具体用法?C++ Map::CanFree怎么用?C++ Map::CanFree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::CanFree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DelMap
int Game::DelMap(unsigned int index, int forced)
{
//this function should archive the area, and remove it only if the area
//contains no active actors (combat, partymembers, etc)
if (index >= Maps.size()) {
return -1;
}
Map *map = Maps[index];
if (MapIndex==(int) index) { //can't remove current map in any case
const char *name = map->GetScriptName();
memcpy(AnotherArea, name, sizeof(AnotherArea) );
return -1;
}
if (!map) { //this shouldn't happen, i guess
printMessage("Game","Erased NULL Map\n",YELLOW);
Maps.erase( Maps.begin()+index);
if (MapIndex>(int) index) {
MapIndex--;
}
return 1;
}
if (forced || (Maps.size()>MAX_MAPS_LOADED) )
{
//keep at least one master
const char *name = map->GetScriptName();
if (MasterArea(name)) {
if(!AnotherArea[0]) {
memcpy(AnotherArea, name, sizeof(AnotherArea));
if (!forced) {
return -1;
}
}
}
//this check must be the last, because
//after PurgeActors you cannot keep the
//area in memory
//Or the queues should be regenerated!
if (!map->CanFree())
{
return 1;
}
//remove map from memory
core->SwapoutArea(Maps[index]);
delete( Maps[index] );
Maps.erase( Maps.begin()+index);
//current map will be decreased
if (MapIndex>(int) index) {
MapIndex--;
}
return 1;
}
//didn't remove the map
return 0;
}
示例2: DelMap
int Game::DelMap(unsigned int index, int forced)
{
//this function should archive the area, and remove it only if the area
//contains no active actors (combat, partymembers, etc)
if (index >= Maps.size()) {
return -1;
}
Map *map = Maps[index];
if (MapIndex==(int) index) { //can't remove current map in any case
const char *name = map->GetScriptName();
memcpy(AnotherArea, name, sizeof(AnotherArea) );
return -1;
}
if (!map) { //this shouldn't happen, i guess
Log(WARNING, "Game", "Erased NULL Map");
Maps.erase( Maps.begin()+index);
if (MapIndex>(int) index) {
MapIndex--;
}
return 1;
}
if (forced || (Maps.size()>MAX_MAPS_LOADED) )
{
//keep at least one master
const char *name = map->GetScriptName();
if (MasterArea(name)) {
if(!AnotherArea[0]) {
memcpy(AnotherArea, name, sizeof(AnotherArea));
if (!forced) {
return -1;
}
}
}
//this check must be the last, because
//after PurgeActors you cannot keep the
//area in memory
//Or the queues should be regenerated!
if (!map->CanFree())
{
return 1;
}
//if there are still selected actors on the map (e.g. summons)
//unselect them now before they get axed
std::vector< Actor*>::iterator m;
for (m = selected.begin(); m != selected.end();) {
if (!(*m)->InParty && !stricmp(Maps[index]->GetScriptName(), (*m)->Area)) {
m = selected.erase(m);
} else {
++m;
}
}
//remove map from memory
core->SwapoutArea(Maps[index]);
delete( Maps[index] );
Maps.erase( Maps.begin()+index);
//current map will be decreased
if (MapIndex>(int) index) {
MapIndex--;
}
return 1;
}
//didn't remove the map
return 0;
}