void promote_match(dbref what, int confidence) { /* * Check for type and locks, if requested */ if (md.pref_type != NOTYPE) { if (Good_obj(what) && (Typeof(what) == md.pref_type)) { confidence |= CON_TYPE; } } if (md.check_keys) { MSTATE save_md; save_match_state(&save_md); if (Good_obj(what) && could_doit(md.player, what, A_LOCK)) { confidence |= CON_LOCK; } restore_match_state(&save_md); } /* * If nothing matched, take it */ if (md.count == 0) { md.match = what; md.confidence = confidence; md.count = 1; return; } /* * If confidence is lower, ignore */ if (confidence < md.confidence) { return; } /* * If confidence is higher, replace */ if (confidence > md.confidence) { md.match = what; md.confidence = confidence; md.count = 1; return; } /* * Equal confidence, pick randomly */ md.count++; if (Randomize(md.count) == 0) { md.match = what; } return; }
static void promote_match(dbref what, int confidence) { #ifdef REALITY_LVLS // Check is the object is visible. // if ( Good_obj(what) && (confidence & CON_LOCAL) && !IsReal(md.player, what) && what != Location(md.player)) { return; } #endif // REALITY_LVLS // Check for type and locks, if requested. // if (md.pref_type != NOTYPE) { if ( Good_obj(what) && Typeof(what) == md.pref_type) { confidence |= CON_TYPE; } } if (md.check_keys) { MSTATE save_md; save_match_state(&save_md); if ( Good_obj(what) && could_doit(md.player, what, A_LOCK)) { confidence |= CON_LOCK; } restore_match_state(&save_md); } // If nothing matched, take it. // if (md.count == 0) { md.match = what; md.confidence = confidence; md.count = 1; return; } // If confidence is lower, ignore. // if (confidence < md.confidence) { return; } // If confidence is higher, replace. // if (confidence > md.confidence) { md.match = what; md.confidence = confidence; md.count = 1; return; } // Equal confidence, pick randomly. // md.count++; if (RandomINT32(1,md.count) == 1) { md.match = what; } return; }