mux/src/match.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include "attrs.h"
#include "powers.h"

Include dependency graph for match.cpp:

Go to the source code of this file.

Defines

#define CON_LOCAL   0x01
#define CON_TYPE   0x02
#define CON_LOCK   0x04
#define CON_COMPLETE   0x08
#define CON_TOKEN   0x10
#define CON_DBREF   0x20

Functions

static void promote_match (dbref what, int confidence)
static char * munge_space_for_match (char *name)
void match_player (void)
static dbref absolute_name (bool bNeedPound)
void match_absolute (void)
static void match_numeric (void)
void match_me (void)
static void match_home (void)
void match_here (void)
static void match_list (dbref first, int local)
void match_possession (void)
void match_neighbor (void)
static bool match_exit_internal (dbref loc, dbref baseloc, int local)
void match_exit (void)
void match_exit_with_parents (void)
void match_carried_exit (void)
void match_carried_exit_with_parents (void)
void match_master_exit (void)
void match_zone_exit (void)
void match_everything (int key)
dbref match_result (void)
dbref last_match_result (void)
dbref match_status (dbref player, dbref match)
dbref noisy_match_result (void)
void save_match_state (MSTATE *mstate)
void restore_match_state (MSTATE *mstate)
void init_match (dbref player, const char *name, int type)
void init_match_check_keys (dbref player, const char *name, int type)
dbref match_thing (dbref player, char *name)
dbref match_thing_quiet (dbref player, char *name)
void safe_match_result (dbref it, char *buff, char **bufc)

Variables

const char * NOMATCH_MESSAGE = "I don't see that here."
const char * AMBIGUOUS_MESSAGE = "I don't know which one you mean!"
const char * NOPERM_MESSAGE = "Permission denied."
const char * FUNC_FAIL_MESSAGE = "#-1"
const char * FUNC_NOMATCH_MESSAGE = "#-1 NO MATCH"
const char * OUT_OF_RANGE = "#-1 OUT OF RANGE"
const char * FUNC_NOT_FOUND = "#-1 NOT FOUND"
const char * FUNC_AMBIGUOUS = "#-2 AMBIGUOUS"
const char * FUNC_NOPERM_MESSAGE = "#-1 PERMISSION DENIED"
static MSTATE md


Define Documentation

#define CON_COMPLETE   0x08

Definition at line 30 of file match.cpp.

Referenced by match_exit_internal(), match_here(), and match_list().

#define CON_DBREF   0x20

Definition at line 32 of file match.cpp.

Referenced by match_absolute(), match_carried_exit(), match_carried_exit_with_parents(), match_exit(), match_exit_internal(), match_exit_with_parents(), match_here(), match_home(), match_list(), match_master_exit(), match_me(), match_neighbor(), match_numeric(), match_player(), match_possession(), and match_zone_exit().

#define CON_LOCAL   0x01

Definition at line 27 of file match.cpp.

Referenced by match_carried_exit(), match_carried_exit_with_parents(), match_exit(), match_exit_with_parents(), match_here(), match_me(), match_neighbor(), match_possession(), and promote_match().

#define CON_LOCK   0x04

Definition at line 29 of file match.cpp.

Referenced by promote_match().

#define CON_TOKEN   0x10

Definition at line 31 of file match.cpp.

Referenced by match_everything(), match_here(), match_home(), match_me(), and match_player().

#define CON_TYPE   0x02

Definition at line 28 of file match.cpp.

Referenced by promote_match().


Function Documentation

static dbref absolute_name ( bool  bNeedPound  )  [static]

Definition at line 180 of file match.cpp.

References Good_obj, match(), md, NOTHING, NUMBER_TOKEN, parse_dbref(), and match_state::string.

Referenced by init_match(), and match_numeric().

00181 {
00182     char *mname = md.string;
00183     if (bNeedPound)
00184     {
00185         if (*mname != NUMBER_TOKEN)
00186         {
00187             return NOTHING;
00188         }
00189         mname++;
00190     }
00191     if (*mname)
00192     {
00193         dbref match = parse_dbref(mname);
00194         if (Good_obj(match))
00195         {
00196             return match;
00197         }
00198     }
00199     return NOTHING;
00200 }

