示例#1
0
文件: pager.c 项目: abzde/dock9
varargs int page(string data, string title, function callback, int no_ansi)
{
    if(!stringp(data)) return 0;
    if(stringp(title)) write("*===| Paging: " + title + " |===*\n\n");
    if(functionp(callback)) cb = callback;
    if(no_ansi) ansi = 0;
    currentLine = 0;

    if(!this_player()->query_env("morelines"))
	myLinesPerCycle = DEF_LINESPERCYCLE;
    else
	myLinesPerCycle = to_int(this_player()->query_env("morelines"));

    linesPerCycle = myLinesPerCycle - 1;

    exploded = explode(data, "\n");
    totalLines = sizeof(exploded);
    page_more();
}
示例#2
0
/*
    Description:
      Prove knowledge of some secret.
    Parameters:
         ( mixed secret, closure cl, mixed extra )
      or ( mixed secret, object ob,  string func, mixed extra )

      secret - something you want to prove knowledge of
      cl     - a closure
      ob     - an object in which to call func
      func   - a function to call in ob
      extra  - an extra parameter to pass

      Depending on which form is used, one of these will be done:
            ob->func( hash, extra )
        or  funcall( hash, extra )
      where hash is the hash value of the secret: hash( secret )

    Returns:
      The return value of the call/eval.
    Notes:
      None.
*/
varargs mixed
prove( mixed val, mixed ob_or_cl, mixed func_or_extra, mixed extra )
{
  if( closurep( ob_or_cl ) )
    return funcall( (closure) ob_or_cl, hash( val ), func_or_extra );
  if( !objectp( ob_or_cl ) || !stringp( func_or_extra ))
    return 0;
  return call_other( (object) ob_or_cl, (string) func_or_extra, 
                     hash( val ), extra );
}
示例#3
0
static void
_stop_listen(string channel, object ob)
{
    if(!channel || !stringp(channel))
	return;

    if(channels[channel])
	m_delkey(channels[channel], ob);
    if (listeners[ob])
	listeners[ob] -= ({channel});
示例#4
0
文件: bboard.c 项目: cosin/XYJ
void setup()
{
	string loc;

	if( stringp(loc = query("location")) )
		move(loc);
	set("no_get", 1);
	seteuid(getuid());
	restore();
}
示例#5
0
文件: climb.c 项目: arylwen/terebi
mixed can_climb_obj() { 
    if( this_player()->GetParalyzed() ) {
        return "You cannot do anything!";
    }
    if(this_player()->GetPosition() != POSITION_STANDING ) {
        return "You must be standing in order to climb.";
    }
    if(!stringp(hobbled(this_player()))) return "Your injuries prevent that movement.";
    return this_player()->CanManipulate();
}
示例#6
0
文件: quest.c 项目: mudchina/nitan3
// 任务的名字
varargs string name()
{
        if (stringp(quest_name))
                return quest_name;

        if (functionp(quest_name))
                return evaluate(quest_name);

        return "未名任务";
}
示例#7
0
varargs nomask mixed
sort_array(mixed arr, mixed lfunc, object obj)
{
    if (stringp(lfunc)) {
	if (!obj)
	    obj = previous_object();
	lfunc = mkfunction(lfunc, obj);
    }
    return sort(arr, lfunc);
}
示例#8
0
void _tarn_turn_on(object pl,string txt,int gen)
{
  if (!objectp(pl)||!interactive(pl)) return WEG();
  if (!stringp(txt)||txt=="") return WEG();
  if (gen<0||gen>2) return WEG();
  player=pl;
  desc=capitalize(txt);
  gender=gen;
  shadow(pl,1);
}
示例#9
0
int save()
{
	string file;

	if( stringp(file = this_object()->query_save_file()) ) {
		assure_file(file+ __SAVE_EXTENSION__);
		return save_object(file);
	}
	return 0;
}
示例#10
0
string relative_name(mixed ob) {
    string * path;
    if (objectp(ob)) 
	path = explode(file_name(ob),"/");
    else if (stringp(ob)) 
	path = explode(ob,"/");
    else 
	error("Object or array expected.\n"); 
    return path[sizeof(path)-1];
}
示例#11
0
int scribe_spell(object me, object ob, string spell)
{
   string file;

   if( !stringp(file = (string)this_object()->scribe_spell_file(spell))
   ||   file_size(file + ".c") <= 0 )
     return 0;

   return (int)call_other( file, "scribe", me, ob );
}
示例#12
0
string query_look() {
   if( stringp(query_message()) )
// Gpfault:  Reading is supposed to cost readiness
// don't let players get the text for free by looking
//      return ::query_look() + "\n\n" + "~CTITThe sign reads~CDEF:\n\n" + query_message();

      return "It's a simple sign post, made of a flat piece of wood bound by leather strips to a post. It has been painted ~CWRNRED~CDEF.\n\nOwned by $(OWNER)." + "\n\nThe sign has writing on it.  Try ~CCOMread~CDEFing it.";
   else
      return "It's a simple sign post, made of a flat piece of wood bound by leather strips to a post. It has been painted ~CWRNRED~CDEF.\n\nOwned by $(OWNER)." + "\n\nThe sign is blank.";
}
示例#13
0
文件: tail.c 项目: BrewerGit/ldmud
varargs int tail(string file)
{
    if (extern_call())
        set_this_object(previous_object());

    if (!stringp(file) || !this_player())
        return 0;
    string txt = read_bytes(file, -(TAIL_MAX_BYTES + 80), (TAIL_MAX_BYTES + 80));
    if (!stringp(txt))
        return 0;

    // cut off first (incomplete) line
    int index = strstr(txt, "\n");
    if (index > -1) {
        if (index + 1 < strlen(txt))
            txt = txt[index+1..];
        else
            txt = "";
    }
示例#14
0
文件: wear.c 项目: huangleon/fy2005
int do_wear(object me, object ob)
{
	string str;

	if( ob->query("female_only")
	&&	(string)me->query("gender") != "��" )
		return notify_fail("����Ů�˵����Σ���һ��������Ҳ�봩������Ҳ���ߣ�\n");

	if( ob->query("male_only")
	&&	(string)me->query("gender") == "��" )
		return notify_fail("���Ǵ����˵������һ��Ů��Ҳ�봩�����������˰ɣ�\n");

	if (userp(me)) {
		if (ob->query("level_required"))
		if (ob->query("level_required") > F_LEVEL->get_level(me->query("combat_exp")))
			return notify_fail("���ʵս����ȼ�̫�ͣ������ܴ����������"
				+ ob->query("level_required")+"����\n");
		
		if (ob->query("strength"))
		if (ob->query("strength")>me->query("str"))
			return notify_fail("�㲻��ǿ׳�����ʺϴ�������ס�\n");
		
		if (ob->query("agility"))
		if (ob->query("agility")>me->query("agi"))
			return notify_fail("�㲻�����ݣ�����������׻�ٲ�ά��ġ�\n");	
	}
		
	if( ob->wear() ) {
		if( !stringp(str = ob->query("wear_msg")) )
			switch( ob->query("armor_type") ) {
				case "cloth":
				case "armor":
				case "boots":
					str = YEL "$N����һ" + ob->query("unit") + "$n��\n" NOR;
					break;
				case "head":
				case "neck":
				case "wrists":
				case "finger":
				case "hands":
					str = YEL "$N����һ" + ob->query("unit") + "$n��\n" NOR;
					break;
				case "waist":
					str = YEL "$N��һ" + ob->query("unit") + "$n"YEL"�������䡣\n" NOR;
					break;
				default:
					str = YEL "$Nװ��$n��\n" NOR;
			}
//		message_vision(str, me, ob);
		me->set_temp("timer/switch_equip",time());
		F_EQUIP->selective_message(str,me,ob,"equip_msg");
		return 1;
	} else
		return 0;
}
示例#15
0
// ### logical-namestring-p object => generalized-boolean
Value SYS_logical_namestring_p(Value arg)
{
  if (!(stringp(arg)))
    return NIL;
  AbstractString * host = get_host_string(the_string(arg));
  if (host == NULL || host->length() == 0)
    return NIL;
  if (LOGICAL_PATHNAME_TRANSLATION_TABLE->get(make_value(host)) != NULL_VALUE)
    return T;
  return NIL;
}
示例#16
0
文件: practice.c 项目: cosin/XYJ
int main(object me, string arg)
{
	string skillname;
	int skill, skill_basic;

	seteuid(getuid());

	if( environment(me)->query("no_fight") || 
		environment(me)->query("no_magic") )
		   return notify_fail("这里不是练功的地方。\n");

	if( me->is_fighting() )
		return notify_fail("你已经在战斗中了,学一点实战经验吧。\n");

	if( me->is_busy() )
		return notify_fail("你现在很忙,不能练习。\n");

	if( !arg ) return (__DIR__"enable")->main(me, arg);

	if( !stringp(skillname = me->query_skill_mapped(arg)) )
		return notify_fail("你只能练习用 enable 指定的特殊技能。\n");

	skill_basic = me->query_skill(arg, 1);
	skill = me->query_skill(skillname, 1);

	if( skill < 1 )
		return notify_fail("你好像还没「学会」这项技能吧?最好先去请教别人。\n");
	if( skill_basic < 1 )
		return notify_fail("你对这方面的技能还是一窍不通,最好从先从基本学起。\n");

	if( skill*skill*skill/10 > (int)me->query("combat_exp") )
		return notify_fail("你的武学修为还没到这个境界,练得再多也没用。\n");
	//note, if a magic skill can also be practiced...need change this.

	notify_fail("你现在不能练习这项技能。\n");
	if( !SKILL_D(skillname)->valid_learn(me) ) return 0;

	// mon 10/19/98
	if(MISC_D->random_capture(me,20000,0)) return 1;

	notify_fail("你试着练习" + to_chinese(skillname) + ",但是并没有任何进步。\n");

        //added by mon. 7/24/97
	if(skill_basic <= skill && random(100)==0)
	  write("你的" + to_chinese(skillname)+ 
            "很难提高了,还是向你师父请教请教吧!\n");

	if( SKILL_D(skillname)->practice_skill(me) ) {
		me->improve_skill(skillname, skill_basic/5 +1, skill_basic > skill? 0: 1);
		write( HIY "你的" + to_chinese(skillname) + "进步了!\n" NOR);
		return 1;
	}
	else return 0;
}
示例#17
0
文件: privs.c 项目: Lundex/lima
void main(mixed input)
{
  mapping tmp;
  if(!stringp(input))
    input = "";
  tmp = SECURE_D->query_access_tree(evaluate_path(input), 0);
  printf("Read: %O\n", tmp[keys(tmp)[0]][0]);
  tmp = SECURE_D->query_access_tree(evaluate_path(input), 1);
  printf("Write: %O\n", tmp[keys(tmp)[0]][0]);
  return;
}
示例#18
0
文件: refs_d.c 项目: ehershey/pd
mixed resolv_ref( mixed a )
{
  mixed ret;
  string ref_d;
  if( !stringp( a ) ) return a;
  if( !sscanf( a, "#%s", ref_d ) ) return a;
// Nightmare does not support cwf
// if( ref_d == "#" ) return (string)this_player()-> query( "cwf" );
  if( undefinedp( ret = get_ref( ref_d ) ) ) return a;
  return ret;
}
示例#19
0
// Default chat function: Let the npc perform special action with 
// his/her enabled martial art
int perform_action(string action)
{
	object weapon;
	string martial_skill, act;

	if( sscanf(action, "%s.%s", martial_skill, act) != 2 )
		return 0;
	martial_skill = query_skill_mapped(martial_skill);
	if( stringp(martial_skill) )
		return SKILL_D(martial_skill)->perform_action(this_object(), act);		
}
示例#20
0
/* reversible explode string */
static string *rexplode(string str, string sep) {
   string dummy;
   string *result;

   argcheck(stringp(str), 1, "non empty string");
   argcheck(stringp(sep), 2, "non empty string");

   if (!strlen(sep)) {
      dummy = "!";
   } else {
      dummy = sep[0] != '!' ? "!" : "?";
   }

   str = dummy + str + dummy;
   result = explode(str, sep);
   result[0] = result[0][1..];
   result[sizeof(result) - 1] =
      result[sizeof(result) - 1][..strlen(result[sizeof(result) - 1]) - 2];
   return result;
}
示例#21
0
// ### fasl-sharp-illegal stream sub-char numarg => value
Value SYS_fasl_sharp_illegal(Value streamarg, Value subchar, Value numarg)
{
  Stream * stream = check_ansi_stream(streamarg);
  String * s = new String("Illegal # macro character: #\\");
  Value name = CL_char_name(subchar);
  if (stringp(name))
    s->append(the_string(name));
  else
    s->append_char(char_value(subchar));
  return signal_lisp_error(new ReaderError(stream, s));
}
示例#22
0
sexpr equalp (sexpr a, sexpr b)
{
    if (a == b) return sx_true;

    if (!pointerp(a) || !pointerp(b)) return sx_false;

    if ((stringp(a) && stringp(b)) || (symbolp(a) && symbolp(b)))
    {
        struct sexpr_string_or_symbol
                *sa = (struct sexpr_string_or_symbol *)sx_pointer(a),
                *sb = (struct sexpr_string_or_symbol *)sx_pointer(b);
        unsigned long i;

        return (str_hash(sa->character_data, &i) ==
                str_hash(sb->character_data, &i))
                ? sx_true : sx_false;
    }
    else if (consp(a) && consp(b))
    {
        return ((truep(equalp(car(a), car(b))) &&
                 truep(equalp(cdr(a), cdr(b))))) ?
                sx_true : sx_false;
    }
    else if (customp(a) && customp(b))
    {
        int type = sx_type (a);

        if (type == sx_type (b))
        {
            struct sexpr_type_descriptor *d = sx_get_descriptor (type);

            if ((d != (struct sexpr_type_descriptor *)0) &&
                (d->equalp != (void *)0))
            {
                return d->equalp (a, b);
            }
        }
    }

    return sx_false;
}
示例#23
0
文件: array.c 项目: mudchina/nitan3
int valid_learn(object me)
{
	if(!me)
		return 0;

	if( stringp(mp)
	&& !wizardp(me)
	&& (me->query("family/family_name") != mp) )
		return notify_fail("你不能学习这个阵法。\n");

	return 1;
}
示例#24
0
void nyx_get_label(unsigned int index,
                   double *start_time,
                   double *end_time,
                   const char **label)
{
   LVAL s = nyx_result;
   LVAL label_expr;
   LVAL t0_expr;
   LVAL t1_expr;
   LVAL str_expr;

   if (nyx_get_type(nyx_result) != nyx_labels) {
      return;
   }

   while (index) {
      index--;
      s = cdr(s);
      if (s == NULL) {
         // index was larger than number of labels
         return;
      }
   }

   /* We either have (t0 "label") or (t0 t1 "label") */

   label_expr = car(s);
   t0_expr = car(label_expr);
   t1_expr = car(cdr(label_expr));
   if (stringp(t1_expr)) {
      str_expr = t1_expr;
      t1_expr = t0_expr;
   }
   else {
      str_expr = car(cdr(cdr(label_expr)));
   }

   if (floatp(t0_expr)) {
      *start_time = getflonum(t0_expr);
   }
   else if (fixp(t0_expr)) {
      *start_time = (double)getfixnum(t0_expr);
   }

   if (floatp(t1_expr)) {
      *end_time = getflonum(t1_expr);
   }
   else if (fixp(t1_expr)) {
      *end_time = (double)getfixnum(t1_expr);
   }

   *label = (const char *)getstring(str_expr);
}
示例#25
0
int do_join(string arg)
{
	object me;

	me = this_player();
	if( stringp(me->query("class")) )
		return notify_fail("你已经参加了其他公会。\n");
	me->set("class", "fighter");
	me->set("startroom", CLASS_D("fighter") + "/guildhall");
	write("\n恭喜,从今天起您已经成为一名武者!\n\n");
	return 1;
}
示例#26
0
static void set_otlvar(string name, mixed value) {
  mapping vars;
  int save;

  argcheck(stringp(name), 1, "string");

  vars = DRIVER->get_tlvar(TLS_OVARS);

  if(!vars) {
    vars = ([ ]);
    save = 1;
  }
示例#27
0
int conjure_magic(object me, string spell, object target)
{
	string file;

	notify_fail("你所选用的法术系中没有这种法术。\n");

	if( !stringp(file = (string)this_object()->conjure_magic_file(spell))
	||	file_size(file + ".c") <= 0 )
		return 0;
	me->set_temp("kill_msg","conjure"+spell);
	return (int)call_other( file, "conjure", me, target);
}
示例#28
0
int cast_spell(object me, string spell, object target)
{
	string file;

//	notify_fail("你所选用的咒文系中没有这种咒文。\n");

	if( !stringp(file = (string)this_object()->cast_spell_file(spell))
	||	file_size(file + ".c") <= 0 )
		return 0;
	me->set_temp("kill_msg","cast_"+spell);
	return (int)call_other( file, "cast", me, target);
}
示例#29
0
文件: shop.c 项目: xxx/cdlib
/*
 * Function name: shop_hook_sell_no_sell
 * Description:   An object has the no sell prop set (OBJ_M_NO_SELL)
 * Arguments:	  ob  - The object
 *		  str - Set if object has an own not sell string
 */
void
shop_hook_sell_no_sell(object ob, string str)
{
    if (stringp(str))
    {
        notify_fail(str);
    }
    else
    {
        notify_fail("I don't want " + LANG_THESHORT(ob) + ".\n");
    }
}
示例#30
0
文件: wield.c 项目: mudchina/es2-utf8
int do_wield(object me, object ob)
{
	string str;

	if( ob->wield() ) {
		if( !stringp(str = ob->query("wield_msg")) )
			str = "$N装备$n作武器。\n";
		message_vision(str, me, ob);
		return 1;
	} else
		return 0;
}