/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/function/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
#ifndef PROCESS_H
#define PROCESS_H

/***************************************************************************/
/* process_msg */

/*
 *  This fn uses the efun process_string()
 *
 *  Process_string(str) allows you to call a function that returns a string.
 *  It has the form, 
 *        "@@function:filename|arg1|arg2...@@"
 *
 *  However, its form only allows specific object names. To be more useful
 *  it needs to be able to accept 'this_player(), this_object()' etc.
 *
 *
 *  Example:
 *   say(process_msg("@@query_name:$this_player()$@@ casts a fireball!\n"));
 *
 *  Now this may seem trivial, why not just say,
 *  say(this_player()->query_name()+" casts a fireball!\n");
 *
 *  The thing is that it can be used in strings of configurable objects!
 */
 

string process_msg(string str) {
  string obj_file, tmp1, tmp2, tmp3;

  if(!str) return "";

  if(this_object()) {
    obj_file = file_name(this_object());
    while(sscanf(str,"%s$this_object()$%s", tmp1, tmp2)) {
      str = tmp1 + obj_file + tmp2;
    }
  }

  if(this_player()) {
    obj_file = file_name(this_player());
    while(sscanf(str,"%s$this_player()$%s", tmp1, tmp2)) {
      str = tmp1 + obj_file + tmp2;
    }
  }

  if(previous_object()) {
    obj_file = file_name(previous_object());
    while(sscanf(str,"%s$previous_object()$%s", tmp1, tmp2)) {
      str = tmp1 + obj_file + tmp2;
    }
  }

  if(environment()) {
    obj_file = file_name(environment());
    while(sscanf(str,"%s$environment()$%s", tmp1, tmp2)) {
      str = tmp1 + obj_file + tmp2;
    }
  }

  if(environment(this_player())) {
    obj_file = file_name(environment(this_player()));
    while(sscanf(str,"%s$environment(this_player())$%s", tmp1, tmp2)) {
      str = tmp1 + obj_file + tmp2;
    }
  }
  str = process_string(str);

/* filter out failed processes - so players don't see them */

  while(sscanf(str,"%s@@%s@@%s", tmp1, tmp2, tmp3)) {
    str = tmp1 + tmp3;
  }
  return str;
}


#endif /* PROCESS_H */