void init_match ( dbref  player,
const char *  name,
int  type 
)

Definition at line 603 of file match.cpp.

References match_state::absolute_form, absolute_name(), match_state::check_keys, match_state::confidence, match_state::count, match_state::match, md, munge_space_for_match(), NOTHING, match_state::player, match_state::pref_type, and match_state::string.

Referenced by do_boot(), do_chopen(), do_chown(), do_chownall(), do_chzone(), do_clone(), do_decomp(), do_destroy(), do_drop(), do_enter(), do_entrances(), do_examine(), do_fixdb(), do_give(), do_kill(), do_link(), do_lock(), do_look(), do_mail_debug(), do_mail_stats(), do_notify(), do_parent(), do_pemit_single(), do_setattr(), do_teleport(), do_teleport_single(), do_toad(), do_unlink(), do_use(), do_verb(), do_wait(), FUNCTION(), give_thing(), init_match_check_keys(), match_controlled_handler(), match_possessed(), match_thing(), match_thing_quiet(), parse_attrib_wild(), parse_boolexp_L(), parse_linkable_room(), and parse_thing_slash().

00604 {
00605     md.confidence = -1;
00606     md.count = 0;
00607     md.check_keys = false;
00608     md.pref_type = type;
00609     md.match = NOTHING;
00610     md.player = player;
00611     md.string = munge_space_for_match((char *)name);
00612     md.absolute_form = absolute_name(true);
00613 }

void init_match_check_keys ( dbref  player,
const char *  name,
int  type 
)

Definition at line 615 of file match.cpp.

References match_state::check_keys, init_match(), and md.

Referenced by do_get(), do_move(), FUNCTION(), and process_command().

00616 {
00617     init_match(player, name, type);
00618     md.check_keys = true;
00619 }

dbref last_match_result ( void   ) 

Definition at line 548 of file match.cpp.

References match_state::match, and md.

Referenced by do_destroy(), FUNCTION(), and process_command().

00549 {
00550     return md.match;
00551 }

void match_absolute ( void   ) 

Definition at line 202 of file match.cpp.

References match_state::absolute_form, CON_DBREF, match_state::confidence, Good_obj, md, and promote_match().

Referenced by do_boot(), do_chown(), do_chownall(), do_enter(), do_get(), do_give(), do_kill(), do_look(), do_mail_debug(), do_mail_stats(), do_toad(), do_use(), FUNCTION(), and match_everything().

00203 {
00204     if (md.confidence >= CON_DBREF)
00205     {
00206         return;
00207     }
00208     if (Good_obj(md.absolute_form))
00209     {
00210         promote_match(md.absolute_form, CON_DBREF);
00211     }
00212 }

void match_carried_exit ( void   ) 

Definition at line 429 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Good_obj, Has_exits, match_exit_internal(), md, and match_state::player.

Referenced by do_drop(), and match_everything().

00430 {
00431     if (md.confidence >= CON_DBREF)
00432     {
00433         return;
00434     }
00435     if (  Good_obj(md.player)
00436        && Has_exits(md.player))
00437     {
00438         (void)match_exit_internal(md.player, md.player, CON_LOCAL);
00439     }
00440 }

void match_carried_exit_with_parents ( void   ) 

Definition at line 442 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Good_obj, Has_exits, ITER_PARENTS, match_exit_internal(), md, and match_state::player.

Referenced by FUNCTION(), and match_everything().

00443 {
00444     if (md.confidence >= CON_DBREF)
00445     {
00446         return;
00447     }
00448     if (  Good_obj(md.player)
00449        && Has_exits(md.player))
00450     {
00451         dbref parent;
00452         int lev;
00453         ITER_PARENTS(md.player, parent, lev)
00454         {
00455             if (match_exit_internal(parent, md.player, CON_LOCAL))
00456             {
00457                 break;
00458             }
00459         }
00460     }
00461 }

void match_everything ( int  key  ) 

Definition at line 489 of file match.cpp.

References CON_TOKEN, match_state::confidence, MAT_EXIT_PARENTS, MAT_HOME, MAT_NO_EXITS, MAT_NUMERIC, match_absolute(), match_carried_exit(), match_carried_exit_with_parents(), match_exit(), match_exit_with_parents(), match_here(), match_home(), match_me(), match_neighbor(), match_numeric(), match_player(), match_possession(), and md.

Referenced by do_chopen(), do_chzone(), do_clone(), do_decomp(), do_entrances(), do_examine(), do_fixdb(), do_link(), do_lock(), do_notify(), do_parent(), do_pemit_single(), do_setattr(), do_teleport(), do_teleport_single(), do_unlink(), do_verb(), do_wait(), FUNCTION(), match_controlled_handler(), match_thing(), match_thing_quiet(), parse_attrib_wild(), parse_boolexp_L(), parse_linkable_room(), and parse_thing_slash().

00490 {
00491     /*
00492      * Try matching me, then here, then absolute, then player FIRST, since
00493      * this will hit most cases. STOP if we get something, since those are
00494      * exact matches.
00495      */
00496 
00497     match_me();
00498     match_here();
00499     match_absolute();
00500     if (key & MAT_NUMERIC)
00501     {
00502         match_numeric();
00503     }
00504     if (key & MAT_HOME)
00505     {
00506         match_home();
00507     }
00508     match_player();
00509     if (md.confidence >= CON_TOKEN)
00510     {
00511         return;
00512     }
00513 
00514     if (!(key & MAT_NO_EXITS))
00515     {
00516         if (key & MAT_EXIT_PARENTS)
00517         {
00518             match_carried_exit_with_parents();
00519             match_exit_with_parents();
00520         }
00521         else
00522         {
00523             match_carried_exit();
00524             match_exit();
00525         }
00526     }
00527     match_neighbor();
00528     match_possession();
00529 }

void match_exit ( void   ) 

Definition at line 392 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Good_obj, Has_location, Location, match_exit_internal(), md, and match_state::player.

Referenced by do_chown(), do_destroy(), do_get(), do_move(), and match_everything().

00393 {
00394     if (md.confidence >= CON_DBREF)
00395     {
00396         return;
00397     }
00398 
00399     dbref loc = Location(md.player);
00400     if (  Good_obj(md.player)
00401        && Has_location(md.player))
00402     {
00403         (void)match_exit_internal(loc, loc, CON_LOCAL);
00404     }
00405 }

static bool match_exit_internal ( dbref  loc,
dbref  baseloc,
int  local 
) [static]

Definition at line 348 of file match.cpp.

References match_state::absolute_form, CON_COMPLETE, CON_DBREF, Dark, DOLIST, Examinable, exit_visible(), Exits, Good_obj, Has_exits, matches_exit_from_list(), md, match_state::player, promote_match(), PureName(), match_state::string, VE_BASE_DARK, VE_LOC_DARK, and VE_LOC_XAM.

Referenced by match_carried_exit(), match_carried_exit_with_parents(), match_exit(), match_exit_with_parents(), match_master_exit(), and match_zone_exit().

00349 {
00350     if (  !Good_obj(loc)
00351        || !Has_exits(loc))
00352     {
00353         return true;
00354     }
00355 
00356     dbref exit;
00357     bool result = false;
00358     int key;
00359 
00360     DOLIST(exit, Exits(loc))
00361     {
00362         if (exit == md.absolute_form)
00363         {
00364             key = 0;
00365             if (Examinable(md.player, loc))
00366             {
00367                 key |= VE_LOC_XAM;
00368             }
00369             if (Dark(loc))
00370             {
00371                 key |= VE_LOC_DARK;
00372             }
00373             if (Dark(baseloc))
00374             {
00375                 key |= VE_BASE_DARK;
00376             }
00377             if (exit_visible(exit, md.player, key))
00378             {
00379                 promote_match(exit, CON_DBREF | local);
00380                 return true;
00381             }
00382         }
00383         if (matches_exit_from_list(md.string, PureName(exit)))
00384         {
00385             promote_match(exit, CON_COMPLETE | local);
00386             result = true;
00387         }
00388     }
00389     return result;
00390 }

void match_exit_with_parents ( void   ) 

Definition at line 407 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Good_obj, Has_location, ITER_PARENTS, Location, match_exit_internal(), md, and match_state::player.

Referenced by do_look(), FUNCTION(), match_everything(), and process_command().

00408 {
00409     if (md.confidence >= CON_DBREF)
00410     {
00411         return;
00412     }
00413     if (  Good_obj(md.player)
00414        && Has_location(md.player))
00415     {
00416         dbref parent;
00417         int lev;
00418         dbref loc = Location(md.player);
00419         ITER_PARENTS(loc, parent, lev)
00420         {
00421             if (match_exit_internal(parent, loc, CON_LOCAL))
00422             {
00423                 break;
00424             }
00425         }
00426     }
00427 }

void match_here ( void   ) 

Definition at line 259 of file match.cpp.

References match_state::absolute_form, CON_COMPLETE, CON_DBREF, CON_LOCAL, CON_TOKEN, match_state::confidence, Good_obj, Has_location, Location, md, match_state::player, promote_match(), PureName(), match_state::string, and string_compare().

Referenced by do_chown(), do_kill(), do_look(), do_use(), FUNCTION(), and match_everything().

00260 {
00261     if (md.confidence >= CON_DBREF)
00262     {
00263         return;
00264     }
00265     if (  Good_obj(md.player)
00266        && Has_location(md.player))
00267     {
00268         dbref loc = Location(md.player);
00269         if (Good_obj(loc))
00270         {
00271             if (loc == md.absolute_form)
00272             {
00273                 promote_match(loc, CON_DBREF | CON_LOCAL);
00274             }
00275             else if (!string_compare(md.string, "here"))
00276             {
00277                 promote_match(loc, CON_TOKEN | CON_LOCAL);
00278             }
00279             else if (!string_compare(md.string, PureName(loc)))
00280             {
00281                 promote_match(loc, CON_COMPLETE | CON_LOCAL);
00282             }
00283         }
00284     }
00285 }

static void match_home ( void   )  [static]

Definition at line 246 of file match.cpp.

References CON_DBREF, CON_TOKEN, match_state::confidence, HOME, md, promote_match(), match_state::string, and string_compare().

Referenced by match_everything().

00247 {
00248     if (md.confidence >= CON_DBREF)
00249     {
00250         return;
00251     }
00252     if (!string_compare(md.string, "home"))
00253     {
00254         promote_match(HOME, CON_TOKEN);
00255     }
00256     return;
00257 }

static void match_list ( dbref  first,
int  local 
) [static]

Definition at line 287 of file match.cpp.

References match_state::absolute_form, CON_COMPLETE, CON_DBREF, match_state::confidence, DOLIST, md, promote_match(), PureName(), match_state::string, string_compare(), and string_match().

Referenced by match_neighbor(), and match_possession().

00288 {
00289     if (md.confidence >= CON_DBREF)
00290     {
00291         return;
00292     }
00293     DOLIST(first, first)
00294     {
00295         if (first == md.absolute_form)
00296         {
00297             promote_match(first, CON_DBREF | local);
00298             return;
00299         }
00300         /*
00301          * Warning: make sure there are no other calls to Name() in
00302          * promote_match or its called subroutines; they
00303          * would overwrite Name()'s static buffer which is
00304          * needed by string_match().
00305          */
00306         const char *namebuf = PureName(first);
00307 
00308         if (!string_compare(namebuf, md.string))
00309         {
00310             promote_match(first, CON_COMPLETE | local);
00311         }
00312         else if (string_match(namebuf, md.string))
00313         {
00314             promote_match(first, local);
00315         }
00316     }
00317 }

void match_master_exit ( void   ) 

Definition at line 463 of file match.cpp.

References CON_DBREF, match_state::confidence, Good_obj, Has_exits, confdata::master_room, match_exit_internal(), md, mudconf, and match_state::player.

Referenced by do_look(), and process_command().

00464 {
00465     if (md.confidence >= CON_DBREF)
00466     {
00467         return;
00468     }
00469     if (  Good_obj(md.player)
00470        && Has_exits(md.player))
00471     {
00472         (void)match_exit_internal(mudconf.master_room, mudconf.master_room, 0);
00473     }
00474 }

void match_me ( void   ) 

Definition at line 227 of file match.cpp.

References match_state::absolute_form, CON_DBREF, CON_LOCAL, CON_TOKEN, match_state::confidence, Good_obj, md, match_state::player, promote_match(), match_state::string, and string_compare().

Referenced by do_chown(), do_give(), do_kill(), do_look(), do_use(), FUNCTION(), give_thing(), and match_everything().

00228 {
00229     if (md.confidence >= CON_DBREF)
00230     {
00231         return;
00232     }
00233     if (  Good_obj(md.absolute_form)
00234        && md.absolute_form == md.player)
00235     {
00236         promote_match(md.player, CON_DBREF | CON_LOCAL);
00237         return;
00238     }
00239     if (!string_compare(md.string, "me"))
00240     {
00241         promote_match(md.player, CON_TOKEN | CON_LOCAL);
00242     }
00243     return;
00244 }

void match_neighbor ( void   ) 

Definition at line 331 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Contents, Good_obj, Has_location, Location, match_list(), md, and match_state::player.

Referenced by do_boot(), do_chownall(), do_enter(), do_get(), do_give(), do_kill(), do_look(), do_toad(), do_use(), FUNCTION(), match_everything(), and match_possessed().

00332 {
00333     if (md.confidence >= CON_DBREF)
00334     {
00335         return;
00336     }
00337     if (  Good_obj(md.player)
00338        && Has_location(md.player))
00339     {
00340         dbref loc = Location(md.player);
00341         if (Good_obj(loc))
00342         {
00343             match_list(Contents(loc), CON_LOCAL);
00344         }
00345     }
00346 }

static void match_numeric ( void   )  [static]

Definition at line 214 of file match.cpp.

References absolute_name(), CON_DBREF, match_state::confidence, Good_obj, match(), md, and promote_match().

Referenced by match_everything().

00215 {
00216     if (md.confidence >= CON_DBREF)
00217     {
00218         return;
00219     }
00220     dbref match = absolute_name(false);
00221     if (Good_obj(match))
00222     {
00223         promote_match(match, CON_DBREF);
00224     }
00225 }

void match_player ( void   ) 

Definition at line 151 of file match.cpp.

References match_state::absolute_form, CON_DBREF, CON_TOKEN, match_state::confidence, Good_obj, isPlayer, lookup_player(), LOOKUP_TOKEN, match(), md, mux_isspace, NOTHING, promote_match(), and match_state::string.

Referenced by do_boot(), do_chown(), do_chownall(), do_give(), do_kill(), do_look(), do_toad(), do_use(), FUNCTION(), and match_everything().

00152 {
00153     if (md.confidence >= CON_DBREF)
00154     {
00155         return;
00156     }
00157     if (Good_obj(md.absolute_form) && isPlayer(md.absolute_form))
00158     {
00159         promote_match(md.absolute_form, CON_DBREF);
00160         return;
00161     }
00162     if (*md.string == LOOKUP_TOKEN)
00163     {
00164         char *p;
00165         for (p = md.string + 1; mux_isspace(*p); p++)
00166         {
00167             ; // Nothing.
00168         }
00169         dbref match = lookup_player(NOTHING, p, true);
00170         if (Good_obj(match))
00171         {
00172             promote_match(match, CON_TOKEN);
00173         }
00174     }
00175 }

void match_possession ( void   ) 

Definition at line 319 of file match.cpp.

References CON_DBREF, CON_LOCAL, match_state::confidence, Contents, Good_obj, Has_contents, match_list(), md, and match_state::player.

Referenced by do_chown(), do_destroy(), do_drop(), do_give(), do_look(), do_use(), FUNCTION(), give_thing(), match_everything(), and match_possessed().

00320 {
00321     if (md.confidence >= CON_DBREF)
00322     {
00323         return;
00324     }
00325     if (Good_obj(md.player) && Has_contents(md.player))
00326     {
00327         match_list(Contents(md.player), CON_LOCAL);
00328     }
00329 }

