- more fixing of map corner position actions causing memory access violations (this will further stabilize the code)
This commit is contained in:
parent
922df8e025
commit
c4795eb6cb
|
@ -2660,12 +2660,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Vec2i pos= c->getPos();
|
Vec2i pos= c->getPos();
|
||||||
if(pos.x < 0) {
|
map->clampPos(pos);
|
||||||
pos.x = 0;
|
|
||||||
}
|
|
||||||
if(pos.y < 0) {
|
|
||||||
pos.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||||
}
|
}
|
||||||
|
@ -2677,12 +2672,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
//meeting point arrow
|
//meeting point arrow
|
||||||
if(unit->getType()->getMeetingPoint()) {
|
if(unit->getType()->getMeetingPoint()) {
|
||||||
Vec2i pos= unit->getMeetingPos();
|
Vec2i pos= unit->getMeetingPos();
|
||||||
if(pos.x < 0) {
|
map->clampPos(pos);
|
||||||
pos.x = 0;
|
|
||||||
}
|
|
||||||
if(pos.y < 0) {
|
|
||||||
pos.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||||
renderArrow(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);
|
||||||
|
|
|
@ -641,7 +641,9 @@ void Unit::setPos(const Vec2i &pos) {
|
||||||
|
|
||||||
this->lastPos= this->pos;
|
this->lastPos= this->pos;
|
||||||
this->pos= pos;
|
this->pos= pos;
|
||||||
|
map->clampPos(this->pos);
|
||||||
this->meetingPos= pos - Vec2i(1);
|
this->meetingPos= pos - Vec2i(1);
|
||||||
|
map->clampPos(this->meetingPos);
|
||||||
|
|
||||||
// Attempt to improve performance
|
// Attempt to improve performance
|
||||||
this->exploreCells();
|
this->exploreCells();
|
||||||
|
@ -656,6 +658,8 @@ void Unit::setTargetPos(const Vec2i &targetPos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i relPos= targetPos - pos;
|
Vec2i relPos= targetPos - pos;
|
||||||
|
//map->clampPos(relPos);
|
||||||
|
|
||||||
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
|
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
|
||||||
#ifdef USE_STREFLOP
|
#ifdef USE_STREFLOP
|
||||||
targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y));
|
targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y));
|
||||||
|
@ -669,6 +673,7 @@ void Unit::setTargetPos(const Vec2i &targetPos) {
|
||||||
//this->targetPos = Vec2i(0);
|
//this->targetPos = Vec2i(0);
|
||||||
|
|
||||||
this->targetPos= targetPos;
|
this->targetPos= targetPos;
|
||||||
|
map->clampPos(this->targetPos);
|
||||||
|
|
||||||
logSynchData(__FILE__,__LINE__);
|
logSynchData(__FILE__,__LINE__);
|
||||||
}
|
}
|
||||||
|
@ -1856,11 +1861,13 @@ void Unit::setTargetVec(const Vec3f &targetVec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::setMeetingPos(const Vec2i &meetingPos) {
|
void Unit::setMeetingPos(const Vec2i &meetingPos) {
|
||||||
if(map->isInside(meetingPos) == false || map->isInsideSurface(map->toSurfCoords(meetingPos)) == false) {
|
this->meetingPos= meetingPos;
|
||||||
throw runtime_error("#8 Invalid path position = " + meetingPos.getString());
|
map->clampPos(this->meetingPos);
|
||||||
|
|
||||||
|
if(map->isInside(this->meetingPos) == false || map->isInsideSurface(map->toSurfCoords(this->meetingPos)) == false) {
|
||||||
|
throw runtime_error("#8 Invalid path position = " + this->meetingPos.getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->meetingPos= meetingPos;
|
|
||||||
logSynchData(__FILE__,__LINE__);
|
logSynchData(__FILE__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -557,13 +557,6 @@ bool World::placeUnit(const Vec2i &startLoc, int radius, Unit *unit, bool spacia
|
||||||
if(freeSpace) {
|
if(freeSpace) {
|
||||||
unit->setPos(pos);
|
unit->setPos(pos);
|
||||||
Vec2i meetingPos = pos-Vec2i(1);
|
Vec2i meetingPos = pos-Vec2i(1);
|
||||||
if(meetingPos.x < 0) {
|
|
||||||
meetingPos.x = 0;
|
|
||||||
}
|
|
||||||
if(meetingPos.y < 0) {
|
|
||||||
meetingPos.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unit->setMeetingPos(meetingPos);
|
unit->setMeetingPos(meetingPos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user