X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=fractalnoise.c;h=c161f12b7c4eaf87387272beea954ee3ff2233e9;hb=3a12518a4f3897519c5578d154c597b8549b8dcf;hp=90419e3d4e4d4a3574aa5460f82545b05eab6440;hpb=6f079ecb90e1e6b7597d4da1a98f95c5822aad8d;p=xonotic%2Fdarkplaces.git diff --git a/fractalnoise.c b/fractalnoise.c index 90419e3d..c161f12b 100644 --- a/fractalnoise.c +++ b/fractalnoise.c @@ -1,7 +1,7 @@ #include "quakedef.h" -void fractalnoise(qbyte *noise, int size, int startgrid) +void fractalnoise(unsigned char *noise, int size, int startgrid) { int x, y, g, g2, amplitude, min, max, size1 = size - 1, sizepower, gridpower; int *noisebuf; @@ -24,7 +24,7 @@ void fractalnoise(qbyte *noise, int size, int startgrid) startgrid = bound(0, startgrid, size); amplitude = 0xFFFF; // this gets halved before use - noisebuf = Mem_Alloc(tempmempool, size*size*sizeof(int)); + noisebuf = (int *)Mem_Alloc(tempmempool, size*size*sizeof(int)); memset(noisebuf, 0, size*size*sizeof(int)); for (g2 = startgrid;g2;g2 >>= 1) @@ -65,13 +65,13 @@ void fractalnoise(qbyte *noise, int size, int startgrid) // normalize noise and copy to output for (y = 0;y < size;y++) for (x = 0;x < size;x++) - *noise++ = (qbyte) (((n(x,y) - min) * 256) / max); + *noise++ = (unsigned char) (((n(x,y) - min) * 256) / max); Mem_Free(noisebuf); #undef n } // unnormalized, used for explosions mainly, does not allocate/free memory (hence the name quick) -void fractalnoisequick(qbyte *noise, int size, int startgrid) +void fractalnoisequick(unsigned char *noise, int size, int startgrid) { int x, y, g, g2, amplitude, size1 = size - 1, sizepower, gridpower; #define n(x,y) noise[((y)&size1)*size+((x)&size1)] @@ -110,13 +110,13 @@ void fractalnoisequick(qbyte *noise, int size, int startgrid) // diamond for (y = 0;y < size;y += g2) for (x = 0;x < size;x += g2) - n(x+g,y+g) = (qbyte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x,y+g2) + (int) n(x+g2,y+g2)) >> 2); + n(x+g,y+g) = (unsigned char) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x,y+g2) + (int) n(x+g2,y+g2)) >> 2); // square for (y = 0;y < size;y += g2) for (x = 0;x < size;x += g2) { - n(x+g,y) = (qbyte) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x+g,y-g) + (int) n(x+g,y+g)) >> 2); - n(x,y+g) = (qbyte) (((int) n(x,y) + (int) n(x,y+g2) + (int) n(x-g,y+g) + (int) n(x+g,y+g)) >> 2); + n(x+g,y) = (unsigned char) (((int) n(x,y) + (int) n(x+g2,y) + (int) n(x+g,y-g) + (int) n(x+g,y+g)) >> 2); + n(x,y+g) = (unsigned char) (((int) n(x,y) + (int) n(x,y+g2) + (int) n(x-g,y+g) + (int) n(x+g,y+g)) >> 2); } } }