BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { // Set up the highest resolution timer we can manage // TIMECAPS tc; // UINT nPeriod; // if( TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)) ) // nPeriod = tc.wPeriodMin; // else // nPeriod = 1; // timeBeginPeriod( nPeriod ); HWND hWnd; g_hMainWnd = hWnd = CreateWindow(g_szWindowClass, g_szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); int x = 480, y = 0; SetWindowPos( hWnd, NULL, x, y, 800, 416, SWP_SHOWWINDOW ); if (!hWnd) return FALSE; SetTimer( g_hMainWnd, 0, SEC( 60 ), NULL ); // 60 SetTimer( g_hMainWnd, 1, MIN( 60 ), NULL ); // 3600 CTime time = CTime::GetCurrentTime(); SetLogInfo( LOGTYPE_TIME, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) ); g_GameTimer.SetTime(time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); #ifndef _DEBUG // #if defined(__MINIDUMP) // InitDumper( DUMP_LEVEL_0 ); // #else // InitEH(); // #endif // !__MINIDUMP #endif // _DEBUG EnableFloatException(); if( InitializeNetLib() == FALSE ) return FALSE; if( InitializeScriptLib() == FALSE ) return FALSE; xSRand( timeGetTime() ); // 속도를 요하는 랜덤은 xRandom()을 쓰도록... if( Script( g_szINI ) == TRUE ) { if( !prj.OpenProject( "Masquerade.prj" ) ) { Error( "OpenProject ERROR check Masquerade.prj" ); return FALSE; } SetLogInfo( LOGTYPE_REDRAW, "" ); SetTitle(); if( CompileItemScript( "ItemScript.lua" ) == FALSE ) return FALSE; #if defined(__REMOVE_SCIRPT_060712) if( CWorldDialog::GetInstance().Init() == FALSE ) { OutputDebugString( "WorldDialog.DLL load failed\n" ); return FALSE; } #endif return CRunObject::GetInstance()->Init(); } else { char szBuffer[300] = {0,}; char szDir[255] = {0,}; GetCurrentDirectory( 255, szDir ); sprintf( szBuffer, "%s\\WorldServer.ini File not found", szDir ); AfxMessageBox( szBuffer ); return FALSE; } }
void CUser::ZoneChange(int zone, float x, float z) { m_bZoneChangeFlag = TRUE; C3DMap* pMap = NULL; _ZONE_SERVERINFO *pInfo = NULL; pMap = g_pMain->GetZoneByID(zone); if (!pMap) return; if( pMap->m_bType == 2 ) { // If Target zone is frontier zone. if( GetLevel() < 20 && g_pMain->m_byBattleOpen != SNOW_BATTLE) return; } if( g_pMain->m_byBattleOpen == NATION_BATTLE ) { // Battle zone open if( m_pUserData.m_bZone == BATTLE_ZONE ) { if( pMap->m_bType == 1 && m_pUserData.m_bNation != zone ) { // ???? ?????? ???? ????.. if( m_pUserData.m_bNation == KARUS && !g_pMain->m_byElmoradOpenFlag ) { TRACE("#### ZoneChange Fail ,,, id=%s, nation=%d, flag=%d\n", m_pUserData.m_id, m_pUserData.m_bNation, g_pMain->m_byElmoradOpenFlag); return; } else if( m_pUserData.m_bNation == ELMORAD && !g_pMain->m_byKarusOpenFlag ) { TRACE("#### ZoneChange Fail ,,, id=%s, nation=%d, flag=%d\n", m_pUserData.m_id, m_pUserData.m_bNation, g_pMain->m_byKarusOpenFlag); return; } } } else if( pMap->m_bType == 1 && m_pUserData.m_bNation != zone ) { // ???? ?????? ???? ????.. return; } // else if( pMap->m_bType == 2 && zone == ZONE_FRONTIER ) { // You can't go to frontier zone when Battlezone is open. int temp_index = 0; char temp_buff[3]; SetByte( temp_buff, WIZ_WARP_LIST, temp_index ); SetByte( temp_buff, 2, temp_index ); SetByte( temp_buff,0, temp_index ); Send(temp_buff, temp_index); // return; } // } else if( g_pMain->m_byBattleOpen == SNOW_BATTLE ) { // Snow Battle zone open if( pMap->m_bType == 1 && m_pUserData.m_bNation != zone ) { // ???? ?????? ???? ????.. return; } else if( pMap->m_bType == 2 && (zone == ZONE_FRONTIER || zone == ZONE_BATTLE ) ) { // You can't go to frontier zone when Battlezone is open. return; } } else { // Battle zone close if( pMap->m_bType == 1 && m_pUserData.m_bNation != zone && (zone < 10 || zone > 21)) return; } m_bWarp = 0x01; UserInOut(INOUT_OUT); if( m_pUserData.m_bZone == ZONE_SNOW_BATTLE ) { //TRACE("ZoneChange - name=%s\n", m_pUserData.m_id); SetMaxHp( 1 ); } m_pUserData.m_bZone = zone; m_pUserData.m_curx = x; m_pUserData.m_curz = z; m_pMap = pMap; if( m_pUserData.m_bZone == ZONE_SNOW_BATTLE ) { //TRACE("ZoneChange - name=%s\n", m_pUserData.m_id); SetMaxHp(); } PartyRemove(GetSocketID()); // ??????? Z?????? ó?? //TRACE("ZoneChange ,,, id=%s, nation=%d, zone=%d, x=%.2f, z=%.2f\n", m_pUserData.m_id, m_pUserData.m_bNation, zone, x, z); if( g_pMain->m_nServerNo != pMap->m_nServerNo ) { pInfo = g_pMain->m_ServerArray.GetData( pMap->m_nServerNo ); if( !pInfo ) return; UserDataSaveToAgent(); CTime t = CTime::GetCurrentTime(); g_pMain->WriteLog("[ZoneChange : %d-%d-%d] - sid=%d, acname=%s, name=%s, zone=%d, x=%d, z=%d \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), GetSocketID(), m_strAccountID, m_pUserData.m_id, zone, (int)x, (int)z); m_pUserData.m_bLogout = 2; // server change flag SendServerChange(pInfo->strServerIP, 2); return; } SetRegion(GetNewRegionX(), GetNewRegionZ()); Packet result(WIZ_ZONE_CHANGE, uint8(3)); // magic numbers, sigh. result << uint16(GetZoneID()) << GetSPosX() << GetSPosZ() << GetSPosY() << g_pMain->m_byOldVictory; Send(&result); if (!m_bZoneChangeSameZone) { m_sWhoKilledMe = -1; m_iLostExp = 0; m_bRegeneType = 0; m_fLastRegeneTime = 0.0f; m_pUserData.m_sBind = -1; InitType3(); InitType4(); } result.Initialize(AG_ZONE_CHANGE); result << GetSocketID() << GetZoneID(); g_pMain->Send_AIServer(&result); m_bZoneChangeSameZone = FALSE; m_bZoneChangeFlag = FALSE; }
void CMainDlg::onRecvProtocol( BasicProtocol* p, SOCKET socket) { using namespace ROBOT_PROTOCOL; switch( p->iid_) { case RBT_CONFIG_REQ: { Robot_Config_Req* req = reinterpret_cast <Robot_Config_Req*>(p); Robot_Config_Ack* ack = new Robot_Config_Ack(); ack->version_ = ROBOT_VERSION; OptionUtil::RobotDesctiption* des = g_opt.find_robot_byname( req->robotname_); if ( des) { if ( des->robotpwd_ != req->robotpwd_) ack->ret_ = -2; else { if ( req->version_ != ROBOT_VERSION) { ack->ret_ = -4; } else { ack->robotid_ = des->robotid_; ack->startuserid_ = des->startuserid_; ack->users_ = des->users_; ack->gatewayip_ = des->gatewayip_; ack->gatewayport_ = des->gatewayport_; ack->ret_ = 0; S_INT_32 item = FindLstItemByName( des->robotname_); if ( -1 != item) { char text[256]; sprintf(text, "%u", socket); lstclients_.SetItem(item, 0, LVIF_TEXT, text, 0, 0, 0, 0); sprintf(text, "%s", des->robotname_.c_str()); lstclients_.SetItem(item, 1, LVIF_TEXT, text, 0, 0, 0, 0); sockaddr_in sa; int salen; salen = sizeof(sa); if( getpeername( socket, (sockaddr*)&sa, &salen ) == 0 ) { sprintf( text, "%s", inet_ntoa( sa.sin_addr)); lstclients_.SetItem(item, 2, LVIF_TEXT, text, 0, 0, 0, 0); sprintf( text, "%d", ntohs( sa.sin_port)); lstclients_.SetItem(item, 3, LVIF_TEXT, text, 0, 0, 0, 0); } else { sprintf( text, "peer ip error"); lstclients_.SetItem(item, 2, LVIF_TEXT, text, 0, 0, 0, 0); sprintf( text, "%d", ntohs( sa.sin_port)); lstclients_.SetItem(item, 3, LVIF_TEXT, text, 0, 0, 0, 0); } CTime tm = CTime::GetCurrentTime(); sprintf(text, "%.2d:%.2d:%.2d", tm.GetHour(), tm.GetMinute(), tm.GetSecond()); lstclients_.SetItem(item, 4, LVIF_TEXT, text, 0, 0, 0, 0); sprintf(text, "%u", des->startuserid_); lstclients_.SetItem(item, 5, LVIF_TEXT, text, 0, 0, 0, 0); sprintf(text, "%u", des->users_); lstclients_.SetItem(item, 6, LVIF_TEXT, text, 0, 0, 0, 0); sprintf(text, "%u", 0); lstclients_.SetItem(item, 7, LVIF_TEXT, text, 0, 0, 0, 0); lstclients_.SetItemData( item, socket); lstclients_.SetItem( item, 0, LVIF_IMAGE, "", ICON_CONNECTED, 0, 0, 0); } } } } else ack->ret_ = -1; listener_.send_protocol(socket, ack); } break; default: break; } }
BOOL TMonsterAIRuleInfo::CheckConditionSpecificDate() { CTime tCurrentTime = CTime::GetTickCount(); CTimeSpan tValidRange(0, 0, 0, this->m_iWaitTime+this->m_iContinuanceTime); int iYear = tCurrentTime.GetYear(); int iMonth = tCurrentTime.GetMonth(); int iDay = tCurrentTime.GetDay(); int iDayOfWeek = tCurrentTime.GetDayOfWeek(); int iHour = tCurrentTime.GetHour(); int iMinute = tCurrentTime.GetMinute(); if ( this->m_iMonth != -1 ) { if ( this->m_iMonth != iMonth ) { CTime tConditionTime(iYear, this->m_iMonth, 0, 0, 0, 0, -1) ; if ( tCurrentTime < tConditionTime || tCurrentTime > tConditionTime+tValidRange ) { return FALSE; } } } if ( this->m_iDay != -1 ) { if ( this->m_iDay != iDay ) { CTime tConditionTime(iYear, (this->m_iMonth == -1)?iMonth : this->m_iMonth , this->m_iDay, 0, 0, 0, -1); if ( tCurrentTime < tConditionTime || tCurrentTime > tConditionTime+tValidRange ) { return FALSE; } } } if ( this->m_iWeekDay != -1 ) { if ( this->m_iWeekDay != iDayOfWeek ) { return FALSE; } } if ( this->m_iHour != -1 ) { if ( this->m_iHour != iHour ) { CTime tConditionTime(iYear, (this->m_iMonth == -1)?iMonth : this->m_iMonth, (this->m_iDay == -1)?iDay : this->m_iDay, this->m_iHour, 0, 0, -1) ; if ( tCurrentTime < tConditionTime || tCurrentTime > tConditionTime+tValidRange ) { return FALSE; } } } if ( this->m_iMinute != -1 ) { if ( this->m_iMinute != iMinute ) { CTime tConditionTime(iYear, (this->m_iMonth == -1)?iMonth : this->m_iMonth, (this->m_iDay == -1)?iDay : this->m_iDay, (this->m_iHour == -1)?iHour : this->m_iHour, this->m_iMinute, 0, -1) ; if ( tCurrentTime < tConditionTime || tCurrentTime > tConditionTime+tValidRange ) { return FALSE; } } } return TRUE; }
void CAISocket::RecvNpcInfo(char* pBuf) { int index = 0; BYTE Mode; // 01(INFO_MODIFY) : NPC 정보 변경 // 02(INFO_DELETE) : NPC 정보 삭제 short nid; // NPC index short sid; // NPC index short sPid; // NPC Picture Number short sSize = 100; // NPC Size int iWeapon_1; // 오른손 무기 int iWeapon_2; // 왼손 무기 BYTE bZone; // Current zone number char szName[MAX_NPC_SIZE+1]; // NPC Name BYTE byGroup; // 소속 집단 BYTE byLevel; // level float fPosX; // X Position float fPosZ; // Z Position float fPosY; // Y Position BYTE byDirection; // 방향 BYTE tState; // NPC 상태 // 00 : NPC Dead // 01 : NPC Live BYTE tNpcKind; // 00 : Monster // 01 : NPC int iSellingGroup; int nMaxHP; // 최대 HP int nHP; // 현재 HP BYTE byGateOpen; short sHitRate; // 공격 성공률 BYTE byObjectType; // 보통 : 0, 특수 : 1 Mode = GetByte(pBuf, index); nid = GetShort(pBuf, index); sid = GetShort(pBuf, index); sPid = GetShort(pBuf, index); sSize = GetShort(pBuf, index); iWeapon_1 = GetDWORD(pBuf, index); iWeapon_2 = GetDWORD(pBuf, index); bZone = GetByte(pBuf, index); int nLength = GetVarString(szName, pBuf, sizeof(BYTE), index); if(nLength < 0 || nLength > MAX_NPC_SIZE) return; // 잘못된 monster 아이디 byGroup = GetByte(pBuf, index); byLevel = GetByte(pBuf, index); fPosX = Getfloat(pBuf, index); fPosZ = Getfloat(pBuf, index); fPosY = Getfloat(pBuf, index); byDirection = GetByte(pBuf, index); tState = GetByte(pBuf, index); tNpcKind = GetByte(pBuf, index); iSellingGroup = GetDWORD(pBuf, index); nMaxHP = GetDWORD(pBuf, index); nHP = GetDWORD(pBuf, index); byGateOpen = GetByte(pBuf, index); sHitRate = GetShort(pBuf, index); byObjectType = GetByte(pBuf, index); CNpc* pNpc = NULL; pNpc = m_pMain->m_arNpcArray.GetData(nid); if(!pNpc) return; pNpc->m_NpcState = NPC_DEAD; if( pNpc->m_NpcState == NPC_LIVE ) { // 살아 있는데 또 정보를 받는 경우 char strLog[256]; CTime t = CTime::GetCurrentTime(); sprintf_s(strLog, sizeof(strLog), "## time(%d:%d-%d) npc regen check(%d) : nid=%d, name=%s, x=%d, z=%d, rx=%d, rz=%d ## \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), pNpc->m_NpcState, nid, szName, (int)pNpc->m_fCurX, (int)pNpc->m_fCurZ, pNpc->m_sRegion_X, pNpc->m_sRegion_Z); EnterCriticalSection( &g_LogFile_critical ); m_pMain->m_RegionLogFile.Write( strLog, strlen(strLog) ); LeaveCriticalSection( &g_LogFile_critical ); TRACE(strLog); // to-do: replace with m_pMain->WriteRegionLog(...); } pNpc->m_NpcState = NPC_LIVE; pNpc->m_sNid = nid; pNpc->m_sSid = sid; pNpc->m_sPid = sPid; pNpc->m_sSize = sSize; pNpc->m_iWeapon_1 = iWeapon_1; pNpc->m_iWeapon_2 = iWeapon_2; strcpy(pNpc->m_strName, szName); pNpc->m_byGroup = byGroup; pNpc->m_byLevel = byLevel; pNpc->m_bCurZone = bZone; pNpc->m_pMap = m_pMain->GetZoneByID(bZone); pNpc->m_fCurX = fPosX; pNpc->m_fCurZ = fPosZ; pNpc->m_fCurY = fPosY; pNpc->m_byDirection = byDirection; pNpc->m_NpcState = tState; pNpc->m_tNpcType = tNpcKind; pNpc->m_iSellingGroup = iSellingGroup; pNpc->m_iMaxHP = nMaxHP; pNpc->m_iHP = nHP; pNpc->m_byGateOpen = byGateOpen; pNpc->m_sHitRate = sHitRate; pNpc->m_byObjectType = byObjectType; if (pNpc->GetMap() == NULL) return; int nRegX = (int)fPosX / VIEW_DISTANCE; int nRegZ = (int)fPosZ / VIEW_DISTANCE; pNpc->m_sRegion_X = nRegX; pNpc->m_sRegion_Z = nRegZ; _OBJECT_EVENT* pEvent = NULL; if( pNpc->m_byObjectType == SPECIAL_OBJECT ) { pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid ); if( pEvent ) pEvent->byLife = 1; } if(Mode == 0) { TRACE("RecvNpcInfo - dead monster nid=%d, name=%s\n", pNpc->m_sNid, pNpc->m_strName); return; } pNpc->NpcInOut(NPC_IN, fPosX, fPosZ, fPosY); }
void CGameSocket::RecvUserInfo(char* pBuf) { // TRACE("RecvUserInfo()\n"); int index = 0; short uid=-1, sHp, sMp, sLength = 0; BYTE bNation, bLevel, bZone, bAuthority=1; short sDamage, sAC; float fHitAgi, fAvoidAgi; char strName[MAX_ID_SIZE+1]; short sItemAC, sAmountLeft, sAmountRight; BYTE bTypeLeft, bTypeRight; uid = GetShort( pBuf, index ); sLength = GetShort( pBuf, index ); if( sLength > MAX_ID_SIZE || sLength <= 0 ) { char countstr[256]; CTime cur = CTime::GetCurrentTime(); sprintf_s( countstr, "RecvUserInfo() Fail : %02d/%02d %02d:%02d - uid=%d, name=%s\r\n", cur.GetMonth(), cur.GetDay(), cur.GetHour(), cur.GetMinute(), uid, strName); LogFileWrite( countstr ); TRACE("### RecvUserInfo() Fail ---> uid = %d, name=%s ### \n", uid, strName); return; } GetString(strName, pBuf, sLength, index); bZone = GetByte( pBuf, index ); bNation = GetByte( pBuf, index ); bLevel = GetByte( pBuf, index ); sHp = GetShort( pBuf, index ); sMp = GetShort( pBuf, index ); sDamage = GetShort( pBuf, index ); sAC = GetShort( pBuf, index ); fHitAgi = Getfloat( pBuf, index ); fAvoidAgi = Getfloat( pBuf, index ); // sItemAC = GetShort(pBuf, index); bTypeLeft = GetByte(pBuf, index); bTypeRight = GetByte(pBuf, index); sAmountLeft = GetShort(pBuf, index); sAmountRight = GetShort(pBuf, index); bAuthority = GetByte(pBuf, index); // //CUser* pUser = m_pMain->GetActiveUserPtr(uid); //if( pUser == NULL ) return; CUser* pUser = new CUser; pUser->Initialize(); pUser->m_iUserId = uid; strcpy(pUser->m_strUserID, strName); pUser->m_curZone = bZone; pUser->m_pMap = m_pMain->GetZoneByID(bZone); pUser->m_bNation = bNation; pUser->m_bLevel = bLevel; pUser->m_sHP = sHp; pUser->m_sMP = sMp; //pUser->m_sSP = sSp; pUser->m_sHitDamage = sDamage; pUser->m_fHitrate = fHitAgi; pUser->m_fAvoidrate = fAvoidAgi; pUser->m_sAC = sAC; pUser->m_bLive = USER_LIVE; // pUser->m_sItemAC = sItemAC; pUser->m_bMagicTypeLeftHand = bTypeLeft; pUser->m_bMagicTypeRightHand = bTypeRight; pUser->m_sMagicAmountLeftHand = sAmountLeft; pUser->m_sMagicAmountRightHand = sAmountRight; pUser->m_byIsOP = bAuthority; // TRACE("**** RecvUserInfo()---> uid = %d, name=%s, leng=%d ******\n", uid, strName, sLength); if(uid >= USER_BAND && uid < MAX_USER) { m_pMain->m_pUser[uid] = pUser; } _USERLOG* pUserLog = NULL; pUserLog = new _USERLOG; pUserLog->t = CTime::GetCurrentTime(); pUserLog->byFlag = USER_LOGIN; pUserLog->byLevel = pUser->m_bLevel; strcpy( pUserLog->strUserID, pUser->m_strUserID ); pUser->m_UserLogList.push_back( pUserLog ); }
//*======================================================================================== //*函数: bool CSmartJZSRCTable::Convert(TSSmartDoc *pDoc, unsigned char *ucRawData) //*功能: 转换结构 //*参数: 略 //*返回: 是否成功 //*说明: 虚基类程序 //*======================================================================================== bool CSmartJZSRCTable::Convert(int nAuthNo, TSSmartDoc *pDoc, unsigned char *ucRawData, char *pszAdjustCode) { CString strValue = "" ; CString strText = ""; CString strData = ""; char szDateTime[7]; CString strDealCode = "20"; //收费机 0232 上机上网机 if( !strcmp(pDoc->m_szMacCode, "0226") || !strcmp(pDoc->m_szMacCode, "0232") ) { strDealCode = "91"; } //增值机 else if( !strcmp(pDoc->m_szMacCode, "0201") ) { strDealCode = "90"; } CTime t = CTime::GetCurrentTime(); strText.Format("%04d-%02d-%02d %02d:%02d:%02d ", t.GetYear(), t.GetMonth(), t.GetDay(), t.GetHour(), t.GetMinute(), t.GetSecond()); sprintf(szDateTime, "%04d%02d", t.GetYear(), t.GetMonth()); m_strTableName.Format("Smart_JZSource%04d%02d", t.GetYear(), t.GetMonth()); strValue.Format("注册号:%.2X%.2X%.2X%.2X ",ucRawData[0],ucRawData[1],ucRawData[2],ucRawData[3]); strText += strValue ; GetValue(strValue, m_SRC.sMachineID); strValue.Format("%s", m_SRC.sMachineID); strData+= strValue; strValue.Format("扎帐流水:%d ", ucRawData[6]*256+ucRawData[7]); strText += strValue ; GetValue(strValue, m_SRC.nSettleInvoice); strValue.Format("%d", m_SRC.nSettleInvoice); strData+= strValue; if( !IsValidDateTime(&ucRawData[8]) ) { char szDateTime[24]; GetCurDateTime(szDateTime); strValue = szDateTime; strText += strValue ; GetValue(strValue, m_SRC.sSettleTime); } else { strValue.Format("扎帐时间:%04d-%02d-%02d %02d:%02d:%02d ",ucRawData[8]+2000,ucRawData[9],ucRawData[10],ucRawData[11],ucRawData[12],ucRawData[13]); strText += strValue ; GetValue(strValue, m_SRC.sSettleTime); } strValue.Format("%s", m_SRC.sSettleTime); strData+= strValue; strValue.Format("起始流水号:%d ",ucRawData[14]*256+ucRawData[15]); strText += strValue ; GetValue(strValue, m_SRC.nBeginInvoice); strValue.Format("%d", m_SRC.nBeginInvoice); strData+= strValue; strValue.Format("结束流水号:%d ",ucRawData[16]*256+ucRawData[17]); strText += strValue ; GetValue(strValue, m_SRC.nEndInvoice); strValue.Format("%d", m_SRC.nEndInvoice); strData+= strValue; strValue.Format("正常消费总笔数:%d ",ucRawData[18]*256+ucRawData[19]); strText += strValue ; GetValue(strValue, m_SRC.nDealCount); strValue.Format("%d", m_SRC.nDealCount); strData+= strValue; strValue.Format("正常消费总金额:%d ",ucRawData[20]+ucRawData[21]*256+ucRawData[22]*65536); strText += strValue ; GetValue(strValue, m_SRC.nDealAmount); strValue.Format("%d", m_SRC.nDealAmount); strData+= strValue; strValue.Format("冲正消费总笔数:%d ",ucRawData[23]*256+ucRawData[24]); strText += strValue ; GetValue(strValue, m_SRC.nCancelCount); strValue.Format("%d", m_SRC.nCancelCount); strData+= strValue; strValue.Format("冲正消费总金额:%d ",ucRawData[25]+ucRawData[26]*256+ucRawData[27]*65536); strText += strValue ; GetValue(strValue, m_SRC.nCancelAmount); strValue.Format("%d", m_SRC.nCancelAmount); strData+= strValue; strValue.Format("异常消费总笔数%d\n",ucRawData[28]*256+ucRawData[29]); strText += strValue ; GetValue(strValue, m_SRC.nExcepCount); strValue.Format("%d", m_SRC.nExcepCount); strData+= strValue; strValue.Format("异常消费总金额%d\n",ucRawData[30]+ucRawData[31]*256+ucRawData[32]*65536); strText += strValue ; GetValue(strValue, m_SRC.nExcepACount); strValue.Format("%d", m_SRC.nExcepACount); strData+= strValue; strValue.Format("其他交易总笔数:%d ",ucRawData[33]*256+ucRawData[34]); strText += strValue ; GetValue(strValue, m_SRC.nOtherCount); strValue.Format("%d", m_SRC.nOtherCount); strData+= strValue; strValue.Format("扎帐标记:%.2X ",ucRawData[35]); strText += strValue ; GetValue(strValue, m_SRC.nOuterkeeper); strValue.Format("%d", m_SRC.nOuterkeeper); strData+= strValue; int nSettType = 0; if(ucRawData[35] == 0x00) strValue = "初次运行扎帐 "; else if(ucRawData[35] == 0x01) strValue = "上位机扎帐 "; else if(ucRawData[35] == 0x02) strValue = "复核扎帐 "; else if(ucRawData[35] == 0x03) { nSettType = 0; strValue = "手工扎帐 "; } else if(ucRawData[35] == 0x04) { nSettType = 1; strValue = "定时扎帐 "; } else if(ucRawData[35] == 0x05) { nSettType = 1; strValue = "开机扎帐 "; } else strValue = "未知类型 "; strValue.Format("CRC:%.2X%.2X\n", ucRawData[36],ucRawData[37]); strText += strValue ; CString strAdjust=GetAdjustCode(pszAdjustCode, m_SRC.nSettleInvoice, m_SRC.sSettleTime, "Smart_Settlement"); if( strAdjust == "" && !IsValidDateTime(&ucRawData[8]) ) { strAdjust = "0204"; } m_pDoc = pDoc ; CString strTemp = "" ; strTemp = "INSERT INTO " + m_strTableName ; strTemp+= "(SMT_RowID, SMT_AuthNo, SMT_Data, SMT_CRC, "; strTemp+= "SMT_DateTime, SMT_DealWith, SMT_DealWithDateTime, SMT_AdjustCode) "; strTemp+= " VALUES(SMART_JZSOURCE%s_rowid.nextval, %ld, '%s', %d, SYSDATE, 0, NULL, '%s')"; if( strAdjust == "0102" ) { strSQL1.Format(strTemp, szDateTime, nAuthNo, strData.GetBuffer(0), 0, strAdjust.GetBuffer(0)); } else { strSQL1.Format(strTemp, szDateTime, nAuthNo, strData.GetBuffer(0), 1, strAdjust.GetBuffer(0)); } strTemp = "INSERT INTO Smart_Settlement(" ; strTemp+= " SMT_RowID, SMT_Authno, SMT_MachineID, SMT_Org_id, " ; strTemp+= " SMT_SettleInvoice, SMT_SettleTime, SMT_BeginInvoice, " ; strTemp+= " SMT_EndInvoice, SMT_DealCount, SMT_DealAmount, " ; strTemp+= " SMT_CancelCount, SMT_CancelAmount, SMT_OtherCount, " ; strTemp+= " SMT_OperatorID, SMT_KeepingDate, SMT_BatchNo, " ; strTemp+= " SMT_SettleType, SMT_DealCode, SMT_EXCEPTCOUNT, SMT_EXCEPTAMOUNT, SMT_ADJUSTCODE) VALUES( " ; strTemp+= " SMART_SETTLEMENT_ROWID.nextval, %d, '%s', '%s', " ; strTemp+= " %d, to_date('%s','yyyy-mm-dd hh24:mi:ss'), %d, " ; strTemp+= " %d, %d, %d, " ; strTemp+= " %d, %d, %d, " ; strTemp+= " '%d', SYSDATE, %d, " ; strTemp+= " %d, '%s', %d, %d,'%s')" ; char szOrg[12]; if( !strcmp(pDoc->m_szOrgid, "") ) strcpy(szOrg, " "); else strcpy(szOrg, pDoc->m_szOrgid); strSQL2.Format(strTemp.GetBuffer(0), nAuthNo, m_SRC.sMachineID, szOrg, m_SRC.nSettleInvoice, m_SRC.sSettleTime, m_SRC.nBeginInvoice, m_SRC.nEndInvoice, m_SRC.nDealCount, m_SRC.nDealAmount, m_SRC.nCancelCount, m_SRC.nCancelAmount, m_SRC.nOtherCount, 999, 0, nSettType, strDealCode.GetBuffer(0), m_SRC.nExcepCount, m_SRC.nExcepACount, strAdjust.GetBuffer(0)); strUpdate.Format("Update Smart_Commrec Set SMT_LASTDEALDATETIME=to_date('%s','yyyy-mm-dd hh24:mi:ss'), SMT_SETTLEINVOICE=%ld, SMT_SETTLETIME=to_date('%s','yyyy-mm-dd hh24:mi:ss'), SMT_BEGININVOICE=%d, SMT_ENDINVOICE=%d Where Smt_AuthNo=%ld ", m_SRC.sSettleTime, m_SRC.nSettleInvoice, m_SRC.sSettleTime, m_SRC.nBeginInvoice, m_SRC.nEndInvoice, nAuthNo); /* CString strString; pDoc->m_nFlow = m_SRC.nSettleInvoice; pDoc->m_nCardID = 0; pDoc->m_nInMoney = m_SRC.nDealAmount; pDoc->m_nOutMoney = m_SRC.nCancelAmount; pDoc->m_nDealCount++; strString.Format("%d&%d&%d&%s&%d&%d&%d", pDoc->m_nAuthID, m_SRC.nSettleInvoice, pDoc->m_nDealCount, m_SRC.sSettleTime, 0, m_SRC.nDealAmount, m_SRC.nCancelAmount); BroadcastPro(PACKET_CMD_1002, pDoc, strString.GetBuffer(0), strString.GetLength()); */ return true; }
//MORPH - Changed by SiRoB, SLS keep only for rar files, reduce saved source and life time //CString CSourceSaver::CalcExpiration(int Days) CString CSourceSaver::CalcExpiration(int Minutes) { CTime expiration = CTime::GetCurrentTime(); //MORPH - Changed by SiRoB, SLS keep only for rare files, reduce Saved Source and life time //CTimeSpan timediff(Days, 0, 0, 0); CTimeSpan timediff(Minutes/1440, (Minutes/60) % 24, Minutes % 60, 0); expiration += timediff; CString strExpiration; //MORPH - Changed by SiRoB, SLS keep only for rare files, reduce Saved Source and life time //strExpiration.Format("%02i%02i%02i", (expiration.GetYear() % 100), expiration.GetMonth(), expiration.GetDay()); strExpiration.Format(_T("%02i%02i%02i%02i%02i"), (expiration.GetYear() % 100), expiration.GetMonth(), expiration.GetDay(), expiration.GetHour(),expiration.GetMinute()); return strExpiration; }
void CMessageDlg::AppendMessage(const TextMessage& msg, BOOL bStore/* = TRUE*/) { //append to message list if(bStore) m_messages.push_back(msg); //insert enter m_richHistory.SetSel(0,0); m_richHistory.ReplaceSel(_T("\r\n")); //insert msg m_richHistory.SetSel(0,0); m_richHistory.ReplaceSel( msg.szMessage ); CHARFORMAT cf; cf.cbSize = sizeof (CHARFORMAT); cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD; cf.dwEffects = (unsigned long)~(CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD); cf.crTextColor = RGB(0, 0, 0); m_richHistory.SetSel(0, long(_tcslen(msg.szMessage))); m_richHistory.SetSelectionCharFormat(cf); //insert enter m_richHistory.SetSel(0,0); m_richHistory.ReplaceSel(_T("\r\n")); CTime tm = CTime::GetCurrentTime(); CString szTime; szTime.Format(_T("%.2d:%.2d"), tm.GetHour(), tm.GetMinute()); CString name; if(msg.nFromUserID == m_myself.nUserID) name.Format(_T("%s:"), GetDisplayName(m_myself)); else { name.Format(_T("%s:"), GetDisplayName(m_user)); } if(m_bShowTimeStamp) name = szTime + _T(" ") + name; //insert name m_richHistory.SetSel(0,0); m_richHistory.ReplaceSel(name); memset(&cf,0,sizeof (CHARFORMAT)); cf.cbSize = sizeof (CHARFORMAT); cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD; cf.dwEffects = CFE_UNDERLINE | CFE_BOLD; if(msg.nFromUserID == m_myself.nUserID) cf.crTextColor = RGB(0, 0, 255); else { if(m_user.uUserType & USERTYPE_ADMIN) cf.crTextColor = RGB(255, 117, 5); else cf.crTextColor = RGB(255, 0, 0); } m_richHistory.SetSel(0,name.GetLength()); m_richHistory.SetSelectionCharFormat(cf); m_richHistory.HideSelection(TRUE, FALSE); if(bStore) WriteLogMsg(m_logFile, name + msg.szMessage + _T("\r\n")); }
void CBatchSNDlg::WriteSerialNumber(unsigned long SN){ CStdioFile file; CString filepath; CString SerialDate; CTime time = CTime::GetCurrentTime(); SerialDate.Format(_T("\n%d,%d-%d-%d %d:%d:%d"),SN,time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); filepath=g_strExePth+_T("Sensor Serial Record.txt"); if(!file.Open(filepath, CFile::shareDenyNone|CFile::modeReadWrite)) { return ; } file.SeekToEnd(); file.WriteString(SerialDate.GetBuffer()); // file.Flush(); file.Close(); }
//处里THREAD的函式 void CKThread::SomeThing(void) { do { CTime time = CTime::GetCurrentTime(); int m_nYear = time.GetYear(); ///年 int m_nMonth = time.GetMonth(); ///月 int m_nDay = time.GetDay(); ///日 int m_nhour = time.GetHour(); int m_nmin = time.GetMinute(); int m_nsec = time.GetSecond(); if(m_vpArray.size() > 0 ) { /*EnterCriticalSection(&m_guard); for(UINT i = 0; i < m_vpArray.size();i++) { CString str1 = m_vpArray[0]; CString str = m_CKbirdge.SendMsg(str1); if(!str.Compare("ok")) { m_vpArray.erase( m_vpArray.begin( ) ); } Sleep(30); } LeaveCriticalSection(&m_guard);*/ if(sort == 3) { string bb = "xxx"; } int sendflag=0; CString SendStr=""; int start1 = 25; int start2 = 24; if(m_vpArray.size() < start1) { sendflag=m_vpArray.size()-1; } else { sendflag =start2; } bool rtn = false; EnterCriticalSection(&m_guard); try { //m_OraDal.AddData(m_vpArray[0]); //m_vpArray.erase( m_vpArray.begin( )); for(UINT i = 0; i <= sendflag;i++) { SendStr += m_vpArray[i]; if(i< sendflag) SendStr += "$"; if(i == sendflag) { SendStr = "Stock$"+SendStr ; CString str = m_CKbirdge.SendMsg(SendStr); if(!str.Compare("ok")) { for(UINT j = 0; j <= sendflag;j++) { m_vpArray.erase( m_vpArray.begin( ) ); } } } } restartCount++; } catch(...) { //Release(); //Init(); } LeaveCriticalSection(&m_guard); if(sendCount >=10) { Sleep(100); } else { Sleep(5); } if(sendCount > 100000) sendCount = 10; if(restartCount>=500) { m_CKbirdge.Release(); m_CKbirdge.Init(); restartCount=0; } } else { //restartCount++; // if(restartCount>=60) { // //m_CKbirdge.Release(); // //m_CKbirdge.Init(); // restartCount=0; //} //if(m_bInit) { // AddData("$ok"); //} Sleep(300); } //DoEvents(); }while(m_SomeThingRun); CloseHandle( m_SomeThingThread); m_SomeThingThread = 0; }
int CScheduler::Check(bool forcecheck){ if (!thePrefs.IsSchedulerEnabled() || theApp.scheduler->GetCount()==0 || !theApp.emuledlg->IsRunning()) return -1; Schedule_Struct* schedule; struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); if (!forcecheck && tNow.GetMinute()==m_iLastCheckedMinute) return -1; m_iLastCheckedMinute=tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); for (uint8 si=0;si<theApp.scheduler->GetCount();si++) { schedule=theApp.scheduler->GetSchedule(si); if (schedule->actions[0]==0 || !schedule->enabled) continue; // check day of week if (schedule->day!=DAY_DAYLY) { int dow=tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO : if (dow!=2) continue; break; case DAY_DI : if (dow!=3) continue; break; case DAY_MI : if (dow!=4) continue; break; case DAY_DO : if (dow!=5) continue; break; case DAY_FR : if (dow!=6) continue; break; case DAY_SA : if (dow!=7) continue; break; case DAY_SO : if (dow!=1) continue; break; case DAY_MO_FR : if (dow==7 || dow==1 ) continue; break; case DAY_MO_SA : if (dow==1) continue; break; case DAY_SA_SO : if (dow>=2 && dow<=6) continue; } } //check time UINT h1,h2,m1,m2; CTime t1=CTime(schedule->time); CTime t2=CTime(schedule->time2); h1=t1.GetHour(); h2=t2.GetHour(); m1=t1.GetMinute(); m2=t2.GetMinute(); int it1,it2, itn; it1=h1*60 + m1; it2=h2*60 + m2; itn=tNow.GetHour()*60 + tNow.GetMinute(); if (it1<=it2) { // normal timespan if ( !(itn>=it1 && itn<it2) ) continue; } else { // reversed timespan (23:30 to 5:10) now 10 if ( !(itn>=it1 || itn<it2)) continue; } // ok, lets do the actions of this schedule ActivateSchedule(si,schedule->time2==0); } return -1; }
void OnTimer( WORD wTimerID ) { if( wTimerID == TIMER_ID_DEFAULT ) { g_GameTimer.Compute(); #ifdef __EVE_NEWYEAR static BOOL s_bCountdown = FALSE; CTime tmCur = CTime::GetCurrentTime(); if( ::GetLanguage() == LANG_GER || ::GetLanguage() == LANG_FRE ) { if( !s_bCountdown && tmCur > CTime( 2009, 12, 31, 22, 58, 59 ) && tmCur < CTime( 2009, 12, 31, 23, 0, 0 ) ) { s_bCountdown = TRUE; g_DPCacheSrvr.SendHdr( PACKETTYPE_NEWYEAR, DPID_ALLPLAYERS, DPID_ALLPLAYERS ); } if( tmCur > CTime( 2009, 12, 31, 23, 0, 0 ) ) s_bCountdown = FALSE; } else { if( !s_bCountdown && tmCur > CTime( 2009, 12, 31, 23, 58, 59 ) && tmCur < CTime( 2010, 1, 1, 0, 0, 0 ) ) { s_bCountdown = TRUE; g_DPCacheSrvr.SendHdr( PACKETTYPE_NEWYEAR, DPID_ALLPLAYERS, DPID_ALLPLAYERS ); } if( tmCur > CTime( 2010, 1, 1, 0, 0, 0 ) ) s_bCountdown = FALSE; } #endif // __EVE_NEWYEAR return; } #if !defined(__INTERNALSERVER) if( wTimerID == TIMER_ID_WANTED ) // 현상금 처리 { g_dpCoreSrvr.SendCWWantedList(); // 현상금 리스트를 보낸다. return; } #endif // __INTERNALSERVER #ifdef __EVENT0913 if( wTimerID == TIMER_ID_EVENT0913 ) { CTime tmCurr = CTime::GetCurrentTime(); BOOL bEventTime = ( tmCurr.GetHour() >= 17 && tmCurr.GetHour() < 18 ) || ( tmCurr.GetHour() >= 22 && tmCurr.GetHour() < 23 ); if( bEventTime && !s_bEvent0913 ) // 이벤트 시간 - 이벤트 설정되어 있지 않으면, { g_dpCoreSrvr.SendEvent0913( s_bEvent0913 = TRUE ); } else if( !bEventTime && s_bEvent0913 ) // 이벤트 시간이 아닌데 이벤트 설정되어 있으면, { g_dpCoreSrvr.SendEvent0913( s_bEvent0913 = FALSE ); } } #endif // __EVENT0913 #ifdef __EVENT1206 if( wTimerID == TIMER_ID_EVENT1206 ) { CTime tmCurr = CTime::GetCurrentTime(); BOOL bEventTime; if( s_bTest ) { bEventTime = ( tmCurr.GetHour() % 2 == 0 ); // even } else { bEventTime = ( tmCurr >= CTime( 2005, 12, 10, 19, 0, 0 ) && tmCurr < CTime( 2005, 12, 10, 22, 0, 0 ) ) || ( tmCurr >= CTime( 2005, 12, 11, 19, 0, 0 ) && tmCurr < CTime( 2005, 12, 11, 22, 0, 0 ) ); } if( bEventTime && !s_bEvent1206 ) // 이벤트 시간 - 이벤트 설정되어 있지 않으면, { g_dpCoreSrvr.SendEvent1206( s_bEvent1206 = TRUE ); } else if( !bEventTime && s_bEvent1206 ) // 이벤트 시간이 아닌데 이벤트 설정되어 있으면, { g_dpCoreSrvr.SendEvent1206( s_bEvent1206 = FALSE ); } } #endif // __EVENT1206 if( wTimerID == TIMER_ID_EVENT ) { BOOL f = FALSE; CTime tmCurr = CTime::GetCurrentTime(); BOOL bXmas; if( s_bTest ) { bXmas = tmCurr < CTime( 2005, 12, 26, 10, 0, 0 ); } else { bXmas = ( tmCurr >= CTime( 2005, 12, 23, 0, 0, 0 ) && tmCurr < CTime( 2005, 12, 27, 9, 0, 0 ) ); } BOOL bNewYear; if( s_bTest ) { bNewYear = tmCurr < CTime( 2006, 1, 31, 10, 0, 0 ); } else { bNewYear = ( tmCurr >= CTime( 2006, 1, 26, 0, 0, 0 ) && tmCurr < CTime( 2006, 1, 31, 10, 0, 0 ) ); } BOOL bValentinesDay; if( s_bTest ) { bValentinesDay = tmCurr < CTime( 2006, 2, 15, 13, 0, 0 ); } else { bValentinesDay = ( tmCurr >= CTime( 2006, 2, 14, 0, 0, 0 ) && tmCurr < CTime( 2006, 2, 15, 13, 0, 0 ) ); } if( bXmas && !( s_dwEvent & EVE_FLAG1219 ) ) { s_dwEvent |= EVE_FLAG1219; f = TRUE; } else if( !bXmas && ( s_dwEvent & EVE_FLAG1219 ) ) { s_dwEvent &= ~EVE_FLAG1219; f = TRUE; } if( bNewYear && !( s_dwEvent & EVE_FLAG0127 ) ) { s_dwEvent |= EVE_FLAG0127; f = TRUE; } else if( !bNewYear && ( s_dwEvent & EVE_FLAG0127 ) ) { s_dwEvent &= ~EVE_FLAG0127; f = TRUE; } if( bValentinesDay && !( s_dwEvent & EVE_FLAG0214 ) ) { s_dwEvent |= EVE_FLAG0214; f = TRUE; } else if( !bValentinesDay && ( s_dwEvent & EVE_FLAG0214 ) ) { s_dwEvent &= ~EVE_FLAG0214; f = TRUE; } if( f ) { g_dpCoreSrvr.SendEvent( s_dwEvent ); } } }
void Alarm::CheckAndTrigger() { if (ValidFieldFlags == 0) return; BOOL Triggered = TRUE; CTime now = CTime::GetCurrentTime(); if ((ValidFieldFlags & VF_TIMEOFDAY) != 0) { if ((now.GetHour() != TimeOfDayHour) || (now.GetMinute() != TimeOfDayMinute)) { Triggered = FALSE; } } if ((ValidFieldFlags & VF_DAYOFWEEK) != 0) { if (now.GetDayOfWeek() != DayOfWeek) Triggered = FALSE; } if ((ValidFieldFlags & VF_DAYOFMONTH) != 0) { if (now.GetDay() != DayOfMonth) Triggered = FALSE; } if ((ValidFieldFlags & VF_MONTHOFYEAR) != 0) { if (now.GetMonth() != MonthOfYear) Triggered = FALSE; } if (Triggered) { CTimeSpan timeSinceLastTrigger = now - TimeLastTriggered; if ((ValidFieldFlags & VF_TIMEOFDAY) != 0) { if (timeSinceLastTrigger.GetTotalMinutes() < 2) Triggered = FALSE; } else if (((ValidFieldFlags & VF_DAYOFWEEK) != 0) || ((ValidFieldFlags & VF_DAYOFMONTH) != 0)) { if (timeSinceLastTrigger.GetTotalHours() < 26) Triggered = FALSE; } else { if (timeSinceLastTrigger.GetTotalHours() < (24*33)) Triggered = FALSE; } } if (Triggered) { TimeLastTriggered = now; TRACE1("TRIGGER: %s\n", TextMessage); DAlarmNotify& dlg = *new DAlarmNotify; dlg.TextMessage = TextMessage; dlg.Create(IDD_ALARMNOTIFY); dlg.ShowWindow(SW_SHOW); sndPlaySound(((CAlarmsDlg*)theApp.m_pMainWnd)->alarmsSoundFile,SND_ASYNC); } }
void CDBProcess::ReConnectODBC(CDatabase *m_db, const char *strdb, const char *strname, const char *strpwd) { char strlog[256]; memset( strlog, 0x00, 256); CTime t = CTime::GetCurrentTime(); sprintf_s(strlog, 256, "[%d-%d %d:%d] Trying to reconnect to ODBC...\r\n", t.GetMonth(), t.GetDay(), t.GetHour(), t.GetMinute()); LogFileWrite( strlog ); // DATABASE 연결... CString strConnect; strConnect.Format (_T("DSN=%s;UID=%s;PWD=%s"), strdb, strname, strpwd); int iCount = 0; do{ iCount++; if( iCount >= 4 ) break; m_db->SetLoginTimeout(10); try { m_db->OpenEx((LPCTSTR )strConnect, CDatabase::noOdbcDialog); } catch( CDBException* e ) { e->Delete(); } }while(!m_db->IsOpen()); }
void CUser::ZoneChange(int zone, float x, float z) { m_bZoneChangeFlag = TRUE; int send_index = 0, zoneindex = 0; char send_buff[128]; C3DMap* pMap = NULL; _ZONE_SERVERINFO *pInfo = NULL; if( g_serverdown_flag ) return; pMap = m_pMain->GetZoneByID(zone); if (!pMap) return; m_pMap = pMap; if( pMap->m_bType == 2 ) { // If Target zone is frontier zone. if( m_pUserData->m_bLevel < 20 && m_pMain->m_byBattleOpen != SNOW_BATTLE) return; } if( m_pMain->m_byBattleOpen == NATION_BATTLE ) { // Battle zone open if( m_pUserData->m_bZone == BATTLE_ZONE ) { if( pMap->m_bType == 1 && m_pUserData->m_bNation != zone ) { // ???? ?????? ???? ????.. if( m_pUserData->m_bNation == KARUS && !m_pMain->m_byElmoradOpenFlag ) { TRACE("#### ZoneChange Fail ,,, id=%s, nation=%d, flag=%d\n", m_pUserData->m_id, m_pUserData->m_bNation, m_pMain->m_byElmoradOpenFlag); return; } else if( m_pUserData->m_bNation == ELMORAD && !m_pMain->m_byKarusOpenFlag ) { TRACE("#### ZoneChange Fail ,,, id=%s, nation=%d, flag=%d\n", m_pUserData->m_id, m_pUserData->m_bNation, m_pMain->m_byKarusOpenFlag); return; } } } else if( pMap->m_bType == 1 && m_pUserData->m_bNation != zone ) { // ???? ?????? ???? ????.. return; } // else if( pMap->m_bType == 2 && zone == ZONE_FRONTIER ) { // You can't go to frontier zone when Battlezone is open. int temp_index = 0; char temp_buff[3]; SetByte( temp_buff, WIZ_WARP_LIST, temp_index ); SetByte( temp_buff, 2, temp_index ); SetByte( temp_buff,0, temp_index ); Send(temp_buff, temp_index); // return; } // } else if( m_pMain->m_byBattleOpen == SNOW_BATTLE ) { // Snow Battle zone open if( pMap->m_bType == 1 && m_pUserData->m_bNation != zone ) { // ???? ?????? ???? ????.. return; } else if( pMap->m_bType == 2 && (zone == ZONE_FRONTIER || zone == ZONE_BATTLE ) ) { // You can't go to frontier zone when Battlezone is open. return; } } else { // Battle zone close if( pMap->m_bType == 1 && m_pUserData->m_bNation != zone && (zone < 10 || zone > 20)) // ???? ?????? ???? ????.. return; } m_bWarp = 0x01; UserInOut( USER_OUT ); if( m_pUserData->m_bZone == ZONE_SNOW_BATTLE ) { //TRACE("ZoneChange - name=%s\n", m_pUserData->m_id); SetMaxHp( 1 ); } m_pUserData->m_bZone = zone; m_pUserData->m_curx = m_fWill_x = x; m_pUserData->m_curz = m_fWill_z = z; if( m_pUserData->m_bZone == ZONE_SNOW_BATTLE ) { //TRACE("ZoneChange - name=%s\n", m_pUserData->m_id); SetMaxHp(); } PartyRemove(m_Sid); // ??????? Z?????? ó?? //TRACE("ZoneChange ,,, id=%s, nation=%d, zone=%d, x=%.2f, z=%.2f\n", m_pUserData->m_id, m_pUserData->m_bNation, zone, x, z); if( m_pMain->m_nServerNo != pMap->m_nServerNo ) { pInfo = m_pMain->m_ServerArray.GetData( pMap->m_nServerNo ); if( !pInfo ) return; UserDataSaveToAgent(); CTime t = CTime::GetCurrentTime(); m_pMain->WriteLog("[ZoneChange : %d-%d-%d] - sid=%d, acname=%s, name=%s, zone=%d, x=%d, z=%d \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), m_Sid, m_strAccountID, m_pUserData->m_id, zone, (int)x, (int)z); m_pUserData->m_bLogout = 2; // server change flag SendServerChange(pInfo->strServerIP, 2); return; } m_pUserData->m_sBind = -1; // Bind Point Clear... m_RegionX = (int)(m_pUserData->m_curx / VIEW_DISTANCE); m_RegionZ = (int)(m_pUserData->m_curz / VIEW_DISTANCE); SetByte( send_buff, WIZ_ZONE_CHANGE, send_index ); SetByte( send_buff, m_pUserData->m_bZone, send_index ); SetShort( send_buff, (WORD)m_pUserData->m_curx*10, send_index ); SetShort( send_buff, (WORD)m_pUserData->m_curz*10, send_index ); SetShort( send_buff, (short)m_pUserData->m_cury*10, send_index ); SetByte( send_buff, m_pMain->m_byOldVictory, send_index ); Send( send_buff, send_index ); if (!m_bZoneChangeSameZone) { m_sWhoKilledMe = -1; m_iLostExp = 0; m_bRegeneType = 0; m_fLastRegeneTime = 0.0f; m_pUserData->m_sBind = -1; InitType3(); InitType4(); } if (m_bZoneChangeSameZone) { m_bZoneChangeSameZone = FALSE; } send_index = 0; SetByte( send_buff, AG_ZONE_CHANGE, send_index ); SetShort( send_buff, m_Sid, send_index ); SetByte( send_buff, getZoneID(), send_index ); m_pMain->Send_AIServer(send_buff, send_index); m_bZoneChangeFlag = FALSE; }
int CScheduler::Check(bool forcecheck){ if (!thePrefs.IsSchedulerEnabled() || theApp.scheduler->GetCount()==0 || !theApp.emuledlg->IsRunning()) return -1; Schedule_Struct* schedule; struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); if (!forcecheck && tNow.GetMinute()==m_iLastCheckedMinute) return -1; m_iLastCheckedMinute=tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); for (uint8 si=0;si<theApp.scheduler->GetCount();si++) { schedule=theApp.scheduler->GetSchedule(si); if (schedule->actions[0]==0 || !schedule->enabled) continue; // check day of week if (schedule->day!=DAY_DAYLY) { int dow=tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO : if (dow!=2) continue; break; case DAY_DI : if (dow!=3) continue; break; case DAY_MI : if (dow!=4) continue; break; case DAY_DO : if (dow!=5) continue; break; case DAY_FR : if (dow!=6) continue; break; case DAY_SA : if (dow!=7) continue; break; case DAY_SO : if (dow!=1) continue; break; case DAY_MO_FR : if (dow==7 || dow==1 ) continue; break; case DAY_MO_SA : if (dow==1) continue; break; case DAY_SA_SO : if (dow>=2 && dow<=6) continue; } } //check time UINT h1,h2,m1,m2; CTime t1=CTime(schedule->time); CTime t2=CTime(schedule->time2); h1=t1.GetHour(); h2=t2.GetHour(); m1=t1.GetMinute(); m2=t2.GetMinute(); int it1,it2, itn; it1=h1*60 + m1; it2=h2*60 + m2; // ==> handling of one-time-events [Mighty Knife] - Stulle // if start-time=end-time, this is an event that should // occur once in that minute. In that case we add 1 to it2 to make sure // it happens (because of the timespan-comparison below, which happens // once per minute, too...) if (it2==it1) it2++; // <== handling of one-time-events [Mighty Knife] - Stulle itn=tNow.GetHour()*60 + tNow.GetMinute(); if (it1<=it2) { // normal timespan if ( !(itn>=it1 && itn<it2) ) continue; } else { // reversed timespan (23:30 to 5:10) now 10 if ( !(itn>=it1 || itn<it2)) continue; } // ok, lets do the actions of this schedule ActivateSchedule(si,schedule->time2==0); } return -1; }
void CAISocket::CloseProcess() { CString logstr; CTime time = CTime::GetCurrentTime(); logstr.Format("*** CloseProcess - socketID=%d... *** %d-%d-%d, %d:%d]\r\n", m_Sid, time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute() ); LogFileWrite( logstr ); Initialize(); CIOCPSocket2::CloseProcess(); }
/* Generates the piece hashes and the info hash for the torrent */ bool TorrentCreator::MakeTorrent(BTInput *pTorrent) { // IF no torrent info exists, return if( pTorrent == NULL ) return false; // Set the local to the torrent info m_pIPData = pTorrent; // Clear any piece hashes that we have if( !m_vPieceHashes.empty() ) { for( int i = 0; i < (int)m_vPieceHashes.size(); i++ ) delete m_vPieceHashes[i]; m_vPieceHashes.clear(); } // Seek the decoy file to the beginning m_decoyDataFile.SeekToBegin(); // Make a new data buffer for the data of a single chunk of the "file data" UCHAR *pDataBuf = new UCHAR[ m_pIPData->GetPieceLength() ]; // The datafiles are already sorted in the ascending order in which they must appear in the torrent file vector<DataFile *> vDatafiles = m_pIPData->GetDataFilesVector(); // Calculate the total data size of the torrent by adding the size of each file in the torrent unsigned int nTotalDataSize = 0; for( vector<DataFile *>::iterator v_iter = vDatafiles.begin(); v_iter != vDatafiles.end(); v_iter++ ) { nTotalDataSize += (*v_iter)->GetFileLength(); } m_pIPData->SetTotalSize( nTotalDataSize ); // Create variables for navigating the decoy data file UINT nDecoyFileSize = (UINT)m_decoyDataFile.GetLength(); UINT nDecoyFileOffset = 0; UINT nDataRead = 0; UINT nPieceSize = m_pIPData->GetPieceLength(); // While there is still more data to process while( nTotalDataSize > 0 ) { // if( nTotalDataSize >= nPieceSize ) { nDataRead = GetDecoyData(nDecoyFileSize, nPieceSize, nDecoyFileOffset, pDataBuf); } else { nDataRead = GetDecoyData(nDecoyFileSize, nTotalDataSize, nDecoyFileOffset, pDataBuf); } nTotalDataSize -= nDataRead; SHA1 sha1; sha1.Update(pDataBuf, nDataRead); sha1.Final(); UCHAR *pSHA1Hash = new UCHAR[ 20 ]; sha1.GetHash( pSHA1Hash ); m_vPieceHashes.push_back( pSHA1Hash ); } WriteTorrentInfoFile(vDatafiles); ComputeInfohash(); delete pDataBuf; // Set the creation time time_t utc_time; time(&utc_time); //unsigned int cur_time = (unsigned int)utc_time; CTime now = CTime(utc_time); char time[15]; sprintf(time, "%04u%02u%02u%02u%02u%02u", now.GetYear(), now.GetMonth(), now.GetDay(), now.GetHour(), now.GetMinute(), now.GetSecond()); m_pIPData->SetCreationTime(utc_time); return true; }
// 날짜 포맷으로 부터 날짜 문자열 획득 CString CAguraDateBox::GetDate(CTime &time, CString &sDateFormat) { int nStart=0, nFind=0; CString sDate(_T("")), sTemp(_T("")); // Year(yyyy) nFind = sDateFormat.Find(_T("yyyy"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%04d"), time.GetYear()); sDate += sTemp; nStart = nFind + 4; } // Month(MM) nFind = sDateFormat.Find(_T("MM"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%02d"), time.GetMonth()); sDate += sTemp; nStart = nFind + 2; } // Day(dd) nFind = sDateFormat.Find(_T("dd"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%02d"), time.GetDay()); sDate += sTemp; nStart = nFind + 2; } // Hour(HH) nFind = sDateFormat.Find(_T("HH"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%02d"), time.GetHour()); sDate += sTemp; nStart = nFind + 2; } // Minute(mm) nFind = sDateFormat.Find(_T("mm"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%02d"), time.GetMinute()); sDate += sTemp; nStart = nFind + 2; } // Seconds(ss) nFind = sDateFormat.Find(_T("ss"), nStart); if( nFind >= 0 ) { sDate += sDateFormat.Mid(nStart, nFind-nStart); sTemp.Format(_T("%02d"), time.GetSecond()); sDate += sTemp; nStart = nFind + 2; } sDate += sDateFormat.Mid(nStart); sDate.Remove(_T('\'')); return sDate; }
void CAISocket::RecvNpcInfo(Packet & pkt) { std::string strName; uint8 Mode, byDirection; uint16 sNid; pkt.SByte(); pkt >> Mode >> sNid; CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sNid); if (pNpc == NULL) return; pkt >> pNpc->m_sSid >> pNpc->m_sPid >> pNpc->m_sSize >> pNpc->m_iWeapon_1 >> pNpc->m_iWeapon_2 >> pNpc->m_bZoneID >> strName >> pNpc->m_byGroup >> pNpc->m_byLevel >> pNpc->m_fCurX >> pNpc->m_fCurZ >> pNpc->m_fCurY >> byDirection >> pNpc->m_NpcState >> pNpc->m_tNpcType >> pNpc->m_iSellingGroup >> pNpc->m_iMaxHP >> pNpc->m_iHP >> pNpc->m_byGateOpen >> pNpc->m_sTotalHitrate >> pNpc->m_sTotalEvasionrate >> pNpc->m_sTotalAc >> pNpc->m_byObjectType; if (strName.empty() || strName.length() > MAX_NPC_SIZE) { delete pNpc; return; } pNpc->m_byDirection = byDirection; strcpy(pNpc->m_strName, strName.c_str()); // Bug? Test? // pNpc->m_NpcState = NPC_DEAD; if (pNpc->m_NpcState == NPC_LIVE) { char strLog[256]; CTime t = CTime::GetCurrentTime(); sprintf_s(strLog, sizeof(strLog), "## time(%d:%d-%d) npc regen check(%d) : nid=%d, name=%s, x=%d, z=%d, rx=%d, rz=%d ## \r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), pNpc->m_NpcState, pNpc->GetID(), pNpc->m_strName, (int)pNpc->m_fCurX, (int)pNpc->m_fCurZ, pNpc->GetRegionX(), pNpc->GetRegionZ()); EnterCriticalSection( &g_LogFile_critical ); g_pMain->m_RegionLogFile.Write( strLog, strlen(strLog) ); LeaveCriticalSection( &g_LogFile_critical ); TRACE(strLog); // to-do: replace with g_pMain->WriteRegionLog(...); } if (pNpc->GetMap() == NULL) return; pNpc->InsertRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ()); pNpc->SetRegion(pNpc->GetNewRegionX(), pNpc->GetNewRegionZ()); if (pNpc->m_byObjectType == SPECIAL_OBJECT) { _OBJECT_EVENT *pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid ); if (pEvent != NULL) pEvent->byLife = 1; } if (Mode == 0) { TRACE("RecvNpcInfo - dead monster nid=%d, name=%s\n", pNpc->GetID(), pNpc->m_strName); return; } pNpc->SendInOut(INOUT_IN, pNpc->GetX(), pNpc->GetZ(), pNpc->GetY()); }
void CGameSocket::CloseProcess() { CString logstr; CTime time = CTime::GetCurrentTime(); logstr.Format("*** CloseProcess - socketID=%d ... sSid = %d *** %d-%d-%d, %d:%d]\r\n", m_Sid, m_sSocketID, time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute() ); LogFileWrite( logstr ); TRACE("*** CloseProcess - socketID=%d ... sSid = %d *** \n", m_Sid, m_sSocketID); m_pMain->DeleteAllUserList(m_sSocketID); Initialize(); CIOCPSocket2::CloseProcess(); }
void CAISocket::OnDisconnect() { CTime time = CTime::GetCurrentTime(); TRACE("*** CloseProcess - socketID=%d... *** %d-%d-%d, %d:%d]\r\n", GetSocketID(), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute() ); }
char* CHSDownloadData::MakeReqPacket( CodeInfo* pCode, short nPeriod , long &lReqLen) { if ( pCode == NULL || IsBadReadPtr(pCode,1)) return NULL; BOOL bChangeRange = FALSE; BOOL bDownLoaded = FALSE; CString str; str.Format("%d-%s",pCode->m_cCodeType,pCode->GetCode()); /* TaskItem* m_pTaskItem = NULL;*/ if( m_pTaskItem && !IsBadReadPtr(m_pTaskItem,1) && m_pTaskItem->m_TaskName.Compare(str) ) { m_pTaskItem->SetDayTaskFinished(); m_pTaskItem->SetMinute1TaskFinished(); m_pTaskItem->SetMinute5TaskFinished(); return NULL; } m_DownLoadCount = 0; int nAfterBegin = 1300,nAfterEnd = 1500; short nGZIndex = MakeGZIndex(pCode->m_cCodeType); short nQihuo = MakeMarket(pCode->m_cCodeType); if (nQihuo == FUTURES_MARKET) { if (nGZIndex) { nAfterEnd = 1515; } else { nAfterBegin = 1330; } } //取本地缓存中已有的数据 GetLocalData(pCode,nPeriod,m_pTaskItem); CArray<DateRange,DateRange> ayDate; CTime t1 = GetNowTime(nPeriod); CTimeSpan tSpan = GetTimeStep(nPeriod); unsigned long nLimitTime = GetLimitDate(pCode,nPeriod,m_nLimitedDay);//修正2012时间问题 unsigned long nEarliestTime = GetIntTimeFromTime(t1,nPeriod);//修正2012时间问题 unsigned long nTodayTime = nEarliestTime;//修正2012时间问题 long lCurDate = 10; CTime tmNow = CTime::GetCurrentTime(); lCurDate = tmNow.GetYear() * 10000 + tmNow.GetMonth() * 100 + tmNow.GetDay(); bDownLoaded = IsDownLoaded(lCurDate,pCode,nPeriod); try { BOOL bExistLastData = FALSE; BOOL bFirstDayRange = TRUE; CString strCode = pCode->GetCode(); StockDay* pStockDay = (StockDay*)m_pTaskItem->m_localData; for(int i = m_pTaskItem->m_localDataCount - 1; i >= 0; i--) { if (bDownLoaded) { break; } if(pStockDay[i].m_lDate <= 0) continue; if(pStockDay[i].m_lDate < nEarliestTime) nEarliestTime = pStockDay[i].m_lDate; if (pStockDay[i].m_lDate == 20000000) //修正错误的日期时间 { pStockDay[i].m_lDate = 19991231; } ///////////////若本地一存在的数据日期在限制时间内 则挑过数据的缺失检查///////////////////////////// if (i == m_pTaskItem->m_localDataCount - 1) { CTime tmNow = t1; CTime tmLastData = GetTimeFromIntTime(pStockDay[i].m_lDate,nPeriod); int nNowYear = tmNow.GetYear(); int nNowMonth = tmNow.GetMonth(); int nNowDay = tmNow.GetDay(); if ( nNowYear == tmLastData.GetYear() && nNowMonth == tmLastData.GetMonth() && tmLastData.GetDay() == nNowDay) { CTime tmlimit = GetTimeFromIntTime(nLimitTime,nPeriod); CTime tmFirstDate = GetTimeFromIntTime(pStockDay[0].m_lDate,nPeriod); if (m_nLimitedDay == 0) { if ( PERIOD_TYPE_DAY != nPeriod) { int nMaxDays = 0; if (nGZIndex) nMaxDays = 36 - 1; //36 = (10000/240 * 240)/270 else nMaxDays = 41 - 1; //41= 10000/240 long lLastDate = tmLastData.GetYear() * 10000 + tmLastData.GetMonth() * 100 + tmLastData.GetDay(); if (lLastDate != lCurDate) { nMaxDays --; } CTimeSpan tmSpan(1,0,0,0); int nCount = 0; while(nCount < nMaxDays) { tmLastData -= tmSpan; if (tmLastData.GetDayOfWeek() != 1&& tmLastData.GetDayOfWeek() != 7) { nCount ++; } } } if (PERIOD_TYPE_DAY == nPeriod) { if (tmFirstDate.GetYear() <= tmlimit.GetYear() && tmFirstDate.GetMonth() <= tmlimit.GetMonth() && tmFirstDate.GetDay() <= tmlimit.GetDay()) { bExistLastData = TRUE; } } else if (tmFirstDate.GetYear() <= tmLastData.GetYear() && tmFirstDate.GetMonth() <= tmLastData.GetMonth() && tmFirstDate.GetDay() <= tmLastData.GetDay()) { bExistLastData = TRUE; } } else { if (tmFirstDate.GetYear() <= tmlimit.GetYear() && tmFirstDate.GetMonth() <= tmlimit.GetMonth() && tmFirstDate.GetDay() <= tmlimit.GetDay()) { bExistLastData = TRUE; } } if (bExistLastData) { break; } } } ////////////////////////////////////////////////////////////////////////// int nCount = 0; long lEndDate = 0; long lBeginDate = 0; CTime t2 = GetTimeFromIntTime(pStockDay[i].m_lDate,nPeriod); CTime t = t2; if (i != m_pTaskItem->m_localDataCount - 1) { t = t + tSpan; } while(t < t1) { if(t.GetDayOfWeek() != 1 && t.GetDayOfWeek() != 7 && t < t1) //1 = Sunday, 2 = Monday, ..., 7 = Saturday { if(lBeginDate == 0) lBeginDate = GetIntTimeFromTime(t,nPeriod); if (!bFirstDayRange) { lEndDate = GetIntTimeFromTime(t1 - tSpan,nPeriod); } else { while(t1.GetDayOfWeek()==1 || t1.GetDayOfWeek() == 7) { CTimeSpan OneDay(1,0,0,0); t1 -= OneDay; } lEndDate = GetIntTimeFromTime(t1,nPeriod); } nCount ++; break; } t = t + tSpan; }; t1 = t2; bFirstDayRange = FALSE; if(nCount > 0 && lBeginDate >= nLimitTime ) { if( lEndDate < nLimitTime) lEndDate = nLimitTime; CTime tmBegin = GetTimeFromIntTime(lBeginDate,nPeriod); CTime tmEnd = GetTimeFromIntTime(lEndDate,nPeriod); if (tmBegin.GetYear() == tmEnd.GetYear() && tmBegin.GetMonth() == tmEnd.GetMonth() && tmBegin.GetDay() == tmEnd.GetDay()) { if (tmBegin.GetHour()*100 + tmBegin.GetMinute() > 1130 && tmEnd.GetHour()*100 + tmEnd.GetMinute() < nAfterBegin) { continue; } } if (lBeginDate > lEndDate) { continue ; } DateRange dr; dr.m_nBeginDate = lBeginDate; dr.m_nEndDate = lEndDate; ayDate.Add(dr); } if (nCount == 0 && pStockDay[i].m_lDate <= nLimitTime) { break; } } //下载分钟线数据时按9840的倍数根往前下载,若没有最近41天的数据,则下载最近82天数据,依次类推,最多倒退41*18天 int nLimitedDays = 0,nPermitCount = 9840; if (ayDate.GetCount() < 1) { if(nEarliestTime > nLimitTime && !bExistLastData) //加入最后一段时间 { DateRange dr; dr.m_nBeginDate = nLimitTime; dr.m_nEndDate = nEarliestTime; ayDate.Add(dr); } } else { int nMaxDays = 0; DateRange LastDateRage = ayDate.GetAt(ayDate.GetUpperBound()); long nPreDate = GetPreDataDate(pCode,LastDateRage.m_nBeginDate,nPeriod); if (nGZIndex) nMaxDays = 36 - 1; //36 = (10000/240 * 240)/270 else nMaxDays = 41 - 1; //41= 10000/240 long nEarlyLimitedDate = nLimitTime; if (PERIOD_TYPE_DAY != nPeriod) { nEarlyLimitedDate = GetPreDate(pStockDay[m_pTaskItem->m_localDataCount -1].m_lDate,nMaxDays,nPeriod); long nCheckDataCount = GetDayDataCount(pCode,nEarlyLimitedDate,nTodayTime,nPeriod); if (nCheckDataCount > nPermitCount) { int nSurplusCount = nCheckDataCount - nPermitCount; nEarlyLimitedDate = GetChangedBeginDate(pCode,nEarlyLimitedDate,nSurplusCount,nPeriod); } } if (nPreDate >= nEarlyLimitedDate) { DateRange dr; dr.m_nBeginDate = nEarlyLimitedDate > nLimitTime ? nEarlyLimitedDate : nLimitTime; dr.m_nEndDate = nPreDate; ayDate.Add(dr); } } CArray<DateRange,DateRange> ayDateChange; int nDateCount = ayDate.GetCount(); nPermitCount = nPermitCount*(m_nReloadDegree + 1); for (int i = nDateCount - 1; i>= 0; i--) { DateRange dateRange = ayDate.GetAt(i); long nRangeCount = GetDayDataCount(pCode,dateRange.m_nBeginDate,dateRange.m_nEndDate,nPeriod); nLimitedDays += nRangeCount; if (nLimitedDays < nPermitCount) { ayDateChange.Add(dateRange); } else { int nSpillCount = nLimitedDays - nPermitCount; dateRange.m_nBeginDate = GetChangedBeginDate(pCode,dateRange.m_nBeginDate,nSpillCount,nPeriod); ayDateChange.Add(dateRange); bChangeRange = TRUE; break; } } if (bChangeRange) { nDateCount = ayDateChange.GetCount(); } if (bDownLoaded) { bChangeRange = TRUE; ayDateChange.RemoveAll(); long nOutRangeDateB = 20101001; //国庆放假无交易行情 long nOutRangeDateE = 20101001; if (PERIOD_TYPE_DAY != nPeriod) { nOutRangeDateB = 2010010930; nOutRangeDateE = 2010010930; } DateRange dr; dr.m_nBeginDate = nOutRangeDateB; dr.m_nEndDate = nOutRangeDateE; nDateCount = ayDateChange.GetCount(); } short nCount = sizeof(ReqDayData) / sizeof(CodeInfo); if( sizeof(ReqDayData) % sizeof(CodeInfo) ) nCount++; int lLen = sizeof(AskData) + sizeof(CodeInfo) * (nCount - 1) + nDateCount * sizeof(DateRange); lReqLen = lLen; AskData* ask = (AskData*)(new char[lLen]); memset(ask,0,lLen); ask->m_nType = RT_TECHDATA_RANGE; ask->m_nSize = nCount; ask->m_lKey = nPeriod; memcpy(&ask->m_nPrivateKey, pCode, sizeof(CodeInfo)); ReqRangeDayData* pRequest = (ReqRangeDayData*)ask->m_pCode; pRequest->m_lBeginPosition = 0; pRequest->m_nDay = 0; pRequest->m_cPeriod = nPeriod; memcpy(&pRequest->m_ciCode, pCode, sizeof(CodeInfo)); pRequest->m_nDataRangCount = nDateCount; DateRange *pRane = pRequest->m_dataRange; CString strRequest,strRang; for(int nIndex = 0; nIndex < nDateCount; nIndex++) { if (bChangeRange) pRane[nIndex] = ayDateChange.GetAt(nIndex); else pRane[nIndex] = ayDate.GetAt(nIndex); m_DownLoadCount += GetDayDataCount(pCode,pRane[nIndex].m_nBeginDate,pRane[nIndex].m_nEndDate,nPeriod); strRang.Format("%d-%d;",pRane[nIndex].m_nBeginDate,pRane[nIndex].m_nEndDate); strRequest += strRang; } return (char*)ask; } catch (...) { } return NULL; }
void cHappyHour::Load() { HappyHourEnabled = Configs.GetInt(0,1,1,"HappyHour","EnableHappyHour",IAJuliaHappyHour); if (HappyHourEnabled == 0) return; char Buff[256]; int Flag = 0; HappyHoursNumber = 0; MessageTimeBeforeCount = 0; MessageTimeAfterCount = 0; CTime t = CTime::GetCurrentTime(); int Hour = t.GetHour(); int Min = t.GetMinute(); int WeekDay = t.GetDayOfWeek(); FILE *conf = fopen(IAJuliaHappyHour,"r"); if ( conf != NULL) { while ( !feof(conf)) { fgets(Buff,256,conf); if(Utilits.IsBadFileLine(Buff, &Flag)) continue; if (Flag == 1) { int n[7]; sscanf(Buff, "%d %d %d %d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4], &n[5], &n[6], &n[7]); HappyStruct[HappyHoursNumber].MapNum = n[0]; HappyStruct[HappyHoursNumber].P_Zen = n[1]; HappyStruct[HappyHoursNumber].P_Drop = n[2]; HappyStruct[HappyHoursNumber].P_Exp = n[3]; HappyStruct[HappyHoursNumber].S_WeekDay = n[4]; HappyStruct[HappyHoursNumber].S_Hour = n[5]; HappyStruct[HappyHoursNumber].S_Min = n[6]; HappyStruct[HappyHoursNumber].T_Delay = n[7]; HappyStruct[HappyHoursNumber].Started = false; HappyStruct[HappyHoursNumber].C_Min = HappyStruct[HappyHoursNumber].S_Min + HappyStruct[HappyHoursNumber].T_Delay; HappyStruct[HappyHoursNumber].C_Hour = HappyStruct[HappyHoursNumber].S_Hour; if(HappyStruct[HappyHoursNumber].S_WeekDay == -1) HappyStruct[HappyHoursNumber].C_WeekDay = WeekDay; else HappyStruct[HappyHoursNumber].C_WeekDay = HappyStruct[HappyHoursNumber].S_WeekDay; while (HappyStruct[HappyHoursNumber].C_Min >=60) { HappyStruct[HappyHoursNumber].C_Hour++; HappyStruct[HappyHoursNumber].C_Min -= 60; } while (HappyStruct[HappyHoursNumber].C_Hour >= 24) { HappyStruct[HappyHoursNumber].C_WeekDay = HappyStruct[HappyHoursNumber].C_WeekDay % 7 + 1; HappyStruct[HappyHoursNumber].C_Hour -= 24; } HappyHoursNumber++; } if (Flag == 2) { sscanf(Buff, "%d", &MessageTimeBefore[MessageTimeBeforeCount++]); } if (Flag == 3) { sscanf(Buff, "%d", &MessageTimeAfter[MessageTimeAfterCount++]); } } } fclose(conf); Log.ConsoleOutPut(1, c_Magenta, t_Default, "[Happy Hour] Loaded %d locations." ,HappyHoursNumber); }
void CStatusDlg::OnRun(CString strID) { CTime Time; Time = CTime::GetCurrentTime(); CString strTime; strTime.Format("%d년 %d월 %d일 - %d시 : %d분 : %d초", Time.GetYear(), Time.GetMonth(), Time.GetDay(), Time.GetHour(), Time.GetMinute(), Time.GetSecond()); m_editStatus.SetWindowTextA("Server is running..."); m_editLoginID.SetWindowTextA(strID); m_editLoginTime.SetWindowTextA(strTime); CString strLog; strLog.Format("%s is just loged in...", strID); g_sToolMgr.GetLog()->AddLog(LOG_TYPE_TOOLWORK, strLog); }
void COBDPNDDlgLog::fAddLog(CString strMsg,WORD wMsgType) { if (theMainDlg->m_pConfigReadWrite->fGetSaveErrLogStatus()) { CTime time = CTime::GetCurrentTime(); CString strTime; strTime.Format(_T("%02d:%02d:%02d "),time.GetHour(),time.GetMinute(),time.GetSecond()); if (m_bShowLog) { switch (wMsgType) { case LOG_TYPE_OBD_DATA: { if (m_chkSeriesData.GetCheck()) { if (m_listLog.GetCount() > MAX_LOG_SIZE) { m_listLog.DeleteString(MAX_LOG_SIZE); } m_listLog.InsertString(0,strTime+strMsg); } } break; case LOG_TYPE_GPS_DATA: { if (m_chkGpsData.GetCheck()) { if (m_listLog.GetCount() > MAX_LOG_SIZE) { m_listLog.DeleteString(MAX_LOG_SIZE); } m_listLog.InsertString(0,strTime+strMsg); } } break; default: { if (m_listLog.GetCount() > MAX_LOG_SIZE) { m_listLog.DeleteString(MAX_LOG_SIZE); } m_listLog.InsertString(0,strTime+strMsg); } break; } } //保存日志记录 TagLogInfo tagLogInfo; tagLogInfo.dwDateTime = GetTickCount(); tagLogInfo.strLogMsg = strTime+strMsg; tagLogInfo.wLogType = wMsgType; if (m_vecLogInfo.size() == MAX_LOG_SIZE) { for (UINT i=0;i<m_vecLogInfo.size()-1;i++) { m_vecLogInfo[i] = m_vecLogInfo[i+1]; } m_vecLogInfo[MAX_LOG_SIZE-1] = tagLogInfo; } else { m_vecLogInfo.push_back(tagLogInfo); } } }