示例#1
0
文件: c_core.c 项目: cinnamoncoin/z26
void emulator() {
	/* omit business about ModuleSP, as the compiler handles such
		things for us */

	InitData();
	RecognizeCart();
	SetupBanks();
	Reset();
	Init_Service();
	Controls();

	/* ExitEmulator gets set by Controls() if the user presses
		Escape */
	while( !ExitEmulator ) {
		VSync();
		srv_CopyScreen();
		ScanFrame();
		Controls();

		while(GamePaused) {
			Controls();
		}
	}

}
示例#2
0
void 
do_parent(dbref player, dbref cause, int key, char *tname, char *pname)
{
    dbref thing, parent, curr;
    int lev;

    /* get victim */

    init_match(player, tname, NOTYPE);
    match_everything(0);
    thing = noisy_match_result();
    if (thing == NOTHING)
	return;

    /* Make sure we can do it */

    if ( NoMod(thing) && !WizMod(player) ) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    if (!Controls(player, thing) &&
        !could_doit(player,thing,A_LTWINK, 0, 0)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    if ( Backstage(player) && NoBackstage(thing) ) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* Find out what the new parent is */

    if (*pname) {
	init_match(player, pname, Typeof(thing));
	match_everything(0);
	parent = noisy_match_result();
	if (parent == NOTHING)
	    return;

	/* Make sure we have rights to set parent */

	if (!Parentable(player, parent)) {
	    notify_quiet(player, "Permission denied.");
	    return;
	}
	/* Verify no recursive reference */

	ITER_PARENTS(parent, curr, lev) {
	    if (curr == thing) {
		notify_quiet(player,
			     "You can't have yourself as a parent!");
		return;
	    }
	}
    } else {
示例#3
0
HS_BOOL8 CHSInterface::ControlsObject(HS_DBREF dbController,
                                      HS_DBREF dbObject)
{
#ifdef PENNMUSH                 // No change in code between versions
    return controls(dbController, dbObject) == 0 ? false : true;
#endif

#if defined(TM3) || defined(MUX)
    return Controls(dbController, dbObject);
#endif
}
示例#4
0
void c_emulator(void) {

	Reset_emulator();

	/* ExitEmulator gets set by Controls() if the user presses Escape */
	while( !ExitEmulator ) 
	{
		if(ResetEmulator) Reset_emulator();

		srv_Events();
		if(srv_done) break;	/* SDL got a 'close window' message */

		ScanFrame();
		Controls();
		srv_CopyScreen();
		while(GamePaused) Controls();
	}
	
	srv_Cleanup();	/* shutdown SDL */
}
示例#5
0
Interactor* Builder::Body () {
    return new HBox(
	new HGlue(gap(), gap(), hfil),
	new VBox(
	    new VGlue(gap(), gap(), vfil),
	    Title(),
	    new VGlue(spc(2), spc(2), 0),
	    Controls(),
	    new VGlue(gap(), gap(), vfil)
	),
	new HGlue(gap(), gap(), hfil)
    );
}
示例#6
0
// ---------------------------------------------------------------------------
// do_query: Command interface to sql_que
//
void do_query
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int   key,
    char *dbref_attr,
    char *dbname_query,
    char *cargs[],
    int   ncargs
)
{
    if (key & QUERY_SQL)
    {
        // SQL Query.
        //
        dbref thing;
        ATTR *pattr;

        if (!( parse_attrib(executor, dbref_attr, &thing, &pattr)
            && pattr))
        {
            notify_quiet(executor, "No match.");
            return;
        }

        if (!Controls(executor, thing))
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }

        char *pQuery = dbname_query;
        char *pDBName = parse_to(&pQuery, '/', 0);

        if (NULL == pQuery)
        {
            notify(executor, "QUERY: No Query.");
            return;
        }

        STARTLOG(LOG_ALWAYS, "CMD", "QUERY");
        Log.tinyprintf("Thing=#%d, Attr=%s, dbname=%s, query=%s", thing, pattr->name, pDBName, pQuery);
        ENDLOG;
    }
    else
    {
        notify_quiet(executor, "At least one query option is required.");
    }
}
示例#7
0
void Reset_emulator(void){
	
	ResetEmulator = 0;
	printf("Reset_emulator 1()\n");
	InitData();
	printf("Reset_emulator 2()\n");
	RecognizeCart();
	printf("Reset_emulator 3()\n");
	SetupBanks();
	printf("Reset_emulator 4()\n");
	Reset();
	printf("Reset_emulator 5()\n");
	Init_Service();
	printf("Reset_emulator 6()\n");
	Controls();
}
示例#8
0
文件: move.c 项目: chazu/btmux
void move_object(dbref thing, dbref dest)
{
	dbref src;

	/*
	 * Remove from the source location 
	 */

	src = Location(thing);
	if(src != NOTHING)
		s_Contents(src, remove_first(Contents(src), thing));

	/*
	 * Special check for HOME 
	 */

	if(dest == HOME)
		dest = Home(thing);

	/*
	 * Add to destination location 
	 */

	if(dest != NOTHING)
		s_Contents(dest, insert_first(Contents(dest), thing));
	else
		s_Next(thing, NOTHING);
	s_Location(thing, dest);

	/*
	 * Look around and do the penny check 
	 */

	look_in(thing, dest, (LK_SHOWEXIT | LK_OBEYTERSE));
	if(isPlayer(thing) && (mudconf.payfind > 0) &&
	   (Pennies(thing) < mudconf.paylimit) && (!Controls(thing, dest)) &&
	   ((random() % mudconf.payfind) == 0)) {
		giveto(thing, 1);
		notify_printf(thing, "You found a %s!", mudconf.one_coin);
	}
}
示例#9
0
int main()
{
    sf::Shape player = sf::Shape::Rectangle(0, 0, PLAYERWIDTH, PLAYERHEIGHT, sf::Color::Red);
    sf::Shape object = sf::Shape::Rectangle(0, 0, OBJECTWIDTH, OBJECTHEIGHT, sf::Color::Blue);

    player.SetPosition(0, 0);
    object.SetPosition(100, 100);

    sf::RenderWindow Window(sf::VideoMode(ScreenWidth, ScreenHeight, 32), "SFML - CodingMadeEasy");

    sf::SoundBuffer buffer;
    sf::Sound collision;
    sf::Music introMusic;

    if(buffer.LoadFromFile("collision.wav"))
        collision.SetBuffer(buffer);
    introMusic.OpenFromFile("intro.ogg");

    srand(time(0));

    introMusic.Play();

    while(Window.IsOpened())
    {
        sf::Event Event;
        while(Window.GetEvent(Event))
        {
            if(Event.Type == sf::Event::Closed || Event.Key.Code == sf::Key::Escape)
                Window.Close();
        }

        Controls(Window, player);
        Collision(Window, collision, player, object);

        Window.Clear();
        Window.Draw(object);
        Window.Draw(player);
        Window.Display();
    }
    return 0;
}
示例#10
0
void Motogame::onReadAvailable()
{
    while (true)
    {
        QByteArray Msg = m_Motogame.readLine();
        if (Msg.size() == 0)
            break;

        MotoWork Work;
        MotoPoW PoW;
        if (motoParseMessage(Msg.data(), Work))
        {
            auto iter = findBlock(Work);
            if (iter != m_Templates.end())
                m_Templates.erase(iter);
        }
        else if (motoParseMessage(Msg.data(), Work, PoW))
        {
            auto iter = findBlock(Work);
            if (iter != m_Templates.end())
            {
                CBlock *pBlock = &(*iter)->block;
                pBlock->Nonce = PoW;
                CheckWork(pBlock, *m_pWallet, m_ReserveKey);
            }
            updateBlock();
        }
        else if (strncmp(Msg.data(), "***Config:*", 11) == 0)
        {
            QString Controls(Msg.data() + 11);
            Controls.remove("\n");
            QSettings settings;
            settings.setValue("GameControls", Controls);
        }
    }
}
示例#11
0
void
do_zone(dbref player, dbref cause, int key, char *tname, char *pname)
{
  dbref thing, zonemaster;

  switch( key ) {
    case ZONE_ADD: /* or default */
      if( *tname && !*pname ) {
        init_match(player, tname, NOTYPE);
        match_everything(0);
        thing = noisy_match_result();
        if( thing == NOTHING )
          return;
        if( !Examinable(player, thing) ) {
          notify_quiet(player, "You can't do that.");
          return;
        }
        viewzonelist(player, thing);
        return;
      }
       
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      /* Make sure we can do it */

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }
      if (!Controls(player, thing)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( ZoneMaster(thing) ) {
        notify_quiet(player, "You can't zone a Zone Master.");
        return;
      }
      /* Find out what the new zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
 
      if( !ZoneMaster(zonemaster) ) {
        notify_quiet(player, "That's not a Zone Master.");
        return;
      }

      if(!Controls(player, zonemaster) && 
        !could_doit(player, zonemaster, A_LZONETO, 0, 0) &&
        !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if( zlist_inlist(thing, zonemaster) ) {
        notify_quiet(player, "Object is already in that zone.");
        return;
      }

      zlist_add(thing, zonemaster);
      zlist_add(zonemaster, thing);

      notify_quiet(player, "Zone Master added to object.");
      break;
    case ZONE_DELETE:
      if( !*tname || !*pname ) {
        notify_quiet(player, "This switch expects two arguments.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, pname, NOTYPE);
      match_everything(0);
      zonemaster = noisy_match_result();
      if (zonemaster == NOTHING)
        return;
     
      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if( thing == NOTHING )
        return;

      if(!zlist_inlist(thing, zonemaster)) {
        notify_quiet(player, "That is not one of this object's Zone Masters.");
        return;
      }

      /* only need to control zmo or be zonewiz to delete 
         or control object */

      if(!Controls(player, thing) &&
         !Controls(player, zonemaster) && 
         !could_doit(player, zonemaster, A_LZONEWIZ, 0, 0)
         ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      if ( (NoMod(thing) && !WizMod(player)) ||
           (Backstage(player) && NoBackstage(thing)) ) {
        notify_quiet(player, "Permission denied.");
        return;
      }

      zlist_del(thing, zonemaster);
      zlist_del(zonemaster, thing);

      notify_quiet(player, "Deleted.");
      break;
    case ZONE_PURGE:
      if( !*tname || *pname) {
        notify_quiet(player, "This switch expects one argument.");
        return;
      }
      /* Find out what the zone is */

      init_match(player, tname, NOTYPE);
      match_everything(0);
      thing = noisy_match_result();
      if (thing == NOTHING)
        return;

      if( ZoneMaster(thing) ) {
        if(!Controls(player, thing) && 
          !could_doit(player, thing, A_LZONEWIZ, 0, 0)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);
        notify_quiet(player, "All objects removed from zone.");
      }
      else {
        if(!Controls(player, thing)) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        if ( (NoMod(thing) && !WizMod(player)) ||
             (Backstage(player) && NoBackstage(thing)) ) {
          notify_quiet(player, "Permission denied.");
          return;
        }
        zlist_destroy(thing);

        notify_quiet(player, "Object removed from all zones.");
      }
      break;
    default:
      notify_quiet(player, "Unknown switch!");
      break;
  }
  return;
}
示例#12
0
void 
do_link(dbref player, dbref cause, int key, char *what, char *where)
{
    dbref thing, room;
    char *buff;
    int nomtest;

    if ( (key & SIDEEFFECT) && !SideFX(player) ) {
       notify(player, "#-1 FUNCTION DISABLED");
       return;
    }

    /* Find the thing to link */

    init_match(player, what, TYPE_EXIT);
    match_everything(0);
    thing = noisy_match_result();
    if (thing == NOTHING)
	return;

    nomtest = ((NoMod(thing) && !WizMod(player)) || (DePriv(player,Owner(thing),DP_MODIFY,POWER7,NOTHING) && (Owner(thing) != Owner(player))) || (Backstage(player) && NoBackstage(thing) && !Immortal(player)));
    /* Allow unlink if where is not specified */

    if (!where || !*where) {
      if (!nomtest)
	do_unlink(player, cause, key, what);
      else
	notify(player,"Permission denied.");
      return;
    }
    switch (Typeof(thing)) {
    case TYPE_EXIT:

	/* Set destination */

	room = parse_linkable_room(player, where);
	if (room != NOTHING) {
	  if (!nomtest)
	    link_exit(player, thing, room, key);
	  else
	    notify(player,"Permission denied.");
	}
	break;
    case TYPE_PLAYER:
    case TYPE_THING:

	/* Set home */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	init_match(player, where, NOTYPE);
	match_everything(MAT_NO_EXITS);
	room = noisy_match_result();
	if (!Good_obj(room))
	    break;
	if (!Has_contents(room)) {
	    notify_quiet(player, "Can't link to an exit.");
	    break;
	}
	if (!can_set_home(player, thing, room) ||
	    !could_doit(player, room, A_LLINK, 1, 0)) {
	    notify_quiet(player, "Permission denied.");
	} else if (room == HOME) {
	    notify_quiet(player, "Can't set home to home.");
	} else {
	    s_Home(thing, room);
	    if (!(Quiet(player) || (key & SIDEEFFECT)) )
		notify_quiet(player, "Home set.");
	}
	break;
    case TYPE_ROOM:

	/* Set dropto */

	if (!Controls(player, thing) || nomtest) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}
	room = parse_linkable_room(player, where);
	if (!Good_obj(room) && (room != HOME)) {
	    notify_quiet(player, "Permission denied.");
	    break;
	}

	if ((room != HOME) && !isRoom(room)) {
	    notify_quiet(player, "That is not a room!");
	} else if ((room != HOME) &&
		   ((!controls(player, room) && !Link_ok(room)) ||
		    !could_doit(player, room, A_LLINK, 1, 0))) {
	    notify_quiet(player, "Permission denied.");
	} else {
	    s_Dropto(thing, room);
	    if (!Quiet(player))
		notify_quiet(player, "Dropto set.");
	}
	break;
    default:
	STARTLOG(LOG_BUGS, "BUG", "OTYPE")
	    buff = alloc_mbuf("do_link.LOG.badtype");
	sprintf(buff, "Strange object type: object #%d = %d",
		thing, Typeof(thing));
	log_text(buff);
	free_mbuf(buff);
	ENDLOG
    }
}
示例#13
0
// ---------------------------------------------------------------------------
// do_wait: Command interface to wait_que
//
void do_wait
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int key,
    char *event,
    char *cmd,
    char *cargs[],
    int ncargs
)
{
    CLinearTimeAbsolute ltaWhen;
    CLinearTimeDelta    ltd;

    // If arg1 is all numeric, do simple (non-sem) timed wait.
    //
    if (is_rational(event))
    {
        if (key & WAIT_UNTIL)
        {
            ltaWhen.SetSecondsString(event);
        }
        else
        {
            ltaWhen.GetUTC();
            ltd.SetSecondsString(event);
            ltaWhen += ltd;
        }
        wait_que(executor, caller, enactor, eval, true, ltaWhen, NOTHING, 0,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
        return;
    }

    // Semaphore wait with optional timeout.
    //
    char *what = parse_to(&event, '/', 0);
    init_match(executor, what, NOTYPE);
    match_everything(0);

    dbref thing = noisy_match_result();
    if (!Good_obj(thing))
    {
        return;
    }
    else if (!Controls(executor, thing) && !Link_ok(thing))
    {
        notify(executor, NOPERM_MESSAGE);
    }
    else
    {
        // Get timeout, default 0.
        //
        int atr = A_SEMAPHORE;
        bool bTimed = false;
        if (event && *event)
        {
            if (is_rational(event))
            {
                if (key & WAIT_UNTIL)
                {
                    ltaWhen.SetSecondsString(event);
                }
                else
                {
                    ltaWhen.GetUTC();
                    ltd.SetSecondsString(event);
                    ltaWhen += ltd;
                }
                bTimed = true;
            }
            else
            {
                ATTR *ap = atr_str(event);
                if (!ap)
                {
                    atr = mkattr(executor, event);
                    if (atr <= 0)
                    {
                        notify_quiet(executor, "Invalid attribute.");
                        return;
                    }
                    ap = atr_num(atr);
                }
                else
                {
                    atr = ap->number;
                }
                if (!bCanSetAttr(executor, thing, ap))
                {
                    notify_quiet(executor, NOPERM_MESSAGE);
                    return;
                }
            }
        }

        int num = add_to(thing, 1, atr);
        if (num <= 0)
        {
            // Thing over-notified, run the command immediately.
            //
            thing = NOTHING;
            bTimed = false;
        }
        wait_que(executor, caller, enactor, eval, bTimed, ltaWhen, thing, atr,
            cmd,
            ncargs, cargs,
            mudstate.global_regs);
    }
}
示例#14
0
void do_notify
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   key,
    int   nargs,
    char *what,
    char *count
)
{
    UNUSED_PARAMETER(caller);
    UNUSED_PARAMETER(enactor);
    UNUSED_PARAMETER(nargs);

    char *obj = parse_to(&what, '/', 0);
    init_match(executor, obj, NOTYPE);
    match_everything(0);

    dbref thing = noisy_match_result();
    if (!Good_obj(thing))
    {
        return;
    }
    if (!Controls(executor, thing) && !Link_ok(thing))
    {
        notify(executor, NOPERM_MESSAGE);
    }
    else
    {
        int atr = A_SEMAPHORE;
        if (  what
           && what[0] != '\0')
        {
            int i = mkattr(executor, what);
            if (0 < i)
            {
                atr = i;
                if (atr != A_SEMAPHORE)
                {
                    // Do they have permission to set this attribute?
                    //
                    ATTR *ap = (ATTR *)anum_get(atr);
                    if (!bCanSetAttr(executor, thing, ap))
                    {
                        notify_quiet(executor, NOPERM_MESSAGE);
                        return;
                    }
                }
            }
        }

        int loccount;
        if (  count
           && count[0] != '\0')
        {
            loccount = mux_atol(count);
        }
        else
        {
            loccount = 1;
        }
        if (loccount > 0)
        {
            nfy_que(thing, atr, key, loccount);
            if (  (!(Quiet(executor) || Quiet(thing)))
               && key != NFY_QUIET)
            {
                if (key == NFY_DRAIN)
                {
                    notify_quiet(executor, "Drained.");
                }
                else
                {
                    notify_quiet(executor, "Notified.");
                }
            }
        }
    }
}
示例#15
0
int DvigChel_1 (int x, int y)
{
     int time_end     = clock();

     Point_t loc      = {x, y};

     Score_t score    = {0};

     Chel_t chel      = {&loc, SPEED};

     Reaction_t react = {&loc, &score};

     PointEN_t locEN  = {291, 195, 5, 5};

     PointEN_t locEN2 = {500, 500, 1, 1};

     PointEN_t locEN3 = {400, 550, 4, 4};

     int time         = 0;

     int counter      = -2;

     int counteren    = 0;

     DrawLevel();

     HDC Cover        = txLoadImage ("Resourses\\Images\\Cover.bmp");

     txPlaySound ("Resourses\\Music\\track_1.wav", SND_ASYNC);

     DrawArbuz (386, 59);
     DrawArbuz (449, 269);
     DrawArbuz (95, 402);
     DrawArbuz (345, 449);
     DrawArbuz (723, 491);
     DrawArbuz (703, 294);

     while (1)
     {
        txBegin();

        DrawTimeTable();

        Interface      (&score, &time, &time_end);

        DrawWalls_1();

        Bonus (&score);

        txSetColor     (TX_YELLOW);
        txSetFillColor (TX_YELLOW);
        txRectangle    (locEN.x - 13, locEN.y - 13, locEN.x + 13, locEN.y + 13);

        MoveEnemy (&locEN);

        counteren++;

        if (counteren % 12 < 5) DrawEnemy_1 (&locEN);

        else
            if (counteren % 12 < 9) DrawEnemy_2 (&locEN);

            else DrawEnemy_3 (&locEN);

        if ((loc.x < locEN.x + 14) &&
            (loc.x > locEN.x - 12) &&
            (loc.y < locEN.y + 13) &&
            (loc.y > locEN.y - 12)) return 0;

        txSetColor     (TX_YELLOW);
        txSetFillColor (TX_YELLOW);
        txRectangle    (locEN2.x - 13, locEN2.y - 13, locEN2.x + 13, locEN2.y + 13);

        MoveEnemy (&locEN2);

        counteren++;

        if (counteren % 12 < 5) DrawEnemy_1 (&locEN2);

        else
            if (counteren % 12 < 9) DrawEnemy_2 (&locEN2);

            else DrawEnemy_3 (&locEN2);

        if ((loc.x < locEN2.x + 14) &&
            (loc.x > locEN2.x - 12) &&
            (loc.y < locEN2.y + 13) &&
            (loc.y > locEN2.y - 12)) return 0;

        txSetColor     (TX_YELLOW);
        txSetFillColor (TX_YELLOW);
        txRectangle    (locEN3.x - 13, locEN3.y - 13, locEN3.x + 13, locEN3.y + 13);

        MoveEnemy (&locEN3);

        counteren++;

        if (counteren % 12 < 5) DrawEnemy_1 (&locEN3);

        else
            if (counteren % 12 < 9) DrawEnemy_2 (&locEN3);

            else DrawEnemy_3 (&locEN3);

        if ((loc.x < locEN3.x + 14) &&
            (loc.x > locEN3.x - 12) &&
            (loc.y < locEN3.y + 13) &&
            (loc.y > locEN3.y - 12)) return 0;

        txTransparentBlt (txDC(), loc.x - 10, loc.y - 10, 21, 21, Cover, 0, 0, TX_WHITE);

        if (Controls (&react) == 1)   {DrawChel_1 (&loc); return 0;};

        if (ReactionEnd1 (&loc) == 1) 
                         {
                                if (score.points > 400) return score.points + 20 - time;
                         };
                         
        if (time > 40) return 0;

        counter++;

        if (counter > 2) counter = -2;

        if (counter < 0) DrawChel_1 (&loc);

           else DrawChel_2 (&loc);

		if (GetAsyncKeyState ('M')) sleep--;
		if (sleep < 0) sleep = 0;
        if (GetAsyncKeyState ('P')) sleep++;

        if (GetAsyncKeyState (VK_ESCAPE)) MenuInGame(&loc, 1);

        Sleep (sleep);
     }

     time_end = time;

     txDeleteDC (Cover);
}