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