refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
parent
e99b526e17
commit
a2b26272d2
338 changed files with 52196 additions and 50944 deletions
|
|
@ -36,10 +36,10 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
return;
|
||||
}
|
||||
|
||||
uint8 random = urand(0, _validPointsVector[_currentPoint].size()-1);
|
||||
uint8 random = urand(0, _validPointsVector[_currentPoint].size() - 1);
|
||||
std::vector<uint8>::iterator randomIter = _validPointsVector[_currentPoint].begin() + random;
|
||||
uint8 newPoint = *randomIter;
|
||||
uint16 pathIdx = uint16(_currentPoint*RANDOM_POINTS_NUMBER + newPoint);
|
||||
uint16 pathIdx = uint16(_currentPoint * RANDOM_POINTS_NUMBER + newPoint);
|
||||
|
||||
// cant go anywhere from new point, so dont go there to not be stuck
|
||||
if (_validPointsVector[newPoint].empty())
|
||||
|
|
@ -62,12 +62,12 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
}
|
||||
|
||||
float ground = INVALID_HEIGHT;
|
||||
float levelZ = map->GetWaterOrGroundLevel(creature->GetPhaseMask(), x, y, z+4.0f, &ground);
|
||||
float levelZ = map->GetWaterOrGroundLevel(creature->GetPhaseMask(), x, y, z + 4.0f, &ground);
|
||||
float newZ = INVALID_HEIGHT;
|
||||
|
||||
// flying creature
|
||||
if (creature->CanFly())
|
||||
newZ = std::max<float>(levelZ, z + rand_norm()*_wanderDistance/2.0f);
|
||||
newZ = std::max<float>(levelZ, z + rand_norm() * _wanderDistance / 2.0f);
|
||||
// point underwater
|
||||
else if (ground < levelZ)
|
||||
{
|
||||
|
|
@ -84,7 +84,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
else
|
||||
{
|
||||
if (levelZ > INVALID_HEIGHT)
|
||||
newZ = std::min<float>(levelZ-2.0f, z + rand_norm()*_wanderDistance/2.0f);
|
||||
newZ = std::min<float>(levelZ - 2.0f, z + rand_norm() * _wanderDistance / 2.0f);
|
||||
newZ = std::max<float>(ground, newZ);
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
{
|
||||
// generated path is too long
|
||||
float pathLen = _pathGenerator->getPathLength();
|
||||
if (pathLen*pathLen > creature->GetExactDistSq(x, y, levelZ) * MAX_PATH_LENGHT_FACTOR*MAX_PATH_LENGHT_FACTOR)
|
||||
if (pathLen * pathLen > creature->GetExactDistSq(x, y, levelZ) * MAX_PATH_LENGHT_FACTOR * MAX_PATH_LENGHT_FACTOR)
|
||||
{
|
||||
_validPointsVector[_currentPoint].erase(randomIter);
|
||||
_preComputedPaths.erase(pathIdx);
|
||||
|
|
@ -128,24 +128,24 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
|
||||
finalPath = _pathGenerator->GetPath();
|
||||
Movement::PointsArray::iterator itr = finalPath.begin();
|
||||
Movement::PointsArray::iterator itrNext = finalPath.begin()+1;
|
||||
Movement::PointsArray::iterator itrNext = finalPath.begin() + 1;
|
||||
float zDiff, distDiff;
|
||||
|
||||
for (; itrNext != finalPath.end(); ++itr, ++itrNext)
|
||||
{
|
||||
distDiff = sqrt(((*itr).x-(*itrNext).x)*((*itr).x-(*itrNext).x) + ((*itr).y-(*itrNext).y)*((*itr).y-(*itrNext).y));
|
||||
distDiff = sqrt(((*itr).x - (*itrNext).x) * ((*itr).x - (*itrNext).x) + ((*itr).y - (*itrNext).y) * ((*itr).y - (*itrNext).y));
|
||||
zDiff = fabs((*itr).z - (*itrNext).z);
|
||||
|
||||
// Xinef: tree climbing, cut as much as we can
|
||||
if (zDiff > 2.0f ||
|
||||
(G3D::fuzzyNe(zDiff, 0.0f) && distDiff / zDiff < 2.15f)) // ~25˚
|
||||
(G3D::fuzzyNe(zDiff, 0.0f) && distDiff / zDiff < 2.15f)) // ~25˚
|
||||
{
|
||||
_validPointsVector[_currentPoint].erase(randomIter);
|
||||
_preComputedPaths.erase(pathIdx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!map->isInLineOfSight((*itr).x, (*itr).y, (*itr).z+2.f, (*itrNext).x, (*itrNext).y, (*itrNext).z+2.f, creature->GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS))
|
||||
if (!map->isInLineOfSight((*itr).x, (*itr).y, (*itr).z + 2.f, (*itrNext).x, (*itrNext).y, (*itrNext).z + 2.f, creature->GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS))
|
||||
{
|
||||
_validPointsVector[_currentPoint].erase(randomIter);
|
||||
_preComputedPaths.erase(pathIdx);
|
||||
|
|
@ -171,7 +171,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||
}
|
||||
|
||||
_currentPoint = newPoint;
|
||||
G3D::Vector3& finalPoint = finalPath[finalPath.size()-1];
|
||||
G3D::Vector3& finalPoint = finalPath[finalPath.size() - 1];
|
||||
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
|
||||
|
||||
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
|
@ -213,9 +213,9 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
|
|||
_destinationPoints.clear();
|
||||
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
|
||||
{
|
||||
float angle = (M_PI*2.0f/(float)RANDOM_POINTS_NUMBER)*i;
|
||||
float factor = 0.5f + rand_norm()*0.5f;
|
||||
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance*cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance*sin(angle)*factor, _initialPosition.GetPositionZ()));
|
||||
float angle = (M_PI * 2.0f / (float)RANDOM_POINTS_NUMBER) * i;
|
||||
float factor = 0.5f + rand_norm() * 0.5f;
|
||||
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance * cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance * sin(angle)*factor, _initialPosition.GetPositionZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ void RandomMovementGenerator<Creature>::DoReset(Creature* creature)
|
|||
template<>
|
||||
void RandomMovementGenerator<Creature>::DoFinalize(Creature* creature)
|
||||
{
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
|
||||
creature->SetWalk(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue