src/match.h File Reference

#include "copyright.h"
#include "db.h"

Include dependency graph for match.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  match_state

Defines

#define NOMATCH_MESSAGE   "I don't see that here."
#define AMBIGUOUS_MESSAGE   "I don't know which one you mean!"
#define NOPERM_MESSAGE   "Permission denied."
#define MAT_NO_EXITS   1
#define MAT_EXIT_PARENTS   2
#define MAT_NUMERIC   4
#define MAT_HOME   8

Typedefs

typedef match_state MSTATE

Functions

void init_match (dbref, char *, int)
void init_match_check_keys (dbref, char *, int)
void match_player (void)
void match_absolute (void)
void match_numeric (void)
void match_me (void)
void match_here (void)
void match_home (void)
void match_possession (void)
void match_neighbor (void)
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_everything (int)
dbref match_result (void)
dbref last_match_result (void)
dbref match_status (dbref, dbref)
dbref noisy_match_result (void)
dbref dispatched_match_result (dbref)
int matched_locally (void)
void save_match_state (MSTATE *)
void restore_match_state (MSTATE *)
dbref match_controlled_quiet (dbref player, char *name)
void match_zone_exit (void)


Define Documentation

#define AMBIGUOUS_MESSAGE   "I don't know which one you mean!"

Definition at line 62 of file match.h.

Referenced by match_status().

#define MAT_EXIT_PARENTS   2

Definition at line 66 of file match.h.

Referenced by do_entrances(), do_examine(), do_lock(), do_setattr(), do_verb(), fun_locate(), fun_setlock(), match_affected(), match_controlled(), match_controlled_quiet(), match_everything(), match_examinable(), match_thing(), parse_attrib_wild(), parse_boolexp_L(), and parse_thing_slash().

#define MAT_HOME   8

Definition at line 68 of file match.h.

Referenced by match_everything(), and parse_linkable_room().

#define MAT_NO_EXITS   1

Definition at line 65 of file match.h.

Referenced by do_link(), match_everything(), and parse_linkable_room().

#define MAT_NUMERIC   4

Definition at line 67 of file match.h.

Referenced by match_everything(), and parse_linkable_room().

#define NOMATCH_MESSAGE   "I don't see that here."

Definition at line 61 of file match.h.

Referenced by match_status().

#define NOPERM_MESSAGE   "Permission denied."

Definition at line 63 of file match.h.

Referenced by match_status().


Typedef Documentation

typedef struct match_state MSTATE

Definition at line 13 of file match.h.


Function Documentation

dbref dispatched_match_result ( dbref   ) 

Definition at line 456 of file match.c.

References match_result(), and match_status().

00458 {
00459         return match_status(player, match_result());
00460 }

void init_match ( dbref  ,
char *  ,
int   
)

Definition at line 495 of file match.c.

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.

00496 {
00497         md.confidence = -1;
00498         md.count = md.check_keys = 0;
00499         md.pref_type = type;
00500         md.match = NOTHING;
00501         md.player = player;
00502         md.string = munge_space_for_match((char *) name);
00503         md.absolute_form = absolute_name(1);
00504 }

void init_match_check_keys ( dbref  ,
char *  ,
int   
)

Definition at line 506 of file match.c.

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

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

00507 {
00508         init_match(player, name, type);
00509         md.check_keys = 1;
00510 }

dbref last_match_result ( void   ) 

Definition at line 426 of file match.c.

References match_state::match, and md.

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

00427 {
00428         return md.match;
00429 }

void match_absolute ( void   ) 

Definition at line 170 of file match.c.

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

00171 {
00172         if(md.confidence >= CON_DBREF)
00173                 return;
00174         if(Good_obj(md.absolute_form))
00175                 promote_match(md.absolute_form, CON_DBREF);
00176 }

void match_carried_exit ( void   ) 

Definition at line 338 of file match.c.

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().

