made all the shifts and type checks use defines, so it can be changed easier, and put it back to normal with a shift of 8.

This commit is contained in:
Cracker64 2011-01-19 13:48:59 -05:00
parent 5c65d69dac
commit ff01973658
4 changed files with 786 additions and 783 deletions

View File

@ -36,6 +36,9 @@
#define MAXSIGNS 16 #define MAXSIGNS 16
#define TAG_MAX 256 #define TAG_MAX 256
#define PS 8 //the particle number shift that also determines element limit
#define TYPE (int)pow(2,PS)-1 //where the type of the particle is stored in pmap
#define ZSIZE_D 16 #define ZSIZE_D 16
#define ZFACTOR_D 8 #define ZFACTOR_D 8
extern unsigned char ZFACTOR; extern unsigned char ZFACTOR;

View File

@ -2901,8 +2901,8 @@ void render_signs(pixel *vid_buf)
} }
if(strcmp(signs[i].text, "{t}")==0) if(strcmp(signs[i].text, "{t}")==0)
{ {
if((pmap[signs[i].y][signs[i].x]>>12)>0 && (pmap[signs[i].y][signs[i].x]>>12)<NPART) if((pmap[signs[i].y][signs[i].x]>>PS)>0 && (pmap[signs[i].y][signs[i].x]>>PS)<NPART)
sprintf(buff, "Temp: %4.2f", parts[pmap[signs[i].y][signs[i].x]>>12].temp-273.15); //...tempirature sprintf(buff, "Temp: %4.2f", parts[pmap[signs[i].y][signs[i].x]>>PS].temp-273.15); //...tempirature
else else
sprintf(buff, "Temp: 0.00"); //...tempirature sprintf(buff, "Temp: 0.00"); //...tempirature
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);

View File

@ -496,7 +496,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
{ {
x = (int)(parts[i].x+0.5f); x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f); y = (int)(parts[i].y+0.5f);
pmap[y][x] = (i<<12)|1; pmap[y][x] = (i<<PS)|1;
} }
else else
fp[nf++] = i; fp[nf++] = i;
@ -573,7 +573,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
{ {
if(pmap[y][x]) if(pmap[y][x])
{ {
k = pmap[y][x]>>12; k = pmap[y][x]>>PS;
parts[k].type = j; parts[k].type = j;
if(j == PT_PHOT) if(j == PT_PHOT)
parts[k].ctype = 0x3fffffff; parts[k].ctype = 0x3fffffff;
@ -1747,28 +1747,28 @@ int main(int argc, char *argv[])
}else{ }else{
cr = pmap[y/sdl_scale][x/sdl_scale]; cr = pmap[y/sdl_scale][x/sdl_scale];
} }
if(!((cr>>12)>=NPART || !cr)) if(!((cr>>PS)>=NPART || !cr))
{ {
#ifdef BETA #ifdef BETA
if(DEBUG_MODE) if(DEBUG_MODE)
{ {
int tctype = parts[cr>>12].ctype; int tctype = parts[cr>>PS].ctype;
if(tctype>=PT_NUM) if(tctype>=PT_NUM)
tctype = 0; tctype = 0;
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f, parts[cr>>12].life); sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&TYPE].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f, parts[cr>>PS].life);
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFFF].name, ptypes[parts[cr>>12].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f, parts[cr>>12].life); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&TYPE].name, ptypes[parts[cr>>PS].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f, parts[cr>>PS].life);
} else } else
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f, parts[cr>>12].life); sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&TYPE].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f, parts[cr>>PS].life);
#else #else
if(DEBUG_MODE) if(DEBUG_MODE)
{ {
int tctype = parts[cr>>12].ctype; int tctype = parts[cr>>PS].ctype;
if(tctype>=PT_NUM) if(tctype>=PT_NUM)
tctype = 0; tctype = 0;
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d,tmp: %d", ptypes[cr&0xFFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f, parts[cr>>12].life,parts[cr>>12].tmp); sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d,tmp: %d", ptypes[cr&TYPE].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f, parts[cr>>PS].life,parts[cr>>PS].tmp);
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFFF].name, ptypes[parts[cr>>12].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f, parts[cr>>12].life); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&TYPE].name, ptypes[parts[cr>>PS].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f, parts[cr>>PS].life);
} else { } else {
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>12].temp-273.15f); sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&TYPE].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>PS].temp-273.15f);
} }
#endif #endif
} }
@ -2235,9 +2235,9 @@ int main(int argc, char *argv[])
{ {
int cr; int cr;
cr = pmap[y][x]; cr = pmap[y][x];
if(!((cr>>12)>=NPART || !cr)) if(!((cr>>PS)>=NPART || !cr))
{ {
c = sl = cr&0xFFF; c = sl = cr&TYPE;
} }
else else
{ {

File diff suppressed because it is too large Load Diff