//
// bool removeCell()
// Last modified: 27Aug2006
//
// Attempts to remove a cell from the environment,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:  <none>
//
bool Environment::removeCell()
{
    Cell *c = NULL;
    if (!removeCell(c)) return false;
    delete c;
    return true;
}   // removeCell()
Beispiel #2
0
void UniformGrid::refine(KdTree * tree)
{    
	int level1;
	float hh;
    Vector3F sample, subs;
	int u;
	unsigned k;
	BoundingBox box;
	m_cellsToRefine->begin();
	while (!m_cellsToRefine->end()) {
		sdb::CellValue * parentCell = m_cellsToRefine->value();
		if(parentCell->visited > 0) {
        
			k = m_cellsToRefine->key();
			
			level1 = parentCell->level + 1;
			hh = cellSizeAtLevel(level1) * .5f;
			sample = cellCenter(k);
			removeCell(k);
			for(u = 0; u < 8; u++) {
				subs = sample + Vector3F(hh * Cell8ChildOffset[u][0], 
				hh * Cell8ChildOffset[u][1], 
				hh * Cell8ChildOffset[u][2]);
				box.setMin(subs.x - hh, subs.y - hh, subs.z - hh);
                box.setMax(subs.x + hh, subs.y + hh, subs.z + hh);
				if(tree->intersectBox(box)) 
					addCell(subs, level1);
			}
		}
		
		m_cellsToRefine->next();
    }
}
Beispiel #3
0
/* Stop the process in the given cell (do not verify if the cell is indeed in 
 * the runningList), i.e.: remove it from the running. The process won't be 
 * running until it start again */
void stop(struct cell * processCell)
{
	void* process = processCell->element;
	removeCell(&runningList, processCell);
	insertAtEnd(&stoppedList, process);
	yield(); /* Yield in case the processus have the processor */
}
Beispiel #4
0
void fileInput(char argv[1], char board[41][41], char tempBoard[41][41]) {
	FILE *fp;
	char input;
	int coordinate1, coordinate2;
	int value = 1;
	
	fp = fopen(argv, "r"); // open file with commands
	blankBoard(board, tempBoard);
	while(value != 0) {
		fscanf(fp, "%c", &input);
		switch(input) {
			case 'a': // create new cell
				fscanf(fp, "%i%i", &coordinate1, &coordinate2);
				newCell(coordinate1, coordinate2, board);
				break;
			case 'r': // remove cell
				fscanf(fp, "%i%i", &coordinate1, &coordinate2);
				removeCell(coordinate1, coordinate2, board);
				break;
			case 'n': // next iteration
				advance(board, tempBoard);
				break;
			case 'q': // quit
				value = 0;
				break;
			case 'p': // run forever
				while(1) {
					advance(board, tempBoard);
					usleep(100000);
				}
				break;
		}
	}
}
Beispiel #5
0
void Board::removeLines()
{
	int score = 14 * m_level;

	// Loop through full lines
	for (int i = 0; i < 4; ++i) {
		int row = m_full_lines[i];
		if (row == -1)
			break;

		// Remove line
		for (int col = 0; col < 10; ++col) {
			removeCell(col, row);
		}
		++m_removed_lines;
		++m_topCellY;
		score *= 3;

		// Shift board down
		for (; row > 0; --row) {
			for (int col = 0; col < 10; ++col) {
				m_cells[col][row] = m_cells[col][row - 1];
			}
		}
	}

	// Remove top line
	if (m_full_lines[0] != -1) {
		for (int col = 0; col < 10; ++col) {
			removeCell(col, 0);
		}
	}

	m_level = (m_removed_lines / 10) + 1;
	//m_shift_timer->setInterval(10000 / (m_removed_lines + 20));
	m_score += score;
	emit levelUpdated(m_level);
	emit linesRemovedUpdated(m_removed_lines);
	emit scoreUpdated(m_score);

	// Empty list of full lines
	for (int i = 0; i < 4; ++i)
		m_full_lines[i] = -1;

	// Add new piece
	createPiece();
}
Beispiel #6
0
void TileLogicCmp::onDestroyed (OnTileDestroyed* event_){
	if (!event_->_tile)
		return;
  if(event_->_tile == getEntity()){
    auto level = Director::getInstance()->getRunningScene()->getLevel();
    auto pos = getEntity()->GET_CMP(PositionComponent)->getPosition();
    Eigen::Vector2i idx = level->posToTileIndex(pos);
    level->removeCell(idx.x(), idx.y());
		event_->_tile = nullptr;}}
