コード例 #1
0
        void mergeGroups(Pixel pixel1, Pixel pixel2) {

            Pixel eraseGroupPixel=  at(pixel1) > at(pixel2) ? pixel1 : pixel2;
            Pixel pixelOfGroupToExpand= at(pixel1) > at(pixel2) ? pixel2 : pixel1;

            uint32_t eraseNumber= at(eraseGroupPixel); 
            uint32_t expandNumber= at(pixelOfGroupToExpand); 

            std::vector<Pixel> toDoStack;

            toDoStack.push_back(eraseGroupPixel);
            while (!toDoStack.empty()) {
                Pixel pixel= toDoStack.back();
                toDoStack.pop_back();
                
                if (isInGroup(pixel) && at(pixel) == eraseNumber) {
                    at(pixel)= expandNumber;
                    if (pixel.y != 0) {
                        toDoStack.push_back(pixel.highNeighbor());
                    }
                    if (pixel.x != width - 1) {
                        toDoStack.push_back(pixel.rightNeighbor());
                    }
                    if (pixel.y != height - 1) {
                        toDoStack.push_back(pixel.lowNeighbor());
                    }
                    if (pixel.x != 0) {
                        toDoStack.push_back(pixel.leftNeighbor());
                    }
                }
            }
            merge_count++;
        }
コード例 #2
0
ファイル: srvauth.c プロジェクト: layerfsd/cifssmb
/* returns the accumulated access rights due to group membership     */
byte Auth_BestAccess (PSMB_SESSIONCTX pCtx, word tid)
{
    word i;
    PUSER user;
    byte best = SECURITY_NONE;

    user = SMBU_GetUser (pCtx, pCtx->uid);

    CLAIM_AUTH ();
    for (i = 0; i < prtsmb_srv_ctx->groupList.numGroups; i ++)
    {
        if (isInGroup (user->authId, i) == TRUE)
        {
            byte actualMode = getMode (&prtsmb_srv_ctx->groupList.groups[i], tid);

            best = mergeAccessRights (best, actualMode);

/*          PRINTF (("user %s in group " RTSMB_STR_TOK " gets permissions %i\n",                                     */
/*              prtsmb_srv_ctx->userList.users[user->authId].name, prtsmb_srv_ctx->groupList.groups[i].name, best));    */

            /* early exit, since can't get better than this */
            if (best == SECURITY_READWRITE)
                break;
        }
    }
    RELEASE_AUTH ();

    return best;
}
コード例 #3
0
bool
Connect::isCompatible(const Port* portInfo0, const Port* portInfo1) const
{
  if (!portInfo0)
    return true;
  if (!portInfo1)
    return true;
  if (!isInGroup(*portInfo0)) {
    Log(Model, Warning) << "Port is in different group than model" << std::endl;
    return false;
  }
  if (!isInGroup(*portInfo1)) {
    Log(Model, Warning) << "Port is in different group than model" << std::endl;
    return false;
  }
  // Just a crude first time check if this will work in principle.
  return portInfo0->canConnect(*portInfo1);
}
コード例 #4
0
 uint32_t getGroupNumber(Pixel pixel) const {
     if (!isInGroup(pixel)) {
         LOG("ERROR: getGroupNumber called for a pixel not in group");
     }
     return at(pixel);
 }
