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


C++ controls函数代码示例

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


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

示例1: first_visible

/** Return the first object near another object that is visible to a player.
 *
 * BEWARE:
 *
 * first_visible() does not behave as intended. It _should_ return the first
 * object in `thing' that is !DARK. However, because of the controls() check
 * the function will return a DARK object if the player owns it.
 *
 * The behavior is left as is because so many functions in fundb.c rely on
 * the incorrect behavior to return expected values. The lv*() functions
 * also make rewriting this fairly pointless.
 *
 * \param player the looker.
 * \param thing an object in the location to be inspected.
 * \return dbref of first visible object or NOTHING.
 */
dbref
first_visible(dbref player, dbref thing)
{
  int lck = 0;
  int ldark;
  dbref loc;

  if (!GoodObject(thing) || IsRoom(thing))
    return NOTHING;
  loc = IsExit(thing) ? Source(thing) : Location(thing);
  if (!GoodObject(loc))
    return NOTHING;
  ldark = IsPlayer(loc) ? Opaque(loc) : Dark(loc);

  while (GoodObject(thing)) {
    if (can_interact(thing, player, INTERACT_SEE, NULL)) {
      if (DarkLegal(thing) || (ldark && !Light(thing))) {
        if (!lck) {
          if (See_All(player) || (loc == player) || controls(player, loc))
            return thing;
          lck = 1;
        }
        if (controls(player, thing))    /* this is what causes DARK objects to show */
          return thing;
      } else {
        return thing;
      }
    }
    thing = Next(thing);
  }
  return thing;
}
开发者ID:zetafunction,项目名称:pennmush-mirror,代码行数:48,代码来源:predicat.c

示例2: control_process

int
control_process(dbref player, int pid)
{
	timequeue ptr = tqhead;

	while ((ptr) && (pid != ptr->eventnum)) {
		ptr = ptr->next;
	}

	/* If the process isn't in the timequeue, that means it's
		waiting for an event, so let the event code handle
		it. */

	if (!ptr) {
		return muf_event_controls(player, pid);
	}

	/* However, if it is in the timequeue, we have to handle it.
		Other than a Wizard, there are three people who can kill it:
		the owner of the program, the owner of the trigger, and the
		person who is currently running it. */

	if (!controls(player, ptr->called_prog) && !controls(player, ptr->trig)
			&& (player != ptr->uid)) {
		return 0;
	}
	return 1;
}
开发者ID:hyena,项目名称:fuzzball,代码行数:28,代码来源:timequeue.c

示例3: can_see

bool
can_see(dbref player, dbref thing, bool can_see_loc)
{
    if (!OkObj(player) || !OkObj(thing))
        return 0;

    if (player == thing || Typeof(thing) == TYPE_EXIT
        || Typeof(thing) == TYPE_ROOM)
        return 0;

    if (Light(thing))
        return 1;

    if (can_see_loc) {
        switch (Typeof(thing)) {
            case TYPE_PROGRAM:
                return ((FLAGS(thing) & LINK_OK) || controls(player, thing)
                        || (POWERS(player) & POW_SEE_ALL));
            case TYPE_PLAYER:
                if (tp_dark_sleepers) {
                    return (!Dark(thing) || online(thing)
                            || (POWERS(player) & POW_SEE_ALL));
                }
            default:
                return (!Dark(thing) || (POWERS(player) & POW_SEE_ALL) ||
                        (controls(player, thing) && !(FLAGS(player) & STICKY)));

        }
    } else {
        /* can't see loc */
        return (controls(player, thing) && !(FLAGS(player) & STICKY));
    }
}
开发者ID:nekosune,项目名称:protomuck,代码行数:33,代码来源:predicates.c

示例4: getView

void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads )
{
    int tl = getView()->GetTopLayer();
    VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
    VECTOR2I p;

    controls()->ForceCursorPosition( false );
    m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
    m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );

    bool snapEnabled = true;

    if( aEvent.IsMotion() || aEvent.IsClick() )
    {
        snapEnabled = !aEvent.Modifier( MD_SHIFT );
        p = aEvent.Position();
    }
    else
    {
        p = cp;
    }

    m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );

    if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
        m_startItem = nullptr;

    m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );

    if( checkSnap( m_startItem ) )
    {
        controls()->ForceCursorPosition( true, m_startSnapPoint );
    }
}
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:34,代码来源:pns_tool_base.cpp

示例5: link_exit