Beispiel #7
0
void TissueState::removeMarginCells() {
  for(set<CellIndex>::iterator it=_ignoredCells.begin(); it!=_ignoredCells.end(); ++it) {
    if(contains(*it)) {
      removeCell(*it);
    } else {
      cout << "TissueState::removeMarginCells: did not find cell with id " << *it << "!" << endl;
      throw std::exception();
    }
  }
}
Beispiel #8
0
void CMesh::cleanActiveCells() {
	list<CCell*>::iterator it = activeCells.begin(), end = activeCells.end();
	for (;it != end; ++it) 
		if ( !(*it)->getActive()) {
#ifdef HYDRO_BOOST_THREADS
			removeCell(it);
#else
			activeCells.erase(it);
#endif
		}
	
}
Beispiel #9
0
int16 Op_RemoveCell() {
	int objType = popVar();
	int objectIdx = popVar();
	int ovlNumber = popVar();

	if (!ovlNumber) {
		ovlNumber = currentScriptPtr->overlayNumber;
	}

	removeCell(&cellHead, ovlNumber, objectIdx, objType, masterScreen);

	return 0;
}
Beispiel #10
0
int16 Op_RemoveMessage() {
	int idx;
	int overlay;

	idx = popVar();
	overlay = popVar();

	if (!overlay) {
		overlay = currentScriptPtr->overlayNumber;
	}

	removeCell(&cellHead, overlay, idx, 5, masterScreen);

	return (0);
}
Beispiel #11
0
/*
 * Delete current process, i.e. remove from runningList, free the Cell, 
 * and switch process. Free the stack too.
 */
void deleteProcess()
{
	struct processDescriptor* process = (struct processDescriptor*)
		 removeCell(&runningList, getIndex(&runningList, 0));
	LOG("Deleting process : ");
	LOG_INT((int) process->pid);
	LOG_CONT("\n");
	free2M(process->map.baseAddress);
	if(process->baseAddress) /* If stored in kernel memory*/
	{
		kfree(process->baseAddress);
	}
	kfree(process);
	struct processDescriptor* next = 
		(struct processDescriptor *) getIndex(&runningList, 0)->element;
	restartProcess(&(next->processState));
}
Beispiel #12
0
int userInput(char board[41][41], char tempBoard[41][41]) {
	char input;
	int coordinate1, coordinate2;
	int value;

	printf("\nPlease select an option.\na: Create a new cell\nr: Remove a cell\nn: Advance to the next iteration\nq: Quit\np: Play the game continuously\n");
	scanf("%c", &input);
	while(getchar() != '\n');
	switch(input) {
		case 'a':
			printf("Enter coordinates (row, column) for a new live cell: ");
			scanf("%i%i", &coordinate1, &coordinate2);
			while(getchar() != '\n');
			newCell(coordinate1, coordinate2, board);
			value = 1;
			break;
		case 'r':
			printf("Enter coordinates (row, column) to remove a cell: ");
			scanf("%i%i", &coordinate1, &coordinate2);
			while(getchar() != '\n');
			removeCell(coordinate1, coordinate2, board);
			value = 1;
			break;
		case 'n': // advance to next iteration
			advance(board, tempBoard);
			value = 1;
			break;
		case 'q': // to quit
			value = 0;
			break;
		case 'p': // run game forever
			while(1) {
				advance(board, tempBoard);
				usleep(100000);
			}
			value = 1;
			break;
		default:
			printf("This is not a valid option. Try again.\n");
			value = 1;
			break;
	}
	return value;
}
//
// void clear()
// Last modified: 27Aug2006
//
// Clears this environment.
//
// Returns:     <none>
// Parameters:  <none>
//
void Environment::clear()
{
    while (removeCell());
}   // clear()
Beispiel #14
0
//This function clusters based on the single linkage method.
void  SingleLinkage::update(double& cutOFF){
	try {
		getRowColCells();	
	
		vector<bool> deleted(nRowCells, false);
		int rowInd;
		int search;
		bool changed;

		// The vector has to be traversed in reverse order to preserve the index
		// for faster removal in removeCell()
		for (int i=nRowCells-1;i>=0;i--) {
			if ((rowCells[i]->row == smallRow) && (rowCells[i]->column == smallCol)) {
				rowInd = i;   // The index of the smallest distance cell in rowCells
			} else {
				if (rowCells[i]->row == smallRow) {
					search = rowCells[i]->column;
				} else {
					search = rowCells[i]->row;
				}
		
				for (int j=0;j<nColCells;j++) {
					if (!((colCells[j]->row == smallRow) && (colCells[j]->column == smallCol))) {
						if (colCells[j]->row == search || colCells[j]->column == search) {
							changed = updateDistance(colCells[j], rowCells[i]);
							// If the cell's distance changed and it had the same distance as 
							// the smallest distance, invalidate the mins vector in SparseMatrix
							if (changed) {
								if (colCells[j]->vectorMap != NULL) {
									*(colCells[j]->vectorMap) = NULL;
									colCells[j]->vectorMap = NULL;
								}
							}
							removeCell(rowCells[i], i , -1);
							deleted[i] = true;
							break;
						}
					}
				}
				if (!deleted[i]) {
					// Assign the cell to the new cluster 
					// remove the old cell from seqVec and add the cell
					// with the new row and column assignment again
					removeCell(rowCells[i], i , -1, false);
					if (search < smallCol){
						rowCells[i]->row = smallCol;
						rowCells[i]->column = search;
					} else {
						rowCells[i]->row = search;
						rowCells[i]->column = smallCol;
					}
					seqVec[rowCells[i]->row].push_back(rowCells[i]);
					seqVec[rowCells[i]->column].push_back(rowCells[i]);
				}
			}	
		}
		clusterBins();
		clusterNames();
		// remove also the cell with the smallest distance

		removeCell(rowCells[rowInd], -1 , -1);
	}
	catch(exception& e) {
		m->errorOut(e, "SingleLinkage", "update");
		exit(1);
	}
}
Beispiel #15
0
 foreach ( QWidget* widg, m_cells )
 {
     removeCell( widg );
     delete widg;
 }