dbref match_result ( void   ) 

Definition at line 531 of file match.cpp.

References AMBIGUOUS, match_state::count, match_state::match, md, and NOTHING.

Referenced by do_chopen(), do_chown(), do_drop(), do_get(), do_give(), do_kill(), do_lock(), do_look(), do_mail_debug(), do_mail_stats(), do_move(), do_pemit_single(), do_teleport_single(), do_unlink(), FUNCTION(), give_thing(), match_controlled_handler(), match_possessed(), match_thing_quiet(), noisy_match_result(), parse_attrib_wild(), parse_boolexp_L(), parse_linkable_room(), and parse_thing_slash().

00532 {
00533     switch (md.count)
00534     {
00535     case 0:
00536         return NOTHING;
00537 
00538     case 1:
00539         return md.match;
00540 
00541     default:
00542         return AMBIGUOUS;
00543     }
00544 }

dbref match_status ( dbref  player,
dbref  match 
)

Definition at line 553 of file match.cpp.

References AMBIGUOUS, AMBIGUOUS_MESSAGE, NOMATCH_MESSAGE, NOPERM, NOPERM_MESSAGE, NOTHING, and notify.

Referenced by do_destroy(), do_get(), do_look(), FUNCTION(), and noisy_match_result().

00554 {
00555     switch (match)
00556     {
00557     case NOTHING:
00558         notify(player, NOMATCH_MESSAGE);
00559         return NOTHING;
00560 
00561     case AMBIGUOUS:
00562         notify(player, AMBIGUOUS_MESSAGE);
00563         return NOTHING;
00564 
00565     case NOPERM:
00566         notify(player, NOPERM_MESSAGE);
00567         return NOTHING;
00568     }
00569     return match;
00570 }

dbref match_thing ( dbref  player,
char *  name 
)

Definition at line 621 of file match.cpp.

References init_match(), MAT_EXIT_PARENTS, match_everything(), noisy_match_result(), and NOTYPE.

Referenced by do_chboot(), do_halt(), do_moniker(), do_prog(), do_quitprog(), and FUNCTION().

00622 {
00623     init_match(player, name, NOTYPE);
00624     match_everything(MAT_EXIT_PARENTS);
00625     return noisy_match_result();
00626 }

dbref match_thing_quiet ( dbref  player,
char *  name 
)

Definition at line 628 of file match.cpp.

References init_match(), MAT_EXIT_PARENTS, match_everything(), match_result(), and NOTYPE.

Referenced by do_icmd(), FUNCTION(), get_obj_and_lock(), grep_handler(), handle_flaglists(), hasattr_handler(), internalPlayerFind(), process_sex(), and scan_zone().

00629 {
00630     init_match(player, name, NOTYPE);
00631     match_everything(MAT_EXIT_PARENTS);
00632     return match_result();
00633 }

void match_zone_exit ( void   ) 

Definition at line 476 of file match.cpp.

References CON_DBREF, match_state::confidence, Good_obj, Has_exits, match_exit_internal(), md, match_state::player, and Zone.

Referenced by process_command().

00477 {
00478     if (md.confidence >= CON_DBREF)
00479     {
00480         return;
00481     }
00482     if (  Good_obj(md.player)
00483        && Has_exits(md.player))
00484     {
00485         (void)match_exit_internal(Zone(md.player), Zone(md.player), 0);
00486     }
00487 }

static char* munge_space_for_match ( char *  name  )  [static]

Definition at line 109 of file match.cpp.

References LBUF_SIZE, and mux_isspace.

Referenced by init_match().

00110 {
00111     static char buffer[LBUF_SIZE];
00112 
00113     char *p = name;
00114     char *q = buffer;
00115 
00116     if (p)
00117     {
00118         // Remove Initial spaces.
00119         //
00120         while (mux_isspace(*p))
00121         {
00122             p++;
00123         }
00124 
00125         while (*p)
00126         {
00127             while (  *p
00128                   && !mux_isspace(*p))
00129             {
00130                 *q++ = *p++;
00131             }
00132 
00133             while (mux_isspace(*p))
00134             {
00135                 p++;
00136             }
00137 
00138             if (*p)
00139             {
00140                 *q++ = ' ';
00141             }
00142         }
00143     }
00144 
00145     // Remove terminal spaces and terminate string.
00146     //
00147     *q = '\0';
00148     return buffer;
00149 }

