Revert "nice"

This reverts commit 14b4dfef87.
This commit is contained in:
Simon
2010-12-20 18:11:11 +00:00
parent 14b4dfef87
commit 5026bfa105
8 changed files with 2586 additions and 2579 deletions

View File

@@ -2,7 +2,7 @@ SOURCES := src/*.c
CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/ CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
LFLAGS := -lSDL -lm -lbz2 LFLAGS := -B static -lSDL -lm -lbz2
MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3 MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3
MFLAGS_SSE2 := -march=native-DX86 -DX86_SSE2 -msse2 MFLAGS_SSE2 := -march=native-DX86 -DX86_SSE2 -msse2
MFLAGS_SSE := -march=native -DX86 -DX86_SSE MFLAGS_SSE := -march=native -DX86 -DX86_SSE

0
includes/font.h Normal file → Executable file
View File

View File

@@ -1012,7 +1012,7 @@ void textnpos(char *s, int n, int w, int *cx, int *cy)
//TODO: Implement Textnheight for wrapped text //TODO: Implement Textnheight for wrapped text
for(; *s; s++) for(; *s; s++)
{ {
if(!n) { if(!n){
break; break;
} }
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
@@ -1306,8 +1306,8 @@ void draw_parts(pixel *vid)
float pt = R_TEMP; float pt = R_TEMP;
if(GRID_MODE) if(GRID_MODE)
{ {
for(ny=0; ny<YRES; ny++) for(ny=0;ny<YRES;ny++)
for(nx=0; nx<XRES; nx++) for(nx=0;nx<XRES;nx++)
{ {
if(ny%(4*GRID_MODE)==0) if(ny%(4*GRID_MODE)==0)
blendpixel(vid, nx, ny, 100, 100, 100, 80); blendpixel(vid, nx, ny, 100, 100, 100, 80);

View File

@@ -246,7 +246,7 @@ void ui_edit_draw(pixel *vid_buf, ui_edit *ed)
if(ed->str[0]) if(ed->str[0])
{ {
if(ed->multiline) { if(ed->multiline){
drawtextwrap(vid_buf, ed->x, ed->y, ed->w-14, str, 255, 255, 255, 255); drawtextwrap(vid_buf, ed->x, ed->y, ed->w-14, str, 255, 255, 255, 255);
drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255); drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255);
} else { } else {
@@ -258,7 +258,7 @@ void ui_edit_draw(pixel *vid_buf, ui_edit *ed)
drawtext(vid_buf, ed->x, ed->y, ed->def, 128, 128, 128, 255); drawtext(vid_buf, ed->x, ed->y, ed->def, 128, 128, 128, 255);
if(ed->focus) if(ed->focus)
{ {
if(ed->multiline) { if(ed->multiline){
textnpos(str, ed->cursor, ed->w-14, &cx, &cy); textnpos(str, ed->cursor, ed->w-14, &cx, &cy);
} else { } else {
cx = textnwidth(str, ed->cursor); cx = textnwidth(str, ed->cursor);
@@ -290,7 +290,7 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed)
else else
str = ed->str; str = ed->str;
if(ed->multiline) { if(ed->multiline){
if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11) if(mx>=ed->x+ed->w-11 && mx<ed->x+ed->w && my>=ed->y-5 && my<ed->y+11)
{ {
ed->focus = 1; ed->focus = 1;
@@ -1680,7 +1680,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
SLALT = h; SLALT = h;
SEC2 = -1; SEC2 = -1;
} }
else { else{
*sl = h; *sl = h;
} }
} }
@@ -1699,7 +1699,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
SLALT = h; SLALT = h;
SEC2 = -1; SEC2 = -1;
} }
else { else{
*sr = h; *sr = h;
} }
} }
@@ -2619,7 +2619,7 @@ int report_ui(pixel* vid_buf, char *save_id)
if(!b) if(!b)
break; break;
} }
while(!sdl_poll()) { while(!sdl_poll()){
fillrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 0,0,0, 255); fillrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 0,0,0, 255);
drawrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 255, 255, 255, 255); drawrect(vid_buf, 200, 150, (XRES+BARSIZE-400), (YRES+MENUSIZE-300), 255, 255, 255, 255);
@@ -2636,10 +2636,10 @@ int report_ui(pixel* vid_buf, char *save_id)
drawrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255); drawrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255);
drawtext(vid_buf, (XRES+BARSIZE-400)+163, (YRES+MENUSIZE-150)-13, "Report", 255, 255, 255, 255); drawtext(vid_buf, (XRES+BARSIZE-400)+163, (YRES+MENUSIZE-150)-13, "Report", 255, 255, 255, 255);
if(mx>(XRES+BARSIZE-400)+150 && my>(YRES+MENUSIZE-150)-18 && mx<(XRES+BARSIZE-400)+200 && my<(YRES+MENUSIZE-150)) { if(mx>(XRES+BARSIZE-400)+150 && my>(YRES+MENUSIZE-150)-18 && mx<(XRES+BARSIZE-400)+200 && my<(YRES+MENUSIZE-150)){
fillrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40); fillrect(vid_buf, (XRES+BARSIZE-400)+150, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
if(b) { if(b){
if(execute_report(vid_buf, save_id, ed.str)) { if(execute_report(vid_buf, save_id, ed.str)){
info_ui(vid_buf, "Success", "This save has been reported"); info_ui(vid_buf, "Success", "This save has been reported");
return 1; return 1;
} else { } else {
@@ -2647,7 +2647,7 @@ int report_ui(pixel* vid_buf, char *save_id)
} }
} }
} }
if(mx>200 && my>(YRES+MENUSIZE-150)-18 && mx<250 && my<(YRES+MENUSIZE-150)) { if(mx>200 && my>(YRES+MENUSIZE-150)-18 && mx<250 && my<(YRES+MENUSIZE-150)){
fillrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40); fillrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 40);
if(b) if(b)
return 0; return 0;
@@ -2756,7 +2756,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
if(status == 200) if(status == 200)
{ {
pixel *full_save = prerender_save(data, data_size, &imgw, &imgh); pixel *full_save = prerender_save(data, data_size, &imgw, &imgh);
if(full_save!=NULL) { if(full_save!=NULL){
save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2); save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2);
data_ready = 1; data_ready = 1;
free(full_save); free(full_save);
@@ -2837,12 +2837,12 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
ccy = 0; ccy = 0;
for(cc=0; cc<info->comment_count; cc++) { for(cc=0; cc<info->comment_count; cc++) {
if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)) { if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)){
drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255); drawtext(vid_buf, 60+(XRES/2)+1, ccy+60, info->commentauthors[cc], 255, 255, 255, 255);
ccy += 12; ccy += 12;
ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185); ccy += drawtextwrap(vid_buf, 60+(XRES/2)+1, ccy+60, XRES+BARSIZE-100-((XRES/2)+1)-20, info->comments[cc], 255, 255, 255, 185);
ccy += 10; ccy += 10;
if(ccy+52<YRES+MENUSIZE-50) { //Try not to draw off the screen. if(ccy+52<YRES+MENUSIZE-50){ //Try not to draw off the screen.
draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE); draw_line(vid_buf, 50+(XRES/2)+2, ccy+52, XRES+BARSIZE-50, ccy+52, 100, 100, 100, XRES+BARSIZE);
} }
} }
@@ -2852,7 +2852,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
authoritah = svf_login && (!strcmp(info->author, svf_user) || svf_admin || svf_mod); authoritah = svf_login && (!strcmp(info->author, svf_user) || svf_admin || svf_mod);
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
} }
if(info_ready && svf_login) { if(info_ready && svf_login){
//Render the comment box. //Render the comment box.
fillrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 0, 0, 0, 255); fillrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 0, 0, 0, 255);
drawrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 200, 200, 200, 255); drawrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 200, 200, 200, 255);
@@ -2917,7 +2917,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
if(b && !bq) { if(b && !bq) {
//Button Clicked //Button Clicked
if(report_ui(vid_buf, save_id)) { if(report_ui(vid_buf, save_id)){
retval = 0; retval = 0;
break; break;
} }
@@ -2928,20 +2928,20 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40);
if(b && !bq) { if(b && !bq) {
//Button Clicked //Button Clicked
if(myown || !info->publish) { if(myown || !info->publish){
if(confirm_ui(vid_buf, "Are you sure you wish to delete this?", "You will not be able recover it.", "Delete")) { if(confirm_ui(vid_buf, "Are you sure you wish to delete this?", "You will not be able recover it.", "Delete")){
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
info_box(vid_buf, "Deleting..."); info_box(vid_buf, "Deleting...");
if(execute_delete(vid_buf, save_id)) { if(execute_delete(vid_buf, save_id)){
retval = 0; retval = 0;
break; break;
} }
} }
} else { } else {
if(confirm_ui(vid_buf, "Are you sure?", "This save will be removed from the search index.", "Remove")) { if(confirm_ui(vid_buf, "Are you sure?", "This save will be removed from the search index.", "Remove")){
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
info_box(vid_buf, "Removing..."); info_box(vid_buf, "Removing...");
if(execute_delete(vid_buf, save_id)) { if(execute_delete(vid_buf, save_id)){
retval = 0; retval = 0;
break; break;
} }
@@ -2973,7 +2973,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
ed.str[0] = 0; ed.str[0] = 0;
} }
} }
if(!(mx>50 && my>50 && mx<XRES+BARSIZE-50 && my<YRES+MENUSIZE-50) && b && !queue_open) { if(!(mx>50 && my>50 && mx<XRES+BARSIZE-50 && my<YRES+MENUSIZE-50) && b && !queue_open){
retval = 0; retval = 0;
break; break;
} }
@@ -3026,16 +3026,16 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128);
} }
} }
if(!info_ready || !data_ready) { if(!info_ready || !data_ready){
info_box(vid_buf, "Loading"); info_box(vid_buf, "Loading");
} }
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
if(info_ready && svf_login) { if(info_ready && svf_login){
ui_edit_process(mx, my, b, &ed); ui_edit_process(mx, my, b, &ed);
} }
if(sdl_key==SDLK_ESCAPE) { if(sdl_key==SDLK_ESCAPE){
retval = 0; retval = 0;
break; break;
} }
@@ -3737,7 +3737,7 @@ int execute_vote(pixel *vid_buf, char *id, char *action)
free(result); free(result);
return 1; return 1;
} }
void open_link(char *uri) { void open_link(char *uri){
#ifdef WIN32 #ifdef WIN32
ShellExecute(0, "OPEN", uri, NULL, NULL, 0); ShellExecute(0, "OPEN", uri, NULL, NULL, 0);
#elif MACOSX #elif MACOSX

View File

@@ -307,7 +307,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
for(j=0; j<w*h; j++) for(j=0; j<w*h; j++)
{ {
i = m[j]; i = m[j];
if(i) { if(i){
//Everybody loves a 16bit int //Everybody loves a 16bit int
//d[p++] = (parts[i-1].life+3)/4; //d[p++] = (parts[i-1].life+3)/4;
int ttlife = (int)parts[i-1].life; int ttlife = (int)parts[i-1].life;
@@ -318,7 +318,7 @@ void *build_save(int *size, int x0, int y0, int w, int h)
for(j=0; j<w*h; j++) for(j=0; j<w*h; j++)
{ {
i = m[j]; i = m[j];
if(i) { if(i){
//Now saving tmp! //Now saving tmp!
//d[p++] = (parts[i-1].life+3)/4; //d[p++] = (parts[i-1].life+3)/4;
int tttmp = (int)parts[i-1].tmp; int tttmp = (int)parts[i-1].tmp;
@@ -427,13 +427,13 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
} }
else else
{ {
if(ver>=44) { if(ver>=44){
legacy_enable = c[3]&0x01; legacy_enable = c[3]&0x01;
if(!sys_pause) { if(!sys_pause){
sys_pause = (c[3]>>1)&0x01; sys_pause = (c[3]>>1)&0x01;
} }
} else { } else {
if(c[3]==1||c[3]==0) { if(c[3]==1||c[3]==0){
legacy_enable = c[3]; legacy_enable = c[3];
} else { } else {
legacy_beta = 1; legacy_beta = 1;
@@ -671,7 +671,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
i = m[j]; i = m[j];
if(i) if(i)
{ {
if(ver>=44) { if(ver>=44){
if(p >= size) { if(p >= size) {
goto corrupt; goto corrupt;
} }
@@ -692,7 +692,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
} }
} }
} }
if(ver>=44) { if(ver>=44){
for(j=0; j<w*h; j++) for(j=0; j<w*h; j++)
{ {
i = m[j]; i = m[j];
@@ -1492,8 +1492,8 @@ int main(int argc, char *argv[])
if(sdl_key=='i') if(sdl_key=='i')
{ {
int nx, ny; int nx, ny;
for(nx = 0; nx<XRES/CELL; nx++) for(nx = 0;nx<XRES/CELL;nx++)
for(ny = 0; ny<YRES/CELL; ny++) for(ny = 0;ny<YRES/CELL;ny++)
{ {
pv[ny][nx] = -pv[ny][nx]; pv[ny][nx] = -pv[ny][nx];
vx[ny][nx] = -vx[ny][nx]; vx[ny][nx] = -vx[ny][nx];
@@ -2033,7 +2033,7 @@ int main(int argc, char *argv[])
memset(fire_g, 0, sizeof(fire_g)); memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b)); memset(fire_b, 0, sizeof(fire_b));
} }
if(x>=19 && x<=35 && svf_last && svf_open && !bq) { if(x>=19 && x<=35 && svf_last && svf_open && !bq){
//int tpval = sys_pause; //int tpval = sys_pause;
parse_save(svf_last, svf_lsize, 1, 0, 0); parse_save(svf_last, svf_lsize, 1, 0, 0);
//sys_pause = tpval; //sys_pause = tpval;

View File

@@ -101,7 +101,7 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID) if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID)
return 0; return 0;
if(r && (r&0xFF) < PT_NUM) { if(r && (r&0xFF) < PT_NUM){
if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY) if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY)
return 2; return 2;
@@ -283,10 +283,7 @@ static int is_boundary(int pt, int x, int y)
{ {
if(!is_blocking(pt,x,y)) if(!is_blocking(pt,x,y))
return 0; return 0;
if(is_blocking(pt,x,y-1) if(is_blocking(pt,x,y-1) && is_blocking(pt,x,y+1) && is_blocking(pt,x-1,y) && is_blocking(pt,x+1,y))
&& is_blocking(pt,x,y+1)
&& is_blocking(pt,x-1,y)
&& is_blocking(pt,x+1,y))
return 0; return 0;
return 1; return 1;
} }
@@ -394,8 +391,7 @@ void kill_part(int i)
{ {
int x, y; int x, y;
if(parts[i].type != PT_PHOT) if(parts[i].type != PT_PHOT) {
{
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);
if(parts[i].type == PT_STKM) if(parts[i].type == PT_STKM)
@@ -403,20 +399,20 @@ void kill_part(int i)
death = 1; death = 1;
isplayer = 0; isplayer = 0;
} }
else if(parts[i].type == PT_STKM2) if(parts[i].type == PT_STKM2)
{ {
death2 = 1; death2 = 1;
isplayer2 = 0; isplayer2 = 0;
} }
else if(parts[i].type == PT_SPAWN) if(parts[i].type == PT_SPAWN)
{ {
ISSPAWN1 = 0; ISSPAWN1 = 0;
} }
else if(parts[i].type == PT_SPAWN2) if(parts[i].type == PT_SPAWN2)
{ {
ISSPAWN2 = 0; ISSPAWN2 = 0;
} }
else if(x>=0 && y>=0 && x<XRES && y<YRES) if(x>=0 && y>=0 && x<XRES && y<YRES)
pmap[y][x] = 0; pmap[y][x] = 0;
} }
@@ -463,27 +459,28 @@ inline int create_part(int p, int x, int y, int t)
} }
if(t==SPC_AIR) if(t==SPC_AIR)
{ {
if(y + CELL < YRES && x + CELL < XRES)
pv[y/CELL][x/CELL] += 0.03f; pv[y/CELL][x/CELL] += 0.03f;
/* if(x+CELL<XRES) if(y+CELL<YRES)
pv[y/CELL+1][x/CELL] += 0.03f;
if(x+CELL<XRES)
{ {
pv[y/CELL][x/CELL+1] += 0.03f; pv[y/CELL][x/CELL+1] += 0.03f;
if(y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += 0.03f; pv[y/CELL+1][x/CELL+1] += 0.03f;
}*/ }
return -1; return -1;
} }
if(t==SPC_VACUUM) if(t==SPC_VACUUM)
{ {
if (y + CELL < YRES && x + CELL < XRES)
pv[y/CELL][x/CELL] -= 0.03f; pv[y/CELL][x/CELL] -= 0.03f;
/*if(y+CELL<YRES) if(y+CELL<YRES)
pv[y/CELL+1][x/CELL] -= 0.03f; pv[y/CELL+1][x/CELL] -= 0.03f;
if(x+CELL<XRES) if(x+CELL<XRES)
{ {
pv[y/CELL][x/CELL+1] -= 0.03f; pv[y/CELL][x/CELL+1] -= 0.03f;
if(y+CELL<YRES) if(y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] -= 0.03f; pv[y/CELL+1][x/CELL+1] -= 0.03f;
}*/ }
return -1; return -1;
} }
@@ -1032,7 +1029,7 @@ void update_particles_i(pixel *vid, int start, int inc)
GRAV_R2 = 30; GRAV_R2 = 30;
GRAV_G2 = 30; GRAV_G2 = 30;
GRAV_B2 = 0; GRAV_B2 = 0;
for( q = 0; q <= GRAV; q++) for( q = 0;q <= GRAV;q++)
{ {
if(GRAV_R >0 && GRAV_G==0) if(GRAV_R >0 && GRAV_G==0)
{ {
@@ -1071,9 +1068,9 @@ void update_particles_i(pixel *vid, int start, int inc)
if(ISLOVE==1) if(ISLOVE==1)
{ {
ISLOVE = 0; ISLOVE = 0;
for(ny=0; ny<YRES-4; ny++) for(ny=0;ny<YRES-4;ny++)
{ {
for(nx=0; nx<XRES-4; nx++) for(nx=0;nx<XRES-4;nx++)
{ {
r=pmap[ny][nx]; r=pmap[ny][nx];
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
@@ -1089,14 +1086,14 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
} }
for(nx=9; nx<=XRES-18; nx++) for(nx=9;nx<=XRES-18;nx++)
{ {
for(ny=9; ny<=YRES-7; ny++) for(ny=9;ny<=YRES-7;ny++)
{ {
if(love[nx/9][ny/9]==1) if(love[nx/9][ny/9]==1)
{ {
for( nnx=0; nnx<9; nnx++) for( nnx=0;nnx<9;nnx++)
for( nny=0; nny<9; nny++) for( nny=0;nny<9;nny++)
{ {
if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES) if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
{ {
@@ -1122,31 +1119,40 @@ void update_particles_i(pixel *vid, int start, int inc)
if(ISLOLZ==1) if(ISLOLZ==1)
{ {
ISLOLZ = 0; ISLOLZ = 0;
for(ny=0; ny<YRES-4; ny++) for(ny=0;ny<YRES-4;ny++)
for(nx=0; nx<XRES-4; nx++) {
for(nx=0;nx<XRES-4;nx++)
{ {
r=pmap[ny][nx]; r=pmap[ny][nx];
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
{
continue; continue;
}
else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ) else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ)
parts[r>>8].type = PT_NONE; parts[r>>8].type = PT_NONE;
else if(parts[r>>8].type==PT_LOLZ) else if(parts[r>>8].type==PT_LOLZ)
{
lolz[nx/9][ny/9] = 1; lolz[nx/9][ny/9] = 1;
}
} }
for(nx=9; nx<=XRES-18; nx++) }
for(nx=9;nx<=XRES-18;nx++)
{ {
for(ny=9; ny<=YRES-7; ny++) for(ny=9;ny<=YRES-7;ny++)
{ {
if(lolz[nx/9][ny/9]==1) if(lolz[nx/9][ny/9]==1)
{ {
for( nnx=0; nnx<9; nnx++) for( nnx=0;nnx<9;nnx++)
for( nny=0; nny<9; nny++) for( nny=0;nny<9;nny++)
{
if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES) if(ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
{ {
rt=pmap[ny+nny][nx+nnx]; rt=pmap[ny+nny][nx+nnx];
if((rt>>8)>=NPART) if((rt>>8)>=NPART)
{
continue; continue;
}
if(!rt&&lolzrule[nny][nnx]==1) if(!rt&&lolzrule[nny][nnx]==1)
create_part(-1,nx+nnx,ny+nny,PT_LOLZ); create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
else if(!rt) else if(!rt)
@@ -1156,6 +1162,7 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
} }
}
lolz[nx/9][ny/9]=0; lolz[nx/9][ny/9]=0;
} }
} }
@@ -1163,8 +1170,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
{ {
int createdsomething = 0; int createdsomething = 0;
for(nx=4; nx<XRES-4; nx++) for(nx=4;nx<XRES-4;nx++)
for(ny=4; ny<YRES-4; ny++) for(ny=4;ny<YRES-4;ny++)
{ {
CGOL=0; CGOL=0;
ISGOL=0; ISGOL=0;
@@ -1175,60 +1182,60 @@ void update_particles_i(pixel *vid, int start, int inc)
continue; continue;
} }
else else
for( golnum=1; golnum<NGOL; golnum++) for( golnum=1;golnum<NGOL;golnum++)
if(parts[r>>8].type==golnum+77) if(parts[r>>8].type==golnum+77)
{ {
gol[nx][ny] = golnum; gol[nx][ny] = golnum;
for( nnx=-1; nnx<2; nnx++) for( nnx=-1;nnx<2;nnx++)
for( nny=-1; nny<2; nny++) //it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check for( nny=-1;nny<2;nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
{ {
if(ny+nny<4&&nx+nnx<4) { //any way to make wrapping code smaller? if(ny+nny<4&&nx+nnx<4){//any way to make wrapping code smaller?
gol2[XRES-5][YRES-5][golnum] ++; gol2[XRES-5][YRES-5][golnum] ++;
gol2[XRES-5][YRES-5][0] ++; gol2[XRES-5][YRES-5][0] ++;
} }
else if(ny+nny<4&&nx+nnx>=XRES-4) { else if(ny+nny<4&&nx+nnx>=XRES-4){
gol2[4][YRES-5][golnum] ++; gol2[4][YRES-5][golnum] ++;
gol2[4][YRES-5][0] ++; gol2[4][YRES-5][0] ++;
} }
else if(ny+nny>=YRES-4&&nx+nnx<4) { else if(ny+nny>=YRES-4&&nx+nnx<4){
gol2[XRES-5][4][golnum] ++; gol2[XRES-5][4][golnum] ++;
gol2[XRES-5][4][0] ++; gol2[XRES-5][4][0] ++;
} }
else if(nx+nnx<4) { else if(nx+nnx<4){
gol2[XRES-5][ny+nny][golnum] ++; gol2[XRES-5][ny+nny][golnum] ++;
gol2[XRES-5][ny+nny][0] ++; gol2[XRES-5][ny+nny][0] ++;
} }
else if(ny+nny<4) { else if(ny+nny<4){
gol2[nx+nnx][YRES-5][golnum] ++; gol2[nx+nnx][YRES-5][golnum] ++;
gol2[nx+nnx][YRES-5][0] ++; gol2[nx+nnx][YRES-5][0] ++;
} }
else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4) { else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4){
gol2[4][4][golnum] ++; gol2[4][4][golnum] ++;
gol2[4][4][0] ++; gol2[4][4][0] ++;
} }
else if(ny+nny>=YRES-4) { else if(ny+nny>=YRES-4){
gol2[nx+nnx][4][golnum] ++; gol2[nx+nnx][4][golnum] ++;
gol2[nx+nnx][4][0] ++; gol2[nx+nnx][4][0] ++;
} }
else if(nx+nnx>=XRES-4) { else if(nx+nnx>=XRES-4){
gol2[4][ny+nny][golnum] ++; gol2[4][ny+nny][golnum] ++;
gol2[4][ny+nny][0] ++; gol2[4][ny+nny][0] ++;
} }
else { else{
gol2[nx+nnx][ny+nny][golnum] ++; gol2[nx+nnx][ny+nny][golnum] ++;
gol2[nx+nnx][ny+nny][0] ++; gol2[nx+nnx][ny+nny][0] ++;
} }
} }
} }
} }
for(nx=4; nx<XRES-4; nx++) for(nx=4;nx<XRES-4;nx++)
for(ny=4; ny<YRES-4; ny++) for(ny=4;ny<YRES-4;ny++)
{ {
int neighbors = gol2[nx][ny][0]; int neighbors = gol2[nx][ny][0];
if(neighbors==0) if(neighbors==0)
continue; continue;
for( golnum = 1; golnum<NGOL; golnum++) for( golnum = 1;golnum<NGOL;golnum++)
for( goldelete = 0; goldelete<9; goldelete++) for( goldelete = 0;goldelete<9;goldelete++)
{ {
if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
{ {
@@ -1239,7 +1246,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[pmap[ny][nx]>>8].type = PT_NONE; parts[pmap[ny][nx]>>8].type = PT_NONE;
} }
gol2[nx][ny][0] = 0; gol2[nx][ny][0] = 0;
for( z = 1; z<NGOL; z++) for( z = 1;z<NGOL;z++)
gol2[nx][ny][z] = 0; gol2[nx][ny][z] = 0;
} }
if(createdsomething) if(createdsomething)
@@ -1252,7 +1259,7 @@ void update_particles_i(pixel *vid, int start, int inc)
//} //}
if(ISWIRE==1) if(ISWIRE==1)
{ {
for( q = 0; q<99; q++) for( q = 0;q<99;q++)
if(!wireless[q][1]) if(!wireless[q][1])
{ {
wireless[q][0] = 0; wireless[q][0] = 0;
@@ -1423,7 +1430,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL]; parts[i].vx -= ptypes[t].advection*vx[y/CELL][x/CELL];
parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity; parts[i].vy -= ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
} }
else { else{
parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL];
parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity; parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity;
@@ -1698,7 +1705,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{ {
t = parts[i].type = pstates[t].gas; t = parts[i].type = pstates[t].gas;
} }
else { else{
t = parts[i].type = pstates[t].gas; t = parts[i].type = pstates[t].gas;
pv[y/CELL][x/CELL] += 0.50f; pv[y/CELL][x/CELL] += 0.50f;
} }
@@ -1971,46 +1978,46 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
} }
} }
else if(t==PT_ARAY && parts[i].life==0) { else if(t==PT_ARAY && parts[i].life==0){
for(nx=-1; nx<2; nx++) { for(nx=-1; nx<2; nx++){
for(ny=-1; ny<2; ny++) { for(ny=-1; ny<2; ny++){
if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny)) { if(x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny)){
r = pmap[y+ny][x+nx]; r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
continue; continue;
if((r&0xFF)==PT_SPRK) { if((r&0xFF)==PT_SPRK){
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) { for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) {
if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) { if(!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)){
break; break;
} }
r = pmap[y+nyi+nyy][x+nxi+nxx]; r = pmap[y+nyi+nyy][x+nxi+nxx];
if(!((r>>8)>=NPART)) { if(!((r>>8)>=NPART)) {
if(!r) { if(!r){
int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
if(nr!=-1&&destroy) { if(nr!=-1&&destroy){
parts[nr].tmp = 2; parts[nr].tmp = 2;
parts[nr].life = 2; parts[nr].life = 2;
} }
} else if(!destroy) { } else if(!destroy) {
if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0) { if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0){
if(nyy!=0 || nxx!=0) { if(nyy!=0 || nxx!=0){
parts[r>>8].type = PT_BRAY; parts[r>>8].type = PT_BRAY;
parts[r>>8].life = 1020; parts[r>>8].life = 1020;
parts[r>>8].tmp = 1; parts[r>>8].tmp = 1;
} }
docontinue = 0; docontinue = 0;
} else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1) { } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1){
parts[r>>8].life = 1020; parts[r>>8].life = 1020;
//docontinue = 1; //docontinue = 1;
} else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) { } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) {
if(nyy!=0 || nxx!=0) { if(nyy!=0 || nxx!=0){
create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
} }
docontinue = 0; docontinue = 0;
} }
} else if(destroy) { } else if(destroy) {
if(parts[r>>8].type==PT_BRAY) { if(parts[r>>8].type==PT_BRAY){
parts[r>>8].life = 1; parts[r>>8].life = 1;
docontinue = 1; docontinue = 1;
} else { } else {
@@ -2393,7 +2400,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{ {
create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN); create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN);
parts[r>>8].temp = MAX_TEMP; parts[r>>8].temp = MAX_TEMP;
if(parts[r>>8].type==PT_LAVA) { if(parts[r>>8].type==PT_LAVA){
parts[r>>8].tmp = 100; parts[r>>8].tmp = 100;
parts[r>>8].ctype = PT_PLUT; parts[r>>8].ctype = PT_PLUT;
} }
@@ -2583,7 +2590,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life--; parts[i].life--;
} }
} }
for( trade = 0; trade<9; trade ++) for( trade = 0; trade<9;trade ++)
{ {
nx = rand()%5-2; nx = rand()%5-2;
ny = rand()%5-2; ny = rand()%5-2;
@@ -2732,7 +2739,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[pmap[y+ny][x+nx]>>8].life = 0; parts[pmap[y+ny][x+nx]>>8].life = 0;
} }
} }
for( trade = 0; trade<4; trade ++) for( trade = 0; trade<4;trade ++)
{ {
nx = rand()%5-2; nx = rand()%5-2;
ny = rand()%5-2; ny = rand()%5-2;
@@ -2760,7 +2767,7 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
else if(t==PT_WARP) else if(t==PT_WARP)
{ {
for( trade = 0; trade<5; trade ++) for( trade = 0; trade<5;trade ++)
{ {
nx = rand()%3-1; nx = rand()%3-1;
ny = rand()%3-1; ny = rand()%3-1;
@@ -2925,8 +2932,8 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
} }
if(parts[i].ctype>1) if(parts[i].ctype>1)
for( q = 0; q<3; q++) for( q = 0;q<3;q++)
for( ctype = 2; ctype<5; ctype++) for( ctype = 2;ctype<5;ctype++)
{ {
if(parts[i].ctype==ctype) if(parts[i].ctype==ctype)
{ {
@@ -3071,7 +3078,7 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
continue; 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))) 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<8; nnx++) for( nnx=0;nnx<8;nnx++)
if(!portal[parts[i].tmp][count-1][nnx]) if(!portal[parts[i].tmp][count-1][nnx])
{ {
portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type; portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type;
@@ -3102,7 +3109,7 @@ void update_particles_i(pixel *vid, int start, int inc)
continue; continue;
if(!r) if(!r)
{ {
for( nnx =0 ; nnx<8; nnx++) for( nnx =0 ;nnx<8;nnx++)
{ {
int randomness = count + rand()%3-1; int randomness = count + rand()%3-1;
if(randomness<1) if(randomness<1)
@@ -3286,8 +3293,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if((r>>8)>=NPART || !r) if((r>>8)>=NPART || !r)
continue; continue;
else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
for( nnx=-1; nnx<2; nnx++) for( nnx=-1;nnx<2;nnx++)
for( nny=-1; nny<2; nny++) for( nny=-1;nny<2;nny++)
{ {
if(7>rand()%200&&parts[i].life==0) if(7>rand()%200&&parts[i].life==0)
{ {
@@ -3322,8 +3329,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if(!r) if(!r)
continue; continue;
else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
for( nnx=-1; nnx<2; nnx++) for( nnx=-1;nnx<2;nnx++)
for( nny=-1; nny<2; nny++) for( nny=-1;nny<2;nny++)
{ {
if(3>rand()%200&&parts[i].life==0) if(3>rand()%200&&parts[i].life==0)
{ {
@@ -3371,8 +3378,8 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].life=7; parts[r>>8].life=7;
} }
else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
for( nnx=-1; nnx<2; nnx++) for( nnx=-1;nnx<2;nnx++)
for( nny=-1; nny<2; nny++) for( nny=-1;nny<2;nny++)
{ {
if(2>rand()%3000&&parts[i].life==0) if(2>rand()%3000&&parts[i].life==0)
{ {
@@ -3415,8 +3422,8 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].life = 7; parts[r>>8].life = 7;
} }
else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0)
for( nnx=-1; nnx<2; nnx++) for( nnx=-1;nnx<2;nnx++)
for( nny=-1; nny<2; nny++) for( nny=-1;nny<2;nny++)
{ {
if(!pmap[y+ny+nny][x+nx+nnx]) if(!pmap[y+ny+nny][x+nx+nnx])
{ {
@@ -4655,7 +4662,7 @@ killed:
create_part(-1, x+nx, y+ny, parts[i].ctype); create_part(-1, x+nx, y+ny, parts[i].ctype);
} }
} }
} else { }else {
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
} }
} }
@@ -5480,7 +5487,7 @@ void update_particles(pixel *vid)
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert) void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{ {
//TODO: MSCC doesn't like arrays who's size is determined at runtime. //TODO: MSCC doesn't like arrays who's size is determined at runtime.
#if !(defined(WIN32) && !defined(__GNUC__)) #if !(defined(WIN32) && !defined(__GNUC__))
int cx = 0; int cx = 0;
int cy = 0; int cy = 0;
unsigned tpmap[area_h][area_w]; unsigned tpmap[area_h][area_w];
@@ -5701,7 +5708,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n; int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
int wall = c - 100; int wall = c - 100;
for(r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++) for(r=UI_ACTUALSTART;r<=UI_ACTUALSTART+UI_WALLCOUNT;r++)
{ {
if(wall==r) if(wall==r)
{ {