Beispiel #16
0
/* Start the process in the given cell (do not verify if the cell is indeed in 
 * the stoppedList), i.e.: add it to the running list. The process may not 
 * run immediately*/
void start(struct cell * processCell)
{
	void* process = processCell->element;
	removeCell(&stoppedList, processCell);
	insertAtEnd(&runningList, process);
}
Beispiel #17
0
Datei: WTable.C Projekt: DTidd/wt
void WTable::removeCell(WTableCell *item)
{
  removeCell(item->row(), item->column());
}
Beispiel #18
0
 void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell)
 {
   removeCell(cell);
 }
Beispiel #19
0
ClipListViewController::~ClipListViewController()
{
    foreach( QWidget* cell, m_cells.values() )
        removeCell( cell );
}
Beispiel #20
0
void CruiseEngine::mainLoop() {
	//int32 t_start,t_left;
	//uint32 t_end;
	//int32 q=0;                     /* Dummy */
	int16 mouseX, mouseY;
	int16 mouseButton;

	int enableUser = 0;

	strcpy(nextOverlay, "");
	strcpy(lastOverlay, "");
	strcpy(cmdLine, "");

	currentActiveMenu = -1;
	autoMsg = -1;
	linkedRelation = 0;
	main21 = 0;
	main22 = 0;
	userWait = 0;
	autoTrack = false;

	initAllData();

	playerDontAskQuit = 0;
	int quitValue2 = 1;
	int quitValue = 0;

	if (ConfMan.hasKey("save_slot"))
		loadGameState(ConfMan.getInt("save_slot"));

	do {
		// Handle frame delay
		uint32 currentTick = g_system->getMillis();

		if (!bFastMode) {
			// Delay for the specified amount of time, but still respond to events
			bool skipEvents = false;

			do {
				g_system->delayMillis(10);
				currentTick = g_system->getMillis();

				if (!skipEvents)
					skipEvents = manageEvents();

				if (playerDontAskQuit)
					break;

				_vm->getDebugger()->onFrame();
			} while (currentTick < lastTick + _gameSpeed);
		} else {
			manageEvents();

			if (currentTick >= (lastTickDebug + 10)) {
				lastTickDebug = currentTick;
				_vm->getDebugger()->onFrame();
			}
		}
		if (playerDontAskQuit)
			break;

		lastTick = g_system->getMillis();

		// Handle switchover in game speed after intro
		if (!_speedFlag && canLoadGameStateCurrently()) {
			_speedFlag = true;
			_gameSpeed = GAME_FRAME_DELAY_2;
		}

		// Handle the next frame

//		frames++;
//      t_start=Osystem_GetTicks();

//      readKeyboard();

		bool isUserWait = userWait != 0;
		playerDontAskQuit = processInput();
		if (playerDontAskQuit)
			break;

		if (enableUser) {
			userEnabled = 1;
			enableUser = 0;
		}

		if (userDelay && !userWait) {
			userDelay--;
			continue;
		}

		if (isUserWait & !userWait) {
			// User waiting has ended
			changeScriptParamInList(-1, -1, &procHead, 9999, 0);
			changeScriptParamInList(-1, -1, &relHead, 9999, 0);

			// Disable any mouse click used to end the user wait
			currentMouseButton = 0;
		}

		// FIXME: I suspect that the original game does multiple script executions between game frames; the bug with
		// Raoul appearing when looking at the book is being there are 3 script iterations separation between the
		// scene being changed to the book, and the Raoul actor being frozen/disabled. This loop is a hack to ensure
		// that when a background changes, a few extra script executions are done
		bool bgChanged;
		int numIterations = 1;

		while (numIterations-- > 0) {
			bgChanged = backgroundChanged[masterScreen];
		
			manageScripts(&relHead);
			manageScripts(&procHead);

			removeFinishedScripts(&relHead);
			removeFinishedScripts(&procHead);

			if (!bgChanged && backgroundChanged[masterScreen]) {
				bgChanged = true;
				numIterations += 2;
			}
		}

		processAnimation();

		if (remdo) {
			// ASSERT(0);
			/*    main3 = 0;
			 * var24 = 0;
			 * var23 = 0;
			 *
			 * freeStuff2(); */
		}

		if (cmdLine[0]) {
			ASSERT(0);
			/*        redrawStrings(0,&cmdLine,8);

			        waitForPlayerInput();

			        cmdLine = 0; */
		}

		if (displayOn) {
			if (doFade)
				PCFadeFlag = 0;

			/*if (!PCFadeFlag)*/
			mainDraw(userWait);
			flipScreen();

			if (userEnabled && !userWait && !autoTrack) {
				if (currentActiveMenu == -1) {
					static int16 oldMouseX = -1;
					static int16 oldMouseY = -1;

					getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY);

					if (mouseX != oldMouseX || mouseY != oldMouseY) {
						int objectType;
						int newCursor1;
						int newCursor2;

						oldMouseX = mouseX;
						oldMouseY = mouseY;

						objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2);

						if (objectType == 9) {
							changeCursor(CURSOR_EXIT);
						} else if (objectType != -1) {
							changeCursor(CURSOR_MAGNIFYING_GLASS);
						} else {
							changeCursor(CURSOR_WALK);
						}
					}
				} else {
					changeCursor(CURSOR_NORMAL);
				}
			} else {
				changeCursor(CURSOR_NORMAL);
			}

			if (userWait == 1) {
				// Waiting for press - original wait loop has been integrated into the
				// main event loop
				continue;
			}

			// wait for character to finish auto track
			if (autoTrack) {
				if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) {
					if (autoMsg != -1) {
						freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0);

						char* pText = getText(autoMsg, autoOvl);

						if (strlen(pText))
							userWait = 1;
					}

					changeScriptParamInList(-1, -1, &relHead, 9998, 0);
					autoTrack = false;
					enableUser = 1;
				} else {
					userEnabled = false;
				}
			} else if (autoMsg != -1) {
				removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen);
				autoMsg = -1;
			}
		} else {
			// Keep ScummVM being responsive even when displayOn is false
			g_system->updateScreen();
		}

	} while (!playerDontAskQuit && quitValue2 && quitValue != 7);

	// Free data
	removeAllScripts(&relHead);
	removeAllScripts(&procHead);
	resetActorPtr(&actorHead);
	freeOverlayTable();
	closeCnf();
	closeBase();
	resetFileEntryRange(0, NUM_FILE_ENTRIES);
	freeObjectList(&cellHead);
	freeBackgroundIncrustList(&backgroundIncrustHead);
}