revert most doubles back to float and truncate at 6 decimals
This commit is contained in:
parent
0eeb526e27
commit
9e60723296
|
@ -995,7 +995,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
const Vec2i unitPos = unit->getPos();
|
const Vec2i unitPos = unit->getPos();
|
||||||
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
const Vec2i finalPos= computeNearestFreePos(unit, targetPos);
|
||||||
|
|
||||||
double dist= unitPos.dist(finalPos);
|
float dist= unitPos.dist(finalPos);
|
||||||
factions[unitFactionIndex].useMaxNodeCount = PathFinder::pathFindNodesMax;
|
factions[unitFactionIndex].useMaxNodeCount = PathFinder::pathFindNodesMax;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 4) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
@ -1352,7 +1352,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
//if consumed all nodes find best node (to avoid strange behaviour)
|
//if consumed all nodes find best node (to avoid strange behaviour)
|
||||||
if(nodeLimitReached == true) {
|
if(nodeLimitReached == true) {
|
||||||
if(factions[unitFactionIndex].closedNodesList.size() > 0) {
|
if(factions[unitFactionIndex].closedNodesList.size() > 0) {
|
||||||
double bestHeuristic = factions[unitFactionIndex].closedNodesList.begin()->first;
|
float bestHeuristic = factions[unitFactionIndex].closedNodesList.begin()->first;
|
||||||
if(bestHeuristic < lastNode->heuristic) {
|
if(bestHeuristic < lastNode->heuristic) {
|
||||||
lastNode= factions[unitFactionIndex].closedNodesList.begin()->second[0];
|
lastNode= factions[unitFactionIndex].closedNodesList.begin()->second[0];
|
||||||
}
|
}
|
||||||
|
@ -1520,10 +1520,10 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, double &nearestDist) {
|
void PathFinder::processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, float &nearestDist) {
|
||||||
Vec2i currPos= finalPos + Vec2i(i, j);
|
Vec2i currPos= finalPos + Vec2i(i, j);
|
||||||
if(map->isAproxFreeCells(currPos, size, field, teamIndex)) {
|
if(map->isAproxFreeCells(currPos, size, field, teamIndex)) {
|
||||||
double dist= currPos.dist(finalPos);
|
float dist= currPos.dist(finalPos);
|
||||||
|
|
||||||
//if nearer from finalPos
|
//if nearer from finalPos
|
||||||
if(dist < nearestDist){
|
if(dist < nearestDist){
|
||||||
|
@ -1557,7 +1557,7 @@ Vec2i PathFinder::computeNearestFreePos(const Unit *unit, const Vec2i &finalPos)
|
||||||
//find nearest pos
|
//find nearest pos
|
||||||
Vec2i unitPos= unit->getPosNotThreadSafe();
|
Vec2i unitPos= unit->getPosNotThreadSafe();
|
||||||
Vec2i nearestPos= unitPos;
|
Vec2i nearestPos= unitPos;
|
||||||
double nearestDist= unitPos.dist(finalPos);
|
float nearestDist= unitPos.dist(finalPos);
|
||||||
|
|
||||||
for(int i= -maxFreeSearchRadius; i <= maxFreeSearchRadius; ++i) {
|
for(int i= -maxFreeSearchRadius; i <= maxFreeSearchRadius; ++i) {
|
||||||
for(int j= -maxFreeSearchRadius; j <= maxFreeSearchRadius; ++j) {
|
for(int j= -maxFreeSearchRadius; j <= maxFreeSearchRadius; ++j) {
|
||||||
|
@ -1639,7 +1639,7 @@ void PathFinder::saveGame(XmlNode *rootNode) {
|
||||||
nodePoolNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
|
nodePoolNode->addAttribute("next",intToStr(nextIdx), mapTagReplacements);
|
||||||
int prevIdx = findNodeIndex(curNode->prev, factionState.nodePool);
|
int prevIdx = findNodeIndex(curNode->prev, factionState.nodePool);
|
||||||
nodePoolNode->addAttribute("prev",intToStr(prevIdx), mapTagReplacements);
|
nodePoolNode->addAttribute("prev",intToStr(prevIdx), mapTagReplacements);
|
||||||
nodePoolNode->addAttribute("heuristic",doubleToStr(curNode->heuristic,6), mapTagReplacements);
|
nodePoolNode->addAttribute("heuristic",floatToStr(curNode->heuristic,6), mapTagReplacements);
|
||||||
nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
|
nodePoolNode->addAttribute("exploredCell",intToStr(curNode->exploredCell), mapTagReplacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
Node *next;
|
Node *next;
|
||||||
Node *prev;
|
Node *prev;
|
||||||
double heuristic;
|
float heuristic;
|
||||||
bool exploredCell;
|
bool exploredCell;
|
||||||
};
|
};
|
||||||
typedef vector<Node*> Nodes;
|
typedef vector<Node*> Nodes;
|
||||||
|
@ -119,8 +119,8 @@ public:
|
||||||
//fa = NULL;
|
//fa = NULL;
|
||||||
}
|
}
|
||||||
std::map<Vec2i, bool> openPosList;
|
std::map<Vec2i, bool> openPosList;
|
||||||
std::map<double, Nodes> openNodesList;
|
std::map<float, Nodes> openNodesList;
|
||||||
std::map<double, Nodes> closedNodesList;
|
std::map<float, Nodes> closedNodesList;
|
||||||
std::vector<Node> nodePool;
|
std::vector<Node> nodePool;
|
||||||
int nodePoolCount;
|
int nodePoolCount;
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
|
@ -201,7 +201,7 @@ private:
|
||||||
|
|
||||||
Vec2i computeNearestFreePos(const Unit *unit, const Vec2i &targetPos);
|
Vec2i computeNearestFreePos(const Unit *unit, const Vec2i &targetPos);
|
||||||
//float heuristic(const Vec2i &pos, const Vec2i &finalPos);
|
//float heuristic(const Vec2i &pos, const Vec2i &finalPos);
|
||||||
inline static double heuristic(const Vec2i &pos, const Vec2i &finalPos) {
|
inline static float heuristic(const Vec2i &pos, const Vec2i &finalPos) {
|
||||||
return pos.dist(finalPos);
|
return pos.dist(finalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ private:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, double &nearestDist);
|
void processNearestFreePos(const Vec2i &finalPos, int i, int j, int size, Field field, int teamIndex,Vec2i unitPos, Vec2i &nearestPos, float &nearestDist);
|
||||||
int getPathFindExtendRefreshNodeCount(int factionIndex);
|
int getPathFindExtendRefreshNodeCount(int factionIndex);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2145,14 +2145,14 @@ void Game::update() {
|
||||||
if(currentCameraFollowUnit!=NULL){
|
if(currentCameraFollowUnit!=NULL){
|
||||||
Vec3f c=currentCameraFollowUnit->getCurrVector();
|
Vec3f c=currentCameraFollowUnit->getCurrVector();
|
||||||
int rotation=currentCameraFollowUnit->getRotation();
|
int rotation=currentCameraFollowUnit->getRotation();
|
||||||
double angle=rotation+180;
|
float angle=rotation+180;
|
||||||
|
|
||||||
c.z=c.z+4*std::cos(degToRad(angle));
|
c.z=c.z+4*std::cos(degToRad(angle));
|
||||||
c.x=c.x+4*std::sin(degToRad(angle));
|
c.x=c.x+4*std::sin(degToRad(angle));
|
||||||
|
|
||||||
c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f;
|
c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f;
|
||||||
|
|
||||||
getGameCameraPtr()->setPos(Vec3f(c));
|
getGameCameraPtr()->setPos(c);
|
||||||
|
|
||||||
rotation=(540-rotation)%360;
|
rotation=(540-rotation)%360;
|
||||||
getGameCameraPtr()->rotateToVH(18.0f,rotation);
|
getGameCameraPtr()->rotateToVH(18.0f,rotation);
|
||||||
|
@ -4426,7 +4426,7 @@ void Game::startCameraFollowUnit() {
|
||||||
if(currentUnit != NULL) {
|
if(currentUnit != NULL) {
|
||||||
currentCameraFollowUnit = currentUnit;
|
currentCameraFollowUnit = currentUnit;
|
||||||
getGameCameraPtr()->setState(GameCamera::sUnit);
|
getGameCameraPtr()->setState(GameCamera::sUnit);
|
||||||
getGameCameraPtr()->setPos(Vec3f(currentCameraFollowUnit->getCurrVector()));
|
getGameCameraPtr()->setPos(currentCameraFollowUnit->getCurrVector());
|
||||||
|
|
||||||
int rotation=currentCameraFollowUnit->getRotation();
|
int rotation=currentCameraFollowUnit->getRotation();
|
||||||
getGameCameraPtr()->stop();
|
getGameCameraPtr()->stop();
|
||||||
|
@ -5159,7 +5159,7 @@ string Game::getDebugStats(std::map<int,string> &factionDebugInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//intToStr(stats.getFramesToCalculatePlaytime()/GameConstants::updateFps/60
|
//intToStr(stats.getFramesToCalculatePlaytime()/GameConstants::updateFps/60
|
||||||
str+= "Time: " + doubleToStr(world.getTimeFlow()->getTime(),2) + " [" + doubleToStr((double)world.getStats()->getFramesToCalculatePlaytime() / (double)GameConstants::updateFps / 60.0,2) + "]\n";
|
str+= "Time: " + floatToStr(world.getTimeFlow()->getTime(),2) + " [" + floatToStr((double)world.getStats()->getFramesToCalculatePlaytime() / (float)GameConstants::updateFps / 60.0,2) + "]\n";
|
||||||
|
|
||||||
if(SystemFlags::getThreadedLoggerRunning() == true) {
|
if(SystemFlags::getThreadedLoggerRunning() == true) {
|
||||||
str+= "Log buffer count: " + intToStr(SystemFlags::getLogEntryBufferCount())+"\n";
|
str+= "Log buffer count: " + intToStr(SystemFlags::getLogEntryBufferCount())+"\n";
|
||||||
|
@ -5203,7 +5203,7 @@ string Game::getDebugStats(std::map<int,string> &factionDebugInfo) {
|
||||||
// }
|
// }
|
||||||
str+= "\n";
|
str+= "\n";
|
||||||
|
|
||||||
str+= "Visible quad area: " + doubleToStr(visibleQuad.area()) +"\n";
|
str+= "Visible quad area: " + floatToStr(visibleQuad.area()) +"\n";
|
||||||
// str+= "Visible quad camera area: " + floatToStr(visibleQuadCamera.area()) +"\n";
|
// str+= "Visible quad camera area: " + floatToStr(visibleQuadCamera.area()) +"\n";
|
||||||
|
|
||||||
// Rect2i boundingRect= visibleQuad.computeBoundingRect();
|
// Rect2i boundingRect= visibleQuad.computeBoundingRect();
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ void Renderer::setupLighting() {
|
||||||
unit->getType()->getLight() && unit->isOperative()) {
|
unit->getType()->getLight() && unit->isOperative()) {
|
||||||
//printf("$$$ Show light for faction: %s # %d / %d for Unit [%d - %s]\n",world->getFaction(i)->getType()->getName().c_str(),lightCount,maxLights,unit->getId(),unit->getFullName().c_str());
|
//printf("$$$ Show light for faction: %s # %d / %d for Unit [%d - %s]\n",world->getFaction(i)->getType()->getName().c_str(),lightCount,maxLights,unit->getId(),unit->getFullName().c_str());
|
||||||
|
|
||||||
Vec4f pos= Vec4f(Vec3f(unit->getCurrVector()));
|
Vec4f pos= Vec4f(unit->getCurrVector());
|
||||||
pos.y+=4.f;
|
pos.y+=4.f;
|
||||||
|
|
||||||
GLenum lightEnum= GL_LIGHT0 + lightCount;
|
GLenum lightEnum= GL_LIGHT0 + lightCount;
|
||||||
|
@ -4584,7 +4584,7 @@ void Renderer::renderObjects(const int renderFps) {
|
||||||
|
|
||||||
Model *objModel= o->getModelPtr();
|
Model *objModel= o->getModelPtr();
|
||||||
//objModel->updateInterpolationData(o->getAnimProgress(), true);
|
//objModel->updateInterpolationData(o->getAnimProgress(), true);
|
||||||
const Vec3f v= Vec3f(o->getConstPos());
|
const Vec3f v= o->getConstPos();
|
||||||
|
|
||||||
if(modelRenderStarted == false) {
|
if(modelRenderStarted == false) {
|
||||||
modelRenderStarted = true;
|
modelRenderStarted = true;
|
||||||
|
@ -4826,7 +4826,7 @@ void Renderer::renderTeamColorCircle(){
|
||||||
for(int visibleUnitIndex = 0;
|
for(int visibleUnitIndex = 0;
|
||||||
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
||||||
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
|
Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
|
||||||
glColor4f(color.x, color.y, color.z, 0.7f);
|
glColor4f(color.x, color.y, color.z, 0.7f);
|
||||||
renderSelectionCircle(currVec, unit->getType()->getSize(), 0.8f, 0.05f);
|
renderSelectionCircle(currVec, unit->getType()->getSize(), 0.8f, 0.05f);
|
||||||
|
@ -4881,7 +4881,7 @@ void Renderer::renderSpecialHighlightUnits(std::map<int,HighlightSpecialUnitInfo
|
||||||
|
|
||||||
glColor4f(color.x, color.y, color.z, alpha);
|
glColor4f(color.x, color.y, color.z, alpha);
|
||||||
|
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
renderSelectionCircle(currVec, unit->getType()->getSize(), radius, thickness);
|
renderSelectionCircle(currVec, unit->getType()->getSize(), radius, thickness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4905,7 +4905,7 @@ void Renderer::renderTeamColorPlane(){
|
||||||
for(int visibleUnitIndex = 0;
|
for(int visibleUnitIndex = 0;
|
||||||
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex){
|
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex){
|
||||||
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
renderTeamColorEffect(currVec,visibleUnitIndex,unit->getType()->getSize(),
|
renderTeamColorEffect(currVec,visibleUnitIndex,unit->getType()->getSize(),
|
||||||
unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0),texture);
|
unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0),texture);
|
||||||
}
|
}
|
||||||
|
@ -5022,7 +5022,7 @@ void Renderer::renderUnits(const int renderFps) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
//translate
|
//translate
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
glTranslatef(currVec.x, currVec.y, currVec.z);
|
glTranslatef(currVec.x, currVec.y, currVec.z);
|
||||||
|
|
||||||
//rotate
|
//rotate
|
||||||
|
@ -5193,7 +5193,7 @@ void Renderer::renderMorphEffects(){
|
||||||
initialized=true;
|
initialized=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
currVec=Vec3f(currVec.x,currVec.y+0.3f,currVec.z);
|
currVec=Vec3f(currVec.x,currVec.y+0.3f,currVec.z);
|
||||||
if(mType->getField() == fAir && unit->getType()->getField()== fLand) {
|
if(mType->getField() == fAir && unit->getType()->getField()== fLand) {
|
||||||
currVec=Vec3f(currVec.x,currVec.y+game->getWorld()->getTileset()->getAirHeight(),currVec.z);
|
currVec=Vec3f(currVec.x,currVec.y+game->getWorld()->getTileset()->getAirHeight(),currVec.z);
|
||||||
|
@ -5247,7 +5247,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
const Unit *unit= selection->getUnit(i);
|
const Unit *unit= selection->getUnit(i);
|
||||||
if(unit != NULL) {
|
if(unit != NULL) {
|
||||||
//translate
|
//translate
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
currVec.y+= 0.3f;
|
currVec.y+= 0.3f;
|
||||||
|
|
||||||
//selection circle
|
//selection circle
|
||||||
|
@ -5283,7 +5283,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
lastPosValue = curPosValue;
|
lastPosValue = curPosValue;
|
||||||
}
|
}
|
||||||
Vec3f currVec2 = Vec3f(unit->getVectorFlat(lastPosValue,curPosValue));
|
Vec3f currVec2 = unit->getVectorFlat(lastPosValue,curPosValue);
|
||||||
currVec2.y+= 0.3f;
|
currVec2.y+= 0.3f;
|
||||||
renderSelectionCircle(currVec2, 1, selectionCircleRadius);
|
renderSelectionCircle(currVec2, 1, selectionCircleRadius);
|
||||||
//renderSelectionCircle(currVec2, unit->getType()->getSize(), selectionCircleRadius);
|
//renderSelectionCircle(currVec2, unit->getType()->getSize(), selectionCircleRadius);
|
||||||
|
@ -5315,7 +5315,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
int findUnitId = effect.currentAttackBoostUnits[i];
|
int findUnitId = effect.currentAttackBoostUnits[i];
|
||||||
Unit *affectedUnit = game->getWorld()->findUnitById(findUnitId);
|
Unit *affectedUnit = game->getWorld()->findUnitById(findUnitId);
|
||||||
if(affectedUnit != NULL) {
|
if(affectedUnit != NULL) {
|
||||||
Vec3f currVecBoost = Vec3f(affectedUnit->getCurrVectorFlat());
|
Vec3f currVecBoost = affectedUnit->getCurrVectorFlat();
|
||||||
currVecBoost.y += 0.3f;
|
currVecBoost.y += 0.3f;
|
||||||
|
|
||||||
renderSelectionCircle(currVecBoost, affectedUnit->getType()->getSize(), 1.f);
|
renderSelectionCircle(currVecBoost, affectedUnit->getType()->getSize(), 1.f);
|
||||||
|
@ -5331,7 +5331,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
int defaultValue= r->getType()->getDefResPerPatch();
|
int defaultValue= r->getType()->getDefResPerPatch();
|
||||||
float colorValue=static_cast<float>(r->getAmount())/static_cast<float>(defaultValue);
|
float colorValue=static_cast<float>(r->getAmount())/static_cast<float>(defaultValue);
|
||||||
glColor4f(0.1f, 0.1f , colorValue, 0.4f);
|
glColor4f(0.1f, 0.1f , colorValue, 0.4f);
|
||||||
renderSelectionCircle(Vec3f(selectedResourceObject->getPos()),2, selectionCircleRadius);
|
renderSelectionCircle(selectedResourceObject->getPos(),2, selectionCircleRadius);
|
||||||
}
|
}
|
||||||
//target arrow
|
//target arrow
|
||||||
if(selection->getCount() == 1) {
|
if(selection->getCount() == 1) {
|
||||||
|
@ -5361,7 +5361,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
Vec3f arrowTarget;
|
Vec3f arrowTarget;
|
||||||
Command *c= unit->getCurrCommand();
|
Command *c= unit->getCurrCommand();
|
||||||
if(c->getUnit() != NULL) {
|
if(c->getUnit() != NULL) {
|
||||||
arrowTarget= Vec3f(c->getUnit()->getCurrVectorFlat());
|
arrowTarget= c->getUnit()->getCurrVectorFlat();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Vec2i pos= c->getPos();
|
Vec2i pos= c->getPos();
|
||||||
|
@ -5370,7 +5370,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderArrow(Vec3f(unit->getCurrVectorFlat()), arrowTarget, arrowColor, 0.3f);
|
renderArrow(unit->getCurrVectorFlat(), arrowTarget, arrowColor, 0.3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5380,7 +5380,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
map->clampPos(pos);
|
map->clampPos(pos);
|
||||||
|
|
||||||
Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||||
renderArrow(Vec3f(unit->getCurrVectorFlat()), arrowTarget, Vec3f(0.f, 0.f, 1.f), 0.3f);
|
renderArrow(unit->getCurrVectorFlat(), arrowTarget, Vec3f(0.f, 0.f, 1.f), 0.3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5398,7 +5398,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
glColor4f(1.f, 0.f, 0.f, highlight);
|
glColor4f(1.f, 0.f, 0.f, highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3f v= Vec3f(unit->getCurrVectorFlat());
|
Vec3f v= unit->getCurrVectorFlat();
|
||||||
v.y+= 0.3f;
|
v.y+= 0.3f;
|
||||||
renderSelectionCircle(v, unit->getType()->getSize(), 0.5f+0.4f*highlight );
|
renderSelectionCircle(v, unit->getType()->getSize(), 0.5f+0.4f*highlight );
|
||||||
}
|
}
|
||||||
|
@ -5429,7 +5429,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
if(object->isHighlighted()) {
|
if(object->isHighlighted()) {
|
||||||
float highlight= object->getHightlight();
|
float highlight= object->getHightlight();
|
||||||
glColor4f(0.1f, 0.1f , 1.0f, highlight);
|
glColor4f(0.1f, 0.1f , 1.0f, highlight);
|
||||||
Vec3f v= Vec3f(object->getPos());
|
Vec3f v= object->getPos();
|
||||||
v.y+= 0.3f;
|
v.y+= 0.3f;
|
||||||
renderSelectionCircle(v, 2, 0.4f+0.4f*highlight );
|
renderSelectionCircle(v, 2, 0.4f+0.4f*highlight );
|
||||||
}
|
}
|
||||||
|
@ -7434,7 +7434,7 @@ vector<Unit *> Renderer::renderUnitsFast(bool renderingShadows, bool colorPickin
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
//translate
|
//translate
|
||||||
Vec3f currVec= Vec3f(unit->getCurrVectorFlat());
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
glTranslatef(currVec.x, currVec.y, currVec.z);
|
glTranslatef(currVec.x, currVec.y, currVec.z);
|
||||||
|
|
||||||
//rotate
|
//rotate
|
||||||
|
@ -7537,7 +7537,7 @@ vector<Object *> Renderer::renderObjectsFast(bool renderingShadows, bool resour
|
||||||
//objModel->updateInterpolationData(o->getAnimProgress(), true);
|
//objModel->updateInterpolationData(o->getAnimProgress(), true);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
const Vec3f v= Vec3f(o->getConstPos());
|
const Vec3f v= o->getConstPos();
|
||||||
|
|
||||||
if(colorPickingSelection == false) {
|
if(colorPickingSelection == false) {
|
||||||
glPushName(OBJECT_SELECT_OFFSET+visibleIndex);
|
glPushName(OBJECT_SELECT_OFFSET+visibleIndex);
|
||||||
|
|
|
@ -305,7 +305,7 @@ void Gui::mouseUpLeftGraphics(int x, int y) {
|
||||||
if(selection.isCommandable() && random.randRange(0, 1)==0){
|
if(selection.isCommandable() && random.randRange(0, 1)==0){
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
selection.getFrontUnit()->getType()->getSelectionSound(),
|
selection.getFrontUnit()->getType()->getSelectionSound(),
|
||||||
Vec3f(selection.getFrontUnit()->getCurrVector()),
|
selection.getFrontUnit()->getCurrVector(),
|
||||||
gameCamera->getPos());
|
gameCamera->getPos());
|
||||||
}
|
}
|
||||||
selectionQuad.disable();
|
selectionQuad.disable();
|
||||||
|
@ -477,7 +477,7 @@ void Gui::giveDefaultOrders(int x, int y,const Unit *targetUnit, bool paintMouse
|
||||||
if(random.randRange(0, 1)==0){
|
if(random.randRange(0, 1)==0){
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
selection.getFrontUnit()->getType()->getCommandSound(),
|
selection.getFrontUnit()->getType()->getCommandSound(),
|
||||||
Vec3f(selection.getFrontUnit()->getCurrVector()),
|
selection.getFrontUnit()->getCurrVector(),
|
||||||
gameCamera->getPos());
|
gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ void Gui::giveTwoClickOrders(int x, int y , bool prepared) {
|
||||||
if(random.randRange(0, 1) == 0) {
|
if(random.randRange(0, 1) == 0) {
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
selection.getFrontUnit()->getType()->getCommandSound(),
|
selection.getFrontUnit()->getType()->getCommandSound(),
|
||||||
Vec3f(selection.getFrontUnit()->getCurrVector()),
|
selection.getFrontUnit()->getCurrVector(),
|
||||||
gameCamera->getPos());
|
gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ bool CommandGroupUnitSorter::compare(const Unit *l, const Unit *r) {
|
||||||
result = curCommandGroupId < commandPeer->getUnitCommandGroupId();
|
result = curCommandGroupId < commandPeer->getUnitCommandGroupId();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double unitDist = l->getCenteredPos().dist(command->getPos());
|
float unitDist = l->getCenteredPos().dist(command->getPos());
|
||||||
double unitDistPeer = r->getCenteredPos().dist(commandPeer->getPos());
|
float unitDistPeer = r->getCenteredPos().dist(commandPeer->getPos());
|
||||||
|
|
||||||
// Closest unit in commandgroup
|
// Closest unit in commandgroup
|
||||||
result = (unitDist < unitDistPeer);
|
result = (unitDist < unitDistPeer);
|
||||||
|
|
|
@ -388,7 +388,7 @@ void UnitAttackBoostEffectOriginator::saveGame(XmlNode *rootNode) {
|
||||||
// class Unit
|
// class Unit
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
const double Unit::ANIMATION_SPEED_MULTIPLIER = 100000.f;
|
const float Unit::ANIMATION_SPEED_MULTIPLIER = 100000.f;
|
||||||
//const float Unit::PROGRESS_SPEED_MULTIPLIER = 100000.f;
|
//const float Unit::PROGRESS_SPEED_MULTIPLIER = 100000.f;
|
||||||
const int64 Unit::PROGRESS_SPEED_MULTIPLIER = 100000;
|
const int64 Unit::PROGRESS_SPEED_MULTIPLIER = 100000;
|
||||||
|
|
||||||
|
@ -726,14 +726,14 @@ Vec2i Unit::getCellPos() const {
|
||||||
|
|
||||||
//find nearest pos to center that is free
|
//find nearest pos to center that is free
|
||||||
Vec2i centeredPos= getCenteredPos();
|
Vec2i centeredPos= getCenteredPos();
|
||||||
double nearestDist= -1.f;
|
float nearestDist= -1.f;
|
||||||
Vec2i nearestPos= pos;
|
Vec2i nearestPos= pos;
|
||||||
|
|
||||||
for(int i=0; i<type->getSize(); ++i){
|
for(int i=0; i<type->getSize(); ++i){
|
||||||
for(int j=0; j<type->getSize(); ++j){
|
for(int j=0; j<type->getSize(); ++j){
|
||||||
if(type->getCellMapCell(i, j, modelFacing)){
|
if(type->getCellMapCell(i, j, modelFacing)){
|
||||||
Vec2i currPos= pos + Vec2i(i, j);
|
Vec2i currPos= pos + Vec2i(i, j);
|
||||||
double dist= currPos.dist(centeredPos);
|
float dist= currPos.dist(centeredPos);
|
||||||
if(nearestDist == -1.f || dist < nearestDist) {
|
if(nearestDist == -1.f || dist < nearestDist) {
|
||||||
nearestDist= dist;
|
nearestDist= dist;
|
||||||
nearestPos= currPos;
|
nearestPos= currPos;
|
||||||
|
@ -836,7 +836,7 @@ int Unit::getProductionPercent() const{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Unit::getProgressRatio() const{
|
float Unit::getProgressRatio() const{
|
||||||
if(anyCommand()){
|
if(anyCommand()){
|
||||||
const ProducibleType *produced= commands.front()->getCommandType()->getProduced();
|
const ProducibleType *produced= commands.front()->getCommandType()->getProduced();
|
||||||
if(produced != NULL){
|
if(produced != NULL){
|
||||||
|
@ -844,28 +844,28 @@ double Unit::getProgressRatio() const{
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
double help = progress2;
|
float help = progress2;
|
||||||
return clamp(help / produced->getProductionTime(), 0.f, 1.f);
|
return clamp(help / produced->getProductionTime(), 0.f, 1.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Unit::getHpRatio() const {
|
float Unit::getHpRatio() const {
|
||||||
if(type == NULL) {
|
if(type == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str());
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str());
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
double maxHpAllowed = type->getTotalMaxHp(&totalUpgrade);
|
float maxHpAllowed = type->getTotalMaxHp(&totalUpgrade);
|
||||||
if(maxHpAllowed == 0.f) {
|
if(maxHpAllowed == 0.f) {
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
return clamp(static_cast<double>(hp) / maxHpAllowed, 0.f, 1.f);
|
return clamp(static_cast<float>(hp) / maxHpAllowed, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Unit::getEpRatio() const {
|
float Unit::getEpRatio() const {
|
||||||
if(type == NULL) {
|
if(type == NULL) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str());
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str());
|
||||||
|
@ -876,11 +876,11 @@ double Unit::getEpRatio() const {
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double maxEpAllowed = type->getTotalMaxEp(&totalUpgrade);
|
float maxEpAllowed = type->getTotalMaxEp(&totalUpgrade);
|
||||||
if(maxEpAllowed == 0.f) {
|
if(maxEpAllowed == 0.f) {
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
return clamp(static_cast<double>(ep) / maxEpAllowed, 0.f, 1.f);
|
return clamp(static_cast<float>(ep) / maxEpAllowed, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const {
|
||||||
Vec2i surfPos= Map::toSurfCoords(sightpos);
|
Vec2i surfPos= Map::toSurfCoords(sightpos);
|
||||||
|
|
||||||
//compute max alpha
|
//compute max alpha
|
||||||
double maxAlpha= 0.0f;
|
float maxAlpha= 0.0f;
|
||||||
if(surfPos.x > 1 && surfPos.y > 1 && surfPos.x < map->getSurfaceW() -2 && surfPos.y < map->getSurfaceH() -2) {
|
if(surfPos.x > 1 && surfPos.y > 1 && surfPos.x < map->getSurfaceW() -2 && surfPos.y < map->getSurfaceH() -2) {
|
||||||
maxAlpha= 1.f;
|
maxAlpha= 1.f;
|
||||||
}
|
}
|
||||||
|
@ -1234,8 +1234,8 @@ FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
//compute alpha
|
//compute alpha
|
||||||
double alpha = maxAlpha;
|
float alpha = maxAlpha;
|
||||||
double dist = this->getPosNotThreadSafe().dist(sightpos);
|
float dist = this->getPosNotThreadSafe().dist(sightpos);
|
||||||
if(dist > sightRange) {
|
if(dist > sightRange) {
|
||||||
alpha= clamp(1.f-(dist - sightRange) / (World::indirectSightRange), 0.f, maxAlpha);
|
alpha= clamp(1.f-(dist - sightRange) / (World::indirectSightRange), 0.f, maxAlpha);
|
||||||
}
|
}
|
||||||
|
@ -1424,9 +1424,9 @@ Vec3f Unit::getCurrVectorFlat() const{
|
||||||
return getVectorFlat(lastPos, pos);
|
return getVectorFlat(lastPos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Unit::getProgressAsFloat() const {
|
float Unit::getProgressAsFloat() const {
|
||||||
double result = (static_cast<double>(progress) / static_cast<double>(PROGRESS_SPEED_MULTIPLIER));
|
float result = (static_cast<float>(progress) / static_cast<float>(PROGRESS_SPEED_MULTIPLIER));
|
||||||
result = truncateDecimal<double>(result,6);
|
result = truncateDecimal<float>(result,6);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2023,8 +2023,8 @@ int64 Unit::getHeightFactor(int64 speedMultiplier) {
|
||||||
throw megaglest_runtime_error("targetCell == NULL");
|
throw megaglest_runtime_error("targetCell == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 heightDiff= ((truncateDecimal<double>(unitCell->getHeight(),2) * speedMultiplier) -
|
int64 heightDiff= ((truncateDecimal<float>(unitCell->getHeight(),2) * speedMultiplier) -
|
||||||
(truncateDecimal<double>(targetCell->getHeight(),2) * speedMultiplier));
|
(truncateDecimal<float>(targetCell->getHeight(),2) * speedMultiplier));
|
||||||
//heightFactor= clamp(speedMultiplier + heightDiff / (5.f * speedMultiplier), 0.2f * speedMultiplier, 5.f * speedMultiplier);
|
//heightFactor= clamp(speedMultiplier + heightDiff / (5.f * speedMultiplier), 0.2f * speedMultiplier, 5.f * speedMultiplier);
|
||||||
heightFactor= clamp(speedMultiplier + heightDiff / (5 * speedMultiplier), (2 * (speedMultiplier / 10)), 5 * speedMultiplier);
|
heightFactor= clamp(speedMultiplier + heightDiff / (5 * speedMultiplier), (2 * (speedMultiplier / 10)), 5 * speedMultiplier);
|
||||||
}
|
}
|
||||||
|
@ -2328,7 +2328,7 @@ bool Unit::update() {
|
||||||
//printf("Test progress = %d for unit [%d - %s]\n",progress,id,getType()->getName().c_str());
|
//printf("Test progress = %d for unit [%d - %s]\n",progress,id,getType()->getName().c_str());
|
||||||
|
|
||||||
if(isAnimProgressBound() == true) {
|
if(isAnimProgressBound() == true) {
|
||||||
double targetProgress=0;
|
float targetProgress=0;
|
||||||
if(currSkill->getClass() == scBeBuilt) {
|
if(currSkill->getClass() == scBeBuilt) {
|
||||||
targetProgress = this->getHpRatio();
|
targetProgress = this->getHpRatio();
|
||||||
}
|
}
|
||||||
|
@ -2342,10 +2342,10 @@ bool Unit::update() {
|
||||||
targetProgress = this->getProgressRatio();
|
targetProgress = this->getProgressRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
double targetProgressIntValue = targetProgress * ANIMATION_SPEED_MULTIPLIER;
|
float targetProgressIntValue = targetProgress * ANIMATION_SPEED_MULTIPLIER;
|
||||||
if(this->animProgress < targetProgressIntValue) {
|
if(this->animProgress < targetProgressIntValue) {
|
||||||
double diff = targetProgressIntValue - this->animProgress;
|
float diff = targetProgressIntValue - this->animProgress;
|
||||||
double progressIncrease = static_cast<double>(this->animProgress) + diff / static_cast<double>(GameConstants::updateFps);
|
float progressIncrease = static_cast<float>(this->animProgress) + diff / static_cast<float>(GameConstants::updateFps);
|
||||||
// Ensure we increment at least a value of 1 of the action will be stuck infinitely
|
// Ensure we increment at least a value of 1 of the action will be stuck infinitely
|
||||||
if(diff > 0.f && GameConstants::updateFps > 0 && progressIncrease == 0.f) {
|
if(diff > 0.f && GameConstants::updateFps > 0 && progressIncrease == 0.f) {
|
||||||
progressIncrease = 1.f;
|
progressIncrease = 1.f;
|
||||||
|
|
|
@ -330,7 +330,7 @@ private:
|
||||||
static std::map<Unit *,bool> mapMemoryList;
|
static std::map<Unit *,bool> mapMemoryList;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const double ANIMATION_SPEED_MULTIPLIER;
|
static const float ANIMATION_SPEED_MULTIPLIER;
|
||||||
static const int64 PROGRESS_SPEED_MULTIPLIER;
|
static const int64 PROGRESS_SPEED_MULTIPLIER;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -517,8 +517,8 @@ public:
|
||||||
|
|
||||||
//inline int getLastAnimProgress() const {return lastAnimProgress;}
|
//inline int getLastAnimProgress() const {return lastAnimProgress;}
|
||||||
//inline int getAnimProgress() const {return animProgress;}
|
//inline int getAnimProgress() const {return animProgress;}
|
||||||
inline double getLastAnimProgressAsFloat() const {return static_cast<double>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
inline float getLastAnimProgressAsFloat() const {return static_cast<float>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
||||||
inline double getAnimProgressAsFloat() const {return static_cast<double>(animProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
inline float getAnimProgressAsFloat() const {return static_cast<float>(animProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
||||||
|
|
||||||
inline float getHightlight() const {return highlight;}
|
inline float getHightlight() const {return highlight;}
|
||||||
inline int getProgress2() const {return progress2;}
|
inline int getProgress2() const {return progress2;}
|
||||||
|
@ -531,9 +531,9 @@ public:
|
||||||
inline int getHp() const {return hp;}
|
inline int getHp() const {return hp;}
|
||||||
inline int getEp() const {return ep;}
|
inline int getEp() const {return ep;}
|
||||||
int getProductionPercent() const;
|
int getProductionPercent() const;
|
||||||
double getProgressRatio() const;
|
float getProgressRatio() const;
|
||||||
double getHpRatio() const;
|
float getHpRatio() const;
|
||||||
double getEpRatio() const;
|
float getEpRatio() const;
|
||||||
inline bool getToBeUndertaken() const {return toBeUndertaken;}
|
inline bool getToBeUndertaken() const {return toBeUndertaken;}
|
||||||
inline Vec2i getTargetPos() const {return targetPos;}
|
inline Vec2i getTargetPos() const {return targetPos;}
|
||||||
inline Vec3f getTargetVec() const {return targetVec;}
|
inline Vec3f getTargetVec() const {return targetVec;}
|
||||||
|
@ -742,7 +742,7 @@ public:
|
||||||
|
|
||||||
std::string toString(bool crcMode=false) const;
|
std::string toString(bool crcMode=false) const;
|
||||||
bool needToUpdate();
|
bool needToUpdate();
|
||||||
double getProgressAsFloat() const;
|
float getProgressAsFloat() const;
|
||||||
int64 getUpdateProgress();
|
int64 getUpdateProgress();
|
||||||
int64 getDiagonalFactor();
|
int64 getDiagonalFactor();
|
||||||
int64 getHeightFactor(int64 speedMultiplier=PROGRESS_SPEED_MULTIPLIER);
|
int64 getHeightFactor(int64 speedMultiplier=PROGRESS_SPEED_MULTIPLIER);
|
||||||
|
|
|
@ -140,7 +140,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(destUnitMightApply == true) {
|
if(destUnitMightApply == true) {
|
||||||
double distance = source->getCenteredPos().dist(dest->getCenteredPos());
|
float distance = source->getCenteredPos().dist(dest->getCenteredPos());
|
||||||
if(distance <= radius) {
|
if(distance <= radius) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ const AnimationAttributes SkillType::getAnimationAttribute(int index) const {
|
||||||
return animationAttributes[index];
|
return animationAttributes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Model *SkillType::getAnimation(double animProgress, const Unit *unit,
|
Model *SkillType::getAnimation(float animProgress, const Unit *unit,
|
||||||
int *lastAnimationIndex, int *animationRandomCycleCount) const {
|
int *lastAnimationIndex, int *animationRandomCycleCount) const {
|
||||||
int modelIndex = 0;
|
int modelIndex = 0;
|
||||||
//printf("Count [%d] animProgress = [%f] for skill [%s] animationRandomCycleCount = %d\n",animations.size(),animProgress,name.c_str(),*animationRandomCycleCount);
|
//printf("Count [%d] animProgress = [%f] for skill [%s] animationRandomCycleCount = %d\n",animations.size(),animProgress,name.c_str(),*animationRandomCycleCount);
|
||||||
|
|
|
@ -175,7 +175,7 @@ public:
|
||||||
int getHpCost() const {return hpCost;}
|
int getHpCost() const {return hpCost;}
|
||||||
int getSpeed() const {return speed;}
|
int getSpeed() const {return speed;}
|
||||||
int getAnimSpeed() const {return animSpeed;}
|
int getAnimSpeed() const {return animSpeed;}
|
||||||
Model *getAnimation(double animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const;
|
Model *getAnimation(float animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const;
|
||||||
StaticSound *getSound() const {return sounds.getRandSound();}
|
StaticSound *getSound() const {return sounds.getRandSound();}
|
||||||
float getSoundStartTime() const {return soundStartTime;}
|
float getSoundStartTime() const {return soundStartTime;}
|
||||||
|
|
||||||
|
|
|
@ -529,8 +529,8 @@ void Map::init(Tileset *tileset) {
|
||||||
|
|
||||||
class FindBestPos {
|
class FindBestPos {
|
||||||
public:
|
public:
|
||||||
double distanceFromUnitNoAdjustment;
|
float distanceFromUnitNoAdjustment;
|
||||||
double distanceFromClickNoAdjustment;
|
float distanceFromClickNoAdjustment;
|
||||||
Vec2i resourcePosNoAdjustment;
|
Vec2i resourcePosNoAdjustment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -540,8 +540,8 @@ bool Map::isResourceNear(int frameIndex,const Vec2i &pos, const ResourceType *rt
|
||||||
Vec2i *resourceClickPos) const {
|
Vec2i *resourceClickPos) const {
|
||||||
|
|
||||||
bool resourceNear = false;
|
bool resourceNear = false;
|
||||||
double distanceFromUnit=-1;
|
float distanceFromUnit=-1;
|
||||||
double distanceFromClick=-1;
|
float distanceFromClick=-1;
|
||||||
|
|
||||||
if(resourceClickPos) {
|
if(resourceClickPos) {
|
||||||
//printf("+++++++++ unit [%s - %d] pos = [%s] resourceClickPos [%s]\n",unit->getFullName().c_str(),unit->getId(),pos.getString().c_str(),resourceClickPos->getString().c_str());
|
//printf("+++++++++ unit [%s - %d] pos = [%s] resourceClickPos [%s]\n",unit->getFullName().c_str(),unit->getId(),pos.getString().c_str(),resourceClickPos->getString().c_str());
|
||||||
|
@ -694,7 +694,7 @@ bool Map::isResourceNear(int frameIndex,const Vec2i &pos, const ResourceType *rt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double bestUnitDist = distanceFromUnit;
|
float bestUnitDist = distanceFromUnit;
|
||||||
for(unsigned int i = 0; i < bestPosList.size(); ++i) {
|
for(unsigned int i = 0; i < bestPosList.size(); ++i) {
|
||||||
FindBestPos &bestPosItem = bestPosList[i];
|
FindBestPos &bestPosItem = bestPosList[i];
|
||||||
|
|
||||||
|
@ -1115,12 +1115,12 @@ Vec2i Map::computeDestPos( const Vec2i &refUnitPos, const Vec2i &unitPos,
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<double,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) {
|
std::pair<float,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) {
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
throw megaglest_runtime_error("unit == NULL");
|
throw megaglest_runtime_error("unit == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<double,Vec2i> result(-1,Vec2i(0));
|
std::pair<float,Vec2i> result(-1,Vec2i(0));
|
||||||
//int unitId= unit->getId();
|
//int unitId= unit->getId();
|
||||||
Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos);
|
Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos);
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ std::pair<double,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,con
|
||||||
Vec2i testPos(i,j);
|
Vec2i testPos(i,j);
|
||||||
|
|
||||||
if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) {
|
if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) {
|
||||||
double distance = unitPos.dist(testPos);
|
float distance = unitPos.dist(testPos);
|
||||||
if(result.first < 0 || result.first > distance) {
|
if(result.first < 0 || result.first > distance) {
|
||||||
result.first = distance;
|
result.first = distance;
|
||||||
result.second = testPos;
|
result.second = testPos;
|
||||||
|
@ -1155,7 +1155,7 @@ const Unit * Map::findClosestUnitToPos(const Selection *selection, Vec2i origina
|
||||||
|
|
||||||
Vec2i pos = originalBuildPos;
|
Vec2i pos = originalBuildPos;
|
||||||
|
|
||||||
double bestRange = -1;
|
float bestRange = -1;
|
||||||
|
|
||||||
Vec2i start = pos - Vec2i(1);
|
Vec2i start = pos - Vec2i(1);
|
||||||
int unitTypeSize = 0;
|
int unitTypeSize = 0;
|
||||||
|
@ -1173,7 +1173,7 @@ const Unit * Map::findClosestUnitToPos(const Selection *selection, Vec2i origina
|
||||||
for(int j = start.y; j <= end.y; ++j){
|
for(int j = start.y; j <= end.y; ++j){
|
||||||
Vec2i testPos(i,j);
|
Vec2i testPos(i,j);
|
||||||
if(isInUnitTypeCells(ut, originalBuildPos,testPos) == false) {
|
if(isInUnitTypeCells(ut, originalBuildPos,testPos) == false) {
|
||||||
double distance = unitBuilderPos.dist(testPos);
|
float distance = unitBuilderPos.dist(testPos);
|
||||||
if(bestRange < 0 || bestRange > distance) {
|
if(bestRange < 0 || bestRange > distance) {
|
||||||
bestRange = distance;
|
bestRange = distance;
|
||||||
pos = testPos;
|
pos = testPos;
|
||||||
|
@ -1198,7 +1198,7 @@ Vec2i Map::findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const
|
||||||
Vec2i unitBuilderPos = unit->getPosNotThreadSafe();
|
Vec2i unitBuilderPos = unit->getPosNotThreadSafe();
|
||||||
Vec2i pos = originalBuildPos;
|
Vec2i pos = originalBuildPos;
|
||||||
|
|
||||||
double bestRange = -1;
|
float bestRange = -1;
|
||||||
|
|
||||||
Vec2i start = pos - Vec2i(unit->getType()->getSize());
|
Vec2i start = pos - Vec2i(unit->getType()->getSize());
|
||||||
Vec2i end = pos + Vec2i(ut->getSize());
|
Vec2i end = pos + Vec2i(ut->getSize());
|
||||||
|
@ -1207,7 +1207,7 @@ Vec2i Map::findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const
|
||||||
for(int j = start.y; j <= end.y; ++j) {
|
for(int j = start.y; j <= end.y; ++j) {
|
||||||
Vec2i testPos(i,j);
|
Vec2i testPos(i,j);
|
||||||
if(isInUnitTypeCells(ut, originalBuildPos,testPos) == false) {
|
if(isInUnitTypeCells(ut, originalBuildPos,testPos) == false) {
|
||||||
double distance = unitBuilderPos.dist(testPos);
|
float distance = unitBuilderPos.dist(testPos);
|
||||||
if(bestRange < 0 || bestRange > distance) {
|
if(bestRange < 0 || bestRange > distance) {
|
||||||
// Check if the cell is occupied by another unit
|
// Check if the cell is occupied by another unit
|
||||||
if(isFreeCellOrHasUnit(testPos, unit->getType()->getField(), unit) == true) {
|
if(isFreeCellOrHasUnit(testPos, unit->getType()->getField(), unit) == true) {
|
||||||
|
|
|
@ -346,7 +346,7 @@ public:
|
||||||
bool isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
bool isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
||||||
bool isNextToUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
bool isNextToUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
||||||
Vec2i findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const UnitType *ut) const;
|
Vec2i findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const UnitType *ut) const;
|
||||||
std::pair<double,Vec2i> getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut);
|
std::pair<float,Vec2i> getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
bool isNextTo(const Vec2i &pos, const Unit *unit) const;
|
bool isNextTo(const Vec2i &pos, const Unit *unit) const;
|
||||||
|
|
|
@ -123,7 +123,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) {
|
if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) {
|
||||||
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
|
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) ||
|
||||||
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
||||||
soundRenderer.playFx(currSkill->getSound(), Vec3f(unit->getCurrVector()), gameCamera->getPos());
|
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
if(Config::getInstance().getBool("DisableWaterSounds","false") == false) {
|
if(Config::getInstance().getBool("DisableWaterSounds","false") == false) {
|
||||||
soundRenderer.playFx(
|
soundRenderer.playFx(
|
||||||
CoreData::getInstance().getWaterSound(),
|
CoreData::getInstance().getWaterSound(),
|
||||||
Vec3f(unit->getCurrVector()),
|
unit->getCurrVector(),
|
||||||
gameCamera->getPos()
|
gameCamera->getPos()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -713,7 +713,7 @@ void UnitUpdater::updateAttackStopped(Unit *unit, int frameIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double distToUnit=-1;
|
float distToUnit=-1;
|
||||||
std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
||||||
unitBeingAttacked(result, unit, asct->getAttackSkillType(), &distToUnit);
|
unitBeingAttacked(result, unit, asct->getAttackSkillType(), &distToUnit);
|
||||||
if(result.first == true) {
|
if(result.first == true) {
|
||||||
|
@ -749,10 +749,10 @@ void UnitUpdater::updateAttackStopped(Unit *unit, int frameIndex) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitUpdater::unitBeingAttacked(std::pair<bool,Unit *> &result, const Unit *unit, const AttackSkillType *ast, double *currentDistToUnit) {
|
void UnitUpdater::unitBeingAttacked(std::pair<bool,Unit *> &result, const Unit *unit, const AttackSkillType *ast, float *currentDistToUnit) {
|
||||||
//std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
//std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
||||||
|
|
||||||
double distToUnit = -1;
|
float distToUnit = -1;
|
||||||
if(currentDistToUnit != NULL) {
|
if(currentDistToUnit != NULL) {
|
||||||
distToUnit = *currentDistToUnit;
|
distToUnit = *currentDistToUnit;
|
||||||
}
|
}
|
||||||
|
@ -787,7 +787,7 @@ void UnitUpdater::unitBeingAttacked(std::pair<bool,Unit *> &result, const Unit *
|
||||||
std::pair<bool,Unit *> UnitUpdater::unitBeingAttacked(const Unit *unit) {
|
std::pair<bool,Unit *> UnitUpdater::unitBeingAttacked(const Unit *unit) {
|
||||||
std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
std::pair<bool,Unit *> result = make_pair(false,(Unit *)NULL);
|
||||||
|
|
||||||
double distToUnit = -1;
|
float distToUnit = -1;
|
||||||
for(unsigned int i = 0; i < unit->getType()->getSkillTypeCount(); ++i) {
|
for(unsigned int i = 0; i < unit->getType()->getSkillTypeCount(); ++i) {
|
||||||
const SkillType *st = unit->getType()->getSkillType(i);
|
const SkillType *st = unit->getType()->getSkillType(i);
|
||||||
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(st);
|
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(st);
|
||||||
|
@ -931,7 +931,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
|
||||||
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
bct->getStartSound(),
|
bct->getStartSound(),
|
||||||
Vec3f(unit->getCurrVector()),
|
unit->getCurrVector(),
|
||||||
gameCamera->getPos());
|
gameCamera->getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,7 +1023,7 @@ void UnitUpdater::updateBuild(Unit *unit, int frameIndex) {
|
||||||
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
(game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) {
|
||||||
SoundRenderer::getInstance().playFx(
|
SoundRenderer::getInstance().playFx(
|
||||||
bct->getBuiltSound(),
|
bct->getBuiltSound(),
|
||||||
Vec3f(unit->getCurrVector()),
|
unit->getCurrVector(),
|
||||||
gameCamera->getPos());
|
gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2210,8 +2210,8 @@ void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &t
|
||||||
attacker->setLastAttackedUnitId(attacked->getId());
|
attacker->setLastAttackedUnitId(attacked->getId());
|
||||||
scriptManager->onUnitAttacking(attacker);
|
scriptManager->onUnitAttacking(attacker);
|
||||||
|
|
||||||
double distance = pci.getPos().dist(targetPos);
|
float distance = pci.getPos().dist(targetPos);
|
||||||
distance = truncateDecimal<double>(distance,6);
|
distance = truncateDecimal<float>(distance,6);
|
||||||
damage(attacker, ast, attacked, distance);
|
damage(attacker, ast, attacked, distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2225,7 +2225,7 @@ void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, double distance) {
|
void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, float distance) {
|
||||||
if(attacker == NULL) {
|
if(attacker == NULL) {
|
||||||
throw megaglest_runtime_error("attacker == NULL");
|
throw megaglest_runtime_error("attacker == NULL");
|
||||||
}
|
}
|
||||||
|
@ -2237,11 +2237,11 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
|
||||||
}
|
}
|
||||||
|
|
||||||
//get vars
|
//get vars
|
||||||
double damage = ast->getTotalAttackStrength(attacker->getTotalUpgrade());
|
float damage = ast->getTotalAttackStrength(attacker->getTotalUpgrade());
|
||||||
int var = ast->getAttackVar();
|
int var = ast->getAttackVar();
|
||||||
int armor = attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
|
int armor = attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
|
||||||
double damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
|
float damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
|
||||||
damageMultiplier = truncateDecimal<double>(damageMultiplier,6);
|
damageMultiplier = truncateDecimal<float>(damageMultiplier,6);
|
||||||
|
|
||||||
//compute damage
|
//compute damage
|
||||||
//damage += random.randRange(-var, var);
|
//damage += random.randRange(-var, var);
|
||||||
|
@ -2249,7 +2249,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
|
||||||
damage /= distance+1;
|
damage /= distance+1;
|
||||||
damage -= armor;
|
damage -= armor;
|
||||||
damage *= damageMultiplier;
|
damage *= damageMultiplier;
|
||||||
damage = truncateDecimal<double>(damage,6);
|
damage = truncateDecimal<float>(damage,6);
|
||||||
|
|
||||||
if(damage < 1) {
|
if(damage < 1) {
|
||||||
damage= 1;
|
damage= 1;
|
||||||
|
@ -2524,10 +2524,10 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
//attack enemies that can attack first
|
//attack enemies that can attack first
|
||||||
double distToUnit= -1;
|
float distToUnit= -1;
|
||||||
Unit* enemySeen= NULL;
|
Unit* enemySeen= NULL;
|
||||||
|
|
||||||
double distToStandingUnit= -1;
|
float distToStandingUnit= -1;
|
||||||
Unit* attackingEnemySeen= NULL;
|
Unit* attackingEnemySeen= NULL;
|
||||||
ControlType controlType= unit->getFaction()->getControlType();
|
ControlType controlType= unit->getFaction()->getControlType();
|
||||||
bool isUltra= controlType == ctCpuUltra || controlType == ctNetworkCpuUltra;
|
bool isUltra= controlType == ctCpuUltra || controlType == ctNetworkCpuUltra;
|
||||||
|
@ -2547,7 +2547,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
||||||
|
|
||||||
// Attackers get first priority
|
// Attackers get first priority
|
||||||
if(enemy->getType()->hasSkillClass(scAttack) == true) {
|
if(enemy->getType()->hasSkillClass(scAttack) == true) {
|
||||||
double currentDist = unit->getCenteredPos().dist(enemy->getCenteredPos());
|
float currentDist = unit->getCenteredPos().dist(enemy->getCenteredPos());
|
||||||
|
|
||||||
// Select closest attacking unit
|
// Select closest attacking unit
|
||||||
if(distToUnit < 0 || currentDist< distToUnit) {
|
if(distToUnit < 0 || currentDist< distToUnit) {
|
||||||
|
@ -2598,8 +2598,8 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
||||||
Vec2f enemyFloatCenter = enemyUnit->getFloatCenteredPos();
|
Vec2f enemyFloatCenter = enemyUnit->getFloatCenteredPos();
|
||||||
// find nearest Attack and cleanup old dates
|
// find nearest Attack and cleanup old dates
|
||||||
AttackWarningData *nearest = NULL;
|
AttackWarningData *nearest = NULL;
|
||||||
double currentDistance = 0.f;
|
float currentDistance = 0.f;
|
||||||
double nearestDistance = 0.f;
|
float nearestDistance = 0.f;
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex(&mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
for(int i = attackWarnings.size() - 1; i >= 0; --i) {
|
for(int i = attackWarnings.size() - 1; i >= 0; --i) {
|
||||||
|
@ -2866,7 +2866,7 @@ void ParticleDamager::update(ParticleSystem *particleSystem) {
|
||||||
//play sound
|
//play sound
|
||||||
StaticSound *projSound= ast->getProjSound();
|
StaticSound *projSound= ast->getProjSound();
|
||||||
if(particleSystem->getVisible() && projSound != NULL) {
|
if(particleSystem->getVisible() && projSound != NULL) {
|
||||||
SoundRenderer::getInstance().playFx(projSound, Vec3f(attacker->getCurrVector()), gameCamera->getPos());
|
SoundRenderer::getInstance().playFx(projSound, attacker->getCurrVector(), gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particleSystem->setObserver(NULL);
|
particleSystem->setObserver(NULL);
|
||||||
|
|
|
@ -124,7 +124,7 @@ public:
|
||||||
|
|
||||||
inline unsigned int getAttackWarningCount() const { return attackWarnings.size(); }
|
inline unsigned int getAttackWarningCount() const { return attackWarnings.size(); }
|
||||||
std::pair<bool,Unit *> unitBeingAttacked(const Unit *unit);
|
std::pair<bool,Unit *> unitBeingAttacked(const Unit *unit);
|
||||||
void unitBeingAttacked(std::pair<bool,Unit *> &result, const Unit *unit, const AttackSkillType *ast,double *currentDistToUnit=NULL);
|
void unitBeingAttacked(std::pair<bool,Unit *> &result, const Unit *unit, const AttackSkillType *ast,float *currentDistToUnit=NULL);
|
||||||
vector<Unit*> enemyUnitsOnRange(const Unit *unit,const AttackSkillType *ast);
|
vector<Unit*> enemyUnitsOnRange(const Unit *unit,const AttackSkillType *ast);
|
||||||
void findEnemiesForCell(const Vec2i pos, int size, int sightRange, const Faction *faction, vector<Unit*> &enemies, bool attackersOnly) const;
|
void findEnemiesForCell(const Vec2i pos, int size, int sightRange, const Faction *faction, vector<Unit*> &enemies, bool attackersOnly) const;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ private:
|
||||||
//attack
|
//attack
|
||||||
void hit(Unit *attacker);
|
void hit(Unit *attacker);
|
||||||
void hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &targetPos, Field targetField);
|
void hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &targetPos, Field targetField);
|
||||||
void damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, double distance);
|
void damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, float distance);
|
||||||
void startAttackParticleSystem(Unit *unit);
|
void startAttackParticleSystem(Unit *unit);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
|
|
|
@ -1164,7 +1164,7 @@ void World::addAttackEffects(const Unit *unit) {
|
||||||
|
|
||||||
//returns the nearest unit that can store a type of resource given a position and a faction
|
//returns the nearest unit that can store a type of resource given a position and a faction
|
||||||
Unit *World::nearestStore(const Vec2i &pos, int factionIndex, const ResourceType *rt) {
|
Unit *World::nearestStore(const Vec2i &pos, int factionIndex, const ResourceType *rt) {
|
||||||
double currDist = infinity;
|
float currDist = infinity;
|
||||||
Unit *currUnit= NULL;
|
Unit *currUnit= NULL;
|
||||||
|
|
||||||
if(factionIndex >= getFactionCount()) {
|
if(factionIndex >= getFactionCount()) {
|
||||||
|
@ -1174,7 +1174,7 @@ Unit *World::nearestStore(const Vec2i &pos, int factionIndex, const ResourceType
|
||||||
for(int i=0; i < getFaction(factionIndex)->getUnitCount(); ++i) {
|
for(int i=0; i < getFaction(factionIndex)->getUnitCount(); ++i) {
|
||||||
Unit *u= getFaction(factionIndex)->getUnit(i);
|
Unit *u= getFaction(factionIndex)->getUnit(i);
|
||||||
if(u != NULL) {
|
if(u != NULL) {
|
||||||
double tmpDist= u->getPos().dist(pos);
|
float tmpDist= u->getPos().dist(pos);
|
||||||
if(tmpDist < currDist && u->getType() != NULL && u->getType()->getStore(rt) > 0 && u->isOperative()) {
|
if(tmpDist < currDist && u->getType() != NULL && u->getType()->getStore(rt) > 0 && u->isOperative()) {
|
||||||
currDist= tmpDist;
|
currDist= tmpDist;
|
||||||
currUnit= u;
|
currUnit= u;
|
||||||
|
@ -2348,7 +2348,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//explore
|
//explore
|
||||||
double posLength = currRelPos.length();
|
float posLength = currRelPos.length();
|
||||||
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
||||||
if(posLength < surfSightRange + indirectSightRange + 1) {
|
if(posLength < surfSightRange + indirectSightRange + 1) {
|
||||||
sc->setExplored(teamIndex, true);
|
sc->setExplored(teamIndex, true);
|
||||||
|
|
|
@ -233,7 +233,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double area() {
|
float area() {
|
||||||
Vec2i v0= p[3]-p[0];
|
Vec2i v0= p[3]-p[0];
|
||||||
Vec2i v1= p[1]-p[2];
|
Vec2i v1= p[1]-p[2];
|
||||||
|
|
||||||
|
@ -312,54 +312,6 @@ inline T radToDeg(T rad){
|
||||||
//#endif
|
//#endif
|
||||||
//}
|
//}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T truncateDecimal(const T &value, int precision=6) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
int iSigned = value >= 0 ? 1: -1;
|
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
|
||||||
unsigned int uiTemp = (unsigned int)(value * streflop::pow((streflop::Simple)10, (streflop::Simple)precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
|
||||||
T result = (((T)uiTemp) / streflop::pow((streflop::Simple)10,(streflop::Simple)precision) * iSigned);
|
|
||||||
#else
|
|
||||||
unsigned int uiTemp = (value * pow((T)10, precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
|
||||||
T result = (((double)uiTemp) / pow((T)10,precision) * iSigned);
|
|
||||||
#endif
|
|
||||||
return result;
|
|
||||||
*/
|
|
||||||
|
|
||||||
T precNum = 0;
|
|
||||||
if(precision == 0) {
|
|
||||||
precNum = 1;
|
|
||||||
}
|
|
||||||
else if(precision == 1) {
|
|
||||||
precNum = 10;
|
|
||||||
}
|
|
||||||
else if(precision == 2) {
|
|
||||||
precNum = 100;
|
|
||||||
}
|
|
||||||
else if(precision == 3) {
|
|
||||||
precNum = 1000;
|
|
||||||
}
|
|
||||||
else if(precision == 4) {
|
|
||||||
precNum = 10000;
|
|
||||||
}
|
|
||||||
else if(precision == 5) {
|
|
||||||
precNum = 100000;
|
|
||||||
}
|
|
||||||
else if(precision == 6) {
|
|
||||||
precNum = 1000000;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
precNum = std::pow((T)10,(T)precision);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64 resultInt = (T)value * (T)precNum;
|
|
||||||
|
|
||||||
T result = (long double)resultInt / precNum;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,61 @@
|
||||||
//#include <tr1/unordered_map>
|
//#include <tr1/unordered_map>
|
||||||
//using namespace std::tr1;
|
//using namespace std::tr1;
|
||||||
|
|
||||||
|
#include "data_types.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
using namespace Shared::Platform;
|
||||||
|
|
||||||
namespace Shared{ namespace Graphics{
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T truncateDecimal(const T &value, int precision=6) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
int iSigned = value >= 0 ? 1: -1;
|
||||||
|
|
||||||
|
#ifdef USE_STREFLOP
|
||||||
|
unsigned int uiTemp = (unsigned int)(value * streflop::pow((streflop::Simple)10, (streflop::Simple)precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
||||||
|
T result = (((T)uiTemp) / streflop::pow((streflop::Simple)10,(streflop::Simple)precision) * iSigned);
|
||||||
|
#else
|
||||||
|
unsigned int uiTemp = (value * pow((T)10, precision)) * iSigned; //Note I'm using unsigned int so that I can increase the precision of the truncate
|
||||||
|
T result = (((double)uiTemp) / pow((T)10,precision) * iSigned);
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
*/
|
||||||
|
|
||||||
|
T precNum = 0;
|
||||||
|
if(precision == 0) {
|
||||||
|
precNum = 1;
|
||||||
|
}
|
||||||
|
else if(precision == 1) {
|
||||||
|
precNum = 10;
|
||||||
|
}
|
||||||
|
else if(precision == 2) {
|
||||||
|
precNum = 100;
|
||||||
|
}
|
||||||
|
else if(precision == 3) {
|
||||||
|
precNum = 1000;
|
||||||
|
}
|
||||||
|
else if(precision == 4) {
|
||||||
|
precNum = 10000;
|
||||||
|
}
|
||||||
|
else if(precision == 5) {
|
||||||
|
precNum = 100000;
|
||||||
|
}
|
||||||
|
else if(precision == 6) {
|
||||||
|
precNum = 1000000;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
precNum = std::pow((T)10,(T)precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 resultInt = (T)value * (T)precNum;
|
||||||
|
|
||||||
|
T result = (long double)resultInt / precNum;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
inline std::vector<std::string> TokenizeString(const std::string str,const std::string delimiters) {
|
inline std::vector<std::string> TokenizeString(const std::string str,const std::string delimiters) {
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
// Assume textLine contains the line of text to parse.
|
// Assume textLine contains the line of text to parse.
|
||||||
|
@ -206,8 +257,10 @@ public:
|
||||||
return x*v.x+y*v.y;
|
return x*v.x+y*v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double dist(const Vec2<T> &v) const{
|
inline float dist(const Vec2<T> &v) const{
|
||||||
return Vec2<T>(v-*this).length();
|
float distance = Vec2<T>(v-*this).length();
|
||||||
|
distance = truncateDecimal<float>(distance,6);
|
||||||
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// strict week ordering, so Vec2<T> can be used as key for set<> or map<>
|
// strict week ordering, so Vec2<T> can be used as key for set<> or map<>
|
||||||
|
@ -215,7 +268,7 @@ public:
|
||||||
return x < v.x || (x == v.x && y < v.y);
|
return x < v.x || (x == v.x && y < v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double length() const {
|
inline float length() const {
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
// if(requireAccuracy == true) {
|
// if(requireAccuracy == true) {
|
||||||
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
|
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
|
||||||
|
@ -224,7 +277,9 @@ public:
|
||||||
//#else
|
//#else
|
||||||
// return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
// return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
||||||
//#endif
|
//#endif
|
||||||
return static_cast<double>(std::sqrt(static_cast<double>(x*x + y*y)));
|
float len = static_cast<float>(std::sqrt(static_cast<float>(x*x + y*y)));
|
||||||
|
len = truncateDecimal<float>(len,6);
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void normalize(){
|
inline void normalize(){
|
||||||
|
@ -233,7 +288,7 @@ public:
|
||||||
y/= m;
|
y/= m;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vec2<T> rotate(double rad) {
|
inline Vec2<T> rotate(float rad) {
|
||||||
// const float
|
// const float
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
// c = streflop::cosf(rad),
|
// c = streflop::cosf(rad),
|
||||||
|
@ -242,13 +297,13 @@ public:
|
||||||
// c = cosf(rad),
|
// c = cosf(rad),
|
||||||
// s = sinf(rad);
|
// s = sinf(rad);
|
||||||
//#endif
|
//#endif
|
||||||
double c = std::cos(rad),
|
float c = std::cos(rad),
|
||||||
s = std::sin(rad);
|
s = std::sin(rad);
|
||||||
|
|
||||||
return Vec2<T>(x*c-y*s,x*s+y*c);
|
return Vec2<T>(x*c-y*s,x*s+y*c);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vec2<T> rotateAround(double rad,const Vec2<T>& pt){
|
inline Vec2<T> rotateAround(float rad,const Vec2<T>& pt) {
|
||||||
return pt+(*this-pt).rotate(rad);
|
return pt+(*this-pt).rotate(rad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,11 +507,13 @@ public:
|
||||||
return x*v.x + y*v.y + z*v.z;
|
return x*v.x + y*v.y + z*v.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double dist(const Vec3<T> &v) const{
|
inline float dist(const Vec3<T> &v) const {
|
||||||
return Vec3<T>(v-*this).length();
|
float distance = Vec3<T>(v-*this).length();
|
||||||
|
distance = truncateDecimal<float>(distance,6);
|
||||||
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double length() const {
|
inline float length() const {
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
// if(requireAccuracy == true) {
|
// if(requireAccuracy == true) {
|
||||||
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
|
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
|
||||||
|
@ -465,7 +522,9 @@ public:
|
||||||
//#else
|
//#else
|
||||||
// return static_cast<float>(sqrt(x*x + y*y + z*z));
|
// return static_cast<float>(sqrt(x*x + y*y + z*z));
|
||||||
//#endif
|
//#endif
|
||||||
return static_cast<double>(std::sqrt(x*x + y*y + z*z));
|
float len = static_cast<float>(std::sqrt(x*x + y*y + z*z));
|
||||||
|
len = truncateDecimal<float>(len,6);
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void normalize() {
|
inline void normalize() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
void init(int seed);
|
void init(int seed);
|
||||||
|
|
||||||
int randRange(int min, int max,std::string lastCaller="");
|
int randRange(int min, int max,std::string lastCaller="");
|
||||||
double randRange(double min, double max,std::string lastCaller="");
|
float randRange(float min, float max,std::string lastCaller="");
|
||||||
|
|
||||||
int getLastNumber() const { return lastNumber; }
|
int getLastNumber() const { return lastNumber; }
|
||||||
void setLastNumber(int value) { lastNumber = value; }
|
void setLastNumber(int value) { lastNumber = value; }
|
||||||
|
|
|
@ -231,10 +231,10 @@ void copyStringToBuffer(char *buffer, int bufferSize, const string& s);
|
||||||
|
|
||||||
//numeric fcs
|
//numeric fcs
|
||||||
int clamp(int value, int min, int max);
|
int clamp(int value, int min, int max);
|
||||||
double clamp(double value, double min, double max);
|
float clamp(float value, float min, float max);
|
||||||
int64 clamp(int64 value, int64 min, int64 max);
|
int64 clamp(int64 value, int64 min, int64 max);
|
||||||
double saturate(double value);
|
float saturate(float value);
|
||||||
int round(double f);
|
int round(float f);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
bool checkVersionComptability(string clientVersionString, string serverVersionString);
|
bool checkVersionComptability(string clientVersionString, string serverVersionString);
|
||||||
|
|
|
@ -109,7 +109,7 @@ void ParticleRendererGl::renderSystem(ParticleSystem *ps){
|
||||||
for(int i=0; i<ps->getAliveParticleCount(); ++i){
|
for(int i=0; i<ps->getAliveParticleCount(); ++i){
|
||||||
const Particle *particle= ps->getParticle(i);
|
const Particle *particle= ps->getParticle(i);
|
||||||
float size= particle->getSize()/2.0f;
|
float size= particle->getSize()/2.0f;
|
||||||
Vec3f pos= Vec3f(particle->getPos());
|
Vec3f pos= particle->getPos();
|
||||||
Vec4f color= particle->getColor();
|
Vec4f color= particle->getColor();
|
||||||
|
|
||||||
vertexBuffer[bufferIndex] = pos - (rightVector - upVector) * size;
|
vertexBuffer[bufferIndex] = pos - (rightVector - upVector) * size;
|
||||||
|
@ -159,8 +159,8 @@ void ParticleRendererGl::renderSystemLine(ParticleSystem *ps){
|
||||||
particle= ps->getParticle(i);
|
particle= ps->getParticle(i);
|
||||||
Vec4f color= particle->getColor();
|
Vec4f color= particle->getColor();
|
||||||
|
|
||||||
vertexBuffer[bufferIndex] = Vec3f(particle->getPos());
|
vertexBuffer[bufferIndex] = particle->getPos();
|
||||||
vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos());
|
vertexBuffer[bufferIndex+1] = particle->getLastPos();
|
||||||
|
|
||||||
colorBuffer[bufferIndex]= color;
|
colorBuffer[bufferIndex]= color;
|
||||||
colorBuffer[bufferIndex+1]= color;
|
colorBuffer[bufferIndex+1]= color;
|
||||||
|
@ -203,8 +203,8 @@ void ParticleRendererGl::renderSystemLineAlpha(ParticleSystem *ps){
|
||||||
particle= ps->getParticle(i);
|
particle= ps->getParticle(i);
|
||||||
Vec4f color= particle->getColor();
|
Vec4f color= particle->getColor();
|
||||||
|
|
||||||
vertexBuffer[bufferIndex] = Vec3f(particle->getPos());
|
vertexBuffer[bufferIndex] = particle->getPos();
|
||||||
vertexBuffer[bufferIndex+1] = Vec3f(particle->getLastPos());
|
vertexBuffer[bufferIndex+1] = particle->getLastPos();
|
||||||
|
|
||||||
colorBuffer[bufferIndex]= color;
|
colorBuffer[bufferIndex]= color;
|
||||||
colorBuffer[bufferIndex+1]= color;
|
colorBuffer[bufferIndex+1]= color;
|
||||||
|
@ -236,11 +236,11 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
//translate
|
//translate
|
||||||
Vec3f pos= Vec3f(ps->getPos());
|
Vec3f pos= ps->getPos();
|
||||||
glTranslatef(pos.x, pos.y, pos.z);
|
glTranslatef(pos.x, pos.y, pos.z);
|
||||||
|
|
||||||
//rotate
|
//rotate
|
||||||
Vec3f direction= Vec3f(ps->getDirection());
|
Vec3f direction= ps->getDirection();
|
||||||
Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z);
|
Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z);
|
||||||
Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection);
|
Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection);
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,8 @@ int RandomGen::randRange(int min, int max,string lastCaller) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int diff= max-min;
|
int diff= max-min;
|
||||||
double numerator = static_cast<double>(diff + 1) * static_cast<double>(RandomGen::rand(lastCaller));
|
float numerator = static_cast<float>(diff + 1) * static_cast<float>(RandomGen::rand(lastCaller));
|
||||||
int res= min + static_cast<int>(truncateDecimal<double>(numerator / static_cast<double>(m),6));
|
int res= min + static_cast<int>(truncateDecimal<float>(numerator / static_cast<float>(m),6));
|
||||||
if(res < min || res > max) {
|
if(res < min || res > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
||||||
|
@ -93,16 +93,16 @@ int RandomGen::randRange(int min, int max,string lastCaller) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
double RandomGen::randRange(double min, double max,string lastCaller) {
|
float RandomGen::randRange(float min, float max,string lastCaller) {
|
||||||
if(min > max) {
|
if(min > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %f, max = %f",__FILE__,__FUNCTION__,__LINE__,min,max);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %f, max = %f",__FILE__,__FUNCTION__,__LINE__,min,max);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
double rand01 = static_cast<double>(RandomGen::rand(lastCaller)) / (m-1);
|
float rand01 = static_cast<float>(RandomGen::rand(lastCaller)) / (m-1);
|
||||||
double res= min + (max - min) * rand01;
|
float res= min + (max - min) * rand01;
|
||||||
res = truncateDecimal<double>(res,6);
|
res = truncateDecimal<float>(res,6);
|
||||||
|
|
||||||
if(res < min || res > max) {
|
if(res < min || res > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
|
|
@ -710,7 +710,7 @@ void copyStringToBuffer(char *buffer, int bufferSize, const string& s){
|
||||||
|
|
||||||
// ==================== numeric fcs ====================
|
// ==================== numeric fcs ====================
|
||||||
|
|
||||||
double saturate(double value) {
|
float saturate(float value) {
|
||||||
if (value < 0.f){
|
if (value < 0.f){
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,7 @@ int64 clamp(int64 value, int64 min, int64 max){
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double clamp(double value, double min, double max) {
|
float clamp(float value, float min, float max) {
|
||||||
if (value < min) {
|
if (value < min) {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
@ -750,7 +750,7 @@ double clamp(double value, double min, double max) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int round(double f){
|
int round(float f){
|
||||||
return (int) f;
|
return (int) f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue