From 6bd48d059f3c10c2a3a9e080e3bb91bebab283de Mon Sep 17 00:00:00 2001 From: Felix Wallin Date: Mon, 16 Aug 2010 17:20:12 +0800 Subject: [PATCH] formatted source code --- font.h | 10 +- http.c | 1178 ++-- md5.c | 67 +- md5.h | 9 +- powder.c | 15589 +++++++++++++++++++++++++++++------------------------ update.c | 117 +- 6 files changed, 9311 insertions(+), 7659 deletions(-) mode change 100755 => 100644 font.h mode change 100755 => 100644 http.c mode change 100755 => 100644 md5.c mode change 100755 => 100644 md5.h mode change 100755 => 100644 powder.c mode change 100755 => 100644 update.c diff --git a/font.h b/font.h old mode 100755 new mode 100644 index 68ac6841b..ffed99506 --- a/font.h +++ b/font.h @@ -19,9 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #define FONT_H 10 -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, 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, 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, +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, 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, 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, 0x0e8a, 0x0e9a, 0x0eaa, 0x0eba, 0x0eca, 0x0eda, 0x0eea, 0x0efa, 0x0f0a, 0x0f1a, 0x0f2a, 0x0f3a, 0x0f4a, 0x0f5a, 0x0f6a, 0x0f7a, 0x0f8a, 0x0f9a, 0x0faa, 0x0fba, 0x0fca, 0x0fda, 0x0fea, 0x0ffa, 0x100a, 0x101a, 0x102a, 0x103a, 0x104a, 0x105a, 0x106a, 0x107a, 0x108a, 0x109a, 0x10aa, 0x10ba, 0x10ca, 0x10da, 0x10ea, 0x10fa, 0x110a, 0x111a, 0x112a, 0x113a, 0x114a, +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, 0x0e8a, 0x0e9a, 0x0eaa, 0x0eba, 0x0eca, 0x0eda, 0x0eea, 0x0efa, 0x0f0a, 0x0f1a, 0x0f2a, 0x0f3a, 0x0f4a, 0x0f5a, 0x0f6a, 0x0f7a, 0x0f8a, 0x0f9a, 0x0faa, 0x0fba, 0x0fca, 0x0fda, 0x0fea, 0x0ffa, 0x100a, 0x101a, 0x102a, 0x103a, 0x104a, 0x105a, 0x106a, 0x107a, 0x108a, 0x109a, 0x10aa, 0x10ba, 0x10ca, 0x10da, 0x10ea, 0x10fa, 0x110a, 0x111a, 0x112a, 0x113a, 0x114a, }; \ No newline at end of file diff --git a/http.c b/http.c old mode 100755 new mode 100644 index 74bafa29c..85ba9f0d4 --- a/http.c +++ b/http.c @@ -72,10 +72,11 @@ static struct sockaddr_in http_proxy; static char *mystrdup(char *s) { char *x; - if(s) { - x = malloc(strlen(s)+1); - strcpy(x, s); - return x; + if(s) + { + x = malloc(strlen(s)+1); + strcpy(x, s); + return x; } return s; } @@ -84,21 +85,22 @@ static int splituri(char *uri, char **host, char **path) { char *p=uri,*q,*x,*y; if(!strncmp(p, "http://", 7)) - p += 7; + p += 7; q = strchr(p, '/'); if(!q) - q = p + strlen(p); + q = p + strlen(p); x = malloc(q-p+1); if(*q) - y = mystrdup(q); + y = mystrdup(q); else - y = mystrdup("/"); + y = mystrdup("/"); strncpy(x, p, q-p); x[q-p] = 0; - if(q==p || x[q-p-1]==':') { - free(x); - free(y); - return 1; + if(q==p || x[q-p-1]==':') + { + free(x); + free(y); + return 1; } *host = x; *path = y; @@ -110,7 +112,7 @@ static char *getserv(char *host) char *q, *x = mystrdup(host); q = strchr(x, ':'); if(q) - *q = 0; + *q = 0; return x; } @@ -119,32 +121,35 @@ static char *getport(char *host) char *p, *q; q = strchr(host, ':'); if(q) - p = mystrdup(q+1); + p = mystrdup(q+1); else - p = mystrdup("80"); + p = mystrdup("80"); return p; } static int resolve(char *dns, char *srv, struct sockaddr_in *addr) { struct addrinfo hnt, *res = 0; - if(http_use_proxy) { - memcpy(addr, &http_proxy, sizeof(struct sockaddr_in)); - return 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; + 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; } @@ -155,20 +160,21 @@ void http_init(char *proxy) #ifdef WIN32 WSADATA wsadata; if(!WSAStartup(MAKEWORD(2,2), &wsadata)) - http_up = 1; + http_up = 1; #else 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); } } @@ -189,7 +195,8 @@ void http_done(void) #define HTS_XMIT 4 #define HTS_RECV 5 #define HTS_DONE 6 -struct http_ctx { +struct http_ctx +{ int state; time_t last; int keep; @@ -213,54 +220,63 @@ struct http_ctx { 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; + 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(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(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(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; + 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; @@ -286,76 +302,92 @@ void http_async_add_header(void *ctx, char *name, char *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(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(!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, "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(!strncmp(str, "Content-Length: ", 16)) + { + cx->contlen = atoi(str+16); + return; } - if(!strcmp(str, "Transfer-Encoding: chunked")) { - cx->chunked = 1; - return; + if(!strcmp(str, "Transfer-Encoding: chunked")) + { + cx->chunked = 1; + return; } - if(!strcmp(str, "Connection: close")) { - cx->cclose = 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; + } } } @@ -369,152 +401,164 @@ int http_async_req_status(void *ctx) unsigned long tmp2; #endif - switch(cx->state) { + 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; + 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; + 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); + 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; + ) + 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); + 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; + 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; + 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; + 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 1; } return 0; @@ -535,37 +579,42 @@ char *http_async_req_stop(void *ctx, int *ret, int *len) char *rxd; if(cx->state != HTS_DONE) - while(!http_async_req_status(ctx)) ; + while(!http_async_req_status(ctx)) ; - if(cx->host) { - free(cx->host); - cx->host = NULL; + if(cx->host) + { + free(cx->host); + cx->host = NULL; } - if(cx->path) { - free(cx->path); - cx->path = NULL; + if(cx->path) + { + free(cx->path); + cx->path = NULL; } - if(cx->txd) { - free(cx->txd); - cx->txd = NULL; - cx->txdl = 0; + if(cx->txd) + { + free(cx->txd); + cx->txd = NULL; + cx->txdl = 0; } - if(cx->hbuf) { - free(cx->hbuf); - cx->hbuf = NULL; + if(cx->hbuf) + { + free(cx->hbuf); + cx->hbuf = NULL; } - if(cx->thdr) { - free(cx->thdr); - cx->thdr = NULL; - cx->thlen = 0; + if(cx->thdr) + { + free(cx->thdr); + cx->thdr = NULL; + cx->thlen = 0; } if(ret) - *ret = cx->ret; + *ret = cx->ret; if(len) - *len = cx->rptr; + *len = cx->rptr; if(cx->rbuf) - cx->rbuf[cx->rptr] = 0; + cx->rbuf[cx->rptr] = 0; rxd = cx->rbuf; cx->rbuf = NULL; cx->rlen = 0; @@ -573,17 +622,20 @@ char *http_async_req_stop(void *ctx, int *ret, int *len) 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; + 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; } @@ -592,23 +644,24 @@ void http_async_get_length(void *ctx, int *total, int *done) { struct http_ctx *cx = ctx; if(done) - *done = cx->rptr; + *done = cx->rptr; if(total) - *total = cx->contlen; + *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->host) + { + cx->keep = 1; + tmp = http_async_req_stop(ctx, NULL, NULL); + if(tmp) + free(tmp); } if(cx->fdhost) - free(cx->fdhost); + free(cx->fdhost); PCLOSE(cx->fd); free(ctx); } @@ -616,55 +669,60 @@ void http_async_req_close(void *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; + 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; + 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; - - 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(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); + } } } 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; + if(!ctx) + { + if(ret) + *ret = 600; + if(len) + *len = 0; + return NULL; } return http_async_req_stop(ctx, ret, len); } @@ -672,83 +730,144 @@ char *http_auth_get(char *uri, char *user, char *pass, int *ret, int *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; + 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) @@ -761,153 +880,172 @@ char *http_multipart_post(char *uri, char **names, char **parts, int *plens, cha int blen = 0; unsigned int map[62], m; struct md5_context md5; - //struct md5_context md52; + //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); + free(plens); return http_async_req_stop(ctx, ret, len); fail: if(data) - free(data); + free(data); if(own_plen) - free(plens); + free(plens); if(ret) - *ret = 600; + *ret = 600; if(len) - *len = 0; + *len = 0; return NULL; } diff --git a/md5.c b/md5.c old mode 100755 new mode 100644 index 874d2c147..2e348e675 --- a/md5.c +++ b/md5.c @@ -33,34 +33,37 @@ void md5_update(struct md5_context *ctx, unsigned char const *buf, unsigned len) // update bit count t = ctx->bits[0]; if((ctx->bits[0] = (t + ((unsigned)len << 3)) & 0xffffffff) < t) - ctx->bits[1]++; // carry + ctx->bits[1]++; // carry ctx->bits[1] += len >> 29; t = (t >> 3) & 0x3f; // 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 - 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 @@ -84,14 +87,17 @@ void md5_final(unsigned char digest[16], struct md5_context *ctx) 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); + 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 @@ -121,7 +127,7 @@ void md5_transform(unsigned buf[4], const unsigned char inraw[64]) int i; for (i = 0; i < 16; ++i) - in[i] = getu32 (inraw + 4 * i); + in[i] = getu32 (inraw + 4 * i); a = buf[0]; b = buf[1]; @@ -210,15 +216,16 @@ void md5_ascii(char *result, unsigned char const *buf, unsigned len) int i; if(len==0) - len = strlen((char *)buf); + len = strlen((char *)buf); 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]; + 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/md5.h b/md5.h old mode 100755 new mode 100644 index 3f675d62a..2ae3ae843 --- a/md5.h +++ b/md5.h @@ -1,10 +1,11 @@ #ifndef MD5_H #define MD5_H -struct md5_context { - unsigned buf[4]; - unsigned bits[2]; - unsigned char in[64]; +struct md5_context +{ + unsigned buf[4]; + unsigned bits[2]; + unsigned char in[64]; }; void md5_init(struct md5_context *context); diff --git a/powder.c b/powder.c old mode 100755 new mode 100644 index 8d63d6fa2..ffc656891 --- a/powder.c +++ b/powder.c @@ -103,39 +103,40 @@ typedef unsigned int pixel; #endif char *it_msg = -"\brThe Powder Toy\n" -"\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" -"\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" -"Ctrl+drag will result in filled rectangles.\n" -"Ctrl+Shift+click will flood-fill a closed area.\n" -"Middle click or Alt+Click to \"sample\" the particles.\n" -"\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 and Pressure). The numbers 1 to 6 will do the same\n" -"Use the mouse scroll wheel to change the tool size for particles.\n" -"'Q' will quit the application.\n" -"The spacebar can be used to pause physics.\n" -"'P' will take a screenshot and save it into the current directory.\n" -"\n" -"\brhttp://powdertoy.co.uk/\n" -"\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 Bryan Hoyle (New elements)\n" -"\n" -"\bgSpecial thanks to Brian Ledbetter for maintaining ports.\n" -"\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html" -; + "\brThe Powder Toy\n" + "\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" + "\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" + "Ctrl+drag will result in filled rectangles.\n" + "Ctrl+Shift+click will flood-fill a closed area.\n" + "Middle click or Alt+Click to \"sample\" the particles.\n" + "\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 and Pressure). The numbers 1 to 6 will do the same\n" + "Use the mouse scroll wheel to change the tool size for particles.\n" + "'Q' will quit the application.\n" + "The spacebar can be used to pause physics.\n" + "'P' will take a screenshot and save it into the current directory.\n" + "\n" + "\brhttp://powdertoy.co.uk/\n" + "\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 Bryan Hoyle (New elements)\n" + "\n" + "\bgSpecial thanks to Brian Ledbetter for maintaining ports.\n" + "\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html" + ; -typedef struct { - int start, inc; - pixel *vid; +typedef struct +{ + int start, inc; + pixel *vid; } upstruc; #ifdef BETA @@ -156,7 +157,8 @@ unsigned char fire_b[YRES/CELL][XRES/CELL]; #define MAXSIGNS 16 -struct sign { +struct sign +{ int x,y,ju; char text[256]; } signs[MAXSIGNS]; @@ -185,138 +187,148 @@ 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)]; - } + 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; + for(i=-1; i<2; i++) + kernel[(i+1)+3*(j+1)] *= s; } -int core_count(){ - int numCPU = 1; +int core_count() +{ + 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; } void update_air(void) { int x, y, i, j; float dp, dx, dy, f, tx, ty; - + for(y=1; y0 && 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; - - ovx[y][x] = dx; - ovy[y][x] = dy; - opv[y][x] = dp; - } + for(x=0; x0 && 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; + + 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)); @@ -324,57 +336,62 @@ void update_air(void) void *update_air_th(void *arg) { - update_air(); - return NULL; + update_air(); + return NULL; } inline unsigned clamp_flt(float f, float min, float max) { if(fmax) - return 255; + return 255; return (int)(255.0f*(f-min)/(max-min)); } -inline float restrict_flt(float f, float min, float max){ - if(fmax) - return max; - return f; + return max; + return f; } void draw_air(pixel *vid) { int x, y, i, j; pixel c; - + if(cmode == 2) - return; - + 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 - 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)); - for(j=0; j 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 + 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)); + for(j=0; j> 4; -const struct part_type ptypes[] = { - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Section H Ins(real world, by triclops200) 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, SC_SPECIAL, R_TEMP+0.0f, 251, "Erases particles."}, - {"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, SC_POWDERS, R_TEMP+0.0f, 70, "Very light dust. Flammable."}, - {"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, SC_LIQUID, R_TEMP+-2.0f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires."}, - {"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, SC_LIQUID, R_TEMP+0.0f, 42, "Liquid. Flammable."}, - {"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, SC_EXPLOSIVE, R_TEMP+400.0f, 88, "Ignites flammable materials. Heats air."}, - {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Heavy particles. Meltable."}, - {"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, SC_LIQUID, R_TEMP+1500.0f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold."}, - {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 97, "Light dust. Explosive."}, - {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 50, "Liquid. Pressure sensitive explosive."}, - {"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, SC_SPECIAL, R_TEMP+0.0f, 251, "Solid. Duplicates any particles it touches."}, - {"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, SC_GAS, R_TEMP+2.0f, 42, "Gas. Diffuses. Flammable. Liquifies under pressure."}, - {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 88, "Solid. Pressure sensitive explosive."}, - {"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, SC_SOLIDS, R_TEMP+0.0f, 75, "Solid. Deforms and disappears under pressure."}, - {"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, SC_SOLIDS, R_TEMP+-50.0f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Conducts electricity. Meltable."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Electricity. Conducted by metal and water."}, - {"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, SC_POWDERS, R_TEMP+-30.0f, 46, "Light particles."}, - {"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, SC_SOLIDS, R_TEMP+0.0f, 164, "Solid. Flammable."}, - {"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, SC_NUCLEAR, R_TEMP+4.0f, 60, "Neutrons. Interact with matter in odd ways."}, - {"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, SC_NUCLEAR, R_TEMP+4.0f, 251, "Heavy particles. Fissile. Generates neutrons under pressure."}, - {"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, SC_SOLIDS, R_TEMP+0.0f, 65, "Plant, drinks water and grows."}, - {"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, SC_LIQUID, R_TEMP+0.0f, 34, "Dissolves almost everything."}, - {"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, SC_SPECIAL, R_TEMP+0.0f, 251, "Hole, will drain away any particles."}, - {"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, SC_GAS, R_TEMP+100.0f, 48, "Steam, heats up air, produced from hot water."}, - {"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, 25, 1, SC_POWDERS, R_TEMP+0.0f, 100, "Concrete, stronger than stone."}, - {"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, SC_LIQUID, R_TEMP+-2.0f, 23, "Distilled water, does not conduct electricity."}, - {"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, SC_POWDERS, R_TEMP+0.0f, 110, "Salt, dissolves in water."}, - {"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, SC_LIQUID, R_TEMP+0.0f, 75, "Saltwater, conducts electricity, difficult to freeze."}, - {"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, SC_SPECIAL, R_TEMP+0.0f, 186, "Diamond. Indestructable."}, //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, SC_SOLIDS, R_TEMP+0.0f, 251, "Breakable metal."}, - {"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, SC_POWDERS, R_TEMP+0.0f, 211, "Broken metal."}, - {"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, SC_ELEC, R_TEMP+900.0f, 251, "Photons. Travel in straight lines."}, - {"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, SC_NUCLEAR, R_TEMP+30.0f, 251, "Heavy particles. Generates heat under pressure."}, - {"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, SC_SOLIDS, R_TEMP+0.0f, 44, "Wax. Melts at moderately high temperatures."}, - {"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, SC_LIQUID, R_TEMP+28.0f, 44, "Liquid Wax."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "P-Type Silicon, Will transfer current to any conductor."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "N-Type Silicon, Will only transfer current to P-Type Silicon."}, - {"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, SC_LIQUID, -205.0f, 70, "Liquid Nitrogen. Very cold."}, - {"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, SC_SPECIAL, R_TEMP+0.0f, 0, "Insulator, does not conduct heat or electricity."}, - {"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, SC_SPECIAL, R_TEMP+70.0f, 255, "Black hole, sucks in other particles and heats up."}, - {"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, SC_SPECIAL, R_TEMP-16.0f, 255, "White hole, pushes other particles away."}, - {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 240, "Rubidium, explosive, especially on contact with water, low melting point"}, - {"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, SC_EXPLOSIVE, R_TEMP+45.0f, 170, "Liquid Rubidium."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)"}, - {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Sand, Heavy particles. Meltable."}, - {"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, 1, 1, SC_SOLIDS, R_TEMP+0.0f, 150, "Solid. Meltable. Shatters under pressure"}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)"}, - {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Broken Glass, Heavy particles. Meltable. Bagels."}, - {"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, SC_ELEC, 3500.0f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals."}, - {"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, SC_GAS, 3500.0f, 115, "Plasma, extremely hot."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)"}, - {"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, SC_SOLIDS, -250.0f, 46, "Nitrogen Ice."}, - {"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, SC_GAS, R_TEMP+2.0f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when intruduced to electricity"}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Generates Electricity."}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)"}, - {"STKM", PIXPACK(0X000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, -0.7f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, SC_SPECIAL, R_TEMP+14.6f, 0, "Stickman. Don't kill him!"}, - {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)"}, - {"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, SC_GAS, R_TEMP+400.0f, 88, "Smoke"}, +const struct part_type ptypes[] = +{ + //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Section H Ins(real world, by triclops200) 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, SC_SPECIAL, R_TEMP+0.0f, 251, "Erases particles."}, + {"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, SC_POWDERS, R_TEMP+0.0f, 70, "Very light dust. Flammable."}, + {"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, SC_LIQUID, R_TEMP+-2.0f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires."}, + {"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, SC_LIQUID, R_TEMP+0.0f, 42, "Liquid. Flammable."}, + {"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, SC_EXPLOSIVE, R_TEMP+400.0f, 88, "Ignites flammable materials. Heats air."}, + {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Heavy particles. Meltable."}, + {"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, SC_LIQUID, R_TEMP+1500.0f, 60, "Heavy liquid. Ignites flammable materials. Solidifies when cold."}, + {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 97, "Light dust. Explosive."}, + {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 50, "Liquid. Pressure sensitive explosive."}, + {"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, SC_SPECIAL, R_TEMP+0.0f, 251, "Solid. Duplicates any particles it touches."}, + {"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, SC_GAS, R_TEMP+2.0f, 42, "Gas. Diffuses. Flammable. Liquifies under pressure."}, + {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 88, "Solid. Pressure sensitive explosive."}, + {"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, SC_SOLIDS, R_TEMP+0.0f, 75, "Solid. Deforms and disappears under pressure."}, + {"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, SC_SOLIDS, R_TEMP+-50.0f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Conducts electricity. Meltable."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Electricity. Conducted by metal and water."}, + {"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, SC_POWDERS, R_TEMP+-30.0f, 46, "Light particles."}, + {"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, SC_SOLIDS, R_TEMP+0.0f, 164, "Solid. Flammable."}, + {"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, SC_NUCLEAR, R_TEMP+4.0f, 60, "Neutrons. Interact with matter in odd ways."}, + {"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, SC_NUCLEAR, R_TEMP+4.0f, 251, "Heavy particles. Fissile. Generates neutrons under pressure."}, + {"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, SC_SOLIDS, R_TEMP+0.0f, 65, "Plant, drinks water and grows."}, + {"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, SC_LIQUID, R_TEMP+0.0f, 34, "Dissolves almost everything."}, + {"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, SC_SPECIAL, R_TEMP+0.0f, 251, "Hole, will drain away any particles."}, + {"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, SC_GAS, R_TEMP+100.0f, 48, "Steam, heats up air, produced from hot water."}, + {"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, 25, 1, SC_POWDERS, R_TEMP+0.0f, 100, "Concrete, stronger than stone."}, + {"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, SC_LIQUID, R_TEMP+-2.0f, 23, "Distilled water, does not conduct electricity."}, + {"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, SC_POWDERS, R_TEMP+0.0f, 110, "Salt, dissolves in water."}, + {"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, SC_LIQUID, R_TEMP+0.0f, 75, "Saltwater, conducts electricity, difficult to freeze."}, + {"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, SC_SPECIAL, R_TEMP+0.0f, 186, "Diamond. Indestructable."}, //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, SC_SOLIDS, R_TEMP+0.0f, 251, "Breakable metal."}, + {"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, SC_POWDERS, R_TEMP+0.0f, 211, "Broken metal."}, + {"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, SC_ELEC, R_TEMP+900.0f, 251, "Photons. Travel in straight lines."}, + {"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, SC_NUCLEAR, R_TEMP+30.0f, 251, "Heavy particles. Generates heat under pressure."}, + {"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, SC_SOLIDS, R_TEMP+0.0f, 44, "Wax. Melts at moderately high temperatures."}, + {"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, SC_LIQUID, R_TEMP+28.0f, 44, "Liquid Wax."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "P-Type Silicon, Will transfer current to any conductor."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "N-Type Silicon, Will only transfer current to P-Type Silicon."}, + {"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, SC_LIQUID, -205.0f, 70, "Liquid Nitrogen. Very cold."}, + {"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, SC_SPECIAL, R_TEMP+0.0f, 0, "Insulator, does not conduct heat or electricity."}, + {"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, SC_SPECIAL, R_TEMP+70.0f, 255, "Black hole, sucks in other particles and heats up."}, + {"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, SC_SPECIAL, R_TEMP-16.0f, 255, "White hole, pushes other particles away."}, + {"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, SC_EXPLOSIVE, R_TEMP+0.0f, 240, "Rubidium, explosive, especially on contact with water, low melting point"}, + {"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, SC_EXPLOSIVE, R_TEMP+45.0f, 170, "Liquid Rubidium."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)"}, + {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Sand, Heavy particles. Meltable."}, + {"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, 1, 1, SC_SOLIDS, R_TEMP+0.0f, 150, "Solid. Meltable. Shatters under pressure"}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)"}, + {"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, SC_POWDERS, R_TEMP+0.0f, 150, "Broken Glass, Heavy particles. Meltable. Bagels."}, + {"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, SC_ELEC, 3500.0f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals."}, + {"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, SC_GAS, 3500.0f, 115, "Plasma, extremely hot."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)"}, + {"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, SC_SOLIDS, -250.0f, 46, "Nitrogen Ice."}, + {"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, SC_GAS, R_TEMP+2.0f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when intruduced to electricity"}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Generates Electricity."}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)"}, + {"STKM", PIXPACK(0X000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, -0.7f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, SC_SPECIAL, R_TEMP+14.6f, 0, "Stickman. Don't kill him!"}, + {"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, SC_ELEC, R_TEMP+0.0f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)"}, + {"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, SC_GAS, R_TEMP+400.0f, 88, "Smoke"}, }; #define ST_NONE 0 #define ST_SOLID 1 #define ST_LIQUID 2 #define ST_GAS 3 -const struct part_state pstates[] = { - // Name Solid Frzp Liquid Mpnt Gas Bpoint - /* 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, 0.0f, PT_NONE, 0.0f, PT_WTRV, 100.0f, PT_NONE, 0.0f}, - /* OIL */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_GASS, 50.0f, PT_NONE, 0.0f}, - /* FIRE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_PLSM, 2500.0f}, - /* STNE */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 710.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LAVA */ {ST_LIQUID, PT_METL, 700.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, 400.0f}, - /* NITR */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.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_OILL, -40.0f, PT_NONE, 50.0f, PT_FIRE, 300.0f}, - /* C-4 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.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, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* METL */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1000.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, 0.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, 500.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, 300.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_ICEI, 0.0f, PT_DSTW, 98.0f, PT_NONE, 100.0f, PT_NONE, 0.0f}, - /* CNCT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 850.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* DSTW */ {ST_LIQUID, PT_ICEI, 0.0f, PT_NONE, 0.0f, PT_WTRV, 100.0f, PT_NONE, 0.0f}, - /* SALT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 900.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SLTW */ {ST_LIQUID, PT_ICEI, -40.0f, PT_NONE, 0.0f, PT_WTRV, 110.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, 1000.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* BRMT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1000.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, 2100.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WAX */ {ST_SOLID, PT_NONE, 0.0f, PT_MWAX, 46.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* MWAX */ {ST_LIQUID, PT_WAX, 45.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.0f}, - /* PSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* NSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* LNTG */ {ST_SOLID, PT_NICE, -210.0f, PT_NONE, 0.0f, PT_NONE, -195.8f, 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, 39.0f, PT_NONE, 0.0f, PT_FIRE, 688.0f}, - /* LRBD */ {ST_LIQUID, PT_RBDM, 38.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 688.0f}, - /* HSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* SAND */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1700.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* GLAS */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1700.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, 1700.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, -209.0f, 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, 2000.0f}, - /* LCRY */ {ST_SOLID, PT_NONE, 0.0f, PT_BGLA, 1000.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_NONE, 0.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_NONE, 0.0f}, +const struct part_state pstates[] = +{ + // Name Solid Frzp Liquid Mpnt Gas Bpoint + /* 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, 0.0f, PT_NONE, 0.0f, PT_WTRV, 100.0f, PT_NONE, 0.0f}, + /* OIL */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_GASS, 50.0f, PT_NONE, 0.0f}, + /* FIRE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_PLSM, 2500.0f}, + /* STNE */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 710.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* LAVA */ {ST_LIQUID, PT_METL, 700.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, 400.0f}, + /* NITR */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.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_OILL, -40.0f, PT_NONE, 50.0f, PT_FIRE, 300.0f}, + /* C-4 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.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, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* METL */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1000.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, 0.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, 500.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, 300.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_ICEI, 0.0f, PT_DSTW, 98.0f, PT_NONE, 100.0f, PT_NONE, 0.0f}, + /* CNCT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 850.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* DSTW */ {ST_LIQUID, PT_ICEI, 0.0f, PT_NONE, 0.0f, PT_WTRV, 100.0f, PT_NONE, 0.0f}, + /* SALT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 900.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SLTW */ {ST_LIQUID, PT_ICEI, -40.0f, PT_NONE, 0.0f, PT_WTRV, 110.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, 1000.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* BRMT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1000.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, 2100.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* WAX */ {ST_SOLID, PT_NONE, 0.0f, PT_MWAX, 46.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* MWAX */ {ST_LIQUID, PT_WAX, 45.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 400.0f}, + /* PSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* NSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* LNTG */ {ST_SOLID, PT_NICE, -210.0f, PT_NONE, 0.0f, PT_NONE, -195.8f, 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, 39.0f, PT_NONE, 0.0f, PT_FIRE, 688.0f}, + /* LRBD */ {ST_LIQUID, PT_RBDM, 38.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 688.0f}, + /* HSCN */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1414.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SAND */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1700.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GLAS */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1700.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, 1700.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, -209.0f, 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, 2000.0f}, + /* LCRY */ {ST_SOLID, PT_NONE, 0.0f, PT_BGLA, 1000.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_NONE, 0.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_NONE, 0.0f}, }; -static const unsigned char can_move[PT_NUM][PT_NUM] = { - /* A B */ - /* A 0 1 | B ligher than A */ - /* B 1 0 | A heavier than B */ - - /* N D W O F M L G N C G P D I W S S W N P P A V W C D S S D B B P U W M P N L F B W R L H S G C B T P E N N B L S S S*/ - /* o u a i i e a u i l a l f c i p n o e l l c o t n s a l m m r h r a W S S N o H H b R S a l s G h l t i B t C T W M*/ - /* n s t l r t v n t n s e r e r r o o u u n i i r c t l t n t m o a x a c c 2 a o o d b C n a c l d s r c L r r K C K*/ - /* e t r l e l a p r e s x m i e k w d t t t d d v t w t w d l t t n x n n m l l m d N d s n a r m d e E y y M H E*/ - /* NONE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* DUST */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* WATR */ {0,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* OILL */ {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* FIRE */ {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0}, - /* METL */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* LAVA */ {0,1,1,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* GUNP */ {0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* NITR */ {0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* CLNE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* GASS */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* PLEX */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* DFRM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* ICEI */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* WIRE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* SPRK */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* SNOW */ {0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* WOOD */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* NEUT */ {0,1,1,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, - /* PLUT */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* PLNT */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* ACID */ {0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* VOID */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* WTRV */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* CNCT */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* DSTW */ {0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* SALT */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* SLTW */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* DMND */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* BMTL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* BRMT */ {0,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* PHOT */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* URAN */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* WAX */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* MWAX */ {0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* PSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* NSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* LNTG */ {0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* FOAM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* BHOL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* WHOL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* RBDM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* LRBD */ {0,1,1,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, - /* HSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* SAND */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* GLAS */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* CSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* BGLA */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, - /* THDR */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* PLSM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* ETRD */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* NICE */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, - /* NBLE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* BTRY */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* LCRY */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* STKM */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* SWCH */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - /* SMKE */ {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0}, +static const unsigned char can_move[PT_NUM][PT_NUM] = +{ + /* A B */ + /* A 0 1 | B ligher than A */ + /* B 1 0 | A heavier than B */ + + /* N D W O F M L G N C G P D I W S S W N P P A V W C D S S D B B P U W M P N L F B W R L H S G C B T P E N N B L S S S*/ + /* o u a i i e a u i l a l f c i p n o e l l c o t n s a l m m r h r a W S S N o H H b R S a l s G h l t i B t C T W M*/ + /* n s t l r t v n t n s e r e r r o o u u n i i r c t l t n t m o a x a c c 2 a o o d b C n a c l d s r c L r r K C K*/ + /* e t r l e l a p r e s x m i e k w d t t t d d v t w t w d l t t n x n n m l l m d N d s n a r m d e E y y M H E*/ + /* NONE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* DUST */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* WATR */ {0,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* OILL */ {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* FIRE */ {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0}, + /* METL */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* LAVA */ {0,1,1,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* GUNP */ {0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* NITR */ {0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* CLNE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* GASS */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* PLEX */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* DFRM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* ICEI */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* WIRE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* SPRK */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* SNOW */ {0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* WOOD */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* NEUT */ {0,1,1,1,1,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, + /* PLUT */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* PLNT */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* ACID */ {0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* VOID */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* WTRV */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* CNCT */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* DSTW */ {0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* SALT */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* SLTW */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* DMND */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* BMTL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* BRMT */ {0,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* PHOT */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* URAN */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* WAX */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* MWAX */ {0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* PSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* NSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* LNTG */ {0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* FOAM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* BHOL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* WHOL */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* RBDM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* LRBD */ {0,1,1,1,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, + /* HSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* SAND */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* GLAS */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* CSCN */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* BGLA */ {0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, + /* THDR */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* PLSM */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* ETRD */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* NICE */ {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, + /* NBLE */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* BTRY */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* LCRY */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* STKM */ {0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* SWCH */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + /* SMKE */ {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0}, }; #define FLAG_STAGNANT 1 -typedef struct { +typedef struct +{ int type; int life, ctype; float x, y, vx, vy; - float temp; - float pavg[2]; + float temp; + float pavg[2]; int flags; } particle; particle *parts; @@ -776,13 +802,15 @@ float player[20]; //[0] is a command cell, [3]-[18] are legs positions, [19] is int isplayer = 0; //It shows is player spawned or not int mousex, mousey = 0; //They contain mouse position -void menu_count(void){ - int i=0; - msections[SC_WALL].itemcount = UI_WALLCOUNT-4; - msections[SC_SPECIAL].itemcount = 4; - for(i=0; i=XRES || ny>=YRES) - return 0; + return 0; if(x==nx && y==ny) - return 1; + return 1; r = pmap[ny][nx]; if(r && (r>>8)>8].type; - - if(parts[i].type==PT_PHOT&&((r&0xFF)==PT_GLAS||(r&0xFF)==PT_PHOT||(r&0xFF)==PT_CLNE||((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))){ - return 1; - } - - if((r&0xFF)==PT_VOID){ - parts[i].type=PT_NONE; - return 0; - } - if((r&0xFF)==PT_BHOL){ - 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; - } + r = (r&~0xFF) | parts[r>>8].type; + + if(parts[i].type==PT_PHOT&&((r&0xFF)==PT_GLAS||(r&0xFF)==PT_PHOT||(r&0xFF)==PT_CLNE||((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))) + { + return 1; + } + + if((r&0xFF)==PT_VOID) + { + parts[i].type=PT_NONE; + return 0; + } + if((r&0xFF)==PT_BHOL) + { + 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; + } + + if(parts[i].type==PT_STKM) //Stick man's head shouldn't collide + { + return 1; + } + + if(bmap[ny/CELL][nx/CELL]==12 && !emap[y/CELL][x/CELL]) + { + return 1; + } + if(bmap[ny/CELL][nx/CELL]==13 && ptypes[parts[i].type].falldown!=0 && parts[i].type!=PT_FIRE) + { + return 0; + } + if((bmap[y/CELL][x/CELL]==12 && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=12 && !emap[ny/CELL][nx/CELL])) + { + return 0; + } - if(parts[i].type==PT_STKM) //Stick man's head shouldn't collide - { - return 1; - } - - if(bmap[ny/CELL][nx/CELL]==12 && !emap[y/CELL][x/CELL]){ - return 1; - } - if(bmap[ny/CELL][nx/CELL]==13 && ptypes[parts[i].type].falldown!=0 && parts[i].type!=PT_FIRE){ - return 0; - } - if((bmap[y/CELL][x/CELL]==12 && !emap[y/CELL][x/CELL]) && (bmap[ny/CELL][nx/CELL]!=12 && !emap[ny/CELL][nx/CELL])){ - return 0; - } - if(ptypes[parts[i].type].falldown!=2 && bmap[ny/CELL][nx/CELL]==3) - return 0; + return 0; if((parts[i].type==PT_NEUT ||parts[i].type==PT_PHOT) && bmap[ny/CELL][nx/CELL]==7 && !emap[ny/CELL][nx/CELL]) - return 0; + return 0; if(r && (r>>8)= PT_NUM || !can_move[parts[i].type][(r&0xFF)])) - return 0; - - if(parts[i].type==PT_CNCT && y= PT_NUM || !can_move[parts[i].type][(r&0xFF)])) + return 0; + + if(parts[i].type==PT_CNCT && y>8)>= 8; - parts[r].x += x-nx; - parts[r].y += y-ny; + if(r && (r>>8)>= 8; + parts[r].x += x-nx; + parts[r].y += y-ny; } - + return 1; } @@ -869,13 +906,13 @@ void kill_part(int i) { int x, y; parts[i].type = PT_NONE; - + x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); - + 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 + 4.0f, MIN_TEMP, MAX_TEMP); - } - if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP){ - 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].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; + 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 + 4.0f, MIN_TEMP, MAX_TEMP); + } + if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) + { + 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].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(p==-1) + { + if(pmap[y][x]) + 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(p==-1) { - if(pmap[y][x]) - 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_STKM) { - 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].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; } - if(t==PT_ACID){ - parts[i].life = 75; - } - //Testing - /*if(t==PT_WOOD){ - parts[i].life = 150; - }*/ - //End Testing + if(t==PT_ACID) + { + parts[i].life = 75; + } + //Testing + /*if(t==PT_WOOD){ + parts[i].life = 150; + }*/ + //End Testing if(t==PT_FIRE) - parts[i].life = rand()%50+120; - if(t==PT_PLSM) - parts[i].life = rand()%150+50; + parts[i].life = rand()%50+120; + if(t==PT_PLSM) + parts[i].life = rand()%150+50; if(t==PT_LAVA) - parts[i].life = rand()%120+240; + parts[i].life = rand()%120+240; if(t==PT_NBLE) - parts[i].life = 0; - if(t==PT_NEUT) { - float r = (rand()%128+128)/127.0f; - float a = (rand()%360)*3.14159f/180.0f; - parts[i].life = rand()%480+480; - parts[i].vx = r*cosf(a); - parts[i].vy = r*sinf(a); + parts[i].life = 0; + if(t==PT_NEUT) + { + float r = (rand()%128+128)/127.0f; + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = rand()%480+480; + parts[i].vx = r*cosf(a); + parts[i].vy = r*sinf(a); } - if(t==PT_PHOT) { - float r = (rand()%3-1)*3; - float a = (rand()%3-1)*3; - parts[i].life = 680; - if(a==0.0f&&r==0.0f){ - parts[i].life = 0; - parts[i].type = PT_NONE; - return -1; - } else { - parts[i].vx = a; - parts[i].vy = r; - } - //} else { - // parts[i].life = 0; - // parts[i].type = PT_NONE; - //} + if(t==PT_PHOT) + { + float r = (rand()%3-1)*3; + float a = (rand()%3-1)*3; + parts[i].life = 680; + if(a==0.0f&&r==0.0f) + { + parts[i].life = 0; + parts[i].type = PT_NONE; + return -1; + } + else + { + parts[i].vx = a; + parts[i].vy = r; + } + //} else { + // parts[i].life = 0; + // parts[i].type = PT_NONE; + //} } - + if(t!=PT_STKM) - pmap[y][x] = t|(i<<8); + pmap[y][x] = t|(i<<8); else { - if(isplayer==0) - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_STKM; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 100; - parts[i].ctype = 0; - parts[i].temp = ptypes[t].heat; - player[2] = PT_DUST; - player[3] = x-1; //Setting legs positions - player[4] = y+6; - player[5] = x-1; - player[6] = y+6; + if(isplayer==0) + { + parts[i].x = (float)x; + parts[i].y = (float)y; + parts[i].type = PT_STKM; + parts[i].vx = 0; + parts[i].vy = 0; + parts[i].life = 100; + parts[i].ctype = 0; + parts[i].temp = ptypes[t].heat; + player[2] = PT_DUST; + 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[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[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; + player[15] = x+3; + player[16] = y+12; + player[17] = x+3; + player[18] = y+12; - isplayer = 1; - } + isplayer = 1; + } } - + return i; } void delete_part(int x, int y) { unsigned i; - + if(x<0 || y<0 || x>=XRES || y>=YRES) - return; + return; i = pmap[y][x]; if(!i || (i>>8)>=NPART) - return; - + return; + kill_part(i>>8); pmap[y][x] = 0; // just in case } @@ -1070,78 +1127,79 @@ inline void blendpixel(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; - 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; + 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); } int sign(float i) //Signum function { - if (i<0) - return -1; - if (i>0) - return 1; - return 0; -} + if (i<0) + return -1; + if (i>0) + return 1; + return 0; +} void draw_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a) //Draws a line { - int dx, dy, i, sx, sy, check, e, x, y; + int dx, dy, i, sx, sy, check, e, x, y; - dx = abs(x1-x2); - dy = abs(y1-y2); - sx = sign(x2-x1); - sy = sign(y2-y1); - x = x1; - y = y1; - check = 0; + dx = abs(x1-x2); + dy = abs(y1-y2); + sx = sign(x2-x1); + sy = sign(y2-y1); + x = x1; + y = y1; + check = 0; - if (dy>dx) - { - 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; + 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; + r = 255; if(g>255) - g = 255; + g = 255; if(b>255) b = 255; vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); @@ -1161,1685 +1219,2060 @@ int is_wire_off(int x, int y) void set_emap(int x, int y) { int x1, x2; - + if(!is_wire_off(x, y)) - return; - + return; + // go left as far as possible x1 = x2 = x; - while(x1>0) { - if(!is_wire_off(x1-1, y)) - break; - x1--; + while(x1>0) + { + 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); + 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); - } - + 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>>8) >= 0){ - return parts[pmr>>8].type; - } else { - return PT_NONE; - } +inline int parts_avg(int ci, int ni) +{ + int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)]; + if((pmr>>8) < NPART && (pmr>>8) >= 0) + { + return parts[pmr>>8].type; + } + else + { + return PT_NONE; + } } -int nearest_part(int ci, int t){ - int distance = sqrt(pow(XRES, 2)+pow(YRES, 2)); - int ndistance = 0; - int id = -1; - int i = 0; - int cx = (int)parts[ci].x; - int cy = (int)parts[ci].y; - for(i=0; i=XRES || y>=YRES || - ((bmap[y/CELL][x/CELL]==1 || - bmap[y/CELL][x/CELL]==8 || - bmap[y/CELL][x/CELL]==9 || - (bmap[y/CELL][x/CELL]==2) || - (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) || - (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) || - (bmap[y/CELL][x/CELL]==6 && (t==PT_WIRE || t==PT_SPRK)) || - (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) { - kill_part(i); - continue; - } - - vx[y/CELL][x/CELL] *= ptypes[t].airloss; - vy[y/CELL][x/CELL] *= ptypes[t].airloss; - vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx; - vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy; - if(t==PT_GASS||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+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_DFRM && !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 { - parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; - parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity; - } - - 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); - } - - // interpolator + float pt = R_TEMP; + float c_heat = 0.0f; + int h_count = 0; + int starti = (start*-1); + for(i=start; i<(NPART-starti); i+=inc) + if(parts[i].type) + { + + lx = parts[i].x; + ly = parts[i].y; + t = parts[i].type; + + if(sys_pause) + goto justdraw; + + if(parts[i].life && t!=PT_ACID && t!=PT_WOOD && t!=PT_NBLE && t!=PT_SWCH && t!=PT_STKM) + { + if(!(parts[i].life==10&&parts[i].type==PT_LCRY)) + parts[i].life--; + if(parts[i].life<=0 && t!=PT_WIRE && t!=PT_WATR && t!=PT_RBDM && t!=PT_LRBD && t!=PT_SLTW && t!=PT_BRMT && t!=PT_PSCN && t!=PT_NSCN && t!=PT_HSCN && t!=PT_CSCN && t!=PT_BMTL && t!=PT_SPRK && t!=PT_LAVA && t!=PT_ETRD&&t!=PT_LCRY) + { + kill_part(i); + continue; + } + if(parts[i].life<=0 && t==PT_SPRK) + { + t = parts[i].ctype; + if(t!=PT_WIRE&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE) + parts[i].temp = R_TEMP; + if(!t) + t = PT_WIRE; + parts[i].type = t; + parts[i].life = 4; + if(t == PT_WATR) + parts[i].life = 64; + if(t == PT_SLTW) + parts[i].life = 54; + } + } + + if(t==PT_SPRK&&parts[i].ctype==PT_SPRK) + { + kill_part(i); + continue; + } + + x = (int)(parts[i].x+0.5f); + y = (int)(parts[i].y+0.5f); + + + if(x<0 || y<0 || x>=XRES || y>=YRES || + ((bmap[y/CELL][x/CELL]==1 || + bmap[y/CELL][x/CELL]==8 || + bmap[y/CELL][x/CELL]==9 || + (bmap[y/CELL][x/CELL]==2) || + (bmap[y/CELL][x/CELL]==3 && ptypes[t].falldown!=2) || + (bmap[y/CELL][x/CELL]==10 && ptypes[t].falldown!=1) || + (bmap[y/CELL][x/CELL]==6 && (t==PT_WIRE || t==PT_SPRK)) || + (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) + { + kill_part(i); + continue; + } + + vx[y/CELL][x/CELL] *= ptypes[t].airloss; + vy[y/CELL][x/CELL] *= ptypes[t].airloss; + vx[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vx; + vy[y/CELL][x/CELL] += ptypes[t].airdrag*parts[i].vy; + if(t==PT_GASS||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+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_DFRM && !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 + { + parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; + parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + ptypes[t].gravity; + } + + 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); + } + + // interpolator #ifdef WIN32 - mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy)); + mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy)); #else - mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy)); + 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]!=5)) { - 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_GASS && pv[y/CELL][x/CELL]>4.0f) - t = parts[i].type = PT_OILL; - if(t==PT_OILL && pv[y/CELL][x/CELL]<-4.0f) - t = parts[i].type = PT_GASS; - } - if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f) - 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.05f || parts[i].pavg[1]-parts[i].pavg[0] < -0.05f){ - parts[i].type = PT_BGLA; - } - } - 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_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1){ - nearp = nearest_part(i, PT_ETRD); - if(nearp!=-1){ - create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 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; - } - } - - if(!legacy_enable){ - int ctemp = pv[y/CELL][x/CELL]*2; - c_heat = 0.0f; - h_count = 0; - if(ptypes[t].hconduct>(rand()%250)){ - 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){ - 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].temp = parts[i].temp; - } - } - } - } - if(pt>=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; - t = parts[i].type = parts[i].ctype; - parts[i].ctype = PT_NONE; - } else if(pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp){ - 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){ - 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; - 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; - } - }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 { - 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_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); - } - pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); - } - } - if(t==PT_CSCN&&parts[i].temp>24.0f){ - pt = parts[i].temp -= 2.5f; - } - if(t==PT_HSCN&&parts[i].temp>24.0f){ - pt = parts[i].temp -= 2.5f; - } - - if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_WIRE || t==PT_RBDM || t==PT_LRBD || t==PT_BRMT || t==PT_PSCN || t==PT_NSCN || t==PT_HSCN || t==PT_CSCN || t==PT_BMTL || t==PT_SPRK|| t == PT_NBLE) { - 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(((r&0xFF)==PT_WIRE || (r&0xFF)==PT_ETRD || (r&0xFF)==PT_PSCN || (r&0xFF)==PT_NSCN || (r&0xFF)==PT_HSCN || (r&0xFF)==PT_CSCN || (r&0xFF)==PT_BMTL || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD || (r&0xFF)==PT_BRMT||(r&0xFF)==PT_NBLE) && 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) { - 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_HSCN||t==PT_CSCN) { - 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_WIRE) { - parts[i].temp = 200.0f; - } - } - } - //PLANT - 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; - } else if((r&0xFF)==PT_LAVA && 1>(rand()%250)){ - parts[i].life = 4; - t = parts[i].type = PT_FIRE; - } - //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; - - } - } - } - 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_SLTW; - } - 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_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 && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50) { - 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()%2 ? PT_LAVA : PT_URAN); - } 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.00f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - fe ++; - } - if((r&0xFF)==PT_GUNP && 15>(rand()%1000)) - parts[r>>8].type = PT_DUST; - 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_DFRM; - if((r&0xFF)==PT_NITR && 15>(rand()%1000)) - parts[r>>8].type = PT_OILL; - if((r&0xFF)==PT_OILL && 5>(rand()%1000)) - parts[r>>8].type = PT_GASS; - if((r&0xFF)==PT_PLNT && 5>(rand()%100)) - parts[r>>8].type = PT_WOOD; - } - } 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; - } - } - } 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_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){ - if((rt==PT_WIRE||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE)&&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; - } - } - } - } - if(t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)) || t ==PT_SWCH) { - if(t==PT_SWCH) - if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11) - { - parts[i].life--; - } - 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]!=5) - continue; - rt = parts[r>>8].type; - if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL) || t!=PT_SPRK) && - (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_METL && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_HSCN && rt!=PT_CSCN && rt!=PT_WIRE && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT)) && - 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_WIRE && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_HSCN && rt!=PT_CSCN && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT)) && - 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_METL; - 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_METL; - 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_METL; - parts[i].ctype = PT_NONE; - goto killed; - } - } - } - pavg = parts_avg(i, r>>8); - if(t==PT_SWCH&&pavg!= PT_INSL){ - if(parts[r>>8].type == 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; - } - } - } - if(rt==PT_SWCH && t==PT_SPRK){ - pavg = parts_avg(r>>8, i); - if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL) - 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); - if(pavg != PT_INSL){ - if(t==PT_SPRK && (rt==PT_WIRE||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)=100.0f)&&parts[i].ctype==PT_HSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=100.0f)&&parts[i].ctype==PT_CSCN) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||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<400.0f&&!legacy_enable&&!(rt==PT_LRBD||rt==PT_RBDM||rt==PT_HSCN||rt==PT_CSCN)) - parts[r>>8].temp = parts[r>>8].temp+10.0f; - } - } - if(t==PT_SPRK && rt==PT_HSCN && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].temp>100.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_CSCN && parts[r>>8].life==0 && - (parts[i].life<3 || ((r>>8)>8].temp<100.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_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_WIRE||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<=1) - { - parts[i].type = PT_SWCH; - parts[i].life = 11; - } - } - } - killed: - if(parts[i].type == PT_NONE) - continue; - } - - if(t==PT_STKM) - { - //Tempirature handling - if(parts[i].temp<-30) - parts[i].life -= 0.2; - if((parts[i].temp<36.6f) && (parts[i].temp>=-30)) - parts[i].temp += 1; - - //Death - if(parts[i].life<=0 || pv[y/CELL][x/CELL]>=4.5f) //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; - } + 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]!=5)) + { + parts[i].x = ix; + parts[i].y = iy; + break; + } + } + } - //Verlet integration - pp = 2*player[3]-player[5]; - player[5] = player[3]; - player[3] = pp; - pp = 2*player[4]-player[6]; - player[6] = player[4]; - player[4] = pp; - - pp = 2*player[7]-player[9]; - player[9] = player[7]; - player[7] = pp; - pp = 2*player[8]-player[10]+1; - player[10] = player[8]; - player[8] = pp; - - pp = 2*player[11]-player[13]; - player[13] = player[11]; - player[11] = pp; - pp = 2*player[12]-player[14]; - player[14] = player[12]; - player[12] = pp; - - pp = 2*player[15]-player[17]; - player[17] = player[15]; - player[15] = pp; - pp = 2*player[16]-player[18]+1; - player[18] = player[16]; - player[16] = pp; + 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_GASS && pv[y/CELL][x/CELL]>4.0f) + t = parts[i].type = PT_OILL; + if(t==PT_OILL && pv[y/CELL][x/CELL]<-4.0f) + t = parts[i].type = PT_GASS; + } + if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f) + 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.05f || parts[i].pavg[1]-parts[i].pavg[0] < -0.05f) + { + parts[i].type = PT_BGLA; + } + } + 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); + } - //Go left - if (((int)(player[0])&0x01) == 0x01) - { - 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[9] += 3; player[10] += 2; player[5] += 2; - } + if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1) + { + nearp = nearest_part(i, PT_ETRD); + if(nearp!=-1) + { + create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 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; + } + } - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[17] += 3; player[18] += 2; player[13] +=2; - } - } - else - { - if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids - { - player[9] += 1; player[10] += 1; player[5] += 1; - } + if(!legacy_enable) + { + int ctemp = pv[y/CELL][x/CELL]*2; + c_heat = 0.0f; + h_count = 0; + if(ptypes[t].hconduct>(rand()%250)) + { + 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) + { + 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].temp = parts[i].temp; + } + } + } + } + if(pt>=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; + t = parts[i].type = parts[i].ctype; + parts[i].ctype = PT_NONE; + } + else if(pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp) + { + 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) + { + 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; + 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; + } + } + 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 + { + 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_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); + } + pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); + } + } + if(t==PT_CSCN&&parts[i].temp>24.0f) + { + pt = parts[i].temp -= 2.5f; + } + if(t==PT_HSCN&&parts[i].temp>24.0f) + { + pt = parts[i].temp -= 2.5f; + } - if (pmap[(int)(player[16]-1)][(int)(player[15])]) - { - player[17] += 1; player[18] += 1; player[13] +=1; - } - } - } - - //Go right - if (((int)(player[0])&0x02) == 0x02) - { - 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[9] -= 3; player[10] += 2; player[5] -= 2; - } + if(t==PT_WATR || t==PT_ETRD || t==PT_SLTW || t==PT_WIRE || t==PT_RBDM || t==PT_LRBD || t==PT_BRMT || t==PT_PSCN || t==PT_NSCN || t==PT_HSCN || t==PT_CSCN || t==PT_BMTL || t==PT_SPRK|| t == PT_NBLE) + { + 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(((r&0xFF)==PT_WIRE || (r&0xFF)==PT_ETRD || (r&0xFF)==PT_PSCN || (r&0xFF)==PT_NSCN || (r&0xFF)==PT_HSCN || (r&0xFF)==PT_CSCN || (r&0xFF)==PT_BMTL || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD || (r&0xFF)==PT_BRMT||(r&0xFF)==PT_NBLE) && 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) + { + 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_HSCN||t==PT_CSCN) + { + 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_WIRE) + { + parts[i].temp = 200.0f; + } + } + } + //PLANT + 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; + } + else if((r&0xFF)==PT_LAVA && 1>(rand()%250)) + { + parts[i].life = 4; + t = parts[i].type = PT_FIRE; + } + //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; - } - } - - //Charge detector wall if foot inside - if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6) - set_emap((int)player[7]/CELL, (int)player[8]/CELL); - if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6) - set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL); + } + } + } + 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_SLTW; + } + 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; - //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((pstates[pmap[ny+y][nx+x]&0xFF].state != ST_SOLID && (pmap[ny+y][nx+x]&0xFF)!=PT_STKM - && (pmap[ny+y][nx+x]&0xFF)!=PT_WHOL && (pmap[ny+y][nx+x]&0xFF)!=PT_BHOL) - || (pmap[ny+y][nx+x]&0xFF) == PT_LNTG) - { - 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); - } + } + } + } + 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((pmap[ny+y][nx+x]&0xFF) == PT_NEUT) - { - parts[i].life -= (102-parts[i].life)/2; - kill_part(pmap[ny+y][nx+x]>>8); - } - } - - //Head position - nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01); - ny = y - 3*(player[1] == 0); + 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; - //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 - { - create_part(-1, nx, ny, player[2]); - r = pmap[ny][nx]; - if( ((r>>8) < NPART) && (r>>8)>=0 ) - parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); - } - } - } + } + 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_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 && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50) + { + 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()%2 ? PT_LAVA : PT_URAN); + } + 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.00f * CFDS; //Used to be 2, some people said nukes weren't powerful enough + fe ++; + } + if((r&0xFF)==PT_GUNP && 15>(rand()%1000)) + parts[r>>8].type = PT_DUST; + 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_DFRM; + if((r&0xFF)==PT_NITR && 15>(rand()%1000)) + parts[r>>8].type = PT_OILL; + if((r&0xFF)==PT_OILL && 5>(rand()%1000)) + parts[r>>8].type = PT_GASS; + if((r&0xFF)==PT_PLNT && 5>(rand()%100)) + parts[r>>8].type = PT_WOOD; + } + } + 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; + } + } + } + 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_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) + { + if((rt==PT_WIRE||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE)&&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; + } + } + } + } + if(t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)) || t ==PT_SWCH) + { + if(t==PT_SWCH) + if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11) + { + parts[i].life--; + } + 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]!=5) + continue; + rt = parts[r>>8].type; + if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL) || t!=PT_SPRK) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_METL && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_HSCN && rt!=PT_CSCN && rt!=PT_WIRE && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT)) && + 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_WIRE && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_HSCN && rt!=PT_CSCN && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT)) && + 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_METL; + 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_METL; + 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_METL; + parts[i].ctype = PT_NONE; + goto killed; + } + } + } + pavg = parts_avg(i, r>>8); + if(t==PT_SWCH&&pavg!= PT_INSL) + { + if(parts[r>>8].type == 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; + } + } + } + if(rt==PT_SWCH && t==PT_SPRK) + { + pavg = parts_avg(r>>8, i); + if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL) + 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); + if(pavg != PT_INSL) + { + if(t==PT_SPRK && (rt==PT_WIRE||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN||rt==PT_NBLE) && parts[r>>8].life==0 && + (parts[i].life<3 || ((r>>8)=100.0f)&&parts[i].ctype==PT_HSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=100.0f)&&parts[i].ctype==PT_CSCN) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||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<400.0f&&!legacy_enable&&!(rt==PT_LRBD||rt==PT_RBDM||rt==PT_HSCN||rt==PT_CSCN)) + parts[r>>8].temp = parts[r>>8].temp+10.0f; + } + } + if(t==PT_SPRK && rt==PT_HSCN && parts[r>>8].life==0 && + (parts[i].life<3 || ((r>>8)>8].temp>100.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_CSCN && parts[r>>8].life==0 && + (parts[i].life<3 || ((r>>8)>8].temp<100.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_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_WIRE||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; + } + } - //Jump - if (((int)(player[0])&0x04) == 0x04) - { - if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])]) - { - parts[i].vy = -5; player[10] += 1; player[18] += 1; - } + 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<=1) + { + parts[i].type = PT_SWCH; + parts[i].life = 11; + } + } + } +killed: + if(parts[i].type == PT_NONE) + continue; + } - } - - //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; + if(t==PT_STKM) + { + //Tempirature handling + if(parts[i].temp<-30) + parts[i].life -= 0.2; + if((parts[i].temp<36.6f) && (parts[i].temp>=-30)) + parts[i].temp += 1; - //Side collisions checking - for(nx = -3; nx <= 3; nx++) - { - if(pmap[(int)(player[16]-2)][(int)(player[15]+nx)]) - player[15] -= nx; + //Death + if(parts[i].life<=0 || pv[y/CELL][x/CELL]>=4.5f) //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; + } - if(pmap[(int)(player[8]-2)][(int)(player[7]+nx)]) - player[7] -= nx; - } + //Verlet integration + pp = 2*player[3]-player[5]; + player[5] = player[3]; + player[3] = pp; + pp = 2*player[4]-player[6]; + player[6] = player[4]; + player[4] = pp; - //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 :-) + pp = 2*player[7]-player[9]; + player[9] = player[7]; + player[7] = pp; + pp = 2*player[8]-player[10]+1; + player[10] = player[8]; + player[8] = pp; - //For left leg - if (r && (r&0xFF)!=PT_STKM) - { - if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) //Liquid checks - { - if(parts[i].y<(player[8]-10)) - parts[i].vy = 1; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5; - } - else - { - player[8] += ny-1; - parts[i].vy -= 0.5*parts[i].vy; - } - player[9] = player[7]; - } + pp = 2*player[11]-player[13]; + player[13] = player[11]; + player[11] = pp; + pp = 2*player[12]-player[14]; + player[14] = player[12]; + player[12] = pp; - r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)]; + pp = 2*player[15]-player[17]; + player[17] = player[15]; + player[15] = pp; + pp = 2*player[16]-player[18]+1; + player[18] = player[16]; + player[16] = pp; - //For right leg - if (r && (r&0xFF)!=PT_STKM) - { - if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) - { - if(parts[i].y<(player[16]-10)) - parts[i].vy = 1; - else - parts[i].vy = 0; - if(abs(parts[i].vx)>1) - parts[i].vx *= 0.5; - } - else - { - player[16] += ny-1; - parts[i].vy -= 0.5*parts[i].vy; - } - player[17] = player[15]; - } + //Go left + if (((int)(player[0])&0x01) == 0x01) + { + 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[9] += 3; + player[10] += 2; + player[5] += 2; + } - //If it falls too fast - if (parts[i].vy>=30) - { - parts[i].y -= 10+ny; - parts[i].vy = -10; - } + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[17] += 3; + player[18] += 2; + player[13] +=2; + } + } + else + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids + { + player[9] += 1; + player[10] += 1; + player[5] += 1; + } - } + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[17] += 1; + player[18] += 1; + player[13] +=1; + } + } + } - //Keeping legs distance - if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1) - { - player[7] += 0.2; - player[15] -= 0.2; - } - - if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1) - { - player[3] += 0.2; - player[11] -= 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>=50 || parts[r>>8].temp<=-30) - { - parts[i].life -= 2; - player[16] -= 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; + //Go right + if (((int)(player[0])&0x02) == 0x02) + { + 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[9] -= 3; + player[10] += 2; + player[5] -= 2; + } - 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>=50 || parts[r>>8].temp<=-30) - { - parts[i].life -= 2; - player[8] -= 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; + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[17] -= 3; + player[18] += 2; + player[13] -= 2; + } + } + else + { + if (pmap[(int)(player[8]-1)][(int)(player[7])]) + { + player[9] -= 1; + player[10] += 1; + player[5] -= 1; + } - isplayer = 1; - } + if (pmap[(int)(player[16]-1)][(int)(player[15])]) + { + player[17] -= 1; + player[18] += 1; + player[13] -= 1; + } - 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=XRES-CELL || - ny=YRES-CELL) { - parts[i].x = lx; - parts[i].y = ly; - kill_part(i); - continue; - } - - 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)) { - s = 0; - if(!rt || nt) - rt = 50; - 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 && jx+ISTP) nx=x+ISTP; - if(nxy+ISTP) ny=y+ISTP; - if(ny(rand()%1000)) { - kill_part(i); - continue; - } else if(try_move(i, x, y, 2*x-nx, ny)) { - parts[i].x = (float)(2*x-nx); - parts[i].y = (float)iy; - parts[i].vx *= ptypes[t].collision; - } else if(try_move(i, x, y, nx, 2*y-ny)) { - parts[i].x = (float)ix; - parts[i].y = (float)(2*y-ny); - parts[i].vy *= ptypes[t].collision; - } else { - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; - } - } - } - - justdraw: - - nx = (int)(parts[i].x+0.5f); - ny = (int)(parts[i].y+0.5f); - - if(nx=XRES-CELL || - ny=YRES-CELL) { - kill_part(i); - continue; - } - if(cmode!=CM_HEAT){ - if(t==PT_STKM) //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", (int)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); - } + //Charge detector wall if foot inside + if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6) + set_emap((int)player[7]/CELL, (int)player[8]/CELL); + if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6) + set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL); - 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); + //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((pstates[pmap[ny+y][nx+x]&0xFF].state != ST_SOLID && (pmap[ny+y][nx+x]&0xFF)!=PT_STKM + && (pmap[ny+y][nx+x]&0xFF)!=PT_WHOL && (pmap[ny+y][nx+x]&0xFF)!=PT_BHOL) + || (pmap[ny+y][nx+x]&0xFF) == PT_LNTG) + { + 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); + } - isplayer = 1; //It's a secret. Tssss... - } + 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(t==PT_ACID) { - if(parts[i].life>255) parts[i].life = 255; - if(parts[i].life<47) parts[i].life = 48; - s = (255/((parts[i].life-46)*28)); - if(s==0) s = 1; - cr = PIXR(ptypes[t].pcolors)/s; - cg = PIXG(ptypes[t].pcolors)/s; - cb = PIXB(ptypes[t].pcolors)/s; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - if(cmode==4){ - 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 == 3||cmode==4) { - 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_PHOT) { - if(cmode == 3||cmode==4) { - vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - cg = 12; - cb = 12; - 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 = 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_SWCH && parts[i].life == 10) { - x = nx; - y = ny; - blendpixel(vid,x,y,17,217,24,255); - } else if(t==PT_SMKE) { - if(cmode == 3||cmode==4) { - 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 == 3||cmode==4) { - 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 == 3||cmode==4) { - 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_LCRY) { - if(cmode == 3||cmode==4) { - //cr = R/8; - //cg = G/8; - //cb = B/8; - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(0x50+(parts[i].life*10), 0x50+(parts[i].life*10), 0x50+(parts[i].life*10)); - //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 = 0x50+(parts[i].life*10); - cg = 0x50+(parts[i].life*10); - cb = 0x50+(parts[i].life*10); - 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_PLSM) { - float ttemp = 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 == 3||cmode==4) { - 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_FIRE && parts[i].life) { - if(cmode == 3||cmode==4) { - 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 == 3||cmode==4) { - 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 == 3 || cmode==4) { - 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))/512) ) *3, 0.0f, (512.0f*3)-3); - uint8 R = color_data[caddress]; - uint8 G = color_data[caddress+1]; - uint8 B = color_data[caddress+2]; + //Head position + nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01); + ny = y - 3*(player[1] == 0); - if(t==PT_STKM) //Stick man should be visible in heat mode - { - char buff[10]; //Buffer for HP + //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 + { + create_part(-1, nx, ny, player[2]); + r = pmap[ny][nx]; + if( ((r>>8) < NPART) && (r>>8)>=0 ) + parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); + } + } + } - if(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head - { - sprintf(buff, "%3d", (int)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); - } + //Jump + if (((int)(player[0])&0x04) == 0x04) + { + if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])]) + { + parts[i].vy = -5; + player[10] += 1; + player[18] += 1; + } + + } + + //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++) + { + if(pmap[(int)(player[16]-2)][(int)(player[15]+nx)]) + player[15] -= nx; + + if(pmap[(int)(player[8]-2)][(int)(player[7]+nx)]) + 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 || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) //Liquid checks + { + if(parts[i].y<(player[8]-10)) + parts[i].vy = 1; + else + parts[i].vy = 0; + if(abs(parts[i].vx)>1) + parts[i].vx *= 0.5; + } + else + { + player[8] += ny-1; + parts[i].vy -= 0.5*parts[i].vy; + } + 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 || pstates[r&0xFF].state == ST_GAS || (r&0xFF)==PT_LNTG) + { + if(parts[i].y<(player[16]-10)) + parts[i].vy = 1; + else + parts[i].vy = 0; + if(abs(parts[i].vx)>1) + parts[i].vx *= 0.5; + } + else + { + player[16] += ny-1; + parts[i].vy -= 0.5*parts[i].vy; + } + player[17] = player[15]; + } + + //If it falls too fast + if (parts[i].vy>=30) + { + parts[i].y -= 10+ny; + parts[i].vy = -10; + } + + } + + //Keeping legs distance + if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1) + { + player[7] += 0.2; + player[15] -= 0.2; + } + + if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1) + { + player[3] += 0.2; + player[11] -= 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>=50 || parts[r>>8].temp<=-30) + { + parts[i].life -= 2; + player[16] -= 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>=50 || parts[r>>8].temp<=-30) + { + parts[i].life -= 2; + player[8] -= 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_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=XRES-CELL || + ny=YRES-CELL) + { + parts[i].x = lx; + parts[i].y = ly; + kill_part(i); + continue; + } + + 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)) + { + s = 0; + if(!rt || nt) + rt = 50; + 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 && jx+ISTP) nx=x+ISTP; + if(nxy+ISTP) ny=y+ISTP; + if(ny(rand()%1000)) + { + kill_part(i); + continue; + } + else if(try_move(i, x, y, 2*x-nx, ny)) + { + parts[i].x = (float)(2*x-nx); + parts[i].y = (float)iy; + parts[i].vx *= ptypes[t].collision; + } + else if(try_move(i, x, y, nx, 2*y-ny)) + { + parts[i].x = (float)ix; + parts[i].y = (float)(2*y-ny); + parts[i].vy *= ptypes[t].collision; + } + else + { + parts[i].vx *= ptypes[t].collision; + parts[i].vy *= ptypes[t].collision; + } + } + } + +justdraw: + + nx = (int)(parts[i].x+0.5f); + ny = (int)(parts[i].y+0.5f); + + if(nx=XRES-CELL || + ny=YRES-CELL) + { + kill_part(i); + continue; + } + if(cmode!=CM_HEAT) + { + if(t==PT_STKM) //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", (int)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... + } + + if(t==PT_ACID) + { + if(parts[i].life>255) parts[i].life = 255; + if(parts[i].life<47) parts[i].life = 48; + s = (255/((parts[i].life-46)*28)); + if(s==0) s = 1; + cr = PIXR(ptypes[t].pcolors)/s; + cg = PIXG(ptypes[t].pcolors)/s; + cb = PIXB(ptypes[t].pcolors)/s; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + if(cmode==4) + { + 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 == 3||cmode==4) + { + 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_PHOT) + { + if(cmode == 3||cmode==4) + { + vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; + cg = 12; + cb = 12; + 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 = 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_SWCH && parts[i].life == 10) + { + x = nx; + y = ny; + blendpixel(vid,x,y,17,217,24,255); + } + else if(t==PT_SMKE) + { + if(cmode == 3||cmode==4) + { + 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 == 3||cmode==4) + { + 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 == 3||cmode==4) + { + 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_LCRY) + { + if(cmode == 3||cmode==4) + { + //cr = R/8; + //cg = G/8; + //cb = B/8; + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(0x50+(parts[i].life*10), 0x50+(parts[i].life*10), 0x50+(parts[i].life*10)); + //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 = 0x50+(parts[i].life*10); + cg = 0x50+(parts[i].life*10); + cb = 0x50+(parts[i].life*10); + 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_PLSM) + { + float ttemp = 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 == 3||cmode==4) + { + 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_FIRE && parts[i].life) + { + if(cmode == 3||cmode==4) + { + 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 == 3||cmode==4) + { + 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 == 3 || cmode==4) + { + 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))/512) ) *3, 0.0f, (512.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(mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head + { + sprintf(buff, "%3d", (int)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); + } + else + { + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B); + //blendpixel(vid, nx+1, ny, R, G, B, 255); + } + } + if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_NONE&&t!=PT_ACID) + { + uint8 R = PIXR(ptypes[t].pcolors); + uint8 G = PIXG(ptypes[t].pcolors); + uint8 B = PIXB(ptypes[t].pcolors); + + //if(vid[(ny-1)*YRES+(nx-1)]!=0){ + // blendpixel(vid, nx, ny-1, R, G, B, 46); + //} + + 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); + } + + } - 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); - } - else - { - vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(R, G, B); - //blendpixel(vid, nx+1, ny, R, G, B, 255); - } - } - if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_NONE&&t!=PT_ACID){ - uint8 R = PIXR(ptypes[t].pcolors); - uint8 G = PIXG(ptypes[t].pcolors); - uint8 B = PIXB(ptypes[t].pcolors); - - //if(vid[(ny-1)*YRES+(nx-1)]!=0){ - // blendpixel(vid, nx, ny-1, R, G, B, 46); - //} - - 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); - } - - } - } -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-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 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-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 update_particles_i_th(void *arg){ - upstruc *newup = (upstruc*)arg; - update_particles_i(newup[0].vid, newup[0].start, newup[0].inc); - return; +void update_particles_i_th(void *arg) +{ + upstruc *newup = (upstruc*)arg; + update_particles_i(newup[0].vid, newup[0].start, newup[0].inc); + return; } void update_particles(pixel *vid) @@ -2847,390 +3280,560 @@ void update_particles(pixel *vid) 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 memset(pmap, 0, sizeof(pmap)); r = rand()%2; - 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]==4) - 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]==7) { - 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]==11) { - 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]==13) { - 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) - 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]==4) - 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]==7) { - 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]==11) { - 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]==9){ - 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) - emap[y][x] --; - } - } - } - + if(cmode==4) + { + 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]==4) + 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]==7) + { + 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]==11) + { + 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]==13) + { + 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) + 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]==4) + 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]==7) + { + 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]==11) + { + 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]==9) + { + 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) + emap[y][x] --; + } + } + } + #ifdef MT - if(numCores > 1) { - InterThreads = (pthread_t *)calloc(sizeof(pthread_t), numCores); - for(pc = 0; pc 1) + { + InterThreads = (pthread_t *)calloc(sizeof(pthread_t), numCores); + for(pc = 0; pc=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]==5 && i!=x && j!=y) - break; - } - drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); - } - + for(x=0; x=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]==5 && i!=x && j!=y) + break; + } + drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); + } + } void update_particles_th(void *arg) { - update_particles((pixel*)arg); - return; + update_particles((pixel*)arg); + return; } /*********************************************************** @@ -3246,11 +3849,11 @@ int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0; void sdl_seticon(void) { #ifdef WIN32 - //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + //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 +#else #ifdef MACOSX - //SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + //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); @@ -3261,7 +3864,8 @@ void sdl_seticon(void) void sdl_open(void) { - if(SDL_Init(SDL_INIT_VIDEO)<0) { + if(SDL_Init(SDL_INIT_VIDEO)<0) + { fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError()); exit(1); } @@ -3271,14 +3875,15 @@ void sdl_open(void) #else sdl_scrn=SDL_SetVideoMode(XRES*sdl_scale + BARSIZE*sdl_scale,YRES*sdl_scale + MENUSIZE*sdl_scale,32,SDL_SWSURFACE); #endif - if(!sdl_scrn) { + if(!sdl_scrn) + { fprintf(stderr, "Creating window: %s\n", SDL_GetError()); exit(1); } SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); sdl_seticon(); SDL_EnableUNICODE(1); - //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch) @@ -3289,10 +3894,11 @@ void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch) 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; + for(j=0; jpitch/PIXELSIZE; + src+=pitch; } if(SDL_MUSTLOCK(sdl_scrn)) SDL_UnlockSurface(sdl_scrn); @@ -3308,15 +3914,18 @@ void sdl_blit_2(int x, int y, int w, int h, pixel *src, int pitch) 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; + for(j=0; jpitch/PIXELSIZE; + } + src+=pitch; } if(SDL_MUSTLOCK(sdl_scrn)) SDL_UnlockSurface(sdl_scrn); @@ -3325,9 +3934,9 @@ void sdl_blit_2(int x, int y, int w, int h, pixel *src, int pitch) void sdl_blit(int x, int y, int w, int h, pixel *src, int pitch) { if(sdl_scale == 2) - sdl_blit_2(x, y, w, h, src, pitch); + sdl_blit_2(x, y, w, h, src, pitch); else - sdl_blit_1(x, y, w, h, src, pitch); + sdl_blit_1(x, y, w, h, src, pitch); } int frame_idx=0; @@ -3340,14 +3949,16 @@ void dump_frame(pixel *src, int w, int h, int pitch) 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 && yPT_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(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; - } - - drawpixel(vid_buf, px+sx, py+sy, r, g, b, 255); - sx++; - } - sy++; - } - + if(bzip2) - free(d); + { + 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(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; + } + + drawpixel(vid_buf, px+sx, py+sy, r, g, b, 255); + sx++; + } + sy++; + } + + if(bzip2) + free(d); return 0; - + corrupt: if(bzip2) - free(d); + free(d); return 1; } static char *mystrdup(char *s) { char *x; - if(s) { - x = malloc(strlen(s)+1); - strcpy(x, s); - return x; + if(s) + { + x = malloc(strlen(s)+1); + strcpy(x, s); + return x; } return s; } void *build_save(int *size, int x0, int y0, int w, int h) { - unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*7+MAXSIGNS*262), *c; + unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*7+MAXSIGNS*262), *c; int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)); int bx0=x0/CELL, by0=y0/CELL, bw=(w+CELL-1)/CELL, bh=(h+CELL-1)/CELL; - + // normalize coordinates x0 = bx0*CELL; y0 = by0*CELL; w = bw *CELL; h = bh *CELL; - + // save the required air state for(y=by0; y255) i=255; - d[p++] = i; - } + for(x=bx0; x255) i=255; + d[p++] = i; + } for(y=by0; y255) i=255; - d[p++] = i; - } - + for(x=bx0; x255) 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; j255) tttemp=255; - d[p++] = tttemp; - } + for(j=0; j255) tttemp=255; + d[p++] = tttemp; + } } - for(j=0; j=x0 && signs[i].x=y0 && signs[i].y=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; - } - + if(signs[i].text[0] && + signs[i].x>=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); c[0] = 0x66; @@ -3706,16 +4347,17 @@ void *build_save(int *size, int x0, int y0, int w, int h) c[9] = p >> 8; c[10] = p >> 16; c[11] = p >> 24; - + i -= 12; - - if(BZ2_bzBuffToBuffCompress((char *)(c+12), (unsigned *)&i, (char *)d, p, 9, 0, 0) != BZ_OK) { - free(d); - free(c); - return NULL; + + 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; } @@ -3726,251 +4368,286 @@ int parse_save(void *save, int size, int replace, int x0, int y0) 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; int fp[NPART], nf=0; - + if(size<16) - return 1; + return 1; if(c[2]!=0x43 || c[1]!=0x75 || c[0]!=0x66) - return 1; + return 1; if(c[4]>SAVE_VERSION) - return 2; + return 2; ver = c[4]; - - if(ver<34){ - legacy_enable = 1; - } else { - if(c[3]==1||c[3]==0) - legacy_enable = c[3]; - else - legacy_beta = 1; - } - + + if(ver<34) + { + legacy_enable = 1; + } + else + { + 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; + bx0 = XRES/CELL - bw; if(by0+bh > YRES/CELL) - by0 = YRES/CELL - bh; + by0 = YRES/CELL - bh; if(bx0 < 0) - bx0 = 0; + bx0 = 0; if(by0 < 0) - by0 = 0; - + by0 = 0; + if(c[5]!=CELL || bx0+bw>XRES/CELL || by0+bh>YRES/CELL) - return 3; + 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; - + return 1; + if(BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) - return 1; + return 1; size = i; - + if(size < bw*bh) - return 1; - + return 1; + // normalize coordinates x0 = bx0*CELL; y0 = by0*CELL; w = bw *CELL; h = bh *CELL; - - if(replace) { - 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)); + + if(replace) + { + 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)); } - + // 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(x=bx0; x= 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; - } - + for(x=bx0; x= 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) - goto corrupt; - if(j && !(isplayer == 1 && j==PT_STKM)) { - if(pmap[y][x]) { - k = pmap[y][x]>>8; - parts[k].type = j; - 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; - 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; - } - } - + for(y=y0; y= size) + goto corrupt; + j=d[p++]; + if(j >= PT_NUM) + goto corrupt; + if(j && !(isplayer == 1 && j==PT_STKM)) + { + if(pmap[y][x]) + { + k = pmap[y][x]>>8; + parts[k].type = j; + 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; + 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; + } + } + // 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; + 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[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[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[7] = parts[i].x-3; - player[8] = parts[i].y+12; - player[9] = parts[i].x-3; - player[10] = parts[i].y+12; + 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[11] = parts[i].x+1; - player[12] = parts[i].y+6; - player[13] = parts[i].x+1; - player[14] = 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[15] = parts[i].x+3; - player[16] = parts[i].y+12; - player[17] = parts[i].x+3; - player[18] = 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; - } - } else - p += 2; - } + } + } + else + p += 2; + } } - for(j=0; j= size) - goto corrupt; - if(i <= NPART) - parts[i-1].life = d[p++]*4; - else - p++; - } + for(j=0; j= size) + goto corrupt; + if(i <= NPART) + parts[i-1].life = d[p++]*4; + else + p++; + } } - for(j=0; j=34&&legacy_beta==0){ - if(p >= size){ - goto corrupt; - } - if(i <= NPART) { - parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; - } else { - p++; - } - } else { - parts[i-1].temp = ptypes[parts[i-1].type].heat; - } - } - } - for(j=0; j=21) || (ty==PT_LAVA && ver>=34))) { - 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) + { + parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; + } + else + { + p++; + } + } + else + { + parts[i-1].temp = ptypes[parts[i-1].type].heat; + } + } } - + for(j=0; j=21) || (ty==PT_LAVA && ver>=34))) + { + if(p >= size) + goto corrupt; + if(i <= NPART) + parts[i-1].ctype = d[p++]; + else + p++; + } + } + if(p >= size) - goto version1; + goto version1; j = d[p++]; - for(i=0; i size) - goto corrupt; - for(k=0; k size) - goto corrupt; - if(k size) + goto corrupt; + for(k=0; k size) + goto corrupt; + if(kSAVE_VERSION) - return NULL; - + return NULL; + bw = c[6]; bh = c[7]; w = bw*CELL; h = bh*CELL; - + if(c[5]!=CELL) - return NULL; - + 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; + return NULL; fb = calloc(w*h, PIXELSIZE); - if(!fb) { - free(d); - return NULL; + if(!fb) + { + free(d); + return NULL; } - + if(BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), size-12, 0, 0)) - goto corrupt; + goto corrupt; size = i; - + if(size < bw*bh) - goto corrupt; - + 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 should be drawed another way - { - //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; - } - } - + goto corrupt; + + for(y=0; y= size) + goto corrupt; + j=d[p++]; + if(j0) + { + if(j==PT_STKM) //Stickman should be drawed another way + { + //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; - + corrupt: free(d); free(fb); @@ -4111,13 +4792,13 @@ corrupt: /* NO, I DON'T THINK SO #include "fbi.h" - + pixel *render_packed_rgb(void *image, int width, int height, int cmp_size) { unsigned char *tmp; pixel *res; int i; - + tmp = malloc(width*height*3); if(!tmp) return NULL; @@ -4126,17 +4807,17 @@ corrupt: free(tmp); return NULL; } - + i = width*height*3; if(BZ2_bzBuffToBuffDecompress((char *)tmp, (unsigned *)&i, (char *)image, cmp_size, 0, 0)) { free(res); free(tmp); return NULL; } - + for(i=0; i1) { - r = (r+c/2)/c; - g = (g+c/2)/c; - b = (b+c/2)/c; - } - q[y*w+x] = PIXRGB(r, g, b); - } + for(x=0; x1) + { + 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; @@ -4256,28 +4947,31 @@ void stamp_gen_thumb(int i) void *data; int size, factor_x, factor_y; pixel *tmp; - - if(stamps[i].thumb) { - free(stamps[i].thumb); - stamps[i].thumb = NULL; + + if(stamps[i].thumb) + { + free(stamps[i].thumb); + stamps[i].thumb = NULL; } - + sprintf(fn, "stamps" PATH_SEP "%s.stm", stamps[i].name); data = file_load(fn, &size); - - 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; - } + + 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); } @@ -4291,34 +4985,34 @@ void stamp_save(int x, int y, int w, int h) int n; char fn[64], sn[16]; void *s=build_save(&n, x, y, w, h); - + #ifdef WIN32 _mkdir("stamps"); #else mkdir("stamps", 0755); #endif - + stamp_gen_name(sn); sprintf(fn, "stamps" PATH_SEP "%s.stm", sn); - + f = fopen(fn, "wb"); if(!f) - return; + return; fwrite(s, n, 1, f); fclose(f); - + free(s); - + if(stamps[STAMP_MAX-1].thumb) - free(stamps[STAMP_MAX-1].thumb); + free(stamps[STAMP_MAX-1].thumb); memmove(stamps+1, stamps, sizeof(struct stamp_info)*(STAMP_MAX-1)); memset(stamps, 0, sizeof(struct stamp_info)); - if(stamp_count0) { - memcpy(&tmp, stamps+i, sizeof(struct stamp_info)); - memmove(stamps+1, stamps, sizeof(struct stamp_info)*i); - memcpy(stamps, &tmp, sizeof(struct stamp_info)); - - stamp_update(); + return NULL; + + if(i>0) + { + memcpy(&tmp, stamps+i, sizeof(struct stamp_info)); + memmove(stamps+1, stamps, sizeof(struct stamp_info)*i); + memcpy(stamps, &tmp, sizeof(struct stamp_info)); + + stamp_update(); } - + return data; } @@ -4351,28 +5046,29 @@ void stamp_init(void) { int i; FILE *f; - + memset(stamps, 0, sizeof(stamps)); - + f=fopen("stamps" PATH_SEP "stamps.def", "rb"); if(!f) - return; - for(i=0; i=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; + 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); } @@ -4400,50 +5097,58 @@ inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a) char *rp = font_data + font_ptrs[c]; w = *(rp++); for(j=0; j>= 2; - bn -= 2; - } + for(i=0; i>= 2; + bn -= 2; + } return x + w; } int drawtext(pixel *vid, int x, int y, char *s, int r, int g, int b, int 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); + 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); } return x; } @@ -4451,13 +5156,15 @@ int drawtext(pixel *vid, int x, int y, char *s, int r, int g, int b, int a) void drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a) { 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=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); + 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); + 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--; + for(; *s; s++) + { + if(!n) + break; + x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + n--; } return x-1; } 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++; + for(; *s; s++) + { + cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; + if(x+(cw/2) >= w) + break; + x += cw; + n++; } return n; } @@ -4536,842 +5246,1107 @@ int textwidthx(char *s, int w) 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 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>=121){ - 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; - case 40: - 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==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); - } - return 26; + if(b>=121) + { + 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; + case 40: + 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==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); + } + return 26; } -void draw_menu(pixel *vid_buf, int i, int hover){ - - //drawtext(vid_buf, XRES+1, /*(12*i)+2*/((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2), msections[i].icon, 255, 255, 255, 255); +void draw_menu(pixel *vid_buf, int i, int hover) +{ + + //drawtext(vid_buf, XRES+1, /*(12*i)+2*/((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2), msections[i].icon, 255, 255, 255, 255); #ifdef MENUV3 - drawrect(vid_buf, XRES-2, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); - if(hover==i){ - fillrect(vid_buf, XRES-2, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); - drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 0, 0, 0, 255); - } else { - drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); - } + drawrect(vid_buf, XRES-2, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); + if(hover==i) + { + fillrect(vid_buf, XRES-2, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 0, 0, 0, 255); + } + else + { + drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); + } #else - drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); + drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255); #endif } -void menu_ui(pixel *vid_buf, int i, int *sl, int *sr){ - int b=1,bq,mx,my,h,x,y,n=0,height,width,sy,rows=0; - pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); - fillrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE, 0, 0, 0, 192); - memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); - - while(!sdl_poll()) { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; +void menu_ui(pixel *vid_buf, int i, int *sl, int *sr) +{ + int b=1,bq,mx,my,h,x,y,n=0,height,width,sy,rows=0; + pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); + fillrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE, 0, 0, 0, 192); + memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE); + + 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); - } - - - 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=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); + } + + + 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=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<=20) + { + x = XRES-BARSIZE-26; + y += 19; + } + x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; + if(!bq && 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-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-10, (char *)mwalls[h-122].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) + { + *sl = h; + } + if(b==4&&h!=-1) + { + *sr = h; } - //drawtext(vid_buf, XRES+2, (12*i)+2, msections[i].icon, 255, 255, 255, 255); } - void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my){ - int h,x,y,n=0,height,width,sy,rows=0; - //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+1;//(((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<=20){ - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(!bq && 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<=20){ - x = XRES-BARSIZE-26; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-122].colour)+5; - if(!bq && 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-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-10, (char *)mwalls[h-122].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){ - *sl = h; - } - if(b==4&&h!=-1){ - *sr = h; - } - } - int create_parts(int x, int y, int r, int c) { int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0; //n; - - if(c == 125) { - i = x / CELL; - j = y / CELL; - for(v=-1;v<2;v++) - for(u=-1;u<2;u++) - if(i+u>=0 && i+u=0 && j+v=0 && i+u=0 && j+v=0&&ox=0&&oy=0&&ox=0&&oyabs(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(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; + 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; + de = dy/(float)dx; else - de = 0.0f; + de = 0.0f; y = y1; sy = (y1= 0.5f) { - y += sy; - if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r) { - if(cp) - create_parts(y, x, r, c); - else - create_parts(x, y, r, c); - } - e -= 1.0f; - } + for(x=x1; x<=x2; x++) + { + if(cp) + create_parts(y, x, r, c); + else + create_parts(x, y, r, c); + e += de; + if(e >= 0.5f) + { + y += sy; + if(c==135 || c==140 || c==134 || c==133 || c==132 || c==131 || c==129 || c==128 || c==127 || c==125 || c==124 || c==123 || c==122 || !r) + { + if(cp) + create_parts(y, x, r, c); + else + create_parts(x, y, r, c); + } + e -= 1.0f; + } } } void create_box(int x1, int y1, int x2, int y2, int c) { int i, j; - if(x1>x2) { - i = x2; - x2 = x1; - x1 = i; + if(x1>x2) + { + i = x2; + x2 = x1; + x1 = i; } - if(y1>y2) { - j = y2; - y2 = y1; - y1 = j; + 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, c); + for(i=x1; i<=x2; i++) + create_parts(i, j, 1, c); } int flood_parts(int x, int y, int c, int cm, int bm) { int x1, x2, dy = (c=122&&c<=122+UI_WALLCOUNT){ - c = c-100; - } - if(cm==-1) { - if(c==0) { - cm = pmap[y][x]&0xFF; - if(!cm) - return 0; - } else - cm = 0; + int co = c; + if(c>=122&&c<=122+UI_WALLCOUNT) + { + c = c-100; } - if(bm==-1) { - if(c==30) { - bm = bmap[y/CELL][x/CELL]; - if(!bm) - return 0; - if(bm==1) - cm = 0xFF; - } else - bm = 0; + if(cm==-1) + { + if(c==0) + { + cm = pmap[y][x]&0xFF; + if(!cm) + return 0; + } + else + cm = 0; } - + if(bm==-1) + { + if(c==30) + { + bm = bmap[y/CELL][x/CELL]; + if(!bm) + return 0; + if(bm==1) + cm = 0xFF; + } + else + bm = 0; + } + if((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm) - return 1; - + 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) - break; - x1--; + while(x1>=CELL) + { + if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) + break; + x1--; } - while(x2=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; + 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=XRES || y>=YRES) - return; + 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); + vid[y*(XRES+BARSIZE)+x] = PIXPACK(0xC0C0C0); else - vid[y*(XRES+BARSIZE)+x] = PIXPACK(0x404040); + 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(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; + 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; + de = dy/(float)dx; else - de = 0.0f; + de = 0.0f; y = y1; sy = (y1= 0.5f) { - y += sy; - e -= 1.0f; - } + for(x=x1; x<=x2; x++) + { + if(cp) + xor_pixel(y, x, vid); + else + xor_pixel(x, y, vid); + e += de; + if(e >= 0.5f) + { + y += sy; + e -= 1.0f; + } } } void draw_svf_ui(pixel *vid_buf) { 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); - + 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); + 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); + 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; - - 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); - } - - drawtext(vid_buf, 192, YRES+(MENUSIZE-12), "\xCB", 0, 187, 18, c); - drawtext(vid_buf, 205, YRES+(MENUSIZE-14), "\xCA", 187, 40, 0, c); - + drawdots(vid_buf, 55, YRES+(MENUSIZE-15), 12, c, c, c, 255); + + 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); + + 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, 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); + 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, 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); - + 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); + 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); + 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); } - - switch(cmode) { - case 0: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); - break; - case 1: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); - break; - case 2: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); - break; - case 3: - 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 4: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); - break; - case 5: - 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; + 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 0: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); + break; + case 1: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); + break; + case 2: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); + break; + case 3: + 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 4: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); + break; + case 5: + 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; } 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? } -typedef struct ui_edit { +typedef struct ui_edit +{ int x, y, w, nx; char str[256],*def; int focus, cursor, hide; @@ -5671,24 +6680,29 @@ void ui_edit_draw(pixel *vid_buf, ui_edit *ed) { int cx, i; 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->str[0]) { - 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) { - cx = textnwidth(str, ed->cursor); - for(i=-3; i<9; i++) - drawpixel(vid_buf, ed->x+cx, ed->y+i, 255, 255, 255, 255); + + 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]) + { + 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) + { + cx = textnwidth(str, ed->cursor); + for(i=-3; i<9; i++) + drawpixel(vid_buf, ed->x+cx, ed->y+i, 255, 255, 255, 255); } } char *shift_0="`1234567890-=[]\\;',./"; @@ -5700,224 +6714,259 @@ void ui_edit_process(int mx, int my, int mb, ui_edit *ed) #ifdef RAWINPUT 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(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) { - ed->focus = 1; - ed->cursor = textwidthx(str, mx-ed->x); - } else - ed->focus = 0; + + 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(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) + { + ed->focus = 1; + ed->cursor = textwidthx(str, mx-ed->x); + } + 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; - - 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: + 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: #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) - 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) + 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) { - ch = sdl_ascii; - ts[0]=ed->hide?0x8D:ch; - ts[1]=0; - if(textwidth(str)+textwidth(ts) > ed->w-14) - 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) + { + ch = sdl_ascii; + ts[0]=ed->hide?0x8D:ch; + ts[1]=0; + if(textwidth(str)+textwidth(ts) > ed->w-14) + 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; + } + } +} +typedef struct ui_checkbox +{ + int x, y; + int focus, checked; +} ui_checkbox; +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); + } +} +void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed) +{ + 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; + } } } - typedef struct ui_checkbox { - int x, y; - int focus, checked; - } ui_checkbox; - 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); - } - } - void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed) - { - 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; - } - } - } 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; - + msg = malloc(strlen(txt)+16); if(err) - sprintf(msg, "%03d %s", err, txt); + sprintf(msg, "%03d %s", err, txt); else - sprintf(msg, "%s", txt); - - while(!sdl_poll()) { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; + sprintf(msg, "%s", txt); + + 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; - - 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(sdl_key==SDLK_RETURN) - break; - if(sdl_key==SDLK_ESCAPE) - break; + + 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)); + + if(b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) + break; + + if(sdl_key==SDLK_RETURN) + break; + if(sdl_key==SDLK_ESCAPE) + break; } - + 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; - - 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; - - 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(sdl_key==SDLK_RETURN) - break; - if(sdl_key==SDLK_ESCAPE) - break; + + 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)); + + if(b && !bq && mx>=x0 && mx=y0+44 && my<=y0+60) + 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; } } @@ -5925,7 +6974,7 @@ void info_box(pixel *vid_buf, char *msg) { 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); @@ -5936,50 +6985,55 @@ 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; - - 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; - - 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(sdl_key==SDLK_RETURN) { - ret = 1; - break; - } - if(sdl_key==SDLK_ESCAPE) - break; + + 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)); + + 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; } - - while(!sdl_poll()) { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; + + while(!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if(!b) + break; } - + return ret; } @@ -5987,48 +7041,52 @@ int execute_tagop(pixel *vid_buf, char *op, char *tag) { int status; char *result; - + 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); - + parts[0] = svf_id; parts[1] = tag; - + result = http_multipart_post( - uri, - names, parts, NULL, - svf_user, svf_pass, - &status, NULL); - + uri, + names, parts, NULL, + svf_user, svf_pass, + &status, NULL); + free(uri); - - if(status!=200) { - error_ui(vid_buf, status, http_ret_text(status)); - if(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 && 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); - + free(result); + return 0; } -struct strlist { +struct strlist +{ char *str; struct strlist *next; }; @@ -6042,18 +7100,19 @@ void strlist_add(struct strlist **list, char *str) 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; + 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); + while(*list) + { + item = *list; + *list = (*list)->next; + free(item); } } @@ -6064,7 +7123,7 @@ void tag_list_ui(pixel *vid_buf) char *tag=NULL, *op=NULL; ui_edit ed; struct strlist *vote=NULL,*down=NULL; - + ed.x = x0+25; ed.y = y0+221; ed.w = 158; @@ -6074,118 +7133,131 @@ void tag_list_ui(pixel *vid_buf) ed.hide = 0; ed.cursor = 0; strcpy(ed.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; - - op = tag = NULL; - - drawrect(vid_buf, x0, y0, 192, 256, 192, 192, 192, 255); - clearrect(vid_buf, x0, y0, 192, 256); - drawtext(vid_buf, x0+8, y0+8, "Current tags:", 255, 255, 255, 255); - p = svf_tags; - s = svf_tags[0] ? ' ' : 0; - y = 36 + y0; - while(s) { - q = strchr(p, ' '); - if(!q) - q = p+strlen(p); - s = *q; - *q = 0; - if(svf_own || svf_admin || svf_mod) { - drawtext(vid_buf, x0+20, y-1, "\x86", 160, 48, 32, 255); - drawtext(vid_buf, x0+20, y-1, "\x85", 255, 255, 255, 255); - d = 14; - if(b && !bq && mx>=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+9 && mx=y0+218 && 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+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=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; - } + 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)); + + 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(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); - + 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; + "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 && !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"); + 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; + svf_mod = 0; } void execute_delete(pixel *vid_buf, char *id) { int status; char *result; - + char *names[] = {"ID", NULL}; char *parts[1]; - + parts[0] = id; - + 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; + "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; } - if(result && strncmp(result, "OK", 2)) { - error_ui(vid_buf, 0, result); - free(result); - return; + if(result && strncmp(result, "OK", 2)) + { + error_ui(vid_buf, 0, result); + free(result); + return; } - + if(result) - free(result); + free(result); } - + int execute_vote(pixel *vid_buf, char *id, char *action) { - int status; - char *result; - - char *names[] = {"ID", "Action", NULL}; - char *parts[2]; - - parts[0] = id; - parts[1] = action; - - 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(result) - free(result); - return 1; + int status; + char *result; + + char *names[] = {"ID", "Action", NULL}; + char *parts[2]; + + parts[0] = id; + parts[1] = action; + + 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(result) + free(result); + return 1; } static char hex[] = "0123456789ABCDEF"; @@ -6550,19 +7650,21 @@ void strcaturl(char *dst, char *src) { char *d; unsigned char *s; - + 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]; - } + + 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; } @@ -6577,36 +7679,39 @@ int thumb_cache_lru[THUMB_CACHE_SIZE]; void thumb_cache_inval(char *id) { int i,j; - for(i=0;i= THUMB_CACHE_SIZE) - return; + 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]--; + 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; - } + 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; + 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=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_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++; - } 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_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; + 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_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++; + } + 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_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++; + i++; return i; } @@ -6838,13 +7963,13 @@ 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,own,last_own=search_own,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; + 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; @@ -6854,36 +7979,37 @@ int search_ui(pixel *vid_buf) int status; char *results; char *tmp, ts[64]; - + 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(search_ids, 0, sizeof(search_ids)); 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_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)); - - do_open = 0; - - while(!sdl_poll()) { - b = SDL_GetMouseState(&mx, &my); - if(!b) - break; + memset(thumb_drawn, 0, sizeof(thumb_drawn)); + + do_open = 0; + + while(!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if(!b) + break; } - + ed.x = 65; ed.y = 13; ed.w = XRES-200; @@ -6893,522 +8019,619 @@ int search_ui(pixel *vid_buf) ed.hide = 0; ed.cursor = strlen(search_expr); strcpy(ed.str, search_expr); - + 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; - - 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); - } - - 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; - } - - 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 && 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(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) { - 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(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; - } - - fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 187, 40, 255); - fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 187, 40, 0, 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); - } - - sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); - - 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(b && !bq && mx>=XRES-64 && mx<=XRES-8 && my>=8 && my<=24 && svf_login) { - search_own = !search_own; - lasttime = TIMEOUT; - } - if(b && !bq && mx>=XRES-129 && mx<=XRES-65 && my>=8 && my<=24) { - search_date = !search_date; - lasttime = TIMEOUT; - } - - if(b && !bq && dp!=-1) - 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 && 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(do_open==1){ - mp = 0; - } - - if((b && !bq && mp!=-1 && !st && !uih) || do_open==1) { - fillrect(vid_buf, 0, 0, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 255); - info_box(vid_buf, "Loading..."); + if(mx!=mxq || my!=myq || sdl_wheel || b) + mmt = 0; + else if(mmt=TIMEOUT) { - lasttime = 0; - last = mystrdup(ed.str); - last_own = search_own; - last_date = search_date; - last_page = search_page; - active = 1; - uri = malloc(strlen(last)*3+80+strlen(SERVER)+strlen(svf_user)); - 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_date) - strcaturl(uri, " sort:date"); + clearrect(vid_buf, -1, -1, (XRES+BARSIZE)+1, YRES+MENUSIZE+1); - 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(http && !active && (time(NULL)>http_last_use+HTTP_TIMEOUT)) { - http_async_req_close(http); - http = NULL; - } - - for(i=0;i 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); + + 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 && 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(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) + { + 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(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; + } + + fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)-nyu, 4, nyu, 0, 187, 40, 255); + fillrect(vid_buf, gx-2+(XRES/GRID_S)+5, gy-2+((YRES/GRID_S+3)/2)+1, 4, nyd, 187, 40, 0, 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); + } + + sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); + + 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(b && !bq && mx>=XRES-64 && mx<=XRES-8 && my>=8 && my<=24 && svf_login) + { + search_own = !search_own; + lasttime = TIMEOUT; + } + if(b && !bq && mx>=XRES-129 && mx<=XRES-65 && my>=8 && my<=24) + { + search_date = !search_date; + lasttime = TIMEOUT; + } + + if(b && !bq && dp!=-1) + 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 && 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(do_open==1) + { + mp = 0; + } + + if((b && !bq && mp!=-1 && !st && !uih) || do_open==1) + { + fillrect(vid_buf, 0, 0, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 255); + info_box(vid_buf, "Loading..."); + + uri = malloc(strlen(search_ids[mp])*3+strlen(SERVER)+64); + strcpy(uri, "http://" SERVER "/Get.api?Op=save&ID="); + strcaturl(uri, search_ids[mp]); + data = http_simple_get(uri, &status, &dlen); + free(uri); + + if(status == 200) + { + status = parse_save(data, dlen, 1, 0, 0); + switch(status) + { + case 1: + error_ui(vid_buf, 0, "Simulation corrupted"); + break; + case 2: + error_ui(vid_buf, 0, "Simulation from a newer version"); + break; + case 3: + error_ui(vid_buf, 0, "Simulation on a too large grid"); + break; + } + if(!status) + { + char *tnames[] = {"ID", NULL}; + char *tparts[1]; + int tplens[1]; + if(svf_last) + free(svf_last); + svf_last = data; + svf_lsize = dlen; + + tparts[0] = search_ids[mp]; + tplens[0] = strlen(search_ids[mp]); + data = http_multipart_post("http://" SERVER "/Tags.api", tnames, tparts, tplens, svf_user, svf_pass, &status, NULL); + + svf_open = 1; + svf_own = svf_login && !strcmp(search_owners[mp], svf_user); + svf_publish = search_publish[mp] && svf_login && !strcmp(search_owners[mp], svf_user); + + strcpy(svf_id, search_ids[mp]); + strcpy(svf_name, search_names[mp]); + if(status == 200) + { + if(data) + { + strncpy(svf_tags, data, 255); + svf_tags[255] = 0; + } + else + svf_tags[0] = 0; + } + else + { + svf_tags[0] = 0; + } + + if(svf_login) + { + char *names[] = {"ID", NULL}; + char *parts[1]; + parts[0] = search_ids[mp]; + data = http_multipart_post("http://" SERVER "/Vote.api", names, parts, NULL, svf_user, svf_pass, &status, NULL); + if(status == 200) + { + if(data) + { + if(!strcmp(data, "Up")) + { + svf_myvote = 1; + } + else if(!strcmp(data, "Down")) + { + svf_myvote = -1; + } + else + { + svf_myvote = 0; + } + } + else + { + svf_myvote = 0; + } + } + else + { + svf_myvote = 0; + } + } + } + else + { + svf_open = 0; + svf_publish = 0; + svf_own = 0; + svf_myvote = 0; + svf_id[0] = 0; + svf_name[0] = 0; + svf_tags[0] = 0; + if(svf_last) + free(svf_last); + svf_last = NULL; + } + } + else + error_ui(vid_buf, status, http_ret_text(status)); + + if(data) + free(data); + 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)) + { + search = 1; + if(strcmp(last, ed.str) || last_own!=search_own || 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; + active = 1; + uri = malloc(strlen(last)*3+80+strlen(SERVER)+strlen(svf_user)); + 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_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); + } + + 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; + } + + for(i=0; i=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=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 18) ? signs[i].y - 18 : signs[i].y + 4; + if(strcmp(signs[i].text, "{t}")==0) + *w = textwidth("Temp: 0000.00"); + + //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 draw_icon(pixel *vid_buf, int x, int y, char ch, int flag) @@ -7578,12 +8825,15 @@ 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); + 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); } } @@ -7592,40 +8842,42 @@ void render_signs(pixel *vid_buf) int i, j, x, y, w, h, dx, dy; char buff[30]; //Buffer for(i=0; i>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp); //...tempirature - else - sprintf(buff, "Temp: 0.00"); //...tempirature - drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); - } + if(signs[i].text[0]) + { + get_sign_pos(i, &x, &y, &w, &h); + clearrect(vid_buf, x, y, w, h); + drawrect(vid_buf, x, y, w, h, 192, 192, 192, 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; - } - } + //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); //...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); + 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; + } + } } void add_sign_ui(pixel *vid_buf, int mx, int my) @@ -7633,36 +8885,40 @@ 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; - } + if(signs[i].text[0]) + { + 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) + { + nm = 1; + for(i=0; i= MAXSIGNS) - return; - - if(nm) { - signs[i].x = mx; - signs[i].y = my; - signs[i].ju = 1; + 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; + + while(!sdl_poll()) + { + b = SDL_GetMouseState(&mx, &my); + if(!b) + break; } - + ed.x = x0+25; ed.y = y0+25; ed.w = 158; @@ -7673,66 +8929,70 @@ void add_sign_ui(pixel *vid_buf, int mx, int my) ed.cursor = strlen(signs[i].text); 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); - } - - 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(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; - } + 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); + } + + 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(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; } @@ -7759,9 +9019,10 @@ int load_string(FILE *f, char *str, int max) unsigned char lb[2]; fread(lb, 2, 1, f); li = lb[0] | (lb[1] << 8); - if(li > max) { - str[0] = 0; - return 1; + if(li > max) + { + str[0] = 0; + return 1; } fread(str, li, 1, f); str[li] = 0; @@ -7776,7 +9037,7 @@ void save_presets(int do_update) unsigned char sig[4] = {0x50, 0x44, 0x65, 0x66}; unsigned char tmp = sdl_scale; if(!f) - return; + return; fwrite(sig, 1, 4, f); save_string(f, svf_user); save_string(f, svf_pass); @@ -7785,8 +9046,8 @@ void save_presets(int do_update) fwrite(&tmp, 1, 1, f); tmp = svf_admin; fwrite(&tmp, 1, 1, f); - tmp = svf_mod; - fwrite(&tmp, 1, 1, f); + tmp = svf_mod; + fwrite(&tmp, 1, 1, f); save_string(f, http_proxy); tmp = SAVE_VERSION; fwrite(&tmp, 1, 1, f); @@ -7802,47 +9063,51 @@ void load_presets(void) FILE *f=fopen("powder.def", "rb"); unsigned char sig[4], tmp; if(!f) - return; + 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(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; + goto fail; if(load_string(f, svf_pass, 63)) - goto fail; + goto fail; svf_login = !!svf_user[0]; if(fread(&tmp, 1, 1, f) != 1) - goto fail; + goto fail; sdl_scale = (tmp == 2) ? 2 : 1; if(fread(&tmp, 1, 1, f) != 1) - goto fail; - cmode = tmp%6; + goto fail; + cmode = tmp%6; if(fread(&tmp, 1, 1, f) != 1) - goto fail; + goto fail; svf_admin = tmp; - if(fread(&tmp, 1, 1, f) != 1) - goto fail; - svf_mod = tmp; + if(fread(&tmp, 1, 1, f) != 1) + goto fail; + svf_mod = tmp; if(load_string(f, http_proxy, 255)) - goto fail; + goto fail; if(fread(sig, 1, 3, f) != 3) - goto fail; + goto fail; last_major = sig[0]; last_minor = sig[1]; update_flag = sig[2]; @@ -7853,17 +9118,18 @@ fail: void dim_copy(pixel *dst, pixel *src) { int i,r,g,b; - for(i=0;i0) - r--; - if(g>0) - g--; - if(b>0) - b--; - dst[i] = PIXRGB(r,g,b); + for(i=0; i0) + r--; + if(g>0) + g--; + if(b>0) + b--; + dst[i] = PIXRGB(r,g,b); } } @@ -7874,41 +9140,43 @@ void prepare_alpha(void) float temp[CELL*3][CELL*3]; memset(temp, 0, sizeof(temp)); for(x=0; x=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; - } + 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 zoom_en = 0; @@ -7922,61 +9190,71 @@ void render_zoom(pixel *img) 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; jr*r || i*i+(j+1)*(j+1)>r*r)) { - 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 = (r/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; ir*r || i*i+(j+1)*(j+1)>r*r)) + { + 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 = (r/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; i2){ - pthread_t pth; - pthread_create(&pth,NULL,update_air_th,""); - } else { - update_air(); - } + if(numCores>2) + { + pthread_t pth; + pthread_create(&pth,NULL,update_air_th,""); + } + else + { + update_air(); + } #else - update_air(); + update_air(); #endif - } - if(cmode==0 || cmode==1) { - draw_air(vid_buf); - } else if(cmode==2) { - memcpy(vid_buf, fire_bg, XRES*YRES*PIXELSIZE); - memset(vid_buf+(XRES*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-(XRES*YRES*PIXELSIZE)); - } else { - memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - update_particles(vid_buf); - - if(cmode==2) { - if(!fire_fc) { - dim_copy(fire_bg, vid_buf); - } else { - memcpy(fire_bg, vid_buf, XRES*YRES*PIXELSIZE); - } - fire_fc = (fire_fc+1) % 3; - } - if(cmode==3||cmode==4) - render_fire(vid_buf); - - render_signs(vid_buf); - - memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE); - clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); - - 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) { + } + if(cmode==0 || cmode==1) + { + draw_air(vid_buf); + } + else if(cmode==2) + { + memcpy(vid_buf, fire_bg, XRES*YRES*PIXELSIZE); + memset(vid_buf+(XRES*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-(XRES*YRES*PIXELSIZE)); + } + else + { + memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + } + update_particles(vid_buf); + + if(cmode==2) + { + if(!fire_fc) + { + dim_copy(fire_bg, vid_buf); + } + else + { + memcpy(fire_bg, vid_buf, XRES*YRES*PIXELSIZE); + } + fire_fc = (fire_fc+1) % 3; + } + if(cmode==3||cmode==4) + render_fire(vid_buf); + + render_signs(vid_buf); + + memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE); + clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); + + 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; - } - - 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=='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') { - if(it > 50) - it = 50; - save_mode = 1; - } - if(sdl_key=='1'){ - set_cmode(0); - } - if(sdl_key=='2'){ - set_cmode(1); - } - if(sdl_key=='3'){ - set_cmode(2); - } - if(sdl_key=='4'){ - set_cmode(3); - } - if(sdl_key=='5'){ - set_cmode(4); - } - if(sdl_key=='6'){ - set_cmode(5); - } - if(sdl_key==SDLK_SPACE) - sys_pause = !sys_pause; - if(sdl_key=='h') - hud_enable = !hud_enable; - if(sdl_key=='p') - dump_frame(vid_buf, XRES, YRES, XRES); - if(sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))){ - if(clipboard_ready==1){ - load_data = malloc(clipboard_length); - memcpy(load_data, clipboard_data, clipboard_length); - load_size = clipboard_length; - 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=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))){ - save_mode = 1; - copy_mode = 2; - } - if(sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))){ - save_mode = 1; - copy_mode = 1; - } else if(sdl_key=='c') { - set_cmode((cmode+1) % 6); - if(it > 50) - it = 50; - } + 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=='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') + { + if(it > 50) + it = 50; + save_mode = 1; + } + if(sdl_key=='1') + { + set_cmode(0); + } + if(sdl_key=='2') + { + set_cmode(1); + } + if(sdl_key=='3') + { + set_cmode(2); + } + if(sdl_key=='4') + { + set_cmode(3); + } + if(sdl_key=='5') + { + set_cmode(4); + } + if(sdl_key=='6') + { + set_cmode(5); + } + if(sdl_key==SDLK_SPACE) + sys_pause = !sys_pause; + if(sdl_key=='h') + hud_enable = !hud_enable; + if(sdl_key=='p') + dump_frame(vid_buf, XRES, YRES, XRES); + if(sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) + { + if(clipboard_ready==1) + { + load_data = malloc(clipboard_length); + memcpy(load_data, clipboard_data, clipboard_length); + load_size = clipboard_length; + 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=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) + { + save_mode = 1; + copy_mode = 2; + } + if(sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) + { + save_mode = 1; + copy_mode = 1; + } + else if(sdl_key=='c') + { + set_cmode((cmode+1) % 6); + if(it > 50) + it = 50; + } #ifdef INTERNAL - if(sdl_key=='v') - vs = !vs; - if(vs) - dump_frame(vid_buf, XRES, YRES, XRES); + if(sdl_key=='v') + vs = !vs; + if(vs) + dump_frame(vid_buf, XRES, YRES, XRES); #endif - - if(sdl_wheel) { - if(sdl_zoom_trig==1){ - ZSIZE += sdl_wheel; - if(ZSIZE>32) - ZSIZE = 32; - if(ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; - sdl_wheel = 0; - } else { - bs += sdl_wheel; - if(bs>16) - bs = 16; - if(bs<0) - bs = 0; - sdl_wheel = 0; - /*if(su >= PT_NUM) { - if(sl < PT_NUM) - su = sl; - if(sr < PT_NUM) - su = sr; - }*/ - } - } - - bq = b; - b = SDL_GetMouseState(&x, &y); - for(i=0; i32) + ZSIZE = 32; + if(ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; + sdl_wheel = 0; + } + else + { + bs += sdl_wheel; + if(bs>16) + bs = 16; + if(bs<0) + bs = 0; + sdl_wheel = 0; + /*if(su >= PT_NUM) { + if(sl < PT_NUM) + su = sl; + if(sr < PT_NUM) + su = sr; + }*/ + } + } + + bq = b; + b = SDL_GetMouseState(&x, &y); + + for(i=0; i=sdl_scale*(XRES+1) && x= sdl_scale*(((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2)-2) && y=sdl_scale*(XRES+1) && x= sdl_scale*(((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2)-2) && y=sdl_scale*(XRES-2) && x= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y=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 - 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, parts[cr>>8].life); + 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, 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); + 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); #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; - } - - 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); - } -#else - 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 { - 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); - 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) - parse_save(svf_last, svf_lsize, 1, 0, 0); - if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) { - if(b & SDL_BUTTON_LMASK) - set_cmode((cmode+1) % 6); - if(b & SDL_BUTTON_RMASK) - set_cmode((cmode+5) % 6); - 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 - } - } - //create_parts(x, y, bs, SPC_AIR); - lx = x; - ly = y; - lb = 0; - lm = 0; - } else { - create_parts(x, y, bs, 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!=127 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=4) - create_line(lx, ly, x, y, bs, 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(save_mode) { - 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, bs); - mousex = mx/sdl_scale; mousey = my/sdl_scale; - } - - 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--; - //if(fbi_img) - //draw_image(vid_buf, fbi_img, (XRES-FBI_W)/2, (YRES-FBI_H)/2+25, FBI_W, FBI_H, it>12?64:it*5); - 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); -#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); - } -#else - 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); - } - /*#ifdef MT - pthread_join(pth2,NULL); - #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; + } - if(hud_enable){ - currentTime = SDL_GetTicks(); - if(currentTime-past>=16) { - past = SDL_GetTicks(); - FPS++; - } - if(currentTime-pastFPS>=1000) { + 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 - sprintf(uitext, "Version %d (Beta %d) FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); + 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(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); + sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); #endif - FPSB = FPS; - FPS = 0; - pastFPS = currentTime; - } - if(sdl_zoom_trig||zoom_en){ - if(zoom_x=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 + { + 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); + 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) + parse_save(svf_last, svf_lsize, 1, 0, 0); + if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) + { + if(b & SDL_BUTTON_LMASK) + set_cmode((cmode+1) % 6); + if(b & SDL_BUTTON_RMASK) + set_cmode((cmode+5) % 6); + 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 + } + } + //create_parts(x, y, bs, SPC_AIR); + lx = x; + ly = y; + lb = 0; + lm = 0; + } + else + { + create_parts(x, y, bs, 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!=127 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=4) + create_line(lx, ly, x, y, bs, 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(save_mode) + { + 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, bs); + mousex = mx/sdl_scale; + mousey = my/sdl_scale; + } + + 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--; + //if(fbi_img) + //draw_image(vid_buf, fbi_img, (XRES-FBI_W)/2, (YRES-FBI_H)/2+25, FBI_W, FBI_H, it>12?64:it*5); + 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); +#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); + } +#else + 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); + } + /*#ifdef MT + pthread_join(pth2,NULL); + #endif*/ + + if(hud_enable) + { + currentTime = SDL_GetTicks(); + if(currentTime-past>=16) + { + past = SDL_GetTicks(); + FPS++; + } + if(currentTime-pastFPS>=1000) + { +#ifdef BETA + sprintf(uitext, "Version %d (Beta %d) FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); +#else + sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); +#endif + FPSB = FPS; + FPS = 0; + pastFPS = currentTime; + } + if(sdl_zoom_trig||zoom_en) + { + if(zoom_x= max) { + 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(_NSGetExecutablePath(fn, &max) != 0) + { + fn = realloc(fn, max); + _NSGetExecutablePath(fn, &max); } - if(realpath(fn, name) == NULL) { - free(fn); - free(name); - return NULL; + 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) { + 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; + if(res <= 0) + { + free(name); + return NULL; } return name; } @@ -85,34 +90,36 @@ int update_start(char *data, int len) int res = 1; if(!self) - return 1; + return 1; #ifdef WIN32 temp = malloc(strlen(self)+12); strcpy(temp, self); p = temp + strlen(temp) - 4; if(_stricmp(p, ".exe")) - p += 4; + p += 4; strcpy(p, "_update.exe"); if(!MoveFile(self, temp)) - goto fail; + goto fail; f = fopen(self, "wb"); if(!f) - goto fail; - if(fwrite(data, 1, len, f) != len) { - fclose(f); - DeleteFile(self); - goto fail; + 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; #else temp = malloc(strlen(self)+8); @@ -121,22 +128,25 @@ int update_start(char *data, int len) f = fopen(temp, "w"); if(!f) - goto fail; - if(fwrite(data, 1, len, f) != len) { - fclose(f); - unlink(temp); - goto fail; + 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); @@ -158,22 +168,25 @@ int update_finish(void) strcpy(temp, self); p = temp + strlen(temp) - 4; if(_stricmp(p, ".exe")) - p += 4; + 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; - } + 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