00339 {
00340         if(md.confidence >= CON_DBREF)
00341                 return;
00342         if(Good_obj(md.player) && Has_exits(md.player))
00343                 (void) match_exit_internal(md.player, md.player, CON_LOCAL);
00344 }

void match_carried_exit_with_parents ( void   ) 

Definition at line 346 of file match.c.

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

Referenced by fun_locate(), and match_everything().

00347 {
00348         dbref parent;
00349         int lev;
00350 
00351         if(md.confidence >= CON_DBREF)
00352                 return;
00353         if(Good_obj(md.player) && (Has_exits(md.player) || isRoom(md.player))) {
00354                 ITER_PARENTS(md.player, parent, lev) {
00355                         if(match_exit_internal(parent, md.player, CON_LOCAL))
00356                                 break;
00357                 }
00358         }
00359 }

dbref match_controlled_quiet ( dbref  player,
char *  name 
)

Definition at line 41 of file set.c.

References Controls, Good_obj, init_match(), MAT_EXIT_PARENTS, match_everything(), match_result(), NOTHING, and NOTYPE.

Referenced by do_destroy().

00042 {
00043         dbref mat;
00044 
00045         init_match(player, name, NOTYPE);
00046         match_everything(MAT_EXIT_PARENTS);
00047         mat = match_result();
00048         if(Good_obj(mat) && !Controls(player, mat)) {
00049                 return NOTHING;
00050         } else {
00051                 return (mat);
00052         }
00053 }

void match_everything ( int   ) 

Definition at line 378 of file match.c.

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_chanobj(), do_chzone(), do_clone(), do_entrances(), do_examine(), do_fixdb(), do_link(), do_lock(), do_notify(), do_parent(), do_pemit(), do_pemit_list(), do_setattr(), do_teleport(), do_unlink(), do_verb(), do_wait(), fun_locate(), fun_setlock(), match_affected(), match_controlled(), match_controlled_quiet(), match_examinable(), match_thing(), parse_attrib_wild(), parse_boolexp_L(), parse_linkable_room(), and parse_thing_slash().

00379 {
00380         /*
00381          * Try matching me, then here, then absolute, then player FIRST, since
00382          * this will hit most cases. STOP if we get something, since those are
00383          * exact matches.
00384          */
00385 
00386         match_me();
00387         match_here();
00388         match_absolute();
00389         if(key & MAT_NUMERIC)
00390                 match_numeric();
00391         if(key & MAT_HOME)
00392                 match_home();
00393         match_player();
00394         if(md.confidence >= CON_TOKEN)
00395                 return;
00396 
00397         if(!(key & MAT_NO_EXITS)) {
00398                 if(key & MAT_EXIT_PARENTS) {
00399                         match_carried_exit_with_parents();
00400                         match_exit_with_parents();
00401                 } else {
00402                         match_carried_exit();
00403                         match_exit();
00404                 }
00405         }
00406         match_neighbor();
00407         match_possession();
00408 }

void match_exit ( void   ) 

Definition at line 311 of file match.c.

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

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

00312 {
00313         dbref loc;
00314 
00315         if(md.confidence >= CON_DBREF)
00316                 return;
00317         loc = Location(md.player);
00318         if(Good_obj(md.player) && Has_location(md.player))
00319                 (void) match_exit_internal(loc, loc, CON_LOCAL);
00320 }

void match_exit_with_parents ( void   ) 

Definition at line 322 of file match.c.

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

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

00323 {
00324         dbref loc, parent;
00325         int lev;
00326 
00327         if(md.confidence >= CON_DBREF)
00328                 return;
00329         if(Good_obj(md.player) && Has_location(md.player)) {
00330                 loc = Location(md.player);
00331                 ITER_PARENTS(loc, parent, lev) {
00332                         if(match_exit_internal(parent, loc, CON_LOCAL))
00333                                 break;
00334                 }
00335         }
00336 }

void match_here ( void   ) 

Definition at line 211 of file match.c.

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

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

