diff --git a/includes/powder.h b/includes/powder.h index 0d4ada5e7..8996ed417 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -866,4 +866,18 @@ int create_parts(int x, int y, int rx, int ry, int c); void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c); void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate); + +#if defined(WIN32) && !defined(__GNUC__) +extern _inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); +#else +extern inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); +#endif + + +#if defined(WIN32) && !defined(__GNUC__) +extern _inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); +#else +extern inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); +#endif + #endif diff --git a/src/elements/prti.c b/src/elements/prti.c index 560ba8ca7..fa87562fa 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -1,7 +1,7 @@ #include int update_PRTI(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry; + int r, nnx, rx, ry, fe = 0; int count =0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; @@ -12,6 +12,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || !r) continue; if ((r&0xFF)==PT_SPRK || ((r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (ptypes[r&0xFF].falldown!= 0 || ptypes[r&0xFF].state == ST_GAS))) @@ -28,5 +30,33 @@ int update_PRTI(UPDATE_FUNC_ARGS) { break; } } + + + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]>1){ + orbd[r] -= 12; + if(orbd[r]<1){ + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } else { + orbl[r] += 2; + orbl[r] = orbl[r]%255; + } + } else { + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/elements/prto.c b/src/elements/prto.c index fbbd5a13f..9bec996b1 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -1,7 +1,7 @@ #include int update_PRTO(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, np; + int r, nnx, rx, ry, np, fe = 0; int count = 0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; @@ -12,6 +12,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || r) continue; if (!r) @@ -51,5 +53,30 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } } } + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]<254){ + orbd[r] += 16; + if(orbd[r]>254){ + orbd[r] = 0; + orbl[r] = rand()%255; + } + //orbl[r] += 1; + //orbl[r] = orbl[r]%255; + } else { + orbd[r] = 0; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/graphics.c b/src/graphics.c index fb3d384f5..917d26768 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1341,6 +1341,8 @@ void xor_rect(pixel *vid, int x, int y, int w, int h) void draw_parts(pixel *vid) { int i, x, y, t, nx, ny, r, s; + int orbd[4] = {0, 0, 0, 0}; + int orbl[4] = {0, 0, 0, 0}; int cr, cg, cb; float fr, fg, fb; float pt = R_TEMP; @@ -1921,32 +1923,76 @@ void draw_parts(pixel *vid) } } } - else if (t==PT_PRTI && DEBUG_MODE) + else if (t==PT_PRTI) { - blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); - if (mousex==(nx) && mousey==(ny)) - { - int z; - for (z = 0; z255) fire_rv = 255; + fire_r[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_rv; + } + addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200); + } + if(DEBUG_MODE){ + blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); + if (mousex==(nx) && mousey==(ny)) + { + int z; + for (z = 0; z255) fire_bv = 255; + fire_b[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_bv; + } + addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200); + } + if(DEBUG_MODE){ + blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255); + if (mousex==(nx) && mousey==(ny)) + { + int z; + for (z = 0; z>8; + resblock1[2] = (block1&0x00FF0000)>>16; + resblock1[3] = (block1&0xFF000000)>>24; + + resblock2[0] = (block2&0x000000FF); + resblock2[1] = (block2&0x0000FF00)>>8; + resblock2[2] = (block2&0x00FF0000)>>16; + resblock2[3] = (block2&0xFF000000)>>24; +} + +#if defined(WIN32) && !defined(__GNUC__) +_inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) +#else +inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]) +#endif +{ + int block1tmp = 0; + int block2tmp = 0; + + block1tmp = (resblock1[0]&0xFF); + block1tmp |= (resblock1[1]&0xFF)<<8; + block1tmp |= (resblock1[2]&0xFF)<<16; + block1tmp |= (resblock1[3]&0xFF)<<24; + + block2tmp = (resblock2[0]&0xFF); + block2tmp |= (resblock2[1]&0xFF)<<8; + block2tmp |= (resblock2[2]&0xFF)<<16; + block2tmp |= (resblock2[3]&0xFF)<<24; + + *block1 = block1tmp; + *block2 = block2tmp; +} +