当前位置: 首页>>代码示例>>C++>>正文


C++ environment函数代码示例

本文整理汇总了C++中environment函数的典型用法代码示例。如果您正苦于以下问题:C++ environment函数的具体用法?C++ environment怎么用?C++ environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了environment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: evalcommand


//.........这里部分代码省略.........
					argc--;
				}
				cmd_flags |= DO_NOFUNC;
				bltinonly = 0;
			} else
				break;
		}
		/*
		 * Special builtins lose their special properties when
		 * called via 'command'.
		 */
		if (cmd_flags & DO_NOFUNC)
			cmdentry.special = 0;
	}

	/* Fork off a child process if necessary. */
	if (((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN)
	    && ((flags & EV_EXIT) == 0 || have_traps()))
	 || ((flags & EV_BACKCMD) != 0
	    && (cmdentry.cmdtype != CMDBUILTIN ||
		 !safe_builtin(cmdentry.u.index, argc, argv)))) {
		jp = makejob(cmd, 1);
		mode = FORK_FG;
		if (flags & EV_BACKCMD) {
			mode = FORK_NOJOB;
			if (pipe(pip) < 0)
				error("Pipe call failed: %s", strerror(errno));
		}
		if (cmdentry.cmdtype == CMDNORMAL &&
		    cmd->ncmd.redirect == NULL &&
		    varlist.count == 0 &&
		    (mode == FORK_FG || mode == FORK_NOJOB) &&
		    !disvforkset() && !iflag && !mflag) {
			vforkexecshell(jp, argv, environment(), path,
			    cmdentry.u.index, flags & EV_BACKCMD ? pip : NULL);
			goto parent;
		}
		if (forkshell(jp, cmd, mode) != 0)
			goto parent;	/* at end of routine */
		if (flags & EV_BACKCMD) {
			FORCEINTON;
			close(pip[0]);
			if (pip[1] != 1) {
				dup2(pip[1], 1);
				close(pip[1]);
			}
			flags &= ~EV_BACKCMD;
		}
		flags |= EV_EXIT;
	}

	/* This is the child process if a fork occurred. */
	/* Execute the command. */
	if (cmdentry.cmdtype == CMDFUNCTION) {
#ifdef DEBUG
		trputs("Shell function:  ");  trargs(argv);
#endif
		saveparam = shellparam;
		shellparam.malloc = 0;
		shellparam.reset = 1;
		shellparam.nparam = argc - 1;
		shellparam.p = argv + 1;
		shellparam.optp = NULL;
		shellparam.optnext = NULL;
		INTOFF;
		savelocalvars = localvars;
开发者ID:FrauBSD,项目名称:FrauBSD,代码行数:67,代码来源:eval.c

示例2: time

    	me->set("timer/pfm/hs_chunxin", time());
		
		// + 200 force for everyone, self = +100
		me->add_temp("pfm/free_perform",1);
		   		
    	msg = HIG"
残雪斑驳,小草吐翠,柳絮轻扬,香山春信匆匆。$N纤指三扣,燕燕轻盈,莺莺
娇软,是耶非耶?是真是幻?曼妙的舞姿,伴着轻柔的歌声:笑江梅、雪里开迟。
香风轻度,翠叶柔枝。与玉郎摘,美人戴,总相宜。。。。\n"NOR;

		message_vision(msg, me);
		
		team1 = me->query_team();
		if (!team1 || sizeof(team1)<2)	team1 = ({ me });
		    		
		team = filter_array(team1,(: present($1,environment($2)) :),me);
		num = sizeof(team);	
		for (i=0; i<num; i++) {
			if (team[i]->query("force") < team[i]->query("max_force")*2) {	
				if (team[i]->query("force") + cloud < team[i]->query("max_force") *2)
					team[i]->add("force",cloud);			
	    	} else
	    		team[i]->set("force", team[i]->query("max_force")*2);
	    	team[i]->force_status_msg("force");
	    	tell_object( team[i],YEL"生机渐盎,如春临大地,一股氤氲之气,缓缓流过你奇经八脉。\n"NOR);
    	}
    	
    	buff =
		([
			"caster":me,
			"who":	 me,
开发者ID:huangleon,项目名称:fy2005,代码行数:31,代码来源:chunxin.c

示例3: start

int start() {
    this_object()->move("/d/citrin/rooms/shack1");
    message("", "One of the many forest guardians enters.", environment(this_object()));
    call_out("a", 3);
    return 1;
}
开发者ID:ehershey,项目名称:pd,代码行数:6,代码来源:guardian.c

示例4: tobe

int tobe(object me,object target,object weapon, object room)
{
	string msg;
	int hit_damage, damage, rate, stage, crit;
	
	if (!me)	return 1;
		
	if(!target || environment(target)!=environment(me)
		|| room!= environment(me)) 
	{
		tell_object(me, WHT"真可惜,你要刺杀的目标溜走了。\n"NOR);	
		return 1;
	}
	
	if (me->query_temp("last_damage_from") || me->query_temp("is_unconcious"))
		return 1;
		
	if(target->is_fighting(me) || target->query_max_hate()== me) {
		tell_object(me, "战斗中无法使用荆轲刺秦!\n");
		return 1;
	}
	
	if (target->is_corpse()) {
		tell_object(me, "他已经没气啦!\n");
		return 1;
	}	
	
	if(!present(weapon,me) || weapon->query("equipped")!="wielded"){
		tell_object(me, WHT"手软了?你怎么把武器收起来了? \n"NOR);
		return 1;
	}
		
	msg = YEL "\n$N跃身而起,手中"+weapon->query("name")+YEL"一转,带起阵阵风雷之声。\n$N手一抖," + weapon->query("name") + YEL"脱手飞出,如风卷黄沙呼啸着击向$n。 \n"NOR;
	message_vision(msg, me, target);
	weapon->move(environment(me));
	
	rate = 80;

    stage = F_LEVEL->get_level(me->query("combat_exp"));	 
    if (stage >= 105 )   		rate = 100;				// 6.6 M
	else if (stage >=95)		rate = 90;				// 5.6 M

		
	// 150*3 + 100 = 550
	// 485*3 + 100 = 1555; 1555*1.5= 2332 average
	// 150*3 + 100 = 550, 485*3 + 100 = 1555
	// Players can reach skill cap @4.6M, so we use hard code to limit it
	//  @4.6M 左右, 1088*1.5 = 1632
	//	1321* 1.5 = 1982 dmg @ 5.6M+
	//  1555* 1.5 = 2332 dmg @ 6.6M + 

	
	hit_damage = 100 + me->query_skill("hammer") * 3*  rate/100;
	hit_damage = hit_damage * (F_ABILITY->check_ability(me,"bolang2_add")*2 + 100)/100;

	// inherently 2% critical chance
	if (F_ABILITY->check_ability(me,"bolang1_add")+2 > random(100)) {
		hit_damage = hit_damage *2;
		crit = 1;
	}
		
	if (COMBAT_D->do_busy_attack(me, target, "assassin-hammer/bolangyiji","unarmed", 500, 10)
		|| ANNIE_D->check_buff(me,"assassinate"))
	{
		damage = hit_damage + random(hit_damage);	
		
		if (ANNIE_D->check_buff(me,"assassinate"))
			damage = hit_damage *2;
			
		damage = COMBAT_D->magic_modifier(me, target, "kee", damage);
		if (damage >= hit_damage *3/2)
			msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HIR"的头部!\n"NOR;
		else
			msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HIR"的胸口!\n"NOR;
		
		if (crit)
			msg = HBRED+HIW"只见" +weapon->query("name")
			+ HBRED+HIW"带着一阵低啸和猛烈的劲风“轰”地击中了$n"HBRED+HIW"的眉心!\n"NOR;	
		message_vision(msg, me, target);
		target->receive_damage("kee",damage, me);
		target->set("eff_kee",target->query("kee"));
		COMBAT_D->report_status(target);		
	}else 
	{
		msg = HIR"只见" +weapon->query("name")+ HIR"带着一阵劲风贴着$n"HIR"的脑袋飞过,只差几寸没有击中!\n"NOR;
		message_vision(msg, me, target);
	}
	target->kill_ob(me);
    	me->kill_ob(target);
	me->stop_busy();
	return 1;
}
开发者ID:huangleon,项目名称:fy2005,代码行数:92,代码来源:jingkeciqin.c

示例5: curse

int curse(object me, object target)
{
	int skill, i, mod, duration;
	int time;
	object* inv;

	if( me->query("class") != "wolfmount" ) {
		return notify_fail("只有狼山弟子才能使用『摄心咒』\n");
	}
	skill = me->query_skill("wolf-curse", 1);	
	if( (skill < 200 || me->query_skill("cursism", 1) < 200) && userp(me) || me->query_skill("summonwolf", 1) < 260 ) {
		return notify_fail("『摄心咒』需要200级天狼血咒和降头术,260级唤狼术!\n");
	}
	// duration = 5mins.
	duration = me->query("timer/pfm/wm_mindcurse") + 300 - time();
	if( duration > 0 ) {
		return notify_fail("『摄心咒』极耗元神,需要"+duration+"秒钟后才能再次运用。\n");
	}
	if( !target ) {
		target = offensive_target(me);
	}
	if( !target || !target->is_character() || !me->is_fighting(target) ) {
		return notify_fail("『摄心咒』只能对战斗中的对手使用。\n");
	}
	if( target->query_temp("mesmerize") || target->is_busy() ) {
		return notify_fail("对方已经在失魂落魄或忙乱中了,快抓紧时间进攻吧。\n");
	}
	mod = COMBAT_D->can_busy(me, target, "wolf-curse");	
	if( !mod ) {
		return notify_fail(HIW"此人功力深湛,不会被此咒法摄魂的。\n"NOR);
	}

	if( userp(target) ) {
		time = 10;
	} else {
		time = 10 + F_ABILITY->check_ability(me, "3_shexin_add", 3) * 2;
	}
	// Mesmerize timer, 无论成败都出现
	me->set("timer/pfm/wm_mindcurse", time());
	target->set_temp("busy_timer/wolf-curse", time());
	message_vision(HIB"\n$N突然发出沁人毛髓的啸叫,如同发狂的猛兽般欺身扑向$n!\n\n" NOR, me, target);

	// Quite high rate of success
	if( COMBAT_D->do_busy_attack(me, target, "wolf-curse/mindcurse", "step", 300, mod) ) {
		message("vision",HIR""+me->name()+HIR"的眼睛突然现出一片腥红之色,"+target->name()+HIR"的眼神与之一碰,当即呆立当场!\n"NOR, environment(me), ({target,me}));
开发者ID:huangleon,项目名称:fy2005,代码行数:45,代码来源:mindcurse.c

示例6: main

int main (object me,string arg)
{
  object can;
  mapping my;

  seteuid(getuid(me));
 
  if (!arg) return help(me);
  if (!objectp(can=present(arg,me))&&
      !objectp(can=present(arg,environment(me))))
    return help(me);

  my = can->query("液体");

  // 可以在容器上头设定额外函数
  if (can->query("液体/额外函数")) return 1;

  if( !can->query("液体/剩") ) {
    if (stringp(can->query("液体/名称")))
      printf ("%s的%s已经被喝光了。\n",can->name(),can->query("液体/名称"));
    else
      printf ("%s是空的。\n",can->name());
    return 1;
  }

  if (me->query("water") >= me->max_water_capacity()) {
    write ("你已经喝太多了,再也灌不下一滴水了。\n");
    return 1;
  }

  can->add("液体/剩",-1);
  
  // 可以在容器上头设定饮用讯息 by ACKY
  if( !can->query("液体/饮用讯息") )
	message_vision ("$N把嘴巴对着" + can->name() + ", 咕噜噜地喝了几口" + can->query("液体/名称") + "。\n",me);

  if (!intp(can->query("液体/止渴")))
    me->add("water",10);
  else
    me->add("water",can->query("液体/止渴"));

  if ((int)me->query("water") > me->max_water_capacity())
    me->set("water",me->max_water_capacity());
  if (me->is_fighting()) me->start_busy(2);
  if (!can->query ("液体/剩")) {
    write ("你已经将" + can->name() + "里的" + can->query("液体/名称") +
           "喝得一滴也不剩了。\n");
    return 1;
  }

  if (can->query("get_poison"))
  {
    write ("糟了 ! 水里有毒 !\n");
    me->apply_condition (can->query("get_poison"),can->query("poison_power"));
  }

  switch(can->query("液体/种类")) {
    case "酒":
      me->apply_condition("drunk",
        (int)me->query_condition("drunk")
        + can->query("液体/酒精成份"));
      break;
  }

  return 1;
}
开发者ID:szhowardhuang,项目名称:fs2,代码行数:66,代码来源:drink.c

示例7: environment

/*! Get the origin of the trajectory.
 */
const StaBody*
ScenarioLoiteringTrajectory::centralBody() const
{
    return environment()->centralBody()->body();
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:7,代码来源:scenarioloitering.cpp

示例8: init

void init()
{
	object me = this_player();

	if( wizardp(me) && getuid(me)!="qfy ")
		message("vision", me->name()+"走了过来。\n", environment(me), ({me}));
开发者ID:heypnus,项目名称:xkx2001,代码行数:6,代码来源:workroom.c

示例9:

sta::StateVector
ScenarioLoiteringTrajectory::computeInitialStateVector() const
{
    return m_simulationParameters->initialStatePosition()->computeStateVector(environment()->centralBody()->body());
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:5,代码来源:scenarioloitering.cpp

示例10: out

/*! Propagate a loitering trajectory, filling the lists of sampleTimes
 *  and samples with the results of each step. Errors during propagation
 *  are indicated by setting the error flag in the PropagationFeedback
 *  object.
 *
 *  The return value of propagate is the final state after propagation
 *  is complete (i.e. the last entry in the samples list.)
 */
sta::StateVector
ScenarioLoiteringTrajectory::propagate(PropagationFeedback& propFeedback,
                                       const sta::StateVector& initialState,
                                       QList<double>& sampleTimes,
                                       QList<sta::StateVector>& samples)
{

    QTextStream out (stdout);

    double mu = centralBody()->mu();

    const ScenarioExtendedTimeline* timeline = simulationParameters()->timeline();

    // Creating the list of perturbations that will influence the propagation
    ScenarioSpaceVehicle* spacevehicle = dynamic_cast<ScenarioSpaceVehicle*>(this->parent()->parent());
    ScenarioProperties* vehicleproperties = spacevehicle->properties();

    QList<Perturbations*> perturbationsList = environment()->createListPerturbations(vehicleproperties);

    double timelineDuration = sta::daysToSecs(timeline->endTime() - timeline->startTime());
    double dt = trajectoryPropagation()->timeStep();

    if (dt == 0.0)
    {
        propFeedback.raiseError(QObject::tr("Time step is zero!"));
        return initialState;
    }

    // We don't output values at every integration step. Instead use the time step
    // from simulation parameters. The actual output step used will not necessarily
    // match the requested output step: the code below sets it to be an integer
    // multiple of the integration step.
    double requestedOutputTimeStep = simulationParameters()->timeline()->timeStep();
    double outputTimeStep;
    unsigned int outputRate;
    if (requestedOutputTimeStep < dt)
    {
        outputRate = 1;
        outputTimeStep = dt;
    }
    else
    {
        outputRate = (unsigned int) floor(requestedOutputTimeStep / dt + 0.5);
        outputTimeStep = outputRate * dt;
    }

    if (timelineDuration / outputTimeStep > MAX_OUTPUT_STEPS)
    {
        propFeedback.raiseError(QObject::tr("Number of propagation steps exceeds %1. Try increasing the simulation time step.").arg(MAX_OUTPUT_STEPS));
        return initialState;
    }

    // Calculate initial keplerian elements in case the propagator Two Body will be used
    sta::KeplerianElements foundKeplerianElements = cartesianTOorbital(mu, initialState);

    double sma            = foundKeplerianElements.SemimajorAxis;
    double e              = foundKeplerianElements.Eccentricity;
    double inclination    = foundKeplerianElements.Inclination;
    double raan           = foundKeplerianElements.AscendingNode;
    double argOfPeriapsis = foundKeplerianElements.ArgumentOfPeriapsis;
    double meanAnomaly    = foundKeplerianElements.MeanAnomaly;

    double perigee = sma * (1-e);

    if (perigee<centralBody()->meanRadius())
    {
        QMessageBox::warning(NULL, QObject::tr("The trajectory has been not propagated"),
                             QObject::tr("The perigee distance is smaller than the main body radius."));
        return initialState.zero();
    }

    sta::StateVector stateVector = initialState;

    // deviation, reference, and q will be used only in Encke propagation
    sta::StateVector deviation(Vector3d::Zero(), Vector3d::Zero());
    sta::StateVector reference = initialState;
    double q = 0.0;

    sampleTimes << timeline->startTime();
    samples << stateVector;

    double time = timeline->startTime(); //mjd
    QFile ciccio("data/PerturbationsData.stae");
    QTextStream cicciostream(&ciccio);
    ciccio.open(QIODevice::WriteOnly);

    unsigned int steps = 0;
    for (double t = dt; t < timelineDuration + dt; t += dt)
    {
        JulianDate jd = timeline->startTime() + sta::secsToDays(t);

        // Choosing the propagator and propagating the trajectory
//.........这里部分代码省略.........
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:101,代码来源:scenarioloitering.cpp

示例11: endCallback

void endCallback(object who) {
    if( who ) {
        send_messages("", "The %^BOLD%^CYAN%^magical shield%^RESET%^ around "
          "$agent_name shatters into nothingness.", who, 0, environment(who), 0);
    }
}
开发者ID:arylwen,项目名称:terebi,代码行数:6,代码来源:buffer.c

示例12: implode

         tmp += words[i];
         if( ob = present(tmp, this_player()) ) {
             if( i == maxi - 1 ) text = "";
             else text = implode(words[i+1..], " ");
             break;
         }
         if( (env=environment(this_player())) && ob = present(tmp, env) ) {
             if( i == maxi - 1 ) text = "";
             else text = implode(words[i+1..], " ");
             break;
         }
         tmp += " ";
     }
 }
 else text = "";
 ob = (ob || environment(this_player()));
 if( text != "" ) {
     if( ob ) {
         tmp = (string)this_player()->GetCapName() + " reports praise in: " +
         identify(ob) + "\non " + ctime(time()) + "\n";
         secondary = GetCreator(ob);
     }
     else 
         tmp = (string)this_player()->GetCapName() + " reports praise on: " +
         ctime(time()) + ":\n";
     log_file("praise", tmp + text + "\n\n");
     if( secondary ) log_file("reports/" + secondary, tmp + text + "\n\n");
     message("system", "Praise reported!!! Thank you!!!", this_player());
     return 1;
 }
 rm( file = DIR_TMP "/" + (string)this_player()->GetKeyName() );
开发者ID:arylwen,项目名称:terebi,代码行数:31,代码来源:praise.c

示例13: main

int main(object me, string arg)
{
	object ob;
	mapping skill;
	int cost, my_skill;
	
    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() || me->query_temp("pending/exercising"))
                return notify_fail("你现在正忙着呢。\n");

	if(!arg || !objectp(ob = present(arg, me)) )
		return notify_fail("你要读什么?\n");

	if( !mapp(skill = ob->query("skill")) )
		return notify_fail("你无法从这样东西学到任何东西。\n");

	if( !me->query_skill("literate", 1) )
		return notify_fail("你是个文盲,先学学读书识字(literate)吧。\n");

	message("vision", me->name() + "正专心地研读" + ob->name()
		+ "。\n", environment(me), me);
  
        my_skill=me->query_skill(skill["name"],1);

	if ( (string)SKILL_D(skill["name"])->type()=="martial" )
	{
		if( my_skill*my_skill*my_skill/10>(int)me->query("combat_exp") || (int)me->query("combat_exp") < skill["exp_required"] )
		{ write("你的武学修为还没到这个境界,光读是没用的。\n");
		return 1; }
	}
	else if ( (string)SKILL_D(skill["name"])->type()=="magic" )
	{
		if( my_skill*my_skill*my_skill/10>(int)me->query("daoxing") || (int)me->query("daoxing") < skill["dx_required"] )
		{ write("你的道行还没到这个境界,光读是没用的。\n");
		return 1; }
	}

	notify_fail("以你目前的能力,还没有办法学这个技能。\n");
	if( !SKILL_D(skill["name"])->valid_learn(me) ) return 0;

	cost = skill["sen_cost"] + skill["sen_cost"] 
		* (skill["difficulty"] - (int)me->query_int())/20;

        if (cost < 5) cost = 5;

	if( (int)me->query("sen") < cost ) {
		write("你现在过于疲倦,无法专心下来研读新知。\n");
		return 1;
	}

	if( me->query_skill(skill["name"], 1) > skill["max_skill"] ) {
		write("你研读了一会儿,但是发现上面所说的对你而言都太浅了,没有学到任何东西。\n");
		return 1;
	}

	me->receive_damage("sen", cost);

	if( !me->query_skill(skill["name"], 1) )
		me->set_skill(skill["name"], 0);
	me->improve_skill(skill["name"], (int)me->query_skill("literate", 1)/5+1);
	write("你研读有关" + to_chinese(skill["name"]) + "的技巧,似乎有点心得。\n");
	return 1;
}
开发者ID:gongfuPanada,项目名称:xyj2006,代码行数:69,代码来源:study.c

示例14: evalcommand


//.........这里部分代码省略.........
		handler = savehandler;
		popredir();
		INTON;
		if (evalskip == SKIPFUNC) {
			evalskip = 0;
			skipcount = 0;
		}
		if (flags & EV_EXIT)
			exitshell(exitstatus);
	} else if (cmdentry.cmdtype == CMDBUILTIN) {
#ifdef DEBUG
		trputs("builtin command:  ");  trargs(argv);
#endif
		mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH;
		if (flags == EV_BACKCMD) {
			memout.nleft = 0;
			memout.nextc = memout.buf;
			memout.bufsize = 64;
			mode |= REDIR_BACKQ;
		}
		savecmdname = commandname;
		cmdenviron = varlist.list;
		e = -1;
		savehandler = handler;
		if (setjmp(jmploc.loc)) {
			e = exception;
			exitstatus = (e == EXINT)? SIGINT+128 : 2;
			goto cmddone;
		}
		handler = &jmploc;
		redirect(cmd->ncmd.redirect, mode);
		if (cmdentry.special)
			listsetvar(cmdenviron);
		commandname = argv[0];
		argptr = argv + 1;
		nextopt_optptr = NULL;		/* initialize nextopt */
		builtin_flags = flags;
		exitstatus = (*builtinfunc[cmdentry.u.index])(argc, argv);
		flushall();
cmddone:
		cmdenviron = NULL;
		out1 = &output;
		out2 = &errout;
		freestdout();
		if (e != EXSHELLPROC) {
			commandname = savecmdname;
			if (flags & EV_EXIT) {
				exitshell(exitstatus);
			}
		}
		handler = savehandler;
		if (e != -1) {
			if ((e != EXERROR && e != EXEXEC)
			    || cmdentry.special)
				exraise(e);
			FORCEINTON;
		}
		if (cmdentry.u.index != EXECCMD)
			popredir();
		if (flags == EV_BACKCMD) {
			backcmd->buf = memout.buf;
			backcmd->nleft = memout.nextc - memout.buf;
			memout.buf = NULL;
		}
	} else {
#ifdef DEBUG
		trputs("normal command:  ");  trargs(argv);
#endif
		clearredir();
		redirect(cmd->ncmd.redirect, 0);
		for (sp = varlist.list ; sp ; sp = sp->next)
			setvareq(sp->text, VEXPORT|VSTACK);
		envp = environment();
		shellexec(argv, envp, pathval(), cmdentry.u.index);
		/*NOTREACHED*/
	}
	goto out;

parent:	/* parent process gets here (if we forked) */
	if (mode == FORK_FG) {	/* argument to fork */
		INTOFF;
		exitstatus = waitforjob(jp, &realstatus);
		INTON;
		if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) {
			evalskip = SKIPBREAK;
			skipcount = loopnest;
		}
	} else if (mode == FORK_NOJOB) {
		backcmd->fd = pip[0];
		close(pip[1]);
		backcmd->jp = jp;
	}

out:
	if (lastarg)
		setvar("_", lastarg, 0);
	if (do_clearcmdentry)
		clearcmdentry(0);
	popstackmark(&smark);
}
开发者ID:grayshadow212,项目名称:usr.src,代码行数:101,代码来源:eval.c

示例15: main

int main(object me, string arg)
{
	string from, item;
	object obj, *inv, env, obj2;
	int i, amount;

	if (!arg)
		return notify_fail("你要捡起什么东西?\n");

	if (me->is_busy())
		return notify_fail("你上一个动作还没有完成!\n");

	if (sscanf(arg, "%s from %s", arg, from) == 2) {
		env = present(from, me);
		if (!env)
			env = present(from, environment(me));
			
		if (!env)
			return notify_fail("你找不到 " + from + " 这样东西。\n");
			
		if ((env->query("no_get_from") || living(env))
			&& (wiz_level(me) <= wiz_level(env)))
			return notify_fail("你的巫师等级必须比对方高,才能搜身。\n");
	} else
		env = environment(me);

	if (sscanf(arg, "%d %s", amount, item) == 2) {
		if (!objectp(obj = present(item, env)))
			return notify_fail("这里没有这样东西。\n");
			
		if (!obj->query_amount())
			return notify_fail(obj->name() + "不能被分开拿走。\n");
			
		if (amount < 1)
			return notify_fail("东西的个数至少是一个。\n");

		if (amount > obj->query_amount())
			return notify_fail("这里没有那麽多的" + obj->name() + "。\n");
		else if(amount == (int)obj->query_amount())
			return do_get(me, obj);
		else {
			obj2 = new(base_name(obj));
			obj2->set_amount((int)obj->query_amount() - amount);
			obj->set_amount( amount );
			do_get(me, obj);
			obj2->move(env);
			if (me->is_fighting())
				me->start_busy(3);
			return 1;
		}
	}

	if (arg=="all") {
		if (me->is_fighting())
			return notify_fail("你还在战斗中!只能一次拿一样。\n");
			
		if (!env->query_max_encumbrance())
			return notify_fail("那不是容器。\n");
			
        	if (env->is_tree())
        		return notify_fail("这是给新手活命用的,还是不要太贪心了吧n");

		inv = all_inventory(env);
		if (!sizeof(inv)) {
        		if (env->is_tree())
                		return notify_fail("树上什么也没有了。\n");
			return notify_fail("那里面没有任何东西。\n");
        	}

		for (i = 0; i < sizeof(inv); i ++) {
			if (inv[i]->is_character() || inv[i]->query("no_get"))
				continue;
			do_get(me, inv[i]);
		}
		write("捡好了。\n");
		return 1;
	}

	if (!objectp(obj = present(arg, env)) || living(obj))
		return notify_fail("你附近没有这样东西。\n");

	if (obj->query("no_get"))
		return notify_fail("这个东西拿不起来。\n");

	return do_get(me, obj);
}
开发者ID:aricxu,项目名称:xkx100,代码行数:86,代码来源:get.c


注:本文中的environment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。