summaryrefslogtreecommitdiff
path: root/src/elements/prti.c
blob: 33b449fd5cf8e54f9da15028fb4d2d78dde7ce82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <powder.h>

int update_PRTI(UPDATE_FUNC_ARGS) {
	int r, temp, nnx, temprange = 100;
	int count =0;
	for ( temp = 0; temp < MAX_TEMP; temp += temprange)
		if (parts[i].temp-73.15>temp&&parts[i].temp-73.15 <temp+temprange)
			parts[i].tmp = temp/100;
	for (ny=-1; ny<2; ny++)
		for (nx=-1; nx<2; nx++)
			if (x+nx>=0 && y+ny>0 &&
			        x+nx<XRES && y+ny<YRES && (nx || ny))
			{
				count ++;
				r = pmap[y+ny][x+nx];
				if ((r>>8)>=NPART || !r)
					continue;
				if (parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)))
					for ( nnx=0; nnx<80; nnx++)
						if (!portal[parts[i].tmp][count-1][nnx])
						{
							portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
							portaltemp[parts[i].tmp][count-1][nnx] = parts[r>>8].temp;
							if (parts[r>>8].type==PT_SPRK)
								parts[r>>8].type = parts[r>>8].ctype;
							else
								parts[r>>8].type = PT_NONE;
							break;
						}
			}
	return 0;
}