static void 
link_exit(dbref player, dbref exit, dbref dest, int key)
{
    int cost, quot;

    /* Make sure we can link there */

    if ((dest != HOME) &&
	((!controls(player, dest) && !Link_ok(dest)) ||
	 !could_doit(player, dest, A_LLINK, 1, 0))) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* Exit must be unlinked or controlled by you */

    if ((Location(exit) != NOTHING) && !controls(player, exit)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* If exit is unlinked and mudconf 'paranoid_exit_linking' is enabled
     * Do not allow the exit to be linked if you do not control it
     */
    if ( (mudconf.paranoid_exit_linking == 1) && !controls(player,exit) ) {
        notify_quiet(player, "Permission denied.");
	return;
    }

    /* handle costs */

    cost = mudconf.linkcost;
    quot = 0;
    if (Owner(exit) != Owner(player)) {
	cost += mudconf.opencost;
	quot += mudconf.exit_quota;
    }
    if (!canpayfees(player, player, cost, quot, TYPE_EXIT))
	return;

    /* Pay the owner for his loss */

    /* Ok, if paranoid_exit_linking is enabled the linker does NOT own exit */
    if (!(mudconf.paranoid_exit_linking)) {
       if (Owner(exit) != Owner(player)) {
	   giveto(Owner(exit), mudconf.opencost, NOTHING);
	   add_quota(Owner(exit), quot, TYPE_EXIT);
	   s_Owner(exit, Owner(player));
	   s_Flags(exit, (Flags(exit) & ~(INHERIT | WIZARD)) | HALT);
       }
    }
    /* link has been validated and paid for, do it and tell the player */

    s_Location(exit, dest);
    if (!(Quiet(player) || (key & SIDEEFFECT)) )
	notify_quiet(player, "Linked.");
}
开发者ID:pdbogen,项目名称:RhostMUSH,代码行数:55,代码来源:create.c

示例6: can_link_to

int
can_link_to(dbref who, object_flag_type what_type, dbref where)
{
		/* Can always link to HOME */
	if (where == HOME)
		return 1;
		/* Can't link to an invalid dbref */
	if (where < 0 || where >= db_top)
		return 0;
	switch (what_type) {
	case TYPE_EXIT:
		/* If the target is LINK_OK, then any exit may be linked
		 * there.  Otherwise, only someone who controls the
		 * target may link there. */
		return (controls(who, where) || (FLAGS(where) & LINK_OK));
		/* NOTREACHED */
		break;
	case TYPE_PLAYER:
		/* Players may only be linked to rooms, that are either
		 * controlled by the player or set either L or A. */
		return (Typeof(where) == TYPE_ROOM && (controls(who, where)
											   || Linkable(where)));
		/* NOTREACHED */
		break;
	case TYPE_ROOM:
		/* Rooms may be linked to rooms or things (this sets their
		 * dropto location).  Target must be controlled, or be L or A. */
		return ((Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_THING)
				&& (controls(who, where) || Linkable(where)));
		/* NOTREACHED */
		break;
	case TYPE_THING:
		/* Things may be linked to rooms, players, or other things (this
		 * sets the thing's home).  Target must be controlled, or be L or A. */
		return (
				(Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_PLAYER ||
				 Typeof(where) == TYPE_THING) && 
				 (controls(who, where) || Linkable(where)));
		/* NOTREACHED */
		break;
	case NOTYPE:
		/* Why is this here? -winged */
		return (controls(who, where) || (FLAGS(where) & LINK_OK) ||
				(Typeof(where) != TYPE_THING && (FLAGS(where) & ABODE)));
		/* NOTREACHED */
		break;
	default:
		/* Programs can't be linked anywhere */
		return 0;
		/* NOTREACHED */
		break;
	}
	/* NOTREACHED */
	return 0;
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:55,代码来源:predicates.c

示例7: mfn_contents

const char *
mfn_contents(MFUNARGS)
{
    char buf2[50];
    int list_limit = MAX_MFUN_LIST_LEN;
    dbref obj = mesg_dbref_local(player, what, perms, argv[0]);
    int typchk, ownroom;
    int outlen, nextlen;

    if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME)
	ABORT_MPI("CONTENTS","Match failed");
    if (obj == PERMDENIED)
	ABORT_MPI("CONTENTS",NOPERM_MESG);

    typchk = NOTYPE;
    if (argc > 1) {
	if (!string_compare(argv[1], "Room")) {
	    typchk = TYPE_ROOM;
	} else if (!string_compare(argv[1], "Exit")) {
	    typchk = TYPE_EXIT;  /* won't find any, though */
	} else if (!string_compare(argv[1], "Player")) {
	    typchk = TYPE_PLAYER;
	} else if (!string_compare(argv[1], "Program")) {
	    typchk = TYPE_PROGRAM;
	} else if (!string_compare(argv[1], "Thing")) {
	    typchk = TYPE_THING;
	} else {
	    ABORT_MPI("CONTENTS","Type must be 'player', 'room', 'thing', 'program', or 'exit'. (2)");
	}
    }
    strcpy(buf, "");
    outlen = 0;
    ownroom = controls(perms, obj);
    obj = DBFETCH(obj)->contents;
    while (obj != NOTHING && list_limit) {
	if ((typchk == NOTYPE || Typeof(obj) == typchk) &&
		(ownroom || controls(perms, obj) ||
		!((FLAGS(obj) & DARK) || (FLAGS(getloc(obj)) & DARK) ||
		(Typeof(obj) == TYPE_PROGRAM && !(FLAGS(obj) & LINK_OK)))) &&
		!(Typeof(obj) == TYPE_ROOM && typchk != TYPE_ROOM)) {
	    ref2str(obj, buf2);
	    nextlen = strlen(buf2);
	    if ((outlen + nextlen) >= (BUFFER_LEN - 3))
		break;
	    if (outlen) strcat((buf+(outlen++)), "\r");
	    strcat((buf + outlen), buf2);
	    outlen += nextlen;
	    list_limit--;
	}
	obj = DBFETCH(obj)->next;
    }
    return buf;
}
开发者ID:GlowMUCK,项目名称:GlowMUCK,代码行数:53,代码来源:mfuns2.c

示例8: controls

void RoundingView::DiscardEdits()
{
    for
        (controls_type::const_iterator it = controls().begin()
        ,end = controls().end()
        ;it != end
        ;++it
        )
        {
        it->second->DiscardEdits();
        }
}
开发者ID:vadz,项目名称:lmi.new,代码行数:12,代码来源:rounding_view.cpp

示例9: controls

void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
{
    int layer;
    bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
    m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
    m_gridHelper->SetSnap( snapEnabled );

    controls()->ForceCursorPosition( false );
    VECTOR2I mousePos = controls()->GetMousePosition();

    if( m_router->Settings().Mode() != RM_MarkObstacles &&
        ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
    {
        m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
        controls()->ForceCursorPosition( true, m_endSnapPoint );
        m_endItem = nullptr;

        return;
    }

    if( m_router->IsPlacingVia() )
        layer = -1;
    else
        layer = m_router->GetCurrentLayer();

    ITEM* endItem = nullptr;

    std::vector<int> nets = m_router->GetCurrentNets();

    for( int net : nets )
    {
        endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );

        if( endItem )
            break;
    }

    if( checkSnap( endItem ) )
    {
        m_endItem = endItem;
        m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
    } else {
        m_endItem = nullptr;
        m_endSnapPoint = m_gridHelper->Align( mousePos );
    }

    controls()->ForceCursorPosition( true, m_endSnapPoint );

    if( m_endItem )
    {
        wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
    }
}
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:53,代码来源:pns_tool_base.cpp

示例10: chown_ok

static int
chown_ok(dbref player, dbref thing, dbref newowner, NEW_PE_INFO *pe_info)
{
  /* Can't touch garbage */
  if (IsGarbage(thing))
    return 0;

  /* Wizards can do it all */
  if (Wizard(player))
    return 1;

  /* In order for non-wiz player to @chown thing to newowner,
   * player must control newowner or newowner must be a Zone Master
   * and player must pass its zone lock.
   *
   * In addition, one of the following must apply:
   *   1.  player owns thing, or
   *   2.  player controls Owner(thing), newowner is a zone master,
   *       and Owner(thing) passes newowner's zone-lock, or
   *   3.  thing is CHOWN_OK, and player holds thing if it's an object.
   *
   * The third condition is syntactic sugar to handle the situation
   * where Joe owns Box, an ordinary object, and Tool, an inherit object,
   * and ZMP, a Zone Master Player, is zone-locked to =tool.
   * In this case, if Joe doesn't pass ZMP's lock, we don't want
   *   Joe to be able to @fo [email protected] Box=ZMP
   */

  /* Does player control newowner, or is newowner a Zone Master and player
   * passes the lock?
   */
  if (!(controls(player, newowner) ||
        (ZMaster(newowner) &&
         eval_lock_with(player, newowner, Zone_Lock, pe_info))))
    return 0;

  /* Target player is legitimate. Does player control the object? */
  if (Owns(player, thing))
    return 1;

  if (controls(player, Owner(thing)) && ZMaster(newowner) &&
      eval_lock_with(Owner(thing), newowner, Zone_Lock, pe_info))
    return 1;

  if ((!IsThing(thing) || (Location(thing) == player)) && ChownOk(thing) &&
      eval_lock_with(player, thing, Chown_Lock, pe_info))
    return 1;

  return 0;
}
开发者ID:captdeaf,项目名称:pennmush,代码行数:50,代码来源:set.c

示例11: can_link_to

bool
can_link_to(dbref who, object_flag_type what_type,
            dbref where)
{
    if (where == HOME)
        return 1;

    if (where == NIL)
        return 1;

    if (!OkObj(who) || !OkObj(where))
        return 0;

    switch (what_type) {
        case TYPE_EXIT:
            return (controls(who, where) || (FLAGS(where) & LINK_OK)
                    || (POWERS(who) & POW_LINK_ANYWHERE));
            /* NOTREACHED */
            break;
        case TYPE_PLAYER:
            return (Typeof(where) == TYPE_ROOM && (controls(who, where)
                                                   || Linkable(where)
                                                   || (POWERS(who) &
                                                       POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case TYPE_ROOM:
            return ((Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_THING)
                    && (controls(who, where) || Linkable(where)
                        || (POWERS(who) & POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case TYPE_THING:
            return ((Typeof(where) == TYPE_ROOM || Typeof(where) == TYPE_PLAYER
                     || Typeof(where) == TYPE_THING)
                    && (controls(who, where) || Linkable(where)
                        || (POWERS(who) & POW_LINK_ANYWHERE)));
            /* NOTREACHED */
            break;
        case NOTYPE:
            return (controls(who, where) || (FLAGS(where) & LINK_OK)
                    || (POWERS(who) & POW_LINK_ANYWHERE)
                    || (Typeof(where) != TYPE_THING && (FLAGS(where) & ABODE)));
            /* NOTREACHED */
            break;
    }

    return 0;
}
开发者ID:nekosune,项目名称:protomuck,代码行数:49,代码来源:predicates.c

示例12: menu

void menu()
{
    char choice;
    begin:
    initMenu();
    settextstyle(GOTHIC_FONT, HORIZ_DIR, 4);
    outtextxy(getmaxx()/2-45, top+5, "MENU");
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 1.75);
    outtextxy(getmaxx()/2-75, top+60, "1. START");
    outtextxy(getmaxx()/2-75, top+75, "2. HIGH SCORE");
    outtextxy(getmaxx()/2-75, top+90, "3. CONTROLS");
    outtextxy(getmaxx()/2-75, top+105, "4. EXIT");
    error1:
    choice=getch();
    switch(choice)
    {
	case '1' : level();
		   return;
	case '2' : disHighscore();
		   goto begin;
    case '3' : controls();
	       goto begin;
	case '4' : closegraph();
		   exit(0);
	default  : goto error1;
    }
}
开发者ID:mintoo511,项目名称:Tetris-in-C,代码行数:27,代码来源:TETRIS.C

示例13: can_link

/* This checks to see if what can be linked to something else by who. */
int
can_link(dbref who, dbref what)
{
	/* Anyone can link an exit that is currently unlinked. */
	return (controls(who, what) || ((Typeof(what) == TYPE_EXIT)
									&& DBFETCH(what)->sp.exit.ndest == 0));
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:8,代码来源:predicates.c

示例14: main

int main() {

	// do setup 
	setup();
	
	DDRC |= (1 << PC5);
	PORTC &= ~(1 << PC5);

/*
	// wait until all buttons released
	uint8_t waitbutton = ~(PIND) & 0b00011111;
	if (~(PINB) & (1<<PB0)) waitbutton |= 0b00100000; // pridame edit tlacitko z portu B
	while (waitbutton) {
		waitbutton = ~(PIND) & 0b00011111;
		if (~(PINB) & (1<<PB0)) waitbutton |= 0b00100000; // pridame edit tlacitko z portu B
	}
*/

	// and go for infinite loop
	for (;;) {
		
		controls();		// read buttons and pots
		lights();		// compute which LED to light up
		
		if (newstep) {
			newstep = 0;
			uint8_t i;
			for (i = 0; i < 4; i++) {
				if (seq[playstep] & (1 << i)) gate[i] = 1;			
			}
		}
	}
}
开发者ID:hadesbox,项目名称:lunchbeat-PCB,代码行数:33,代码来源:lunchbeat-pcb.c

示例15: main

int main() {
	char ch;
	welcomescreen();	
	printrule();	
	do {
		switch(mainmenu()) {
			case 0 :loadgame();
				break;
			case 1: controls();
				break;
			case 2: ;
				break;
		
			}
	
		printf("\nDo you want to play now ? ( Y OR N)\n");
		scanf("%c",&ch);
		ch = tolower(ch);	
	} while(ch =='y');
		
	clrscr();
	printf("Your score has been saved to Snake.txt\n");
	FILE *fp;
	fp = fopen("Snake.txt", "a");
	fprintf(fp,"Player score : %d\n", globscore);	
	printf("\n\nThanks for playing\n");
	fclose(fp);
return 0 ;

}		
开发者ID:shantanuusharma,项目名称:Project,代码行数:30,代码来源:snake.c


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