00212 {
00213         dbref loc;
00214 
00215         if(md.confidence >= CON_DBREF)
00216                 return;
00217         if(Good_obj(md.player) && Has_location(md.player)) {
00218                 loc = Location(md.player);
00219                 if(Good_obj(loc)) {
00220                         if(loc == md.absolute_form) {
00221                                 promote_match(loc, CON_DBREF | CON_LOCAL);
00222                         } else if(!string_compare(md.string, "here")) {
00223                                 promote_match(loc, CON_TOKEN | CON_LOCAL);
00224                         } else if(!string_compare(md.string, (char *) PureName(loc))) {
00225                                 promote_match(loc, CON_COMPLETE | CON_LOCAL);
00226                         }
00227                 }
00228         }
00229 }

void match_home ( void   ) 

Definition at line 202 of file match.c.

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

Referenced by match_everything().

00203 {
00204         if(md.confidence >= CON_DBREF)
00205                 return;
00206         if(!string_compare(md.string, "home"))
00207                 promote_match(HOME, CON_TOKEN);
00208         return;
00209 }

void match_master_exit ( void   ) 

Definition at line 361 of file match.c.

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().

00362 {
00363         if(md.confidence >= CON_DBREF)
00364                 return;
00365         if(Good_obj(md.player) && Has_exits(md.player))
00366                 (void) match_exit_internal(mudconf.master_room,
00367                                                                    mudconf.master_room, 0);
00368 }

void match_me ( void   ) 

Definition at line 189 of file match.c.

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(), fun_locate(), give_thing(), and match_everything().

00190 {
00191         if(md.confidence >= CON_DBREF)
00192                 return;
00193         if(Good_obj(md.absolute_form) && (md.absolute_form == md.player)) {
00194                 promote_match(md.player, CON_DBREF | CON_LOCAL);
00195                 return;
00196         }
00197         if(!string_compare(md.string, "me"))
00198                 promote_match(md.player, CON_TOKEN | CON_LOCAL);
00199         return;
00200 }

void match_neighbor ( void   ) 

Definition at line 266 of file match.c.

References CON_DBREF, CON_LOCAL, match_state::confidence, Contents, Good_obj, Has_location, loc, 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(), fun_locate(), match_everything(), and match_possessed().

00267 {
00268         dbref loc;
00269 
00270         if(md.confidence >= CON_DBREF)
00271                 return;
00272         if(Good_obj(md.player) && Has_location(md.player)) {
00273                 loc = Location(md.player);
00274                 if(Good_obj(loc)) {
00275                         match_list(Contents(loc), CON_LOCAL);
00276                 }
00277         }
00278 }

void match_numeric ( void   ) 

Definition at line 178 of file match.c.

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

Referenced by match_everything().

00179 {
00180         dbref match;
00181 
00182         if(md.confidence >= CON_DBREF)
00183                 return;
00184         match = absolute_name(0);
00185         if(Good_obj(match))
00186                 promote_match(match, CON_DBREF);
00187 }

void match_player ( void   ) 

Definition at line 125 of file match.c.

References match_state::absolute_form, CON_DBREF, CON_TOKEN, match_state::confidence, Good_obj, isPlayer, lookup_player(), LOOKUP_TOKEN, md, 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(), fun_locate(), and match_everything().

00126 {
00127         dbref match;
00128         char *p;
00129 
00130         if(md.confidence >= CON_DBREF) {
00131                 return;
00132         }
00133         if(Good_obj(md.absolute_form) && isPlayer(md.absolute_form)) {
00134                 promote_match(md.absolute_form, CON_DBREF);
00135                 return;
00136         }
00137         if(*md.string == LOOKUP_TOKEN) {
00138                 for(p = md.string + 1; isspace(*p); p++);
00139                 match = lookup_player(NOTHING, p, 1);
00140                 if(Good_obj(match)) {
00141                         promote_match(match, CON_TOKEN);
00142                 }
00143         }
00144 }

void match_possession ( void   ) 