dbref noisy_match_result ( void   ) 

Definition at line 572 of file match.cpp.

References match_result(), match_status(), md, and match_state::player.

Referenced by do_boot(), do_chownall(), do_chzone(), do_clone(), do_decomp(), do_enter(), do_entrances(), do_examine(), do_fixdb(), do_link(), do_notify(), do_parent(), do_setattr(), do_teleport(), do_toad(), do_use(), do_verb(), do_wait(), FUNCTION(), match_controlled_handler(), and match_thing().

00573 {
00574     return match_status(md.player, match_result());
00575 }

static void promote_match ( dbref  what,
int  confidence 
) [static]

Definition at line 36 of file match.cpp.

References A_LOCK, match_state::check_keys, CON_LOCAL, CON_LOCK, CON_TYPE, match_state::confidence, could_doit(), match_state::count, Good_obj, IsReal, Location, match_state::match, md, NOTYPE, match_state::player, match_state::pref_type, RandomINT32(), restore_match_state(), save_match_state(), and Typeof.

Referenced by match_absolute(), match_exit_internal(), match_here(), match_home(), match_list(), match_me(), match_numeric(), and match_player().

00037 {
00038 #ifdef REALITY_LVLS
00039     // Check is the object is visible
00040     if(Good_obj(what) && (confidence & CON_LOCAL) &&
00041       !IsReal(md.player, what) && what != Location(md.player))
00042         return;
00043 #endif /* REALITY_LVLS */
00044     // Check for type and locks, if requested.
00045     //
00046     if (md.pref_type != NOTYPE)
00047     {
00048         if (  Good_obj(what)
00049            && Typeof(what) == md.pref_type)
00050         {
00051             confidence |= CON_TYPE;
00052         }
00053     }
00054     if (md.check_keys)
00055     {
00056         MSTATE save_md;
00057 
00058         save_match_state(&save_md);
00059         if (  Good_obj(what)
00060            && could_doit(md.player, what, A_LOCK))
00061         {
00062             confidence |= CON_LOCK;
00063         }
00064         restore_match_state(&save_md);
00065     }
00066 
00067     // If nothing matched, take it.
00068     //
00069     if (md.count == 0)
00070     {
00071         md.match = what;
00072         md.confidence = confidence;
00073         md.count = 1;
00074         return;
00075     }
00076 
00077     // If confidence is lower, ignore.
00078     //
00079     if (confidence < md.confidence)
00080     {
00081         return;
00082     }
00083 
00084     // If confidence is higher, replace.
00085     //
00086     if (confidence > md.confidence)
00087     {
00088         md.match = what;
00089         md.confidence = confidence;
00090         md.count = 1;
00091         return;
00092     }
00093 
00094     // Equal confidence, pick randomly.
00095     //
00096     md.count++;
00097     if (RandomINT32(1,md.count) == 1)
00098     {
00099         md.match = what;
00100     }
00101     return;
00102 }

void restore_match_state ( MSTATE mstate  ) 

Definition at line 590 of file match.cpp.

References match_state::absolute_form, match_state::check_keys, match_state::confidence, match_state::count, free_lbuf, match_state::match, md, match_state::player, match_state::pref_type, and match_state::string.

Referenced by parse_boolexp_L(), and promote_match().

00591 {
00592     md.confidence = mstate->confidence;
00593     md.count = mstate->count;
00594     md.pref_type = mstate->pref_type;
00595     md.check_keys = mstate->check_keys;
00596     md.absolute_form = mstate->absolute_form;
00597     md.match = mstate->match;
00598     md.player = mstate->player;
00599     strcpy(md.string, mstate->string);
00600     free_lbuf(mstate->string);
00601 }

void safe_match_result ( dbref  it,
char *  buff,
char **  bufc 
)

Definition at line 635 of file match.cpp.

