예제 #1
0
VOID CLogFile::MakeLogfilenameWithPostfix()
{
    DateTime now;

    _snprintf(m_szLogFileName,MAX_FILE_NAME, "%s/%s_%.4d%.2d%.2d_%.2d%.2d%.2d_%.2d.log", m_szFilePath, m_szFileName, now.GetYear(), now.GetMonth(),
              now.GetDay(), now.GetHour(), now.GetMinute(), now.GetSecond(), now.GetMilliSecond());
}
예제 #2
0
KDint xmBadaStat ( const KDchar* path, struct stat* buf )
{
	struct tm       t;
	FileAttributes  attr;
	DateTime        dt;
	result          r;

	r = File::GetAttributes ( path, attr );

	if ( IsFailed ( r ) )
	{
		goto failed;
	}

	dt = attr.GetLastModifiedTime ( );

	t.tm_year = dt.GetYear   ( );
	t.tm_mon  = dt.GetMonth  ( ) - 1;
	t.tm_mday = dt.GetDay    ( );
	t.tm_hour = dt.GetHour   ( );
	t.tm_min  = dt.GetMinute ( );
	t.tm_sec  = dt.GetSecond ( );

	buf->st_mtime = mktime ( &t );
	buf->st_mode  = attr.IsDirectory ( ) ? 0x4000 : 0x8000;
	buf->st_size  = attr.GetFileSize ( );

	return 0;

failed :

	xmBadaSetError ( r );

	return -1;
}
예제 #3
0
VOID CLogFile::CacheLog(enum_LOG_LEVEL	logLevel, const CHAR* pLogString , ... )
{
    //等级太低,不需打印控制台和文件
    if (logLevel < m_eConsoleLogLevel && logLevel < m_eFileLogLevel)
    {
        return ;
    }

    CHAR szLine[MAX_LOG_LINE] = {0};
    va_list	va;
    va_start(va,pLogString);
#ifdef __LINUX
    vsprintf(szLine,pLogString,va);
#else
    vsprintf_s(szLine,MAX_LOG_LINE,pLogString,va);
#endif
    va_end(va);

    DateTime now;
    CHAR szLogStr[MAX_LOG_LINE] = {'\0'};
    _snprintf(szLogStr, MAX_LOG_LINE-1, "%2d/%02d/%02d %02d:%02d:%02d.%03d	tId:%ld	%s\n",
              now.GetYear(),
              now.GetMonth(),
              now.GetDay(),
              now.GetHour(),
              now.GetMinute(),
              now.GetSecond(),
              now.GetMilliSecond(),
              GetThreadID(),
              szLine);
    //高等与控制台等级,则打印到控制台
    if (logLevel >= m_eConsoleLogLevel)
    {
        printf("%s", szLogStr);
    }

    //高等与文件等级,则打印到文件
    if (logLevel >= m_eFileLogLevel)
    {
        CSmartLock sLock(m_lock);

        int strLength = strlen(szLogStr);
        if (m_pWriteBuf + strLength - m_pFrontBuf >=  LOG_BUF_LEN)
        {
            //front 缓冲满了
            if (m_bBackBufAvailable)
            {
                //两块全满了,这条要丢。
                printf("LOG LOST!!, %s", szLogStr);
                return;
            }
            //back空着,将front交换到back
            SwitchBuf();
        }

        //写入front
        strcpy( m_pWriteBuf, szLogStr );
        m_pWriteBuf += strLength;
    }
}
예제 #4
0
CEbenezerDlg::CEbenezerDlg()
{
	DateTime now;

	m_sYear = now.GetYear();
	m_sMonth = now.GetMonth();
	m_sDate = now.GetDay();
	m_sHour = now.GetHour();
	m_sMin = now.GetMinute();

	m_byWeather = 0;
	m_sWeatherAmount = 0;
	m_byKingWeatherEvent = 0;
	m_byKingWeatherEvent_Day = 0;
	m_byKingWeatherEvent_Hour = 0;
	m_byKingWeatherEvent_Minute = 0;

	m_byExpEventAmount = m_byCoinEventAmount = 0;

	m_sPartyIndex = 0;

	m_nCastleCapture = 0;

	m_bKarusFlag = 0;
	m_bElmoradFlag = 0;

	m_byKarusOpenFlag = m_byElmoradOpenFlag = false;
	m_byBanishFlag = false;
	m_sBanishDelay = 0;

	m_sKarusDead = 0;
	m_sElmoradDead = 0;

	m_bVictory = 0;	
	m_byOldVictory = 0;
	m_byBattleSave = false;
	m_sKarusCount = 0;
	m_sElmoradCount = 0;

	m_nBattleZoneOpenWeek=m_nBattleZoneOpenHourStart=m_nBattleZoneOpenHourEnd = 0;

	m_byBattleZone = 0;
	m_byBattleOpen = NO_BATTLE;
	m_byOldBattleOpen = NO_BATTLE;
	m_bFirstServerFlag = false;
	// m_bPointCheckFlag = false;
	m_bPointCheckFlag = true;

	m_nServerNo = 0;
	m_nServerGroupNo = 0;
	m_nServerGroup = 0;
	m_sDiscount = 0;
	
	m_bPermanentChatMode = false;
	m_bSantaOrAngel = FLYING_NONE;
}
예제 #5
0
String Utils::formatTime(DateTime dateTime){
	int hour = 	dateTime.GetHour();
	int min = 	dateTime.GetMinute();
	String time;
	if(hour<10) time += L"0";
	time += Integer::ToString(hour)+ L":";
	if(min < 10) time += L"0";
	time += Integer::ToString(min);
	return time;
}
예제 #6
0
void BadaSystem::getTimeAndDate(TimeDate &td) const {
	DateTime currentTime;

	if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) {
		td.tm_sec = currentTime.GetSecond();
		td.tm_min = currentTime.GetMinute();
		td.tm_hour = currentTime.GetHour();
		td.tm_mday = currentTime.GetDay();
		td.tm_mon = currentTime.GetMonth();
		td.tm_year = currentTime.GetYear();
	}
}
예제 #7
0
void JMChattControl::DrawTimeText(Canvas* pCanvas, Rectangle rtText, DateTime timeSend)
{
	String strTime;
	int nHour=0;


	nHour = timeSend.GetHour();
	if( nHour > 12 ) {
		nHour -= 12;
		strTime.Format(50, L"PM %d:%02d", nHour, timeSend.GetMinute());
	}
	else {
		strTime.Format(50, L"AM %d:%02d", nHour, timeSend.GetMinute());
	}
	Point tmp;
	tmp.x= rtText.GetTopLeft().x-10;
	tmp.y= rtText.GetTopLeft().y-10;
	pCanvas->SetForegroundColor(__stScreenInfo.colorTextTime);
	pCanvas->SetBackgroundColor(__stScreenInfo.colorTextBackTime);
	pCanvas->SetFont(__stScreenInfo.fontTime);
	pCanvas->DrawText(tmp, strTime);
}
예제 #8
0
TEST(DateTimeTest, TestDefault)
{
    DateTime defaultDate;
    ASSERT_TRUE(defaultDate.WasParseSuccessful());
    ASSERT_EQ(DayOfWeek::Thursday, defaultDate.GetDayOfWeek());
    ASSERT_EQ(01, defaultDate.GetDay());
    ASSERT_EQ(Month::January, defaultDate.GetMonth());
    ASSERT_EQ(1970, defaultDate.GetYear());
    ASSERT_EQ(0, defaultDate.GetHour());
    ASSERT_EQ(0, defaultDate.GetMinute());
    ASSERT_EQ(0, defaultDate.GetSecond());
    ASSERT_EQ("Thu, 01 Jan 1970 00:00:00 GMT", defaultDate.ToGmtString(DateFormat::RFC822));
}
bool ModelValidator::isValid(const DateTime& dateTime, bool allowDefaults/* = false*/)
{
	if (dateTime == DateTime() && !allowDefaults)
		RETURN_WITH_ERROR("DateTime is empty");

	// Check Date
	RETURN_IF_NOT_VALID1(dateTime.GetDate(), allowDefaults, "");

	// Check Time
	RETURN_IF_RANGE_NOT_VALID(dateTime.GetHour(), 0, 23, "Hour");
	RETURN_IF_RANGE_NOT_VALID(dateTime.GetMinute(), 0, 59, "Minute");
	RETURN_IF_RANGE_NOT_VALID(dateTime.GetSecond(), 0.0, 59.999999, "Seconds");

	return true;
}
예제 #10
0
파일: system.cpp 프로젝트: SinSiXX/scummvm
void TizenSystem::getTimeAndDate(TimeDate &td) const {
	DateTime currentTime;

	if (E_SUCCESS == SystemTime::GetCurrentTime(WALL_TIME, currentTime)) {
		td.tm_sec = currentTime.GetSecond();
		td.tm_min = currentTime.GetMinute();
		td.tm_hour = currentTime.GetHour();
		td.tm_mday = currentTime.GetDay();
		td.tm_mon = currentTime.GetMonth();
		td.tm_year = currentTime.GetYear();

		Calendar *calendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
		calendar->SetTime(currentTime);
		td.tm_wday = calendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK) - 1;
		delete calendar;
	}
}
예제 #11
0
파일: workload.cpp 프로젝트: dangpu/momoko
void WorkloadMaster::updateWorkload()
{
    pthread_mutex_lock(&m_locker);

    // 分配时间槽
    DateTime now = DateTime::Now();
    int hour = now.GetHour();
    int minute = now.GetMinute();
    int timeslot = (hour*60+minute) / INTERVAL;
    m_today = DateTime::Today();

    // 将上一时间槽的任务监控写入数据库
    monitorTasks(timeslot);
    m_status = 0;

    // 取新任务
    ostringstream oss;
    oss << "SELECT workload_key, content, source FROM workload_" << m_today.ToString(string("yyyyMMdd")) << " WHERE timeslot = " << timeslot;
    //oss << "SELECT workload_key, content, source FROM workload_" << m_today.ToString(string("yyyyMMdd")) << " WHERE timeslot = " << timeslot << " or timeslot = " << timeslot+1;
    string sql = oss.str();
    // 清空task任务和状态
    m_tasks.clear();
    m_task_status.clear();
    getTasksBySQL(sql, m_tasks);
    m_task_num = m_tasks.size();
    TASK_MAP::iterator it = m_tasks.begin();
    for(; it != m_tasks.end(); ++it)
    {
        // 初始化m_task_status
        vector<string> status;
        status.push_back("0");
        status.push_back("0");
        status.push_back("-1");
        status.push_back(it->second.m_content);
        status.push_back(it->second.m_source);
        m_task_status[it->second.m_workload_key] = status;
    }

    pthread_mutex_unlock(&m_locker);
}
예제 #12
0
bool CServerDlg::Startup()
{
	g_timerThreads.push_back(new Thread(Timer_CheckAliveTest));

	m_sMapEventNpc = 0;
	m_bFirstServerFlag = false;			

	// Server Start
	DateTime time;
	printf("Server started on %04d-%02d-%02d at %02d:%02d\n\n", time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute());

	//----------------------------------------------------------------------
	//	DB part initialize
	//----------------------------------------------------------------------
	GetServerInfoIni();

	if (!m_GameDB.Connect(m_strGameDSN, m_strGameUID, m_strGamePWD, false))
	{
		OdbcError *pError = m_GameDB.GetError();
		printf("ERROR: Could not connect to the database server, received error:\n%s\n", 
			pError->ErrorMessage.c_str());
		delete pError;
		return false;
	}

	//----------------------------------------------------------------------
	//	Communication Part Initialize ...
	//----------------------------------------------------------------------
	if (!m_socketMgr.Listen(AI_SERVER_PORT, MAX_SOCKET))
		return false;

	//----------------------------------------------------------------------
	//	Load tables
	//----------------------------------------------------------------------
	if (!GetMagicTableData()
		|| !GetMagicType1Data()
		|| !GetMagicType2Data()
		|| !GetMagicType4Data()
		|| !GetNpcItemTable()
		|| !GetMakeItemGroupTable()
		|| !GetMakeWeaponItemTableData()
		|| !GetMakeDefensiveItemTableData()
		|| !GetMakeGradeItemTableData()
		|| !GetMakeLareItemTableData()
		|| !GetServerResourceTable()
		|| !GetNpcTableData(false)
		|| !GetNpcTableData(true)
		// Load maps
		|| !MapFileLoad()
		// Spawn NPC threads
		|| !CreateNpcThread())
		return false;

	//----------------------------------------------------------------------
	//	Start NPC THREAD
	//----------------------------------------------------------------------
	ResumeAI();
	return true; 
}
예제 #13
0
/**
* @brief        Executes the death process.
*
* @param        pKiller        The killer.
*/
void CNpc::OnDeathProcess(Unit *pKiller)
{
        CUser * pUser = TO_USER(pKiller);

        if (TO_NPC(this) != nullptr && pUser != nullptr)
        {
                if (pUser->isPlayer())
                {
                        if (!m_bMonster)
                        {
                                switch (m_tNpcType)
                                {
                                case NPC_BIFROST_MONUMENT:
                                        pUser->BifrostProcess(pUser);
                                        break;
                                case NPC_PVP_MONUMENT:
                                        PVPMonumentProcess(pUser);
                                        break;
                                case NPC_BATTLE_MONUMENT:
                                        BattleMonumentProcess(pUser);
                                        break;
                                case NPC_HUMAN_MONUMENT:
                                        NationMonumentProcess(pUser);
                                        break;
                                case NPC_KARUS_MONUMENT:
                                        NationMonumentProcess(pUser);
                                        break;
                                }
                        }
                        else if (m_bMonster)
                        {
                                if (m_sSid == 700 || m_sSid == 750)
                                {
                                        if (pUser->CheckExistEvent(STARTER_SEED_QUEST, 1))
                                                pUser->SaveEvent(STARTER_SEED_QUEST, 2);
                                }
                                else if (g_pMain->m_MonsterRespawnListArray.GetData(m_sSid) != nullptr) {
                                        if (pUser->isInPKZone() || GetZoneID() == ZONE_JURAD_MOUNTAIN)
                                                g_pMain->SpawnEventNpc(g_pMain->m_MonsterRespawnListArray.GetData(m_sSid)->sSid, true, GetZoneID(), GetX(), GetY(), GetZ(), g_pMain->m_MonsterRespawnListArray.GetData(m_sSid)->sCount);
                                } else if (m_tNpcType == NPC_CHAOS_STONE && pUser->isInPKZone()) {
                                        ChaosStoneProcess(pUser,5);
                                }
                        }

                        DateTime time;
                        g_pMain->WriteDeathUserLogFile(string_format("[ %s - %d:%d:%d ] Killer=%s,SID=%d,Target=%s,Zone=%d,X=%d,Z=%d\n",m_bMonster ? "MONSTER" : "NPC",time.GetHour(),time.GetMinute(),time.GetSecond(),pKiller->GetName().c_str(),m_sSid,GetName().c_str(),GetZoneID(),uint16(GetX()),uint16(GetZ())));
                }
        }
}
예제 #14
0
   void 
   UtilitiesTester::TestReceivedHeaderParse_()
   {
      String sHeader = "from host.edu (host.edu [1.2.3.4]) by mail.host.edu (8.8.5) id 004A21; Tue, Mar 18 1997 14:36:17 -0800 (PST)";
      String sRecipient = Utilities::GetRecipientFromReceivedHeader(sHeader);
      if (sRecipient != _T(""))
         throw;

      String hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("host.edu"))
            throw;

      sHeader = "from host.edu (host.edu [1.2.3.4]) by mailhost.host.edu (8.8.5/8.7.2) with ESMTP id LAA20869 for <*****@*****.**>; Tue, 18 Mar 1997 14:39:24 -0800 (PST)";
      sRecipient = Utilities::GetRecipientFromReceivedHeader(sHeader);
      if (sRecipient != _T("*****@*****.**"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("host.edu"))
         throw;

      sHeader = "Received: from unknown (HELO mail-***.icp-***-irony4.*****.***.au) ([123.123.123.123])\r\n "
                "(envelope-sender <*****@*****.**>)\r\n"
                "by mail.*****.***.au (qmail-ldap-1.03) with SMTP\r\n"
                "for <*****@*****.**>; 20 Oct 2006 04:42:47 -0000\r\n";

      sRecipient = Utilities::GetRecipientFromReceivedHeader(sHeader);
      if (sRecipient != _T("*****@*****.**"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("unknown"))
         throw;

      sHeader = "Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) "
                "by j218.ryd.student.liu.se (Postfix) with ESMTP id D84F433035 "
                "for <*****@*****.**>; Thu, 14 Mar 2002 21:39:17 +0100 (CET) ";

      sRecipient = Utilities::GetRecipientFromReceivedHeader(sHeader);
      if (sRecipient != _T("*****@*****.**"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("mail.lysator.liu.se"))
         throw;

      sHeader = "Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) "
         "by j218.ryd.student.liu.se (Postfix) with ESMTP id D84F433035 "
         "for <*****@*****.**>; Thu, 14 Mar 2002 21:39:17 +0100 (CET) ";

      DateTime dtTime = Utilities::GetDateTimeFromReceivedHeader(sHeader);
      if (dtTime.GetYear() != 2002 || 
          dtTime.GetMonth() != 3 ||
          dtTime.GetDay() != 14 ||
          dtTime.GetHour() != 20 ||
          dtTime.GetMinute() != 39 ||
          dtTime.GetSecond() != 17)
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("mail.lysator.liu.se"))
         throw;

      // Test IP Address parsing
      sHeader = "Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) "
         "by j218.ryd.student.liu.se (Postfix) with ESMTP id D84F433035 "
         "for <*****@*****.**>; Thu, 14 Mar 2002 21:39:17 +0100 (CET) ";

      String sIPAddress = Utilities::GetIPAddressFromReceivedHeader(sHeader).ToString();
      if (sIPAddress != _T("130.236.254.3"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
         if (hostName != _T("mail.lysator.liu.se"))
            throw;
      
      sHeader = "from host.edu (host.edu [1.2.3.4]) by mail.host.edu (8.8.5) id 004A21; Tue, Mar 18 1997 14:36:17 -0800 (PST)";
      sIPAddress = Utilities::GetIPAddressFromReceivedHeader(sHeader).ToString();
      if (sIPAddress != _T("1.2.3.4"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("host.edu"))
         throw;

      sHeader = "Received: from unknown (HELO mail-***.icp-***-irony4.*****.***.au) ([123.123.123.125])\r\n "
         "(envelope-sender <*****@*****.**>)\r\n"
         "by mail.*****.***.au (qmail-ldap-1.03) with SMTP\r\n"
         "for <*****@*****.**>; 20 Oct 2006 04:42:47 -0000\r\n";
      sIPAddress = Utilities::GetIPAddressFromReceivedHeader(sHeader).ToString();
      if (sIPAddress != _T("123.123.123.125"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("unknown"))
        throw;

      sHeader = "Received: from outbound1.den.paypal.com ([216.113.188.96])\r\n"
                "  by mail.hmailserver.com\r\n"
                "  ; Sun, 13 Dec 2009 09:22:54 +0100\r\n";
      
      sIPAddress = Utilities::GetIPAddressFromReceivedHeader(sHeader).ToString();
      if (sIPAddress != _T("216.113.188.96"))
         throw;

      hostName = Utilities::GetHostNameFromReceivedHeader(sHeader);
      if (hostName != _T("outbound1.den.paypal.com"))
         throw;
   }
예제 #15
0
void RouteRequestManager::setRequest(Request* req,bool addToResults_){
	addToResults= addToResults_;
	__pRequest = req;
	String hostAddr = L"http://api.irail.be";

	result r = E_SUCCESS;
	__pSession = new HttpSession();
	r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null ,hostAddr,null);
	if (IsFailed(r))
		AppLogDebug("Construct Session failed. (%s)\n", GetErrorMessage(r));


	__pTransaction = __pSession->OpenTransactionN();
	if (null == __pTransaction)
		AppLogDebug("Construct Session failed. \n");

	r = __pTransaction->AddHttpTransactionListener(*this);
	if (IsFailed(r))
		AppLogDebug("AddHttpTransactionListener Session failed.\n");

	__pHttpRequest = __pTransaction->GetRequest();
	if(__pHttpRequest == null)
		AppLogDebug("GetRequest failed. \n");

	String hostAddr2(L"http://api.irail.be/connections/?to=");
	hostAddr2.Append(*req->getToStation()->getNameN());
	hostAddr2.Append(L"&from=");
	hostAddr2.Append(*req->getFromStation()->getNameN());
	hostAddr2.Replace(L" ","-");
	hostAddr2.Append(L"&typeOfTransport=train");
	DateTime* dt = req->getDateTime();
	if(dt){
		//LocaleManager localeManager;
		//localeManager.Construct();
		//TimeZone timeZone = localeManager.GetSystemTimeZone();
		//DateTime utcDateTime = timeZone.WallTimeToUtcTime(*req->getDateTime());
		hostAddr2.Append(L"&date=");
		if(dt->GetDay()<10)
			hostAddr2.Append(L"0");
		hostAddr2.Append(Integer::ToString(dt->GetDay()));
		if(dt->GetMonth()<10)
			hostAddr2.Append(L"0");
		hostAddr2.Append(Integer::ToString(dt->GetMonth()));
		String year;
		Integer::ToString(dt->GetYear()).SubString(2,year);
		hostAddr2.Append(year);

		hostAddr2.Append(L"&time=");
		if(dt->GetHour()<10)
			hostAddr2.Append(L"0");
		hostAddr2.Append(Integer::ToString(dt->GetHour()));
		if(dt->GetMinute()<10)
			hostAddr2.Append(L"0");
		hostAddr2.Append(Integer::ToString(dt->GetMinute()));
	}

	//AppLog("request link: %S",hostAddr2.GetPointer());

	r = __pHttpRequest->SetUri(hostAddr2);
	if(IsFailed(r))
		AppLogDebug("SetUri failed. (%s)\n", GetErrorMessage(r));

	r = __pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
	if(IsFailed(r))
		AppLogDebug("SetMethod failed. (%s)\n", GetErrorMessage(r));

	// Header Setting
	HttpHeader* pHttpHeader = null;
	pHttpHeader = __pHttpRequest->GetHeader();
	if (null == pHttpHeader){
		r = GetLastResult();
		AppLogDebug("Uri Setting failed. (%s)\n", GetErrorMessage(r));
		r = pHttpHeader->AddField(L"Content-Length", L"1024");
		if (IsFailed(r))AppLogDebug("Header Setting failed. (%s)\n", GetErrorMessage(r));
	}

	r = __pTransaction->Submit();
	if(IsFailed(r))
		AppLogDebug("Submit failed. (%s)\n", GetErrorMessage(r));
	//AppLog("request sended");

	//TODO delete __pHttpRequest
	//TODO delete pHttpHeader
}
예제 #16
0
void CMagicProcess::MagicPacket(Packet & pkt, Unit * pCaster /*= nullptr*/)
{
	if (g_pMain->m_IsMagicTableInUpdateProcess)
		return;

	MagicInstance instance;
	pkt >> instance.bOpcode >> instance.nSkillID;

	instance.pSkill = g_pMain->m_MagictableArray.GetData(instance.nSkillID);
	if (instance.pSkill == nullptr)
	{
		if (pCaster != nullptr)
			TRACE("[%s] Used skill %d but it does not exist.\n", pCaster->GetName().c_str(), instance.nSkillID);

		if (pCaster->isPlayer() && instance.nSkillID < 0)
		{
			DateTime time;
			g_pMain->SendFormattedNotice("%s is currently disconnect for skill hack.",Nation::ALL, pCaster->GetName().c_str());
			g_pMain->WriteCheatLogFile(string_format("[ SkillHack - %d:%d:%d ] %s Disconnected for SkillHack.\n", time.GetHour(),time.GetMinute(),time.GetSecond(), pCaster->GetName().c_str()));
			TO_USER(pCaster)->Disconnect();
		}

		return;
	}

	pkt >> instance.sCasterID >> instance.sTargetID
		>> instance.sData[0] >> instance.sData[1] >> instance.sData[2] >> instance.sData[3]
	>> instance.sData[4] >> instance.sData[5] >> instance.sData[6];

	// Prevent users from faking other players or NPCs.
	if (pCaster != nullptr // if it's nullptr, it's from AI.
		&& (instance.sCasterID >= NPC_BAND 
		|| instance.sCasterID != pCaster->GetID()))
		return;

	instance.bIsRecastingSavedMagic = false;
	instance.Run();
}
예제 #17
0
void Chatting::OnActionPerformed(const Tizen::Ui::Control& source,
		int actionId) {
	SceneManager* pSceneManager = SceneManager::GetInstance();
	AppAssert(pSceneManager);
	AppResource* pAppResource = Application::GetInstance()->GetAppResource();


	switch (actionId) {


	case IDC_BUTTON_SEND:
		AppLog("Send Button is clicked! \n");
		RequestHttpPost();
		OnButtonSend();
		break;

	case ID_BUTTON_EDITFIELD_DONE:
		//__pPanel->
		__pEditField->Draw();
		__pEditField->Show();
		break;
	case ID_BUTTON_EDITFIELD_CANCEL:
		__pEditField->SetText(*__pEditFieldText);
		//__pPanel->CloseOverlayWindow();
		__pEditField->Draw();
		__pEditField->Show();
		break;

	case IDC_BUTTON_PLUS:
		if (ischeck_plus == false) {

			__pChattControl->SetPosition(0, -444);
			//__pChattControl->SetPosition(0, -813);
			__pChattControl->Draw();
			__pPanel->SetPosition(where.x, where.y - 444);
			__pButtonPlus->SetNormalBackgroundBitmap(
					*pAppResource->GetBitmapN(L"chatting_x.png"));
			__pButtonPlus->Draw();
			__pPanel->Draw();
			ischeck_plus = true;


		} else {
			if(ischeck_key == false)
			{
			__pChattControl->SetPosition(where2.x, where2.y);
			__pChattControl->Draw();
			__pPanel->SetPosition(where.x, where.y);
			__pButtonPlus->SetNormalBackgroundBitmap(
					*pAppResource->GetBitmapN(L"chatting_plus.png"));
			__pButtonPlus->Draw();
			__pPanel->Draw();

			ischeck_plus = false;
			} else {

				__pEditField->SetKeypadEnabled(false);

				__pChattControl->SetPosition(where2.x, where2.y);
				__pChattControl->Draw();
				__pPanel->SetPosition(where.x, where.y);
				__pButtonPlus->SetNormalBackgroundBitmap(
				*pAppResource->GetBitmapN(L"chatting_plus.png"));
				__pButtonPlus->Draw();
				__pPanel->Draw();
				ischeck_key = false;
				ischeck_plus = false;
				__pEditField->SetKeypadEnabled(true);
			}
		}

		break;
	case IDC_BUTTON_FEEDBACKB:
	case IDC_BUTTON_RECORDGO:
		popup->SetShowState(true);
		popup->Show();
		break;
	case IDC_BUTTON_FEEDBACKX:
		popup->SetShowState(false);
		Record_Status=0;
		break;
	case IDC_BUTTON_RECORDER:
		if (Record_Status == 0) {
			AppLog("녹음중");

			__Record->SetNormalBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Start.png"));
			__Record->SetHighlightedBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Start.png"));
			__Record->SetPressedBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Start.png"));
			__Record->Draw();
			popup->RequestRedraw(true);
			Record_Status = 1;

			DateTime currentTime;
			SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);

			__filename.Format(32, L"%04d%02d%02d_%02d%02d%02d.mp3",
					currentTime.GetYear(), currentTime.GetMonth(),
					currentTime.GetDay(), currentTime.GetHour(),
					currentTime.GetMinute(), currentTime.GetSecond());
			__filepath = App::GetInstance()->GetAppDataPath() + __filename;

			__audioRecorder.CreateAudioFile(__filepath, true);
			__audioRecorder.SetMaxRecordingTime(60000); //60 sec
			__audioRecorder.SetQuality(RECORDING_QUALITY_HIGH);
			__audioRecorder.SetFormat(CODEC_MP3, MEDIA_CONTAINER_MP3);

			__audioRecorder.Record();
			__audioDestPath = Tizen::System::Environment::GetMediaPath()
					+ __filepath;
		} else if (Record_Status == 1) {
			AppLog("녹음완료");
			__Record->SetNormalBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Complete.png"));
			__Record->SetHighlightedBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Complete.png"));
			__Record->SetPressedBackgroundBitmap(
					*pAppResource->GetBitmapN(L"Record_Complete.png"));
			__Record->Draw();
			Record_Status = 2;

			__audioRecorder.Stop();
			__audioRecorder.Close();

			trans_voice->SetNormalBackgroundBitmap(
							*pAppResource->GetBitmapN(L"voice_trans2.png"));
				trans_voice->SetHighlightedBackgroundBitmap(
							*pAppResource->GetBitmapN(L"voice_trans2.png"));
				trans_voice->SetPressedBackgroundBitmap(
							*pAppResource->GetBitmapN(L"voice_trans2.png"));
				trans_voice->Draw();
				istransport = true;
		} else if (Record_Status == 2) {
			AppLog("재생");
			__filepath = App::GetInstance()->GetAppDataPath() + __filename;
			__player.OpenFile(__filepath);
			__player.SetVolume(100);
			__player.Play();

		}

		break;
	case IDC_BUTTON_TRANSPORT:
		if(istransport == true)
		{
			trans_voice->SetNormalBackgroundBitmap(
									*pAppResource->GetBitmapN(L"voice_trans1.png"));
						trans_voice->SetHighlightedBackgroundBitmap(
									*pAppResource->GetBitmapN(L"voice_trans1.png"));
						trans_voice->SetPressedBackgroundBitmap(
									*pAppResource->GetBitmapN(L"voice_trans1.png"));
						trans_voice->Draw();

			istransport = false;
			Toast* to = new Toast();
			to->Construct(Rectangle(30,1100 ,660,70), L"음성피드백을 전송하였습니다", 2000);
		}
		break;
	default:
		break;
	}
}
예제 #18
0
VOID CLogFile::DiskLog(enum_LOG_LEVEL	logLevel, const CHAR* pLogString , ...)
{
    //等级太低,不需打印控制台和文件
    if (logLevel < m_eConsoleLogLevel && logLevel < m_eFileLogLevel)
    {
        return ;
    }

    CHAR szLine[MAX_LOG_LINE] = {0};
    va_list	va;
    va_start(va,pLogString);
#ifdef __LINUX
    vsprintf(szLine,pLogString,va);
#else
    vsprintf_s(szLine,MAX_LOG_LINE,pLogString,va);
#endif
    va_end(va);

    DateTime now;
    CHAR szLogStr[MAX_LOG_LINE] = {'\0'};
    _snprintf(szLogStr, MAX_LOG_LINE, "%2d/%02d/%02d %02d:%02d:%02d.%03d	tId:%ld	%s\n",
              now.GetYear(),
              now.GetMonth(),
              now.GetDay(),
              now.GetHour(),
              now.GetMinute(),
              now.GetSecond(),
              now.GetMilliSecond(),
              GetThreadID(),
              szLine);

    //高等与控制台等级,则打印到控制台
    if (logLevel >= m_eConsoleLogLevel)
    {
        printf("%s", szLogStr);
    }

    //高等与文件等级,则打印到文件
    if (logLevel >= m_eFileLogLevel)
    {
        CSmartLock sLock(m_lock);

        INT nLogStrLen = strlen(szLogStr);

        if ((m_bBackBufAvailable) &&
                (m_pWriteBuf + nLogStrLen - m_pFrontBuf >=  LOG_BUF_LEN))
        {
            //如果back有东西, front还写不下,就要写2次文件了,不过这种情况应该很少
            WriteBackBufToFile();
        }

        if (m_pWriteBuf + nLogStrLen - m_pFrontBuf >=  LOG_BUF_LEN)
        {
            //front写不下,那么back肯定空着
            SwitchBuf();
        }

        //写入front
        strcpy( m_pWriteBuf, szLogStr );
        m_pWriteBuf += nLogStrLen;

        //全写入文件中
        WriteAllBufToFile();
    }
}