コード例 #5
0
ファイル: maps.c プロジェクト: ecalot/princed
void* mapLoadLevel(tMemory level) {
	tMap* map=(tMap*)malloc(sizeof(tMap));
	int i,j;
	int gates=0;
	int gateInRoom=0;
	int pressables=0;
	int pressableInRoom=0;
	int dangers=0;
	int dangerInRoom=0;
	tGate** auxGates=malloc(sizeof(tGate*)*24*30);
	map->flyingObjects=NULL;
	
	/* copy maps, links and start position */
	memcpy(map->fore,level.array+MAPS_BLOCK_OFFSET_WALL,30*24);
	memcpy(map->back,level.array+MAPS_BLOCK_OFFSET_BACK,30*24);
	memcpy(map->start,level.array+MAPS_BLOCK_OFFSET_START_POSITION,3);
	memcpy(map->links,level.array+MAPS_BLOCK_OFFSET_LINK,4*24);

	/* generate and load tPressable and tGate structures */
	for (i=0;i<24;i++) { /* count gates and create gate tree middle nodes */
		for (j=0;j<30;j++) {
/*			if (((map->fore[i*30+j]&0x1f)==TILE_GATE)||((map->fore[i*30+j]&0x1f)==TILE_EXIT_LEFT)) {*/
			if (isInGroup(map->fore[i*30+j],0,TILES_GATES)) {
				gateInRoom++;
				gates++;
			} else if (isInGroup(map->fore[i*30+j],0,TILES_PRESSABLE)) {
/*			} else if (((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==TILE_BTN_DROP)) {*/
				pressableInRoom++;
				pressables++;
			} else if (isInGroup(map->fore[i*30+j],0,TILES_CHOPPER_SPIKE)) {
				dangerInRoom++;
				dangers++;
			}
		}
		if (gateInRoom) {
			map->screenGates[i]=malloc(gateInRoom*sizeof(tGate*));
		} else {
			map->screenGates[i]=NULL;
		}
		if (pressableInRoom) {
			map->screenPressables[i]=malloc(pressableInRoom*sizeof(tPressable*));
		} else {
			map->screenPressables[i]=NULL;
		}
		if (dangerInRoom) {
			map->screenDangers[i]=malloc(dangerInRoom*sizeof(tDanger*));
		} else {
			map->screenDangers[i]=NULL;
		}
		gateInRoom=0;
		pressableInRoom=0;
		dangerInRoom=0;
	}
	/* create gates sctucture */
	map->gates=malloc(gates*sizeof(tGate));
	map->totalGates=gates;
	map->pressables=malloc(pressables*sizeof(tPressable));
	map->totalPressables=pressables;
	map->dangers=malloc(dangers*sizeof(tDanger));
	map->totalDangers=dangers;
	gates=0;
	pressables=0;
	dangers=0;
	for (i=0;i<24;i++) {
		for (j=0;j<30;j++) {
			if (isInGroup(map->fore[i*30+j],0,TILES_GATES)) {
			/*if (((map->fore[i*30+j]&0x1f)==TILE_GATE)||((map->fore[i*30+j]&0x1f)==TILE_EXIT_LEFT)) {*/
				tGate newGate;
				newGate.frame=map->back[i*30+j];
				newGate.action=map->back[i*30+j]?eClose:eOpen;
				newGate.type=((map->fore[i*30+j]&0x1f)==TILE_GATE)?eNormalGate:eExitGate;
				map->back[i*30+j]=gateInRoom;
				map->screenGates[i][gateInRoom]=map->gates+gates;
				auxGates[i*30+j]=map->gates+gates;
#ifdef DEBUGMAPS
				fprintf(stderr,"mapLoadLevel: Loading gate: indexed=%d gate pointer=%p\n",i,(void*)auxGates[i*30+j]);
#endif
				map->gates[gates++]=newGate;
				gateInRoom++;
			/*} else if (((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==TILE_BTN_DROP)) {*/
			} else if (isInGroup(map->fore[i*30+j],0,TILES_PRESSABLE)) {
				tPressable newPressable;
				newPressable.event=map->events+map->back[i*30+j];
				newPressable.action=eNormal;
				newPressable.type=((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)?eRaise:eDrop;
				map->back[i*30+j]=pressableInRoom;
				map->screenPressables[i][pressableInRoom]=map->pressables+pressables;
#ifdef DEBUGMAPS
				fprintf(stderr,"mapLoadLevel: Creating button: indexed=%d,%d btn pointer=%p\n",i,pressableInRoom,(void*)(map->pressables+pressables));
#endif
				map->pressables[pressables++]=newPressable;
				pressableInRoom++;
			} else if (isInGroup(map->fore[i*30+j],0,TILES_CHOPPER_SPIKE)) {
				tDanger newDanger;
				/* initialize the tDanger object*/
	 			newDanger.frame=0;
	 			newDanger.more.time=1;
				switch (map->fore[i*30+j]&0x1f) {
				case TILE_CHOPPER:
					newDanger.action=eChoInactive;
					break;
				case TILE_SPIKES:
					newDanger.action=eSpiDown;
					break;
				case TILE_LOOSE:
					newDanger.action=eLosNormal;
					newDanger.pos=i*30+j;
					break;
				}
				map->back[i*30+j]=dangerInRoom;
				map->screenDangers[i][dangerInRoom]=map->dangers+dangers;
#ifdef DEBUGMAPS
				fprintf(stderr,"mapLoadLevel: Creating danger tile: indexed=%d,%d btn pointer=%p\n",i,dangerInRoom,(void*)(map->dangers+dangers));
#endif
				map->dangers[dangers++]=newDanger;
				dangerInRoom++;
			}
		}
		if (!gateInRoom) map->screenGates[i]=NULL;
		if (!pressableInRoom) map->screenPressables[i]=NULL;
		if (!dangerInRoom) map->screenDangers[i]=NULL;
		gateInRoom=0;
		pressableInRoom=0;
		dangerInRoom=0;
	}

	/* read event list from file and convert it into the event array in memory */
	for (i=0;i<256;i++) {
		unsigned char byte1=level.array[MAPS_BLOCK_OFFSET_GATE_1+i];
		unsigned char byte2=level.array[MAPS_BLOCK_OFFSET_GATE_2+i];
		int S,L,T;
		S=((byte1>>5)&3)|((byte2>>3)&28);
		L=byte1&31;
		T=!((byte1>>7)&1);
		map->events[i].triggerNext=T;
		map->events[i].gate=auxGates[(S-1)*30+L]; /* in case of error null is assigned */
	}
	free(auxGates);
	map->refresh=0;
	
	return (void*)map;
}