コード例 #1
0
ファイル: PrehistobotActions.cpp プロジェクト: Neobot/PC
void ColorScanAction::timeout()
{
	if (!_destinationReached && _destination)
		_finder->stop();

	_destinationReached = true;
	checkEnding();
}
コード例 #2
0
ファイル: PrehistobotActions.cpp プロジェクト: Neobot/PC
void ColorScanAction::destinationReached()
{
	_destinationReached = true;
	if (_timeout)
		_timeout->stop();

	checkEnding();
}
コード例 #3
0
ファイル: PrehistobotActions.cpp プロジェクト: Neobot/PC
void ColorScanAction::armActionFinsihed(ArmState& armState, bool result)
{
	switch(armState)
	{
		case Moving:
			armState = Scanning;
			checkEnding();
			break;
		default:
			Q_ASSERT(false);
			break;
	}
}
コード例 #4
0
/**
 * Display menu and play menu music.
 */
    void
WorldMap::own_resumeState()
{
    LevelNode *nextLevel = NULL;
    if (m_levelStatus->wasRunning()) {
        if (m_levelStatus->isComplete()) {
            markSolved();
            if (checkEnding()) {
                nextLevel = m_ending;
            }
        }
        m_levelStatus->setRunning(false);

        OptionAgent *options = OptionAgent::agent();
        options->setParam("caption", findDesc("menu"));
        options->setParam("screen_width", m_bg->getW());
        options->setParam("screen_height", m_bg->getH());
        VideoAgent::agent()->initVideoMode();
    }
    m_selected = nextLevel;

    SoundAgent::agent()->playMusic(
            Path::dataReadPath("music/menu.ogg"), NULL);
}
コード例 #5
0
ファイル: finds.c プロジェクト: derstling/014SC
/*
* Descend through the hierarchy, starting at "fullpath".
* If "fullpath" is anything other than a directory, we lstat() it,
* call the search function, and return. For a directory, we call ourself
* recursively for each name in the directory.
*/
static int /* we return whatever func() returns */

dopath(char *searchstr, struct FlagOpts *flags)
{
	struct stat statbuf;
	struct dirent *dirp;
	DIR *dp;
	int ret;
	char *ptr;
	
	int errnum;
	errno = 0;

	if (lstat(fullpath, &statbuf) < 0) { /* stat error */
		errnum = errno;
		my_errprintf("Error reading file attribute: %s\n", strerror(errnum) );
	}

	if (S_ISLNK(statbuf.st_mode) != 0) { /* symbolic link */
		if( (*flags).l == 1) { // search symbolic links
			int k = readlink( fullpath, symlpath, PATH_MAX+1 );
			symlpath[k] = '\0';
			if (stat(fullpath, &statbuf) < 0) { /* stat error */
				errnum = errno;
				my_errprintf("Error reading file attribute: %s\n", strerror(errnum) );
			}
		} 
		else { // do not search file or folder
			return 0;
		}
	}

	// Do not read already visited files
	if ( alreadyVisited(statbuf.st_ino) == 1 ) {
		return 0;
	}
	
	if (S_ISDIR(statbuf.st_mode) == 0) { /* not a directory */
		// Skip certain files according to [-f] flags used
		if ( fileTypesFlag == 1 )
		{
			if ( checkEnding('c',fullpath)==1 ) {
				if( flags->c == 0) return 0;
			}
			else if ( checkEnding('h',fullpath)==1 ) {
				if( flags->h == 0) return 0;
			}
			else if ( checkEnding('S',fullpath)==1 ) {
				if( flags->S == 0) return 0;
			}
			else { //other type of file - skip since flag opt used
				return 0;
			}
		}

		// add regular file i-node to list of files visited
		markVisited(statbuf.st_ino);
		return(readfile(fullpath, searchstr, &statbuf, FTW_F));
	}

	/*
* It's a directory. First call func() for the directory,
* then process each filename in the directory.
*/
	// add directory i-node to list of files visited
	markVisited(statbuf.st_ino);

	if ((ret = readfile(fullpath, searchstr, &statbuf, FTW_D)) != 0)
		return(ret);

	ptr = fullpath + strlen(fullpath); /* point to end of fullpath */
	*ptr++ = '/';
	*ptr = 0;

	if ((dp = opendir(fullpath)) == NULL) /* can't read directory */
		return(readfile(fullpath, searchstr, &statbuf, FTW_DNR));

	while ((dirp = readdir(dp)) != NULL) {
		if (strcmp(dirp->d_name, ".") == 0 ||
				strcmp(dirp->d_name, "..") == 0)
			continue; /* ignore dot and dot-dot */
		strcpy(ptr, dirp->d_name); /* append name after slash */
		if ((ret = dopath(searchstr, flags)) != 0) /* recursive */
			break; /* time to leave */
	}

	ptr[-1] = 0; /* erase everything from slash onwards */
	if (closedir(dp) < 0) ;
	return(ret);
}