Skip to content
Permalink
Browse files

Merge pull request #1177 from NHOrus/nocxx11

Annual cleanup and warning fix
  • Loading branch information
SupSuper committed Mar 21, 2018
2 parents 1b4c1c7 + 0ed2fff commit 7478b29875fdb2acd2cc44bb4820b4d32d5b3ab0
@@ -650,6 +650,7 @@ void SellState::changeByValue(int change, int dir)
_spaceChange -= dir * change * item->getSize();
break;
default:
//TRANSFER_SCIENTIST and TRANSFER_ENGINEER do not own anything that takes storage
break;
}

@@ -157,6 +157,7 @@ void SoldierDiaryMissionState::init()
{
case STATUS_DEAD:
kills++;
//Fall-through
case STATUS_UNCONSCIOUS:
case STATUS_PANICKING:
case STATUS_TURNING:
@@ -87,7 +87,7 @@ void AIModule::load(const YAML::Node &node)
int fromNodeID, toNodeID;
fromNodeID = node["fromNode"].as<int>(-1);
toNodeID = node["toNode"].as<int>(-1);
_AIMode = node["AIMode"].as<int>(0);
_AIMode = node["AIMode"].as<int>(AI_PATROL);
_wasHitBy = node["wasHitBy"].as<std::vector<int> >(_wasHitBy);
if (fromNodeID != -1)
{
@@ -136,7 +136,7 @@ void AIModule::think(BattleAction *action)
_knownEnemies = countKnownTargets();
_visibleEnemies = selectNearestTarget();
_spottingEnemies = getSpottingUnits(_unit->getPosition());
_melee = _unit->getMeleeWeapon() != 0;
_melee = (_unit->getMeleeWeapon() != 0);
_rifle = false;
_blaster = false;
_reachable = _save->getPathfinding()->findReachable(_unit, _unit->getTimeUnits());
@@ -160,16 +160,16 @@ void AIModule::think(BattleAction *action)
std::string AIMode;
switch (_AIMode)
{
case 0:
case AI_PATROL:
AIMode = "Patrol";
break;
case 1:
case AI_AMBUSH:
AIMode = "Ambush";
break;
case 2:
case AI_COMBAT:
AIMode = "Combat";
break;
case 3:
case AI_ESCAPE:
AIMode = "Escape";
break;
}
@@ -235,35 +235,22 @@ void AIModule::think(BattleAction *action)

bool evaluate = false;

if (_AIMode == AI_ESCAPE)
{
if (!_spottingEnemies || !_knownEnemies)
{
evaluate = true;
}
}
else if (_AIMode == AI_PATROL)
{
if (_spottingEnemies || _visibleEnemies || _knownEnemies || RNG::percent(10))
{
evaluate = true;
}
}
else if (_AIMode == AI_AMBUSH)
{
if (!_rifle || !_ambushTUs || _visibleEnemies)
switch (_AIMode)
{
evaluate = true;
}
}
case AI_PATROL:
evaluate = (bool)(_spottingEnemies || _visibleEnemies || _knownEnemies || RNG::percent(10));
break;
case AI_AMBUSH:
evaluate = (!_rifle || !_ambushTUs || _visibleEnemies);
break;
case AI_COMBAT:
evaluate = (_attackAction->type == BA_RETHINK);
break;
case AI_ESCAPE:
evaluate = (!_spottingEnemies || !_knownEnemies);
break;
}

if (_AIMode == AI_COMBAT)
{
if (_attackAction->type == BA_RETHINK)
{
evaluate = true;
}
}
if (_spottingEnemies > 2
|| _unit->getHealth() < 2 * _unit->getBaseStats()->health / 3
|| (_aggroTarget && _aggroTarget->getTurnsSinceSpotted() > _intelligence))
@@ -285,16 +272,16 @@ void AIModule::think(BattleAction *action)
std::string AIMode;
switch (_AIMode)
{
case 0:
case AI_PATROL:
AIMode = "Patrol";
break;
case 1:
case AI_AMBUSH:
AIMode = "Ambush";
break;
case 2:
case AI_COMBAT:
AIMode = "Combat";
break;
case 3:
case AI_ESCAPE:
AIMode = "Escape";
break;
}
@@ -331,6 +318,7 @@ void AIModule::think(BattleAction *action)
break;
case 2:
_reserve = BA_SNAPSHOT;
break;
default:
break;
}
@@ -586,7 +574,6 @@ void AIModule::setupAmbush()