Definition at line 258 of file match.c.

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(), fun_locate(), give_thing(), match_everything(), and match_possessed().

00259 {
00260         if(md.confidence >= CON_DBREF)
00261                 return;
00262         if(Good_obj(md.player) && Has_contents(md.player))
00263                 match_list(Contents(md.player), CON_LOCAL);
00264 }

dbref match_result ( void   ) 

Definition at line 410 of file match.c.

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

00411 {
00412         switch (md.count) {
00413         case 0:
00414                 return NOTHING;
00415         case 1:
00416                 return md.match;
00417         default:
00418                 return AMBIGUOUS;
00419         }
00420 }

dbref match_status ( dbref  ,
dbref   
)

Definition at line 431 of file match.c.

References AMBIGUOUS, AMBIGUOUS_MESSAGE, Builder, Dark, Good_obj, match_status(), NOMATCH_MESSAGE, NOPERM, NOPERM_MESSAGE, NOTHING, notify, Owner, and WizRoy.

Referenced by dispatched_match_result(), do_destroy(), do_get(), do_look(), fun_locate(), match_status(), and noisy_match_result().

00433 {
00434         switch (match) {
00435         case NOTHING:
00436                 notify(player, NOMATCH_MESSAGE);
00437                 return NOTHING;
00438         case AMBIGUOUS:
00439                 notify(player, AMBIGUOUS_MESSAGE);
00440                 return NOTHING;
00441         case NOPERM:
00442                 notify(player, NOPERM_MESSAGE);
00443                 return NOTHING;
00444         }
00445         if(Good_obj(match) && Dark(match) && Good_obj(player) &&
00446            !WizRoy(Owner(player)) && !Builder(Owner(player)))
00447                 return match_status(player, NOTHING);
00448         return match;
00449 }

void match_zone_exit ( void   ) 

Definition at line 370 of file match.c.

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

Referenced by process_command().

00371 {
00372         if(md.confidence >= CON_DBREF)
00373                 return;
00374         if(Good_obj(md.player) && Has_exits(md.player))
00375                 (void) match_exit_internal(Zone(md.player), Zone(md.player), 0);
00376 }

int matched_locally ( void   ) 

Definition at line 462 of file match.c.

References CON_LOCAL, match_state::confidence, and md.

00463 {
00464         return (md.confidence & CON_LOCAL);
00465 }

dbref noisy_match_result ( void   ) 

Definition at line 451 of file match.c.

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

Referenced by do_boot(), do_chownall(), do_chzone(), do_clone(), 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(), match_affected(), match_controlled(), match_examinable(), and match_thing().

00452 {
00453         return match_status(md.player, match_result());
00454 }

void restore_match_state ( MSTATE  ) 

Definition at line 481 of file match.c.

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, match_state::string, and StringCopy.

Referenced by parse_boolexp_L(), and promote_match().

00483 {
00484         md.confidence = mstate->confidence;
00485         md.count = mstate->count;
00486         md.pref_type = mstate->pref_type;
00487         md.check_keys = mstate->check_keys;
00488         md.absolute_form = mstate->absolute_form;
00489         md.match = mstate->match;
00490         md.player = mstate->player;
00491         StringCopy(md.string, mstate->string);
00492         free_lbuf(mstate->string);
00493 }

void save_match_state ( MSTATE  ) 

Definition at line 467 of file match.c.

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, match_state::string, and StringCopy.

Referenced by parse_boolexp_L(), and promote_match().

00469 {
00470         mstate->confidence = md.confidence;
00471         mstate->count = md.count;
00472         mstate->pref_type = md.pref_type;
00473         mstate->check_keys = md.check_keys;
00474         mstate->absolute_form = md.absolute_form;
00475         mstate->match = md.match;
00476         mstate->player = md.player;
00477         mstate->string = alloc_lbuf("save_match_state");
00478         StringCopy(mstate->string, md.string);
00479 }


Generated on Mon May 28 04:25:46 2007 for BattletechMUX by  doxygen 1.4.7