summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-01-04 18:54:25 (GMT)
committer jacob1 <jfu614@gmail.com>2013-01-04 18:54:25 (GMT)
commit1b2e7b3c70bf72b069786c1ccd2a782028ae84ce (patch)
tree3e2ed576045bb83ae6cb973b18898afdbed0fba4 /src
parent8e50abcab956b7cf842a7891bcb1ceac40caf5d4 (diff)
downloadpowder-1b2e7b3c70bf72b069786c1ccd2a782028ae84ce.zip
powder-1b2e7b3c70bf72b069786c1ccd2a782028ae84ce.tar.gz
fix Ctrl+x being one pixel off, better xor_rect from tpt, delete test.c
Diffstat (limited to 'src')
-rw-r--r--src/game/GameView.cpp6
-rw-r--r--src/graphics/RasterDrawMethods.inl21
-rw-r--r--src/simulation/Simulation.cpp4
-rw-r--r--src/tests/test.c171
4 files changed, 24 insertions, 178 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index f8d8cd3..dfd4b40 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -1847,10 +1847,10 @@ void GameView::OnDraw()
y2 = YRES-1;
ren->fillrect(0, 0, XRES, y1, 0, 0, 0, 100);
- ren->fillrect(0, y2, XRES, YRES-y2, 0, 0, 0, 100);
+ ren->fillrect(0, y2+1, XRES, YRES-y2-1, 0, 0, 0, 100);
- ren->fillrect(0, y1, x1, (y2-y1), 0, 0, 0, 100);
- ren->fillrect(x2, y1, XRES-x2, (y2-y1), 0, 0, 0, 100);
+ ren->fillrect(0, y1, x1, (y2-y1)+1, 0, 0, 0, 100);
+ ren->fillrect(x2+1, y1, XRES-x2-1, (y2-y1)+1, 0, 0, 0, 100);
ren->xor_rect(x1, y1, (x2-x1)+1, (y2-y1)+1);
}
diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl
index 55a64c9..dec15f1 100644
--- a/src/graphics/RasterDrawMethods.inl
+++ b/src/graphics/RasterDrawMethods.inl
@@ -236,12 +236,29 @@ void PIXELMETHODS_CLASS::xor_rect(int x, int y, int w, int h)
for (i=0; i<w; i+=2)
{
xor_pixel(x+i, y);
- xor_pixel(x+i, y+h-1);
}
+ if (h != 1)
+ {
+ if (h%2 == 1) i = 2;
+ else i = 1;
+ for (; i<w; i+=2)
+ {
+ xor_pixel(x+i, y+h-1);
+ }
+ }
+
for (i=2; i<h; i+=2)
{
xor_pixel(x, y+i);
- xor_pixel(x+w-1, y+i);
+ }
+ if (w != 1)
+ {
+ if (w%2 == 1) i = 2;
+ else i = 1;
+ for (; i<h-1; i+=2)
+ {
+ xor_pixel(x+w-1, y+i);
+ }
}
}
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index a30fea8..a8cc41f 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -343,9 +343,9 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
{
int cx = 0;
int cy = 0;
- for (cy=0; cy<area_h; cy++)
+ for (cy=0; cy<=area_h; cy++)
{
- for (cx=0; cx<area_w; cx++)
+ for (cx=0; cx<=area_w; cx++)
{
if(bmap[(cy+area_y)/CELL][(cx+area_x)/CELL] == WL_GRAV)
gravWallChanged = true;
diff --git a/src/tests/test.c b/src/tests/test.c
deleted file mode 100644
index 06b9e95..0000000
--- a/src/tests/test.c
+++ /dev/null
@@ -1,171 +0,0 @@
-int g;
-
-int trapp(int a, int b);
-float compl(float* a, unsigned int n);
-void spam();
-
-int main()
-{
- int l, r;
- int a, b, m, d, s, as;
- int b1, b2, b3;
- float f, dd;
- int i;
- int k, j, o;
- unsigned int ua, ub, um, ud, us, uas;
- int re;
- float arr[] = { 1.6f, -3.0f, 1.41f, -0.01f };
- float* point;
- float res;
-
- trap_Print("System calls work\n");
-
- if (!1)
- return -1;
-
- trap_Print("Negation works\n");
-
- if (!(9 == 9 && 6!=4 && 100>10 && 34<85))
- return -1;
-
- trap_Print("Basic comparisons work\n");
-
- b1 = 9 & 3;
- b2 = 7 | 8;
- b3 = 10 ^ 3;
-
- if (!(b1 == 1 && b2 == 15 && b3 == 9))
- return -1;
-
- trap_Print("Boolean functions work\n");
-
- l = 2;
- l = l<<2;
-
- r = 9;
- r = r>>2;
-
- if (!(l == 8 && r == 2))
- return -1;
-
- trap_Print("Bit shifts work\n");
-
- a = 6;
- b = 2*2;
-
- m = a*b;
- d = a/b;
- s = a+b;
- as = a-b;
-
- if (!(m == 24 && d == 1 && s == 10 && as == 2))
- return -1;
-
- trap_Print("Arithmetics works\n");
-
- f = 5.1f;
- dd = 3.1415f;
-
- if (!((f*dd)>15.0f && (f*dd)<17.0f && (f-dd)<2.0f && (f-dd)>1.0f))
- return -1;
-
- trap_Print("Floating point arithmetics works\n");
-
- i = f*dd;
-
- if (!(i==16))
- return -1;
-
- trap_Print("Float to Int works\n");
-
- f = i+1;
-
- if (!(f>16.0f && f<18.0f))
- return -1;
-
- trap_Print("Int to Float works\n");
-
- j = 0; o = 0;
- for(k=0; k<5; k++)
- j++;
-
- for(k=5; k>0; k--)
- o++;
-
- if (!(o == 5 && j == 5))
- return -1;
-
- trap_Print("Cycles work\n");
-
- g = 11;
- g++;
-
- if (!(g == 12))
- return -1;
-
- trap_Print("Global variables work\n");
-
- ua = 6;
- ub = 2*2;
-
- um = ua*ub;
- ud = ua/ub;
- us = ua+ub;
- uas = ua-ub;
-
- if (!(um == 24 && ud == 1 && us == 10 && uas == 2))
- return -1;
-
- trap_Print("Unsigned ints work\n");
-
- point = &arr[0];
- point += 2;
- if (!(*point == 1.41f))
- return -1;
-
- trap_Print("Pointer arithmetics works\n");
-
- re = trapp(12, 4);
-
- if (!(re == 8))
- return -1;
-
- trap_Print("Function calls work\n");
-
- res = compl(arr, 4);
-
- if (!(res<0.01f && res>(-0.01f)))
- return -1;
-
- trap_Print("Complex function call works\n");
-
- for(i=0; i<1000000; i++)
- spam();
-
- trap_Print("Stack spam check passed\n");
-
- trap_Print("All checks are passed!\n");
-
- return 10;
-}
-
-int trapp(int a, int b)
-{
- int c;
- c = (a+b)/2;
- return c;
-}
-
-float compl(float* a, unsigned int n)
-{
- int s, i;
- for(i=0; i<n; i++)
- s+=a[i];
- return s;
-}
-
-void spam()
-{
- return;
-}
-