if (selectClosestKnownEnemy())
{
Position target;
const int BASE_SYSTEMATIC_SUCCESS = 100;
const int COVER_BONUS = 25;
const int FAST_PASS_THRESHOLD = 80;
@@ -613,6 +600,7 @@ void AIModule::setupAmbush()
}

// make sure we can't be seen here.
Position target;
if (!_save->getTileEngine()->canTargetUnit(&origin, tile, &target, _aggroTarget, _unit) && !getSpottingUnits(pos))
{
_save->getPathfinding()->calculate(_unit, pos);
@@ -354,9 +354,6 @@ bool BattlescapeGame::kneel(BattleUnit *bu)
*/
void BattlescapeGame::endTurn()
{

Position p;

_debugPlay = false;
_currentAction.type = BA_NONE;
getMap()->getWaypoints()->clear();
@@ -371,6 +368,8 @@ void BattlescapeGame::endTurn()
{
getMod()->getSoundByDepth(_save->getDepth(), Mod::SLIDING_DOOR_CLOSE)->play(); // ufo door closed
}

Position p;

// check for hot grenades on the ground
for (int i = 0; i < _save->getMapSizeXYZ(); ++i)
@@ -878,10 +878,10 @@ BattleUnit *BattlescapeGenerator::addXCOMVehicle(Vehicle *v)
RuleItem *ruleItem = _game->getMod()->getItem(*i);
if (ruleItem)
{
BattleItem *item = new BattleItem(ruleItem, _save->getCurrentItemId());
if (!addItem(item, unit))
BattleItem *weapon = new BattleItem(ruleItem, _save->getCurrentItemId());
if (!addItem(weapon, unit))
{
delete item;
delete weapon;
}
}
}
@@ -1587,7 +1587,7 @@ int BattlescapeGenerator::loadMAP(MapBlock *mapblock, int xoff, int yoff, RuleTe

while (mapFile.read((char*)&value, sizeof(value)))
{
for (int part = 0; part < 4; ++part)
for (int part = O_FLOOR; part <= O_OBJECT; ++part)
{
terrainObjectID = ((unsigned char)value[part]);
if (terrainObjectID>0)
@@ -1597,9 +1597,10 @@ int BattlescapeGenerator::loadMAP(MapBlock *mapblock, int xoff, int yoff, RuleTe
MapData *md = terrain->getMapData(&mapDataID, &mapDataSetID);
if (mapDataSetOffset > 0) // ie: ufo or craft.
{
_save->getTile(Position(x, y, z))->setMapData(0, -1, -1, 3);
_save->getTile(Position(x, y, z))->setMapData(0, -1, -1, O_OBJECT);
}
_save->getTile(Position(x, y, z))->setMapData(md, mapDataID, mapDataSetID, part);
TilePart tp = (TilePart) part;
_save->getTile(Position(x, y, z))->setMapData(md, mapDataID, mapDataSetID, tp);
}
}

@@ -2410,8 +2411,8 @@ void BattlescapeGenerator::clearModule(int x, int y, int sizeX, int sizeY)
for (int dy = y; dy != y + sizeY; ++dy)
{
Tile *tile = _save->getTile(Position(dx,dy,z));
for (int i = 0; i < 4; ++i)
tile->setMapData(0, -1, -1, i);
for (int i = O_FLOOR; i <= O_OBJECT; i++)
tile->setMapData(0, -1, -1, (TilePart)i);
}
}
}
@@ -2759,14 +2760,15 @@ void BattlescapeGenerator::drillModules(TunnelData* data, const std::vector<SDL_
{
if (_blocks[i][j] == 0)
continue;
Tile *tile;

MapData *md;

if (dir != MD_VERTICAL)
{
// drill east
if (i < (_mapsize_x / 10)-1 && (_drillMap[i][j] == MD_HORIZONTAL || _drillMap[i][j] == MD_BOTH) && _blocks[i+1][j] != 0)
{
Tile *tile;
// remove stuff
for (int k = rect.y; k != rect.y + rect.h; ++k)
{
@@ -2842,7 +2844,7 @@ void BattlescapeGenerator::drillModules(TunnelData* data, const std::vector<SDL_
if (wWall)
{
md = _terrain->getMapDataSets()->at(wWall->set)->getObjects()->at(wWall->entry);
tile = _save->getTile(Position((i*10)+rect.x, (j*10)+9, data->level));
Tile *tile = _save->getTile(Position((i*10)+rect.x, (j*10)+9, data->level));
tile->setMapData(md, wWall->entry, wWall->set, O_WESTWALL);
tile = _save->getTile(Position((i*10)+rect.x+rect.w, (j*10)+9, data->level));
tile->setMapData(md, wWall->entry, wWall->set, O_WESTWALL);
@@ -2851,7 +2853,7 @@ void BattlescapeGenerator::drillModules(TunnelData* data, const std::vector<SDL_
if (corner)
{
md = _terrain->getMapDataSets()->at(corner->set)->getObjects()->at(corner->entry);
tile = _save->getTile(Position((i*10)+rect.x, (j+1)*10, data->level));
Tile *tile = _save->getTile(Position((i*10)+rect.x, (j+1)*10, data->level));
if (tile->getMapData(O_WESTWALL) == 0)
tile->setMapData(md, corner->entry, corner->set, O_WESTWALL);
}
@@ -2969,9 +2971,10 @@ void BattlescapeGenerator::setupObjectives(AlienDeployment *ruleDeploy)

for (int i = 0; i < _save->getMapSizeXYZ(); ++i)
{
for (int j = 0; j != 4; ++j)
for (int j = O_FLOOR; j <= O_OBJECT; ++j)
{
if (_save->getTiles()[i]->getMapData(j) && _save->getTiles()[i]->getMapData(j)->getSpecialType() == targetType)
TilePart tp = (TilePart)j;
if (_save->getTiles()[i]->getMapData(tp) && _save->getTiles()[i]->getMapData(tp)->getSpecialType() == targetType)
{
actualCount++;
}
@@ -1647,13 +1647,12 @@ void BattlescapeState::saveAIMap()

int w = _save->getMapSizeX();
int h = _save->getMapSizeY();
Position pos(unit->getPosition());

SDL_Surface *img = SDL_AllocSurface(0, w * 8, h * 8, 24, 0xff, 0xff00, 0xff0000, 0);
Log(LOG_INFO) << "unit = " << unit->getId();
memset(img->pixels, 0, img->pitch * img->h);

Position tilePos(pos);
Position tilePos(unit->getPosition());
SDL_Rect r;
r.h = 8;
r.w = 8;
@@ -1784,7 +1783,7 @@ void BattlescapeState::saveVoxelView()
Position targetVoxel,hitPos;
double dist = 0;
bool _debug = _save->getDebugMode();
double dir = ((float)bu->getDirection()+4)/4*M_PI;
double dir = ((double)bu->getDirection()+4)/4*M_PI;
image.clear();
for (int y = -256+32; y < 256+32; ++y)
{
@@ -1860,12 +1859,12 @@ void BattlescapeState::saveVoxelView()
dist*=0.9;
}
if (dist > 1) dist = 1;
if (tile) dist *= (16 - (float)tile->getShade())/16;
if (tile) dist *= (16 - (double)tile->getShade())/16;
}

image.push_back((int)((float)(pal[test*3+0])*dist));
image.push_back((int)((float)(pal[test*3+1])*dist));
image.push_back((int)((float)(pal[test*3+2])*dist));
image.push_back((int)((double)(pal[test*3+0])*dist));
image.push_back((int)((double)(pal[test*3+1])*dist));
image.push_back((int)((double)(pal[test*3+2])*dist));
}
}

@@ -1347,11 +1347,12 @@ void DebriefingState::prepareDebriefing()
for (int i = 0; i < battle->getMapSizeXYZ(); ++i)
{
// get recoverable map data objects from the battlescape map
for (int part = 0; part < 4; ++part)
for (int part = O_FLOOR; part <= O_OBJECT; ++part)
{
if (battle->getTiles()[i]->getMapData(part))
TilePart tp = (TilePart)part;
if (battle->getTiles()[i]->getMapData(tp))
{
int specialType = battle->getTiles()[i]->getMapData(part)->getSpecialType();
int specialType = battle->getTiles()[i]->getMapData(tp)->getSpecialType();
if (specialType != nonRecoverType && _recoveryStats.find(specialType) != _recoveryStats.end())
{
addStat(_recoveryStats[specialType]->name, 1, _recoveryStats[specialType]->value);
@@ -39,7 +39,14 @@ class RuleItem;
class BattleUnit;
struct UnitStats;

struct DebriefingStat { DebriefingStat(const std::string &_item, bool recovery) : item(_item), qty(0), score(0), recovery(recovery) {}; std::string item; int qty; int score; bool recovery; };
struct DebriefingStat {
std::string item;
int qty;
int score;
bool recovery;

DebriefingStat(const std::string &_item, bool _recovery) : item(_item), qty(0), score(0), recovery(_recovery) {};
};

struct ReequipStat { std::string item; int qty; std::wstring craft; };

@@ -629,10 +629,10 @@ void Map::drawTerrain(Surface *surface)
if (westUnit && (!tileWest->getMapData(O_OBJECT) || tileWest->getMapData(O_OBJECT)->getBigWall() < 6 || tileWest->getMapData(O_OBJECT)->getBigWall() == 9) && (westUnit->getVisible() || _save->getDebugMode()))
{
// the part is 0 for small units, large units have parts 1,2 & 3 depending on the relative x/y position of this tile vs the actual unit position.
int part = 0;
part += tileWest->getPosition().x - westUnit->getPosition().x;
part += (tileWest->getPosition().y - westUnit->getPosition().y)*2;
tmpSurface = westUnit->getCache(&invalid, part);
int unitPart = 0;
unitPart += tileWest->getPosition().x - westUnit->getPosition().x;
unitPart += (tileWest->getPosition().y - westUnit->getPosition().y)*2;
tmpSurface = westUnit->getCache(&invalid, unitPart);
if (tmpSurface)
{
Position offset;
@@ -86,9 +86,9 @@ void MiniMapView::draw()
px++;
continue;
}
for (int i = 0; i < 4; i++)
for (int i = O_FLOOR; i <= O_OBJECT; i++)
{
data = t->getMapData(i);
data = t->getMapData((TilePart)i);

if (data && data->getMiniMapIndex())
{
@@ -623,9 +623,9 @@ bool Pathfinding::isBlocked(Tile *tile, const int part, BattleUnit *missileTarge
}
if (part == O_FLOOR)
{
BattleUnit *unit = tile->getUnit();
if (unit != 0)
if (tile->getUnit())
{
BattleUnit *unit = tile->getUnit();
if (unit == _unit || unit == missileTarget || unit->isOut()) return false;
if (missileTarget && unit != missileTarget && unit->getFaction() == FACTION_HOSTILE)
return true; // AI pathfinding with missiles shouldn't path through their own units
@@ -668,13 +668,14 @@ bool Pathfinding::isBlocked(Tile *tile, const int part, BattleUnit *missileTarge
}
}
// missiles can't pathfind through closed doors.
if (missileTarget != 0 && tile->getMapData(part) &&
(tile->getMapData(part)->isDoor() ||
(tile->getMapData(part)->isUFODoor() &&
!tile->isUfoDoorOpen(part))))
{ TilePart tp = (TilePart)part;
if (missileTarget != 0 && tile->getMapData(tp) &&
(tile->getMapData(tp)->isDoor() ||
(tile->getMapData(tp)->isUFODoor() &&
!tile->isUfoDoorOpen(tp))))
{
return true;
}
}}
if (tile->getTUCost(part, _movementType) == 255) return true; // blocking part
return false;
}

0 comments on commit 7478b29

Please sign in to comment.
You can’t perform that action at this time.