Skip to content

Commit

Permalink
Fix telescope eyes not preventing eye mutations (#37849)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 9, 2020
1 parent 55195aa commit 7a38932
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
24 changes: 23 additions & 1 deletion data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,29 @@
"name": "Telescopic Eyes",
"description": "Much of the material in your inner eye has been surgically removed and replaced with an array of high-powered, auto-focusing lenses. They function as integrated binoculars, letting you see much farther than before, and any vision problems you might have had are now gone.",
"occupied_bodyparts": [ [ "EYES", 2 ] ],
"canceled_mutations": [ "HYPEROPIC", "MYOPIC" ]
"canceled_mutations": [
"HYPEROPIC",
"MYOPIC",
"URSINE_EYE",
"NIGHTVISION3",
"NIGHTVISION2",
"NIGHTVISION",
"BIRD_EYE",
"COMPOUND_EYES",
"LIZ_IR",
"EAGLEEYED",
"CEPH_VISION",
"CEPH_EYES",
"ELFA_FNV",
"ELFA_NV",
"ELFAEYES",
"FEL_NV",
"FEL_EYE",
"INFRARED",
"LIZ_EYE",
"EYEBULGE",
"SEESLEEP"
]
},
{
"id": "bio_face_mask",
Expand Down
10 changes: 10 additions & 0 deletions src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "rng.h"
#include "string_id.h"
#include "enums.h"
#include "bionics.h"
#include "cata_string_consts.h"

namespace io
Expand Down Expand Up @@ -580,6 +581,15 @@ bool Character::mutation_ok( const trait_id &mutation, bool force_good, bool for
// We already have this mutation or something that replaces it.
return false;
}

for( const bionic_id &bid : get_bionics() ) {
for( const trait_id &mid : bid->canceled_mutations ) {
if( mid == mutation ) {
return false;
}
}
}

const mutation_branch &mdata = mutation.obj();
if( force_bad && mdata.points > 0 ) {
// This is a good mutation, and we're due for a bad one.
Expand Down
19 changes: 8 additions & 11 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,13 @@
#include "requirements.h"
#include "stats_tracker.h"
#include "vpart_position.h"
#include "cata_string_consts.h"

struct oter_type_t;
struct mutation_branch;

#define dbg(x) DebugLog((DebugLevel)(x),D_GAME) << __FILE__ << ":" << __LINE__ << ": "

static const trait_id trait_HYPEROPIC( "HYPEROPIC" );
static const trait_id trait_MYOPIC( "MYOPIC" );
static const efftype_id effect_riding( "riding" );

static const std::array<std::string, NUM_OBJECTS> obj_type_name = { { "OBJECT_NONE", "OBJECT_ITEM", "OBJECT_ACTOR", "OBJECT_PLAYER",
"OBJECT_NPC", "OBJECT_MONSTER", "OBJECT_VEHICLE", "OBJECT_TRAP", "OBJECT_FIELD",
"OBJECT_TERRAIN", "OBJECT_FURNITURE"
Expand Down Expand Up @@ -923,13 +920,13 @@ void player::load( const JsonObject &data )
add_bionic( bionic_id( "bio_blindfold" ) );
}

// Fixes bugged characters for telescopic eyes CBM.
if( has_bionic( bionic_id( "bio_eye_optic" ) ) && has_trait( trait_HYPEROPIC ) ) {
remove_mutation( trait_HYPEROPIC );
}

if( has_bionic( bionic_id( "bio_eye_optic" ) ) && has_trait( trait_MYOPIC ) ) {
remove_mutation( trait_MYOPIC );
// Fixes bugged characters for CBM's preventing mutations.
for( const bionic_id &bid : get_bionics() ) {
for( const trait_id &mid : bid->canceled_mutations ) {
if( has_trait( mid ) ) {
remove_mutation( mid );
}
}
}

if( data.has_array( "faction_warnings" ) ) {
Expand Down

0 comments on commit 7a38932

Please sign in to comment.