diff --git a/includes/defines.h b/includes/defines.h index 11b9a5338..f5d238599 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -56,6 +56,12 @@ extern unsigned char ZSIZE; #define STAMP_Y 4 #define STAMP_MAX 120 +#define NGOL 13 + +#define CIRCLE_BRUSH 0 +#define SQUARE_BRUSH 1 +#define BRUSH_NUM 2 + #ifdef PIX16 typedef unsigned short pixel; #else @@ -80,6 +86,15 @@ extern int amd; extern int FPSB; +int NUM_PARTS; +int GRAV; +int GRAV_R; +int GRAV_G; +int GRAV_B; +int GRAV_R2; +int GRAV_G2; +int GRAV_B2; + extern int legacy_enable; extern int sys_pause; @@ -103,6 +118,24 @@ struct stamp }; typedef struct stamp stamp; +int MSIGN; +int CGOL; +int ISGOL; +int ISLOVE; +int ISLOLZ; +int ISGRAV; +int ISWIRE; +int GSPEED; +int love[XRES/9][YRES/9]; +int lolz[XRES/9][YRES/9]; +int gol[XRES][YRES]; +int gol2[XRES][YRES][NGOL]; +int SEC; +int SEC2; +int REPLACE_MODE; +int CURRENT_BRUSH; +int GRID_MODE; +int VINE_MODE; extern sign signs[MAXSIGNS]; extern stamp stamps[STAMP_MAX]; extern int stamp_count; diff --git a/includes/graphics.h b/includes/graphics.h index e23fe9d10..352439521 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -137,7 +137,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height); int render_thumb(void *thumb, int size, int bzip2, pixel *vid_buf, int px, int py, int scl); -void render_cursor(pixel *vid, int x, int y, int t, int r); +void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry); void sdl_open(void); diff --git a/includes/interface.h b/includes/interface.h index f12d25bff..a5f1a116a 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -8,6 +8,7 @@ struct menu_section char *icon; const char *name; int itemcount; + int doshow; }; typedef struct menu_section menu_section; @@ -50,19 +51,23 @@ static menu_wall mwalls[] = #define SC_GAS 3 #define SC_LIQUID 4 #define SC_NUCLEAR 7 -#define SC_TOTAL 9 +#define SC_LIFE 9 +#define SC_CRACKER 10 +#define SC_TOTAL 10 static menu_section msections[] = { - {"\xC1", "Walls", 0}, - {"\xC2", "Electronics", 0}, - {"\xC3", "Explosives", 0}, - {"\xC5", "Gasses", 0}, - {"\xC4", "Liquids", 0}, - {"\xD0", "Powders", 0}, - {"\xD1", "Solids", 0}, - {"\xC6", "Radioactive", 0}, - {"\xCC", "Special", 0}, + {"\xC1", "Walls", 0, 1}, + {"\xC2", "Electronics", 0, 1}, + {"\xC3", "Explosives", 0, 1}, + {"\xC5", "Gasses", 0, 1}, + {"\xC4", "Liquids", 0, 1}, + {"\xD0", "Powders", 0, 1}, + {"\xD1", "Solids", 0, 1}, + {"\xC6", "Radioactive", 0, 1}, + {"\xCC", "Special", 0, 1}, + {"\xC8", "Life", 0, 1}, + {"\xC8", "Cracker", 0, 0}, }; struct ui_edit @@ -100,6 +105,7 @@ struct ui_checkbox }; typedef struct ui_checkbox ui_checkbox; +int SLALT; extern SDLMod sdl_mod; extern int sdl_key, sdl_wheel, sdl_caps, sdl_ascii, sdl_zoom_trig; extern char *shift_0; diff --git a/includes/misc.h b/includes/misc.h index db3c2cb70..5f08c950a 100644 --- a/includes/misc.h +++ b/includes/misc.h @@ -69,4 +69,4 @@ void *file_load(char *fn, int *size); int cpu_check(void); -#endif \ No newline at end of file +#endif diff --git a/includes/powder.h b/includes/powder.h index b2450d5da..880cdaca1 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -5,7 +5,10 @@ #include "defines.h" #include "interface.h" -#define CM_COUNT 7 +#define CM_COUNT 10 +#define CM_GRAD 9 +#define CM_CRACK 8 +#define CM_NOTHING 7 #define CM_FANCY 6 #define CM_HEAT 5 #define CM_BLOB 4 @@ -14,29 +17,35 @@ #define CM_PRESS 1 #define CM_VEL 0 -#define UI_WALLSTART 37 + +#define UI_WALLSTART 222 +#define UI_ACTUALSTART 122 #define UI_WALLCOUNT 19 -#define SPC_AIR 136 -#define SPC_HEAT 137 -#define SPC_COOL 138 -#define SPC_VACUUM 139 +#define WL_WALLELEC 122 +#define WL_EWALL 123 +#define WL_DETECT 124 +#define WL_STREAM 125 +#define WL_SIGN 126 +#define WL_FAN 127 +#define WL_FANHELPER 255 +#define WL_ALLOWLIQUID 128 +#define WL_DESTROYALL 129 +#define WL_ERASE 130 +#define WL_WALL 131 +#define WL_ALLOWAIR 132 +#define WL_ALLOWSOLID 133 +#define WL_ALLOWALLELEC 134 +#define WL_EHOLE 135 + +#define SPC_AIR 236 +#define SPC_HEAT 237 +#define SPC_COOL 238 +#define SPC_VACUUM 239 + +#define WL_ALLOWGAS 140 + -#define WL_WALLELEC 22 -#define WL_EWALL 23 -#define WL_DETECT 24 -#define WL_STREAM 25 -#define WL_SIGN 26 -#define WL_FAN 27 -#define WL_ALLOWLIQUID 28 -#define WL_DESTROYALL 29 -#define WL_ERASE 30 -#define WL_WALL 31 -#define WL_ALLOWAIR 32 -#define WL_ALLOWSOLID 33 -#define WL_ALLOWALLELEC 34 -#define WL_EHOLE 35 -#define WL_ALLOWGAS 40 #define PT_NONE 0 #define PT_DUST 1 @@ -116,7 +125,55 @@ #define PT_HSWC 75 #define PT_IRON 76 #define PT_MORT 77 -#define PT_NUM 78 +#define PT_GOL 78 +#define PT_HLIF 79 +#define PT_ASIM 80 +#define PT_2x2 81 +#define PT_DANI 82 +#define PT_AMOE 83 +#define PT_MOVE 84 +#define PT_PGOL 85 +#define PT_DMOE 86 +#define PT_34 87 +#define PT_LLIF 88 +#define PT_STAN 89 +#define PT_CRAC 90 +#define PT_RIME 91 +#define PT_FOG 92 +#define PT_BCLN 93 +#define PT_LOVE 94 +#define PT_DEUT 95 +#define PT_WARP 96 +#define PT_PUMP 97 +#define PT_FWRK 98 +#define PT_PIPE 99 +#define PT_FRZZ 100 +#define PT_FRZW 101 +#define PT_GRAV 102 +#define PT_A_A 103 +#define PT_A_AG 104 +#define PT_A_AS 105 +#define PT_INST 106 +#define PT_ISOZ 107 +#define PT_ISZS 108 +#define PT_PRTI 109 +#define PT_PRTO 110 +#define PT_PSTE 111 +#define PT_PSTS 112 +#define PT_ANAR 113 +#define PT_VINE 114 +#define PT_INVIS 115 +#define PT_EQUALVEL 116//all particles equal their velocities +#define PT_INST2 117 +#define PT_INST3 118 +#define PT_SHLD1 119 +#define PT_SHLD2 120 +#define PT_SHLD3 121 +#define PT_SHLD4 122 +#define PT_LOLZ 123 +#define PT_WIFI 124 +#define PT_FILT 125 +#define PT_NUM 126 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -129,7 +186,7 @@ #define ST_LIQUID 2 #define ST_GAS 3 /* - TODO: We should start to implement these. (Almost done) + TODO: We should start to implement these. */ #define TYPE_PART 0x0001 //1 Powders #define TYPE_LIQUID 0x0002 //2 Liquids @@ -231,7 +288,7 @@ static const part_type ptypes[PT_NUM] = {"ACID", PIXPACK(0xED55FF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 40, 0, 0, 1, 1, 10, SC_LIQUID, R_TEMP+0.0f +273.15f, 34, "Dissolves almost everything.", TYPE_LIQUID}, {"VOID", PIXPACK(0x790B0B), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Hole, will drain away any particles.", TYPE_SOLID}, {"WTRV", PIXPACK(0xA0A0FF), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, -0.1f, 0.75f, 0.0003f * CFDS, 0, 0, 0, 0, 4, 1, 1, SC_GAS, R_TEMP+100.0f+273.15f, 48, "Steam, heats up air, produced from hot water.", TYPE_GAS}, - {"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, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 100, "Concrete, stronger than stone.", TYPE_PART}, + {"CNCT", PIXPACK(0xC0C0C0), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 55, SC_POWDERS, R_TEMP+0.0f +273.15f, 100, "Concrete, stronger than stone.", TYPE_PART}, {"DSTW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 23, "Distilled water, does not conduct electricity.", TYPE_LIQUID|PROP_NEUTPENETRATE}, {"SALT", PIXPACK(0xFFFFFF), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 75, SC_POWDERS, R_TEMP+0.0f +273.15f, 110, "Salt, dissolves in water.", TYPE_PART}, {"SLTW", PIXPACK(0x4050F0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 35, SC_LIQUID, R_TEMP+0.0f +273.15f, 75, "Saltwater, conducts electricity, difficult to freeze.", TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE}, @@ -252,7 +309,7 @@ static const part_type ptypes[PT_NUM] = {"LRBD", PIXPACK(0xAAAAAA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 1000, 1, 0, 2, 1, 45, SC_EXPLOSIVE, R_TEMP+45.0f+273.15f, 170, "Liquid Rubidium.", TYPE_LIQUID|PROP_CONDUCTS}, {"NTCT", PIXPACK(0x505040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)", TYPE_SOLID}, {"SAND", PIXPACK(0xFFD090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Sand, Heavy particles. Meltable.", TYPE_PART}, - {"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, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", TYPE_SOLID | PROP_NEUTPASS}, + {"GLAS", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", TYPE_SOLID | PROP_NEUTPASS}, {"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)", TYPE_SOLID}, {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", TYPE_PART}, {"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_ELEC, 9000.0f +273.15f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", TYPE_ENERGY}, @@ -285,7 +342,56 @@ static const part_type ptypes[PT_NUM] = {"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", TYPE_SOLID}, {"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrlosis of WATR", TYPE_SOLID}, {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 0, -1, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 60, "Steam Train.", TYPE_PART}, - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins(real world, by triclops200) Description + {"GOL ", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! (23/3)", TYPE_SOLID}, + {"HLIF", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "High Life! (like GOL 23/36)", TYPE_SOLID}, + {"ASIM", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Assimilation! (4567/345)", TYPE_SOLID}, + {"2x2 ", PIXPACK(0xFFFF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "2x2! (125/36)", TYPE_SOLID}, + {"DANI", PIXPACK(0x00FFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Day and Night! (34678/3678)", TYPE_SOLID}, + {"AMOE", PIXPACK(0xFF00FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Amoeba! (1358/357)", TYPE_SOLID}, + {"MOVE", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type(245/368)", TYPE_SOLID}, + {"PGOL", PIXPACK(0xE05010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Pseudo Life! (238/357)", TYPE_SOLID}, + {"DMOE", PIXPACK(0x500000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Diamoeba! (5678/35678)", TYPE_SOLID}, + {"34 ", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! (34/34)", TYPE_SOLID}, + {"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! (5/345)", TYPE_SOLID}, + {"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! (235678/3678)", TYPE_SOLID}, + {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.",TYPE_SOLID}, + {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 100, SC_CRACKER, 243.15f, 100, "Not quite Ice",TYPE_SOLID}, + {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_CRACKER, 243.15f, 100, "Not quite Steam",TYPE_GAS}, + {"BCLN", PIXPACK(0xFFD040), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Breakable Clone.", TYPE_SOLID}, + {"LOVE", PIXPACK(0xFF30FF), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 373.0f, 40, "Love...", TYPE_SOLID}, + {"DEUT", PIXPACK(0x00153F), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 251, "Deuterium oxide. Volume changes with temp, radioactive with neutrons.", TYPE_LIQUID|PROP_NEUTPENETRATE}, + {"WARP", PIXPACK(0x000000), 0.8f, 0.00f * CFDS, 0.9f, 0.70f, -0.1f, 0.0f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, SC_NUCLEAR, R_TEMP +273.15f, 100, "Displaces other elements.",TYPE_GAS}, + {"PUMP", PIXPACK(0x10103B), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_ELEC, 273.15f, 0, "Changes pressure to its temp when activated. (use HEAT/COOL).", TYPE_SOLID}, + {"FWRK", PIXPACK(0x666666), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 97, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 100, "First fireworks made, activated by heat/neutrons."}, + {"PIPE", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SOLIDS, 273.15f, 0, "Moves elements around, read FAQ on website for help.", TYPE_SOLID}, + {"FRZZ", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 0, 50, SC_CRACKER, 90.0f, 46, "FREEZE", TYPE_PART}, + {"FRZW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 0, 30, SC_CRACKER, 120.0f, 29, "FREEZE WATER", TYPE_LIQUID}, + {"GRAV", PIXPACK(0xFFE0A0), 0.7f, 0.00f * CFDS, 1.00f, 1.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Changes colour based on velocity.", TYPE_PART}, + {"@_@", PIXPACK(0x00FF77), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 30, SC_LIQUID, R_TEMP+0.0f +273.15f, 29, "@_@, contradicts the normal state changes.", TYPE_LIQUID}, + {"@_@G", PIXPACK(0x00FFBB), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 2.75f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 1, SC_CRACKER, R_TEMP-200.0f+273.15f, 42, "@_@ gas", TYPE_GAS}, + {"@_@S", PIXPACK(0x00E455), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_CRACKER, R_TEMP+300.0f+273.15f, 251, "@_@ solid", TYPE_SOLID}, + {"INST", PIXPACK(0x404039), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Instantly conducts, like walls, is now also a battery, PSCN to charge, NSCN to take.", TYPE_SOLID|PROP_CONDUCTS}, + {"ISOZ", PIXPACK(0xAA30D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 24, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 29, "Radioactive liquid", TYPE_LIQUID|PROP_NEUTPENETRATE}, + {"ISZS", PIXPACK(0x662089), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0007f* CFDS, 0, 0, 0, 1, 1, 1, 100, SC_NUCLEAR, 140.00f, 251, "Solid form of ISOZ, slowly decays.", TYPE_SOLID}, + {"PRTI", PIXPACK(0xEB5917), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 40, "Portal IN. Things go in here", TYPE_SOLID}, + {"PRTO", PIXPACK(0x0020EB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 40, "Portal OUT. Things come out here", TYPE_SOLID}, + {"PSTE", PIXPACK(0xAA99AA), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Colloid, Hardens under pressure", TYPE_LIQUID}, + {"PSTS", PIXPACK(0x776677), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 20, 0, 100, SC_CRACKER, R_TEMP-2.0f +273.15f, 29, "Solid form of PSTE, temporary", TYPE_SOLID}, + {"ANAR", PIXPACK(0xFFFFEE), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.1f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Behaves opposite gravity", TYPE_PART}, + {"VINE", PIXPACK(0x079A00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Vine, grows", TYPE_SOLID}, + {"INVS", PIXPACK(0x00CCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Invisible to everything while under pressure.", TYPE_SOLID}, + {"EQVE", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 85, SC_CRACKER, R_TEMP+0.0f +273.15f, 70, "Shared velocity test", TYPE_PART}, + {"INST", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "helper for INST", 0}, + {"INST", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "helper for INST", 0}, + {"SHLD", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0}, + {"SHD2", PIXPACK(0x777777), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER, R_TEMP+0.0f +273.15f, 0, "Shield lvl 2", 0}, + {"SHD3", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER, R_TEMP+0.0f +273.15f, 0, "Shield lvl 3", 0}, + {"SHD4", PIXPACK(0x212121), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER, R_TEMP+0.0f +273.15f, 0, "Shield lvl 4", 0}, + {"LOLZ", PIXPACK(0x569212), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.0f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 373.0f, 40, "Lolz", TYPE_SOLID}, + {"WIFI", PIXPACK(0x40A060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "Wireless transmitter, color coded.", TYPE_SOLID}, + {"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", TYPE_SOLID}, + +//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins(real world, by triclops200) Description }; static part_state pstates[PT_NUM] = @@ -314,7 +420,7 @@ static part_state pstates[PT_NUM] = /* PLNT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 573.0f}, /* ACID */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* VOID */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* WTRV */ {ST_GAS, PT_ICEI, 273.0f, PT_DSTW, 371.0f, PT_NONE, 373.0f, PT_NONE, 0.0f}, + /* WTRV */ {ST_GAS, PT_RIME, 273.0f, PT_DSTW, 371.0f, PT_NONE, 373.0f, PT_NONE, 0.0f}, /* CNCT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1123.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* DSTW */ {ST_LIQUID, PT_ICEI, 273.15f, PT_NONE, 0.0f, PT_WTRV, 373.0f, PT_NONE, 0.0f}, /* SALT */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1173.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, @@ -368,8 +474,100 @@ static part_state pstates[PT_NUM] = /* PCLN */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* HSWC */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* IRON */ {ST_SOLID, PT_NONE, 0.0f, PT_LAVA, 1687.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* MORT */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* MORT */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* Crac */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 2730.0f}, + /* RIME */ {ST_SOLID, PT_NONE, 0.0f, PT_WATR, 273.15f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FOG */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* BCLN */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* LOVE */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* WTF */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* WARP */ {ST_GAS , PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PUMP */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FWRK */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FWRK */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FRZZ */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FRZW */ {ST_LIQUID, PT_ICEI, 53.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* GRAV */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* @_@ */ {ST_LIQUID, PT_A_AG, 100.0f, PT_NONE, 0.0f, PT_A_AS, 400.0f, PT_NONE, 0.0f}, + /* @_@g */ {ST_GAS , PT_A_AG, 100.0f, PT_A_A , 273.0f, PT_A_AS, 400.0f, PT_NONE, 0.0f}, + /* @_@s */ {ST_SOLID, PT_A_AG, 100.0f, PT_A_A , 273.0f, PT_A_AS, 400.0f, PT_NONE, 0.0f}, + /* INST */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* ISOZ */ {ST_LIQUID, PT_ISZS, 160.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* ISZS */ {ST_SOLID, PT_NONE, 0.0f, PT_ISOZ, 300.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PRTI */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PRTO */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PSTE */ {ST_LIQUID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* PSTS */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* ANAR */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* VINE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 573.0f}, + /* INVS */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* EQVE */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* INST2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* INST3*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SHLD1*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SHLD2*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SHLD3*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* SHLD4*/ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* LOlZ */ {ST_GAS, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* WIFI */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* FILT */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + }; +static int grule[NGOL][9] = +{ +// 0,1,2,3,4,5,6,7,8 live=1 spawn=2 spawn&live=3 + {0,0,0,0,0,0,0,0,0},//blank + {0,0,1,3,0,0,0,0,0},//GOL + {0,0,1,3,0,0,2,0,0},//HLIF + {0,0,0,2,3,3,1,1,0},//ASIM + {0,1,1,2,0,1,2,0,0},//2x2 + {0,0,0,3,1,0,3,3,3},//DANI + {0,1,0,3,0,3,0,2,1},//AMOE + {0,0,1,2,1,1,2,0,2},//MOVE + {0,0,1,3,0,2,0,2,1},//PGOL + {0,0,0,2,0,3,3,3,3},//DMOE + {0,0,0,3,3,0,0,0,0},//34 + {0,0,0,2,2,3,0,0,0},//LLIF + {0,0,1,3,0,1,3,3,3},//STAN +}; +static int loverule[9][9] = +{ + {0,0,1,1,0,0,0,0,0}, + {0,1,0,0,1,1,0,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,0,0,0,0,1,0}, + {0,1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1,0}, + {1,0,0,0,0,0,1,0,0}, + {0,1,0,0,1,1,0,0,0}, + {0,0,1,1,0,0,0,0,0}, +}; +static int lolzrule[9][9] = +{ + {0,0,0,0,0,0,0,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,0,0,0,1,0,0}, + {1,0,0,1,1,0,0,1,0}, + {1,0,1,0,0,1,0,1,0}, + {1,0,1,0,0,1,0,1,0}, + {0,1,0,1,1,0,0,1,0}, + {0,1,0,0,0,0,0,1,0}, + {0,1,0,0,0,0,0,1,0}, +}; +int portal[8][8]; +int wireless[25]; extern int isplayer; extern float player[27]; @@ -419,9 +617,9 @@ extern inline int is_wire_off(int x, int y); void set_emap(int x, int y); #if defined(WIN32) && !defined(__GNUC__) -_inline int parts_avg(int ci, int ni); +_inline int parts_avg(int ci, int ni, int t); #else -int parts_avg(int ci, int ni); +int parts_avg(int ci, int ni, int t); #endif int nearest_part(int ci, int t); @@ -436,8 +634,8 @@ void create_box(int x1, int y1, int x2, int y2, int c); int flood_parts(int x, int y, int c, int cm, int bm); -int create_parts(int x, int y, int r, int c); +int create_parts(int x, int y, int rx, int ry, int c); -void create_line(int x1, int y1, int x2, int y2, int r, int c); +void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c); #endif diff --git a/src/air.c b/src/air.c index 385abef86..04141e2dc 100644 --- a/src/air.c +++ b/src/air.c @@ -54,15 +54,15 @@ void update_air(void) vy[y][x] *= VLOSS; vx[y][x] += dx*TSTEPV; vy[y][x] += dy*TSTEPV; - if(bmap[y][x]==1 || bmap[y][x+1]==1 || - bmap[y][x]==8 || bmap[y][x+1]==8 || - (bmap[y][x]==7 && !emap[y][x]) || - (bmap[y][x+1]==7 && !emap[y][x+1])) + if(bmap[y][x]==WL_WALL || bmap[y][x+1]==WL_WALL || + bmap[y][x]==WL_WALLELEC || bmap[y][x+1]==WL_WALLELEC || + (bmap[y][x]==WL_EWALL && !emap[y][x]) || + (bmap[y][x+1]==WL_EWALL && !emap[y][x+1])) vx[y][x] = 0; - if(bmap[y][x]==1 || bmap[y+1][x]==1 || - bmap[y][x]==8 || bmap[y+1][x]==8 || - (bmap[y][x]==7 && !emap[y][x]) || - (bmap[y+1][x]==7 && !emap[y+1][x])) + if(bmap[y][x]==WL_WALL || bmap[y+1][x]==WL_WALL || + bmap[y][x]==WL_WALLELEC || bmap[y+1][x]==WL_WALLELEC || + (bmap[y][x]==WL_EWALL && !emap[y][x]) || + (bmap[y+1][x]==WL_EWALL && !emap[y+1][x])) vy[y][x] = 0; } @@ -76,9 +76,9 @@ void update_air(void) for(i=-1; i<2; i++) if(y+j>0 && y+j0 && x+i 256.0f) dp = 256.0f; if(dp < -256.0f) dp = -256.0f; if(dx > 256.0f) dx = 256.0f; diff --git a/src/graphics.c b/src/graphics.c index 67a1324f3..5476bf719 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -21,7 +21,7 @@ #include -unsigned cmode = 3; +unsigned cmode = CM_FIRE; SDL_Surface *sdl_scrn; int sdl_scale = 1; @@ -447,7 +447,7 @@ void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswa int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) { int i, j, c; - if(b>=121) + if(b>=UI_WALLSTART) { b = b-100; //x = (2+32*((b-22)/1)); @@ -470,7 +470,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 23: + case WL_EWALL: for(j=1; j<15; j++) { for(i=1; i<6+j; i++) @@ -489,7 +489,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 24: + case WL_DETECT: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -498,7 +498,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 25: + case WL_STREAM: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -512,7 +512,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) drawpixel(vid_buf, x+i, y+8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255); } break; - case 26: + case WL_SIGN: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -523,7 +523,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) 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: + case WL_FAN: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -532,7 +532,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 28: + case WL_ALLOWLIQUID: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -544,7 +544,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 29: + case WL_DESTROYALL: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -553,7 +553,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 30: + case WL_ERASE: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<13; i+=2) @@ -569,7 +569,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 32: + case WL_ALLOWAIR: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -578,7 +578,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 33: + case WL_ALLOWSOLID: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -587,7 +587,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 34: + case WL_ALLOWALLELEC: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -599,7 +599,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } break; - case 36: + case SPC_AIR-100: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -618,7 +618,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } drawtext(vid_buf, x+14-textwidth("AIR")/2, y+4, "AIR", c, c, c, 255); break; - case 37: + case SPC_HEAT-100: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -637,7 +637,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } drawtext(vid_buf, x+14-textwidth("HEAT")/2, y+4, "HEAT", c, c, c, 255); break; - case 38: + case SPC_COOL-100: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -656,7 +656,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } drawtext(vid_buf, x+14-textwidth("COOL")/2, y+4, "COOL", c, c, c, 255); break; - case 39: + case SPC_VACUUM-100: for(j=1; j<15; j++) { for(i=1; i<27; i++) @@ -675,7 +675,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } drawtext(vid_buf, x+14-textwidth("VAC")/2, y+4, "VAC", c, c, c, 255); break; - case 40: + case WL_ALLOWGAS: for(j=1; j<15; j+=2) { for(i=1+(1&(j>>1)); i<27; i+=2) @@ -693,7 +693,7 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) } } } - if(b==30) + if(b==WL_ERASE) { for(j=4; j<12; j++) { @@ -745,7 +745,10 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) void draw_menu(pixel *vid_buf, int i, int hover) { - drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); + if(i==SEC&&SEC!=0) + drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 0, 255, 255, 255); + else + drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); if(hover==i) { fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255); @@ -1107,23 +1110,56 @@ void draw_air(pixel *vid) int x, y, i, j; pixel c; - if(cmode == 2) + if(cmode == CM_PERS) return; for(y=0; y 0.0f) c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0); else c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f)); } - else + else if(cmode == CM_VEL) + { c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f), clamp_flt(pv[y][x], 0.0f, 8.0f), clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f)); + } + else if(cmode == CM_CRACK) + { + int r; + int g; + int b; + r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f); + g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f); + b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f); + if(pv[y][x] > 0.0f) + { + r += clamp_flt(pv[y][x], 0.0f, 16.0f); + if(r>255) + r=255; + if(g>255) + g=255; + if(b>255) + b=255; + c = PIXRGB(r, g, b); + } + else + { + b += clamp_flt(-pv[y][x], 0.0f, 16.0f); + if(r>255) + r=255; + if(g>255) + g=255; + if(b>255) + b=255; + c = PIXRGB(r, g, b); + } + } for(j=0; j=255) + cr = 255; + if(cg>=255) + cg = 255; + if(cb>=255) + cb = 255; + if(cr<=0) + cr = 0; + if(cg<=0) + cg = 0; + if(cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + + } + else if(t==PT_MWAX&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1372,6 +1448,189 @@ void draw_parts(pixel *vid) } } + else if(t==PT_CRAC) + { + cr = PIXR(ptypes[t].pcolors) - parts[i].life*15; + cg = PIXG(ptypes[t].pcolors) - parts[i].life*15; + cb = PIXB(ptypes[t].pcolors) - parts[i].life*15; + if(cr<=50) + cr = 50; + if(cg<=50) + cg = 50; + if(cb<=20) + cb = 20; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + } + else if(t==PT_DEUT) + { + + if(parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) + { + x = nx/CELL; + y = ny/CELL; + cr = 20; + cg = 20; + cb = 20; + cg += fire_g[y][x]; + if(cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if(cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if(cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + { + cr = PIXR(ptypes[t].pcolors) + parts[i].life*1; + cg = PIXG(ptypes[t].pcolors) + parts[i].life*2; + cb = PIXB(ptypes[t].pcolors) + parts[i].life*4; + if(cr>=255) + cr = 255; + if(cg>=255) + cg = 255; + if(cb>=255) + cb = 255; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + } + + } + else if(t==PT_DUST && parts[i].life >= 1) + { + x = nx; + y = ny; + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) + { + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags); + cg = parts[i].tmp/4; + cb = parts[i].ctype/4; + cr = parts[i].flags/4; + x = nx/CELL; + y = ny/CELL; + cg += fire_g[y][x]; + if(cg > 255) cg = 255; + fire_g[y][x] = cg; + cb += fire_b[y][x]; + if(cb > 255) cb = 255; + fire_b[y][x] = cb; + cr += fire_r[y][x]; + if(cr > 255) cr = 255; + fire_r[y][x] = cr; + } + else + blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255); + } + else if(t==PT_GRAV) + { + cr = 20; + cg = 20; + cb = 20; + if(parts[i].vx>0) + { + cr += (parts[i].vx)*GRAV_R; + cg += (parts[i].vx)*GRAV_G; + cb += (parts[i].vx)*GRAV_B; + } + if(parts[i].vy>0) + { + cr += (parts[i].vy)*GRAV_G; + cg += (parts[i].vy)*GRAV_B; + cb += (parts[i].vy)*GRAV_R; + + } + if(parts[i].vx<0) + { + cr -= (parts[i].vx)*GRAV_B; + cg -= (parts[i].vx)*GRAV_R; + cb -= (parts[i].vx)*GRAV_G; + + } + if(parts[i].vy<0) + { + cr -= (parts[i].vy)*GRAV_R2; + cg -= (parts[i].vy)*GRAV_G2; + cb -= (parts[i].vy)*GRAV_B2; + } + if(cr>255) + cr=255; + if(cg>255) + cg=255; + if(cb>255) + cb=255; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if(t==PT_WIFI) + { + float frequency = 0.25; + int q = parts[i].tmp; + cr = sin(frequency*q + 0) * 127 + 128; + cg = sin(frequency*q + 2) * 127 + 128; + cb = sin(frequency*q + 4) * 127 + 128; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } + else if(t==PT_PIPE) + { + if(parts[i].ctype==2) + { + cr = 50; + cg = 1; + cb = 1; + } + else if(parts[i].ctype==3) + { + cr = 1; + cg = 50; + cb = 1; + } + else if(parts[i].ctype==4) + { + cr = 1; + cg = 1; + cb = 50; + } + else if(parts[i].temp<272.15&&parts[i].ctype!=1) + { + if(parts[i].temp>173.25&&parts[i].temp<273.15) + { + cr = 50; + cg = 1; + cb = 1; + } + if(parts[i].temp>73.25&&parts[i].temp<=173.15) + { + cr = 1; + cg = 50; + cb = 1; + } + if(parts[i].temp>=0&&parts[i].temp<=73.15) + { + cr = 1; + cg = 1; + cb = 50; + } + } + else + { + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + } + if(parts[i].tmp) + { + cr = PIXR(ptypes[parts[i].tmp].pcolors); + cg = PIXG(ptypes[parts[i].tmp].pcolors); + cb = PIXB(ptypes[parts[i].tmp].pcolors); + } + blendpixel(vid, nx, ny, cr, cg, cb, 255); + + + + } + else if(t==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) + blendpixel(vid, nx, ny, 15, 0, 150, 100); else if(t==PT_ACID) { if(parts[i].life>255) parts[i].life = 255; @@ -1381,7 +1640,7 @@ void draw_parts(pixel *vid) cr = PIXR(ptypes[t].pcolors)/s; cg = PIXG(ptypes[t].pcolors)/s; cb = PIXB(ptypes[t].pcolors)/s; - if(cmode==6) { + if(cmode==CM_FANCY) { for(x=-1; x<=1; x++) { for(y=-1; y<=1; y++) @@ -1396,7 +1655,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx, ny, cr, cg, cb, 255); } - if(cmode==4) + if(cmode==CM_BLOB) { blendpixel(vid, nx+1, ny, cr, cg, cb, 223); blendpixel(vid, nx-1, ny, cr, cg, cb, 223); @@ -1409,7 +1668,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); } } - else if(t==PT_OIL&&cmode == 6) + else if(t==PT_OIL&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1424,7 +1683,7 @@ void draw_parts(pixel *vid) } else if(t==PT_NEUT) { - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; cg = 8; @@ -1453,7 +1712,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32); blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); } - } else if(t==PT_PLUT&&cmode == 6) + } else if(t==PT_PLUT&&cmode == CM_FANCY) { int tempx; int tempy; @@ -1473,7 +1732,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); } } - } else if(t==PT_URAN&&cmode == 6) + } else if(t==PT_URAN&&cmode == CM_FANCY) { int tempx; int tempy; @@ -1493,7 +1752,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5); } } - } else if(t==PT_SLTW&&cmode == 6) + } else if(t==PT_SLTW&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1506,9 +1765,33 @@ void draw_parts(pixel *vid) } } } + else if(t==PT_FILT) + { + int temp_bin = (int)((parts[i].temp-273.0f)*0.025f); + if(temp_bin < 0) temp_bin = 0; + if(temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; + cg = 0; + cb = 0; + cr = 0; + for(x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for(x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 127); + } else if(t==PT_PHOT) { - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cg = 0; cb = 0; @@ -1575,7 +1858,7 @@ void draw_parts(pixel *vid) y = ny; blendpixel(vid,x,y,17,217,24,255); } - else if(t==PT_LNTG&&cmode == 6) + else if(t==PT_LNTG&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1590,7 +1873,7 @@ void draw_parts(pixel *vid) } else if(t==PT_SMKE) { - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { x = nx/CELL; y = ny/CELL; @@ -1623,7 +1906,7 @@ void draw_parts(pixel *vid) } } } - else if(t==PT_WATR&&cmode == 6) + else if(t==PT_WATR&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1636,7 +1919,7 @@ void draw_parts(pixel *vid) } } - } else if(t==PT_DSTW&&cmode == 6) + } else if(t==PT_DSTW&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1649,7 +1932,7 @@ void draw_parts(pixel *vid) } } } - else if(t==PT_NITR&&cmode == 6) + else if(t==PT_NITR&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1663,7 +1946,7 @@ void draw_parts(pixel *vid) } } - else if(t==PT_LRBD&&cmode == 6) + else if(t==PT_LRBD&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1678,7 +1961,7 @@ void draw_parts(pixel *vid) } - else if(t==PT_NBLE&&cmode == 6) + else if(t==PT_NBLE&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1694,7 +1977,7 @@ void draw_parts(pixel *vid) } } - else if(t==PT_GAS&&cmode == 6) + else if(t==PT_GAS&&cmode == CM_FANCY) { for(x=-1; x<=1; x++) { @@ -1712,7 +1995,7 @@ void draw_parts(pixel *vid) } else if(t==PT_WTRV) { - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { x = nx/CELL; y = ny/CELL; @@ -1747,7 +2030,7 @@ void draw_parts(pixel *vid) } else if(t==PT_THDR) { - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; cg = 16; @@ -1792,7 +2075,7 @@ void draw_parts(pixel *vid) fr = 2 * pv[ny/CELL][nx/CELL]; } vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255)); - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { x = nx/CELL; y = ny/CELL; @@ -1806,7 +2089,7 @@ void draw_parts(pixel *vid) if(fr > 255) fr = 255; fire_r[y][x] = fr; } - if(cmode == 4) { + if(cmode == CM_BLOB) { uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255); uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255); uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255); @@ -1826,7 +2109,7 @@ void draw_parts(pixel *vid) { uint8 GR = 0x50+(parts[i].life*10); vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, GR); - if(cmode == 4) { + if(cmode == CM_BLOB) { blendpixel(vid, nx+1, ny, GR, GR, GR, 223); blendpixel(vid, nx-1, ny, GR, GR, GR, 223); blendpixel(vid, nx, ny+1, GR, GR, GR, 223); @@ -1842,7 +2125,7 @@ void draw_parts(pixel *vid) { uint8 GR = 0x3B+(parts[i].life*19); vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, GR, 10); - if(cmode == 4) { + if(cmode == CM_BLOB) { blendpixel(vid, nx+1, ny, GR, GR, 10, 223); blendpixel(vid, nx-1, ny, GR, GR, 10, 223); blendpixel(vid, nx, ny+1, GR, GR, 10, 223); @@ -1858,7 +2141,7 @@ void draw_parts(pixel *vid) { uint8 GR = 0x3B+(parts[i].life*19); vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(GR, 10, 10); - if(cmode == 4) { + if(cmode == CM_BLOB) { blendpixel(vid, nx+1, ny, GR, 10, 10, 223); blendpixel(vid, nx-1, ny, GR, 10, 10, 223); blendpixel(vid, nx, ny+1, GR, 10, 10, 223); @@ -1870,6 +2153,22 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112); } } + else if(t==PT_PUMP) + { + uint8 GR = 0x3B+(parts[i].life*19); + vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR); + if(cmode == CM_BLOB) { + blendpixel(vid, nx+1, ny, 10, 10, GR, 223); + blendpixel(vid, nx-1, ny, 10, 10, GR, 223); + blendpixel(vid, nx, ny+1, 10, 10, GR, 223); + blendpixel(vid, nx, ny-1, 10, 10, GR, 223); + + blendpixel(vid, nx+1, ny-1, 10, 10, GR, 112); + blendpixel(vid, nx-1, ny-1, 10, 10, GR, 112); + blendpixel(vid, nx+1, ny+1, 10, 10, GR, 112); + blendpixel(vid, nx-1, ny+1, 10, 10, GR, 112); + } + } else if(t==PT_PLSM) { float ttemp = (float)parts[i].life; @@ -1877,7 +2176,7 @@ void draw_parts(pixel *vid) uint8 R = plasma_data[caddress]; uint8 G = plasma_data[caddress+1]; uint8 B = plasma_data[caddress+2]; - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cr = R/8; cg = G/8; @@ -1916,7 +2215,7 @@ void draw_parts(pixel *vid) uint8 R = hflm_data[caddress]; uint8 G = hflm_data[caddress+1]; uint8 B = hflm_data[caddress+2]; - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cr = R/8; cg = G/8; @@ -1955,7 +2254,7 @@ void draw_parts(pixel *vid) uint8 R = firw_data[caddress]; uint8 G = firw_data[caddress+1]; uint8 B = firw_data[caddress+2]; - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cr = R/2; cg = G/2; @@ -1995,7 +2294,7 @@ void draw_parts(pixel *vid) uint8 R = flm_data[caddress]; uint8 G = flm_data[caddress+1]; uint8 B = flm_data[caddress+2]; - if(cmode == 3||cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cr = R/8; cg = G/8; @@ -2083,7 +2382,7 @@ void draw_parts(pixel *vid) 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 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { cr /= 32; cg /= 32; @@ -2104,7 +2403,7 @@ void draw_parts(pixel *vid) else if(t==PT_LAVA || t==PT_SPRK) { vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; - if(cmode == 3 || cmode==4 || cmode==6) + if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY) { if(t == PT_LAVA) { @@ -2173,7 +2472,7 @@ void draw_parts(pixel *vid) //blendpixel(vid, nx+1, ny, R, G, B, 255); } } - if(cmode == 4&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3)) + if(cmode == CM_BLOB&&t!=PT_FIRE&&t!=PT_PLSM&&t!=PT_HFLM&&t!=PT_NONE&&t!=PT_ACID&&t!=PT_LCRY&&t!=PT_GLOW&&t!=PT_SWCH&&t!=PT_SMKE&&t!=PT_WTRV&&!(t==PT_FIRW&&parts[i].tmp==3)) { if(t==PT_PHOT) { cg = 0; @@ -2223,7 +2522,7 @@ void draw_parts(pixel *vid) void render_signs(pixel *vid_buf) { - int i, j, x, y, w, h, dx, dy; + int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq; char buff[30]; //Buffer for(i=0; i>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)r*r || i*i+(j+1)*(j+1)>r*r)) + else if(ry<=0) + xor_pixel(x, y, vid); + if(rx+ry<=0) + xor_pixel(x, y, vid); + else if(CURRENT_BRUSH==SQUARE_BRUSH) + { + for(j=0; j<=ry; j++) + for(i=0; i<=rx; i++) + if(i*j<=ry*rx && ((i+1)>rx || (j+1)>ry)) + { + xor_pixel(x+i, y+j, vid); + xor_pixel(x-i, y-j, vid); + if(i&&j)xor_pixel(x+i, y-j, vid); + if(i&&j)xor_pixel(x-i, y+j, vid); + } + } + else if(CURRENT_BRUSH==CIRCLE_BRUSH) + for(j=0; j<=ry; j++) + for(i=0; i<=rx; i++) + if((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1 && ((pow(i+1,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))>1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1)) { xor_pixel(x+i, y+j, vid); if(j) xor_pixel(x+i, y-j, vid); @@ -2651,7 +2975,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int r) else { int tc; - c = (r/CELL) * CELL; + c = (rx/CELL) * CELL; x = (x/CELL) * CELL; y = (y/CELL) * CELL; diff --git a/src/interface.c b/src/interface.c index 00aa02093..044b65c77 100644 --- a/src/interface.c +++ b/src/interface.c @@ -101,11 +101,16 @@ 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; @@ -120,7 +125,6 @@ void add_sign_ui(pixel *vid_buf, int mx, int my) } if(i >= MAXSIGNS) return; - if(nm) { signs[i].x = mx; @@ -166,12 +170,18 @@ void add_sign_ui(pixel *vid_buf, int mx, int my) draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1); draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2); + + + + if(!nm) { drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255); drawtext(vid_buf, x0+138, y0+45, "\x85", 255, 255, 255, 255); drawtext(vid_buf, x0+152, y0+46, "Delete", 255, 255, 255, 255); drawrect(vid_buf, x0+134, y0+42, 50, 15, 255, 255, 255, 255); + drawrect(vid_buf,x0+104,y0+42,26,15,255,255,255,255); + drawtext(vid_buf, x0+110, y0+48, "Mv.", 255, 255, 255, 255); } drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255); @@ -188,6 +198,11 @@ void add_sign_ui(pixel *vid_buf, int mx, int my) if(b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59) ju = 2; + if(!nm && b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59) + { + MSIGN = i; + break; + } if(b && !bq && mx>=x0+9 && mx=y0+22 && my=x0 && mx=y0+64 && my<=y0+80) @@ -513,28 +528,37 @@ void draw_svf_ui(pixel *vid_buf) switch(cmode) { - case 0: + case CM_VEL: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); break; - case 1: + case CM_PRESS: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); break; - case 2: + case CM_PERS: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); break; - case 3: + case CM_FIRE: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9B", 255, 0, 0, 255); drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9C", 255, 255, 64, 255); break; - case 4: + case CM_BLOB: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); break; - case 5: + case CM_HEAT: drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); break; - case 6: + case CM_FANCY: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255); + break; + case CM_NOTHING: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); + break; + case CM_CRACK: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); + break; + case CM_GRAD: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); break; } drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); @@ -1460,32 +1484,42 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr) 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; + SEC = SEC2; 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); h = -1; - x = XRES-BARSIZE-26; + x = XRES-BARSIZE-18; y = YRES+1; sy = y; if(i==SC_WALL) { - for(n = 122; n<122+UI_WALLCOUNT; n++) + for(n = UI_WALLSTART; n=x+32 && mx=y && my< y+15) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); h = n; } + if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if(n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } else if(n==*sl) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); @@ -1499,21 +1533,30 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } else if(i==SC_SPECIAL) { - for(n = 122; n<122+UI_WALLCOUNT; n++) + for(n = UI_WALLSTART; n=x+32 && mx=y && my< y+15) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); h = n; } + if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if(n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } else if(n==*sl) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); @@ -1528,9 +1571,9 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if(ptypes[n].menusection==i&&ptypes[n].menu==1) { - if(x-26<=20) + if(x-18<=20) { - x = XRES-BARSIZE-26; + x = XRES-BARSIZE-18; y += 19; } x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; @@ -1539,6 +1582,15 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); h = n; } + if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if(n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } else if(n==*sl) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); @@ -1556,9 +1608,9 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if(ptypes[n].menusection==i&&ptypes[n].menu==1) { - if(x-26<=20) + if(x-18<=20) { - x = XRES-BARSIZE-26; + x = XRES-BARSIZE-18; y += 19; } x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; @@ -1567,6 +1619,15 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); h = n; } + if(!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + h = n; + } + else if(n==SLALT) + { + drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + } else if(n==*sl) { drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); @@ -1578,27 +1639,64 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } } } + if(!bq&&mx>=sdl_scale*((XRES+BARSIZE)-16) && mx= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && my=0&&i=122)) + else if(i==SC_WALL||(i==SC_SPECIAL&&h>=UI_WALLSTART)) { - drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-122].descs)-BARSIZE, sy-10, (char *)mwalls[h-122].descs, 255, 255, 255, 255); + drawtext(vid_buf, XRES-textwidth((char *)mwalls[h-UI_WALLSTART].descs)-BARSIZE, sy-10, (char *)mwalls[h-UI_WALLSTART].descs, 255, 255, 255, 255); } else { drawtext(vid_buf, XRES-textwidth((char *)ptypes[h].descs)-BARSIZE, sy-10, (char *)ptypes[h].descs, 255, 255, 255, 255); } + if(b==1&&h==-1) + { + if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + { + SLALT = -1; + SEC2 = SEC; + } + } if(b==1&&h!=-1) { - *sl = h; + if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + { + SLALT = h; + SEC2 = -1; + } + else{ + *sl = h; + } + } + if(b==4&&h==-1) + { + if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0) + { + SLALT = -1; + SEC2 = SEC; + } } if(b==4&&h!=-1) { - *sr = h; + if(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)) + { + SLALT = h; + SEC2 = -1; + } + else{ + *sr = h; + } } } @@ -1685,38 +1783,44 @@ void set_cmode(int cm) { cmode = cm; itc = 51; - if(cmode==4) + if(cmode==CM_BLOB) { memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); strcpy(itc_msg, "Blob Display"); } - else if(cmode==5) + else if(cmode==CM_HEAT) { strcpy(itc_msg, "Heat Display"); } - else if(cmode==6) + else if(cmode==CM_FANCY) { memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); strcpy(itc_msg, "Fancy Display"); } - else if(cmode==3) + else if(cmode==CM_FIRE) { memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); strcpy(itc_msg, "Fire Display"); } - else if(cmode==2) + else if(cmode==CM_PERS) { memset(fire_bg, 0, XRES*YRES*PIXELSIZE); strcpy(itc_msg, "Persistent Display"); } - else if(cmode==1) + else if(cmode==CM_PRESS) strcpy(itc_msg, "Pressure Display"); + else if(cmode==CM_NOTHING) + strcpy(itc_msg, "Nothing Display"); + else if(cmode==CM_CRACK) + strcpy(itc_msg, "Alternate Velocity Display"); + else if(cmode==CM_GRAD) + strcpy(itc_msg, "Heat Gradient Display"); else strcpy(itc_msg, "Velocity Display"); } @@ -2542,7 +2646,6 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) drawrect(vid_buf, 50, 50, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 155); drawrect(vid_buf, 50+(XRES/2)+1, 50, XRES+BARSIZE-100-((XRES/2)+1), YRES+MENUSIZE-100, 155, 155, 155, 255); drawtext(vid_buf, 50+(XRES/4)-textwidth("Loading...")/2, 50+(YRES/4), "Loading...", 255, 255, 255, 128); - //Also, The Game. ed.x = 57+(XRES/2)+1; ed.y = YRES+MENUSIZE-118; diff --git a/src/main.c b/src/main.c index d548a45dc..d191fad3a 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ * Copyright (c) 2010 Skresanov Savely * Copyright (c) 2010 Bryan Hoyle * Copyright (c) 2010 Nathan Cousins + * Copyright (c) 2010 cracker64 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + #include #include #include @@ -28,6 +30,7 @@ #include #include #include + #ifdef WIN32 #include #else @@ -49,7 +52,7 @@ #include static const char *it_msg = - "\brThe Powder Toy\n" + "\brThe Powder Toy - http://powdertoy.co.uk/\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" @@ -66,18 +69,16 @@ static const char *it_msg = "'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 7 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 cracker64\n" "\bgCopyright (c) 2010 Bryan Hoyle (New elements)\n" "\bgCopyright (c) 2010 Nathan Cousins (New elements, small engine mods.)\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" ; @@ -99,6 +100,9 @@ int legacy_enable = 0; //Used to disable new features such as heat, will be set int death = 0, framerender = 0; int amd = 1; int FPSB = 0; +int MSIGN =-1; +//int CGOL = 0; +//int GSPEED = 1;//causes my .exe to crash.. sign signs[MAXSIGNS]; @@ -245,7 +249,7 @@ void *build_save(int *size, int x0, int y0, int w, int h) d[p++] = bmap[y][x]; for(y=by0; y=43) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34))) + if(i && (ty==PT_CLNE || (ty==PT_PCLN && ver>=43) || (ty==PT_SPRK && ver>=21) || (ty==PT_LAVA && ver>=34) || (ty==PT_PIPE && ver>=43))) { if(p >= size) goto corrupt; @@ -1003,7 +1041,7 @@ int main(int argc, char *argv[]) int vs = 0; #endif int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty; - int da = 0, db = 0, it = 2047, mx, my, bs = 2; + int da = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2; float nfvx, nfvy; int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0; void *load_data=NULL; @@ -1118,7 +1156,7 @@ int main(int argc, char *argv[]) { for(i=1; i32) - ZSIZE = 32; + if(ZSIZE>60) + ZSIZE = 60; if(ZSIZE<2) ZSIZE = 2; ZFACTOR = 256/ZSIZE; } else { - if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) - bs -= 1; + if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx -= 1; + bsy -= 1; + } + else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx -= 1; + } + else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy -= 1; + } else - bs -= ceil((bs/5)+0.5f); - if(bs>1224) - bs = 1224; - if(bs<0) - bs = 0; + { + bsx -= ceil((bsx/5)+0.5f); + bsy -= ceil((bsy/5)+0.5f); + } + if(bsx>1180) + bsx = 1180; + if(bsy>1180) + bsy = 1180; + if(bsx<0) + bsx = 0; + if(bsy<0) + bsy = 0; } } if(sdl_key==SDLK_RIGHTBRACKET) { if(sdl_zoom_trig==1) { ZSIZE += 1; - if(ZSIZE>32) - ZSIZE = 32; + if(ZSIZE>60) + ZSIZE = 60; if(ZSIZE<2) ZSIZE = 2; ZFACTOR = 256/ZSIZE; } else { - if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) - bs += 1; + if(sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx += 1; + bsy += 1; + } + else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx += 1; + } + else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy += 1; + } else - bs += ceil((bs/5)+0.5f); - if(bs>1224) - bs = 1224; - if(bs<0) - bs = 0; + { + bsx += ceil((bsx/5)+0.5f); + bsy += ceil((bsy/5)+0.5f); + } + if(bsx>1180) + bsx = 1180; + if(bsy>1180) + bsy = 1180; + if(bsx<0) + bsx = 0; + if(bsy<0) + bsy = 0; } } + if(sdl_key==SDLK_INSERT) + REPLACE_MODE = !REPLACE_MODE; + if(sdl_key=='g') + GRID_MODE = (GRID_MODE+1)%10; + if(sdl_key=='t') + VINE_MODE = !VINE_MODE; if(sdl_key==SDLK_SPACE) sys_pause = !sys_pause; if(sdl_key=='h') @@ -1357,7 +1453,7 @@ int main(int argc, char *argv[]) } else if(sdl_key=='c') { - set_cmode((cmode+1) % 7); + set_cmode((cmode+1) % CM_COUNT); if(it > 50) it = 50; } @@ -1394,8 +1490,8 @@ int main(int argc, char *argv[]) if(sdl_zoom_trig==1) { ZSIZE += sdl_wheel; - if(ZSIZE>32) - ZSIZE = 32; + if(ZSIZE>60) + ZSIZE = 60; if(ZSIZE<2) ZSIZE = 2; ZFACTOR = 256/ZSIZE; @@ -1403,11 +1499,27 @@ int main(int argc, char *argv[]) } else { - bs += sdl_wheel; - if(bs>1224) - bs = 1224; - if(bs<0) - bs = 0; + if(!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx += sdl_wheel; + bsy += sdl_wheel; + } + else if(sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx += sdl_wheel; + } + else if(sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy += sdl_wheel; + } + if(bsx>1180) + bsx = 1180; + if(bsx<0) + bsx = 0; + if(bsy>1180) + bsy = 1180; + if(bsy<0) + bsy = 0; sdl_wheel = 0; /*if(su >= PT_NUM) { if(sl < PT_NUM) @@ -1794,9 +1906,9 @@ int main(int argc, char *argv[]) if(x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) { if(b & SDL_BUTTON_LMASK) - set_cmode((cmode+1) % 7); + set_cmode((cmode+1) % CM_COUNT); if(b & SDL_BUTTON_RMASK) - set_cmode((cmode+6) % 7); + set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); save_presets(0); } if(x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) @@ -1808,7 +1920,7 @@ int main(int argc, char *argv[]) { c = (b&1) ? sl : sr; su = c; - if(c==126) + if(c==WL_SIGN+100) { if(!bq) add_sign_ui(vid_buf, x, y); @@ -1818,18 +1930,18 @@ int main(int argc, char *argv[]) if(lm == 1) { xor_line(lx, ly, x, y, vid_buf); - if(c==127 && lx>=0 && ly>=0 && lx=0 && ly>=0 && lx0 && y0 && x=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=4) - create_line(lx, ly, x, y, bs, c); + if(c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN) + create_line(lx, ly, x, y, bsx, bsy, c); } else create_box(lx, ly, x, y, c); @@ -1958,7 +2072,7 @@ int main(int argc, char *argv[]) if(zoom_en!=1 && !load_mode && !save_mode) { - render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bs); + render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy); mousex = mx/sdl_scale; mousey = my/sdl_scale; } @@ -2071,16 +2185,23 @@ int main(int argc, char *argv[]) } if(currentTime-pastFPS>=1000) { -#ifdef BETA - sprintf(uitext, "Version %d (Beta %d) FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); - //printf("%s\n", uitext); -#else - sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); -#endif FPSB = FPS; FPS = 0; pastFPS = currentTime; } + +#ifdef BETA + sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS); +#else + sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); +#endif + if(REPLACE_MODE) + strappend(uitext, " [REPLACE MODE]"); + if(sdl_mod&(KMOD_CAPS)) + strappend(uitext, " [CAP LOCKS]"); + if(GRID_MODE) + sprintf(uitext, "%s [GRID: %d]", uitext, GRID_MODE); + if(sdl_zoom_trig||zoom_en) { if(zoom_x>8].life > 5))) + (r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS || + (r&0xFF)==PT_FILT || + ((r&0xFF)==PT_LCRY&&parts[r>>8].life > 5))) return 2; if(pt==PT_STKM) //Stick man's head shouldn't collide return 2; - if(bmap[ny/CELL][nx/CELL]==13 && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE) + if(bmap[ny/CELL][nx/CELL]==WL_ALLOWGAS && ptypes[pt].falldown!=0 && pt!=PT_FIRE && pt!=PT_SMKE) return 0; - if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==3) + if(ptypes[pt].falldown!=2 && bmap[ny/CELL][nx/CELL]==WL_ALLOWLIQUID) return 0; - if((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==7 && !emap[ny/CELL][nx/CELL]) + if((pt==PT_NEUT ||pt==PT_PHOT) && bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL]) + return 0; + if(bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL]) + return 2; + if(bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR) return 0; - if(bmap[ny/CELL][nx/CELL]==9) + if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID) return 0; - - if(ptypes[pt].falldown!=1 && bmap[ny/CELL][nx/CELL]==10) - return 0; - if(r && (r&0xFF) < PT_NUM){ if(ptypes[pt].properties&TYPE_ENERGY && ptypes[(r&0xFF)].properties&TYPE_ENERGY) return 2; @@ -127,7 +129,8 @@ int try_move(int i, int x, int y, int nx, int ny) return 1; e = eval_move(parts[i].type, nx, ny, &r); - + if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) + return 1; /* half-silvered mirror */ if(!e && parts[i].type==PT_PHOT && (((r&0xFF)==PT_BMTL && rand()>8].life = 120; create_gain_photon(i); } - + if(parts[i].type == PT_PHOT && (r&0xFF)==PT_FILT) + { + int temp_bin = (int)((parts[r>>8].temp-273.0f)*0.025f); + if(temp_bin < 0) temp_bin = 0; + if(temp_bin > 25) temp_bin = 25; + parts[i].ctype = 0x1F << temp_bin; + } if(parts[i].type == PT_NEUT && (r&0xFF)==PT_GLAS) { if(rand() < RAND_MAX/10) create_cherenkov_photon(i); @@ -178,17 +187,17 @@ int try_move(int i, int x, int y, int nx, int ny) return 0; } - if((pmap[ny][nx]&0xFF)==PT_CNCT) - return 0; + if((pmap[ny][nx]&0xFF)==PT_CNCT) + return 0; if(parts[i].type==PT_CNCT && y>8)>8)>8].temp>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); + if((pmap[y][x]&0xFF)==PT_PUMP) + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP); + else + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); } if(t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP); + if((pmap[y][x]&0xFF)==PT_PUMP) + parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP); + else + 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; } @@ -390,6 +405,25 @@ inline int create_part(int p, int x, int y, int t) return -1; } } + if(t==PT_INST2) + if((pmap[y][x]&0xFF)==PT_INST) + { + parts[pmap[y][x]>>8].type = PT_INST2; + parts[pmap[y][x]>>8].life += 5; + pmap[y][x] = (pmap[y][x]&~0xFF) | PT_INST2; + return pmap[y][x]>>8; + } + if(t==PT_INST3) + if((pmap[y][x]&0xFF)==PT_INST||(pmap[y][x]&0xFF)==PT_INST2) + { + parts[pmap[y][x]>>8].type = PT_INST3; + if(parts[pmap[y][x]>>8].life%4==0) + parts[pmap[y][x]>>8].life -=0; + else + parts[pmap[y][x]>>8].life -= 2; + pmap[y][x] = (pmap[y][x]&~0xFF) | PT_INST3; + return pmap[y][x]>>8; + } if(t==SPC_AIR) { pv[y/CELL][x/CELL] += 0.03f; @@ -435,6 +469,8 @@ inline int create_part(int p, int x, int y, int t) (pmap[y][x]&0xFF)!=PT_IRON && (pmap[y][x]&0xFF)!=PT_INWR) return -1; + if(parts[pmap[y][x]>>8].life!=0) + return -1; parts[pmap[y][x]>>8].type = PT_SPRK; parts[pmap[y][x]>>8].life = 4; parts[pmap[y][x]>>8].ctype = pmap[y][x]&0xFF; @@ -479,16 +515,25 @@ inline int create_part(int p, int x, int y, int t) parts[i].life = 150; } End Testing*/ + if(t==PT_WARP) { + parts[i].life = rand()%95+70; + } if(t==PT_FUSE) { parts[i].life = 50; parts[i].tmp = 50; } + if(t==PT_PUMP) + parts[i].life= 10; if(t==PT_FSEP) parts[i].life = 50; if(t==PT_COAL) { parts[i].life = 110; parts[i].tmp = 50; } + if(t==PT_FRZW) + parts[i].life = 100; + if(t==PT_PIPE) + parts[i].life = 60; if(t==PT_BCOL) parts[i].life = 110; if(t==PT_FIRE) @@ -524,7 +569,7 @@ inline int create_part(int p, int x, int y, int t) parts[i].vy = 3.0f*sinf(a); } - if(t!=PT_STKM && t!=PT_PHOT && t!=PT_NEUT) + if(t!=PT_STKM)// && t!=PT_PHOT && t!=PT_NEUT) is this needed? it breaks floodfill pmap[y][x] = t|(i<<8); else if(t==PT_STKM) { @@ -669,9 +714,18 @@ inline void delete_part(int x, int y) i = pmap[y][x]; if(!i || (i>>8)>=NPART) return; - - kill_part(i>>8); - pmap[y][x] = 0; // just in case + if((parts[i>>8].type==SLALT)||SLALT==0) + { + kill_part(i>>8); + pmap[y][x] = 0; + } + else if(ptypes[parts[i>>8].type].menusection==SEC) + { + kill_part(i>>8); + pmap[y][x] = 0; + } + else + return; } #if defined(WIN32) && !defined(__GNUC__) @@ -680,7 +734,7 @@ _inline int is_wire(int x, int y) inline int is_wire(int x, int y) #endif { - return bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12; + return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE; } #if defined(WIN32) && !defined(__GNUC__) @@ -689,7 +743,7 @@ _inline int is_wire_off(int x, int y) inline int is_wire_off(int x, int y) #endif { - return (bmap[y][x]==6 || bmap[y][x]==7 || bmap[y][x]==3 || bmap[y][x]==8 || bmap[y][x]==11 || bmap[y][x]==12) && emap[y][x]<8; + return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE) && emap[y][x]<8; } int get_wavelength_bin(int *wm) @@ -775,20 +829,30 @@ void set_emap(int x, int y) } #if defined(WIN32) && !defined(__GNUC__) -_inline int parts_avg(int ci, int ni) +_inline int parts_avg(int ci, int ni,int t)//t is the particle you are looking for #else -inline int parts_avg(int ci, int ni) +inline int parts_avg(int ci, int ni,int t) #endif { - 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) >= 1) - { - return parts[pmr>>8].type; - } - else - { - return PT_NONE; - } + if(t==PT_INSL)//to keep electronics working + { + int pmr = pmap[(int)((parts[ci].y + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)]; + if((pmr>>8) < NPART && pmr) + return parts[pmr>>8].type; + else + return PT_NONE; + } + else + { + int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate. + if((pmr2>>8) < NPART && pmr2) + { + if(parts[pmr2>>8].type==t) + return t; + } + else + return PT_NONE; + } } @@ -824,6 +888,247 @@ void update_particles_i(pixel *vid, int start, int inc) float c_heat = 0.0f; int h_count = 0; int starti = (start*-1); + if(sys_pause&&!framerender) + return; + if(ISGRAV==1) + { + ISGRAV = 0; + GRAV ++; + GRAV_R = 60; + GRAV_G = 0; + GRAV_B = 0; + GRAV_R2 = 30; + GRAV_G2 = 30; + GRAV_B2 = 0; + for(int q = 0;q <= GRAV;q++) + { + if(GRAV_R >0 && GRAV_G==0) + { + GRAV_R--; + GRAV_B++; + } + if(GRAV_B >0 && GRAV_R==0) + { + GRAV_B--; + GRAV_G++; + } + if(GRAV_G >0 && GRAV_B==0) + { + GRAV_G--; + GRAV_R++; + } + if(GRAV_R2 >0 && GRAV_G2==0) + { + GRAV_R2--; + GRAV_B2++; + } + if(GRAV_B2 >0 && GRAV_R2==0) + { + GRAV_B2--; + GRAV_G2++; + } + if(GRAV_G2 >0 && GRAV_B2==0) + { + GRAV_G2--; + GRAV_R2++; + } + } + if(GRAV>180) GRAV = 0; + + } + if(ISLOVE==1) + { + ISLOVE = 0; + for(ny=0;ny>8)>=NPART || !r) + { + continue; + } + else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE) + parts[r>>8].type = PT_NONE; + else if(parts[r>>8].type==PT_LOVE) + { + love[nx/9][ny/9] = 1; + } + + } + } + for(nx=9;nx<=XRES-18;nx++) + { + for(ny=9;ny<=YRES-7;ny++) + { + if(love[nx/9][ny/9]==1) + { + for(int nnx=0;nnx<9;nnx++) + for(int nny=0;nny<9;nny++) + { + if(ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) + { + continue; + } + if(!rt&&loverule[nnx][nny]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOVE); + else if(!rt) + continue; + else if(parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0) + parts[rt>>8].type=PT_NONE; + + } + } + } + love[nx/9][ny/9]=0; + } + } + } + if(ISLOLZ==1) + { + ISLOLZ = 0; + for(ny=0;ny>8)>=NPART || !r) + { + continue; + } + else if((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ) + parts[r>>8].type = PT_NONE; + else if(parts[r>>8].type==PT_LOLZ) + { + lolz[nx/9][ny/9] = 1; + } + + } + } + for(nx=9;nx<=XRES-18;nx++) + { + for(ny=9;ny<=YRES-7;ny++) + { + if(lolz[nx/9][ny/9]==1) + { + for(int nnx=0;nnx<9;nnx++) + for(int nny=0;nny<9;nny++) + { + if(ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) + { + continue; + } + if(!rt&&lolzrule[nny][nnx]==1) + create_part(-1,nx+nnx,ny+nny,PT_LOLZ); + else if(!rt) + continue; + else if(parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0) + parts[rt>>8].type=PT_NONE; + + } + } + } + lolz[nx/9][ny/9]=0; + } + } + } + if(ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation + { + for(nx=4;nx>8)>=NPART || !r) + { + gol[nx][ny] = 0; + continue; + } + else + for(int golnum=1;golnum>8].type==golnum+77) + { + gol[nx][ny] = golnum; + for(int nnx=-1;nnx<2;nnx++) + for(int nny=-1;nny<2;nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check + { + if(ny+nny<4&&nx+nnx<4){//any way to make wrapping code smaller? + gol2[XRES-5][YRES-5][golnum] ++; + gol2[XRES-5][YRES-5][0] ++; + } + else if(ny+nny<4&&nx+nnx>=XRES-4){ + gol2[4][YRES-5][golnum] ++; + gol2[4][YRES-5][0] ++; + } + else if(ny+nny>=YRES-4&&nx+nnx<4){ + gol2[XRES-5][4][golnum] ++; + gol2[XRES-5][4][0] ++; + } + else if(nx+nnx<4){ + gol2[XRES-5][ny+nny][golnum] ++; + gol2[XRES-5][ny+nny][0] ++; + } + else if(ny+nny<4){ + gol2[nx+nnx][YRES-5][golnum] ++; + gol2[nx+nnx][YRES-5][0] ++; + } + else if(ny+nny>=YRES-4&&nx+nnx>=XRES-4){ + gol2[4][4][golnum] ++; + gol2[4][4][0] ++; + } + else if(ny+nny>=YRES-4){ + gol2[nx+nnx][4][golnum] ++; + gol2[nx+nnx][4][0] ++; + } + else if(nx+nnx>=XRES-4){ + gol2[4][ny+nny][golnum] ++; + gol2[4][ny+nny][0] ++; + } + else{ + gol2[nx+nnx][ny+nny][golnum] ++; + gol2[nx+nnx][ny+nny][0] ++; + } + } + } + } + for(nx=4;nx=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) + { + create_part(-1,nx,ny,golnum+77); + } + else if(neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself + parts[pmap[ny][nx]>>8].type = PT_NONE; + } + gol2[nx][ny][0] = 0; + for(int z = 1;z=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]==13 && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) || - (bmap[y/CELL][x/CELL]==6 && (t==PT_METL || t==PT_SPRK)) || - (bmap[y/CELL][x/CELL]==7 && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) + ((bmap[y/CELL][x/CELL]==WL_WALL || + bmap[y/CELL][x/CELL]==WL_WALLELEC || + bmap[y/CELL][x/CELL]==WL_ALLOWAIR || + (bmap[y/CELL][x/CELL]==WL_DESTROYALL) || + (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) || + (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) || + (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE) || + (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) || + (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM))) { kill_part(i); continue; @@ -888,20 +1192,50 @@ void update_particles_i(pixel *vid, int start, int inc) 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_GAS||t==PT_NBLE) + if(t==PT_ANAR) + { + vx[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vx; + vy[y/CELL][x/CELL] -= ptypes[t].airdrag*parts[i].vy; + } + else + { + 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_GAS||t==PT_NBLE||t==PT_PUMP) { - if(pv[y/CELL][x/CELL]<3.5f) - pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]); - if(y+CELL=256.0+273.15) + parts[i].temp=256.0+273.15; + if(parts[i].temp<= -256.0+273.15) + parts[i].temp = -256.0+273.15; + + if(pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) + pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-pv[y/CELL][x/CELL]); + if(y+CELL1.0f) { @@ -937,10 +1271,27 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].life = rand()%80+300; } } + else if((t==PT_BCLN) && !parts[i].life) + { + if(pv[y/CELL][x/CELL]>4.0f) + { + parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL]; + parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL]; + parts[i].life = rand()%40+80; + } + } else { + if(t==PT_ANAR) + { + 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; + } + 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) @@ -984,7 +1335,7 @@ void update_particles_i(pixel *vid, int start, int inc) 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)) + if(nx<0 || ny<0 || nx>=XRES || ny>=YRES || pmap[ny][nx] || (bmap[ny/CELL][nx/CELL] && bmap[ny/CELL][nx/CELL]!=WL_STREAM)) { parts[i].x = ix; parts[i].y = iy; @@ -998,7 +1349,7 @@ void update_particles_i(pixel *vid, int start, int inc) for(ny=-1; ny<2; ny++) if(x+nx>=0 && y+ny>0 && x+nx1.0f && parts[i].tmp==1) t = parts[i].type = PT_BRMT; - if(t==PT_BRCK && pv[y/CELL][x/CELL]>2.8f) + if(t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f) t = parts[i].type = PT_STNE; + if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f) + t = parts[i].type = PT_BRMT; + if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f) + t = parts[i].type = PT_PSTS; + if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f) + t = parts[i].type = PT_PSTE; + if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f) + t = parts[i].type = PT_NONE; + if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f) + t = parts[i].type = PT_NONE; + if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f) + t = parts[i].type = PT_NONE; + if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f) + t = parts[i].type = PT_NONE; //if(t==PT_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) + if(parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) { parts[i].type = PT_BGLA; } @@ -1046,13 +1411,26 @@ void update_particles_i(pixel *vid, int start, int inc) t = PT_NEUT; create_part(i, x, y, t); } - + if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) + { + t = PT_PHOT; + float rr = (rand()%228+128)/127.0f; + float a = (rand()%8) * 0.78540f; + parts[i].life = 680; + parts[i].ctype = 0x3FFFFFFF; + parts[i].vx = rr*cosf(a); + parts[i].vy = rr*sinf(a); + create_part(i, x, y, t); + } + if(t==PT_PSTE) + if(parts[i].temp>747.0f) + t = parts[i].type = PT_BRCK; if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1) { nearp = nearest_part(i, PT_ETRD); - if(nearp!=-1&&parts_avg(i, nearp)!=PT_INSL) + if(nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) { - create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, PT_PLSM); + create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM); t = parts[i].type = PT_ETRD; parts[i].ctype = PT_NONE; parts[i].life = 20; @@ -1080,7 +1458,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)) + if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)) { h_count++; c_heat += parts[r>>8].temp; @@ -1098,7 +1476,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)) + if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)) { parts[r>>8].temp = parts[i].temp; } @@ -1173,7 +1551,8 @@ void update_particles_i(pixel *vid, int start, int inc) else { t = parts[i].type = pstates[t].gas; - pv[y/CELL][x/CELL] += 0.50f; + if(t!=PT_A_AS) + pv[y/CELL][x/CELL] += 0.50f; if(t==PT_FIRE) parts[i].life = rand()%50+120; if(t==PT_HFLM) @@ -1239,14 +1618,14 @@ void update_particles_i(pixel *vid, int start, int inc) t = PT_SPRK; } } - else if(bmap[ny][nx]==6 || bmap[ny][nx]==7 || bmap[ny][nx]==3 || bmap[ny][nx]==8 || bmap[ny][nx]==11 || bmap[ny][nx]==12) + else if(bmap[ny][nx]==WL_DETECT || bmap[ny][nx]==WL_EWALL || bmap[ny][nx]==WL_ALLOWLIQUID || bmap[ny][nx]==WL_WALLELEC || bmap[ny][nx]==WL_ALLOWALLELEC || bmap[ny][nx]==WL_EHOLE) set_emap(nx, ny); } } nx = x/CELL; ny = y/CELL; - if(bmap[ny][nx]==6 && emap[ny][nx]<8) + if(bmap[ny][nx]==WL_DETECT && emap[ny][nx]<8) set_emap(nx, ny); fe = 0; @@ -1284,6 +1663,13 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(t==PT_ICEI || t==PT_SNOW) { + if(parts[i].ctype==PT_FRZW) + { + parts[i].temp -= 1.0f; + if(parts[i].temp<0) + parts[i].temp = 0; + + } for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) if(x+nx>=0 && y+ny>0 && @@ -1521,7 +1907,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL && parts_avg(i, r>>8)!=PT_INSL) + if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_METL && parts_avg(i, r>>8,PT_INSL)!=PT_INSL) { parts[i].temp = 473.0f; } @@ -1547,10 +1933,59 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].life = 4; t = parts[i].type = PT_FIRE; } + else if((r&0xFF)==PT_SMKE && (1>rand()%250)) + { + parts[r>>8].type = PT_NONE; + parts[i].life = rand()%60 + 60; + } + else if((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE) + { + int nnx = rand()%3 -1; + int nny = rand()%3 -1; + if(x+nx+nnx>=0 && y+ny+nny>0 && + x+nx+nnx>8].temp = parts[i].temp; + } //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000)) //t = parts[i].type = PT_WATR; } + if(parts[i].life==2) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART) + continue; + if(!r) + create_part(-1,x+nx,y+ny,PT_O2); + } + parts[i].life = 0; + } } + else if(t==PT_VINE) + { + nx=(rand()%3)-1; + ny=(rand()%3)-1; + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART) + continue; + if(1>rand()%15) + parts[i].type=PT_PLNT; + else if(!r) + { + create_part(-1,x+nx,y+ny,PT_VINE); + parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp; + parts[i].type=PT_PLNT; + } + } + } else if(t==PT_THRM) { for(nx=-2; nx<3; nx++) @@ -1610,7 +2045,11 @@ void update_particles_i(pixel *vid, int start, int inc) { parts[i].life = 4; t = parts[i].type = PT_FIRE; - + } + if(((r&0xFF)==PT_CNCT&&t==PT_WATR) && 1>(rand()%500)) + { + t = parts[i].type = PT_PSTE; + parts[r>>8].type = PT_NONE; } } } @@ -1633,6 +2072,8 @@ void update_particles_i(pixel *vid, int start, int inc) { parts[r>>8].type = PT_SLTW; } + if((r&0xFF)==PT_PLNT&&5>(rand()%1000)) + parts[r>>8].type = PT_NONE; if(((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && pt>12.0f && 1>(rand()%500)) { parts[i].life = 4; @@ -1707,8 +2148,11 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50) { - parts[i].life--; - parts[r>>8].type = PT_NONE; + if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) + { + parts[i].life--; + parts[r>>8].type = PT_NONE; + } } else if (parts[i].life==50) { @@ -1754,6 +2198,22 @@ void update_particles_i(pixel *vid, int start, int inc) pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough fe ++; } + if((r&0xFF)==PT_DEUT && (rt+1)>(rand()%1000)) + { + + create_part(r>>8, x+nx, y+ny, PT_NEUT); + parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; + parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; + if(parts[r>>8].life>0) + { + parts[r>>8].life --; + parts[r>>8].temp += (parts[r>>8].life*17); + pv[y/CELL][x/CELL] += 6.0f * CFDS; + + } + else + parts[r>>8].type = PT_NONE; + } if((r&0xFF)==PT_GUNP && 15>(rand()%1000)) parts[r>>8].type = PT_DUST; if((r&0xFF)==PT_DYST && 15>(rand()%1000)) @@ -1777,6 +2237,10 @@ void update_particles_i(pixel *vid, int start, int inc) parts[r>>8].type = PT_GAS; if((r&0xFF)==PT_COAL && 5>(rand()%100)) parts[r>>8].type = PT_WOOD; + if((r&0xFF)==PT_DUST && 5>(rand()%100)) + parts[r>>8].type = PT_FWRK; + if((r&0xFF)==PT_FWRK && 5>(rand()%100)) + parts[r>>8].ctype = PT_DUST; /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| @@ -1802,10 +2266,345 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].vy *= 0.995; } } + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + parts[r>>8].type = PT_PHOT; + float a = (rand()%8) * 0.78540f; + float rr = (rand()%128+128)/127.0f; + parts[r>>8].life = 680; + parts[r>>8].ctype = 0x3FFFFFFF; + parts[r>>8].vx = rr*cosf(a); + parts[r>>8].vy = rr*sinf(a); + pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + if((r&0xFF)==PT_ISZS && 5>(rand()%2000)) + { + parts[i].vx *= 0.90; + parts[i].vy *= 0.90; + parts[r>>8].type = PT_PHOT; + float rr = (rand()%228+128)/127.0f; + float a = (rand()%8) * 0.78540f; + parts[r>>8].life = 680; + parts[r>>8].ctype = 0x3FFFFFFF; + parts[r>>8].vx = rr*cosf(a); + parts[r>>8].vy = rr*sinf(a); + pv[y/CELL][x/CELL] -= 15.0f * CFDS; + } + } } else if(t==PT_MORT) { create_part(-1, x, y-1, PT_SMKE); } + else if(t==PT_GOL||t==PT_HLIF||t==PT_ASIM||t==PT_2x2||t==PT_DANI||t==PT_AMOE||t==PT_MOVE||t==PT_PGOL||t==PT_DMOE||t==PT_34||t==PT_LLIF||t==PT_STAN) + { + if(parts[i].temp>0) + parts[i].temp -= 50.0f; + ISGOL=1; + } + else if(t==PT_LOVE) + ISLOVE=1; + else if(t==PT_LOLZ) + ISLOLZ=1; + else if(t==PT_GRAV) + ISGRAV=1; + else if(t==PT_CRAC) + { + if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r || parts[i].temp>374.0f) + continue; + if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1) + { + parts[i].life++; + parts[r>>8].type=PT_NONE; + } + } + } + else + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL|| + bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS)) + continue; + if((!r)&&parts[i].life>=1)//if nothing then create water + { + create_part(-1,x+nx,y+ny,PT_WATR); + parts[i].life--; + } + } + for(int trade = 0; trade<9;trade ++) + { + nx = rand()%5-2; + ny = rand()%5-2; + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + int temp = parts[i].life - parts[r>>8].life; + if(temp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + trade = 9; + } + else if(temp>0) + { + parts[r>>8].life += temp/2; + parts[i].life -= temp/2; + trade = 9; + } + } + } + } + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_FIRE&&parts[i].life>0) + { + if(parts[i].life<=2) + parts[i].life --; + parts[i].life -= parts[i].life/3; + } + } + if(parts[i].temp>=374) + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID)) + continue; + if((!r)&&parts[i].life>=1)//if nothing then create steam + { + create_part(-1,x+nx,y+ny,PT_WTRV); + parts[i].life--; + parts[i].temp -= 40.0f; + } + } + } + else if(t==PT_FOG) + { + if(parts[i].temp>=373.15) + t = parts[i].type = PT_WTRV; + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(pstates[parts[r>>8].type].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!(parts[r>>8].type==PT_CLNE||parts[r>>8].type==PT_PCLN)) + { + t = parts[i].type = PT_RIME; + } + if(parts[r>>8].type==PT_SPRK) + { + parts[i].life += rand()%20; + } + } + } + else if(t==PT_RIME) + { + parts[i].vx = 0; + parts[i].vy = 0; + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + if(rt==PT_SPRK) + { + t = parts[i].type = PT_FOG; + parts[i].life = rand()%50 + 60; + } + else if(rt==PT_FOG&&parts[r>>8].life>0) + { + t = parts[i].type = PT_FOG; + parts[i].life = parts[r>>8].life; + } + } + } + else if(t==PT_DEUT) + { + int maxlife = ((10000/(parts[i].temp + 1))-1); + if((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) + maxlife ++; + if(parts[i].life < maxlife) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r || (parts[i].life >=maxlife)) + continue; + if(parts[r>>8].type==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1) + { + if((parts[i].life + parts[r>>8].life + 1) <= maxlife) + { + parts[i].life += parts[r>>8].life + 1; + parts[r>>8].type=PT_NONE; + } + } + } + } + else + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || (parts[i].life<=maxlife)) + continue; + if((bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALLELEC||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_EWALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_DESTROYALL||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_WALL|| + bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWAIR||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWSOLID||bmap[(y+ny)/CELL][(x+nx)/CELL]==WL_ALLOWGAS)) + continue; + if((!r)&&parts[i].life>=1)//if nothing then create deut + { + create_part(-1,x+nx,y+ny,PT_DEUT); + parts[i].life--; + parts[pmap[y+ny][x+nx]>>8].temp = parts[i].temp; + } + } + for(int trade = 0; trade<4;trade ++) + { + nx = rand()%5-2; + ny = rand()%5-2; + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + int temp = parts[i].life - parts[r>>8].life; + if(temp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + } + else if(temp>0) + { + parts[r>>8].life += temp/2; + parts[i].life -= temp/2; + } + } + } + } + } + else if(t==PT_WARP) + { + for(int trade = 0; trade<5;trade ++) + { + nx = rand()%3-1; + ny = rand()%3-1; + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type!=PT_WARP&&parts[r>>8].type!=PT_STKM&&parts[r>>8].type!=PT_DMND&&parts[r>>8].type!=PT_CLNE&&parts[r>>8].type!=PT_BCLN&&parts[r>>8].type!=PT_PCLN&&(10>=rand()%200)) + { + t = parts[i].type = parts[r>>8].type; + parts[i].ctype = parts[r>>8].ctype; + parts[i].life = parts[r>>8].life; + parts[i].tmp = parts[r>>8].tmp; + parts[i].temp = parts[r>>8].temp; + parts[i].vx = parts[r>>8].vx; + parts[i].vy = parts[r>>8].vy; + parts[r>>8].type = PT_WARP; + parts[r>>8].life = rand()%90+1; + trade = 5; + } + } + } + } + else if(t==PT_FWRK) + { + if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) + { + create_part(-1, x , y-1 , PT_FWRK); + r = pmap[y-1][x]; + if(parts[r>>8].type==PT_FWRK) + { + parts[r>>8].vy = rand()%8-22; + parts[r>>8].vx = rand()%20-rand()%20; + parts[r>>8].life=rand()%15+25; + t=parts[i].type=PT_NONE; + } + } + if(parts[i].life>1) + { + if(parts[i].life>=45&&parts[i].type==PT_FWRK) + parts[i].life=0; + } + if((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0) + { + int q = (rand()%255+1); + int w = (rand()%255+1); + int e = (rand()%255+1); + for(nx=-1; nx<2; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx=rand()%8) + { + if(!pmap[y+ny][x+nx]) + { + create_part(-1, x+nx, y+ny , PT_DUST); + pv[y/CELL][x/CELL] += 2.00f*CFDS; + a= pmap[y+ny][x+nx]; + if(parts[a>>8].type==PT_DUST) + { + parts[a>>8].vy = -(rand()%10-1); + parts[a>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; + parts[a>>8].life= rand()%37+18; + parts[a>>8].tmp=q; + parts[a>>8].flags=w; + parts[a>>8].ctype=e; + parts[a>>8].temp= rand()%20+6000; + } + } + } + } + t=parts[i].type=PT_NONE; + } + } else if(t==PT_LCRY) { for(nx=-1; nx<2; nx++) @@ -1841,6 +2640,304 @@ void update_particles_i(pixel *vid, int start, int inc) } } } + else if(t==PT_PIPE) + { + if(!parts[i].ctype && parts[i].life<=10) + { + if(parts[i].temp<272.15) + { + if(parts[i].temp>173.25&&parts[i].temp<273.15) + { + parts[i].ctype = 2; + parts[i].life = 0; + } + if(parts[i].temp>73.25&&parts[i].temp<=173.15) + { + parts[i].ctype = 3; + parts[i].life = 0; + } + if(parts[i].temp>=0&&parts[i].temp<=73.15) + { + parts[i].ctype = 4; + parts[i].life = 0; + } + } + else + { + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART ) + continue; + if(!r) + create_part(-1,x+nx,y+ny,PT_BRCK); + } + if(parts[i].life==1) + parts[i].ctype = 1; + } + } + if(parts[i].ctype==1) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + if(!r&&!parts[i].life) + parts[i].life=50; + } + if(parts[i].life==2) + { + parts[i].ctype = 2; + parts[i].life = 6; + } + } + if(parts[i].ctype>1) + for(int o = 0;o<3;o++) + for(int ctype = 2;ctype<5;ctype++) + { + if(parts[i].ctype==ctype) + { + if(parts[i].life==3) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_PIPE&&parts[r>>8].ctype==1) + { + parts[r>>8].ctype = (((ctype)%3)+2);//reverse + parts[r>>8].life = 6; + } + } + } + else + { + nx = rand()%3-1; + ny = rand()%3-1; + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + else if(!r&&parts[i].tmp!=0) + { + create_part(-1,x+nx,y+ny,parts[i].tmp); + parts[i].tmp = 0; + continue; + } + else if(!r) + continue; + else if(parts[i].tmp == 0 && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS)) + { + parts[i].tmp = parts[r>>8].type; + parts[r>>8].type = PT_NONE; + } + else if(parts[r>>8].type==PT_PIPE && parts[r>>8].ctype!=(((ctype)%3)+2) && parts[r>>8].tmp==0&&parts[i].tmp>0) + { + parts[r>>8].tmp = parts[i].tmp; + parts[i].tmp = 0; + } + } + } + } + } + } + else if(t==PT_FRZZ) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_WATR&&5>rand()%100) + { + parts[r>>8].type=PT_FRZW; + parts[r>>8].life = 100; + t = parts[i].type = PT_NONE; + } + + } + } + else if(t==PT_FRZW) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_WATR&&5>rand()%70) + { + parts[r>>8].type=PT_FRZW; + } + } + if(parts[i].life==0&&13>rand()%2500) + { + t = parts[i].type=PT_ICEI; + parts[i].ctype=PT_FRZW; + parts[i].temp -= 200.0f; + if(parts[i].temp<0) + parts[i].temp = 0; + } + else if((100-(parts[i].life))>rand()%50000) + { + t = parts[i].type=PT_ICEI; + parts[i].ctype=PT_FRZW; + parts[i].temp -= 200.0f; + if(parts[i].temp<0) + parts[i].temp = 0; + } + } + else if(t==PT_INST) + { + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0) + { + flood_parts(x,y,PT_INST2,PT_INST,-1);//add life + parts[r>>8].type==parts[r>>8].ctype; + } + else if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0&&(parts[i].life>=4)&&parts[i].life%4<=1) + { + create_part(-1,x+nx,y+ny,PT_SPRK); + flood_parts(x,y,PT_INST3,PT_INST,-1);//sub life + } + else if(parts[r>>8].type==PT_SWCH&&parts[r>>8].life==10&&(parts[i].life>=4)&&parts[i].life%4<=1) + { + parts[r>>8].type=PT_SPRK; + parts[r>>8].ctype=PT_SWCH; + parts[r>>8].life=4; + flood_parts(x,y,PT_INST3,PT_INST,-1);//sub life + } + } + } + else if(t==PT_INST2) + { + if(parts[i].life%4<=1) + t = parts[pmap[y][x]>>8].type=PT_INST; + } + else if(t==PT_INST3) + { + if(parts[i].life%4<=1) + t = parts[pmap[y][x]>>8].type=PT_INST; + } + else if(t==PT_PRTI) + { + int count =0; + for(ny=-1; ny<2; ny++) + for(nx=-1; nx<2; nx++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))) + for(int nnx=0;nnx<8;nnx++) + if(!portal[count-1][nnx]) + { + portal[count-1][nnx] = parts[r>>8].type; + if(parts[r>>8].type==PT_SPRK) + parts[r>>8].type = parts[r>>8].ctype; + else + parts[r>>8].type = PT_NONE; + break; + } + } + } + else if(t==PT_PRTO) + { + int count = 0; + for(ny=1; ny>-2; ny--) + for(nx=1; nx>-2; nx--) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || r) + continue; + if(!r) + { + for(int nnx =0 ;nnx<8;nnx++) + { + int randomness = count + rand()%3-1; + if(randomness<1) + randomness=1; + if(randomness>8) + randomness=8; + if(portal[randomness-1][nnx]==PT_SPRK)//todo. make it look better + { + create_part(-1,x+1,y,portal[randomness-1][nnx]); + create_part(-1,x+1,y+1,portal[randomness-1][nnx]); + create_part(-1,x+1,y-1,portal[randomness-1][nnx]); + create_part(-1,x,y-1,portal[randomness-1][nnx]); + create_part(-1,x,y+1,portal[randomness-1][nnx]); + create_part(-1,x-1,y+1,portal[randomness-1][nnx]); + create_part(-1,x-1,y,portal[randomness-1][nnx]); + create_part(-1,x-1,y-1,portal[randomness-1][nnx]); + portal[randomness-1][nnx] = 0; + break; + } + else if(portal[randomness-1][nnx]) + { + create_part(-1,x+nx,y+ny,portal[randomness-1][nnx]); + portal[randomness-1][nnx] = 0; + break; + } + } + } + } + } + else if(t==PT_WIFI) + { + CGOL = 1; + int temprange = 100; + for(int temp = 0; temp < 2500; temp += temprange) + if(parts[i].temp-273.15>temp&&parts[i].temp-273.15=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_NSCN&&parts[r>>8].life==0 && wireless[parts[i].tmp]) + { + parts[r>>8].type = PT_SPRK; + parts[r>>8].ctype = PT_NSCN; + parts[r>>8].life = 4; + } + else if(parts[r>>8].type==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3 && !wireless[parts[i].tmp]) + { + parts[r>>8].type = parts[r>>8].ctype; + wireless[parts[i].tmp] = 1; + ISWIRE = 1; + } + } + } else if(t==PT_PCLN) { for(nx=-2; nx<3; nx++) @@ -1911,6 +3008,192 @@ void update_particles_i(pixel *vid, int start, int inc) } } } + else if(t==PT_PUMP) + { + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + rt = parts[r>>8].type; + if(rt==PT_SPRK) + { + if(parts[r>>8].ctype==PT_PSCN) + { + parts[i].life = 10; + } + else if(parts[r>>8].ctype==PT_NSCN) + { + parts[i].life = 9; + } + } + if(rt==PT_PUMP) + { + if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) + { + parts[i].life = 9; + } + else if(parts[i].life==0&&parts[r>>8].life==10) + { + parts[i].life = 10; + } + } + } + } + else if(t==PT_SHLD1) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART || !r) + continue; + else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) + for(int nnx=-1;nnx<2;nnx++) + for(int nny=-1;nny<2;nny++) + { + if(7>rand()%200&&parts[i].life==0) + { + t = parts[i].type = PT_SHLD2; + parts[i].life = 7; + } + else if(!pmap[y+ny+nny][x+nx+nnx]) + { + create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); + //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + else if(parts[r>>8].type==PT_SHLD3&&4>rand()%10) + { + t = parts[i].type=PT_SHLD2; + parts[i].life = 7; + } + } + } + else if(t==PT_SHLD2) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART) + continue; + if(!r && parts[i].life>0) + create_part(-1,x+nx,y+ny,PT_SHLD1); + if(!r) + continue; + else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) + for(int nnx=-1;nnx<2;nnx++) + for(int nny=-1;nny<2;nny++) + { + if(3>rand()%200&&parts[i].life==0) + { + t = parts[i].type = PT_SHLD3; + parts[i].life = 7; + } + else if(!pmap[y+ny+nny][x+nx+nnx]) + { + create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); + parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + else if(parts[r>>8].type==PT_SHLD4&&4>rand()%10) + { + t = parts[i].type=PT_SHLD3; + parts[i].life = 7; + } + } + } + else if(t==PT_SHLD3) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART) + continue; + if(!r) + { + if(1>rand()%2500) + { + create_part(-1,x+nx,y+ny,PT_SHLD1); + parts[pmap[y+ny][x+nx]>>8].life=7; + t = parts[i].type = PT_SHLD2; + } + else + continue; + + } + if(parts[r>>8].type==PT_SHLD1 && parts[i].life>3) + { + parts[r>>8].type = PT_SHLD2; + parts[r>>8].life=7; + } + else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) + for(int nnx=-1;nnx<2;nnx++) + for(int nny=-1;nny<2;nny++) + { + if(2>rand()%3000&&parts[i].life==0) + { + t = parts[i].type = PT_SHLD4; + parts[i].life = 7; + } + else if(!pmap[y+ny+nny][x+nx+nnx]) + { + create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); + parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + } + } + else if(t==PT_SHLD4) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx>8)>=NPART) + continue; + if(!r) + { + if(1>rand()%5500) + { + create_part(-1,x+nx,y+ny,PT_SHLD1); + parts[pmap[y+ny][x+nx]>>8].life=7; + t = parts[i].type = PT_SHLD2; + } + else + continue; + + } + if(parts[r>>8].type==PT_SHLD2 && parts[i].life>3) + { + parts[r>>8].type = PT_SHLD3; + parts[r>>8].life = 7; + } + else if(parts[r>>8].type==PT_SPRK&&parts[i].life==0) + for(int nnx=-1;nnx<2;nnx++) + for(int nny=-1;nny<2;nny++) + { + if(!pmap[y+ny+nny][x+nx+nnx]) + { + create_part(-1,x+nx+nnx,y+ny+nny,PT_SHLD1); + parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + } + } else if(t==PT_AMTR) { for(nx=-1; nx<2; nx++) @@ -1965,7 +3248,7 @@ void update_particles_i(pixel *vid, int start, int inc) } else { float newVel = parts[i].life/25; parts[i].flags = parts[i].flags&0xFFFFFFFE; - if((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE) { + if((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) { parts[i].vy = -newVel; ly-=newVel; iy-=newVel; @@ -2015,7 +3298,7 @@ void update_particles_i(pixel *vid, int start, int inc) if((r>>8)>=NPART || !r) continue; rt = parts[r>>8].type; - if(parts_avg(i,r>>8) != PT_INSL) + if(parts_avg(i,r>>8,PT_INSL) != PT_INSL) { if((rt==PT_METL||rt==PT_IRON||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) { @@ -2037,7 +3320,7 @@ void update_particles_i(pixel *vid, int start, int inc) if((r>>8)>=NPART || !r) continue; rt = parts[r>>8].type; - if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8)!=PT_INSL) + if(parts[r>>8].type == PT_SWCH&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { if(parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) { @@ -2051,7 +3334,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } if(t==PT_SWCH) - if((parts[i].life>0&&parts[i].life<10)|| parts[i].life == 11) + if((parts[i].life>0&&parts[i].life<10)|| parts[i].life > 10) { parts[i].life--; } @@ -2065,12 +3348,12 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=5) + if(bmap[(y+ny)/CELL][(x+nx)/CELL] && bmap[(y+ny)/CELL][(x+nx)/CELL]!=WL_STREAM) continue; rt = parts[r>>8].type; if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) && !(t==PT_PHOT && rt==PT_INSL) && - (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_CRAC && parts[r>>8].life>0) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000)) { parts[r>>8].type = PT_FIRE; @@ -2143,36 +3426,36 @@ void update_particles_i(pixel *vid, int start, int inc) //If so turn the SPRK that covers the SWCH back into SWCH and turn it off if(rt==PT_SPRK && parts[r>>8].ctype == PT_SWCH && t==PT_SPRK) { - pavg = parts_avg(r>>8, i); + pavg = parts_avg(r>>8, i,PT_INSL); if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL) { parts[r>>8].type = PT_SWCH; parts[r>>8].ctype = PT_NONE; - parts[r>>8].life = 0; + parts[r>>8].life = 9; } } - pavg = parts_avg(i, r>>8); + pavg = parts_avg(i, r>>8,PT_INSL); if(rt==PT_SWCH && t==PT_SPRK) { - pavg = parts_avg(r>>8, i); - if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL) + pavg = parts_avg(r>>8, i,PT_INSL); + if(parts[i].ctype == PT_PSCN&&pavg != PT_INSL && parts[r>>8].life<10) parts[r>>8].life = 10; if(parts[i].ctype == PT_NSCN&&pavg != PT_INSL) parts[r>>8].life = 9; - if(!(parts[i].ctype == PT_PSCN||parts[i].ctype == PT_NSCN)&&parts[r>>8].life >= 10&&pavg != PT_INSL) //Life can be 11 too, so don't just check for 10 + 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); + pavg = parts_avg(i, r>>8,PT_INSL); if(pavg != PT_INSL) { if(t==PT_SPRK && (rt==PT_METL||rt==PT_IRON||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)=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN)) ) + if(!(rt==PT_PSCN&&parts[i].ctype==PT_NSCN)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp>=373.0f)&&parts[i].ctype==PT_NTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN&&parts[i].temp<=373.0f)&&parts[i].ctype==PT_PTCT)&&!(rt!=PT_PSCN&&!(rt==PT_NSCN)&&parts[i].ctype==PT_INWR) && pavg != PT_INSL &&!(parts[i].ctype==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN))&&!(parts[i].ctype==PT_INST&&rt!=PT_NSCN) ) { parts[r>>8].type = PT_SPRK; parts[r>>8].life = 4; @@ -2246,10 +3529,10 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].temp = 3500; pv[y/CELL][x/CELL] += 1; } - if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=1) + if(t==PT_SPRK&&parts[i].ctype==PT_SWCH&&parts[i].life<=0) { parts[i].type = PT_SWCH; - parts[i].life = 11; + parts[i].life = 14; } } } @@ -2414,9 +3697,9 @@ killed: } //Charge detector wall if foot inside - if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==6) + if(bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT) set_emap((int)player[7]/CELL, (int)player[8]/CELL); - if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==6) + if(bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT) set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL); //Searching for particles near head @@ -2443,7 +3726,7 @@ killed: parts[i].life -= (102-parts[i].life)/2; kill_part(pmap[ny+y][nx+x]>>8); } - if(bmap[(ny+y)/CELL][(nx+x)/CELL]==4) + if(bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN) player[2] = SPC_AIR; } @@ -2465,7 +3748,7 @@ killed: else { if(player[2] == SPC_AIR) - create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, SPC_AIR); + create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR); else create_part(-1, nx, ny, player[2]); @@ -2666,6 +3949,27 @@ killed: create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); } + } + if(t==PT_BCLN) + { + if(!parts[i].ctype) + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && + x+nx0) @@ -2861,14 +4165,14 @@ killed: else r = -1; if(s) - for(j=y+r; j>=0 && j=y-rt && j=0 && j=y-rt && j>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i>1)&1; i=122&&c<=122+UI_WALLCOUNT) + if(cm==PT_INST&&(co==PT_INST2||co==PT_INST3)) + if((pmap[y][x]&0xFF)==PT_INST2 || (pmap[y][x]&0xFF)==PT_INST3) + return 0; + if(c>=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT) { c = c-100; } if(cm==-1) { - if(c==0) + if(c==0) { cm = pmap[y][x]&0xFF; if(!cm) return 0; + if(REPLACE_MODE && cm!=SLALT) + return 0; } else cm = 0; } if(bm==-1) { - if(c==30) + if(c==WL_ERASE) { bm = bmap[y/CELL][x/CELL]; if(!bm) return 0; - if(bm==1) + if(bm==WL_WALL) cm = 0xFF; } else bm = 0; } - if((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm) + if(((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )||( (sdl_mod & (KMOD_CAPS)) && cm!=SLALT)) return 1; // go left as far as possible @@ -3588,22 +4899,67 @@ int flood_parts(int x, int y, int c, int cm, int bm) while(x1>=CELL) { if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) - break; + { + if(cm!=PT_INST) + break; + else if((pmap[y][x1-1]&0xFF)!=PT_INST2&&(pmap[y][x1-1]&0xFF)!=PT_INST3) + break; + } x1--; } while(x2=CELL+dy && x1==x2 && + ((pmap[y-1][x1-1]&0xFF)==PT_INST||((pmap[y-1][x1-1]&0xFF)==PT_INST3||(pmap[y-1][x1-1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1]&0xFF)==PT_INST||((pmap[y-1][x1]&0xFF)==PT_INST3||(pmap[y-1][x1]&0xFF)==PT_INST2)) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || ((pmap[y-1][x1+1]&0xFF)==PT_INST3||(pmap[y-1][x1+1]&0xFF)==PT_INST2)) && + (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||((pmap[y-2][x1]&0xFF)==PT_INST3||(pmap[y-2][x1]&0xFF)==PT_INST2)) && (pmap[y-2][x1+1]&0xFF)!=PT_INST) + flood_parts(x1, y-2, co, cm, bm); + else if(y>=CELL+dy) + for(x=x1; x<=x2; x++) + if((pmap[y-1][x]&0xFF)!=co) + { + if(x==x1 || x==x2 || y>=YRES-CELL-1 || + (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST || + (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=co) || (pmap[y+1][x+1]&0xFF)==PT_INST) + flood_parts(x, y-dy, co, cm, bm); + + } + + if(y=CELL+dy) for(x=x1; x<=x2; x++) if((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm) @@ -3614,149 +4970,137 @@ int flood_parts(int x, int y, int c, int cm, int bm) 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; - return 1; + } + if(!(cm==PT_INST&&(co==PT_INST2||co==PT_INST3))) + return 1; } -int create_parts(int x, int y, int r, int c) +int create_parts(int x, int y, int rx, int ry, int c) { - int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0; //n; - - if(c == 125) + int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n; + + int wall = c - 100; + for(int r=UI_ACTUALSTART;r<=UI_ACTUALSTART+UI_WALLCOUNT;r++) { - 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&&ox=0&&oy=0 && i+u=0 && j+vabs(x2-x1), x, y, dx, dy, sy; float e, de; @@ -3790,19 +5134,19 @@ void create_line(int x1, int y1, int x2, int y2, int r, int c) for(x=x1; x<=x2; x++) { if(cp) - create_parts(y, x, r, c); + create_parts(y, x, rx, ry, c); else - create_parts(x, y, r, c); + create_parts(x, y, rx, ry, 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(c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC || !(rx+ry)) { if(cp) - create_parts(y, x, r, c); + create_parts(y, x, rx, ry, c); else - create_parts(x, y, r, c); + create_parts(x, y, rx, ry, c); } e -= 1.0f; }