Beispiel #1
0
/*
 * Performs an inorder traversal of the tree rooted at the specified node. An O(n) operation.
 *
 * Parameters:
 * - ptree = Pointer to the tree head structure.
 * - ptn = Pointer to the root of the current tree node.
 * - pfnWalk = Pointer to a function called for each tree node we encounter.  This function returns TRUE
 *             to continue the traversal or FALSE to stop it.
 * - pData = Arbitrary data pointer that gets passed to the pfnWalk function.
 *
 * Returns:
 * TRUE if the tree was entirely traversed, FALSE if the tree walk was interrupted.
 *
 * N.B.:
 * This function is recursive; however, the nature of the tree guarantees that the stack space consumed
 * by its stack frames will be O(log n).
 */
static BOOL do_walk(PRBTREE ptree, PRBTREENODE ptn, PFNRBTWALK pfnWalk, PVOID pData)
{
    register BOOL rc = TRUE;
    if (ptn->ptnLeft)
        rc = do_walk(ptree, ptn->ptnLeft, pfnWalk, pData);
    if (rc)
        rc = (*pfnWalk)(ptree, (*(ptree->pfnGetFromNodePtr))(ptn), pData);
    if (rc && rbtNodeRight(ptn))
        rc = do_walk(ptree, rbtNodeRight(ptn), pfnWalk, pData);
    return rc;
}
void cArenaTry::process()
{
	if (!ids_set) set_ids();							// we need to make sure the ID variables are set
	init();
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home

	/*
	*	otherwise, compare event IDs
	*
	*	if it's the back button, pop the window off the stack
	*	and we're done
	*/
	if (g_InterfaceEvents.CheckButton(back_id))
	{
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	else if (g_InterfaceEvents.CheckButton(walk_id))
	{
		do_walk();
		if (!g_Cheats) g_TryOuts = true;
		g_InitWin = true;
	}
}
Beispiel #3
0
void w_drawdesk(GRECT *pc)
{
        register LONG   tree;
        register WORD   depth;
        register WORD   root;
        GRECT           pt;
        
        rc_copy(pc, &pt);
        if (gl_newdesk)
        {
          tree = gl_newdesk;
          depth = MAX_DEPTH;
          root = gl_newroot;
        }
        else
        {
          tree = gl_wtree;
          depth = 0;
          root = ROOT;
        }
                                                /* account for drop     */
                                                /*   shadow             */
                                                /* BUGFIX in 2.1        */
        pt.g_w += 2;
        pt.g_h += 2;

        do_walk(DESKWH, tree, root, depth, pc);
}
Beispiel #4
0
void w_cpwalk(WORD wh, WORD obj, WORD depth, WORD usetrue)
{
        GRECT           c;
                                                /* start with window's  */
                                                /*   true size as clip  */
        if ( usetrue )
          w_getsize(WS_TRUE, wh, &c);
        else
        {
                                                /* use global clip      */
          gsx_gclip(&c);
                                                /* add in drop shadow   */
          c.g_w += 2;
          c.g_h += 2;
        }
        w_bldactive(wh);
        do_walk(wh, gl_awind, obj, depth, &c);
}
Beispiel #5
0
int
main(int argc, char *argv[])
{
	PMEMlogpool *plp;

	START(argc, argv, "log_walker");

	if (argc != 2)
		UT_FATAL("usage: %s file-name", argv[0]);

	const char *path = argv[1];

	int fd = OPEN(path, O_RDWR);

	/* pre-allocate 2MB of persistent memory */
	errno = posix_fallocate(fd, (off_t)0, (size_t)(2 * 1024 * 1024));
	if (errno != 0)
		UT_FATAL("!posix_fallocate");

	CLOSE(fd);

	if ((plp = pmemlog_create(path, 0, S_IWUSR | S_IRUSR)) == NULL)
		UT_FATAL("!pmemlog_create: %s", path);

	/* append some data */
	do_append(plp);

	/* arrange to catch SEGV */
	struct sigaction v;
	sigemptyset(&v.sa_mask);
	v.sa_flags = 0;
	v.sa_handler = signal_handler;
	SIGACTION(SIGSEGV, &v, NULL);

	if (!sigsetjmp(Jmp, 1)) {
		do_walk(plp);
	}

	pmemlog_close(plp);

	DONE(NULL);
}
Beispiel #6
0
static void dump_matching_branch(git_repository *repo, const char *remote, void *arg)
{
	char full_remote[512];
	struct gbr_dump_context *ctx = arg;
	git_object *obj;
	int err;


	snprintf(full_remote, sizeof(full_remote), "remotes/%s/%s",
		 remote,  ctx->local_name);

	obj = NULL;
	err = git_revparse_single(&obj, repo, full_remote);

	switch (err) {
	case GIT_ENOTFOUND:
		/* FIXME: Log this once we have --verbose */
		break;
	case 0:
		break;
	default:
		printf(" %s:%d", remote, err);
		break;
	}

	if (err == 0) {
		if (err == 0) {
			/* fprintf(stderr, "%s(): Looking at %s\n", __func__, local); */
			do_walk(ctx, remote, git_object_id(ctx->local_obj), git_object_id(obj));
		} else {
			/* How could the local object lookup fail _here_? */
			gbr_perror("dump_matching_branch()");
		}
	}

	git_object_free(obj);
}
void cScreenTown::process()
{
	if (!ids_set)set_ids();								// we need to make sure the ID variables are set
	init();
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home
	if (girlimage_id != -1 && !eventrunning)	HideImage(girlimage_id, true);

	/*
	*	otherwise, compare event IDs
	*
	*	if it's the back button, pop the window off the stack
	*	and we're done
	*/
	/* */if (g_InterfaceEvents.CheckButton(back_id))		{ g_InitWin = true;		g_WinManager.Pop();					return; }
	else if (g_InterfaceEvents.CheckButton(slavemarket_id)) { g_InitWin = true;		g_WinManager.push("Slave Market");	return; }
	else if (g_InterfaceEvents.CheckButton(prison_id))		{ g_InitWin = true;		g_WinManager.push("Prison");		return; }
	else if (g_InterfaceEvents.CheckButton(house_id))		{ g_Building = BUILDING_HOUSE;	g_CurrHouse = 0;	g_InitWin = true;	g_WinManager.push("Player House");	return; }
	else if (g_InterfaceEvents.CheckButton(clinic_id))		{ check_clinic(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(studio_id))		{ check_studio(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(arena_id))		{ check_arena(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(centre_id))		{ check_centre(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(farm_id))		{ check_farm(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(mayor_id))		{ g_InitWin = true;		g_WinManager.push("Mayor");	return; }
	else if (g_InterfaceEvents.CheckButton(bank_id))		{ g_InitWin = true;		g_WinManager.push("Bank");	return; }
	else if (g_InterfaceEvents.CheckButton(shop_id))		{ g_InitWin = true;		g_AllTogle = false;	g_WinManager.push("Item Management");	return; }
	else if (g_InterfaceEvents.CheckButton(brothel0_id))	{ check_brothel(0);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel1_id))	{ check_brothel(1);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel2_id))	{ check_brothel(2);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel3_id))	{ check_brothel(3);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel4_id))	{ check_brothel(4);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel5_id))	{ check_brothel(5);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel6_id))	{ check_brothel(6);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(walk_id))		{ do_walk();			if (!g_Cheats) g_WalkAround = true;	g_InitWin = true; }
	else if (g_InterfaceEvents.CheckButton(setup_id))		{ g_InitWin = true;		g_WinManager.push("Property Management");		return; }	// `J` added

}
Beispiel #8
0
/*
 * Performs an inorder traversal of the tree.  An O(n) operation.
 *
 * Parameters:
 * - ptree = Pointer to the tree head structure.
 * - pfnWalk = Pointer to a function called for each tree node we encounter.  This function returns TRUE
 *             to continue the traversal or FALSE to stop it.
 * - pData = Arbitrary data pointer that gets passed to the pfnWalk function.
 *
 * Returns:
 * TRUE if the tree was entirely traversed, FALSE if the tree walk was interrupted.
 */
