From f709af8a613c368162b4addb038b03af55b5b1e6 Mon Sep 17 00:00:00 2001 From: KA101 Date: Sun, 2 Nov 2014 21:51:23 -0500 Subject: [PATCH 01/10] Vehicles block acid fields --- src/field.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/field.cpp b/src/field.cpp index f59dba8cb2c5c..589bf51e6f77e 100644 --- a/src/field.cpp +++ b/src/field.cpp @@ -1441,19 +1441,22 @@ void map::step_in_field(int x, int y) case fd_acid: //Acid deals damage at all levels now; the inside refers to inside a vehicle. //TODO: Add resistance to this with rubber shoes or something? - if (cur->getFieldDensity() == 3 && !inside) { + if (veh) { + break; + } + if (cur->getFieldDensity() == 3) { add_msg(m_bad, _("The acid burns your legs and feet!")); g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 4, 10 ) ) ); g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 4, 10 ) ) ); g->u.deal_damage( nullptr, bp_leg_l, damage_instance( DT_ACID, rng( 2, 8 ) ) ); g->u.deal_damage( nullptr, bp_leg_r, damage_instance( DT_ACID, rng( 2, 8 ) ) ); - } else if (cur->getFieldDensity() == 2 && !inside) { + } else if (cur->getFieldDensity() == 2) { add_msg(m_bad, _("The acid burns your legs and feet!")); g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 2, 5 ) ) ); g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 2, 5 ) ) ); g->u.deal_damage( nullptr, bp_leg_l, damage_instance( DT_ACID, rng( 1, 4 ) ) ); g->u.deal_damage( nullptr, bp_leg_r, damage_instance( DT_ACID, rng( 1, 4 ) ) ); - } else if (!inside) { + } else { add_msg(m_bad, _("The acid burns your legs and feet!")); g->u.deal_damage( nullptr, bp_foot_l, damage_instance( DT_ACID, rng( 1, 3 ) ) ); g->u.deal_damage( nullptr, bp_foot_r, damage_instance( DT_ACID, rng( 1, 3 ) ) ); From 071a61184c28150d22fe9622126d0aab0299d80e Mon Sep 17 00:00:00 2001 From: KA101 Date: Sun, 2 Nov 2014 22:43:52 -0500 Subject: [PATCH 02/10] Removes muzzle gunmod location on revolvers --- data/json/items/ranged.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/data/json/items/ranged.json b/data/json/items/ranged.json index 2fb0028a6bab1..085b40705d829 100644 --- a/data/json/items/ranged.json +++ b/data/json/items/ranged.json @@ -619,7 +619,7 @@ "burst": 0, "clip_size": 7, "reload": 75, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "sw_619", @@ -647,7 +647,7 @@ "burst": 0, "clip_size": 7, "reload": 75, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "taurus_38", @@ -729,7 +729,7 @@ "burst": 0, "clip_size": 6, "reload": 60, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "sw_500", @@ -757,7 +757,7 @@ "burst": 0, "clip_size": 5, "reload": 80, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "raging_bull", @@ -785,7 +785,7 @@ "burst": 0, "clip_size": 5, "reload": 80, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "ruger_redhawk", @@ -813,7 +813,7 @@ "burst": 0, "clip_size": 6, "reload": 80, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "deagle_44", @@ -978,7 +978,7 @@ "burst": 0, "clip_size": 6, "reload": 75, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "l_bak_223", @@ -1006,7 +1006,7 @@ "burst": 0, "clip_size": 5, "reload": 75, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "muzzle", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "grip", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "fn57", @@ -3192,7 +3192,7 @@ "burst": 0, "clip_size": 5, "reload": 90, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "rm103a_pistol", @@ -3825,7 +3825,7 @@ "burst": 0, "clip_size": 4, "reload": 100, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "cop_38", @@ -3853,7 +3853,7 @@ "burst": 0, "clip_size": 4, "reload": 100, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "arx160", @@ -4209,7 +4209,7 @@ "burst" : 0, "clip_size": 6, "reload" : 130, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "colt_army", @@ -4237,7 +4237,7 @@ "burst" : 0, "clip_size": 5, "reload" : 150, - "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "muzzle", 1 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] + "valid_mod_locations": [[ "accessories", 2 ],[ "barrel", 1 ],[ "bore", 1 ],[ "conversion", 1 ],[ "grip", 1 ],[ "magazine", 2 ],[ "mechanism", 4 ],[ "rail", 1 ],[ "sights", 1 ],[ "stock", 1 ],[ "underbarrel", 1 ]] }, { "id": "rifle_flintlock", From 3acdb9f420b30f247e6f70e6e0bbe8757dd9c553 Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:32:19 -0800 Subject: [PATCH 03/10] Create constants for bounds of scentmap in for loops. --- src/game.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index d1ecbac97d57d..16e09dcc14b96 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3788,6 +3788,12 @@ void game::update_scent() bool has_wall_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of bool reduce_scent_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant) + // for loop constants + const int scentmap_minx = u.posx - SCENT_RADIUS; + const int scentmap_maxx = u.posx + SCENT_RADIUS; + const int scentmap_miny = u.posy - SCENT_RADIUS; + const int scentmap_maxy = u.posy + SCENT_RADIUS; + const int diffusivity = 100; // decrease this to reduce gas spread. Keep it under 125 for // stability. This is essentially a decimal number * 1000. @@ -3801,10 +3807,10 @@ void game::update_scent() // note: this method needs an array that is one square larger on each side in the x direction // than the final scent matrix. I think this is fine since SCENT_RADIUS is less than // SEEX*MAPSIZE, but if that changes, this may need tweaking. - for (int x = u.posx - SCENT_RADIUS - 1; x <= u.posx + SCENT_RADIUS + 1; x++) { - for (int y = u.posy - SCENT_RADIUS; y <= u.posy + SCENT_RADIUS; y++) { + for (int x = scentmap_minx - 1; x <= scentmap_maxx + 1; x++) { + for (int y = scentmap_miny; y <= scentmap_maxy; y++) { // cache expensive flag checks, once per tile. - if (y == u.posy - SCENT_RADIUS) { // Setting y-1 y-0, when we are at the top row... + if (y == scentmap_miny) { // Setting y-1 y-0, when we are at the top row... for (int i = y - 1; i <= y; ++i) { has_wall_here[x][i] = m.has_flag(TFLAG_WALL, x, i); reduce_scent_here[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i); @@ -3830,8 +3836,8 @@ void game::update_scent() } } } - for (int x = u.posx - SCENT_RADIUS; x <= u.posx + SCENT_RADIUS; x++) { - for (int y = u.posy - SCENT_RADIUS; y <= u.posy + SCENT_RADIUS; y++) { + for (int x = scentmap_minx; x <= scentmap_maxx; x++) { + for (int y = scentmap_miny; y <= scentmap_maxy; y++) { if (has_wall_here[x][y] == false) { // to how many neighboring squares do we diffuse out? (include our own square // since we also include our own square when diffusing in) From dca0591e2ec59dce092859ae30a0a3ec7c1d5f1d Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:34:51 -0800 Subject: [PATCH 04/10] Whitespace formatting for grscent assignment readability. --- src/game.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 16e09dcc14b96..30a9f7d264d7f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3859,9 +3859,12 @@ void game::update_scent() // we've already summed neighboring scent values in the y direction in the previous // loop. Now we do it for the x direction, multiply by diffusion, and this is what // diffuses into our current square. - grscent[x][y] = (temp_scent + this_diffusivity * - (sum_3_scent_y[y][x - 1] + sum_3_scent_y[y][x] + - sum_3_scent_y[y][x + 1])) / (1000 * 10); + grscent[x][y] = + (temp_scent + + this_diffusivity * (sum_3_scent_y[y][x - 1] + + sum_3_scent_y[y][x] + + sum_3_scent_y[y][x + 1]) + ) / (1000 * 10); const int fslime = m.get_field_strength(point(x, y), fd_slime) * 10; From 6c9aff4217400149d522f4e11b393d5a2d5ab5e7 Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:37:32 -0800 Subject: [PATCH 05/10] Rename bool matrix has_wall_here to blocks_scent. --- src/game.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 30a9f7d264d7f..7727ccfd24e41 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3785,7 +3785,7 @@ void game::update_scent() int sum_3_scent_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable int squares_used_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable - bool has_wall_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of + bool blocks_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of bool reduce_scent_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant) // for loop constants @@ -3812,18 +3812,18 @@ void game::update_scent() // cache expensive flag checks, once per tile. if (y == scentmap_miny) { // Setting y-1 y-0, when we are at the top row... for (int i = y - 1; i <= y; ++i) { - has_wall_here[x][i] = m.has_flag(TFLAG_WALL, x, i); + blocks_scent[x][i] = m.has_flag(TFLAG_WALL, x, i); reduce_scent_here[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i); } } - has_wall_here[x][y + 1] = m.has_flag(TFLAG_WALL, x, y + 1); // ...so only y+1 here. + blocks_scent[x][y + 1] = m.has_flag(TFLAG_WALL, x, y + 1); // ...so only y+1 here. reduce_scent_here[x][y + 1] = m.has_flag(TFLAG_REDUCE_SCENT, x, y + 1); // remember the sum of the scent val for the 3 neighboring squares that can defuse into sum_3_scent_y[y][x] = 0; squares_used_y[y][x] = 0; for (int i = y - 1; i <= y + 1; ++i) { - if (has_wall_here[x][i] == false) { + if (blocks_scent[x][i] == false) { if (reduce_scent_here[x][i] == true) { // only 20% of scent can diffuse on REDUCE_SCENT squares sum_3_scent_y[y][x] += 2 * grscent[x][i]; @@ -3838,7 +3838,7 @@ void game::update_scent() } for (int x = scentmap_minx; x <= scentmap_maxx; x++) { for (int y = scentmap_miny; y <= scentmap_maxy; y++) { - if (has_wall_here[x][y] == false) { + if (blocks_scent[x][y] == false) { // to how many neighboring squares do we diffuse out? (include our own square // since we also include our own square when diffusing in) int squares_used = squares_used_y[y][x - 1] From 00d70f895fb74fa8a3dae8c4fca35b2761f371b5 Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:39:06 -0800 Subject: [PATCH 06/10] Rename bool matrix reduce_scent_here to reduces_scent. --- src/game.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 7727ccfd24e41..1e079328fc7cd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3786,7 +3786,7 @@ void game::update_scent() int squares_used_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable bool blocks_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of - bool reduce_scent_here[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant) + bool reduces_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant) // for loop constants const int scentmap_minx = u.posx - SCENT_RADIUS; @@ -3813,18 +3813,18 @@ void game::update_scent() if (y == scentmap_miny) { // Setting y-1 y-0, when we are at the top row... for (int i = y - 1; i <= y; ++i) { blocks_scent[x][i] = m.has_flag(TFLAG_WALL, x, i); - reduce_scent_here[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i); + reduces_scent[x][i] = m.has_flag(TFLAG_REDUCE_SCENT, x, i); } } blocks_scent[x][y + 1] = m.has_flag(TFLAG_WALL, x, y + 1); // ...so only y+1 here. - reduce_scent_here[x][y + 1] = m.has_flag(TFLAG_REDUCE_SCENT, x, y + 1); + reduces_scent[x][y + 1] = m.has_flag(TFLAG_REDUCE_SCENT, x, y + 1); // remember the sum of the scent val for the 3 neighboring squares that can defuse into sum_3_scent_y[y][x] = 0; squares_used_y[y][x] = 0; for (int i = y - 1; i <= y + 1; ++i) { if (blocks_scent[x][i] == false) { - if (reduce_scent_here[x][i] == true) { + if (reduces_scent[x][i] == true) { // only 20% of scent can diffuse on REDUCE_SCENT squares sum_3_scent_y[y][x] += 2 * grscent[x][i]; squares_used_y[y][x] += 2; // only 20% diffuses into REDUCE_SCENT squares @@ -3846,7 +3846,7 @@ void game::update_scent() + squares_used_y[y][x + 1]; int this_diffusivity; - if (reduce_scent_here[x][y] == false) { + if (reduces_scent[x][y] == false) { this_diffusivity = diffusivity; } else { this_diffusivity = diffusivity / 5; //less air movement for REDUCE_SCENT square From b0ac0c8a92dcf2ec10813adf40c9ddc21a439234 Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:40:39 -0800 Subject: [PATCH 07/10] No need to compare bools to bools. --- src/game.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 1e079328fc7cd..d545aa4b042e5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3823,8 +3823,8 @@ void game::update_scent() sum_3_scent_y[y][x] = 0; squares_used_y[y][x] = 0; for (int i = y - 1; i <= y + 1; ++i) { - if (blocks_scent[x][i] == false) { - if (reduces_scent[x][i] == true) { + if (not blocks_scent[x][i]) { + if (reduces_scent[x][i]) { // only 20% of scent can diffuse on REDUCE_SCENT squares sum_3_scent_y[y][x] += 2 * grscent[x][i]; squares_used_y[y][x] += 2; // only 20% diffuses into REDUCE_SCENT squares @@ -3838,7 +3838,7 @@ void game::update_scent() } for (int x = scentmap_minx; x <= scentmap_maxx; x++) { for (int y = scentmap_miny; y <= scentmap_maxy; y++) { - if (blocks_scent[x][y] == false) { + if (not blocks_scent[x][y]) { // to how many neighboring squares do we diffuse out? (include our own square // since we also include our own square when diffusing in) int squares_used = squares_used_y[y][x - 1] @@ -3846,7 +3846,7 @@ void game::update_scent() + squares_used_y[y][x + 1]; int this_diffusivity; - if (reduces_scent[x][y] == false) { + if (not reduces_scent[x][y]) { this_diffusivity = diffusivity; } else { this_diffusivity = diffusivity / 5; //less air movement for REDUCE_SCENT square From 14048a58616037a4c2c0d827d10ff6609e84a1cb Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:55:57 -0800 Subject: [PATCH 08/10] Additional comments and some rewording. --- src/game.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index d545aa4b042e5..bb65facff9329 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3779,14 +3779,18 @@ void game::update_scent() player_last_moved = calendar::turn; } - // note: the next two intermediate variables need to be at least + // note: the next four intermediate matrices need to be at least // [2*SCENT_RADIUS+3][2*SCENT_RADIUS+1] in size to hold enough data // The code I'm modifying used [SEEX * MAPSIZE]. I'm staying with that to avoid new bugs. - int sum_3_scent_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable + + // These two matrices are transposed so that x addresses are contiguous in memory + int sum_3_scent_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable int squares_used_y[SEEY * MAPSIZE][SEEX * MAPSIZE]; //intermediate variable - bool blocks_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // stash instead of - bool reduces_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // checking 14884 * (3 redundant) + // these are for caching flag lookups + bool blocks_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // currently only TFLAG_WALL blocks scent + bool reduces_scent[SEEX * MAPSIZE][SEEY * MAPSIZE]; + // for loop constants const int scentmap_minx = u.posx - SCENT_RADIUS; @@ -3827,7 +3831,7 @@ void game::update_scent() if (reduces_scent[x][i]) { // only 20% of scent can diffuse on REDUCE_SCENT squares sum_3_scent_y[y][x] += 2 * grscent[x][i]; - squares_used_y[y][x] += 2; // only 20% diffuses into REDUCE_SCENT squares + squares_used_y[y][x] += 2; } else { sum_3_scent_y[y][x] += 10 * grscent[x][i]; squares_used_y[y][x] += 10; @@ -3877,7 +3881,7 @@ void game::update_scent() debugmsg("Wacky scent at %d, %d (%d)", x, y, grscent[x][y]); grscent[x][y] = 0; // Scent should never be higher } - } else { // there is a wall here + } else { // this cell blocks scent grscent[x][y] = 0; } } From d8a22ffbcfd9a4294fceb9216b25efb35179521b Mon Sep 17 00:00:00 2001 From: wormingdead Date: Sun, 2 Nov 2014 20:58:14 -0800 Subject: [PATCH 09/10] Pre-increment instead of post. Bleh. --- src/game.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index bb65facff9329..5c1fd0b00d525 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3811,8 +3811,8 @@ void game::update_scent() // note: this method needs an array that is one square larger on each side in the x direction // than the final scent matrix. I think this is fine since SCENT_RADIUS is less than // SEEX*MAPSIZE, but if that changes, this may need tweaking. - for (int x = scentmap_minx - 1; x <= scentmap_maxx + 1; x++) { - for (int y = scentmap_miny; y <= scentmap_maxy; y++) { + for (int x = scentmap_minx - 1; x <= scentmap_maxx + 1; ++x) { + for (int y = scentmap_miny; y <= scentmap_maxy; ++y) { // cache expensive flag checks, once per tile. if (y == scentmap_miny) { // Setting y-1 y-0, when we are at the top row... for (int i = y - 1; i <= y; ++i) { @@ -3840,8 +3840,8 @@ void game::update_scent() } } } - for (int x = scentmap_minx; x <= scentmap_maxx; x++) { - for (int y = scentmap_miny; y <= scentmap_maxy; y++) { + for (int x = scentmap_minx; x <= scentmap_maxx; ++x) { + for (int y = scentmap_miny; y <= scentmap_maxy; ++y) { if (not blocks_scent[x][y]) { // to how many neighboring squares do we diffuse out? (include our own square // since we also include our own square when diffusing in) From 53ff7ec2a60de0c5510e42b6adbad587d07ca504 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Mon, 3 Nov 2014 22:57:03 -0600 Subject: [PATCH 10/10] Document why we're shutting off acid damage. --- src/field.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/field.cpp b/src/field.cpp index 589bf51e6f77e..64e14e0eeda10 100644 --- a/src/field.cpp +++ b/src/field.cpp @@ -1439,8 +1439,9 @@ void map::step_in_field(int x, int y) } break; case fd_acid: - //Acid deals damage at all levels now; the inside refers to inside a vehicle. //TODO: Add resistance to this with rubber shoes or something? + // Assume vehicles block acid damage entirely, + // you're certainly not standing in it. if (veh) { break; }