예제 #1
0
void DataProcesser::updateData()
{
	// 因为share_gl中的rotation是持续增长的, 因此要做个求余
	int abs_rotation = (share_gl->rotation) % (settings->pieces_in_pottery);

	//检查手有没有触发按钮
	checkButtonAndAction();
	// 先检测右手
	Piece* this_piece = &(share_gl->pieces[abs_rotation]);
	doModify(this_piece, 1);
	// 再检左手
	abs_rotation = (abs_rotation + settings->pieces_in_pottery/2)%
			(settings->pieces_in_pottery);
	this_piece = &(share_gl->pieces[abs_rotation]);
	doModify(this_piece, 0);

	//doFixPiece();

	// 旋转
	share_gl->rotation += 1;
}
예제 #2
0
bool CHistoryManager::undo()
{
	if ( m_undoAction.size() == 0 )
		return false;	

	getIView()->getDocument()->clearSelect();		

	m_disable = true;

	HistoryAction lastAction = m_undoAction.back();
	SAction* action;

	bool isFailed = false;	
	
	int nAction = lastAction.size();
	for ( int iAction = nAction - 1; iAction >= 0; iAction-- )
	{
		action = &lastAction[iAction];

		if ( action->actionType == CHistoryManager::CreateObject )
		{
			if ( doCreate( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::DeleteObject )
		{
			if ( doDelete( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::ModifyObject )
		{
			if ( doModify( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
	}

	if ( isFailed == true )
	{				
		m_redoAction.clear();
		m_undoAction.clear();
	}
	else
	{
		m_redoAction.push_back( lastAction );
		m_undoAction.pop_back();
	}
	
	getIView()->setObjectProperty( NULL );
	m_disable = false;

	return true;
}
예제 #3
0
bool CHistoryManager::redo()
{
	if ( m_redoAction.size() == 0 )	
		return false;	

	getIView()->getDocument()->clearSelect();		

	m_disable = true;

	HistoryAction lastAction = m_redoAction.back();
	SAction* action;

	bool isFailed = false;

	HistoryAction::iterator i = lastAction.begin(), end = lastAction.end();
	while ( i != end )
	{
		action = &(*i);

		if ( action->actionType == CHistoryManager::CreateObject )
		{		
			if ( doCreate( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::DeleteObject )
		{
			if ( doDelete( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::ModifyObject )
		{			
			if ( doModify( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}

		++i;
	}

	if ( isFailed == true )
	{
		m_redoAction.clear();
		m_undoAction.clear();
		return false;
	}
	else
	{
		m_undoAction.push_back( lastAction );
		m_redoAction.pop_back();		
	}


	// update box
	getIView()->setObjectProperty( NULL );
	m_disable = false;

	return true;
}
예제 #4
0
파일: bnlutil.c 프로젝트: cluenet/cluevpn
int main(int argc, char **argv) {
	char *optstring = "c:t:b:";
	int copt;
	char bnlspecified = 0;
	int r;
	char *rptr;
	newtimestamp = time(NULL);
	argv0 = argv[0];
	if(argc < 2) {
		printUsage(argv[0]);
		return 1;
	}
	for(;;) {
		copt = getopt(argc, argv, optstring);
		if(copt == -1) break;
		if(copt == '?') {
			fprintf(stderr, "Invalid option.");
			return 1;
		}
		switch(copt) {
			case 'c':
				strcpy(configfile_dir, optarg);
				break;
			case 't':
				newtimestamp = atoi(optarg);
				break;
			case 'b':
				strcpy(bnl_filename, optarg);
				bnlspecified = 1;
				break;
		}
	}
	// Get orig directory
	rptr = getcwd(configfile_origdir, CONFIGFILE_FILENAME_LEN);
	// cd to the new directory
	r = chdir(configfile_dir);
	if(r != 0) {
		fprintf(stderr, "Error changing to configfile dir");
		return 1;
	}
	// Load config file
	if(configfile_load() != CONFIGFILE_OK) { fprintf(stderr, "Error loading config file.\n"); return 1; }
	// Load SSL error strings
	SSL_load_error_strings();
	// Initialize signatures
	if(sig_init() != SIG_OK) { fprintf(stderr, "Error initializing signatures.\n"); return 1; }
	// Command
	if(argc - optind < 1) {
		printUsage(argv[0]);
		return 1;
	}
	if(bnlspecified) r = chdir(configfile_origdir);
	if(strcmp(argv[optind], "print") == 0) {
		if(argc - optind != 1) {
			printUsage(argv[0]);
			return 1;
		}
		return doPrintBNL();
	}
	if(strcmp(argv[optind], "new") == 0) {
		if(argc - optind != 1) {
			printUsage(argv[0]);
			return 1;
		}
		return doNew(newtimestamp);
	}
	if(strcmp(argv[optind], "add") == 0) {
		return doAdd(argc - optind - 1, &argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "modify") == 0) {
		return doModify(argc - optind - 1, &argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "remove") == 0) {
		if(argc - optind != 2) {
			printUsage(argv[0]);
			return 1;
		}
		return doRemove(argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "addsubnet") == 0) {
		if(argc - optind != 3) {
			printUsage(argv[0]);
			return 1;
		}
		return doAddSubnet(argv[optind + 1], argv[optind + 2], newtimestamp);
	}
	if(strcmp(argv[optind], "delsubnet") == 0) {
		if(argc - optind != 3) {
			printUsage(argv[0]);
			return 1;
		}
		return doDelSubnet(argv[optind + 1], argv[optind + 2], newtimestamp);
	}
	printUsage(argv[0]);
	return 1;
}