BOOL RbtWalk(PRBTREE ptree, PFNRBTWALK pfnWalk, PVOID pData)
{
    return (ptree->ptnRoot ? do_walk(ptree, ptree->ptnRoot, pfnWalk, pData) : TRUE);
}
Beispiel #9
0
void wm_set(WORD w_handle, WORD w_field, WORD *pinwds)
{
        WORD            which, liketop, i;
        register WORD   wbar;
        WORD            osl, osz, nsl, nsz;
        GRECT           t;
        WINDOW          *pwin;  

        osl = osz = nsl = nsz = 0;
        which = -1;
                                                /* grab the window sync */
        wm_update(TRUE);
        pwin = &D.w_win[w_handle];
        wbar = wm_gsizes(w_field, &osl, &osz); 
        if (wbar)
        {
          pinwds[0] = max(-1, pinwds[0]);
          pinwds[0] = min(1000, pinwds[0]);
        }
        liketop = ( ( w_handle == gl_wtop ) ||
                    ( pwin->w_flags & VF_SUBWIN ) );
        switch(w_field)
        {
          case WF_NAME:
                which = W_NAME;
                break;
          case WF_INFO:
                which = W_INFO;
                break;
          case WF_SIZTOP:
                ob_order(gl_wtree, w_handle, NIL);
                                                /* fall thru    */
          case WF_CXYWH:
                draw_change(w_handle, (GRECT *)&pinwds[0]);
                break;
          case WF_TOP:
                if (w_handle != gl_wtop)
                {
                  for(i=W_TREE[ROOT].ob_head; i>ROOT; i=W_TREE[i].ob_next)
                  {
                    if ( (i != w_handle) &&
                         (D.w_win[i].w_owner == rlr) &&
                         (D.w_win[i].w_flags & VF_SUBWIN) &&
                         (pwin->w_flags & VF_SUBWIN) )
                      wm_mktop(i);
                  }
                  wm_mktop(w_handle);
                }
                break;
          case WF_NEWDESK:
                pwin->w_owner = rlr;
                desk_tree[rlr->p_pid] = gl_newdesk = *(LONG *) &pinwds[0];
                desk_root[rlr->p_pid] = gl_newroot = pinwds[2];
                break;
          case WF_HSLSIZ:
                pwin->w_hslsiz = pinwds[0];
                break;
          case WF_VSLSIZ:
                pwin->w_vslsiz = pinwds[0];
                break;
          case WF_HSLIDE:
                pwin->w_hslide = pinwds[0];
                break;
          case WF_VSLIDE:
                pwin->w_vslide = pinwds[0];
                break;
          case WF_TATTRB:
                if (pinwds[0] & WA_SUBWIN)
                  pwin->w_flags |= VF_SUBWIN;
                else
                  pwin->w_flags &= ~VF_SUBWIN;
                if (pinwds[0] & WA_KEEPWIN)
                  pwin->w_flags |= VF_KEEPWIN;
                else
                  pwin->w_flags &= ~VF_KEEPWIN;
                break;
        }
        if ( (wbar) &&
             (liketop) )
        {
          w_bldactive(w_handle);
          wm_gsizes(w_field, &nsl, &nsz); 
          if ( (osl != nsl) ||
               (osz != nsz) ||
               (pwin->w_flags & VF_SUBWIN) )
          {
            w_getsize(WS_TRUE, w_handle, &t);
            do_walk(w_handle, gl_awind, wbar + 3, MAX_DEPTH, &t);
          }
        }
        if (which != -1)
          w_strchg(w_handle, which, *(LONG *)pinwds);
                                                /* give up the sync     */
        wm_update(FALSE);
}