References AMBIGUOUS, safe_ambiguous, and safe_notfound.

Referenced by FUNCTION(), get_obj_and_lock(), grep_handler(), hasattr_handler(), internalPlayerFind(), process_sex(), and scan_zone().

00636 {
00637     if (it == AMBIGUOUS)
00638     {
00639         safe_ambiguous(buff, bufc);
00640     }
00641     else
00642     {
00643         safe_notfound(buff, bufc);
00644     }
00645 }

void save_match_state ( MSTATE mstate  ) 

Definition at line 577 of file match.cpp.

References match_state::absolute_form, alloc_lbuf, match_state::check_keys, match_state::confidence, match_state::count, match_state::match, md, match_state::player, match_state::pref_type, and match_state::string.

Referenced by parse_boolexp_L(), and promote_match().

00578 {
00579     mstate->confidence = md.confidence;
00580     mstate->count = md.count;
00581     mstate->pref_type = md.pref_type;
00582     mstate->check_keys = md.check_keys;
00583     mstate->absolute_form = md.absolute_form;
00584     mstate->match = md.match;
00585     mstate->player = md.player;
00586     mstate->string = alloc_lbuf("save_match_state");
00587     strcpy(mstate->string, md.string);
00588 }


Variable Documentation

const char* AMBIGUOUS_MESSAGE = "I don't know which one you mean!"

Definition at line 18 of file match.cpp.

Referenced by match_status().

const char* FUNC_AMBIGUOUS = "#-2 AMBIGUOUS"

Definition at line 24 of file match.cpp.

const char* FUNC_FAIL_MESSAGE = "#-1"

Definition at line 20 of file match.cpp.

const char* FUNC_NOMATCH_MESSAGE = "#-1 NO MATCH"

Definition at line 21 of file match.cpp.

const char* FUNC_NOPERM_MESSAGE = "#-1 PERMISSION DENIED"

Definition at line 25 of file match.cpp.

const char* FUNC_NOT_FOUND = "#-1 NOT FOUND"

Definition at line 23 of file match.cpp.

MSTATE md [static]

Definition at line 34 of file match.cpp.

Referenced by absolute_name(), init_match(), init_match_check_keys(), last_match_result(), match(), match_absolute(), match_carried_exit(), match_carried_exit_with_parents(), match_everything(), match_exit(), match_exit_internal(), match_exit_with_parents(), match_here(), match_home(), match_list(), match_master_exit(), match_me(), match_neighbor(), match_numeric(), match_player(), match_possession(), match_ref(), match_result(), match_zone_exit(), noisy_match_result(), promote_match(), restore_match_state(), and save_match_state().

const char* NOMATCH_MESSAGE = "I don't see that here."

Definition at line 17 of file match.cpp.

Referenced by do_examine(), do_function(), do_prog(), look_simple(), and match_status().

const char* NOPERM_MESSAGE = "Permission denied."

Definition at line 19 of file match.cpp.

Referenced by CF_HAND(), cf_set(), create_obj(), do_addcommand(), do_alias(), do_boot(), do_cemit(), do_channelwho(), do_cheader(), do_chopen(), do_chown(), do_clone(), do_createchannel(), do_delcommand(), do_destroychannel(), do_doing(), do_drop(), do_editchannel(), do_enter(), do_enter_internal(), do_examine(), do_forwardlist(), do_function(), do_get(), do_halt(), do_last(), do_link(), do_lock(), do_notify(), do_parent(), do_pemit_single(), do_prog(), do_ps(), do_quitprog(), do_quota(), do_restart(), do_set(), do_shutdown(), do_teleport_single(), do_trigger(), do_unlink(), do_unlock(), do_wait(), flag_set(), FUNCTION(), get_stats(), give_thing(), link_exit(), match_controlled_handler(), match_status(), open_exit(), power_set(), process_cmdent(), process_command(), and set_attr_internal().

const char* OUT_OF_RANGE = "#-1 OUT OF RANGE"

Definition at line 22 of file match.cpp.


Generated on Mon May 28 04:40:20 2007 for MUX by  doxygen 1.4.7