Exemplo n.º 1
0
static void setdate(cell year,cell month,cell day)
{
  int maxday;

  #if defined __WIN32__ || defined _WIN32 || defined WIN32
    SYSTEMTIME systim;

    GetLocalTime(&systim);
    if (year!=CELLMIN)
      systim.wYear=(WORD)wrap((int)year,1970,2099);
    if (month!=CELLMIN)
      systim.wMonth=(WORD)wrap((int)month,1,12);
    maxday=monthdays[systim.wMonth - 1];
    if (systim.wMonth==2 && ((systim.wYear % 4)==0 && ((systim.wYear % 100)!=0 || (systim.wYear % 400)==0)))
      maxday++;
    if (day!=CELLMIN)
      systim.wDay=(WORD)wrap((int)day,1,maxday);
    SetLocalTime(&systim);
  #else
    /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you
     * must have "root" permission to call stime()
     */
    time_t sec1970;
    struct tm gtm;

    time(&sec1970);
    gtm=*localtime(&sec1970);
    if (year!=CELLMIN)
      gtm.tm_year=year-1900;
    if (month!=CELLMIN)
      gtm.tm_mon=month-1;
    if (day!=CELLMIN)
      gtm.tm_mday=day;
    sec1970=mktime(&gtm);
    stime(&sec1970);
  #endif
}
Exemplo n.º 2
0
void BL_Action::Update(float curtime)
{
	// Don't bother if we're done with the animation
	if (m_done)
		return;

	curtime -= KX_KetsjiEngine::GetSuspendedDelta();

	// Grab the start time here so we don't end up with a negative m_localtime when
	// suspending and resuming scenes.
	if (m_starttime < 0)
		m_starttime = curtime;

	if (m_calc_localtime)
		SetLocalTime(curtime);
	else
	{
		ResetStartTime(curtime);
		m_calc_localtime = true;
	}

	// Handle wrap around
	if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) {
		switch (m_playmode) {
			case ACT_MODE_PLAY:
				// Clamp
				m_localtime = m_endframe;
				m_done = true;
				break;
			case ACT_MODE_LOOP:
				// Put the time back to the beginning
				m_localtime = m_startframe;
				m_starttime = curtime;
				break;
			case ACT_MODE_PING_PONG:
				// Swap the start and end frames
				float temp = m_startframe;
				m_startframe = m_endframe;
				m_endframe = temp;

				m_starttime = curtime;

				break;
		}
	}

	if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
	{
		BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
		obj->GetPose(&m_pose);

		// Extract the pose from the action
		{
			Object *arm = obj->GetArmatureObject();
			bPose *temp = arm->pose;

			arm->pose = m_pose;
			animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);

			arm->pose = temp;
		}

		// Handle blending between armature actions
		if (m_blendin && m_blendframe<m_blendin)
		{
			IncrementBlending(curtime);

			// Calculate weight
			float weight = 1.f - (m_blendframe/m_blendin);

			// Blend the poses
			game_blend_poses(m_pose, m_blendinpose, weight);
		}


		// Handle layer blending
		if (m_layer_weight >= 0)
		{
			obj->GetMRDPose(&m_blendpose);
			game_blend_poses(m_pose, m_blendpose, m_layer_weight);
		}

		obj->SetPose(m_pose);

		obj->SetActiveAction(NULL, 0, curtime);
	}
	else
	{
		BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
		BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());

		// Handle shape actions if we have any
		if (shape_deformer && shape_deformer->GetKey())
		{
			Key *key = shape_deformer->GetKey();


			animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);

			// Handle blending between shape actions
			if (m_blendin && m_blendframe < m_blendin)
			{
				IncrementBlending(curtime);

				float weight = 1.f - (m_blendframe/m_blendin);

				// We go through and clear out the keyblocks so there isn't any interference
				// from other shape actions
				KeyBlock *kb;
				for (kb=(KeyBlock*)key->block.first; kb; kb=(KeyBlock*)kb->next)
					kb->curval = 0.f;

				// Now blend the shape
				BlendShape(key, weight, m_blendinshape);
			}

			// Handle layer blending
			if (m_layer_weight >= 0)
			{
				obj->GetShape(m_blendshape);
				BlendShape(key, m_layer_weight, m_blendshape);
			}

			obj->SetActiveAction(NULL, 0, curtime);
		}

		m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
	}
}
Exemplo n.º 3
0
static BOOL ParseTime (LPTSTR s)
{
	SYSTEMTIME t;
	LPTSTR p = s;

	if (!*s)
		return TRUE;

	GetLocalTime (&t);
	t.wHour = 0;
	t.wMinute = 0;
	t.wSecond = 0;
	t.wMilliseconds = 0;

	// first get hour
	if (_istdigit(*p))
	{
		while (_istdigit(*p))
		{
			t.wHour = t.wHour * 10 + *p - _T('0');
			p++;
		}
	}
	else
		return FALSE;

	// get time separator
	if (*p != cTimeSeparator)
		return FALSE;
	p++;

	// now get minutes
	if (_istdigit(*p))
	{
		while (_istdigit(*p))
		{
			t.wMinute = t.wMinute * 10 + *p - _T('0');
			p++;
		}
	}
	else
		return FALSE;

	// get time separator
	if (*p != cTimeSeparator)
		return FALSE;
	p++;

	// now get seconds
	if (_istdigit(*p))
	{
		while (_istdigit(*p))
		{
			t.wSecond = t.wSecond * 10 + *p - _T('0');
			p++;
		}
	}
	else
		return FALSE;

	// get decimal separator
	if (*p == cDecimalSeparator)
	{
		p++;

		// now get hundreths
		if (_istdigit(*p))
		{
			while (_istdigit(*p))
			{
//				t.wMilliseconds = t.wMilliseconds * 10 + *p - _T('0');
				p++;
			}
//			t.wMilliseconds *= 10;
		}
	}

	/* special case: 12 hour format */
	if (nTimeFormat == 0)
	{
		if (_totupper(*s) == _T('P'))
		{
			t.wHour += 12;
		}

		if ((_totupper(*s) == _T('A')) && (t.wHour == 12))
		{
			t.wHour = 0;
		}
	}

	if (t.wHour > 23 || t.wMinute > 60 || t.wSecond > 60 || t.wMilliseconds > 999)
		return FALSE;

	SetLocalTime (&t);

	return TRUE;
}
Exemplo n.º 4
0
BOOL CSVToolDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	ShowWindow(SW_SHOW);
	m_Font.CreatePointFont(100, _T("微软雅黑"), NULL);
	m_static.SetFont(&m_Font, true);

	// TODO: 在此添加额外的初始化代码
	SetWindowText(_T("SVTool - V1.0"));
	
	CRect tabRect;

	m_tab.InsertItem(0,_T("ACPI"));
	m_tab.InsertItem(1,_T("CCTool"));

	CCTool.Create(IDD_DIALOG_CCTool, &m_tab);
	ACPI.Create(IDD_DIALOG_ACPI, &m_tab);

	m_tab.GetClientRect(&tabRect);
	tabRect.left += 5;                  
    tabRect.right -= 5;   
    tabRect.top += 25;   
    tabRect.bottom -= 5;

	//设置子对话框尺寸并移动到指定位置

	ACPI.MoveWindow(&tabRect);
	CCTool.MoveWindow(&tabRect);

	//分别设置隐藏和显示
	ACPI.ShowWindow(true);
	CCTool.ShowWindow(false);

	m_tab.SetCurSel(0);

	// 根据调整好的tabRect放置m_jzmDlg子对话框,并设置为显示   
    // CCTool.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);   
    // 根据调整好的tabRect放置m_androidDlg子对话框,并设置为隐藏   
    //ACPI.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

	//ACPI
	TCHAR rbPath[MAX_PATH];
	GetModuleFileName(NULL,rbPath,MAX_PATH);
	ACPI.rootpath = rbPath;

	CString temp1;
	TCHAR TMP1[1024];
	DWORD dd;
	CRegKey KKey;
	CString HWinfo = ACPI.hardwareinfo();
	ACPI.SetDlgItemText(IDC_HWINFO,HWinfo);
	if(KKey.Open(HKEY_CURRENT_USER,_T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
	{
		AfxMessageBox(_T("1"));
		KKey.QueryStringValue(_T("OrigHWInfo"),TMP1,&dd);
		temp1 = TMP1;
		KKey.QueryStringValue(_T("ErrorPath"),TMP1,&dd);
		ACPI.errorpath = TMP1;
		if(ACPI.CheckDiffInfo(ACPI.ACPIs, temp1, HWinfo))
			ACPI.GetDlgItem(IDC_STATIC_Error)->EnableWindow(TRUE); 
	}
	KKey.Close();

	CRegKey hKey;
	if(hKey.Open(HKEY_CURRENT_USER,_T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
	{
		AfxMessageBox(_T("2"));
		TCHAR TMP[1024];
		CString temp;
		DWORD dwcount = 1024, dwType = REG_SZ;
		//从注册表中恢复设置
		hKey.QueryStringValue(_T("SetLoop"), TMP, &dwcount);
		temp = TMP;
		ACPI.SetDlgItemText(IDC_Loop, temp);

		hKey.QueryStringValue(_T("SetTime"), TMP, &dwcount);
		temp = TMP;
		ACPI.SetDlgItemText(IDC_Countdown, temp);
		ACPI.SetDlgItemText(IDC_time_to_run, temp);

		CRegKey lKey;
		if (lKey.Open(HKEY_CURRENT_USER, _T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
		{
			AfxMessageBox(_T("3"));
			lKey.QueryStringValue(_T("CurrState"), TMP, &dwcount);
			ACPI.ACPIs = TMP;
			temp = TMP;

			ULONGLONG a;
			lKey.QueryQWORDValue(_T("LastLoop"), a);
			CString Loop;
			Loop.Format(_T("%d"), a);
			ACPI.SetDlgItemText(IDC_Loop_time, Loop);
		}

		CString time;
		HKEY tKey;
		if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\SVACPI\\ACPI Information"), 0, KEY_READ | KEY_WRITE, &tKey) == ERROR_SUCCESS)
		{
			DWORD dwReturn = 1024;
			RegQueryValueEx(tKey, _T("RealTime"), NULL, &dwType, (LPBYTE)(&TMP), &dwReturn);
			time = TMP;
		}

		//S5开机初始化
		if(temp == _T("S5"))
		{
			ACPI.SetDlgItemText(IDC_S5BUTTON,_T("Stop S5"));
			ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_RbBUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(TRUE);

			FILETIME ft; LARGE_INTEGER tmp; LONGLONG tmptime;
			SYSTEMTIME st;
			GetLocalTime(&st);

			SystemTimeToFileTime(&st, &ft);
			tmp.LowPart = ft.dwLowDateTime;
			tmp.HighPart = ft.dwHighDateTime;
			tmptime = tmp.QuadPart;

			tmptime += _ttoi64(time);
			tmp.QuadPart = tmptime;
			ft.dwLowDateTime = tmp.LowPart;
			ft.dwHighDateTime = tmp.HighPart;
			FileTimeToSystemTime(&ft, &st);
			SetLocalTime(&st);
		}
		//Reboot开机初始化
		else
		{
			ACPI.SetDlgItemText(IDC_RbBUTTON,_T("Stop Reboot"));
			ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S5BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(TRUE);
		}
		hKey.Close();
		lKey.Close();
		ACPI.SetTimer(21,1000,NULL);
	}
	else
	{
		ACPI.SetDlgItemText(IDC_Loop,_T("9999"));
		ACPI.SetDlgItemText(IDC_Countdown,_T("15"));
		ACPI.SetDlgItemText(IDC_Loop_time,_T("0"));
		ACPI.SetDlgItemText(IDC_time_to_run,_T("-"));

		ACPI.SetDlgItemText(IDC_PBUTTON,_T("Pause"));
		ACPI.SetDlgItemText(IDC_S3BUTTON,_T("Run S1/S3"));
		ACPI.SetDlgItemText(IDC_S4BUTTON,_T("Run S4"));
		ACPI.SetDlgItemText(IDC_S5BUTTON,_T("Run S5"));
		ACPI.SetDlgItemText(IDC_RbBUTTON, _T("Reboot"));


		ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(FALSE);
		ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_S5BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_RbBUTTON)->EnableWindow(TRUE);
	}

	//copycompare
	CCTool.CheckDlgButton(IDC_200MS_RADIO, 1);
	CCTool.sourcepath = _T("D:\\CCData\\200MS");
	CCTool.SetDlgItemText(IDC_SOURCE_PATH_EDIT,CCTool.sourcepath);


	CString filename ;
	TCHAR SysTmpPath[MAX_PATH];
	GetTempPath(MAX_PATH,SysTmpPath);
	filename = SysTmpPath;
	filename+=_T("CCtool.bat");

	CFileFind finder;
	BOOL iffind = finder.FindFile(filename);
	if(iffind)
	{
		CFile CCbat;
		CCbat.Remove(filename);
	}
	
	CFile CCbat(filename, CFile::modeCreate|CFile::modeWrite);
	CCbat.Write("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n", sizeof("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n")-1);
	CCbat.Write("ping 127.0.0.1 -n 11>nul\r\n",sizeof("ping 127.0.0.1 -n 11>nul\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("set /a looptime=0\r\n",sizeof("set /a looptime=0\r\n")-1);
	CCbat.Write("set sdisk=%2\r\n",sizeof("set sdisk=%2\r\n")-1);
	CCbat.Write("set ddisk=%3\r\n",sizeof("set ddisk=%3\r\n")-1);
	CCbat.Write("set s=%sdisk:~0,1%\r\n",sizeof("set s=%sdisk:~0,1%\r\n")-1);
	CCbat.Write("set d=%ddisk:~0,1%\r\n",sizeof("set d=%ddisk:~0,1%\r\n")-1);
	CCbat.Write("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n",sizeof("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n",sizeof("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n")-1);
	CCbat.Write("break=on\r\n",sizeof("break=on\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n",sizeof("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":start\r\n",sizeof(":start\r\n")-1);
	CCbat.Write("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":l\r\n",sizeof(":l\r\n")-1);
	CCbat.Write("if exist %3 rd /s /q %3\r\n",sizeof("if exist %3 rd /s /q %3\r\n")-1);
	CCbat.Write("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n",sizeof("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":loop\r\n",sizeof(":loop\r\n")-1);
	CCbat.Write("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo **************  Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo **************  Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("md %3\r\n",sizeof("md %3\r\n")-1);
	CCbat.Write("echo %time%\r\n",sizeof("echo %time%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("set copybgntime=%time%\r\n",sizeof("set copybgntime=%time%\r\n")-1);
	CCbat.Write("set copybgndate=%date%\r\n",sizeof("set copybgndate=%date%\r\n")-1);
	CCbat.Write("copy /Y %2 %3\r\n",sizeof("copy /Y %2 %3\r\n")-1);
	CCbat.Write("set copyendtime=%time%\r\n",sizeof("set copyendtime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color fc&echo ERROR happened when copy from %2 to %3 !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color fc&echo ERROR happened when copy from %2 to %3 !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 4 color cf&echo ERROR happened when copy from %2 to %3 !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 4 color cf&echo ERROR happened when copy from %2 to %3 !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo n|comp %2 %3\r\n",sizeof("echo n|comp %2 %3\r\n")-1);
	CCbat.Write("set compendtime=%time%\r\n",sizeof("set compendtime=%time%\r\n")-1);
	CCbat.Write("set compenddate=%date%\r\n",sizeof("set compenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color cf&echo ERROR happened when compare %2 with %3 !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color cf&echo ERROR happened when compare %2 with %3 !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 2 color fd&echo ERROR happened when compare %2 with %3 !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 2 color fd&echo ERROR happened when compare %2 with %3 !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo Start copy from %2 to %3: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Start copy from %2 to %3: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish copy from %2 to %3: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish copy from %2 to %3: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish comp from %2 to %3: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish comp from %2 to %3: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-copy\r\n",sizeof("set info=%s%-%d%-%1-copy\r\n")-1);
	CCbat.Write("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-comp\r\n",sizeof("set info=%s%-%d%-%1-comp\r\n")-1);
	CCbat.Write("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("md D:\\%d%-%1-C\r\n",sizeof("md D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set copybgntime=%time%\r\n",sizeof("set copybgntime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("copy /Y %3 D:\\%d%-%1-C\r\n",sizeof("copy /Y %3 D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set copyendtime=%time%\r\n",sizeof("set copyendtime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color fc&echo ERROR happened when copy from %3 to D:\\%d%-%1-C !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color fc&echo ERROR happened when copy from %3 to D:\\DataComp !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 4 color cf&echo ERROR happened when copy from %3 to D:\\%d%-%1-C !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 4 color cf&echo ERROR happened when copy from %3 to D:\\DataComp !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("echo n|comp %2 D:\\%d%-%1-C\r\n",sizeof("echo n|comp %2 D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set compendtime=%time%\r\n",sizeof("set compendtime=%time%\r\n")-1);
	CCbat.Write("set compenddate=%date%\r\n",sizeof("set compenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color cf&echo ERROR happened when compare %2 with D:\\%d%-%1-C !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color cf&echo ERROR happened when compare %2 with D:\\DataComp !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 2 color fd&echo ERROR happened when compare %2 with D:\\%d%-%1-C !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 2 color fd&echo ERROR happened when compare %2 with D:\\DataComp !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo Start copy from %2 to D:\\%d%-%1-C: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Start copy from %2 to D:\\%d%-%1-C: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish copy from %2 to D:\\%d%-%1-C: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish copy from %2 to D:\\%d%-%1-C: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish comp from %2 to D:\\%d%-%1-C: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish comp from %2 to D:\\%d%-%1-C: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-copy\r\n",sizeof("set info=%s%-%d%-%1-copy\r\n")-1);
	CCbat.Write("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-comp\r\n",sizeof("set info=%s%-%d%-%1-comp\r\n")-1);
	CCbat.Write("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("rd /s /q %3\r\n",sizeof("rd /s /q %3\r\n")-1);
	CCbat.Write("rd /s /q D:\\%d%-%1-C\r\n",sizeof("rd /s /q D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("echo **************  Loop %looptime% has finished ***************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo **************  Loop %looptime% has finished ***************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set /a looptime=looptime+1\r\n",sizeof("set /a looptime=looptime+1\r\n")-1);
	CCbat.Write("ping 127.0.0.1 -n 05>nul\r\n",sizeof("ping 127.0.0.1 -n 05>nul\r\n")-1);
	CCbat.Write("goto loop\r\n",sizeof("goto loop\r\n")-1);
	CCbat.Flush();
	CCbat.Close();

	GetTempPath(MAX_PATH,SysTmpPath);
	filename = SysTmpPath;
	filename+=_T("count.bat");
	iffind = finder.FindFile(filename);
	if(iffind)
	{
		CFile CCcount;
		CCcount.Remove(filename);
	}

	CFile Countbat(filename, CFile::modeCreate|CFile::modeWrite);

	Countbat.Write("set tmptime=%1\r\n",sizeof("set tmptime=%1\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==: (\r\n",sizeof("if %tmptime:~2,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,2%\r\n",sizeof("set /a hour=%tmptime:~0,2%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n",sizeof("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n",sizeof("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n",sizeof("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n",sizeof("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n")-1);
	Countbat.Write("if %tmptime:~1,1%==: (\r\n",sizeof("if %tmptime:~1,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,1%\r\n",sizeof("set /a hour=%tmptime:~0,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n",sizeof("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n",sizeof("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n",sizeof("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n",sizeof("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n")-1);
	Countbat.Write("set /a begin=%hour%*3600+%min%*60+%sec%\r\n",sizeof("set /a begin=%hour%*3600+%min%*60+%sec%\r\n")-1);
	Countbat.Write("\r\n",sizeof("\r\n")-1);
	Countbat.Write("set tmptime=%2\r\n",sizeof("set tmptime=%2\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==: (\r\n",sizeof("if %tmptime:~2,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,2%\r\n",sizeof("set /a hour=%tmptime:~0,2%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n",sizeof("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n",sizeof("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n",sizeof("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n",sizeof("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n")-1);
	Countbat.Write("if %tmptime:~1,1%==: (\r\n",sizeof("if %tmptime:~1,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,1%\r\n",sizeof("set /a hour=%tmptime:~0,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n",sizeof("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n",sizeof("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n",sizeof("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n",sizeof("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n")-1);
	Countbat.Write("set /a final=%hour%*3600+%min%*60+%sec%\r\n",sizeof("set /a final=%hour%*3600+%min%*60+%sec%\r\n")-1);
	Countbat.Write("\r\n",sizeof("\r\n")-1);
	Countbat.Write("set /a total=%final%-%begin%\r\n",sizeof("set /a total=%final%-%begin%\r\n")-1);
	Countbat.Write("set info=%3\r\n",sizeof("set info=%3\r\n")-1);
	Countbat.Write("echo total %info% time: %total% seconds >>%info:~0,-5%.txt\r\n",sizeof("echo total %info% time: %total% seconds >>%info:~0,-5%.txt\r\n")-1);
	Countbat.Write("echo --                            >>%info:~0,-5%.txt\r\n",sizeof("echo --                            >>%info:~0,-5%.txt\r\n")-1);
	Countbat.Flush();
	Countbat.Close();

	return FALSE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Exemplo n.º 5
0
Arquivo: date.c Projeto: GYGit/reactos
static BOOL
ParseDate (LPTSTR s)
{
    SYSTEMTIME d;
    unsigned char leap;
    LPTSTR p = s;

    if (!*s)
        return TRUE;

    GetLocalTime (&d);

    d.wYear = 0;
    d.wDay = 0;
    d.wMonth = 0;

    switch (nDateFormat)
    {
        case 0: /* mmddyy */
        default:
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            break;

        case 1: /* ddmmyy */
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            break;

        case 2: /* yymmdd */
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            break;
    }

    /* if only entered two digits: */
    /*   assume 2000's if value less than 80 */
    /*   assume 1900's if value greater or equal 80 */
    if (d.wYear <= 99)
    {
        if (d.wYear >= 80)
            d.wYear = 1900 + d.wYear;
        else
            d.wYear = 2000 + d.wYear;
    }

    leap = (!(d.wYear % 4) && (d.wYear % 100)) || !(d.wYear % 400);

    if ((d.wMonth >= 1 && d.wMonth <= 12) &&
        (d.wDay >= 1 && d.wDay <= awMonths[leap][d.wMonth]) &&
        (d.wYear >= 1980 && d.wYear <= 2099))
    {
        SetLocalTime (&d);
        return TRUE;
    }

    return FALSE;
}
bool BL_ActionActuator::Update(double curtime, bool frame)
{
	bool bNegativeEvent = false;
	bool bPositiveEvent = false;
	bool bUseContinue = false;
	KX_GameObject *obj = (KX_GameObject*)GetParent();
	short playtype = BL_Action::ACT_MODE_PLAY;
	float start = m_startframe;
	float end = m_endframe;

	// If we don't have an action, we can't do anything
	if (!m_action)
		return false;

	// Convert our playtype to one that BL_Action likes
	switch(m_playtype)
	{
		case ACT_ACTION_LOOP_END:
		case ACT_ACTION_LOOP_STOP:
			playtype = BL_Action::ACT_MODE_LOOP;
			break;

		case ACT_ACTION_PINGPONG:
			// We handle ping pong ourselves to increase compabitility
			// with files made prior to animation changes from GSoC 2011.
			playtype = BL_Action::ACT_MODE_PLAY;
		
			if (m_flag & ACT_FLAG_REVERSE)
			{
				start = m_endframe;
				end = m_startframe;
			}

			break;
		case ACT_ACTION_FROM_PROP:
			CValue* prop = GetParent()->GetProperty(m_propname);

			// If we don't have a property, we can't do anything, so just bail
			if (!prop) return false;

			playtype = BL_Action::ACT_MODE_PLAY;
			start = end = prop->GetNumber();

			break;
	}

	if (m_flag & ACT_FLAG_CONTINUE)
		bUseContinue = true;
	
	
	// Handle events
	if (frame)
	{
		bNegativeEvent = m_negevent;
		bPositiveEvent = m_posevent;
		RemoveAllEvents();
	}

	// "Active" actions need to keep updating their current frame
	if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
		m_localtime = obj->GetActionFrame(m_layer);

	if (m_flag & ACT_FLAG_ATTEMPT_PLAY)
		SetLocalTime(curtime);
	else
		ResetStartTime(curtime);

	// Handle a frame property if it's defined
	if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
	{
		CValue* oldprop = obj->GetProperty(m_framepropname);
		CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
		if (oldprop)
			oldprop->SetValue(newval);
		else
			obj->SetProperty(m_framepropname, newval);

		newval->Release();
	}

	// Handle a finished animation
	if ((m_flag & ACT_FLAG_PLAY_END) && (m_flag & ACT_FLAG_ACTIVE) && obj->IsActionDone(m_layer))
	{
		m_flag &= ~ACT_FLAG_ACTIVE;
		m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;

		if (m_playtype == ACT_ACTION_PINGPONG)
			m_flag ^= ACT_FLAG_REVERSE;
		return false;
	}
	
	// If a different action is playing, we've been overruled and are no longer active
	if (obj->GetCurrentAction(m_layer) != m_action && !obj->IsActionDone(m_layer))
		m_flag &= ~ACT_FLAG_ACTIVE;

	if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE)))
	{
		if (bPositiveEvent && m_playtype == ACT_ACTION_PLAY)
		{
			if (obj->IsActionDone(m_layer))
				m_localtime = start;
			ResetStartTime(curtime);
		}

		if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags))
		{
			m_flag |= ACT_FLAG_ACTIVE;
			if (bUseContinue)
				obj->SetActionFrame(m_layer, m_localtime);

			if (m_playtype == ACT_ACTION_PLAY || m_playtype == ACT_ACTION_PINGPONG)
				m_flag |= ACT_FLAG_PLAY_END;
			else
				m_flag &= ~ACT_FLAG_PLAY_END;
		}
		m_flag |= ACT_FLAG_ATTEMPT_PLAY;
	}
	else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent)
	{	
		m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
		m_localtime = obj->GetActionFrame(m_layer);
		bAction *curr_action = obj->GetCurrentAction(m_layer);
		if (curr_action && curr_action != m_action)
		{
			// Someone changed the action on us, so we wont mess with it
			// Hopefully there wont be too many problems with two actuators using
			// the same action...
			m_flag &= ~ACT_FLAG_ACTIVE;
			return false;
		}

		switch(m_playtype)
		{
			case ACT_ACTION_LOOP_STOP:
				obj->StopAction(m_layer); // Stop the action after getting the frame

				// We're done
				m_flag &= ~ACT_FLAG_ACTIVE;
				return false;
			case ACT_ACTION_LOOP_END:
				// Convert into a play and let it finish
				obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY);

				m_flag |= ACT_FLAG_PLAY_END;
				break;
	
			case ACT_ACTION_FLIPPER:
				// Convert into a play action and play back to the beginning
				end = start;
				start = obj->GetActionFrame(m_layer);
				obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags);

				m_flag |= ACT_FLAG_PLAY_END;
				break;
		}
	}

	return m_flag & ACT_FLAG_ACTIVE;
}
Exemplo n.º 7
0
bool BL_ShapeActionActuator::Update(double curtime, bool frame)
{
	bool bNegativeEvent = false;
	bool bPositiveEvent = false;
	bool keepgoing = true;
	bool wrap = false;
	bool apply=true;
	int	priority;
	float newweight;

	curtime -= KX_KetsjiEngine::GetSuspendedDelta();
	
	// result = true if animation has to be continued, false if animation stops
	// maybe there are events for us in the queue !
	if (frame)
	{
		bNegativeEvent = m_negevent;
		bPositiveEvent = m_posevent;
		RemoveAllEvents();
		
		if (bPositiveEvent)
			m_flag |= ACT_FLAG_ACTIVE;
		
		if (bNegativeEvent)
		{
			if (!(m_flag & ACT_FLAG_ACTIVE))
				return false;
			m_flag &= ~ACT_FLAG_ACTIVE;
		}
	}
	
	/*	This action can only be attached to a deform object */
	BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
	float length = m_endframe - m_startframe;
	
	priority = m_priority;
	
	/* Determine pre-incrementation behaviour and set appropriate flags */
	switch (m_playtype){
	case ACT_ACTION_MOTION:
		if (bNegativeEvent){
			keepgoing=false;
			apply=false;
		};
		break;
	case ACT_ACTION_FROM_PROP:
		if (bNegativeEvent){
			apply=false;
			keepgoing=false;
		}
		break;
	case ACT_ACTION_LOOP_END:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_KEYUP;
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag |= ACT_FLAG_LOCKINPUT;
				m_localtime = m_startframe;
				m_starttime = curtime;
			}
		}
		if (bNegativeEvent){
			m_flag |= ACT_FLAG_KEYUP;
		}
		break;
	case ACT_ACTION_LOOP_STOP:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag &= ~ACT_FLAG_KEYUP;
				m_flag |= ACT_FLAG_LOCKINPUT;
				SetStartTime(curtime);
			}
		}
		if (bNegativeEvent){
			m_flag |= ACT_FLAG_KEYUP;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
			keepgoing=false;
			apply=false;
		}
		break;
	case ACT_ACTION_PINGPONG:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_KEYUP;
				m_localtime = m_starttime;
				m_starttime = curtime;
				m_flag |= ACT_FLAG_LOCKINPUT;
			}
		}
		break;
	case ACT_ACTION_FLIPPER:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag |= ACT_FLAG_LOCKINPUT;
				SetStartTime(curtime);
			}
		}
		else if (bNegativeEvent){
			m_flag |= ACT_FLAG_REVERSE;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
			SetStartTime(curtime);
		}
		break;
	case ACT_ACTION_PLAY:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_localtime = m_starttime;
				m_starttime = curtime;
				m_flag |= ACT_FLAG_LOCKINPUT;
			}
		}
		break;
	default:
		break;
	}
	
	/* Perform increment */
	if (keepgoing){
		if (m_playtype == ACT_ACTION_MOTION){
			MT_Point3	newpos;
			MT_Point3	deltapos;
			
			newpos = obj->NodeGetWorldPosition();
			
			/* Find displacement */
			deltapos = newpos-m_lastpos;
			m_localtime += (length/m_stridelength) * deltapos.length();
			m_lastpos = newpos;
		}
		else{
			SetLocalTime(curtime);
		}
	}
	
	/* Check if a wrapping response is needed */
	if (length){
		if (m_localtime < m_startframe || m_localtime > m_endframe)
		{
			m_localtime = m_startframe + fmod(m_localtime, length);
			wrap = true;
		}
	}
	else
		m_localtime = m_startframe;
	
	/* Perform post-increment tasks */
	switch (m_playtype){
	case ACT_ACTION_FROM_PROP:
		{
			CValue* propval = GetParent()->GetProperty(m_propname);
			if (propval)
				m_localtime = propval->GetNumber();
			
			if (bNegativeEvent){
				keepgoing=false;
			}
		}
		break;
	case ACT_ACTION_MOTION:
		break;
	case ACT_ACTION_LOOP_STOP:
		break;
	case ACT_ACTION_PINGPONG:
		if (wrap){
			if (!(m_flag & ACT_FLAG_REVERSE))
				m_localtime = m_endframe;
			else 
				m_localtime = m_startframe;

			m_flag &= ~ACT_FLAG_LOCKINPUT;
			m_flag ^= ACT_FLAG_REVERSE; //flip direction
			keepgoing = false;
		}
		break;
	case ACT_ACTION_FLIPPER:
		if (wrap){
			if (!(m_flag & ACT_FLAG_REVERSE)){
				m_localtime=m_endframe;
				//keepgoing = false;
			}
			else {
				m_localtime=m_startframe;
				keepgoing = false;
			}
		}
		break;
	case ACT_ACTION_LOOP_END:
		if (wrap){
			if (m_flag & ACT_FLAG_KEYUP){
				keepgoing = false;
				m_localtime = m_endframe;
				m_flag &= ~ACT_FLAG_LOCKINPUT;
			}
			SetStartTime(curtime);
		}
		break;
	case ACT_ACTION_PLAY:
		if (wrap){
			m_localtime = m_endframe;
			keepgoing = false;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
		}
		break;
	default:
		keepgoing = false;
		break;
	}
	
	/* Set the property if its defined */
	if (m_framepropname[0] != '\0') {
		CValue* propowner = GetParent();
		CValue* oldprop = propowner->GetProperty(m_framepropname);
		CValue* newval = new CFloatValue(m_localtime);
		if (oldprop) {
			oldprop->SetValue(newval);
		} else {
			propowner->SetProperty(m_framepropname, newval);
		}
		newval->Release();
	}
	
	if (bNegativeEvent)
		m_blendframe=0.0f;
	
	/* Apply the pose if necessary*/
	if (apply) {

		/* Priority test */
		if (obj->SetActiveAction(this, priority, curtime)){
			BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
			Key *key = NULL;

			if (shape_deformer)
				key = shape_deformer->GetKey();

			if (!key) {
				// this could happen if the mesh was changed in the middle of an action
				// and the new mesh has no key, stop the action
				keepgoing = false;
			}
			else {
				ListBase tchanbase= {NULL, NULL};
			
				if (m_blendin && m_blendframe==0.0f){
					// this is the start of the blending, remember the startup shape
					obj->GetShape(m_blendshape);
					m_blendstart = curtime;
				}

				KeyBlock *kb;
				// We go through and clear out the keyblocks so there isn't any interference
				// from other shape actions
				for (kb=(KeyBlock*)key->block.first; kb; kb=(KeyBlock*)kb->next)
					kb->curval = 0.f;

				animsys_evaluate_action(m_idptr, m_action, NULL, m_localtime);

				// XXX - in 2.5 theres no way to do this. possibly not that important to support - Campbell
				if (0) { // XXX !execute_ipochannels(&tchanbase)) {
					// no update, this is possible if action does not match the keys, stop the action
					keepgoing = false;
				} 
				else {
					// the key have changed, apply blending if needed
					if (m_blendin && (m_blendframe<m_blendin)){
						newweight = (m_blendframe/(float)m_blendin);

						BlendShape(key, 1.0f - newweight);

						/* Increment current blending percentage */
						m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
						if (m_blendframe>m_blendin)
							m_blendframe = m_blendin;
					}
					m_lastUpdate = m_localtime;
				}
				BLI_freelistN(&tchanbase);
			}
		}
		else{
			m_blendframe = 0.0f;
		}
	}
	
	if (!keepgoing){
		m_blendframe = 0.0f;
	}
	return keepgoing;
};
Exemplo n.º 8
0
void
setCurrentTime (const TimeValue *now) {
#if defined(HAVE_CLOCK_SETTIME) && defined(CLOCK_REALTIME)
  const struct timespec ts = {
    .tv_sec = now->seconds,
    .tv_nsec = now->nanoseconds
  };

  if (clock_settime(CLOCK_REALTIME, &ts) == -1) {
    logSystemError("clock_settime");
  }

#elif defined(HAVE_SETTIMEOFDAY)
  const struct timeval tv = {
    .tv_sec = now->seconds,
    .tv_usec = now->nanoseconds / NSECS_PER_USEC
  };

  if (settimeofday(&tv, NULL) == -1) {
    logSystemError("settimeofday");
  }

#elif defined(__MINGW32__)
  TimeComponents components;
  expandTimeValue(now, &components);

  SYSTEMTIME time = {
    .wYear = components.year,
    .wMonth = components.month + 1,
    .wDay = components.day + 1,
    .wHour = components.hour,
    .wMinute = components.minute,
    .wSecond = components.second,
    .wMilliseconds = now->nanoseconds / NSECS_PER_MSEC
  };

  if (!SetLocalTime(&time)) {
    logWindowsSystemError("SetLocalTime");
  }

#elif defined(HAVE_STIME)
  const time_t seconds = now->seconds;

  if (stime(&seconds) == -1) {
    logSystemError("stime");
  }

#else /* set current time */
#warning set current time not supported on this platform
#endif /* get current time */
}

void
makeTimeValue (TimeValue *value, const TimeComponents *components) {
  value->nanoseconds = components->nanosecond;

#if defined(GRUB_RUNTIME)
  value->seconds = 0;

#else /* make seconds */
  struct tm time = {
    .tm_year = components->year - 1900,
    .tm_mon = components->month,
    .tm_mday = components->day + 1,
    .tm_hour = components->hour,
    .tm_min = components->minute,
    .tm_sec = components->second,
    .tm_isdst = -1
  };

  value->seconds = mktime(&time);
#endif /* make seconds */
}

void
expandTimeValue (const TimeValue *value, TimeComponents *components) {
  time_t seconds = value->seconds;
  struct tm time;

  localtime_r(&seconds, &time);
  components->nanosecond = value->nanoseconds;

#if defined(GRUB_RUNTIME)
  components->year = time.tm.year;
  components->month = time.tm.month - 1;
  components->day = time.tm.day - 1;
  components->hour = time.tm.hour;
  components->minute = time.tm.minute;
  components->second = time.tm.second;

#else /* expand seconds */
  components->year = time.tm_year + 1900;
  components->month = time.tm_mon;
  components->day = time.tm_mday - 1;
  components->hour = time.tm_hour;
  components->minute = time.tm_min;
  components->second = time.tm_sec;
#endif /* expand seconds */
}

size_t
formatSeconds (char *buffer, size_t size, const char *format, int32_t seconds) {
  time_t time = seconds;
  struct tm description;

  localtime_r(&time, &description);
  return strftime(buffer, size, format, &description);
}

void
normalizeTimeValue (TimeValue *time) {
  while (time->nanoseconds < 0) {
    time->seconds -= 1;
    time->nanoseconds += NSECS_PER_SEC;
  }

  while (time->nanoseconds >= NSECS_PER_SEC) {
    time->seconds += 1;
    time->nanoseconds -= NSECS_PER_SEC;
  }
}

void
adjustTimeValue (TimeValue *time, int milliseconds) {
  TimeValue amount = {
    .seconds = milliseconds / MSECS_PER_SEC,
    .nanoseconds = (milliseconds % MSECS_PER_SEC) * NSECS_PER_MSEC
  };

  normalizeTimeValue(time);
  normalizeTimeValue(&amount);
  time->seconds += amount.seconds;
  time->nanoseconds += amount.nanoseconds;
  normalizeTimeValue(time);
}
Exemplo n.º 9
0
/*
 * Application entry.
 */
int main(void)
{
    uint32_t baud = 115200;
    int cmd;

    /* Use UART device for stdin and stdout. */
    NutRegisterDevice(&DEV_CONSOLE, 0, 0);
    freopen(DEV_CONSOLE.dev_name, "w", stdout);
    freopen(DEV_CONSOLE.dev_name, "r", stdin);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
    printf("\n\nCalendar Time %s running on Nut/OS %s\n"
           , version, NutVersionString());

#ifdef USE_LINE_EDITOR
    /* Open line editor, if configured. */
    printf("Opening line editor...");
    edline = EdLineOpen(EDIT_MODE_ECHO);
    if (edline) {
        puts("OK");
    } else {
        puts("failed");
    }
#else
    puts("Note: Enable local echo!");
#endif

#if USE_TIME_ZONE
    _timezone = USE_TIME_ZONE;
#endif

#ifdef RTC_CHIP
    /* Register and query hardware RTC, if available. */
    printf("Registering RTC hardware...");
    if (NutRegisterRtc(&RTC_CHIP)) {
        puts("failed");
    } else {
        uint32_t rtc_stat;

        NutRtcGetStatus(&rtc_stat);
        if (rtc_stat & RTC_STATUS_PF) {
#if defined(USE_BUILD_TIME)
            puts("power failure, Setting Time from Build date");
            /* Initially use the compile date and time. */
            time_t now = RfcTimeParse("Unk, " __DATE__ " " __TIME__);
            stime(&now);
            puts("Built " __DATE__ " " __TIME__);
#else
            puts("power failure");
#endif
        } else {
            puts("OK");
        }
    }
#elif USE_BUILD_TIME
    {
        /* Initially use the compile date and time. */
        time_t now = RfcTimeParse("Unk, " __DATE__ " " __TIME__);
        stime(&now);
        puts("Built " __DATE__ " " __TIME__);
    }
#endif

    for (;;) {
        /* Print command menu. */
        puts("\n  0 - Display seconds counter");
        puts("  1 - Display universal time");
        puts("  2 - Display local time");
        puts("  3 - Display system uptime");
        puts("  C - Calculate weekday");
        puts("  S - Set local time");
        puts("  Y - Toggle DST calculation");
        puts("  Z - Set timezone");

        printf("What is thy bidding, my master? ");

        /* Flush input buffer. */
        while (kbhit()) {
            cmd = getchar();
        }

        /* Get the next command. */
        cmd = getchar();
        putchar('\n');

        /* Process the command. */
        switch (cmd) {
        case '0':
            DisplaySeconds();
            break;
        case '1':
            DisplayZuluTime();
            break;
        case '2':
            DisplayLocalTime();
            break;
        case '3':
            DisplayUpTime();
            break;
        case 'C':
        case 'c':
            CalcWeekDay();
            break;
        case 'S':
        case 's':
            SetLocalTime();
            break;
        case 'Y':
        case 'y':
            /* Nut/OS uses a global variable to enable/disable DST.
               Toggle the current status and display the result. */
            _daylight = _daylight == 0;
            printf("DST calculation %sabled\n", _daylight ? "en" : "dis");
            break;
        case 'Z':
        case 'z':
            SetTimeZone();
            break;
        }
    }
    return 0;
}
Exemplo n.º 10
0
void BL_Action::Update(float curtime, bool applyToObject)
{
	/* Don't bother if we're done with the animation and if the animation was already applied to the object.
	 * of if the animation made a double update for the same time and that it was applied to the object.
	 */
	if ((m_done && m_appliedToObject) || (m_prevUpdate == curtime && m_appliedToObject)) {
		return;
	}
	m_prevUpdate = curtime;

	curtime -= (float)KX_KetsjiEngine::GetSuspendedDelta();

	if (m_calc_localtime)
		SetLocalTime(curtime);
	else
	{
		ResetStartTime(curtime);
		m_calc_localtime = true;
	}

	// Handle wrap around
	if (m_localframe < std::min(m_startframe, m_endframe) || m_localframe > std::max(m_startframe, m_endframe)) {
		switch (m_playmode) {
			case ACT_MODE_PLAY:
				// Clamp
				m_localframe = m_endframe;
				m_done = true;
				break;
			case ACT_MODE_LOOP:
				// Put the time back to the beginning
				m_localframe = m_startframe;
				m_starttime = curtime;
				break;
			case ACT_MODE_PING_PONG:
				// Swap the start and end frames
				float temp = m_startframe;
				m_startframe = m_endframe;
				m_endframe = temp;

				m_starttime = curtime;

				break;
		}
	}

	m_appliedToObject = applyToObject;
	// In case of culled armatures (doesn't requesting to transform the object) we only manages time.
	if (!applyToObject) {
		return;
	}

	if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
	{
		BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;

		if (m_layer_weight >= 0)
			obj->GetPose(&m_blendpose);

		// Extract the pose from the action
		obj->SetPoseByAction(m_tmpaction, m_localframe);

		// Handle blending between armature actions
		if (m_blendin && m_blendframe<m_blendin)
		{
			IncrementBlending(curtime);

			// Calculate weight
			float weight = 1.f - (m_blendframe/m_blendin);

			// Blend the poses
			obj->BlendInPose(m_blendinpose, weight, ACT_BLEND_BLEND);
		}


		// Handle layer blending
		if (m_layer_weight >= 0)
			obj->BlendInPose(m_blendpose, m_layer_weight, m_blendmode);

		obj->UpdateTimestep(curtime);
	}
	else
	{
		BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
		BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());

		// Handle shape actions if we have any
		if (shape_deformer && shape_deformer->GetKey())
		{
			Key *key = shape_deformer->GetKey();

			PointerRNA ptrrna;
			RNA_id_pointer_create(&key->id, &ptrrna);

			animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localframe);

			// Handle blending between shape actions
			if (m_blendin && m_blendframe < m_blendin)
			{
				IncrementBlending(curtime);

				float weight = 1.f - (m_blendframe/m_blendin);

				// We go through and clear out the keyblocks so there isn't any interference
				// from other shape actions
				KeyBlock *kb;
				for (kb=(KeyBlock *)key->block.first; kb; kb=(KeyBlock *)kb->next)
					kb->curval = 0.f;

				// Now blend the shape
				BlendShape(key, weight, m_blendinshape);
			}

			// Handle layer blending
			if (m_layer_weight >= 0)
			{
				obj->GetShape(m_blendshape);
				BlendShape(key, m_layer_weight, m_blendshape);
			}

			obj->SetActiveAction(0, curtime);
		}
	}
}
Exemplo n.º 11
0
bool KX_IpoActuator::Update(double curtime, bool frame)
{
	// result = true if animation has to be continued, false if animation stops
	// maybe there are events for us in the queue !
	bool bNegativeEvent = false;
	bool numevents = false;
	bool bIpoStart = false;

	curtime -= KX_KetsjiEngine::GetSuspendedDelta();

	if (frame)
	{
		numevents = m_posevent || m_negevent;
		bNegativeEvent = IsNegativeEvent();
		RemoveAllEvents();
	}
	
	float  start_smaller_then_end = ( m_startframe < m_endframe ? 1.0f : -1.0f);

	bool result=true;
	if (!bNegativeEvent)
	{
		if (m_starttime < -2.0f*fabs(m_endframe - m_startframe))
		{
			// start for all Ipo, initial start for LOOP_STOP
			m_starttime = curtime;
			m_bIpoPlaying = true;
			bIpoStart = true;
		}
	}

	switch ((IpoActType)m_type)
	{
		
	case KX_ACT_IPO_PLAY:
	{
		// Check if playing forwards.  result = ! finished
		
		if (start_smaller_then_end > 0.f)
			result = (m_localtime < m_endframe && m_bIpoPlaying);
		else
			result = (m_localtime > m_endframe && m_bIpoPlaying);
		
		if (result)
		{
			SetLocalTime(curtime);
		
			/* Perform clamping */
			ClampLocalTime();
	
			if (bIpoStart)
				((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
			((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
		} else
		{
			m_localtime=m_startframe;
			m_direction=1;
		}
		break;
	}
	case KX_ACT_IPO_PINGPONG:
	{
		result = true;
		if (bNegativeEvent && !m_bIpoPlaying)
			result = false;
		else
			SetLocalTime(curtime);
			
		if (ClampLocalTime())
		{
			result = false;
			m_direction = -m_direction;
		}
		
		if (bIpoStart && m_direction > 0)
			((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
		((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
		break;
	}
	case KX_ACT_IPO_FLIPPER:
	{
		if (bNegativeEvent && !m_bIpoPlaying)
			result = false;
		if (numevents)
		{
			float oldDirection = m_direction;
			if (bNegativeEvent)
				m_direction = -1;
			else
				m_direction = 1;
			if (m_direction != oldDirection)
				// changing direction, reset start time
				SetStartTime(curtime);
		}
		
		SetLocalTime(curtime);
		
		if (ClampLocalTime() && m_localtime == m_startframe)
			result = false;

		if (bIpoStart)
			((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
		((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
		break;
	}

	case KX_ACT_IPO_LOOPSTOP:
	{
		if (numevents)
		{
			if (bNegativeEvent)
			{
				result = false;
				m_bNegativeEvent = false;
				numevents = false;
			}
			if (!m_bIpoPlaying)
			{
				// Ipo was stopped, make sure we will restart from where it stopped
				SetStartTime(curtime);
				if (!bNegativeEvent)
					// positive signal will restart the Ipo
					m_bIpoPlaying = true;
			}

		} // fall through to loopend, and quit the ipo animation immediatly 
	}
	case KX_ACT_IPO_LOOPEND:
	{
		if (numevents) {
			if (bNegativeEvent && m_bIpoPlaying) {
				m_bNegativeEvent = true;
			}
		}
		
		if (bNegativeEvent && !m_bIpoPlaying) {
			result = false;
		} 
		else
		{
			if (m_localtime*start_smaller_then_end < m_endframe*start_smaller_then_end)
			{
				SetLocalTime(curtime);
			}
			else {
				if (!m_bNegativeEvent) {
					/* Perform wraparound */
					SetLocalTime(curtime);
					if (start_smaller_then_end > 0.f)
						m_localtime = m_startframe + fmod(m_localtime - m_startframe, m_endframe - m_startframe);
					else
						m_localtime = m_startframe - fmod(m_startframe - m_localtime, m_startframe - m_endframe);
					SetStartTime(curtime);
					bIpoStart = true;
				}
				else
				{
					/* Perform clamping */
					m_localtime=m_endframe;
					result = false;
					m_bNegativeEvent = false;
				}
			}
		}
		
		if (m_bIpoPlaying && bIpoStart)
			((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
		((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
		break;
	}
	
	case KX_ACT_IPO_KEY2KEY:
	{
		// not implemented yet
		result = false;
		break;
	}
	
	case KX_ACT_IPO_FROM_PROP:
	{
		result = !bNegativeEvent;

		CValue* propval = GetParent()->GetProperty(m_propname);
		if (propval)
		{
			m_localtime = propval->GetNumber(); 
	
			if (bIpoStart)
				((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
			((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
		} else
		{
			result = false;
		}
		break;
	}
		
	default:
		result = false;
	}

	/* Set the property if its defined */
	if (m_framepropname[0] != '\0') {
		CValue* propowner = GetParent();
		CValue* oldprop = propowner->GetProperty(m_framepropname);
		CValue* newval = new CFloatValue(m_localtime);
		if (oldprop) {
			oldprop->SetValue(newval);
		} else {
			propowner->SetProperty(m_framepropname, newval);
		}
		newval->Release();
	}

	if (!result)
	{
		if (m_type != KX_ACT_IPO_LOOPSTOP)
			this->ResetStartTime();
		m_bIpoPlaying = false;
	}

	return result;
}
Exemplo n.º 12
0
void
TimeConfigPanel::OnModified(DataField &df)
{
  if (IsDataField(UTCOffset, df))
    SetLocalTime(RoughTimeDelta::FromSeconds(df.GetAsInteger()));
}
Exemplo n.º 13
0
void
TimeConfigPanel::OnModified(DataField &df)
{
  if (IsDataField(UTCOffset, df))
    SetLocalTime(df.GetAsInteger());
}
Exemplo n.º 14
0
bool BL_ActionActuator::Update(double curtime, bool frame)
{
	bool bNegativeEvent = false;
	bool bPositiveEvent = false;
	bool keepgoing = true;
	bool wrap = false;
	bool apply=true;
	int	priority;
	float newweight;

	curtime -= KX_KetsjiEngine::GetSuspendedDelta();
	
	// result = true if animation has to be continued, false if animation stops
	// maybe there are events for us in the queue !
	if (frame)
	{
		bNegativeEvent = m_negevent;
		bPositiveEvent = m_posevent;
		RemoveAllEvents();
		
		if (bPositiveEvent)
			m_flag |= ACT_FLAG_ACTIVE;
		
		if (bNegativeEvent)
		{
			// dont continue where we left off when restarting
			if (m_end_reset) {
				m_flag &= ~ACT_FLAG_LOCKINPUT;
			}
			
			if (!(m_flag & ACT_FLAG_ACTIVE))
				return false;
			m_flag &= ~ACT_FLAG_ACTIVE;
		}
	}
	
	/*	We know that action actuators have been discarded from all non armature objects:
	if we're being called, we're attached to a BL_ArmatureObject */
	BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
	float length = m_endframe - m_startframe;
	
	priority = m_priority;
	
	/* Determine pre-incrementation behaviour and set appropriate flags */
	switch (m_playtype){
	case ACT_ACTION_MOTION:
		if (bNegativeEvent){
			keepgoing=false;
			apply=false;
		};
		break;
	case ACT_ACTION_FROM_PROP:
		if (bNegativeEvent){
			apply=false;
			keepgoing=false;
		}
		break;
	case ACT_ACTION_LOOP_END:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_KEYUP;
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag |= ACT_FLAG_LOCKINPUT;
				m_localtime = m_startframe;
				m_starttime = curtime;
			}
		}
		if (bNegativeEvent){
			m_flag |= ACT_FLAG_KEYUP;
		}
		break;
	case ACT_ACTION_LOOP_STOP:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag &= ~ACT_FLAG_KEYUP;
				m_flag |= ACT_FLAG_LOCKINPUT;
				SetStartTime(curtime);
			}
		}
		if (bNegativeEvent){
			m_flag |= ACT_FLAG_KEYUP;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
			keepgoing=false;
			apply=false;
		}
		break;
	case ACT_ACTION_FLIPPER:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_flag |= ACT_FLAG_LOCKINPUT;
				SetStartTime(curtime);
			}
		}
		else if (bNegativeEvent){
			m_flag |= ACT_FLAG_REVERSE;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
			SetStartTime(curtime);
		}
		break;
	case ACT_ACTION_PLAY:
		if (bPositiveEvent){
			if (!(m_flag & ACT_FLAG_LOCKINPUT)){
				m_flag &= ~ACT_FLAG_REVERSE;
				m_localtime = m_starttime;
				m_starttime = curtime;
				m_flag |= ACT_FLAG_LOCKINPUT;
			}
		}
		break;
	default:
		break;
	}
	
	/* Perform increment */
	if (keepgoing){
		if (m_playtype == ACT_ACTION_MOTION){
			MT_Point3	newpos;
			MT_Point3	deltapos;
			
			newpos = obj->NodeGetWorldPosition();
			
			/* Find displacement */
			deltapos = newpos-m_lastpos;
			m_localtime += (length/m_stridelength) * deltapos.length();
			m_lastpos = newpos;
		}
		else{
			SetLocalTime(curtime);
		}
	}
	
	/* Check if a wrapping response is needed */
	if (length){
		if (m_localtime < m_startframe || m_localtime > m_endframe)
		{
			m_localtime = m_startframe + fmod(m_localtime, length);
			wrap = true;
		}
	}
	else
		m_localtime = m_startframe;
	
	/* Perform post-increment tasks */
	switch (m_playtype){
	case ACT_ACTION_FROM_PROP:
		{
			CValue* propval = GetParent()->GetProperty(m_propname);
			if (propval)
				m_localtime = propval->GetNumber();
			
			if (bNegativeEvent){
				keepgoing=false;
			}
		}
		break;
	case ACT_ACTION_MOTION:
		break;
	case ACT_ACTION_LOOP_STOP:
		break;
	case ACT_ACTION_FLIPPER:
		if (wrap){
			if (!(m_flag & ACT_FLAG_REVERSE)){
				m_localtime=m_endframe;
				//keepgoing = false;
			}
			else {
				m_localtime=m_startframe;
				keepgoing = false;
			}
		}
		break;
	case ACT_ACTION_LOOP_END:
		if (wrap){
			if (m_flag & ACT_FLAG_KEYUP){
				keepgoing = false;
				m_localtime = m_endframe;
				m_flag &= ~ACT_FLAG_LOCKINPUT;
			}
			SetStartTime(curtime);
		}
		break;
	case ACT_ACTION_PLAY:
		if (wrap){
			m_localtime = m_endframe;
			keepgoing = false;
			m_flag &= ~ACT_FLAG_LOCKINPUT;
		}
		break;
	default:
		keepgoing = false;
		break;
	}
	
	/* Set the property if its defined */
	if (m_framepropname[0] != '\0') {
		CValue* propowner = GetParent();
		CValue* oldprop = propowner->GetProperty(m_framepropname);
		CValue* newval = new CFloatValue(m_localtime);
		if (oldprop) {
			oldprop->SetValue(newval);
		} else {
			propowner->SetProperty(m_framepropname, newval);
		}
		newval->Release();
	}
	
	if (bNegativeEvent)
		m_blendframe=0.0;
	
	/* Apply the pose if necessary*/
	if (apply){

		/* Priority test */
		if (obj->SetActiveAction(this, priority, curtime)){
			
			/* Get the underlying pose from the armature */
			obj->GetPose(&m_pose);

// 2.4x function, 
			/* Override the necessary channels with ones from the action */
			// XXX extract_pose_from_action(m_pose, m_action, m_localtime);
			
			
// 2.5x - replacement for extract_pose_from_action(...) above.
			{
				struct PointerRNA id_ptr;
				Object *arm= obj->GetArmatureObject();
				bPose *pose_back= arm->pose;
				
				arm->pose= m_pose;
				RNA_id_pointer_create((ID *)arm, &id_ptr);
				animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime);
				
				arm->pose= pose_back;
			
// 2.5x - could also do this but looks too high level, constraints use this, it works ok.
//				Object workob; /* evaluate using workob */
//				what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime);
			}

			// done getting the pose from the action
			
			/* Perform the user override (if any) */
			if (m_userpose){
				extract_pose_from_pose(m_pose, m_userpose);
				game_free_pose(m_userpose); //cant use MEM_freeN(m_userpose) because the channels need freeing too.
				m_userpose = NULL;
			}
#if 1
			/* Handle blending */
			if (m_blendin && (m_blendframe<m_blendin)){
				/* If this is the start of a blending sequence... */
				if ((m_blendframe==0.0) || (!m_blendpose)){
					obj->GetMRDPose(&m_blendpose);
					m_blendstart = curtime;
				}
				
				/* Find percentages */
				newweight = (m_blendframe/(float)m_blendin);
				game_blend_poses(m_pose, m_blendpose, 1.0 - newweight);

				/* Increment current blending percentage */
				m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
				if (m_blendframe>m_blendin)
					m_blendframe = m_blendin;
				
			}
#endif
			m_lastUpdate = m_localtime;
			obj->SetPose (m_pose);
		}
		else{
			m_blendframe = 0.0;
		}
	}
	
	if (!keepgoing){
		m_blendframe = 0.0;
	}
	return keepgoing;
};
Exemplo n.º 15
0
void plAnimStage::ResetAtTime(double globalTime, float localTime, plArmatureMod *avMod)
{
    SetLocalTime(localTime, true);
    avMod->GetRootAnimator()->Reset(globalTime);
}
Exemplo n.º 16
0
int fb_hSetDate( int y, int m, int d )
{
#if defined( HOST_DOS )
	struct date dt;
	dt.da_year = y;
	dt.da_mon = m;
	dt.da_day = d;
	setdate(&dt);
	return 0;

#elif defined( HOST_UNIX )
	const int month_len[12] =
	{
		2678400, 2419200, 2678400, 2592000, 2678400, 2592000,
		2678400, 2678400, 2592000, 2678400, 2592000, 2678400
	};

	struct timeval tv;
	time_t secs;
	int i;

	if( y < 1970 )
		return -1;
	gettimeofday( &tv, NULL );
	secs = tv.tv_sec % 86400;
	tv.tv_sec = 0;
	for( i = 1970; i < y; i++ ) {
		tv.tv_sec += 31536000;
		if( ((i % 4) == 0) || ((i / 400) == 0) )
			d++;
	}
	tv.tv_sec += (m * month_len[m-1]);
	if( ((y % 4) == 0) || ((y / 400) == 0) )
		d++;
	tv.tv_sec += (d * 86400) + secs;
	if( settimeofday( &tv, NULL ) )
		return -1;

	return 0;

#elif defined( HOST_WIN32 )
	/* get current local time and date */
	SYSTEMTIME st;
	GetLocalTime( &st );

	/* set time fields */
	st.wYear = y;
	st.wMonth = m;
	st.wDay = d;

	/* set system time relative to local time zone */
	if( SetLocalTime( &st ) == 0) {
		return -1;
	}

	/* send WM_TIMECHANGE to all top-level windows on NT and 95/98/Me
	 * (_not_ on 2K/XP etc.) */
	/* if ((GetVersion() & 0xFF) == 4)
		SendMessage(HWND_BROADCAST, WM_TIMECHANGE, 0, 0); */

	return 0;

#elif defined( HOST_XBOX )
	/* TODO: use NtSetSystemTime */
	return 0;
#else
#	error TODO
#endif
}