diff --git a/src/simulation/elements/BACT.cpp b/src/simulation/elements/BACT.cpp index 5390bac71f..203eac3ea0 100644 --- a/src/simulation/elements/BACT.cpp +++ b/src/simulation/elements/BACT.cpp @@ -50,10 +50,10 @@ void Element::Element_BACT() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + short r, rx, ry; - rx = RNG::Ref().between(-2, 2); - ry = RNG::Ref().between(-2, 2); + rx = RNG::Ref().between(-2, 2); + ry = RNG::Ref().between(-2, 2); // O2 use itself (made very slow for somewhat accuracy) if (RNG::Ref().chance(1, 1000)){ @@ -71,8 +71,8 @@ static int update(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; - int t = TYP(r); - int ir = ID(r); + short t = TYP(r); + short ir = ID(r); if (r){ // Steal O2 and offload CO2 @@ -131,8 +131,8 @@ static int update(UPDATE_FUNC_ARGS) && BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - int t = TYP(r); - int ir = ID(r); + short t = TYP(r); + short ir = ID(r); // Empty if (t == 0){ @@ -157,14 +157,14 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int o = cpart->bio.o2; + short o = cpart->bio.o2; // C02 - int c = cpart->bio.co2; + short c = cpart->bio.co2; - int q = cpart->bio.o2; + //short q = cpart->bio.o2; - int d = o - c; + short d = o - c; *colr = (int)fmin(d, 20) * 2; diff --git a/src/simulation/elements/BLD.cpp b/src/simulation/elements/BLD.cpp index 6da9634310..a29bebabb1 100644 --- a/src/simulation/elements/BLD.cpp +++ b/src/simulation/elements/BLD.cpp @@ -50,7 +50,7 @@ void Element::Element_BLD() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + short r, rx, ry; rx = RNG::Ref().between(-2, 2); ry = RNG::Ref().between(-2, 2); @@ -69,8 +69,8 @@ static int update(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; - int t = TYP(r); - int ir = ID(r); + short t = TYP(r); + short ir = ID(r); if (r){ // Oxygen collection @@ -141,7 +141,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 100)){ // convert biology to tumor (grow) if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_TUMOR){ - int ir = ID(r); + short ir = ID(r); sim->part_change_type(ir, parts[ir].x, parts[ir].y, PT_TUMOR); } } @@ -152,13 +152,13 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { + // o and c can be delcared as short as both bio.o2 and bio.co2 do not go over 32768 // Oxygen - int o = cpart->bio.o2; + short o = cpart->bio.o2; // C02 - int c = cpart->bio.co2; + short c = cpart->bio.co2; - int q = cpart->bio.o2; *colr = (int)fmax(9 * o, 75); *colg = 0; *colb = 8 * c; diff --git a/src/simulation/elements/BVES.cpp b/src/simulation/elements/BVES.cpp index 1e01a1a475..e82cdb5e14 100644 --- a/src/simulation/elements/BVES.cpp +++ b/src/simulation/elements/BVES.cpp @@ -394,7 +394,7 @@ int Element_BVES_update(UPDATE_FUNC_ARGS) if (!r) { // BRCK border - int index = sim->create_part(-1,x+rx,y+ry,PT_MEAT); + //int index = sim->create_part(-1,x+rx,y+ry,PT_MEAT); } } } @@ -575,7 +575,8 @@ static void transfer_bves_to_bves(Particle *src, Particle *dest, bool STOR) static void pushParticle(Simulation * sim, int i, int count, int original) { - int rndstore, rnd, rx, ry, r, x, y, np, q; + int rndstore, rnd, x, y, np, q; + short rx, ry, r; unsigned int notctype = nextColor(sim->parts[i].tmp); if (!TYP(sim->parts[i].ctype) || count >= 2)//don't push if there is nothing there, max speed of 2 per frame return; diff --git a/src/simulation/elements/GGOO.cpp b/src/simulation/elements/GGOO.cpp index 6766084755..b2f2dccfa7 100644 --- a/src/simulation/elements/GGOO.cpp +++ b/src/simulation/elements/GGOO.cpp @@ -48,7 +48,7 @@ void Element::Element_GGOO() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + short r, rx, ry; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (BOUNDS_CHECK && (rx || ry)) diff --git a/src/simulation/elements/LUNG.cpp b/src/simulation/elements/LUNG.cpp index dc42798848..43d88f8864 100644 --- a/src/simulation/elements/LUNG.cpp +++ b/src/simulation/elements/LUNG.cpp @@ -51,7 +51,7 @@ void Element::Element_LUNG() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + short r, rx, ry; rx = RNG::Ref().between(-2, 2); ry = RNG::Ref().between(-2, 2); @@ -69,7 +69,7 @@ static int update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - int ir = ID(r); + short ir = ID(r); if (r) { // Oxygen collection (more efficient than BLD) @@ -146,14 +146,14 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int o = cpart->bio.o2; + unsigned char o = cpart->bio.o2; // C02 - int c = cpart->bio.co2; + //unsigned char c = cpart->bio.co2; - *colr = (int)fmax(7 * o, 100); + *colr = (short)fmax(7 * o, 100); *colg = 0; - *colb = (int)fmax(7 * o, 60); + *colb = (short)fmax(7 * o, 60); *pixel_mode |= PMODE_BLUR; *colr = int(*colr * (cpart->bio.health) / 100.0f); diff --git a/src/simulation/elements/MEAT.cpp b/src/simulation/elements/MEAT.cpp index 918afb039a..9bc29dfb4c 100644 --- a/src/simulation/elements/MEAT.cpp +++ b/src/simulation/elements/MEAT.cpp @@ -53,8 +53,9 @@ void Element::Element_MEAT() static int update(UPDATE_FUNC_ARGS) { int r, rx, ry; - int rad = parts[i].tmp; - int max_health = parts[i].tmp2; + + //int rad = parts[i].tmp; + //int max_health = parts[i].tmp2; rx = RNG::Ref().between(-2, 2); ry = RNG::Ref().between(-2, 2); @@ -77,7 +78,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 2)){ // Diffuse among bio if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_BLD){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; @@ -132,14 +133,15 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int o = cpart->bio.o2; + unsigned char o = cpart->bio.o2; // C02 - int c = cpart->bio.co2; + //wasn't used, just commented it out just incase + //unsigned char c = cpart->bio.co2; - *colr = (int)fmax(7 * o, 100); + *colr = (short)fmax(7 * o, 100); *colg = 0; - *colb = (int)fmax(3 * o, 30); + *colb = (short)fmax(3 * o, 30); *pixel_mode |= PMODE_BLUR; // Life mix diff --git a/src/simulation/elements/NEUR.cpp b/src/simulation/elements/NEUR.cpp index c94bb0a662..364477eea4 100644 --- a/src/simulation/elements/NEUR.cpp +++ b/src/simulation/elements/NEUR.cpp @@ -52,7 +52,7 @@ void Element::Element_NEUR() static int update(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry; + int r,/* nnx, nny,*/ rx, ry; // O2 use by neuron itself if (RNG::Ref().chance(1, 100)){ @@ -74,7 +74,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 2)){ // Diffuse among bio if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_BLD){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; diff --git a/src/simulation/elements/PSN.cpp b/src/simulation/elements/PSN.cpp index a7e914d113..a4daa93f0e 100644 --- a/src/simulation/elements/PSN.cpp +++ b/src/simulation/elements/PSN.cpp @@ -56,7 +56,7 @@ static int update(UPDATE_FUNC_ARGS) rx = RNG::Ref().between(-2, 2); ry = RNG::Ref().between(-2, 2); r = pmap[y+ry][x+rx]; - int ir = ID(r); + short ir = ID(r); if (sim->elements[TYP(r)].Properties & TYPE_BIO){ parts[ir].bio.health -= parts[i].tmp; parts[i].life--; @@ -72,12 +72,12 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int o = cpart->tmp; + unsigned char o = cpart->tmp; // C02 - int c = cpart->bio.co2; + //unsigned char c = cpart->bio.co2; - int q = cpart->bio.o2; + //unsigned char q = cpart->bio.o2; *colr = 0; *colg = (int)fmax(9 * o, 75);; *colb = 0; diff --git a/src/simulation/elements/SKIND.cpp b/src/simulation/elements/SKIND.cpp index e3b93146cb..3e8c60e1a2 100644 --- a/src/simulation/elements/SKIND.cpp +++ b/src/simulation/elements/SKIND.cpp @@ -51,7 +51,7 @@ void Element::Element_SKIND() static int update(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry; + short r,/* nnx, nny,*/ rx, ry; // O2 use by skin itself if (RNG::Ref().chance(1, 150)){ @@ -73,7 +73,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 2)){ // Diffuse among bio if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_BLD){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; diff --git a/src/simulation/elements/SKINE.cpp b/src/simulation/elements/SKINE.cpp index d55d87c0a9..30d585eaa5 100644 --- a/src/simulation/elements/SKINE.cpp +++ b/src/simulation/elements/SKINE.cpp @@ -51,7 +51,8 @@ void Element::Element_SKINE() static int update(UPDATE_FUNC_ARGS) { -int r, nnx, nny, rx, ry; + //r, rx, and ry can be short as all values are under 32768, may change to signed char later + short r,/* nnx, nny,*/ rx, ry; // O2 use by skin itself if (RNG::Ref().chance(1, 150)){ @@ -73,7 +74,7 @@ int r, nnx, nny, rx, ry; if (RNG::Ref().chance(1, 2)){ // Diffuse among bio if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_BLD){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; diff --git a/src/simulation/elements/SKINS.cpp b/src/simulation/elements/SKINS.cpp index 2794139e93..3ed7519fa9 100644 --- a/src/simulation/elements/SKINS.cpp +++ b/src/simulation/elements/SKINS.cpp @@ -49,14 +49,11 @@ void Element::Element_SKINS() Graphics = &graphics; } -static int update(UPDATE_FUNC_ARGS) -{ - - int r, nnx, nny, rx, ry; +static int update(UPDATE_FUNC_ARGS){ + short r,/* nnx, nny,*/ rx, ry; // O2 use by skin itself if (RNG::Ref().chance(1, 150)){ - if (parts[i].bio.o2 > 0){ parts[i].bio.o2 -= 1; parts[i].bio.co2 += 1; @@ -67,14 +64,13 @@ static int update(UPDATE_FUNC_ARGS) ry = RNG::Ref().between(-2, 2); // Resource diffuse - if (BOUNDS_CHECK && (rx || ry)) - { + if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; if (r) { if (RNG::Ref().chance(1, 2)){ // Diffuse among bio if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_BLD){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; @@ -93,8 +89,7 @@ static int update(UPDATE_FUNC_ARGS) if (parts[i].bio.o2 > 10){ // Growth check - if (BOUNDS_CHECK && (rx || ry)) - { + if (BOUNDS_CHECK && (rx || ry)){ bool f_meat = 0; for (rx=-2; rx<3; rx++){ @@ -103,7 +98,7 @@ static int update(UPDATE_FUNC_ARGS) for (ry=-2; ry<3; ry++){ - if (f_meat) break; + if (f_meat) {break;}; r = pmap[y+ry][x+rx]; if (r){ diff --git a/src/simulation/elements/THOR.cpp b/src/simulation/elements/THOR.cpp index f75bf92c44..ce3d497481 100644 --- a/src/simulation/elements/THOR.cpp +++ b/src/simulation/elements/THOR.cpp @@ -49,8 +49,8 @@ void Element::Element_THOR() static int update(UPDATE_FUNC_ARGS) { - - int r, rx, ry, rt; + //why was rt even here if unused?, has been commented out + short r, rx, ry/*, rt*/; for (rx = -1; rx < 2; rx++) { for (ry = -1; ry < 2; ry++) { if (BOUNDS_CHECK) { diff --git a/src/simulation/elements/TUMOR.cpp b/src/simulation/elements/TUMOR.cpp index 1e57783554..0128f059cb 100644 --- a/src/simulation/elements/TUMOR.cpp +++ b/src/simulation/elements/TUMOR.cpp @@ -51,7 +51,7 @@ void Element::Element_TUMOR() static int update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + short r, rx, ry; rx = RNG::Ref().between(-2, 2); ry = RNG::Ref().between(-2, 2); @@ -73,7 +73,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 2)){ // Diffuse among tumor if (TYP(r) == PT_TUMOR){ - int ir = ID(r); + short ir = ID(r); if (parts[i].bio.o2 > parts[ir].bio.o2){ parts[i].bio.o2--; @@ -86,7 +86,7 @@ static int update(UPDATE_FUNC_ARGS) } // steal o2 from bio, offload co2 to bio (tumor is greedy) if (sim->elements[TYP(r)].Properties & TYPE_BIO){ - int ir = ID(r); + short ir = ID(r); if (parts[ir].bio.o2 > 1){ parts[i].bio.o2++; @@ -98,7 +98,7 @@ static int update(UPDATE_FUNC_ARGS) } } if (TYP(r) == PT_BLD && RNG::Ref().chance(1, 1000)){ - int ir = ID(r); + short ir = ID(r); parts[ir].ctype = PT_TUMOR; } } @@ -107,7 +107,7 @@ static int update(UPDATE_FUNC_ARGS) if (RNG::Ref().chance(1, 100)){ // convert biology to tumor (grow) if (sim->elements[TYP(r)].Properties & TYPE_BIO && TYP(r) != PT_TUMOR){ - int ir = ID(r); + short ir = ID(r); sim->part_change_type(ir, parts[ir].x, parts[ir].y, PT_TUMOR); parts[i].bio.o2--; parts[i].bio.co2++; @@ -145,10 +145,10 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int o = cpart->bio.o2; + short o = cpart->bio.o2; // C02 - int c = cpart->bio.co2; + //short c = cpart->bio.co2; *colr = (int)fmax(3 * o, 77); *colg = (int)fmax(3 * o, 62); diff --git a/src/simulation/elements/WACK.cpp b/src/simulation/elements/WACK.cpp index 27081003cf..afb4982eaf 100644 --- a/src/simulation/elements/WACK.cpp +++ b/src/simulation/elements/WACK.cpp @@ -49,7 +49,7 @@ static int update(UPDATE_FUNC_ARGS) { if (RNG::Ref().chance(1, 30)) { - int rtype = 0; + short rtype = 0; do { rtype = RNG::Ref().between(0, 206); @@ -58,7 +58,7 @@ static int update(UPDATE_FUNC_ARGS) while (rtype == PT_GGOO || rtype == PT_RGOO || rtype == PT_VIRS || rtype == PT_LIFE || rtype == PT_VRSS || rtype == PT_VRSG); - int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), rtype); + //int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), rtype); } return 0; diff --git a/src/simulation/elements/WACKY.cpp b/src/simulation/elements/WACKY.cpp index 1a44e9dea4..86225fb5a6 100644 --- a/src/simulation/elements/WACKY.cpp +++ b/src/simulation/elements/WACKY.cpp @@ -49,7 +49,7 @@ static int update(UPDATE_FUNC_ARGS) { if (RNG::Ref().chance(1, 30)) { - int rtype = 0; + short rtype = 0; do { rtype = RNG::Ref().between(0, 206); @@ -57,7 +57,7 @@ static int update(UPDATE_FUNC_ARGS) } while (!(sim->elements[rtype].MenuSection == SC_NUCLEAR)); - int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), rtype); + //int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), rtype); } return 0; diff --git a/src/simulation/elements/WBLD.cpp b/src/simulation/elements/WBLD.cpp index ea2a75fb57..f5e2d390f3 100644 --- a/src/simulation/elements/WBLD.cpp +++ b/src/simulation/elements/WBLD.cpp @@ -69,8 +69,8 @@ static int update(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; - int t = TYP(r); - int ir = ID(r); + short t = TYP(r); + short ir = ID(r); if (r){ // Take resources from blood @@ -151,7 +151,7 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { // Oxygen - int l = cpart->bio.health; + short l = cpart->bio.health; *colr = (l / 200) * 255; *colg = (l / 200) * 255;