diff --git a/.gitignore b/.gitignore index 4e9c377b2..65b90da54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.*.swp +.directory powder.def gmon.out *.*.orig diff --git a/Makefile b/Makefile index 37e3c8d11..3a61b1183 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCES := src/*.c +SOURCES := src/*.c src/elements/*.c CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/ OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations diff --git a/includes/defines.h b/includes/defines.h index 562ee0dc6..f22a3c8e8 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -112,16 +112,16 @@ extern int death; struct sign { - int x,y,ju; - char text[256]; + int x,y,ju; + char text[256]; }; typedef struct sign sign; struct stamp { - char name[11]; - pixel *thumb; - int thumb_w, thumb_h, dodelete; + char name[11]; + pixel *thumb; + int thumb_w, thumb_h, dodelete; }; typedef struct stamp stamp; diff --git a/includes/font.h b/includes/font.h old mode 100755 new mode 100644 index 45aff5b16..d3a75fe94 --- a/includes/font.h +++ b/includes/font.h @@ -23,10 +23,10 @@ #define FONT_H 10 #ifdef INCLUDE_FONTDATA char font_data[] = { - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc7, 0x31, 0x0c, 0x02, 0x70, 0x04, 0x00, 0x00, 0x05, 0xcc, 0x74, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x80, 0x19, 0xcc, 0xe0, 0x3f, 0xcc, 0xf0, 0x2f, 0xcc, 0x90, 0x09, 0x00, 0x00, 0x00, 0x06, 0x30, 0xd0, 0x3f, 0x33, 0xe1, 0x07, 0xf4, 0x12, 0x33, 0xff, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x2d, 0xce, 0xcc, 0xe1, 0x1d, 0xc0, 0x03, 0x74, 0x4b, 0x33, 0xb3, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7d, 0x30, 0x0c, 0x13, 0xd0, 0x32, 0xb3, 0x33, 0x1c, 0x7d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4c, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x34, 0x1d, 0x07, 0x03, 0x07, 0x1d, 0x34, 0x00, 0x00, 0x00, 0x04, 0x07, 0x1d, 0x34, 0x30, 0x34, 0x1d, 0x07, 0x00, 0x00, 0x00, 0x06, 0x44, 0xd0, 0x1c, 0x64, 0xf0, 0x3f, 0x64, 0xd0, 0x1c, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02, 0x30, 0xe0, 0x2f, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0d, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, 0x70, 0x00, 0x00, 0x00, 0x06, 0x80, 0x02, 0x0c, 0xa0, 0x00, 0x03, 0x28, 0xc0, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xe0, 0x39, 0x07, 0x33, 0x32, 0x03, 0xb3, 0x38, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x30, 0xf0, 0x60, 0x03, 0x0c, 0x30, 0xc0, 0x40, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x41, 0x03, 0x0a, 0x2c, 0x70, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0x71, 0x34, 0x01, 0x03, 0x1e, 0x00, 0x33, 0x34, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xc0, 0x03, 0x37, 0x1c, 0x73, 0x34, 0xbf, 0x03, 0x30, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x33, 0x00, 0x57, 0xe0, 0x2f, 0x00, 0x13, 0x30, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd3, 0x00, 0x07, 0xf0, 0x1f, 0x03, 0x33, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x07, 0x34, 0x80, 0x03, 0x0e, 0x38, 0xd0, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x03, 0xd3, 0x1f, 0x03, 0x73, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x03, 0xc3, 0x3f, 0x40, 0x23, 0x30, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x70, 0x04, 0x40, 0x70, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x1c, 0x04, 0x00, 0x0c, 0x0d, 0x03, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc0, 0xc3, 0x0b, 0x1b, 0xc0, 0x0b, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x0f, 0x90, 0x83, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfd, 0x71, 0x30, 0x81, 0x03, 0x0e, 0x34, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf8, 0x0f, 0x1d, 0x30, 0xe7, 0x37, 0x73, 0x1c, 0xe3, 0x2f, 0x07, 0x00, 0xfd, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x74, 0xd0, 0x1d, 0x47, 0x33, 0x30, 0xff, 0x33, 0x30, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xbf, 0x30, 0x38, 0x43, 0xf3, 0x1f, 0x43, 0x33, 0x34, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd1, 0x34, 0x03, 0x31, 0x00, 0x03, 0x70, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f, 0x30, 0x1d, 0x43, 0x33, 0x30, 0x03, 0x33, 0x34, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x32, 0x00, 0x03, 0xf0, 0x0b, 0x03, 0x30, 0x10, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x33, 0x10, 0x03, 0xf0, 0x0b, 0x03, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd1, 0x34, 0x03, 0x30, 0x3e, 0x03, 0x73, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x47, 0x33, 0x30, 0x03, 0xf3, 0x3f, 0x03, 0x33, 0x30, 0x47, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x1d, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1d, 0x00, 0x00, 0x00, 0x06, 0xd0, 0x01, 0x0c, 0xc0, 0x00, 0x0c, 0xc0, 0x10, 0x0d, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x47, 0xc3, 0x34, 0x70, 0x03, 0xbc, 0x00, 0xb3, 0xc0, 0xb0, 0x70, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x30, 0x10, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x03, 0x30, 0x1f, 0x3d, 0x7b, 0x3b, 0xe3, 0x32, 0x83, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0xcd, 0x03, 0x73, 0xc3, 0x8c, 0x32, 0xc3, 0xcd, 0xc0, 0x33, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf4, 0x41, 0xc7, 0x71, 0xd0, 0x0c, 0x30, 0x03, 0xcd, 0xd1, 0xd1, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f, 0x30, 0x1d, 0x43, 0x73, 0x34, 0xff, 0x31, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf4, 0x41, 0xd3, 0x71, 0xd0, 0x0c, 0x30, 0xc3, 0xcd, 0xd1, 0xd1, 0xdf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x31, 0x34, 0x03, 0xf3, 0x0f, 0xd7, 0x30, 0x34, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x31, 0x07, 0xd0, 0x0f, 0x90, 0x23, 0x34, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x13, 0x13, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xcc, 0x00, 0x33, 0xc0, 0x0c, 0x30, 0x03, 0xcd, 0xd2, 0xd1, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x33, 0x30, 0x03, 0xb3, 0x38, 0xcd, 0xc1, 0x0d, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x03, 0x30, 0x43, 0x30, 0xc7, 0x34, 0xcd, 0x1c, 0xed, 0x1e, 0x2c, 0x0e, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0x4c, 0xc3, 0x81, 0x3b, 0xd0, 0x03, 0xdc, 0x42, 0xc3, 0x31, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0xb3, 0x38, 0xdc, 0x40, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x0f, 0xd0, 0x02, 0x2c, 0xc0, 0x02, 0x2d, 0xc0, 0x06, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2f, 0x00, 0x00, 0x00, 0x05, 0x03, 0x28, 0xc0, 0x00, 0x0a, 0x30, 0x80, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3e, 0x00, 0x00, 0x00, 0x04, 0x1d, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x47, 0x30, 0xfc, 0x0c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x07, 0x0c, 0xf0, 0xc7, 0x35, 0xc3, 0x0c, 0xf3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc3, 0x25, 0x03, 0x4c, 0xd2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0xd0, 0x00, 0x83, 0x8f, 0x33, 0xc3, 0x1c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0xbf, 0x0c, 0xd0, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3d, 0x07, 0x03, 0x2f, 0x03, 0x03, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xc0, 0xcb, 0x32, 0xc3, 0xf4, 0x03, 0x4c, 0x30, 0x7e, 0x00, 0x00, 0x05, 0x03, 0x0c, 0xf0, 0xc7, 0x39, 0xc3, 0x0c, 0x73, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x1c, 0x00, 0x0d, 0x0c, 0x0c, 0x1d, 0x00, 0x00, 0x00, 0x04, 0x00, 0x30, 0x00, 0x34, 0x30, 0x30, 0x30, 0x30, 0x1e, 0x00, 0x05, 0x03, 0x0c, 0x31, 0xce, 0x0e, 0x1f, 0xcc, 0x31, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x47, 0x3d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9b, 0x71, 0x37, 0x33, 0x33, 0x32, 0x43, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xc7, 0x31, 0xc3, 0x0c, 0x33, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x31, 0xc3, 0x4c, 0xd3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xc7, 0x31, 0xc3, 0x4c, 0xf3, 0xc7, 0x00, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xdf, 0x31, 0xc3, 0x4c, 0xd3, 0x0f, 0x30, 0xc0, 0x00, 0x05, 0x03, 0x00, 0x30, 0x7f, 0xc7, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xc0, 0xc7, 0x10, 0x3c, 0x04, 0xf3, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x1c, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x70, 0xdc, 0x30, 0xc3, 0x4c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcc, 0x30, 0xd3, 0xdc, 0xc2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x33, 0x32, 0x33, 0x73, 0x37, 0xcd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcd, 0x32, 0x7d, 0x8c, 0x73, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcc, 0x30, 0xc7, 0x74, 0x43, 0x07, 0x0c, 0x1f, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0x4f, 0x2c, 0x2c, 0x2c, 0xf1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x04, 0x38, 0x0c, 0x0c, 0x03, 0x0c, 0x0c, 0x38, 0x00, 0x00, 0x00, 0x02, 0x32, 0x33, 0x33, 0x13, 0x00, 0x04, 0x0b, 0x0c, 0x0c, 0x30, 0x0c, 0x0c, 0x0b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1d, 0x72, 0x37, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x00, 0xff, 0x01, 0xff, 0x07, 0xff, 0x1f, 0xff, 0x7f, 0xff, 0x1b, 0xbf, 0x01, 0x1b, 0x00, 0x0c, 0x00, 0x40, 0xff, 0x00, 0x00, 0xf8, 0xf0, 0x3f, 0xee, 0x2c, 0x30, 0xcb, 0x0b, 0x30, 0x42, 0xc3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xf3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xff, 0x3f, 0x00, 0x0c, 0xc2, 0x00, 0x00, 0xcb, 0x00, 0x00, 0xee, 0xc0, 0xff, 0xf8, 0xb0, 0xc0, 0xff, 0x2c, 0xc0, 0x00, 0x0c, 0xcf, 0x00, 0x0c, 0xc0, 0x00, 0xcc, 0xcf, 0x00, 0x0c, 0xc0, 0x00, 0xfc, 0xff, 0x0a, 0x00, 0x00, 0x0d, 0x00, 0x70, 0x00, 0x00, 0xf3, 0xff, 0xd3, 0x03, 0xe0, 0x3c, 0x3f, 0x38, 0x03, 0xd0, 0x33, 0xff, 0x38, 0x03, 0xe0, 0xf0, 0xff, 0x03, 0x0c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x8b, 0xf7, 0x0c, 0x13, 0x9f, 0x3b, 0x37, 0x00, 0xc0, 0x23, 0xff, 0xff, 0x8b, 0x03, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0x03, 0x2c, 0x0d, 0x00, 0x37, 0x00, 0xc0, 0xf3, 0xff, 0x3c, 0xff, 0xcf, 0x03, 0x00, 0xdc, 0x00, 0x70, 0x38, 0xc0, 0x02, 0xfd, 0x07, 0x0a, 0x00, 0x00, 0x00, 0xfc, 0x03, 0xf0, 0xff, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0x03, 0xff, 0x0f, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x0a, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0x03, 0x00, 0x3c, 0xf0, 0xc0, 0xc3, 0x3a, 0x3c, 0x0b, 0xce, 0x2b, 0x80, 0x7e, 0x00, 0xd0, 0x03, 0x00, 0xfc, 0xff, 0xff, 0x0a, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0x03, 0x2c, 0x0d, 0x0f, 0x37, 0xf0, 0xc0, 0xf3, 0xff, 0x3c, 0xff, 0xcf, 0x03, 0x0f, 0xdc, 0xf0, 0x70, 0x38, 0xc0, 0x02, 0xfd, 0x07, 0x0a, 0x40, 0x1f, 0x00, 0xad, 0x07, 0xb0, 0xc5, 0x00, 0x17, 0x0c, 0x70, 0xd0, 0x00, 0x0c, 0x03, 0xbc, 0xef, 0xb3, 0x11, 0xe0, 0x07, 0x05, 0x3c, 0x52, 0xc8, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xc0, 0x3f, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, 0xf0, 0x00, 0xc0, 0x30, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0xfc, 0xff, 0x3f, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb8, 0xe0, 0x2f, 0xff, 0xe3, 0x2f, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0xff, 0x2f, 0xfd, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x7f, 0xf8, 0xff, 0x02, 0xfd, 0x07, 0x0a, 0x40, 0x01, 0x00, 0x02, 0x00, 0xc8, 0x07, 0x10, 0xc3, 0x00, 0x31, 0x0d, 0x00, 0xfd, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x0a, 0x40, 0x05, 0x80, 0xff, 0x8b, 0x1e, 0xd0, 0x2e, 0x00, 0xf0, 0x00, 0xe0, 0xff, 0x0b, 0x00, 0x0f, 0x00, 0xb8, 0x03, 0xb0, 0xe2, 0xff, 0x02, 0x50, 0x01, 0x08, 0xff, 0x07, 0x03, 0x1e, 0x03, 0x73, 0x03, 0xef, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x00, 0xe4, 0x2f, 0xe0, 0x1b, 0x0c, 0x1d, 0x00, 0xff, 0x03, 0xbe, 0xf0, 0xc1, 0x01, 0xad, 0x34, 0xc0, 0x36, 0x0b, 0x30, 0xdc, 0xe4, 0x07, 0xfd, 0x1b, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x02, 0xa0, 0xaa, 0x00, 0xa8, 0xc2, 0x0f, 0x2a, 0xff, 0x03, 0xca, 0x3f, 0x80, 0xfc, 0x0f, 0x20, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x01, 0x00, 0xc0, 0x07, 0xaa, 0xea, 0x1f, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xaa, 0xea, 0x1f, 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x40, 0x03, 0x00, 0xd0, 0x03, 0x00, 0xf4, 0xab, 0xaa, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xf4, 0xab, 0xaa, 0xd0, 0x03, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x09, 0xfe, 0xff, 0xe3, 0xff, 0x0f, 0xaa, 0x3e, 0x0a, 0xf8, 0x2e, 0xe0, 0xbf, 0x80, 0xff, 0xaa, 0xfe, 0xff, 0xe2, 0xff, 0x02, 0x02, 0x00, 0x00, 0x09, 0x00, 0x80, 0x04, 0xd0, 0xe2, 0xff, 0x02, 0x00, 0x00, 0xff, 0x6f, 0x00, 0x40, 0xe6, 0xaf, 0x50, 0x00, 0x09, 0x00, 0x20, 0x00, 0x64, 0x00, 0x09, 0xe0, 0x3f, 0x70, 0x60, 0x63, 0xc0, 0xe4, 0x80, 0xc2, 0x03, 0x07, 0x0f, 0x1e, 0x6c, 0xff, 0x27, 0xff, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x09, 0x44, 0x44, 0x00, 0x12, 0x41, 0x88, 0x04, 0x21, 0x21, 0x84, 0x48, 0x20, 0x23, 0xc2, 0xcc, 0x08, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x1d, 0x00, 0x1d, 0x00, 0x78, 0x00, 0xb4, 0x07, 0xf0, 0x2f, 0xc0, 0xfb, 0x00, 0xbe, 0x02, 0xf4, 0x07, 0xfd, 0xff, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x00, 0x19, 0x00, 0xa8, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0xf0, 0xdc, 0xcb, 0x03, 0x00, 0xff, 0xff, 0x4f, 0x07, 0x40, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xff, 0x3f, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0x07, 0x00, 0xbd, 0x02, 0xe8, 0xb3, 0xe0, 0x3c, 0xac, 0xc3, 0x03, 0x0f, 0x3c, 0x00, 0xc0, 0x03, 0x00, 0xfc, 0xff, 0xff, 0x0b, 0xc0, 0xc8, 0xc0, 0x91, 0x1b, 0xcd, 0x36, 0xe7, 0x00, 0x47, 0x03, 0xa7, 0x80, 0x36, 0xfd, 0xff, 0xc1, 0x9b, 0xf9, 0xb8, 0xb8, 0xb8, 0xb7, 0x99, 0xf7, 0xff, 0xff, 0x0f, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x03, 0x00, 0xfc, 0x00, 0xc0, 0xff, 0x00, 0xf0, 0x3f, 0x00, 0xff, 0x3f, 0xf0, 0xff, 0x3f, 0xfc, 0xff, 0xcf, 0xff, 0xff, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x1f, 0xcb, 0x30, 0xc3, 0x3f, 0xc7, 0x00, 0x7e, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0x0c, 0x00, 0xc3, 0xfc, 0x33, 0x0c, 0x24, 0xc3, 0xc0, 0x31, 0x0c, 0x06, 0xc3, 0x30, 0x30, 0x0c, 0x00, 0xc3, 0xff, 0x3f, 0x0a, 0xff, 0x3f, 0x30, 0x00, 0x03, 0xc3, 0x30, 0x30, 0x3f, 0xff, 0xff, 0x3f, 0x3c, 0x00, 0xff, 0xff, 0xff, 0x0c, 0x0c, 0xc3, 0xc0, 0x00, 0x0c, 0xfc, 0xff, 0x0a, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfc, 0x0f, 0xc0, 0xff, 0x00, 0xfc, 0x0f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x3c, 0x00, 0xc0, 0x03, 0xf0, 0x3f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x09, 0xe0, 0x2f, 0xf0, 0xff, 0xe3, 0xb8, 0xec, 0x9b, 0xf9, 0xbf, 0xf8, 0xbf, 0x99, 0xef, 0xb8, 0x2c, 0xff, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x87, 0x87, 0xc3, 0x30, 0x0c, 0xe3, 0xde, 0x01, 0x03, 0x74, 0xbb, 0x0c, 0xc3, 0x30, 0x2c, 0x2d, 0x0d, 0x05, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x34, 0xc3, 0x0c, 0x73, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x39, 0xc0, 0x00, 0x43, 0x2f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x87, 0x30, 0x60, 0x60, 0x60, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x87, 0x30, 0xb8, 0x00, 0x23, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0e, 0x36, 0xc6, 0xfc, 0x03, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xcb, 0x00, 0x7f, 0x40, 0x13, 0x8c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xcb, 0x10, 0x2f, 0x4c, 0x33, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0x0f, 0x30, 0x60, 0x60, 0xc0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0x7d, 0x4c, 0x33, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0xc6, 0xe0, 0x03, 0x8c, 0x1f, 0x00, 0x00, 0x00, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xc0, 0xf0, 0x3c, 0xcf, 0xf3, 0x3c, 0x03, 0x00, 0x03, 0x00, 0xcc, 0xf3, 0x3c, 0xcf, 0xf3, 0x30, 0x00, 0x05, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x30, 0xc0, 0x0f, 0x30, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xd0, 0x7f, 0x40, 0xff, 0x1f, 0xfc, 0xff, 0x43, 0xff, 0x1f, 0x40, 0x15, 0x00, 0x00, 0x00, 0x0a, 0xe4, 0x06, 0x90, 0x91, 0x01, 0x06, 0x24, 0x30, 0x90, 0x1b, 0x46, 0x6e, 0x96, 0xb9, 0x91, 0xe4, 0x06, 0x0c, 0x18, 0x90, 0x40, 0x46, 0x06, 0x90, 0x1b, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x02, 0xc2, 0xab, 0xaa, 0x3e, 0x20, 0xe0, 0xab, 0xaa, 0x3e, 0x02, 0xc2, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x08, 0x02, 0xc0, 0x30, 0x00, 0x0c, 0x03, 0xf0, 0xff, 0x00, 0xfe, 0x0b, 0xd0, 0x7f, 0x00, 0xa4, 0x01, 0x00, 0x0a, 0x00, 0xa0, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x81, 0x24, 0x10, 0x85, 0x00, 0x20, 0x66, 0x40, 0x15, 0x45, 0x62, 0x90, 0x4d, 0xd0, 0xf1, 0x23, 0x01, 0xfd, 0x41, 0x41, 0x07, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xa0, 0x00, 0x40, 0x1f, 0x00, 0xf8, 0x02, 0xd0, 0x7f, 0x00, 0xfe, 0x0b, 0xf0, 0xff, 0x00, 0xff, 0x0f, 0xd0, 0x7f, 0x00, 0xf4, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xd4, 0x01, 0xd0, 0x06, 0x40, 0x7f, 0x00, 0xfd, 0x01, 0xf4, 0x07, 0xd0, 0x1f, 0x00, 0x7f, 0x00, 0xd0, 0x01, 0x00, 0x0a, 0x40, 0x15, 0x00, 0xfe, 0x0b, 0x88, 0x2f, 0x52, 0xf0, 0x50, 0x01, 0x0a, 0xd4, 0xaf, 0x7f, 0xfd, 0xf5, 0xc7, 0x0b, 0x3e, 0x70, 0xd0, 0x00, 0xa4, 0x01, 0x0a, 0x80, 0x2f, 0x80, 0x5f, 0x2f, 0x0c, 0x00, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0x01, 0x34, 0x34, 0xc0, 0x01, 0x07, 0x0d, 0xd0, 0x75, 0x00, 0xf4, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xf4, 0x01, 0xc0, 0x3f, 0x00, 0xf0, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xe0, 0xef, 0x00, 0xbb, 0x0b, 0xa0, 0xaa, 0x00, 0xaa, 0x0a, 0x80, 0x19, 0x00, 0x64, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x2d, 0x80, 0xe7, 0x0b, 0xbe, 0xf8, 0xfa, 0x02, 0xfe, 0x0b, 0x80, 0x2f, 0x00, 0x50, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xf8, 0x02, 0xe0, 0xbf, 0x80, 0xaf, 0x2f, 0xbe, 0xe0, 0xdb, 0x02, 0x78, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xa0, 0x00, 0x40, 0x1f, 0x50, 0xfe, 0x5b, 0xfd, 0xff, 0x47, 0xff, 0x1f, 0xe0, 0xbf, 0x00, 0xfe, 0x0b, 0xf0, 0xf5, 0x40, 0x01, 0x14, 0x0a, 0x40, 0x1a, 0x00, 0x09, 0x06, 0x20, 0x80, 0x00, 0x02, 0x08, 0xfc, 0xff, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0xff, 0x3f, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x0a, 0xf0, 0xff, 0x00, 0xaa, 0x0a, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x09, 0xe0, 0x2f, 0xf0, 0xff, 0xe3, 0xff, 0xed, 0xff, 0xe1, 0xdf, 0xe1, 0x2f, 0xe1, 0xef, 0xe2, 0x2f, 0xef, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x0a, 0xc0, 0x31, 0x00, 0x30, 0x01, 0x40, 0x34, 0x00, 0xcc, 0x00, 0x00, 0x0a, 0x00, 0xf8, 0x02, 0xe0, 0xbf, 0x80, 0xff, 0x2f, 0xfe, 0xff, 0xfb, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x80, 0xff, 0x2f, 0xfc, 0xff, 0xc3, 0x07, 0x3d, 0x3c, 0xc0, 0xc3, 0x03, 0x3c, 0x7c, 0xd0, 0xc3, 0xff, 0x3f, 0xf8, 0xff, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xf3, 0x3c, 0x3c, 0xcf, 0x03, 0x00, 0x00, 0x0a, 0xb9, 0x91, 0xe3, 0x46, 0x2e, 0x1b, 0xb9, 0x61, 0xe4, 0x06, 0x91, 0x1b, 0x41, 0x6e, 0x24, 0xb9, 0x91, 0xe3, 0x46, 0x2e, 0x1b, 0xb9, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x0c, 0xc0, 0x23, 0x00, 0x80, 0x08, 0x00, 0x20, 0x0f, 0xc0, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xe0, 0x2f, 0xc0, 0x01, 0x0d, 0x06, 0x40, 0x32, 0x00, 0x30, 0x03, 0x00, 0x33, 0x00, 0x30, 0x06, 0x40, 0xc2, 0x01, 0x0d, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc7, 0x31, 0x0c, 0x02, 0x70, 0x04, 0x00, 0x00, 0x05, 0xcc, 0x74, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x80, 0x19, 0xcc, 0xe0, 0x3f, 0xcc, 0xf0, 0x2f, 0xcc, 0x90, 0x09, 0x00, 0x00, 0x00, 0x06, 0x30, 0xd0, 0x3f, 0x33, 0xe1, 0x07, 0xf4, 0x12, 0x33, 0xff, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x2d, 0xce, 0xcc, 0xe1, 0x1d, 0xc0, 0x03, 0x74, 0x4b, 0x33, 0xb3, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7d, 0x30, 0x0c, 0x13, 0xd0, 0x32, 0xb3, 0x33, 0x1c, 0x7d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4c, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x34, 0x1d, 0x07, 0x03, 0x07, 0x1d, 0x34, 0x00, 0x00, 0x00, 0x04, 0x07, 0x1d, 0x34, 0x30, 0x34, 0x1d, 0x07, 0x00, 0x00, 0x00, 0x06, 0x44, 0xd0, 0x1c, 0x64, 0xf0, 0x3f, 0x64, 0xd0, 0x1c, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x02, 0x30, 0xe0, 0x2f, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0d, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, 0x70, 0x00, 0x00, 0x00, 0x06, 0x80, 0x02, 0x0c, 0xa0, 0x00, 0x03, 0x28, 0xc0, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xe0, 0x39, 0x07, 0x33, 0x32, 0x03, 0xb3, 0x38, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x30, 0xf0, 0x60, 0x03, 0x0c, 0x30, 0xc0, 0x40, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x41, 0x03, 0x0a, 0x2c, 0x70, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0x71, 0x34, 0x01, 0x03, 0x1e, 0x00, 0x33, 0x34, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xc0, 0x03, 0x37, 0x1c, 0x73, 0x34, 0xbf, 0x03, 0x30, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x33, 0x00, 0x57, 0xe0, 0x2f, 0x00, 0x13, 0x30, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd3, 0x00, 0x07, 0xf0, 0x1f, 0x03, 0x33, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x07, 0x34, 0x80, 0x03, 0x0e, 0x38, 0xd0, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x03, 0xd3, 0x1f, 0x03, 0x73, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x34, 0x03, 0xc3, 0x3f, 0x40, 0x23, 0x30, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x70, 0x04, 0x40, 0x70, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x1c, 0x04, 0x00, 0x0c, 0x0d, 0x03, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc0, 0xc3, 0x0b, 0x1b, 0xc0, 0x0b, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x0f, 0x90, 0x83, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfd, 0x71, 0x30, 0x81, 0x03, 0x0e, 0x34, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf8, 0x0f, 0x1d, 0x30, 0xe7, 0x37, 0x73, 0x1c, 0xe3, 0x2f, 0x07, 0x00, 0xfd, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x74, 0xd0, 0x1d, 0x47, 0x33, 0x30, 0xff, 0x33, 0x30, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xbf, 0x30, 0x38, 0x43, 0xf3, 0x1f, 0x43, 0x33, 0x34, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd1, 0x34, 0x03, 0x31, 0x00, 0x03, 0x70, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f, 0x30, 0x1d, 0x43, 0x33, 0x30, 0x03, 0x33, 0x34, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x32, 0x00, 0x03, 0xf0, 0x0b, 0x03, 0x30, 0x10, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x33, 0x10, 0x03, 0xf0, 0x0b, 0x03, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf4, 0xd1, 0x34, 0x03, 0x30, 0x3e, 0x03, 0x73, 0x34, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x47, 0x33, 0x30, 0x03, 0xf3, 0x3f, 0x03, 0x33, 0x30, 0x47, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x1d, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1d, 0x00, 0x00, 0x00, 0x06, 0xd0, 0x01, 0x0c, 0xc0, 0x00, 0x0c, 0xc0, 0x10, 0x0d, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x47, 0xc3, 0x34, 0x70, 0x03, 0xbc, 0x00, 0xb3, 0xc0, 0xb0, 0x70, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x30, 0x10, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x03, 0x30, 0x1f, 0x3d, 0x7b, 0x3b, 0xe3, 0x32, 0x83, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0xcd, 0x03, 0x73, 0xc3, 0x8c, 0x32, 0xc3, 0xcd, 0xc0, 0x33, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf4, 0x41, 0xc7, 0x71, 0xd0, 0x0c, 0x30, 0x03, 0xcd, 0xd1, 0xd1, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f, 0x30, 0x1d, 0x43, 0x73, 0x34, 0xff, 0x31, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf4, 0x41, 0xd3, 0x71, 0xd0, 0x0c, 0x30, 0xc3, 0xcd, 0xd1, 0xd1, 0xdf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x31, 0x34, 0x03, 0xf3, 0x0f, 0xd7, 0x30, 0x34, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0xfc, 0xb1, 0x31, 0x07, 0xd0, 0x0f, 0x90, 0x23, 0x34, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x13, 0x13, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xcc, 0x00, 0x33, 0xc0, 0x0c, 0x30, 0x03, 0xcd, 0xd2, 0xd1, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0x33, 0x30, 0x03, 0xb3, 0x38, 0xcd, 0xc1, 0x0d, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x03, 0x30, 0x43, 0x30, 0xc7, 0x34, 0xcd, 0x1c, 0xed, 0x1e, 0x2c, 0x0e, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0x4c, 0xc3, 0x81, 0x3b, 0xd0, 0x03, 0xdc, 0x42, 0xc3, 0x31, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x03, 0xb3, 0x38, 0xdc, 0x40, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x0f, 0xd0, 0x02, 0x2c, 0xc0, 0x02, 0x2d, 0xc0, 0x06, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2f, 0x00, 0x00, 0x00, 0x05, 0x03, 0x28, 0xc0, 0x00, 0x0a, 0x30, 0x80, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3e, 0x00, 0x00, 0x00, 0x04, 0x1d, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x47, 0x30, 0xfc, 0x0c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x07, 0x0c, 0xf0, 0xc7, 0x35, 0xc3, 0x0c, 0xf3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc3, 0x25, 0x03, 0x4c, 0xd2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0xd0, 0x00, 0x83, 0x8f, 0x33, 0xc3, 0x1c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0xbf, 0x0c, 0xd0, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3d, 0x07, 0x03, 0x2f, 0x03, 0x03, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xc0, 0xcb, 0x32, 0xc3, 0xf4, 0x03, 0x4c, 0x30, 0x7e, 0x00, 0x00, 0x05, 0x03, 0x0c, 0xf0, 0xc7, 0x39, 0xc3, 0x0c, 0x73, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x1c, 0x00, 0x0d, 0x0c, 0x0c, 0x1d, 0x00, 0x00, 0x00, 0x04, 0x00, 0x30, 0x00, 0x34, 0x30, 0x30, 0x30, 0x30, 0x1e, 0x00, 0x05, 0x03, 0x0c, 0x31, 0xce, 0x0e, 0x1f, 0xcc, 0x31, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x47, 0x3d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9b, 0x71, 0x37, 0x33, 0x33, 0x32, 0x43, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xc7, 0x31, 0xc3, 0x0c, 0x33, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x31, 0xc3, 0x4c, 0xd3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xc7, 0x31, 0xc3, 0x4c, 0xf3, 0xc7, 0x00, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xdf, 0x31, 0xc3, 0x4c, 0xd3, 0x0f, 0x30, 0xc0, 0x00, 0x05, 0x03, 0x00, 0x30, 0x7f, 0xc7, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xc0, 0xc7, 0x10, 0x3c, 0x04, 0xf3, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x1c, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x70, 0xdc, 0x30, 0xc3, 0x4c, 0xd3, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcc, 0x30, 0xd3, 0xdc, 0xc2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x33, 0x32, 0x33, 0x73, 0x37, 0xcd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcd, 0x32, 0x7d, 0x8c, 0x73, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x30, 0xcc, 0x30, 0xc7, 0x74, 0x43, 0x07, 0x0c, 0x1f, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0x4f, 0x2c, 0x2c, 0x2c, 0xf1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x04, 0x38, 0x0c, 0x0c, 0x03, 0x0c, 0x0c, 0x38, 0x00, 0x00, 0x00, 0x02, 0x32, 0x33, 0x33, 0x13, 0x00, 0x04, 0x0b, 0x0c, 0x0c, 0x30, 0x0c, 0x0c, 0x0b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1d, 0x72, 0x37, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x00, 0xff, 0x01, 0xff, 0x07, 0xff, 0x1f, 0xff, 0x7f, 0xff, 0x1b, 0xbf, 0x01, 0x1b, 0x00, 0x0c, 0x00, 0x40, 0xff, 0x00, 0x00, 0xf8, 0xf0, 0x3f, 0xee, 0x2c, 0x30, 0xcb, 0x0b, 0x30, 0x42, 0xc3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xf3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xff, 0x3f, 0x00, 0x0c, 0xc2, 0x00, 0x00, 0xcb, 0x00, 0x00, 0xee, 0xc0, 0xff, 0xf8, 0xb0, 0xc0, 0xff, 0x2c, 0xc0, 0x00, 0x0c, 0xcf, 0x00, 0x0c, 0xc0, 0x00, 0xcc, 0xcf, 0x00, 0x0c, 0xc0, 0x00, 0xfc, 0xff, 0x0a, 0x00, 0x00, 0x0d, 0x00, 0x70, 0x00, 0x00, 0xf3, 0xff, 0xd3, 0x03, 0xe0, 0x3c, 0x3f, 0x38, 0x03, 0xd0, 0x33, 0xff, 0x38, 0x03, 0xe0, 0xf0, 0xff, 0x03, 0x0c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x8b, 0xf7, 0x0c, 0x13, 0x9f, 0x3b, 0x37, 0x00, 0xc0, 0x23, 0xff, 0xff, 0x8b, 0x03, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0x03, 0x2c, 0x0d, 0x00, 0x37, 0x00, 0xc0, 0xf3, 0xff, 0x3c, 0xff, 0xcf, 0x03, 0x00, 0xdc, 0x00, 0x70, 0x38, 0xc0, 0x02, 0xfd, 0x07, 0x0a, 0x00, 0x00, 0x00, 0xfc, 0x03, 0xf0, 0xff, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0x03, 0xff, 0x0f, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x0a, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0x03, 0x00, 0x3c, 0xf0, 0xc0, 0xc3, 0x3a, 0x3c, 0x0b, 0xce, 0x2b, 0x80, 0x7e, 0x00, 0xd0, 0x03, 0x00, 0xfc, 0xff, 0xff, 0x0a, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0x03, 0x2c, 0x0d, 0x0f, 0x37, 0xf0, 0xc0, 0xf3, 0xff, 0x3c, 0xff, 0xcf, 0x03, 0x0f, 0xdc, 0xf0, 0x70, 0x38, 0xc0, 0x02, 0xfd, 0x07, 0x0a, 0x40, 0x1f, 0x00, 0xad, 0x07, 0xb0, 0xc5, 0x00, 0x17, 0x0c, 0x70, 0xd0, 0x00, 0x0c, 0x03, 0xbc, 0xef, 0xb3, 0x11, 0xe0, 0x07, 0x05, 0x3c, 0x52, 0xc8, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xc0, 0x3f, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, 0xf0, 0x00, 0xc0, 0x30, 0xc0, 0xff, 0x3f, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0xfc, 0xff, 0x3f, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb8, 0xe0, 0x2f, 0xff, 0xe3, 0x2f, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xd0, 0x7f, 0x80, 0xff, 0x2f, 0xfd, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x7f, 0xf8, 0xff, 0x02, 0xfd, 0x07, 0x0a, 0x40, 0x01, 0x00, 0x02, 0x00, 0xc8, 0x07, 0x10, 0xc3, 0x00, 0x31, 0x0d, 0x00, 0xfd, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x0f, 0x0f, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x0a, 0x40, 0x05, 0x80, 0xff, 0x8b, 0x1e, 0xd0, 0x2e, 0x00, 0xf0, 0x00, 0xe0, 0xff, 0x0b, 0x00, 0x0f, 0x00, 0xb8, 0x03, 0xb0, 0xe2, 0xff, 0x02, 0x50, 0x01, 0x08, 0xff, 0x07, 0x03, 0x1e, 0x03, 0x73, 0x03, 0xef, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x00, 0xe4, 0x2f, 0xe0, 0x1b, 0x0c, 0x1d, 0x00, 0xff, 0x03, 0xbe, 0xf0, 0xc1, 0x01, 0xad, 0x34, 0xc0, 0x36, 0x0b, 0x30, 0xdc, 0xe4, 0x07, 0xfd, 0x1b, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x02, 0xa0, 0xaa, 0x00, 0xa8, 0xc2, 0x0f, 0x2a, 0xff, 0x03, 0xca, 0x3f, 0x80, 0xfc, 0x0f, 0x20, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x01, 0x00, 0xc0, 0x07, 0xaa, 0xea, 0x1f, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xaa, 0xea, 0x1f, 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x40, 0x03, 0x00, 0xd0, 0x03, 0x00, 0xf4, 0xab, 0xaa, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xf4, 0xab, 0xaa, 0xd0, 0x03, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x09, 0xfe, 0xff, 0xe3, 0xff, 0x0f, 0xaa, 0x3e, 0x0a, 0xf8, 0x2e, 0xe0, 0xbf, 0x80, 0xff, 0xaa, 0xfe, 0xff, 0xe2, 0xff, 0x02, 0x02, 0x00, 0x00, 0x09, 0x00, 0x80, 0x04, 0xd0, 0xe2, 0xff, 0x02, 0x00, 0x00, 0xff, 0x6f, 0x00, 0x40, 0xe6, 0xaf, 0x50, 0x00, 0x09, 0x00, 0x20, 0x00, 0x64, 0x00, 0x09, 0xe0, 0x3f, 0x70, 0x60, 0x63, 0xc0, 0xe4, 0x80, 0xc2, 0x03, 0x07, 0x0f, 0x1e, 0x6c, 0xff, 0x27, 0xff, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x09, 0x44, 0x44, 0x00, 0x12, 0x41, 0x88, 0x04, 0x21, 0x21, 0x84, 0x48, 0x20, 0x23, 0xc2, 0xcc, 0x08, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x1d, 0x00, 0x1d, 0x00, 0x78, 0x00, 0xb4, 0x07, 0xf0, 0x2f, 0xc0, 0xfb, 0x00, 0xbe, 0x02, 0xf4, 0x07, 0xfd, 0xff, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x00, 0x19, 0x00, 0xa8, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0xf0, 0xdc, 0xcb, 0x03, 0x00, 0xff, 0xff, 0x4f, 0x07, 0x40, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xff, 0x3f, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0x07, 0x00, 0xbd, 0x02, 0xe8, 0xb3, 0xe0, 0x3c, 0xac, 0xc3, 0x03, 0x0f, 0x3c, 0x00, 0xc0, 0x03, 0x00, 0xfc, 0xff, 0xff, 0x0b, 0xc0, 0xc8, 0xc0, 0x91, 0x1b, 0xcd, 0x36, 0xe7, 0x00, 0x47, 0x03, 0xa7, 0x80, 0x36, 0xfd, 0xff, 0xc1, 0x9b, 0xf9, 0xb8, 0xb8, 0xb8, 0xb7, 0x99, 0xf7, 0xff, 0xff, 0x0f, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x03, 0x00, 0xfc, 0x00, 0xc0, 0xff, 0x00, 0xf0, 0x3f, 0x00, 0xff, 0x3f, 0xf0, 0xff, 0x3f, 0xfc, 0xff, 0xcf, 0xff, 0xff, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x1f, 0xcb, 0x30, 0xc3, 0x3f, 0xc7, 0x00, 0x7e, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xfc, 0xff, 0xc3, 0xff, 0x3f, 0x0c, 0x00, 0xc3, 0xfc, 0x33, 0x0c, 0x24, 0xc3, 0xc0, 0x31, 0x0c, 0x06, 0xc3, 0x30, 0x30, 0x0c, 0x00, 0xc3, 0xff, 0x3f, 0x0a, 0xff, 0x3f, 0x30, 0x00, 0x03, 0xc3, 0x30, 0x30, 0x3f, 0xff, 0xff, 0x3f, 0x3c, 0x00, 0xff, 0xff, 0xff, 0x0c, 0x0c, 0xc3, 0xc0, 0x00, 0x0c, 0xfc, 0xff, 0x0a, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfc, 0x0f, 0xc0, 0xff, 0x00, 0xfc, 0x0f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x3c, 0x00, 0xc0, 0x03, 0xf0, 0x3f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x09, 0xe0, 0x2f, 0xf0, 0xff, 0xe3, 0xb8, 0xec, 0x9b, 0xf9, 0xbf, 0xf8, 0xbf, 0x99, 0xef, 0xb8, 0x2c, 0xff, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0x87, 0x87, 0xc3, 0x30, 0x0c, 0xe3, 0xde, 0x01, 0x03, 0x74, 0xbb, 0x0c, 0xc3, 0x30, 0x2c, 0x2d, 0x0d, 0x05, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x34, 0xc3, 0x0c, 0x73, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x39, 0xc0, 0x00, 0x43, 0x2f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x87, 0x30, 0x60, 0x60, 0x60, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0x87, 0x30, 0xb8, 0x00, 0x23, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0e, 0x36, 0xc6, 0xfc, 0x03, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0xcb, 0x00, 0x7f, 0x40, 0x13, 0x8c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xcb, 0x10, 0x2f, 0x4c, 0x33, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xf0, 0x0f, 0x30, 0x60, 0x60, 0xc0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0x7d, 0x4c, 0x33, 0x4c, 0x1f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xd0, 0xc7, 0x30, 0xc6, 0xe0, 0x03, 0x8c, 0x1f, 0x00, 0x00, 0x00, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xc0, 0xf0, 0x3c, 0xcf, 0xf3, 0x3c, 0x03, 0x00, 0x03, 0x00, 0xcc, 0xf3, 0x3c, 0xcf, 0xf3, 0x30, 0x00, 0x05, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x30, 0xc0, 0x0f, 0x30, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xd0, 0x7f, 0x40, 0xff, 0x1f, 0xfc, 0xff, 0x43, 0xff, 0x1f, 0x40, 0x15, 0x00, 0x00, 0x00, 0x0a, 0xe4, 0x06, 0x90, 0x91, 0x01, 0x06, 0x24, 0x30, 0x90, 0x1b, 0x46, 0x6e, 0x96, 0xb9, 0x91, 0xe4, 0x06, 0x0c, 0x18, 0x90, 0x40, 0x46, 0x06, 0x90, 0x1b, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x02, 0xc2, 0xab, 0xaa, 0x3e, 0x20, 0xe0, 0xab, 0xaa, 0x3e, 0x02, 0xc2, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x08, 0x02, 0xc0, 0x30, 0x00, 0x0c, 0x03, 0xf0, 0xff, 0x00, 0xfe, 0x0b, 0xd0, 0x7f, 0x00, 0xa4, 0x01, 0x00, 0x0a, 0x00, 0xa0, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x81, 0x24, 0x10, 0x85, 0x00, 0x20, 0x66, 0x40, 0x15, 0x45, 0x62, 0x90, 0x4d, 0xd0, 0xf1, 0x23, 0x01, 0xfd, 0x41, 0x41, 0x07, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xa0, 0x00, 0x40, 0x1f, 0x00, 0xf8, 0x02, 0xd0, 0x7f, 0x00, 0xfe, 0x0b, 0xf0, 0xff, 0x00, 0xff, 0x0f, 0xd0, 0x7f, 0x00, 0xf4, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xd4, 0x01, 0xd0, 0x06, 0x40, 0x7f, 0x00, 0xfd, 0x01, 0xf4, 0x07, 0xd0, 0x1f, 0x00, 0x7f, 0x00, 0xd0, 0x01, 0x00, 0x0a, 0x40, 0x15, 0x00, 0xfe, 0x0b, 0x88, 0x2f, 0x52, 0xf0, 0x50, 0x01, 0x0a, 0xd4, 0xaf, 0x7f, 0xfd, 0xf5, 0xc7, 0x0b, 0x3e, 0x70, 0xd0, 0x00, 0xa4, 0x01, 0x0a, 0x80, 0x2f, 0x80, 0x5f, 0x2f, 0x0c, 0x00, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0x01, 0x34, 0x34, 0xc0, 0x01, 0x07, 0x0d, 0xd0, 0x75, 0x00, 0xf4, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xf4, 0x01, 0xc0, 0x3f, 0x00, 0xf0, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xe0, 0xef, 0x00, 0xbb, 0x0b, 0xa0, 0xaa, 0x00, 0xaa, 0x0a, 0x80, 0x19, 0x00, 0x64, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x2d, 0x80, 0xe7, 0x0b, 0xbe, 0xf8, 0xfa, 0x02, 0xfe, 0x0b, 0x80, 0x2f, 0x00, 0x50, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xf8, 0x02, 0xe0, 0xbf, 0x80, 0xaf, 0x2f, 0xbe, 0xe0, 0xdb, 0x02, 0x78, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xa0, 0x00, 0x40, 0x1f, 0x50, 0xfe, 0x5b, 0xfd, 0xff, 0x47, 0xff, 0x1f, 0xe0, 0xbf, 0x00, 0xfe, 0x0b, 0xf0, 0xf5, 0x40, 0x01, 0x14, 0x0a, 0x40, 0x1a, 0x00, 0x09, 0x06, 0x20, 0x80, 0x00, 0x02, 0x08, 0xfc, 0xff, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0x00, 0x30, 0x0c, 0x00, 0xc3, 0xff, 0x3f, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x0a, 0xf0, 0xff, 0x00, 0xaa, 0x0a, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x09, 0xe0, 0x2f, 0xf0, 0xff, 0xe3, 0xff, 0xed, 0xff, 0xe1, 0xdf, 0xe1, 0x2f, 0xe1, 0xef, 0xe2, 0x2f, 0xef, 0x3f, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x0a, 0xc0, 0x31, 0x00, 0x30, 0x01, 0x40, 0x34, 0x00, 0xcc, 0x00, 0x00, 0x0a, 0x00, 0xf8, 0x02, 0xe0, 0xbf, 0x80, 0xff, 0x2f, 0xfe, 0xff, 0xfb, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x80, 0xff, 0x2f, 0xfc, 0xff, 0xc3, 0x07, 0x3d, 0x3c, 0xc0, 0xc3, 0x03, 0x3c, 0x7c, 0xd0, 0xc3, 0xff, 0x3f, 0xf8, 0xff, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xf3, 0x3c, 0x3c, 0xcf, 0x03, 0x00, 0x00, 0x0a, 0xb9, 0x91, 0xe3, 0x46, 0x2e, 0x1b, 0xb9, 0x61, 0xe4, 0x06, 0x91, 0x1b, 0x41, 0x6e, 0x24, 0xb9, 0x91, 0xe3, 0x46, 0x2e, 0x1b, 0xb9, 0x01, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x0c, 0xc0, 0x23, 0x00, 0x80, 0x08, 0x00, 0x20, 0x0f, 0xc0, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xe0, 0x2f, 0xc0, 0x01, 0x0d, 0x06, 0x40, 0x32, 0x00, 0x30, 0x03, 0x00, 0x33, 0x00, 0x30, 0x06, 0x40, 0xc2, 0x01, 0x0d, 0xe0, 0x2f, 0x00, 0x00, 0x00, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0xdc, 0xc0, 0x0c, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, }; short font_ptrs[] = { - 0x0000, 0x000e, 0x001c, 0x002a, 0x0038, 0x0046, 0x0054, 0x0062, 0x0070, 0x007e, 0x008c, 0x009a, 0x00a8, 0x00b6, 0x00c4, 0x00d2, 0x00e0, 0x00ee, 0x00fc, 0x010a, 0x0118, 0x0126, 0x0134, 0x0142, 0x0150, 0x015e, 0x016c, 0x017a, 0x0188, 0x0196, 0x01a4, 0x01b2, 0x01c0, 0x01ce, 0x01d7, 0x01e5, 0x01f5, 0x0205, 0x0218, 0x0228, 0x0231, 0x023c, 0x0247, 0x0257, 0x0267, 0x0272, 0x0280, 0x0289, 0x0299, 0x02a9, 0x02b7, 0x02c7, 0x02d7, 0x02e7, 0x02f7, 0x0307, 0x0317, 0x0327, 0x0337, 0x0340, 0x034b, 0x035b, 0x036b, 0x037b, 0x038b, 0x03a0, 0x03b0, 0x03c0, 0x03d0, 0x03e0, 0x03f0, 0x0400, 0x0410, 0x0420, 0x042b, 0x043b, 0x044e, 0x045e, 0x0473, 0x0486, 0x0499, 0x04a9, 0x04bc, 0x04cc, 0x04dc, 0x04ec, 0x04ff, 0x050f, 0x0524, 0x0537, 0x0547, 0x055a, 0x0565, 0x0573, 0x057e, 0x0589, 0x0599, 0x05a2, 0x05b0, 0x05be, 0x05cc, 0x05da, 0x05e8, 0x05f3, 0x0601, 0x060f, 0x061a, 0x0625, 0x0633, 0x063e, 0x064e, 0x065c, 0x066a, 0x0678, 0x0686, 0x068f, 0x069d, 0x06a8, 0x06b6, 0x06c4, 0x06d4, 0x06e2, 0x06f0, 0x06fe, 0x0709, 0x070f, 0x071a, 0x072a, 0x0735, 0x074a, 0x0769, 0x0788, 0x07a2, 0x07c1, 0x07db, 0x07f5, 0x080f, 0x0829, 0x0843, 0x085d, 0x0877, 0x0896, 0x08a6, 0x08c0, 0x08da, 0x08f4, 0x090e, 0x0923, 0x0940, 0x095d, 0x097c, 0x099b, 0x09b3, 0x09cb, 0x09e3, 0x09fb, 0x0a13, 0x0a2b, 0x0a43, 0x0a5b, 0x0a73, 0x0a8b, 0x0aa3, 0x0abd, 0x0ada, 0x0af7, 0x0b0c, 0x0b26, 0x0b40, 0x0b5a, 0x0b74, 0x0b8c, 0x0b97, 0x0ba0, 0x0ba9, 0x0bb7, 0x0bc5, 0x0bd3, 0x0be1, 0x0bef, 0x0bfd, 0x0c0b, 0x0c19, 0x0c27, 0x0c35, 0x0c43, 0x0c4e, 0x0c57, 0x0c60, 0x0c6e, 0x0c7e, 0x0c8e, 0x0ca8, 0x0cc2, 0x0cdc, 0x0cf6, 0x0d10, 0x0d2a, 0x0d44, 0x0d5e, 0x0d78, 0x0d92, 0x0dac, 0x0dc6, 0x0de0, 0x0dfa, 0x0e14, 0x0e2e, 0x0e46, 0x0e60, 0x0e7a, 0x0e94, 0x0eae, 0x0ec8, 0x0ee2, 0x0ef2, 0x0f02, 0x0f12, 0x0f22, 0x0f32, 0x0f42, 0x0f52, 0x0f62, 0x0f72, 0x0f82, 0x0f92, 0x0fa2, 0x0fb2, 0x0fc2, 0x0fd2, 0x0fe2, 0x0ff2, 0x1002, 0x1012, 0x1022, 0x1032, 0x1042, 0x1052, 0x1062, 0x1072, 0x1082, 0x1092, 0x10a2, 0x10b2, 0x10c2, 0x10d2, 0x10e2, 0x10f2, 0x1102, 0x1112, 0x1122, 0x1132, 0x1142, 0x1152, 0x1162, 0x1172, + 0x0000, 0x000e, 0x001c, 0x002a, 0x0038, 0x0046, 0x0054, 0x0062, 0x0070, 0x007e, 0x008c, 0x009a, 0x00a8, 0x00b6, 0x00c4, 0x00d2, 0x00e0, 0x00ee, 0x00fc, 0x010a, 0x0118, 0x0126, 0x0134, 0x0142, 0x0150, 0x015e, 0x016c, 0x017a, 0x0188, 0x0196, 0x01a4, 0x01b2, 0x01c0, 0x01ce, 0x01d7, 0x01e5, 0x01f5, 0x0205, 0x0218, 0x0228, 0x0231, 0x023c, 0x0247, 0x0257, 0x0267, 0x0272, 0x0280, 0x0289, 0x0299, 0x02a9, 0x02b7, 0x02c7, 0x02d7, 0x02e7, 0x02f7, 0x0307, 0x0317, 0x0327, 0x0337, 0x0340, 0x034b, 0x035b, 0x036b, 0x037b, 0x038b, 0x03a0, 0x03b0, 0x03c0, 0x03d0, 0x03e0, 0x03f0, 0x0400, 0x0410, 0x0420, 0x042b, 0x043b, 0x044e, 0x045e, 0x0473, 0x0486, 0x0499, 0x04a9, 0x04bc, 0x04cc, 0x04dc, 0x04ec, 0x04ff, 0x050f, 0x0524, 0x0537, 0x0547, 0x055a, 0x0565, 0x0573, 0x057e, 0x0589, 0x0599, 0x05a2, 0x05b0, 0x05be, 0x05cc, 0x05da, 0x05e8, 0x05f3, 0x0601, 0x060f, 0x061a, 0x0625, 0x0633, 0x063e, 0x064e, 0x065c, 0x066a, 0x0678, 0x0686, 0x068f, 0x069d, 0x06a8, 0x06b6, 0x06c4, 0x06d4, 0x06e2, 0x06f0, 0x06fe, 0x0709, 0x070f, 0x071a, 0x072a, 0x0735, 0x074a, 0x0769, 0x0788, 0x07a2, 0x07c1, 0x07db, 0x07f5, 0x080f, 0x0829, 0x0843, 0x085d, 0x0877, 0x0896, 0x08a6, 0x08c0, 0x08da, 0x08f4, 0x090e, 0x0923, 0x0940, 0x095d, 0x097c, 0x099b, 0x09b3, 0x09cb, 0x09e3, 0x09fb, 0x0a13, 0x0a2b, 0x0a43, 0x0a5b, 0x0a73, 0x0a8b, 0x0aa3, 0x0abd, 0x0ada, 0x0af7, 0x0b0c, 0x0b26, 0x0b40, 0x0b5a, 0x0b74, 0x0b8c, 0x0b97, 0x0ba0, 0x0ba9, 0x0bb7, 0x0bc5, 0x0bd3, 0x0be1, 0x0bef, 0x0bfd, 0x0c0b, 0x0c19, 0x0c27, 0x0c35, 0x0c43, 0x0c4e, 0x0c57, 0x0c60, 0x0c6e, 0x0c7e, 0x0c8e, 0x0ca8, 0x0cc2, 0x0cdc, 0x0cf6, 0x0d10, 0x0d2a, 0x0d44, 0x0d5e, 0x0d78, 0x0d92, 0x0dac, 0x0dc6, 0x0de0, 0x0dfa, 0x0e14, 0x0e2e, 0x0e46, 0x0e60, 0x0e7a, 0x0e94, 0x0eae, 0x0ec8, 0x0ee2, 0x0ef2, 0x0f02, 0x0f12, 0x0f22, 0x0f32, 0x0f42, 0x0f52, 0x0f62, 0x0f72, 0x0f82, 0x0f92, 0x0fa2, 0x0fb2, 0x0fc2, 0x0fd2, 0x0fe2, 0x0ff2, 0x1002, 0x1012, 0x1022, 0x1032, 0x1042, 0x1052, 0x1062, 0x1072, 0x1082, 0x1092, 0x10a2, 0x10b2, 0x10c2, 0x10d2, 0x10e2, 0x10f2, 0x1102, 0x1112, 0x1122, 0x1132, 0x1142, 0x1152, 0x1162, 0x1172, }; #endif #endif diff --git a/includes/interface.h b/includes/interface.h index 29b5aadb1..4bee583dd 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -5,41 +5,41 @@ struct menu_section { - char *icon; - const char *name; - int itemcount; + char *icon; + const char *name; + int itemcount; int doshow; }; typedef struct menu_section menu_section; struct menu_wall { - pixel colour; - const char *descs; + pixel colour; + const char *descs; }; typedef struct menu_wall menu_wall; static menu_wall mwalls[] = { - {PIXPACK(0xC0C0C0), "Wall. Indestructible. Blocks everything. Conductive."}, - {PIXPACK(0x808080), "E-Wall. Becomes transparent when electricity is connected."}, - {PIXPACK(0xFF8080), "Detector. Generates electricity when a particle is inside."}, - {PIXPACK(0x808080), "Streamline. Set start point of a streamline."}, - {PIXPACK(0x808080), "Sign. Click on a sign to edit it or anywhere else to place a new one."}, - {PIXPACK(0x8080FF), "Fan. Accelerates air. Use line tool to set direction and strength."}, - {PIXPACK(0xC0C0C0), "Wall. Blocks most particles but lets liquids through. Conductive."}, - {PIXPACK(0x808080), "Wall. Absorbs particles but lets air currents through."}, - {PIXPACK(0x808080), "Erases walls."}, - {PIXPACK(0x808080), "Wall. Indestructible. Blocks everything."}, - {PIXPACK(0x3C3C3C), "Wall. Indestructible. Blocks particles, allows air"}, - {PIXPACK(0x575757), "Wall. Indestructible. Blocks liquids and gasses, allows solids"}, - {PIXPACK(0xFFFF22), "Conductor, allows particles, conducts electricity"}, - {PIXPACK(0x242424), "E-Hole, absorbs particles, release them when powered"}, - {PIXPACK(0xFFFFFF), "Air, creates airflow and pressure"}, - {PIXPACK(0xFFBB00), "Heats the targetted element."}, - {PIXPACK(0x00BBFF), "Cools the targetted element."}, - {PIXPACK(0x303030), "Vacuum, reduces air pressure."}, - {PIXPACK(0x579777), "Wall. Indestructible. Blocks liquids and solids, allows gasses"}, + {PIXPACK(0xC0C0C0), "Wall. Indestructible. Blocks everything. Conductive."}, + {PIXPACK(0x808080), "E-Wall. Becomes transparent when electricity is connected."}, + {PIXPACK(0xFF8080), "Detector. Generates electricity when a particle is inside."}, + {PIXPACK(0x808080), "Streamline. Set start point of a streamline."}, + {PIXPACK(0x808080), "Sign. Click on a sign to edit it or anywhere else to place a new one."}, + {PIXPACK(0x8080FF), "Fan. Accelerates air. Use line tool to set direction and strength."}, + {PIXPACK(0xC0C0C0), "Wall. Blocks most particles but lets liquids through. Conductive."}, + {PIXPACK(0x808080), "Wall. Absorbs particles but lets air currents through."}, + {PIXPACK(0x808080), "Erases walls."}, + {PIXPACK(0x808080), "Wall. Indestructible. Blocks everything."}, + {PIXPACK(0x3C3C3C), "Wall. Indestructible. Blocks particles, allows air"}, + {PIXPACK(0x575757), "Wall. Indestructible. Blocks liquids and gasses, allows solids"}, + {PIXPACK(0xFFFF22), "Conductor, allows particles, conducts electricity"}, + {PIXPACK(0x242424), "E-Hole, absorbs particles, release them when powered"}, + {PIXPACK(0xFFFFFF), "Air, creates airflow and pressure"}, + {PIXPACK(0xFFBB00), "Heats the targetted element."}, + {PIXPACK(0x00BBFF), "Cools the targetted element."}, + {PIXPACK(0x303030), "Vacuum, reduces air pressure."}, + {PIXPACK(0x579777), "Wall. Indestructible. Blocks liquids and solids, allows gasses"}, }; #define SC_WALL 0 @@ -59,53 +59,52 @@ static menu_wall mwalls[] = static menu_section msections[] = { - {"\xC1", "Walls", 0, 1}, - {"\xC2", "Electronics", 0, 1}, - {"\xC3", "Explosives", 0, 1}, - {"\xC5", "Gasses", 0, 1}, - {"\xC4", "Liquids", 0, 1}, - {"\xD0", "Powders", 0, 1}, - {"\xD1", "Solids", 0, 1}, - {"\xC6", "Radioactive", 0, 1}, - {"\xCC", "Special", 0, 1}, - {"\xD2", "Life", 0, 1}, - {"\xD2", "More Life", 0, 1}, - {"\xC8", "Cracker", 0, 0}, - {"\xC8", "Cracker!", 0, 0}, + {"\xC1", "Walls", 0, 1}, + {"\xC2", "Electronics", 0, 1}, + {"\xC3", "Explosives", 0, 1}, + {"\xC5", "Gasses", 0, 1}, + {"\xC4", "Liquids", 0, 1}, + {"\xD0", "Powders", 0, 1}, + {"\xD1", "Solids", 0, 1}, + {"\xC6", "Radioactive", 0, 1}, + {"\xCC", "Special", 0, 1}, + {"\xD2", "Life", 0, 1}, + {"\xC8", "Cracker", 0, 0}, + {"\xC8", "Cracker!", 0, 0}, }; struct ui_edit { - int x, y, w, nx, h; - char str[256],*def; - int focus, cursor, hide, multiline; + int x, y, w, nx, h; + char str[256],*def; + int focus, cursor, hide, multiline; }; typedef struct ui_edit ui_edit; struct save_info { - char *title; - char *name; - char *author; - char *date; - char *description; - int publish; - int voteup; - int votedown; - int vote; - int myvote; - int myfav; - char *tags; - int comment_count; - char *comments[6]; - char *commentauthors[6]; + char *title; + char *name; + char *author; + char *date; + char *description; + int publish; + int voteup; + int votedown; + int vote; + int myvote; + int myfav; + char *tags; + int comment_count; + char *comments[6]; + char *commentauthors[6]; }; typedef struct save_info save_info; struct ui_checkbox { - int x, y; - int focus, checked; + int x, y; + int focus, checked; }; typedef struct ui_checkbox ui_checkbox; diff --git a/includes/md5.h b/includes/md5.h index 2ae3ae843..a8ef123b2 100644 --- a/includes/md5.h +++ b/includes/md5.h @@ -3,9 +3,9 @@ struct md5_context { - unsigned buf[4]; - unsigned bits[2]; - unsigned char in[64]; + unsigned buf[4]; + unsigned bits[2]; + unsigned char in[64]; }; void md5_init(struct md5_context *context); diff --git a/includes/misc.h b/includes/misc.h index 5f08c950a..7efb3f14d 100644 --- a/includes/misc.h +++ b/includes/misc.h @@ -43,8 +43,8 @@ char *mystrdup(char *s); struct strlist { - char *str; - struct strlist *next; + char *str; + struct strlist *next; }; void strlist_add(struct strlist **list, char *str); diff --git a/includes/powder.h b/includes/powder.h index f30e87980..cc177e7cb 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -1,6 +1,7 @@ #ifndef POWDER_H #define POWDER_H +#include "air.h" #include "graphics.h" #include "defines.h" #include "interface.h" @@ -226,60 +227,136 @@ #define PROP_RADIOACTIVE 0x2000 //8192 Radioactive #define FLAG_STAGNANT 1 +#define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space +// to call another update function with same arguments: +#define UPDATE_FUNC_SUBCALL_ARGS i, x, y, surround_space + +int update_ACID(UPDATE_FUNC_ARGS); +int update_AMTR(UPDATE_FUNC_ARGS); +int update_ARAY(UPDATE_FUNC_ARGS); +int update_BCLN(UPDATE_FUNC_ARGS); +int update_BCOL(UPDATE_FUNC_ARGS); +int update_BMTL(UPDATE_FUNC_ARGS); +int update_BOMB(UPDATE_FUNC_ARGS); +int update_BOYL(UPDATE_FUNC_ARGS); +int update_BTRY(UPDATE_FUNC_ARGS); +int update_C5(UPDATE_FUNC_ARGS); +int update_CLNE(UPDATE_FUNC_ARGS); +int update_COAL(UPDATE_FUNC_ARGS); +int update_DEUT(UPDATE_FUNC_ARGS); +int update_DSTW(UPDATE_FUNC_ARGS); +int update_FOG(UPDATE_FUNC_ARGS); +int update_FRZW(UPDATE_FUNC_ARGS); +int update_FRZZ(UPDATE_FUNC_ARGS); +int update_FSEP(UPDATE_FUNC_ARGS); +int update_FUSE(UPDATE_FUNC_ARGS); +int update_FIRW(UPDATE_FUNC_ARGS); +int update_FWRK(UPDATE_FUNC_ARGS); +int update_GLAS(UPDATE_FUNC_ARGS); +int update_GLOW(UPDATE_FUNC_ARGS); +int update_GOO(UPDATE_FUNC_ARGS); +int update_HSWC(UPDATE_FUNC_ARGS); +int update_IRON(UPDATE_FUNC_ARGS); +int update_ICEI(UPDATE_FUNC_ARGS); +int update_ISZ(UPDATE_FUNC_ARGS); +int update_LCRY(UPDATE_FUNC_ARGS); +int update_MORT(UPDATE_FUNC_ARGS); +int update_NEUT(UPDATE_FUNC_ARGS); +int update_NPTCT(UPDATE_FUNC_ARGS); +int update_PCLN(UPDATE_FUNC_ARGS); +int update_PHOT(UPDATE_FUNC_ARGS); +int update_PIPE(UPDATE_FUNC_ARGS); +int update_PLNT(UPDATE_FUNC_ARGS); +int update_PLUT(UPDATE_FUNC_ARGS); +int update_PRTI(UPDATE_FUNC_ARGS); +int update_PRTO(UPDATE_FUNC_ARGS); +int update_PYRO(UPDATE_FUNC_ARGS); +int update_PUMP(UPDATE_FUNC_ARGS); +int update_QRTZ(UPDATE_FUNC_ARGS); +int update_RIME(UPDATE_FUNC_ARGS); +int update_SHLD1(UPDATE_FUNC_ARGS); +int update_SHLD2(UPDATE_FUNC_ARGS); +int update_SHLD3(UPDATE_FUNC_ARGS); +int update_SHLD4(UPDATE_FUNC_ARGS); +int update_SING(UPDATE_FUNC_ARGS); +int update_SLTW(UPDATE_FUNC_ARGS); +int update_SPAWN(UPDATE_FUNC_ARGS); +int update_SPAWN2(UPDATE_FUNC_ARGS); +int update_SPNG(UPDATE_FUNC_ARGS); +int update_SPRK(UPDATE_FUNC_ARGS); +int update_STKM(UPDATE_FUNC_ARGS); +int update_STKM2(UPDATE_FUNC_ARGS); +int update_SWCH(UPDATE_FUNC_ARGS); +int update_THDR(UPDATE_FUNC_ARGS); +int update_THRM(UPDATE_FUNC_ARGS); +int update_URAN(UPDATE_FUNC_ARGS); +int update_VINE(UPDATE_FUNC_ARGS); +int update_WARP(UPDATE_FUNC_ARGS); +int update_WATR(UPDATE_FUNC_ARGS); +int update_WIFI(UPDATE_FUNC_ARGS); +int update_WTRV(UPDATE_FUNC_ARGS); +int update_YEST(UPDATE_FUNC_ARGS); + +int update_MISC(UPDATE_FUNC_ARGS); +int update_legacy_PYRO(UPDATE_FUNC_ARGS); +int update_legacy_all(UPDATE_FUNC_ARGS); + + struct particle { - int type; - int life, ctype; - float x, y, vx, vy; - float temp; - float pavg[2]; - int flags; - int tmp; + int type; + int life, ctype; + float x, y, vx, vy; + float temp; + float pavg[2]; + int flags; + int tmp; }; typedef struct particle particle; struct part_type { - const char *name; - pixel pcolors; - float advection; - float airdrag; - float airloss; - float loss; - float collision; - float gravity; - float diffusion; - float hotair; - int falldown; - int flammable; - int explosive; - int meltable; - int hardness; - int menu; - int weight; - int menusection; - float heat; - unsigned char hconduct; - const char *descs; - const unsigned short properties; - int (*update_func) (int); + const char *name; + pixel pcolors; + float advection; + float airdrag; + float airloss; + float loss; + float collision; + float gravity; + float diffusion; + float hotair; + int falldown; + int flammable; + int explosive; + int meltable; + int hardness; + int menu; + int weight; + int menusection; + float heat; + unsigned char hconduct; + const char *descs; + char state; + const unsigned short properties; + int (*update_func) (UPDATE_FUNC_ARGS); }; typedef struct part_type part_type; -struct part_state +struct part_transition { - char state; - int solid; - float stemp; - int liquid; - float ltemp; - int gas; - float gtemp; - int burn; - float btemp; + float plv; // transition occurs if pv is lower than this + int plt; + float phv; // transition occurs if pv is higher than this + int pht; + float tlv; // transition occurs if t is lower than this + int tlt; + float thv; // transition occurs if t is higher than this + int tht; }; +typedef struct part_transition part_transition; + -typedef struct part_state part_state; //Should probably be const. /* Weight Help * 1 = Gas || @@ -288,311 +365,330 @@ typedef struct part_state part_state; * 100 = Solid || * -1 is Neutrons and Photons */ +// TODO: falldown, properties, state - should at least one of these be removed? static const part_type ptypes[PT_NUM] = { - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weight Section H Ins Description - {"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", 0, NULL}, - {"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", TYPE_PART, NULL}, - {"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, NULL}, - {"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", TYPE_LIQUID, NULL}, - {"FIRE", PIXPACK(0xFF1000), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, R_TEMP+400.0f+273.15f, 88, "Ignites flammable materials. Heats air.", TYPE_GAS, NULL}, - {"STNE", PIXPACK(0xA0A0A0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Heavy particles. Meltable.", TYPE_PART, NULL}, - {"LAVA", PIXPACK(0xE05010), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 45, SC_LIQUID, R_TEMP+1500.0f+273.15f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold.", TYPE_LIQUID, NULL}, - {"GUN", PIXPACK(0xC0C0D0), 0.7f, 0.02f * CFDS, 0.94f, 0.80f, -0.1f, 0.1f, 0.00f, 0.000f * CFDS, 1, 600, 1, 0, 10, 1, 85, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 97, "Light dust. Explosive.", TYPE_PART, NULL}, - {"NITR", PIXPACK(0x20E010), 0.5f, 0.02f * CFDS, 0.92f, 0.97f, 0.0f, 0.2f, 0.00f, 0.000f * CFDS, 2, 1000, 2, 0, 3, 1, 23, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 50, "Liquid. Pressure sensitive explosive.", TYPE_LIQUID, NULL}, - {"CLNE", PIXPACK(0xFFD010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Duplicates any particles it touches.", TYPE_SOLID, NULL}, - {"GAS", PIXPACK(0xE0FF20), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 600, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Gas. Diffuses. Flammable. Liquifies under pressure.", TYPE_GAS, NULL}, - {"C-4", PIXPACK(0xD080E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 2, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Solid. Pressure sensitive explosive.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, - {"GOO", PIXPACK(0x804000), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, - {"ICE", PIXPACK(0xA0C0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP-50.0f+273.15f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air.", TYPE_SOLID, NULL}, - {"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, - {"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", TYPE_SOLID, NULL}, - {"SNOW", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_POWDERS, R_TEMP-30.0f+273.15f, 46, "Light particles.", TYPE_PART, NULL}, - {"WOOD", PIXPACK(0xC0A040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Solid. Flammable.", TYPE_SOLID, NULL}, - {"NEUT", PIXPACK(0x20E0FF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 60, "Neutrons. Interact with matter in odd ways.", TYPE_ENERGY, NULL}, - {"PLUT", PIXPACK(0x407020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 251, "Heavy particles. Fissile. Generates neutrons under pressure.", TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE, NULL}, - {"PLNT", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Plant, drinks water and grows.", TYPE_SOLID, NULL}, - {"ACID", PIXPACK(0xED55FF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 40, 0, 0, 1, 1, 10, SC_LIQUID, R_TEMP+0.0f +273.15f, 34, "Dissolves almost everything.", TYPE_LIQUID, NULL}, - {"VOID", PIXPACK(0x790B0B), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Hole, will drain away any particles.", TYPE_SOLID, NULL}, - {"WTRV", PIXPACK(0xA0A0FF), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, -0.1f, 0.75f, 0.0003f * CFDS, 0, 0, 0, 0, 4, 1, 1, SC_GAS, R_TEMP+100.0f+273.15f, 48, "Steam, heats up air, produced from hot water.", TYPE_GAS, NULL}, - {"CNCT", PIXPACK(0xC0C0C0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 100, "Concrete, stronger than stone.", TYPE_PART, NULL}, - {"DSTW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 23, "Distilled water, does not conduct electricity.", TYPE_LIQUID|PROP_NEUTPENETRATE, NULL}, - {"SALT", PIXPACK(0xFFFFFF), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 75, SC_POWDERS, R_TEMP+0.0f +273.15f, 110, "Salt, dissolves in water.", TYPE_PART, NULL}, - {"SLTW", PIXPACK(0x4050F0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 35, SC_LIQUID, R_TEMP+0.0f +273.15f, 75, "Saltwater, conducts electricity, difficult to freeze.", TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, NULL}, - {"DMND", PIXPACK(0xCCFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Diamond. Indestructable.", TYPE_SOLID, NULL}, //ief015 - Added diamond. Because concrete blocks are kinda pointless. - {"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, - {"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", TYPE_PART|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, - {"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", TYPE_ENERGY, NULL}, - {"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", TYPE_PART | PROP_RADIOACTIVE, NULL}, - {"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", TYPE_SOLID, NULL}, - {"MWAX", PIXPACK(0xE0E0AA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 5, 0, 0, 2, 1, 25, SC_LIQUID, R_TEMP+28.0f+273.15f, 44, "Liquid Wax.", TYPE_LIQUID, NULL}, - {"PSCN", PIXPACK(0x805050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "P-Type Silicon, Will transfer current to any conductor.", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"NSCN", PIXPACK(0x505080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "N-Type Silicon, Will only transfer current to P-Type Silicon.", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"LN2", PIXPACK(0x80A0DF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 30, SC_LIQUID, 70.15f, 70, "Liquid Nitrogen. Very cold.", TYPE_LIQUID, NULL}, - {"INSL", PIXPACK(0x9EA3B6), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 7, 0, 0, 10, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 0, "Insulator, does not conduct heat or electricity.", TYPE_SOLID, NULL}, - {"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, -0.01f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+70.0f+273.15f, 255, "Black hole, sucks in other particles and heats up.", TYPE_SOLID, NULL}, - {"WHOL", PIXPACK(0xEFEFEF), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.010f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP-16.0f+273.15f, 255, "White hole, pushes other particles away.", TYPE_SOLID, NULL}, - {"RBDM", PIXPACK(0xCCCCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 1, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 240, "Rubidium, explosive, especially on contact with water, low melting point", TYPE_SOLID|PROP_CONDUCTS, NULL}, - {"LRBD", PIXPACK(0xAAAAAA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 1000, 1, 0, 2, 1, 45, SC_EXPLOSIVE, R_TEMP+45.0f+273.15f, 170, "Liquid Rubidium.", TYPE_LIQUID|PROP_CONDUCTS, NULL}, - {"NTCT", PIXPACK(0x505040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"SAND", PIXPACK(0xFFD090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Sand, Heavy particles. Meltable.", TYPE_PART, NULL}, - {"GLAS", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW, NULL}, - {"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", TYPE_PART | PROP_HOT_GLOW, NULL}, - {"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_ELEC, 9000.0f +273.15f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", TYPE_ENERGY, NULL}, - {"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, 9000.0f +273.15f, 115, "Plasma, extremely hot.", TYPE_GAS, NULL}, - {"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"NICE", PIXPACK(0xC0E0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, 35.0f, 46, "Nitrogen Ice.", TYPE_SOLID, NULL}, - {"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when intruduced to electricity", TYPE_GAS | PROP_CONDUCTS, NULL}, - {"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", TYPE_SOLID, NULL}, - {"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", TYPE_SOLID, NULL}, - {"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL}, - {"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", TYPE_SOLID, NULL}, - {"SMKE", PIXPACK(0x222222), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+320.0f+273.15f, 88, "Smoke", TYPE_GAS, NULL}, - {"DESL", PIXPACK(0x440000), 1.0f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.0f, 0.0f * CFDS, 2, 2, 0, 0, 5, 1, 15, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Explodes under high pressure and temperatures", TYPE_LIQUID, NULL}, - {"COAL", PIXPACK(0x222222), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly.", TYPE_SOLID, NULL}, - {"LO2", PIXPACK(0x80A0EF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 5000, 0, 0, 0, 1, 30, SC_LIQUID, 80.0f, 70, "Liquid Oxygen. Very cold. Reacts with fire", TYPE_LIQUID, NULL}, - {"O2", PIXPACK(0x80A0FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 3.0f, 0.000f * CFDS, 0, 1000, 0, 0, 0, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 70, "Gas. Ignites easily.", TYPE_GAS, NULL}, - {"INWR", PIXPACK(0x544141), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Insulated Wire. Doesn't conduct to metal or semiconductors.", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"YEST", PIXPACK(0xEEE0C0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 15, 0, 0, 30, 1, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Yeast, grows when warm (~37C).", TYPE_PART, NULL}, - {"DYST", PIXPACK(0xBBB0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 20, 0, 0, 30, 0, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Dead Yeast.", TYPE_PART, NULL}, - {"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremly high temperature.", TYPE_PART, NULL}, - {"GLOW", PIXPACK(0x445544), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", TYPE_LIQUID, NULL}, - {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", TYPE_SOLID|PROP_HOT_GLOW, NULL}, - {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", TYPE_GAS, NULL}, - {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", TYPE_PART, NULL}, - {"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", TYPE_SOLID, NULL}, - {"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", TYPE_PART, NULL}, - {"AMTR", PIXPACK(0x808080), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.00f, 0.10f, 1.00f, 0.0000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Anti-Matter, Destroys a majority of particles", TYPE_PART, NULL}, //Maybe TYPE_ENERGY? - {"BCOL", PIXPACK(0x333333), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Coal. Heavy particles. See COAL", TYPE_PART, NULL}, - {"PCLN", PIXPACK(0x3B3B10), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. When actived, duplicates any particles it touches.", TYPE_SOLID, NULL}, - {"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", TYPE_SOLID, NULL}, - {"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrolysis of WATR", TYPE_SOLID | PROP_CONDUCTS, NULL}, - {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", TYPE_PART, NULL}, - {"GOL ", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", TYPE_SOLID|PROP_LIFE, NULL}, - {"HLIF", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "High Life! B36/S23", TYPE_SOLID|PROP_LIFE, NULL}, - {"ASIM", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Assimilation! B345/S4567", TYPE_SOLID|PROP_LIFE, NULL}, - {"2x2 ", PIXPACK(0xFFFF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "2x2! B36/S125", TYPE_SOLID|PROP_LIFE, NULL}, - {"DANI", PIXPACK(0x00FFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Day and Night! B3678/S34678", TYPE_SOLID|PROP_LIFE, NULL}, - {"AMOE", PIXPACK(0xFF00FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Amoeba! B357/S1358", TYPE_SOLID|PROP_LIFE, NULL}, - {"MOVE", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type B368/S245", TYPE_SOLID|PROP_LIFE, NULL}, - {"PGOL", PIXPACK(0xE05010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Pseudo Life! B357/S238", TYPE_SOLID|PROP_LIFE, NULL}, - {"DMOE", PIXPACK(0x500000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Diamoeba! B35678/S5678", TYPE_SOLID|PROP_LIFE, NULL}, - {"34 ", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", TYPE_SOLID|PROP_LIFE, NULL}, - {"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", TYPE_SOLID|PROP_LIFE, NULL}, - {"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", TYPE_SOLID|PROP_LIFE, NULL}, - {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.",TYPE_SOLID, NULL}, - {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice",TYPE_SOLID, NULL}, - {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam",TYPE_GAS, NULL}, - {"BCLN", PIXPACK(0xFFD040), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Breakable Clone.", TYPE_SOLID, NULL}, - {"LOVE", PIXPACK(0xFF30FF), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_CRACKER2, 373.0f, 40, "Love...", TYPE_SOLID, NULL}, - {"DEUT", PIXPACK(0x00153F), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 251, "Deuterium oxide. Volume changes with temp, radioactive with neutrons.", TYPE_LIQUID|PROP_NEUTPENETRATE, NULL}, - {"WARP", PIXPACK(0x000000), 0.8f, 0.00f * CFDS, 0.9f, 0.70f, -0.1f, 0.0f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_NUCLEAR, R_TEMP +273.15f, 100, "Displaces other elements.",TYPE_GAS, NULL}, - {"PUMP", PIXPACK(0x10103B), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_ELEC, 273.15f, 0, "Changes pressure to its temp when activated. (use HEAT/COOL).", TYPE_SOLID, NULL}, - {"FWRK", PIXPACK(0x666666), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 1, 1, 97, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 100, "First fireworks made, activated by heat/neutrons.", TYPE_PART, NULL}, - {"PIPE", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, 273.15f, 0, "Moves elements around, read FAQ on website for help.", TYPE_SOLID, NULL}, - {"FRZZ", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_CRACKER2, 90.0f, 46, "FREEZE", TYPE_PART, NULL}, - {"FRZW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_CRACKER2, 120.0f, 29, "FREEZE WATER", TYPE_LIQUID, NULL}, - {"GRAV", PIXPACK(0xFFE0A0), 0.7f, 0.00f * CFDS, 1.00f, 1.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Changes colour based on velocity.", TYPE_PART, NULL}, - {"BIZR", PIXPACK(0x00FF77), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP+0.0f +273.15f, 29, "Bizarre... contradicts the normal state changes.", TYPE_LIQUID, NULL}, - {"BIZG", PIXPACK(0x00FFBB), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 2.75f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_CRACKER2, R_TEMP-200.0f+273.15f, 42, "Bizarre gas", TYPE_GAS, NULL}, - {"BIZS", PIXPACK(0x00E455), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_CRACKER2, R_TEMP+300.0f+273.15f, 251, "Bizarre solid", TYPE_SOLID, NULL}, - {"INST", PIXPACK(0x404039), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Instantly conducts, PSCN to charge, NSCN to take.", TYPE_SOLID, NULL}, - {"ISOZ", PIXPACK(0xAA30D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 24, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 29, "Radioactive liquid", TYPE_LIQUID|PROP_NEUTPENETRATE, NULL}, - {"ISZS", PIXPACK(0x662089), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0007f* CFDS, 0, 0, 0, 1, 1, 1, 100, SC_NUCLEAR, 140.00f, 251, "Solid form of ISOZ, slowly decays.", TYPE_SOLID, NULL}, - {"PRTI", PIXPACK(0xEB5917), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal IN. Things go in here, now with channels (same as WIFI)", TYPE_SOLID, NULL}, - {"PRTO", PIXPACK(0x0020EB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal OUT. Things come out here, now with channels (same as WIFI)", TYPE_SOLID, NULL}, - {"PSTE", PIXPACK(0xAA99AA), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Colloid, Hardens under pressure", TYPE_LIQUID, NULL}, - {"PSTS", PIXPACK(0x776677), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 20, 0, 100, SC_CRACKER, R_TEMP-2.0f +273.15f, 29, "Solid form of PSTE, temporary", TYPE_SOLID, NULL}, - {"ANAR", PIXPACK(0xFFFFEE), -0.7f, -0.02f * CFDS, 0.96f, 0.80f, 0.1f, -0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Behaves opposite gravity", TYPE_PART, NULL}, - {"VINE", PIXPACK(0x079A00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Vine, grows", TYPE_SOLID, NULL}, - {"INVS", PIXPACK(0x00CCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Invisible to everything while under pressure.", TYPE_SOLID | PROP_NEUTPASS, NULL}, - {"EQVE", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 0, 85, SC_CRACKER2, R_TEMP+0.0f +273.15f, 70, "Shared velocity test", TYPE_PART, NULL}, - {"SPWN2", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL}, - {"SPWN", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL}, - {"SHLD", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL}, - {"SHD2", PIXPACK(0x777777), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 2", 0, NULL}, - {"SHD3", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 3", 0, NULL}, - {"SHD4", PIXPACK(0x212121), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 4", 0, NULL}, - {"LOLZ", PIXPACK(0x569212), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_CRACKER2, 373.0f, 40, "Lolz", TYPE_SOLID, NULL}, - {"WIFI", PIXPACK(0x40A060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 2, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "Wireless transmitter, color coded.", TYPE_SOLID, NULL}, - {"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", TYPE_SOLID, NULL}, - {"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emmitter. Rays create points when they collide", TYPE_SOLID, NULL}, - {"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL}, - {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL}, - {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", TYPE_PART, NULL}, - {"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, - {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", TYPE_PART, NULL}, - {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", TYPE_SOLID | PROP_HOT_GLOW, NULL}, - {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", TYPE_PART| PROP_HOT_GLOW, NULL}, - {"SEED", PIXPACK(0xFBEC7D), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B2/S", TYPE_SOLID|PROP_LIFE, NULL}, - {"MAZE", PIXPACK(0xA8E4A0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3/S12345", TYPE_SOLID|PROP_LIFE, NULL}, - {"COAG", PIXPACK(0x9ACD32), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B378/S235678", TYPE_SOLID|PROP_LIFE, NULL}, - {"WALL", PIXPACK(0x0047AB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B45678/S2345", TYPE_SOLID|PROP_LIFE, NULL}, - {"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1/S1", TYPE_SOLID|PROP_LIFE, NULL}, - {"REPL", PIXPACK(0x259588), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1357/S1357", TYPE_SOLID|PROP_LIFE, NULL}, - {"MYST", PIXPACK(0x0C3C00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3458/S05678", TYPE_SOLID|PROP_LIFE, NULL}, - {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", TYPE_GAS, NULL}, - {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", TYPE_SOLID|PROP_LIFE, NULL}, - {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", TYPE_SOLID|PROP_LIFE, NULL}, - {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", TYPE_SOLID|PROP_LIFE, NULL}, - {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", TYPE_SOLID|PROP_LIFE, NULL}, - {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", TYPE_SOLID|PROP_LIFE, NULL}, + //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weight Section H Ins Description + {"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL}, + {"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", ST_SOLID, TYPE_PART, NULL}, + {"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, &update_WATR}, + {"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", ST_LIQUID, TYPE_LIQUID, NULL}, + {"FIRE", PIXPACK(0xFF1000), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, R_TEMP+400.0f+273.15f, 88, "Ignites flammable materials. Heats air.", ST_GAS, TYPE_GAS, &update_PYRO}, + {"STNE", PIXPACK(0xA0A0A0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Heavy particles. Meltable.", ST_SOLID, TYPE_PART, NULL}, + {"LAVA", PIXPACK(0xE05010), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 45, SC_LIQUID, R_TEMP+1500.0f+273.15f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold.", ST_LIQUID, TYPE_LIQUID, &update_PYRO}, + {"GUN", PIXPACK(0xC0C0D0), 0.7f, 0.02f * CFDS, 0.94f, 0.80f, -0.1f, 0.1f, 0.00f, 0.000f * CFDS, 1, 600, 1, 0, 10, 1, 85, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 97, "Light dust. Explosive.", ST_SOLID, TYPE_PART, NULL}, + {"NITR", PIXPACK(0x20E010), 0.5f, 0.02f * CFDS, 0.92f, 0.97f, 0.0f, 0.2f, 0.00f, 0.000f * CFDS, 2, 1000, 2, 0, 3, 1, 23, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 50, "Liquid. Pressure sensitive explosive.", ST_LIQUID, TYPE_LIQUID, NULL}, + {"CLNE", PIXPACK(0xFFD010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Solid. Duplicates any particles it touches.", ST_SOLID, TYPE_SOLID, &update_CLNE}, + {"GAS", PIXPACK(0xE0FF20), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 600, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Gas. Diffuses. Flammable. Liquefies under pressure.", ST_GAS, TYPE_GAS, NULL}, + {"C-4", PIXPACK(0xD080E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 2, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Solid. Pressure sensitive explosive.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, + {"GOO", PIXPACK(0x804000), 0.0f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_GOO}, + {"ICE", PIXPACK(0xA0C0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP-50.0f+273.15f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air.", ST_SOLID, TYPE_SOLID, &update_ICEI}, + {"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, + {"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", ST_SOLID, TYPE_SOLID, &update_SPRK}, + {"SNOW", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_POWDERS, R_TEMP-30.0f+273.15f, 46, "Light particles.", ST_SOLID, TYPE_PART, &update_ICEI}, + {"WOOD", PIXPACK(0xC0A040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Solid. Flammable.", ST_SOLID, TYPE_SOLID, NULL}, + {"NEUT", PIXPACK(0x20E0FF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 60, "Neutrons. Interact with matter in odd ways.", ST_GAS, TYPE_ENERGY, &update_NEUT}, + {"PLUT", PIXPACK(0x407020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 251, "Heavy particles. Fissile. Generates neutrons under pressure.", ST_SOLID, TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE, &update_PLUT}, + {"PLNT", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Plant, drinks water and grows.", ST_SOLID, TYPE_SOLID, &update_PLNT}, + {"ACID", PIXPACK(0xED55FF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 40, 0, 0, 1, 1, 10, SC_LIQUID, R_TEMP+0.0f +273.15f, 34, "Dissolves almost everything.", ST_LIQUID, TYPE_LIQUID, &update_ACID}, + {"VOID", PIXPACK(0x790B0B), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Hole, will drain away any particles.", ST_SOLID, TYPE_SOLID, NULL}, + {"WTRV", PIXPACK(0xA0A0FF), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, -0.1f, 0.75f, 0.0003f * CFDS, 0, 0, 0, 0, 4, 1, 1, SC_GAS, R_TEMP+100.0f+273.15f, 48, "Steam, heats up air, produced from hot water.", ST_GAS, TYPE_GAS, &update_WTRV}, + {"CNCT", PIXPACK(0xC0C0C0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 100, "Concrete, stronger than stone.", ST_SOLID, TYPE_PART, NULL}, + {"DSTW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 23, "Distilled water, does not conduct electricity.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE, &update_DSTW}, + {"SALT", PIXPACK(0xFFFFFF), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 75, SC_POWDERS, R_TEMP+0.0f +273.15f, 110, "Salt, dissolves in water.", ST_SOLID, TYPE_PART, NULL}, + {"SLTW", PIXPACK(0x4050F0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 35, SC_LIQUID, R_TEMP+0.0f +273.15f, 75, "Saltwater, conducts electricity, difficult to freeze.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, &update_SLTW}, + {"DMND", PIXPACK(0xCCFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Diamond. Indestructible.", ST_SOLID, TYPE_SOLID, NULL}, + {"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, &update_BMTL}, + {"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, + {"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", ST_GAS, TYPE_ENERGY, &update_PHOT}, + {"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", ST_SOLID, TYPE_PART | PROP_RADIOACTIVE, &update_URAN}, + {"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", ST_SOLID, TYPE_SOLID, NULL}, + {"MWAX", PIXPACK(0xE0E0AA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 5, 0, 0, 2, 1, 25, SC_LIQUID, R_TEMP+28.0f+273.15f, 44, "Liquid Wax.", ST_LIQUID, TYPE_LIQUID, NULL}, + {"PSCN", PIXPACK(0x805050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "P-Type Silicon, Will transfer current to any conductor.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"NSCN", PIXPACK(0x505080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "N-Type Silicon, Will only transfer current to P-Type Silicon.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"LN2", PIXPACK(0x80A0DF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 30, SC_LIQUID, 70.15f, 70, "Liquid Nitrogen. Very cold.", ST_SOLID, TYPE_LIQUID, NULL}, + {"INSL", PIXPACK(0x9EA3B6), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 7, 0, 0, 10, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 0, "Insulator, does not conduct heat or electricity.", ST_SOLID, TYPE_SOLID, NULL}, + {"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, -0.01f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+70.0f+273.15f, 255, "Black hole, sucks in other particles and heats up.", ST_NONE, TYPE_SOLID, NULL}, + {"WHOL", PIXPACK(0xEFEFEF), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.010f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP-16.0f+273.15f, 255, "White hole, pushes other particles away.", ST_NONE, TYPE_SOLID, NULL}, + {"RBDM", PIXPACK(0xCCCCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 1, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 240, "Rubidium, explosive, especially on contact with water, low melting point", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"LRBD", PIXPACK(0xAAAAAA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 1000, 1, 0, 2, 1, 45, SC_EXPLOSIVE, R_TEMP+45.0f+273.15f, 170, "Liquid Rubidium.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS, NULL}, + {"NTCT", PIXPACK(0x505040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_NPTCT}, + {"SAND", PIXPACK(0xFFD090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Sand, Heavy particles. Meltable.", ST_SOLID, TYPE_PART, NULL}, + {"GLAS", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", ST_SOLID, TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW, &update_GLAS}, + {"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 100C)", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_NPTCT}, + {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", ST_SOLID, TYPE_PART | PROP_HOT_GLOW, NULL}, + {"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_ELEC, 9000.0f +273.15f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", ST_NONE, TYPE_ENERGY, &update_THDR}, + {"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, 9000.0f +273.15f, 115, "Plasma, extremely hot.", ST_NONE, TYPE_GAS, &update_PYRO}, + {"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", ST_NONE, TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"NICE", PIXPACK(0xC0E0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, 35.0f, 46, "Nitrogen Ice.", ST_SOLID, TYPE_SOLID, NULL}, + {"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity", ST_GAS, TYPE_GAS|PROP_CONDUCTS, NULL}, + {"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", ST_SOLID, TYPE_SOLID, &update_BTRY}, + {"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", ST_SOLID, TYPE_SOLID, &update_LCRY}, + {"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM}, + {"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", ST_SOLID, TYPE_SOLID, &update_SWCH}, + {"SMKE", PIXPACK(0x222222), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+320.0f+273.15f, 88, "Smoke", ST_SOLID, TYPE_GAS, NULL}, + {"DESL", PIXPACK(0x440000), 1.0f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.0f, 0.0f * CFDS, 2, 2, 0, 0, 5, 1, 15, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Explodes under high pressure and temperatures", ST_LIQUID, TYPE_LIQUID, NULL}, + {"COAL", PIXPACK(0x222222), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly.", ST_SOLID, TYPE_SOLID, &update_COAL}, + {"LO2", PIXPACK(0x80A0EF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 5000, 0, 0, 0, 1, 30, SC_LIQUID, 80.0f, 70, "Liquid Oxygen. Very cold. Reacts with fire", ST_LIQUID, TYPE_LIQUID, NULL}, + {"O2", PIXPACK(0x80A0FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 3.0f, 0.000f * CFDS, 0, 1000, 0, 0, 0, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 70, "Gas. Ignites easily.", ST_GAS, TYPE_GAS, NULL}, + {"INWR", PIXPACK(0x544141), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Insulated Wire. Doesn't conduct to metal or semiconductors.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"YEST", PIXPACK(0xEEE0C0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 15, 0, 0, 30, 1, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Yeast, grows when warm (~37C).", ST_SOLID, TYPE_PART, &update_YEST}, + {"DYST", PIXPACK(0xBBB0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 20, 0, 0, 30, 0, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Dead Yeast.", ST_SOLID, TYPE_PART, NULL}, + {"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremely high temperature.", ST_SOLID, TYPE_PART, &update_THRM}, + {"GLOW", PIXPACK(0x445544), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW}, + {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW, NULL}, + {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL}, + {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", ST_SOLID, TYPE_PART, &update_FIRW}, + {"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", ST_SOLID, TYPE_SOLID, &update_FUSE}, + {"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", ST_SOLID, TYPE_PART, &update_FSEP}, + {"AMTR", PIXPACK(0x808080), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.00f, 0.10f, 1.00f, 0.0000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Anti-Matter, Destroys a majority of particles", ST_NONE, TYPE_PART, NULL}, //Maybe TYPE_ENERGY? + {"BCOL", PIXPACK(0x333333), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Coal. Heavy particles. See COAL", ST_SOLID, TYPE_PART, &update_BCOL}, + {"PCLN", PIXPACK(0x3B3B10), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. When activated, duplicates any particles it touches.", ST_NONE, TYPE_SOLID, &update_PCLN}, + {"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", ST_NONE, TYPE_SOLID, &update_HSWC}, + {"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrolysis of WATR", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_IRON}, + {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", ST_NONE, TYPE_PART, &update_MORT}, + {"GOL ", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"HLIF", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "High Life! B36/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"ASIM", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Assimilation! B345/S4567", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"2x2 ", PIXPACK(0xFFFF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"DANI", PIXPACK(0x00FFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Day and Night! B3678/S34678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"AMOE", PIXPACK(0xFF00FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Amoeba! B357/S1358", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"MOVE", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type B368/S245", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"PGOL", PIXPACK(0xE05010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Pseudo Life! B357/S238", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"DMOE", PIXPACK(0x500000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Diamoeba! B35678/S5678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"34 ", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, + {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice", ST_SOLID, TYPE_SOLID, &update_RIME}, + {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam", ST_GAS, TYPE_GAS, &update_FOG}, + {"BCLN", PIXPACK(0xFFD040), 0.0f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Breakable Clone.", ST_NONE, TYPE_SOLID, &update_BCLN}, + {"LOVE", PIXPACK(0xFF30FF), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_CRACKER2, 373.0f, 40, "Love...", ST_GAS, TYPE_SOLID, &update_MISC}, + {"DEUT", PIXPACK(0x00153F), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 251, "Deuterium oxide. Volume changes with temp, radioactive with neutrons.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE, &update_DEUT}, + {"WARP", PIXPACK(0x000000), 0.8f, 0.00f * CFDS, 0.9f, 0.70f, -0.1f, 0.0f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_NUCLEAR, R_TEMP +273.15f, 100, "Displaces other elements.", ST_GAS, TYPE_GAS, &update_WARP}, + {"PUMP", PIXPACK(0x10103B), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_ELEC, 273.15f, 0, "Changes pressure to its temp when activated. (use HEAT/COOL).", ST_SOLID, TYPE_SOLID, &update_PUMP}, + {"FWRK", PIXPACK(0x666666), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 1, 1, 97, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 100, "First fireworks made, activated by heat/neutrons.", ST_SOLID, TYPE_PART, &update_FWRK}, + {"PIPE", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, 273.15f, 0, "Moves elements around, read FAQ on website for help.", ST_SOLID, TYPE_SOLID, &update_PIPE}, + {"FRZZ", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_CRACKER2, 90.0f, 46, "FREEZE", ST_SOLID, TYPE_PART, &update_FRZZ}, + {"FRZW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_CRACKER2, 120.0f, 29, "FREEZE WATER", ST_LIQUID, TYPE_LIQUID, &update_FRZW}, + {"GRAV", PIXPACK(0xFFE0A0), 0.7f, 0.00f * CFDS, 1.00f, 1.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Changes colour based on velocity.", ST_SOLID, TYPE_PART, &update_MISC}, + {"BIZR", PIXPACK(0x00FF77), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP+0.0f +273.15f, 29, "Bizarre... contradicts the normal state changes.", ST_LIQUID, TYPE_LIQUID, NULL}, + {"BIZG", PIXPACK(0x00FFBB), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 2.75f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_CRACKER2, R_TEMP-200.0f+273.15f, 42, "Bizarre gas", ST_GAS, TYPE_GAS, NULL}, + {"BIZS", PIXPACK(0x00E455), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_CRACKER2, R_TEMP+300.0f+273.15f, 251, "Bizarre solid", ST_SOLID, TYPE_SOLID, NULL}, + {"INST", PIXPACK(0x404039), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Instantly conducts, PSCN to charge, NSCN to take.", ST_SOLID, TYPE_SOLID, NULL}, + {"ISOZ", PIXPACK(0xAA30D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 24, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 29, "Radioactive liquid", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE, &update_ISZ}, + {"ISZS", PIXPACK(0x662089), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0007f* CFDS, 0, 0, 0, 1, 1, 1, 100, SC_NUCLEAR, 140.00f, 251, "Solid form of ISOZ, slowly decays.", ST_SOLID, TYPE_SOLID, &update_ISZ}, + {"PRTI", PIXPACK(0xEB5917), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal IN. Things go in here, now with channels (same as WIFI)", ST_SOLID, TYPE_SOLID, &update_PRTI}, + {"PRTO", PIXPACK(0x0020EB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal OUT. Things come out here, now with channels (same as WIFI)", ST_SOLID, TYPE_SOLID, &update_PRTO}, + {"PSTE", PIXPACK(0xAA99AA), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Colloid, Hardens under pressure", ST_LIQUID, TYPE_LIQUID, NULL}, + {"PSTS", PIXPACK(0x776677), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 20, 0, 100, SC_CRACKER, R_TEMP-2.0f +273.15f, 29, "Solid form of PSTE, temporary", ST_SOLID, TYPE_SOLID, NULL}, + {"ANAR", PIXPACK(0xFFFFEE), -0.7f, -0.02f * CFDS, 0.96f, 0.80f, 0.1f, -0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Behaves opposite gravity", ST_SOLID, TYPE_PART, NULL}, + {"VINE", PIXPACK(0x079A00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Vine, grows", ST_SOLID, TYPE_SOLID, &update_VINE}, + {"INVS", PIXPACK(0x00CCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Invisible to everything while under pressure.", ST_SOLID, TYPE_SOLID | PROP_NEUTPASS, NULL}, + {"EQVE", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 0, 85, SC_CRACKER2, R_TEMP+0.0f +273.15f, 70, "Shared velocity test", ST_SOLID, TYPE_PART, NULL}, + {"SPWN2", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "STK2 spawn point", ST_SOLID, 0, &update_SPAWN2}, + {"SPWN", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "STKM spawn point", ST_SOLID, 0, &update_SPAWN}, + {"SHLD", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", ST_SOLID, 0, &update_SHLD1}, + {"SHD2", PIXPACK(0x777777), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 2", ST_SOLID, 0, &update_SHLD2}, + {"SHD3", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 3", ST_SOLID, 0, &update_SHLD3}, + {"SHD4", PIXPACK(0x212121), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 4", ST_SOLID, 0, &update_SHLD4}, + {"LOLZ", PIXPACK(0x569212), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_CRACKER2, 373.0f, 40, "Lolz", ST_GAS, TYPE_SOLID, &update_MISC}, + {"WIFI", PIXPACK(0x40A060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 2, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "Wireless transmitter, color coded.", ST_SOLID, TYPE_SOLID, &update_WIFI}, + {"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", ST_SOLID, TYPE_SOLID, NULL}, + {"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emitter. Rays create points when they collide", ST_SOLID, TYPE_SOLID, &update_ARAY}, + {"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", ST_SOLID, TYPE_SOLID, NULL}, + {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM2}, + {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", ST_NONE, TYPE_PART, &update_BOMB}, + {"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_C5}, + {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART, &update_SING}, + {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, &update_QRTZ}, + {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", ST_SOLID, TYPE_PART| PROP_HOT_GLOW, NULL}, + {"SEED", PIXPACK(0xFBEC7D), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B2/S", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"MAZE", PIXPACK(0xA8E4A0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3/S12345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"COAG", PIXPACK(0x9ACD32), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B378/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"WALL", PIXPACK(0x0047AB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B45678/S2345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"REPL", PIXPACK(0x259588), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1357/S1357", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"MYST", PIXPACK(0x0C3C00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3458/S05678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + + {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL}, + {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", TYPE_SOLID|PROP_LIFE, NULL}, + {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", TYPE_SOLID|PROP_LIFE, NULL}, + {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", TYPE_SOLID|PROP_LIFE, NULL}, + {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", TYPE_SOLID|PROP_LIFE, NULL}, + {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", TYPE_SOLID|PROP_LIFE, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; -static part_state pstates[PT_NUM] = -{ - // Name State Solid Frzp Liquid Mpnt Gas Bpoint 'Plasma' Flashpoint - /* NONE */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* DUST */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WATR */ {ST_LIQUID, PT_ICEI, 273.15f, PT_NONE, 0.0f, PT_WTRV, 373.0f, PT_NONE, 0.0f}, - /* OIL */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_GAS, 333.0f, PT_NONE, 0.0f}, - /* FIRE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_PLSM, 2773.0f}, - /* STNE */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 983.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LAVA */ {ST_LIQUID, PT_STNE, 973.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GUN */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 673.0f}, - /* NITR */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 673.0f}, - /* CLNE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GAS */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 50.0f, PT_FIRE, 573.0f}, - /* C-4 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 673.0f}, - /* GOO */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ICE */ {ST_SOLID, PT_NONE, 0.0f, PT_WATR, 274.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* METL */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1273.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SPRK */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SNOW */ {ST_SOLID, PT_NONE, 0.0f, PT_WATR, 273.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WOOD */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 873.0f}, - /* NEUT */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PLUT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PLNT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 573.0f}, - /* ACID */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* VOID */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WTRV */ {ST_GAS, PT_RIME, 273.0f, PT_DSTW, 371.0f, PT_NONE, 373.0f, PT_NONE, 0.0f}, - /* CNCT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1123.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* DSTW */ {ST_LIQUID, PT_ICEI, 273.15f, PT_NONE, 0.0f, PT_WTRV, 373.0f, PT_NONE, 0.0f}, - /* SALT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1173.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SLTW */ {ST_LIQUID, PT_ICEI, 233.0f, PT_NONE, 0.0f, PT_WTRV, 483.0f, PT_NONE, 0.0f}, - /* DMND */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BMTL */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1273.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BRMT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1273.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PHOT */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* URAN */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 2373.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WAX */ {ST_SOLID, PT_NONE, 0.0f, PT_MWAX, 319.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* MWAX */ {ST_LIQUID, PT_WAX, 318.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 673.0f}, - /* PSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* NSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LNTG */ {ST_SOLID, PT_NICE, 63.0f, PT_NONE, 0.0f, PT_NONE, 77.0f, PT_NONE, 0.0f}, - /* FOAM */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BHOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WHOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* RBDM */ {ST_SOLID, PT_NONE, 0.0f, PT_LRBD, 312.0f, PT_NONE, 0.0f, PT_FIRE, 961.0f}, - /* LRBD */ {ST_LIQUID, PT_RBDM, 311.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 961.0f}, - /* HSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SAND */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1973.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GLAS */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1973.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* CSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BGLA */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1973.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* THDR */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PLSM */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ETRD */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* NICE */ {ST_SOLID, PT_NONE, 0.0f, PT_LNTG, 63.1f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* NBLE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BTRY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_PLSM, 2273.0f}, - /* LCRY */ {ST_SOLID, PT_NONE, 0.0f, PT_BGLA, 1273.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* STKM */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f}, - /* SWCH */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SMKE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 625.0f}, - /* DESL */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 335.0f}, - /* COAL */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LO2 */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_O2, 90.1f, PT_NONE, 0.0f}, - /* O2 */ {ST_GAS, PT_NONE, 0.0f, PT_LO2, 90.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* INWR */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* YEST */ {ST_SOLID, PT_NONE, 0.0f, PT_DYST, 373.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* DYST */ {ST_SOLID, PT_NONE, 0.0f, PT_DUST, 473.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* THRM */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GLOW */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BRCK */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1223.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* HFLM */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FIRW */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FUSE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FSEP */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* AMtr */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BCOL */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PCLN */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* HSWC */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* IRON */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* MORT */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SPNG */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 2730.0f}, - /* RIME */ {ST_SOLID, PT_NONE, 0.0f, PT_WATR, 273.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FOG */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BCLN */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LOVE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WTF */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WARP */ {ST_GAS , PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PUMP */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FWRK */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FWRK */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FRZZ */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FRZW */ {ST_LIQUID, PT_ICEI, 53.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GRAV */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BIZR */ {ST_LIQUID, PT_BIZRG, 100.0f, PT_NONE, 0.0f, PT_BIZRS, 400.0f, PT_NONE, 0.0f}, - /* BIZRG*/ {ST_GAS , PT_BIZRG, 100.0f, PT_BIZR , 273.0f, PT_BIZRS, 400.0f, PT_NONE, 0.0f}, - /* BIZRS*/ {ST_SOLID, PT_BIZRG, 100.0f, PT_BIZR , 273.0f, PT_BIZRS, 400.0f, PT_NONE, 0.0f}, - /* INST */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ISOZ */ {ST_LIQUID, PT_ISZS, 160.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ISZS */ {ST_SOLID, PT_NONE, 0.0f, PT_ISOZ, 300.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PRTI */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PRTO */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PSTE */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PSTS */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ANAR */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* VINE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 573.0f}, - /* INVS */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* EQVE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SPWN2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SPAWN*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SHLD1*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SHLD2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SHLD3*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SHLD4*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LOlZ */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WIFI */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* FILT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* ARAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BRAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* STKM2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f}, - /* BOMB */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* C-5 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SING */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* QRTZ */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 2573.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* PQRT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 2573.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BOYL */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 50.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, +// temporarily define abbreviations for impossible p/t values +#define IPL -257.0f +#define IPH 257.0f +#define ITL MIN_TEMP-1 +#define ITH MAX_TEMP+1 +// no transition (PT_NONE means kill part) +#define NT -1 +// special transition - lava ctypes etc need extra code, which is only found and run if ST is given +#define ST PT_NUM +static part_transition ptransitions[PT_NUM] = +{ // if low pressure if high pressure if low temperature if high temperature + // Name plv plt phv pht tlv tlt thv tht + /* NONE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* DUST */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WATR */ {IPL, NT, IPH, NT, 273.15f,PT_ICEI, 373.0f, PT_WTRV}, + /* OIL */ {IPL, NT, IPH, NT, ITL, NT, 333.0f, PT_GAS}, + /* FIRE */ {IPL, NT, IPH, NT, ITL, NT, 2773.0f,PT_PLSM}, + /* STNE */ {IPL, NT, IPH, NT, ITL, NT, 983.0f, PT_LAVA}, + /* LAVA */ {IPL, NT, IPH, NT, 2573.15f,ST, ITH, NT}, // 2573.15f is highest melt pt of possible ctypes + /* GUN */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, + /* NITR */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, + /* CLNE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GAS */ {-6.0f, PT_OIL, 6.0f, PT_OIL, ITL, NT, 573.0f, PT_FIRE}, + /* C-4 */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, + /* GOO */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* ICE */ {IPL, NT, 0.8f, PT_SNOW, ITL, NT, 233.0f, ST}, + /* METL */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_LAVA}, + /* SPRK */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SNOW */ {IPL, NT, IPH, NT, ITL, NT, 273.0f, PT_WATR}, + /* WOOD */ {IPL, NT, IPH, NT, ITL, NT, 873.0f, PT_FIRE}, + /* NEUT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PLUT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PLNT */ {IPL, NT, IPH, NT, ITL, NT, 573.0f, PT_FIRE}, + /* ACID */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* VOID */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WTRV */ {IPL, NT, IPH, NT, 371.0f, ST, ITH, NT}, + /* CNCT */ {IPL, NT, IPH, NT, ITL, NT, 1123.0f,PT_LAVA}, + /* DSTW */ {IPL, NT, IPH, NT, 273.15f,PT_ICEI, 373.0f, PT_WTRV}, + /* SALT */ {IPL, NT, IPH, NT, ITL, NT, 1173.0f,PT_LAVA}, + /* SLTW */ {IPL, NT, IPH, NT, 233.0f, PT_ICEI, 483.0f, ST}, + /* DMND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BMTL */ {IPL, NT, 1.0f, ST, ITL, NT, 1273.0f,PT_LAVA}, + /* BRMT */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_LAVA}, + /* PHOT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* URAN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WAX */ {IPL, NT, IPH, NT, ITL, NT, 319.0f, PT_MWAX}, + /* MWAX */ {IPL, NT, IPH, NT, 318.0f, PT_WAX, 673.0f, PT_FIRE}, + /* PSCN */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA}, + /* NSCN */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA}, + /* LN2 */ {IPL, NT, IPH, NT, 63.0f, PT_NICE, 77.0f, PT_NONE}, + /* INSL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BHOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WHOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* RBDM */ {IPL, NT, IPH, NT, ITL, NT, 312.0f, PT_LRBD}, + /* LRBD */ {IPL, NT, IPH, NT, 311.0f, PT_RBDM, 961.0f, PT_FIRE}, + /* NTCT */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA}, + /* SAND */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA}, + /* GLAS */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA}, + /* PTCT */ {IPL, NT, IPH, NT, ITL, NT, 1414.0f,PT_LAVA}, + /* BGLA */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA}, + /* THDR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PLSM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* ETRD */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* NICE */ {IPL, NT, IPH, NT, ITL, NT, 63.1f, PT_LNTG}, + /* NBLE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BTRY */ {IPL, NT, IPH, NT, ITL, NT, 2273.0f,PT_PLSM}, + /* LCRY */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_BGLA}, + /* STKM */ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE}, + /* SWCH */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SMKE */ {IPL, NT, IPH, NT, ITL, NT, 625.0f, PT_FIRE}, + /* DESL */ {IPL, NT, 5.0f, PT_FIRE, ITL, NT, 335.0f, PT_FIRE}, + /* COAL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* LO2 */ {IPL, NT, IPH, NT, ITL, NT, 90.1f, PT_O2}, + /* O2 */ {IPL, NT, IPH, NT, 90.0f, PT_LO2, ITH, NT}, + /* INWR */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA}, + /* YEST */ {IPL, NT, IPH, NT, ITL, NT, 373.0f, PT_DYST}, + /* DYST */ {IPL, NT, IPH, NT, ITL, NT, 473.0f, PT_DUST}, + /* THRM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GLOW */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BRCK */ {IPL, NT, 8.8f, PT_STNE, ITL, NT, 1223.0f,PT_LAVA}, + /* CFLM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* FIRW */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* FUSE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* FSEP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* AMTR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BCOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PCLN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* HSWC */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* IRON */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA}, + /* MORT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SPNG */ {IPL, NT, IPH, NT, ITL, NT, 2730.0f,PT_FIRE}, + /* RIME */ {IPL, NT, IPH, NT, ITL, NT, 273.15f,PT_WATR}, + /* FOG */ {IPL, NT, IPH, NT, ITL, NT, 373.15f,PT_WTRV}, + /* BCLN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* LOVE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* DEUT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WARP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PUMP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* FWRK */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PIPE */ {IPL, NT, 10.0f, PT_BRMT, ITL, NT, ITH, NT}, + /* FRZZ */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* FRZW */ {IPL, NT, IPH, NT, ITL, NT, 53.0f, PT_ICEI}, + /* GRAV */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BIZR */ {IPL, NT, IPH, NT, 100.0f, PT_BIZRG, 400.0f, PT_BIZRS}, + /* BIZRG*/ {IPL, NT, IPH, NT, ITL, NT, 100.0f, PT_BIZR},//, 400.0f, PT_BIZRS}, + /* BIZRS*/ {IPL, NT, IPH, NT, 400.0f, PT_BIZR, ITH, NT},// 100.0f, PT_BIZRG}, + /* INST */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* ISOZ */ {IPL, NT, IPH, NT, 160.0f, PT_ISZS, ITH, NT}, + /* ISZS */ {IPL, NT, IPH, NT, ITL, NT, 300.0f, PT_ISOZ}, + /* PRTI */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PRTO */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* PSTE */ {IPL, NT, 0.5f, PT_PSTS, ITL, NT, 747.0f, PT_BRCK}, + /* PSTS */ {0.5f, PT_PSTE, IPH, NT, ITL, NT, ITH, NT}, + /* ANAR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* VINE */ {IPL, NT, IPH, NT, ITL, NT, 573.0f, PT_FIRE}, + /* INVS */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* EQVE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SPWN2*/ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SPAWN*/ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SHLD1*/ {IPL, NT, 7.0f, PT_NONE, ITL, NT, ITH, NT}, + /* SHLD2*/ {IPL, NT, 15.0f, PT_NONE, ITL, NT, ITH, NT}, + /* SHLD3*/ {IPL, NT, 25.0f, PT_NONE, ITL, NT, ITH, NT}, + /* SHLD4*/ {IPL, NT, 40.0f, PT_NONE, ITL, NT, ITH, NT}, + /* LOlZ */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* WIFI */ {IPL, NT, 15.0f, PT_BRMT, ITL, NT, ITH, NT}, + /* FILT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* ARAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* STKM2*/ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE}, + /* BOMB */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* C-5 */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* SING */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* QRTZ */ {IPL, NT, IPH, NT, ITL, NT, 2573.15f,PT_LAVA}, + /* PQRT */ {IPL, NT, IPH, NT, ITL, NT, 2573.15f,PT_LAVA}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* BOYL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, }; -static int grule[NGOL][10] = +#undef IPL +#undef IPH +#undef ITL +#undef ITH +#undef NT +#undef ST + + +static int grule[NGOL][9] = { // 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing {0,0,0,0,0,0,0,0,0,2},//blank @@ -621,7 +717,7 @@ static int grule[NGOL][10] = {0,1,1,2,2,0,0,0,0,3},//FROG {0,0,2,0,2,0,3,0,0,3},//BRAN }; -static int goltype[NGOL] = +static int goltype[NGOL] = { PT_GOL, PT_HLIF, @@ -672,10 +768,10 @@ static int lolzrule[9][9] = {0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0}, }; -int portal[MAX_TEMP/100][8][80]; -float portaltemp[MAX_TEMP/100][8][80]; -int portalctype[MAX_TEMP/100][8][80]; -int wireless[MAX_TEMP/100][2]; +int portal[(int)(MAX_TEMP-73.15f)/100+2][8][80]; +float portaltemp[(int)(MAX_TEMP-73.15f)/100+2][8][80]; +int portalctype[(int)(MAX_TEMP-73.15f)/100+2][8][80]; +int wireless[(int)(MAX_TEMP-73.15f)/100+2][2]; extern int isplayer; extern float player[27]; @@ -701,9 +797,19 @@ unsigned cb_pmap[YRES][XRES]; unsigned photons[YRES][XRES]; int try_move(int i, int x, int y, int nx, int ny); +int eval_move(int pt, int nx, int ny, unsigned *rr); + +static void create_cherenkov_photon(int pp); +static void create_gain_photon(int pp); void kill_part(int i); +#if defined(WIN32) && !defined(__GNUC__) +extern _inline void part_change_type(int n, int x, int y, int t); +#else +extern inline void part_change_type(int i, int x, int y, int t); +#endif + #if defined(WIN32) && !defined(__GNUC__) extern _inline int create_part(int p, int x, int y, int t); #else diff --git a/src/air.c b/src/air.c index 04141e2dc..33a491376 100644 --- a/src/air.c +++ b/src/air.c @@ -16,126 +16,172 @@ float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL]; void make_kernel(void) { - int i, j; - float s = 0.0f; - for(j=-1; j<2; j++) - for(i=-1; i<2; i++) - { - kernel[(i+1)+3*(j+1)] = expf(-2.0f*(i*i+j*j)); - s += kernel[(i+1)+3*(j+1)]; - } - s = 1.0f / s; - for(j=-1; j<2; j++) - for(i=-1; i<2; i++) - kernel[(i+1)+3*(j+1)] *= s; + int i, j; + float s = 0.0f; + for (j=-1; j<2; j++) + for (i=-1; i<2; i++) + { + kernel[(i+1)+3*(j+1)] = expf(-2.0f*(i*i+j*j)); + s += kernel[(i+1)+3*(j+1)]; + } + s = 1.0f / s; + for (j=-1; j<2; j++) + for (i=-1; i<2; i++) + kernel[(i+1)+3*(j+1)] *= s; } void update_air(void) { - int x, y, i, j; - float dp, dx, dy, f, tx, ty; + int x, y, i, j; + float dp, dx, dy, f, tx, ty; + for (i=0; i0 && y+j0 && x+i=2 && i=2 && j0 && y+j0 && x+i=2 && i=2 && j 256.0f) dp = 256.0f; - if(dp < -256.0f) dp = -256.0f; - if(dx > 256.0f) dx = 256.0f; - if(dx < -256.0f) dx = -256.0f; - if(dy > 256.0f) dy = 256.0f; - if(dy < -256.0f) dy = -256.0f; + if (bmap[y][x] == WL_FAN) + { + dx += fvx[y][x]; + dy += fvy[y][x]; + } - ovx[y][x] = dx; - ovy[y][x] = dy; - opv[y][x] = dp; - } - memcpy(vx, ovx, sizeof(vx)); - memcpy(vy, ovy, sizeof(vy)); - memcpy(pv, opv, sizeof(pv)); + if (dp > 256.0f) dp = 256.0f; + if (dp < -256.0f) dp = -256.0f; + if (dx > 256.0f) dx = 256.0f; + if (dx < -256.0f) dx = -256.0f; + if (dy > 256.0f) dy = 256.0f; + if (dy < -256.0f) dy = -256.0f; + + ovx[y][x] = dx; + ovy[y][x] = dy; + opv[y][x] = dp; + } + memcpy(vx, ovx, sizeof(vx)); + memcpy(vy, ovy, sizeof(vy)); + memcpy(pv, opv, sizeof(pv)); } diff --git a/src/elements/acid.c b/src/elements/acid.c new file mode 100644 index 000000000..18f38910c --- /dev/null +++ b/src/elements/acid.c @@ -0,0 +1,37 @@ +#include + +int update_ACID(UPDATE_FUNC_ARGS) { + int r,rx,ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_ACID) + { + if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD) + { + part_change_type(i,x,y,PT_FIRE); + part_change_type(r>>8,x+rx,y+ry,PT_FIRE); + parts[i].life = 4; + parts[r>>8].life = 4; + } + else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) + { + if (parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) + { + parts[i].life--; + kill_part(r>>8); + } + } + else if (parts[i].life<=50) + { + kill_part(i); + return 1; + } + } + } + return 0; +} diff --git a/src/elements/amtr.c b/src/elements/amtr.c new file mode 100644 index 000000000..748254b65 --- /dev/null +++ b/src/elements/amtr.c @@ -0,0 +1,28 @@ +#include + +int update_AMTR(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO) + { + parts[i].life++; + if (parts[i].life==3) + { + kill_part(i); + return 1; + } + if (2>(rand()/(RAND_MAX/100))) + create_part(r>>8, x+rx, y+ry, PT_PHOT); + else + kill_part(r>>8); + pv[y/CELL][x/CELL] -= 5.0f; + } + } + return 0; +} diff --git a/src/elements/aray.c b/src/elements/aray.c new file mode 100644 index 000000000..55d6b289a --- /dev/null +++ b/src/elements/aray.c @@ -0,0 +1,74 @@ +#include + +int update_ARAY(UPDATE_FUNC_ARGS) { + int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr; + if (parts[i].life==0) { + int colored =0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPRK) { + int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; + int nostop = (parts[r>>8].ctype==PT_INST)?1:0; + for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) { + if (!(x+nxi+nxx= 0 && y+nyi+nyy >= 0)) { + break; + } + r = pmap[y+nyi+nyy][x+nxi+nxx]; + if (!((r>>8)>=NPART)) { + if (!r) { + int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); + if (nr!=-1) { + if (destroy) { + parts[nr].tmp = 2; + parts[nr].life = 2; + } else + parts[nr].ctype = colored; + } + } else if (!destroy) { + if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==0) { + if (nyy!=0 || nxx!=0) { + parts[r>>8].life = 1020; + parts[r>>8].tmp = 1; + if (!parts[r>>8].ctype) + parts[r>>8].ctype = colored; + } + docontinue = 0; + } else if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==1) { + parts[r>>8].life = 1020; + //docontinue = 1; + } + else if ((r&0xFF)==PT_FILT) { + colored = parts[r>>8].ctype; + } else if ((r&0xFF)!=PT_INWR && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { + if (nyy!=0 || nxx!=0) { + create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); + } + if (!(nostop && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { + docontinue = 0; + } else { + docontinue = 1; + } + } + } else if (destroy) { + if ((r&0xFF)==PT_BRAY) { + parts[r>>8].life = 1; + docontinue = 1; + } else if ((r&0xFF)==PT_INWR || (r&0xFF)==PT_ARAY || (r&0xFF)==PT_WIFI || (r&0xFF)==PT_FILT || ((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { + docontinue = 1; + } else { + docontinue = 0; + } + } + } + } + } + //parts[i].life = 4; + } + } + return 0; +} diff --git a/src/elements/bcln.c b/src/elements/bcln.c new file mode 100644 index 000000000..dfcfcd827 --- /dev/null +++ b/src/elements/bcln.c @@ -0,0 +1,33 @@ +#include + +int update_BCLN(UPDATE_FUNC_ARGS) { + if (!parts[i].life) + { + if (pv[y/CELL][x/CELL]>4.0f) + { + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; + parts[i].life = rand()%40+80; + } + } + if (!parts[i].ctype) + { + int rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx + +int update_BCOL(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life<=0) { + create_part(i, x, y, PT_FIRE); + return 1; + } else if (parts[i].life < 100) { + parts[i].life--; + create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) + { + if (parts[i].life>100) { + parts[i].life = 99; + } + } + } + return 0; +} diff --git a/src/elements/bmtl.c b/src/elements/bmtl.c new file mode 100644 index 000000000..5a2703e3d --- /dev/null +++ b/src/elements/bmtl.c @@ -0,0 +1,26 @@ +#include + +int update_BMTL(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt; + if (parts[i].tmp>1) { + parts[i].tmp--; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) + { + part_change_type(r>>8,x+rx,y+ry,PT_BMTL); + parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; + } + } + } else if (parts[i].tmp==1 && 1>rand()%1000) { + parts[i].tmp = 0; + part_change_type(i,x,y,PT_BRMT); + } + return 0; +} diff --git a/src/elements/bomb.c b/src/elements/bomb.c new file mode 100644 index 000000000..814f120bc --- /dev/null +++ b/src/elements/bomb.c @@ -0,0 +1,64 @@ +#include + +int update_BOMB(UPDATE_FUNC_ARGS) { + int r, rx, ry, nb; + if (parts[i].tmp==1) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_BOMB) { + kill_part(i); + return 1; + } + } + } else if (parts[i].tmp==0) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) { + int rad = 8; + int nxi; + int nxj; + pmap[y][x] = 0; + for (nxj=-(rad+1); nxj<=(rad+1); nxj++) + for (nxi=-(rad+1); nxi<=(rad+1); nxi++) + if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) { + nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + if (nb!=-1) { + parts[nb].tmp = 1; + parts[nb].life = 50; + parts[nb].temp = MAX_TEMP; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + } + } + for (nxj=-rad; nxj<=rad; nxj++) + for (nxi=-rad; nxi<=rad; nxi++) + if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) + if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) { + delete_part(x+nxi, y+nxj); + pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; + nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + if (nb!=-1) { + parts[nb].tmp = 2; + parts[nb].life = 2; + parts[nb].temp = MAX_TEMP; + } + } + //create_parts(x, y, 9, 9, PT_BOMB); + //create_parts(x, y, 8, 8, PT_NONE); + kill_part(i); + return 1; + } + } + } + return 0; +} diff --git a/src/elements/boyl.c b/src/elements/boyl.c new file mode 100644 index 000000000..bd54c6f95 --- /dev/null +++ b/src/elements/boyl.c @@ -0,0 +1,43 @@ +#include + +int update_BOYL(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (pv[y/CELL][x/CELL]<(parts[i].temp/100)) + pv[y/CELL][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL]); + if (y+CELL=0 && pv[y/CELL-1][x/CELL]<(parts[i].temp/100)) + pv[y/CELL-1][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL]); + if (x-CELL>=0) + { + pv[y/CELL][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL-1]); + if (y-CELL>=0) + pv[y/CELL-1][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL-1]); + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && + x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR && 1>rand()%30) + { + part_change_type(r>>8,x+rx,y+ry,PT_FOG); + } + else if ((r&0xFF)==PT_O2 && 1>rand()%9) + { + kill_part(r>>8); + part_change_type(i,x,y,PT_WATR); + pv[y/CELL][x/CELL] += 4.0; + } + } + return 0; +} diff --git a/src/elements/btry.c b/src/elements/btry.c new file mode 100644 index 000000000..a0cb65150 --- /dev/null +++ b/src/elements/btry.c @@ -0,0 +1,24 @@ +#include + +int update_BTRY(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + if (parts_avg(i,r>>8,PT_INSL) != PT_INSL) + { + if ((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4) + { + parts[r>>8].life = 4; + parts[r>>8].ctype = rt; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + } + } + } + return 0; +} diff --git a/src/elements/c5.c b/src/elements/c5.c new file mode 100644 index 000000000..ff51be323 --- /dev/null +++ b/src/elements/c5.c @@ -0,0 +1,24 @@ +#include + +int update_C5(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100)||(r&0xFF)==PT_HFLM) + { + if (1>rand()%6) + { + part_change_type(i,x,y,PT_HFLM); + parts[r>>8].temp = parts[i].temp = 0; + parts[i].life = rand()%150+50; + pv[y/CELL][x/CELL] += 1.5; + } + } + } + return 0; +} diff --git a/src/elements/clne.c b/src/elements/clne.c new file mode 100644 index 000000000..dcb205bfe --- /dev/null +++ b/src/elements/clne.c @@ -0,0 +1,23 @@ +#include + +int update_CLNE(UPDATE_FUNC_ARGS) { + if (!parts[i].ctype) + { + int rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx + +int update_COAL(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life<=0) { + create_part(i, x, y, PT_FIRE); + return 1; + } else if (parts[i].life < 100) { + parts[i].life--; + create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + if ((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if (parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if (parts[i].tmp<=0) { + create_part(i, x, y, PT_BCOL); + return 1; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) + { + if (parts[i].life>100) { + parts[i].life = 99; + } + } + } + return 0; +} diff --git a/src/elements/deut.c b/src/elements/deut.c new file mode 100644 index 000000000..640d84a43 --- /dev/null +++ b/src/elements/deut.c @@ -0,0 +1,73 @@ +#include + +int update_DEUT(UPDATE_FUNC_ARGS) { + int r, rx, ry, trade, np; + int maxlife = ((10000/(parts[i].temp + 1))-1); + if ((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) + maxlife ++; + if (parts[i].life < maxlife) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r || (parts[i].life >=maxlife)) + continue; + if ((r&0xFF)==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1) + { + if ((parts[i].life + parts[r>>8].life + 1) <= maxlife) + { + parts[i].life += parts[r>>8].life + 1; + kill_part(r>>8); + } + } + } + } + else + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || (parts[i].life<=maxlife)) + continue; + if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL|| + bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS)) + continue; + if ((!r)&&parts[i].life>=1)//if nothing then create deut + { + np = create_part(-1,x+rx,y+ry,PT_DEUT); + if (np<0) continue; + parts[i].life--; + parts[np].temp = parts[i].temp; + parts[np].life = 0; + } + } + for ( trade = 0; trade<4; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + int temp = parts[i].life - parts[r>>8].life; + if (temp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + } + else if (temp>0) + { + parts[r>>8].life += temp/2; + parts[i].life -= temp/2; + } + } + } + } + return 0; +} diff --git a/src/elements/dstw.c b/src/elements/dstw.c new file mode 100644 index 000000000..ae6db18b3 --- /dev/null +++ b/src/elements/dstw.c @@ -0,0 +1,32 @@ +#include + +int update_DSTW(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SALT && 1>(rand()%250)) + { + part_change_type(i,x,y,PT_SLTW); + part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_WATR); + } + if ((r&0xFF)==PT_SLTW && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_SLTW); + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + } + return 0; +} diff --git a/src/elements/firw.c b/src/elements/firw.c new file mode 100644 index 000000000..e8e1c4a13 --- /dev/null +++ b/src/elements/firw.c @@ -0,0 +1,66 @@ +#include + +int update_FIRW(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt; + if (parts[i].tmp==0) { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) + { + parts[i].tmp = 1; + parts[i].life = rand()%50+60; + } + } + } + else if (parts[i].tmp==1) { + if (parts[i].life==0) { + parts[i].tmp=2; + } else { + float newVel = parts[i].life/25; + parts[i].flags = parts[i].flags&0xFFFFFFFE; + /* TODO: + if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) { + parts[i].vy = -newVel; + ly-=newVel; + iy-=newVel; + }*/ + parts[i].vy = -newVel; + } + } + else if (parts[i].tmp==2) { + int col = rand()%200+4; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_FIRW) { + parts[r>>8].vx = (rand()%3-1)*tmul; + parts[r>>8].vy = (rand()%3-1)*tmul; + parts[r>>8].tmp = col; + parts[r>>8].life = rand()%100+100; + parts[r>>8].temp = 6000.0f; + } + } + pv[y/CELL][x/CELL] += 20; + kill_part(i); + return 1; + } else if (parts[i].tmp>=3) { + if (parts[i].life<=0) { + kill_part(i); + return 1; + } + } + return 0; +} diff --git a/src/elements/fog.c b/src/elements/fog.c new file mode 100644 index 000000000..17d4c736c --- /dev/null +++ b/src/elements/fog.c @@ -0,0 +1,22 @@ +#include + +int update_FOG(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? + { + part_change_type(i,x,y,PT_RIME); + } + if ((r&0xFF)==PT_SPRK) + { + parts[i].life += rand()%20; + } + } + return 0; +} diff --git a/src/elements/frzw.c b/src/elements/frzw.c new file mode 100644 index 000000000..ac7170d98 --- /dev/null +++ b/src/elements/frzw.c @@ -0,0 +1,30 @@ +#include + +int update_FRZW(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR&&5>rand()%70) + { + part_change_type(r>>8,x+rx,y+ry,PT_FRZW); + } + } + if (parts[i].life==0&&13>rand()%2500) + { + part_change_type(i,x,y,PT_ICEI); + parts[i].ctype=PT_FRZW; + parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); + } + else if ((100-(parts[i].life))>rand()%50000) + { + part_change_type(i,x,y,PT_ICEI); + parts[i].ctype=PT_FRZW; + parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); + } + return 0; +} diff --git a/src/elements/frzz.c b/src/elements/frzz.c new file mode 100644 index 000000000..087239766 --- /dev/null +++ b/src/elements/frzz.c @@ -0,0 +1,25 @@ +#include + +int update_FRZZ(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR&&5>rand()%100) + { + part_change_type(r>>8,x+rx,y+ry,PT_FRZW); + parts[r>>8].life = 100; + parts[i].type = PT_NONE; + } + + } + if (parts[i].type==PT_NONE) { + kill_part(i); + return 1; + } + return 0; +} diff --git a/src/elements/fsep.c b/src/elements/fsep.c new file mode 100644 index 000000000..0149b155a --- /dev/null +++ b/src/elements/fsep.c @@ -0,0 +1,35 @@ +#include + +int update_FSEP(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life<=0) { + r = create_part(i, x, y, PT_PLSM); + if (r!=-1) + parts[r].life = 50; + return 1; + } else if (parts[i].life < 40) { + parts[i].life--; + if ((rand()%10)==0) { + r = create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); + if (r!=-1) + parts[r].life = 50; + } + } + else { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15)) + { + if (parts[i].life>40) { + parts[i].life = 39; + } + } + } + } + return 0; +} diff --git a/src/elements/fuse.c b/src/elements/fuse.c new file mode 100644 index 000000000..1b6e8bf2c --- /dev/null +++ b/src/elements/fuse.c @@ -0,0 +1,41 @@ +#include + +int update_FUSE(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life<=0) { + r = create_part(i, x, y, PT_PLSM); + if (r!=-1) + parts[r].life = 50; + return 1; + } else if (parts[i].life < 40) { + parts[i].life--; + if ((rand()%100)==0) { + r = create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); + if (r!=-1) + parts[r].life = 50; + } + } + if ((pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if (parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if (parts[i].tmp<=0) { + create_part(i, x, y, PT_FSEP); + return 1; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))) + { + if (parts[i].life>40) { + parts[i].life = 39; + } + } + } + return 0; +} diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c new file mode 100644 index 000000000..f74990de0 --- /dev/null +++ b/src/elements/fwrk.c @@ -0,0 +1,51 @@ +#include + +int update_FWRK(UPDATE_FUNC_ARGS) { + int r, rx, ry, np; + if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) + { + np = create_part(-1, x , y-1 , PT_FWRK); + if (np!=-1) + { + parts[r>>8].vy = rand()%8-22; + parts[r>>8].vx = rand()%20-rand()%20; + parts[r>>8].life=rand()%15+25; + kill_part(i); + return 1; + } + } + if (parts[i].life>=45) + parts[i].life=0; + if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0) + { + int q = (rand()%255+1); + int w = (rand()%255+1); + int e = (rand()%255+1); + for (rx=-1; rx<2; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx=rand()%8) + { + if (!pmap[y+ry][x+rx]) + { + np = create_part(-1, x+rx, y+ry , PT_DUST); + pv[y/CELL][x/CELL] += 2.00f*CFDS; + if (np!=-1) + { + parts[r>>8].vy = -(rand()%10-1); + parts[r>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; + parts[r>>8].life= rand()%37+18; + parts[r>>8].tmp=q; + parts[r>>8].flags=w; + parts[r>>8].ctype=e; + parts[r>>8].temp= rand()%20+6000; + } + } + } + } + kill_part(i); + return 1; + } + return 0; +} diff --git a/src/elements/glas.c b/src/elements/glas.c new file mode 100644 index 000000000..ed6df85a3 --- /dev/null +++ b/src/elements/glas.c @@ -0,0 +1,11 @@ +#include + +int update_GLAS(UPDATE_FUNC_ARGS) { + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) + { + part_change_type(i,x,y,PT_BGLA); + } + return 0; +} diff --git a/src/elements/glow.c b/src/elements/glow.c new file mode 100644 index 000000000..aa4d2b0cd --- /dev/null +++ b/src/elements/glow.c @@ -0,0 +1,24 @@ +#include + +int update_GLOW(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR&&5>(rand()%2000)) + { + parts[i].type = PT_NONE; + part_change_type(r>>8,x+rx,y+ry,PT_DEUT); + parts[r>>8].life = 10; + } + } + if (parts[i].type==PT_NONE) { + kill_part(i); + return 1; + } + return 0; +} diff --git a/src/elements/goo.c b/src/elements/goo.c new file mode 100644 index 000000000..7ae529b3f --- /dev/null +++ b/src/elements/goo.c @@ -0,0 +1,15 @@ +#include + +int update_GOO(UPDATE_FUNC_ARGS) { + if (!parts[i].life) + { + if (pv[y/CELL][x/CELL]>1.0f) + { + float advection = 0.1f; + parts[i].vx += advection*vx[y/CELL][x/CELL]; + parts[i].vy += advection*vy[y/CELL][x/CELL]; + parts[i].life = rand()%80+300; + } + } + return 0; +} diff --git a/src/elements/hswc.c b/src/elements/hswc.c new file mode 100644 index 000000000..bfb723835 --- /dev/null +++ b/src/elements/hswc.c @@ -0,0 +1,24 @@ +#include + +int update_HSWC(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life==10) + { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_HSWC) + { + if (parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} diff --git a/src/elements/ice.c b/src/elements/ice.c new file mode 100644 index 000000000..e361fa63e --- /dev/null +++ b/src/elements/ice.c @@ -0,0 +1,23 @@ +#include + +int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well + int r, rx, ry; + if (parts[i].ctype==PT_FRZW) + { + parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000)) + { + part_change_type(i,x,y,PT_SLTW); + part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + } + return 0; +} diff --git a/src/elements/iron.c b/src/elements/iron.c new file mode 100644 index 000000000..dc3963478 --- /dev/null +++ b/src/elements/iron.c @@ -0,0 +1,25 @@ +#include + +int update_IRON(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) || + ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || + ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || + ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || + ((r&0xFF) == PT_LO2))&& + (!(parts[i].life)) + ) + { + part_change_type(i,x,y,PT_BMTL); + parts[i].tmp=(rand()/(RAND_MAX/10))+20; + } + } + return 0; +} diff --git a/src/elements/isz.c b/src/elements/isz.c new file mode 100644 index 000000000..5bb465ae2 --- /dev/null +++ b/src/elements/isz.c @@ -0,0 +1,14 @@ +#include + +int update_ISZ(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ + float rr, rrr; + if (1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) + { + create_part(i, x, y, PT_PHOT); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[i].vx = rr*cosf(rrr); + parts[i].vy = rr*sinf(rrr); + } + return 0; +} diff --git a/src/elements/lcry.c b/src/elements/lcry.c new file mode 100644 index 000000000..5f888a936 --- /dev/null +++ b/src/elements/lcry.c @@ -0,0 +1,24 @@ +#include + +int update_LCRY(UPDATE_FUNC_ARGS) { + if (parts[i].life==10) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_LCRY) + { + if (parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} diff --git a/src/elements/legacy.c b/src/elements/legacy.c new file mode 100644 index 000000000..c8fce736e --- /dev/null +++ b/src/elements/legacy.c @@ -0,0 +1,120 @@ +#include + +// Interactions which only occur when legacy_enable is on +int update_legacy_all(UPDATE_FUNC_ARGS) { + if (!legacy_enable) return 0; + int r, rx, ry, rt; + int t = parts[i].type; + if (t==PT_WTRV) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && + x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000)) + { + part_change_type(i,x,y,PT_WATR); + part_change_type(r>>8,x+rx,y+ry,PT_WATR); + } + if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) + { + part_change_type(i,x,y,PT_WATR); + if (1>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_WATR); + } + } + } + else if (t==PT_WATR) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && + x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + { + part_change_type(i,x,y,PT_WTRV); + } + } + } + else if (t==PT_SLTW) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && + x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + { + part_change_type(i,x,y,PT_SALT); + part_change_type(r>>8,x+rx,y+ry,PT_WTRV); + } + } + } + else if (t==PT_DSTW) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && + x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + { + part_change_type(i,x,y,PT_WTRV); + } + } + } + else if (t==PT_ICEI) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) + { + part_change_type(i,x,y,PT_ICEI); + part_change_type(r>>8,x+rx,y+ry,PT_ICEI); + } + } + } + else if (t==PT_SNOW) { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) + { + part_change_type(i,x,y,PT_ICEI); + part_change_type(r>>8,x+rx,y+ry,PT_ICEI); + } + if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) + part_change_type(i,x,y,PT_WATR); + } + } + if (t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f) + part_change_type(i,x,y,PT_DSTW); + if (t==PT_OIL && pv[y/CELL][x/CELL]<-6.0f) + part_change_type(i,x,y,PT_GAS); + if (t==PT_GAS && pv[y/CELL][x/CELL]>6.0f) + part_change_type(i,x,y,PT_OIL); + if (t==PT_DESL && pv[y/CELL][x/CELL]>12.0f) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = rand()%50+120; + } + return 0; +} diff --git a/src/elements/misc.c b/src/elements/misc.c new file mode 100644 index 000000000..67309c652 --- /dev/null +++ b/src/elements/misc.c @@ -0,0 +1,12 @@ +#include + +int update_MISC(UPDATE_FUNC_ARGS) { + int t = parts[i].type; + if (t==PT_LOVE) + ISLOVE=1; + else if (t==PT_LOLZ) + ISLOLZ=1; + else if (t==PT_GRAV) + ISGRAV=1; + return 0; +} diff --git a/src/elements/mort.c b/src/elements/mort.c new file mode 100644 index 000000000..609eafded --- /dev/null +++ b/src/elements/mort.c @@ -0,0 +1,6 @@ +#include + +int update_MORT(UPDATE_FUNC_ARGS) { + create_part(-1, x, y-1, PT_SMKE); + return 0; +} diff --git a/src/elements/neut.c b/src/elements/neut.c new file mode 100644 index 000000000..42ee9d343 --- /dev/null +++ b/src/elements/neut.c @@ -0,0 +1,88 @@ +#include + +int update_NEUT(UPDATE_FUNC_ARGS) { + int r, rx, ry; + int pressureFactor = 3 + (int)pv[y/CELL][x/CELL]; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) + { + parts[i].vx *= 0.995; + parts[i].vy *= 0.995; + } + if ((r&0xFF)==PT_PLUT && pressureFactor>(rand()%1000)) + { + if (33>rand()%100) + { + create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN); + parts[r>>8].temp = MAX_TEMP; + if (parts[r>>8].type==PT_LAVA) { + parts[r>>8].tmp = 100; + parts[r>>8].ctype = PT_PLUT; + } + } + else + { + create_part(r>>8, x+rx, y+ry, PT_NEUT); + parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; + parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; + } + pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + } + else if ((r&0xFF)==PT_DEUT && (pressureFactor+1)>(rand()%1000)) + { +#ifdef SDEUT + create_n_parts(parts[r>>8].life, x+rx, y+ry, parts[i].vx, parts[i].vy, PT_NEUT); +#else + create_part(r>>8, x+rx, y+ry, PT_NEUT); + parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; + parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; + if (parts[r>>8].life>0) + { + parts[r>>8].life --; + parts[r>>8].temp += (parts[r>>8].life*17); + pv[y/CELL][x/CELL] += 6.0f * CFDS; + } + else + kill_part(r>>8); +#endif + } + else if ((r&0xFF)==PT_GUNP && 15>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_DUST); + else if ((r&0xFF)==PT_DYST && 15>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_YEST); + else if ((r&0xFF)==PT_YEST) + part_change_type(r>>8,x+rx,y+ry,PT_DYST); + else if ((r&0xFF)==PT_WATR && 15>(rand()%100)) + part_change_type(r>>8,x+rx,y+ry,PT_DSTW); + else if ((r&0xFF)==PT_PLEX && 15>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_GOO); + else if ((r&0xFF)==PT_NITR && 15>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_DESL); + else if ((r&0xFF)==PT_PLNT && 5>(rand()%100)) + create_part(r>>8, x+rx, y+ry, PT_WOOD); + else if ((r&0xFF)==PT_DESL && 15>(rand()%1000)) + part_change_type(r>>8,x+rx,y+ry,PT_GAS); + else if ((r&0xFF)==PT_COAL && 5>(rand()%100)) + create_part(r>>8, x+rx, y+ry, PT_WOOD); + else if ((r&0xFF)==PT_DUST && 5>(rand()%100)) + create_part(r>>8, x+rx, y+ry, PT_FWRK); + else if ((r&0xFF)==PT_FWRK && 5>(rand()%100)) + create_part(r>>8, x+rx, y+ry, PT_DUST); + else if ((r&0xFF)==PT_ACID && 5>(rand()%100)) + create_part(r>>8, x+rx, y+ry, PT_ISOZ); + /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && + (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| + ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| + ptypes[parts[r>>8].type-1].menusection==SC_GAS|| + ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) + parts[r>>8].type--;*/ + } + return 0; +} diff --git a/src/elements/none.c b/src/elements/none.c new file mode 100644 index 000000000..7e38fd07c --- /dev/null +++ b/src/elements/none.c @@ -0,0 +1,6 @@ +#include + +int update_(UPDATE_FUNC_ARGS) { + + return 0; +} diff --git a/src/elements/nptct.c b/src/elements/nptct.c new file mode 100644 index 000000000..116294f07 --- /dev/null +++ b/src/elements/nptct.c @@ -0,0 +1,7 @@ +#include + +int update_NPTCT(UPDATE_FUNC_ARGS) { + if (parts[i].temp>295.0f) + parts[i].temp -= 2.5f; + return 0; +} diff --git a/src/elements/pcln.c b/src/elements/pcln.c new file mode 100644 index 000000000..45edd1e8c --- /dev/null +++ b/src/elements/pcln.c @@ -0,0 +1,65 @@ +#include + +int update_PCLN(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPRK) + { + if (parts[r>>8].ctype==PT_PSCN) + parts[i].life = 10; + else if (parts[r>>8].ctype==PT_NSCN) + parts[i].life = 9; + } + if ((r&0xFF)==PT_PCLN) + { + if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[i].life==0&&parts[r>>8].life==10) + parts[i].life = 10; + } + } + if (!parts[i].ctype) + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx + +int update_PHOT(UPDATE_FUNC_ARGS) { + if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + int r, rt, rx, ry; + float rr, rrr; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + create_part(r>>8, x+rx, y+ry, PT_PHOT); + rrr = (rand()%360)*3.14159f/180.0f; + rr = (rand()%128+128)/127.0f; + parts[r>>8].vx = rr*cosf(rrr); + parts[r>>8].vy = rr*sinf(rrr); + pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + if ((r&0xFF)==PT_ISZS && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + create_part(r>>8, x+rx, y+ry, PT_PHOT); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[r>>8].vx = rr*cosf(rrr); + parts[r>>8].vy = rr*sinf(rrr); + pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + } + r = pmap[y][x]; + rt = r&0xFF; + if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN) { + if (!parts[r>>8].ctype) + parts[r>>8].ctype = PT_PHOT; + } + + return 0; +} diff --git a/src/elements/pipe.c b/src/elements/pipe.c new file mode 100644 index 000000000..4bd1799fe --- /dev/null +++ b/src/elements/pipe.c @@ -0,0 +1,122 @@ +#include + +int update_PIPE(UPDATE_FUNC_ARGS) { + int r, rx, ry, np, trade, q, ctype; + if (!parts[i].ctype && parts[i].life<=10) + { + if (parts[i].temp<272.15) + { + if (parts[i].temp>173.25&&parts[i].temp<273.15) + { + parts[i].ctype = 2; + parts[i].life = 0; + } + if (parts[i].temp>73.25&&parts[i].temp<=173.15) + { + parts[i].ctype = 3; + parts[i].life = 0; + } + if (parts[i].temp>=0&&parts[i].temp<=73.15) + { + parts[i].ctype = 4; + parts[i].life = 0; + } + } + else + { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART ) + continue; + if (!r) + create_part(-1,x+rx,y+ry,PT_BRCK); + } + if (parts[i].life==1) + parts[i].ctype = 1; + } + } + if (parts[i].ctype==1) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (!r&&!parts[i].life) + parts[i].life=50; + } + if (parts[i].life==2) + { + parts[i].ctype = 2; + parts[i].life = 6; + } + } + if (parts[i].ctype>1) + for ( q = 0; q<3; q++) + for ( ctype = 2; ctype<5; ctype++) + { + if (parts[i].ctype==ctype) + { + if (parts[i].life==3) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_PIPE&&parts[r>>8].ctype==1) + { + parts[r>>8].ctype = (((ctype)%3)+2);//reverse + parts[r>>8].life = 6; + } + } + } + else + { + rx = rand()%3-1; + ry = rand()%3-1; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + else if (!r&&parts[i].tmp!=0) + { + np = create_part(-1,x+rx,y+ry,parts[i].tmp); + if (np!=-1) + { + parts[np].temp = parts[i].temp;//pipe saves temp and life now + parts[np].life = parts[i].flags; + } + parts[i].tmp = 0; + continue; + } + else if (!r) + continue; + else if (parts[i].tmp == 0 && (ptypes[r&0xFF].falldown!= 0 || ptypes[r&0xFF].state == ST_GAS)) + { + parts[i].tmp = parts[r>>8].type; + parts[i].temp = parts[r>>8].temp; + parts[i].flags = parts[r>>8].life; + kill_part(r>>8); + } + else if ((r&0xFF)==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0) + { + parts[r>>8].tmp = parts[i].tmp; + parts[r>>8].temp = parts[i].temp; + parts[r>>8].flags = parts[i].flags; + parts[i].tmp = 0; + } + } + } + } + } + return 0; +} diff --git a/src/elements/plnt.c b/src/elements/plnt.c new file mode 100644 index 000000000..79c9d8a19 --- /dev/null +++ b/src/elements/plnt.c @@ -0,0 +1,57 @@ +#include + +int update_PLNT(UPDATE_FUNC_ARGS) { + int r, rx, ry, np; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_WATR && 1>(rand()%250)) + { + np = create_part(r>>8,x+rx,y+ry,PT_PLNT); + if (np<0) continue; + parts[np].life = 0; + } + else if ((r&0xFF)==PT_LAVA && 1>(rand()%250)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + else if ((r&0xFF)==PT_SMKE && (1>rand()%250)) + { + kill_part(r>>8); + parts[i].life = rand()%60 + 60; + } + else if ((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(rx+ry)<=2 && VINE_MODE) + { + int nnx = rand()%3 -1; + int nny = rand()%3 -1; + if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx>8)>=NPART||pmap[y+ry+nny][x+rx+nnx]) + continue; + np = create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE); + if (np<0) continue; + parts[np].temp = parts[i].temp; + } + } + } + if (parts[i].life==2) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (!r) + create_part(-1,x+rx,y+ry,PT_O2); + } + parts[i].life = 0; + } + return 0; +} diff --git a/src/elements/plut.c b/src/elements/plut.c new file mode 100644 index 000000000..738e29d58 --- /dev/null +++ b/src/elements/plut.c @@ -0,0 +1,9 @@ +#include + +int update_PLUT(UPDATE_FUNC_ARGS) { + if (1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000)) + { + create_part(i, x, y, PT_NEUT); + } + return 0; +} diff --git a/src/elements/prti.c b/src/elements/prti.c new file mode 100644 index 000000000..4310f86a0 --- /dev/null +++ b/src/elements/prti.c @@ -0,0 +1,30 @@ +#include + +int update_PRTI(UPDATE_FUNC_ARGS) { + int r, nnx, rx, ry; + int count =0; + parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>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))) + 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; + portalctype[parts[i].tmp][count-1][nnx] = parts[r>>8].ctype; + if ((r&0xFF)==PT_SPRK) + part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype); + else + kill_part(r>>8); + break; + } + } + return 0; +} diff --git a/src/elements/prto.c b/src/elements/prto.c new file mode 100644 index 000000000..4889e89e2 --- /dev/null +++ b/src/elements/prto.c @@ -0,0 +1,53 @@ +#include + +int update_PRTO(UPDATE_FUNC_ARGS) { + int r, nnx, rx, ry, np; + int count = 0; + parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || r) + continue; + if (!r) + { + for ( nnx =0 ; nnx<80; nnx++) + { + int randomness = count + rand()%3-1; + if (randomness<1) + randomness=1; + if (randomness>8) + randomness=8; + if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better + { + create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]); + create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]); + portal[parts[i].tmp][randomness-1][nnx] = 0; + portaltemp[parts[i].tmp][randomness-1][nnx] = 0; + break; + } + else if (portal[parts[i].tmp][randomness-1][nnx]) + { + np = create_part(-1,x+rx,y+ry,portal[parts[i].tmp][randomness-1][nnx]); + if (np<0) continue; + parts[np].temp = portaltemp[parts[i].tmp][randomness-1][nnx]; + parts[np].ctype = portalctype[parts[i].tmp][randomness-1][nnx]; + portal[parts[i].tmp][randomness-1][nnx] = 0; + portaltemp[parts[i].tmp][randomness-1][nnx] = 0; + portalctype[parts[i].tmp][randomness-1][nnx] = 0; + break; + } + } + } + } + return 0; +} diff --git a/src/elements/pump.c b/src/elements/pump.c new file mode 100644 index 000000000..c1c120163 --- /dev/null +++ b/src/elements/pump.c @@ -0,0 +1,39 @@ +#include + +int update_PUMP(UPDATE_FUNC_ARGS) { + int r, rx, ry; + if (parts[i].life==10) + { + if (parts[i].temp>=256.0+273.15) + parts[i].temp=256.0+273.15; + if (parts[i].temp<= -256.0+273.15) + parts[i].temp = -256.0+273.15; + + if (pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) + pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]); + if (y+CELL=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_PUMP) + { + if (parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} diff --git a/src/elements/pyro.c b/src/elements/pyro.c new file mode 100644 index 000000000..ba821681f --- /dev/null +++ b/src/elements/pyro.c @@ -0,0 +1,111 @@ +#include + +int update_PYRO(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt, t = parts[i].type; + if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1) + { + t = PT_NBLE; + part_change_type(i,x,y,t); + parts[i].life = 0; + } + if (t==PT_FIRE && parts[i].life <=1 && parts[i].temp<625) + { + t = PT_SMKE; + part_change_type(i,x,y,t); + parts[i].life = rand()%20+250; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) + continue; + rt = parts[r>>8].type; + if ((surround_space || ptypes[rt].explosive) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH)) && + !(t==PT_PHOT && rt==PT_INSL) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR && rt!=PT_QRTZ)) + && !(rt==PT_SPNG && parts[r>>8].life>0) && + ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) + { + part_change_type(r>>8,x+rx,y+ry,PT_FIRE); + parts[r>>8].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2), MIN_TEMP, MAX_TEMP); + parts[r>>8].life = rand()%80+180; + if (ptypes[rt].explosive) + pv[y/CELL][x/CELL] += 0.25f * CFDS; + continue; + } + } + if (legacy_enable) update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + return 0; +} + +int update_legacy_PYRO(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt, lpv, t = parts[i].type; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) + continue; + rt = r&0xFF; + lpv = (int)pv[(y+ry)/CELL][(x+rx)/CELL]; + if (lpv < 1) lpv = 1; + if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && + ptypes[rt].meltable*lpv>(rand()%1000)) + { + if (t!=PT_LAVA || parts[i].life>0) + { + parts[r>>8].ctype = (rt==PT_BRMT)?PT_BMTL:parts[r>>8].type; + parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype; + part_change_type(r>>8,x+rx,y+ry,PT_LAVA); + parts[r>>8].life = rand()%120+240; + } + else + { + parts[i].life = 0; + t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; + parts[i].ctype = PT_NONE;//rt; + part_change_type(i,x,y,t); + return 1; + } + } + if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW)) + { + parts[r>>8].type = PT_WATR; + if (t==PT_FIRE) + { + kill_part(i); + return 1; + } + if (t==PT_LAVA) + { + parts[i].life = 0; + t = parts[i].type = PT_STNE; + part_change_type(i,x,y,t); + } + } + if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)) + { + kill_part(r>>8); + if (t==PT_FIRE) + { + kill_part(i); + return 1; + } + if (t==PT_LAVA) + { + parts[i].life = 0; + t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; + parts[i].ctype = PT_NONE; + part_change_type(i,x,y,t); + } + } + } + return 0; +} diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c new file mode 100644 index 000000000..2fb97b071 --- /dev/null +++ b/src/elements/qrtz.c @@ -0,0 +1,11 @@ +#include + +int update_QRTZ(UPDATE_FUNC_ARGS) { + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) + { + part_change_type(i,x,y,PT_PQRT); + } + return 0; +} diff --git a/src/elements/rime.c b/src/elements/rime.c new file mode 100644 index 000000000..845d8a293 --- /dev/null +++ b/src/elements/rime.c @@ -0,0 +1,26 @@ +#include + +int update_RIME(UPDATE_FUNC_ARGS) { + int r, rx, ry; + parts[i].vx = 0; + parts[i].vy = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPRK) + { + part_change_type(i,x,y,PT_FOG); + parts[i].life = rand()%50 + 60; + } + else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0) + { + part_change_type(i,x,y,PT_FOG); + parts[i].life = parts[r>>8].life; + } + } + return 0; +} diff --git a/src/elements/shld.c b/src/elements/shld.c new file mode 100644 index 000000000..434a9dbfd --- /dev/null +++ b/src/elements/shld.c @@ -0,0 +1,168 @@ +#include + +int update_SHLD1(UPDATE_FUNC_ARGS) { + int r, nnx, nny, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + { + if (55>rand()%200&&parts[i].life==0) + { + part_change_type(i,x,y,PT_SHLD2); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + } + else if ((r&0xFF)==PT_SHLD3&&4>rand()%10) + { + part_change_type(i,x,y,PT_SHLD2); + parts[i].life = 7; + } + } + return 0; +} + +int update_SHLD2(UPDATE_FUNC_ARGS) { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (!r && parts[i].life>0) + create_part(-1,x+rx,y+ry,PT_SHLD1); + if (!r) + continue; + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + { + if (25>rand()%200&&parts[i].life==0) + { + part_change_type(i,x,y,PT_SHLD3); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + else if ((r&0xFF)==PT_SHLD4&&4>rand()%10) + { + part_change_type(i,x,y,PT_SHLD3); + parts[i].life = 7; + } + } + return 0; +} + +int update_SHLD3(UPDATE_FUNC_ARGS) { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (!r) + { + if (1>rand()%2500) + { + np = create_part(-1,x+rx,y+ry,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + part_change_type(i,x,y,PT_SHLD2); + } + else + continue; + + } + if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) + { + part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); + parts[r>>8].life=7; + } + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + { + if (18>rand()%3000&&parts[i].life==0) + { + part_change_type(i,x,y,PT_SHLD4); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + } + return 0; +} + +int update_SHLD4(UPDATE_FUNC_ARGS) { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (!r) + { + if (1>rand()%5500) + { + np = create_part(-1,x+rx,y+ry,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + part_change_type(i,x,y,PT_SHLD2); + } + else + continue; + + } + if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) + { + part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); + parts[r>>8].life = 7; + } + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + return 0; +} diff --git a/src/elements/sing.c b/src/elements/sing.c new file mode 100644 index 000000000..7127f7764 --- /dev/null +++ b/src/elements/sing.c @@ -0,0 +1,59 @@ +#include + +int update_SING(UPDATE_FUNC_ARGS) { + int r, rx, ry; + int singularity = -parts[i].life; + + if (pv[y/CELL][x/CELL]0 && pv[y/CELL-1][x/CELL]0) + { + pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]); + if (y+CELL>0) + pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]); + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1) + { + if ((r&0xFF)==PT_SING && parts[r>>8].life >10) + { + if (parts[i].life+parts[r>>8].life > 255) + continue; + parts[i].life += parts[r>>8].life; + } + else + { + if (parts[i].life+3 > 255) + { + if (parts[r>>8].type!=PT_SING && 1>rand()%100) + { + int np; + np = create_part(r>>8,x+rx,y+ry,PT_SING); + parts[np].life = rand()%50+60; + } + continue; + } + parts[i].life += 3; + } + parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); + kill_part(r>>8); + } + } + return 0; +} diff --git a/src/elements/sltw.c b/src/elements/sltw.c new file mode 100644 index 000000000..7f23f1c19 --- /dev/null +++ b/src/elements/sltw.c @@ -0,0 +1,23 @@ +#include + +int update_SLTW(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SALT && 1>(rand()%10000)) + kill_part(r>>8); + if ((r&0xFF)==PT_PLNT&&5>(rand()%1000)) + kill_part(r>>8); + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + } + return 0; +} diff --git a/src/elements/spng.c b/src/elements/spng.c new file mode 100644 index 000000000..d8eb1f1be --- /dev/null +++ b/src/elements/spng.c @@ -0,0 +1,97 @@ +#include + +int update_SPNG(UPDATE_FUNC_ARGS) { + int r, trade, rx, ry, tmp; + if (pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3&&parts[i].temp<=374.0f) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r || parts[i].temp>374.0f) + continue; + if ((r&0xFF)==PT_WATR&&33>=rand()/(RAND_MAX/100)+1) + { + parts[i].life++; + kill_part(r>>8); + } + } + } + else + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL|| + bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS)) + continue; + if ((!r)&&parts[i].life>=1)//if nothing then create water + { + create_part(-1,x+rx,y+ry,PT_WATR); + parts[i].life--; + } + } + for ( trade = 0; trade<9; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + tmp = parts[i].life - parts[r>>8].life; + if (tmp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + trade = 9; + } + else if (tmp>0) + { + parts[r>>8].life += tmp/2; + parts[i].life -= tmp/2; + trade = 9; + } + } + } + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_FIRE&&parts[i].life>0) + { + if (parts[i].life<=2) + parts[i].life --; + parts[i].life -= parts[i].life/3; + } + } + if (parts[i].temp>=374) + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID)) + continue; + if ((!r)&&parts[i].life>=1)//if nothing then create steam + { + create_part(-1,x+rx,y+ry,PT_WTRV); + parts[i].life--; + parts[i].temp -= 40.0f; + } + } + return 0; +} diff --git a/src/elements/sprk.c b/src/elements/sprk.c new file mode 100644 index 000000000..891be3a68 --- /dev/null +++ b/src/elements/sprk.c @@ -0,0 +1,168 @@ +#include + +int update_SPRK(UPDATE_FUNC_ARGS) { + update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + int r, rx, ry, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype; + if (parts[i].life<=0) + { + if (ct==PT_WATR||ct==PT_SLTW||ct==PT_PSCN||ct==PT_NSCN||ct==PT_ETRD) + parts[i].temp = R_TEMP + 273.15f; + if (!ct) + ct = PT_METL; + part_change_type(i,x,y,ct); + parts[i].life = 4; + if (ct == PT_WATR) + parts[i].life = 64; + if (ct == PT_SLTW) + parts[i].life = 54; + if (ct == PT_SWCH) + parts[i].life = 14; + return 0; + } + if (ct==PT_SPRK) + { + kill_part(i); + return 1; + } + else if (ct==PT_ETRD&&parts[i].life==1) + { + nearp = nearest_part(i, PT_ETRD); + if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) + { + create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM); + part_change_type(i,x,y,ct); + ct = parts[i].ctype = PT_NONE; + parts[i].life = 20; + part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); + parts[nearp].life = 9; + parts[nearp].ctype = PT_ETRD; + } + } + else if (ct==PT_NBLE&&parts[i].life<=1) + { + parts[i].life = rand()%150+50; + part_change_type(i,x,y,PT_PLSM); + parts[i].ctype = PT_NBLE; + parts[i].temp = 3500; + pv[y/CELL][x/CELL] += 1; + } + else if (ct==PT_IRON) { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) || + ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) || + ((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000)))) + { + part_change_type(r>>8,x+rx,y+ry,PT_O2); + //parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20; + } + } + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + conduct_sprk = 1; + + + pavg = parts_avg(r>>8, i,PT_INSL); + if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL) // make sparked SWCH turn off correctly + { + if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) { + parts[r>>8].life = 10; + } + if (ct==PT_NSCN) { + part_change_type(r>>8,x+rx,y+ry,PT_SWCH); + parts[r>>8].ctype = PT_NONE; + parts[r>>8].life = 9; + } + } + else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_HSWC||(rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2))) + { + if (ct==PT_PSCN) parts[r>>8].life = 10; + else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; + } + + + // ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed + + if (pavg == PT_INSL) conduct_sprk = 0; + if (!(ptypes[rt].properties&PROP_CONDUCTS||rt==PT_INST)) conduct_sprk = 0; + if (abs(rx)+abs(ry)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH) + conduct_sprk = 0; + + + if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT)))) + { + parts[r>>8].temp = 473.0f; + if (rt==PT_NTCT||rt==PT_PTCT) + conduct_sprk = 0; + } + if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f))) + conduct_sprk = 0; + if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f))) + conduct_sprk = 0; + if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN)) + conduct_sprk = 0; + if (ct==PT_NSCN && rt==PT_PSCN) + conduct_sprk = 0; + if (ct==PT_ETRD && (parts[i].life!=5||!(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN))) + conduct_sprk = 0; + if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0; + if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) + conduct_sprk = 0; + if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||pv[(y+ry)/CELL][(x+rx)/CELL]>8))) + conduct_sprk = 0; + if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f))) + conduct_sprk = 0; + if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f))) + conduct_sprk = 0; + if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN)) + conduct_sprk = 0; + if (rt==PT_INST&&ct!=PT_PSCN) + conduct_sprk = 0; + + if (conduct_sprk) { + if (ct==PT_ETRD) { + part_change_type(i,x,y,PT_ETRD); + parts[i].ctype = PT_NONE; + parts[i].life = 20; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + parts[r>>8].ctype = rt; + } + else if (rt==PT_WATR||rt==PT_SLTW) { + if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)>8,x+rx,y+ry,PT_SPRK); + if (rt==PT_WATR) parts[r>>8].life = 6; + else parts[r>>8].life = 5; + parts[r>>8].ctype = rt; + } + } + else if (rt==PT_INST) { + if (parts[i].life>=3&&parts[r>>8].life==0) + { + flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1);//spark the wire + } + } + else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)>8].life = 4; + parts[r>>8].ctype = rt; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON)) + parts[r>>8].temp = parts[r>>8].temp+10.0f; + } + } + } + return 0; +} diff --git a/src/elements/stkm.c b/src/elements/stkm.c new file mode 100644 index 000000000..9576ae327 --- /dev/null +++ b/src/elements/stkm.c @@ -0,0 +1,412 @@ +#include + +int update_SPAWN(UPDATE_FUNC_ARGS) { + ISSPAWN1 = 1; + if (death) + { + playerspawn = create_part(-1,x,y,PT_STKM); + isplayer = 1; + death = 0; + } + return 0; +} + +int update_STKM(UPDATE_FUNC_ARGS) { + int r, rx, ry; + float pp, d; + float dt = 0.9;///(FPSB*FPSB); //Delta time in square + //Tempirature handling + if (parts[i].temp<243) + parts[i].life -= 1; + if ((parts[i].temp<309.6f) && (parts[i].temp>=243)) + parts[i].temp += 1; + + if (isplayer) { //Already a stickman in the simulation + death = 1; + parts[i].type = PT_NONE; + } + + //Death + if (parts[i].life<1 || death || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... + { + for (r=-2; r<=1; r++) + { + create_part(-1, x+r, y-2, player[2]); + create_part(-1, x+r+1, y+2, player[2]); + create_part(-1, x-2, y+r+1, player[2]); + create_part(-1, x+2, y+r, player[2]); + } + kill_part(i); //Kill him + return 1; + } + + parts[i].vy += -0.7*dt; //Head up! + + //Verlet integration + pp = 2*player[3]-player[5]+player[19]*dt*dt;; + player[5] = player[3]; + player[3] = pp; + pp = 2*player[4]-player[6]+player[20]*dt*dt;; + player[6] = player[4]; + player[4] = pp; + + pp = 2*player[7]-player[9]+player[21]*dt*dt;; + player[9] = player[7]; + player[7] = pp; + pp = 2*player[8]-player[10]+(player[22]+1)*dt*dt;; + player[10] = player[8]; + player[8] = pp; + + pp = 2*player[11]-player[13]+player[23]*dt*dt;; + player[13] = player[11]; + player[11] = pp; + pp = 2*player[12]-player[14]+player[24]*dt*dt;; + player[14] = player[12]; + player[12] = pp; + + pp = 2*player[15]-player[17]+player[25]*dt*dt;; + player[17] = player[15]; + player[15] = pp; + pp = 2*player[16]-player[18]+(player[26]+1)*dt*dt;; + player[18] = player[16]; + player[16] = pp; + + //Setting acceleration to 0 + player[19] = 0; + player[20] = 0; + + player[21] = 0; + player[22] = 0; + + player[23] = 0; + player[24] = 0; + + player[25] = 0; + player[26] = 0; + + //Go left + if (((int)(player[0])&0x01) == 0x01 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + { + if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) + { + player[21] = -3; + player[22] = -2; + player[19] = -2; + } + + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[25] = -3; + player[26] = -2; + player[23] = -2; + } + } + else + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids + { + player[21] = -1; + player[22] = -1; + player[19] = -1; + } + + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[25] = -1; + player[26] = -1; + player[23] = -1; + } + } + } + + //Go right + if (((int)(player[0])&0x02) == 0x02 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + { + if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) + { + player[21] = 3; + player[22] = -2; + player[19] = 2; + } + + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[25] = 3; + player[26] = -2; + player[23] = 2; + } + } + else + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) + { + player[21] = 1; + player[22] = -1; + player[19] = 1; + } + + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[25] = 1; + player[26] = -1; + player[23] = 1; + } + + } + } + + //Jump + if (((int)(player[0])&0x04) == 0x04 && (ptypes[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || ptypes[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS)) + { + if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])]) + { + parts[i].vy = -5; + player[22] -= 1; + player[26] -= 1; + } + } + + //Charge detector wall if foot inside + if (bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT) + set_emap((int)player[7]/CELL, (int)player[8]/CELL); + if (bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT) + set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL); + + //Searching for particles near head + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended. + { + player[2] = r&0xFF; //Current element + } + if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP + { + if (parts[i].life<=95) + parts[i].life += 5; + else + parts[i].life = 100; + kill_part(r>>8); + } + + if ((r&0xFF) == PT_NEUT) + { + parts[i].life -= (102-parts[i].life)/2; + kill_part(r>>8); + } + if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN) + player[2] = SPC_AIR; + } + + //Head position + rx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01); + ry = y - 3*(player[1] == 0); + + //Spawn + if (((int)(player[0])&0x08) == 0x08) + { + ry -= 2*(rand()%2)+1; + r = pmap[ry][rx]; + if (!((r>>8)>=NPART)) + { + if (ptypes[r&0xFF].state == ST_SOLID) + { + create_part(-1, rx, ry, PT_SPRK); + } + else + { + if (player[2] == SPC_AIR) + create_parts(rx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR); + else + create_part(-1, rx, ry, player[2]); + + r = pmap[ry][rx]; + if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR) + parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); + if (((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT) + { + int random = abs(rand()%3-1)*3; + if (random==0) + { + parts[r>>8].life = 0; + parts[r>>8].type = PT_NONE; + } + else + { + parts[r>>8].vy = 0; + parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random; + } + } + + } + } + } + + //Simulation of joints + d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance + player[7] -= (player[3]-player[7])*d; + player[8] -= (player[4]-player[8])*d; + player[3] += (player[3]-player[7])*d; + player[4] += (player[4]-player[8])*d; + + d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5; + player[15] -= (player[11]-player[15])*d; + player[16] -= (player[12]-player[16])*d; + player[11] += (player[11]-player[15])*d; + player[12] += (player[12]-player[16])*d; + + d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5; + parts[i].vx -= (player[3]-parts[i].x)*d; + parts[i].vy -= (player[4]-parts[i].y)*d; + player[3] += (player[3]-parts[i].x)*d; + player[4] += (player[4]-parts[i].y)*d; + + d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5; + parts[i].vx -= (player[11]-parts[i].x)*d; + parts[i].vy -= (player[12]-parts[i].y)*d; + player[11] += (player[11]-parts[i].x)*d; + player[12] += (player[12]-parts[i].y)*d; + + //Side collisions checking + for (rx = -3; rx <= 3; rx++) + { + r = pmap[(int)(player[16]-2)][(int)(player[15]+rx)]; + if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + player[15] -= rx; + + r = pmap[(int)(player[8]-2)][(int)(player[7]+rx)]; + if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + player[7] -= rx; + } + + //Collision checks + for (ry = -2-(int)parts[i].vy; ry<=0; ry++) + { + r = pmap[(int)(player[8]+ry)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-) + + //For left leg + if (r && (r&0xFF)!=PT_STKM) + { + if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks + { + if (parts[i].y<(player[8]-10)) + parts[i].vy = 1*dt; + else + parts[i].vy = 0; + if (abs(parts[i].vx)>1) + parts[i].vx *= 0.5*dt; + } + else + { + if (ptypes[r&0xFF].state != ST_GAS) + { + player[8] += ry-1; + parts[i].vy -= 0.5*parts[i].vy*dt; + } + } + player[9] = player[7]; + } + + r = pmap[(int)(player[16]+ry)][(int)(player[15]+0.5)]; + + //For right leg + if (r && (r&0xFF)!=PT_STKM) + { + if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) + { + if (parts[i].y<(player[16]-10)) + parts[i].vy = 1*dt; + else + parts[i].vy = 0; + if (abs(parts[i].vx)>1) + parts[i].vx *= 0.5*dt; + } + else + { + if (ptypes[r&0xFF].state != ST_GAS) + { + player[16] += ry-1; + parts[i].vy -= 0.5*parts[i].vy*dt; + } + } + player[17] = player[15]; + } + + //If it falls too fast + if (parts[i].vy>=30) + { + parts[i].y -= (10+ry)*dt; + parts[i].vy = -10*dt; + } + + } + + //Keeping legs distance + if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1) + { + player[21] -= 0.2; + player[25] += 0.2; + } + + if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1) + { + player[19] -= 0.2; + player[23] += 0.2; + } + + //If legs touch something + r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)]; + if ((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) //If hot or cold + { + parts[i].life -= 2; + player[26] -= 1; + } + } + + if ((r&0xFF)==PT_ACID) //If on acid + parts[i].life -= 5; + + if ((r&0xFF)==PT_PLUT) //If on plut + parts[i].life -= 1; + + r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)]; + if ((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) + { + parts[i].life -= 2; + player[22] -= 1; + } + } + + if ((r&0xFF)==PT_ACID) //If on acid + parts[i].life -= 5; + + if ((r&0xFF)==PT_PLUT) //If on plut + parts[i].life -= 1; + + isplayer = 1; + return 0; +} diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c new file mode 100644 index 000000000..805cb736e --- /dev/null +++ b/src/elements/stkm2.c @@ -0,0 +1,413 @@ +#include + +int update_SPAWN2(UPDATE_FUNC_ARGS) { + ISSPAWN2 = 1; + if (death2) + { + player2spawn = create_part(-1,x,y,PT_STKM2); + isplayer2 = 1; + death2 = 0; + } + return 0; +} + +int update_STKM2(UPDATE_FUNC_ARGS) { + int r, rx, ry; + float pp, d; + float dt = 0.9;///(FPSB*FPSB); //Delta time in square + //Tempirature handling + if (parts[i].temp<243) + parts[i].life -= 1; + if ((parts[i].temp<309.6f) && (parts[i].temp>=243)) + parts[i].temp += 1; + + if (isplayer2) { //Already a stickman2 in the simulation + death2 = 1; + parts[i].type = PT_NONE; + } + + //Death + if (parts[i].life<1 || death2 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... + { + for (r=-2; r<=1; r++) + { + create_part(-1, x+r, y-2, player2[2]); + create_part(-1, x+r+1, y+2, player2[2]); + create_part(-1, x-2, y+r+1, player2[2]); + create_part(-1, x+2, y+r, player2[2]); + } + kill_part(i); //Kill him + return 1; + } + + parts[i].vy += -0.7*dt; //Head up! + + //Verlet integration + pp = 2*player2[3]-player2[5]+player2[19]*dt*dt;; + player2[5] = player2[3]; + player2[3] = pp; + pp = 2*player2[4]-player2[6]+player2[20]*dt*dt;; + player2[6] = player2[4]; + player2[4] = pp; + + pp = 2*player2[7]-player2[9]+player2[21]*dt*dt;; + player2[9] = player2[7]; + player2[7] = pp; + pp = 2*player2[8]-player2[10]+(player2[22]+1)*dt*dt;; + player2[10] = player2[8]; + player2[8] = pp; + + pp = 2*player2[11]-player2[13]+player2[23]*dt*dt;; + player2[13] = player2[11]; + player2[11] = pp; + pp = 2*player2[12]-player2[14]+player2[24]*dt*dt;; + player2[14] = player2[12]; + player2[12] = pp; + + pp = 2*player2[15]-player2[17]+player2[25]*dt*dt;; + player2[17] = player2[15]; + player2[15] = pp; + pp = 2*player2[16]-player2[18]+(player2[26]+1)*dt*dt;; + player2[18] = player2[16]; + player2[16] = pp; + + //Setting acceleration to 0 + player2[19] = 0; + player2[20] = 0; + + player2[21] = 0; + player2[22] = 0; + + player2[23] = 0; + player2[24] = 0; + + player2[25] = 0; + player2[26] = 0; + + //Go left + if (((int)(player2[0])&0x01) == 0x01 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + { + if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + { + if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) + { + player2[21] = -3; + player2[22] = -2; + player2[19] = -2; + } + + if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) + { + player2[25] = -3; + player2[26] = -2; + player2[23] = -2; + } + } + else + { + if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) //It should move another way in liquids + { + player2[21] = -1; + player2[22] = -1; + player2[19] = -1; + } + + if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) + { + player2[25] = -1; + player2[26] = -1; + player2[23] = -1; + } + } + } + + //Go right + if (((int)(player2[0])&0x02) == 0x02 && ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) + { + if (ptypes[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID + && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) + { + if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) + { + player2[21] = 3; + player2[22] = -2; + player2[19] = 2; + } + + if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) + { + player2[25] = 3; + player2[26] = -2; + player2[23] = 2; + } + } + else + { + if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) + { + player2[21] = 1; + player2[22] = -1; + player2[19] = 1; + } + + if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) + { + player2[25] = 1; + player2[26] = -1; + player2[23] = 1; + } + + } + } + + //Jump + if (((int)(player2[0])&0x04) == 0x04 && (ptypes[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || ptypes[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS)) + { + if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])]) + { + parts[i].vy = -5; + player2[22] -= 1; + player2[26] -= 1; + } + } + + //Charge detector wall if foot inside + if (bmap[(int)(player2[8]+0.5)/CELL][(int)(player2[7]+0.5)/CELL]==WL_DETECT) + set_emap((int)player2[7]/CELL, (int)player2[8]/CELL); + if (bmap[(int)(player2[16]+0.5)/CELL][(int)(player2[15]+0.5)/CELL]==WL_DETECT) + set_emap((int)(player2[15]+0.5)/CELL, (int)(player2[16]+0.5)/CELL); + + //Searching for particles near head + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + continue; + if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended. + { + player2[2] = r&0xFF; //Current element + } + if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP + { + if (parts[i].life<=95) + parts[i].life += 5; + else + parts[i].life = 100; + kill_part(r>>8); + } + + if ((r&0xFF) == PT_NEUT) + { + parts[i].life -= (102-parts[i].life)/2; + kill_part(r>>8); + } + if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN) + player2[2] = SPC_AIR; + } + + //Head position + rx = x + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01); + ry = y - 3*(player2[1] == 0); + + //Spawn + if (((int)(player2[0])&0x08) == 0x08) + { + ry -= 2*(rand()%2)+1; + r = pmap[ry][rx]; + if (!((r>>8)>=NPART)) + { + if (ptypes[r&0xFF].state == ST_SOLID) + { + create_part(-1, rx, ry, PT_SPRK); + } + else + { + if (player2[2] == SPC_AIR) + create_parts(rx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR); + else + create_part(-1, rx, ry, player2[2]); + + r = pmap[ry][rx]; + if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR) + parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01); + if (((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT) + { + int random = abs(rand()%3-1)*3; + if (random==0) + { + parts[r>>8].life = 0; + parts[r>>8].type = PT_NONE; + } + else + { + parts[r>>8].vy = 0; + parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random; + } + } + + } + } + } + + //Simulation of joints + d = 25/(pow((player2[3]-player2[7]), 2) + pow((player2[4]-player2[8]), 2)+25) - 0.5; //Fast distance + player2[7] -= (player2[3]-player2[7])*d; + player2[8] -= (player2[4]-player2[8])*d; + player2[3] += (player2[3]-player2[7])*d; + player2[4] += (player2[4]-player2[8])*d; + + d = 25/(pow((player2[11]-player2[15]), 2) + pow((player2[12]-player2[16]), 2)+25) - 0.5; + player2[15] -= (player2[11]-player2[15])*d; + player2[16] -= (player2[12]-player2[16])*d; + player2[11] += (player2[11]-player2[15])*d; + player2[12] += (player2[12]-player2[16])*d; + + d = 36/(pow((player2[3]-parts[i].x), 2) + pow((player2[4]-parts[i].y), 2)+36) - 0.5; + parts[i].vx -= (player2[3]-parts[i].x)*d; + parts[i].vy -= (player2[4]-parts[i].y)*d; + player2[3] += (player2[3]-parts[i].x)*d; + player2[4] += (player2[4]-parts[i].y)*d; + + d = 36/(pow((player2[11]-parts[i].x), 2) + pow((player2[12]-parts[i].y), 2)+36) - 0.5; + parts[i].vx -= (player2[11]-parts[i].x)*d; + parts[i].vy -= (player2[12]-parts[i].y)*d; + player2[11] += (player2[11]-parts[i].x)*d; + player2[12] += (player2[12]-parts[i].y)*d; + + //Side collisions checking + for (rx = -3; rx <= 3; rx++) + { + r = pmap[(int)(player2[16]-2)][(int)(player2[15]+rx)]; + if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + player2[15] -= rx; + + r = pmap[(int)(player2[8]-2)][(int)(player2[7]+rx)]; + if (r && ptypes[r&0xFF].state != ST_GAS && ptypes[r&0xFF].state != ST_LIQUID) + player2[7] -= rx; + } + + //Collision checks + for (ry = -2-(int)parts[i].vy; ry<=0; ry++) + { + r = pmap[(int)(player2[8]+ry)][(int)(player2[7]+0.5)]; //This is to make coding more pleasant :-) + + //For left leg + if (r && (r&0xFF)!=PT_STKM) + { + if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks + { + if (parts[i].y<(player2[8]-10)) + parts[i].vy = 1*dt; + else + parts[i].vy = 0; + if (abs(parts[i].vx)>1) + parts[i].vx *= 0.5*dt; + } + else + { + if (ptypes[r&0xFF].state != ST_GAS) + { + player2[8] += ry-1; + parts[i].vy -= 0.5*parts[i].vy*dt; + } + } + player2[9] = player2[7]; + } + + r = pmap[(int)(player2[16]+ry)][(int)(player2[15]+0.5)]; + + //For right leg + if (r && (r&0xFF)!=PT_STKM) + { + if (ptypes[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) + { + if (parts[i].y<(player2[16]-10)) + parts[i].vy = 1*dt; + else + parts[i].vy = 0; + if (abs(parts[i].vx)>1) + parts[i].vx *= 0.5*dt; + } + else + { + if (ptypes[r&0xFF].state != ST_GAS) + { + player2[16] += ry-1; + parts[i].vy -= 0.5*parts[i].vy*dt; + } + } + player2[17] = player2[15]; + } + + //If it falls too fast + if (parts[i].vy>=30) + { + parts[i].y -= (10+ry)*dt; + parts[i].vy = -10*dt; + } + + } + + //Keeping legs distance + if (pow((player2[7] - player2[15]), 2)<16 && pow((player2[8]-player2[16]), 2)<1) + { + player2[21] -= 0.2; + player2[25] += 0.2; + } + + if (pow((player2[3] - player2[11]), 2)<16 && pow((player2[4]-player2[12]), 2)<1) + { + player2[19] -= 0.2; + player2[23] += 0.2; + } + + //If legs touch something + r = pmap[(int)(player2[8]+0.5)][(int)(player2[7]+0.5)]; + if ((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) //If hot or cold + { + parts[i].life -= 2; + player2[26] -= 1; + } + } + + if ((r&0xFF)==PT_ACID) //If on acid + parts[i].life -= 5; + + if ((r&0xFF)==PT_PLUT) //If on plut + parts[i].life -= 1; + + r = pmap[(int)(player2[16]+0.5)][(int)(player2[15]+0.5)]; + if ((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) + { + parts[i].life -= 2; + player2[22] -= 1; + } + } + + if ((r&0xFF)==PT_ACID) //If on acid + parts[i].life -= 5; + + if ((r&0xFF)==PT_PLUT) //If on plut + parts[i].life -= 1; + + isplayer2 = 1; + return 0; +} + diff --git a/src/elements/swch.c b/src/elements/swch.c new file mode 100644 index 000000000..8a8e989b7 --- /dev/null +++ b/src/elements/swch.c @@ -0,0 +1,37 @@ +#include + +int update_SWCH(UPDATE_FUNC_ARGS) { + int r, rt, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { + rt = r&0xFF; + if (rt==PT_SWCH) + { + if (parts[i].life>=10&&parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[i].life==0&&parts[r>>8].life==10) + parts[i].life = 10; + } + else if (rt==PT_SPRK&&parts[i].life==10&&parts[r>>8].ctype!=PT_PSCN&&parts[r>>8].ctype!=PT_NSCN) { + part_change_type(i,x,y,PT_SPRK); + parts[i].ctype = PT_SWCH; + parts[i].life = 4; + } + } + } + if (parts[i].life==10 && (!(pmap[y-1][x-1]&0xFF) && ((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) && !(pmap[y-1][x+1]&0xFF) && ((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2))) + { + parts[i].life = 9; + } + else if (parts[i].life<=5 && (!(pmap[y-1][x-1]&0xFF) && (((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) || ((pmap[y+1][x]&0xFF)==PT_BRAY&&parts[pmap[y+1][x]>>8].tmp==2)) && !(pmap[y-1][x+1]&0xFF) && (((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2) || ((pmap[y][x-1]&0xFF)==PT_BRAY&&parts[pmap[y][x-1]>>8].tmp==2)))) + { + parts[i].life = 14; + } + return 0; +} diff --git a/src/elements/thdr.c b/src/elements/thdr.c new file mode 100644 index 000000000..0f25ccde2 --- /dev/null +++ b/src/elements/thdr.c @@ -0,0 +1,38 @@ +#include + +int update_THDR(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) + { + parts[i].type = PT_NONE; + parts[r>>8].ctype = parts[r>>8].type; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + } + else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF)) + { + pv[y/CELL][x/CELL] += 100.0f; + if (legacy_enable&&1>(rand()%200)) + { + parts[i].life = rand()%50+120; + part_change_type(i,x,y,PT_FIRE); + } + else + { + parts[i].type = PT_NONE; + } + } + } + if (parts[i].type==PT_NONE) { + kill_part(i); + return 1; + } + return 0; +} diff --git a/src/elements/thrm.c b/src/elements/thrm.c new file mode 100644 index 000000000..3529c2ef2 --- /dev/null +++ b/src/elements/thrm.c @@ -0,0 +1,29 @@ +#include + +int update_THRM(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO? + { + if (1>(rand()%500)) { + part_change_type(i,x,y,PT_LAVA); + parts[i].ctype = PT_BMTL; + parts[i].temp = 3500.0f; + pv[y/CELL][x/CELL] += 50.0f; + } else { + part_change_type(i,x,y,PT_LAVA); + parts[i].life = 400; + parts[i].ctype = PT_THRM; + parts[i].temp = 3500.0f; + parts[i].tmp = 20; + } + } + } + return 0; +} diff --git a/src/elements/uran.c b/src/elements/uran.c new file mode 100644 index 000000000..ecf89cc8d --- /dev/null +++ b/src/elements/uran.c @@ -0,0 +1,10 @@ +#include + +int update_URAN(UPDATE_FUNC_ARGS) { + if (!legacy_enable && pv[y/CELL][x/CELL]>0.0f) + { + float atemp = parts[i].temp + (-MIN_TEMP); + parts[i].temp = restrict_flt((atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP); + } + return 0; +} diff --git a/src/elements/vine.c b/src/elements/vine.c new file mode 100644 index 000000000..a5d932aaa --- /dev/null +++ b/src/elements/vine.c @@ -0,0 +1,21 @@ +#include + +int update_VINE(UPDATE_FUNC_ARGS) { + int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + return 0; + if (1>rand()%15) + part_change_type(i,x,y,PT_PLNT); + else if (!r) + { + np = create_part(-1,x+rx,y+ry,PT_VINE); + if (np<0) return 0; + parts[np].temp = parts[i].temp; + part_change_type(i,x,y,PT_PLNT); + } + } + return 0; +} diff --git a/src/elements/warp.c b/src/elements/warp.c new file mode 100644 index 000000000..d0fe62cac --- /dev/null +++ b/src/elements/warp.c @@ -0,0 +1,28 @@ +#include + +int update_WARP(UPDATE_FUNC_ARGS) { + int trade, r, rx, ry; + for ( trade = 0; trade<5; trade ++) + { + rx = rand()%3-1; + ry = rand()%3-1; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200)) + { + parts[i].x = parts[r>>8].x; + parts[i].y = parts[r>>8].y; + parts[r>>8].x = x; + parts[r>>8].y = y; + parts[i].life += 4; + pmap[y][x] = r; + pmap[y+ry][x+rx] = (i<<8)|parts[i].type; + trade = 5; + } + } + } + return 0; +} diff --git a/src/elements/watr.c b/src/elements/watr.c new file mode 100644 index 000000000..8f1df1869 --- /dev/null +++ b/src/elements/watr.c @@ -0,0 +1,29 @@ +#include + +int update_WATR(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SALT && 1>(rand()%250)) + { + part_change_type(i,x,y,PT_SLTW); + part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_PSTE); + kill_part(r>>8); + } + } + return 0; +} diff --git a/src/elements/wifi.c b/src/elements/wifi.c new file mode 100644 index 000000000..a6b9ab0cf --- /dev/null +++ b/src/elements/wifi.c @@ -0,0 +1,33 @@ +#include + +int update_WIFI(UPDATE_FUNC_ARGS) { + int r, rx, ry; + parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (wireless[parts[i].tmp][0]) + { + if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && wireless[parts[i].tmp][0]) + { + parts[r>>8].ctype = r&0xFF; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + } + } + else + { + if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) + { + wireless[parts[i].tmp][0] = 1; + wireless[parts[i].tmp][1] = 1; + ISWIRE = 1; + } + } + } + return 0; +} diff --git a/src/elements/wtrv.c b/src/elements/wtrv.c new file mode 100644 index 000000000..45ffb304c --- /dev/null +++ b/src/elements/wtrv.c @@ -0,0 +1,19 @@ +#include + +int update_WTRV(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + } + return 0; +} diff --git a/src/elements/yest.c b/src/elements/yest.c new file mode 100644 index 000000000..d3ee0fec4 --- /dev/null +++ b/src/elements/yest.c @@ -0,0 +1,21 @@ +#include + +int update_YEST(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable) + { + part_change_type(i,x,y,PT_DYST); + } + } + if (parts[i].temp>303&&parts[i].temp<317) { + create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST); + } + return 0; +} diff --git a/src/graphics.c b/src/graphics.c index 286182aff..06cd6fbbc 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -34,730 +34,730 @@ pixel *fire_bg; pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f) { - int i,j,x,y,w,h,r,g,b,c; - pixel p, *q; - w = (sw+f-1)/f; - h = (sh+f-1)/f; - q = malloc(w*h*PIXELSIZE); - for(y=0; y1) - { - r = (r+c/2)/c; - g = (g+c/2)/c; - b = (b+c/2)/c; - } - q[y*w+x] = PIXRGB(r, g, b); - } - *qw = w; - *qh = h; - return q; + int i,j,x,y,w,h,r,g,b,c; + pixel p, *q; + w = (sw+f-1)/f; + h = (sh+f-1)/f; + q = malloc(w*h*PIXELSIZE); + for (y=0; y1) + { + r = (r+c/2)/c; + g = (g+c/2)/c; + b = (b+c/2)/c; + } + q[y*w+x] = PIXRGB(r, g, b); + } + *qw = w; + *qh = h; + return q; } void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch) { - pixel *dst; - int j; - if(SDL_MUSTLOCK(sdl_scrn)) - if(SDL_LockSurface(sdl_scrn)<0) - return; - dst=(pixel *)sdl_scrn->pixels+y*sdl_scrn->pitch/PIXELSIZE+x; - for(j=0; jpitch/PIXELSIZE; - src+=pitch; - } - if(SDL_MUSTLOCK(sdl_scrn)) - SDL_UnlockSurface(sdl_scrn); - SDL_UpdateRect(sdl_scrn,0,0,0,0); + pixel *dst; + int j; + if (SDL_MUSTLOCK(sdl_scrn)) + if (SDL_LockSurface(sdl_scrn)<0) + return; + dst=(pixel *)sdl_scrn->pixels+y*sdl_scrn->pitch/PIXELSIZE+x; + for (j=0; jpitch/PIXELSIZE; + src+=pitch; + } + if (SDL_MUSTLOCK(sdl_scrn)) + SDL_UnlockSurface(sdl_scrn); + SDL_UpdateRect(sdl_scrn,0,0,0,0); } void sdl_blit_2(int x, int y, int w, int h, pixel *src, int pitch) { - pixel *dst; - int j; - int i,k; - if(SDL_MUSTLOCK(sdl_scrn)) - if(SDL_LockSurface(sdl_scrn)<0) - return; - dst=(pixel *)sdl_scrn->pixels+y*sdl_scrn->pitch/PIXELSIZE+x; - for(j=0; jpitch/PIXELSIZE; - } - src+=pitch; - } - if(SDL_MUSTLOCK(sdl_scrn)) - SDL_UnlockSurface(sdl_scrn); - SDL_UpdateRect(sdl_scrn,0,0,0,0); + pixel *dst; + int j; + int i,k; + if (SDL_MUSTLOCK(sdl_scrn)) + if (SDL_LockSurface(sdl_scrn)<0) + return; + dst=(pixel *)sdl_scrn->pixels+y*sdl_scrn->pitch/PIXELSIZE+x; + for (j=0; jpitch/PIXELSIZE; + } + src+=pitch; + } + if (SDL_MUSTLOCK(sdl_scrn)) + SDL_UnlockSurface(sdl_scrn); + SDL_UpdateRect(sdl_scrn,0,0,0,0); } void sdl_blit(int x, int y, int w, int h, pixel *src, int pitch) { #ifdef OpenGL - RenderScene(); + RenderScene(); #else - if(sdl_scale == 2) - sdl_blit_2(x, y, w, h, src, pitch); - else - sdl_blit_1(x, y, w, h, src, pitch); + if (sdl_scale == 2) + sdl_blit_2(x, y, w, h, src, pitch); + else + sdl_blit_1(x, y, w, h, src, pitch); #endif } void drawblob(pixel *vid, int x, int y, unsigned char cr, unsigned char cg, unsigned char cb) { - blendpixel(vid, x+1, y, cr, cg, cb, 112); - blendpixel(vid, x-1, y, cr, cg, cb, 112); - blendpixel(vid, x, y+1, cr, cg, cb, 112); - blendpixel(vid, x, y-1, cr, cg, cb, 112); + blendpixel(vid, x+1, y, cr, cg, cb, 112); + blendpixel(vid, x-1, y, cr, cg, cb, 112); + blendpixel(vid, x, y+1, cr, cg, cb, 112); + blendpixel(vid, x, y-1, cr, cg, cb, 112); - blendpixel(vid, x+1, y-1, cr, cg, cb, 64); - blendpixel(vid, x-1, y-1, cr, cg, cb, 64); - blendpixel(vid, x+1, y+1, cr, cg, cb, 64); - blendpixel(vid, x-1, y+1, cr, cg, cb, 64); + blendpixel(vid, x+1, y-1, cr, cg, cb, 64); + blendpixel(vid, x-1, y-1, cr, cg, cb, 64); + blendpixel(vid, x+1, y+1, cr, cg, cb, 64); + blendpixel(vid, x-1, y+1, cr, cg, cb, 64); } void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswall) { - int x, y, i, j, c; - int bo = b; - if(iswall==1) - { - b = b-100; - x = (2+32*((b-22)/1)); - y = YRES+2+40; - switch(b) - { - case WL_WALLELEC: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - else - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXPACK(0x808080); - } - } - } - break; - case 23: - for(j=1; j<15; j++) - { - for(i=1; i<6+j; i++) - { - if(!(i&j&1)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - for(; i<27; i++) - { - if(i&j&1) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case 24: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 25: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); - drawtext(vid_buf, x+4, y+3, "\x8D", 255, 255, 255, 255); - } - } - for(i=9; i<27; i++) - { - drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255); - } - break; - case 26: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); - } - } - drawtext(vid_buf, x+9, y+3, "\xA1", 32, 64, 128, 255); - drawtext(vid_buf, x+9, y+3, "\xA0", 255, 255, 255, 255); - break; - case 27: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 28: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case 29: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 30: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<13; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - for(j=1; j<15; j++) - { - for(i=14; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 32: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 33: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case 34: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case 36: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255); - break; - case 37: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255); - break; - case 38: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255); - break; - case 39: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255); - break; - default: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - if(b==30) - { - for(j=4; j<12; j++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); - } - } - } - else - { - x = 2+32*(b/2); - y = YRES+2+20*(b%2); - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - if(b==0) - { - for(j=4; j<12; j++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); - } - } - c = PIXB(ptypes[b].pcolors) + 3*PIXG(ptypes[b].pcolors) + 2*PIXR(ptypes[b].pcolors); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth((char *)ptypes[b].name)/2, y+4, (char *)ptypes[b].name, c, c, c, 255); - } - if(bo==sl || bo==sr) - { - c = 0; - if(bo==sl) - c |= PIXPACK(0xFF0000); - if(bo==sr) - c |= PIXPACK(0x0000FF); - for(i=0; i<30; i++) - { - vid_buf[(XRES+BARSIZE)*(y-1)+(x+i-1)] = c; - vid_buf[(XRES+BARSIZE)*(y+16)+(x+i-1)] = c; - } - for(j=0; j<18; j++) - { - vid_buf[(XRES+BARSIZE)*(y+j-1)+(x-1)] = c; - vid_buf[(XRES+BARSIZE)*(y+j-1)+(x+28)] = c; - } - } + int x, y, i, j, c; + int bo = b; + if (iswall==1) + { + b = b-100; + x = (2+32*((b-22)/1)); + y = YRES+2+40; + switch (b) + { + case WL_WALLELEC: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + else + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXPACK(0x808080); + } + } + } + break; + case 23: + for (j=1; j<15; j++) + { + for (i=1; i<6+j; i++) + { + if (!(i&j&1)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + for (; i<27; i++) + { + if (i&j&1) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case 24: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 25: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); + drawtext(vid_buf, x+4, y+3, "\x8D", 255, 255, 255, 255); + } + } + for (i=9; i<27; i++) + { + drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255); + } + break; + case 26: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); + } + } + drawtext(vid_buf, x+9, y+3, "\xA1", 32, 64, 128, 255); + drawtext(vid_buf, x+9, y+3, "\xA0", 255, 255, 255, 255); + break; + case 27: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 28: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case 29: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 30: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<13; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + for (j=1; j<15; j++) + { + for (i=14; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 32: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 33: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case 34: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case 36: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255); + break; + case 37: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255); + break; + case 38: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255); + break; + case 39: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255); + break; + default: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + if (b==30) + { + for (j=4; j<12; j++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); + } + } + } + else + { + x = 2+32*(b/2); + y = YRES+2+20*(b%2); + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + if (b==0) + { + for (j=4; j<12; j++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); + } + } + c = PIXB(ptypes[b].pcolors) + 3*PIXG(ptypes[b].pcolors) + 2*PIXR(ptypes[b].pcolors); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth((char *)ptypes[b].name)/2, y+4, (char *)ptypes[b].name, c, c, c, 255); + } + if (bo==sl || bo==sr) + { + c = 0; + if (bo==sl) + c |= PIXPACK(0xFF0000); + if (bo==sr) + c |= PIXPACK(0x0000FF); + for (i=0; i<30; i++) + { + vid_buf[(XRES+BARSIZE)*(y-1)+(x+i-1)] = c; + vid_buf[(XRES+BARSIZE)*(y+16)+(x+i-1)] = c; + } + for (j=0; j<18; j++) + { + vid_buf[(XRES+BARSIZE)*(y+j-1)+(x-1)] = c; + vid_buf[(XRES+BARSIZE)*(y+j-1)+(x+28)] = c; + } + } } int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) { - int i, j, c; - if(b>=UI_WALLSTART) - { - b = b-100; - //x = (2+32*((b-22)/1)); - //y = YRES+2+40; - switch(b) - { - case WL_WALLELEC: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - else - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXPACK(0x808080); - } - } - } - break; - case WL_EWALL: - for(j=1; j<15; j++) - { - for(i=1; i<6+j; i++) - { - if(!(i&j&1)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - for(; i<27; i++) - { - if(i&j&1) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case WL_DETECT: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_STREAM: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); - drawtext(vid_buf, x+4, y+3, "\x8D", 255, 255, 255, 255); - } - } - for(i=9; i<27; i++) - { - drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255); - } - break; - case WL_SIGN: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); - } - } - drawtext(vid_buf, x+9, y+3, "\xA1", 32, 64, 128, 255); - drawtext(vid_buf, x+9, y+3, "\xA0", 255, 255, 255, 255); - break; - case WL_FAN: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_ALLOWLIQUID: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case WL_DESTROYALL: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_ERASE: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<13; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - for(j=1; j<15; j++) - { - for(i=14; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_ALLOWAIR: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_ALLOWSOLID: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - case WL_ALLOWALLELEC: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - if(!(i%2) && !(j%2)) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - break; - case SPC_AIR-100: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255); - break; - case SPC_HEAT-100: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255); - break; - case SPC_COOL-100: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255); - break; - case SPC_VACUUM-100: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255); - break; - case WL_ALLOWGAS: - for(j=1; j<15; j+=2) - { - for(i=1+(1&(j>>1)); i<27; i+=2) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - break; - default: - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } - } - if(b==WL_ERASE) - { - for(j=4; j<12; j++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); - } - } - } - else - { - //x = 2+32*(b/2); - //y = YRES+2+20*(b%2); + int i, j, c; + if (b>=UI_WALLSTART) + { + b = b-100; + //x = (2+32*((b-22)/1)); + //y = YRES+2+40; + switch (b) + { + case WL_WALLELEC: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + else + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXPACK(0x808080); + } + } + } + break; + case WL_EWALL: + for (j=1; j<15; j++) + { + for (i=1; i<6+j; i++) + { + if (!(i&j&1)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + for (; i<27; i++) + { + if (i&j&1) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case WL_DETECT: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_STREAM: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); + drawtext(vid_buf, x+4, y+3, "\x8D", 255, 255, 255, 255); + } + } + for (i=9; i<27; i++) + { + drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255); + } + break; + case WL_SIGN: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = i==1||i==26||j==1||j==14 ? PIXPACK(0xA0A0A0) : PIXPACK(0x000000); + } + } + drawtext(vid_buf, x+9, y+3, "\xA1", 32, 64, 128, 255); + drawtext(vid_buf, x+9, y+3, "\xA0", 255, 255, 255, 255); + break; + case WL_FAN: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_ALLOWLIQUID: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case WL_DESTROYALL: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_ERASE: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<13; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + for (j=1; j<15; j++) + { + for (i=14; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_ALLOWAIR: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_ALLOWSOLID: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + case WL_ALLOWALLELEC: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + if (!(i%2) && !(j%2)) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + break; + case SPC_AIR-100: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255); + break; + case SPC_HEAT-100: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255); + break; + case SPC_COOL-100: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255); + break; + case SPC_VACUUM-100: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + c = PIXR(pc) + 3*PIXG(pc) + 2*PIXB(pc); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255); + break; + case WL_ALLOWGAS: + for (j=1; j<15; j+=2) + { + for (i=1+(1&(j>>1)); i<27; i+=2) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + break; + default: + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } + } + if (b==WL_ERASE) + { + for (j=4; j<12; j++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); + } + } + } + else + { + //x = 2+32*(b/2); + //y = YRES+2+20*(b%2); #ifdef OpenGL - fillrect(vid_buf, x, y, 28, 16, PIXR(pc), PIXG(pc), PIXB(pc), 255); + fillrect(vid_buf, x, y, 28, 16, PIXR(pc), PIXG(pc), PIXB(pc), 255); #else - for(j=1; j<15; j++) - { - for(i=1; i<27; i++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; - } - } + for (j=1; j<15; j++) + { + for (i=1; i<27; i++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = pc; + } + } #endif - if(b==0) - { - for(j=4; j<12; j++) - { - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); - vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); - } - } - c = PIXB(ptypes[b].pcolors) + 3*PIXG(ptypes[b].pcolors) + 2*PIXR(ptypes[b].pcolors); - if(c<544) - { - c = 255; - } - else - { - c = 0; - } - drawtext(vid_buf, x+14-textwidth((char *)ptypes[b].name)/2, y+4, (char *)ptypes[b].name, c, c, c, 255); - } - return 26; + if (b==0) + { + for (j=4; j<12; j++) + { + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+6)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x+j+7)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+21)] = PIXPACK(0xFF0000); + vid_buf[(XRES+BARSIZE)*(y+j)+(x-j+22)] = PIXPACK(0xFF0000); + } + } + c = PIXB(ptypes[b].pcolors) + 3*PIXG(ptypes[b].pcolors) + 2*PIXR(ptypes[b].pcolors); + if (c<544) + { + c = 255; + } + else + { + c = 0; + } + drawtext(vid_buf, x+14-textwidth((char *)ptypes[b].name)/2, y+4, (char *)ptypes[b].name, c, c, c, 255); + } + return 26; } void draw_menu(pixel *vid_buf, int i, int hover) { - if(i==SEC&&SEC!=0) + if (i==SEC&&SEC!=0) drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 0, 255, 255, 255); else drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); - if(hover==i) - { - fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); - drawtext(vid_buf, (XRES+BARSIZE)-13, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 0, 0, 0, 255); - } - else - { - drawtext(vid_buf, (XRES+BARSIZE)-13, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); - } + if (hover==i) + { + fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); + drawtext(vid_buf, (XRES+BARSIZE)-13, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 0, 0, 0, 255); + } + else + { + drawtext(vid_buf, (XRES+BARSIZE)-13, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); + } } #if defined(WIN32) && !defined(__GNUC__) @@ -766,17 +766,17 @@ _inline void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a) inline void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a) #endif { - pixel t; - if(x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) - return; - if(a!=255) - { - t = vid[y*(XRES+BARSIZE)+x]; - r = (a*r + (255-a)*PIXR(t)) >> 8; - g = (a*g + (255-a)*PIXG(t)) >> 8; - b = (a*b + (255-a)*PIXB(t)) >> 8; - } - vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); + pixel t; + if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) + return; + if (a!=255) + { + t = vid[y*(XRES+BARSIZE)+x]; + r = (a*r + (255-a)*PIXR(t)) >> 8; + g = (a*g + (255-a)*PIXG(t)) >> 8; + b = (a*b + (255-a)*PIXB(t)) >> 8; + } + vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); } #if defined(WIN32) && !defined(__GNUC__) @@ -785,276 +785,276 @@ _inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a) #endif { - int i, j, w, bn = 0, ba = 0; - char *rp = font_data + font_ptrs[c]; - w = *(rp++); - for(j=0; j>= 2; - bn -= 2; - } - return x + w; + int i, j, w, bn = 0, ba = 0; + char *rp = font_data + font_ptrs[c]; + w = *(rp++); + for (j=0; j>= 2; + bn -= 2; + } + return x + w; } int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a) { #ifdef OpenGL #else - int sx = x; - for(; *s; s++) - { - if(*s == '\n') - { - x = sx; - y += FONT_H+2; - } - else if(*s == '\b') - { - switch(s[1]) - { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'b': - r = g = 0; - b = 255; - break; - } - s++; - } - else - x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); - } + int sx = x; + for (; *s; s++) + { + if (*s == '\n') + { + x = sx; + y += FONT_H+2; + } + else if (*s == '\b') + { + switch (s[1]) + { + case 'w': + r = g = b = 255; + break; + case 'g': + r = g = b = 192; + break; + case 'o': + r = 255; + g = 216; + b = 32; + break; + case 'r': + r = 255; + g = b = 0; + break; + case 'b': + r = g = 0; + b = 255; + break; + } + s++; + } + else + x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); + } #endif - return x; + return x; } int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, int b, int a) { #ifdef OpenGL #else - int sx = x; - int rh = 12; - int rw = 0; - int cw = x; - for(; *s; s++) - { - if(*s == '\n') - { - x = sx; - rw = 0; - y += FONT_H+2; - } - else if(*s == '\b') - { - switch(s[1]) - { - case 'w': - r = g = b = 255; - break; - case 'g': - r = g = b = 192; - break; - case 'o': - r = 255; - g = 216; - b = 32; - break; - case 'r': - r = 255; - g = b = 0; - break; - case 'b': - r = g = 0; - b = 255; - break; - } - s++; - } - else - { - if(x-cw>=w) { - x = sx; - rw = 0; - y+=FONT_H+2; - rh+=FONT_H+2; - } - x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); - } - } + int sx = x; + int rh = 12; + int rw = 0; + int cw = x; + for (; *s; s++) + { + if (*s == '\n') + { + x = sx; + rw = 0; + y += FONT_H+2; + } + else if (*s == '\b') + { + switch (s[1]) + { + case 'w': + r = g = b = 255; + break; + case 'g': + r = g = b = 192; + break; + case 'o': + r = 255; + g = 216; + b = 32; + break; + case 'r': + r = 255; + g = b = 0; + break; + case 'b': + r = g = 0; + b = 255; + break; + } + s++; + } + else + { + if (x-cw>=w) { + x = sx; + rw = 0; + y+=FONT_H+2; + rh+=FONT_H+2; + } + x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); + } + } #endif - return rh; + return rh; } void drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a) { #ifdef OpenGL - glBegin(GL_LINE_LOOP); - glColor4ub(r, g, b, a); - glVertex2i(x, y); - glVertex2i(x+w, y); - glVertex2i(x+w, y+h); - glVertex2i(x, y+h); - glEnd(); + glBegin(GL_LINE_LOOP); + glColor4ub(r, g, b, a); + glVertex2i(x, y); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + glEnd(); #else - int i; - for(i=0; i<=w; i++) - { - drawpixel(vid, x+i, y, r, g, b, a); - drawpixel(vid, x+i, y+h, r, g, b, a); - } - for(i=1; i=w && x+textwidth(s)>=w+5) - break; - x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); - } - if(*s) - for(i=0; i<3; i++) - x = drawchar(vid, x, y, '.', r, g, b, a); - return x; + int i; + w += x-5; + for (; *s; s++) + { + if (x+font_data[font_ptrs[(int)(*(unsigned char *)s)]]>=w && x+textwidth(s)>=w+5) + break; + x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a); + } + if (*s) + for (i=0; i<3; i++) + x = drawchar(vid, x, y, '.', r, g, b, a); + return x; } int textnwidth(char *s, int n) { - int x = 0; - for(; *s; s++) - { - if(!n) - break; - x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - n--; - } - return x-1; + int x = 0; + for (; *s; s++) + { + if (!n) + break; + x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + n--; + } + return x-1; } void textnpos(char *s, int n, int w, int *cx, int *cy) { - int x = 0; + int x = 0; int y = 0; //TODO: Implement Textnheight for wrapped text - for(; *s; s++) - { - if(!n){ - break; + for (; *s; s++) + { + if (!n) { + break; } - x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - if(x>=w) { + x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if (x>=w) { x = 0; y += FONT_H+2; } - n--; - } - *cx = x-1; + n--; + } + *cx = x-1; *cy = y; } int textwidthx(char *s, int w) { - int x=0,n=0,cw; - for(; *s; s++) - { - cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - if(x+(cw/2) >= w) - break; - x += cw; - n++; - } - return n; + int x=0,n=0,cw; + for (; *s; s++) + { + cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if (x+(cw/2) >= w) + break; + x += cw; + n++; + } + return n; } int textposxy(char *s, int width, int w, int h) { - int x=0,y=0,n=0,cw; - for(; *s; s++) - { - cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; - if(x+(cw/2) >= w && y+6 >= h) - break; - x += cw; - if(x>=width) { + int x=0,y=0,n=0,cw; + for (; *s; s++) + { + cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if (x+(cw/2) >= w && y+6 >= h) + break; + x += cw; + if (x>=width) { x = 0; y += FONT_H+2; } - n++; - } - return n; + n++; + } + return n; } #if defined(WIN32) && !defined(__GNUC__) @@ -1064,1513 +1064,1470 @@ inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a) #endif { #ifdef OpenGL - if(x<0 || y<0 || x>=XRES || r>=YRES) - return; - if(a!=255) - { - glBegin (GL_QUADS); - glColor4ub(r,g,b,a); - glVertex2i(x, y); - } - vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); + if (x<0 || y<0 || x>=XRES || r>=YRES) + return; + if (a!=255) + { + glBegin (GL_QUADS); + glColor4ub(r,g,b,a); + glVertex2i(x, y); + } + vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); #else - pixel t; - if(x<0 || y<0 || x>=XRES || y>=YRES) - return; - if(a!=255) - { - t = vid[y*(XRES+BARSIZE)+x]; - r = (a*r + (255-a)*PIXR(t)) >> 8; - g = (a*g + (255-a)*PIXG(t)) >> 8; - b = (a*b + (255-a)*PIXB(t)) >> 8; - } - vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); + pixel t; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return; + if (a!=255) + { + t = vid[y*(XRES+BARSIZE)+x]; + r = (a*r + (255-a)*PIXR(t)) >> 8; + g = (a*g + (255-a)*PIXG(t)) >> 8; + b = (a*b + (255-a)*PIXB(t)) >> 8; + } + vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); #endif //OpenGL } void draw_icon(pixel *vid_buf, int x, int y, char ch, int flag) { - char t[2]; - t[0] = ch; - t[1] = 0; - if(flag) - { - fillrect(vid_buf, x-1, y-1, 17, 17, 255, 255, 255, 255); - drawtext(vid_buf, x+3, y+2, t, 0, 0, 0, 255); - } - else - { - drawrect(vid_buf, x, y, 15, 15, 255, 255, 255, 255); - drawtext(vid_buf, x+3, y+2, t, 255, 255, 255, 255); - } + char t[2]; + t[0] = ch; + t[1] = 0; + if (flag) + { + fillrect(vid_buf, x-1, y-1, 17, 17, 255, 255, 255, 255); + drawtext(vid_buf, x+3, y+2, t, 0, 0, 0, 255); + } + else + { + drawrect(vid_buf, x, y, 15, 15, 255, 255, 255, 255); + drawtext(vid_buf, x+3, y+2, t, 255, 255, 255, 255); + } } void draw_air(pixel *vid) { - int x, y, i, j; - pixel c; + int x, y, i, j; + pixel c; - if(cmode == CM_PERS) - return; + if (cmode == CM_PERS) + return; - for(y=0; y 0.0f) - c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0); - else - c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f)); - } - else if(cmode == CM_VEL) + for (y=0; y 0.0f) + if (cmode == CM_PRESS) { - r += clamp_flt(pv[y][x], 0.0f, 16.0f); - if(r>255) - r=255; - if(g>255) - g=255; - if(b>255) - b=255; - c = PIXRGB(r, g, b); + if (pv[y][x] > 0.0f) + c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0); + else + c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f)); } - else + else if (cmode == CM_VEL) { - b += clamp_flt(-pv[y][x], 0.0f, 16.0f); - if(r>255) - r=255; - if(g>255) - g=255; - if(b>255) - b=255; - c = PIXRGB(r, g, b); + c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f), + clamp_flt(pv[y][x], 0.0f, 8.0f), + clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f)); } + else if (cmode == CM_CRACK) + { + int r; + int g; + int b; + r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f); + g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f); + b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f); + if (pv[y][x] > 0.0f) + { + r += clamp_flt(pv[y][x], 0.0f, 16.0f); + if (r>255) + r=255; + if (g>255) + g=255; + if (b>255) + b=255; + c = PIXRGB(r, g, b); + } + else + { + b += clamp_flt(-pv[y][x], 0.0f, 16.0f); + if (r>255) + r=255; + if (g>255) + g=255; + if (b>255) + b=255; + c = PIXRGB(r, g, b); + } + } + for (j=0; jdx) - { - dx = dx+dy; - dy = dx-dy; - dx = dx-dy; - check = 1; - } + if (dy>dx) + { + dx = dx+dy; + dy = dx-dy; + dx = dx-dy; + check = 1; + } - e = (dy<<2)-dx; - for (i=0; i<=dx; i++) - { - vid[x+y*a] =PIXRGB(r, g, b); - if (e>=0) - { - if (check==1) - x = x+sx; - else - y = y+sy; - e = e-(dx<<2); - } - if (check==1) - y = y+sy; - else - x = x+sx; - e = e+(dy<<2); - } + e = (dy<<2)-dx; + for (i=0; i<=dx; i++) + { + vid[x+y*a] =PIXRGB(r, g, b); + if (e>=0) + { + if (check==1) + x = x+sx; + else + y = y+sy; + e = e-(dx<<2); + } + if (check==1) + y = y+sy; + else + x = x+sx; + e = e+(dy<<2); + } } void addpixel(pixel *vid, int x, int y, int r, int g, int b, int a) { - pixel t; - if(x<0 || y<0 || x>=XRES || y>=YRES) - return; - t = vid[y*(XRES+BARSIZE)+x]; - r = (a*r + 255*PIXR(t)) >> 8; - g = (a*g + 255*PIXG(t)) >> 8; - b = (a*b + 255*PIXB(t)) >> 8; - if(r>255) - r = 255; - if(g>255) - g = 255; - if(b>255) - b = 255; - vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); + pixel t; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return; + t = vid[y*(XRES+BARSIZE)+x]; + r = (a*r + 255*PIXR(t)) >> 8; + g = (a*g + 255*PIXG(t)) >> 8; + b = (a*b + 255*PIXB(t)) >> 8; + if (r>255) + r = 255; + if (g>255) + g = 255; + if (b>255) + b = 255; + vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); } void xor_pixel(int x, int y, pixel *vid) { - int c; - if(x<0 || y<0 || x>=XRES || y>=YRES) - return; - c = vid[y*(XRES+BARSIZE)+x]; - c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c); - if(c<512) - vid[y*(XRES+BARSIZE)+x] = PIXPACK(0xC0C0C0); - else - vid[y*(XRES+BARSIZE)+x] = PIXPACK(0x404040); + int c; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return; + c = vid[y*(XRES+BARSIZE)+x]; + c = PIXB(c) + 3*PIXG(c) + 2*PIXR(c); + if (c<512) + vid[y*(XRES+BARSIZE)+x] = PIXPACK(0xC0C0C0); + else + vid[y*(XRES+BARSIZE)+x] = PIXPACK(0x404040); } void xor_line(int x1, int y1, int x2, int y2, pixel *vid) { - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; - float e, de; - if(cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if(x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if(dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1= 0.5f) - { - y += sy; - e -= 1.0f; - } - } + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + e -= 1.0f; + } + } } void xor_rect(pixel *vid, int x, int y, int w, int h) { - int i; - for(i=0; i(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head - { - sprintf(buff, "%3d", parts[i].life); //Show HP - drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); - } - - for(r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p - { - s = XRES+BARSIZE; - vid[(ny-2)*s+nx+r] = ptypes[(int)player[2]].pcolors; - vid[(ny+2)*s+nx+r+1] = ptypes[(int)player[2]].pcolors; - vid[(ny+r+1)*s+nx-2] = ptypes[(int)player[2]].pcolors; - vid[(ny+r)*s+nx+2] = ptypes[(int)player[2]].pcolors; - } - draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s); - draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s); - draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s); - draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s); - - isplayer = 1; //It's a secret. Tssss... - } - else if(t==PT_STKM2) //Just draw head here - { - char buff[10]; //Buffer for HP - - if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head - { - sprintf(buff, "%3d", parts[i].life); //Show HP - drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); - } - - for(r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p - { - s = XRES+BARSIZE; - vid[(ny-2)*s+nx+r] = ptypes[(int)player2[2]].pcolors; - vid[(ny+2)*s+nx+r+1] = ptypes[(int)player2[2]].pcolors; - vid[(ny+r+1)*s+nx-2] = ptypes[(int)player2[2]].pcolors; - vid[(ny+r)*s+nx+2] = ptypes[(int)player2[2]].pcolors; - } - draw_line(vid , nx, ny+3, player2[3], player2[4], 100, 100, 255, s); - draw_line(vid , player2[3], player2[4], player2[7], player2[8], 100, 100, 255, s); - draw_line(vid , nx, ny+3, player2[11], player2[12], 100, 100, 255, s); - draw_line(vid , player2[11], player2[12], player2[15], player2[16], 100, 100, 255, s); - - isplayer2 = 1; //It's a secret. Tssss... - } - if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes - { - if(t==PT_PHOT) + nx = (int)(parts[i].x+0.5f); + ny = (int)(parts[i].y+0.5f); + if (cmode!=CM_HEAT) { - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else - { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - } - else if(cmode==CM_GRAD)//forgot to put else, broke nothing view - { - float frequency = 0.05; - int q = parts[i].temp-40; - cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors); - cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors); - cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors); - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - if(cr<=0) - cr = 0; - if(cg<=0) - cg = 0; - if(cb<=0) - cb = 0; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else if(cmode==CM_FANCY && - t!=PT_FIRE && t!=PT_PLSM && t!=PT_WTRV && - t!=PT_HFLM && t!=PT_SPRK && t!=PT_FIRW && - t!=PT_DUST && t!=PT_FIRW && t!=PT_FWRK && - t!=PT_NEUT && t!=PT_LAVA && t!=PT_BOMB && - t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE) - { - if(ptypes[parts[i].type].properties&TYPE_LIQUID) - { - if(parts[i].type==PT_DEUT) + if (t==PT_STKM) //Just draw head here { - cr = PIXR(ptypes[t].pcolors) + parts[i].life*1; - cg = PIXG(ptypes[t].pcolors) + parts[i].life*2; - cb = PIXB(ptypes[t].pcolors) + parts[i].life*4; - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - for(x=-1; x<=1; x++) + char buff[10]; //Buffer for HP + + if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head { - for(y=-1; y<=1; y++) - { - if ((abs(x) == 0) && (abs(y) == 0)) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); - else if (abs(y) != 0 || abs(x) != 0) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); - } + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); } - } - else if(parts[i].type==PT_LAVA && parts[i].life) - { - cr = parts[i].life * 2 + 0xE0; - cg = parts[i].life * 1 + 0x50; - cb = parts[i].life/2 + 0x10; - if(cr>255) cr = 255; - if(cg>192) cg = 192; - if(cb>128) cb = 128; - for(x=-1; x<=1; x++) + + for (r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p { - for(y=-1; y<=1; y++) - { - if ((abs(x) == 0) && (abs(y) == 0)) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); - else if (abs(y) != 0 || abs(x) != 0) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); - } + s = XRES+BARSIZE; + vid[(ny-2)*s+nx+r] = ptypes[(int)player[2]].pcolors; + vid[(ny+2)*s+nx+r+1] = ptypes[(int)player[2]].pcolors; + vid[(ny+r+1)*s+nx-2] = ptypes[(int)player[2]].pcolors; + vid[(ny+r)*s+nx+2] = ptypes[(int)player[2]].pcolors; } - } - else if(parts[i].type==PT_GLOW) - { - fg = 0; - fb = 0; - fr = 0; - if(pv[ny/CELL][nx/CELL]>0) { - fg = 6 * pv[ny/CELL][nx/CELL]; - fb = 4 * pv[ny/CELL][nx/CELL]; - fr = 2 * pv[ny/CELL][nx/CELL]; - } - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); + draw_line(vid , nx, ny+3, player[3], player[4], 255, 255, 255, s); + draw_line(vid , player[3], player[4], player[7], player[8], 255, 255, 255, s); + draw_line(vid , nx, ny+3, player[11], player[12], 255, 255, 255, s); + draw_line(vid , player[11], player[12], player[15], player[16], 255, 255, 255, s); - /*x = nx/CELL; - y = ny/CELL; - fg += fire_g[y][x]; - if(fg > 255) fg = 255; - fire_g[y][x] = fg; - fb += fire_b[y][x]; - if(fb > 255) fb = 255; - fire_b[y][x] = fb; - fr += fire_r[y][x]; - if(fr > 255) fr = 255; - fire_r[y][x] = fr;*/ - - cr = (int)restrict_flt(0x44 + fr*8, 0, 255); - cg = (int)restrict_flt(0x88 + fg*8, 0, 255); - cb = (int)restrict_flt(0x44 + fb*8, 0, 255); - for(x=-1; x<=1; x++) + isplayer = 1; //It's a secret. Tssss... + } + else if (t==PT_STKM2) //Just draw head here + { + char buff[10]; //Buffer for HP + + if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head { - for(y=-1; y<=1; y++) - { - if ((abs(x) == 0) && (abs(y) == 0)) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); - else if (abs(y) != 0 || abs(x) != 0) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); - } + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); } - } - else - { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - for(x=-1; x<=1; x++) + + for (r=-2; r<=1; r++) //Here I use r variable not as I should, but I think you will excuse me :-p { - for(y=-1; y<=1; y++) - { - if ((abs(x) == 0) && (abs(y) == 0)) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); - else if (abs(y) != 0 || abs(x) != 0) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); - } + s = XRES+BARSIZE; + vid[(ny-2)*s+nx+r] = ptypes[(int)player2[2]].pcolors; + vid[(ny+2)*s+nx+r+1] = ptypes[(int)player2[2]].pcolors; + vid[(ny+r+1)*s+nx-2] = ptypes[(int)player2[2]].pcolors; + vid[(ny+r)*s+nx+2] = ptypes[(int)player2[2]].pcolors; } - } - } - else if (ptypes[parts[i].type].properties&TYPE_GAS) - { - //if(parts[i].type!=PT_FIRE&&parts[i].type!=PT_SMKE&&parts[i].type!=PT_PLSM&&parts[i].type!=PT_WTRV) + draw_line(vid , nx, ny+3, player2[3], player2[4], 100, 100, 255, s); + draw_line(vid , player2[3], player2[4], player2[7], player2[8], 100, 100, 255, s); + draw_line(vid , nx, ny+3, player2[11], player2[12], 100, 100, 255, s); + draw_line(vid , player2[11], player2[12], player2[15], player2[16], 100, 100, 255, s); + + isplayer2 = 1; //It's a secret. Tssss... + } + if (cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - for(x=-1; x<=1; x++) + if (t==PT_PHOT) { - for(y=-1; y<=1; y++) - { - if ((abs(x) == 0) && (abs(y) == 0)) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,180); - else if (abs(y) != 0 && abs(x) != 0) - blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); - else - blendpixel(vid,x+nx,y+ny,cr,cg,cb,80); + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 255); } - } - } - else if(ptypes[parts[i].type].properties&PROP_RADIOACTIVE) - { - int tempx = 0; - int tempy = 0; - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - //blendpixel(vid, nx, ny, cr, cg, cb, 192); - //blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - //blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - //blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - //blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - addpixel(vid, nx, ny, cr, cg, cb, 192); - addpixel(vid, nx+1, ny, cr, cg, cb, 96); - addpixel(vid, nx-1, ny, cr, cg, cb, 96); - addpixel(vid, nx, ny+1, cr, cg, cb, 96); - addpixel(vid, nx, ny-1, cr, cg, cb, 96); - for(tempx = 2; tempx < 7; tempx++) { - for(tempy = 2; tempy < 7; tempy++) { - addpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5); - addpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5); - addpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5); - addpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); - //blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5); - //blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5); - //blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5); - //blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); - } - } - } - else - { - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - } - } - else if(cmode==CM_LIFE) - { - float frequency = 0.4; - int q; - if(!(parts[i].life<5)) - q = sqrt(parts[i].life); - else - q = parts[i].life; - cr = sin(frequency*q) * 100 + 128; - cg = sin(frequency*q) * 100 + 128; - cb = sin(frequency*q) * 100 + 128; - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - if(cr<=0) - cr = 0; - if(cg<=0) - cg = 0; - if(cb<=0) - cb = 0; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else if(t==PT_QRTZ || t==PT_PQRT) - { - int z = parts[i].tmp - 5; - if(parts[i].temp>(pstates[t].ltemp-800.0f)) - { - float frequency = 3.1415/(2*pstates[t].ltemp-(pstates[t].ltemp-800.0f)); - int q = (parts[i].temp>pstates[t].ltemp)?pstates[t].ltemp-(pstates[t].ltemp-800.0f):parts[i].temp-(pstates[t].ltemp-800.0f); - cr = sin(frequency*q) * 226 + (z * 16 + PIXR(ptypes[t].pcolors)); - cg = sin(frequency*q*4.55 +3.14) * 34 + (z * 16 + PIXR(ptypes[t].pcolors)); - cb = sin(frequency*q*2.22 +3.14) * 64 + (z * 16 + PIXR(ptypes[t].pcolors)); - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - if(cr<=0) - cr = 0; - if(cg<=0) - cg = 0; - if(cb<=0) - cb = 0; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else - { - cr = z * 16 + PIXR(ptypes[t].pcolors); - cg = z * 16 + PIXG(ptypes[t].pcolors); - cb = z * 16 + PIXB(ptypes[t].pcolors); - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - } - else if(t==PT_SPNG) - { - cr = PIXR(ptypes[t].pcolors) - parts[i].life*15; - cg = PIXG(ptypes[t].pcolors) - parts[i].life*15; - cb = PIXB(ptypes[t].pcolors) - parts[i].life*15; - if(cr<=50) - cr = 50; - if(cg<=50) - cg = 50; - if(cb<=20) - cb = 20; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - - } - else if(t==PT_TEST) - { - if(parts[i].tmp==2) - blendpixel(vid, nx, ny, 255, 128, 0, 255); - else if(parts[i].tmp==1) - blendpixel(vid, nx, ny, 255, 255, 0, 255); - else - blendpixel(vid, nx, ny, 255, 0, 0, 255); - } - else if(t==PT_TEST2) - { - if(parts[i].tmp==2) - blendpixel(vid, nx, ny, 0, 100, 50, 255); - else - blendpixel(vid, nx, ny, 0, 255, 90, 255); - } - else if(t==PT_TEST3) - { - if(parts[i].tmp==4) - blendpixel(vid, nx, ny, 0, 0, 128, 255); - else if(parts[i].tmp==3) - blendpixel(vid, nx, ny, 0, 0, 150, 255); - else if(parts[i].tmp==2) - blendpixel(vid, nx, ny, 0, 0, 190, 255); - else if(parts[i].tmp==1) - blendpixel(vid, nx, ny, 0, 0, 230, 255); - else - blendpixel(vid, nx, ny, 0, 0, 70, 255); - } - else if(t==PT_FROG) - { - if(parts[i].tmp==2) - blendpixel(vid, nx, ny, 0, 100, 0, 255); - else - blendpixel(vid, nx, ny, 0, 255, 0, 255); - } - else if(t==PT_BRAN) - { - if(parts[i].tmp==1) - blendpixel(vid, nx, ny, 150, 150, 0, 255); - else - blendpixel(vid, nx, ny, 255, 255, 0, 255); - } - else if(t==PT_DEUT) - { - - if(parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) - { - x = nx/CELL; - y = ny/CELL; - cr = 20; - cg = 20; - cb = 20; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = PIXR(ptypes[t].pcolors) + parts[i].life*1; - cg = PIXG(ptypes[t].pcolors) + parts[i].life*2; - cb = PIXB(ptypes[t].pcolors) + parts[i].life*4; - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - - } - - } - else if(t==PT_DUST && parts[i].life >= 1) - { - x = nx; - y = ny; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags); - cg = parts[i].tmp/4; - cb = parts[i].ctype/4; - cr = parts[i].flags/4; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255); - } - else if(t==PT_GRAV) - { - cr = 20; - cg = 20; - cb = 20; - if(parts[i].vx>0) - { - cr += (parts[i].vx)*GRAV_R; - cg += (parts[i].vx)*GRAV_G; - cb += (parts[i].vx)*GRAV_B; - } - if(parts[i].vy>0) - { - cr += (parts[i].vy)*GRAV_G; - cg += (parts[i].vy)*GRAV_B; - cb += (parts[i].vy)*GRAV_R; - - } - if(parts[i].vx<0) - { - cr -= (parts[i].vx)*GRAV_B; - cg -= (parts[i].vx)*GRAV_R; - cb -= (parts[i].vx)*GRAV_G; - - } - if(parts[i].vy<0) - { - cr -= (parts[i].vy)*GRAV_R2; - cg -= (parts[i].vy)*GRAV_G2; - cb -= (parts[i].vy)*GRAV_B2; - } - if(cr>255) - cr=255; - if(cg>255) - cg=255; - if(cb>255) - cb=255; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else if(t==PT_WIFI) - { - float frequency = 0.0628; - int q = parts[i].tmp; - cr = sin(frequency*q + 0) * 127 + 128; - cg = sin(frequency*q + 2) * 127 + 128; - cb = sin(frequency*q + 4) * 127 + 128; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - if(mousex==(nx) && mousey==(ny) && DEBUG_MODE) - { - int z; - for(z = 0; z> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) { - fg = 0; - fb = 0; - fr = 0; - fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy); - fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy); - fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy); - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255)); - x = nx/CELL; - y = ny/CELL; - fg += fire_g[y][x]; - if(fg > 255) fg = 255; - fire_g[y][x] = fg; - fb += fire_b[y][x]; - if(fb > 255) fb = 255; - fire_b[y][x] = fb; - fr += fire_r[y][x]; - if(fr > 255) fr = 255; - fire_r[y][x] = fr; - } - else - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else if(t==PT_PIPE) - { - if(parts[i].ctype==2) - { - cr = 50; - cg = 1; - cb = 1; - } - else if(parts[i].ctype==3) - { - cr = 1; - cg = 50; - cb = 1; - } - else if(parts[i].ctype==4) - { - cr = 1; - cg = 1; - cb = 50; - } - else if(parts[i].temp<272.15&&parts[i].ctype!=1) - { - if(parts[i].temp>173.25&&parts[i].temp<273.15) - { - cr = 50; - cg = 1; - cb = 1; - } - if(parts[i].temp>73.25&&parts[i].temp<=173.15) - { - cr = 1; - cg = 50; - cb = 1; - } - if(parts[i].temp>=0&&parts[i].temp<=73.15) - { - cr = 1; - cg = 1; - cb = 50; - } - } - else - { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - } - if(parts[i].tmp) - { - cr = PIXR(ptypes[parts[i].tmp].pcolors); - cg = PIXG(ptypes[parts[i].tmp].pcolors); - cb = PIXB(ptypes[parts[i].tmp].pcolors); - } - blendpixel(vid, nx, ny, cr, cg, cb, 255); - - - - } - else if(t==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) - { - blendpixel(vid, nx, ny, 15, 0, 150, 100); - } - else if(t==PT_ACID) - { - if(parts[i].life>75) parts[i].life = 75; - if(parts[i].life<49) parts[i].life = 49; - s = (parts[i].life-49)*3; - if(s==0) s = 1; - cr = 0x86 + s*4; - cg = 0x36 + s*1; - cb = 0x90 + s*2; - - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - - blendpixel(vid, nx, ny, cr, cg, cb, 255); - - if(cmode==CM_BLOB) - { - blendpixel(vid, nx+1, ny, cr, cg, cb, 223); - blendpixel(vid, nx-1, ny, cr, cg, cb, 223); - blendpixel(vid, nx, ny+1, cr, cg, cb, 223); - blendpixel(vid, nx, ny-1, cr, cg, cb, 223); - - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); - } - } - else if(t==PT_NEUT) - { - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - cg = 8; - cb = 12; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - else - { - cr = 0x20; - cg = 0xE0; - cb = 0xFF; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } - else if(t==PT_FILT) - { - int temp_bin = (int)((parts[i].temp-273.0f)*0.025f); - if(temp_bin < 0) temp_bin = 0; - if(temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, 127); - } - else if(t==PT_BRAY && parts[i].tmp==0) - { - int trans = parts[i].life * 7; - if(parts[i].ctype){ - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, trans); - }else - blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); - } - else if(t==PT_BRAY && parts[i].tmp==1) - { - int trans = parts[i].life/4; - if(parts[i].ctype){ - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, trans); - }else - blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); - } - else if(t==PT_BRAY && parts[i].tmp==2) - { - int trans = parts[i].life*100; - blendpixel(vid, nx, ny, 255, 150, 50, trans); - } - else if(t==PT_PHOT) - { - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr>255?255:cr,cg>255?255:cg,cb>255?255:cb); - cr >>= 4; - cg >>= 4; - cb >>= 4; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } - //Life can be 11 too, so don't just check for 10 - else if(t==PT_SWCH && parts[i].life >= 10) - { - x = nx; - y = ny; - blendpixel(vid,x,y,17,217,24,255); - } - else if(t==PT_SMKE) - { - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - x = nx/CELL; - y = ny/CELL; - cg = 10; - cb = 10; - cr = 10; - cg += fire_g[y][x]; - if(cg > 50) cg = 50; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 50) cb = 50; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 50) cr = 50; - fire_r[y][x] = cr; - } - else - { - for(x=-3; x<4; x++) - { - for(y=-3; y<4; y++) - { - if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) - blendpixel(vid,x+nx,y+ny,100,100,100,30); - if(abs(x)+abs(y) <=3 && abs(x)+abs(y)) - blendpixel(vid,x+nx,y+ny,100,100,100,10); - if (abs(x)+abs(y) == 2) - blendpixel(vid,x+nx,y+ny,100,100,100,20); - } - } - } - } - else if(t==PT_WTRV) - { - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - x = nx/CELL; - y = ny/CELL; - cg = PIXG(ptypes[t].pcolors)/3; - cb = PIXB(ptypes[t].pcolors)/3; - cr = PIXR(ptypes[t].pcolors)/3; - cg += fire_g[y][x]; - if(cg > PIXG(ptypes[t].pcolors)/2) cg = PIXG(ptypes[t].pcolors)/2; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > PIXB(ptypes[t].pcolors)/2) cb = PIXB(ptypes[t].pcolors)/2; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > PIXR(ptypes[t].pcolors)/2) cr = PIXR(ptypes[t].pcolors)/2; - fire_r[y][x] = cr; - } - else - { - for(x=-3; x<4; x++) - { - for(y=-3; y<4; y++) - { - if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) - blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 30); - if(abs(x)+abs(y) <=3 && abs(x)+abs(y)) - blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 10); - if (abs(x)+abs(y) == 2) - blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 20); - } - } - } - } - else if(t==PT_THDR) - { - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - cg = 16; - cb = 20; - cr = 12; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = 0xFF; - cg = 0xFF; - cb = 0xA0; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } - else if(t==PT_GLOW) - { - fg = 0; - fb = 0; - fr = 0; - if(pv[ny/CELL][nx/CELL]>0) { - fg = 6 * pv[ny/CELL][nx/CELL]; - fb = 4 * pv[ny/CELL][nx/CELL]; - fr = 2 * pv[ny/CELL][nx/CELL]; - } - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - x = nx/CELL; - y = ny/CELL; - fg += fire_g[y][x]; - if(fg > 255) fg = 255; - fire_g[y][x] = fg; - fb += fire_b[y][x]; - if(fb > 255) fb = 255; - fire_b[y][x] = fb; - fr += fire_r[y][x]; - if(fr > 255) fr = 255; - fire_r[y][x] = fr; - } - if(cmode == CM_BLOB) { - uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255); - uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255); - uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255); - - blendpixel(vid, nx+1, ny, R, G, B, 223); - blendpixel(vid, nx-1, ny, R, G, B, 223); - blendpixel(vid, nx, ny+1, R, G, B, 223); - blendpixel(vid, nx, ny-1, R, G, B, 223); - - blendpixel(vid, nx+1, ny-1, R, G, B, 112); - blendpixel(vid, nx-1, ny-1, R, G, B, 112); - blendpixel(vid, nx+1, ny+1, R, G, B, 112); - blendpixel(vid, nx-1, ny+1, R, G, B, 112); - } - } - else if(t==PT_LCRY) - { - uint8 GR = 0x50+(parts[i].life*10); - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, GR); - if(cmode == CM_BLOB) { - blendpixel(vid, nx+1, ny, GR, GR, GR, 223); - blendpixel(vid, nx-1, ny, GR, GR, GR, 223); - blendpixel(vid, nx, ny+1, GR, GR, GR, 223); - blendpixel(vid, nx, ny-1, GR, GR, GR, 223); - - blendpixel(vid, nx+1, ny-1, GR, GR, GR, 112); - blendpixel(vid, nx-1, ny-1, GR, GR, GR, 112); - blendpixel(vid, nx+1, ny+1, GR, GR, GR, 112); - blendpixel(vid, nx-1, ny+1, GR, GR, GR, 112); - } - } - else if(t==PT_PCLN) - { - uint8 GR = 0x3B+(parts[i].life*19); - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, 10); - if(cmode == CM_BLOB) { - blendpixel(vid, nx+1, ny, GR, GR, 10, 223); - blendpixel(vid, nx-1, ny, GR, GR, 10, 223); - blendpixel(vid, nx, ny+1, GR, GR, 10, 223); - blendpixel(vid, nx, ny-1, GR, GR, 10, 223); - - blendpixel(vid, nx+1, ny-1, GR, GR, 10, 112); - blendpixel(vid, nx-1, ny-1, GR, GR, 10, 112); - blendpixel(vid, nx+1, ny+1, GR, GR, 10, 112); - blendpixel(vid, nx-1, ny+1, GR, GR, 10, 112); - } - } - else if(t==PT_HSWC) - { - uint8 GR = 0x3B+(parts[i].life*19); - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, 10, 10); - if(cmode == CM_BLOB) { - blendpixel(vid, nx+1, ny, GR, 10, 10, 223); - blendpixel(vid, nx-1, ny, GR, 10, 10, 223); - blendpixel(vid, nx, ny+1, GR, 10, 10, 223); - blendpixel(vid, nx, ny-1, GR, 10, 10, 223); - - blendpixel(vid, nx+1, ny-1, GR, 10, 10, 112); - blendpixel(vid, nx-1, ny-1, GR, 10, 10, 112); - blendpixel(vid, nx+1, ny+1, GR, 10, 10, 112); - blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112); - } - } - else if(t==PT_PUMP) - { - uint8 GR = 0x3B+(parts[i].life*19); - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR); - if(cmode == CM_BLOB) { - blendpixel(vid, nx+1, ny, 10, 10, GR, 223); - blendpixel(vid, nx-1, ny, 10, 10, GR, 223); - blendpixel(vid, nx, ny+1, 10, 10, GR, 223); - blendpixel(vid, nx, ny-1, 10, 10, GR, 223); - - blendpixel(vid, nx+1, ny-1, 10, 10, GR, 112); - blendpixel(vid, nx-1, ny-1, 10, 10, GR, 112); - blendpixel(vid, nx+1, ny+1, 10, 10, GR, 112); - blendpixel(vid, nx-1, ny+1, 10, 10, GR, 112); - } - } - else if(t==PT_PLSM) - { - float ttemp = (float)parts[i].life; - int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - uint8 R = plasma_data[caddress]; - uint8 G = plasma_data[caddress+1]; - uint8 B = plasma_data[caddress+2]; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cr = R/8; - cg = G/8; - cb = B/8; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = R; - cg = G; - cb = B; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } else if(t==PT_HFLM) - { - float ttemp = (float)parts[i].life; - int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - uint8 R = hflm_data[caddress]; - uint8 G = hflm_data[caddress+1]; - uint8 B = hflm_data[caddress+2]; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cr = R/8; - cg = G/8; - cb = B/8; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = R; - cg = G; - cb = B; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } else if(t==PT_FIRW&&parts[i].tmp>=3) - { - float ttemp = (float)parts[i].tmp-4; - int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - uint8 R = firw_data[caddress]; - uint8 G = firw_data[caddress+1]; - uint8 B = firw_data[caddress+2]; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cr = R/2; - cg = G/2; - cb = B/2; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = R; - cg = G; - cb = B; - blendpixel(vid, nx, ny, cr, cg, cb, 192); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - } - else if(t==PT_BOMB) - { - if(parts[i].tmp==0){ + else + { cr = PIXR(ptypes[t].pcolors); cg = PIXG(ptypes[t].pcolors); cb = PIXB(ptypes[t].pcolors); - if(cmode != CM_CRACK){ + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + } + else if (cmode==CM_GRAD)//forgot to put else, broke nothing view + { + float frequency = 0.05; + int q = parts[i].temp-40; + cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors); + cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors); + cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors); + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + if (cr<=0) + cr = 0; + if (cg<=0) + cg = 0; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if (cmode==CM_FANCY && + t!=PT_FIRE && t!=PT_PLSM && t!=PT_WTRV && + t!=PT_HFLM && t!=PT_SPRK && t!=PT_FIRW && + t!=PT_DUST && t!=PT_FIRW && t!=PT_FWRK && + t!=PT_NEUT && t!=PT_LAVA && t!=PT_BOMB && + t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE) + { + if (ptypes[parts[i].type].properties&TYPE_LIQUID) + { + if (parts[i].type==PT_DEUT) + { + cr = PIXR(ptypes[t].pcolors) + parts[i].life*1; + cg = PIXG(ptypes[t].pcolors) + parts[i].life*2; + cb = PIXB(ptypes[t].pcolors) + parts[i].life*4; + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + for (x=-1; x<=1; x++) + { + for (y=-1; y<=1; y++) + { + if ((abs(x) == 0) && (abs(y) == 0)) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); + else if (abs(y) != 0 || abs(x) != 0) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); + } + } + } + else if (parts[i].type==PT_LAVA && parts[i].life) + { + cr = parts[i].life * 2 + 0xE0; + cg = parts[i].life * 1 + 0x50; + cb = parts[i].life/2 + 0x10; + if (cr>255) cr = 255; + if (cg>192) cg = 192; + if (cb>128) cb = 128; + for (x=-1; x<=1; x++) + { + for (y=-1; y<=1; y++) + { + if ((abs(x) == 0) && (abs(y) == 0)) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); + else if (abs(y) != 0 || abs(x) != 0) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); + } + } + } + else if (parts[i].type==PT_GLOW) + { + fg = 0; + fb = 0; + fr = 0; + if (pv[ny/CELL][nx/CELL]>0) { + fg = 6 * pv[ny/CELL][nx/CELL]; + fb = 4 * pv[ny/CELL][nx/CELL]; + fr = 2 * pv[ny/CELL][nx/CELL]; + } + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); + + /*x = nx/CELL; + y = ny/CELL; + fg += fire_g[y][x]; + if(fg > 255) fg = 255; + fire_g[y][x] = fg; + fb += fire_b[y][x]; + if(fb > 255) fb = 255; + fire_b[y][x] = fb; + fr += fire_r[y][x]; + if(fr > 255) fr = 255; + fire_r[y][x] = fr;*/ + + cr = (int)restrict_flt(0x44 + fr*8, 0, 255); + cg = (int)restrict_flt(0x88 + fg*8, 0, 255); + cb = (int)restrict_flt(0x44 + fb*8, 0, 255); + for (x=-1; x<=1; x++) + { + for (y=-1; y<=1; y++) + { + if ((abs(x) == 0) && (abs(y) == 0)) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); + else if (abs(y) != 0 || abs(x) != 0) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); + } + } + } + else + { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + for (x=-1; x<=1; x++) + { + for (y=-1; y<=1; y++) + { + if ((abs(x) == 0) && (abs(y) == 0)) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,100); + else if (abs(y) != 0 || abs(x) != 0) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); + } + } + } + } + else if (ptypes[parts[i].type].properties&TYPE_GAS) + { + //if(parts[i].type!=PT_FIRE&&parts[i].type!=PT_SMKE&&parts[i].type!=PT_PLSM&&parts[i].type!=PT_WTRV) + { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + for (x=-1; x<=1; x++) + { + for (y=-1; y<=1; y++) + { + if ((abs(x) == 0) && (abs(y) == 0)) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,180); + else if (abs(y) != 0 && abs(x) != 0) + blendpixel(vid,x+nx,y+ny,cr,cg,cb,50); + else + blendpixel(vid,x+nx,y+ny,cr,cg,cb,80); + } + } + } + } + else if (ptypes[parts[i].type].properties&PROP_RADIOACTIVE) + { + int tempx = 0; + int tempy = 0; + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + //blendpixel(vid, nx, ny, cr, cg, cb, 192); + //blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + //blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + //blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + //blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + addpixel(vid, nx, ny, cr, cg, cb, 192); + addpixel(vid, nx+1, ny, cr, cg, cb, 96); + addpixel(vid, nx-1, ny, cr, cg, cb, 96); + addpixel(vid, nx, ny+1, cr, cg, cb, 96); + addpixel(vid, nx, ny-1, cr, cg, cb, 96); + for (tempx = 2; tempx < 7; tempx++) { + for (tempy = 2; tempy < 7; tempy++) { + addpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5); + addpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5); + addpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5); + addpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); + //blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5); + //blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5); + //blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5); + //blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); + } + } + } + else + { + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + } + } + else if (cmode==CM_LIFE) + { + float frequency = 0.4; + int q; + if (!(parts[i].life<5)) + q = sqrt(parts[i].life); + else + q = parts[i].life; + cr = sin(frequency*q) * 100 + 128; + cg = sin(frequency*q) * 100 + 128; + cb = sin(frequency*q) * 100 + 128; + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + if (cr<=0) + cr = 0; + if (cg<=0) + cg = 0; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if (t==PT_QRTZ || t==PT_PQRT) + { + int z = parts[i].tmp - 5; + if (parts[i].temp>(ptransitions[t].thv-800.0f)) + { + float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); + int q = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); + cr = sin(frequency*q) * 226 + (z * 16 + PIXR(ptypes[t].pcolors)); + cg = sin(frequency*q*4.55 +3.14) * 34 + (z * 16 + PIXR(ptypes[t].pcolors)); + cb = sin(frequency*q*2.22 +3.14) * 64 + (z * 16 + PIXR(ptypes[t].pcolors)); + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + if (cr<=0) + cr = 0; + if (cg<=0) + cg = 0; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else + { + cr = z * 16 + PIXR(ptypes[t].pcolors); + cg = z * 16 + PIXG(ptypes[t].pcolors); + cb = z * 16 + PIXB(ptypes[t].pcolors); + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + } + else if (t==PT_SPNG) + { + cr = PIXR(ptypes[t].pcolors) - parts[i].life*15; + cg = PIXG(ptypes[t].pcolors) - parts[i].life*15; + cb = PIXB(ptypes[t].pcolors) - parts[i].life*15; + if (cr<=50) + cr = 50; + if (cg<=50) + cg = 50; + if (cb<=20) + cb = 20; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + } + else if (t==PT_DEUT) + { + + if (parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) + { + x = nx/CELL; + y = ny/CELL; + cr = 20; + cg = 20; + cb = 20; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = PIXR(ptypes[t].pcolors) + parts[i].life*1; + cg = PIXG(ptypes[t].pcolors) + parts[i].life*2; + cb = PIXB(ptypes[t].pcolors) + parts[i].life*4; + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + } + + } + else if (t==PT_DUST && parts[i].life >= 1) + { + x = nx; + y = ny; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags); + cg = parts[i].tmp/4; + cb = parts[i].ctype/4; + cr = parts[i].flags/4; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255); + } + else if (t==PT_GRAV) + { + cr = 20; + cg = 20; + cb = 20; + if (parts[i].vx>0) + { + cr += (parts[i].vx)*GRAV_R; + cg += (parts[i].vx)*GRAV_G; + cb += (parts[i].vx)*GRAV_B; + } + if (parts[i].vy>0) + { + cr += (parts[i].vy)*GRAV_G; + cg += (parts[i].vy)*GRAV_B; + cb += (parts[i].vy)*GRAV_R; + + } + if (parts[i].vx<0) + { + cr -= (parts[i].vx)*GRAV_B; + cg -= (parts[i].vx)*GRAV_R; + cb -= (parts[i].vx)*GRAV_G; + + } + if (parts[i].vy<0) + { + cr -= (parts[i].vy)*GRAV_R2; + cg -= (parts[i].vy)*GRAV_G2; + cb -= (parts[i].vy)*GRAV_B2; + } + if (cr>255) + cr=255; + if (cg>255) + cg=255; + if (cb>255) + cb=255; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if (t==PT_WIFI) + { + float frequency = 0.0628; + int q = parts[i].tmp; + cr = sin(frequency*q + 0) * 127 + 128; + cg = sin(frequency*q + 2) * 127 + 128; + cb = sin(frequency*q + 4) * 127 + 128; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + if (mousex==(nx) && mousey==(ny) && DEBUG_MODE) + { + int z; + for (z = 0; z> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + if (fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) { + fg = 0; + fb = 0; + fr = 0; + fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy); + fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy); + fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255)); + x = nx/CELL; + y = ny/CELL; + fg += fire_g[y][x]; + if (fg > 255) fg = 255; + fire_g[y][x] = fg; + fb += fire_b[y][x]; + if (fb > 255) fb = 255; + fire_b[y][x] = fb; + fr += fire_r[y][x]; + if (fr > 255) fr = 255; + fire_r[y][x] = fr; + } + else + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if (t==PT_PIPE) + { + if (parts[i].ctype==2) + { + cr = 50; + cg = 1; + cb = 1; + } + else if (parts[i].ctype==3) + { + cr = 1; + cg = 50; + cb = 1; + } + else if (parts[i].ctype==4) + { + cr = 1; + cg = 1; + cb = 50; + } + else if (parts[i].temp<272.15&&parts[i].ctype!=1) + { + if (parts[i].temp>173.25&&parts[i].temp<273.15) + { + cr = 50; + cg = 1; + cb = 1; + } + if (parts[i].temp>73.25&&parts[i].temp<=173.15) + { + cr = 1; + cg = 50; + cb = 1; + } + if (parts[i].temp>=0&&parts[i].temp<=73.15) + { + cr = 1; + cg = 1; + cb = 50; + } + } + else + { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + } + if (parts[i].tmp) + { + cr = PIXR(ptypes[parts[i].tmp].pcolors); + cg = PIXG(ptypes[parts[i].tmp].pcolors); + cb = PIXB(ptypes[parts[i].tmp].pcolors); + } + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + + + } + else if (t==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) + { + blendpixel(vid, nx, ny, 15, 0, 150, 100); + } + else if (t==PT_ACID) + { + if (parts[i].life>75) parts[i].life = 75; + if (parts[i].life<49) parts[i].life = 49; + s = (parts[i].life-49)*3; + if (s==0) s = 1; + cr = 0x86 + s*4; + cg = 0x36 + s*1; + cb = 0x90 + s*2; + + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + if (cmode==CM_BLOB) + { + blendpixel(vid, nx+1, ny, cr, cg, cb, 223); + blendpixel(vid, nx-1, ny, cr, cg, cb, 223); + blendpixel(vid, nx, ny+1, cr, cg, cb, 223); + blendpixel(vid, nx, ny-1, cr, cg, cb, 223); + + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); + } + } + else if (t==PT_NEUT) + { + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + cg = 8; + cb = 12; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + else + { + cr = 0x20; + cg = 0xE0; + cb = 0xFF; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } + else if (t==PT_FILT) + { + int temp_bin = (int)((parts[i].temp-273.0f)*0.025f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 127); + } + else if (t==PT_BRAY && parts[i].tmp==0) + { + int trans = parts[i].life * 7; + if (parts[i].ctype) { + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, trans); + } else + blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); + } + else if (t==PT_BRAY && parts[i].tmp==1) + { + int trans = parts[i].life/4; + if (parts[i].ctype) { + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, trans); + } else + blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); + } + else if (t==PT_BRAY && parts[i].tmp==2) + { + int trans = parts[i].life*100; + blendpixel(vid, nx, ny, 255, 150, 50, trans); + } + else if (t==PT_PHOT) + { + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr>255?255:cr,cg>255?255:cg,cb>255?255:cb); + cr >>= 4; + cg >>= 4; + cb >>= 4; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } + //Life can be 11 too, so don't just check for 10 + else if (t==PT_SWCH && parts[i].life >= 10) + { + x = nx; + y = ny; + blendpixel(vid,x,y,17,217,24,255); + } + else if (t==PT_SMKE) + { + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + x = nx/CELL; + y = ny/CELL; + cg = 10; + cb = 10; + cr = 10; + cg += fire_g[y][x]; + if (cg > 50) cg = 50; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 50) cb = 50; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 50) cr = 50; + fire_r[y][x] = cr; + } + else + { + for (x=-3; x<4; x++) + { + for (y=-3; y<4; y++) + { + if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) + blendpixel(vid,x+nx,y+ny,100,100,100,30); + if (abs(x)+abs(y) <=3 && abs(x)+abs(y)) + blendpixel(vid,x+nx,y+ny,100,100,100,10); + if (abs(x)+abs(y) == 2) + blendpixel(vid,x+nx,y+ny,100,100,100,20); + } + } + } + } + else if (t==PT_WTRV) + { + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + x = nx/CELL; + y = ny/CELL; + cg = PIXG(ptypes[t].pcolors)/3; + cb = PIXB(ptypes[t].pcolors)/3; + cr = PIXR(ptypes[t].pcolors)/3; + cg += fire_g[y][x]; + if (cg > PIXG(ptypes[t].pcolors)/2) cg = PIXG(ptypes[t].pcolors)/2; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > PIXB(ptypes[t].pcolors)/2) cb = PIXB(ptypes[t].pcolors)/2; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > PIXR(ptypes[t].pcolors)/2) cr = PIXR(ptypes[t].pcolors)/2; + fire_r[y][x] = cr; + } + else + { + for (x=-3; x<4; x++) + { + for (y=-3; y<4; y++) + { + if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) + blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 30); + if (abs(x)+abs(y) <=3 && abs(x)+abs(y)) + blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 10); + if (abs(x)+abs(y) == 2) + blendpixel(vid,x+nx,y+ny, PIXR(ptypes[t].pcolors)/1.6, PIXG(ptypes[t].pcolors)/1.6, PIXB(ptypes[t].pcolors)/1.6, 20); + } + } + } + } + else if (t==PT_THDR) + { + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + cg = 16; + cb = 20; + cr = 12; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = 0xFF; + cg = 0xFF; + cb = 0xA0; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } + else if (t==PT_GLOW) + { + fg = 0; + fb = 0; + fr = 0; + if (pv[ny/CELL][nx/CELL]>0) { + fg = 6 * pv[ny/CELL][nx/CELL]; + fb = 4 * pv[ny/CELL][nx/CELL]; + fr = 2 * pv[ny/CELL][nx/CELL]; + } + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + x = nx/CELL; + y = ny/CELL; + fg += fire_g[y][x]; + if (fg > 255) fg = 255; + fire_g[y][x] = fg; + fb += fire_b[y][x]; + if (fb > 255) fb = 255; + fire_b[y][x] = fb; + fr += fire_r[y][x]; + if (fr > 255) fr = 255; + fire_r[y][x] = fr; + } + if (cmode == CM_BLOB) { + uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255); + uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255); + uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255); + + blendpixel(vid, nx+1, ny, R, G, B, 223); + blendpixel(vid, nx-1, ny, R, G, B, 223); + blendpixel(vid, nx, ny+1, R, G, B, 223); + blendpixel(vid, nx, ny-1, R, G, B, 223); + + blendpixel(vid, nx+1, ny-1, R, G, B, 112); + blendpixel(vid, nx-1, ny-1, R, G, B, 112); + blendpixel(vid, nx+1, ny+1, R, G, B, 112); + blendpixel(vid, nx-1, ny+1, R, G, B, 112); + } + } + else if (t==PT_LCRY) + { + uint8 GR = 0x50+(parts[i].life*10); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, GR); + if (cmode == CM_BLOB) { + blendpixel(vid, nx+1, ny, GR, GR, GR, 223); + blendpixel(vid, nx-1, ny, GR, GR, GR, 223); + blendpixel(vid, nx, ny+1, GR, GR, GR, 223); + blendpixel(vid, nx, ny-1, GR, GR, GR, 223); + + blendpixel(vid, nx+1, ny-1, GR, GR, GR, 112); + blendpixel(vid, nx-1, ny-1, GR, GR, GR, 112); + blendpixel(vid, nx+1, ny+1, GR, GR, GR, 112); + blendpixel(vid, nx-1, ny+1, GR, GR, GR, 112); + } + } + else if (t==PT_PCLN) + { + uint8 GR = 0x3B+(parts[i].life*19); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, 10); + if (cmode == CM_BLOB) { + blendpixel(vid, nx+1, ny, GR, GR, 10, 223); + blendpixel(vid, nx-1, ny, GR, GR, 10, 223); + blendpixel(vid, nx, ny+1, GR, GR, 10, 223); + blendpixel(vid, nx, ny-1, GR, GR, 10, 223); + + blendpixel(vid, nx+1, ny-1, GR, GR, 10, 112); + blendpixel(vid, nx-1, ny-1, GR, GR, 10, 112); + blendpixel(vid, nx+1, ny+1, GR, GR, 10, 112); + blendpixel(vid, nx-1, ny+1, GR, GR, 10, 112); + } + } + else if (t==PT_HSWC) + { + uint8 GR = 0x3B+(parts[i].life*19); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, 10, 10); + if (cmode == CM_BLOB) { + blendpixel(vid, nx+1, ny, GR, 10, 10, 223); + blendpixel(vid, nx-1, ny, GR, 10, 10, 223); + blendpixel(vid, nx, ny+1, GR, 10, 10, 223); + blendpixel(vid, nx, ny-1, GR, 10, 10, 223); + + blendpixel(vid, nx+1, ny-1, GR, 10, 10, 112); + blendpixel(vid, nx-1, ny-1, GR, 10, 10, 112); + blendpixel(vid, nx+1, ny+1, GR, 10, 10, 112); + blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112); + } + } + else if (t==PT_PUMP) + { + uint8 GR = 0x3B+(parts[i].life*19); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR); + if (cmode == CM_BLOB) { + blendpixel(vid, nx+1, ny, 10, 10, GR, 223); + blendpixel(vid, nx-1, ny, 10, 10, GR, 223); + blendpixel(vid, nx, ny+1, 10, 10, GR, 223); + blendpixel(vid, nx, ny-1, 10, 10, GR, 223); + + blendpixel(vid, nx+1, ny-1, 10, 10, GR, 112); + blendpixel(vid, nx-1, ny-1, 10, 10, GR, 112); + blendpixel(vid, nx+1, ny+1, 10, 10, GR, 112); + blendpixel(vid, nx-1, ny+1, 10, 10, GR, 112); + } + } + else if (t==PT_PLSM) + { + float ttemp = (float)parts[i].life; + int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + uint8 R = plasma_data[caddress]; + uint8 G = plasma_data[caddress+1]; + uint8 B = plasma_data[caddress+2]; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr = R/8; + cg = G/8; + cb = B/8; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = R; + cg = G; + cb = B; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } else if (t==PT_HFLM) + { + float ttemp = (float)parts[i].life; + int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + uint8 R = hflm_data[caddress]; + uint8 G = hflm_data[caddress+1]; + uint8 B = hflm_data[caddress+2]; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr = R/8; + cg = G/8; + cb = B/8; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = R; + cg = G; + cb = B; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } else if (t==PT_FIRW&&parts[i].tmp>=3) + { + float ttemp = (float)parts[i].tmp-4; + int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + uint8 R = firw_data[caddress]; + uint8 G = firw_data[caddress+1]; + uint8 B = firw_data[caddress+2]; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr = R/2; + cg = G/2; + cb = B/2; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = R; + cg = G; + cb = B; + blendpixel(vid, nx, ny, cr, cg, cb, 192); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + } + else if (t==PT_BOMB) + { + if (parts[i].tmp==0) { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + if (cmode != CM_CRACK) { int newx = 0; float gradv = 100; blendpixel(vid, nx+1, ny, cr, cg, cb, 223); blendpixel(vid, nx-1, ny, cr, cg, cb, 223); blendpixel(vid, nx, ny+1, cr, cg, cb, 223); blendpixel(vid, nx, ny-1, cr, cg, cb, 223); - + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); - for(newx = 0; gradv>0.5; newx++){ + for (newx = 0; gradv>0.5; newx++) { addpixel(vid, nx+newx, ny, cr, cg, cb, gradv); addpixel(vid, nx-newx, ny, cr, cg, cb, gradv); - + addpixel(vid, nx, ny+newx, cr, cg, cb, gradv); addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); gradv = gradv/1.1f; @@ -2579,17 +2536,17 @@ void draw_parts(pixel *vid) blendpixel(vid, nx, ny, cr, cg, cb, 255); } } - else if(parts[i].tmp==1){ + else if (parts[i].tmp==1) { cr = PIXR(ptypes[t].pcolors); cg = PIXG(ptypes[t].pcolors); cb = PIXB(ptypes[t].pcolors); - if(cmode != CM_CRACK){ + if (cmode != CM_CRACK) { int newx = 0; float gradv = 4*parts[i].life; - for(newx = 0; gradv>0.5; newx++){ + for (newx = 0; gradv>0.5; newx++) { addpixel(vid, nx+newx, ny, cr, cg, cb, gradv); addpixel(vid, nx-newx, ny, cr, cg, cb, gradv); - + addpixel(vid, nx, ny+newx, cr, cg, cb, gradv); addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); gradv = gradv/1.5f; @@ -2603,912 +2560,912 @@ void draw_parts(pixel *vid) } } - else if(ptypes[t].properties&PROP_HOT_GLOW && parts[i].temp>(pstates[t].ltemp-800.0f)) + else if (ptypes[t].properties&PROP_HOT_GLOW && parts[i].temp>(ptransitions[t].thv-800.0f)) { - float frequency = 3.1415/(2*pstates[t].ltemp-(pstates[t].ltemp-800.0f)); - int q = (parts[i].temp>pstates[t].ltemp)?pstates[t].ltemp-(pstates[t].ltemp-800.0f):parts[i].temp-(pstates[t].ltemp-800.0f); + float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); + int q = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors); cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors); cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors); - if(cr>=255) + if (cr>=255) cr = 255; - if(cg>=255) + if (cg>=255) cg = 255; - if(cb>=255) + if (cb>=255) cb = 255; - if(cr<=0) + if (cr<=0) cr = 0; - if(cg<=0) + if (cg<=0) cg = 0; - if(cb<=0) + if (cb<=0) cb = 0; blendpixel(vid, nx, ny, cr, cg, cb, 255); } - else if(t==PT_FIRE && parts[i].life) - { - float ttemp = (float)((int)(parts[i].life/2)); - int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - uint8 R = flm_data[caddress]; - uint8 G = flm_data[caddress+1]; - uint8 B = flm_data[caddress+2]; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cr = R/8; - cg = G/8; - cb = B/8; - x = nx/CELL; - y = ny/CELL; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - } - else - { - cr = parts[i].life * 8; - cg = parts[i].life * 2; - cb = parts[i].life; - if(cr>255) cr = 255; - if(cg>192) cg = 212; - if(cb>128) cb = 192; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - } - // Older Code - /*if(cmode == 3||cmode==4 || cmode==6) - { - cr = parts[i].life / 4; - cg = parts[i].life / 16; - cb = parts[i].life / 32; - if(cr>255) cr = 255; - if(cg>192) cg = 212; - if(cb>128) cb = 192; - x = nx/CELL; - y = ny/CELL; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - else - { - cr = parts[i].life * 8; - cg = parts[i].life * 2; - cb = parts[i].life; - if(cr>255) cr = 255; - if(cg>192) cg = 212; - if(cb>128) cb = 192; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - blendpixel(vid, nx+1, ny, cr, cg, cb, 96); - blendpixel(vid, nx-1, ny, cr, cg, cb, 96); - blendpixel(vid, nx, ny+1, cr, cg, cb, 96); - blendpixel(vid, nx, ny-1, cr, cg, cb, 96); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); - }*/ - } - else if(t==PT_LAVA && parts[i].life) - { - cr = parts[i].life * 2 + 0xE0; - cg = parts[i].life * 1 + 0x50; - cb = parts[i].life/2 + 0x10; - if(cr>255) cr = 255; - if(cg>192) cg = 192; - if(cb>128) cb = 128; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - blendpixel(vid, nx+1, ny, cr, cg, cb, 64); - blendpixel(vid, nx-1, ny, cr, cg, cb, 64); - blendpixel(vid, nx, ny+1, cr, cg, cb, 64); - blendpixel(vid, nx, ny-1, cr, cg, cb, 64); - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - cr /= 32; - cg /= 32; - cb /= 32; - x = nx/CELL; - y = ny/CELL; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - else if(t==PT_LAVA || t==PT_SPRK) - { - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) - { - if(t == PT_LAVA) - { - cr = 3; - cg = i%2; - cb = 0; - } - else - { - cr = 8; - cg = 12; - cb = 16; - } - x = nx/CELL; - y = ny/CELL; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - else - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - } - else - { - float ttemp = parts[i].temp+(-MIN_TEMP); - int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3); - uint8 R = color_data[caddress]; - uint8 G = color_data[caddress+1]; - uint8 B = color_data[caddress+2]; + else if (t==PT_FIRE && parts[i].life) + { + float ttemp = (float)((int)(parts[i].life/2)); + int caddress = restrict_flt(restrict_flt(ttemp, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + uint8 R = flm_data[caddress]; + uint8 G = flm_data[caddress+1]; + uint8 B = flm_data[caddress+2]; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr = R/8; + cg = G/8; + cb = B/8; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = parts[i].life * 8; + cg = parts[i].life * 2; + cb = parts[i].life; + if (cr>255) cr = 255; + if (cg>192) cg = 212; + if (cb>128) cb = 192; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + } + // Older Code + /*if(cmode == 3||cmode==4 || cmode==6) + { + cr = parts[i].life / 4; + cg = parts[i].life / 16; + cb = parts[i].life / 32; + if(cr>255) cr = 255; + if(cg>192) cg = 212; + if(cb>128) cb = 192; + x = nx/CELL; + y = ny/CELL; + cr += fire_r[y][x]; + if(cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if(cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if(cb > 255) cb = 255; + fire_b[y][x] = cb; + } + else + { + cr = parts[i].life * 8; + cg = parts[i].life * 2; + cb = parts[i].life; + if(cr>255) cr = 255; + if(cg>192) cg = 212; + if(cb>128) cb = 192; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + blendpixel(vid, nx+1, ny, cr, cg, cb, 96); + blendpixel(vid, nx-1, ny, cr, cg, cb, 96); + blendpixel(vid, nx, ny+1, cr, cg, cb, 96); + blendpixel(vid, nx, ny-1, cr, cg, cb, 96); + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); + }*/ + } + else if (t==PT_LAVA && parts[i].life) + { + cr = parts[i].life * 2 + 0xE0; + cg = parts[i].life * 1 + 0x50; + cb = parts[i].life/2 + 0x10; + if (cr>255) cr = 255; + if (cg>192) cg = 192; + if (cb>128) cb = 128; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + blendpixel(vid, nx+1, ny, cr, cg, cb, 64); + blendpixel(vid, nx-1, ny, cr, cg, cb, 64); + blendpixel(vid, nx, ny+1, cr, cg, cb, 64); + blendpixel(vid, nx, ny-1, cr, cg, cb, 64); + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + cr /= 32; + cg /= 32; + cb /= 32; + x = nx/CELL; + y = ny/CELL; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + else if (t==PT_LAVA || t==PT_SPRK) + { + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + if (t == PT_LAVA) + { + cr = 3; + cg = i%2; + cb = 0; + } + else + { + cr = 8; + cg = 12; + cb = 16; + } + x = nx/CELL; + y = ny/CELL; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + else + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + } + else + { + float ttemp = parts[i].temp+(-MIN_TEMP); + int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3); + uint8 R = color_data[caddress]; + uint8 G = color_data[caddress+1]; + uint8 B = color_data[caddress+2]; - if(t==PT_STKM) //Stick man should be visible in heat mode - { - char buff[10]; //Buffer for HP + if (t==PT_STKM) //Stick man should be visible in heat mode + { + char buff[10]; //Buffer for HP - if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head - { - sprintf(buff, "%3d", parts[i].life); //Show HP - drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); - } + if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head + { + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); + } - for(r=-2; r<=1; r++) - { - s = XRES+BARSIZE; - vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B); - vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B); - vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B); - vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B); - } - draw_line(vid , nx, ny+3, player[3], player[4], R, G, B, s); - draw_line(vid , player[3], player[4], player[7], player[8], R, G, B, s); - draw_line(vid , nx, ny+3, player[11], player[12], R, G, B, s); - draw_line(vid , player[11], player[12], player[15], player[16], R, G, B, s); + for (r=-2; r<=1; r++) + { + s = XRES+BARSIZE; + vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B); + vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B); + vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B); + vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B); + } + draw_line(vid , nx, ny+3, player[3], player[4], R, G, B, s); + draw_line(vid , player[3], player[4], player[7], player[8], R, G, B, s); + draw_line(vid , nx, ny+3, player[11], player[12], R, G, B, s); + draw_line(vid , player[11], player[12], player[15], player[16], R, G, B, s); - isplayer = 1; //It's a secret. Tssss... - } - else if(t==PT_STKM2) //Stick man should be visible in heat mode - { - char buff[10]; //Buffer for HP + isplayer = 1; //It's a secret. Tssss... + } + else if (t==PT_STKM2) //Stick man should be visible in heat mode + { + char buff[10]; //Buffer for HP - if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head - { - sprintf(buff, "%3d", parts[i].life); //Show HP - drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); - } + if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head + { + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); + } - for(r=-2; r<=1; r++) - { - s = XRES+BARSIZE; - vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B); - vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B); - vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B); - vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B); - } - draw_line(vid , nx, ny+3, player2[3], player2[4], R, G, B, s); - draw_line(vid , player2[3], player2[4], player2[7], player2[8], R, G, B, s); - draw_line(vid , nx, ny+3, player2[11], player2[12], R, G, B, s); - draw_line(vid , player2[11], player2[12], player2[15], player2[16], R, G, B, s); + for (r=-2; r<=1; r++) + { + s = XRES+BARSIZE; + vid[(ny-2)*s+nx+r] = PIXRGB (R, G, B); + vid[(ny+2)*s+nx+r+1] = PIXRGB (R, G, B); + vid[(ny+r+1)*s+nx-2] = PIXRGB (R, G, B); + vid[(ny+r)*s+nx+2] = PIXRGB (R, G, B); + } + draw_line(vid , nx, ny+3, player2[3], player2[4], R, G, B, s); + draw_line(vid , player2[3], player2[4], player2[7], player2[8], R, G, B, s); + draw_line(vid , nx, ny+3, player2[11], player2[12], R, G, B, s); + draw_line(vid , player2[11], player2[12], player2[15], player2[16], R, G, B, s); - isplayer2 = 1; //It's a secret. Tssss... - } - else - { - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B); - //blendpixel(vid, nx+1, ny, R, G, B, 255); - } - } - if(cmode == CM_BLOB&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3)) - { - if(t==PT_PHOT) { - cg = 0; - cb = 0; - cr = 0; - for(x=0; x<12; x++) { - cr += (parts[i].ctype >> (x+18)) & 1; - cb += (parts[i].ctype >> x) & 1; - } - for(x=0; x<14; x++) - cg += (parts[i].ctype >> (x+9)) & 1; - x = 624/(cr+cg+cb+1); - cr *= x; - cg *= x; - cb *= x; - cr = cr>255?255:cr; - cg = cg>255?255:cg; - cb = cb>255?255:cb; - } else { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - } + isplayer2 = 1; //It's a secret. Tssss... + } + else + { + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B); + //blendpixel(vid, nx+1, ny, R, G, B, 255); + } + } + if (cmode == CM_BLOB&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3)) + { + if (t==PT_PHOT) { + cg = 0; + cb = 0; + cr = 0; + for (x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for (x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + } else { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + } - //if(vid[(ny-1)*YRES+(nx-1)]!=0){ - // blendpixel(vid, nx, ny-1, R, G, B, 46); - //} + //if(vid[(ny-1)*YRES+(nx-1)]!=0){ + // blendpixel(vid, nx, ny-1, R, G, B, 46); + //} - blendpixel(vid, nx+1, ny, cr, cg, cb, 223); - blendpixel(vid, nx-1, ny, cr, cg, cb, 223); - blendpixel(vid, nx, ny+1, cr, cg, cb, 223); - blendpixel(vid, nx, ny-1, cr, cg, cb, 223); + blendpixel(vid, nx+1, ny, cr, cg, cb, 223); + blendpixel(vid, nx-1, ny, cr, cg, cb, 223); + blendpixel(vid, nx, ny+1, cr, cg, cb, 223); + blendpixel(vid, nx, ny-1, cr, cg, cb, 223); - blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); - blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); - blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); - blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); - } - } + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); + } + } #endif - } + } #ifdef OpenGL - glFlush (); + glFlush (); #endif } void render_signs(pixel *vid_buf) { - int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq; - char buff[30]; //Buffer - for(i=0; i>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp-273.15); //...tempirature - else - sprintf(buff, "Temp: 0.00"); //...tempirature - drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); - } + //Displaying special information + if (strcmp(signs[i].text, "{p}")==0) + { + sprintf(buff, "Pressure: %3.2f", pv[signs[i].y/CELL][signs[i].x/CELL]); //...pressure + drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); + } + if (strcmp(signs[i].text, "{t}")==0) + { + if ((pmap[signs[i].y][signs[i].x]>>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp-273.15); //...tempirature + else + sprintf(buff, "Temp: 0.00"); //...tempirature + drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); + } - //Usual text - if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) - drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); + //Usual text + if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) + drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); - x = signs[i].x; - y = signs[i].y; - dx = 1 - signs[i].ju; - dy = (signs[i].y > 18) ? -1 : 1; - for(j=0; j<4; j++) - { - drawpixel(vid_buf, x, y, 192, 192, 192, 255); - x+=dx; - y+=dy; - } - if(MSIGN==i) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; - signs[i].x = mx; - signs[i].y = my; - } - } + x = signs[i].x; + y = signs[i].y; + dx = 1 - signs[i].ju; + dy = (signs[i].y > 18) ? -1 : 1; + for (j=0; j<4; j++) + { + drawpixel(vid_buf, x, y, 192, 192, 192, 255); + x+=dx; + y+=dy; + } + if (MSIGN==i) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + signs[i].x = mx; + signs[i].y = my; + } + } } void render_fire(pixel *dst) { - int i,j,x,y,r,g,b; - for(j=0; j=0 && j+y>=0 && i+x4 ? r-4 : 0; - fire_g[j][i] = g>4 ? g-4 : 0; - fire_b[j][i] = b>4 ? b-4 : 0; - } + int i,j,x,y,r,g,b; + for (j=0; j=0 && j+y>=0 && i+x4 ? r-4 : 0; + fire_g[j][i] = g>4 ? g-4 : 0; + fire_b[j][i] = b>4 ? b-4 : 0; + } } void prepare_alpha(void) { - int x,y,i,j; - float temp[CELL*3][CELL*3]; - memset(temp, 0, sizeof(temp)); - for(x=0; x0) - r--; - if(g>0) - g--; - if(b>0) - b--; - dst[i] = PIXRGB(r,g,b); - } + int i,r,g,b; + for (i=0; i0) + r--; + if (g>0) + g--; + if (b>0) + b--; + dst[i] = PIXRGB(r,g,b); + } } void dim_copy_pers(pixel *dst, pixel *src) { - int i,r,g,b; - for(i=0; i<(XRES+BARSIZE)*YRES; i++) - { - r = PIXR(src[i]); - g = PIXG(src[i]); - b = PIXB(src[i]); - if(r>0) - r--; - if(g>0) - g--; - if(b>0) - b--; - dst[i] = PIXRGB(r,g,b); - } + int i,r,g,b; + for (i=0; i<(XRES+BARSIZE)*YRES; i++) + { + r = PIXR(src[i]); + g = PIXG(src[i]); + b = PIXB(src[i]); + if (r>0) + r--; + if (g>0) + g--; + if (b>0) + b--; + dst[i] = PIXRGB(r,g,b); + } } void render_zoom(pixel *img) { - int x, y, i, j; - pixel pix; - drawrect(img, zoom_wx-2, zoom_wy-2, ZSIZE*ZFACTOR+2, ZSIZE*ZFACTOR+2, 192, 192, 192, 255); - drawrect(img, zoom_wx-1, zoom_wy-1, ZSIZE*ZFACTOR, ZSIZE*ZFACTOR, 0, 0, 0, 255); - clearrect(img, zoom_wx, zoom_wy, ZSIZE*ZFACTOR, ZSIZE*ZFACTOR); - for(j=0; jSAVE_VERSION) - return NULL; + if (size<16) + return NULL; + if (!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) + return NULL; + if (c[2]==0x43 && c[1]==0x75 && c[0]==0x66) { + new_format = 1; + } + if (c[4]>SAVE_VERSION) + return NULL; - bw = c[6]; - bh = c[7]; - w = bw*CELL; - h = bh*CELL; + bw = c[6]; + bh = c[7]; + w = bw*CELL; + h = bh*CELL; - if(c[5]!=CELL) - return NULL; + if (c[5]!=CELL) + return NULL; - i = (unsigned)c[8]; - i |= ((unsigned)c[9])<<8; - i |= ((unsigned)c[10])<<16; - i |= ((unsigned)c[11])<<24; - d = malloc(i); - if(!d) - return NULL; - fb = calloc(w*h, PIXELSIZE); - if(!fb) - { - free(d); - return NULL; - } + i = (unsigned)c[8]; + i |= ((unsigned)c[9])<<8; + i |= ((unsigned)c[10])<<16; + i |= ((unsigned)c[11])<<24; + d = malloc(i); + if (!d) + return NULL; + fb = calloc(w*h, PIXELSIZE); + if (!fb) + { + free(d); + return NULL; + } - if(BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) - goto corrupt; - size = i; + if (BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) + goto corrupt; + size = i; - if(size < bw*bh) - goto corrupt; + if (size < bw*bh) + goto corrupt; - k = 0; - for(y=0; y>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i=size) - goto corrupt; + k = 0; + for (y=0; y>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i=size) + goto corrupt; - for(y=0; y= size) - goto corrupt; - j=d[p++]; - if(j0) - { - if(j==PT_STKM) - { - //Stickman drawing - for(k=-2; k<=1; k++) - { - fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178); - fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178); - fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178); - fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178); - } - draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w); - draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w); - draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w); - draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w); - } - else if(j==PT_STKM2) - { - //Stickman drawing - for(k=-2; k<=1; k++) - { - fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178); - fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178); - fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178); - fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178); - } - draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w); - draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w); - draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w); - draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w); - } - else - fb[y*w+x] = ptypes[j].pcolors; - } - } + for (y=0; y= size) + goto corrupt; + j=d[p++]; + if (j0) + { + if (j==PT_STKM) + { + //Stickman drawing + for (k=-2; k<=1; k++) + { + fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178); + fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178); + fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178); + fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178); + } + draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w); + draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w); + draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w); + draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w); + } + else if (j==PT_STKM2) + { + //Stickman drawing + for (k=-2; k<=1; k++) + { + fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178); + fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178); + fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178); + fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178); + } + draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w); + draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w); + draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w); + draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w); + } + else + fb[y*w+x] = ptypes[j].pcolors; + } + } - free(d); - *width = w; - *height = h; - return fb; + free(d); + *width = w; + *height = h; + return fb; corrupt: - free(d); - free(fb); - return NULL; + free(d); + free(fb); + return NULL; } int render_thumb(void *thumb, int size, int bzip2, pixel *vid_buf, int px, int py, int scl) { - unsigned char *d,*c=thumb; - int i,j,x,y,a,t,r,g,b,sx,sy; + unsigned char *d,*c=thumb; + int i,j,x,y,a,t,r,g,b,sx,sy; - if(bzip2) - { - if(size<16) - return 1; - if(c[3]!=0x74 || c[2]!=0x49 || c[1]!=0x68 || c[0]!=0x53) - return 1; - if(c[4]>PT_NUM) - return 2; - if(c[5]!=CELL || c[6]!=XRES/CELL || c[7]!=YRES/CELL) - return 3; - i = XRES*YRES; - d = malloc(i); - if(!d) - return 1; + if (bzip2) + { + if (size<16) + return 1; + if (c[3]!=0x74 || c[2]!=0x49 || c[1]!=0x68 || c[0]!=0x53) + return 1; + if (c[4]>PT_NUM) + return 2; + if (c[5]!=CELL || c[6]!=XRES/CELL || c[7]!=YRES/CELL) + return 3; + i = XRES*YRES; + d = malloc(i); + if (!d) + return 1; - if(BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+8), size-8, 0, 0)) - return 1; - size = i; - } - else - d = c; + if (BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+8), size-8, 0, 0)) + return 1; + size = i; + } + else + d = c; - if(size < XRES*YRES) - { - if(bzip2) - free(d); - return 1; - } + if (size < XRES*YRES) + { + if (bzip2) + free(d); + return 1; + } - sy = 0; - for(y=0; y+scl<=YRES; y+=scl) - { - sx = 0; - for(x=0; x+scl<=XRES; x+=scl) - { - a = 0; - r = g = b = 0; - for(j=0; j=PT_NUM) - goto corrupt; - r += PIXR(ptypes[t].pcolors); - g += PIXG(ptypes[t].pcolors); - b += PIXB(ptypes[t].pcolors); - a ++; - } - } - if(a) - { - a = 256/a; - r = (r*a)>>8; - g = (g*a)>>8; - b = (b*a)>>8; - } + sy = 0; + for (y=0; y+scl<=YRES; y+=scl) + { + sx = 0; + for (x=0; x+scl<=XRES; x+=scl) + { + a = 0; + r = g = b = 0; + for (j=0; j=PT_NUM) + goto corrupt; + r += PIXR(ptypes[t].pcolors); + g += PIXG(ptypes[t].pcolors); + b += PIXB(ptypes[t].pcolors); + a ++; + } + } + if (a) + { + a = 256/a; + r = (r*a)>>8; + g = (g*a)>>8; + b = (b*a)>>8; + } - drawpixel(vid_buf, px+sx, py+sy, r, g, b, 255); - sx++; - } - sy++; - } + drawpixel(vid_buf, px+sx, py+sy, r, g, b, 255); + sx++; + } + sy++; + } - if(bzip2) - free(d); - return 0; + if (bzip2) + free(d); + return 0; corrupt: - if(bzip2) - free(d); - return 1; + if (bzip2) + free(d); + return 1; } void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) { - int i,j,c; - if(trx || (j+1)>ry)) + if (rx<=0) + xor_pixel(x, y, vid); + else if (ry<=0) + xor_pixel(x, y, vid); + if (rx+ry<=0) + xor_pixel(x, y, vid); + else if (CURRENT_BRUSH==SQUARE_BRUSH) { - xor_pixel(x+i, y+j, vid); - xor_pixel(x-i, y-j, vid); - if(i&&j)xor_pixel(x+i, y-j, vid); - if(i&&j)xor_pixel(x-i, y+j, vid); + for (j=0; j<=ry; j++) + for (i=0; i<=rx; i++) + if (i*j<=ry*rx && ((i+1)>rx || (j+1)>ry)) + { + xor_pixel(x+i, y+j, vid); + xor_pixel(x-i, y-j, vid); + if (i&&j)xor_pixel(x+i, y-j, vid); + if (i&&j)xor_pixel(x-i, y+j, vid); + } + } + else if (CURRENT_BRUSH==CIRCLE_BRUSH) + for (j=0; j<=ry; j++) + for (i=0; i<=rx; i++) + if ((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1 && ((pow(i+1,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))>1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1)) + { + xor_pixel(x+i, y+j, vid); + if (j) xor_pixel(x+i, y-j, vid); + if (i) xor_pixel(x-i, y+j, vid); + if (i&&j) xor_pixel(x-i, y-j, vid); + } + } + else + { + int tc; + c = (rx/CELL) * CELL; + x = (x/CELL) * CELL; + y = (y/CELL) * CELL; + + tc = !((c%(CELL*2))==0); + + x -= c/2; + y -= c/2; + + x += tc*(CELL/2); + y += tc*(CELL/2); + + for (i=0; i1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1)) - { - xor_pixel(x+i, y+j, vid); - if(j) xor_pixel(x+i, y-j, vid); - if(i) xor_pixel(x-i, y+j, vid); - if(i&&j) xor_pixel(x-i, y-j, vid); - } - } - else - { - int tc; - c = (rx/CELL) * CELL; - x = (x/CELL) * CELL; - y = (y/CELL) * CELL; - - tc = !((c%(CELL*2))==0); - - x -= c/2; - y -= c/2; - - x += tc*(CELL/2); - y += tc*(CELL/2); - - for(i=0; iai_family != AF_INET) - { - freeaddrinfo(res); - return 1; - } - memcpy(addr, res->ai_addr, res->ai_addrlen); - freeaddrinfo(res); - return 0; - } - return 1; + struct addrinfo hnt, *res = 0; + if (http_use_proxy) + { + memcpy(addr, &http_proxy, sizeof(struct sockaddr_in)); + return 0; + } + memset(&hnt, 0, sizeof(hnt)); + hnt.ai_family = AF_INET; + hnt.ai_socktype = SOCK_STREAM; + if (getaddrinfo(dns, srv, &hnt, &res)) + return 1; + if (res) + { + if (res->ai_family != AF_INET) + { + freeaddrinfo(res); + return 1; + } + memcpy(addr, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); + return 0; + } + return 1; } void http_init(char *proxy) { - char *host, *port; + char *host, *port; #ifdef WIN32 - WSADATA wsadata; - if(!WSAStartup(MAKEWORD(2,2), &wsadata)) - http_up = 1; + WSADATA wsadata; + if (!WSAStartup(MAKEWORD(2,2), &wsadata)) + http_up = 1; #else - signal(SIGPIPE, SIG_IGN); - http_up = 1; + signal(SIGPIPE, SIG_IGN); + http_up = 1; #endif - if(proxy) - { - host = getserv(proxy); - port = getport(proxy); - if(resolve(host, port, &http_proxy)) - http_up = 0; - else - http_use_proxy = 1; - free(host); - free(port); - } + if (proxy) + { + host = getserv(proxy); + port = getport(proxy); + if (resolve(host, port, &http_proxy)) + http_up = 0; + else + http_use_proxy = 1; + free(host); + free(port); + } } void http_done(void) { #ifdef WIN32 - WSACleanup(); + WSACleanup(); #endif - http_up = 0; + http_up = 0; } #define CHUNK 4096 @@ -197,855 +197,855 @@ void http_done(void) #define HTS_DONE 6 struct http_ctx { - int state; - time_t last; - int keep; - int ret; - char *host, *path; - char *thdr; - int thlen; - char *txd; - int txdl; - struct sockaddr_in addr; - char *tbuf; - int tlen, tptr; - char *hbuf; - int hlen, hptr; - char *rbuf; - int rlen, rptr; - int chunked, chunkhdr, rxtogo, contlen, cclose; - int fd; - char *fdhost; + int state; + time_t last; + int keep; + int ret; + char *host, *path; + char *thdr; + int thlen; + char *txd; + int txdl; + struct sockaddr_in addr; + char *tbuf; + int tlen, tptr; + char *hbuf; + int hlen, hptr; + char *rbuf; + int rlen, rptr; + int chunked, chunkhdr, rxtogo, contlen, cclose; + int fd; + char *fdhost; }; void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep) { - struct http_ctx *cx = ctx; - if(!ctx) - { - ctx = calloc(1, sizeof(struct http_ctx)); - cx = ctx; - cx->fd = PERROR; - } + struct http_ctx *cx = ctx; + if (!ctx) + { + ctx = calloc(1, sizeof(struct http_ctx)); + cx = ctx; + cx->fd = PERROR; + } - if(!cx->hbuf) - { - cx->hbuf = malloc(256); - cx->hlen = 256; - } + if (!cx->hbuf) + { + cx->hbuf = malloc(256); + cx->hlen = 256; + } - if(!http_up) - { - cx->ret = 604; - cx->state = HTS_DONE; - return ctx; - } + if (!http_up) + { + cx->ret = 604; + cx->state = HTS_DONE; + return ctx; + } - if(cx->state!=HTS_STRT && cx->state!=HTS_IDLE) - { - fprintf(stderr, "HTTP: unclean request restart state.\n"); - exit(1); - } + if (cx->state!=HTS_STRT && cx->state!=HTS_IDLE) + { + fprintf(stderr, "HTTP: unclean request restart state.\n"); + exit(1); + } - cx->keep = keep; - cx->ret = 600; - if(splituri(uri, &cx->host, &cx->path)) - { - cx->ret = 601; - cx->state = HTS_DONE; - return ctx; - } - if(http_use_proxy) - { - free(cx->path); - cx->path = mystrdup(uri); - } - if(cx->fdhost && strcmp(cx->host, cx->fdhost)) - { - free(cx->fdhost); - cx->fdhost = NULL; - PCLOSE(cx->fd); - cx->fd = PERROR; - cx->state = HTS_STRT; - } - if(data) - { - if(!dlen) - dlen = strlen(data); - cx->txd = malloc(dlen); - memcpy(cx->txd, data, dlen); - cx->txdl = dlen; - } - else - cx->txdl = 0; + cx->keep = keep; + cx->ret = 600; + if (splituri(uri, &cx->host, &cx->path)) + { + cx->ret = 601; + cx->state = HTS_DONE; + return ctx; + } + if (http_use_proxy) + { + free(cx->path); + cx->path = mystrdup(uri); + } + if (cx->fdhost && strcmp(cx->host, cx->fdhost)) + { + free(cx->fdhost); + cx->fdhost = NULL; + PCLOSE(cx->fd); + cx->fd = PERROR; + cx->state = HTS_STRT; + } + if (data) + { + if (!dlen) + dlen = strlen(data); + cx->txd = malloc(dlen); + memcpy(cx->txd, data, dlen); + cx->txdl = dlen; + } + else + cx->txdl = 0; - cx->contlen = 0; - cx->chunked = 0; - cx->chunkhdr = 0; - cx->rxtogo = 0; - cx->cclose = 0; + cx->contlen = 0; + cx->chunked = 0; + cx->chunkhdr = 0; + cx->rxtogo = 0; + cx->cclose = 0; - cx->tptr = 0; - cx->tlen = 0; + cx->tptr = 0; + cx->tlen = 0; - cx->last = time(NULL); + cx->last = time(NULL); - return ctx; + return ctx; } void http_async_add_header(void *ctx, char *name, char *data) { - struct http_ctx *cx = ctx; - cx->thdr = realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 4); - cx->thlen += sprintf(cx->thdr+cx->thlen, "%s: %s\n", name, data); + struct http_ctx *cx = ctx; + cx->thdr = realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 4); + cx->thlen += sprintf(cx->thdr+cx->thlen, "%s: %s\n", name, data); } static void process_header(struct http_ctx *cx, char *str) { - char *p; - if(cx->chunkhdr) - { - p = strchr(str, ';'); - if(p) - *p = 0; - cx->rxtogo = strtoul(str, NULL, 16); - cx->chunkhdr = 0; - if(!cx->rxtogo) - cx->chunked = 0; - } - if(!str[0]) - { - cx->rxtogo = cx->contlen; - cx->chunkhdr = cx->chunked; - if(!cx->contlen && !cx->chunked && cx->ret!=100) - cx->state = HTS_DONE; - return; - } - if(!strncmp(str, "HTTP/", 5)) - { - p = strchr(str, ' '); - if(!p) - { - cx->ret = 603; - cx->state = HTS_DONE; - return; - } - p++; - cx->ret = atoi(p); - return; - } - if(!strncmp(str, "Content-Length: ", 16)) - { - cx->contlen = atoi(str+16); - return; - } - if(!strcmp(str, "Transfer-Encoding: chunked")) - { - cx->chunked = 1; - return; - } - if(!strcmp(str, "Connection: close")) - { - cx->cclose = 1; - return; - } + char *p; + if (cx->chunkhdr) + { + p = strchr(str, ';'); + if (p) + *p = 0; + cx->rxtogo = strtoul(str, NULL, 16); + cx->chunkhdr = 0; + if (!cx->rxtogo) + cx->chunked = 0; + } + if (!str[0]) + { + cx->rxtogo = cx->contlen; + cx->chunkhdr = cx->chunked; + if (!cx->contlen && !cx->chunked && cx->ret!=100) + cx->state = HTS_DONE; + return; + } + if (!strncmp(str, "HTTP/", 5)) + { + p = strchr(str, ' '); + if (!p) + { + cx->ret = 603; + cx->state = HTS_DONE; + return; + } + p++; + cx->ret = atoi(p); + return; + } + if (!strncmp(str, "Content-Length: ", 16)) + { + cx->contlen = atoi(str+16); + return; + } + if (!strcmp(str, "Transfer-Encoding: chunked")) + { + cx->chunked = 1; + return; + } + if (!strcmp(str, "Connection: close")) + { + cx->cclose = 1; + return; + } } static void process_byte(struct http_ctx *cx, char ch) { - if(cx->rxtogo) - { - cx->rxtogo--; + if (cx->rxtogo) + { + cx->rxtogo--; - if(!cx->rbuf) - { - cx->rbuf = malloc(256); - cx->rlen = 256; - } - if(cx->rptr >= cx->rlen-1) - { - cx->rlen *= 2; - cx->rbuf = realloc(cx->rbuf, cx->rlen); - } - cx->rbuf[cx->rptr++] = ch; + if (!cx->rbuf) + { + cx->rbuf = malloc(256); + cx->rlen = 256; + } + if (cx->rptr >= cx->rlen-1) + { + cx->rlen *= 2; + cx->rbuf = realloc(cx->rbuf, cx->rlen); + } + cx->rbuf[cx->rptr++] = ch; - if(!cx->rxtogo && !cx->chunked) - cx->state = HTS_DONE; - } - else - { - if(ch == '\n') - { - cx->hbuf[cx->hptr] = 0; - process_header(cx, cx->hbuf); - cx->hptr = 0; - } - else if(ch != '\r') - { - if(cx->hptr >= cx->hlen-1) - { - cx->hlen *= 2; - cx->hbuf = realloc(cx->hbuf, cx->hlen); - } - cx->hbuf[cx->hptr++] = ch; - } - } + if (!cx->rxtogo && !cx->chunked) + cx->state = HTS_DONE; + } + else + { + if (ch == '\n') + { + cx->hbuf[cx->hptr] = 0; + process_header(cx, cx->hbuf); + cx->hptr = 0; + } + else if (ch != '\r') + { + if (cx->hptr >= cx->hlen-1) + { + cx->hlen *= 2; + cx->hbuf = realloc(cx->hbuf, cx->hlen); + } + cx->hbuf[cx->hptr++] = ch; + } + } } int http_async_req_status(void *ctx) { - struct http_ctx *cx = ctx; - char *dns,*srv,buf[CHUNK]; - int tmp, i; - time_t now = time(NULL); + struct http_ctx *cx = ctx; + char *dns,*srv,buf[CHUNK]; + int tmp, i; + time_t now = time(NULL); #ifdef WIN32 - unsigned long tmp2; + unsigned long tmp2; #endif - switch(cx->state) - { - case HTS_STRT: - dns = getserv(cx->host); - srv = getport(cx->host); - if(resolve(dns, srv, &cx->addr)) - { - free(dns); - free(srv); - cx->state = HTS_DONE; - cx->ret = 602; - return 1; - } - free(dns); - free(srv); - cx->state = HTS_RSLV; - return 0; - case HTS_RSLV: - cx->state = HTS_CONN; - cx->last = now; - return 0; - case HTS_CONN: - if(cx->fd == PERROR) - { - cx->fd = socket(AF_INET, SOCK_STREAM, 0); - if(cx->fd == PERROR) - goto fail; - cx->fdhost = mystrdup(cx->host); + switch (cx->state) + { + case HTS_STRT: + dns = getserv(cx->host); + srv = getport(cx->host); + if (resolve(dns, srv, &cx->addr)) + { + free(dns); + free(srv); + cx->state = HTS_DONE; + cx->ret = 602; + return 1; + } + free(dns); + free(srv); + cx->state = HTS_RSLV; + return 0; + case HTS_RSLV: + cx->state = HTS_CONN; + cx->last = now; + return 0; + case HTS_CONN: + if (cx->fd == PERROR) + { + cx->fd = socket(AF_INET, SOCK_STREAM, 0); + if (cx->fd == PERROR) + goto fail; + cx->fdhost = mystrdup(cx->host); #ifdef WIN32 - tmp2 = 1; - if(ioctlsocket(cx->fd, FIONBIO, &tmp2) == SOCKET_ERROR) - goto fail; + tmp2 = 1; + if (ioctlsocket(cx->fd, FIONBIO, &tmp2) == SOCKET_ERROR) + goto fail; #else - tmp = fcntl(cx->fd, F_GETFL); - if(tmp < 0) - goto fail; - if(fcntl(cx->fd, F_SETFL, tmp|O_NONBLOCK) < 0) - goto fail; + tmp = fcntl(cx->fd, F_GETFL); + if (tmp < 0) + goto fail; + if (fcntl(cx->fd, F_SETFL, tmp|O_NONBLOCK) < 0) + goto fail; #endif - } - if(!connect(cx->fd, (struct sockaddr *)&cx->addr, sizeof(cx->addr))) - cx->state = HTS_IDLE; + } + if (!connect(cx->fd, (struct sockaddr *)&cx->addr, sizeof(cx->addr))) + cx->state = HTS_IDLE; #ifdef WIN32 - else if(PERRNO==WSAEISCONN) - cx->state = HTS_IDLE; + else if (PERRNO==WSAEISCONN) + cx->state = HTS_IDLE; #endif #ifdef MACOSX - else if(PERRNO==EISCONN) - cx->state = HTS_IDLE; + else if (PERRNO==EISCONN) + cx->state = HTS_IDLE; #endif - else if(PERRNO!=PEINPROGRESS && PERRNO!=PEALREADY + else if (PERRNO!=PEINPROGRESS && PERRNO!=PEALREADY #ifdef WIN32 - && PERRNO!=PEAGAIN && PERRNO!=WSAEINVAL + && PERRNO!=PEAGAIN && PERRNO!=WSAEINVAL #endif - ) - goto fail; - if(now-cx->last>http_timeout) - goto timeout; - return 0; - case HTS_IDLE: - if(cx->txdl) - { - // generate POST - cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 121 + cx->txdl + cx->thlen); - cx->tptr = 0; - cx->tlen = 0; - cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path); - cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host); - if(!cx->keep) - cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n"); - if(cx->thdr) - { - memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen); - cx->tlen += cx->thlen; - free(cx->thdr); - cx->thdr = NULL; - cx->thlen = 0; - } - cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl); + ) + goto fail; + if (now-cx->last>http_timeout) + goto timeout; + return 0; + case HTS_IDLE: + if (cx->txdl) + { + // generate POST + cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 121 + cx->txdl + cx->thlen); + cx->tptr = 0; + cx->tlen = 0; + cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host); + if (!cx->keep) + cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n"); + if (cx->thdr) + { + memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen); + cx->tlen += cx->thlen; + free(cx->thdr); + cx->thdr = NULL; + cx->thlen = 0; + } + cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl); #ifdef BETA - cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); #else - cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); #endif - cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n"); - memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl); - cx->tlen += cx->txdl; - free(cx->txd); - cx->txd = NULL; - cx->txdl = 0; - } - else - { - // generate GET - cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 89 + cx->thlen); - cx->tptr = 0; - cx->tlen = 0; - cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path); - cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host); - if(cx->thdr) - { - memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen); - cx->tlen += cx->thlen; - free(cx->thdr); - cx->thdr = NULL; - cx->thlen = 0; - } - if(!cx->keep) - cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n"); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n"); + memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl); + cx->tlen += cx->txdl; + free(cx->txd); + cx->txd = NULL; + cx->txdl = 0; + } + else + { + // generate GET + cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 89 + cx->thlen); + cx->tptr = 0; + cx->tlen = 0; + cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host); + if (cx->thdr) + { + memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen); + cx->tlen += cx->thlen; + free(cx->thdr); + cx->thdr = NULL; + cx->thlen = 0; + } + if (!cx->keep) + cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n"); #ifdef BETA - cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); #else - cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); + cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION); #endif - cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n"); - } - cx->state = HTS_XMIT; - cx->last = now; - return 0; - case HTS_XMIT: - tmp = send(cx->fd, cx->tbuf+cx->tptr, cx->tlen-cx->tptr, 0); - if(tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR) - goto fail; - if(tmp!=PERROR) - { - cx->tptr += tmp; - if(cx->tptr == cx->tlen) - { - cx->tptr = 0; - cx->tlen = 0; - if(cx->tbuf) - free(cx->tbuf); - cx->state = HTS_RECV; - } - cx->last = now; - } - if(now-cx->last>http_timeout) - goto timeout; - return 0; - case HTS_RECV: - tmp = recv(cx->fd, buf, CHUNK, 0); - if(tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR) - goto fail; - if(tmp!=PERROR) - { - for(i=0; istate == HTS_DONE) - return 1; - } - cx->last = now; - } - if(now-cx->last>http_timeout) - goto timeout; - return 0; - case HTS_DONE: - return 1; - } - return 0; + cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n"); + } + cx->state = HTS_XMIT; + cx->last = now; + return 0; + case HTS_XMIT: + tmp = send(cx->fd, cx->tbuf+cx->tptr, cx->tlen-cx->tptr, 0); + if (tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR) + goto fail; + if (tmp!=PERROR) + { + cx->tptr += tmp; + if (cx->tptr == cx->tlen) + { + cx->tptr = 0; + cx->tlen = 0; + if (cx->tbuf) + free(cx->tbuf); + cx->state = HTS_RECV; + } + cx->last = now; + } + if (now-cx->last>http_timeout) + goto timeout; + return 0; + case HTS_RECV: + tmp = recv(cx->fd, buf, CHUNK, 0); + if (tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR) + goto fail; + if (tmp!=PERROR) + { + for (i=0; istate == HTS_DONE) + return 1; + } + cx->last = now; + } + if (now-cx->last>http_timeout) + goto timeout; + return 0; + case HTS_DONE: + return 1; + } + return 0; fail: - cx->ret = 600; - cx->state = HTS_DONE; - return 1; + cx->ret = 600; + cx->state = HTS_DONE; + return 1; timeout: - cx->ret = 605; - cx->state = HTS_DONE; - return 1; + cx->ret = 605; + cx->state = HTS_DONE; + return 1; } char *http_async_req_stop(void *ctx, int *ret, int *len) { - struct http_ctx *cx = ctx; - char *rxd; + struct http_ctx *cx = ctx; + char *rxd; - if(cx->state != HTS_DONE) - while(!http_async_req_status(ctx)) ; + if (cx->state != HTS_DONE) + while (!http_async_req_status(ctx)) ; - if(cx->host) - { - free(cx->host); - cx->host = NULL; - } - if(cx->path) - { - free(cx->path); - cx->path = NULL; - } - if(cx->txd) - { - free(cx->txd); - cx->txd = NULL; - cx->txdl = 0; - } - if(cx->hbuf) - { - free(cx->hbuf); - cx->hbuf = NULL; - } - if(cx->thdr) - { - free(cx->thdr); - cx->thdr = NULL; - cx->thlen = 0; - } + if (cx->host) + { + free(cx->host); + cx->host = NULL; + } + if (cx->path) + { + free(cx->path); + cx->path = NULL; + } + if (cx->txd) + { + free(cx->txd); + cx->txd = NULL; + cx->txdl = 0; + } + if (cx->hbuf) + { + free(cx->hbuf); + cx->hbuf = NULL; + } + if (cx->thdr) + { + free(cx->thdr); + cx->thdr = NULL; + cx->thlen = 0; + } - if(ret) - *ret = cx->ret; - if(len) - *len = cx->rptr; - if(cx->rbuf) - cx->rbuf[cx->rptr] = 0; - rxd = cx->rbuf; - cx->rbuf = NULL; - cx->rlen = 0; - cx->rptr = 0; - cx->contlen = 0; + if (ret) + *ret = cx->ret; + if (len) + *len = cx->rptr; + if (cx->rbuf) + cx->rbuf[cx->rptr] = 0; + rxd = cx->rbuf; + cx->rbuf = NULL; + cx->rlen = 0; + cx->rptr = 0; + cx->contlen = 0; - if(!cx->keep) - http_async_req_close(ctx); - else if(cx->cclose) - { - PCLOSE(cx->fd); - cx->fd = PERROR; - if(cx->fdhost) - { - free(cx->fdhost); - cx->fdhost = NULL; - } - cx->state = HTS_STRT; - } - else - cx->state = HTS_IDLE; + if (!cx->keep) + http_async_req_close(ctx); + else if (cx->cclose) + { + PCLOSE(cx->fd); + cx->fd = PERROR; + if (cx->fdhost) + { + free(cx->fdhost); + cx->fdhost = NULL; + } + cx->state = HTS_STRT; + } + else + cx->state = HTS_IDLE; - return rxd; + return rxd; } void http_async_get_length(void *ctx, int *total, int *done) { - struct http_ctx *cx = ctx; - if(done) - *done = cx->rptr; - if(total) - *total = cx->contlen; + struct http_ctx *cx = ctx; + if (done) + *done = cx->rptr; + if (total) + *total = cx->contlen; } void http_async_req_close(void *ctx) { - struct http_ctx *cx = ctx; - void *tmp; - if(cx->host) - { - cx->keep = 1; - tmp = http_async_req_stop(ctx, NULL, NULL); - if(tmp) - free(tmp); - } - if(cx->fdhost) - free(cx->fdhost); - PCLOSE(cx->fd); - free(ctx); + struct http_ctx *cx = ctx; + void *tmp; + if (cx->host) + { + cx->keep = 1; + tmp = http_async_req_stop(ctx, NULL, NULL); + if (tmp) + free(tmp); + } + if (cx->fdhost) + free(cx->fdhost); + PCLOSE(cx->fd); + free(ctx); } char *http_simple_get(char *uri, int *ret, int *len) { - void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); - if(!ctx) - { - if(ret) - *ret = 600; - if(len) - *len = 0; - return NULL; - } - return http_async_req_stop(ctx, ret, len); + void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); + if (!ctx) + { + if (ret) + *ret = 600; + if (len) + *len = 0; + return NULL; + } + return http_async_req_stop(ctx, ret, len); } static char hex[] = "0123456789abcdef"; void http_auth_headers(void *ctx, char *user, char *pass) { - char *tmp; - int i; - unsigned char hash[16]; - unsigned int m; - struct md5_context md5; + char *tmp; + int i; + unsigned char hash[16]; + unsigned int m; + struct md5_context md5; - if(user) - { - http_async_add_header(ctx, "X-Auth-User", user); - if(pass) - { - md5_init(&md5); - md5_update(&md5, (unsigned char *)user, strlen(user)); - md5_update(&md5, (unsigned char *)"-", 1); - m = 0; + if (user) + { + http_async_add_header(ctx, "X-Auth-User", user); + if (pass) + { + md5_init(&md5); + md5_update(&md5, (unsigned char *)user, strlen(user)); + md5_update(&md5, (unsigned char *)"-", 1); + m = 0; - md5_update(&md5, (unsigned char *)pass, strlen(pass)); - md5_final(hash, &md5); - tmp = malloc(33); - for(i=0; i<16; i++) - { - tmp[i*2] = hex[hash[i]>>4]; - tmp[i*2+1] = hex[hash[i]&15]; - } - tmp[32] = 0; - http_async_add_header(ctx, "X-Auth-Hash", tmp); - free(tmp); - } - } + md5_update(&md5, (unsigned char *)pass, strlen(pass)); + md5_final(hash, &md5); + tmp = malloc(33); + for (i=0; i<16; i++) + { + tmp[i*2] = hex[hash[i]>>4]; + tmp[i*2+1] = hex[hash[i]&15]; + } + tmp[32] = 0; + http_async_add_header(ctx, "X-Auth-Hash", tmp); + free(tmp); + } + } } char *http_auth_get(char *uri, char *user, char *pass, int *ret, int *len) { - void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); + void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0); - if(!ctx) - { - if(ret) - *ret = 600; - if(len) - *len = 0; - return NULL; - } - return http_async_req_stop(ctx, ret, len); + if (!ctx) + { + if (ret) + *ret = 600; + if (len) + *len = 0; + return NULL; + } + return http_async_req_stop(ctx, ret, len); } char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len) { - void *ctx = http_async_req_start(NULL, uri, data, dlen, 0); - if(!ctx) - { - if(ret) - *ret = 600; - if(len) - *len = 0; - return NULL; - } - return http_async_req_stop(ctx, ret, len); + void *ctx = http_async_req_start(NULL, uri, data, dlen, 0); + if (!ctx) + { + if (ret) + *ret = 600; + if (len) + *len = 0; + return NULL; + } + return http_async_req_stop(ctx, ret, len); } char *http_ret_text(int ret) { - switch(ret) - { - case 100: - return "Continue"; - case 101: - return "Switching Protocols"; - case 102: - return "Processing"; + switch (ret) + { + case 100: + return "Continue"; + case 101: + return "Switching Protocols"; + case 102: + return "Processing"; - case 200: - return "OK"; - case 201: - return "Created"; - case 202: - return "Accepted"; - case 203: - return "Non-Authoritative Information"; - case 204: - return "No Content"; - case 205: - return "Reset Content"; - case 206: - return "Partial Content"; - case 207: - return "Multi-Status"; + case 200: + return "OK"; + case 201: + return "Created"; + case 202: + return "Accepted"; + case 203: + return "Non-Authoritative Information"; + case 204: + return "No Content"; + case 205: + return "Reset Content"; + case 206: + return "Partial Content"; + case 207: + return "Multi-Status"; - case 300: - return "Multiple Choices"; - case 301: - return "Moved Permanently"; - case 302: - return "Found"; - case 303: - return "See Other"; - case 304: - return "Not Modified"; - case 305: - return "Use Proxy"; - case 306: - return "Switch Proxy"; - case 307: - return "Temporary Redirect"; + case 300: + return "Multiple Choices"; + case 301: + return "Moved Permanently"; + case 302: + return "Found"; + case 303: + return "See Other"; + case 304: + return "Not Modified"; + case 305: + return "Use Proxy"; + case 306: + return "Switch Proxy"; + case 307: + return "Temporary Redirect"; - case 400: - return "Bad Request"; - case 401: - return "Unauthorized"; - case 402: - return "Payment Required"; - case 403: - return "Forbidden"; - case 404: - return "Not Found"; - case 405: - return "Method Not Allowed"; - case 406: - return "Not Acceptable"; - case 407: - return "Proxy Authentication Required"; - case 408: - return "Request Timeout"; - case 409: - return "Conflict"; - case 410: - return "Gone"; - case 411: - return "Length Required"; - case 412: - return "Precondition Failed"; - case 413: - return "Request Entity Too Large"; - case 414: - return "Request URI Too Long"; - case 415: - return "Unsupported Media Type"; - case 416: - return "Requested Range Not Satisfiable"; - case 417: - return "Expectation Failed"; - case 422: - return "Unprocessable Entity"; - case 423: - return "Locked"; - case 424: - return "Failed Dependency"; - case 425: - return "Unordered Collection"; - case 426: - return "Upgrade Required"; + case 400: + return "Bad Request"; + case 401: + return "Unauthorized"; + case 402: + return "Payment Required"; + case 403: + return "Forbidden"; + case 404: + return "Not Found"; + case 405: + return "Method Not Allowed"; + case 406: + return "Not Acceptable"; + case 407: + return "Proxy Authentication Required"; + case 408: + return "Request Timeout"; + case 409: + return "Conflict"; + case 410: + return "Gone"; + case 411: + return "Length Required"; + case 412: + return "Precondition Failed"; + case 413: + return "Request Entity Too Large"; + case 414: + return "Request URI Too Long"; + case 415: + return "Unsupported Media Type"; + case 416: + return "Requested Range Not Satisfiable"; + case 417: + return "Expectation Failed"; + case 422: + return "Unprocessable Entity"; + case 423: + return "Locked"; + case 424: + return "Failed Dependency"; + case 425: + return "Unordered Collection"; + case 426: + return "Upgrade Required"; - case 500: - return "Internal Server Error"; - case 501: - return "Not Implemented"; - case 502: - return "Bad Gateway"; - case 503: - return "Service Unavailable"; - case 504: - return "Gateway Timeout"; - case 505: - return "HTTP Version Not Supported"; - case 506: - return "Variant Also Negotiates"; - case 507: - return "Insufficient Storage"; - case 509: - return "Bandwidth Limit Exceeded"; - case 510: - return "Not Extended"; + case 500: + return "Internal Server Error"; + case 501: + return "Not Implemented"; + case 502: + return "Bad Gateway"; + case 503: + return "Service Unavailable"; + case 504: + return "Gateway Timeout"; + case 505: + return "HTTP Version Not Supported"; + case 506: + return "Variant Also Negotiates"; + case 507: + return "Insufficient Storage"; + case 509: + return "Bandwidth Limit Exceeded"; + case 510: + return "Not Extended"; - case 600: - return "Internal Client Error"; - case 601: - return "Unsupported Protocol"; - case 602: - return "Server Not Found"; - case 603: - return "Malformed Response"; - case 604: - return "Network Not Available"; - case 605: - return "Request Timed Out"; - default: - return "Unknown Status Code"; - } + case 600: + return "Internal Client Error"; + case 601: + return "Unsupported Protocol"; + case 602: + return "Server Not Found"; + case 603: + return "Malformed Response"; + case 604: + return "Network Not Available"; + case 605: + return "Request Timed Out"; + default: + return "Unknown Status Code"; + } } char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, int *ret, int *len) { - void *ctx; - char *data = NULL, *tmp, *p; - int dlen = 0, i, j; - unsigned char hash[16]; - unsigned char boundary[32], ch; - int blen = 0; - unsigned int map[62], m; - struct md5_context md5; - //struct md5_context md52; - int own_plen = 0; + void *ctx; + char *data = NULL, *tmp, *p; + int dlen = 0, i, j; + unsigned char hash[16]; + unsigned char boundary[32], ch; + int blen = 0; + unsigned int map[62], m; + struct md5_context md5; + //struct md5_context md52; + int own_plen = 0; - if(names) - { - if(!plens) - { - own_plen = 1; - for(i=0; names[i]; i++) ; - plens = calloc(i, sizeof(int)); - for(i=0; names[i]; i++) - plens[i] = strlen(parts[i]); - } + if (names) + { + if (!plens) + { + own_plen = 1; + for (i=0; names[i]; i++) ; + plens = calloc(i, sizeof(int)); + for (i=0; names[i]; i++) + plens[i] = strlen(parts[i]); + } retry: - if(blen >= 31) - goto fail; - memset(map, 0, 62*sizeof(int)); - for(i=0; names[i]; i++) - { - for(j=0; j='0' && ch<='9') - map[ch-'0']++; - else if(ch>='A' && ch<='Z') - map[ch-'A'+10]++; - else if(ch>='a' && ch<='z') - map[ch-'a'+36]++; - } - } - m = ~0; - j = 61; - for(i=0; i<62; i++) - if(map[i]= 31) + goto fail; + memset(map, 0, 62*sizeof(int)); + for (i=0; names[i]; i++) + { + for (j=0; j='0' && ch<='9') + map[ch-'0']++; + else if (ch>='A' && ch<='Z') + map[ch-'A'+10]++; + else if (ch>='a' && ch<='z') + map[ch-'a'+36]++; + } + } + m = ~0; + j = 61; + for (i=0; i<62; i++) + if (map[i]>4]; - tmp[i*2+1] = hex[hash[i]&15]; - } - tmp[32] = 0; - http_async_add_header(ctx, "X-Auth-Hash", tmp); - free(tmp); - } - } + md5_update(&md5, (unsigned char *)pass, strlen(pass)); + md5_final(hash, &md5); + tmp = malloc(33); + for (i=0; i<16; i++) + { + tmp[i*2] = hex[hash[i]>>4]; + tmp[i*2+1] = hex[hash[i]&15]; + } + tmp[32] = 0; + http_async_add_header(ctx, "X-Auth-Hash", tmp); + free(tmp); + } + } - if(data) - { - tmp = malloc(32+strlen((char *)boundary)); - sprintf(tmp, "multipart/form-data, boundary=%s", boundary); - http_async_add_header(ctx, "Content-type", tmp); - free(tmp); - free(data); - } + if (data) + { + tmp = malloc(32+strlen((char *)boundary)); + sprintf(tmp, "multipart/form-data, boundary=%s", boundary); + http_async_add_header(ctx, "Content-type", tmp); + free(tmp); + free(data); + } - if(own_plen) - free(plens); - return http_async_req_stop(ctx, ret, len); + if (own_plen) + free(plens); + return http_async_req_stop(ctx, ret, len); fail: - if(data) - free(data); - if(own_plen) - free(plens); - if(ret) - *ret = 600; - if(len) - *len = 0; - return NULL; + if (data) + free(data); + if (own_plen) + free(plens); + if (ret) + *ret = 600; + if (len) + *len = 0; + return NULL; } diff --git a/src/interface.c b/src/interface.c index b37c3e9f0..05016c278 100644 --- a/src/interface.c +++ b/src/interface.c @@ -68,236 +68,236 @@ unsigned char ZSIZE = ZSIZE_D; void menu_count(void) { - int i=0; - msections[SC_WALL].itemcount = UI_WALLCOUNT-4; - msections[SC_SPECIAL].itemcount = 4; - for(i=0; i 18) ? signs[i].y - 18 : signs[i].y + 4; + //Ususal width + if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) + *w = textwidth(signs[i].text) + 5; + *h = 14; + *x0 = (signs[i].ju == 2) ? signs[i].x - *w : + (signs[i].ju == 1) ? signs[i].x - *w/2 : signs[i].x; + *y0 = (signs[i].y > 18) ? signs[i].y - 18 : signs[i].y + 4; } void add_sign_ui(pixel *vid_buf, int mx, int my) { - int i, w, h, x, y, nm=0, ju; - int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq; - ui_edit ed; - - // check if it is an existing sign - for(i=0; i=x && mx<=x+w && my>=y && my<=y+h) + break; } - get_sign_pos(i, &x, &y, &w, &h); - if(mx>=x && mx<=x+w && my>=y && my<=y+h) - break; - } - // else look for empty spot - if(i >= MAXSIGNS) - { - nm = 1; - for(i=0; i= MAXSIGNS) - return; - if(nm) - { - signs[i].x = mx; - signs[i].y = my; - signs[i].ju = 1; - } - - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } - - ed.x = x0+25; - ed.y = y0+25; - ed.w = 158; - ed.nx = 1; - ed.def = "[message]"; - ed.focus = 1; - ed.hide = 0; - ed.cursor = strlen(signs[i].text); - ed.multiline = 0; - strcpy(ed.str, signs[i].text); - ju = signs[i].ju; - - fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192); - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; - - drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255); - clearrect(vid_buf, x0, y0, 192, 80); - drawtext(vid_buf, x0+8, y0+8, nm ? "New sign:" : "Edit sign:", 255, 255, 255, 255); - drawtext(vid_buf, x0+12, y0+23, "\xA1", 32, 64, 128, 255); - drawtext(vid_buf, x0+12, y0+23, "\xA0", 255, 255, 255, 255); - drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255); - ui_edit_draw(vid_buf, &ed); - drawtext(vid_buf, x0+8, y0+46, "Justify:", 255, 255, 255, 255); - draw_icon(vid_buf, x0+50, y0+42, 0x9D, ju == 0); - draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1); - draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2); - - - - - - if(!nm) - { - drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255); - drawtext(vid_buf, x0+138, y0+45, "\x85", 255, 255, 255, 255); - drawtext(vid_buf, x0+152, y0+46, "Delete", 255, 255, 255, 255); - drawrect(vid_buf, x0+134, y0+42, 50, 15, 255, 255, 255, 255); - drawrect(vid_buf,x0+104,y0+42,26,15,255,255,255,255); - drawtext(vid_buf, x0+110, y0+48, "Mv.", 255, 255, 255, 255); - } - - drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255); - drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); - - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - - ui_edit_process(mx, my, b, &ed); - - if(b && !bq && mx>=x0+50 && mx<=x0+67 && my>=y0+42 && my<=y0+59) - ju = 0; - if(b && !bq && mx>=x0+68 && mx<=x0+85 && my>=y0+42 && my<=y0+59) - ju = 1; - if(b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59) - ju = 2; - - if(!nm && b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59) + // else look for empty spot + if (i >= MAXSIGNS) { - MSIGN = i; - break; + nm = 1; + for (i=0; i= MAXSIGNS) + return; + if (nm) + { + signs[i].x = mx; + signs[i].y = my; + signs[i].ju = 1; } - if(b && !bq && mx>=x0+9 && mx=y0+22 && my=x0 && mx=y0+64 && my<=y0+80) - break; - if(!nm && b && !bq && mx>=x0+134 && my>=y0+42 && mx<=x0+184 && my<=y0+59) - { - signs[i].text[0] = 0; - return; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - if(sdl_key==SDLK_RETURN) - break; - if(sdl_key==SDLK_ESCAPE) - { - if(!ed.focus) - return; - ed.focus = 0; - } - } + ed.x = x0+25; + ed.y = y0+25; + ed.w = 158; + ed.nx = 1; + ed.def = "[message]"; + ed.focus = 1; + ed.hide = 0; + ed.cursor = strlen(signs[i].text); + ed.multiline = 0; + strcpy(ed.str, signs[i].text); + ju = signs[i].ju; - strcpy(signs[i].text, ed.str); - signs[i].ju = ju; + fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192); + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + + drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255); + clearrect(vid_buf, x0, y0, 192, 80); + drawtext(vid_buf, x0+8, y0+8, nm ? "New sign:" : "Edit sign:", 255, 255, 255, 255); + drawtext(vid_buf, x0+12, y0+23, "\xA1", 32, 64, 128, 255); + drawtext(vid_buf, x0+12, y0+23, "\xA0", 255, 255, 255, 255); + drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255); + ui_edit_draw(vid_buf, &ed); + drawtext(vid_buf, x0+8, y0+46, "Justify:", 255, 255, 255, 255); + draw_icon(vid_buf, x0+50, y0+42, 0x9D, ju == 0); + draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1); + draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2); + + + + + + if (!nm) + { + drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255); + drawtext(vid_buf, x0+138, y0+45, "\x85", 255, 255, 255, 255); + drawtext(vid_buf, x0+152, y0+46, "Delete", 255, 255, 255, 255); + drawrect(vid_buf, x0+134, y0+42, 50, 15, 255, 255, 255, 255); + drawrect(vid_buf,x0+104,y0+42,26,15,255,255,255,255); + drawtext(vid_buf, x0+110, y0+48, "Mv.", 255, 255, 255, 255); + } + + drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255); + drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); + + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + + ui_edit_process(mx, my, b, &ed); + + if (b && !bq && mx>=x0+50 && mx<=x0+67 && my>=y0+42 && my<=y0+59) + ju = 0; + if (b && !bq && mx>=x0+68 && mx<=x0+85 && my>=y0+42 && my<=y0+59) + ju = 1; + if (b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59) + ju = 2; + + if (!nm && b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59) + { + MSIGN = i; + break; + } + if (b && !bq && mx>=x0+9 && mx=y0+22 && my=x0 && mx=y0+64 && my<=y0+80) + break; + + if (!nm && b && !bq && mx>=x0+134 && my>=y0+42 && mx<=x0+184 && my<=y0+59) + { + signs[i].text[0] = 0; + return; + } + + if (sdl_key==SDLK_RETURN) + break; + if (sdl_key==SDLK_ESCAPE) + { + if (!ed.focus) + return; + ed.focus = 0; + } + } + + strcpy(signs[i].text, ed.str); + signs[i].ju = ju; } //TODO: Finish text wrapping in text edits void ui_edit_draw(pixel *vid_buf, ui_edit *ed) { - int cx, i, cy; - char echo[256], *str; + int cx, i, cy; + char echo[256], *str; - if(ed->hide) - { - for(i=0; ed->str[i]; i++) - echo[i] = 0x8D; - echo[i] = 0; - str = echo; - } - else - str = ed->str; + if (ed->hide) + { + for (i=0; ed->str[i]; i++) + echo[i] = 0x8D; + echo[i] = 0; + str = echo; + } + else + str = ed->str; - if(ed->str[0]) - { - if(ed->multiline){ + if (ed->str[0]) + { + if (ed->multiline) { 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); } else { drawtext(vid_buf, ed->x, ed->y, str, 255, 255, 255, 255); drawtext(vid_buf, ed->x+ed->w-11, ed->y-1, "\xAA", 128, 128, 128, 255); } - } - else if(!ed->focus) - drawtext(vid_buf, ed->x, ed->y, ed->def, 128, 128, 128, 255); - if(ed->focus) - { - if(ed->multiline){ + } + else if (!ed->focus) + drawtext(vid_buf, ed->x, ed->y, ed->def, 128, 128, 128, 255); + if (ed->focus) + { + if (ed->multiline) { textnpos(str, ed->cursor, ed->w-14, &cx, &cy); } else { cx = textnwidth(str, ed->cursor); - cy = 0; + cy = 0; } - - for(i=-3; i<9; i++) - drawpixel(vid_buf, ed->x+cx, ed->y+i+cy, 255, 255, 255, 255); - } + + for (i=-3; i<9; i++) + drawpixel(vid_buf, ed->x+cx, ed->y+i+cy, 255, 255, 255, 255); + } } void ui_edit_process(int mx, int my, int mb, ui_edit *ed) { - char ch, ts[2], echo[256], *str; - int l, i; + char ch, ts[2], echo[256], *str; + int l, i; #ifdef RAWINPUT - char *p; + char *p; #endif - if(mb) - { - if(ed->hide) - { - for(i=0; ed->str[i]; i++) - echo[i] = 0x8D; - echo[i] = 0; - str = echo; - } - else - str = ed->str; + if (mb) + { + if (ed->hide) + { + for (i=0; ed->str[i]; i++) + echo[i] = 0x8D; + echo[i] = 0; + str = echo; + } + else + str = ed->str; - if(ed->multiline){ - if(mx>=ed->x+ed->w-11 && mxx+ed->w && my>=ed->y-5 && myy+11) + if (ed->multiline) { + if (mx>=ed->x+ed->w-11 && mxx+ed->w && my>=ed->y-5 && myy+11) { ed->focus = 1; ed->cursor = 0; ed->str[0] = 0; } - else if(mx>=ed->x-ed->nx && mxx+ed->w && my>=ed->y-5 && myy+ed->h) + else if (mx>=ed->x-ed->nx && mxx+ed->w && my>=ed->y-5 && myy+ed->h) { ed->focus = 1; ed->cursor = textposxy(str, ed->w-14, mx-ed->x, my-ed->y); @@ -305,13 +305,13 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed) else ed->focus = 0; } else { - if(mx>=ed->x+ed->w-11 && mxx+ed->w && my>=ed->y-5 && myy+11) + if (mx>=ed->x+ed->w-11 && mxx+ed->w && my>=ed->y-5 && myy+11) { ed->focus = 1; ed->cursor = 0; ed->str[0] = 0; } - else if(mx>=ed->x-ed->nx && mxx+ed->w && my>=ed->y-5 && myy+11) + else if (mx>=ed->x-ed->nx && mxx+ed->w && my>=ed->y-5 && myy+11) { ed->focus = 1; ed->cursor = textwidthx(str, mx-ed->x); @@ -319,1558 +319,1558 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed) else ed->focus = 0; } - } - if(ed->focus && sdl_key) - { - if(ed->hide) - { - for(i=0; ed->str[i]; i++) - echo[i] = 0x8D; - echo[i] = 0; - str = echo; - } - else - str = ed->str; + } + if (ed->focus && sdl_key) + { + if (ed->hide) + { + for (i=0; ed->str[i]; i++) + echo[i] = 0x8D; + echo[i] = 0; + str = echo; + } + else + str = ed->str; - l = strlen(ed->str); - switch(sdl_key) - { - case SDLK_HOME: - ed->cursor = 0; - break; - case SDLK_END: - ed->cursor = l; - break; - case SDLK_LEFT: - if(ed->cursor > 0) - ed->cursor --; - break; - case SDLK_RIGHT: - if(ed->cursor < l) - ed->cursor ++; - break; - case SDLK_DELETE: - if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) - ed->str[ed->cursor] = 0; - else if(ed->cursor < l) - memmove(ed->str+ed->cursor, ed->str+ed->cursor+1, l-ed->cursor); - break; - case SDLK_BACKSPACE: - if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) - { - if(ed->cursor > 0) - memmove(ed->str, ed->str+ed->cursor, l-ed->cursor+1); - ed->cursor = 0; - } - else if(ed->cursor > 0) - { - ed->cursor--; - memmove(ed->str+ed->cursor, ed->str+ed->cursor+1, l-ed->cursor); - } - break; - default: + l = strlen(ed->str); + switch (sdl_key) + { + case SDLK_HOME: + ed->cursor = 0; + break; + case SDLK_END: + ed->cursor = l; + break; + case SDLK_LEFT: + if (ed->cursor > 0) + ed->cursor --; + break; + case SDLK_RIGHT: + if (ed->cursor < l) + ed->cursor ++; + break; + case SDLK_DELETE: + if (sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) + ed->str[ed->cursor] = 0; + else if (ed->cursor < l) + memmove(ed->str+ed->cursor, ed->str+ed->cursor+1, l-ed->cursor); + break; + case SDLK_BACKSPACE: + if (sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) + { + if (ed->cursor > 0) + memmove(ed->str, ed->str+ed->cursor, l-ed->cursor+1); + ed->cursor = 0; + } + else if (ed->cursor > 0) + { + ed->cursor--; + memmove(ed->str+ed->cursor, ed->str+ed->cursor+1, l-ed->cursor); + } + break; + default: #ifdef RAWINPUT - if(sdl_key>=SDLK_SPACE && sdl_key<=SDLK_z && l<255) - { - ch = sdl_key; - if((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT|KMOD_CAPS))) - { - if(ch>='a' && ch<='z') - ch &= ~0x20; - p = strchr(shift_0, ch); - if(p) - ch = shift_1[p-shift_0]; - } - ts[0]=ed->hide?0x8D:ch; - ts[1]=0; - if((textwidth(str)+textwidth(ts) > ed->w-14 && !ed->multiline) || (float)(((textwidth(str)+textwidth(ts))/(ed->w-14)*12) > ed->h && ed->multiline)) - break; - memmove(ed->str+ed->cursor+1, ed->str+ed->cursor, l+1-ed->cursor); - ed->str[ed->cursor] = ch; - ed->cursor++; - } + if (sdl_key>=SDLK_SPACE && sdl_key<=SDLK_z && l<255) + { + ch = sdl_key; + if ((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT|KMOD_CAPS))) + { + if (ch>='a' && ch<='z') + ch &= ~0x20; + p = strchr(shift_0, ch); + if (p) + ch = shift_1[p-shift_0]; + } + ts[0]=ed->hide?0x8D:ch; + ts[1]=0; + if ((textwidth(str)+textwidth(ts) > ed->w-14 && !ed->multiline) || (float)(((textwidth(str)+textwidth(ts))/(ed->w-14)*12) > ed->h && ed->multiline)) + break; + memmove(ed->str+ed->cursor+1, ed->str+ed->cursor, l+1-ed->cursor); + ed->str[ed->cursor] = ch; + ed->cursor++; + } #else - if(sdl_ascii>=' ' && sdl_ascii<127 && l<255) - { - ch = sdl_ascii; - ts[0]=ed->hide?0x8D:ch; - ts[1]=0; - if((textwidth(str)+textwidth(ts) > ed->w-14 && !ed->multiline) || (float)(((textwidth(str)+textwidth(ts))/(ed->w-14)*12) > ed->h && ed->multiline)) - break; - memmove(ed->str+ed->cursor+1, ed->str+ed->cursor, l+1-ed->cursor); - ed->str[ed->cursor] = ch; - ed->cursor++; - } + if (sdl_ascii>=' ' && sdl_ascii<127 && l<255) + { + ch = sdl_ascii; + ts[0]=ed->hide?0x8D:ch; + ts[1]=0; + if ((textwidth(str)+textwidth(ts) > ed->w-14 && !ed->multiline) || (float)(((textwidth(str)+textwidth(ts))/(ed->w-14)*12) > ed->h && ed->multiline)) + break; + memmove(ed->str+ed->cursor+1, ed->str+ed->cursor, l+1-ed->cursor); + ed->str[ed->cursor] = ch; + ed->cursor++; + } #endif - break; - } - } + break; + } + } } void ui_checkbox_draw(pixel *vid_buf, ui_checkbox *ed) { - int w = 12; - if(ed->checked) - { - drawtext(vid_buf, ed->x+2, ed->y+2, "\xCF", 128, 128, 128, 255); - } - if(ed->focus) - { - drawrect(vid_buf, ed->x, ed->y, w, w, 255, 255, 255, 255); - } - else - { - drawrect(vid_buf, ed->x, ed->y, w, w, 128, 128, 128, 255); - } + int w = 12; + if (ed->checked) + { + drawtext(vid_buf, ed->x+2, ed->y+2, "\xCF", 128, 128, 128, 255); + } + if (ed->focus) + { + drawrect(vid_buf, ed->x, ed->y, w, w, 255, 255, 255, 255); + } + else + { + drawrect(vid_buf, ed->x, ed->y, w, w, 128, 128, 128, 255); + } } void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed) { - int w = 12; + int w = 12; - if(mb && !mbq) - { - if(mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w) - { - ed->checked = (ed->checked)?0:1; - } - } - else - { - if(mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w) - { - ed->focus = 1; - } - else - { - ed->focus = 0; - } - } + if (mb && !mbq) + { + if (mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w) + { + ed->checked = (ed->checked)?0:1; + } + } + else + { + if (mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w) + { + ed->focus = 1; + } + else + { + ed->focus = 0; + } + } } void draw_svf_ui(pixel *vid_buf) { - int c; + int c; - drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255); - drawrect(vid_buf, 1, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255); + drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255); + drawrect(vid_buf, 1, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255); - c = svf_open ? 255 : 128; - drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); - drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255); + c = svf_open ? 255 : 128; + drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); + drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255); - c = svf_login ? 255 : 128; - drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", c, c, c, 255); - if(svf_open) - drawtext(vid_buf, 58, YRES+(MENUSIZE-12), svf_name, c, c, c, 255); - else - drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[untitled simulation]", c, c, c, 255); - drawrect(vid_buf, 37, YRES+(MENUSIZE-16), 150, 14, c, c, c, 255); - if(svf_open && svf_own) - drawdots(vid_buf, 55, YRES+(MENUSIZE-15), 12, c, c, c, 255); + c = svf_login ? 255 : 128; + drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", c, c, c, 255); + if (svf_open) + drawtext(vid_buf, 58, YRES+(MENUSIZE-12), svf_name, c, c, c, 255); + else + drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[untitled simulation]", c, c, c, 255); + drawrect(vid_buf, 37, YRES+(MENUSIZE-16), 150, 14, c, c, c, 255); + if (svf_open && svf_own) + drawdots(vid_buf, 55, YRES+(MENUSIZE-15), 12, c, c, c, 255); - c = (svf_login && svf_open) ? 255 : 128; + c = (svf_login && svf_open) ? 255 : 128; - drawrect(vid_buf, 189, YRES+(MENUSIZE-16), 14, 14, c, c, c, 255); - drawrect(vid_buf, 203, YRES+(MENUSIZE-16), 14, 14, c, c, c, 255); + drawrect(vid_buf, 189, YRES+(MENUSIZE-16), 14, 14, c, c, c, 255); + drawrect(vid_buf, 203, YRES+(MENUSIZE-16), 14, 14, c, c, c, 255); - if(svf_myvote==1 && (svf_login && svf_open)) - { - fillrect(vid_buf, 189, YRES+(MENUSIZE-16), 14, 14, 0, 108, 10, 255); - } - else if(svf_myvote==-1 && (svf_login && svf_open)) - { - fillrect(vid_buf, 203, YRES+(MENUSIZE-16), 14, 14, 108, 10, 0, 255); - } + if (svf_myvote==1 && (svf_login && svf_open)) + { + fillrect(vid_buf, 189, YRES+(MENUSIZE-16), 14, 14, 0, 108, 10, 255); + } + else if (svf_myvote==-1 && (svf_login && svf_open)) + { + fillrect(vid_buf, 203, YRES+(MENUSIZE-16), 14, 14, 108, 10, 0, 255); + } - drawtext(vid_buf, 192, YRES+(MENUSIZE-12), "\xCB", 0, 187, 18, c); - drawtext(vid_buf, 205, YRES+(MENUSIZE-14), "\xCA", 187, 40, 0, c); + drawtext(vid_buf, 192, YRES+(MENUSIZE-12), "\xCB", 0, 187, 18, c); + drawtext(vid_buf, 205, YRES+(MENUSIZE-14), "\xCA", 187, 40, 0, c); - drawtext(vid_buf, 222, YRES+(MENUSIZE-15), "\x83", c, c, c, 255); - if(svf_tags[0]) - drawtextmax(vid_buf, 240, YRES+(MENUSIZE-12), 154, svf_tags, c, c, c, 255); - else - drawtext(vid_buf, 240, YRES+(MENUSIZE-12), "[no tags set]", c, c, c, 255); + drawtext(vid_buf, 222, YRES+(MENUSIZE-15), "\x83", c, c, c, 255); + if (svf_tags[0]) + drawtextmax(vid_buf, 240, YRES+(MENUSIZE-12), 154, svf_tags, c, c, c, 255); + else + drawtext(vid_buf, 240, YRES+(MENUSIZE-12), "[no tags set]", c, c, c, 255); - drawrect(vid_buf, 219, YRES+(MENUSIZE-16), XRES+BARSIZE-380, 14, c, c, c, 255); + drawrect(vid_buf, 219, YRES+(MENUSIZE-16), XRES+BARSIZE-380, 14, c, c, c, 255); - drawtext(vid_buf, XRES-139+BARSIZE/*371*/, YRES+(MENUSIZE-14), "\x92", 255, 255, 255, 255); - drawrect(vid_buf, XRES-143+BARSIZE/*367*/, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES-139+BARSIZE/*371*/, YRES+(MENUSIZE-14), "\x92", 255, 255, 255, 255); + drawrect(vid_buf, XRES-143+BARSIZE/*367*/, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255); - drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255); - if(svf_login) - drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 255); - else - drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[sign in]", 255, 255, 255, 255); - drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255); + if (svf_login) + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 255); + else + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[sign in]", 255, 255, 255, 255); + drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255); - if(sys_pause) - { - fillrect(vid_buf, XRES-17+BARSIZE/*493*/, YRES+(MENUSIZE-17), 16, 16, 255, 255, 255, 255); - drawtext(vid_buf, XRES-14+BARSIZE/*496*/, YRES+(MENUSIZE-14), "\x90", 0, 0, 0, 255); - } - else - { - drawtext(vid_buf, XRES-14+BARSIZE/*496*/, YRES+(MENUSIZE-14), "\x90", 255, 255, 255, 255); - drawrect(vid_buf, XRES-16+BARSIZE/*494*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); - } + if (sys_pause) + { + fillrect(vid_buf, XRES-17+BARSIZE/*493*/, YRES+(MENUSIZE-17), 16, 16, 255, 255, 255, 255); + drawtext(vid_buf, XRES-14+BARSIZE/*496*/, YRES+(MENUSIZE-14), "\x90", 0, 0, 0, 255); + } + else + { + drawtext(vid_buf, XRES-14+BARSIZE/*496*/, YRES+(MENUSIZE-14), "\x90", 255, 255, 255, 255); + drawrect(vid_buf, XRES-16+BARSIZE/*494*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); + } - if(!legacy_enable) - { - fillrect(vid_buf, XRES-160+BARSIZE/*493*/, YRES+(MENUSIZE-17), 16, 16, 255, 255, 255, 255); - drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); - drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 0, 0, 0, 255); - } - else - { - drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); - drawrect(vid_buf, XRES-159+BARSIZE/*494*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); - } + if (!legacy_enable) + { + fillrect(vid_buf, XRES-160+BARSIZE/*493*/, YRES+(MENUSIZE-17), 16, 16, 255, 255, 255, 255); + drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); + drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 0, 0, 0, 255); + } + else + { + drawtext(vid_buf, XRES-154+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); + drawrect(vid_buf, XRES-159+BARSIZE/*494*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); + } - switch(cmode) - { - case CM_VEL: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); - break; - case CM_PRESS: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); - break; - case CM_PERS: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); - break; - case CM_FIRE: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9B", 255, 0, 0, 255); - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9C", 255, 255, 64, 255); - break; - case CM_BLOB: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); - break; - case CM_HEAT: - drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); - drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); - break; - case CM_FANCY: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255); - break; - case CM_NOTHING: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); - break; - case CM_CRACK: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD4", 255, 55, 55, 255); + switch (cmode) + { + case CM_VEL: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); + break; + case CM_PRESS: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); + break; + case CM_PERS: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); + break; + case CM_FIRE: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9B", 255, 0, 0, 255); + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9C", 255, 255, 64, 255); + break; + case CM_BLOB: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); + break; + case CM_HEAT: + drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); + drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); + break; + case CM_FANCY: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255); + break; + case CM_NOTHING: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); + break; + case CM_CRACK: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD4", 255, 55, 55, 255); drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD5", 55, 255, 55, 255); - break; - case CM_GRAD: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD3", 255, 50, 255, 255); - break; - case CM_LIFE: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 255, 50, 255, 255); - break; - } - drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); + break; + case CM_GRAD: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD3", 255, 50, 255, 255); + break; + case CM_LIFE: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 255, 50, 255, 255); + break; + } + drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); - if(svf_admin) - { - drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC9", 232, 127, 35, 255); - drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC7", 255, 255, 255, 255); - drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC8", 255, 255, 255, 255); - } - else if(svf_mod) - { - drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC9", 35, 127, 232, 255); - drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC7", 255, 255, 255, 255); - }//else if(amd) - // drawtext(vid_buf, XRES-45/*465*/, YRES+(MENUSIZE-15), "\x97", 0, 230, 153, 255); Why is this here? + if (svf_admin) + { + drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC9", 232, 127, 35, 255); + drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC7", 255, 255, 255, 255); + drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC8", 255, 255, 255, 255); + } + else if (svf_mod) + { + drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC9", 35, 127, 232, 255); + drawtext(vid_buf, XRES-45+BARSIZE/*463*/, YRES+(MENUSIZE-14), "\xC7", 255, 255, 255, 255); + }//else if(amd) + // drawtext(vid_buf, XRES-45/*465*/, YRES+(MENUSIZE-15), "\x97", 0, 230, 153, 255); Why is this here? } void error_ui(pixel *vid_buf, int err, char *txt) { - int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; - char *msg; + int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; + char *msg; - msg = malloc(strlen(txt)+16); - if(err) - sprintf(msg, "%03d %s", err, txt); - else - sprintf(msg, "%s", txt); + msg = malloc(strlen(txt)+16); + if (err) + sprintf(msg, "%03d %s", err, txt); + else + sprintf(msg, "%s", txt); - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - clearrect(vid_buf, x0-2, y0-2, 244, 64); - drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); - if(err) - drawtext(vid_buf, x0+8, y0+8, "HTTP error:", 255, 64, 32, 255); - else - drawtext(vid_buf, x0+8, y0+8, "Error:", 255, 64, 32, 255); - drawtext(vid_buf, x0+8, y0+26, msg, 255, 255, 255, 255); - drawtext(vid_buf, x0+5, y0+49, "Dismiss", 255, 255, 255, 255); - drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + clearrect(vid_buf, x0-2, y0-2, 244, 64); + drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); + if (err) + drawtext(vid_buf, x0+8, y0+8, "HTTP error:", 255, 64, 32, 255); + else + drawtext(vid_buf, x0+8, y0+8, "Error:", 255, 64, 32, 255); + drawtext(vid_buf, x0+8, y0+26, msg, 255, 255, 255, 255); + drawtext(vid_buf, x0+5, y0+49, "Dismiss", 255, 255, 255, 255); + drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - if(b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) - break; + if (b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) + break; - if(sdl_key==SDLK_RETURN) - break; - if(sdl_key==SDLK_ESCAPE) - break; - } + if (sdl_key==SDLK_RETURN) + break; + if (sdl_key==SDLK_ESCAPE) + break; + } - free(msg); + free(msg); - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } } void info_ui(pixel *vid_buf, char *top, char *txt) { - int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; + int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - clearrect(vid_buf, x0-2, y0-2, 244, 64); - drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); - drawtext(vid_buf, x0+8, y0+8, top, 160, 160, 255, 255); - drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255); - drawtext(vid_buf, x0+5, y0+49, "OK", 255, 255, 255, 255); - drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + clearrect(vid_buf, x0-2, y0-2, 244, 64); + drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); + drawtext(vid_buf, x0+8, y0+8, top, 160, 160, 255, 255); + drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255); + drawtext(vid_buf, x0+5, y0+49, "OK", 255, 255, 255, 255); + drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - if(b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) - break; + if (b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) + break; - if(sdl_key==SDLK_RETURN) - break; - if(sdl_key==SDLK_ESCAPE) - break; - } + if (sdl_key==SDLK_RETURN) + break; + if (sdl_key==SDLK_ESCAPE) + break; + } - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } } void info_box(pixel *vid_buf, char *msg) { - int w = textwidth(msg)+16; - int x0=(XRES-w)/2,y0=(YRES-24)/2; + int w = textwidth(msg)+16; + int x0=(XRES-w)/2,y0=(YRES-24)/2; - clearrect(vid_buf, x0-2, y0-2, w+4, 28); - drawrect(vid_buf, x0, y0, w, 24, 192, 192, 192, 255); - drawtext(vid_buf, x0+8, y0+8, msg, 192, 192, 240, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + clearrect(vid_buf, x0-2, y0-2, w+4, 28); + drawrect(vid_buf, x0, y0, w, 24, 192, 192, 192, 255); + drawtext(vid_buf, x0+8, y0+8, msg, 192, 192, 240, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); } int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn) { - int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; - int ret = 0; + int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2,b=1,bq,mx,my; + int ret = 0; - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - clearrect(vid_buf, x0-2, y0-2, 244, 64); - drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); - drawtext(vid_buf, x0+8, y0+8, top, 255, 216, 32, 255); - drawtext(vid_buf, x0+8, y0+26, msg, 255, 255, 255, 255); - drawtext(vid_buf, x0+5, y0+49, "Cancel", 255, 255, 255, 255); - drawtext(vid_buf, x0+165, y0+49, btn, 255, 216, 32, 255); - drawrect(vid_buf, x0, y0+44, 160, 16, 192, 192, 192, 255); - drawrect(vid_buf, x0+160, y0+44, 80, 16, 192, 192, 192, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + clearrect(vid_buf, x0-2, y0-2, 244, 64); + drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); + drawtext(vid_buf, x0+8, y0+8, top, 255, 216, 32, 255); + drawtext(vid_buf, x0+8, y0+26, msg, 255, 255, 255, 255); + drawtext(vid_buf, x0+5, y0+49, "Cancel", 255, 255, 255, 255); + drawtext(vid_buf, x0+165, y0+49, btn, 255, 216, 32, 255); + drawrect(vid_buf, x0, y0+44, 160, 16, 192, 192, 192, 255); + drawrect(vid_buf, x0+160, y0+44, 80, 16, 192, 192, 192, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - if(b && !bq && mx>=x0+160 && mx=y0+44 && my<=y0+60) - { - ret = 1; - break; - } - if(b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) - break; + if (b && !bq && mx>=x0+160 && mx=y0+44 && my<=y0+60) + { + ret = 1; + break; + } + if (b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) + break; - if(sdl_key==SDLK_RETURN) - { - ret = 1; - break; - } - if(sdl_key==SDLK_ESCAPE) - break; - } + if (sdl_key==SDLK_RETURN) + { + ret = 1; + break; + } + if (sdl_key==SDLK_ESCAPE) + break; + } - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - return ret; + return ret; } void login_ui(pixel *vid_buf) { - int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq,mx,my,err; - ui_edit ed1,ed2; - char *res; + int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq,mx,my,err; + ui_edit ed1,ed2; + char *res; - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - ed1.x = x0+25; - ed1.y = y0+25; - ed1.w = 158; - ed1.nx = 1; - ed1.def = "[user name]"; - ed1.focus = 1; - ed1.hide = 0; - ed1.multiline = 0; - ed1.cursor = strlen(svf_user); - strcpy(ed1.str, svf_user); - ed2.x = x0+25; - ed2.y = y0+45; - ed2.w = 158; - ed2.nx = 1; - ed2.def = "[password]"; - ed2.focus = 0; - ed2.hide = 1; - ed2.cursor = 0; - ed2.multiline = 0; - strcpy(ed2.str, ""); + ed1.x = x0+25; + ed1.y = y0+25; + ed1.w = 158; + ed1.nx = 1; + ed1.def = "[user name]"; + ed1.focus = 1; + ed1.hide = 0; + ed1.multiline = 0; + ed1.cursor = strlen(svf_user); + strcpy(ed1.str, svf_user); + ed2.x = x0+25; + ed2.y = y0+45; + ed2.w = 158; + ed2.nx = 1; + ed2.def = "[password]"; + ed2.focus = 0; + ed2.hide = 1; + ed2.cursor = 0; + ed2.multiline = 0; + strcpy(ed2.str, ""); - fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192); - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192); + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255); - clearrect(vid_buf, x0, y0, 192, 80); - drawtext(vid_buf, x0+8, y0+8, "Server login:", 255, 255, 255, 255); - drawtext(vid_buf, x0+12, y0+23, "\x8B", 32, 64, 128, 255); - drawtext(vid_buf, x0+12, y0+23, "\x8A", 255, 255, 255, 255); - drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255); - drawtext(vid_buf, x0+11, y0+44, "\x8C", 160, 144, 32, 255); - drawtext(vid_buf, x0+11, y0+44, "\x84", 255, 255, 255, 255); - drawrect(vid_buf, x0+8, y0+40, 176, 16, 192, 192, 192, 255); - ui_edit_draw(vid_buf, &ed1); - ui_edit_draw(vid_buf, &ed2); - drawtext(vid_buf, x0+5, y0+69, "Sign in", 255, 255, 255, 255); - drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255); + clearrect(vid_buf, x0, y0, 192, 80); + drawtext(vid_buf, x0+8, y0+8, "Server login:", 255, 255, 255, 255); + drawtext(vid_buf, x0+12, y0+23, "\x8B", 32, 64, 128, 255); + drawtext(vid_buf, x0+12, y0+23, "\x8A", 255, 255, 255, 255); + drawrect(vid_buf, x0+8, y0+20, 176, 16, 192, 192, 192, 255); + drawtext(vid_buf, x0+11, y0+44, "\x8C", 160, 144, 32, 255); + drawtext(vid_buf, x0+11, y0+44, "\x84", 255, 255, 255, 255); + drawrect(vid_buf, x0+8, y0+40, 176, 16, 192, 192, 192, 255); + ui_edit_draw(vid_buf, &ed1); + ui_edit_draw(vid_buf, &ed2); + drawtext(vid_buf, x0+5, y0+69, "Sign in", 255, 255, 255, 255); + drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - ui_edit_process(mx, my, b, &ed1); - ui_edit_process(mx, my, b, &ed2); + ui_edit_process(mx, my, b, &ed1); + ui_edit_process(mx, my, b, &ed2); - if(b && !bq && mx>=x0+9 && mx=y0+22 && my=x0+9 && mx=y0+42 && my=x0 && mx=y0+64 && my<=y0+80) - break; + if (b && !bq && mx>=x0+9 && mx=y0+22 && my=x0+9 && mx=y0+42 && my=x0 && mx=y0+64 && my<=y0+80) + break; - if(sdl_key==SDLK_RETURN || sdl_key==SDLK_TAB) - { - if(!ed1.focus) - break; - ed1.focus = 0; - ed2.focus = 1; - } - if(sdl_key==SDLK_ESCAPE) - { - if(!ed1.focus && !ed2.focus) - return; - ed1.focus = 0; - ed2.focus = 0; - } - } + if (sdl_key==SDLK_RETURN || sdl_key==SDLK_TAB) + { + if (!ed1.focus) + break; + ed1.focus = 0; + ed2.focus = 1; + } + if (sdl_key==SDLK_ESCAPE) + { + if (!ed1.focus && !ed2.focus) + return; + ed1.focus = 0; + ed2.focus = 0; + } + } - strcpy(svf_user, ed1.str); - md5_ascii(svf_pass, (unsigned char *)ed2.str, 0); + strcpy(svf_user, ed1.str); + md5_ascii(svf_pass, (unsigned char *)ed2.str, 0); - res = http_multipart_post( - "http://" SERVER "/Login.api", - NULL, NULL, NULL, - svf_user, svf_pass, - &err, NULL); - if(err != 200) - { - error_ui(vid_buf, err, http_ret_text(err)); - if(res) - free(res); - goto fail; - } - if(res && !strncmp(res, "OK", 2)) - { - if(!strcmp(res, "OK ADMIN")) - { - svf_admin = 1; - svf_mod = 0; - } - else if(!strcmp(res, "OK MOD")) - { - svf_admin = 0; - svf_mod = 1; - } - else - { - svf_admin = 0; - svf_mod = 0; - } - free(res); - svf_login = 1; - return; - } - if(!res) - res = mystrdup("Unspecified Error"); - error_ui(vid_buf, 0, res); - free(res); + res = http_multipart_post( + "http://" SERVER "/Login.api", + NULL, NULL, NULL, + svf_user, svf_pass, + &err, NULL); + if (err != 200) + { + error_ui(vid_buf, err, http_ret_text(err)); + if (res) + free(res); + goto fail; + } + if (res && !strncmp(res, "OK", 2)) + { + if (!strcmp(res, "OK ADMIN")) + { + svf_admin = 1; + svf_mod = 0; + } + else if (!strcmp(res, "OK MOD")) + { + svf_admin = 0; + svf_mod = 1; + } + else + { + svf_admin = 0; + svf_mod = 0; + } + free(res); + svf_login = 1; + return; + } + if (!res) + res = mystrdup("Unspecified Error"); + error_ui(vid_buf, 0, res); + free(res); fail: - strcpy(svf_user, ""); - strcpy(svf_pass, ""); - svf_login = 0; - svf_own = 0; - svf_admin = 0; - svf_mod = 0; + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; } int stamp_ui(pixel *vid_buf) { - int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=STAMP_X*STAMP_Y,page_count; - char page_info[64]; - page_count = ceil((float)stamp_count/(float)per_page); + int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=STAMP_X*STAMP_Y,page_count; + char page_info[64]; + page_count = ceil((float)stamp_count/(float)per_page); - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); - k = stamp_page*per_page;//0; - r = -1; - d = -1; - for(j=0; j=gx+XRES/GRID_S-4 && mx<(gx+XRES/GRID_S)+6 && my>=gy-6 && my=gx && mx=gy && my=gx+XRES/GRID_S-4 && mx<(gx+XRES/GRID_S)+6 && my>=gy-6 && my=gx && mx=gy && my=1 && mx<=17 && my>=YRES+MENUSIZE-18 && my0) - { - if(stamp_page) - { - stamp_page --; - } - sdl_wheel = 0; - } - if((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-18 && my=1 && mx<=17 && my>=YRES+MENUSIZE-18 && my0) + { + if (stamp_page) + { + stamp_page --; + } + sdl_wheel = 0; + } + if ((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-18 && my=x0+18 && mx=y-2 && my=x0+d+18 && mx=y-2 && my=x0+d+32 && mx=y-2 && my=x0+18 && mx=y-2 && my=x0+d+18 && mx=y-2 && my=x0+d+32 && mx=y-2 && my=x0 && mx<=x0+192 && my>=y0+240 && my=x0 && mx<=x0+192 && my>=y0+240 && my=x0+9 && mx=y0+218 && my=x0+9 && mx=y0+218 && my=x0+9 && mx=y0+22 && my=x0 && mx=y0+74+YRES/4 && my=x0+9 && mx=y0+22 && my=x0 && mx=y0+74+YRES/4 && my=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else if(i==SC_SPECIAL) - { - for(n = 122; n<122+UI_WALLCOUNT; n++) - { - if(n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) - { - if(x-26<=60) - { - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else - { - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + rows = ceil((float)msections[i].itemcount/16.0f); + height = (ceil((float)msections[i].itemcount/16.0f)*18); + width = restrict_flt(msections[i].itemcount*31, 0, 16*31); + //clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); + h = -1; + x = XRES-BARSIZE-26; + y = (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-(height/2)+(FONT_H/2)+1; + sy = y; + //clearrect(vid_buf, (XRES-BARSIZE-width)+1, y-4, width+4, height+4+rows); + fillrect(vid_buf, (XRES-BARSIZE-width)-7, y-10, width+16, height+16+rows, 0, 0, 0, 100); + drawrect(vid_buf, (XRES-BARSIZE-width)-7, y-10, width+16, height+16+rows, 255, 255, 255, 255); + fillrect(vid_buf, (XRES-BARSIZE)+11, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-2, 15, FONT_H+3, 0, 0, 0, 100); + drawrect(vid_buf, (XRES-BARSIZE)+10, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-2, 16, FONT_H+3, 255, 255, 255, 255); + drawrect(vid_buf, (XRES-BARSIZE)+9, (((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2))-1, 1, FONT_H+1, 0, 0, 0, 255); + if (i==SC_WALL) + { + for (n = 122; n<122+UI_WALLCOUNT; n++) + { + if (n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM) + { + if (x-26<=60) + { + x = XRES-BARSIZE-26; + y += 19; + } + x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; + if (mx>=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else if (i==SC_SPECIAL) + { + for (n = 122; n<122+UI_WALLCOUNT; n++) + { + if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) + { + if (x-26<=60) + { + x = XRES-BARSIZE-26; + y += 19; + } + x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; + if (mx>=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + for (n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else + { + for (n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } - if(h==-1) - { - drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy+height+10, (char *)msections[i].name, 255, 255, 255, 255); - } - else if(i==SC_WALL||(i==SC_SPECIAL&&h>=122)) - { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy+height+10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); - } - else - { - drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy+height+10, (char *)ptypes[h].descs, 255, 255, 255, 255); - } + if (h==-1) + { + drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy+height+10, (char *)msections[i].name, 255, 255, 255, 255); + } + else if (i==SC_WALL||(i==SC_SPECIAL&&h>=122)) + { + drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy+height+10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); + } + else + { + drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy+height+10, (char *)ptypes[h].descs, 255, 255, 255, 255); + } - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - if(!(mx>=(XRES-BARSIZE-width)-7 && my>=sy-10 && my=(XRES-BARSIZE-width)-7 && my>=sy-10 && my=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - h = n; - } - else if(n==SLALT) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else if(i==SC_SPECIAL) - { - for(n = UI_WALLSTART; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - h = n; - } - else if(n==SLALT) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - h = n; - } - else if(n==SLALT) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - else - { - for(n = 0; n=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - h = n; - } - if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - h = n; - } - else if(n==SLALT) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); - } - else if(n==*sl) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); - } - else if(n==*sr) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); - } - } - } - } - if(!bq&&mx>=sdl_scale*((XRES+BARSIZE)-16) && mx= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && my=0&&i=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if (n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else if (i==SC_SPECIAL) + { + for (n = UI_WALLSTART; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if (n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + for (n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if (n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + else + { + for (n = 0; n=x+32 && mx=y && my< y+15) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + h = n; + } + if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if (n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } + else if (n==*sl) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + } + else if (n==*sr) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + } + } + } + } + if (!bq&&mx>=sdl_scale*((XRES+BARSIZE)-16) && mx= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && my=0&&i=UI_WALLSTART)) - { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255); - } - else - { - drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255); - } + if (h==-1) + { + drawtext(vid_buf, XRES-textwidth((char *)msections[i].name)-BARSIZE, sy-10, (char *)msections[i].name, 255, 255, 255, 255); + } + else if (i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART)) + { + drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255); + } + else + { + drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255); + } - if(b==1&&h==-1) - { - if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + if (b==1&&h==-1) { - SLALT = -1; - SEC2 = SEC; + if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + { + SLALT = -1; + SEC2 = SEC; + } } - } - if(b==1&&h!=-1) - { - if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + if (b==1&&h!=-1) { - SLALT = h; - SEC2 = -1; + if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + { + SLALT = h; + SEC2 = -1; + } + else { + *sl = h; + } } - else{ - *sl = h; - } - } - if(b==4&&h==-1) - { - if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + if (b==4&&h==-1) { - SLALT = -1; - SEC2 = SEC; + if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + { + SLALT = -1; + SEC2 = SEC; + } } - } - if(b==4&&h!=-1) - { - if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + if (b==4&&h!=-1) { - SLALT = h; - SEC2 = -1; + if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + { + SLALT = h; + SEC2 = -1; + } + else { + *sr = h; + } } - else{ - *sr = h; - } - } } int sdl_poll(void) { - SDL_Event event; - sdl_key=sdl_wheel=sdl_ascii=0; - while(SDL_PollEvent(&event)) - { - switch (event.type) - { - case SDL_KEYDOWN: - sdl_key=event.key.keysym.sym; - sdl_ascii=event.key.keysym.unicode; - if(event.key.keysym.sym == SDLK_CAPSLOCK) - sdl_caps = 1; - if(event.key.keysym.unicode=='z' || event.key.keysym.unicode=='Z') - { - sdl_zoom_trig = 1; - Z_keysym = event.key.keysym.sym; - } - if( event.key.keysym.sym == SDLK_PLUS) - { - sdl_wheel++; - } - if( event.key.keysym.sym == SDLK_MINUS) - { - sdl_wheel--; - } - // 4 - //1 8 2 - if(event.key.keysym.sym == SDLK_RIGHT) - { - player[0] = (int)(player[0])|0x02; //Go right command - } - if(event.key.keysym.sym == SDLK_LEFT) - { - player[0] = (int)(player[0])|0x01; //Go left command - } - if(event.key.keysym.sym == SDLK_DOWN && ((int)(player[0])&0x08)!=0x08) - { - player[0] = (int)(player[0])|0x08; //Go left command - } - if(event.key.keysym.sym == SDLK_UP && ((int)(player[0])&0x04)!=0x04) - { - player[0] = (int)(player[0])|0x04; //Jump command - } - - if(event.key.keysym.sym == SDLK_d) - { - player2[0] = (int)(player2[0])|0x02; //Go right command - } - if(event.key.keysym.sym == SDLK_a) - { - player2[0] = (int)(player2[0])|0x01; //Go left command - } - if(event.key.keysym.sym == SDLK_s && ((int)(player2[0])&0x08)!=0x08) - { - player2[0] = (int)(player2[0])|0x08; //Go left command - } - if(event.key.keysym.sym == SDLK_w && ((int)(player2[0])&0x04)!=0x04) - { - player2[0] = (int)(player2[0])|0x04; //Jump command - } - break; + SDL_Event event; + sdl_key=sdl_wheel=sdl_ascii=0; + while (SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_KEYDOWN: + sdl_key=event.key.keysym.sym; + sdl_ascii=event.key.keysym.unicode; + if (event.key.keysym.sym == SDLK_CAPSLOCK) + sdl_caps = 1; + if (event.key.keysym.unicode=='z' || event.key.keysym.unicode=='Z') + { + sdl_zoom_trig = 1; + Z_keysym = event.key.keysym.sym; + } + if ( event.key.keysym.sym == SDLK_PLUS) + { + sdl_wheel++; + } + if ( event.key.keysym.sym == SDLK_MINUS) + { + sdl_wheel--; + } + // 4 + //1 8 2 + if (event.key.keysym.sym == SDLK_RIGHT) + { + player[0] = (int)(player[0])|0x02; //Go right command + } + if (event.key.keysym.sym == SDLK_LEFT) + { + player[0] = (int)(player[0])|0x01; //Go left command + } + if (event.key.keysym.sym == SDLK_DOWN && ((int)(player[0])&0x08)!=0x08) + { + player[0] = (int)(player[0])|0x08; //Go left command + } + if (event.key.keysym.sym == SDLK_UP && ((int)(player[0])&0x04)!=0x04) + { + player[0] = (int)(player[0])|0x04; //Jump command + } - case SDL_KEYUP: - if(event.key.keysym.sym == SDLK_CAPSLOCK) - sdl_caps = 0; - if(event.key.keysym.sym == Z_keysym) - sdl_zoom_trig = 0; - if(event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_LEFT) - { - player[1] = player[0]; //Saving last movement - player[0] = (int)(player[0])&12; //Stop command - } - if(event.key.keysym.sym == SDLK_UP) - { - player[0] = (int)(player[0])&11; - } - if(event.key.keysym.sym == SDLK_DOWN) - { - player[0] = (int)(player[0])&7; - } - - if(event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a) - { - player2[1] = player2[0]; //Saving last movement - player2[0] = (int)(player2[0])&12; //Stop command - } - if(event.key.keysym.sym == SDLK_w) - { - player2[0] = (int)(player2[0])&11; - } - if(event.key.keysym.sym == SDLK_s) - { - player2[0] = (int)(player2[0])&7; - } - break; - case SDL_MOUSEBUTTONDOWN: - if(event.button.button == SDL_BUTTON_WHEELUP) - sdl_wheel++; - if(event.button.button == SDL_BUTTON_WHEELDOWN) - sdl_wheel--; - break; - case SDL_QUIT: - return 1; - } - } - sdl_mod = SDL_GetModState(); - return 0; + if (event.key.keysym.sym == SDLK_d) + { + player2[0] = (int)(player2[0])|0x02; //Go right command + } + if (event.key.keysym.sym == SDLK_a) + { + player2[0] = (int)(player2[0])|0x01; //Go left command + } + if (event.key.keysym.sym == SDLK_s && ((int)(player2[0])&0x08)!=0x08) + { + player2[0] = (int)(player2[0])|0x08; //Go left command + } + if (event.key.keysym.sym == SDLK_w && ((int)(player2[0])&0x04)!=0x04) + { + player2[0] = (int)(player2[0])|0x04; //Jump command + } + break; + + case SDL_KEYUP: + if (event.key.keysym.sym == SDLK_CAPSLOCK) + sdl_caps = 0; + if (event.key.keysym.sym == Z_keysym) + sdl_zoom_trig = 0; + if (event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_LEFT) + { + player[1] = player[0]; //Saving last movement + player[0] = (int)(player[0])&12; //Stop command + } + if (event.key.keysym.sym == SDLK_UP) + { + player[0] = (int)(player[0])&11; + } + if (event.key.keysym.sym == SDLK_DOWN) + { + player[0] = (int)(player[0])&7; + } + + if (event.key.keysym.sym == SDLK_d || event.key.keysym.sym == SDLK_a) + { + player2[1] = player2[0]; //Saving last movement + player2[0] = (int)(player2[0])&12; //Stop command + } + if (event.key.keysym.sym == SDLK_w) + { + player2[0] = (int)(player2[0])&11; + } + if (event.key.keysym.sym == SDLK_s) + { + player2[0] = (int)(player2[0])&7; + } + break; + case SDL_MOUSEBUTTONDOWN: + if (event.button.button == SDL_BUTTON_WHEELUP) + sdl_wheel++; + if (event.button.button == SDL_BUTTON_WHEELDOWN) + sdl_wheel--; + break; + case SDL_QUIT: + return 1; + } + } + sdl_mod = SDL_GetModState(); + return 0; } void set_cmode(int cm) { - cmode = cm; - itc = 51; - if(cmode==CM_BLOB) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Blob Display"); - } - else if(cmode==CM_HEAT) - { - strcpy(itc_msg, "Heat Display"); - } - else if(cmode==CM_FANCY) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fancy Display"); - } - else if(cmode==CM_FIRE) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fire Display"); - } - else if(cmode==CM_PERS) - { - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); - strcpy(itc_msg, "Persistent Display"); - } - else if(cmode==CM_PRESS) + cmode = cm; + itc = 51; + if (cmode==CM_BLOB) { - strcpy(itc_msg, "Pressure Display"); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Blob Display"); } - else if(cmode==CM_NOTHING) + else if (cmode==CM_HEAT) { - strcpy(itc_msg, "Nothing Display"); + strcpy(itc_msg, "Heat Display"); } - else if(cmode==CM_CRACK) + else if (cmode==CM_FANCY) { - strcpy(itc_msg, "Alternate Velocity Display"); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Fancy Display"); } - else if(cmode==CM_GRAD) + else if (cmode==CM_FIRE) { - strcpy(itc_msg, "Heat Gradient Display"); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + strcpy(itc_msg, "Fire Display"); } - else if(cmode==CM_LIFE) + else if (cmode==CM_PERS) { - if(DEBUG_MODE) + memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + strcpy(itc_msg, "Persistent Display"); + } + else if (cmode==CM_PRESS) + { + strcpy(itc_msg, "Pressure Display"); + } + else if (cmode==CM_NOTHING) + { + strcpy(itc_msg, "Nothing Display"); + } + else if (cmode==CM_CRACK) + { + strcpy(itc_msg, "Alternate Velocity Display"); + } + else if (cmode==CM_GRAD) + { + strcpy(itc_msg, "Heat Gradient Display"); + } + else if (cmode==CM_LIFE) + { + if (DEBUG_MODE) { strcpy(itc_msg, "Life Display"); } @@ -1879,908 +1879,909 @@ void set_cmode(int cm) set_cmode(CM_CRACK); } } - else + else { - strcpy(itc_msg, "Velocity Display"); + strcpy(itc_msg, "Velocity Display"); } } char *download_ui(pixel *vid_buf, char *uri, int *len) { - int dstate = 0; - void *http = http_async_req_start(NULL, uri, NULL, 0, 0); - int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2; - int done, total, i, ret, zlen, ulen; - char str[16], *tmp, *res; + int dstate = 0; + void *http = http_async_req_start(NULL, uri, NULL, 0, 0); + int x0=(XRES-240)/2,y0=(YRES-MENUSIZE)/2; + int done, total, i, ret, zlen, ulen; + char str[16], *tmp, *res; - while(!http_async_req_status(http)) - { - sdl_poll(); + while (!http_async_req_status(http)) + { + sdl_poll(); - http_async_get_length(http, &total, &done); + http_async_get_length(http, &total, &done); - clearrect(vid_buf, x0-2, y0-2, 244, 64); - drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); - drawtext(vid_buf, x0+8, y0+8, "Please wait", 255, 216, 32, 255); - drawtext(vid_buf, x0+8, y0+26, "Downloading update...", 255, 255, 255, 255); + clearrect(vid_buf, x0-2, y0-2, 244, 64); + drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255); + drawtext(vid_buf, x0+8, y0+8, "Please wait", 255, 216, 32, 255); + drawtext(vid_buf, x0+8, y0+26, "Downloading update...", 255, 255, 255, 255); - if(total) - { - i = (236*done)/total; - fillrect(vid_buf, x0+1, y0+45, i+1, 14, 255, 216, 32, 255); - i = (100*done)/total; - sprintf(str, "%d%%", i); - if(i<50) - drawtext(vid_buf, x0+120-textwidth(str)/2, y0+48, str, 192, 192, 192, 255); - else - drawtext(vid_buf, x0+120-textwidth(str)/2, y0+48, str, 0, 0, 0, 255); - } - else - drawtext(vid_buf, x0+120-textwidth("Waiting...")/2, y0+48, "Waiting...", 255, 216, 32, 255); + if (total) + { + i = (236*done)/total; + fillrect(vid_buf, x0+1, y0+45, i+1, 14, 255, 216, 32, 255); + i = (100*done)/total; + sprintf(str, "%d%%", i); + if (i<50) + drawtext(vid_buf, x0+120-textwidth(str)/2, y0+48, str, 192, 192, 192, 255); + else + drawtext(vid_buf, x0+120-textwidth(str)/2, y0+48, str, 0, 0, 0, 255); + } + else + drawtext(vid_buf, x0+120-textwidth("Waiting...")/2, y0+48, "Waiting...", 255, 216, 32, 255); - drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - } + drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + } - tmp = http_async_req_stop(http, &ret, &zlen); - if(ret!=200) - { - error_ui(vid_buf, ret, http_ret_text(ret)); - if(tmp) - free(tmp); - return NULL; - } - if(!tmp) - { - error_ui(vid_buf, 0, "Server did not return data"); - return NULL; - } + tmp = http_async_req_stop(http, &ret, &zlen); + if (ret!=200) + { + error_ui(vid_buf, ret, http_ret_text(ret)); + if (tmp) + free(tmp); + return NULL; + } + if (!tmp) + { + error_ui(vid_buf, 0, "Server did not return data"); + return NULL; + } - if(zlen<16) - { - printf("ZLen is not 16!\n"); - goto corrupt; - } - if(tmp[0]!=0x42 || tmp[1]!=0x75 || tmp[2]!=0x54 || tmp[3]!=0x54) - { - printf("Tmperr %d, %d, %d, %d\n", tmp[0], tmp[1], tmp[2], tmp[3]); - goto corrupt; - } + if (zlen<16) + { + printf("ZLen is not 16!\n"); + goto corrupt; + } + if (tmp[0]!=0x42 || tmp[1]!=0x75 || tmp[2]!=0x54 || tmp[3]!=0x54) + { + printf("Tmperr %d, %d, %d, %d\n", tmp[0], tmp[1], tmp[2], tmp[3]); + goto corrupt; + } - ulen = (unsigned char)tmp[4]; - ulen |= ((unsigned char)tmp[5])<<8; - ulen |= ((unsigned char)tmp[6])<<16; - ulen |= ((unsigned char)tmp[7])<<24; + ulen = (unsigned char)tmp[4]; + ulen |= ((unsigned char)tmp[5])<<8; + ulen |= ((unsigned char)tmp[6])<<16; + ulen |= ((unsigned char)tmp[7])<<24; - res = (char *)malloc(ulen); - if(!res) - { - printf("No res!\n"); - goto corrupt; - } - dstate = BZ2_bzBuffToBuffDecompress((char *)res, (unsigned *)&ulen, (char *)(tmp+8), zlen-8, 0, 0); - if(dstate) - { - printf("Decompression failure: %d!\n", dstate); - free(res); - goto corrupt; - } + res = (char *)malloc(ulen); + if (!res) + { + printf("No res!\n"); + goto corrupt; + } + dstate = BZ2_bzBuffToBuffDecompress((char *)res, (unsigned *)&ulen, (char *)(tmp+8), zlen-8, 0, 0); + if (dstate) + { + printf("Decompression failure: %d!\n", dstate); + free(res); + goto corrupt; + } - free(tmp); - if(len) - *len = ulen; - return res; + free(tmp); + if (len) + *len = ulen; + return res; corrupt: - error_ui(vid_buf, 0, "Downloaded update is corrupted"); - free(tmp); - return NULL; + error_ui(vid_buf, 0, "Downloaded update is corrupted"); + free(tmp); + return NULL; } int search_ui(pixel *vid_buf) { - int uih=0,nyu,nyd,b=1,bq,mx=0,my=0,mxq=0,myq=0,mmt=0,gi,gj,gx,gy,pos,i,mp,dp,dap,own,last_own=search_own,last_fav=search_fav,page_count=0,last_page=0,last_date=0,j,w,h,st=0,lv; - int is_p1=0, exp_res=GRID_X*GRID_Y, tp, view_own=0; - int thumb_drawn[GRID_X*GRID_Y]; - pixel *v_buf = (pixel *)malloc(((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); - float ry; - time_t http_last_use=HTTP_TIMEOUT; - ui_edit ed; + int uih=0,nyu,nyd,b=1,bq,mx=0,my=0,mxq=0,myq=0,mmt=0,gi,gj,gx,gy,pos,i,mp,dp,dap,own,last_own=search_own,last_fav=search_fav,page_count=0,last_page=0,last_date=0,j,w,h,st=0,lv; + int is_p1=0, exp_res=GRID_X*GRID_Y, tp, view_own=0; + int thumb_drawn[GRID_X*GRID_Y]; + pixel *v_buf = (pixel *)malloc(((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); + float ry; + time_t http_last_use=HTTP_TIMEOUT; + ui_edit ed; - void *http = NULL; - int active = 0; - char *last = NULL; - int search = 0; - int lasttime = TIMEOUT; - char *uri; - int status; - char *results; - char *tmp, ts[64]; + void *http = NULL; + int active = 0; + char *last = NULL; + int search = 0; + int lasttime = TIMEOUT; + char *uri; + int status; + char *results; + char *tmp, ts[64]; - void *img_http[IMGCONNS]; - char *img_id[IMGCONNS]; - void *thumb, *data; - int thlen, dlen; + void *img_http[IMGCONNS]; + char *img_id[IMGCONNS]; + void *thumb, *data; + int thlen, dlen; - memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); + memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); - memset(img_http, 0, sizeof(img_http)); - memset(img_id, 0, sizeof(img_id)); + memset(img_http, 0, sizeof(img_http)); + memset(img_id, 0, sizeof(img_id)); - memset(search_ids, 0, sizeof(search_ids)); - memset(search_dates, 0, sizeof(search_dates)); - memset(search_names, 0, sizeof(search_names)); - memset(search_scoreup, 0, sizeof(search_scoreup)); - memset(search_scoredown, 0, sizeof(search_scoredown)); - memset(search_publish, 0, sizeof(search_publish)); - memset(search_owners, 0, sizeof(search_owners)); - memset(search_thumbs, 0, sizeof(search_thumbs)); - memset(search_thsizes, 0, sizeof(search_thsizes)); + memset(search_ids, 0, sizeof(search_ids)); + memset(search_dates, 0, sizeof(search_dates)); + memset(search_names, 0, sizeof(search_names)); + memset(search_scoreup, 0, sizeof(search_scoreup)); + memset(search_scoredown, 0, sizeof(search_scoredown)); + memset(search_publish, 0, sizeof(search_publish)); + memset(search_owners, 0, sizeof(search_owners)); + memset(search_thumbs, 0, sizeof(search_thumbs)); + memset(search_thsizes, 0, sizeof(search_thsizes)); - memset(thumb_drawn, 0, sizeof(thumb_drawn)); + memset(thumb_drawn, 0, sizeof(thumb_drawn)); - do_open = 0; + do_open = 0; - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - ed.x = 65; - ed.y = 13; - ed.w = XRES-200; - ed.nx = 1; - ed.def = "[search terms]"; - ed.focus = 1; - ed.hide = 0; - ed.cursor = strlen(search_expr); + ed.x = 65; + ed.y = 13; + ed.w = XRES-200; + ed.nx = 1; + ed.def = "[search terms]"; + ed.focus = 1; + ed.hide = 0; + ed.cursor = strlen(search_expr); ed.multiline = 0; - strcpy(ed.str, search_expr); + strcpy(ed.str, search_expr); - sdl_wheel = 0; + sdl_wheel = 0; - while(!sdl_poll()) - { - uih = 0; - bq = b; - mxq = mx; - myq = my; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + while (!sdl_poll()) + { + uih = 0; + bq = b; + mxq = mx; + myq = my; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; - if(mx!=mxq || my!=myq || sdl_wheel || b) - mmt = 0; - else if(mmt 9) - { - drawtext(vid_buf, XRES-15, YRES+MENUSIZE-16, "\x95", 255, 255, 255, 255); - drawrect(vid_buf, XRES-18, YRES+MENUSIZE-20, 16, 16, 255, 255, 255, 255); - } + if (search_page) + { + drawtext(vid_buf, 4, YRES+MENUSIZE-16, "\x96", 255, 255, 255, 255); + drawrect(vid_buf, 1, YRES+MENUSIZE-20, 16, 16, 255, 255, 255, 255); + } + if (page_count > 9) + { + drawtext(vid_buf, XRES-15, YRES+MENUSIZE-16, "\x95", 255, 255, 255, 255); + drawrect(vid_buf, XRES-18, YRES+MENUSIZE-20, 16, 16, 255, 255, 255, 255); + } - ui_edit_draw(vid_buf, &ed); + ui_edit_draw(vid_buf, &ed); - if((b && !bq && mx>=1 && mx<=17 && my>=YRES+MENUSIZE-20 && my0) - { - if(search_page) - { - search_page --; - lasttime = TIMEOUT; - } - sdl_wheel = 0; - uih = 1; - } - if((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-20 && myexp_res) - { - lasttime = TIMEOUT; - search_page ++; - page_count = exp_res; - } - sdl_wheel = 0; - uih = 1; - } + if ((b && !bq && mx>=1 && mx<=17 && my>=YRES+MENUSIZE-20 && my0) + { + if (search_page) + { + search_page --; + lasttime = TIMEOUT; + } + sdl_wheel = 0; + uih = 1; + } + if ((b && !bq && mx>=XRES-18 && mx<=XRES-1 && my>=YRES+MENUSIZE-20 && myexp_res) + { + lasttime = TIMEOUT; + search_page ++; + page_count = exp_res; + } + sdl_wheel = 0; + uih = 1; + } - tp = -1; - if(is_p1) - { - drawtext(vid_buf, (XRES-textwidth("Popular tags:"))/2, 31, "Popular tags:", 255, 192, 64, 255); - for(gj=0; gj<((GRID_Y-GRID_P)*YRES)/(GRID_Y*14); gj++) - for(gi=0; giTAG_MAX || !tag_names[pos]) - break; - if(tag_votes[0]) - i = 127+(128*tag_votes[pos])/tag_votes[0]; - else - i = 192; - w = textwidth(tag_names[pos]); - if(w>XRES/GRID_X-5) - w = XRES/GRID_X-5; - gx = (XRES/GRID_X)*gi; - gy = gj*14 + 46; - if(mx>=gx && mx=gy && myTAG_MAX || !tag_names[pos]) + break; + if (tag_votes[0]) + i = 127+(128*tag_votes[pos])/tag_votes[0]; + else + i = 192; + w = textwidth(tag_names[pos]); + if (w>XRES/GRID_X-5) + w = XRES/GRID_X-5; + gx = (XRES/GRID_X)*gi; + gy = gj*14 + 46; + if (mx>=gx && mx=gy && my XRES/GRID_X-10) - { - tmp = malloc(strlen(search_names[pos])+4); - strcpy(tmp, search_names[pos]); - j = textwidthx(tmp, XRES/GRID_X-15); - strcpy(tmp+j, "..."); - drawtext(vid_buf, gx+XRES/(GRID_S*2)-textwidth(tmp)/2, gy+YRES/GRID_S+7, tmp, 192, 192, 192, 255); - free(tmp); - } - else - drawtext(vid_buf, gx+XRES/(GRID_S*2)-textwidth(search_names[pos])/2, gy+YRES/GRID_S+7, search_names[pos], 192, 192, 192, 255); - j = textwidth(search_owners[pos]); - if(mx>=gx+XRES/(GRID_S*2)-j/2 && mx<=gx+XRES/(GRID_S*2)+j/2 && - my>=gy+YRES/GRID_S+18 && my<=gy+YRES/GRID_S+31) - { - st = 1; - drawtext(vid_buf, gx+XRES/(GRID_S*2)-j/2, gy+YRES/GRID_S+20, search_owners[pos], 128, 128, 160, 255); - } - else - drawtext(vid_buf, gx+XRES/(GRID_S*2)-j/2, gy+YRES/GRID_S+20, search_owners[pos], 128, 128, 128, 255); - if(search_thumbs[pos]&&thumb_drawn[pos]==0) - { - render_thumb(search_thumbs[pos], search_thsizes[pos], 1, v_buf, gx, gy, GRID_S); - thumb_drawn[pos] = 1; - } - own = svf_login && (!strcmp(svf_user, search_owners[pos]) || svf_admin || svf_mod); - if(mx>=gx-2 && mx<=gx+XRES/GRID_S+3 && my>=gy-2 && my<=gy+YRES/GRID_S+30) - mp = pos; - if(own) - { - if(mx>=gx+XRES/GRID_S-4 && mx<=gx+XRES/GRID_S+6 && my>=gy-6 && my<=gy+4) - { - mp = -1; - dp = pos; - } - if(!search_dates[pos] && mx>=gx-6 && mx<=gx+4 && my>=gy+YRES/GRID_S-4 && my<=gy+YRES/GRID_S+6) - { - mp = -1; - dap = pos; - } - } - drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, YRES/GRID_S+3, 128, 128, 128, 255); - fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, 1+(YRES/GRID_S+3)/2, 0, 107, 10, 255); - fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 6, 1+(YRES/GRID_S+3)/2, 107, 10, 0, 255); + mp = dp = -1; + dap = -1; + st = 0; + for (gj=0; gj XRES/GRID_X-10) + { + tmp = malloc(strlen(search_names[pos])+4); + strcpy(tmp, search_names[pos]); + j = textwidthx(tmp, XRES/GRID_X-15); + strcpy(tmp+j, "..."); + drawtext(vid_buf, gx+XRES/(GRID_S*2)-textwidth(tmp)/2, gy+YRES/GRID_S+7, tmp, 192, 192, 192, 255); + free(tmp); + } + else + drawtext(vid_buf, gx+XRES/(GRID_S*2)-textwidth(search_names[pos])/2, gy+YRES/GRID_S+7, search_names[pos], 192, 192, 192, 255); + j = textwidth(search_owners[pos]); + if (mx>=gx+XRES/(GRID_S*2)-j/2 && mx<=gx+XRES/(GRID_S*2)+j/2 && + my>=gy+YRES/GRID_S+18 && my<=gy+YRES/GRID_S+31) + { + st = 1; + drawtext(vid_buf, gx+XRES/(GRID_S*2)-j/2, gy+YRES/GRID_S+20, search_owners[pos], 128, 128, 160, 255); + } + else + drawtext(vid_buf, gx+XRES/(GRID_S*2)-j/2, gy+YRES/GRID_S+20, search_owners[pos], 128, 128, 128, 255); + if (search_thumbs[pos]&&thumb_drawn[pos]==0) + { + render_thumb(search_thumbs[pos], search_thsizes[pos], 1, v_buf, gx, gy, GRID_S); + thumb_drawn[pos] = 1; + } + own = svf_login && (!strcmp(svf_user, search_owners[pos]) || svf_admin || svf_mod); + if (mx>=gx-2 && mx<=gx+XRES/GRID_S+3 && my>=gy-2 && my<=gy+YRES/GRID_S+30) + mp = pos; + if (own) + { + if (mx>=gx+XRES/GRID_S-4 && mx<=gx+XRES/GRID_S+6 && my>=gy-6 && my<=gy+4) + { + mp = -1; + dp = pos; + } + if (!search_dates[pos] && mx>=gx-6 && mx<=gx+4 && my>=gy+YRES/GRID_S-4 && my<=gy+YRES/GRID_S+6) + { + mp = -1; + dap = pos; + } + } + drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, YRES/GRID_S+3, 128, 128, 128, 255); + fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2, 6, 1+(YRES/GRID_S+3)/2, 0, 107, 10, 255); + fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 6, 1+(YRES/GRID_S+3)/2, 107, 10, 0, 255); - if(mp==pos && !st) - drawrect(vid_buf, gx-2, gy-2, XRES/GRID_S+3, YRES/GRID_S+3, 160, 160, 192, 255); - else - drawrect(vid_buf, gx-2, gy-2, XRES/GRID_S+3, YRES/GRID_S+3, 128, 128, 128, 255); - if(own && search_fav!=1) - { - if(dp == pos) - drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x86", 255, 48, 32, 255); - else - drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x86", 160, 48, 32, 255); - drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x85", 255, 255, 255, 255); - } - if(!search_publish[pos]) - { - drawtext(vid_buf, gx-6, gy-6, "\xCD", 255, 255, 255, 255); - drawtext(vid_buf, gx-6, gy-6, "\xCE", 212, 151, 81, 255); - } - if(!search_dates[pos] && own) - { - fillrect(vid_buf, gx-5, gy+YRES/GRID_S-3, 7, 8, 255, 255, 255, 255); - if(dap == pos) { - drawtext(vid_buf, gx-6, gy+YRES/GRID_S-4, "\xA6", 200, 100, 80, 255); - } else { - drawtext(vid_buf, gx-6, gy+YRES/GRID_S-4, "\xA6", 160, 70, 50, 255); - } - //drawtext(vid_buf, gx-6, gy-6, "\xCE", 212, 151, 81, 255); - } - if(view_own || svf_admin || svf_mod) - { - sprintf(ts+1, "%d", search_votes[pos]); - ts[0] = 0xBB; - for(j=1; ts[j]; j++) - ts[j] = 0xBC; - ts[j-1] = 0xB9; - ts[j] = 0xBA; - ts[j+1] = 0; - w = gx+XRES/GRID_S-2-textwidth(ts); - h = gy+YRES/GRID_S-11; - drawtext(vid_buf, w, h, ts, 16, 72, 16, 255); - for(j=0; ts[j]; j++) - ts[j] -= 14; - drawtext(vid_buf, w, h, ts, 192, 192, 192, 255); - sprintf(ts, "%d", search_votes[pos]); - for(j=0; ts[j]; j++) - ts[j] += 127; - drawtext(vid_buf, w+3, h, ts, 255, 255, 255, 255); - } - if(search_scoreup[pos]>0||search_scoredown[pos]>0) - { - lv = (search_scoreup[pos]>search_scoredown[pos]?search_scoreup[pos]:search_scoredown[pos]); + if (mp==pos && !st) + drawrect(vid_buf, gx-2, gy-2, XRES/GRID_S+3, YRES/GRID_S+3, 160, 160, 192, 255); + else + drawrect(vid_buf, gx-2, gy-2, XRES/GRID_S+3, YRES/GRID_S+3, 128, 128, 128, 255); + if (own && search_fav!=1) + { + if (dp == pos) + drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x86", 255, 48, 32, 255); + else + drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x86", 160, 48, 32, 255); + drawtext(vid_buf, gx+XRES/GRID_S-4, gy-6, "\x85", 255, 255, 255, 255); + } + if (!search_publish[pos]) + { + drawtext(vid_buf, gx-6, gy-6, "\xCD", 255, 255, 255, 255); + drawtext(vid_buf, gx-6, gy-6, "\xCE", 212, 151, 81, 255); + } + if (!search_dates[pos] && own) + { + fillrect(vid_buf, gx-5, gy+YRES/GRID_S-3, 7, 8, 255, 255, 255, 255); + if (dap == pos) { + drawtext(vid_buf, gx-6, gy+YRES/GRID_S-4, "\xA6", 200, 100, 80, 255); + } else { + drawtext(vid_buf, gx-6, gy+YRES/GRID_S-4, "\xA6", 160, 70, 50, 255); + } + //drawtext(vid_buf, gx-6, gy-6, "\xCE", 212, 151, 81, 255); + } + if (view_own || svf_admin || svf_mod) + { + sprintf(ts+1, "%d", search_votes[pos]); + ts[0] = 0xBB; + for (j=1; ts[j]; j++) + ts[j] = 0xBC; + ts[j-1] = 0xB9; + ts[j] = 0xBA; + ts[j+1] = 0; + w = gx+XRES/GRID_S-2-textwidth(ts); + h = gy+YRES/GRID_S-11; + drawtext(vid_buf, w, h, ts, 16, 72, 16, 255); + for (j=0; ts[j]; j++) + ts[j] -= 14; + drawtext(vid_buf, w, h, ts, 192, 192, 192, 255); + sprintf(ts, "%d", search_votes[pos]); + for (j=0; ts[j]; j++) + ts[j] += 127; + drawtext(vid_buf, w+3, h, ts, 255, 255, 255, 255); + } + if (search_scoreup[pos]>0||search_scoredown[pos]>0) + { + lv = (search_scoreup[pos]>search_scoredown[pos]?search_scoreup[pos]:search_scoredown[pos]); - if(((YRES/GRID_S+3)/2)>lv) - { - ry = ((float)((YRES/GRID_S+3)/2)/(float)lv); - if(lv<8) - { - ry = ry/(8-lv); - } - nyu = search_scoreup[pos]*ry; - nyd = search_scoredown[pos]*ry; - } - else - { - ry = ((float)lv/(float)((YRES/GRID_S+3)/2)); - nyu = search_scoreup[pos]/ry; - nyd = search_scoredown[pos]/ry; - } + if (((YRES/GRID_S+3)/2)>lv) + { + ry = ((float)((YRES/GRID_S+3)/2)/(float)lv); + if (lv<8) + { + ry = ry/(8-lv); + } + nyu = search_scoreup[pos]*ry; + nyd = search_scoredown[pos]*ry; + } + else + { + ry = ((float)lv/(float)((YRES/GRID_S+3)/2)); + nyu = search_scoreup[pos]/ry; + nyd = search_scoredown[pos]/ry; + } - fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-1+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 57, 187, 57, 255); - fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 4, nyd, 187, 57, 57, 255); - //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 107, 10, 255); - //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 107, 10, 0, 255); - } - } + fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-1+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 57, 187, 57, 255); + fillrect(vid_buf, gx-1+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2), 4, nyd, 187, 57, 57, 255); + //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 107, 10, 255); + //drawrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 107, 10, 0, 255); + } + } - if(mp!=-1 && mmt>=TIMEOUT/5 && !st) - { - gi = mp % GRID_X; - gj = mp / GRID_X; - if(is_p1) - gj += GRID_Y-GRID_P; - gx = ((XRES/GRID_X)*gi) + (XRES/GRID_X-XRES/GRID_S)/2; - gy = (((YRES+15)/GRID_Y)*gj) + (YRES/GRID_Y-YRES/GRID_S+10)/2 + 18; - i = w = textwidth(search_names[mp]); - h = YRES/GRID_Z+30; - if(w=XRES-2) gx=XRES-3-w; - if(gy<32) gy=32; - if(gy+h>=YRES+(MENUSIZE-2)) gy=YRES+(MENUSIZE-3)-h; - clearrect(vid_buf, gx-2, gy-3, w+4, h); - drawrect(vid_buf, gx-2, gy-3, w+4, h, 160, 160, 192, 255); - if(search_thumbs[mp]) - render_thumb(search_thumbs[mp], search_thsizes[mp], 1, vid_buf, gx+(w-(XRES/GRID_Z))/2, gy, GRID_Z); - drawtext(vid_buf, gx+(w-i)/2, gy+YRES/GRID_Z+4, search_names[mp], 192, 192, 192, 255); - drawtext(vid_buf, gx+(w-textwidth(search_owners[mp]))/2, gy+YRES/GRID_Z+16, search_owners[mp], 128, 128, 128, 255); - } + if (mp!=-1 && mmt>=TIMEOUT/5 && !st) + { + gi = mp % GRID_X; + gj = mp / GRID_X; + if (is_p1) + gj += GRID_Y-GRID_P; + gx = ((XRES/GRID_X)*gi) + (XRES/GRID_X-XRES/GRID_S)/2; + gy = (((YRES+15)/GRID_Y)*gj) + (YRES/GRID_Y-YRES/GRID_S+10)/2 + 18; + i = w = textwidth(search_names[mp]); + h = YRES/GRID_Z+30; + if (w=XRES-2) gx=XRES-3-w; + if (gy<32) gy=32; + if (gy+h>=YRES+(MENUSIZE-2)) gy=YRES+(MENUSIZE-3)-h; + clearrect(vid_buf, gx-2, gy-3, w+4, h); + drawrect(vid_buf, gx-2, gy-3, w+4, h, 160, 160, 192, 255); + if (search_thumbs[mp]) + render_thumb(search_thumbs[mp], search_thsizes[mp], 1, vid_buf, gx+(w-(XRES/GRID_Z))/2, gy, GRID_Z); + drawtext(vid_buf, gx+(w-i)/2, gy+YRES/GRID_Z+4, search_names[mp], 192, 192, 192, 255); + drawtext(vid_buf, gx+(w-textwidth(search_owners[mp]))/2, gy+YRES/GRID_Z+16, search_owners[mp], 128, 128, 128, 255); + } - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - ui_edit_process(mx, my, b, &ed); + ui_edit_process(mx, my, b, &ed); - if(sdl_key==SDLK_RETURN) - { - if(!last || (!active && (strcmp(last, ed.str) || last_own!=search_own || last_date!=search_date || last_page!=search_page))) - lasttime = TIMEOUT; - else if(search_ids[0] && !search_ids[1]) - { - bq = 0; - b = 1; - mp = 0; - } - } - if(sdl_key==SDLK_ESCAPE) - goto finish; + if (sdl_key==SDLK_RETURN) + { + if (!last || (!active && (strcmp(last, ed.str) || last_own!=search_own || last_date!=search_date || last_page!=search_page))) + lasttime = TIMEOUT; + else if (search_ids[0] && !search_ids[1]) + { + bq = 0; + b = 1; + mp = 0; + } + } + if (sdl_key==SDLK_ESCAPE) + goto finish; - if(b && !bq && mx>=XRES-64+16 && mx<=XRES-8+16 && my>=8 && my<=24 && svf_login) - { - search_own = !search_own; - lasttime = TIMEOUT; - } - if(b && !bq && mx>=XRES-129+16 && mx<=XRES-65+16 && my>=8 && my<=24) - { - search_date = !search_date; - lasttime = TIMEOUT; - } - if(b && !bq && mx>=XRES-134 && mx<=XRES-134+16 && my>=8 && my<=24) - { - search_fav = !search_fav; - lasttime = TIMEOUT; - } + if (b && !bq && mx>=XRES-64+16 && mx<=XRES-8+16 && my>=8 && my<=24 && svf_login) + { + search_own = !search_own; + lasttime = TIMEOUT; + } + if (b && !bq && mx>=XRES-129+16 && mx<=XRES-65+16 && my>=8 && my<=24) + { + search_date = !search_date; + lasttime = TIMEOUT; + } + if (b && !bq && mx>=XRES-134 && mx<=XRES-134+16 && my>=8 && my<=24) + { + search_fav = !search_fav; + lasttime = TIMEOUT; + } - if(b && !bq && dp!=-1 && search_fav==0) - if(confirm_ui(vid_buf, "Do you want to delete?", search_names[dp], "Delete")) - { - execute_delete(vid_buf, search_ids[dp]); - lasttime = TIMEOUT; - if(last) - { - free(last); - last = NULL; - } - } - if(b && !bq && dap!=-1) - { - sprintf(ed.str, "history:%s", search_ids[dap]); - lasttime = TIMEOUT; - } + if (b && !bq && dp!=-1 && search_fav==0) + if (confirm_ui(vid_buf, "Do you want to delete?", search_names[dp], "Delete")) + { + execute_delete(vid_buf, search_ids[dp]); + lasttime = TIMEOUT; + if (last) + { + free(last); + last = NULL; + } + } + if (b && !bq && dap!=-1) + { + sprintf(ed.str, "history:%s", search_ids[dap]); + lasttime = TIMEOUT; + } - if(b && !bq && tp!=-1) - { - strncpy(ed.str, tag_names[tp], 255); - lasttime = TIMEOUT; - } + if (b && !bq && tp!=-1) + { + strncpy(ed.str, tag_names[tp], 255); + lasttime = TIMEOUT; + } - if(b && !bq && mp!=-1 && st) - { - sprintf(ed.str, "user:%s", search_owners[mp]); - lasttime = TIMEOUT; - } + if (b && !bq && mp!=-1 && st) + { + sprintf(ed.str, "user:%s", search_owners[mp]); + lasttime = TIMEOUT; + } - if(do_open==1) - { - mp = 0; - } + if (do_open==1) + { + mp = 0; + } - if((b && !bq && mp!=-1 && !st && !uih) || do_open==1) - { - if(open_ui(vid_buf, search_ids[mp], search_dates[mp]?search_dates[mp]:NULL)==1) { - goto finish; - } - } + if ((b && !bq && mp!=-1 && !st && !uih) || do_open==1) + { + if (open_ui(vid_buf, search_ids[mp], search_dates[mp]?search_dates[mp]:NULL)==1) { + goto finish; + } + } - if(!last) - { - search = 1; - } - else if(!active && (strcmp(last, ed.str) || last_own!=search_own || last_date!=search_date || last_page!=search_page || last_fav!=search_fav)) - { - search = 1; - if(strcmp(last, ed.str) || last_own!=search_own || last_fav!=search_fav || last_date!=search_date) - { - search_page = 0; - page_count = 0; - } - free(last); - last = NULL; - } - else - search = 0; + if (!last) + { + search = 1; + } + else if (!active && (strcmp(last, ed.str) || last_own!=search_own || last_date!=search_date || last_page!=search_page || last_fav!=search_fav)) + { + search = 1; + if (strcmp(last, ed.str) || last_own!=search_own || last_fav!=search_fav || last_date!=search_date) + { + search_page = 0; + page_count = 0; + } + free(last); + last = NULL; + } + else + search = 0; - if(search && lasttime>=TIMEOUT) - { - lasttime = 0; - last = mystrdup(ed.str); - last_own = search_own; - last_date = search_date; - last_page = search_page; - last_fav = search_fav; - active = 1; - // TODO: Create a better fix for this bug - uri = malloc(strlen(last)*3+180+strlen(SERVER)+strlen(svf_user)+20); //Increase "padding" from 80 to 180 to fix the search memory corruption bug - if(search_own || svf_admin || svf_mod) - tmp = "&ShowVotes=true"; - else - tmp = ""; - if(!search_own && !search_date && !*last) - { - if(search_page) - { - exp_res = GRID_X*GRID_Y; - sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d%s&Query=", (search_page-1)*GRID_X*GRID_Y+GRID_X*GRID_P, exp_res+1, tmp); - } - else - { - exp_res = GRID_X*GRID_P; - sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d&t=%d%s&Query=", 0, exp_res+1, ((GRID_Y-GRID_P)*YRES)/(GRID_Y*14)*GRID_X, tmp); - } - } - else - { - exp_res = GRID_X*GRID_Y; - sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d%s&Query=", search_page*GRID_X*GRID_Y, exp_res+1, tmp); - } - strcaturl(uri, last); - if(search_own) - { - strcaturl(uri, " user:"); - strcaturl(uri, svf_user); - } - if(search_fav) - { - strcaturl(uri, " cat:favs"); - } - if(search_date) - strcaturl(uri, " sort:date"); + if (search && lasttime>=TIMEOUT) + { + lasttime = 0; + last = mystrdup(ed.str); + last_own = search_own; + last_date = search_date; + last_page = search_page; + last_fav = search_fav; + active = 1; + // TODO: Create a better fix for this bug + uri = malloc(strlen(last)*3+180+strlen(SERVER)+strlen(svf_user)+20); //Increase "padding" from 80 to 180 to fix the search memory corruption bug + if (search_own || svf_admin || svf_mod) + tmp = "&ShowVotes=true"; + else + tmp = ""; + if (!search_own && !search_date && !*last) + { + if (search_page) + { + exp_res = GRID_X*GRID_Y; + sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d%s&Query=", (search_page-1)*GRID_X*GRID_Y+GRID_X*GRID_P, exp_res+1, tmp); + } + else + { + exp_res = GRID_X*GRID_P; + sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d&t=%d%s&Query=", 0, exp_res+1, ((GRID_Y-GRID_P)*YRES)/(GRID_Y*14)*GRID_X, tmp); + } + } + else + { + exp_res = GRID_X*GRID_Y; + sprintf(uri, "http://" SERVER "/Search.api?Start=%d&Count=%d%s&Query=", search_page*GRID_X*GRID_Y, exp_res+1, tmp); + } + strcaturl(uri, last); + if (search_own) + { + strcaturl(uri, " user:"); + strcaturl(uri, svf_user); + } + if (search_fav) + { + strcaturl(uri, " cat:favs"); + } + if (search_date) + strcaturl(uri, " sort:date"); - http = http_async_req_start(http, uri, NULL, 0, 1); - if(svf_login) - { - http_auth_headers(http, svf_user, svf_pass); - } - http_last_use = time(NULL); - free(uri); - } + http = http_async_req_start(http, uri, NULL, 0, 1); + if (svf_login) + { + http_auth_headers(http, svf_user, svf_pass); + } + http_last_use = time(NULL); + free(uri); + } - if(active && http_async_req_status(http)) - { - http_last_use = time(NULL); - results = http_async_req_stop(http, &status, NULL); - view_own = last_own; - if(status == 200) - { - page_count = search_results(results, last_own||svf_admin||svf_mod); - memset(thumb_drawn, 0, sizeof(thumb_drawn)); - memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); - } - is_p1 = (exp_res < GRID_X*GRID_Y); - free(results); - active = 0; - } + if (active && http_async_req_status(http)) + { + http_last_use = time(NULL); + results = http_async_req_stop(http, &status, NULL); + view_own = last_own; + if (status == 200) + { + page_count = search_results(results, last_own||svf_admin||svf_mod); + memset(thumb_drawn, 0, sizeof(thumb_drawn)); + memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE); + } + is_p1 = (exp_res < GRID_X*GRID_Y); + free(results); + active = 0; + } - if(http && !active && (time(NULL)>http_last_use+HTTP_TIMEOUT)) - { - http_async_req_close(http); - http = NULL; - } + if (http && !active && (time(NULL)>http_last_use+HTTP_TIMEOUT)) + { + http_async_req_close(http); + http = NULL; + } - for(i=0; i(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); - if(b){ - if(execute_report(vid_buf, save_id, ed.str)){ + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } + while (!sdl_poll()) { + 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, 205, 155, (XRES+BARSIZE-400)-10, (YRES+MENUSIZE-300)-28, 255, 255, 255, 170); + + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + + + drawrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255); + drawtext(vid_buf, 213, (YRES+MENUSIZE-150)-13, "Cancel", 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); + 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); + if (b) { + if (execute_report(vid_buf, save_id, ed.str)) { info_ui(vid_buf, "Success", "This save has been reported"); return 1; - } else { - return 0; - } - } - } - 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); - if(b) - return 0; - } - ui_edit_draw(vid_buf, &ed); + } else { + return 0; + } + } + } + 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); + if (b) + return 0; + } + ui_edit_draw(vid_buf, &ed); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); ui_edit_process(mx, my, b, &ed); - } - return 0; + } + return 0; } int open_ui(pixel *vid_buf, char *save_id, char *save_date) { - int b=1,bq,mx,my,ca=0,thumb_w,thumb_h,active=0,active_2=0,cc=0,ccy=0,cix=0,hasdrawninfo=0,hasdrawnthumb=0,authoritah=0,myown=0,queue_open=0,data_size=0,retval=0,bc=255,openable=1; - int nyd,nyu,ry,lv; - + int b=1,bq,mx,my,ca=0,thumb_w,thumb_h,active=0,active_2=0,cc=0,ccy=0,cix=0,hasdrawninfo=0,hasdrawnthumb=0,authoritah=0,myown=0,queue_open=0,data_size=0,retval=0,bc=255,openable=1; + int nyd,nyu,ry,lv; + float ryf; + char *uri, *uri_2, *o_uri; - void *data, *info_data; - save_info *info = malloc(sizeof(save_info)); - void *http = NULL, *http_2 = NULL; - int lasttime = TIMEOUT; - int status, status_2, info_ready = 0, data_ready = 0; - time_t http_last_use = HTTP_TIMEOUT, http_last_use_2 = HTTP_TIMEOUT; - pixel *save_pic;// = malloc((XRES/2)*(YRES/2)); + void *data, *info_data; + save_info *info = malloc(sizeof(save_info)); + void *http = NULL, *http_2 = NULL; + int lasttime = TIMEOUT; + int status, status_2, info_ready = 0, data_ready = 0; + time_t http_last_use = HTTP_TIMEOUT, http_last_use_2 = HTTP_TIMEOUT; + pixel *save_pic;// = malloc((XRES/2)*(YRES/2)); ui_edit ed; - pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); + pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); - fillrect(vid_buf, 50, 50, XRES+BARSIZE-100, YRES+MENUSIZE-100, 0, 0, 0, 255); - drawrect(vid_buf, 50, 50, XRES+BARSIZE-100, YRES+MENUSIZE-100, 255, 255, 255, 255); - drawrect(vid_buf, 50, 50, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 155); - drawrect(vid_buf, 50+(XRES/2)+1, 50, XRES+BARSIZE-100-((XRES/2)+1), YRES+MENUSIZE-100, 155, 155, 155, 255); - drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); + fillrect(vid_buf, 50, 50, XRES+BARSIZE-100, YRES+MENUSIZE-100, 0, 0, 0, 255); + drawrect(vid_buf, 50, 50, XRES+BARSIZE-100, YRES+MENUSIZE-100, 255, 255, 255, 255); + drawrect(vid_buf, 50, 50, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 155); + drawrect(vid_buf, 50+(XRES/2)+1, 50, XRES+BARSIZE-100-((XRES/2)+1), YRES+MENUSIZE-100, 155, 155, 155, 255); + drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); ed.x = 57+(XRES/2)+1; ed.y = YRES+MENUSIZE-118; ed.w = XRES+BARSIZE-114-((XRES/2)+1); ed.h = 48; - ed.nx = 1; - ed.def = "Add comment"; - ed.focus = 1; - ed.hide = 0; + ed.nx = 1; + ed.def = "Add comment"; + ed.focus = 1; + ed.hide = 0; ed.multiline = 1; - ed.cursor = 0; - strcpy(ed.str, ""); - - memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + ed.cursor = 0; + strcpy(ed.str, ""); - while(!sdl_poll()) - { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; - } + memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - //Begin Async loading of data - if(save_date) { - // We're loading an historical save - uri = malloc(strlen(save_id)*3+strlen(save_date)*3+strlen(SERVER)+71); - strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); - strcaturl(uri, save_id); - strappend(uri, "&Date="); - strcaturl(uri, save_date); + while (!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if (!b) + break; + } - uri_2 = malloc(strlen(save_id)*3+strlen(save_date)*3+strlen(SERVER)+71); - strcpy(uri_2, "http://" SERVER "/Info.api?ID="); - strcaturl(uri_2, save_id); - strappend(uri_2, "&Date="); - strcaturl(uri_2, save_date); - } else { - //We're loading a normal save - uri = malloc(strlen(save_id)*3+strlen(SERVER)+64); - strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); - strcaturl(uri, save_id); + //Begin Async loading of data + if (save_date) { + // We're loading an historical save + uri = malloc(strlen(save_id)*3+strlen(save_date)*3+strlen(SERVER)+71); + strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); + strcaturl(uri, save_id); + strappend(uri, "&Date="); + strcaturl(uri, save_date); - uri_2 = malloc(strlen(save_id)*3+strlen(SERVER)+64); - strcpy(uri_2, "http://" SERVER "/Info.api?ID="); - strcaturl(uri_2, save_id); - } - http = http_async_req_start(http, uri, NULL, 0, 1); - http_2 = http_async_req_start(http_2, uri_2, NULL, 0, 1); - if(svf_login) - { - http_auth_headers(http, svf_user, svf_pass); - http_auth_headers(http_2, svf_user, svf_pass); - } - http_last_use = time(NULL); - http_last_use_2 = time(NULL); - free(uri); - free(uri_2); - active = 1; - active_2 = 1; - while(!sdl_poll()) - { - bq = b; - b = SDL_GetMouseState(&mx, &my); - mx /= sdl_scale; - my /= sdl_scale; + uri_2 = malloc(strlen(save_id)*3+strlen(save_date)*3+strlen(SERVER)+71); + strcpy(uri_2, "http://" SERVER "/Info.api?ID="); + strcaturl(uri_2, save_id); + strappend(uri_2, "&Date="); + strcaturl(uri_2, save_date); + } else { + //We're loading a normal save + uri = malloc(strlen(save_id)*3+strlen(SERVER)+64); + strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); + strcaturl(uri, save_id); - if(active && http_async_req_status(http)) - { - int imgh, imgw, nimgh, nimgw; - http_last_use = time(NULL); - data = http_async_req_stop(http, &status, &data_size); - if(status == 200) - { - pixel *full_save = prerender_save(data, data_size, &imgw, &imgh); - if(full_save!=NULL){ + uri_2 = malloc(strlen(save_id)*3+strlen(SERVER)+64); + strcpy(uri_2, "http://" SERVER "/Info.api?ID="); + strcaturl(uri_2, save_id); + } + http = http_async_req_start(http, uri, NULL, 0, 1); + http_2 = http_async_req_start(http_2, uri_2, NULL, 0, 1); + if (svf_login) + { + http_auth_headers(http, svf_user, svf_pass); + http_auth_headers(http_2, svf_user, svf_pass); + } + http_last_use = time(NULL); + http_last_use_2 = time(NULL); + free(uri); + free(uri_2); + active = 1; + active_2 = 1; + while (!sdl_poll()) + { + bq = b; + b = SDL_GetMouseState(&mx, &my); + mx /= sdl_scale; + my /= sdl_scale; + + if (active && http_async_req_status(http)) + { + int imgh, imgw, nimgh, nimgw; + http_last_use = time(NULL); + data = http_async_req_stop(http, &status, &data_size); + if (status == 200) + { + pixel *full_save = prerender_save(data, data_size, &imgw, &imgh); + if (full_save!=NULL) { save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2); data_ready = 1; free(full_save); @@ -2788,68 +2789,68 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) error_ui(vid_buf, 0, "Save may be from a newer version"); break; } - } - active = 0; - free(http); - http = NULL; - } - if(active_2 && http_async_req_status(http_2)) - { - http_last_use_2 = time(NULL); - info_data = http_async_req_stop(http_2, &status_2, NULL); - if(status_2 == 200) - { - info_ready = info_parse(info_data, info); - if(info_ready==-1) { - error_ui(vid_buf, 0, "Not found"); - break; - } - } - free(info_data); - active_2 = 0; - free(http_2); - http_2 = NULL; - } - - if(data_ready && !hasdrawnthumb) { - draw_image(vid_buf, save_pic, 51, 51, thumb_w, thumb_h, 255); - hasdrawnthumb = 1; - memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - } - if(info_ready && !hasdrawninfo) { - //Render all the save information - cix = drawtext(vid_buf, 60, (YRES/2)+60, info->name, 255, 255, 255, 255); - cix = drawtext(vid_buf, 60, (YRES/2)+72, "Author:", 255, 255, 255, 155); - cix = drawtext(vid_buf, cix+4, (YRES/2)+72, info->author, 255, 255, 255, 255); - cix = drawtext(vid_buf, cix+4, (YRES/2)+72, "Date:", 255, 255, 255, 155); - cix = drawtext(vid_buf, cix+4, (YRES/2)+72, info->date, 255, 255, 255, 255); - drawtextwrap(vid_buf, 62, (YRES/2)+86, (XRES/2)-24, info->description, 255, 255, 255, 200); - + } + active = 0; + free(http); + http = NULL; + } + if (active_2 && http_async_req_status(http_2)) + { + http_last_use_2 = time(NULL); + info_data = http_async_req_stop(http_2, &status_2, NULL); + if (status_2 == 200) + { + info_ready = info_parse(info_data, info); + if (info_ready==-1) { + error_ui(vid_buf, 0, "Not found"); + break; + } + } + free(info_data); + active_2 = 0; + free(http_2); + http_2 = NULL; + } + + if (data_ready && !hasdrawnthumb) { + draw_image(vid_buf, save_pic, 51, 51, thumb_w, thumb_h, 255); + hasdrawnthumb = 1; + memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + } + if (info_ready && !hasdrawninfo) { + //Render all the save information + cix = drawtext(vid_buf, 60, (YRES/2)+60, info->name, 255, 255, 255, 255); + cix = drawtext(vid_buf, 60, (YRES/2)+72, "Author:", 255, 255, 255, 155); + cix = drawtext(vid_buf, cix+4, (YRES/2)+72, info->author, 255, 255, 255, 255); + cix = drawtext(vid_buf, cix+4, (YRES/2)+72, "Date:", 255, 255, 255, 155); + cix = drawtext(vid_buf, cix+4, (YRES/2)+72, info->date, 255, 255, 255, 255); + drawtextwrap(vid_buf, 62, (YRES/2)+86, (XRES/2)-24, info->description, 255, 255, 255, 200); + //Draw the score bars - if(info->voteup>0||info->votedown>0) + if (info->voteup>0||info->votedown>0) { lv = (info->voteup>info->votedown)?info->voteup:info->votedown; lv = (lv>10)?lv:10; - - if(50>lv) + + if (50>lv) { - ry = ((float)(50)/(float)lv); + ryf = 50.0f/((float)lv); //if(lv<8) //{ // ry = ry/(8-lv); //} - nyu = info->voteup*ry; - nyd = info->votedown*ry; + nyu = info->voteup*ryf; + nyd = info->votedown*ryf; } else { - ry = ((float)lv/(float)(50)); - nyu = info->voteup/ry; - nyd = info->votedown/ry; + ryf = ((float)lv)/50.0f; + nyu = info->voteup/ryf; + nyd = info->votedown/ryf; } nyu = nyu>50?50:nyu; nyd = nyd>50?50:nyd; - + fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 0, 107, 10, 255); fillrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+59, 52, 6, 107, 10, 0, 255); drawrect(vid_buf, 48+(XRES/2)-51, (YRES/2)+53, 52, 6, 128, 128, 128, 255); @@ -2859,124 +2860,124 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) fillrect(vid_buf, 48+(XRES/2)-nyd, (YRES/2)+60, nyd, 4, 187, 57, 57, 255); } - ccy = 0; - for(cc=0; cccomment_count; cc++) { - if((ccy + 72 + ((textwidth(info->comments[cc])/(XRES+BARSIZE-100-((XRES/2)+1)-20)))*12)<(YRES+MENUSIZE-50)){ + ccy = 0; + for (cc=0; cccomment_count; cc++) { + 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); 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 += 10; - if(ccy+52author, svf_user); + } + hasdrawninfo = 1; + myown = svf_login && !strcmp(info->author, svf_user); authoritah = svf_login && (!strcmp(info->author, svf_user) || svf_admin || svf_mod); - memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - } - if(info_ready && svf_login){ + memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + } + if (info_ready && svf_login) { //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); drawrect(vid_buf, 50+(XRES/2)+1, YRES+MENUSIZE-125, XRES+BARSIZE-100-((XRES/2)+1), 75, 200, 200, 200, 255); - + drawrect(vid_buf, 54+(XRES/2)+1, YRES+MENUSIZE-121, XRES+BARSIZE-108-((XRES/2)+1), 48, 255, 255, 255, 200); - + ui_edit_draw(vid_buf, &ed); - + drawrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 255); drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255); } - //Open Button - bc = openable?255:150; - drawrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); - drawtext(vid_buf, 73, YRES+MENUSIZE-63, "Open", 255, 255, 255, bc); - drawtext(vid_buf, 58, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc); - //Fav Button - bc = svf_login?255:150; - drawrect(vid_buf, 100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); - drawtext(vid_buf, 122, YRES+MENUSIZE-63, "Fav.", 255, 255, 255, bc); - drawtext(vid_buf, 107, YRES+MENUSIZE-64, "\xCC", 255, 255, 255, bc); - //Report Button - bc = (svf_login && info_ready)?255:150; - drawrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); - drawtext(vid_buf, 168, YRES+MENUSIZE-63, "Report", 255, 255, 255, bc); - drawtext(vid_buf, 158, YRES+MENUSIZE-63, "!", 255, 255, 255, bc); - //Delete Button - bc = authoritah?255:150; - drawrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); - drawtext(vid_buf, 218, YRES+MENUSIZE-63, "Delete", 255, 255, 255, bc); - drawtext(vid_buf, 206, YRES+MENUSIZE-64, "\xAA", 255, 255, 255, bc); - //Open in browser button - bc = 255; - drawrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, bc); - drawtext(vid_buf, 273, YRES+MENUSIZE-63, "Open in Browser", 255, 255, 255, bc); - drawtext(vid_buf, 258, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc); - - //Open Button - if(sdl_key==SDLK_RETURN && openable) { - queue_open = 1; - } - if(mx > 50 && mx < 50+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && openable && !queue_open) { - fillrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); - if(b && !bq) { - //Button Clicked - queue_open = 1; - } - } - //Fav Button - if(mx > 100 && mx < 100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && !queue_open) { - fillrect(vid_buf, 100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); - if(b && !bq) { - //Button Clicked - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); - info_box(vid_buf, "Adding to favourites..."); - execute_fav(vid_buf, save_id); - } - } - //Report Button - if(mx > 150 && mx < 150+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) { - fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); - if(b && !bq) { - //Button Clicked - if(report_ui(vid_buf, save_id)){ - retval = 0; - break; - } - } - } + //Open Button + bc = openable?255:150; + drawrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); + drawtext(vid_buf, 73, YRES+MENUSIZE-63, "Open", 255, 255, 255, bc); + drawtext(vid_buf, 58, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc); + //Fav Button + bc = svf_login?255:150; + drawrect(vid_buf, 100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); + drawtext(vid_buf, 122, YRES+MENUSIZE-63, "Fav.", 255, 255, 255, bc); + drawtext(vid_buf, 107, YRES+MENUSIZE-64, "\xCC", 255, 255, 255, bc); + //Report Button + bc = (svf_login && info_ready)?255:150; + drawrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); + drawtext(vid_buf, 168, YRES+MENUSIZE-63, "Report", 255, 255, 255, bc); + drawtext(vid_buf, 158, YRES+MENUSIZE-63, "!", 255, 255, 255, bc); //Delete Button - if(mx > 200 && mx < 200+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && (authoritah || myown) && !queue_open) { - fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); - if(b && !bq) { + bc = authoritah?255:150; + drawrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, bc); + drawtext(vid_buf, 218, YRES+MENUSIZE-63, "Delete", 255, 255, 255, bc); + drawtext(vid_buf, 206, YRES+MENUSIZE-64, "\xAA", 255, 255, 255, bc); + //Open in browser button + bc = 255; + drawrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, bc); + drawtext(vid_buf, 273, YRES+MENUSIZE-63, "Open in Browser", 255, 255, 255, bc); + drawtext(vid_buf, 258, YRES+MENUSIZE-64, "\x81", 255, 255, 255, bc); + + //Open Button + if (sdl_key==SDLK_RETURN && openable) { + queue_open = 1; + } + if (mx > 50 && mx < 50+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && openable && !queue_open) { + fillrect(vid_buf, 50, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); + if (b && !bq) { //Button Clicked - 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")){ + queue_open = 1; + } + } + //Fav Button + if (mx > 100 && mx < 100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && !queue_open) { + fillrect(vid_buf, 100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); + if (b && !bq) { + //Button Clicked + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); + info_box(vid_buf, "Adding to favourites..."); + execute_fav(vid_buf, save_id); + } + } + //Report Button + if (mx > 150 && mx < 150+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) { + fillrect(vid_buf, 150, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); + if (b && !bq) { + //Button Clicked + if (report_ui(vid_buf, save_id)) { + retval = 0; + break; + } + } + } + //Delete Button + if (mx > 200 && mx < 200+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && (authoritah || myown) && !queue_open) { + fillrect(vid_buf, 200, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); + if (b && !bq) { + //Button Clicked + 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")) { fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); info_box(vid_buf, "Deleting..."); - if(execute_delete(vid_buf, save_id)){ + if (execute_delete(vid_buf, save_id)) { retval = 0; - break; + break; } - } + } } 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); info_box(vid_buf, "Removing..."); - if(execute_delete(vid_buf, save_id)){ + if (execute_delete(vid_buf, save_id)) { retval = 0; - break; + break; } - } + } } } } //Open in browser button - if(mx > 250 && mx < 250+107 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && !queue_open) { - fillrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, 40); - if(b && !bq) { + if (mx > 250 && mx < 250+107 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && !queue_open) { + fillrect(vid_buf, 250, YRES+MENUSIZE-68, 107, 18, 255, 255, 255, 40); + if (b && !bq) { //Button Clicked //TODO: Open link o_uri = malloc(7+strlen(SERVER)+41+strlen(save_id)*3); @@ -2984,784 +2985,784 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) strcaturl(o_uri, save_id); open_link(o_uri); free(o_uri); - } - } - //Submit Button - if(mx > XRES+BARSIZE-100 && mx < XRES+BARSIZE-100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) { - fillrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); - if(b && !bq) { - //Button Clicked - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); - info_box(vid_buf, "Submitting Comment..."); - execute_submit(vid_buf, save_id, ed.str); - ed.str[0] = 0; - } - } - if(!(mx>50 && my>50 && mx XRES+BARSIZE-100 && mx < XRES+BARSIZE-100+50 && my > YRES+MENUSIZE-68 && my < YRES+MENUSIZE-50 && svf_login && info_ready && !queue_open) { + fillrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 40); + if (b && !bq) { + //Button Clicked + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192); + info_box(vid_buf, "Submitting Comment..."); + execute_submit(vid_buf, save_id, ed.str); + ed.str[0] = 0; + } + } + if (!(mx>50 && my>50 && mxauthor, svf_user); - svf_publish = info->publish && svf_login && !strcmp(info->author, svf_user); + svf_open = 1; + svf_own = svf_login && !strcmp(info->author, svf_user); + svf_publish = info->publish && svf_login && !strcmp(info->author, svf_user); - strcpy(svf_id, save_id); - strcpy(svf_name, info->name); - strcpy(svf_description, info->description); - if(info->tags) - { - strncpy(svf_tags, info->tags, 255); - svf_tags[255] = 0; - } else { - svf_tags[0] = 0; - } - svf_myvote = info->myvote; - retval = 1; - break; - } else { - queue_open = 0; + strcpy(svf_id, save_id); + strcpy(svf_name, info->name); + strcpy(svf_description, info->description); + if (info->tags) + { + strncpy(svf_tags, info->tags, 255); + svf_tags[255] = 0; + } else { + svf_tags[0] = 0; + } + svf_myvote = info->myvote; + retval = 1; + break; + } else { + queue_open = 0; - svf_open = 0; - svf_publish = 0; - svf_own = 0; - svf_myvote = 0; - svf_id[0] = 0; - svf_name[0] = 0; - svf_description[0] = 0; - svf_tags[0] = 0; - if(svf_last) - free(svf_last); - svf_last = NULL; - error_ui(vid_buf, 0, "An Error Occurred"); - } - } else { - fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 190); - drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); - } - } - if(!info_ready || !data_ready){ + svf_open = 0; + svf_publish = 0; + svf_own = 0; + svf_myvote = 0; + svf_id[0] = 0; + svf_name[0] = 0; + svf_description[0] = 0; + svf_tags[0] = 0; + if (svf_last) + free(svf_last); + svf_last = NULL; + error_ui(vid_buf, 0, "An Error Occurred"); + } + } else { + fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 190); + drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); + } + } + if (!info_ready || !data_ready) { info_box(vid_buf, "Loading"); } - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - if(info_ready && svf_login){ + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + if (info_ready && svf_login) { ui_edit_process(mx, my, b, &ed); } - if(sdl_key==SDLK_ESCAPE){ - retval = 0; - break; - } + if (sdl_key==SDLK_ESCAPE) { + retval = 0; + break; + } - if(lasttimetitle = mystrdup(info_data+6); - j++; - } - else if(!strncmp(info_data, "NAME ", 5)) - { - info->name = mystrdup(info_data+5); - j++; - } - else if(!strncmp(info_data, "AUTHOR ", 7)) - { - info->author = mystrdup(info_data+7); - j++; - } - else if(!strncmp(info_data, "DATE ", 5)) - { - info->date = mystrdup(info_data+5); - j++; - } - else if(!strncmp(info_data, "DESCRIPTION ", 12)) - { - info->description = mystrdup(info_data+12); - j++; - } - else if(!strncmp(info_data, "VOTEUP ", 7)) - { - info->voteup = atoi(info_data+7); - j++; - } - else if(!strncmp(info_data, "VOTEDOWN ", 9)) - { - info->votedown = atoi(info_data+9); - j++; - } - else if(!strncmp(info_data, "VOTE ", 5)) - { - info->vote = atoi(info_data+5); - j++; - } - else if(!strncmp(info_data, "MYVOTE ", 7)) - { - info->myvote = atoi(info_data+7); - j++; - } - else if(!strncmp(info_data, "MYFAV ", 6)) - { - info->myfav = atoi(info_data+6); - j++; - } - else if(!strncmp(info_data, "PUBLISH ", 8)) - { - info->publish = atoi(info_data+8); - j++; - } - else if(!strncmp(info_data, "TAGS ", 5)) - { - info->tags = mystrdup(info_data+5); - j++; - } - else if(!strncmp(info_data, "COMMENT ", 8)) - { - if(info->comment_count>=6) { - info_data = p; - continue; - } else { - q = strchr(info_data+8, ' '); - *(q++) = 0; - info->commentauthors[info->comment_count] = mystrdup(info_data+8); - info->comments[info->comment_count] = mystrdup(q); - info->comment_count++; - } - j++; - } - info_data = p; - } - if(j>=8) { - return 1; - } else { - return -1; - } + if (!strncmp(info_data, "TITLE ", 6)) + { + info->title = mystrdup(info_data+6); + j++; + } + else if (!strncmp(info_data, "NAME ", 5)) + { + info->name = mystrdup(info_data+5); + j++; + } + else if (!strncmp(info_data, "AUTHOR ", 7)) + { + info->author = mystrdup(info_data+7); + j++; + } + else if (!strncmp(info_data, "DATE ", 5)) + { + info->date = mystrdup(info_data+5); + j++; + } + else if (!strncmp(info_data, "DESCRIPTION ", 12)) + { + info->description = mystrdup(info_data+12); + j++; + } + else if (!strncmp(info_data, "VOTEUP ", 7)) + { + info->voteup = atoi(info_data+7); + j++; + } + else if (!strncmp(info_data, "VOTEDOWN ", 9)) + { + info->votedown = atoi(info_data+9); + j++; + } + else if (!strncmp(info_data, "VOTE ", 5)) + { + info->vote = atoi(info_data+5); + j++; + } + else if (!strncmp(info_data, "MYVOTE ", 7)) + { + info->myvote = atoi(info_data+7); + j++; + } + else if (!strncmp(info_data, "MYFAV ", 6)) + { + info->myfav = atoi(info_data+6); + j++; + } + else if (!strncmp(info_data, "PUBLISH ", 8)) + { + info->publish = atoi(info_data+8); + j++; + } + else if (!strncmp(info_data, "TAGS ", 5)) + { + info->tags = mystrdup(info_data+5); + j++; + } + else if (!strncmp(info_data, "COMMENT ", 8)) + { + if (info->comment_count>=6) { + info_data = p; + continue; + } else { + q = strchr(info_data+8, ' '); + *(q++) = 0; + info->commentauthors[info->comment_count] = mystrdup(info_data+8); + info->comments[info->comment_count] = mystrdup(q); + info->comment_count++; + } + j++; + } + info_data = p; + } + if (j>=8) { + return 1; + } else { + return -1; + } } int search_results(char *str, int votes) { - int i,j; - char *p,*q,*r,*s,*vu,*vd,*pu,*sd; + int i,j; + char *p,*q,*r,*s,*vu,*vd,*pu,*sd; - for(i=0; i=GRID_X*GRID_Y) - break; - if(votes) - { - pu = strchr(str+5, ' '); - if(!pu) - return i; - *(pu++) = 0; - s = strchr(pu, ' '); - if(!s) - return i; - *(s++) = 0; - vu = strchr(s, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - else - { - pu = strchr(str+5, ' '); - if(!pu) - return i; - *(pu++) = 0; - vu = strchr(pu, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - if(!q) - return i; - *(q++) = 0; - r = strchr(q, ' '); - if(!r) - return i; - *(r++) = 0; - search_ids[i] = mystrdup(str+5); + i = 0; + j = 0; + s = NULL; + do_open = 0; + while (1) + { + if (!*str) + break; + p = strchr(str, '\n'); + if (!p) + p = str + strlen(str); + else + *(p++) = 0; + if (!strncmp(str, "OPEN ", 5)) + { + do_open = 1; + if (i>=GRID_X*GRID_Y) + break; + if (votes) + { + pu = strchr(str+5, ' '); + if (!pu) + return i; + *(pu++) = 0; + s = strchr(pu, ' '); + if (!s) + return i; + *(s++) = 0; + vu = strchr(s, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + else + { + pu = strchr(str+5, ' '); + if (!pu) + return i; + *(pu++) = 0; + vu = strchr(pu, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + if (!q) + return i; + *(q++) = 0; + r = strchr(q, ' '); + if (!r) + return i; + *(r++) = 0; + search_ids[i] = mystrdup(str+5); - search_publish[i] = atoi(pu); - search_scoreup[i] = atoi(vu); - search_scoredown[i] = atoi(vd); + search_publish[i] = atoi(pu); + search_scoreup[i] = atoi(vu); + search_scoredown[i] = atoi(vd); - search_owners[i] = mystrdup(q); - search_names[i] = mystrdup(r); + search_owners[i] = mystrdup(q); + search_names[i] = mystrdup(r); - if(s) - search_votes[i] = atoi(s); - thumb_cache_find(str+5, search_thumbs+i, search_thsizes+i); - i++; - } - else if(!strncmp(str, "HISTORY ", 8)) - { - if(i>=GRID_X*GRID_Y) - break; - if(votes) - { - sd = strchr(str+8, ' '); - if(!sd) - return i; - *(sd++) = 0; - pu = strchr(sd, ' '); - if(!pu) - return i; - *(pu++) = 0; - s = strchr(pu, ' '); - if(!s) - return i; - *(s++) = 0; - vu = strchr(s, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - else - { - sd = strchr(str+8, ' '); - if(!sd) - return i; - *(sd++) = 0; - pu = strchr(sd, ' '); - if(!pu) - return i; - *(pu++) = 0; - vu = strchr(pu, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - if(!q) - return i; - *(q++) = 0; - r = strchr(q, ' '); - if(!r) - return i; - *(r++) = 0; - search_ids[i] = mystrdup(str+8); + if (s) + search_votes[i] = atoi(s); + thumb_cache_find(str+5, search_thumbs+i, search_thsizes+i); + i++; + } + else if (!strncmp(str, "HISTORY ", 8)) + { + if (i>=GRID_X*GRID_Y) + break; + if (votes) + { + sd = strchr(str+8, ' '); + if (!sd) + return i; + *(sd++) = 0; + pu = strchr(sd, ' '); + if (!pu) + return i; + *(pu++) = 0; + s = strchr(pu, ' '); + if (!s) + return i; + *(s++) = 0; + vu = strchr(s, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + else + { + sd = strchr(str+8, ' '); + if (!sd) + return i; + *(sd++) = 0; + pu = strchr(sd, ' '); + if (!pu) + return i; + *(pu++) = 0; + vu = strchr(pu, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + if (!q) + return i; + *(q++) = 0; + r = strchr(q, ' '); + if (!r) + return i; + *(r++) = 0; + search_ids[i] = mystrdup(str+8); - search_dates[i] = mystrdup(sd); + search_dates[i] = mystrdup(sd); - search_publish[i] = atoi(pu); - search_scoreup[i] = atoi(vu); - search_scoredown[i] = atoi(vd); + search_publish[i] = atoi(pu); + search_scoreup[i] = atoi(vu); + search_scoredown[i] = atoi(vd); - search_owners[i] = mystrdup(q); - search_names[i] = mystrdup(r); + search_owners[i] = mystrdup(q); + search_names[i] = mystrdup(r); - if(s) - search_votes[i] = atoi(s); - thumb_cache_find(str+8, search_thumbs+i, search_thsizes+i); - i++; - } - else if(!strncmp(str, "TAG ", 4)) - { - if(j >= TAG_MAX) - { - str = p; - continue; - } - q = strchr(str+4, ' '); - if(!q) - { - str = p; - continue; - } - *(q++) = 0; - tag_names[j] = mystrdup(str+4); - tag_votes[j] = atoi(q); - j++; - } - else - { - if(i>=GRID_X*GRID_Y) - break; - if(votes) - { - pu = strchr(str, ' '); - if(!pu) - return i; - *(pu++) = 0; - s = strchr(pu, ' '); - if(!s) - return i; - *(s++) = 0; - vu = strchr(s, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - else - { - pu = strchr(str, ' '); - if(!pu) - return i; - *(pu++) = 0; - vu = strchr(pu, ' '); - if(!vu) - return i; - *(vu++) = 0; - vd = strchr(vu, ' '); - if(!vd) - return i; - *(vd++) = 0; - q = strchr(vd, ' '); - } - if(!q) - return i; - *(q++) = 0; - r = strchr(q, ' '); - if(!r) - return i; - *(r++) = 0; - search_ids[i] = mystrdup(str); + if (s) + search_votes[i] = atoi(s); + thumb_cache_find(str+8, search_thumbs+i, search_thsizes+i); + i++; + } + else if (!strncmp(str, "TAG ", 4)) + { + if (j >= TAG_MAX) + { + str = p; + continue; + } + q = strchr(str+4, ' '); + if (!q) + { + str = p; + continue; + } + *(q++) = 0; + tag_names[j] = mystrdup(str+4); + tag_votes[j] = atoi(q); + j++; + } + else + { + if (i>=GRID_X*GRID_Y) + break; + if (votes) + { + pu = strchr(str, ' '); + if (!pu) + return i; + *(pu++) = 0; + s = strchr(pu, ' '); + if (!s) + return i; + *(s++) = 0; + vu = strchr(s, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + else + { + pu = strchr(str, ' '); + if (!pu) + return i; + *(pu++) = 0; + vu = strchr(pu, ' '); + if (!vu) + return i; + *(vu++) = 0; + vd = strchr(vu, ' '); + if (!vd) + return i; + *(vd++) = 0; + q = strchr(vd, ' '); + } + if (!q) + return i; + *(q++) = 0; + r = strchr(q, ' '); + if (!r) + return i; + *(r++) = 0; + search_ids[i] = mystrdup(str); - search_publish[i] = atoi(pu); - search_scoreup[i] = atoi(vu); - search_scoredown[i] = atoi(vd); + search_publish[i] = atoi(pu); + search_scoreup[i] = atoi(vu); + search_scoredown[i] = atoi(vd); - search_owners[i] = mystrdup(q); - search_names[i] = mystrdup(r); + search_owners[i] = mystrdup(q); + search_names[i] = mystrdup(r); - if(s) - search_votes[i] = atoi(s); - thumb_cache_find(str, search_thumbs+i, search_thsizes+i); - i++; - } - str = p; - } - if(*str) - i++; - return i; + if (s) + search_votes[i] = atoi(s); + thumb_cache_find(str, search_thumbs+i, search_thsizes+i); + i++; + } + str = p; + } + if (*str) + i++; + return i; } int execute_tagop(pixel *vid_buf, char *op, char *tag) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", "Tag", NULL}; - char *parts[2]; + char *names[] = {"ID", "Tag", NULL}; + char *parts[2]; - char *uri = malloc(strlen(SERVER)+strlen(op)+36); - sprintf(uri, "http://" SERVER "/Tag.api?Op=%s", op); + char *uri = malloc(strlen(SERVER)+strlen(op)+36); + sprintf(uri, "http://" SERVER "/Tag.api?Op=%s", op); - parts[0] = svf_id; - parts[1] = tag; + parts[0] = svf_id; + parts[1] = tag; - result = http_multipart_post( - uri, - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + uri, + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - free(uri); + free(uri); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return 1; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return 1; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return 1; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return 1; + } - if(result[2]) - { - strncpy(svf_tags, result+3, 255); - svf_id[15] = 0; - } + if (result[2]) + { + strncpy(svf_tags, result+3, 255); + svf_id[15] = 0; + } - if(result) - free(result); + if (result) + free(result); - return 0; + return 0; } void execute_save(pixel *vid_buf) { - int status; - char *result; + int status; + char *result; - char *names[] = {"Name","Description", "Data:save.bin", "Thumb:thumb.bin", "Publish", "ID", NULL}; - char *parts[6]; - int plens[6]; + char *names[] = {"Name","Description", "Data:save.bin", "Thumb:thumb.bin", "Publish", "ID", NULL}; + char *parts[6]; + int plens[6]; - parts[0] = svf_name; - plens[0] = strlen(svf_name); - parts[1] = svf_description; - plens[1] = strlen(svf_description); - parts[2] = build_save(plens+2, 0, 0, XRES, YRES); - parts[3] = build_thumb(plens+3, 1); - parts[4] = (svf_publish==1)?"Public":"Private"; - plens[4] = strlen((svf_publish==1)?"Public":"Private"); + parts[0] = svf_name; + plens[0] = strlen(svf_name); + parts[1] = svf_description; + plens[1] = strlen(svf_description); + parts[2] = build_save(plens+2, 0, 0, XRES, YRES); + parts[3] = build_thumb(plens+3, 1); + parts[4] = (svf_publish==1)?"Public":"Private"; + plens[4] = strlen((svf_publish==1)?"Public":"Private"); - if(svf_id[0]) - { - parts[5] = svf_id; - plens[5] = strlen(svf_id); - } - else - names[5] = NULL; + if (svf_id[0]) + { + parts[5] = svf_id; + plens[5] = strlen(svf_id); + } + else + names[5] = NULL; - result = http_multipart_post( - "http://" SERVER "/Save.api", - names, parts, plens, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Save.api", + names, parts, plens, + svf_user, svf_pass, + &status, NULL); - if(svf_last) - free(svf_last); - svf_last = parts[2]; - svf_lsize = plens[2]; + if (svf_last) + free(svf_last); + svf_last = parts[2]; + svf_lsize = plens[2]; - free(parts[3]); + free(parts[3]); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return; + } - if(result[2]) - { - strncpy(svf_id, result+3, 15); - svf_id[15] = 0; - } + if (result[2]) + { + strncpy(svf_id, result+3, 15); + svf_id[15] = 0; + } - if(!svf_id[0]) - { - error_ui(vid_buf, 0, "No ID supplied by server"); - free(result); - return; - } + if (!svf_id[0]) + { + error_ui(vid_buf, 0, "No ID supplied by server"); + free(result); + return; + } - thumb_cache_inval(svf_id); + thumb_cache_inval(svf_id); - svf_own = 1; - if(result) - free(result); + svf_own = 1; + if (result) + free(result); } int execute_delete(pixel *vid_buf, char *id) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", NULL}; - char *parts[1]; + char *names[] = {"ID", NULL}; + char *parts[1]; - parts[0] = id; + parts[0] = id; - result = http_multipart_post( - "http://" SERVER "/Delete.api", - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Delete.api", + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return 0; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return 0; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return 0; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return 0; + } - if(result) - free(result); + if (result) + free(result); return 1; } void execute_submit(pixel *vid_buf, char *id, char *message) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", "Message", NULL}; - char *parts[2]; + char *names[] = {"ID", "Message", NULL}; + char *parts[2]; - parts[0] = id; - parts[1] = message; + parts[0] = id; + parts[1] = message; - result = http_multipart_post( - "http://" SERVER "/Comment.api", - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Comment.api", + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return; + } - if(result) - free(result); + if (result) + free(result); } int execute_report(pixel *vid_buf, char *id, char *reason) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", "Reason", NULL}; - char *parts[2]; + char *names[] = {"ID", "Reason", NULL}; + char *parts[2]; - parts[0] = id; - parts[1] = reason; + parts[0] = id; + parts[1] = reason; - result = http_multipart_post( - "http://" SERVER "/Report.api", - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Report.api", + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return 0; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return 0; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return 0; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return 0; + } - if(result) - free(result); + if (result) + free(result); return 1; } void execute_fav(pixel *vid_buf, char *id) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", NULL}; - char *parts[1]; + char *names[] = {"ID", NULL}; + char *parts[1]; - parts[0] = id; + parts[0] = id; - result = http_multipart_post( - "http://" SERVER "/Favourite.api", - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Favourite.api", + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return; + } - if(result) - free(result); + if (result) + free(result); } int execute_vote(pixel *vid_buf, char *id, char *action) { - int status; - char *result; + int status; + char *result; - char *names[] = {"ID", "Action", NULL}; - char *parts[2]; + char *names[] = {"ID", "Action", NULL}; + char *parts[2]; - parts[0] = id; - parts[1] = action; + parts[0] = id; + parts[1] = action; - result = http_multipart_post( - "http://" SERVER "/Vote.api", - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); + result = http_multipart_post( + "http://" SERVER "/Vote.api", + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); - if(status!=200) - { - error_ui(vid_buf, status, http_ret_text(status)); - if(result) - free(result); - return 0; - } - if(result && strncmp(result, "OK", 2)) - { - error_ui(vid_buf, 0, result); - free(result); - return 0; - } + if (status!=200) + { + error_ui(vid_buf, status, http_ret_text(status)); + if (result) + free(result); + return 0; + } + if (result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return 0; + } - if(result) - free(result); - return 1; + if (result) + free(result); + return 1; } -void open_link(char *uri){ +void open_link(char *uri) { #ifdef WIN32 ShellExecute(0, "OPEN", uri, NULL, NULL, 0); #elif MACOSX diff --git a/src/main.c b/src/main.c index 96ecea337..68c114065 100644 --- a/src/main.c +++ b/src/main.c @@ -56,7 +56,7 @@ static const char *it_msg = "\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\n" "\n" "\bgControl+C/V/X are Copy, Paste and cut respectively.\n" - "\bgTo choose a material, hover over once of the icons on the right, it will show a selection of elements in that group.\n" + "\bgTo choose a material, hover over one of the icons on the right, it will show a selection of elements in that group.\n" "\bgPick your material from the menu using mouse left/right buttons.\n" "Draw freeform lines by dragging your mouse left/right button across the drawing area.\n" "Shift+drag will create straight lines of particles.\n" @@ -67,7 +67,7 @@ static const char *it_msg = "\n\boUse 'Z' for a zoom tool. Click to make the drawable zoom window stay around. Use the wheel to change the zoom strength\n" "Use 'S' to save parts of the window as 'stamps'.\n" "'L' will load the most recent stamp, 'K' shows a library of stamps you saved.\n" - "'C' will cycle the display mode (Fire, Blob, Velocity, ect.). The numbers on the keyboard do the same\n" + "'C' will cycle the display mode (Fire, Blob, Velocity, etc.). The numbers on the keyboard do the same\n" "Use the mouse scroll wheel to change the tool size for particles.\n" "The spacebar can be used to pause physics.\n" "'P' will take a screenshot and save it into the current directory.\n" @@ -75,7 +75,7 @@ static const char *it_msg = "\bgCopyright (c) 2008-10 Stanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg)\n" "\bgCopyright (c) 2010 Simon Robertshaw (\brhttp://powdertoy.co.uk\bg, \bbirc.freenode.net #powder\bg)\n" "\bgCopyright (c) 2010 Skresanov Savely (Stickman)\n" - "\bgCopyright (c) 2010 cracker64\n" + "\bgCopyright (c) 2010 cracker64\n" "\bgCopyright (c) 2010 Bryan Hoyle (New elements)\n" "\bgCopyright (c) 2010 Nathan Cousins (New elements, small engine mods.)\n" "\n" @@ -84,8 +84,8 @@ static const char *it_msg = typedef struct { - int start, inc; - pixel *vid; + int start, inc; + pixel *vid; } upstruc; #ifdef BETA @@ -110,27 +110,27 @@ int numCores = 4; int core_count() { - int numCPU = 1; + int numCPU = 1; #ifdef MT #ifdef WIN32 - SYSTEM_INFO sysinfo; - GetSystemInfo( &sysinfo ); - numCPU = sysinfo.dwNumberOfProcessors; + SYSTEM_INFO sysinfo; + GetSystemInfo( &sysinfo ); + numCPU = sysinfo.dwNumberOfProcessors; #else #ifdef MACOSX - numCPU = 4; + numCPU = 4; #else - numCPU = sysconf( _SC_NPROCESSORS_ONLN ); + numCPU = sysconf( _SC_NPROCESSORS_ONLN ); #endif #endif - printf("Cpus: %d\n", numCPU); - if(numCPU>1) - printf("Multithreading enabled\n"); - else - printf("Multithreading disabled\n"); + printf("Cpus: %d\n", numCPU); + if (numCPU>1) + printf("Multithreading enabled\n"); + else + printf("Multithreading disabled\n"); #endif - return numCPU; + return numCPU; } int mousex = 0, mousey = 0; //They contain mouse position @@ -139,15 +139,15 @@ int kiosk_enable = 0; void sdl_seticon(void) { #ifdef WIN32 - //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - //SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); + //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + //SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); #else #ifdef MACOSX - //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - //SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); + //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + //SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); #else - SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon, 16, 16, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); + SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon, 16, 16, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/); #endif #endif } @@ -155,26 +155,26 @@ void sdl_seticon(void) int frame_idx=0; void dump_frame(pixel *src, int w, int h, int pitch) { - char frame_name[32]; - int j,i; - unsigned char c[3]; - FILE *f; - sprintf(frame_name,"frame%04d.ppm",frame_idx); - f=fopen(frame_name,"wb"); - fprintf(f,"P6\n%d %d\n255\n",w,h); - for(j=0; j=0 && x=0 && y=0 && x=0 && y255) i=255; - d[p++] = i; - } - for(y=by0; y255) i=255; - d[p++] = i; - } + // save the required air state + for (y=by0; y255) i=255; + d[p++] = i; + } + for (y=by0; y255) i=255; + d[p++] = i; + } - // save the particle map - for(i=0; i=x0 && x=y0 && y=x0 && x=y0 && y255) x=255; - if(y<0) y=0; - if(y>255) y=255; - d[p++] = x; - d[p++] = y; - } - } - for(j=0; j255) x=255; + if (y<0) y=0; + if (y>255) y=255; + d[p++] = x; + d[p++] = y; + } + } + for (j=0; j>8); - d[p++] = (ttlife&0x00FF); + d[p++] = ((ttlife&0xFF00)>>8); + d[p++] = (ttlife&0x00FF); } - } - for(j=0; j>8); - d[p++] = (tttmp&0x00FF); + d[p++] = ((tttmp&0xFF00)>>8); + d[p++] = (tttmp&0x00FF); } - } - for(j=0; j>8); - d[p++] = (tttemp&0x00FF); - } - } - for(j=0; j>8); + d[p++] = (tttemp&0x00FF); + } + } + for (j=0; j=x0 && signs[i].x=y0 && signs[i].y=x0 && signs[i].x=y0 && signs[i].y>8; - d[p++] = (signs[i].y-y0); - d[p++] = (signs[i].y-y0)>>8; - d[p++] = signs[i].ju; - x = strlen(signs[i].text); - d[p++] = x; - memcpy(d+p, signs[i].text, x); - p+=x; - } + j = 0; + for (i=0; i=x0 && signs[i].x=y0 && signs[i].y=x0 && signs[i].x=y0 && signs[i].y>8; + d[p++] = (signs[i].y-y0); + d[p++] = (signs[i].y-y0)>>8; + d[p++] = signs[i].ju; + x = strlen(signs[i].text); + d[p++] = x; + memcpy(d+p, signs[i].text, x); + p+=x; + } - i = (p*101+99)/100 + 612; - c = malloc(i); + i = (p*101+99)/100 + 612; + c = malloc(i); - //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures - //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error + //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures + //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error - c[0] = 0x50; //0x66; - c[1] = 0x53; //0x75; - c[2] = 0x76; //0x43; - c[3] = legacy_enable|((sys_pause<<1)&0x02); - c[4] = SAVE_VERSION; - c[5] = CELL; - c[6] = bw; - c[7] = bh; - c[8] = p; - c[9] = p >> 8; - c[10] = p >> 16; - c[11] = p >> 24; + c[0] = 0x50; //0x66; + c[1] = 0x53; //0x75; + c[2] = 0x76; //0x43; + c[3] = legacy_enable|((sys_pause<<1)&0x02); + c[4] = SAVE_VERSION; + c[5] = CELL; + c[6] = bw; + c[7] = bh; + c[8] = p; + c[9] = p >> 8; + c[10] = p >> 16; + c[11] = p >> 24; - i -= 12; + i -= 12; - if(BZ2_bzBuffToBuffCompress((char *)(c+12), (unsigned *)&i, (char *)d, p, 9, 0, 0) != BZ_OK) - { - free(d); - free(c); - return NULL; - } - free(d); + if (BZ2_bzBuffToBuffCompress((char *)(c+12), (unsigned *)&i, (char *)d, p, 9, 0, 0) != BZ_OK) + { + free(d); + free(c); + return NULL; + } + free(d); - *size = i+12; - return c; + *size = i+12; + return c; } int parse_save(void *save, int size, int replace, int x0, int y0) { - unsigned char *d,*c=save; - int i,j,k,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)), ver, pty, ty, legacy_beta=0; - int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h, q; - int fp[NPART], nf=0, new_format = 0, ttv = 0; + unsigned char *d,*c=save; + int q,i,j,k,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)), ver, pty, ty, legacy_beta=0; + int bx0=x0/CELL, by0=y0/CELL, bw, bh, w, h; + int fp[NPART], nf=0, new_format = 0, ttv = 0; - //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures - //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error + //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures + //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error - if(size<16) - return 1; - if(!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) - return 1; - if(c[2]==0x76 && c[1]==0x53 && c[0]==0x50) { - new_format = 1; - } - if(c[4]>SAVE_VERSION) - return 2; - ver = c[4]; + if (size<16) + return 1; + if (!(c[2]==0x43 && c[1]==0x75 && c[0]==0x66) && !(c[2]==0x76 && c[1]==0x53 && c[0]==0x50)) + return 1; + if (c[2]==0x76 && c[1]==0x53 && c[0]==0x50) { + new_format = 1; + } + if (c[4]>SAVE_VERSION) + return 2; + ver = c[4]; - if(ver<34) - { - legacy_enable = 1; - } - else - { - if(ver>=44){ + if (ver<34) + { + legacy_enable = 1; + } + else + { + if (ver>=44) { legacy_enable = c[3]&0x01; - if(!sys_pause){ + if (!sys_pause) { sys_pause = (c[3]>>1)&0x01; } } else { - if(c[3]==1||c[3]==0){ + if (c[3]==1||c[3]==0) { legacy_enable = c[3]; } else { legacy_beta = 1; } } - } + } - bw = c[6]; - bh = c[7]; - if(bx0+bw > XRES/CELL) - bx0 = XRES/CELL - bw; - if(by0+bh > YRES/CELL) - by0 = YRES/CELL - bh; - if(bx0 < 0) - bx0 = 0; - if(by0 < 0) - by0 = 0; + bw = c[6]; + bh = c[7]; + if (bx0+bw > XRES/CELL) + bx0 = XRES/CELL - bw; + if (by0+bh > YRES/CELL) + by0 = YRES/CELL - bh; + if (bx0 < 0) + bx0 = 0; + if (by0 < 0) + by0 = 0; - if(c[5]!=CELL || bx0+bw>XRES/CELL || by0+bh>YRES/CELL) - return 3; - i = (unsigned)c[8]; - i |= ((unsigned)c[9])<<8; - i |= ((unsigned)c[10])<<16; - i |= ((unsigned)c[11])<<24; - d = malloc(i); - if(!d) - return 1; + if (c[5]!=CELL || bx0+bw>XRES/CELL || by0+bh>YRES/CELL) + return 3; + i = (unsigned)c[8]; + i |= ((unsigned)c[9])<<8; + i |= ((unsigned)c[10])<<16; + i |= ((unsigned)c[11])<<24; + d = malloc(i); + if (!d) + return 1; - if(BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) - return 1; - size = i; + if (BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) + return 1; + size = i; - if(size < bw*bh) - return 1; + if (size < bw*bh) + return 1; - // normalize coordinates - x0 = bx0*CELL; - y0 = by0*CELL; - w = bw *CELL; - h = bh *CELL; + // normalize coordinates + x0 = bx0*CELL; + y0 = by0*CELL; + w = bw *CELL; + h = bh *CELL; - if(replace) - { + if (replace) + { gravityMode = 1; - memset(bmap, 0, sizeof(bmap)); - memset(emap, 0, sizeof(emap)); - memset(signs, 0, sizeof(signs)); - memset(parts, 0, sizeof(particle)*NPART); - memset(pmap, 0, sizeof(pmap)); - memset(vx, 0, sizeof(vx)); - memset(vy, 0, sizeof(vy)); - memset(pv, 0, sizeof(pv)); - memset(photons, 0, sizeof(photons)); - memset(wireless, 0, sizeof(wireless)); - memset(gol2, 0, sizeof(gol2)); - memset(portal, 0, sizeof(portal)); - } + memset(photons, 0, sizeof(photons)); + memset(wireless, 0, sizeof(wireless)); + memset(gol2, 0, sizeof(gol2)); + memset(portal, 0, sizeof(portal)); - // make a catalog of free parts - memset(pmap, 0, sizeof(pmap)); - for(i=0; i= size) + goto corrupt; + fvx[y][x] = (d[p++]-127.0f)/64.0f; + } + for (y=by0; y= size) + goto corrupt; + fvy[y][x] = (d[p++]-127.0f)/64.0f; + } + + // load the particle map + i = 0; + pty = p; + for (y=y0; y= size) + goto corrupt; + j=d[p++]; + if (j >= PT_NUM) { + //TODO: Possibly some server side translation + j = PT_DUST;//goto corrupt; + } + gol[x][y]=0; + if (j)// && !(isplayer == 1 && j==PT_STKM)) + { + if (pmap[y][x]) + { + k = pmap[y][x]>>8; + parts[k].type = j; + if (j == PT_PHOT) + parts[k].ctype = 0x3fffffff; + parts[k].x = (float)x; + parts[k].y = (float)y; + m[(x-x0)+(y-y0)*w] = k+1; + } + else if (i < nf) + { + parts[fp[i]].type = j; + if (j == PT_COAL) + parts[fp[i]].tmp = 50; + if (j == PT_FUSE) + parts[fp[i]].tmp = 50; + if (j == PT_PHOT) + parts[fp[i]].ctype = 0x3fffffff; + parts[fp[i]].x = (float)x; + parts[fp[i]].y = (float)y; + m[(x-x0)+(y-y0)*w] = fp[i]+1; + i++; + } + else + m[(x-x0)+(y-y0)*w] = NPART+1; + } } - p++; - } - for(y=by0; y= size) - goto corrupt; - fvx[y][x] = (d[p++]-127.0f)/64.0f; - } - for(y=by0; y= size) - goto corrupt; - fvy[y][x] = (d[p++]-127.0f)/64.0f; - } + // load particle properties + for (j=0; j= size) + goto corrupt; + if (i < NPART) + { + parts[i].vx = (d[p++]-127.0f)/16.0f; + parts[i].vy = (d[p++]-127.0f)/16.0f; + if (parts[i].type == PT_STKM) + { + //player[2] = PT_DUST; - // load the particle map - i = 0; - pty = p; - for(y=y0; y= size) - goto corrupt; - j=d[p++]; - if(j >= PT_NUM) { - //TODO: Possibly some server side translation - j = PT_DUST;//goto corrupt; - } - gol[x][y]=0; - if(j)// && !(isplayer == 1 && j==PT_STKM)) - { - if(pmap[y][x]) - { - k = pmap[y][x]>>8; - parts[k].type = j; - if(j == PT_PHOT) - parts[k].ctype = 0x3fffffff; - parts[k].x = (float)x; - parts[k].y = (float)y; - m[(x-x0)+(y-y0)*w] = k+1; - } - else if(i < nf) - { - parts[fp[i]].type = j; - if(j == PT_COAL) - parts[fp[i]].tmp = 50; - if(j == PT_FUSE) - parts[fp[i]].tmp = 50; - if(j == PT_PHOT) - parts[fp[i]].ctype = 0x3fffffff; - parts[fp[i]].x = (float)x; - parts[fp[i]].y = (float)y; - m[(x-x0)+(y-y0)*w] = fp[i]+1; - i++; - } - else - m[(x-x0)+(y-y0)*w] = NPART+1; - } - } + player[3] = parts[i].x-1; //Setting legs positions + player[4] = parts[i].y+6; + player[5] = parts[i].x-1; + player[6] = parts[i].y+6; - // load particle properties - for(j=0; j= size) - goto corrupt; - if(i < NPART) - { - parts[i].vx = (d[p++]-127.0f)/16.0f; - parts[i].vy = (d[p++]-127.0f)/16.0f; - if(parts[i].type == PT_STKM) - { - //player[2] = PT_DUST; + player[7] = parts[i].x-3; + player[8] = parts[i].y+12; + player[9] = parts[i].x-3; + player[10] = parts[i].y+12; - player[3] = parts[i].x-1; //Setting legs positions - player[4] = parts[i].y+6; - player[5] = parts[i].x-1; - player[6] = parts[i].y+6; + player[11] = parts[i].x+1; + player[12] = parts[i].y+6; + player[13] = parts[i].x+1; + player[14] = parts[i].y+6; - player[7] = parts[i].x-3; - player[8] = parts[i].y+12; - player[9] = parts[i].x-3; - player[10] = parts[i].y+12; + player[15] = parts[i].x+3; + player[16] = parts[i].y+12; + player[17] = parts[i].x+3; + player[18] = parts[i].y+12; - player[11] = parts[i].x+1; - player[12] = parts[i].y+6; - player[13] = parts[i].x+1; - player[14] = parts[i].y+6; + } + if (parts[i].type == PT_STKM2) + { + //player[2] = PT_DUST; - player[15] = parts[i].x+3; - player[16] = parts[i].y+12; - player[17] = parts[i].x+3; - player[18] = parts[i].y+12; + player2[3] = parts[i].x-1; //Setting legs positions + player2[4] = parts[i].y+6; + player2[5] = parts[i].x-1; + player2[6] = parts[i].y+6; - } - if(parts[i].type == PT_STKM2) - { - //player[2] = PT_DUST; + player2[7] = parts[i].x-3; + player2[8] = parts[i].y+12; + player2[9] = parts[i].x-3; + player2[10] = parts[i].y+12; - player2[3] = parts[i].x-1; //Setting legs positions - player2[4] = parts[i].y+6; - player2[5] = parts[i].x-1; - player2[6] = parts[i].y+6; + player2[11] = parts[i].x+1; + player2[12] = parts[i].y+6; + player2[13] = parts[i].x+1; + player2[14] = parts[i].y+6; - player2[7] = parts[i].x-3; - player2[8] = parts[i].y+12; - player2[9] = parts[i].x-3; - player2[10] = parts[i].y+12; + player2[15] = parts[i].x+3; + player2[16] = parts[i].y+12; + player2[17] = parts[i].x+3; + player2[18] = parts[i].y+12; - player2[11] = parts[i].x+1; - player2[12] = parts[i].y+6; - player2[13] = parts[i].x+1; - player2[14] = parts[i].y+6; - - player2[15] = parts[i].x+3; - player2[16] = parts[i].y+12; - player2[17] = parts[i].x+3; - player2[18] = parts[i].y+12; - - } - } - else - p += 2; - } - } - for(j=0; j=44){ - if(p >= size) { + } + } + else + p += 2; + } + } + for (j=0; j=44) { + if (p >= size) { goto corrupt; } - if(i <= NPART) { + if (i <= NPART) { ttv = (d[p++])<<8; ttv |= (d[p++]); parts[i-1].life = ttv; @@ -689,25 +691,25 @@ int parse_save(void *save, int size, int replace, int x0, int y0) p+=2; } } else { - if(p >= size) + if (p >= size) goto corrupt; - if(i <= NPART) + if (i <= NPART) parts[i-1].life = d[p++]*4; else p++; } - } - } - if(ver>=44){ - for(j=0; j=44) { + for (j=0; j= size) { + if (p >= size) { goto corrupt; } - if(i <= NPART) { + if (i <= NPART) { ttv = (d[p++])<<8; ttv |= (d[p++]); parts[i-1].tmp = ttv; @@ -722,111 +724,111 @@ int parse_save(void *save, int size, int replace, int x0, int y0) } } } - for(j=0; j=34&&legacy_beta==0) - { - if(p >= size) - { - goto corrupt; - } - if(i <= NPART) - { - if(ver>=42) { - if(new_format) { - ttv = (d[p++])<<8; - ttv |= (d[p++]); - if(parts[i-1].type==PT_PUMP) { - parts[i-1].temp = ttv + 0.15;//fix PUMP saved at 0, so that it loads at 0. - } else { - parts[i-1].temp = ttv; - } - } else { - parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; - } - } else { - parts[i-1].temp = ((d[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273; - } - } - else - { - p++; - if(new_format) { - p++; - } - } - } - else - { - parts[i-1].temp = ptypes[parts[i-1].type].heat; - } - } - } - for(j=0; j=43) || (ty==PT_BCLN && ver>=44) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34) || (ty==PT_PIPE && ver>=43))) - { - if(p >= size) - goto corrupt; - if(i <= NPART) - parts[i-1].ctype = d[p++]; - else - p++; - } - } + for (j=0; j=34&&legacy_beta==0) + { + if (p >= size) + { + goto corrupt; + } + if (i <= NPART) + { + if (ver>=42) { + if (new_format) { + ttv = (d[p++])<<8; + ttv |= (d[p++]); + if (parts[i-1].type==PT_PUMP) { + parts[i-1].temp = ttv + 0.15;//fix PUMP saved at 0, so that it loads at 0. + } else { + parts[i-1].temp = ttv; + } + } else { + parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; + } + } else { + parts[i-1].temp = ((d[p++]*((O_MAX_TEMP+(-O_MIN_TEMP))/255))+O_MIN_TEMP)+273; + } + } + else + { + p++; + if (new_format) { + p++; + } + } + } + else + { + parts[i-1].temp = ptypes[parts[i-1].type].heat; + } + } + } + for (j=0; j=43) || (ty==PT_BCLN && ver>=44) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34) || (ty==PT_PIPE && ver>=43))) + { + if (p >= size) + goto corrupt; + if (i <= NPART) + parts[i-1].ctype = d[p++]; + else + p++; + } + } - if(p >= size) - goto version1; - j = d[p++]; - for(i=0; i size) - goto corrupt; - for(k=0; k size) - goto corrupt; - if(k= size) + goto version1; + j = d[p++]; + for (i=0; i size) + goto corrupt; + for (k=0; k size) + goto corrupt; + if (kXRES/GRID_S || stamps[i].thumb_h>YRES/GRID_S)) - { - factor_x = ceil((float)stamps[i].thumb_w/(float)(XRES/GRID_S)); - factor_y = ceil((float)stamps[i].thumb_h/(float)(YRES/GRID_S)); - if(factor_y > factor_x) - factor_x = factor_y; - tmp = rescale_img(stamps[i].thumb, stamps[i].thumb_w, stamps[i].thumb_h, &(stamps[i].thumb_w), &(stamps[i].thumb_h), factor_x); - free(stamps[i].thumb); - stamps[i].thumb = tmp; - } - } + if (data) + { + stamps[i].thumb = prerender_save(data, size, &(stamps[i].thumb_w), &(stamps[i].thumb_h)); + if (stamps[i].thumb && (stamps[i].thumb_w>XRES/GRID_S || stamps[i].thumb_h>YRES/GRID_S)) + { + factor_x = ceil((float)stamps[i].thumb_w/(float)(XRES/GRID_S)); + factor_y = ceil((float)stamps[i].thumb_h/(float)(YRES/GRID_S)); + if (factor_y > factor_x) + factor_x = factor_y; + tmp = rescale_img(stamps[i].thumb, stamps[i].thumb_w, stamps[i].thumb_h, &(stamps[i].thumb_w), &(stamps[i].thumb_h), factor_x); + free(stamps[i].thumb); + stamps[i].thumb = tmp; + } + } - free(data); + free(data); } int clipboard_ready = 0; @@ -910,94 +912,94 @@ int clipboard_length = 0; void stamp_save(int x, int y, int w, int h) { - FILE *f; - int n; - char fn[64], sn[16]; - void *s=build_save(&n, x, y, w, h); + FILE *f; + int n; + char fn[64], sn[16]; + void *s=build_save(&n, x, y, w, h); #ifdef WIN32 - _mkdir("stamps"); + _mkdir("stamps"); #else - mkdir("stamps", 0755); + mkdir("stamps", 0755); #endif - stamp_gen_name(sn); - sprintf(fn, "stamps" PATH_SEP "%s.stm", sn); + stamp_gen_name(sn); + sprintf(fn, "stamps" PATH_SEP "%s.stm", sn); - f = fopen(fn, "wb"); - if(!f) - return; - fwrite(s, n, 1, f); - fclose(f); + f = fopen(fn, "wb"); + if (!f) + return; + fwrite(s, n, 1, f); + fclose(f); - free(s); + free(s); - if(stamps[STAMP_MAX-1].thumb) - free(stamps[STAMP_MAX-1].thumb); - memmove(stamps+1, stamps, sizeof(struct stamp)*(STAMP_MAX-1)); - memset(stamps, 0, sizeof(struct stamp)); - if(stamp_count0) - { - memcpy(&tmp, stamps+i, sizeof(struct stamp)); - memmove(stamps+1, stamps, sizeof(struct stamp)*i); - memcpy(stamps, &tmp, sizeof(struct stamp)); + if (i>0) + { + memcpy(&tmp, stamps+i, sizeof(struct stamp)); + memmove(stamps+1, stamps, sizeof(struct stamp)*i); + memcpy(stamps, &tmp, sizeof(struct stamp)); - stamp_update(); - } + stamp_update(); + } - return data; + return data; } void stamp_init(void) { - int i; - FILE *f; + int i; + FILE *f; - memset(stamps, 0, sizeof(stamps)); + memset(stamps, 0, sizeof(stamps)); - f=fopen("stamps" PATH_SEP "stamps.def", "rb"); - if(!f) - return; - for(i=0; i= THUMB_CACHE_SIZE) - return; - free(thumb_cache_id[i]); - free(thumb_cache_data[i]); - thumb_cache_id[i] = NULL; - for(j=0; j thumb_cache_lru[i]) - thumb_cache_lru[j]--; + int i,j; + for (i=0; i= THUMB_CACHE_SIZE) + return; + free(thumb_cache_id[i]); + free(thumb_cache_data[i]); + thumb_cache_id[i] = NULL; + for (j=0; j thumb_cache_lru[i]) + thumb_cache_lru[j]--; } void thumb_cache_add(char *id, void *thumb, int size) { - int i,m=-1,j=-1; - thumb_cache_inval(id); - for(i=0; i m) - { - m = thumb_cache_lru[i]; - j = i; - } - } - if(i >= THUMB_CACHE_SIZE) - { - thumb_cache_inval(thumb_cache_id[j]); - i = j; - } - for(j=0; j m) + { + m = thumb_cache_lru[i]; + j = i; + } + } + if (i >= THUMB_CACHE_SIZE) + { + thumb_cache_inval(thumb_cache_id[j]); + i = j; + } + for (j=0; j= THUMB_CACHE_SIZE) - return 0; - for(j=0; j= THUMB_CACHE_SIZE) + return 0; + for (j=0; j1180) + if (bsx>1180) bsx = 1180; - if(bsx<0) + if (bsx<0) bsx = 0; - if(bsy>1180) + if (bsy>1180) bsy = 1180; - if(bsy<0) + if (bsy<0) bsy = 0; - - update_particles(vid_buf); - draw_parts(vid_buf); - if(cmode==CM_PERS) - { - if(!fire_fc) - { - dim_copy_pers(pers_bg, vid_buf); - } - else - { - memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - fire_fc = (fire_fc+1) % 3; - } - if(cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY) - render_fire(vid_buf); + update_particles(vid_buf); + draw_parts(vid_buf); - render_signs(vid_buf); + if (cmode==CM_PERS) + { + if (!fire_fc) + { + dim_copy_pers(pers_bg, vid_buf); + } + else + { + memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); + } + fire_fc = (fire_fc+1) % 3; + } + if (cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY) + render_fire(vid_buf); - memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE); - clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); + render_signs(vid_buf); - draw_svf_ui(vid_buf); + memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE); + clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); - if(http_ver_check) - { - if(!do_check && http_async_req_status(http_ver_check)) - { - ver_data = http_async_req_stop(http_ver_check, &http_ret, NULL); - if(http_ret==200 && ver_data) - { + draw_svf_ui(vid_buf); + + if (http_ver_check) + { + if (!do_check && http_async_req_status(http_ver_check)) + { + ver_data = http_async_req_stop(http_ver_check, &http_ret, NULL); + if (http_ret==200 && ver_data) + { #ifdef BETA - if(sscanf(ver_data, "%d.%d.%d", &major, &minor, &is_beta)==3) - if(major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION) || (major==SAVE_VERSION && is_beta == 0)) - old_version = 1; + if (sscanf(ver_data, "%d.%d.%d", &major, &minor, &is_beta)==3) + if (major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION) || (major==SAVE_VERSION && is_beta == 0)) + old_version = 1; #else - if(sscanf(ver_data, "%d.%d", &major, &minor)==2) - if(major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION)) - old_version = 1; + if (sscanf(ver_data, "%d.%d", &major, &minor)==2) + if (major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION)) + old_version = 1; #endif - free(ver_data); - } - http_ver_check = NULL; - } - do_check = (do_check+1) & 15; - } + free(ver_data); + } + http_ver_check = NULL; + } + do_check = (do_check+1) & 15; + } - if(sdl_key=='q' || sdl_key==SDLK_ESCAPE) - { - if(confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit")) - { - break; - } - } - //if(sdl_key=='d' && isplayer) - //{ - // death = 1; - // //death = !(death); - //} - if(sdl_key=='f') - { - framerender = 1; - } - if((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0]) - { - if(load_mode) - { - free(load_img); - free(load_data); - load_mode = 0; - load_data = NULL; - load_img = NULL; - } - if(it > 50) - it = 50; - if(sdl_key=='k' && stamps[1].name[0]) - { - j = stamp_ui(vid_buf); - if(j>=0) - load_data = stamp_load(j, &load_size); - else - load_data = NULL; - } - else - load_data = stamp_load(0, &load_size); - if(load_data) - { - load_img = prerender_save(load_data, load_size, &load_w, &load_h); - if(load_img) - load_mode = 1; - else - free(load_data); - } - } - if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2)) - { - if(it > 50) - it = 50; - save_mode = 1; - } - if(sdl_key=='1') - { - set_cmode(CM_VEL); - } - if(sdl_key=='2') - { - set_cmode(CM_PRESS); - } - if(sdl_key=='3') - { - set_cmode(CM_PERS); - } - if(sdl_key=='4') - { - set_cmode(CM_FIRE); - } - if(sdl_key=='5') - { - set_cmode(CM_BLOB); - } - if(sdl_key=='6') - { - set_cmode(CM_HEAT); - } - if(sdl_key=='7') - { - set_cmode(CM_FANCY); - } - if(sdl_key=='8') - { - set_cmode(CM_NOTHING); - } - if(sdl_key=='9') - { - set_cmode(CM_GRAD); - } - if(sdl_key=='0') - { - set_cmode(CM_CRACK); - } - if(sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE) - { - set_cmode(CM_LIFE); - } - if(sdl_key==SDLK_TAB) - { - CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ; - } - if(sdl_key==SDLK_LEFTBRACKET) { - if(sdl_zoom_trig==1) - { - ZSIZE -= 1; - if(ZSIZE>60) - ZSIZE = 60; - if(ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; - } - else - { - if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + if (sdl_key=='q' || sdl_key==SDLK_ESCAPE) { - bsx -= 1; - bsy -= 1; - } - else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) - { - bsx -= 1; - } - else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) - { - bsy -= 1; - } - else - { - bsx -= ceil((bsx/5)+0.5f); - bsy -= ceil((bsy/5)+0.5f); - } - if(bsx>1180) - bsx = 1180; - if(bsy>1180) - bsy = 1180; - if(bsx<0) - bsx = 0; - if(bsy<0) - bsy = 0; - } - } - if(sdl_key==SDLK_RIGHTBRACKET) { - if(sdl_zoom_trig==1) - { - ZSIZE += 1; - if(ZSIZE>60) - ZSIZE = 60; - if(ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; - } - else - { - if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) - { - bsx += 1; - bsy += 1; - } - else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) - { - bsx += 1; - } - else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) - { - bsy += 1; - } - else - { - bsx += ceil((bsx/5)+0.5f); - bsy += ceil((bsy/5)+0.5f); - } - if(bsx>1180) - bsx = 1180; - if(bsy>1180) - bsy = 1180; - if(bsx<0) - bsx = 0; - if(bsy<0) - bsy = 0; - } - } - if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2)) - DEBUG_MODE = !DEBUG_MODE; - if(sdl_key=='i') - { - int nx, ny; - for(nx = 0;nx 50) + it = 50; + if (sdl_key=='k' && stamps[1].name[0]) + { + j = stamp_ui(vid_buf); + if (j>=0) + load_data = stamp_load(j, &load_size); + else + load_data = NULL; + } + else + load_data = stamp_load(0, &load_size); + if (load_data) + { + load_img = prerender_save(load_data, load_size, &load_w, &load_h); + if (load_img) + load_mode = 1; + else + free(load_data); + } + } + if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2)) + { + if (it > 50) + it = 50; + save_mode = 1; + } + if (sdl_key=='1') + { + set_cmode(CM_VEL); + } + if (sdl_key=='2') + { + set_cmode(CM_PRESS); + } + if (sdl_key=='3') + { + set_cmode(CM_PERS); + } + if (sdl_key=='4') + { + set_cmode(CM_FIRE); + } + if (sdl_key=='5') + { + set_cmode(CM_BLOB); + } + if (sdl_key=='6') + { + set_cmode(CM_HEAT); + } + if (sdl_key=='7') + { + set_cmode(CM_FANCY); + } + if (sdl_key=='8') + { + set_cmode(CM_NOTHING); + } + if (sdl_key=='9') + { + set_cmode(CM_GRAD); + } + if (sdl_key=='0') + { + set_cmode(CM_CRACK); + } + if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE) + { + set_cmode(CM_LIFE); + } + if (sdl_key==SDLK_TAB) + { + CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ; + } + if (sdl_key==SDLK_LEFTBRACKET) { + if (sdl_zoom_trig==1) + { + ZSIZE -= 1; + if (ZSIZE>60) + ZSIZE = 60; + if (ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; + } + else + { + if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx -= 1; + bsy -= 1; + } + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx -= 1; + } + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy -= 1; + } + else + { + bsx -= ceil((bsx/5)+0.5f); + bsy -= ceil((bsy/5)+0.5f); + } + if (bsx>1180) + bsx = 1180; + if (bsy>1180) + bsy = 1180; + if (bsx<0) + bsx = 0; + if (bsy<0) + bsy = 0; + } + } + if (sdl_key==SDLK_RIGHTBRACKET) { + if (sdl_zoom_trig==1) + { + ZSIZE += 1; + if (ZSIZE>60) + ZSIZE = 60; + if (ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; + } + else + { + if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx += 1; + bsy += 1; + } + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx += 1; + } + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy += 1; + } + else + { + bsx += ceil((bsx/5)+0.5f); + bsy += ceil((bsy/5)+0.5f); + } + if (bsx>1180) + bsx = 1180; + if (bsy>1180) + bsy = 1180; + if (bsx<0) + bsx = 0; + if (bsy<0) + bsy = 0; + } + } + if (sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2)) + DEBUG_MODE = !DEBUG_MODE; + if (sdl_key=='i') + { + int nx, ny; + for (nx = 0; nx 50) - it = 50; - } - if(sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo - { - int cbx, cby, cbi; - for(cbi=0; cbi 50) + it = 50; + } + if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo + { + int cbx, cby, cbi; - for(cby = 0; cby=1) + if (sdl_mod & (KMOD_SHIFT)) { + if (vs>=1) vs = 0; else vs = 3;//every other frame } else { - if(vs>=1) + if (vs>=1) vs = 0; else vs = 1; } counterthing = 0; } - if(vs) + if (vs) { - if(counterthing+1>=vs) + if (counterthing+1>=vs) { dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE); counterthing = 0; @@ -1684,837 +1630,843 @@ int main(int argc, char *argv[]) } #endif - if(sdl_wheel) - { - if(sdl_zoom_trig==1) - { - ZSIZE += sdl_wheel; - if(ZSIZE>60) - ZSIZE = 60; - if(ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; - sdl_wheel = 0; - } - else - { - if(!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + if (sdl_wheel) { - bsx += sdl_wheel; - bsy += sdl_wheel; + if (sdl_zoom_trig==1) + { + ZSIZE += sdl_wheel; + if (ZSIZE>60) + ZSIZE = 60; + if (ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; + sdl_wheel = 0; + } + else + { + if (!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx += sdl_wheel; + bsy += sdl_wheel; + } + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx += sdl_wheel; + } + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy += sdl_wheel; + } + if (bsx>1180) + bsx = 1180; + if (bsx<0) + bsx = 0; + if (bsy>1180) + bsy = 1180; + if (bsy<0) + bsy = 0; + sdl_wheel = 0; + /*if(su >= PT_NUM) { + if(sl < PT_NUM) + su = sl; + if(sr < PT_NUM) + su = sr; + }*/ + } } - else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + + bq = b; + b = SDL_GetMouseState(&x, &y); + + for (i=0; i=sdl_scale*(XRES-2) && x= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y1180) - bsx = 1180; - if(bsx<0) - bsx = 0; - if(bsy>1180) - bsy = 1180; - if(bsy<0) - bsy = 0; - sdl_wheel = 0; - /*if(su >= PT_NUM) { - if(sl < PT_NUM) - su = sl; - if(sr < PT_NUM) - su = sr; - }*/ - } - } + menu_ui_v3(vid_buf, active_menu, &sl, &sr, b, bq, x, y); - bq = b; - b = SDL_GetMouseState(&x, &y); - - for(i=0; i=sdl_scale*(XRES-2) && x= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy - && x0 && y0 && x>8)>=NPART || !cr)) - { + if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy + && x0 && y0 && x>8)>=NPART || !cr)) + { #ifdef BETA - if(DEBUG_MODE) - { - int tctype = parts[cr>>8].ctype; - if(tctype>=PT_NUM) - tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + if (DEBUG_MODE) + { + int tctype = parts[cr>>8].ctype; + if (tctype>=PT_NUM) + tctype = 0; + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + } else + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); #else - if(DEBUG_MODE) - { - int tctype = parts[cr>>8].ctype; - if(tctype>=PT_NUM) - tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d,tmp: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life,parts[cr>>8].tmp); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else { - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); - } + if (DEBUG_MODE) + { + int tctype = parts[cr>>8].ctype; + if (tctype>=PT_NUM) + tctype = 0; + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + } else { + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); + } #endif - } - else - { - sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); - } - } - mx = x; - my = y; - if(update_flag) - { - info_box(vid_buf, "Finalizing update..."); - if(last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION)) - { - update_cleanup(); - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); - } - else - { - if(update_finish()) - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); - else - info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!"); - } - update_flag = 0; - } + } + else + { + sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); + } + } + mx = x; + my = y; + if (update_flag) + { + info_box(vid_buf, "Finalizing update..."); + if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION)) + { + update_cleanup(); + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + } + else + { + if (update_finish()) + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + else + info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!"); + } + update_flag = 0; + } - if(b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale && - x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version) - { - tmp = malloc(64); + if (b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale && + x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version) + { + tmp = malloc(64); #ifdef BETA - if(is_beta) - { - sprintf(tmp, "Your version: %d (Beta %d), new version: %d (Beta %d).", SAVE_VERSION, MINOR_VERSION, major, minor); - } - else - { - sprintf(tmp, "Your version: %d (Beta %d), new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); - } + if (is_beta) + { + sprintf(tmp, "Your version: %d (Beta %d), new version: %d (Beta %d).", SAVE_VERSION, MINOR_VERSION, major, minor); + } + else + { + sprintf(tmp, "Your version: %d (Beta %d), new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); + } #else - sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); + sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); #endif - if(confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update")) - { - free(tmp); - tmp = download_ui(vid_buf, my_uri, &i); - if(tmp) - { - save_presets(1); - if(update_start(tmp, i)) - { - update_cleanup(); - save_presets(0); - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); - } - else - return 0; - } - } - else - free(tmp); - } - if(y>=sdl_scale*(YRES+(MENUSIZE-20))) - { - if(x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0) - { - db = svf_own ? 275 : 272; - if(da < 51) - da ++; - } - else if(x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0) - { - db = svf_own ? 275 : 272; - if(da < 51) - da ++; - } - else if(x>=189 && x<=217 && svf_login && svf_open && svf_myvote!=0) - { - db = (svf_myvote==1) ? 273 : 274; - if(da < 51) - da ++; - } - else if(x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open) - { - db = svf_own ? 257 : 256; - if(da < 51) - da ++; - } - else if(x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale)) - { - db = 270; - if(da < 51) - da ++; - } - else if(x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale)) - { - db = 266; - if(da < 51) - da ++; - } - else if(x>=37*sdl_scale && x<=187*sdl_scale && svf_login) - { - db = 259; - if(svf_open && svf_own && x<=55*sdl_scale) - db = 258; - if(da < 51) - da ++; - } - else if(x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale)) - { - db = svf_login ? 261 : 260; - if(svf_admin) - { - db = 268; - } - else if(svf_mod) - { - db = 271; - } - if(da < 51) - da ++; - } - else if(x>=sdl_scale && x<=17*sdl_scale) - { - db = 262; - if(da < 51) - da ++; - } - else if(x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale)) - { - db = sys_pause ? 264 : 263; - if(da < 51) - da ++; - } - else if(x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale)) - { - db = 267; - if(da < 51) - da ++; - } - else if(x>=19*sdl_scale && x<=35*sdl_scale && svf_open) - { - db = 265; - if(da < 51) - da ++; - } - else if(da > 0) - da --; - } - else if(da > 0) - da --; - - if(!sdl_zoom_trig && zoom_en==1) - zoom_en = 0; - - if(sdl_key==Z_keysym && zoom_en==2) - zoom_en = 1; - - if(load_mode) - { - load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL); - load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL); - if(load_x+load_w>XRES) load_x=XRES-load_w; - if(load_y+load_h>YRES) load_y=YRES-load_h; - if(load_x<0) load_x=0; - if(load_y<0) load_y=0; - if(bq==1 && !b) - { - parse_save(load_data, load_size, 0, load_x, load_y); - free(load_data); - free(load_img); - load_mode = 0; - } - else if(bq==4 && !b) - { - free(load_data); - free(load_img); - load_mode = 0; - } - } - else if(save_mode==1) - { - save_x = (mx/sdl_scale)/CELL; - save_y = (my/sdl_scale)/CELL; - if(save_x >= XRES/CELL) save_x = XRES/CELL-1; - if(save_y >= YRES/CELL) save_y = YRES/CELL-1; - save_w = 1; - save_h = 1; - if(b==1) - { - save_mode = 2; - } - else if(b==4) - { - save_mode = 0; - copy_mode = 0; - } - } - else if(save_mode==2) - { - save_w = (mx/sdl_scale+CELL/2)/CELL - save_x; - save_h = (my/sdl_scale+CELL/2)/CELL - save_y; - if(save_w>XRES/CELL) save_w = XRES/CELL; - if(save_h>YRES/CELL) save_h = YRES/CELL; - if(save_w<1) save_w = 1; - if(save_h<1) save_h = 1; - if(!b) - { - if(copy_mode==1) - { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - clipboard_ready = 1; - save_mode = 0; - copy_mode = 0; - } - else if(copy_mode==2) - { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - clipboard_ready = 1; - save_mode = 0; - copy_mode = 0; - clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - } - else if(copy_mode==3)//rotation - { - if(save_h>save_w) - save_w = save_h; - rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now - save_mode = 0; - copy_mode = 0; + if (confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update")) + { + free(tmp); + tmp = download_ui(vid_buf, my_uri, &i); + if (tmp) + { + save_presets(1); + if (update_start(tmp, i)) + { + update_cleanup(); + save_presets(0); + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + } + else + return 0; + } + } + else + free(tmp); } - else if(copy_mode==4)//invertion - { - if(save_h>save_w) - save_w = save_h; - rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now - save_mode = 0; - copy_mode = 0; + if (y>=sdl_scale*(YRES+(MENUSIZE-20))) + { + if (x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0) + { + db = svf_own ? 275 : 272; + if (da < 51) + da ++; + } + else if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0) + { + db = svf_own ? 275 : 272; + if (da < 51) + da ++; + } + else if (x>=189 && x<=217 && svf_login && svf_open && svf_myvote!=0) + { + db = (svf_myvote==1) ? 273 : 274; + if (da < 51) + da ++; + } + else if (x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open) + { + db = svf_own ? 257 : 256; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale)) + { + db = 270; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale)) + { + db = 266; + if (da < 51) + da ++; + } + else if (x>=37*sdl_scale && x<=187*sdl_scale && svf_login) + { + db = 259; + if (svf_open && svf_own && x<=55*sdl_scale) + db = 258; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale)) + { + db = svf_login ? 261 : 260; + if (svf_admin) + { + db = 268; + } + else if (svf_mod) + { + db = 271; + } + if (da < 51) + da ++; + } + else if (x>=sdl_scale && x<=17*sdl_scale) + { + db = 262; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale)) + { + db = sys_pause ? 264 : 263; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale)) + { + db = 267; + if (da < 51) + da ++; + } + else if (x>=19*sdl_scale && x<=35*sdl_scale && svf_open) + { + db = 265; + if (da < 51) + da ++; + } + else if (da > 0) + da --; } - else - { - stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - save_mode = 0; - } - } - } - else if(sdl_zoom_trig && zoom_en<2) - { - x /= sdl_scale; - y /= sdl_scale; - x -= ZSIZE/2; - y -= ZSIZE/2; - if(x<0) x=0; - if(y<0) y=0; - if(x>XRES-ZSIZE) x=XRES-ZSIZE; - if(y>YRES-ZSIZE) y=YRES-ZSIZE; - zoom_x = x; - zoom_y = y; - zoom_wx = (x 50) - it = 50; - x /= sdl_scale; - y /= sdl_scale; - if(y>=YRES+(MENUSIZE-20)) - { - if(!lb) - { - if(x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0 && svf_own==0) - { - if(execute_vote(vid_buf, svf_id, "Up")) - { - svf_myvote = 1; - } - } - if(x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0 && svf_own==0) - { - if(execute_vote(vid_buf, svf_id, "Down")) - { - svf_myvote = -1; - } - } - if(x>=219 && x<=(XRES+BARSIZE-(510-349)) && svf_login && svf_open) - tag_list_ui(vid_buf); - if(x>=(XRES+BARSIZE-(510-351)) && x<(XRES+BARSIZE-(510-366)) && !bq) - { - legacy_enable = !legacy_enable; - } - if(x>=(XRES+BARSIZE-(510-367)) && x<=(XRES+BARSIZE-(510-383)) && !bq) - { - memset(signs, 0, sizeof(signs)); - memset(pv, 0, sizeof(pv)); - memset(vx, 0, sizeof(vx)); - memset(vy, 0, sizeof(vy)); - memset(fvx, 0, sizeof(fvx)); - memset(fvy, 0, sizeof(fvy)); - memset(bmap, 0, sizeof(bmap)); - memset(emap, 0, sizeof(emap)); - memset(parts, 0, sizeof(particle)*NPART); - memset(photons, 0, sizeof(photons)); - memset(wireless, 0, sizeof(wireless)); - memset(gol2, 0, sizeof(gol2)); - memset(portal, 0, sizeof(portal)); - for(i=0; i 0) + da --; - legacy_enable = 0; - svf_myvote = 0; - svf_open = 0; - svf_publish = 0; - svf_own = 0; - svf_id[0] = 0; - svf_name[0] = 0; - svf_tags[0] = 0; + if (!sdl_zoom_trig && zoom_en==1) + zoom_en = 0; + + if (sdl_key==Z_keysym && zoom_en==2) + zoom_en = 1; + + if (load_mode) + { + load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL); + load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL); + if (load_x+load_w>XRES) load_x=XRES-load_w; + if (load_y+load_h>YRES) load_y=YRES-load_h; + if (load_x<0) load_x=0; + if (load_y<0) load_y=0; + if (bq==1 && !b) + { + parse_save(load_data, load_size, 0, load_x, load_y); + free(load_data); + free(load_img); + load_mode = 0; + } + else if (bq==4 && !b) + { + free(load_data); + free(load_img); + load_mode = 0; + } + } + else if (save_mode==1) + { + save_x = (mx/sdl_scale)/CELL; + save_y = (my/sdl_scale)/CELL; + if (save_x >= XRES/CELL) save_x = XRES/CELL-1; + if (save_y >= YRES/CELL) save_y = YRES/CELL-1; + save_w = 1; + save_h = 1; + if (b==1) + { + save_mode = 2; + } + else if (b==4) + { + save_mode = 0; + copy_mode = 0; + } + } + else if (save_mode==2) + { + save_w = (mx/sdl_scale+CELL/2)/CELL - save_x; + save_h = (my/sdl_scale+CELL/2)/CELL - save_y; + if (save_w>XRES/CELL) save_w = XRES/CELL; + if (save_h>YRES/CELL) save_h = YRES/CELL; + if (save_w<1) save_w = 1; + if (save_h<1) save_h = 1; + if (!b) + { + if (copy_mode==1) + { + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + clipboard_ready = 1; + save_mode = 0; + copy_mode = 0; + } + else if (copy_mode==2) + { + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + clipboard_ready = 1; + save_mode = 0; + copy_mode = 0; + clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + } + else if (copy_mode==3)//rotation + { + if (save_h>save_w) + save_w = save_h; + rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,0);//just do squares for now + save_mode = 0; + copy_mode = 0; + } + else if (copy_mode==4)//invertion + { + if (save_h>save_w) + save_w = save_h; + rotate_area(save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL,1);//just do squares for now + save_mode = 0; + copy_mode = 0; + } + else + { + stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + save_mode = 0; + } + } + } + else if (sdl_zoom_trig && zoom_en<2) + { + x /= sdl_scale; + y /= sdl_scale; + x -= ZSIZE/2; + y -= ZSIZE/2; + if (x<0) x=0; + if (y<0) y=0; + if (x>XRES-ZSIZE) x=XRES-ZSIZE; + if (y>YRES-ZSIZE) y=YRES-ZSIZE; + zoom_x = x; + zoom_y = y; + zoom_wx = (x 50) + it = 50; + x /= sdl_scale; + y /= sdl_scale; + if (y>=YRES+(MENUSIZE-20)) + { + if (!lb) + { + if (x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + { + if (execute_vote(vid_buf, svf_id, "Up")) + { + svf_myvote = 1; + } + } + if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + { + if (execute_vote(vid_buf, svf_id, "Down")) + { + svf_myvote = -1; + } + } + if (x>=219 && x<=(XRES+BARSIZE-(510-349)) && svf_login && svf_open) + tag_list_ui(vid_buf); + if (x>=(XRES+BARSIZE-(510-351)) && x<(XRES+BARSIZE-(510-366)) && !bq) + { + legacy_enable = !legacy_enable; + } + if (x>=(XRES+BARSIZE-(510-367)) && x<=(XRES+BARSIZE-(510-383)) && !bq) + { + memset(signs, 0, sizeof(signs)); + memset(pv, 0, sizeof(pv)); + memset(vx, 0, sizeof(vx)); + memset(vy, 0, sizeof(vy)); + memset(fvx, 0, sizeof(fvx)); + memset(fvy, 0, sizeof(fvy)); + memset(bmap, 0, sizeof(bmap)); + memset(emap, 0, sizeof(emap)); + memset(parts, 0, sizeof(particle)*NPART); + + memset(photons, 0, sizeof(photons)); + memset(wireless, 0, sizeof(wireless)); + memset(gol2, 0, sizeof(gol2)); + memset(portal, 0, sizeof(portal)); + for (i=0; i=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) - { - login_ui(vid_buf); - if(svf_login) - save_presets(0); - } - if(x>=37 && x<=187 && svf_login) - { - if(!svf_open || !svf_own || x>51) - { - if(save_name_ui(vid_buf)) - execute_save(vid_buf); - } - else - execute_save(vid_buf); - while(!sdl_poll()) - if(!SDL_GetMouseState(&x, &y)) - break; - b = bq = 0; - } - if(x>=1 && x<=17) - { - search_ui(vid_buf); - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - } - if(x>=19 && x<=35 && svf_last && svf_open && !bq){ + memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + } + if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) + { + login_ui(vid_buf); + if (svf_login) + save_presets(0); + } + if (x>=37 && x<=187 && svf_login) + { + if (!svf_open || !svf_own || x>51) + { + if (save_name_ui(vid_buf)) + execute_save(vid_buf); + } + else + execute_save(vid_buf); + while (!sdl_poll()) + if (!SDL_GetMouseState(&x, &y)) + break; + b = bq = 0; + } + if (x>=1 && x<=17) + { + search_ui(vid_buf); + memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + } + if (x>=19 && x<=35 && svf_last && svf_open && !bq) { //int tpval = sys_pause; parse_save(svf_last, svf_lsize, 1, 0, 0); + for (j= 0; j<99; j++) { //reset wifi on reload + wireless[j][0] = 0; + wireless[j][1] = 0; + } //sys_pause = tpval; } - if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) - { - if(b & SDL_BUTTON_LMASK){ - set_cmode((cmode+1) % CM_COUNT); + if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) + { + if (b & SDL_BUTTON_LMASK) { + set_cmode((cmode+1) % CM_COUNT); } - if(b & SDL_BUTTON_RMASK){ - if((cmode+(CM_COUNT-1)) % CM_COUNT == CM_LIFE) { + if (b & SDL_BUTTON_RMASK) { + if ((cmode+(CM_COUNT-1)) % CM_COUNT == CM_LIFE) { set_cmode(CM_GRAD); } else { set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); } } - save_presets(0); - } - if(x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) - sys_pause = !sys_pause; - lb = 0; - } - } - else if(y=0 && ly>=0 && lx0 && y0 && x>8)>=NPART || !cr)) - { - c = sl = cr&0xFF; - } - else - { - //Something - } - } - lx = x; - ly = y; - lb = 0; - lm = 0; - } - else - { - //Copy state before drawing any particles (for undo)7 - int cbx, cby, cbi; + save_presets(0); + } + if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) + sys_pause = !sys_pause; + lb = 0; + } + } + else if (y=0 && ly>=0 && lx0 && y0 && x>8)>=NPART || !cr)) + { + c = sl = cr&0xFF; + } + else + { + //Something + } + } + lx = x; + ly = y; + lb = 0; + lm = 0; + } + else + { + //Copy state before drawing any particles (for undo)7 + int cbx, cby, cbi; - for(cbi=0; cbi=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN) - create_line(lx, ly, x, y, bsx, bsy, c); - } - else - create_box(lx, ly, x, y, c); - lm = 0; - } - lb = 0; - } + create_parts(x, y, bsx, bsy, c); + lx = x; + ly = y; + lb = b; + lm = 0; + } + } + } + } + else + { + if (lb && lm) + { + x /= sdl_scale; + y /= sdl_scale; + c = (lb&1) ? sl : sr; + su = c; + if (lm == 1) + { + if (c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN) + create_line(lx, ly, x, y, bsx, bsy, c); + } + else + create_box(lx, ly, x, y, c); + lm = 0; + } + lb = 0; + } - if(load_mode) - { - draw_image(vid_buf, load_img, load_x, load_y, load_w, load_h, 128); - xor_rect(vid_buf, load_x, load_y, load_w, load_h); - } + if (load_mode) + { + draw_image(vid_buf, load_img, load_x, load_y, load_w, load_h, 128); + xor_rect(vid_buf, load_x, load_y, load_w, load_h); + } - if(save_mode) - { - if(copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles - { - if(save_h>save_w) - save_w = save_h; - xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL); - } - else - xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - da = 51; - db = 269; - } + if (save_mode) + { + if (copy_mode==3||copy_mode==4)//special drawing for rotate, can remove once it can do rectangles + { + if (save_h>save_w) + save_w = save_h; + xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_w*CELL); + } + else + xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + da = 51; + db = 269; + } - if(zoom_en!=1 && !load_mode && !save_mode) - { - render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy); - mousex = mx/sdl_scale; - mousey = my/sdl_scale; - } + if (zoom_en!=1 && !load_mode && !save_mode) + { + render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy); + mousex = mx/sdl_scale; + mousey = my/sdl_scale; + } - if(zoom_en) - render_zoom(vid_buf); + if (zoom_en) + render_zoom(vid_buf); - if(da) - switch(db) - { - case 256: - drawtext(vid_buf, 16, YRES-24, "Add simulation tags.", 255, 255, 255, da*5); - break; - case 257: - drawtext(vid_buf, 16, YRES-24, "Add and remove simulation tags.", 255, 255, 255, da*5); - break; - case 258: - drawtext(vid_buf, 16, YRES-24, "Save the simulation under the current name.", 255, 255, 255, da*5); - break; - case 259: - drawtext(vid_buf, 16, YRES-24, "Save the simulation under a new name.", 255, 255, 255, da*5); - break; - case 260: - drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server.", 255, 255, 255, da*5); - break; - case 261: - drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server under a new name.", 255, 255, 255, da*5); - break; - case 262: - drawtext(vid_buf, 16, YRES-24, "Find & open a simulation", 255, 255, 255, da*5); - break; - case 263: - drawtext(vid_buf, 16, YRES-24, "Pause the simulation", 255, 255, 255, da*5); - break; - case 264: - drawtext(vid_buf, 16, YRES-24, "Resume the simulation", 255, 255, 255, da*5); - break; - case 265: - drawtext(vid_buf, 16, YRES-24, "Reload the simulation", 255, 255, 255, da*5); - break; - case 266: - drawtext(vid_buf, 16, YRES-24, "Erase all particles and walls", 255, 255, 255, da*5); - break; - case 267: - drawtext(vid_buf, 16, YRES-24, "Change display mode", 255, 255, 255, da*5); - break; - case 268: - drawtext(vid_buf, 16, YRES-24, "Annuit C\245ptis", 255, 255, 255, da*5); - break; - case 269: - drawtext(vid_buf, 16, YRES-24, "Click-and-drag to specify a rectangle to copy (right click = cancel).", 255, 216, 32, da*5); - break; - case 270: - drawtext(vid_buf, 16, YRES-24, "Enable or disable compatability mode (disables heat simulation).", 255, 255, 255, da*5); - break; - case 271: - drawtext(vid_buf, 16, YRES-24, "You're a moderator", 255, 255, 255, da*5); - break; - case 272: - drawtext(vid_buf, 16, YRES-24, "Like/Dislike this save.", 255, 255, 255, da*5); - break; - case 273: - drawtext(vid_buf, 16, YRES-24, "You like this.", 255, 255, 255, da*5); - break; - case 274: - drawtext(vid_buf, 16, YRES-24, "You dislike this.", 255, 255, 255, da*5); - break; - case 275: - drawtext(vid_buf, 16, YRES-24, "You cannot vote on your own save.", 255, 255, 255, da*5); - break; - default: - drawtext(vid_buf, 16, YRES-24, (char *)ptypes[db].descs, 255, 255, 255, da*5); - } - if(itc) - { - itc--; - drawtext(vid_buf, (XRES-textwidth(itc_msg))/2, ((YRES/2)-10), itc_msg, 255, 255, 255, itc>51?255:itc*5); - } - if(it) - { - it--; - drawtext(vid_buf, 16, 20, it_msg, 255, 255, 255, it>51?255:it*5); - } + if (da) + switch (db) + { + case 256: + drawtext(vid_buf, 16, YRES-24, "Add simulation tags.", 255, 255, 255, da*5); + break; + case 257: + drawtext(vid_buf, 16, YRES-24, "Add and remove simulation tags.", 255, 255, 255, da*5); + break; + case 258: + drawtext(vid_buf, 16, YRES-24, "Save the simulation under the current name.", 255, 255, 255, da*5); + break; + case 259: + drawtext(vid_buf, 16, YRES-24, "Save the simulation under a new name.", 255, 255, 255, da*5); + break; + case 260: + drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server.", 255, 255, 255, da*5); + break; + case 261: + drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server under a new name.", 255, 255, 255, da*5); + break; + case 262: + drawtext(vid_buf, 16, YRES-24, "Find & open a simulation", 255, 255, 255, da*5); + break; + case 263: + drawtext(vid_buf, 16, YRES-24, "Pause the simulation", 255, 255, 255, da*5); + break; + case 264: + drawtext(vid_buf, 16, YRES-24, "Resume the simulation", 255, 255, 255, da*5); + break; + case 265: + drawtext(vid_buf, 16, YRES-24, "Reload the simulation", 255, 255, 255, da*5); + break; + case 266: + drawtext(vid_buf, 16, YRES-24, "Erase all particles and walls", 255, 255, 255, da*5); + break; + case 267: + drawtext(vid_buf, 16, YRES-24, "Change display mode", 255, 255, 255, da*5); + break; + case 268: + drawtext(vid_buf, 16, YRES-24, "Annuit C\245ptis", 255, 255, 255, da*5); + break; + case 269: + drawtext(vid_buf, 16, YRES-24, "Click-and-drag to specify a rectangle to copy (right click = cancel).", 255, 216, 32, da*5); + break; + case 270: + drawtext(vid_buf, 16, YRES-24, "Enable or disable compatibility mode (disables heat simulation).", 255, 255, 255, da*5); + break; + case 271: + drawtext(vid_buf, 16, YRES-24, "You're a moderator", 255, 255, 255, da*5); + break; + case 272: + drawtext(vid_buf, 16, YRES-24, "Like/Dislike this save.", 255, 255, 255, da*5); + break; + case 273: + drawtext(vid_buf, 16, YRES-24, "You like this.", 255, 255, 255, da*5); + break; + case 274: + drawtext(vid_buf, 16, YRES-24, "You dislike this.", 255, 255, 255, da*5); + break; + case 275: + drawtext(vid_buf, 16, YRES-24, "You cannot vote on your own save.", 255, 255, 255, da*5); + break; + default: + drawtext(vid_buf, 16, YRES-24, (char *)ptypes[db].descs, 255, 255, 255, da*5); + } + if (itc) + { + itc--; + drawtext(vid_buf, (XRES-textwidth(itc_msg))/2, ((YRES/2)-10), itc_msg, 255, 255, 255, itc>51?255:itc*5); + } + if (it) + { + it--; + drawtext(vid_buf, 16, 20, it_msg, 255, 255, 255, it>51?255:it*5); + } - if(old_version) - { - clearrect(vid_buf, XRES-21-old_ver_len, YRES-24, old_ver_len+9, 17); + if (old_version) + { + clearrect(vid_buf, XRES-21-old_ver_len, YRES-24, old_ver_len+9, 17); #ifdef BETA - if(is_beta) - { - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg_beta, 255, 216, 32, 255); - } - else - { - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); - } + if (is_beta) + { + drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg_beta, 255, 216, 32, 255); + } + else + { + drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); + } #else - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); + drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); #endif - drawrect(vid_buf, XRES-19-old_ver_len, YRES-22, old_ver_len+5, 13, 255, 216, 32, 255); - } + drawrect(vid_buf, XRES-19-old_ver_len, YRES-22, old_ver_len+5, 13, 255, 216, 32, 255); + } + + if (hud_enable) + { + currentTime = SDL_GetTicks(); + if (currentTime-past>=16) + { + past = SDL_GetTicks(); + FPS++; + } + if (currentTime-pastFPS>=1000) + { + FPSB = FPS; + FPS = 0; + pastFPS = currentTime; + } - if(hud_enable) - { - currentTime = SDL_GetTicks(); - if(currentTime-past>=16) - { - past = SDL_GetTicks(); - FPS++; - } - if(currentTime-pastFPS>=1000) - { - FPSB = FPS; - FPS = 0; - pastFPS = currentTime; - } - #ifdef BETA sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); #else - if(DEBUG_MODE) + if (DEBUG_MODE) sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); else sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); #endif - if(REPLACE_MODE) + if (REPLACE_MODE) strappend(uitext, " [REPLACE MODE]"); - if(sdl_mod&(KMOD_CAPS)) + if (sdl_mod&(KMOD_CAPS)) strappend(uitext, " [CAP LOCKS]"); - if(GRID_MODE) + if (GRID_MODE) sprintf(uitext, "%s [GRID: %d]", uitext, GRID_MODE); #ifdef INTERNAL - if(vs) + if (vs) strappend(uitext, " [FRAME CAPTURE]"); #endif - - if(sdl_zoom_trig||zoom_en) - { - if(zoom_x0 || sr == PT_NEUT || sr == PT_PHOT) - player[2] = sr; - else - player[2] = PT_DUST; - } - if(isplayer2==0) - { - if(ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT) - player2[2] = sr; - else - player2[2] = PT_DUST; - } + if (sdl_zoom_trig||zoom_en) + { + if (zoom_x0 || sr == PT_NEUT || sr == PT_PHOT) + player[2] = sr; + else + player[2] = PT_DUST; + } + if (isplayer2==0) + { + if (ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT) + player2[2] = sr; + else + player2[2] = PT_DUST; + } - http_done(); - return 0; + } + + http_done(); + return 0; } diff --git a/src/md5.c b/src/md5.c index a51f4fea4..1bad12ba1 100644 --- a/src/md5.c +++ b/src/md5.c @@ -4,112 +4,112 @@ static unsigned getu32(const unsigned char *addr) { - return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0]; + return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0]; } static void putu32(unsigned data, unsigned char *addr) { - addr[0] = (unsigned char)data; - addr[1] = (unsigned char)(data >> 8); - addr[2] = (unsigned char)(data >> 16); - addr[3] = (unsigned char)(data >> 24); + addr[0] = (unsigned char)data; + addr[1] = (unsigned char)(data >> 8); + addr[2] = (unsigned char)(data >> 16); + addr[3] = (unsigned char)(data >> 24); } void md5_init(struct md5_context *ctx) { - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - ctx->bits[0] = 0; - ctx->bits[1] = 0; + ctx->bits[0] = 0; + ctx->bits[1] = 0; } void md5_update(struct md5_context *ctx, unsigned char const *buf, unsigned len) { - unsigned t; + unsigned t; - // update bit count - t = ctx->bits[0]; - if((ctx->bits[0] = (t + ((unsigned)len << 3)) & 0xffffffff) < t) - ctx->bits[1]++; // carry - ctx->bits[1] += len >> 29; + // update bit count + t = ctx->bits[0]; + if ((ctx->bits[0] = (t + ((unsigned)len << 3)) & 0xffffffff) < t) + ctx->bits[1]++; // carry + ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; + t = (t >> 3) & 0x3f; - // use leading data to top up the buffer + // use leading data to top up the buffer - if(t) - { - unsigned char *p = ctx->in + t; + if (t) + { + unsigned char *p = ctx->in + t; - t = 64-t; - if (len < t) - { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - md5_transform(ctx->buf, ctx->in); - buf += t; - len -= t; - } + t = 64-t; + if (len < t) + { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + md5_transform(ctx->buf, ctx->in); + buf += t; + len -= t; + } - // following 64-byte chunks + // following 64-byte chunks - while(len >= 64) - { - memcpy(ctx->in, buf, 64); - md5_transform(ctx->buf, ctx->in); - buf += 64; - len -= 64; - } + while (len >= 64) + { + memcpy(ctx->in, buf, 64); + md5_transform(ctx->buf, ctx->in); + buf += 64; + len -= 64; + } - // save rest of bytes for later + // save rest of bytes for later - memcpy(ctx->in, buf, len); + memcpy(ctx->in, buf, len); } void md5_final(unsigned char digest[16], struct md5_context *ctx) { - unsigned count; - unsigned char *p; + unsigned count; + unsigned char *p; - // #bytes mod64 - count = (ctx->bits[0] >> 3) & 0x3F; + // #bytes mod64 + count = (ctx->bits[0] >> 3) & 0x3F; - // first char of padding = 0x80 - p = ctx->in + count; - *p++ = 0x80; + // first char of padding = 0x80 + p = ctx->in + count; + *p++ = 0x80; - // calculate # of bytes to pad - count = 64 - 1 - count; + // calculate # of bytes to pad + count = 64 - 1 - count; - // Pad out to 56 mod 64 - if(count < 8) - { - // we need to finish a whole block before padding - memset(p, 0, count); - md5_transform(ctx->buf, ctx->in); - memset(ctx->in, 0, 56); - } - else - { - // just pad to 56 bytes - memset(p, 0, count-8); - } + // Pad out to 56 mod 64 + if (count < 8) + { + // we need to finish a whole block before padding + memset(p, 0, count); + md5_transform(ctx->buf, ctx->in); + memset(ctx->in, 0, 56); + } + else + { + // just pad to 56 bytes + memset(p, 0, count-8); + } - // append length & final transform - putu32(ctx->bits[0], ctx->in + 56); - putu32(ctx->bits[1], ctx->in + 60); + // append length & final transform + putu32(ctx->bits[0], ctx->in + 56); + putu32(ctx->bits[1], ctx->in + 60); - md5_transform(ctx->buf, ctx->in); - putu32(ctx->buf[0], digest); - putu32(ctx->buf[1], digest + 4); - putu32(ctx->buf[2], digest + 8); - putu32(ctx->buf[3], digest + 12); - memset(ctx, 0, sizeof(ctx)); + md5_transform(ctx->buf, ctx->in); + putu32(ctx->buf[0], digest); + putu32(ctx->buf[1], digest + 4); + putu32(ctx->buf[2], digest + 8); + putu32(ctx->buf[3], digest + 12); + memset(ctx, 0, sizeof(ctx)); } #define F1(x, y, z) (z ^ (x & (y ^ z))) @@ -122,110 +122,110 @@ void md5_final(unsigned char digest[16], struct md5_context *ctx) void md5_transform(unsigned buf[4], const unsigned char inraw[64]) { - unsigned a, b, c, d; - unsigned in[16]; - int i; + unsigned a, b, c, d; + unsigned in[16]; + int i; - for (i = 0; i < 16; ++i) - in[i] = getu32 (inraw + 4 * i); + for (i = 0; i < 16; ++i) + in[i] = getu32 (inraw + 4 * i); - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; - MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); + MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); - MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); + MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); - MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); + MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); - MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); + MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } static char hex[] = "0123456789abcdef"; void md5_ascii(char *result, unsigned char const *buf, unsigned len) { - struct md5_context md5; - unsigned char hash[16]; - int i; + struct md5_context md5; + unsigned char hash[16]; + int i; - if(len==0) - len = strlen((char *)buf); + if (len==0) + len = strlen((char *)buf); - md5_init(&md5); - md5_update(&md5, buf, len); - md5_final(hash, &md5); + md5_init(&md5); + md5_update(&md5, buf, len); + md5_final(hash, &md5); - for(i=0; i<16; i++) - { - result[i*2] = hex[(hash[i]>>4)&0xF]; - result[i*2+1] = hex[hash[i]&0x0F]; - } - result[32] = 0; + for (i=0; i<16; i++) + { + result[i*2] = hex[(hash[i]>>4)&0xF]; + result[i*2+1] = hex[hash[i]&0x0F]; + } + result[32] = 0; } diff --git a/src/misc.c b/src/misc.c index 87615cd51..64c2af51f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -13,11 +13,11 @@ _inline int isign(float i) inline int isign(float i) #endif { - if (i<0) - return -1; - if (i>0) - return 1; - return 0; + if (i<0) + return -1; + if (i>0) + return 1; + return 0; } #if defined(WIN32) && !defined(__GNUC__) @@ -26,11 +26,11 @@ _inline unsigned clamp_flt(float f, float min, float max) inline unsigned clamp_flt(float f, float min, float max) #endif { - if(fmax) - return 255; - return (int)(255.0f*(f-min)/(max-min)); + if (fmax) + return 255; + return (int)(255.0f*(f-min)/(max-min)); } #if defined(WIN32) && !defined(__GNUC__) @@ -39,245 +39,245 @@ _inline float restrict_flt(float f, float min, float max) inline float restrict_flt(float f, float min, float max) #endif { - if(fmax) - return max; - return f; + if (fmax) + return max; + return f; } char *mystrdup(char *s) { - char *x; - if(s) - { - x = (char*)malloc(strlen(s)+1); - strcpy(x, s); - return x; - } - return s; + char *x; + if (s) + { + x = (char*)malloc(strlen(s)+1); + strcpy(x, s); + return x; + } + return s; } void strlist_add(struct strlist **list, char *str) { - struct strlist *item = malloc(sizeof(struct strlist)); - item->str = mystrdup(str); - item->next = *list; - *list = item; + struct strlist *item = malloc(sizeof(struct strlist)); + item->str = mystrdup(str); + item->next = *list; + *list = item; } int strlist_find(struct strlist **list, char *str) { - struct strlist *item; - for(item=*list; item; item=item->next) - if(!strcmp(item->str, str)) - return 1; - return 0; + struct strlist *item; + for (item=*list; item; item=item->next) + if (!strcmp(item->str, str)) + return 1; + return 0; } void strlist_free(struct strlist **list) { - struct strlist *item; - while(*list) - { - item = *list; - *list = (*list)->next; - free(item); - } + struct strlist *item; + while (*list) + { + item = *list; + *list = (*list)->next; + free(item); + } } void save_presets(int do_update) { - FILE *f=fopen("powder.def", "wb"); - unsigned char sig[4] = {0x50, 0x44, 0x65, 0x66}; - unsigned char tmp = sdl_scale; - if(!f) - return; - fwrite(sig, 1, 4, f); - save_string(f, svf_user); - save_string(f, svf_pass); - fwrite(&tmp, 1, 1, f); - tmp = cmode; - fwrite(&tmp, 1, 1, f); - tmp = svf_admin; - fwrite(&tmp, 1, 1, f); - tmp = svf_mod; - fwrite(&tmp, 1, 1, f); - save_string(f, http_proxy_string); - tmp = SAVE_VERSION; - fwrite(&tmp, 1, 1, f); - tmp = MINOR_VERSION; - fwrite(&tmp, 1, 1, f); - tmp = do_update; - fwrite(&tmp, 1, 1, f); - fclose(f); + FILE *f=fopen("powder.def", "wb"); + unsigned char sig[4] = {0x50, 0x44, 0x65, 0x66}; + unsigned char tmp = sdl_scale; + if (!f) + return; + fwrite(sig, 1, 4, f); + save_string(f, svf_user); + save_string(f, svf_pass); + fwrite(&tmp, 1, 1, f); + tmp = cmode; + fwrite(&tmp, 1, 1, f); + tmp = svf_admin; + fwrite(&tmp, 1, 1, f); + tmp = svf_mod; + fwrite(&tmp, 1, 1, f); + save_string(f, http_proxy_string); + tmp = SAVE_VERSION; + fwrite(&tmp, 1, 1, f); + tmp = MINOR_VERSION; + fwrite(&tmp, 1, 1, f); + tmp = do_update; + fwrite(&tmp, 1, 1, f); + fclose(f); } void load_presets(void) { - FILE *f=fopen("powder.def", "rb"); - unsigned char sig[4], tmp; - if(!f) - return; - fread(sig, 1, 4, f); - if(sig[0]!=0x50 || sig[1]!=0x44 || sig[2]!=0x65 || sig[3]!=0x66) - { - if(sig[0]==0x4D && sig[1]==0x6F && sig[2]==0x46 && sig[3]==0x6F) - { - if(fseek(f, -3, SEEK_END)) - { - remove("powder.def"); - return; - } - if(fread(sig, 1, 3, f) != 3) - { - remove("powder.def"); - goto fail; - } - last_major = sig[0]; - last_minor = sig[1]; - update_flag = sig[2]; - } - fclose(f); - remove("powder.def"); - return; - } - if(load_string(f, svf_user, 63)) - goto fail; - if(load_string(f, svf_pass, 63)) - goto fail; - svf_login = !!svf_user[0]; - if(fread(&tmp, 1, 1, f) != 1) - goto fail; - sdl_scale = (tmp == 2) ? 2 : 1; - if(fread(&tmp, 1, 1, f) != 1) - goto fail; - cmode = tmp%7; - if(fread(&tmp, 1, 1, f) != 1) - goto fail; - svf_admin = tmp; - if(fread(&tmp, 1, 1, f) != 1) - goto fail; - svf_mod = tmp; - if(load_string(f, http_proxy_string, 255)) - goto fail; - if(fread(sig, 1, 3, f) != 3) - goto fail; - last_major = sig[0]; - last_minor = sig[1]; - update_flag = sig[2]; + FILE *f=fopen("powder.def", "rb"); + unsigned char sig[4], tmp; + if (!f) + return; + fread(sig, 1, 4, f); + if (sig[0]!=0x50 || sig[1]!=0x44 || sig[2]!=0x65 || sig[3]!=0x66) + { + if (sig[0]==0x4D && sig[1]==0x6F && sig[2]==0x46 && sig[3]==0x6F) + { + if (fseek(f, -3, SEEK_END)) + { + remove("powder.def"); + return; + } + if (fread(sig, 1, 3, f) != 3) + { + remove("powder.def"); + goto fail; + } + last_major = sig[0]; + last_minor = sig[1]; + update_flag = sig[2]; + } + fclose(f); + remove("powder.def"); + return; + } + if (load_string(f, svf_user, 63)) + goto fail; + if (load_string(f, svf_pass, 63)) + goto fail; + svf_login = !!svf_user[0]; + if (fread(&tmp, 1, 1, f) != 1) + goto fail; + sdl_scale = (tmp == 2) ? 2 : 1; + if (fread(&tmp, 1, 1, f) != 1) + goto fail; + cmode = tmp%7; + if (fread(&tmp, 1, 1, f) != 1) + goto fail; + svf_admin = tmp; + if (fread(&tmp, 1, 1, f) != 1) + goto fail; + svf_mod = tmp; + if (load_string(f, http_proxy_string, 255)) + goto fail; + if (fread(sig, 1, 3, f) != 3) + goto fail; + last_major = sig[0]; + last_minor = sig[1]; + update_flag = sig[2]; fail: - fclose(f); + fclose(f); } void save_string(FILE *f, char *str) { - int li = strlen(str); - unsigned char lb[2]; - lb[0] = li; - lb[1] = li >> 8; - fwrite(lb, 2, 1, f); - fwrite(str, li, 1, f); + int li = strlen(str); + unsigned char lb[2]; + lb[0] = li; + lb[1] = li >> 8; + fwrite(lb, 2, 1, f); + fwrite(str, li, 1, f); } int load_string(FILE *f, char *str, int max) { - int li; - unsigned char lb[2]; - fread(lb, 2, 1, f); - li = lb[0] | (lb[1] << 8); - if(li > max) - { - str[0] = 0; - return 1; - } - fread(str, li, 1, f); - str[li] = 0; - return 0; + int li; + unsigned char lb[2]; + fread(lb, 2, 1, f); + li = lb[0] | (lb[1] << 8); + if (li > max) + { + str[0] = 0; + return 1; + } + fread(str, li, 1, f); + str[li] = 0; + return 0; } void strcaturl(char *dst, char *src) { - char *d; - unsigned char *s; + char *d; + unsigned char *s; - for(d=dst; *d; d++) ; + for (d=dst; *d; d++) ; - for(s=(unsigned char *)src; *s; s++) - { - if((*s>='0' && *s<='9') || - (*s>='a' && *s<='z') || - (*s>='A' && *s<='Z')) - *(d++) = *s; - else - { - *(d++) = '%'; - *(d++) = hex[*s>>4]; - *(d++) = hex[*s&15]; - } - } - *d = 0; + for (s=(unsigned char *)src; *s; s++) + { + if ((*s>='0' && *s<='9') || + (*s>='a' && *s<='z') || + (*s>='A' && *s<='Z')) + *(d++) = *s; + else + { + *(d++) = '%'; + *(d++) = hex[*s>>4]; + *(d++) = hex[*s&15]; + } + } + *d = 0; } void strappend(char *dst, char *src) { - char *d; - unsigned char *s; + char *d; + unsigned char *s; - for(d=dst; *d; d++) ; + for (d=dst; *d; d++) ; - for(s=(unsigned char *)src; *s; s++) - { - *(d++) = *s; - } - *d = 0; + for (s=(unsigned char *)src; *s; s++) + { + *(d++) = *s; + } + *d = 0; } void *file_load(char *fn, int *size) { - FILE *f = fopen(fn, "rb"); - void *s; + FILE *f = fopen(fn, "rb"); + void *s; - if(!f) - return NULL; - fseek(f, 0, SEEK_END); - *size = ftell(f); - fseek(f, 0, SEEK_SET); - s = malloc(*size); - if(!s) - { - fclose(f); - return NULL; - } - fread(s, *size, 1, f); - fclose(f); - return s; + if (!f) + return NULL; + fseek(f, 0, SEEK_END); + *size = ftell(f); + fseek(f, 0, SEEK_SET); + s = malloc(*size); + if (!s) + { + fclose(f); + return NULL; + } + fread(s, *size, 1, f); + fclose(f); + return s; } int cpu_check(void) { #ifdef MACOSX - return 0; + return 0; #else #ifdef X86 - unsigned af,bf,cf,df; - x86_cpuid(0, af, bf, cf, df); - if(bf==0x68747541 && cf==0x444D4163 && df==0x69746E65) - amd = 1; - x86_cpuid(1, af, bf, cf, df); + unsigned af,bf,cf,df; + x86_cpuid(0, af, bf, cf, df); + if (bf==0x68747541 && cf==0x444D4163 && df==0x69746E65) + amd = 1; + x86_cpuid(1, af, bf, cf, df); #ifdef X86_SSE - if(!(df&(1<<25))) - return 1; + if (!(df&(1<<25))) + return 1; #endif #ifdef X86_SSE2 - if(!(df&(1<<26))) - return 1; + if (!(df&(1<<26))) + return 1; #endif #ifdef X86_SSE3 - if(!(cf&1)) - return 1; + if (!(cf&1)) + return 1; #endif #endif #endif - return 0; + return 0; } diff --git a/src/powder.c b/src/powder.c index 27b48faa0..d595a5ab6 100644 --- a/src/powder.c +++ b/src/powder.c @@ -28,32 +28,32 @@ unsigned photons[YRES][XRES]; static int pn_junction_sprk(int x, int y, int pt) { - unsigned r = pmap[y][x]; - if((r & 0xFF) != pt) - return 0; - r >>= 8; - if(parts[r].type != pt) - return 0; - if(parts[r].life != 0) - return 0; - - parts[r].ctype = pt; - parts[r].type = PT_SPRK; - parts[r].life = 4; - return 1; + unsigned r = pmap[y][x]; + if ((r & 0xFF) != pt) + return 0; + r >>= 8; + if (parts[r].type != pt) + return 0; + if (parts[r].life != 0) + return 0; + + parts[r].ctype = pt; + part_change_type(r,x,y,PT_SPRK); + parts[r].life = 4; + return 1; } static void photoelectric_effect(int nx, int ny) { - unsigned r = pmap[ny][nx]; + unsigned r = pmap[ny][nx]; - if((r&0xFF) == PT_PSCN) { - if((pmap[ny][nx-1] & 0xFF) == PT_NSCN || - (pmap[ny][nx+1] & 0xFF) == PT_NSCN || - (pmap[ny-1][nx] & 0xFF) == PT_NSCN || - (pmap[ny+1][nx] & 0xFF) == PT_NSCN) - pn_junction_sprk(nx, ny, PT_PSCN); - } + if ((r&0xFF) == PT_PSCN) { + if ((pmap[ny][nx-1] & 0xFF) == PT_NSCN || + (pmap[ny][nx+1] & 0xFF) == PT_NSCN || + (pmap[ny-1][nx] & 0xFF) == PT_NSCN || + (pmap[ny+1][nx] & 0xFF) == PT_NSCN) + pn_junction_sprk(nx, ny, PT_PSCN); + } } /* RETURN-value explenation @@ -61,374 +61,407 @@ static void photoelectric_effect(int nx, int ny) 0 = No move/Bounce 2 = Both particles occupy the same space. */ -static int eval_move(int pt, int nx, int ny, unsigned *rr) +int eval_move(int pt, int nx, int ny, unsigned *rr) { - unsigned r; + unsigned r; - if(nx<0 || ny<0 || nx>=XRES || ny>=YRES) - return 0; + if (nx<0 || ny<0 || nx>=XRES || ny>=YRES) + return 0; - r = pmap[ny][nx]; - if(r && (r>>8)>8].type; - if(rr) - *rr = r; + r = pmap[ny][nx]; + if (r && (r>>8)>8].type; + if (rr) + *rr = r; - if((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL) - return 1; + if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL) + return 1; - if(pt==PT_PHOT&&( - (r&0xFF)==PT_GLAS || (r&0xFF)==PT_PHOT || - (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || - (r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR || - (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || - (r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS || - (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS || - (r&0xFF)==PT_QRTZ || (r&0xFF)==PT_PQRT || - ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))) - return 2; + if (pt==PT_PHOT&&( + (r&0xFF)==PT_GLAS || (r&0xFF)==PT_PHOT || + (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || + (r&0xFF)==PT_GLOW || (r&0xFF)==PT_WATR || + (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || + (r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS || + (r&0xFF)==PT_FILT || (r&0xFF)==PT_INVIS || + (r&0xFF)==PT_QRTZ || (r&0xFF)==PT_PQRT || + ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))) + return 2; - if(pt==PT_STKM) //Stick man's head shouldn't collide - return 2; - if(pt==PT_STKM2) //Stick man's head shouldn't collide - return 2; - if((pt==PT_BIZR||pt==PT_BIZRG)&&(r&0xFF)==PT_FILT) - return 2; - if(bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE) - return 0; - if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID) - return 0; - if((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL]) - return 0; - if(bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL]) - return 2; - if(bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR) - return 0; + if (pt==PT_STKM) //Stick man's head shouldn't collide + return 2; + if (pt==PT_STKM2) //Stick man's head shouldn't collide + return 2; + if ((pt==PT_BIZR||pt==PT_BIZRG)&&(r&0xFF)==PT_FILT) + return 2; + if (bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE) + return 0; + if (ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID) + return 0; + if ((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL]) + return 0; + if (bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL]) + return 2; + if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR) + return 0; - if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID) - return 0; - if(r && (r&0xFF) < PT_NUM){ - if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY) + if (ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID) + return 0; + if (r && (r&0xFF) < PT_NUM) { + if (ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY) return 2; - - if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS) + + if (pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPASS) return 2; - if(pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE) + if (pt==PT_NEUT && ptypes[(r&0xFF)].properties&PROP_NEUTPENETRATE) return 1; - if((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE) + if ((r&0xFF)==PT_NEUT && ptypes[pt].properties&PROP_NEUTPENETRATE) return 0; - } - - if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight))) - return 0; + } - if(pt == PT_PHOT) - return 2; + if (r && ((r&0xFF) >= PT_NUM || (ptypes[pt].weight <= ptypes[(r&0xFF)].weight))) + return 0; - return 1; + if (pt == PT_PHOT) + return 2; + + return 1; } -static void create_cherenkov_photon(int pp); -static void create_gain_photon(int pp); - int try_move(int i, int x, int y, int nx, int ny) { - unsigned r, e; + unsigned r, e; - if(x==nx && y==ny) - return 1; + if (x==nx && y==ny) + return 1; - e = eval_move(parts[i].type, nx, ny, &r); - - if((pmap[ny][nx]&0xFF)==PT_BOMB && parts[i].type==PT_BOMB && parts[i].tmp == 1) + e = eval_move(parts[i].type, nx, ny, &r); + + if ((pmap[ny][nx]&0xFF)==PT_BOMB && parts[i].type==PT_BOMB && parts[i].tmp == 1) e = 2; - - if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) - return 1; - /* half-silvered mirror */ - if(!e && parts[i].type==PT_PHOT && - (((r&0xFF)==PT_BMTL && rand()>8].temp = parts[i].temp; + if ((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) + return 1; + /* half-silvered mirror */ + if (!e && parts[i].type==PT_PHOT && + (((r&0xFF)==PT_BMTL && rand()>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP); - } - return 0; - } - - if(e == 2) - { - if(parts[i].type == PT_PHOT && (r&0xFF)==PT_GLOW && !parts[r>>8].life) - if(rand() < RAND_MAX/30) - { - parts[r>>8].life = 120; - create_gain_photon(i); - } - if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT) - { - int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f); - if(temp_bin < 0) temp_bin = 0; - if(temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; - } - if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) { - if(rand() < RAND_MAX/10) - create_cherenkov_photon(i); - } - if(parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) { - parts[i].type = PT_NEUT; - parts[i].ctype = 0; - } - if((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT) - { - int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f); - if(temp_bin < 0) temp_bin = 0; - if(temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; - } - return 1; - } - - if((r&0xFF)==PT_VOID) - { - if(parts[i].type == PT_STKM) + if (!e) { - death = 1; - isplayer = 0; + if (!legacy_enable && parts[i].type==PT_PHOT && r) + { + if ((r & 0xFF) == PT_COAL || (r & 0xFF) == PT_BCOL) + parts[r>>8].temp = parts[i].temp; + + if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct) + parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP); + } + return 0; } - if(parts[i].type == PT_STKM2) + + if (e == 2) { - death2 = 1; - isplayer2 = 0; + if (parts[i].type == PT_PHOT && (r&0xFF)==PT_GLOW && !parts[r>>8].life) + if (rand() < RAND_MAX/30) + { + parts[r>>8].life = 120; + create_gain_photon(i); + } + if (parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT) + { + int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; + } + if (parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) { + if (rand() < RAND_MAX/10) + create_cherenkov_photon(i); + } + if (parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) { + part_change_type(i,x,y,PT_NEUT); + parts[i].ctype = 0; + } + if ((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT) + { + int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; + } + return 1; } - parts[i].type=PT_NONE; - return 0; - } - if((r&0xFF)==PT_BHOL) - { - if(parts[i].type == PT_STKM) + + if ((r&0xFF)==PT_VOID) { - death = 1; - isplayer = 0; + if (parts[i].type == PT_STKM) + { + death = 1; + isplayer = 0; + } + if (parts[i].type == PT_STKM2) + { + death2 = 1; + isplayer2 = 0; + } + parts[i].type=PT_NONE; + return 0; } - if(parts[i].type == PT_STKM2) + if ((r&0xFF)==PT_BHOL) { - death2 = 1; - isplayer2 = 0; + if (parts[i].type == PT_STKM) + { + death = 1; + isplayer = 0; + } + if (parts[i].type == PT_STKM2) + { + death2 = 1; + isplayer2 = 0; + } + parts[i].type=PT_NONE; + if (!legacy_enable) + { + parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f; + } + + return 0; } - parts[i].type=PT_NONE; - if(!legacy_enable) - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP);//3.0f; - } + if ((pmap[ny][nx]&0xFF)==PT_CNCT) + return 0; + if (parts[i].type==PT_CNCT && y>8)>8)> 8; + if (r && e> 8; - if(r && e= 0) | - (((dx + dy) >= 0) << 1) | /* 567 */ - ((dy >= 0) << 2) | /* 4+0 */ - (((dy - dx) >= 0) << 3) | /* 321 */ - ((dx <= 0) << 4) | - (((dx + dy) <= 0) << 5) | - ((dy <= 0) << 6) | - (((dy - dx) <= 0) << 7); + // TODO: + // Adding extra directions causes some inaccuracies. + // Not adding them causes problems with some diagonal surfaces (photons absorbed instead of reflected). + // For now, don't add them. + // Solution may involve more intelligent setting of initial i0 value in find_next_boundary? + // or rewriting normal/boundary finding code + + return (dx >= 0) | + (((dx + dy) >= 0) << 1) | /* 567 */ + ((dy >= 0) << 2) | /* 4+0 */ + (((dy - dx) >= 0) << 3) | /* 321 */ + ((dx <= 0) << 4) | + (((dx + dy) <= 0) << 5) | + ((dy <= 0) << 6) | + (((dy - dx) <= 0) << 7); + /* + return (dx >= -0.001) | + (((dx + dy) >= -0.001) << 1) | // 567 + ((dy >= -0.001) << 2) | // 4+0 + (((dy - dx) >= -0.001) << 3) | // 321 + ((dx <= 0.001) << 4) | + (((dx + dy) <= 0.001) << 5) | + ((dy <= 0.001) << 6) | + (((dy - dx) <= 0.001) << 7); + }*/ } static int is_blocking(int t, int x, int y) { - if(t & REFRACT) { - if(x<0 || y<0 || x>=XRES || y>=YRES) - return 0; - if((pmap[y][x] & 0xFF) == PT_GLAS) - return 1; - return 0; - } + if (t & REFRACT) { + if (x<0 || y<0 || x>=XRES || y>=YRES) + return 0; + if ((pmap[y][x] & 0xFF) == PT_GLAS) + return 1; + return 0; + } - return !eval_move(t, x, y, NULL); + return !eval_move(t, x, y, NULL); } static int is_boundary(int pt, int x, int y) { - if(!is_blocking(pt,x,y)) - return 0; - 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)) - return 0; - return 1; + if (!is_blocking(pt,x,y)) + return 0; + 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)) + return 0; + return 1; } static int find_next_boundary(int pt, int *x, int *y, int dm, int *em) { - static int dx[8] = {1,1,0,-1,-1,-1,0,1}; - static int dy[8] = {0,1,1,1,0,-1,-1,-1}; - static int de[8] = {0x83,0x07,0x0E,0x1C,0x38,0x70,0xE0,0xC1}; - int i, ii, i0; + static int dx[8] = {1,1,0,-1,-1,-1,0,1}; + static int dy[8] = {0,1,1,1,0,-1,-1,-1}; + static int de[8] = {0x83,0x07,0x0E,0x1C,0x38,0x70,0xE0,0xC1}; + int i, ii, i0; - if(*x <= 0 || *x >= XRES-1 || *y <= 0 || *y >= YRES-1) - return 0; + if (*x <= 0 || *x >= XRES-1 || *y <= 0 || *y >= YRES-1) + return 0; - if(*em != -1) { - i0 = *em; - dm &= de[i0]; - } else - i0 = 0; + if (*em != -1) { + i0 = *em; + dm &= de[i0]; + } else + i0 = 0; - for(ii=0; ii<8; ii++) { - i = (ii + i0) & 7; - if((dm & (1 << i)) && is_boundary(pt, *x+dx[i], *y+dy[i])) { - *x += dx[i]; - *y += dy[i]; - *em = i; - return 1; - } - } + for (ii=0; ii<8; ii++) { + i = (ii + i0) & 7; + if ((dm & (1 << i)) && is_boundary(pt, *x+dx[i], *y+dy[i])) { + *x += dx[i]; + *y += dy[i]; + *em = i; + return 1; + } + } - return 0; + return 0; } int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny) { - int ldm, rdm, lm, rm; - int lx, ly, lv, rx, ry, rv; - int i, j; - float r, ex, ey; + int ldm, rdm, lm, rm; + int lx, ly, lv, rx, ry, rv; + int i, j; + float r, ex, ey; - if(!dx && !dy) - return 0; + if (!dx && !dy) + return 0; - if(!is_boundary(pt, x, y)) - return 0; + if (!is_boundary(pt, x, y)) + return 0; - ldm = direction_to_map(-dy, dx); - rdm = direction_to_map(dy, -dx); - lx = rx = x; - ly = ry = y; - lv = rv = 1; - lm = rm = -1; + ldm = direction_to_map(-dy, dx, pt); + rdm = direction_to_map(dy, -dx, pt); + lx = rx = x; + ly = ry = y; + lv = rv = 1; + lm = rm = -1; - j = 0; - for(i=0; i= NORMAL_INTERP) - return 0; + for (i=0; i= NORMAL_INTERP) + return 0; - if(pt == PT_PHOT) - photoelectric_effect(x, y); + if (pt == PT_PHOT) + photoelectric_effect(x, y); - return get_normal(pt, x, y, dx, dy, nx, ny); + return get_normal(pt, x, y, dx, dy, nx, ny); } void kill_part(int i) { - int x, y; + int x, y; - if(parts[i].type != PT_PHOT) { - x = (int)(parts[i].x+0.5f); - y = (int)(parts[i].y+0.5f); - if(parts[i].type == PT_STKM) - { - death = 1; - isplayer = 0; + if (parts[i].type != PT_PHOT) { + x = (int)(parts[i].x+0.5f); + y = (int)(parts[i].y+0.5f); + if (parts[i].type == PT_STKM) + { + death = 1; + isplayer = 0; + } + if (parts[i].type == PT_STKM2) + { + death2 = 1; + isplayer2 = 0; + } + if (parts[i].type == PT_SPAWN) + { + ISSPAWN1 = 0; + } + if (parts[i].type == PT_SPAWN2) + { + ISSPAWN2 = 0; + } + if (x>=0 && y>=0 && x>8)==i) + pmap[y][x] = 0; + else if ((photons[y][x]>>8)==i) + photons[y][x] = 0; + } } - if(parts[i].type == PT_STKM2) - { - death2 = 1; - isplayer2 = 0; - } - if(parts[i].type == PT_SPAWN) - { - ISSPAWN1 = 0; - } - if(parts[i].type == PT_SPAWN2) - { - ISSPAWN2 = 0; - } - if(x>=0 && y>=0 && x=XRES || y>=YRES || i>=NPART) + return -1; + parts[i].type = t; + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) + pmap[y][x] = t|(i<<8); + else if ((pmap[y][x]>>8)==i) + pmap[y][x] = 0; } #if defined(WIN32) && !defined(__GNUC__) @@ -439,33 +472,35 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) { int i, c; n = (n/10); - if(n<1){ + if (n<1) { n = 1; } - if(n>680){ + if (n>680) { n = 680; } - if(x<0 || y<0 || x>=XRES || y>=YRES) - return -1; - + if (x<0 || y<0 || x>=XRES || y>=YRES) + return -1; + for (c; c=XRES || y>=YRES) - return -1; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return -1; - if(t==SPC_HEAT||t==SPC_COOL) - { - if((pmap[y][x]&0xFF)!=PT_NONE&&(pmap[y][x]&0xFF)>8].temp>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP); - } else if((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); - } - } - if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) - { - if((pmap[y][x]&0xFF)==PT_PUMP) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP); - } else if((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP); - } - } - return pmap[y][x]>>8; - } - else - { - return -1; - } - } - if(t==SPC_AIR) - { - pv[y/CELL][x/CELL] += 0.03f; - if(y+CELL>8].life!=0) - return -1; - parts[pmap[y][x]>>8].type = PT_SPRK; - parts[pmap[y][x]>>8].life = 4; - parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF; - pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK; - return pmap[y][x]>>8; - } - if(t==PT_SPAWN&&ISSPAWN1) - return -1; - if(t==PT_SPAWN2&&ISSPAWN2) - return -1; - if(p==-1)//creating from anything but brush - { - if(pmap[y][x]) + if (t==SPC_HEAT||t==SPC_COOL) + { + if ((pmap[y][x]&0xFF)!=PT_NONE&&(pmap[y][x]&0xFF)>8].temp>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP); + } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 50.0f, MIN_TEMP, MAX_TEMP); + } else { + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); + } + } + if (t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) + { + if ((pmap[y][x]&0xFF)==PT_PUMP) { + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP); + } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 50.0f, MIN_TEMP, MAX_TEMP); + } else { + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP); + } + } + return pmap[y][x]>>8; + } + else + { + return -1; + } + } + if (t==SPC_AIR) + { + pv[y/CELL][x/CELL] += 0.03f; + if (y+CELL>8].life!=0) + return -1; + parts[pmap[y][x]>>8].type = PT_SPRK; + parts[pmap[y][x]>>8].life = 4; + parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF; + pmap[y][x] = (pmap[y][x]&~0xFF) | PT_SPRK; + return pmap[y][x]>>8; + } + if (t==PT_SPAWN&&ISSPAWN1) + return -1; + if (t==PT_SPAWN2&&ISSPAWN2) + return -1; + if (p==-1)//creating from anything but brush + { + if (pmap[y][x]) + { + if ((pmap[y][x]&0xFF)!=PT_SPAWN&&(pmap[y][x]&0xFF)!=PT_SPAWN2) + { + if (t!=PT_STKM&&t!=PT_STKM2) { return -1; } } } - if(pfree == -1) - return -1; - i = pfree; - pfree = parts[i].life; - } - else if(p==-2)//creating from brush - { - if(pmap[y][x]) - { - if(((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||(pmap[y][x]&0xFF)==PT_PCLN)&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN&&t!=PT_STKM&&t!=PT_STKM2)) - { - parts[pmap[y][x]>>8].ctype = t; - } - return -1; - } - if(photons[y][x] && t==PT_PHOT) + if (photons[y][x] && t==PT_PHOT) return -1; - if(pfree == -1) - return -1; - i = pfree; - pfree = parts[i].life; - } - else - i = p; + if (pfree == -1) + return -1; + i = pfree; + pfree = parts[i].life; + } + else if (p==-2)//creating from brush + { + if (pmap[y][x]) + { + if (((pmap[y][x]&0xFF)==PT_CLNE||(pmap[y][x]&0xFF)==PT_BCLN||((pmap[y][x]&0xFF)==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN))&&(t!=PT_CLNE&&t!=PT_PCLN&&t!=PT_BCLN&&t!=PT_STKM&&t!=PT_STKM2)) + { + parts[pmap[y][x]>>8].ctype = t; + } + return -1; + } + if (photons[y][x] && t==PT_PHOT) + return -1; + if (pfree == -1) + return -1; + i = pfree; + pfree = parts[i].life; + } + else + i = p; - if(t==PT_GLAS) - { - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - } - if(t==PT_QRTZ) - { - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - } - if(t!=PT_STKM&&t!=PT_STKM2) - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = t; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 0; - parts[i].ctype = 0; - parts[i].temp = ptypes[t].heat; - parts[i].tmp = 0; - } - if(t==PT_ACID) - { - parts[i].life = 75; - } - /*Testing - if(t==PT_WOOD){ - parts[i].life = 150; - } - End Testing*/ - if(t==PT_WARP) { + if (t==PT_GLAS) + { + parts[i].pavg[1] = pv[y/CELL][x/CELL]; + } + if (t==PT_QRTZ) + { + parts[i].pavg[1] = pv[y/CELL][x/CELL]; + } + if (t!=PT_STKM&&t!=PT_STKM2) + { + parts[i].x = (float)x; + parts[i].y = (float)y; + parts[i].type = t; + parts[i].vx = 0; + parts[i].vy = 0; + parts[i].life = 0; + parts[i].ctype = 0; + parts[i].temp = ptypes[t].heat; + parts[i].tmp = 0; + } + if (t==PT_ACID) + { + parts[i].life = 75; + } + /*Testing + if(t==PT_WOOD){ + parts[i].life = 150; + } + End Testing*/ + if (t==PT_WARP) { parts[i].life = rand()%95+70; } - if(t==PT_FUSE) { - parts[i].life = 50; - parts[i].tmp = 50; - } - if(t==PT_DEUT) - parts[i].life = 10; - if(t==PT_BRAY) - parts[i].life = 30; - if(t==PT_PUMP) - parts[i].life= 10; - if(t==PT_SING) - parts[i].life = rand()%50+60; - if(t==PT_QRTZ) - parts[i].tmp = (rand()%11); - if(t==PT_PQRT) - parts[i].tmp = (rand()%11); - if(ptypes[t].properties&PROP_LIFE) { - int r; - for(r = 0;r>8].type = PT_STKM; parts[pmap[y][x]>>8].vx = 0; parts[pmap[y][x]>>8].vy = 0; parts[pmap[y][x]>>8].life = 100; parts[pmap[y][x]>>8].ctype = 0; - parts[pmap[y][x]>>8].temp = ptypes[t].heat; - + parts[pmap[y][x]>>8].temp = ptypes[t].heat; + } else { @@ -737,52 +750,52 @@ inline int create_part(int p, int x, int y, int t) parts[i].ctype = 0; parts[i].temp = ptypes[t].heat; } - - - - player[3] = x-1; //Setting legs positions - player[4] = y+6; - player[5] = x-1; - player[6] = y+6; - - player[7] = x-3; - player[8] = y+12; - player[9] = x-3; - player[10] = y+12; - - player[11] = x+1; - player[12] = y+6; - player[13] = x+1; - player[14] = y+6; - - player[15] = x+3; - player[16] = y+12; - player[17] = x+3; - player[18] = y+12; - - isplayer = 1; - } - else + + + + player[3] = x-1; //Setting legs positions + player[4] = y+6; + player[5] = x-1; + player[6] = y+6; + + player[7] = x-3; + player[8] = y+12; + player[9] = x-3; + player[10] = y+12; + + player[11] = x+1; + player[12] = y+6; + player[13] = x+1; + player[14] = y+6; + + player[15] = x+3; + player[16] = y+12; + player[17] = x+3; + player[18] = y+12; + + isplayer = 1; + } + else { return -1; } //kill_part(playerspawn); create_part(-1,x,y,PT_SPAWN); ISSPAWN1 = 1; - } - if(t==PT_STKM2) - { - if(isplayer2==0) - { - if(pmap[y][x]&0xFF==PT_SPAWN2) + } + if (t==PT_STKM2) + { + if (isplayer2==0) + { + if (pmap[y][x]&0xFF==PT_SPAWN2) { parts[pmap[y][x]>>8].type = PT_STKM2; parts[pmap[y][x]>>8].vx = 0; parts[pmap[y][x]>>8].vy = 0; parts[pmap[y][x]>>8].life = 100; parts[pmap[y][x]>>8].ctype = 0; - parts[pmap[y][x]>>8].temp = ptypes[t].heat; - + parts[pmap[y][x]>>8].temp = ptypes[t].heat; + } else { @@ -795,135 +808,135 @@ inline int create_part(int p, int x, int y, int t) parts[i].ctype = 0; parts[i].temp = ptypes[t].heat; } - - - - player2[3] = x-1; //Setting legs positions - player2[4] = y+6; - player2[5] = x-1; - player2[6] = y+6; - - player2[7] = x-3; - player2[8] = y+12; - player2[9] = x-3; - player2[10] = y+12; - - player2[11] = x+1; - player2[12] = y+6; - player2[13] = x+1; - player2[14] = y+6; - - player2[15] = x+3; - player2[16] = y+12; - player2[17] = x+3; - player2[18] = y+12; - - isplayer2 = 1; - } - else + + + + player2[3] = x-1; //Setting legs positions + player2[4] = y+6; + player2[5] = x-1; + player2[6] = y+6; + + player2[7] = x-3; + player2[8] = y+12; + player2[9] = x-3; + player2[10] = y+12; + + player2[11] = x+1; + player2[12] = y+6; + player2[13] = x+1; + player2[14] = y+6; + + player2[15] = x+3; + player2[16] = y+12; + player2[17] = x+3; + player2[18] = y+12; + + isplayer2 = 1; + } + else { return -1; } //kill_part(player2spawn); create_part(-1,x,y,PT_SPAWN2); ISSPAWN2 = 1; - } - if(t==PT_BIZR||t==PT_BIZRG) - parts[i].ctype = 0x47FFFF; - if(t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP - pmap[y][x] = t|(i<<8); + } + if (t==PT_BIZR||t==PT_BIZRG) + parts[i].ctype = 0x47FFFF; + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP + pmap[y][x] = t|(i<<8); - return i; + return i; } static void create_gain_photon(int pp) { - float xx, yy; - int i, lr, temp_bin, nx, ny; + float xx, yy; + int i, lr, temp_bin, nx, ny; - if(pfree == -1) - return; - i = pfree; + if (pfree == -1) + return; + i = pfree; - lr = rand() % 2; + lr = rand() % 2; - if(lr) { - xx = parts[pp].x - 0.3*parts[pp].vy; - yy = parts[pp].y + 0.3*parts[pp].vx; - } else { - xx = parts[pp].x + 0.3*parts[pp].vy; - yy = parts[pp].y - 0.3*parts[pp].vx; - } + if (lr) { + xx = parts[pp].x - 0.3*parts[pp].vy; + yy = parts[pp].y + 0.3*parts[pp].vx; + } else { + xx = parts[pp].x + 0.3*parts[pp].vy; + yy = parts[pp].y - 0.3*parts[pp].vx; + } - nx = (int)(xx + 0.5f); - ny = (int)(yy + 0.5f); + nx = (int)(xx + 0.5f); + ny = (int)(yy + 0.5f); - if(nx<0 || ny<0 || nx>=XRES || ny>=YRES) - return; + if (nx<0 || ny<0 || nx>=XRES || ny>=YRES) + return; - if((pmap[ny][nx] & 0xFF) != PT_GLOW) - return; + if ((pmap[ny][nx] & 0xFF) != PT_GLOW) + return; - pfree = parts[i].life; + pfree = parts[i].life; - parts[i].type = PT_PHOT; - parts[i].life = 680; - parts[i].x = xx; - parts[i].y = yy; - parts[i].vx = parts[pp].vx; - parts[i].vy = parts[pp].vy; - parts[i].temp = parts[pmap[ny][nx] >> 8].temp; - parts[i].tmp = 0; - photons[ny][nx] = PT_PHOT|(i<<8); + parts[i].type = PT_PHOT; + parts[i].life = 680; + parts[i].x = xx; + parts[i].y = yy; + parts[i].vx = parts[pp].vx; + parts[i].vy = parts[pp].vy; + parts[i].temp = parts[pmap[ny][nx] >> 8].temp; + parts[i].tmp = 0; + photons[ny][nx] = PT_PHOT|(i<<8); - temp_bin = (int)((parts[i].temp-273.0f)*0.25f); - if(temp_bin < 0) temp_bin = 0; - if(temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; + temp_bin = (int)((parts[i].temp-273.0f)*0.25f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; } static void create_cherenkov_photon(int pp) { - int i, lr, nx, ny; - float r, eff_ior; + int i, lr, nx, ny; + float r, eff_ior; - if(pfree == -1) - return; - i = pfree; + if (pfree == -1) + return; + i = pfree; - nx = (int)(parts[pp].x + 0.5f); - ny = (int)(parts[pp].y + 0.5f); - if((pmap[ny][nx] & 0xFF) != PT_GLAS) - return; + nx = (int)(parts[pp].x + 0.5f); + ny = (int)(parts[pp].y + 0.5f); + if ((pmap[ny][nx] & 0xFF) != PT_GLAS) + return; - if(hypotf(parts[pp].vx, parts[pp].vy) < 1.44f) - return; + if (hypotf(parts[pp].vx, parts[pp].vy) < 1.44f) + return; - pfree = parts[i].life; + pfree = parts[i].life; - lr = rand() % 2; + lr = rand() % 2; - parts[i].type = PT_PHOT; - parts[i].ctype = 0x00000F80; - parts[i].life = 680; - parts[i].x = parts[pp].x; - parts[i].y = parts[pp].y; - parts[i].temp = parts[pmap[ny][nx] >> 8].temp; - parts[i].tmp = 0; - photons[ny][nx] = PT_PHOT|(i<<8); + parts[i].type = PT_PHOT; + parts[i].ctype = 0x00000F80; + parts[i].life = 680; + parts[i].x = parts[pp].x; + parts[i].y = parts[pp].y; + parts[i].temp = parts[pmap[ny][nx] >> 8].temp; + parts[i].tmp = 0; + photons[ny][nx] = PT_PHOT|(i<<8); - if(lr) { - parts[i].vx = parts[pp].vx - 2.5f*parts[pp].vy; - parts[i].vy = parts[pp].vy + 2.5f*parts[pp].vx; - } else { - parts[i].vx = parts[pp].vx + 2.5f*parts[pp].vy; - parts[i].vy = parts[pp].vy - 2.5f*parts[pp].vx; - } + if (lr) { + parts[i].vx = parts[pp].vx - 2.5f*parts[pp].vy; + parts[i].vy = parts[pp].vy + 2.5f*parts[pp].vx; + } else { + parts[i].vx = parts[pp].vx + 2.5f*parts[pp].vy; + parts[i].vy = parts[pp].vy - 2.5f*parts[pp].vx; + } - /* photons have speed of light. no discussion. */ - r = 1.269 / hypotf(parts[i].vx, parts[i].vy); - parts[i].vx *= r; - parts[i].vy *= r; + /* photons have speed of light. no discussion. */ + r = 1.269 / hypotf(parts[i].vx, parts[i].vy); + parts[i].vx *= r; + parts[i].vy *= r; } #if defined(WIN32) && !defined(__GNUC__) @@ -932,30 +945,29 @@ _inline void delete_part(int x, int y) inline void delete_part(int x, int y) #endif { - unsigned i; + unsigned i; - if(x<0 || y<0 || x>=XRES || y>=YRES) - return; - if(photons[y][x]){ - i = photons[y][x]; - } else { - i = pmap[y][x]; - } - - if(!i || (i>>8)>=NPART) - return; - if((parts[i>>8].type==SLALT)||SLALT==0) - { - kill_part(i>>8); - pmap[y][x] = 0; + if (x<0 || y<0 || x>=XRES || y>=YRES) + return; + if (photons[y][x]) { + i = photons[y][x]; + } else { + i = pmap[y][x]; } - else if(ptypes[parts[i>>8].type].menusection==SEC) + + if (!i || (i>>8)>=NPART) + return; + if ((parts[i>>8].type==SLALT)||SLALT==0) + { + kill_part(i>>8); + } + else if (ptypes[parts[i>>8].type].menusection==SEC) { kill_part(i>>8); - pmap[y][x] = 0; } else - return; + return; + } #if defined(WIN32) && !defined(__GNUC__) @@ -964,7 +976,7 @@ _inline int is_wire(int x, int y) inline int is_wire(int x, int y) #endif { - return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE; + return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE; } #if defined(WIN32) && !defined(__GNUC__) @@ -973,89 +985,89 @@ _inline int is_wire_off(int x, int y) inline int is_wire_off(int x, int y) #endif { - return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE) && emap[y][x]<8; + return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE) && emap[y][x]<8; } int get_wavelength_bin(int *wm) { - int i, w0=30, wM=0; + int i, w0=30, wM=0; - if(!*wm) - return -1; + if (!*wm) + return -1; - for(i=0; i<30; i++) - if(*wm & (1< wM) - wM = i; - } + for (i=0; i<30; i++) + if (*wm & (1< wM) + wM = i; + } - if(wM-w0 < 5) - return (wM+w0)/2; + if (wM-w0 < 5) + return (wM+w0)/2; - i = rand() % (wM-w0-3); - i += w0; + i = rand() % (wM-w0-3); + i += w0; - *wm &= 0x1F << i; - return i + 2; + *wm &= 0x1F << i; + return i + 2; } void set_emap(int x, int y) { - int x1, x2; + int x1, x2; - if(!is_wire_off(x, y)) - return; + if (!is_wire_off(x, y)) + return; - // go left as far as possible - x1 = x2 = x; - while(x1>0) - { - if(!is_wire_off(x1-1, y)) - break; - x1--; - } - while(x20) + { + if (!is_wire_off(x1-1, y)) + break; + x1--; + } + while (x21 && x1==x2 && - is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) && - !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2)) - set_emap(x1, y-2); - else if(y>0) - for(x=x1; x<=x2; x++) - if(is_wire_off(x, y-1)) - { - if(x==x1 || x==x2 || y>=YRES/CELL-1 || - is_wire(x-1, y-1) || is_wire(x+1, y-1) || - is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1)) - set_emap(x, y-1); - } + if (y>1 && x1==x2 && + is_wire(x1-1, y-1) && is_wire(x1, y-1) && is_wire(x1+1, y-1) && + !is_wire(x1-1, y-2) && is_wire(x1, y-2) && !is_wire(x1+1, y-2)) + set_emap(x1, y-2); + else if (y>0) + for (x=x1; x<=x2; x++) + if (is_wire_off(x, y-1)) + { + if (x==x1 || x==x2 || y>=YRES/CELL-1 || + is_wire(x-1, y-1) || is_wire(x+1, y-1) || + is_wire(x-1, y+1) || !is_wire(x, y+1) || is_wire(x+1, y+1)) + set_emap(x, y-1); + } - if(y>8) < NPART && pmr) + if ((pmr>>8) < NPART && pmr) return parts[pmr>>8].type; - else + else return PT_NONE; } else { int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate. - if((pmr2>>8) < NPART && pmr2) + if ((pmr2>>8) < NPART && pmr2) { - if(parts[pmr2>>8].type==t) + if (parts[pmr2>>8].type==t) return t; } else @@ -1089,41 +1101,45 @@ inline int parts_avg(int ci, int ni,int t) int nearest_part(int ci, int t) { - int distance = MAX_DISTANCE; - int ndistance = 0; - int id = -1; - int i = 0; - int cx = (int)parts[ci].x; - int cy = (int)parts[ci].y; - for(i=0; i0 && GRAV_G==0) + if (GRAV_R >0 && GRAV_G==0) { GRAV_R--; GRAV_B++; } - if(GRAV_B >0 && GRAV_R==0) + if (GRAV_B >0 && GRAV_R==0) { GRAV_B--; GRAV_G++; } - if(GRAV_G >0 && GRAV_B==0) + if (GRAV_G >0 && GRAV_B==0) { GRAV_G--; GRAV_R++; } - if(GRAV_R2 >0 && GRAV_G2==0) + if (GRAV_R2 >0 && GRAV_G2==0) { GRAV_R2--; GRAV_B2++; } - if(GRAV_B2 >0 && GRAV_R2==0) + if (GRAV_B2 >0 && GRAV_R2==0) { GRAV_B2--; GRAV_G2++; } - if(GRAV_G2 >0 && GRAV_B2==0) + if (GRAV_G2 >0 && GRAV_B2==0) { GRAV_G2--; GRAV_R2++; } } - if(GRAV>180) GRAV = 0; - + if (GRAV>180) GRAV = 0; + } - if(ISLOVE==1) + if (ISLOVE==1) { - ISLOVE = 0; - for(ny=0;ny>8)>=NPART || !r) + for (nx=0; nxYRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE) - parts[r>>8].type = PT_NONE; - else if(parts[r>>8].type==PT_LOVE) - { - love[nx/9][ny/9] = 1; - } - - } - } - for(nx=9;nx<=XRES-18;nx++) - { - for(ny=9;ny<=YRES-7;ny++) - { - if(love[nx/9][ny/9]==1) - { - for( nnx=0;nnx<9;nnx++) - for( nny=0;nny<9;nny++) + r=pmap[ny][nx]; + if ((r>>8)>=NPART || !r) { - if(ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) - { - continue; - } - if(!rt&&loverule[nnx][nny]==1) - create_part(-1,nx+nnx,ny+nny,PT_LOVE); - else if(!rt) - continue; - else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0) - parts[rt>>8].type=PT_NONE; - - } + continue; } - } - love[nx/9][ny/9]=0; - } - } - } - if(ISLOLZ==1) - { - ISLOLZ = 0; - for(ny=0;ny>8)>=NPART || !r) - { - continue; - } - else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ) - parts[r>>8].type = PT_NONE; - else if(parts[r>>8].type==PT_LOLZ) - { - lolz[nx/9][ny/9] = 1; - } - - } - } - for(nx=9;nx<=XRES-18;nx++) - { - for(ny=9;ny<=YRES-7;ny++) - { - if(lolz[nx/9][ny/9]==1) - { - for( nnx=0;nnx<9;nnx++) - for( nny=0;nny<9;nny++) + else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE) + kill_part(r>>8); + else if (parts[r>>8].type==PT_LOVE) { - if(ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) - { - continue; - } - if(!rt&&lolzrule[nny][nnx]==1) - create_part(-1,nx+nnx,ny+nny,PT_LOLZ); - else if(!rt) - continue; - else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0) - parts[rt>>8].type=PT_NONE; - - } + love[nx/9][ny/9] = 1; } + + } + } + for (nx=9; nx<=XRES-18; nx++) + { + for (ny=9; ny<=YRES-7; ny++) + { + if (love[nx/9][ny/9]==1) + { + for ( nnx=0; nnx<9; nnx++) + for ( nny=0; nny<9; nny++) + { + if (ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) + { + continue; + } + if (!rt&&loverule[nnx][nny]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOVE); + else if (!rt) + continue; + else if (parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0) + kill_part(rt>>8); + } + } + } + love[nx/9][ny/9]=0; } - lolz[nx/9][ny/9]=0; } - } } - if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation + if (ISLOLZ==1) + { + ISLOLZ = 0; + for (ny=0; ny>8)>=NPART || !r) + { + continue; + } + else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ) + kill_part(r>>8); + else if (parts[r>>8].type==PT_LOLZ) + { + lolz[nx/9][ny/9] = 1; + } + + } + } + for (nx=9; nx<=XRES-18; nx++) + { + for (ny=9; ny<=YRES-7; ny++) + { + if (lolz[nx/9][ny/9]==1) + { + for ( nnx=0; nnx<9; nnx++) + for ( nny=0; nny<9; nny++) + { + if (ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) + { + continue; + } + if (!rt&&lolzrule[nny][nnx]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOLZ); + else if (!rt) + continue; + else if (parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0) + kill_part(rt>>8); + + } + } + } + lolz[nx/9][ny/9]=0; + } + } + } + if (ISGOL==1&&++CGOL>=GSPEED)//GSPEED is frames per generation { - int createdsomething = 0; CGOL=0; ISGOL=0; - for(nx=CELL;nx>8)>=NPART || !r) + int createdsomething = 0; + for (nx=CELL; nx>8].type==goltype[golnum-1]) - { - if(parts[r>>8].tmp == grule[golnum][9]-1) { - gol[nx][ny] = golnum; - 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 - { - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; - gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; - } - } else { - parts[r>>8].tmp --; - if(parts[r>>8].tmp<=0) - parts[r>>8].type = PT_NONE; - } - } - } - for(nx=CELL;nx>8)>=NPART) - continue; - for( golnum = 1;golnum>8)>=NPART || !r) { - if(neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) - { - if(create_part(-1,nx,ny,goltype[golnum-1])) - createdsomething = 1; - } - else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2)) {//subtract 1 because it counted itself - if(parts[r>>8].tmp==grule[golnum][9]-1) - parts[r>>8].tmp --; - } - if(parts[r>>8].tmp<=0) - parts[r>>8].type = PT_NONE; + gol[nx][ny] = 0; + continue; } - gol2[nx][ny][0] = 0; - for( z = 1;z>8].type==goltype[golnum-1]) + { + gol[nx][ny] = golnum; + 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 + { + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; + } + } + } + for (nx=CELL; nx=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) + { + if (create_part(-1,nx,ny,goltype[golnum-1])) + createdsomething = 1; + } + else if (neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself + kill_part(pmap[ny][nx]>>8); + } + gol2[nx][ny][0] = 0; + for ( z = 1; z=XRES || y>=YRES || - ((bmap[y/CELL][x/CELL]==WL_WALL || - bmap[y/CELL][x/CELL]==WL_WALLELEC || - bmap[y/CELL][x/CELL]==WL_ALLOWAIR || - (bmap[y/CELL][x/CELL]==WL_DESTROYALL) || - (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) || - (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) || - (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) || - (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) || - (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2))) - { - kill_part(i); - continue; - } - - vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vx; - vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vy; - - if(t==PT_GAS||t==PT_NBLE) - { - if(pv[y/CELL][x/CELL]<3.5f) - pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]); - if(y+CELL=256.0+273.15) - parts[i].temp=256.0+273.15; - if(parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) - pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]); - if(y+CELL0 && pv[y/CELL-1][x/CELL]<(parts[i].temp/100)) - pv[y/CELL-1][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL]); - if(x+CELL>0) - { - pv[y/CELL][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL-1]); - if(y+CELL>0) - pv[y/CELL-1][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL-1]); - } - } - else if(t==PT_SING) - { - int singularity = -parts[i].life; - - if(pv[y/CELL][x/CELL]0 && pv[y/CELL-1][x/CELL]0) - { - pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]); - if(y+CELL>0) - pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]); - } - } - else - { - pv[y/CELL][x/CELL] += ptypes[t].hotair; - if(y+CELL2.5f) - { - parts[i].life = rand()%80+180; - rt = parts[i].type = PT_FIRE; - parts[i].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2); - pv[y/CELL][x/CELL] += 0.25f * CFDS; - t = PT_FIRE; - } - - parts[i].vx *= ptypes[t].loss; - parts[i].vy *= ptypes[t].loss; - - if((t==PT_GOO) && !parts[i].life) - { - if(pv[y/CELL][x/CELL]>1.0f) - { - parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; - parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL]; - parts[i].life = rand()%80+300; - } - } - else if((t==PT_BCLN) && !parts[i].life) - { - if(pv[y/CELL][x/CELL]>4.0f) - { - parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; - parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL]; - parts[i].life = rand()%40+80; - } - } - else - { - //Gravity mode by Moach - switch (gravityMode) + if (!(parts[i].life==10&&(t==PT_SWCH||t==PT_LCRY||t==PT_PCLN||t==PT_HSWC||t==PT_PUMP))) + parts[i].life--; + if (parts[i].life<=0 && !(ptypes[t].properties&PROP_CONDUCTS) && t!=PT_ARAY && t!=PT_FIRW && t!=PT_SWCH && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_SPRK && t!=PT_LAVA && t!=PT_LCRY && t!=PT_QRTZ && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4) { - default: - case 0: - pGravX = pGravY = 0.0f; - break; - case 1: - pGravX = 0.0f; - pGravY = ptypes[t].gravity; - break; - case 2: - - pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); - - pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD); - pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD); - + kill_part(i); + continue; } - - parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX; - parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY; - } + } - if(ptypes[t].diffusion) - { - parts[i].vx += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f); - parts[i].vy += ptypes[t].diffusion*(rand()/(0.5f*RAND_MAX)-1.0f); - } + x = (int)(parts[i].x+0.5f); + y = (int)(parts[i].y+0.5f); - // interpolator -#if defined(WIN32) && !defined(__GNUC__) - mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy)); -#else - mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy)); -#endif - if(mv < ISTP) - { - parts[i].x += parts[i].vx; - parts[i].y += parts[i].vy; - ix = parts[i].x; - iy = parts[i].y; - } - else - { - dx = parts[i].vx*ISTP/mv; - dy = parts[i].vy*ISTP/mv; - ix = parts[i].x; - iy = parts[i].y; - while(1) - { - mv -= ISTP; - if(mv <= 0.0f) - { - // nothing found - parts[i].x += parts[i].vx; - parts[i].y += parts[i].vy; - ix = parts[i].x; - iy = parts[i].y; - break; - } - ix += dx; - iy += dy; - nx = (int)(ix+0.5f); - ny = (int)(iy+0.5f); - if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=WL_STREAM)) - { - parts[i].x = ix; - parts[i].y = iy; - break; - } - } - } - a = nt = 0; - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx4.0f) - t = parts[i].type = PT_DSTW; - if(t==PT_OIL && pv[y/CELL][x/CELL]<-6.0f) - t = parts[i].type = PT_GAS; - if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f) - t = parts[i].type = PT_OIL; - if(t==PT_DESL && pv[y/CELL][x/CELL]>12.0f) - { - t = parts[i].type = PT_FIRE; - parts[i].life = rand()%50+120; - } - } - if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f) - t = parts[i].type = PT_OIL; - if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f) + if (x=XRES-CELL || y>=YRES-CELL || + (bmap[y/CELL][x/CELL] && + (bmap[y/CELL][x/CELL]==WL_WALL || + bmap[y/CELL][x/CELL]==WL_WALLELEC || + bmap[y/CELL][x/CELL]==WL_ALLOWAIR || + (bmap[y/CELL][x/CELL]==WL_DESTROYALL) || + (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) || + (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) || + (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) || + (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) || + (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2))) { - t = parts[i].type = PT_FIRE; - parts[i].life = rand()%50+120; - } - if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f) - t = parts[i].type = PT_OIL; - if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f) - t = parts[i].type = PT_BRMT; - if(t==PT_BMTL && pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1) - t = parts[i].type = PT_BRMT; - if(t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f) - t = parts[i].type = PT_STNE; - if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f) - t = parts[i].type = PT_BRMT; - if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f) - t = parts[i].type = PT_PSTS; - if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f) - t = parts[i].type = PT_PSTE; - if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f) - t = parts[i].type = PT_NONE; - if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f) - t = parts[i].type = PT_NONE; - if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f) - t = parts[i].type = PT_NONE; - if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f) - t = parts[i].type = PT_NONE; - if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f) - t = parts[i].type = PT_BRMT; - //if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f) - // t = parts[i].type = PT_BGLA; - if(t==PT_GLAS) - { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - if(parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) - { - parts[i].type = PT_BGLA; - } - } - if(t==PT_QRTZ) - { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - if(parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) - { - parts[i].type = PT_PQRT; - } - } - if(t==PT_ICEI && pv[y/CELL][x/CELL]>0.8f) - t = parts[i].type = PT_SNOW; - if(t==PT_PLUT && 1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000)) - { - t = PT_NEUT; - create_part(i, x, y, t); - } - if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) - { - t = PT_PHOT; - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[i].life = 680; - parts[i].ctype = 0x3FFFFFFF; - parts[i].vx = rr*cosf(rrr); - parts[i].vy = rr*sinf(rrr); - create_part(i, x, y, t); - } - if(t==PT_PSTE) - if(parts[i].temp>747.0f) - t = parts[i].type = PT_BRCK; - if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1) - { - nearp = nearest_part(i, PT_ETRD); - if(nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) - { - create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM); - t = parts[i].type = PT_ETRD; - parts[i].ctype = PT_NONE; - parts[i].life = 20; - parts[nearp].type = PT_SPRK; - parts[nearp].life = 9; - parts[nearp].ctype = PT_ETRD; - } - } + kill_part(i); + continue; + } + if (bmap[y/CELL][x/CELL]==WL_DETECT && emap[y/CELL][x/CELL]<8) + set_emap(x/CELL, y/CELL); - if(!legacy_enable) - { - int ctemp = pv[y/CELL][x/CELL]*2; - c_heat = 0.0f; - h_count = 0; - if(t==PT_ICEI && !parts[i].ctype) - parts[i].ctype = PT_WATR; - if(ptypes[t].hconduct>(rand()%250)&&!(parts[i].type==PT_HSWC&&parts[i].life!=10)) - { - for(nx=-1; nx<2; nx++) - { - for(ny=-1; ny<2; ny++) - { - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) - { - h_count++; - c_heat += parts[r>>8].temp; - } - } - } - } - pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+1); - for(nx=-1; nx<2; nx++) - { - for(ny=-1; ny<2; ny++) - { - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) - { - parts[r>>8].temp = parts[i].temp; - } - } - } - } - if(y-2 >= 0 && y-2 < YRES && ptypes[t].properties&TYPE_LIQUID){ - float swappage; - r = pmap[y-2][x]; - if(!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))){ - if(parts[i].temp>parts[r>>8].temp){ - swappage = parts[i].temp; - parts[i].temp = parts[r>>8].temp; - parts[r>>8].temp = swappage; - } + + vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vx; + vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vy; + + if (t==PT_GAS||t==PT_NBLE) + { + if (pv[y/CELL][x/CELL]<3.5f) + pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]); + if (y+CELL=pstates[t].btemp&&pstates[t].burn) - { - t = parts[i].type = pstates[t].burn; - if(t==PT_FIRE||t==PT_PLSM) - parts[i].life = rand()%50+120; - } - else if((pt<=pstates[t].stemp||(t==PT_LAVA&&(pt<=pstates[parts[i].ctype].ltemp)))&&pstates[t].solid) - { - if(t==PT_LAVA&&parts[i].ctype) - { - parts[i].life = 0; - if(parts[i].ctype==PT_THRM) - { - parts[i].tmp = 0; - parts[i].ctype = PT_BMTL; - } - if(parts[i].ctype==PT_PLUT) - { - parts[i].tmp = 0; - parts[i].ctype = PT_LAVA; - } - t = parts[i].type = parts[i].ctype; - parts[i].ctype = PT_NONE; + } + + if (!legacy_enable) + { + if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) { + float swappage; + r = pmap[y-2][x]; + if (!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))) { + if (parts[i].temp>parts[r>>8].temp) { + swappage = parts[i].temp; + parts[i].temp = parts[r>>8].temp; + parts[r>>8].temp = swappage; } - else if(pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp) + } + } + + c_heat = 0.0f; + h_count = 0; + if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250)) + { + for (j=0; j<8; j++) + { + surround_hconduct[j] = i; + r = surround[j]; + if ((r>>8)>=NPART || !r) + continue; + rt = r&0xFF; + if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10) + &&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG)) + &&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))) { + surround_hconduct[j] = r>>8; + c_heat += parts[r>>8].temp; + h_count++; + } + } + + pt = parts[i].temp = (c_heat+parts[i].temp)/(h_count+1); + for (j=0; j<8; j++) + { + parts[surround_hconduct[j]].temp = pt; + } + + s = 1; + if (pt>ptransitions[t].thv&&ptransitions[t].tht>-1) { + // particle type change due to high temperature + if (ptransitions[t].tht!=PT_NUM) + t = ptransitions[t].tht; + else if (t==PT_ICEI) { + if (parts[i].ctype&&parts[i].ctype!=PT_ICEI) { + if (ptransitions[parts[i].ctype].tlt==PT_ICEI&&pt<=ptransitions[parts[i].ctype].tlv) s = 0; + else { + t = parts[i].ctype; + parts[i].ctype = PT_NONE; + parts[i].life = 0; + } + } + else if (pt>274.0f) t = PT_WATR; + else s = 0; + } + else if (t==PT_SLTW) { + if (1>rand()%6) t = PT_SALT; + else t = PT_WTRV; + } + else s = 0; + } else if (pt-1) { + // particle type change due to low temperature + if (ptransitions[t].tlt!=PT_NUM) + t = ptransitions[t].tlt; + else if (t==PT_WTRV) { + if (pt<273.0f) t = PT_RIME; + else t = PT_DSTW; + } + else if (t==PT_LAVA) { + if (parts[i].ctype&&parts[i].ctype!=PT_LAVA) { + if (ptransitions[parts[i].ctype].tht==PT_LAVA&&pt>=ptransitions[parts[i].ctype].thv) s = 0; + else if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0; + else { + t = parts[i].ctype; + parts[i].ctype = PT_NONE; + if (t==PT_THRM) { + parts[i].tmp = 0; + t = PT_BMTL; + } + if (parts[i].ctype==PT_PLUT) + { + parts[i].tmp = 0; + t = parts[i].ctype = PT_LAVA; + } + } + } + else if (pt<973.0f) t = PT_STNE; + else s = 0; + } + else s = 0; + if (s) parts[i].life = 0; + } + else s = 0; + if (s) { // particle type change occurred + if (t==PT_ICEI||t==PT_LAVA) parts[i].ctype = parts[i].type; - t = parts[i].type = PT_ICEI; - } - else - { - parts[i].life = 0; - t = parts[i].type = pstates[t].solid; - } - } - else if((pt>=pstates[t].ltemp&&(pt<=pstates[t].gtemp||!pstates[t].gas)&&pstates[t].state==ST_SOLID&&pstates[t].liquid)||(t==PT_ICEI&&pt>pstates[parts[i].ctype].stemp)) - { - if(pstates[t].liquid==PT_LAVA) - { + if (ptypes[t].state==ST_GAS&&ptypes[parts[i].type].state!=ST_GAS) + pv[y/CELL][x/CELL] += 0.50f; + part_change_type(i,x,y,t); + if (t==PT_FIRE||t==PT_PLSM||t==PT_HFLM) + parts[i].life = rand()%50+120; + if (t==PT_LAVA) { + if (parts[i].ctype==PT_BRMT) parts[i].ctype = PT_BMTL; + else if (parts[i].ctype==PT_SAND) parts[i].ctype = PT_GLAS; + else if (parts[i].ctype==PT_BGLA) parts[i].ctype = PT_GLAS; + else if (parts[i].ctype==PT_PQRT) parts[i].ctype = PT_QRTZ; parts[i].life = rand()%120+240; - parts[i].ctype = (parts[i].type==PT_BRMT)?PT_BMTL:parts[i].type; - parts[i].ctype = (parts[i].ctype==PT_SAND)?PT_GLAS:parts[i].ctype; - parts[i].ctype = (parts[i].ctype==PT_BGLA)?PT_GLAS:parts[i].ctype; - parts[i].ctype = (parts[i].ctype==PT_PQRT)?PT_QRTZ:parts[i].ctype; - t = parts[i].type = pstates[t].liquid; } - else if(t==PT_ICEI&&parts[i].ctype) - { - t = parts[i].type = parts[i].ctype; - parts[i].ctype = PT_NONE; - } - else - { - t = parts[i].type = pstates[t].liquid; + if (t==PT_NONE) { + kill_part(i); + goto killed; } } - else if(pt-ctemp<=pstates[t].ltemp&&pstates[t].liquid&&pstates[t].state==ST_GAS) - { - t = parts[i].type = pstates[t].liquid; - } - else if(pt-ctemp>=pstates[t].gtemp&&(pstates[t].gas||parts[i].type==PT_LNTG)&&(pstates[t].state==ST_LIQUID||pstates[t].state==ST_SOLID)) - { - if(t==PT_SLTW&&1>rand()%6) - { - t = parts[i].type = PT_SALT; - } - else - { - if((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp) - { - t = parts[i].type = pstates[t].gas; - } - else{ - t = parts[i].type = pstates[t].gas; - pv[y/CELL][x/CELL] += 0.50f; - } - - if(t==PT_FIRE) - parts[i].life = rand()%50+120; - if(t==PT_HFLM) - parts[i].life = rand()%50+120; - } - } - if(t==PT_URAN && pv[y/CELL][x/CELL]>0.0f) - { - float atemp = parts[i].temp + (-MIN_TEMP); - pt = parts[i].temp = (atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP; - } - if(t==PT_LAVA) - { - parts[i].life = restrict_flt((pt-700)/7, 0.0f, 400.0f); - if(parts[i].ctype==PT_THRM&&parts[i].tmp>0) + + pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); + if (t==PT_LAVA) { + parts[i].life = restrict_flt((parts[i].temp-700)/7, 0.0f, 400.0f); + if (parts[i].ctype==PT_THRM&&parts[i].tmp>0) { parts[i].tmp--; parts[i].temp = 3500; } - if(parts[i].ctype==PT_PLUT&&parts[i].tmp>0) + if (parts[i].ctype==PT_PLUT&&parts[i].tmp>0) { parts[i].tmp--; parts[i].temp = MAX_TEMP; } } - pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); - } - } - if(t==PT_PTCT&&parts[i].temp>295.0f) - { - pt = parts[i].temp -= 2.5f; - } - if(t==PT_NTCT&&parts[i].temp>295.0f) - { - pt = parts[i].temp -= 2.5f; - } - - if((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK) - { - nx = x % CELL; - if(nx == 0) - nx = x/CELL - 1; - else if(nx == CELL-1) - nx = x/CELL + 1; - else - nx = x/CELL; - ny = y % CELL; - if(ny == 0) - ny = y/CELL - 1; - else if(ny == CELL-1) - ny = y/CELL + 1; - else - ny = y/CELL; - if(nx>=0 && ny>=0 && nx=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) - { - t = parts[i].type = PT_NONE; - parts[r>>8].ctype = parts[r>>8].type; - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - } - else if((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF)) - { - pv[y/CELL][x/CELL] += 100.0f; - if(legacy_enable&&1>(rand()%200)) - { - parts[i].life = rand()%50+120; - t = parts[i].type = PT_FIRE; - } - else - { - t = parts[i].type = PT_NONE; - } - } - } - } - else if(t==PT_ICEI || t==PT_SNOW) - { - if(parts[i].ctype==PT_FRZW) - { - parts[i].temp -= 1.0f; - if(parts[i].temp<0) - parts[i].temp = 0; - - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000)) - { - t = parts[i].type = PT_SLTW; - parts[r>>8].type = PT_SLTW; - } - if(legacy_enable) - { - if(((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) - { - t = parts[i].type = PT_ICEI; - parts[r>>8].type = PT_ICEI; - } - if(t==PT_SNOW && ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) - t = parts[i].type = PT_WATR; - } - } - } - else if(t==PT_BMTL) { - if(parts[i].tmp>1) { - parts[i].tmp--; - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - rt =parts[r>>8].type; - if((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) - { - parts[r>>8].type=PT_BMTL; - parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; - } - } - } else if(parts[i].tmp==1 && 1>rand()%1000) { - parts[i].tmp = 0; - t = parts[i].type = PT_BRMT; - } - } - - else if(t==PT_IRON) { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || - ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || - ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || - ((r&0xFF) == PT_LO2))&& - (!(parts[i].life)) - ) - { - parts[i].type=PT_BMTL; - parts[i].tmp=(rand()/(RAND_MAX/10))+20; - } - } - } - else if((t==PT_SPRK||parts[i].type==PT_SPRK) && parts[i].ctype==PT_IRON) { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) || - ((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000)))) - { - parts[r>>8].type=PT_O2; - //parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20; - } - } - } - else if(t==PT_COAL) - { - if(parts[i].life<=0) { - t = PT_NONE; - kill_part(i); - create_part(-1, x, y, PT_FIRE); - goto killed; - } else if(parts[i].life < 100) { - parts[i].life--; - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - if((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if(parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if(parts[i].tmp<=0) { - t = PT_NONE; - kill_part(i); - r = create_part(-1, x, y, PT_BCOL); - goto killed; - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) - { - if(parts[i].life>100) { - parts[i].life = 99; - } - } - } - } - else if(t==PT_BCOL) - { - if(parts[i].life<=0) { - t = PT_NONE; - kill_part(i); - create_part(-1, x, y, PT_FIRE); - goto killed; - } else if(parts[i].life < 100) { - parts[i].life--; - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) - { - if(parts[i].life>100) { - parts[i].life = 99; - } - } - } - } - else if(t==PT_ARAY && parts[i].life==0){ - int colored =0; - for(nx=-1; nx<2; nx++){ - for(ny=-1; ny<2; ny++){ - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_SPRK){ - int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; - int nostop = (parts[r>>8].ctype==PT_INST)?1:0; - for (docontinue = 1, nxx = 0, nyy = 0, nxi = nx*-1, nyi = ny*-1; docontinue; nyy+=nyi, nxx+=nxi) { - if(!(x+nxi+nxx= 0 && y+nyi+nyy >= 0)){ - break; - } - r = pmap[y+nyi+nyy][x+nxi+nxx]; - if(!((r>>8)>=NPART)) { - if(!r){ - int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); - if(nr!=-1){ - if(destroy){ - parts[nr].tmp = 2; - parts[nr].life = 2; - }else - parts[nr].ctype = colored; - } - } else if(!destroy) { - if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0){ - if(nyy!=0 || nxx!=0){ - parts[r>>8].type = PT_BRAY; - parts[r>>8].life = 1020; - parts[r>>8].tmp = 1; - if(!parts[r>>8].ctype) - parts[r>>8].ctype = colored; - } - docontinue = 0; - } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1){ - parts[r>>8].life = 1020; - //docontinue = 1; - } - else if(parts[r>>8].type==PT_FILT){ - colored = parts[r>>8].ctype; - }else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY && parts[r>>8].type!=PT_WIFI && !(parts[r>>8].type==PT_SWCH && parts[r>>8].life>=10)) { - if(nyy!=0 || nxx!=0){ - create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); - } - if(!(nostop && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))){ - docontinue = 0; - } else { - docontinue = 1; - } - } - } else if(destroy) { - if(parts[r>>8].type==PT_BRAY){ - parts[r>>8].life = 1; - docontinue = 1; - } else if(parts[r>>8].type==PT_INWR || parts[r>>8].type==PT_ARAY || parts[r>>8].type==PT_WIFI || parts[r>>8].type==PT_FILT || (parts[r>>8].type==PT_SWCH && parts[r>>8].life>=10)) { - docontinue = 1; - } else { - docontinue = 0; - } - } - } - } - } - //parts[i].life = 4; - } - } } } - else if(t==PT_FUSE) - { - if(parts[i].life<=0) { - //t = parts[i].life = PT_NONE; - kill_part(i); - r = create_part(-1, x, y, PT_PLSM); - if(r!=-1) - parts[r].life = 50; - goto killed; - } else if (parts[i].life < 40) { - parts[i].life--; - if((rand()%100)==0) { - r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM); - if(r!=-1) - parts[r].life = 50; - } - } - if((pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if(parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if(parts[i].tmp<=0) { - //t = PT_NONE; - kill_part(i); - r = create_part(-1, x, y, PT_FSEP); - goto killed; - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))) - { - if(parts[i].life>40) { - parts[i].life = 39; - } - } - } - } - else if(t==PT_FSEP) - { - if(parts[i].life<=0) { - //t = PT_NONE; - kill_part(i); - r = create_part(-1, x, y, PT_PLSM); - if(r!=-1) - parts[r].life = 50; - goto killed; - } else if (parts[i].life < 40) { - parts[i].life--; - if((rand()%10)==0) { - r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_PLSM); - if(r!=-1) - parts[r].life = 50; - } - } - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15)) - { - if(parts[i].life>40) { - parts[i].life = 39; - } - } - } - } - else if(t==PT_NTCT||t==PT_PTCT||t==PT_INWR) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL && parts_avg(i, r>>8,PT_INSL)!=PT_INSL) - { - parts[i].temp = 473.0f; - } - } - } - else if(t==PT_PLNT) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_WATR && 1>(rand()%250)) - { - t = parts[i].type = PT_PLNT; - parts[r>>8].type = PT_PLNT; - parts[r>>8].life = 0; - } - else if((r&0xFF)==PT_LAVA && 1>(rand()%250)) - { - parts[i].life = 4; - t = parts[i].type = PT_FIRE; - } - else if((r&0xFF)==PT_SMKE && (1>rand()%250)) - { - parts[r>>8].type = PT_NONE; - parts[i].life = rand()%60 + 60; - } - else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE) - { - int nnx = rand()%3 -1; - int nny = rand()%3 -1; - if(x+nx+nnx>=0 && y+ny+nny>0 && - x+nx+nnx>8)>=NPART||pmap[y+ny+nny][x+nx+nnx]) - continue; - if(create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE)) - parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp; - } - } - //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000)) - //t = parts[i].type = PT_WATR; - } - if(parts[i].life==2) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART) - continue; - if(!r) - create_part(-1,x+nx,y+ny,PT_O2); + + if (ptypes[t].properties&PROP_LIFE) + { + parts[i].temp = restrict_flt(parts[i].temp-50.0f, MIN_TEMP, MAX_TEMP); + ISGOL=1; } - parts[i].life = 0; - } - } - else if(t==PT_VINE) - { - nx=(rand()%3)-1; - ny=(rand()%3)-1; - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART) - continue; - if(1>rand()%15) - parts[i].type=PT_PLNT; - else if(!r) + if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK) + { + nx = x % CELL; + if (nx == 0) + nx = x/CELL - 1; + else if (nx == CELL-1) + nx = x/CELL + 1; + else + nx = x/CELL; + ny = y % CELL; + if (ny == 0) + ny = y/CELL - 1; + else if (ny == CELL-1) + ny = y/CELL + 1; + else + ny = y/CELL; + if (nx>=0 && ny>=0 && nx>8].temp = parts[i].temp; - parts[i].type=PT_PLNT; - } - } - } - else if(t==PT_THRM) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) - { - if(1>(rand()%500)) { - t = parts[i].type = PT_LAVA; - parts[i].ctype = PT_BMTL; - pt = parts[i].temp = 3500.0f; - pv[y/CELL][x/CELL] += 50.0f; - } else { - t = parts[i].type = PT_LAVA; - parts[i].life = 400; - parts[i].ctype = PT_THRM; - pt = parts[i].temp = 3500.0f; - parts[i].tmp = 20; - } - } - //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000)) - //t = parts[i].type = PT_WATR; - } - } - else if(t==PT_WATR||t==PT_DSTW) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable) - { - t = parts[i].type = PT_WTRV; - } - else if((r&0xFF)==PT_SALT && 1>(rand()%250)) - { - t = parts[i].type = PT_SLTW; - parts[r>>8].type = PT_SLTW; - } - if((((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW)&&t==PT_DSTW) && 1>(rand()%500)) - { - t = parts[i].type = PT_WATR; - } - if(((r&0xFF)==PT_SLTW&&t==PT_DSTW) && 1>(rand()%500)) - { - t = parts[i].type = PT_SLTW; - } - if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||pt>12.0f) && 1>(rand()%500)) - { - parts[i].life = 4; - t = parts[i].type = PT_FIRE; - } - if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500)) - { - t = parts[i].type = PT_PSTE; - parts[r>>8].type = PT_NONE; - } - } - } - else if(t==PT_SLTW) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10) && legacy_enable) - { - t = parts[i].type = PT_SALT; - parts[r>>8].type = PT_WTRV; - } - else if((r&0xFF)==PT_SALT && 1>(rand()%10000)) - { - parts[r>>8].type = PT_NONE; - } - if((r&0xFF)==PT_PLNT&&5>(rand()%1000)) - parts[r>>8].type = PT_NONE; - if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500)) - { - parts[i].life = 4; - t = parts[i].type = PT_FIRE; - - } - } - } - else if(t==PT_WTRV) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000) && legacy_enable) - { - t = parts[i].type = PT_WATR; - parts[r>>8].type = PT_WATR; - } - - if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500)) - { - parts[i].life = 4; - t = parts[i].type = PT_FIRE; - - } - if(((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000) && legacy_enable) - { - t = parts[i].type = PT_WATR; - if(1>(rand()%1000)) - parts[r>>8].type = PT_WATR; - } - } - } - else if(t==PT_YEST) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable) - { - t = parts[i].type = PT_DYST; - } - } - } - else if(t==PT_ACID) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)!=PT_ACID) - { - if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD) - { - t = parts[i].type = PT_FIRE; - parts[i].life = 4; - parts[r>>8].type = PT_FIRE; - parts[r>>8].life = 4; - } - else if(((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50) - { - if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) - { - parts[i].life--; - parts[r>>8].type = PT_NONE; - } - } - else if (parts[i].life<=50) - { - parts[i].life = 0; - t = parts[i].type = PT_NONE; - } - } - } - } - else if(t==PT_NEUT) - { - rt = 3 + (int)pv[y/CELL][x/CELL]; - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) - { - parts[i].vx *= 0.995; - parts[i].vy *= 0.995; - } - if((r&0xFF)==PT_PLUT && rt>(rand()%1000)) - { - if(33>rand()%100) - { - create_part(r>>8, x+nx, y+ny, rand()%3 ? PT_LAVA : PT_URAN); - parts[r>>8].temp = MAX_TEMP; - if(parts[r>>8].type==PT_LAVA){ - parts[r>>8].tmp = 100; - parts[r>>8].ctype = PT_PLUT; - } - } - else - { - create_part(r>>8, x+nx, y+ny, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; - } - pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - fe ++; - } - if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000)) - { -#ifdef SDEUT - create_n_parts(parts[r>>8].life, x+nx, y+ny, parts[i].vx, parts[i].vy, PT_NEUT); -#else - create_part(r>>8, x+nx, y+ny, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; - if(parts[r>>8].life>0) - { - parts[r>>8].life --; - parts[r>>8].temp += (parts[r>>8].life*17); - pv[y/CELL][x/CELL] += 6.0f * CFDS; - - } - else - parts[r>>8].type = PT_NONE; -#endif - } - if((r&0xFF)==PT_GUNP && 15>(rand()%1000)) - parts[r>>8].type = PT_DUST; - if((r&0xFF)==PT_DYST && 15>(rand()%1000)) - parts[r>>8].type = PT_YEST; - if((r&0xFF)==PT_YEST) { - parts[r>>8].type = PT_DYST; - } - - if((r&0xFF)==PT_WATR && 15>(rand()%100)) - parts[r>>8].type = PT_DSTW; - if((r&0xFF)==PT_PLEX && 15>(rand()%1000)) - parts[r>>8].type = PT_GOO; - if((r&0xFF)==PT_NITR && 15>(rand()%1000)) - parts[r>>8].type = PT_DESL; - if((r&0xFF)==PT_PLNT && 5>(rand()%100)) - parts[r>>8].type = PT_WOOD; - if((r&0xFF)==PT_DESL && 15>(rand()%1000)) - parts[r>>8].type = PT_GAS; - if((r&0xFF)==PT_COAL && 5>(rand()%100)) - parts[r>>8].type = PT_WOOD; - if((r&0xFF)==PT_DUST && 5>(rand()%100)) - parts[r>>8].type = PT_FWRK; - if((r&0xFF)==PT_FWRK && 5>(rand()%100)) - parts[r>>8].ctype = PT_DUST; - if((r&0xFF)==PT_ACID && 5>(rand()%100)) - { - parts[r>>8].type = PT_ISOZ; - parts[r>>8].life = 0; - } - /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && - (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| - ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| - ptypes[parts[r>>8].type-1].menusection==SC_GAS|| - ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) - parts[r>>8].type--;*/ - } - } - else if(t==PT_PHOT) - { - rt = 3 + (int)pv[y/CELL][x/CELL]; - for(nx=0; nx<1; nx++) - for(ny=0; ny<1; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) - { - parts[i].vx *= 0.995; - parts[i].vy *= 0.995; - } - } - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) - { - parts[i].vx *= 0.90; - parts[i].vy *= 0.90; - parts[r>>8].type = PT_PHOT; - rrr = (rand()%360)*3.14159f/180.0f; - rr = (rand()%128+128)/127.0f; - parts[r>>8].life = 680; - parts[r>>8].ctype = 0x3FFFFFFF; - parts[r>>8].vx = rr*cosf(rrr); - parts[r>>8].vy = rr*sinf(rrr); - pv[y/CELL][x/CELL] -= 15.0f * CFDS; - } - if((r&0xFF)==PT_ISZS && 5>(rand()%2000)) - { - parts[i].vx *= 0.90; - parts[i].vy *= 0.90; - parts[r>>8].type = PT_PHOT; - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[r>>8].life = 680; - parts[r>>8].ctype = 0x3FFFFFFF; - parts[r>>8].vx = rr*cosf(rrr); - parts[r>>8].vy = rr*sinf(rrr); - pv[y/CELL][x/CELL] -= 15.0f * CFDS; - } - } - } - else if(t==PT_GLOW) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_WATR&&5>(rand()%2000)) - { - t = parts[i].type = PT_NONE; - parts[r>>8].type = PT_DEUT; - parts[r>>8].life = 10; - } - } - } - else if(t==PT_MORT) { - create_part(-1, x, y-1, PT_SMKE); - } - else if(ptypes[t].properties&PROP_LIFE) - { - if(parts[i].temp>0) - parts[i].temp -= 50.0f; - ISGOL=1; - } - else if(t==PT_LOVE) - ISLOVE=1; - else if(t==PT_LOLZ) - ISLOLZ=1; - else if(t==PT_GRAV) - ISGRAV=1; - else if(t==PT_SPNG) - { - if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r || parts[i].temp>374.0f) - continue; - if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1) - { - parts[i].life++; - parts[r>>8].type=PT_NONE; - } - } - } - else - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) - continue; - if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL|| - bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS)) - continue; - if((!r)&&parts[i].life>=1)//if nothing then create water - { - create_part(-1,x+nx,y+ny,PT_WATR); - parts[i].life--; - } - } - for( trade = 0; trade<9;trade ++) - { - nx = rand()%5-2; - ny = rand()%5-2; - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - int temp = parts[i].life - parts[r>>8].life; - if(temp ==1) + if (t!=PT_SPRK) { - parts[r>>8].life ++; - parts[i].life --; - trade = 9; - } - else if(temp>0) - { - parts[r>>8].life += temp/2; - parts[i].life -= temp/2; - trade = 9; - } - } - } - } - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_FIRE&&parts[i].life>0) - { - if(parts[i].life<=2) - parts[i].life --; - parts[i].life -= parts[i].life/3; - } - } - if(parts[i].temp>=374) - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) - continue; - if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID)) - continue; - if((!r)&&parts[i].life>=1)//if nothing then create steam - { - create_part(-1,x+nx,y+ny,PT_WTRV); - parts[i].life--; - parts[i].temp -= 40.0f; - } - } - } - else if(t==PT_FOG) - { - if(parts[i].temp>=373.15) - t = parts[i].type = PT_WTRV; - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN)) - { - t = parts[i].type = PT_RIME; - } - if(parts[r>>8].type==PT_SPRK) - { - parts[i].life += rand()%20; - } - } - } - else if(t==PT_RIME) - { - parts[i].vx = 0; - parts[i].vy = 0; - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_SPRK) - { - t = parts[i].type = PT_FOG; - parts[i].life = rand()%50 + 60; - } - else if(rt==PT_FOG&&parts[r>>8].life>0) - { - t = parts[i].type = PT_FOG; - parts[i].life = parts[r>>8].life; - } - } - } - else if(t==PT_DEUT) - { - int maxlife = ((10000/(parts[i].temp + 1))-1); - if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) - maxlife ++; - if(parts[i].life < maxlife) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r || (parts[i].life >=maxlife)) - continue; - if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1) - { - if((parts[i].life + parts[r>>8].life + 1) <= maxlife) + if (emap[ny][nx]==12 && !parts[i].life) { - parts[i].life += parts[r>>8].life + 1; - parts[r>>8].type=PT_NONE; + part_change_type(i,x,y,PT_SPRK); + parts[i].life = 4; + parts[i].ctype = t; + t = PT_SPRK; } } + else if (bmap[ny][nx]==WL_DETECT || bmap[ny][nx]==WL_EWALL || bmap[ny][nx]==WL_ALLOWLIQUID || bmap[ny][nx]==WL_WALLELEC || bmap[ny][nx]==WL_ALLOWALLELEC || bmap[ny][nx]==WL_EHOLE) + set_emap(nx, ny); + } + } + + + if ((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f) + { + parts[i].life = rand()%80+180; + parts[i].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[t].flammable/2), MIN_TEMP, MAX_TEMP); + t = PT_FIRE; + part_change_type(i,x,y,t); + pv[y/CELL][x/CELL] += 0.25f * CFDS; + } + + + s = 1; + if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) { + // particle type change due to high pressure + if (ptransitions[t].pht!=PT_NUM) + t = ptransitions[t].pht; + else if (t==PT_BMTL) { + if (pv[y/CELL][x/CELL]>2.5f) + t = PT_BRMT; + else if (pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1) + t = PT_BRMT; + else s = 0; + } + else s = 0; + } else if (pv[y/CELL][x/CELL]-1) { + // particle type change due to low pressure + if (ptransitions[t].plt!=PT_NUM) + t = ptransitions[t].plt; + else s = 0; + } + else s = 0; + if (s) { // particle type change occurred + part_change_type(i,x,y,t); + if (t==PT_FIRE) + parts[i].life = rand()%50+120; + if (t==PT_NONE) { + kill_part(i); + goto killed; + } + } + + if (ptypes[t].update_func) + { + if ((*(ptypes[t].update_func))(i,x,y,surround_space)) + continue; + } + if (legacy_enable) + update_legacy_all(i,x,y,surround_space); + +killed: + if (parts[i].type == PT_NONE) + continue; + + if (!parts[i].vx&&!parts[i].vy) + continue; + +#if defined(WIN32) && !defined(__GNUC__) + mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy)); +#else + mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy)); +#endif + if (mv < ISTP) + { + clear_x = x; + clear_y = y; + clear_xf = parts[i].x; + clear_yf = parts[i].y; + fin_xf = clear_xf + parts[i].vx; + fin_yf = clear_yf + parts[i].vy; + fin_x = (int)(fin_xf+0.5f); + fin_y = (int)(fin_yf+0.5f); + } + else + { + // interpolate to see if there is anything in the way + dx = parts[i].vx*ISTP/mv; + dy = parts[i].vy*ISTP/mv; + fin_xf = parts[i].x; + fin_yf = parts[i].y; + while (1) + { + mv -= ISTP; + fin_xf += dx; + fin_yf += dy; + fin_x = (int)(fin_xf+0.5f); + fin_y = (int)(fin_yf+0.5f); + if (mv <= 0.0f) + { + // nothing found + fin_xf = parts[i].x + parts[i].vx; + fin_yf = parts[i].y + parts[i].vy; + fin_x = (int)(fin_xf+0.5f); + fin_y = (int)(fin_yf+0.5f); + clear_xf = fin_xf-dx; + clear_yf = fin_yf-dy; + clear_x = (int)(clear_xf+0.5f); + clear_y = (int)(clear_yf+0.5f); + break; + } + if (fin_x=XRES-CELL || fin_y>=YRES-CELL || pmap[fin_y][fin_x] || (bmap[fin_y/CELL][fin_x/CELL] && bmap[fin_y/CELL][fin_x/CELL]!=WL_STREAM)) + { + // found an obstacle + clear_xf = fin_xf-dx; + clear_yf = fin_yf-dy; + clear_x = (int)(clear_xf+0.5f); + clear_y = (int)(clear_yf+0.5f); + break; + } + + } + } + + if ((t==PT_PHOT||t==PT_NEUT)) { + if (t == PT_PHOT) { + rt = pmap[fin_y][fin_x] & 0xFF; + lt = pmap[y][x] & 0xFF; + + r = eval_move(PT_PHOT, fin_x, fin_y, NULL); + if (((rt==PT_GLAS && lt!=PT_GLAS) || (rt!=PT_GLAS && lt==PT_GLAS)) && r) { + if (!get_normal_interp(REFRACT|t, parts[i].x, parts[i].y, parts[i].vx, parts[i].vy, &nrx, &nry)) { + kill_part(i); + continue; + } + + r = get_wavelength_bin(&parts[i].ctype); + if (r == -1) { + kill_part(i); + continue; + } + nn = GLASS_IOR - GLASS_DISP*(r-15)/15.0f; + nn *= nn; + nrx = -nrx; + nry = -nry; + if (rt==PT_GLAS && lt!=PT_GLAS) + nn = 1.0f/nn; + ct1 = parts[i].vx*nrx + parts[i].vy*nry; + ct2 = 1.0f - (nn*nn)*(1.0f-(ct1*ct1)); + if (ct2 < 0.0f) { + // total internal reflection + parts[i].vx -= 2.0f*ct1*nrx; + parts[i].vy -= 2.0f*ct1*nry; + fin_xf = parts[i].x; + fin_yf = parts[i].y; + fin_x = x; + fin_y = y; + } else { + // refraction + ct2 = sqrtf(ct2); + ct2 = ct2 - nn*ct1; + parts[i].vx = nn*parts[i].vx + ct2*nrx; + parts[i].vy = nn*parts[i].vy + ct2*nry; + } + } + } + if (try_move(i, x, y, fin_x, fin_y)) { + parts[i].x = fin_xf; + parts[i].y = fin_yf; + } else { + // reflection + parts[i].flags |= FLAG_STAGNANT; + if (t==PT_NEUT && 100>(rand()%1000)) + { + kill_part(i); + continue; + } + r = pmap[fin_y][fin_x]; + + // this should be replaced with a particle type attribute ("photwl" or something) + if ((r & 0xFF) == PT_PSCN) parts[i].ctype = 0x00000000; + if ((r & 0xFF) == PT_NSCN) parts[i].ctype = 0x00000000; + if ((r & 0xFF) == PT_SPRK) parts[i].ctype = 0x00000000; + if ((r & 0xFF) == PT_COAL) parts[i].ctype = 0x00000000; + if ((r & 0xFF) == PT_BCOL) parts[i].ctype = 0x00000000; + if ((r & 0xFF) == PT_PLEX) parts[i].ctype &= 0x1F00003E; + if ((r & 0xFF) == PT_NITR) parts[i].ctype &= 0x0007C000; + if ((r & 0xFF) == PT_NBLE) parts[i].ctype &= 0x3FFF8000; + if ((r & 0xFF) == PT_LAVA) parts[i].ctype &= 0x3FF00000; + if ((r & 0xFF) == PT_ACID) parts[i].ctype &= 0x1FE001FE; + if ((r & 0xFF) == PT_DUST) parts[i].ctype &= 0x3FFFFFC0; + if ((r & 0xFF) == PT_SNOW) parts[i].ctype &= 0x03FFFFFF; + if ((r & 0xFF) == PT_GOO) parts[i].ctype &= 0x3FFAAA00; + if ((r & 0xFF) == PT_PLNT) parts[i].ctype &= 0x0007C000; + if ((r & 0xFF) == PT_PLUT) parts[i].ctype &= 0x001FCE00; + if ((r & 0xFF) == PT_URAN) parts[i].ctype &= 0x003FC000; + + if (get_normal_interp(t, parts[i].x, parts[i].y, parts[i].vx, parts[i].vy, &nrx, &nry)) { + dp = nrx*parts[i].vx + nry*parts[i].vy; + parts[i].vx -= 2.0f*dp*nrx; + parts[i].vy -= 2.0f*dp*nry; + fin_x = (int)(parts[i].x + parts[i].vx + 0.5f); + fin_y = (int)(parts[i].y + parts[i].vy + 0.5f); + // cast as int then back to float for compatibility with existing saves + if (try_move(i, x, y, fin_x, fin_y)) { + parts[i].x = (float)fin_x; + parts[i].y = (float)fin_y; + } else { + kill_part(i); + continue; + } + } else { + if (t!=PT_NEUT) + kill_part(i); + continue; + } + if (!parts[i].ctype&&t!=PT_NEUT) { + kill_part(i); + continue; + } + } + } + else if (ptypes[t].falldown==0) + { + // gasses and solids (but not powders) + if (try_move(i, x, y, fin_x, fin_y)) { + parts[i].x = fin_xf; + parts[i].y = fin_yf; + } else { + // TODO + if (fin_x>x+ISTP) fin_x=x+ISTP; + if (fin_xy+ISTP) fin_y=y+ISTP; + if (fin_y=0 && y+ny>0 && x+nx>8)>=NPART || (parts[i].life<=maxlife)) - continue; - if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL|| - bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS)) - continue; - if((!r)&&parts[i].life>=1)//if nothing then create deut - { - create_part(-1,x+nx,y+ny,PT_DEUT); - parts[i].life--; - parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp; - parts[pmap[y+ny][x+nx]>>8].life = 0; - } - } - for( trade = 0; trade<4;trade ++) - { - nx = rand()%5-2; - ny = rand()%5-2; - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - int temp = parts[i].life - parts[r>>8].life; - if(temp ==1) - { - parts[r>>8].life ++; - parts[i].life --; - } - else if(temp>0) - { - parts[r>>8].life += temp/2; - parts[i].life -= temp/2; - } - } + parts[i].x = fin_xf; + parts[i].y = clear_yf; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; } - } - } - else if(t==PT_WARP) - { - for( trade = 0; trade<5;trade ++) - { - nx = rand()%3-1; - ny = rand()%3-1; - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200)) - { - parts[i].x = parts[r>>8].x; - parts[i].y = parts[r>>8].y; - parts[r>>8].x = x; - parts[r>>8].y = y; - parts[i].life += 4; - trade = 5; - } + parts[i].x = clear_xf; + parts[i].y = fin_yf; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; } - } - } - else if(t==PT_C5) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if((parts[r>>8].temp<100 && parts[r>>8].type!=PT_C5)||parts[r>>8].type==PT_HFLM) - { - if(1>rand()%6) - { - t = parts[i].type = PT_HFLM; - parts[r>>8].temp = parts[i].temp = 0; - parts[i].life = rand()%150+50; - pv[y/CELL][x/CELL] += 1.5; - } - } - } - } - else if(t==PT_BOMB) - { - int nb; - if(parts[i].tmp==1){ - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB){ - parts[i].type = PT_NONE; - goto killed; - } - } - } else if(parts[i].tmp==0){ - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB && parts[r>>8].type!=PT_DMND && parts[r>>8].type!=PT_CLNE && parts[r>>8].type!=PT_PCLN && parts[r>>8].type!=PT_BCLN){ - int rad = 8; - int nxi; - int nxj; - pmap[y][x] = 0; - for(nxj=-(rad+1); nxj<=(rad+1); nxj++) - for(nxi=-(rad+1); nxi<=(rad+1); nxi++) - if((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1){ - nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); - if(nb!=-1){ - parts[nb].tmp = 1; - parts[nb].life = 50; - parts[nb].temp = MAX_TEMP; - parts[nb].vx = rand()%20-10; - parts[nb].vy = rand()%20-10; - } - } - for(nxj=-rad; nxj<=rad; nxj++) - for(nxi=-rad; nxi<=rad; nxi++) - if((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) - if((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN){ - delete_part(x+nxi, y+nxj); - pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; - nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); - if(nb!=-1){ - parts[nb].tmp = 2; - parts[nb].life = 2; - parts[nb].temp = MAX_TEMP; - } - } - //create_parts(x, y, 9, 9, PT_BOMB); - //create_parts(x, y, 8, 8, PT_NONE); - parts[i].type = PT_NONE; - goto killed; - } - } - } - } - else if(t==PT_FWRK) - { - if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) - { - create_part(-1, x , y-1 , PT_FWRK); - r = pmap[y-1][x]; - if((r&0xFF)==PT_FWRK) - { - parts[r>>8].vy = rand()%8-22; - parts[r>>8].vx = rand()%20-rand()%20; - parts[r>>8].life=rand()%15+25; - t=parts[i].type=PT_NONE; - } - } - if(parts[i].life>1) - { - if(parts[i].life>=45&&parts[i].type==PT_FWRK) - parts[i].life=0; - } - if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0) - { - int q = (rand()%255+1); - int w = (rand()%255+1); - int e = (rand()%255+1); - for(nx=-1; nx<2; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx=rand()%8) + parts[i].x = clear_xf+r; + parts[i].y = fin_yf; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + else if (fin_y!=clear_y && try_move(i, x, y, clear_x-r, fin_y)) + { + parts[i].x = clear_xf-r; + parts[i].y = fin_yf; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y+r)) + { + parts[i].x = fin_xf; + parts[i].y = clear_yf+r; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + else if (fin_x!=clear_x && try_move(i, x, y, fin_x, clear_y-r)) + { + parts[i].x = fin_xf; + parts[i].y = clear_yf-r; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + else if (ptypes[t].falldown>1 && (parts[i].vy>fabs(parts[i].vx) || gravityMode==2)) + { + s = 0; + if (!rt || nt) //nt is if there is an something else besides the current particle type, around the particle + rt = 30;//slight less water lag, although it changes how it moves a lot + else + rt = 10; + for (j=clear_x+r; j>=0 && j>=clear_x-rt && j>8].type==PT_DUST) + parts[i].x = clear_xf+(j-clear_x); + parts[i].y = fin_yf; + x = j; + y = fin_y; + s = 1; + break; + } + if (try_move(i, x, y, j, clear_y)) + { + parts[i].x = clear_xf+(j-clear_x); + x = j; + s = 1; + break; + } + if ((pmap[y][j]&255)!=t || (bmap[y/CELL][j/CELL] && bmap[y/CELL][j/CELL]!=WL_STREAM)) + break; + } + if (parts[i].vy>0) + r = 1; + else + r = -1; + if (s) + for (j=clear_y+r; j>=0 && j=clear_y-rt && j>8].vy = -(rand()%10-1); - parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; - parts[a>>8].life= rand()%37+18; - parts[a>>8].tmp=q; - parts[a>>8].flags=w; - parts[a>>8].ctype=e; - parts[a>>8].temp= rand()%20+6000; + parts[i].y = clear_yf+(j-clear_y); + break; + } + if ((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=WL_STREAM)) + { + s = 0; + break; } } + else if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + // if interpolation was done and haven't yet moved, try moving to last clear position + parts[i].x = clear_xf; + parts[i].y = clear_yf; } + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + if (!s) + parts[i].flags |= FLAG_STAGNANT; } - t=parts[i].type=PT_NONE; + else + { + if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + // if interpolation was done, try moving to last clear position + parts[i].x = clear_xf; + parts[i].y = clear_yf; + } + parts[i].flags |= FLAG_STAGNANT; + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + } + } } - } - else if(t==PT_LCRY) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_SPRK) - { - if(parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = 10; - } - else if(parts[r>>8].ctype==PT_NSCN) - { - parts[i].life = 9; - } - } - if(rt==PT_LCRY) - { - if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - { - parts[i].life = 9; - } - else if(parts[i].life==0&&parts[r>>8].life==10) - { - parts[i].life = 10; - } - } - } - } - else if(t==PT_PIPE) - { - if(!parts[i].ctype && parts[i].life<=10) - { - if(parts[i].temp<272.15) - { - if(parts[i].temp>173.25&&parts[i].temp<273.15) - { - parts[i].ctype = 2; - parts[i].life = 0; - } - if(parts[i].temp>73.25&&parts[i].temp<=173.15) - { - parts[i].ctype = 3; - parts[i].life = 0; - } - if(parts[i].temp>=0&&parts[i].temp<=73.15) - { - parts[i].ctype = 4; - parts[i].life = 0; - } - } - else - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART ) - continue; - if(!r) - create_part(-1,x+nx,y+ny,PT_BRCK); - } - if(parts[i].life==1) - parts[i].ctype = 1; - } - } - if(parts[i].ctype==1) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) - continue; - if(!r&&!parts[i].life) - parts[i].life=50; - } - if(parts[i].life==2) - { - parts[i].ctype = 2; - parts[i].life = 6; - } - } - if(parts[i].ctype>1) - for( q = 0;q<3;q++) - for( ctype = 2;ctype<5;ctype++) - { - if(parts[i].ctype==ctype) + nx = (int)(parts[i].x+0.5f); + ny = (int)(parts[i].y+0.5f); + if (nx=XRES-CELL || ny=YRES-CELL) { - if(parts[i].life==3) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1) - { - parts[r>>8].ctype = (((ctype)%3)+2);//reverse - parts[r>>8].life = 6; - } - } - } - else - { - nx = rand()%3-1; - ny = rand()%3-1; - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) - continue; - else if(!r&&parts[i].tmp!=0) - { - if(create_part(-1,x+nx,y+ny,parts[i].tmp)) - { - parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp;//pipe saves temp and life now - parts[pmap[y+ny][x+nx]>>8].life = parts[i].flags; - } - parts[i].tmp = 0; - continue; - } - else if(!r) - continue; - else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)) - { - parts[i].tmp = parts[r>>8].type; - parts[i].temp = parts[r>>8].temp; - parts[i].flags = parts[r>>8].life; - parts[r>>8].type = PT_NONE; - } - else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0) - { - parts[r>>8].tmp = parts[i].tmp; - parts[r>>8].temp = parts[i].temp; - parts[r>>8].flags = parts[i].flags; - parts[i].tmp = 0; - } - } - } + kill_part(i); + continue; } - } - } - else if(t==PT_FRZZ) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_WATR&&5>rand()%100) - { - parts[r>>8].type=PT_FRZW; - parts[r>>8].life = 100; - t = parts[i].type = PT_NONE; - } - - } - } - else if(t==PT_FRZW) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_WATR&&5>rand()%70) - { - parts[r>>8].type=PT_FRZW; - } - } - if(parts[i].life==0&&13>rand()%2500) - { - t = parts[i].type=PT_ICEI; - parts[i].ctype=PT_FRZW; - parts[i].temp -= 200.0f; - if(parts[i].temp<0) - parts[i].temp = 0; - } - else if((100-(parts[i].life))>rand()%50000) - { - t = parts[i].type=PT_ICEI; - parts[i].ctype=PT_FRZW; - parts[i].temp -= 200.0f; - if(parts[i].temp<0) - parts[i].temp = 0; - } - } - else if(t==PT_INST) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life==0&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) - { - flood_parts(x,y,PT_SPRK,PT_INST,-1);//spark the wire - //parts[r>>8].type=parts[r>>8].ctype; - } - } - } - else if(t==PT_PRTI) - { - int 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 =0 && y+ny>0 && - x+nx>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; - portalctype[parts[i].tmp][count-1][nnx] = parts[r>>8].ctype; - if(parts[r>>8].type==PT_SPRK) - parts[r>>8].type = parts[r>>8].ctype; - else - parts[r>>8].type = PT_NONE; - break; - } - } - } - else if(t==PT_PRTO) - { - int 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 -2; ny--) - for(nx=1; nx>-2; nx--) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || r) - continue; - if(!r) - { - for( nnx =0 ;nnx<80;nnx++) - { - int randomness = count + rand()%3-1; - if(randomness<1) - randomness=1; - if(randomness>8) - randomness=8; - if(portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better - { - create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x+1,y-1,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x,y-1,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x,y+1,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x-1,y+1,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x-1,y,portal[parts[i].tmp][randomness-1][nnx]); - create_part(-1,x-1,y-1,portal[parts[i].tmp][randomness-1][nnx]); - portal[parts[i].tmp][randomness-1][nnx] = 0; - portaltemp[parts[i].tmp][randomness-1][nnx] = 0; - break; - } - else if(portal[parts[i].tmp][randomness-1][nnx]) - { - create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]); - parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx]; - parts[pmap[y+ny][x+nx]>>8].ctype = portalctype[parts[i].tmp][randomness-1][nnx]; - portal[parts[i].tmp][randomness-1][nnx] = 0; - portaltemp[parts[i].tmp][randomness-1][nnx] = 0; - portalctype[parts[i].tmp][randomness-1][nnx] = 0; - break; - } - } - } - } - } - else if(t==PT_WIFI) - { - int temprange = 100; - for( temp = 0; temp < MAX_TEMP; temp += temprange) - if(parts[i].temp-73.15>temp&&parts[i].temp-73.15 =0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0]) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].ctype = PT_NSCN; - parts[r>>8].life = 4; - } - else if(parts[r>>8].type==PT_PSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp][0]) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].ctype = PT_PSCN; - parts[r>>8].life = 4; - } - else if(parts[r>>8].type==PT_INWR&&parts[r>>8].life==0 && wireless[parts[i].tmp][0]) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].ctype = PT_INWR; - parts[r>>8].life = 4; - } - else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp][0]) - { - //parts[r>>8].type = parts[r>>8].ctype; - wireless[parts[i].tmp][0] = 1; - wireless[parts[i].tmp][1] = 1; - ISWIRE = 1; - } - } - } - else if(t==PT_PCLN) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_SPRK) - { - if(parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = 10; - } - else if(parts[r>>8].ctype==PT_NSCN) - { - parts[i].life = 9; - } - } - if(rt==PT_PCLN) - { - if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - { - parts[i].life = 9; - } - else if(parts[i].life==0&&parts[r>>8].life==10) - { - parts[i].life = 10; - } - } - } - } - else if(t==PT_HSWC) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_SPRK) - { - if(parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = 10; - } - else if(parts[r>>8].ctype==PT_NSCN) - { - parts[i].life = 9; - } - } - if(rt==PT_HSWC) - { - if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - { - parts[i].life = 9; - } - else if(parts[i].life==0&&parts[r>>8].life==10) - { - parts[i].life = 10; - } - } - } - } - else if(t==PT_PUMP) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_SPRK) - { - if(parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = 10; - } - else if(parts[r>>8].ctype==PT_NSCN) - { - parts[i].life = 9; - } - } - if(rt==PT_PUMP) - { - if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - { - parts[i].life = 9; - } - else if(parts[i].life==0&&parts[r>>8].life==10) - { - parts[i].life = 10; - } - } - } - } - else if(t==PT_SHLD1) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) - for( nnx=-1;nnx<2;nnx++) - for( nny=-1;nny<2;nny++) - { - if(7>rand()%200&&parts[i].life==0) - { - t = parts[i].type = PT_SHLD2; - parts[i].life = 7; - } - else if(!pmap[y+ny+nny][x+nx+nnx]) - { - create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); - //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10) - { - t = parts[i].type=PT_SHLD2; - parts[i].life = 7; - } - } - } - else if(t==PT_SHLD2) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART) - continue; - if(!r && parts[i].life>0) - create_part(-1,x+nx,y+ny,PT_SHLD1); - if(!r) - continue; - else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) - for( nnx=-1;nnx<2;nnx++) - for( nny=-1;nny<2;nny++) - { - if(3>rand()%200&&parts[i].life==0) - { - t = parts[i].type = PT_SHLD3; - parts[i].life = 7; - } - else if(!pmap[y+ny+nny][x+nx+nnx]) - { - create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); - parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10) - { - t = parts[i].type=PT_SHLD3; - parts[i].life = 7; - } - } - } - else if(t==PT_SHLD3) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART) - continue; - if(!r) - { - if(1>rand()%2500) - { - create_part(-1,x+nx,y+ny,PT_SHLD1); - parts[pmap[y+ny][x+nx]>>8].life=7; - t = parts[i].type = PT_SHLD2; - } - else - continue; - - } - if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3) - { - parts[r>>8].type = PT_SHLD2; - parts[r>>8].life=7; - } - else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) - for( nnx=-1;nnx<2;nnx++) - for( nny=-1;nny<2;nny++) - { - if(2>rand()%3000&&parts[i].life==0) - { - t = parts[i].type = PT_SHLD4; - parts[i].life = 7; - } - else if(!pmap[y+ny+nny][x+nx+nnx]) - { - create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); - parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - } - } - else if(t==PT_SHLD4) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART) - continue; - if(!r) - { - if(1>rand()%5500) - { - create_part(-1,x+nx,y+ny,PT_SHLD1); - parts[pmap[y+ny][x+nx]>>8].life=7; - t = parts[i].type = PT_SHLD2; - } - else - continue; - - } - if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3) - { - parts[r>>8].type = PT_SHLD3; - parts[r>>8].life = 7; - } - else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) - for( nnx=-1;nnx<2;nnx++) - for( nny=-1;nny<2;nny++) - { - if(!pmap[y+ny+nny][x+nx+nnx]) - { - create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); - parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - } - } - else if(t==PT_AMTR) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO) - { - t = parts[i].life++; - if(parts[i].life==3) - { - parts[i].type = PT_NONE; - kill_part(i); - goto killed; - } - parts[r>>8].life = 0; - parts[r>>8].type = PT_NONE; - kill_part(r>>8); - if(2>(rand()/(RAND_MAX/100))) - create_part(-1, x+nx, y+ny, PT_PHOT); - pv[y/CELL][x/CELL] -= 5.0f; - //goto killed; - } - } - } - else if(t==PT_SING) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1) - { - if(parts[r>>8].type==PT_SING && parts[r>>8].life >10) - { - if(parts[i].life+parts[r>>8].life > 255) - continue; - parts[i].life += parts[r>>8].life; - } - else - { - if(parts[i].life+3 > 255) - { - if(parts[r>>8].type!=PT_SING && 1>rand()%100) - { - parts[r>>8].type = PT_SING; - parts[r>>8].life = rand()%50+60; - } - continue; - } - parts[i].life += 3; - } - parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); - parts[r>>8].type=PT_NONE; - } - } - } - else if(t==PT_BOYL) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_WATR && 1>rand()%30) - { - parts[r>>8].type = PT_FOG; - } - if(parts[r>>8].type==PT_O2 && 1>rand()%9) - { - parts[r>>8].type = PT_NONE; - t = parts[i].type = PT_WATR; - pv[y/CELL][x/CELL] += 4.0; - } - } - } - else if(t==PT_FIRW) { - if(parts[i].tmp==0) { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) - { - parts[i].tmp = 1; - parts[i].life = rand()%50+60; - } - } - } - else if(parts[i].tmp==1) { - if(parts[i].life==0) { - parts[i].tmp=2; - } else { - float newVel = parts[i].life/25; - parts[i].flags = parts[i].flags&0xFFFFFFFE; - if((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) { - parts[i].vy = -newVel; - ly-=newVel; - iy-=newVel; - } - } - } - else if(parts[i].tmp==2) { - int col = rand()%200+4; - for(nx=-2; nx<3; nx++) { - for(ny=-2; ny<3; ny++) { - if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) - continue; - if(parts[r>>8].type==PT_FIRW) { - parts[r>>8].vx = (rand()%3-1)*tmul; - parts[r>>8].vy = (rand()%3-1)*tmul; - parts[r>>8].tmp = col; - parts[r>>8].life = rand()%100+100; - parts[r>>8].temp = 6000.0f; - } - } - } - } - pv[y/CELL][x/CELL] += 20; - kill_part(i); - goto killed; - } else if(parts[i].tmp>=3) { - if(parts[i].life<=0) { - kill_part(i); - goto killed; - } - } - } - else if(t==PT_BTRY) - { - rt = 3 + (int)pv[y/CELL][x/CELL]; - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - if(parts_avg(i,r>>8,PT_INSL) != PT_INSL) - { - if((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(nx)+abs(ny) < 4) - { - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - parts[r>>8].type = PT_SPRK; - } - } - } - } else if(t==PT_SWCH) - { - rt = 3 + (int)pv[y/CELL][x/CELL]; - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - rt = parts[r>>8].type; - - if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) - { - if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - { - parts[i].life = 9; - } - else if(parts[i].life==0&&parts[r>>8].life==10) - { - parts[i].life = 10; - } - } - else if(parts[r>>8].type == PT_SPRK && parts[r>>8].ctype==PT_SWCH && parts[i].life<10 && parts[i].life>0 &&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) - { - parts[r>>8].type = parts[r>>8].ctype; - parts[r>>8].life = 9; - } - } - if(parts[i].life==10 && (!(pmap[y-1][x-1]&0xFF) && ((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) && !(pmap[y-1][x+1]&0xFF) && ((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2))) - { - parts[i].life = 9; } - else if(parts[i].life<=5 && (!(pmap[y-1][x-1]&0xFF) && (((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) || ((pmap[y+1][x]&0xFF)==PT_BRAY&&parts[pmap[y+1][x]>>8].tmp==2)) && !(pmap[y-1][x+1]&0xFF) && (((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2) || ((pmap[y][x-1]&0xFF)==PT_BRAY&&parts[pmap[y][x-1]>>8].tmp==2)))) - { - parts[i].life = 14; - } - } - if(t==PT_SWCH) - if((parts[i].life>0&&parts[i].life<10)|| parts[i].life > 10) - { - parts[i].life--; - } - if(t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10))) - { - for(nx=-2; nx<3; nx++) - for(ny=-2; ny<3; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r) - continue; - if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=WL_STREAM) - continue; - rt = parts[r>>8].type; - if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) && - !(t==PT_PHOT && rt==PT_INSL) && - (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR && rt!=PT_QRTZ)) && !(rt==PT_SPNG && parts[r>>8].life>0) && - ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000)) - { - parts[r>>8].type = PT_FIRE; - parts[r>>8].temp = ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2); - parts[r>>8].life = rand()%80+180; - if(ptypes[rt].explosive) - pv[y/CELL][x/CELL] += 0.25f * CFDS; - continue; - } - lpv = (int)pv[(y+ny)/CELL][(x+nx)/CELL]; - if(lpv < 1) lpv = 1; - if(legacy_enable) - { - if(t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && - ptypes[rt].meltable*lpv>(rand()%1000)) - { - if(t!=PT_LAVA || parts[i].life>0) - { - parts[r>>8].ctype = (parts[r>>8].type==PT_BRMT)?PT_BMTL:parts[r>>8].type; - parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype; - parts[r>>8].type = PT_LAVA; - parts[r>>8].life = rand()%120+240; - } - else - { - parts[i].life = 0; - t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; - parts[i].ctype = PT_NONE;//rt; - goto killed; - } - } - if(t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW)) - { - parts[r>>8].type = PT_WATR; - if(t==PT_FIRE) - { - parts[i].x = lx; - parts[i].y = ly; - kill_part(i); - goto killed; - } - if(t==PT_LAVA) - { - parts[i].life = 0; - t = parts[i].type = PT_STNE; - goto killed; - } - } - if(t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)) - { - kill_part(r>>8); - if(t==PT_FIRE) - { - parts[i].x = lx; - parts[i].y = ly; - kill_part(i); - goto killed; - } - if(t==PT_LAVA) - { - parts[i].life = 0; - t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; - parts[i].ctype = PT_NONE; - goto killed; - } - } - } - //Check if there is a SWCH that is currently covered with SPRK - //If so check if the current SPRK is covering a NSCN - //If so turn the SPRK that covers the SWCH back into SWCH and turn it off - if(rt==PT_SPRK && parts[r>>8].ctype == PT_SWCH && t==PT_SPRK) - { - pavg = parts_avg(r>>8, i,PT_INSL); - if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL) - { - parts[r>>8].type = PT_SWCH; - parts[r>>8].ctype = PT_NONE; - parts[r>>8].life = 9; - } - } - pavg = parts_avg(i, r>>8,PT_INSL); - if(rt==PT_SWCH && t==PT_SPRK) - { - pavg = parts_avg(r>>8, i,PT_INSL); - if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL && parts[r>>8].life<10) - parts[r>>8].life = 10; - if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL) - parts[r>>8].life = 9; - if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life == 10&&pavg != PT_INSL) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].ctype = PT_SWCH; - parts[r>>8].life = 4; - } - } - pavg = parts_avg(i, r>>8,PT_INSL); - if(pavg != PT_INSL) - { - if(t==PT_SPRK && (ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN))&&!(parts[i].ctype==PT_INST&&rt!=PT_NSCN) ) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - if(parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&!(rt==PT_LRBD||rt==PT_RBDM||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) - parts[r>>8].temp = parts[r>>8].temp+10.0f; - } - } - if(t==PT_SPRK && rt==PT_NTCT && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].temp>373.0f))&&pavg != PT_INSL) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - } - } - if(t==PT_SPRK && rt==PT_PTCT && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].temp<373.0f))&&pavg != PT_INSL) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - } - } - if(t==PT_SPRK && rt==PT_INWR && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - } - } - if(t==PT_SPRK && rt==PT_QRTZ && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].temp<173.15||pv[(y+ny)/CELL][(x+nx)/CELL]>8)) - { - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - } - } - if(t==PT_SPRK && rt==PT_WATR && parts[r>>8].life==0 && - (parts[i].life<2 || ((r>>8)>8].type = PT_SPRK; - parts[r>>8].life = 6; - parts[r>>8].ctype = rt; - } - if(t==PT_SPRK && rt==PT_SLTW && parts[r>>8].life==0 && - (parts[i].life<2 || ((r>>8)>8].type = PT_SPRK; - parts[r>>8].life = 5; - parts[r>>8].ctype = rt; - } - if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==5) - { - if(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN) - { - t = parts[i].type = PT_ETRD; - parts[i].ctype = PT_NONE; - parts[i].life = 20; - parts[r>>8].type = PT_SPRK; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - } - } - - if(t==PT_SPRK&&parts[i].ctype==PT_NBLE&&parts[i].life<=1) - { - parts[i].life = rand()%150+50; - parts[i].type = PT_PLSM; - parts[i].ctype = PT_NBLE; - parts[i].temp = 3500; - pv[y/CELL][x/CELL] += 1; - } - if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=0) - { - parts[i].type = PT_SWCH; - parts[i].life = 14; - } - } - } -killed: - if(parts[i].type == PT_NONE) - continue; - } - if(t==PT_STKM) - { - float dt = 0.9;///(FPSB*FPSB); //Delta time in square - //Tempirature handling - if(parts[i].temp<243) - parts[i].life -= 1; - if((parts[i].temp<309.6f) && (parts[i].temp>=243)) - parts[i].temp += 1; - - if (isplayer) { //Already a stickman in the simulation - death = 1; - parts[i].type = PT_NONE; - } - - //Death - if(parts[i].life<1 || death == 1 || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... - { - for(r=-2; r<=1; r++) - { - create_part(-1, x+r, y-2, player[2]); - create_part(-1, x+r+1, y+2, player[2]); - create_part(-1, x-2, y+r+1, player[2]); - create_part(-1, x+2, y+r, player[2]); - } - kill_part(i); //Kill him - goto killed; - } - - parts[i].vy += -0.7*dt; //Head up! - - //Verlet integration - pp = 2*player[3]-player[5]+player[19]*dt*dt;; - player[5] = player[3]; - player[3] = pp; - pp = 2*player[4]-player[6]+player[20]*dt*dt;; - player[6] = player[4]; - player[4] = pp; - - pp = 2*player[7]-player[9]+player[21]*dt*dt;; - player[9] = player[7]; - player[7] = pp; - pp = 2*player[8]-player[10]+(player[22]+1)*dt*dt;; - player[10] = player[8]; - player[8] = pp; - - pp = 2*player[11]-player[13]+player[23]*dt*dt;; - player[13] = player[11]; - player[11] = pp; - pp = 2*player[12]-player[14]+player[24]*dt*dt;; - player[14] = player[12]; - player[12] = pp; - - pp = 2*player[15]-player[17]+player[25]*dt*dt;; - player[17] = player[15]; - player[15] = pp; - pp = 2*player[16]-player[18]+(player[26]+1)*dt*dt;; - player[18] = player[16]; - player[16] = pp; - - //Setting acceleration to 0 - player[19] = 0; - player[20] = 0; - - player[21] = 0; - player[22] = 0; - - player[23] = 0; - player[24] = 0; - - player[25] = 0; - player[26] = 0; - - //Go left - if (((int)(player[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) - { - if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) - { - if (pmap[(int)(player[8]-1)][(int)(player[7])]) - { - player[21] = -3; - player[22] = -2; - player[19] = -2; - } - - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[25] = -3; - player[26] = -2; - player[23] = -2; - } - } - else - { - if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids - { - player[21] = -1; - player[22] = -1; - player[19] = -1; - } - - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[25] = -1; - player[26] = -1; - player[23] = -1; - } - } - } - - //Go right - if (((int)(player[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) - { - if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) - { - if (pmap[(int)(player[8]-1)][(int)(player[7])]) - { - player[21] = 3; - player[22] = -2; - player[19] = 2; - } - - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[25] = 3; - player[26] = -2; - player[23] = 2; - } - } - else - { - if (pmap[(int)(player[8]-1)][(int)(player[7])]) - { - player[21] = 1; - player[22] = -1; - player[19] = 1; - } - - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[25] = 1; - player[26] = -1; - player[23] = 1; - } - - } - } - - //Jump - if (((int)(player[0])&0x04) == 0x04 && (pstates[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS)) - { - if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])]) - { - parts[i].vy = -5; - player[22] -= 1; - player[26] -= 1; - } - } - - //Charge detector wall if foot inside - if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT) - set_emap((int)player[7]/CELL, (int)player[8]/CELL); - if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT) - set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL); - - //Searching for particles near head - for(nx = -2; nx <= 2; nx++) - for(ny = 0; ny>=-2; ny--) - { - if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART) - continue; - if(ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT) - { - player[2] = pmap[ny+y][nx+x]&0xFF; //Current element - } - if((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP - { - if(parts[i].life<=95) - parts[i].life += 5; - else - parts[i].life = 100; - kill_part(pmap[ny+y][nx+x]>>8); - } - - if((pmap[ny+y][nx+x]&0xFF) == PT_NEUT) - { - parts[i].life -= (102-parts[i].life)/2; - kill_part(pmap[ny+y][nx+x]>>8); - } - if(bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN) - player[2] = SPC_AIR; - } - - //Head position - nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01); - ny = y - 3*(player[1] == 0); - - //Spawn - if(((int)(player[0])&0x08) == 0x08) - { - ny -= 2*(rand()%2)+1; - r = pmap[ny][nx]; - if(!((r>>8)>=NPART)) - { - if(pstates[r&0xFF].state == ST_SOLID) - { - create_part(-1, nx, ny, PT_SPRK); - } - else - { - if(player[2] == SPC_AIR) - create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR); - else - create_part(-1, nx, ny, player[2]); - - r = pmap[ny][nx]; - if( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR) - parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); - if(((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT) - { - int random = abs(rand()%3-1)*3; - if (random==0) - { - parts[r>>8].life = 0; - parts[r>>8].type = PT_NONE; - } - else - { - parts[r>>8].vy = 0; - parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random; - } - } - - } - } - } - - //Simulation of joints - d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance - player[7] -= (player[3]-player[7])*d; - player[8] -= (player[4]-player[8])*d; - player[3] += (player[3]-player[7])*d; - player[4] += (player[4]-player[8])*d; - - d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5; - player[15] -= (player[11]-player[15])*d; - player[16] -= (player[12]-player[16])*d; - player[11] += (player[11]-player[15])*d; - player[12] += (player[12]-player[16])*d; - - d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (player[3]-parts[i].x)*d; - parts[i].vy -= (player[4]-parts[i].y)*d; - player[3] += (player[3]-parts[i].x)*d; - player[4] += (player[4]-parts[i].y)*d; - - d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (player[11]-parts[i].x)*d; - parts[i].vy -= (player[12]-parts[i].y)*d; - player[11] += (player[11]-parts[i].x)*d; - player[12] += (player[12]-parts[i].y)*d; - - //Side collisions checking - for(nx = -3; nx <= 3; nx++) - { - r = pmap[(int)(player[16]-2)][(int)(player[15]+nx)]; - if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID) - player[15] -= nx; - - r = pmap[(int)(player[8]-2)][(int)(player[7]+nx)]; - if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID) - player[7] -= nx; - } - - //Collision checks - for(ny = -2-(int)parts[i].vy; ny<=0; ny++) - { - r = pmap[(int)(player[8]+ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-) - - //For left leg - if (r && (r&0xFF)!=PT_STKM) - { - if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks - { - if(parts[i].y<(player[8]-10)) - parts[i].vy = 1*dt; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5*dt; - } - else - { - if(pstates[r&0xFF].state != ST_GAS) - { - player[8] += ny-1; - parts[i].vy -= 0.5*parts[i].vy*dt; - } - } - player[9] = player[7]; - } - - r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)]; - - //For right leg - if (r && (r&0xFF)!=PT_STKM) - { - if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) - { - if(parts[i].y<(player[16]-10)) - parts[i].vy = 1*dt; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5*dt; - } - else - { - if(pstates[r&0xFF].state != ST_GAS) - { - player[16] += ny-1; - parts[i].vy -= 0.5*parts[i].vy*dt; - } - } - player[17] = player[15]; - } - - //If it falls too fast - if (parts[i].vy>=30) - { - parts[i].y -= (10+ny)*dt; - parts[i].vy = -10*dt; - } - - } - - //Keeping legs distance - if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1) - { - player[21] -= 0.2; - player[25] += 0.2; - } - - if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1) - { - player[19] -= 0.2; - player[23] += 0.2; - } - - //If legs touch something - r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)]; - if((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) - { - parts[i].life -= 2; - player[26] -= 1; - } - } - - if ((r&0xFF)==PT_ACID) //If on acid - parts[i].life -= 5; - - if ((r&0xFF)==PT_PLUT) //If on plut - parts[i].life -= 1; - - r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)]; - if((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) - { - parts[i].life -= 2; - player[22] -= 1; - } - } - - if ((r&0xFF)==PT_ACID) //If on acid - parts[i].life -= 5; - - if ((r&0xFF)==PT_PLUT) //If on plut - parts[i].life -= 1; - - isplayer = 1; - } - if(t==PT_STKM2) - { - float dt = 0.9;///(FPSB*FPSB); //Delta time in square - //Tempirature handling - if(parts[i].temp<243) - parts[i].life -= 1; - if((parts[i].temp<309.6f) && (parts[i].temp>=243)) - parts[i].temp += 1; - - if (isplayer2) { //Already a stickman2 in the simulation - death2 = 1; - parts[i].type = PT_NONE; - } - - //Death - if(parts[i].life<1 || death2 == 1 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... - { - for(r=-2; r<=1; r++) - { - create_part(-1, x+r, y-2, player2[2]); - create_part(-1, x+r+1, y+2, player2[2]); - create_part(-1, x-2, y+r+1, player2[2]); - create_part(-1, x+2, y+r, player2[2]); - } - kill_part(i); //Kill him - continue; - } - - parts[i].vy += -0.7*dt; //Head up! - - //Verlet integration - pp = 2*player2[3]-player2[5]+player2[19]*dt*dt;; - player2[5] = player2[3]; - player2[3] = pp; - pp = 2*player2[4]-player2[6]+player2[20]*dt*dt;; - player2[6] = player2[4]; - player2[4] = pp; - - pp = 2*player2[7]-player2[9]+player2[21]*dt*dt;; - player2[9] = player2[7]; - player2[7] = pp; - pp = 2*player2[8]-player2[10]+(player2[22]+1)*dt*dt;; - player2[10] = player2[8]; - player2[8] = pp; - - pp = 2*player2[11]-player2[13]+player2[23]*dt*dt;; - player2[13] = player2[11]; - player2[11] = pp; - pp = 2*player2[12]-player2[14]+player2[24]*dt*dt;; - player2[14] = player2[12]; - player2[12] = pp; - - pp = 2*player2[15]-player2[17]+player2[25]*dt*dt;; - player2[17] = player2[15]; - player2[15] = pp; - pp = 2*player2[16]-player2[18]+(player2[26]+1)*dt*dt;; - player2[18] = player2[16]; - player2[16] = pp; - - //Setting acceleration to 0 - player2[19] = 0; - player2[20] = 0; - - player2[21] = 0; - player2[22] = 0; - - player2[23] = 0; - player2[24] = 0; - - player2[25] = 0; - player2[26] = 0; - - //Go left - if (((int)(player2[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) - { - if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) - { - if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) - { - player2[21] = -3; - player2[22] = -2; - player2[19] = -2; - } - - if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) - { - player2[25] = -3; - player2[26] = -2; - player2[23] = -2; - } - } - else - { - if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) //It should move another way in liquids - { - player2[21] = -1; - player2[22] = -1; - player2[19] = -1; - } - - if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) - { - player2[25] = -1; - player2[26] = -1; - player2[23] = -1; - } - } - } - - //Go right - if (((int)(player2[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS) - { - if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID - && (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG) - { - if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) - { - player2[21] = 3; - player2[22] = -2; - player2[19] = 2; - } - - if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) - { - player2[25] = 3; - player2[26] = -2; - player2[23] = 2; - } - } - else - { - if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) - { - player2[21] = 1; - player2[22] = -1; - player2[19] = 1; - } - - if (pmap[(int)(player2[16]-1)][(int)(player2[15])]) - { - player2[25] = 1; - player2[26] = -1; - player2[23] = 1; - } - - } - } - - //Jump - if (((int)(player2[0])&0x04) == 0x04 && (pstates[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS)) - { - if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])]) - { - parts[i].vy = -5; - player2[22] -= 1; - player2[26] -= 1; - } - } - - //Charge detector wall if foot inside - if(bmap[(int)(player2[8]+0.5)/CELL][(int)(player2[7]+0.5)/CELL]==WL_DETECT) - set_emap((int)player2[7]/CELL, (int)player2[8]/CELL); - if(bmap[(int)(player2[16]+0.5)/CELL][(int)(player2[15]+0.5)/CELL]==WL_DETECT) - set_emap((int)(player2[15]+0.5)/CELL, (int)(player2[16]+0.5)/CELL); - - //Searching for particles near head - for(nx = -2; nx <= 2; nx++) - for(ny = 0; ny>=-2; ny--) - { - if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART) - continue; - if(ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT) - { - player2[2] = pmap[ny+y][nx+x]&0xFF; //Current element - } - if((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP - { - if(parts[i].life<=95) - parts[i].life += 5; - else - parts[i].life = 100; - kill_part(pmap[ny+y][nx+x]>>8); - } - - if((pmap[ny+y][nx+x]&0xFF) == PT_NEUT) - { - parts[i].life -= (102-parts[i].life)/2; - kill_part(pmap[ny+y][nx+x]>>8); - } - if(bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN) - player2[2] = SPC_AIR; - } - - //Head position - nx = x + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01); - ny = y - 3*(player2[1] == 0); - - //Spawn - if(((int)(player2[0])&0x08) == 0x08) - { - ny -= 2*(rand()%2)+1; - r = pmap[ny][nx]; - if(!((r>>8)>=NPART)) - { - if(pstates[r&0xFF].state == ST_SOLID) - { - create_part(-1, nx, ny, PT_SPRK); - } - else - { - if(player2[2] == SPC_AIR) - create_parts(nx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR); - else - create_part(-1, nx, ny, player2[2]); - - r = pmap[ny][nx]; - if( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR) - parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01); - if(((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT) - { - int random = abs(rand()%3-1)*3; - if (random==0) - { - parts[r>>8].life = 0; - parts[r>>8].type = PT_NONE; - } - else - { - parts[r>>8].vy = 0; - parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random; - } - } - - } - } - } - - //Simulation of joints - d = 25/(pow((player2[3]-player2[7]), 2) + pow((player2[4]-player2[8]), 2)+25) - 0.5; //Fast distance - player2[7] -= (player2[3]-player2[7])*d; - player2[8] -= (player2[4]-player2[8])*d; - player2[3] += (player2[3]-player2[7])*d; - player2[4] += (player2[4]-player2[8])*d; - - d = 25/(pow((player2[11]-player2[15]), 2) + pow((player2[12]-player2[16]), 2)+25) - 0.5; - player2[15] -= (player2[11]-player2[15])*d; - player2[16] -= (player2[12]-player2[16])*d; - player2[11] += (player2[11]-player2[15])*d; - player2[12] += (player2[12]-player2[16])*d; - - d = 36/(pow((player2[3]-parts[i].x), 2) + pow((player2[4]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (player2[3]-parts[i].x)*d; - parts[i].vy -= (player2[4]-parts[i].y)*d; - player2[3] += (player2[3]-parts[i].x)*d; - player2[4] += (player2[4]-parts[i].y)*d; - - d = 36/(pow((player2[11]-parts[i].x), 2) + pow((player2[12]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (player2[11]-parts[i].x)*d; - parts[i].vy -= (player2[12]-parts[i].y)*d; - player2[11] += (player2[11]-parts[i].x)*d; - player2[12] += (player2[12]-parts[i].y)*d; - - //Side collisions checking - for(nx = -3; nx <= 3; nx++) - { - r = pmap[(int)(player2[16]-2)][(int)(player2[15]+nx)]; - if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID) - player2[15] -= nx; - - r = pmap[(int)(player2[8]-2)][(int)(player2[7]+nx)]; - if(r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID) - player2[7] -= nx; - } - - //Collision checks - for(ny = -2-(int)parts[i].vy; ny<=0; ny++) - { - r = pmap[(int)(player2[8]+ny)][(int)(player2[7]+0.5)]; //This is to make coding more pleasant :-) - - //For left leg - if (r && (r&0xFF)!=PT_STKM2) - { - if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks - { - if(parts[i].y<(player2[8]-10)) - parts[i].vy = 1*dt; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5*dt; - } - else - { - if(pstates[r&0xFF].state != ST_GAS) - { - player2[8] += ny-1; - parts[i].vy -= 0.5*parts[i].vy*dt; - } - } - player2[9] = player2[7]; - } - - r = pmap[(int)(player2[16]+ny)][(int)(player2[15]+0.5)]; - - //For right leg - if (r && (r&0xFF)!=PT_STKM2) - { - if(pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) - { - if(parts[i].y<(player2[16]-10)) - parts[i].vy = 1*dt; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5*dt; - } - else - { - if(pstates[r&0xFF].state != ST_GAS) - { - player2[16] += ny-1; - parts[i].vy -= 0.5*parts[i].vy*dt; - } - } - player2[17] = player2[15]; - } - - //If it falls too fast - if (parts[i].vy>=30) - { - parts[i].y -= (10+ny)*dt; - parts[i].vy = -10*dt; - } - - } - - //Keeping legs distance - if (pow((player2[7] - player2[15]), 2)<16 && pow((player2[8]-player2[16]), 2)<1) - { - player2[21] -= 0.2; - player2[25] += 0.2; - } - - if (pow((player2[3] - player2[11]), 2)<16 && pow((player2[4]-player2[12]), 2)<1) - { - player2[19] -= 0.2; - player2[23] += 0.2; - } - - //If legs touch something - r = pmap[(int)(player2[8]+0.5)][(int)(player2[7]+0.5)]; - if((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) - { - parts[i].life -= 2; - player2[26] -= 1; - } - } - - if ((r&0xFF)==PT_ACID) //If on acid - parts[i].life -= 5; - - if ((r&0xFF)==PT_PLUT) //If on plut - parts[i].life -= 1; - - r = pmap[(int)(player2[16]+0.5)][(int)(player2[15]+0.5)]; - if((r&0xFF)==PT_SPRK && r && (r>>8)0 && (r>>8)>8].temp>=323 || parts[r>>8].temp<=243) - { - parts[i].life -= 2; - player2[22] -= 1; - } - } - - if ((r&0xFF)==PT_ACID) //If on acid - parts[i].life -= 5; - - if ((r&0xFF)==PT_PLUT) //If on plut - parts[i].life -= 1; - - isplayer2 = 1; - } - if(t==PT_SPAWN) - { - if(death==1) - { - playerspawn = create_part(-1,x,y,PT_STKM); - isplayer = 1; - } - death = 0; - } - if(t==PT_SPAWN2) - { - if(death2==1) - { - player2spawn = create_part(-1,x,y,PT_STKM2); - isplayer2 = 1; - } - death2 = 0; - } - if(t==PT_CLNE) - { - if(!parts[i].ctype) - { - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx=0 && y+ny>0 && - x+nx=0 && y+ny>0 && - x+nx303&&parts[i].temp<317) { - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST); - } - } - if(t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1) - { - parts[i].type = PT_NBLE; - parts[i].life = 0; - } - if (t==PT_FIRE && parts[i].life <=1 && parts[i].temp<625) - { - t = parts[i].type = PT_SMKE; - parts[i].life = rand()%20+250; - } - - nx = (int)(parts[i].x+0.5f); - ny = (int)(parts[i].y+0.5f); - - if(nx=XRES-CELL || - ny=YRES-CELL) - { - parts[i].x = lx; - parts[i].y = ly; - kill_part(i); - continue; - } - - if(parts[i].type == PT_PHOT) { - rt = pmap[ny][nx] & 0xFF; - - if(rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN) { - lt = pmap[ny][nx] >> 8; - if(!parts[lt].ctype) - parts[lt].ctype = PT_PHOT; - } - - lt = pmap[y][x] & 0xFF; - - r = eval_move(PT_PHOT, nx, ny, NULL); - - if(((rt==PT_GLAS && lt!=PT_GLAS) || (rt!=PT_GLAS && lt==PT_GLAS)) && r) { - if(!get_normal_interp(REFRACT|parts[i].type, x, y, parts[i].vx, parts[i].vy, &nrx, &nry)) { - kill_part(i); - continue; - } - - r = get_wavelength_bin(&parts[i].ctype); - if(r == -1) { - kill_part(i); - continue; - } - nn = GLASS_IOR - GLASS_DISP*(r-15)/15.0f; - nn *= nn; - - nrx = -nrx; - nry = -nry; - if(rt==PT_GLAS && lt!=PT_GLAS) - nn = 1.0f/nn; - ct1 = parts[i].vx*nrx + parts[i].vy*nry; - ct2 = 1.0f - (nn*nn)*(1.0f-(ct1*ct1)); - if(ct2 < 0.0f) { - parts[i].vx -= 2.0f*ct1*nrx; - parts[i].vy -= 2.0f*ct1*nry; - parts[i].x = lx; - parts[i].y = ly; - nx = (int)(lx + 0.5f); - ny = (int)(ly + 0.5f); - } else { - ct2 = sqrtf(ct2); - ct2 = ct2 - nn*ct1; - parts[i].vx = nn*parts[i].vx + ct2*nrx; - parts[i].vy = nn*parts[i].vy + ct2*nry; - } - } - } - - rt = parts[i].flags & FLAG_STAGNANT; - parts[i].flags &= ~FLAG_STAGNANT; - if(!try_move(i, x, y, nx, ny)) - { - parts[i].x = lx; - parts[i].y = ly; - if(ptypes[t].falldown) - { - if(nx!=x && try_move(i, x, y, nx, y)) - { - parts[i].x = ix; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else if(ny!=y && try_move(i, x, y, x, ny)) - { - parts[i].y = iy; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else - { - r = (rand()%2)*2-1; - if(ny!=y && try_move(i, x, y, x+r, ny)) - { - parts[i].x += r; - parts[i].y = iy; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else if(ny!=y && try_move(i, x, y, x-r, ny)) - { - parts[i].x -= r; - parts[i].y = iy; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else if(nx!=x && try_move(i, x, y, nx, y+r)) - { - parts[i].x = ix; - parts[i].y += r; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else if(nx!=x && try_move(i, x, y, nx, y-r)) - { - parts[i].x = ix; - parts[i].y -= r; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - else if(ptypes[t].falldown>1 && (parts[i].vy>fabs(parts[i].vx) || gravityMode==2)) - { - s = 0; - if(!rt || nt) //nt is if there is an something else besides the current particle type, around the particle - rt = 30;//slight less water lag, although it changes how it moves a lot - else - rt = 10; - for(j=x+r; j>=0 && j>=x-rt && j0) - r = 1; - else - r = -1; - if(s) - for(j=y+r; j>=0 && j=y-rt && j(rand()%1000)) - { - kill_part(i); - continue; - } - else if(t==PT_NEUT || t==PT_PHOT) //Seems to break neutrons, sorry Skylark - { - r = pmap[ny][nx]; - - /* this should be replaced with a particle type attribute ("photwl" or something) */ - if((r & 0xFF) == PT_PSCN) parts[i].ctype = 0x00000000; - if((r & 0xFF) == PT_NSCN) parts[i].ctype = 0x00000000; - if((r & 0xFF) == PT_SPRK) parts[i].ctype = 0x00000000; - if((r & 0xFF) == PT_COAL) parts[i].ctype = 0x00000000; - if((r & 0xFF) == PT_BCOL) parts[i].ctype = 0x00000000; - if((r & 0xFF) == PT_PLEX) parts[i].ctype &= 0x1F00003E; - if((r & 0xFF) == PT_NITR) parts[i].ctype &= 0x0007C000; - if((r & 0xFF) == PT_NBLE) parts[i].ctype &= 0x3FFF8000; - if((r & 0xFF) == PT_LAVA) parts[i].ctype &= 0x3FF00000; - if((r & 0xFF) == PT_ACID) parts[i].ctype &= 0x1FE001FE; - if((r & 0xFF) == PT_DUST) parts[i].ctype &= 0x3FFFFFC0; - if((r & 0xFF) == PT_SNOW) parts[i].ctype &= 0x03FFFFFF; - if((r & 0xFF) == PT_GOO) parts[i].ctype &= 0x3FFAAA00; - if((r & 0xFF) == PT_PLNT) parts[i].ctype &= 0x0007C000; - if((r & 0xFF) == PT_PLUT) parts[i].ctype &= 0x001FCE00; - if((r & 0xFF) == PT_URAN) parts[i].ctype &= 0x003FC000; - - if(get_normal_interp(t, lx, ly, parts[i].vx, parts[i].vy, &nrx, &nry)) { - dp = nrx*parts[i].vx + nry*parts[i].vy; - parts[i].vx -= 2.0f*dp*nrx; - parts[i].vy -= 2.0f*dp*nry; - nx = (int)(parts[i].x + parts[i].vx + 0.5f); - ny = (int)(parts[i].y + parts[i].vy + 0.5f); - if(try_move(i, x, y, nx, ny)) { - parts[i].x = (float)nx; - parts[i].y = (float)ny; - } else { - kill_part(i); - continue; - } - } else { - if(t!=PT_NEUT) - kill_part(i); - continue; - } - - if(!parts[i].ctype) { - if(t!=PT_NEUT) - kill_part(i); - continue; - } - } - - else - { - if(nx>x+ISTP) nx=x+ISTP; - if(nxy+ISTP) ny=y+ISTP; - if(ny=XRES-CELL || ny=YRES-CELL) - { - kill_part(i); - continue; - } - } - if(framerender) { - framerender = 0; - sys_pause = 1; - } + if (framerender) { + framerender = 0; + sys_pause = 1; + } } void update_particles(pixel *vid) { - int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1; - float lx, ly; + int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1; + float lx, ly; #ifdef MT - int pt = 0, pc = 0; - pthread_t *InterThreads; + int pt = 0, pc = 0; + pthread_t *InterThreads; #endif - isplayer = 0; //Needed for player spawning - isplayer2 = 0; - memset(pmap, 0, sizeof(pmap)); - memset(photons, 0, sizeof(photons)); - r = rand()%2; - NUM_PARTS = 0; - for(j=0; j=0 && y>=0 && x=0 && y>=0 && x>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_FAN) - for(j=0; j>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_EWALL) - { - if(emap[y][x]) - { - cr = cg = cb = 128; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - for(j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_ALLOWALLELEC) - { - for(j=0; j>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_FAN) + for (j=0; j>1)&1; i>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_EWALL) + { + if (emap[y][x]) + { + cr = cg = cb = 128; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + for (j=0; j 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_ALLOWALLELEC) + { + for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_ALLOWGAS) - { - for(j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(emap[y][x] && (!sys_pause||framerender)) - emap[y][x] --; - } - } - } - else - { - for(y=0; y>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_FAN) - for(j=0; j>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_EWALL) - { - if(emap[y][x]) - { - cr = cg = cb = 128; - cr += fire_r[y][x]; - if(cr > 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - for(j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_ALLOWALLELEC) - { - for(j=0; j 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_ALLOWGAS) + { + for (j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (emap[y][x] && (!sys_pause||framerender)) + emap[y][x] --; + } + } + } + else + { + for (y=0; y>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_FAN) + for (j=0; j>1)&1; i>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_EWALL) + { + if (emap[y][x]) + { + cr = cg = cb = 128; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + for (j=0; j 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_ALLOWALLELEC) + { + for (j=0; j 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(bmap[y][x]==WL_ALLOWAIR) - { - for(j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; - fire_r[y][x] = cr; - cg += fire_g[y][x]; - if(cg > 255) cg = 255; - fire_g[y][x] = cg; - cb += fire_b[y][x]; - if(cb > 255) cb = 255; - fire_b[y][x] = cb; - } - } - if(emap[y][x] && (!sys_pause||framerender)) - emap[y][x] --; - } - } - } + } + if (emap[y][x]) + { + cr = cg = cb = 16; + cr += fire_r[y][x]; + if (cr > 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (bmap[y][x]==WL_ALLOWAIR) + { + for (j=0; j>1)&1; i>1)&1; i>1)&1; i 255) cr = 255; + fire_r[y][x] = cr; + cg += fire_g[y][x]; + if (cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if (cb > 255) cb = 255; + fire_b[y][x] = cb; + } + } + if (emap[y][x] && (!sys_pause||framerender)) + emap[y][x] --; + } + } + } - update_particles_i(vid, 0, 1); + update_particles_i(vid, 0, 1); - for(y=0; y=XRES || ny<0 || ny>=YRES) - break; - addpixel(vid, nx, ny, 255, 255, 255, 64); - i = nx/CELL; - j = ny/CELL; - lx += vx[j][i]*0.125f; - ly += vy[j][i]*0.125f; - if(bmap[j][i]==WL_STREAM && i!=x && j!=y) - break; - } - drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); - } + for (y=0; y=XRES || ny<0 || ny>=YRES) + break; + addpixel(vid, nx, ny, 255, 255, 255, 64); + i = nx/CELL; + j = ny/CELL; + lx += vx[j][i]*0.125f; + ly += vy[j][i]*0.125f; + if (bmap[j][i]==WL_STREAM && i!=x && j!=y) + break; + } + drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); + } } 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. - #if !(defined(WIN32) && !defined(__GNUC__)) - int cx = 0; - int cy = 0; - unsigned tpmap[area_h][area_w]; - unsigned rtpmap[area_w][area_h]; - unsigned char tbmap[area_h/CELL][area_w/CELL]; - unsigned char rtbmap[area_w/CELL][area_h/CELL]; - float tfvy[area_h/CELL][area_w/CELL]; - float tfvx[area_h/CELL][area_w/CELL]; - for(cy=0; cy>8)<=NPART&&rtpmap[cy][cx]) + if (area_x + cx>8].x = area_x +cx; - parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy; + if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]) { + tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]; + if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]==WL_FAN) { + tfvx[cy/CELL][cx/CELL] = fvx[(cy+area_y)/CELL][(cx+area_x)/CELL]; + tfvy[cy/CELL][cx/CELL] = fvy[(cy+area_y)/CELL][(cx+area_x)/CELL]; + } + } else { + tbmap[cy/CELL][cx/CELL] = 0; + tfvx[cy/CELL][cx/CELL] = 0; + tfvy[cy/CELL][cx/CELL] = 0; + } + } + } + } + for (cy=0; cy>8)<=NPART&&rtpmap[cy][cx]) + { + parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].x = area_x +cx; + parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy; + } + bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL]; + fvy[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvy[cy/CELL][cx/CELL]; + fvx[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvx[cy/CELL][cx/CELL]; } - bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL]; - fvy[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvy[cy/CELL][cx/CELL]; - fvx[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvx[cy/CELL][cx/CELL]; } } - } #endif } void clear_area(int area_x, int area_y, int area_w, int area_h) { - int cx = 0; - int cy = 0; - for(cy=0; cyx2) - { - i = x2; - x2 = x1; - x1 = i; - } - if(y1>y2) - { - j = y2; - y2 = y1; - y1 = j; - } - for(j=y1; j<=y2; j++) - for(i=x1; i<=x2; i++) - create_parts(i, j, 1, 1, c); + int i, j; + if (x1>x2) + { + i = x2; + x2 = x1; + x1 = i; + } + if (y1>y2) + { + j = y2; + y2 = y1; + y1 = j; + } + for (j=y1; j<=y2; j++) + for (i=x1; i<=x2; i++) + create_parts(i, j, 1, 1, c); } int flood_parts(int x, int y, int c, int cm, int bm) { - int x1, x2, dy = (c=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT) - { - wall = c-100; - } - if(cm==-1) - { - if(c==0) - { - cm = pmap[y][x]&0xFF; - if(!cm) - return 0; - if(REPLACE_MODE && cm!=SLALT) - return 0; - } - else - cm = 0; - } - if(bm==-1) - { - if(wall==WL_ERASE) - { - bm = bmap[y/CELL][x/CELL]; - if(!bm) - return 0; - if(bm==WL_WALL) - cm = 0xFF; - } - else - bm = 0; - } - - if(((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT)) - return 1; - - // go left as far as possible - x1 = x2 = x; - while(x1>=CELL) - { - if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) + int x1, x2, dy = (c=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT) { - break; + wall = c-100; } - x1--; - } - while(x2=CELL+dy && x1==x2 && - ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) && - (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST) - flood_parts(x1, y-2, co, cm, bm); - else if(y>=CELL+dy) - for(x=x1; x<=x2; x++) - if((pmap[y-1][x]&0xFF)!=PT_SPRK) + if (c==0) { - if(x==x1 || x==x2 || y>=YRES-CELL-1 || - (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST || - (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST) - flood_parts(x, y-dy, co, cm, bm); - - } - - if(y=CELL+dy) - for(x=x1; x<=x2; x++) - if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm) - if(!flood_parts(x, y-dy, co, cm, bm)) - return 0; - if(y=CELL) + { + if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) + { + break; + } + x1--; + } + while (x2=CELL+dy && x1==x2 && + ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) && + (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST) + flood_parts(x1, y-2, co, cm, bm); + else if (y>=CELL+dy) + for (x=x1; x<=x2; x++) + if ((pmap[y-1][x]&0xFF)!=PT_SPRK) + { + if (x==x1 || x==x2 || y>=YRES-CELL-1 || + (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST || + (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST) + flood_parts(x, y-dy, co, cm, bm); + + } + + if (y=CELL+dy) + for (x=x1; x<=x2; x++) + if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm) + if (!flood_parts(x, y-dy, co, cm, bm)) + return 0; + if (y=0&&ox=0&&oy=0 && i+u=0 && j+v=0&&ox=0&&oy=0 && i+u=0 && j+vabs(x2-x1), x, y, dx, dy, sy; - float e, de; - if(cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if(x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if(dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1= 0.5f) - { - y += sy; - if(c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC || !(rx+ry)) - { - if(cp) - create_parts(y, x, rx, ry, c); - else - create_parts(x, y, rx, ry, c); - } - e -= 1.0f; - } - } + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1= 0.5f) + { + y += sy; + if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC || !(rx+ry)) + { + if (cp) + create_parts(y, x, rx, ry, c); + else + create_parts(x, y, rx, ry, c); + } + e -= 1.0f; + } + } } diff --git a/src/update.c b/src/update.c index 99b9d1bc2..46712d78c 100644 --- a/src/update.c +++ b/src/update.c @@ -42,160 +42,160 @@ static char *exe_name(void) { #if defined WIN32 - char *name= (char *)malloc(64), max=64, res; - while((res = (char)GetModuleFileName(NULL, name, max)) >= max) - { + char *name= (char *)malloc(64), max=64, res; + while ((res = (char)GetModuleFileName(NULL, name, max)) >= max) + { #elif defined MACOSX - char *fn=malloc(64),*name=malloc(PATH_MAX), max=64, res; - if(_NSGetExecutablePath(fn, &max) != 0) - { - fn = realloc(fn, max); - _NSGetExecutablePath(fn, &max); - } - if(realpath(fn, name) == NULL) - { - free(fn); - free(name); - return NULL; - } - res = 1; + char *fn=malloc(64),*name=malloc(PATH_MAX), max=64, res; + if (_NSGetExecutablePath(fn, &max) != 0) + { + fn = realloc(fn, max); + _NSGetExecutablePath(fn, &max); + } + if (realpath(fn, name) == NULL) + { + free(fn); + free(name); + return NULL; + } + res = 1; #else - char fn[64], *name=malloc(64), max=64, res; - sprintf(fn, "/proc/self/exe"); - memset(name, 0, max); - while((res = readlink(fn, name, max)) >= max-1) - { + char fn[64], *name=malloc(64), max=64, res; + sprintf(fn, "/proc/self/exe"); + memset(name, 0, max); + while ((res = readlink(fn, name, max)) >= max-1) + { #endif #ifndef MACOSX - max *= 2; - name = realloc(name, max); - memset(name, 0, max); - } + max *= 2; + name = realloc(name, max); + memset(name, 0, max); + } #endif - if(res <= 0) - { - free(name); - return NULL; - } - return name; + if (res <= 0) + { + free(name); + return NULL; + } + return name; } int update_start(char *data, int len) { - char *self=exe_name(), *temp; + char *self=exe_name(), *temp; #ifdef WIN32 - char *p; + char *p; #endif - FILE *f; - int res = 1; + FILE *f; + int res = 1; - if(!self) - return 1; + if (!self) + return 1; #ifdef WIN32 - temp = malloc(strlen(self)+12); - strcpy(temp, self); - p = temp + strlen(temp) - 4; - if(_stricmp(p, ".exe")) - p += 4; - strcpy(p, "_update.exe"); + temp = malloc(strlen(self)+12); + strcpy(temp, self); + p = temp + strlen(temp) - 4; + if (_stricmp(p, ".exe")) + p += 4; + strcpy(p, "_update.exe"); - if(!MoveFile(self, temp)) - goto fail; + if (!MoveFile(self, temp)) + goto fail; - f = fopen(self, "wb"); - if(!f) - goto fail; - if(fwrite(data, 1, len, f) != len) - { - fclose(f); - DeleteFile(self); - goto fail; - } - fclose(f); + f = fopen(self, "wb"); + if (!f) + goto fail; + if (fwrite(data, 1, len, f) != len) + { + fclose(f); + DeleteFile(self); + goto fail; + } + fclose(f); - if((int)ShellExecute(NULL, "open", self, NULL, NULL, SW_SHOWNORMAL) <= 32) - { - DeleteFile(self); - goto fail; - } + if ((int)ShellExecute(NULL, "open", self, NULL, NULL, SW_SHOWNORMAL) <= 32) + { + DeleteFile(self); + goto fail; + } - return 0; + return 0; #else - temp = malloc(strlen(self)+8); - strcpy(temp, self); - strcat(temp, "-update"); + temp = malloc(strlen(self)+8); + strcpy(temp, self); + strcat(temp, "-update"); - f = fopen(temp, "w"); - if(!f) - goto fail; - if(fwrite(data, 1, len, f) != len) - { - fclose(f); - unlink(temp); - goto fail; - } - fclose(f); + f = fopen(temp, "w"); + if (!f) + goto fail; + if (fwrite(data, 1, len, f) != len) + { + fclose(f); + unlink(temp); + goto fail; + } + fclose(f); - if(chmod(temp, 0755)) - { - unlink(temp); - goto fail; - } + if (chmod(temp, 0755)) + { + unlink(temp); + goto fail; + } - if(rename(temp, self)) - { - unlink(temp); - goto fail; - } + if (rename(temp, self)) + { + unlink(temp); + goto fail; + } - execl(self, "powder-update", NULL); + execl(self, "powder-update", NULL); #endif fail: - free(temp); - free(self); - return res; + free(temp); + free(self); + return res; } int update_finish(void) { #ifdef WIN32 - char *temp, *self=exe_name(), *p; - int timeout = 60, err; + char *temp, *self=exe_name(), *p; + int timeout = 60, err; - temp = malloc(strlen(self)+12); - strcpy(temp, self); - p = temp + strlen(temp) - 4; - if(_stricmp(p, ".exe")) - p += 4; - strcpy(p, "_update.exe"); + temp = malloc(strlen(self)+12); + strcpy(temp, self); + p = temp + strlen(temp) - 4; + if (_stricmp(p, ".exe")) + p += 4; + strcpy(p, "_update.exe"); - while(!DeleteFile(temp)) - { - err = GetLastError(); - if(err == ERROR_FILE_NOT_FOUND) - { - // just as well, then - free(temp); - return 0; - } - Sleep(500); - timeout--; - if(timeout <= 0) - { - free(temp); - return 1; - } - } - free(temp); + while (!DeleteFile(temp)) + { + err = GetLastError(); + if (err == ERROR_FILE_NOT_FOUND) + { + // just as well, then + free(temp); + return 0; + } + Sleep(500); + timeout--; + if (timeout <= 0) + { + free(temp); + return 1; + } + } + free(temp); #endif - return 0; + return 0; } void update_cleanup(void) { #ifdef WIN32 - update_finish(); + update_finish(); #endif }