Fix use of | instead of & for rect intersection

This commit is contained in:
2015-10-01 23:40:19 -04:00
parent f6183cad63
commit a515bd0b0e
5 changed files with 12 additions and 12 deletions

View File

@@ -1474,7 +1474,7 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
dest_rect.offset(where_draw.x * 28,where_draw.y * 36);
source_rect = store_rect = dest_rect;
dest_rect.offset(x_adj,y_adj);
dest_rect |= big_to;
dest_rect &= big_to;
dest_rect.offset(win_to_rects[0].left,win_to_rects[0].top);
@@ -1631,7 +1631,7 @@ void draw_targeting_line(location where_curs) {
redraw_rect.right = max(where_curs.x,k) + 4;
redraw_rect.top = min(where_curs.y,l) - 4;
redraw_rect.bottom = max(where_curs.y,l) + 4;
redraw_rect2 = redraw_rect | terrain_rect;
redraw_rect2 = redraw_rect & terrain_rect;
// Now place targeting pattern
for(i = 0; i < 9; i++)

View File

@@ -142,7 +142,7 @@ void apply_unseen_mask() {
to_rect = base_rect;
to_rect.offset(-28 + i * 28,-36 + 36 * j);
to_rect |= big_to;
to_rect &= big_to;
tileImage(terrain_screen_gworld, to_rect, bw_pats[3], sf::BlendAlpha);
}
}

View File

@@ -65,8 +65,8 @@ bool operator != (rectangle r1, rectangle r2) {
return !(r1 == r2);
}
rectangle operator|(rectangle one, rectangle two) {
return one |= two;
rectangle operator&(rectangle one, rectangle two) {
return one &= two;
}
rectangle rectunion(rectangle one, rectangle two) {
@@ -167,7 +167,7 @@ void rectangle::inset(int dh, int dv) {
top += dv; bottom -= dv;
}
rectangle& rectangle::operator|=(rectangle other) {
rectangle& rectangle::operator&=(rectangle other) {
left = std::max(left, other.left);
top = std::max(top, other.top);
right = std::min(right, other.right);

View File

@@ -74,7 +74,7 @@ struct rectangle {
template<typename T>
void offset(sf::Vector2<T> diff) {offset(diff.x,diff.y);}
void inset(int dh, int dv);
rectangle& operator|=(rectangle other);
rectangle& operator&=(rectangle other);
template<typename T>
operator typename sf::template Rect<T>() {
return sf::Rect<T>(left, top, width(), height());
@@ -126,7 +126,7 @@ bool operator != (location p1,location p2);
bool operator == (rectangle r1, rectangle r2);
bool operator != (rectangle r1, rectangle r2);
// TODO: This isn't a union, because it returns a rectangle.
rectangle operator|(rectangle one, rectangle two);
rectangle operator&(rectangle one, rectangle two);
rectangle rectunion(rectangle one, rectangle two);
short dist(location p1,location p2);
short vdist(location p1,location p2);

View File

@@ -393,7 +393,7 @@ rectangle calc_rect(short i, short j){
extern sf::Texture fields_gworld;
graf_pos cCustomGraphics::find_graphic(pic_num_t which_rect, bool party) {
static graf_pos dummy = {&fields_gworld, {72,0,108,28}};
static graf_pos dummy = {&fields_gworld, {72,140,108,28}};
if(party && !party_sheet) return dummy;
else if(!party && !is_old && (which_rect / 100) >= numSheets)
return dummy;
@@ -406,7 +406,7 @@ graf_pos cCustomGraphics::find_graphic(pic_num_t which_rect, bool party) {
store_rect.offset(28 * (which_rect % 10),36 * (which_rect / 10));
sf::Texture* the_sheet = party ? party_sheet.get() : &sheets[sheet];
rectangle test(*the_sheet);
if((store_rect | test) != store_rect) return dummy;
if((store_rect & test) != store_rect) return dummy;
return std::make_pair(the_sheet,store_rect);
}
@@ -927,7 +927,7 @@ void Region::setStencil(sf::RenderWindow& where) {
}
void clip_rect(sf::RenderTarget& where, rectangle rect) {
rect |= rectangle(where); // Make sure we don't draw out of bounds
rect &= rectangle(where); // Make sure we don't draw out of bounds
// TODO: Make sure this works for the scissor test...
setActiveRenderTarget(where);
glEnable(GL_SCISSOR_TEST);
@@ -1027,7 +1027,7 @@ void tileImage(sf::RenderTarget& target, rectangle area, tessel_ref_t tessel, sf
rectangle clipArea = area;
area.left -= area.left % tesselInfo.srcRect.width();
area.top -= area.top % tesselInfo.srcRect.height();
area |= rectangle(target); // Make sure we don't draw out of bounds
area &= rectangle(target); // Make sure we don't draw out of bounds
sf::RectangleShape tesselShape(sf::Vector2f(area.width(),area.height()));
tesselShape.setTexture(&tesselInfo.tessel->getTexture());