BOOL CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { OPENFILENAME ofn; POINT pt; RECT rect; switch(uMsg){ case WM_INITDIALOG: InitCommonControls(); hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN)); SendMessage(hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon); CheckDlgButton(hDlg, IDC_BACKUP, BST_CHECKED); SendMessage(GetDlgItem(hDlg, IDC_FILE), EM_SETREADONLY, (WPARAM)TRUE, (LPARAM)0); hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_EXE)); SendMessage(GetDlgItem(hDlg, IDC_ICONIMG), STM_SETICON, (WPARAM)hIcon, (LPARAM)0); EnableWindow(GetDlgItem(hDlg, IDC_BUILD), FALSE); SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); break; case WM_CLOSE: EndDialog(hDlg, 0); break; case WM_PAINT: SendMessage(GetDlgItem(hDlg, IDC_ICONIMG), STM_SETICON, (WPARAM)hIcon, (LPARAM)0); break; case WM_DROPFILES: HDROP hDrop; hDrop = HDROP(wParam); DragQueryFile(hDrop, 0, szEFileName, sizeof(szEFileName)); DragFinish(hDrop); if(LoadPE(szEFileName) == FALSE) { MessageBox(hDlg, "Could not load file!", "Cryptic", MB_ICONERROR); return TRUE; } SetDlgItemText(hDlg, IDC_FILE, szEFileName); EnableWindow(GetDlgItem(hDlg, IDC_BUILD), TRUE); break; case WM_MOUSEMOVE: GetCursorPos(&pt); GetWindowRect(GetDlgItem(hDlg, IDC_ICONIMG), &rect); if(PtInRect(&rect, pt)) { SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); } else { SetCursor(LoadCursor(NULL, IDC_ARROW)); } break; case WM_LBUTTONDOWN: GetCursorPos(&pt); GetWindowRect(GetDlgItem(hDlg, IDC_ICONIMG), &rect); if(PtInRect(&rect, pt)) { SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); memset(&ofn, 0, sizeof(ofn)); szIFileName[0] = '\0'; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = "Icon Files (*.ico)\0*.ico\0\0"; ofn.lpstrFile = szIFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_PATHMUSTEXIST; if(GetOpenFileName(&ofn)) { hIcon = ExtractIcon(hInst, szIFileName, 0); SendMessage(GetDlgItem(hDlg, IDC_ICONIMG), STM_SETICON, (WPARAM)hIcon, (LPARAM)0); } } break; case WM_RBUTTONDOWN: GetCursorPos(&pt); GetWindowRect(GetDlgItem(hDlg, IDC_ICONIMG), &rect); if(PtInRect(&rect, pt)) { SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(32649))); } break; case WM_COMMAND: switch LOWORD(wParam){ case IDC_BROWSE: memset(&ofn, 0, sizeof(ofn)); szEFileName[0] = '\0'; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = "Executable Files (*.exe)\0*.exe\0\0"; ofn.lpstrFile = szEFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_PATHMUSTEXIST; if(GetOpenFileName(&ofn)) { if(LoadPE(szEFileName) == FALSE) { MessageBox(hDlg, "Could not load file!", "Cryptic", MB_ICONERROR); return TRUE; } SetDlgItemText(hDlg, IDC_FILE, szEFileName); EnableWindow(GetDlgItem(hDlg, IDC_BUILD), TRUE); } break; case IDC_BUILD: EnableControls(hDlg, FALSE); HRSRC hRsrc; hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_STUB), "STUB"); if(hRsrc == NULL) { MessageBox(hDlg, "Could not find resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } DWORD dwRsrcSize; dwRsrcSize = SizeofResource(NULL, hRsrc); HGLOBAL hGlob; hGlob = LoadResource(NULL, hRsrc); if(hGlob == NULL) { MessageBox(hDlg, "Could not load resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } LPBYTE lpBuffer; lpBuffer = (LPBYTE)LockResource(hGlob); if(lpBuffer == NULL) { MessageBox(hDlg, "Could not lock resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } GetDlgItemText(hDlg, IDC_FILE, szEFileName, MAX_PATH); if(IsDlgButtonChecked(hDlg, IDC_BACKUP) == BST_CHECKED) { CHAR szBFileName[MAX_PATH]; GetDlgItemText(hDlg, IDC_FILE, szBFileName, MAX_PATH); strcat(szBFileName, ".bak"); if(CopyFile(szEFileName, szBFileName, FALSE) == 0) { free(lpBuffer); MessageBox(hDlg, "Could not copy file!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } } BYTE lpKey[14]; srand(time(NULL)); int i; for(i = 0; i < 15; i++) { lpKey[i] = BYTE(rand() % 255 + 1); } HANDLE hFile; hFile = CreateFile(szEFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) { free(lpBuffer); MessageBox(hDlg, "Could not create file!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } DWORD dwBytesWritten; if(WriteFile(hFile, lpBuffer, dwRsrcSize, &dwBytesWritten, NULL) == 0) { CloseHandle(hFile); free(lpBuffer); MessageBox(hDlg, "Could not write to file!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } CloseHandle(hFile); free(lpBuffer); if(IsDlgButtonChecked(hDlg, IDC_ADDICON) == BST_CHECKED) { if(AddIcon(szIFileName, szEFileName) == FALSE) { MessageBox(hDlg, "Could add icon!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } } HANDLE hUpdate; hUpdate = BeginUpdateResource(szEFileName, FALSE); if(hUpdate == NULL) { MessageBox(hDlg, "Could add resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } if(UpdateResource(hUpdate, RT_RCDATA, MAKEINTRESOURCE(150), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), RC4(lpFileBuffer, lpKey, dwFileSize, 15), dwFileSize) == FALSE) { MessageBox(hDlg, "Could add resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } if(UpdateResource(hUpdate, RT_RCDATA, MAKEINTRESOURCE(151), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), &lpKey[0], 15) == FALSE) { MessageBox(hDlg, "Could add resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } if(EndUpdateResource(hUpdate, FALSE) == FALSE) { MessageBox(hDlg, "Could add resource!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } RC4(lpFileBuffer, lpKey, dwFileSize, 15); pish = (PIMAGE_SECTION_HEADER)&lpFileBuffer[pidh->e_lfanew + sizeof(IMAGE_NT_HEADERS) + sizeof(IMAGE_SECTION_HEADER) * (pinh->FileHeader.NumberOfSections - 1)]; if(dwFileSize > (pish->PointerToRawData + pish->SizeOfRawData)) { MessageBox(hDlg, "EOF data found!", "Cryptic", MB_OK); hFile = CreateFile(szEFileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) { MessageBox(hDlg, "Could not open file!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } SetFilePointer(hFile, 0, NULL, FILE_END); if(WriteFile(hFile, &lpFileBuffer[pish->PointerToRawData + pish->SizeOfRawData + 1], dwFileSize - (pish->PointerToRawData + pish->SizeOfRawData), &dwBytesWritten, NULL) == 0) { CloseHandle(hFile); MessageBox(hDlg, "Could not write to file!", "Cryptic", MB_ICONERROR); EnableControls(hDlg, TRUE); return TRUE; } CloseHandle(hFile); } MessageBox(hDlg, "File successfully crypted!", "Cryptic", MB_ICONINFORMATION); EnableControls(hDlg, TRUE); break; case IDC_ABOUT: MessageBox(hDlg, "Cryptic v3.0\nCoded by Tughack", "About", MB_ICONINFORMATION); break; case IDC_EXIT: EndDialog(hDlg, 0); break; } } return FALSE; }
bool FZipFile::Open(bool quiet) { DWORD centraldir = Zip_FindCentralDir(Reader); FZipEndOfCentralDirectory info; int skipped = 0; Lumps = NULL; if (centraldir == 0) { if (!quiet) Printf(TEXTCOLOR_RED "\n%s: ZIP file corrupt!\n", Filename); return false; } // Read the central directory info. Reader->Seek(centraldir, SEEK_SET); Reader->Read(&info, sizeof(FZipEndOfCentralDirectory)); // No multi-disk zips! if (info.NumEntries != info.NumEntriesOnAllDisks || info.FirstDisk != 0 || info.DiskNumber != 0) { if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Multipart Zip files are not supported.\n", Filename); return false; } NumLumps = LittleShort(info.NumEntries); Lumps = new FZipLump[NumLumps]; // Load the entire central directory. Too bad that this contains variable length entries... int dirsize = LittleLong(info.DirectorySize); void *directory = malloc(dirsize); Reader->Seek(LittleLong(info.DirectoryOffset), SEEK_SET); Reader->Read(directory, dirsize); char *dirptr = (char*)directory; FZipLump *lump_p = Lumps; for (DWORD i = 0; i < NumLumps; i++) { FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr; int len = LittleShort(zip_fh->NameLength); FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len); dirptr += sizeof(FZipCentralDirectoryInfo) + LittleShort(zip_fh->NameLength) + LittleShort(zip_fh->ExtraLength) + LittleShort(zip_fh->CommentLength); if (dirptr > ((char*)directory) + dirsize) // This directory entry goes beyond the end of the file. { free(directory); if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Central directory corrupted.", Filename); return false; } // skip Directories if (name[len - 1] == '/' && LittleLong(zip_fh->UncompressedSize) == 0) { skipped++; continue; } // Ignore unknown compression formats zip_fh->Method = LittleShort(zip_fh->Method); if (zip_fh->Method != METHOD_STORED && zip_fh->Method != METHOD_DEFLATE && zip_fh->Method != METHOD_LZMA && zip_fh->Method != METHOD_BZIP2 && zip_fh->Method != METHOD_IMPLODE && zip_fh->Method != METHOD_SHRINK) { if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name.GetChars(), zip_fh->Method); skipped++; continue; } // Also ignore encrypted entries zip_fh->Flags = LittleShort(zip_fh->Flags); if (zip_fh->Flags & ZF_ENCRYPTED) { if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name.GetChars()); skipped++; continue; } FixPathSeperator(name); name.ToLower(); lump_p->LumpNameSetup(name); lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize); lump_p->Owner = this; // The start of the Reader will be determined the first time it is accessed. lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART; lump_p->Method = BYTE(zip_fh->Method); lump_p->GPFlags = zip_fh->Flags; lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize); lump_p->Position = LittleLong(zip_fh->LocalHeaderOffset); lump_p->CheckEmbedded(); // Ignore some very specific names if (0 == stricmp("dehacked.exe", name)) { memset(lump_p->Name, 0, sizeof(lump_p->Name)); } lump_p++; } // Resize the lump record array to its actual size NumLumps -= skipped; free(directory); if (!quiet) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps); PostProcessArchive(&Lumps[0], sizeof(FZipLump)); return true; }
void Protocol::DataRecv(DWORD Case, LPBYTE Data, int Len, int aIndex) { BYTE ProtocolType = Data[0]; // ---- if( ProtocolType == 0xC1 ) { switch(BYTE(Case)) { case 0x11: { gVisualFix.RecvDamage((PMSG_ATTACKRESULT*) Data); } break; case 0x17: { gVisualFix.RecvKilledObject((PMSG_DIEPLAYER*)Data); } break; case 0x26: { gVisualFix.RecvHPSD((PMSG_REFILL*)Data); } break; case 0x27: { gVisualFix.RecvMPAG((PMSG_MANASEND*)Data); } break; case 0x76: { gCheatGuard.Check((CHEATGUARD_REQ_CHECK*)Data); } break; // -- case 0xF1: { PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2*)Data; switch(lpDef->subcode) { case 0x00: { gVisualFix.RecvIndex((PMSG_JOINRESULT*)Data); } break; } } break; case 0xF3: { PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2*)Data; // ---- switch(lpDef->subcode) { case 3: { gConnectEx.RestoreGame(); gVisualFix.RecvUpPoint((PMSG_CHARMAPJOINRESULT*)Data); } break; case 0x04: { gVisualFix.RecvRespawn(); } break; case 0x05: { gVisualFix.RecvUpLevel((PMSG_LEVELUP*)Data); } break; case 0x06: { gVisualFix.RecvDownPoint((PMSG_LVPOINTADDRESULT*)Data); } break; } } break; // -- case 0xFB: { PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2*)Data; // ---- switch(lpDef->subcode) { #ifdef __NOVUS__ case 0: { gCraftSystem.SetData((CRAFT_ANS_USERDATA*)Data); } break; // -- case 1: { gCraftSystem.GetQuestResult((CRAFT_ANS_QUESTFINISH*)Data); } break; // -- #endif case 5: { gResetSystem.SetData((RESET_ANS_USERDATA*)Data); } break; // -- case 6: { gResetSystem.GetResetResult(); } break; // -- case 7: { gObjUser.SetTargetData((PMSG_TARGETDATA_ANS*)Data); } break; // -- case 8: { gObjUser.UpdateCharInfo((CHAR_UPDATEINFO*)Data); } break; // -- case 0xC: { gConnectEx.m_ConnectState = ConnectExType::OnForceDisconnect; } break; } } break; // -- case 0xFC: { gObjUser.SetBattleMapData((PMSG_BATTLE_LIST*)Data); } break; } } else if( ProtocolType == 0xC2 ) { switch(BYTE(Case)) { case 0xFD: { gNewsBoard.OpenMain((NEWS_ANS_TITLES*)Data); } break; // -- case 0xFE: { gNewsBoard.OpenItem((NEWS_ANS_NEWS*)Data); } break; } } // ---- pDataRecv(Case, Data, Len, aIndex); }
BOOL CDatagrams::OnReceiveSGP(const SOCKADDR_IN* pHost, const SGP_HEADER* pHeader, DWORD nLength) { #ifdef DEBUG_UDP theApp.Message( MSG_DEBUG, _T("UDP: Received SGP (#%i) %i of %i from %s"), pHeader->nSequence, pHeader->nPart, pHeader->nCount, (LPCTSTR)CString( inet_ntoa( pHost->sin_addr ) ) ); #endif m_nInFrags++; if ( pHeader->nFlags & SGP_ACKNOWLEDGE ) { SGP_HEADER pAck; memcpy( pAck.szTag, SGP_TAG_2, 3 ); pAck.nFlags = 0; pAck.nSequence = pHeader->nSequence; pAck.nPart = pHeader->nPart; pAck.nCount = 0; CNetwork::SendTo( m_hSocket, (LPCSTR)&pAck, sizeof( pAck ), pHost ); } BYTE nHash = BYTE( ( pHost->sin_addr.S_un.S_un_b.s_b1 + pHost->sin_addr.S_un.S_un_b.s_b2 + pHost->sin_addr.S_un.S_un_b.s_b3 + pHost->sin_addr.S_un.S_un_b.s_b4 + pHost->sin_port + pHeader->nSequence ) & 0xff ); CDatagramIn** pHash = m_pInputHash + ( nHash & HASH_MASK ); CDatagramIn* pDG = *pHash; for ( ; pDG ; pDG = pDG->m_pNextHash ) { if ( pDG->m_pHost.sin_addr.S_un.S_addr == pHost->sin_addr.S_un.S_addr && pDG->m_pHost.sin_port == pHost->sin_port && pDG->m_nSequence == pHeader->nSequence && pDG->m_nCount == pHeader->nCount ) { if ( pDG->Add( pHeader->nPart, &pHeader[1], nLength ) ) { if ( CG2Packet* pPacket = pDG->ToG2Packet() ) { try { m_nInPackets++; pPacket->OnPacket( pHost ); } catch ( CException* pException ) { pException->Delete(); DEBUG_ONLY( pPacket->Debug( _T("Malformed packet.") ) ); } pPacket->Release(); } // Keep it to check sequence numbers // Remove( pDG ); } return TRUE; } } while ( m_pInputFree == NULL || m_nBufferFree < pHeader->nCount ) { if ( m_pInputLast == NULL ) return FALSE; Remove( m_pInputLast ); } if ( m_nBufferFree < pHeader->nCount ) return FALSE; pDG = m_pInputFree; pDG->Create( pHost, pHeader->nFlags, pHeader->nSequence, pHeader->nCount ); for ( WORD nPart = 0 ; nPart < pDG->m_nCount ; nPart++ ) { ASSERT( pDG->m_pBuffer[ nPart ] == NULL ); pDG->m_pBuffer[ nPart ] = m_pBufferFree; m_pBufferFree = m_pBufferFree->m_pNext; m_nBufferFree--; } if ( pDG->Add( pHeader->nPart, &pHeader[1], nLength ) ) { if ( CG2Packet* pPacket = pDG->ToG2Packet() ) { try { m_nInPackets++; pPacket->OnPacket( pHost ); } catch ( CException* pException ) { pException->Delete(); DEBUG_ONLY( pPacket->Debug( _T("Malformed packet.") ) ); } pPacket->Release(); } // Don't remove it, keep it to check sequence numbers // Remove( pDG, TRUE ); } // Always add it to the list pDG->m_pNextTime = NULL; pDG->m_pPrevTime = m_pInputFirst; if ( m_pInputFirst ) m_pInputFirst->m_pNextTime = pDG; else m_pInputLast = pDG; m_pInputFirst = pDG; m_pInputFree = pDG->m_pNextHash; if ( *pHash ) (*pHash)->m_pPrevHash = &pDG->m_pNextHash; pDG->m_pNextHash = *pHash; pDG->m_pPrevHash = pHash; *pHash = pDG; return TRUE; }
void OnDBPassMessage(CMessage* pMsg) { size_t nSavePlayerCnt = 0, nCreationCnt = 0, nRestoreCnt = 0, nDeletionCnt = 0; long nTransactionCounter = 0; char pszLogingInfo[512]=""; switch(pMsg->GetType()) { case MSG_DB2W_PASS_GM_BANPLAYER: { char szCdkey[128]; pMsg->GetStr(szCdkey, 128); long time = pMsg->GetLong(); CMessage msg(MSG_W2L_GM_BANPLAYER); msg.Add(szCdkey); msg.Add(time); msg.SendToSocket(GetGame()->GetLSSocketID()); AddLogText("DB2W:ban player %s OK!", szCdkey); } break; case MSG_DB2W_PASS_LOG_PLAYERBASELIST_DELTIMER: // WS传递LS的请求 { // 删除定时器 long msgTimerID = pMsg->GetLong(); //GetGame()->DelMsgTimer(msgTimerID); } break; case MSG_DB2W_PASS_LOG_PLAYERBASELIST: // WS传递LS的请求 { char strCDKey[20]; BYTE nRoleCnt; CGUID playerid; BYTE bRet=0; bRet=pMsg->GetByte(); pMsg->GetStr(strCDKey,20); nRoleCnt=BYTE(pMsg->GetShort()); char szGUID[128]={0}; CMessage logMsg(MSG_W2L_LOG_ANSWER_PLAYERBASELIST); // 创建验证码 long lTestSignCode = 0; GetGame()->GenerateSignCodeByTime(lTestSignCode); // 添加验证代码 logMsg.Add((long)lTestSignCode); logMsg.Add((BYTE)bRet); logMsg.Add(strCDKey); logMsg.Add((short)nRoleCnt); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(strCDKey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"Err MSG_DB2W_PASS_LOG_PLAYERBASELIST: LoginInfo[%s] Is Null!", strCDKey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage log2Msg(MSG_W2L_LOG_ANSWER_PLAYERBASELIST); // 添加验证代码 log2Msg.Add((long)0xFFFFFFFF); log2Msg.Add((BYTE)0); log2Msg.Add(strCDKey); log2Msg.Add((short)0); logMsg.Add((short)0); // 填充 log2Msg.Add((short)0);//角色个数 log2Msg.SendToSocket(GetGame()->GetLSSocketID()); return; } tLoginInfo->lSignCode = lTestSignCode; if(0 < nRoleCnt) { for(int i=0;i<nRoleCnt;i++) { CGUID lplayerID; pMsg->GetGUID(lplayerID); lplayerID.tostring(szGUID); CDBLoginPlayer* lPlayer = GetGame()->GetDBEntityManager()->FindLoginPlayer(lplayerID); if(lPlayer) { lPlayer->SetAccount(strCDKey, 20); tLoginInfo->PlayerState = PLAYER_STATE_LOADED_BASE_DATA; tLoginInfo->lLastLoginTime = timeGetTime(); // 为LoginPlayer单独处理添加map映射 GetGame()->GetDBEntityManager()->AddLoginPlayerByCdkey(lPlayer); // 填充 logMsg.Add((short)nRoleCnt);//角色个数 logMsg.Add(lplayerID); char* szName = (char*)lPlayer->GetStringAttr(string("Name"), 0); if(szName) logMsg.Add(szName);//得到名字 else logMsg.Add(""); logMsg.Add((WORD)lPlayer->GetLongAttr(string("Levels"), 0));//得到等级 logMsg.Add((short)lPlayer->GetLongAttr(string("Occupation"), 0));//得到职业类别 logMsg.Add((short)lPlayer->GetLongAttr(string("Sex"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("Country"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("HEAD"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("HAIR"), 0)); logMsg.Add((long)lPlayer->GetLongAttr(string( "FACE"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("NECKLACE"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("WING"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BODY"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BACK"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("GLOVE"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BOOT"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("HEADGEAR"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("FROCK"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("LRING"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("RRING"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("MEDAL1"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("MEDAL2"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("MEDAL3"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("FAIRY"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("WEAPON"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("WEAPON2"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("HeadLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("NecklaceLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("WingLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BodyLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BackLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("GloveLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("BootLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("HeadgearLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("FrockLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("LRingLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("RRingLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("Medal1Level"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("Medal2Level"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("Medal3Level"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("FairyLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("WeaponLevel"), 0)); logMsg.Add((short)lPlayer->GetLongAttr(string("Weapon2Level"), 0)); logMsg.Add((long)lPlayer->GetDelTime()); logMsg.Add((long)lPlayer->GetLongAttr(string("Region"), 0)); } _snprintf(pszLogingInfo,512,"MSG_DB2W_PASS_LOG_PLAYERBASELIST!MSGID[1175297],玩家ID[%s],Cdkey[%s],ret[%d]!", szGUID, strCDKey, bRet); PutStringToFile("Login_WS_Info",pszLogingInfo); } logMsg.SendToSocket(GetGame()->GetLSSocketID()); return; } else { logMsg.Add((short)0); // 填充 logMsg.Add((short)0);//角色个数 logMsg.SendToSocket(GetGame()->GetLSSocketID()); } } break; case MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA: // WS传递LS的请求 { long msgTimerID = pMsg->GetLong(); char flag = pMsg->GetChar(); // 删除定时器 //GetGame()->DelMsgTimer(msgTimerID); if(flag == LOGIN_QUEST_PLAYERDATA_FAILED) { char szCdkey[32]; CGUID guid; pMsg->GetGUID(guid);//获取PLAYERID pMsg->GetStr(szCdkey,32);//获取CDKEY CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512, "Err MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA: LoginInfo[%s] Is Null!", szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg2(MSG_W2L_LOG_ANSWER_PLAYERDATA); // 添加验证代码 msg2.Add((long)0xFFFFFFFF); msg2.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg2.Add(szCdkey); msg2.Send(); return; } if(tLoginInfo) { // 创建验证码 GetGame()->GenerateSignCodeByTime(tLoginInfo->lSignCode); // 添加验证代码 msg.Add((long)tLoginInfo->lSignCode); } msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg.Add(szCdkey); msg.Send(); char szGuid[128]=""; guid.tostring(szGuid); _snprintf(pszLogingInfo,512,"W2DB请求玩家数据失败,ID[%s],Cdkey[%s]!", szGuid, szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CDBLoginPlayer* lPlayer = GetGame()->GetDBEntityManager()->FindLoginPlayer(guid); if(lPlayer) { tLoginInfo->PlayerState = PLAYER_STATE_OFFLINE; tLoginInfo->lLastLoginTime = timeGetTime(); } return; } else if( flag == LOGIN_QUEST_PLAYERDATA_SUCCEED ) { char szCdkey[32]; CGUID guid; LONG64 time; pMsg->GetGUID(guid);//获取PLAYERID pMsg->GetStr(szCdkey,32);//获取CDKEY char szGUID[128]; guid.tostring(szGUID); //计费需 DWORD dwClientIP=pMsg->GetDWord(); time = pMsg->GetLONG64(); CDBLoginPlayer* lPlayer = GetGame()->GetDBEntityManager()->FindLoginPlayer(guid); if(NULL == lPlayer) { _snprintf(pszLogingInfo,512,"--[W2DB请求玩家数据失败,登录步骤错误或非法登录!ID[%s],CdKey[%s]!", szGUID, szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); return; } //if(lPlayer->GetPlayerState() != PLAYER_STATE_RESTORED) { // 先检查是否角色已经被记上删除标记 time_t tDel = GetGame()->GetDeletionPlayerTime(guid); if(!tDel) { tDel = (time_t)time; } // 删除日期不为0,则存在,所以不能登陆 if(tDel>0) { _snprintf(pszLogingInfo,512,"--[W2DB请求玩家数据失败,请求详细信息失败(删除日期不为0)!ID[%s],CdKey[%s]!", szGUID, szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg(MSG_W2L_LOG_ANSWER_PLAYERDATA); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"Err MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA_2: LoginInfo[%s] Is Null!", szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg2(MSG_W2L_LOG_ANSWER_PLAYERDATA); // 添加验证代码 msg2.Add((long)0xFFFFFFFF); msg2.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg2.Add(szCdkey); msg2.SendToSocket(GetGame()->GetLSSocketID()); return; } if(tLoginInfo) { // 创建验证码 GetGame()->GenerateSignCodeByTime(tLoginInfo->lSignCode); // 添加验证代码 msg.Add((long)tLoginInfo->lSignCode); } msg.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg.Add(szCdkey); msg.SendToSocket(GetGame()->GetLSSocketID()); tLoginInfo->PlayerState = PLAYER_STATE_LOADED_BASE_DATA; tLoginInfo->lLastLoginTime = timeGetTime(); return; } } // 添加CPlayer CPlayer* pPlayer = GetGame()->GetMapPlayer(guid); if(NULL == pPlayer) { pPlayer = new CPlayer; pPlayer->SetExID(guid); // 初始化Account数据 pPlayer->SetAccount(szCdkey); GetGame()->DeleteMapPlayer(guid); GetGame()->AppendMapPlayer(pPlayer); } // 添加CDBPlayer CDBPlayer* dbPlayer = GetGame()->GetDBEntityManager()->FindPlayer(guid); if(NULL == dbPlayer) { _snprintf(pszLogingInfo,512,"DBS在回应MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA消息前未发送DBPlayer数据!"); PutStringToFile("Login_WS_Info",pszLogingInfo); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"DBS在回应MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA消息前未发送DBPlayer数据! LoginInfo[%s] Is Null!", szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg2(MSG_W2L_LOG_ANSWER_PLAYERDATA); // 添加验证代码 msg2.Add((long)0xFFFFFFFF); msg2.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg2.Add(szCdkey); msg2.SendToSocket(GetGame()->GetLSSocketID()); return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_OFFLINE; tLoginInfo->lLastLoginTime = timeGetTime(); } return; } GetGame()->GetDBEntityManager()->CDBPlayerToCPlayer(dbPlayer, pPlayer); GetGame()->GetDBEntityManager()->CDBLoginPlayerToCPlayer(lPlayer, pPlayer); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"PLAYER_STATE_LOADED_CHAR_DATA! LoginInfo[%s] Is Null!", szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg2(MSG_W2L_LOG_ANSWER_PLAYERDATA); // 添加验证代码 msg2.Add((long)0xFFFFFFFF); msg2.Add((char)LOGIN_QUEST_PLAYERDATA_FAILED); msg2.Add(szCdkey); msg2.SendToSocket(GetGame()->GetLSSocketID()); return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_LOADED_CHAR_DATA; // 加上本次登录时间 tLoginInfo->lLastLoginTime = timeGetTime(); } // 返回LS消息 GetGame()->InitPlayerInfo(pPlayer, szCdkey); _snprintf(pszLogingInfo,512,"MSG_DB2W_PASS_LOG_QUEST_PLAYERDATA!MSGID[1175299],玩家ID[%s],Cdkey[%s]!", szGUID, szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); } } break; case MSG_DB2W_PASS_LOG_CREATEROLE: // WS请求创建一个角色 { long msgTimerID = pMsg->GetLong(); char flag = pMsg->GetChar(); // 创建结果标志 if(flag == LOGIN_CREATEROLE_SUCCEED) { CGUID tGuid; char szName[50],szCdkey[20]; pMsg->GetStr(szName,50); char nOccupation = pMsg->GetChar(); char nSex = pMsg->GetChar(); BYTE nHead = pMsg->GetByte(); BYTE nFace = pMsg->GetByte(); BYTE btCountry = pMsg->GetByte(); pMsg->GetStr(szCdkey,20); pMsg->GetGUID(tGuid); char szGUID[128]; tGuid.tostring(szGUID); // 加初角色 CPlayer *pPlayer = GetGame()->GetMapPlayer(tGuid); if(NULL == pPlayer) { char szGUID[128]; tGuid.tostring(szGUID); _snprintf(pszLogingInfo,512,"创建角色返回消息:未找到预先创建的CPlayer对象!:ID[%s]!", szGUID); PutStringToFile("Login_WS_Info",pszLogingInfo); } if(pPlayer) { pPlayer->SetName(szName); pPlayer->LoadDefaultProperty(nOccupation, nSex, btCountry); pPlayer->SetHeadPic (nHead); pPlayer->SetFacePic (nFace); pPlayer->SetAccount(szCdkey); pPlayer->SetName(szName); pPlayer->SetOccupation(nOccupation); pPlayer->SetGraphicsID(nSex+1); pPlayer->SetPKOnOff(127); pPlayer->SetOccuLevel(1); // 加初始装备到身上 GetGame()->AddOrginGoodsToPlayer(pPlayer); GetGame()->InitSkillToPlayer(pPlayer); //发送创建成功的消息 short nLevel=pPlayer->GetLevel ();//m_Property.lLevel; CGUID lPlayerid=pPlayer->GetExID(); DWORD dwBody=0,dwGlov=0,dwBoot=0,dwHelm=0,dwWeapon=0,dwBack=0, dwHeadgear=0,dwFrock=0,dwWing=0,dwManteau=0,dwFairy=0; BYTE nBodyLevel=0,nGlovLevel=0,nBootLevel=0,nHelmLevel=0,nWeaponLevel=0,nBackLevel=0, nHeadgearLevel=0,nFrockLevel=0,nWingLevel=0,nManteauLevel=0,nFairyLevel=0; GetGame()->GetPlayerEquipID(pPlayer, dwHelm, dwBody, dwGlov, dwBoot, dwWeapon, dwBack, dwHeadgear,dwFrock,dwWing,dwManteau,dwFairy, nHelmLevel, nBodyLevel, nGlovLevel, nBootLevel, nWeaponLevel, nBackLevel, nHeadgearLevel,nFrockLevel,nWingLevel,nManteauLevel,nFairyLevel); CMessage msg(MSG_W2L_LOG_CREATEROLE); msg.Add((char)LOGIN_CREATEROLE_SUCCEED); msg.Add(szCdkey); msg.Add(lPlayerid); msg.Add(szName); msg.Add(nLevel); msg.Add(nOccupation); msg.Add(nSex); msg.Add(btCountry); msg.Add(nHead); msg.Add(nHead); msg.Add(nFace); msg.Add(dwHelm); msg.Add(dwBody); msg.Add(dwGlov); msg.Add(dwBoot); msg.Add(dwWeapon); msg.Add(dwBack); // -- 新装备 msg.Add(dwHeadgear); msg.Add(dwFrock); msg.Add(dwWing); msg.Add(dwManteau); msg.Add(dwFairy); // -- msg.Add(nHelmLevel); msg.Add(nBodyLevel); msg.Add(nGlovLevel); msg.Add(nBootLevel); msg.Add(nWeaponLevel); msg.Add(nBackLevel); // -- 新装备 msg.Add(nHeadgearLevel); msg.Add(nFrockLevel); msg.Add(nWingLevel); msg.Add(nManteauLevel); msg.Add(nFairyLevel); // 发送存盘消息MSG_W2DB_SAVE_PLAYER CDBPlayer* dbPlayer = NULL; CDBEntityManager::DBPlayerMapItr itr = GetGame()->GetDBEntityManager()->GetDBPlayerMap().find(pPlayer->GetExID()); if(itr != GetGame()->GetDBEntityManager()->GetDBPlayerMap().end()) { dbPlayer = itr->second; } else { char szGUID[128]; tGuid.tostring(szGUID); _snprintf(pszLogingInfo,512,"创建角色返回消息:未找到预先创建的DBPlayer对象!:ID[%s]!", szGUID); PutStringToFile("Login_WS_Info",pszLogingInfo); } if(dbPlayer) { string tableName = "baseproperty"; dbPlayer->SetStringAttr(string("Name"), tableName, 0, szName); dbPlayer->SetLongAttr(string("HeadPic"), tableName, 0, nHead); dbPlayer->SetLongAttr(string("FacePic"), tableName, 0, nFace); dbPlayer->SetAccount(szCdkey, sizeof(szCdkey)); dbPlayer->SetLongAttr(string("Occupation"), tableName, 0, nOccupation); GetGame()->GetDBEntityManager()->CPlayerToCDBPlayer(pPlayer, dbPlayer); // 生成AutoSupplyData数据 AutoSupplyData tsupplyData; vector<BYTE> psDataBA; tsupplyData.AddToByteArray(psDataBA); dbPlayer->SetBufAttr(string("AutoSupplyData"), string("CSL_Player_Sprite_System"), 0, &psDataBA[0], psDataBA.size()); // 生成PlayerSetupOnServer数据 PlayerSetupOnServer tSetupOnServer; vector<BYTE> psetupServerBA; tSetupOnServer.AddToByteArray(psetupServerBA); dbPlayer->SetBufAttr(string("PlayerSetup"), string("CSL_Player_Sprite_System"), 0, &psetupServerBA[0], psetupServerBA.size()); GetGame()->SendSavePlayerMsg(dbPlayer); GetGame()->SendSaveSetup(); } // 创建LoginPlayer CDBLoginPlayer* dblPlayer = NULL; CDBEntityManager::DBLoginPlayerMapItr litr = GetGame()->GetDBEntityManager()->GetDBLoginPlayerMap().find(pPlayer->GetExID()); if(litr != GetGame()->GetDBEntityManager()->GetDBLoginPlayerMap().end()) { dblPlayer = litr->second; } else { char szGUID[128]; tGuid.tostring(szGUID); _snprintf(pszLogingInfo,512,"创建角色返回消息:未找到预先创建的DBLoginPlayer对象!:ID[%s]!", szGUID); PutStringToFile("Login_WS_Info",pszLogingInfo); } if(dblPlayer) { CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"MSG_DB2W_PASS_LOG_CREATEROLE! LoginInfo[%s] Is Null!", szCdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msgx(MSG_W2L_LOG_CREATEROLE); msgx.Add((char)LOGIN_CREATEROLE_FAILED); msgx.Add(szCdkey); msgx.SendToSocket(GetGame()->GetLSSocketID()); return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_LOADED_BASE_DATA; // 加上本次登录时间 tLoginInfo->lLastLoginTime = timeGetTime(); } dblPlayer->SetDelTime(-1); string logTableName = "CSL_PLAYER_BASE"; dblPlayer->SetStringAttr(string("Name"), logTableName, 0, szName);//得到名字 dblPlayer->SetLongAttr(string("Levels"), logTableName, 0,pPlayer->GetLevel());//得到等级 dblPlayer->SetLongAttr(string("Occupation"), logTableName, 0, nOccupation);//得到职业类别 dblPlayer->SetLongAttr(string("Sex"), logTableName, 0, pPlayer->GetSex()); dblPlayer->SetLongAttr(string("Country"), logTableName, 0, pPlayer->GetCountry()); dblPlayer->SetLongAttr(string("Region"), logTableName, 0, pPlayer->GetRegionID()); dblPlayer->SetLongAttr(string("HEAD"), logTableName, 0, nHead); dblPlayer->SetLongAttr(string("HAIR"), logTableName, 0, nHead); dblPlayer->SetLongAttr(string( "FACE"), logTableName, 0, nFace); dblPlayer->SetLongAttr(string("BODY"), logTableName, 0, dwBody); dblPlayer->SetLongAttr(string("BACK"), logTableName, 0, dwBack); dblPlayer->SetLongAttr(string("GLOVE"), logTableName, 0, dwGlov); dblPlayer->SetLongAttr(string("BOOT"), logTableName, 0, dwBoot); dblPlayer->SetLongAttr(string("HEADGEAR"), logTableName, 0, dwHeadgear); dblPlayer->SetLongAttr(string("FROCK"), logTableName, 0, dwFrock); dblPlayer->SetLongAttr(string("FAIRY"), logTableName, 0, dwFairy); dblPlayer->SetLongAttr(string("HeadLevel"), logTableName, 0, nHelmLevel); dblPlayer->SetLongAttr(string("BodyLevel"), logTableName, 0, nBodyLevel); dblPlayer->SetLongAttr(string("BackLevel"), logTableName, 0, nBackLevel); dblPlayer->SetLongAttr(string("GloveLevel"), logTableName, 0, nGlovLevel); dblPlayer->SetLongAttr(string("BootLevel"), logTableName, 0, nBootLevel); dblPlayer->SetLongAttr(string("HeadgearLevel"), logTableName, 0, nHeadgearLevel); dblPlayer->SetLongAttr(string("FrockLevel"), logTableName, 0, nFrockLevel); dblPlayer->SetLongAttr(string("FairyLevel"), logTableName, 0, nFairyLevel); GetGame()->SendSaveLoginPlayer(tGuid); } // 发送创建成功消息到LS msg.SendToSocket(GetGame()->GetLSSocketID()); } _snprintf(pszLogingInfo,512,"创建角色 Name:[%s], ID:[%s] 成功!", szCdkey, szGUID); PutStringToFile("Login_WS_Info",pszLogingInfo); } else { char szCDKEY[128]; pMsg->GetStr(szCDKEY, 128); CGUID tGuid; pMsg->GetGUID(tGuid); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(szCDKEY); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"MSG_DB2W_PASS_LOG_CREATEROLE_2! LoginInfo[%s] Is Null!", szCDKEY); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msgx(MSG_W2L_LOG_CREATEROLE); msgx.Add((char)LOGIN_CREATEROLE_FAILED); msgx.Add(szCDKEY); msgx.SendToSocket(GetGame()->GetLSSocketID()); return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_OFFLINE; tLoginInfo->lLastLoginTime = timeGetTime(); } // 删除CDBLoginPlayer对象 GetGame()->GetDBEntityManager()->DelOneDBLoginPlayer(tGuid); // 删除CDBPlayer对象 GetGame()->GetDBEntityManager()->DelOneDBPlayer(tGuid); // 删除CPlayer对象 GetGame()->DeleteMapPlayer(tGuid); tLoginInfo->setLoginGuid.erase(tGuid); CMessage msg(MSG_W2L_LOG_CREATEROLE); switch(flag) { case (char)LOGIN_CREATEROLE_NAMEEXIST: msg.Add((char)LOGIN_CREATEROLE_NAMEEXIST); break; case (char)LOGIN_CREATEROLE_DBERROR: msg.Add((char)LOGIN_CREATEROLE_DBERROR); break; case (char)LOGIN_CREATEROLE_FULL: msg.Add((char)LOGIN_CREATEROLE_FULL); break; case (char)LOGIN_CREATEROLE_NAMEINVALID: msg.Add((char)LOGIN_CREATEROLE_NAMEINVALID); break; } msg.Add(szCDKEY); msg.SendToSocket(GetGame()->GetLSSocketID()); char szGUID[128]; tGuid.tostring(szGUID); _snprintf(pszLogingInfo,512,"创建角色 Name:[%s], ID:[%s] 失败, 失败标志:[%d]!", szCDKEY, szGUID, flag); PutStringToFile("Login_WS_Info",pszLogingInfo); } // 删除定时器 //GetGame()->DelMsgTimer(msgTimerID); } break; case MSG_DB2W_PASS_LOG_DELETEROLE: // WS请求创建一个角色 { long msgTimerID = pMsg->GetLong(); char Flag = pMsg->GetChar(); // 是否成功标志位 CGUID nID; pMsg->GetGUID(nID); // Player ID char CDKey[64]; pMsg->GetStr(CDKey, 64); long delTime = pMsg->GetLong(); char name[128]; // player name pMsg->GetStr(name, 128); if(Flag == LOGIN_DELETEROLE_SUCCEED) { // 在恢复列表中删除 //GetGame()->DeleteRestorePlayer(nID); // 把角色id和删除日期追加到删除列表 //GetGame()->AppendDeletionPlayer(nID, delTime); CDBLoginPlayer* lPlayer = GetGame()->GetDBEntityManager()->FindLoginPlayer(nID); if(lPlayer) { lPlayer->SetDelTime(delTime); CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(CDKey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"DELETEROLE! LoginInfo[%s] Is Null!", CDKey); PutStringToFile("Login_WS_Info",pszLogingInfo); CMessage msg(MSG_W2L_LOG_DELETEROLE); msg.Add((char)LOGIN_DELETEROLE_FAILED); msg.Add(nID); msg.Add(CDKey); msg.Send();//send to loginserver return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_LOADED_BASE_DATA; tLoginInfo->lLastLoginTime = timeGetTime(); } tm *now; time_t tDate; time(&tDate); now = localtime(&tDate); long delTime[6] = {0}; delTime[0] = now->tm_year+1900; delTime[1] = now->tm_mon+1; delTime[2] = now->tm_mday; lPlayer->SetTimeAttr(string("DelDate"), string("CSL_PLAYER_BASE"), 0, delTime, sizeof(long)*6); } // 因为是刚删除的,直接返回设置里的删除天数即可。 char nRemainDays = char(CGlobeSetup::GetSetup()->dwDelDays); CMessage msg(MSG_W2L_LOG_DELETEROLE); msg.Add((char)LOGIN_DELETEROLE_SUCCEED); msg.Add(nID); msg.Add(CDKey); msg.Add(nRemainDays); msg.Send();//send to loginserver } else { CMessage msg(MSG_W2L_LOG_DELETEROLE); msg.Add((char)Flag); msg.Add(nID); msg.Add(CDKey); msg.Send();//send to loginserver } // 删除定时器 //GetGame()->DelMsgTimer(msgTimerID); } break; case MSG_DB2W_PASS_LOG_RESTOREROLE: { char flag; CGUID guid; char cdkey[128]; flag = pMsg->GetChar(); pMsg->GetGUID(guid); pMsg->GetStr(cdkey, 128); CMessage msg(MSG_W2L_LOG_RESTOREROLE); if(flag == 0) { msg.Add((char)LOGIN_RESTOREROLE_FAILED); } else { CDBLoginPlayer* lPlayer = GetGame()->GetDBEntityManager()->FindLoginPlayer(guid); if(lPlayer) { CDBEntityManager::tagLoginInfo* tLoginInfo = GetGame()->GetDBEntityManager()->FindLoginPlayerByCdkey(cdkey); if(!tLoginInfo) { _snprintf(pszLogingInfo,512,"MSG_DB2W_PASS_LOG_RESTOREROLE! LoginInfo[%s] Is Null!", cdkey); PutStringToFile("Login_WS_Info",pszLogingInfo); msg.Add((char)LOGIN_RESTOREROLE_FAILED); msg.Add(guid); msg.Add(cdkey); msg.Send(); return; } if(tLoginInfo) { tLoginInfo->PlayerState = PLAYER_STATE_LOADED_BASE_DATA; tLoginInfo->lLastLoginTime = timeGetTime(); } lPlayer->SetDelTime((time_t)-1); } msg.Add((char)LOGIN_RESTOREROLE_SUCCEED); long delTime[6] = {0}; lPlayer->SetTimeAttr(string("DelDate"), string("CSL_PLAYER_BASE"), 0, delTime, sizeof(long)*6); } msg.Add(guid); msg.Add(cdkey); msg.Send(); } break; case MSG_W2DB_PASS_CARD_VALIDATE_RESPONSE: // 棘手卡 break; case MSG_DB2W_PSASS_OTHER_GETLOG_REQUEST: { long gsid = pMsg->GetLong(); // gsid CGUID PlayerGuid; pMsg->GetGUID(PlayerGuid); // 请求的玩家GUID long IncLogNum = pMsg->GetLong();// 个数 //[070716 AHC] BYTE byType; DWORD dwMoney; char szDesc[256]; char szAcc[64]; if(IncLogNum) { // 清空该玩家日志 CIncrementLog::GetInstance()->DelAllPlayerIncLog(PlayerGuid); for(int i=0; i<IncLogNum; i++) { byType = pMsg->GetByte(); dwMoney = pMsg->GetDWord(); pMsg->GetStr(szDesc, 256); pMsg->GetStr(szAcc, 64); SYSTEMTIME time; pMsg->GetEx(&time, sizeof(SYSTEMTIME)); // 添加到记录数据 CIncrementLog::GetInstance()->Add(PlayerGuid, &time, byType, dwMoney, szDesc); } CMessage msg(MSG_W2S_OTHER_GETLOG_RESPONSE); msg.Add(PlayerGuid); vector<BYTE> vecLogData; if (CIncrementLog::GetInstance()->AddIncrementLogsToByteArray(vecLogData, PlayerGuid)) { msg.Add((long)vecLogData.size()); if(vecLogData.size() > 0) msg.AddEx(&vecLogData[0],vecLogData.size()); msg.SendGSID(gsid); } } } break; case MSG_DB2W_PASS_LOAD_ALL_FACTION_FINISH: { GetOrganiCtrl()->OnInitFactionEndMsg(pMsg); } break; case MSG_DB2W_PASS_DelFaction_Finish: { GetOrganiCtrl()->OnDelFactionFinishMsg(pMsg); } break; } }
/** * Handles the message sent for the creation of a corpse in the world. * * This function is called whenever a corpse should be created in the world for a client. * @return cMessage - Returns a server message to the client. */ cMessage cCorpse::CreatePacket( ) { cMessage cmCreate; unsigned char bUnknown[] = { 0x00, 0x00, 0x3D, 0x00, 0x02, 0xF0, 0xB5, 0x02, 0x11, 0x00, 0x00, 0x00, }; cModels *pcMonster = cModels::FindModel(this->m_MonsterModelID); #ifdef _DEBUG cMasterServer::ServerMessage( ColorYellow,NULL,"m_dwModel = %d",this->m_MonsterModelID); #endif if(pcMonster) { cmCreate << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant cmCreate << pcMonster->m_bPaletteChange << pcMonster->m_bTextureChange << pcMonster->m_bModelChange; // The Model Vectors if ( pcMonster->m_bPaletteChange != 0) { for (int i = 0; i < pcMonster->m_bPaletteChange; i++) { cmCreate.pasteData((UCHAR*)&pcMonster->m_vectorPal[i],sizeof(pcMonster->m_vectorPal[i])); } } if (pcMonster->m_bPaletteChange != 0) { cmCreate << WORD( pcMonster->m_wUnknown1 ); } if ( pcMonster->m_bTextureChange != 0) { for (int i = 0; i < pcMonster->m_bTextureChange; i++) { cmCreate.pasteData((UCHAR*)&pcMonster->m_vectorTex[i],sizeof(pcMonster->m_vectorTex[i])); } } if ( pcMonster->m_bModelChange != 0) { for (int i = 0; i < pcMonster->m_bModelChange; i++) { cmCreate.pasteData((UCHAR*)&pcMonster->m_vectorMod[i],sizeof(pcMonster->m_vectorMod[i])); } } } cmCreate.pasteAlign(4); DWORD dwFlags = 0x00019883L; cmCreate << dwFlags; cmCreate << WORD( 0x0414 ); cmCreate << WORD( 0x000C ); // MASK 0x00010000 unknown Bytes - Starting Animation cmCreate << 0x0CL; cmCreate.pasteData(bUnknown,sizeof(bUnknown)); cmCreate << 0x0L; // MASK 0x00008000 -- Location if ( !m_fIsOwned ) cmCreate.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) ); // MASK 0x00000002 -- Animation Set DWORD dwAnimC = 0x09000000L + m_wAnimConfig; cmCreate << dwAnimC; // MASK 0x00000800 -- Sound Set DWORD dwSoundSet = 0x20000000L + m_wSoundSet; cmCreate << dwSoundSet; // MASK 0x00001000 -- Particle Effects (unknown_blue) cmCreate << 0x3400006EL;//0x00000000L; // MASK 0x00000001 -- ModelNumber DWORD dwModel = 0x02000000L + m_dwModel; cmCreate << dwModel; cmCreate << float(m_flScale); // SeaGreens WORD wNuminteracts = 0x0; WORD wNumbubbles = 0x0; WORD wNumJumps = 0x0; WORD wNumOverrides = 0x0; WORD wUnkFlag8 = 0x0; WORD wUnkFlag10 = 0x0; cmCreate << m_wPositionSequence << m_wNumAnims //wNuminteracts << wNumbubbles << wNumJumps << m_wNumPortals << m_wNumAnims << wNumOverrides << wUnkFlag8 << m_wNumLogins << wUnkFlag10; DWORD dwFlags2 = 0x00200036; cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon);//WORD( 0x019C ) << WORD( 0x1317 );;//WORD( 0x0116 ) << WORD( 0x1317 ); /* Category of object: 0x00000001 Melee Weapon 0x00000002 Armor 0x00000004 Clothing 0x00000008 Jewelry 0x00000010 Creature (Player/NPC/Monster) 0x00000020 Food 0x00000040 Pyreals 0x00000080 Miscellaneous 0x00000100 Missile Weapons/Ammunition 0x00000200 Containers 0x00000400 Wrapped Fletching Supplies, House Decorations 0x00000800 Gems, Pack dolls, Decorative Statues 0x00001000 Spell Components 0x00002000 Books, Parchment, Scrolls, Signs, Statues 0x00004000 Keys, Lockpicks 0x00008000 Casting Item (wand, orb, staff) 0x00010000 Portal 0x00020000 Lockable 0x00040000 Trade Notes 0x00080000 Mana Stones, Mana Charges 0x00100000 Services 0x00200000 unknown (no longer plants) 0x00400000 Cooking Ingredients and Supplies, Plants, Dye Pots 0x00800000 Loose Fletching Supplies 0x01000000 unknown 0x02000000 unknown 0x04000000 Alchemy Ingredients and Supplies, Oils, Dye Vials 0x08000000 unknown 0x10000000 Lifestone 0x20000000 Ust 0x40000000 Salvage 0x80000000 unknown */ DWORD dwObjectFlags1 = 0x0200L; cmCreate << dwObjectFlags1; /* Behavior of object: 0x00000001 can be opened (false if locked) 0x00000002 can be inscribed 0x00000004 cannot be picked up 0x00000008 is a player 0x00000010 is not an npc 0x00000020 unknown 0x00000040 unknown 0x00000080 cannot be selected 0x00000100 can be read 0x00000200 is a merchant 0x00000400 is a pk altar 0x00000800 is an npk altar 0x00001000 is a door 0x00002000 is a corpse 0x00004000 can be attuned to (lifestone) 0x00008000 adds to health, stamina or mana 0x00010000 is a healing kit 0x00020000 is a lockpick 0x00040000 is a portal 0x00800000 is a foci 0x04000000 has an extra flags DWORD */ DWORD dwObjectFlags2 = 0x2015L; cmCreate << dwObjectFlags2; /* Masked against dwFlags2 in reverse order: 0x00000002 - Item Slots 0x00000004 - Pack Slots 0x00000008 - Value 0x00000010 - Unknown1 0x00000020 - Approach Distance 0x00200000 - Burden */ cmCreate << BYTE (0x78); //78 is item slots. (120) cmCreate << BYTE (0x00); //00 is pack slots //cmCreate << DWORD (0x000009C4); //Value cmCreate << DWORD (0x00000030); //Unknown cmCreate << float(3.0); //Approach Distance. cmCreate << WORD (0x0000); //Burden return cmCreate; }
void R_InitPicAnims (void) { const BITFIELD texflags = FTextureManager::TEXMAN_Overridable; // I think better not! This is only for old ANIMATED definition that // don't know about ZDoom's more flexible texture system. // | FTextureManager::TEXMAN_TryAny; if (Wads.CheckNumForName ("ANIMATED") != -1) { FMemLump animatedlump = Wads.ReadLump ("ANIMATED"); const char *animdefs = (const char *)animatedlump.GetMem(); const char *anim_p; FTextureID pic1, pic2; int animtype; DWORD animspeed; // Init animation animtype = FAnimDef::ANIM_Forward; for (anim_p = animdefs; *anim_p != -1; anim_p += 23) { if (*anim_p /* .istexture */ & 1) { // different episode ? if (!(pic1 = TexMan.CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Wall, texflags)).Exists() || !(pic2 = TexMan.CheckForTexture (anim_p + 1 /* .endname */, FTexture::TEX_Wall, texflags)).Exists()) continue; // [RH] Bit 1 set means allow decals on walls with this texture TexMan[pic2]->bNoDecals = TexMan[pic1]->bNoDecals = !(*anim_p & 2); } else { if (!(pic1 = TexMan.CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Flat, texflags)).Exists() || !(pic2 = TexMan.CheckForTexture (anim_p + 1 /* .startname */, FTexture::TEX_Flat, texflags)).Exists()) continue; } if (pic1 == pic2) { // This animation only has one frame. Skip it. (Doom aborted instead.) Printf ("Animation %s in ANIMATED has only one frame", anim_p + 10); continue; } FTexture *tex1 = TexMan[pic1]; FTexture *tex2 = TexMan[pic2]; if (tex1->UseType != tex2->UseType) { // not the same type - continue; } if (debuganimated) { Printf("Defining animation '%s' (texture %d, lump %d, file %d) to '%s' (texture %d, lump %d, file %d)\n", tex1->Name, pic1.GetIndex(), tex1->GetSourceLump(), Wads.GetLumpFile(tex1->GetSourceLump()), tex2->Name, pic2.GetIndex(), tex2->GetSourceLump(), Wads.GetLumpFile(tex2->GetSourceLump())); } // [RH] Allow for backward animations as well as forward. if (pic1 > pic2) { swap (pic1, pic2); animtype = FAnimDef::ANIM_Backward; } // Speed is stored as tics, but we want ms so scale accordingly. animspeed = /* .speed */ Scale ((BYTE(anim_p[19]) << 0) | (BYTE(anim_p[20]) << 8) | (BYTE(anim_p[21]) << 16) | (BYTE(anim_p[22]) << 24), 1000, 35); R_AddSimpleAnim (pic1, pic2 - pic1 + 1, animtype, animspeed); } } // [RH] Load any ANIMDEFS lumps R_InitAnimDefs (); Anims.FixAnimations (); }
//********************************************************** LPVOID __TBCOMMON_EXPORT__ COMMON_CreateItemEntry(LPCSTR a_pszName, DWORD a_dwType, TBVALUE_ENTRY *a_pValue, long a_cbSize, TMemAlloc *a_pMalloc) { long nNameLen = a_pszName ? strlen(a_pszName)+1 : 0; long nOffset = 0; long cbBlkSize = 0; TBITEM_ENTRY *pNewItem = NULL; DWORD dwHash = HASH_ComputeHash(a_pszName); long cbSize = a_cbSize; if(a_pMalloc == NULL) a_pMalloc = G_pMalloc; switch(a_dwType) { case TBVTYPE_INTEGER : cbSize = sizeof(long); break; case TBVTYPE_FLOAT : cbSize = sizeof(double); break; case TBVTYPE_RECT : cbSize = sizeof(RECT); break; case TBVTYPE_POINT : cbSize = sizeof(POINT); break; case TBVTYPE_FRECT : cbSize = sizeof(FLOAT_RECT); break; case TBVTYPE_FPOINT : cbSize = sizeof(FLOAT_POINT); break; case TBVTYPE_DATE : cbSize = sizeof(FILETIME); break; case TBVTYPE_PTGROUP: cbSize = offsetof(TB_PTGROUP_ENTRY, points) + a_pValue->ptGroup.count * sizeof(POINT); break; case TBVTYPE_FPTGROUP: cbSize = offsetof(TB_FPTGROUP_ENTRY, points) + a_pValue->ptGroup.count * sizeof(FLOAT_POINT); break; case TBVTYPE_CURRENCY : cbSize = sizeof(CURRENCY); break; case TBVTYPE_TEXT : cbSize = strlen(a_pValue->text) + 1; break; case TBVTYPE_SECTION: case TBVTYPE_LONGBINARY: cbSize = sizeof(long); break; } cbBlkSize = sizeof(TBITEM_ENTRY) + nNameLen + sizeof(DWORD) + cbSize; cbBlkSize = AdjustToFibonacciSize(cbBlkSize); pNewItem = (TBITEM_ENTRY *)a_pMalloc->Alloc(cbBlkSize); if (pNewItem==NULL) return FALSE; // fill new item nOffset = sizeof(TBITEM_ENTRY); pNewItem->dwHash = dwHash; pNewItem->wSize = (WORD)cbBlkSize; pNewItem->iName = BYTE(nOffset); pNewItem->iType = BYTE(nOffset += nNameLen); pNewItem->iValue = BYTE(nOffset += sizeof(DWORD)); strcpy(TBITEM_NAME(pNewItem), a_pszName); TBITEM_TYPE(pNewItem) = a_dwType; memcpy(TBITEM_VALUE(pNewItem), a_pValue, cbSize); return pNewItem; }
void cht_DoCheat (player_t *player, int cheat) { static const char * BeholdPowers[9] = { "PowerInvulnerable", "PowerStrength", "PowerInvisibility", "PowerIronFeet", "MapRevealer", "PowerLightAmp", "PowerShadow", "PowerMask", "PowerTargeter", }; const PClass *type; AInventory *item; const char *msg = ""; char msgbuild[32]; int i; switch (cheat) { case CHT_IDDQD: if (!(player->cheats & CF_GODMODE) && player->playerstate == PST_LIVE) { if (player->mo) player->mo->health = deh.GodHealth; player->health = deh.GodHealth; } // fall through to CHT_GOD case CHT_GOD: player->cheats ^= CF_GODMODE; if (player->cheats & CF_GODMODE) msg = GStrings("STSTR_DQDON"); else msg = GStrings("STSTR_DQDOFF"); ST_SetNeedRefresh(); break; case CHT_BUDDHA: player->cheats ^= CF_BUDDHA; if (player->cheats & CF_BUDDHA) msg = GStrings("TXT_BUDDHAON"); else msg = GStrings("TXT_BUDDHAOFF"); break; case CHT_NOCLIP: player->cheats ^= CF_NOCLIP; if (player->cheats & CF_NOCLIP) msg = GStrings("STSTR_NCON"); else msg = GStrings("STSTR_NCOFF"); break; case CHT_NOCLIP2: player->cheats ^= CF_NOCLIP2; if (player->cheats & CF_NOCLIP2) { player->cheats |= CF_NOCLIP; msg = GStrings("STSTR_NC2ON"); } else { player->cheats &= ~CF_NOCLIP; msg = GStrings("STSTR_NCOFF"); } break; case CHT_NOVELOCITY: player->cheats ^= CF_NOVELOCITY; if (player->cheats & CF_NOVELOCITY) msg = GStrings("TXT_LEADBOOTSON"); else msg = GStrings("TXT_LEADBOOTSOFF"); break; case CHT_FLY: if (player->mo != NULL) { player->cheats ^= CF_FLY; if (player->cheats & CF_FLY) { player->mo->flags |= MF_NOGRAVITY; player->mo->flags2 |= MF2_FLY; msg = GStrings("TXT_LIGHTER"); } else { player->mo->flags &= ~MF_NOGRAVITY; player->mo->flags2 &= ~MF2_FLY; msg = GStrings("TXT_GRAVITY"); } } break; case CHT_MORPH: msg = cht_Morph (player, PClass::FindClass (gameinfo.gametype == GAME_Heretic ? NAME_ChickenPlayer : NAME_PigPlayer), true); break; case CHT_NOTARGET: player->cheats ^= CF_NOTARGET; if (player->cheats & CF_NOTARGET) msg = "notarget ON"; else msg = "notarget OFF"; break; case CHT_ANUBIS: player->cheats ^= CF_FRIGHTENING; if (player->cheats & CF_FRIGHTENING) msg = "\"Quake with fear!\""; else msg = "No more ogre armor"; break; case CHT_CHASECAM: player->cheats ^= CF_CHASECAM; if (player->cheats & CF_CHASECAM) msg = "chasecam ON"; else msg = "chasecam OFF"; R_ResetViewInterpolation (); break; case CHT_CHAINSAW: if (player->mo != NULL && player->health >= 0) { type = PClass::FindClass ("Chainsaw"); if (player->mo->FindInventory (type) == NULL) { player->mo->GiveInventoryType (type); } msg = GStrings("STSTR_CHOPPERS"); } // [RH] The original cheat also set powers[pw_invulnerability] to true. // Since this is a timer and not a boolean, it effectively turned off // the invulnerability powerup, although it looks like it was meant to // turn it on. break; case CHT_POWER: if (player->mo != NULL && player->health >= 0) { item = player->mo->FindInventory (RUNTIME_CLASS(APowerWeaponLevel2), true); if (item != NULL) { item->Destroy (); msg = GStrings("TXT_CHEATPOWEROFF"); } else { player->mo->GiveInventoryType (RUNTIME_CLASS(APowerWeaponLevel2)); msg = GStrings("TXT_CHEATPOWERON"); } } break; case CHT_IDKFA: cht_Give (player, "backpack"); cht_Give (player, "weapons"); cht_Give (player, "ammo"); cht_Give (player, "keys"); cht_Give (player, "armor"); msg = GStrings("STSTR_KFAADDED"); break; case CHT_IDFA: cht_Give (player, "backpack"); cht_Give (player, "weapons"); cht_Give (player, "ammo"); cht_Give (player, "armor"); msg = GStrings("STSTR_FAADDED"); break; case CHT_BEHOLDV: case CHT_BEHOLDS: case CHT_BEHOLDI: case CHT_BEHOLDR: case CHT_BEHOLDA: case CHT_BEHOLDL: case CHT_PUMPUPI: case CHT_PUMPUPM: case CHT_PUMPUPT: i = cheat - CHT_BEHOLDV; if (i == 4) { level.flags2 ^= LEVEL2_ALLMAP; } else if (player->mo != NULL && player->health >= 0) { item = player->mo->FindInventory (BeholdPowers[i]); if (item == NULL) { if (i != 0) { cht_Give(player, BeholdPowers[i]); if (cheat == CHT_BEHOLDS) { P_GiveBody (player->mo, -100); } } else { // Let's give the item here so that the power doesn't need colormap information. cht_Give(player, "InvulnerabilitySphere"); } } else { item->Destroy (); } } msg = GStrings("STSTR_BEHOLDX"); break; case CHT_MASSACRE: { int killcount = P_Massacre (); // killough 3/22/98: make more intelligent about plural // Ty 03/27/98 - string(s) *not* externalized mysnprintf (msgbuild, countof(msgbuild), "%d Monster%s Killed", killcount, killcount==1 ? "" : "s"); msg = msgbuild; } break; case CHT_HEALTH: if (player->mo != NULL && player->playerstate == PST_LIVE) { player->health = player->mo->health = player->mo->GetDefault()->health; msg = GStrings("TXT_CHEATHEALTH"); } break; case CHT_KEYS: cht_Give (player, "keys"); msg = GStrings("TXT_CHEATKEYS"); break; // [GRB] case CHT_RESSURECT: if (player->playerstate != PST_LIVE && player->mo != NULL) { if (player->mo->IsKindOf(RUNTIME_CLASS(APlayerChunk))) { Printf("Unable to resurrect. Player is no longer connected to its body.\n"); } else { player->playerstate = PST_LIVE; player->health = player->mo->health = player->mo->GetDefault()->health; player->viewheight = ((APlayerPawn *)player->mo->GetDefault())->ViewHeight; player->mo->flags = player->mo->GetDefault()->flags; player->mo->flags2 = player->mo->GetDefault()->flags2; player->mo->flags3 = player->mo->GetDefault()->flags3; player->mo->flags4 = player->mo->GetDefault()->flags4; player->mo->flags5 = player->mo->GetDefault()->flags5; player->mo->flags6 = player->mo->GetDefault()->flags6; player->mo->flags7 = player->mo->GetDefault()->flags7; player->mo->renderflags &= ~RF_INVISIBLE; player->mo->height = player->mo->GetDefault()->height; player->mo->radius = player->mo->GetDefault()->radius; player->mo->special1 = 0; // required for the Hexen fighter's fist attack. // This gets set by AActor::Die as flag for the wimpy death and must be reset here. player->mo->SetState (player->mo->SpawnState); if (!(player->mo->flags2 & MF2_DONTTRANSLATE)) { player->mo->Translation = TRANSLATION(TRANSLATION_Players, BYTE(player-players)); } player->mo->DamageType = NAME_None; // player->mo->GiveDefaultInventory(); if (player->ReadyWeapon != NULL) { P_SetPsprite(player, ps_weapon, player->ReadyWeapon->GetUpState()); } if (player->morphTics > 0) { P_UndoPlayerMorph(player, player); } } } break; case CHT_GIMMIEA: cht_Give (player, "ArtiInvulnerability"); msg = "Valador's Ring of Invunerability"; break; case CHT_GIMMIEB: cht_Give (player, "ArtiInvisibility"); msg = "Shadowsphere"; break; case CHT_GIMMIEC: cht_Give (player, "ArtiHealth"); msg = "Quartz Flask"; break; case CHT_GIMMIED: cht_Give (player, "ArtiSuperHealth"); msg = "Mystic Urn"; break; case CHT_GIMMIEE: cht_Give (player, "ArtiTomeOfPower"); msg = "Tyketto's Tome of Power"; break; case CHT_GIMMIEF: cht_Give (player, "ArtiTorch"); msg = "Torch"; break; case CHT_GIMMIEG: cht_Give (player, "ArtiTimeBomb"); msg = "Delmintalintar's Time Bomb of the Ancients"; break; case CHT_GIMMIEH: cht_Give (player, "ArtiEgg"); msg = "Torpol's Morph Ovum"; break; case CHT_GIMMIEI: cht_Give (player, "ArtiFly"); msg = "Inhilicon's Wings of Wrath"; break; case CHT_GIMMIEJ: cht_Give (player, "ArtiTeleport"); msg = "Darchala's Chaos Device"; break; case CHT_GIMMIEZ: for (int i=0;i<16;i++) { cht_Give (player, "artifacts"); } msg = "All artifacts!"; break; case CHT_TAKEWEAPS: if (player->morphTics || player->mo == NULL || player->mo->health <= 0) { return; } { // Take away all weapons that are either non-wimpy or use ammo. AInventory **invp = &player->mo->Inventory, **lastinvp; for (item = *invp; item != NULL; item = *invp) { lastinvp = invp; invp = &(*invp)->Inventory; if (item->IsKindOf (RUNTIME_CLASS(AWeapon))) { AWeapon *weap = static_cast<AWeapon *> (item); if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) || weap->AmmoType1 != NULL) { item->Destroy (); invp = lastinvp; } } } } msg = GStrings("TXT_CHEATIDKFA"); break; case CHT_NOWUDIE: cht_Suicide (player); msg = GStrings("TXT_CHEATIDDQD"); break; case CHT_ALLARTI: for (int i=0;i<25;i++) { cht_Give (player, "artifacts"); } msg = GStrings("TXT_CHEATARTIFACTS3"); break; case CHT_PUZZLE: cht_Give (player, "puzzlepieces"); msg = GStrings("TXT_CHEATARTIFACTS3"); break; case CHT_MDK: if (player->mo == NULL) { Printf ("What do you want to kill outside of a game?\n"); } else if (!deathmatch) { // Don't allow this in deathmatch even with cheats enabled, because it's // a very very cheap kill. P_LineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE, P_AimLineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE), TELEFRAG_DAMAGE, NAME_MDK, NAME_BulletPuff); } break; case CHT_DONNYTRUMP: cht_Give (player, "HealthTraining"); msg = GStrings("TXT_MIDASTOUCH"); break; case CHT_LEGO: if (player->mo != NULL && player->health >= 0) { int oldpieces = ASigil::GiveSigilPiece (player->mo); item = player->mo->FindInventory (RUNTIME_CLASS(ASigil)); if (item != NULL) { if (oldpieces == 5) { item->Destroy (); } else { player->PendingWeapon = static_cast<AWeapon *> (item); } } } break; case CHT_PUMPUPH: cht_Give (player, "MedPatch"); cht_Give (player, "MedicalKit"); cht_Give (player, "SurgeryKit"); msg = GStrings("TXT_GOTSTUFF"); break; case CHT_PUMPUPP: cht_Give (player, "AmmoSatchel"); msg = GStrings("TXT_GOTSTUFF"); break; case CHT_PUMPUPS: cht_Give (player, "UpgradeStamina", 10); cht_Give (player, "UpgradeAccuracy"); msg = GStrings("TXT_GOTSTUFF"); break; case CHT_CLEARFROZENPROPS: player->cheats &= ~(CF_FROZEN|CF_TOTALLYFROZEN); msg = "Frozen player properties turned off"; break; case CHT_FREEZE: bglobal.changefreeze ^= 1; if (bglobal.freeze ^ bglobal.changefreeze) { msg = GStrings("TXT_FREEZEON"); } else { msg = GStrings("TXT_FREEZEOFF"); } break; } if (!*msg) // [SO] Don't print blank lines! return; if (player == &players[consoleplayer]) Printf ("%s\n", msg); else if (cheat != CHT_CHASECAM) Printf ("%s cheats: %s\n", player->userinfo.GetName(), msg); }
int COil::_DealComu51(char *v_szData, DWORD v_dwDaraLen) { char buf[1024] = {0}; char buf1[500] = {0}; char buf2[500] = {0}; int iBufLen = 0; int iBufLen1 = 0; tag1QOilBiaodingCfg objOilBDCfg; GetImpCfg(&objOilBDCfg,sizeof(objOilBDCfg), offsetof(tagImportantCfg,m_uni1QOilBiaodingCfg.m_obj1QOilBiaodingCfg),sizeof(objOilBDCfg)); memcpy(m_usONRealOilData,objOilBDCfg.m_aryONOilBiaoding,sizeof(m_usONRealOilData)); memcpy(m_usOFFRealOilData,objOilBDCfg.m_aryOFFOilBiaoding,sizeof(m_usOFFRealOilData)); int len = 0; buf1[len++] = BYTE(m_usONRealOilData[0][0]>>8); buf1[len++] = BYTE(m_usONRealOilData[0][0]%256); buf1[len++] = BYTE(m_usONRealOilData[0][1]>>8); buf1[len++] = BYTE(m_usONRealOilData[0][1]%256); buf1[len++] = BYTE(m_usONRealOilData[1][0]>>8); buf1[len++] = BYTE(m_usONRealOilData[1][0]%256); buf1[len++] = BYTE(m_usONRealOilData[1][1]>>8); buf1[len++] = BYTE(m_usONRealOilData[1][1]%256); buf1[len++] = BYTE(m_usONRealOilData[2][0]>>8); buf1[len++] = BYTE(m_usONRealOilData[2][0]%256); buf1[len++] = BYTE(m_usONRealOilData[2][1]>>8); buf1[len++] = BYTE(m_usONRealOilData[2][1]%256); buf1[len++] = BYTE(m_usONRealOilData[3][0]>>8); buf1[len++] = BYTE(m_usONRealOilData[3][0]%256); buf1[len++] = BYTE(m_usONRealOilData[3][1]>>8); buf1[len++] = BYTE(m_usONRealOilData[3][1]%256); buf1[len++] = BYTE(m_usONRealOilData[4][0]>>8); buf1[len++] = BYTE(m_usONRealOilData[4][0]%256); buf1[len++] = BYTE(m_usONRealOilData[4][1]>>8); buf1[len++] = BYTE(m_usONRealOilData[4][1]%256); buf1[len++] = BYTE(m_usOFFRealOilData[0][0]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[0][0]%256); buf1[len++] = BYTE(m_usOFFRealOilData[0][1]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[0][1]%256); buf1[len++] = BYTE(m_usOFFRealOilData[1][0]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[1][0]%256); buf1[len++] = BYTE(m_usOFFRealOilData[1][1]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[1][1]%256); buf1[len++] = BYTE(m_usOFFRealOilData[2][0]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[2][0]%256); buf1[len++] = BYTE(m_usOFFRealOilData[2][1]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[2][1]%256); buf1[len++] = BYTE(m_usOFFRealOilData[3][0]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[3][0]%256); buf1[len++] = BYTE(m_usOFFRealOilData[3][1]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[3][1]%256); buf1[len++] = BYTE(m_usOFFRealOilData[4][0]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[4][0]%256); buf1[len++] = BYTE(m_usOFFRealOilData[4][1]>>8); buf1[len++] = BYTE(m_usOFFRealOilData[4][1]%256); int iRet = g_objSms.MakeSmsFrame((char *)&buf1,len,0x37,0x51,buf,sizeof(buf),iBufLen,CVT_8TO7); if(!iRet) { g_objSock.SOCKSNDSMSDATA(buf,iBufLen,LV12,DATASYMB_SMSBACKUP); } return iRet; }
IC BYTE ClampColor(float a) { int c = iFloor(a); if (c<0) c=0; else if (c>255) c=255; return BYTE(c); }
int COil::DealDiaoDu(char *v_szData, DWORD v_dwDataLen) { if( !v_szData || v_dwDataLen < 1 ) return ERR_PAR; switch( BYTE(v_szData[0]) ) { case 0x00: _DealComuBD00(v_szData+1,v_dwDataLen-1); break; case 0x14: _DealComuBD14(v_szData+1,v_dwDataLen-1); break; case 0x12: _DealComuBD12(v_szData+1,v_dwDataLen-1); break; case 0x34: _DealComuBD34(v_szData+1,v_dwDataLen-1); break; case 0x10: _DealComuBDFull(v_szData+1,v_dwDataLen-1); break; case 0xF1: _DealComuBDF1(v_szData+1,v_dwDataLen-1); break; case 0xF2: _DealComuBDF2(v_szData+1,v_dwDataLen-1); break; case 0xF3: _DealComuBDF3(v_szData+1,v_dwDataLen-1); break; case 0xF4: _DealComuBDF4(v_szData+1,v_dwDataLen-1); break; case 0xF5: _DealComuBDF5(v_szData+1,v_dwDataLen-1); break; case 0x01: _DealComuC1(v_szData+1,v_dwDataLen-1); break; case 0x03: _DealComuC3(v_szData+1,v_dwDataLen-1); break; case 0x04: _DealComuC4(v_szData+1,v_dwDataLen-1); break; case 0x51: _DealComu51(v_szData+1,v_dwDataLen-1); break; default: return ERR_PAR; } return 0; }
bool XARGenerator::OutputStyles(const Style& style, const Transformation& trans, const RectD& boundings, UINT32 witch) { bool ok = true; CXaraFileRecord Rec(0); wxString sXmlId = style.GetXmlId(); if (!sXmlId.IsEmpty()) { // XXX how to output object labels in XAR? #if SVGDEBUG svgtrace(DBGTRACE_SHAPES, "object id: %s\n", (const char *)sXmlId.mb_str(wxConvUTF8)); #endif } // XXX TODO to avoid XAR redundancy, we should look // if the styles we are outputting are already the default // in Xara's stack if (witch & STYLE_FILL_COLOUR) { if (style.IsFillColourDefined()) { wxColour col = style.GetFillColour(); if (col.Ok()) { UINT32 iRecNo = DefineColour(col); Rec.Reinit(TAG_FLATFILL, TAG_FLATFILL_SIZE); ok = Rec.WriteReference(iRecNo); ok = m_pExporter->WriteRecord(&Rec); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "fill colour %d,%d,%d\n", col.Red(), col.Green(), col.Blue()); #endif } else { m_pExporter->WriteZeroSizedRecord(TAG_FLATFILL_NONE); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "no fill colour\n"); #endif } } else if (!style.IsFillGradientDefined()) { m_pExporter->WriteZeroSizedRecord(TAG_FLATFILL_NONE); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "no fill colour\n"); #endif } } if (witch & STYLE_FILL_GRADIENT && style.IsFillGradientDefined()) { Gradient* pGradient = style.GetFillGradient(); if (pGradient->type == Gradient::Linear) { OutputFillLinearGradient(style, trans, boundings); } else if (pGradient->type == Gradient::Radial) { OutputFillRadialGradient(style, trans, boundings); } } if (witch & STYLE_FILL_OPACITY && style.IsFillOpacityDefined()) { double opacity = style.GetFillOpacity(); if (opacity < 1.0) { BYTE bOpacity = (BYTE)((1.0-opacity)*255.0); Rec.Reinit(TAG_FLATTRANSPARENTFILL, TAG_FLATTRANSPARENTFILL_SIZE); ok = Rec.WriteBYTE(bOpacity); ok = Rec.WriteBYTE(0x01); ok = m_pExporter->WriteRecord(&Rec); } } if (witch & STYLE_STROKE_COLOUR) { if (style.IsStrokeColourDefined()) { wxColour col = style.GetStrokeColour(); if (col.Ok()) { UINT32 iRecNo = DefineColour(col); Rec.Reinit(TAG_LINECOLOUR, TAG_LINECOLOUR_SIZE); ok = Rec.WriteReference(iRecNo); ok = m_pExporter->WriteRecord(&Rec); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "stroke colour %d,%d,%d\n", col.Red(), col.Green(), col.Blue()); #endif } else { m_pExporter->WriteZeroSizedRecord(TAG_LINECOLOUR_NONE); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "no stroke colour\n"); #endif } } else { m_pExporter->WriteZeroSizedRecord(TAG_LINECOLOUR_NONE); #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "no stroke colour\n"); #endif } } if (witch & STYLE_STROKE_WIDTH && style.IsStrokeWidthDefined()) { UINT32 iStrokeWidth = style.GetStrokeWidth(); Rec.Reinit(TAG_LINEWIDTH, TAG_LINEWIDTH_SIZE); ok = Rec.WriteINT32(iStrokeWidth); ok = m_pExporter->WriteRecord(&Rec); } if (witch & STYLE_STROKE_LINEJOIN ) { JointType jt; if (style.IsStrokeLineJoinDefined()) { jt=style.GetStrokeLineJoin(); #if SVGDEBUG switch(jt) { case MitreJoin: svgtrace(DBGTRACE_STYLES, "stroke join mitre\n"); break; case BevelledJoin: svgtrace(DBGTRACE_STYLES, "stroke join bevel\n"); break; case RoundJoin: svgtrace(DBGTRACE_STYLES, "stroke join round\n"); break; } #endif } else { jt=MitreJoin; #if SVGDEBUG svgtrace(DBGTRACE_STYLES, "no stroke specified, using mitre\n"); #endif } Rec.Reinit(TAG_JOINSTYLE, TAG_JOINSTYLE_SIZE); ok = Rec.WriteBYTE(BYTE(jt)); ok = m_pExporter->WriteRecord(&Rec); } if (witch & STYLE_STROKE_LINECAP && style.IsStrokeLineCapDefined()) { LineCapType lct=style.GetStrokeLineCap(); Rec.Reinit(TAG_STARTCAP, TAG_STARTCAP_SIZE); ok = Rec.WriteBYTE(BYTE(lct)); ok = m_pExporter->WriteRecord(&Rec); Rec.Reinit(TAG_ENDCAP, TAG_ENDCAP_SIZE); ok = Rec.WriteBYTE(BYTE(lct)); ok = m_pExporter->WriteRecord(&Rec); #if SVGDEBUG switch(lct) { case LineCapButt: svgtrace(DBGTRACE_STYLES, "stroke cap butt\n"); break; case LineCapRound: svgtrace(DBGTRACE_STYLES, "stroke cap round\n"); break; case LineCapSquare: svgtrace(DBGTRACE_STYLES, "stroke cap square\n"); break; } #endif } if (witch & STYLE_STROKE_OPACITY && style.IsStrokeOpacityDefined()) { double opacity = style.GetStrokeOpacity(); if (opacity < 1.0) { BYTE bOpacity = (BYTE)((1.0-opacity)*255.0); Rec.Reinit(TAG_LINETRANSPARENCY, TAG_LINETRANSPARENCY_SIZE); ok = Rec.WriteBYTE(bOpacity); ok = Rec.WriteBYTE(0x01); // mix ok = m_pExporter->WriteRecord(&Rec); } } if (witch & STYLE_OPACITY && style.IsOpacityDefined()) { double fOpacity = style.GetOpacity(); if (fOpacity < 1.0) { double fFillOpacity = fOpacity; double fStrokeOpacity = fOpacity; if (style.IsFillOpacityDefined()) fFillOpacity *= style.GetFillOpacity(); if (style.IsStrokeOpacityDefined()) fStrokeOpacity *= style.GetStrokeOpacity(); BYTE bFillOpacity = (BYTE)((1.0-fFillOpacity)*255.0); BYTE bStrokeOpacity = (BYTE)((1.0-fStrokeOpacity)*255.0); Rec.Reinit(TAG_FLATTRANSPARENTFILL, TAG_FLATTRANSPARENTFILL_SIZE); ok = Rec.WriteBYTE(bFillOpacity); ok = Rec.WriteBYTE(0x01); // mix ok = m_pExporter->WriteRecord(&Rec); Rec.Reinit(TAG_LINETRANSPARENCY, TAG_LINETRANSPARENCY_SIZE); ok = Rec.WriteBYTE(bStrokeOpacity); ok = Rec.WriteBYTE(0x01); // mix ok = m_pExporter->WriteRecord(&Rec); } } return ok; }
void CDissolveDialog::RemoveResult(const ITEMBASE& sourceItem) { ResultContainer resultContainer; GetDissolvedResult( sourceItem, resultContainer); ResultContainer remainedResultContainer; for(BYTE tabIndex = 0; tabIndex < GetTabNum(); ++tabIndex) { cPushupButton* const button = GetTabBtn( tabIndex); if(FALSE == button->IsActive()) { break; } cIconGridDialog* const iconGridDialog = (cIconGridDialog*)GetTabSheet( tabIndex); for(WORD cellIndex = 0; cellIndex < iconGridDialog->GetCellNum(); ++cellIndex) { CItem* const item = (CItem*)iconGridDialog->GetIconForIdx( cellIndex); const ResultContainer::iterator iterator = resultContainer.find( item->GetItemIdx()); if(resultContainer.end() == iterator) { continue; } const DURTYPE quantity = iterator->second; if(item->GetDurability() <= quantity) { Clear( *item); } else { item->SetDurability( item->GetDurability() - quantity); } } } ResultContainer randomResultContainer; GetDissolvedResult( sourceItem, randomResultContainer); // 랜덤 결과를 제거한다 for(ResultContainer::const_iterator iterator = randomResultContainer.begin(); randomResultContainer.end() != iterator; ++iterator) { const ItemIndex itemIndex = iterator->first; const ItemQuantity itemQuantity = iterator->second; for(WORD cellIndex = 0; mRandomResultDialog->GetCellNum() > cellIndex; ++cellIndex) { CItem* const item = (CItem*)mRandomResultDialog->GetIconForIdx( cellIndex); if(item->GetItemIdx() != itemIndex) { continue; } else if(item->GetDurability() <= DURTYPE(itemQuantity)) { Clear( *item); break; } item->SetDurability( item->GetDurability() - itemQuantity); break; } } // 결과를 재배치한다 { ClearResult(); for(WORD cellIndex = 0; mSourceDialog->GetCellNum() > cellIndex; ++cellIndex) { CItem* const item = (CItem*)mSourceDialog->GetIconForIdx( cellIndex); if(item->GetDBIdx() == sourceItem.dwDBIdx) { continue; } AddResult( item->GetItemBaseInfo()); } } // 현재 탭이 숨겨질 경우, 그 이전 탭으로 변경해야한다 { cPushupButton* const button = GetTabBtn( GetCurTabNum()); if(FALSE == button->IsActive()) { SelectTab( BYTE(max(int(GetCurTabNum()) - 1, 0))); } } }
//--------------------------------------------------------------------------- void TShortcutBox::AddPickerLine(int p) { if (add_but[0].handle==0){ add_but[0].create(XD,sa.handle,0,0,(sa.w-10-HXC_SCROLLBAR_WIDTH)/2-5,25,button_notify_proc,this, BT_TEXT,T("Add New"),9998,BkCol); add_but[1].create(XD,sa.handle,0,0,(sa.w-10-HXC_SCROLLBAR_WIDTH)/2-5,25,button_notify_proc,this, BT_TEXT,T("Add Copy"),9999,BkCol); } if (p<0) return; int Base=p*100; int x=5,y=5+p*30; hxc_buttonpicker *p_pick; hxc_dropdown *p_dd; for (int n=0;n<3;n++){ p_pick=new hxc_buttonpicker(XD,sa.handle,x,y,80,25,picker_notify_proc,this,Base+n); x+=80; p_pick->allow_joy=true; p_pick->DirID=CurrentCuts[p].Id[n]; new hxc_button(XD,sa.handle,x,y,10,25,NULL,this, BT_TEXT | BT_STATIC | BT_BORDER_NONE | BT_TEXT_CENTRE, (char*)((n==2) ? "=":"+"),Base+90+n,BkCol); x+=10; } TranslateCutNames(); p_dd=new hxc_dropdown(XD,sa.handle,x,y,165,300,dd_notify_proc,this); p_dd->id=Base+3; p_dd->make_empty(); for (int s=0;s<TranslatedCutNamesSL.NumStrings;s++){ long i=TranslatedCutNamesSL[s].Data[0]; switch (i){ // Fullscreen not available case 15:case 16:case 17: break; default: p_dd->sl.Add(TranslatedCutNamesSL[s].String,i); } } for (int i=0;i<2;i++){ if (p_dd->select_item_by_data(CurrentCuts[p].Action,0)>=0) break; p_dd->sl.Add(T("Other"),CurrentCuts[p].Action); } p_dd->dropped_w=165+5+75+40; x+=165+5; p_pick=new hxc_buttonpicker(XD,sa.handle,x,y,70,25, picker_notify_proc,this,Base+4); p_pick->st_keys_only=true; p_pick->DirID=CurrentCuts[p].PressKey; p_dd=new hxc_dropdown(XD,sa.handle,x,y,70,400,dd_notify_proc,this); p_dd->make_empty(); DynamicArray<DWORD> Chars; GetAvailablePressChars(&Chars); for (int i=0;i<Chars.NumItems;i++){ p_dd->sl.Add("",101+BYTE(HIWORD(Chars[i]))-32,Chars[i]); } p_dd->select_item_by_data(CurrentCuts[p].PressChar,1); p_dd->lpig=&st_chars_ig; p_dd->lv.lpig=&st_chars_ig; p_dd->lv.display_mode=1; p_dd->id=Base+8; hxc_button *p_but=new hxc_button(XD,sa.handle,x,y,70,25,button_notify_proc, this,BT_TEXT,"",Base+9,BkCol); SetMacroFileButtonText(p_but,p); x+=75; new hxc_button(XD,sa.handle,x,y,40,25,button_notify_proc,this, BT_TEXT,T("Del"),Base+5,BkCol); ShowHidePressSTKeyPicker(p); }
void CStateMachinen::DoStand(CMonster& monster, eStateEvent evt) { const BASE_MONSTER_LIST& baseMonsterList = monster.GetSMonsterList(); StateParameter& stateParamter = monster.mStateParamter; switch(evt) { case eSEVENT_Enter: { // 소유주가 전투중인 경우 도와주러 간다 if(CObject* const ownerObject = g_pUserTable->FindUser(monster.GetOwnerIndex())) { if(ownerObject->GetObjectBattleState() && TRUE == monster.SetTObject(ownerObject->GetTObject())) { SetState( &monster, eMA_PERSUIT); stateParamter.nextTime = gCurTime + 500; break; } } stateParamter.nextTime = gCurTime + baseMonsterList.StandTime; monster.DoStand(); if(FALSE == monster.IsNoCheckCollision()) { break; } VECTOR3 vPos = {0}; monster.GetPosition(&vPos); if(g_pServerSystem->GetMap()->CollisionTilePos( vPos.x, vPos.z, g_pServerSystem->GetMapNum())) { break; } monster.SetNoCheckCollision(FALSE); break; } case eSEVENT_Process: { if(stateParamter.nextTime > gCurTime) { break; } Mon_SpeechState speechState = eMon_Speech_MAX; const BYTE rate = BYTE(rand() % 100); if(rate < baseMonsterList.StandRate) { SetState( &monster, eMA_STAND); speechState = eMon_Speech_KeepWalkAround; } else { SetState( &monster, eMA_WALKAROUND); speechState = eMon_Speech_WalkAround; } // 100617 ONS 정지상태에서 타겟이 죽었을 경우, 배회상태로 변경한다. if( monster.GetTObject() && monster.GetTObject()->GetState() == eObjectState_Die ) { monster.SetTObject(0); SetState( &monster, eMA_WALKAROUND); } const MonSpeechInfo* const speechInfo = MON_SPEECHMGR->GetCurStateSpeechIndex( monster.GetMonsterKind(), speechState); if(0 == speechInfo) { break; } monster.AddSpeech( speechInfo->SpeechType, speechInfo->SpeechIndex); break; } } }
void Buf::Next() { BYTE buffer[RecordSize]; m_Game.clear(); if ((m_dwRead = m_bufFile.Read(buffer, RecordSize)) && (buffer[0] != 0)) { bool isTime = false; bool isReverse = false; bool isDraw = false; bool isBlackWin = false; bool isWhiteWin = false; CString strBlackPlayer; CString strWhitePlayer; for (int i = 0; i < StartIndex; i++) { if (buffer[i] > 127) { buffer[i] -= 100; if (i == 24) { isTime = true; } else if (i == 25) { isDraw = true; } else if (i == 26) { isReverse = false; } else if (i == 27) { isWhiteWin = true; } else if (i == 28) { isBlackWin = true; } else if (i == 29) { isReverse = true; } } } for (i = 0; i < 15; i++) { strBlackPlayer += buffer[i]; } for (i = 15; i < 30; i++) { strWhitePlayer += buffer[i]; } Utils::trim(strBlackPlayer); Utils::trim(strWhitePlayer); CString strResult; if (isDraw) { strResult = "0.5 - 0.5"; } else if (isBlackWin) { strResult = "1 - 0"; } else //if (isWhiteWin) { strResult = "0 - 1"; } CString str5A("?"); for (i=StartIndex; i < RecordSize; i++) { if (buffer[i] == 0) { break; } int y = 16 - (buffer[i] + 14) / 15; int x = (buffer[i] + 14) % 15 + 1; if (i == StartIndex && (x != 8 || y != 8)) { str5A.Format( "%s%s", Utils::XCoordinateImage(x, true, false), Utils::YCoordinateImage(y, false)); x = 8; y = 8; } m_Game.addPos(BYTE((15-y) * 16 + x)); } const int lastMove = m_Game.numberOfMoves(); const CString strResultComment(strBlackPlayer + " - " + strWhitePlayer + " " + strResult); m_Game.addOneLineComment(lastMove, strResultComment); CString strFileAndNumber; strFileAndNumber.Format("File: %s, No: %d", m_bufFile.GetFileTitle(), m_nRecord); m_Game.addMultiLineComment(lastMove, strFileAndNumber); CString strReverse("Reverse: "); strReverse += (isReverse ? "R" : "-"); m_Game.addMultiLineComment(lastMove, strReverse); m_Game.addMultiLineComment(lastMove, "5A: " + str5A); if (isTime) { m_Game.addMultiLineComment(lastMove, "Time loss"); } m_nRecord++; } if (Done()) { m_bufFile.Close(); } }
/** * Handles the message sent for the creation of lockpicks in the world. * * This function is called whenever a lockpick should be created in the world for a client. * * @return cMessage - Returns a Create Object (0x0000F745) server message. */ cMessage cLockpicks::CreatePacket( ) { cMessage cmReturn; cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID ); cObject *pcObject = cWorldManager::FindObject( m_dwGUID ); if( pcModel ) { cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant cmReturn << pcModel->m_bPaletteChange << pcModel->m_bTextureChange << pcModel->m_bModelChange; // The Model Vectors if ( pcModel->m_bPaletteChange != 0) { for (int i = 0; i < pcModel->m_bPaletteChange; i++) { cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i])); } } if (pcModel->m_bPaletteChange != 0) { //Cubem0j0: Test code for armor only. cmReturn << WORD( 0x0C50 ); } if ( pcModel->m_bTextureChange != 0) { for (int i = 0; i < pcModel->m_bTextureChange; i++) { cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i])); } } if ( pcModel->m_bModelChange != 0) { for (int i = 0; i < pcModel->m_bModelChange; i++) { cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i])); } } } cmReturn.pasteAlign(4); cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L; // MASK 0x00008000 -- Location if ( !m_fIsOwned ) cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) ); // MASK 0x00000800 -- Sound Set DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet; cmReturn << dwSoundSet; // MASK 0x00001000 -- Particle Effects (unknown_blue) cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue; // MASK 0x00000001 -- ModelNumber DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber; cmReturn << dwModel; // SeaGreens WORD wNuminteracts = 0x0; WORD wNumbubbles = 0x0; WORD wNumJumps = 0x0; WORD wNumOverrides = 0x0; WORD wUnkFlag8 = 0x0; WORD wUnkFlag10 = 0x0; cmReturn << m_wPositionSequence << m_wNumAnims //wNuminteracts << wNumbubbles << wNumJumps << m_wNumPortals << m_wNumAnims << wNumOverrides << wUnkFlag8 << m_wNumLogins << wUnkFlag10; if(pcModel->m_dwContainerID != 0) { DWORD owned = pcModel->m_dwFlags2 & 0x00004000; cmReturn << owned; } else { cmReturn << pcModel->m_dwFlags2; // Object Flags } cmReturn << Name( ); // Object's Name cmReturn << pcModel->m_wModel; // Object's Model cmReturn << this->m_wIcon; // Object's Icon cmReturn << pcModel->m_dwObjectFlags1; // Object Flags cmReturn << pcModel->m_dwObjectFlags2; // Object Flags //Lockpicks flag2 - 00280c18 // Mask 0x0008 - Value if(pcModel->m_dwFlags2 & 0x00000008) { cmReturn << pcModel->m_dwValue; } // Mask 0x0010 dwUnknown_v2 if(pcModel->m_dwFlags2 & 0x00000010) cmReturn << DWORD(0x00200008); // Mask 0x80000 Usable on if(pcModel->m_dwFlags2 & 0x00080000) cmReturn << pcModel->m_dwUseableOn; // Mase 0x0400 Uses Remaining if(pcModel->m_dwFlags2 & 0x00000400) { cmReturn << pcModel->m_wUses; } // Mase 0x0800 Max # of uses if(pcModel->m_dwFlags2 & 0x00000800) { cmReturn << pcModel->m_wUseLimit; } // Mask 0x00200000 - Burden if(pcModel->m_dwFlags2 & 0x00200000) { cmReturn << pcModel->m_wBurden; } //Padding cmReturn << WORD(0x0000); return cmReturn; }
void image_bmp::Ideallow() { // 中间变量 double dTemp,MAX,MIN; // 循环变量 LONG i; LONG j; // 进行付立叶变换的宽度和高度(2的整数次方) LONG fw; LONG fh; int wp; int hp; // 赋初值 fw = 1; fh = 1; wp = 0; hp = 0; int H=Gray.rowsCount(); int W=Gray.colsCount(); datatemp=new imagedata *[H]; for(i=0;i<H;i++) datatemp[i]=new imagedata [W]; // 计算进行付立叶变换的宽度和高度(2的整数次方) while(fw * 2 <= W) { fw *= 2; wp++; } while(fh * 2 <= H) { fh *= 2; hp++; } // 分配内存 TD = new complex<double>[fw * fh]; FD = new complex<double>[fw * fh]; // 行 for(i = 0; i <fh; i++) { // 列 for(j = 0; j < fw; j++) { if((i+j)%2==0) // 给时域赋值 TD[j + fw * i] = complex<double>(Gray(i,j), 0); else // 给时域赋值 TD[j + fw * i] = complex<double>(-Gray(i,j), 0); } } for(i = 0; i <fh; i++) { // 对y方向进行快速付立叶变换 FFT_1D(&TD[fw * i], &FD[fw * i], wp); } // 保存变换结果 for(i = 0; i < fh; i++) { for(j = 0; j < fw; j++) { TD[i + fh * j] = FD[j + fw * i]; } } for(i = 0; i < fw; i++) { // 对x方向进行快速付立叶变换 FFT_1D(&TD[i * fh], &FD[i * fh], hp); } for(i = 0; i < fh; i++) for(j = 0; j < fw; j++) GrayTemp(i,j) = sqrt(FD[j * fh + i].real() * FD[j * fh + i].real() + FD[j * fh + i].imag() * FD[j * fh + i].imag()); MAX=GrayTemp.getMaxVal();MIN=GrayTemp.getMinVal(); int D0=20; // 行 for(i = 0; i < fh; i++) { // 列 for(j = 0; j < fw; j++) { // 计算频谱 dTemp = (double)sqrt(((double)i-H/2)*((double)i-H/2)+((double)j-W/2)*((double)j-W/2)); double Huv=(dTemp<=D0)?1:2; FD[j*fh+i]=FD[j*fh+i]*Huv; } } for(i = 0; i < fh; i++) for(j = 0; j < fw; j++) GrayTemp(i,j) = sqrt(FD[j * fh + i].real() * FD[j * fh + i].real() + FD[j * fh + i].imag() * FD[j * fh + i].imag()); for(i = 0; i < fh; i++) for(j = 0; j < fw; j++) { GrayTemp(i,j)=(GrayTemp(i,j)-MIN)/(MAX-MIN)*255; if(GrayTemp(i,j)>=1) GrayTemp(i,j)=255; else GrayTemp(i,j)=GrayTemp(i,j)*255; datatemp[i][j].blue=GrayTemp(i,j); datatemp[i][j].green=GrayTemp(i,j); datatemp[i][j].red=GrayTemp(i,j); } path="保存的图片\\Ideallow_FFT.bmp"; save_image(); //进行逆变换 for(i = 0; i < fh; i++) { // 对y方向进行快速付立叶变换 IFFT_1D(&FD[fw * i], &TD[fw * i], wp); } // 保存变换结果 for(i = 0; i < fh; i++) { for(j = 0; j < fw; j++) { FD[i + fh * j] = TD[j + fw * i]; } } for(i = 0; i < fw; i++) { // 对x方向进行快速付立叶变换 IFFT_1D(&FD[i * fh], &TD[i * fh], hp); } // 行 for(i = 0; i < fh; i++) { // 列 for(j = 0; j < fw; j++) { // 计算频谱 dTemp = sqrt(TD[i * fh + j].real() * TD[i * fh + j].real() + TD[i * fh + j].imag() * TD[i * fh + j].imag()); // 更新临时数组datatemp datatemp[i][j].blue=BYTE(dTemp); datatemp[i][j].green=BYTE(dTemp); datatemp[i][j].red=BYTE(dTemp); } } path="保存的图片\\Ideallow.bmp"; save_image(); for(i=0;i<H;i++) delete[] datatemp[i]; delete[] datatemp; delete[] TD; delete[] FD; }
//--------------------------------------------------------------------------- BYTE ASMCALL io_read_b(MEM_ADDRESS addr) { /* Allowed addresses 000000 - 3FFFFF RAM D00000 - D7FFFF E00000 - E3FFFF TOS E40000 - EBFFFF FA0000 - FBFFFF Cart FE0000 - FE1FFF FF8000 - FF800F MMU FF8200 - FF820F SHIFTER FF8240 - FF827F pallette, res FF8608 - FF860F FDC FF8800 - FF88FF sound chip FF8900 - FF893F DMA sound, microwire FF8A00 - FF8A3F blitter FF9000 - FF9001 FF9201, FF9202, FF9203 paddles FF9211, FF9213, FF9215, FF9217 paddles FFFA01, odd addresses up to FFFA3F MFP FFFC00 - FFFDFF ACIA, realtime clock Word differences: FF8604 - FF860F FDC FF9200, FF9202 paddles FF9210, FF9212, FF9214, FF9216 paddles FF9220, FF9222 paddles FFFA00 - FFFA3F MFP */ DEBUG_CHECK_READ_IO_B(addr); #ifdef ONEGAME if (addr>=OG_TEXT_ADDRESS && addr<OG_TEXT_ADDRESS+OG_TEXT_LEN){ return BYTE(OG_TextMem[addr-OG_TEXT_ADDRESS]); } #endif switch (addr & 0xffff00){ //fffe00 case 0xfffc00: //----------------------------------- ACIAs { // Only cause bus jam once per word DEBUG_ONLY( if (mode==STEM_MODE_CPU) ) { if (io_word_access==0 || (addr & 1)==0){ // if (passed VBL or HBL point){ // BUS_JAM_TIME(4); // }else{ // Jorge Cwik: // Access to the ACIA is synchronized to the E signal. Which is a clock with // one tenth the frequency of the main CPU clock (800 Khz). So the timing // should depend on the phase relationship between both clocks. int rel_cycle=ABSOLUTE_CPU_TIME-shifter_cycle_base; rel_cycle=8000000-rel_cycle; rel_cycle%=10; BUS_JAM_TIME(rel_cycle+6); // BUS_JAM_TIME(8); } } switch (addr){ /******************** Keyboard ACIA ************************/ case 0xfffc00: //status { BYTE x=0; if (ACIA_IKBD.rx_not_read || ACIA_IKBD.overrun==ACIA_OVERRUN_YES) x|=BIT_0; //full bit if (ACIA_IKBD.tx_flag==0) x|=BIT_1; //empty bit // if (acia[ACIA_IKBD].rx_not_read && acia[ACIA_IKBD].rx_irq_enabled) x|=BIT_7; //irq bit if (ACIA_IKBD.irq) x|=BIT_7; //irq bit if (ACIA_IKBD.overrun==ACIA_OVERRUN_YES) x|=BIT_5; //overrun return x; } case 0xfffc02: //data { DEBUG_ONLY( if (mode!=STEM_MODE_CPU) return ACIA_IKBD.data; ) // if (acia[ACIA_IKBD].rx_not_read) keyboard_buffer_length--; ACIA_IKBD.rx_not_read=0; LOG_ONLY( bool old_irq=ACIA_IKBD.irq; ) if (ACIA_IKBD.overrun==ACIA_OVERRUN_COMING){ ACIA_IKBD.overrun=ACIA_OVERRUN_YES; if (ACIA_IKBD.rx_irq_enabled) ACIA_IKBD.irq=true; LOG_ONLY( log_to_section(LOGSECTION_IKBD,EasyStr("IKBD: ")+HEXSl(old_pc,6)+ " - OVERRUN! Read data ($"+HEXSl(ACIA_IKBD.data,2)+ "), changing ACIA IRQ bit from "+old_irq+" to "+ACIA_IKBD.irq); ) }else{ ACIA_IKBD.overrun=ACIA_OVERRUN_NO; // IRQ should be off for receive, but could be set for tx empty interrupt ACIA_IKBD.irq=(ACIA_IKBD.tx_irq_enabled && ACIA_IKBD.tx_flag==0); LOG_ONLY( if (ACIA_IKBD.irq!=old_irq) log_to_section(LOGSECTION_IKBD,Str("IKBD: ")+ HEXSl(old_pc,6)+" - Read data ($"+HEXSl(ACIA_IKBD.data,2)+ "), changing ACIA IRQ bit from "+old_irq+" to "+ACIA_IKBD.irq); ) } mfp_gpip_set_bit(MFP_GPIP_ACIA_BIT,!(ACIA_IKBD.irq || ACIA_MIDI.irq)); return ACIA_IKBD.data; }
BOOL CDatagrams::Send(const SOCKADDR_IN* pHost, CPacket* pPacket, BOOL bRelease, LPVOID pToken, BOOL bAck) { ASSERT( pHost != NULL && pPacket != NULL ); if ( ! IsValid() || Security.IsDenied( &pHost->sin_addr ) ) { if ( bRelease ) pPacket->Release(); return FALSE; } if ( pPacket->m_nProtocol != PROTOCOL_G2 ) { CBuffer pBuffer; pPacket->ToBuffer( &pBuffer, false ); m_nOutPackets++; switch ( pPacket->m_nProtocol ) { case PROTOCOL_G1: Statistics.Current.Gnutella1.Outgoing++; break; case PROTOCOL_ED2K: Statistics.Current.eDonkey.Outgoing++; break; case PROTOCOL_DC: Statistics.Current.DC.Outgoing++; break; case PROTOCOL_BT: Statistics.Current.BitTorrent.Outgoing++; break; //default: // ; // Other? } pPacket->SmartDump( pHost, TRUE, TRUE ); if ( bRelease ) pPacket->Release(); CNetwork::SendTo( m_hSocket, (LPSTR)pBuffer.m_pBuffer, pBuffer.m_nLength, pHost ); return TRUE; } // Gnutella2 uses SGP-powered datagrams if ( m_pOutputFree == NULL || m_pBufferFree == NULL ) { if ( m_pOutputLast == NULL ) { if ( bRelease ) pPacket->Release(); theApp.Message( MSG_DEBUG, _T("CDatagrams output frames exhausted.") ); return FALSE; } Remove( m_pOutputLast ); } if ( m_pBufferFree == NULL ) { if ( bRelease ) pPacket->Release(); theApp.Message( MSG_DEBUG, _T("CDatagrams output frames really exhausted.") ); return FALSE; } CDatagramOut* pDG = m_pOutputFree; m_pOutputFree = m_pOutputFree->m_pNextHash; if ( m_nInFrags < 1 ) bAck = FALSE; pDG->Create( pHost, (CG2Packet*)pPacket, m_nSequence++, m_pBufferFree, bAck ); m_pBufferFree = m_pBufferFree->m_pNext; m_nBufferFree--; pDG->m_pToken = pToken; pDG->m_pNextTime = NULL; pDG->m_pPrevTime = m_pOutputFirst; if ( m_pOutputFirst ) m_pOutputFirst->m_pNextTime = pDG; else m_pOutputLast = pDG; m_pOutputFirst = pDG; BYTE nHash = BYTE( ( pHost->sin_addr.S_un.S_un_b.s_b1 + pHost->sin_addr.S_un.S_un_b.s_b2 + pHost->sin_addr.S_un.S_un_b.s_b3 + pHost->sin_addr.S_un.S_un_b.s_b4 + pHost->sin_port + pDG->m_nSequence ) & 0xff ); CDatagramOut** pHash = m_pOutputHash + ( nHash & HASH_MASK ); if ( *pHash ) (*pHash)->m_pPrevHash = &pDG->m_pNextHash; pDG->m_pNextHash = *pHash; pDG->m_pPrevHash = pHash; *pHash = pDG; m_nOutPackets++; Statistics.Current.Gnutella2.Outgoing++; #ifdef DEBUG_UDP theApp.Message( MSG_DEBUG, _T("UDP: Queued SGP (#%i) x%i for %s:%lu"), pDG->m_nSequence, pDG->m_nCount, (LPCTSTR)CString( inet_ntoa( pDG->m_pHost.sin_addr ) ), htons( pDG->m_pHost.sin_port ) ); #endif pPacket->SmartDump( pHost, TRUE, TRUE ); if ( bRelease ) pPacket->Release(); TryWrite(); return TRUE; }
//--------------------------------------------------------------------------- void SerialInBufNotEmpty() { mfp_reg[MFPR_RSR]|=BYTE(BIT_2); // Character in progress agenda_add(agenda_serial_replace,rs232_hbls_per_word+1,0); //+1 for middle of scanline }
SKILL_RESULT cSkillManager::OnSkillStartSyn(MSG_SKILL_START_SYN* pmsg, ITEMBASE* pItemBase) { CPlayer* const pOperator = (CPlayer*)g_pUserTable->FindUser(pmsg->Operator); if(0 == pOperator) { return SKILL_OPERATOR_INVALUED; } else if(eObjectKind_Player != pOperator->GetObjectKind()) { return SKILL_OPERATOR_INVALUED; } else if(0 < pOperator->CurCastingSkillID) { return SKILL_OPERATOR_INVALUED; } else if(eBATTLE_KIND_GTOURNAMENT == pOperator->GetBattle()->GetBattleKind()) { if(eBattleTeam_Max == pOperator->GetBattleTeam()) { return SKILL_STATE_INVALUED; } } const cActiveSkillInfo* const pSkillInfo = SKILLMGR->GetActiveInfo( pmsg->SkillIdx ); if(0 == pSkillInfo) { return SKILL_INFO_INVALUED; } else if(FALSE == pSkillInfo->IsExcutableSkillState(*pOperator, pmsg->mConsumeItem)) { return SKILL_STATE_INVALUED; } else if(pOperator->IsCoolTime(pSkillInfo->GetInfo())) { return SKILL_COOLING; } else if(0 == pItemBase) { const SkillScript& skillScript = GAMERESRCMNGR->GetSkillScript( pmsg->SkillIdx ); if( skillScript.mIsNeedCheck ) { const SKILL_BASE* const skillBase = pOperator->GetSkillTree().GetData( pmsg->SkillIdx / 100 * 100 + 1 ); if( ! skillBase ) { LogScriptHack( *pOperator, "SkillList.bin", "*player has no skill" ); return SKILL_OPERATOR_INVALUED; } const BYTE skillLevelFromClient = BYTE( pmsg->SkillIdx % 100 ); const BOOL isWrongSkillLevel = ( skillLevelFromClient > skillBase->Level ); if( isWrongSkillLevel ) { LogScriptHack( *pOperator, "SkillList.bin", "*wrong level" ); return SKILL_OPERATOR_INVALUED; } } } // 080410 KTH -- 아이템 사용으로 스킬을 사용할 경우 아이템의 정보를 확인한다. else { const ITEM_INFO* const itemInfo = ITEMMGR->GetItemInfo( pItemBase->wIconIdx ); if(0 == itemInfo) { return SKILL_OPERATOR_INVALUED; } else if(pSkillInfo->GetIndex() != itemInfo->SupplyValue) { return SKILL_OPERATOR_INVALUED; } } switch(pSkillInfo->GetInfo().Unit) { case UNITKIND_PHYSIC_ATTCK: { if(pOperator->GetAbnormalStatus()->IsBlockAttack) { return SKILL_STATE_INVALUED; } break; } default: { if(pOperator->GetAbnormalStatus()->IsSilence) { return SKILL_STATE_INVALUED; } break; } } OBJECTSTATEMGR_OBJ->EndObjectState( pOperator, eObjectState_Immortal); VECTOR3 TargetPos = {0}; CObject* pTargetObject = 0; if(FALSE == GetMainTargetPos(&pmsg->MainTarget, &TargetPos, &pTargetObject)) { return SKILL_TARGET_INVALUED; } switch(pTargetObject ? pTargetObject->GetObjectKind() : eObjectKind_None) { case eObjectKind_Player: { CPlayer* const targetPlayer = (CPlayer*)pTargetObject; if(targetPlayer->GetImmortalTime() && targetPlayer->GetBattleTeam() != pOperator->GetBattleTeam()) { return SKILL_TARGET_IMMORTALED; } else if(pOperator->IsPKMode()) { break; } else if(targetPlayer->IsPKMode()) { break; } else if(SIEGEWARFAREMGR->IsSiegeWarfareZone(g_pServerSystem->GetMapNum())) { break; } else if(SIEGEDUNGEONMGR->IsSiegeDungeon(g_pServerSystem->GetMapNum())) { break; } else if(GUILDWARMGR->IsGuildWar(targetPlayer->GetGuildIdx()) && GUILDWARMGR->IsGuildWar(pOperator->GetGuildIdx())) { break; } else if(UNITKIND_PHYSIC_ATTCK != pSkillInfo->GetInfo().Unit && UNITKIND_MAGIC_ATTCK != pSkillInfo->GetInfo().Unit) { if(UNITKIND_RESURRECTION == pSkillInfo->GetInfo().Unit && eObjectState_Die != OBJECTSTATEMGR_OBJ->GetObjectState(pTargetObject)) { return SKILL_TARGET_INVALUED; } break; } else if(eBATTLE_KIND_NONE != pOperator->GetBattle()->GetBattleKind() && eBATTLE_KIND_NONE != targetPlayer->GetBattle()->GetBattleKind()) { break; } else if(pTargetObject != pOperator) { return SKILL_TARGET_INVALUED; } for(CTargetListIterator iter(&pmsg->TargetList); 0 < iter.GetNextTarget();) { CObject* const pObject = g_pUserTable->FindUser( iter.GetTargetID()); if(0 == pObject) { continue; } else if(eObjectKind_Player != pObject->GetObjectKind()) { continue; } return SKILL_TARGET_INVALUED; } break; } case eObjectKind_Monster: case eObjectKind_BossMonster: case eObjectKind_SpecialMonster: case eObjectKind_FieldBossMonster: case eObjectKind_FieldSubMonster: case eObjectKind_ToghterPlayMonster: case eObjectKind_ChallengeZoneMonster: { pOperator->SetLastActionTime(gCurTime); break; } } switch(pSkillInfo->GetInfo().Target) { case eSkillTargetKind_None: { return SKILL_TARGET_INVALUED; } case eSkillTargetKind_OnlyOthers: { if( pTargetObject == pOperator ) { return SKILL_TARGET_INVALUED; } break; } case eSkillTargetKind_OnlySelf: { if( pTargetObject != pOperator ) { return SKILL_TARGET_INVALUED; } break; } } const float TargetRadius = (pTargetObject ? pTargetObject->GetRadius() : 0); if(pSkillInfo->IsInRange(*pOperator, TargetPos, TargetRadius) == FALSE ) { return SKILL_RANGE_NOTENOUGH; } else if(SKILLKIND_ONOFF == pSkillInfo->GetKind()) { BOOL destroy = FALSE; for(WORD i = 0; i < MAX_BUFF_COUNT; ++i) { const DWORD idx = pSkillInfo->GetInfo().Buff[ i ]; cSkillObject* const pSkill = pTargetObject->GetBuffList().GetData( idx / 100 ); if(0 == pSkill) { continue; } else if(pSkill->GetSkillIdx() > pSkillInfo->GetInfo().Buff[ i ]) { continue; } pSkill->SetEndState(); pSkill->EndState(); destroy = TRUE; } if( destroy ) { // 100615 ShinJS --- 스킬제거 정보를 전송한다. MSG_DWORD msg; ZeroMemory( &msg, sizeof(msg) ); msg.Category = MP_SKILL; msg.Protocol = MP_SKILL_START_DESTROY_ACK; msg.dwObjectID = pOperator->GetID(); msg.dwData = pmsg->mConsumeItem.dwDBIdx; pOperator->SendMsg( &msg, sizeof(msg) ); return SKILL_SUCCESS; } } // 090629 ONS 현재 실행한 스킬과 기존에 실행중인 버프스킬이 같은 그룹이 존재할 경우 해당 버프스킬을 제거한다. // 마족의 가호계열(베르제의 가호, 루피아의 가호, 파르세이카의 가호)의 버프스킬의 경우, // 스킬 발동시 기존에 실행중이던 가호 버프스킬이 있다면 해제하고 실행해야한다. // 확장을 위해 가호계열을 하나의 그룹으로 지정하고 다른 그룹에 영향을 받지 않고 제거할 수 있도록 처리. RemoveGroupBuffSkill( pTargetObject, pSkillInfo->GetInfo()); // 080602 LUJ, 전역 스킬은 DB에서 직접 처리한 후 전송된다. 취소 등을 위해 오브젝트 ID를 직접 받아온다 const DWORD skillObjectIndex = GetNewSkillObjectID(); // 길드/패밀리 포인트 등 동기화가 필요한 경우에만 처리한다. 이러한 것들은 일단 스킬을 발동시키고 // 조건이 적합지 않을 때 취소한다. 따라서 스킬을 취소해도 소모가 된다. switch(pSkillInfo->GetInfo().mConsumePoint.mType) { case ACTIVE_SKILL_INFO::ConsumePoint::TypeFamily: case ACTIVE_SKILL_INFO::ConsumePoint::TypeGuild: { const ACTIVE_SKILL_INFO::ConsumePoint& consumePoint = pSkillInfo->GetInfo().mConsumePoint; g_DB.FreeMiddleQuery( RSkillCheckUsable, skillObjectIndex, "EXEC dbo.MP_SKILL_CHECK_USABLE %d, %d, %d, %d", pOperator->GetID(), pSkillInfo->GetIndex(), ACTIVE_SKILL_INFO::ConsumePoint::TypeFamily == consumePoint.mType ? consumePoint.mValue : 0, ACTIVE_SKILL_INFO::ConsumePoint::TypeGuild == consumePoint.mType ? consumePoint.mValue : 0); break; } } cSkillObject* const pSObj = pSkillInfo->GetSkillObject(); if(0 == pSObj) { return SKILL_INFO_INVALUED; } sSKILL_CREATE_INFO info; info.level = pSkillInfo->GetLevel(); info.operatorId = pOperator->GetID(); info.mainTarget = pmsg->MainTarget; info.skillDir = pmsg->SkillDir; // 080602 LUJ, DB 업데이트 실패 시 스킬 오브젝트를 취소할 수 있도록 위에서 인덱스를 미리 받아놓도록 했다 info.skillObjectId = skillObjectIndex; info.pos = (pSkillInfo->GetInfo().Target ? TargetPos : *CCharMove::GetPosition(pOperator)); info.usedItem = pmsg->mConsumeItem; // 090108 LUJ, 멀티 타겟을 설정할 때 유효 여부를 검사하므로, 먼저 초기화를 해야한다. pSObj->Init( &info ); pSObj->SetMultiTarget( &( pmsg->TargetList ) ); pSObj->SetBattle( pOperator->GetBattleID(), pOperator->GetBattleTeam() ); pSObj->SetGridID( pOperator->GetGridID() ); /// 테이블에 등록 m_SkillObjectTable.Add( pSObj, pSObj->GetID() ); mProcessList.push_back(pSObj->GetID()); g_pServerSystem->AddSkillObject( pSObj, &info.pos ); pOperator->SetCurrentSkill(pSObj->GetID()); pOperator->SetCoolTime(pSkillInfo->GetInfo()); /// 스킬 생성 성공 return SKILL_SUCCESS; }
static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { JABBER_MUC_JIDLIST_INFO* dat = (JABBER_MUC_JIDLIST_INFO*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch( msg ) { case WM_INITDIALOG: { LVCOLUMN lvc; RECT rc; HWND hwndList; TranslateDialogDefault( hwndDlg ); hwndList = GetDlgItem( hwndDlg, IDC_LIST ); ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); GetClientRect( hwndList, &rc ); //rc.right -= GetSystemMetrics( SM_CXVSCROLL ); lvc.mask = LVCF_WIDTH; lvc.cx = rc.right - 20; ListView_InsertColumn( hwndList, 0, &lvc ); lvc.cx = 20; ListView_InsertColumn( hwndList, 1, &lvc ); SendMessage( hwndDlg, WM_JABBER_REFRESH, 0, lParam ); dat = (JABBER_MUC_JIDLIST_INFO*)lParam; static struct { int idc; char *title; char *icon; bool push; } buttons[] = { {IDC_BTN_FILTERAPPLY, "Apply filter", "sd_filter_apply", false}, {IDC_BTN_FILTERRESET, "Reset filter", "sd_filter_reset", false}, }; for (int i = 0; i < SIZEOF(buttons); ++i) { SendDlgItemMessage(hwndDlg, buttons[i].idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->ppro->LoadIconEx(buttons[i].icon)); SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONADDTOOLTIP, (WPARAM)buttons[i].title, 0); if (buttons[i].push) SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASPUSHBTN, 0, 0); } Utils_RestoreWindowPosition(hwndDlg, NULL, dat->ppro->m_szModuleName, "jidListWnd_"); } return TRUE; case WM_SIZE: { UTILRESIZEDIALOG urd = {0}; urd.cbSize = sizeof(urd); urd.hInstance = hInst; urd.hwndDlg = hwndDlg; urd.lpTemplate = MAKEINTRESOURCEA(IDD_JIDLIST); urd.pfnResizer = sttJidListResizer; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); RECT listrc; LVCOLUMN lvc; HWND hwndList = GetDlgItem( hwndDlg, IDC_LIST ); GetClientRect( hwndList, &listrc ); lvc.mask = LVCF_WIDTH; //listrc.right -= GetSystemMetrics( SM_CXVSCROLL ); lvc.cx = listrc.right - 20; SendMessage(hwndList, LVM_SETCOLUMN, 0, (LPARAM)&lvc); break; } break; case WM_JABBER_REFRESH: { // lParam is ( JABBER_MUC_JIDLIST_INFO * ) HXML iqNode, queryNode; const TCHAR* from; TCHAR title[256]; // Clear current GWL_USERDATA, if any if ( dat != NULL ) delete dat; // Set new GWL_USERDATA dat = ( JABBER_MUC_JIDLIST_INFO * ) lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) dat ); // Populate displayed list from iqNode lstrcpyn( title, TranslateT( "JID List" ), SIZEOF( title )); if (( dat=( JABBER_MUC_JIDLIST_INFO * ) lParam ) != NULL ) { if (( iqNode = dat->iqNode ) != NULL ) { if (( from = xmlGetAttrValue( iqNode, _T("from"))) != NULL ) { dat->roomJid = mir_tstrdup( from ); if (( queryNode = xmlGetChild( iqNode , "query" )) != NULL ) { TCHAR* localFrom = mir_tstrdup( from ); mir_sntprintf( title, SIZEOF( title ), TranslateT("%s, %d items (%s)"), ( dat->type == MUC_VOICELIST ) ? TranslateT( "Voice List" ) : ( dat->type == MUC_MEMBERLIST ) ? TranslateT( "Member List" ) : ( dat->type == MUC_MODERATORLIST ) ? TranslateT( "Moderator List" ) : ( dat->type == MUC_BANLIST ) ? TranslateT( "Ban List" ) : ( dat->type == MUC_ADMINLIST ) ? TranslateT( "Admin List" ) : ( dat->type == MUC_OWNERLIST ) ? TranslateT( "Owner List" ) : TranslateT( "JID List" ), xmlGetChildCount(queryNode), localFrom ); mir_free( localFrom ); } } } } SetWindowText( hwndDlg, title ); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 0); sttFillJidList(hwndDlg); } break; case WM_NOTIFY: if (( ( LPNMHDR )lParam )->idFrom == IDC_LIST ) { switch (( ( LPNMHDR )lParam )->code ) { case NM_CUSTOMDRAW: { NMLVCUSTOMDRAW *nm = ( NMLVCUSTOMDRAW * ) lParam; switch ( nm->nmcd.dwDrawStage ) { case CDDS_PREPAINT: case CDDS_ITEMPREPAINT: SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW ); return TRUE; case CDDS_SUBITEM|CDDS_ITEMPREPAINT: { RECT rc; HICON hIcon; ListView_GetSubItemRect( nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc ); if ( nm->iSubItem == 1 ) { if( nm->nmcd.lItemlParam == ( LPARAM )( -1 )) hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_ADDCONTACT ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ); else hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_DELETE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ); DrawIconEx( nm->nmcd.hdc, ( rc.left+rc.right-GetSystemMetrics( SM_CXSMICON ))/2, ( rc.top+rc.bottom-GetSystemMetrics( SM_CYSMICON ))/2,hIcon, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL ); DestroyIcon( hIcon ); SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT ); return TRUE; } } } } break; case NM_CLICK: { NMLISTVIEW *nm = ( NMLISTVIEW * ) lParam; LVITEM lvi; LVHITTESTINFO hti; TCHAR text[128]; if ( nm->iSubItem < 1 ) break; hti.pt.x = ( short ) LOWORD( GetMessagePos()); hti.pt.y = ( short ) HIWORD( GetMessagePos()); ScreenToClient( nm->hdr.hwndFrom, &hti.pt ); if ( ListView_SubItemHitTest( nm->hdr.hwndFrom, &hti ) == -1 ) break; if ( hti.iSubItem != 1 ) break; lvi.mask = LVIF_PARAM | LVIF_TEXT; lvi.iItem = hti.iItem; lvi.iSubItem = 0; lvi.pszText = text; lvi.cchTextMax = sizeof( text ); ListView_GetItem( nm->hdr.hwndFrom, &lvi ); if ( lvi.lParam == ( LPARAM )( -1 )) { TCHAR szBuffer[ 1024 ]; _tcscpy( szBuffer, dat->type2str()); if ( !dat->ppro->EnterString(szBuffer, SIZEOF(szBuffer), NULL, JES_COMBO, "gcAddNick_")) break; // Trim leading and trailing whitespaces TCHAR *p = szBuffer, *q; for ( p = szBuffer; *p!='\0' && isspace( BYTE( *p )); p++); for ( q = p; *q!='\0' && !isspace( BYTE( *q )); q++); if (*q != '\0') *q = '\0'; if (*p == '\0') break; TCHAR rsn[ 1024 ]; _tcscpy( rsn, dat->type2str()); if ( dat->type == MUC_BANLIST ) { dat->ppro->EnterString(rsn, SIZEOF(rsn), TranslateT("Reason to ban") , JES_COMBO, "gcAddReason_"); if ( szBuffer ) dat->ppro->AddMucListItem( dat, p , rsn); else dat->ppro->AddMucListItem( dat, p ); } else dat->ppro->AddMucListItem( dat, p ); } else { //delete TCHAR msgText[128]; mir_sntprintf( msgText, SIZEOF( msgText ), _T("%s %s?"), TranslateT( "Removing" ), text ); if ( MessageBox( hwndDlg, msgText, dat->type2str(), MB_YESNO|MB_SETFOREGROUND ) == IDYES ) { dat->ppro->DeleteMucListItem( dat, ( TCHAR* )lvi.lParam ); mir_free(( void * )lvi.lParam ); ListView_DeleteItem( nm->hdr.hwndFrom, hti.iItem ); } } } break; } break; } break; case WM_COMMAND: if ((LOWORD(wParam) == IDC_BTN_FILTERAPPLY) || ((LOWORD(wParam) == IDOK) && (GetFocus() == GetDlgItem(hwndDlg, IDC_FILTER)))) { SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 1); sttFillJidList(hwndDlg); } else if ((LOWORD(wParam) == IDC_BTN_FILTERRESET) || ((LOWORD(wParam) == IDCANCEL) && (GetFocus() == GetDlgItem(hwndDlg, IDC_FILTER)))) { SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 0); sttFillJidList(hwndDlg); } break; /* case WM_SETCURSOR: if ( LOWORD( LPARAM )!= HTCLIENT ) break; if ( GetForegroundWindow() == GetParent( hwndDlg )) { POINT pt; GetCursorPos( &pt ); ScreenToClient( hwndDlg,&pt ); SetFocus( ChildWindowFromPoint( hwndDlg,pt )); //ugly hack because listviews ignore their first click } break; */ case WM_CLOSE: { HWND hwndList; int count, i; LVITEM lvi; // Free lParam of the displayed list items hwndList = GetDlgItem( hwndDlg, IDC_LIST ); count = ListView_GetItemCount( hwndList ); lvi.mask = LVIF_PARAM; lvi.iSubItem = 0; for ( i=0; i<count; i++ ) { lvi.iItem = i; if ( ListView_GetItem( hwndList, &lvi ) == TRUE ) { if ( lvi.lParam!=( LPARAM )( -1 ) && lvi.lParam!=( LPARAM )( NULL )) { mir_free(( void * ) lvi.lParam ); } } } ListView_DeleteAllItems( hwndList ); CJabberProto* ppro = dat->ppro; switch ( dat->type ) { case MUC_VOICELIST: ppro->m_hwndMucVoiceList = NULL; break; case MUC_MEMBERLIST: ppro->m_hwndMucMemberList = NULL; break; case MUC_MODERATORLIST: ppro->m_hwndMucModeratorList = NULL; break; case MUC_BANLIST: ppro->m_hwndMucBanList = NULL; break; case MUC_ADMINLIST: ppro->m_hwndMucAdminList = NULL; break; case MUC_OWNERLIST: ppro->m_hwndMucOwnerList = NULL; break; } DestroyWindow( hwndDlg ); } break; case WM_DESTROY: // Clear GWL_USERDATA if ( dat != NULL ) { Utils_SaveWindowPosition(hwndDlg, NULL, dat->ppro->m_szModuleName, "jidListWnd_"); delete dat; } break; } return FALSE; }
GIFError CGIFFile::InitOutput(long width, long height) { if (!m_File.IsOpen()) return GIF_FileNotOpen; if (m_IsInput) return GIF_WriteToInputFile; m_ImageWidth = width; m_ImageHeight = height; GIFError status; status = writeToFile("GIF87a", 6); if (status != GIF_Success) return status; GIFScreenDescriptor screen; screen.Width = WORD(m_ImageWidth); screen.Height = WORD(m_ImageHeight); screen.PackedFields = 0; if (m_GlobalColorMapEntryCount > 0) { DWORD highest = highestBit(m_GlobalColorMapEntryCount); if (highest < 3) highest = 1; else highest -= 2; screen.PackedFields |= (BYTE)GIFGlobalMapPresent; screen.PackedFields |= highest; // color table size screen.PackedFields |= highest << 4; // color resolution } screen.BackgroundIndex = 0; screen.AspectRatio = 0; status = writeToFile(&screen, sizeof(screen)); if (status != GIF_Success) return status; if (m_GlobalColorMapEntryCount > 0) { status = writeToFile(m_GlobalColorMap, m_GlobalColorMapEntryCount * 3); if (status != GIF_Success) return status; } if (m_pCommentBuffer != 0) { BYTE extension = 0x21; status = writeToFile(&extension, sizeof(extension)); if (status != GIF_Success) return status; BYTE commentExtension = 0xFE; status = writeToFile(&commentExtension, sizeof(commentExtension)); if (status != GIF_Success) return status; BYTE comLen; int commentLength = m_CommentBufferSize; int commentOffset = 0; do { if (commentLength > 255) comLen = BYTE(255); else comLen = BYTE(commentLength); status = writeToFile(&comLen, sizeof(comLen)); if (status != GIF_Success) return status; status = writeToFile(&(m_pCommentBuffer[commentOffset]), comLen); if (status != GIF_Success) return status; commentLength -= comLen; commentOffset += comLen; } while (commentLength > 0); comLen = 0; status = writeToFile(&comLen, sizeof(comLen)); if (status != GIF_Success) return status; } return GIF_Success; }
void CHexDlg::OnOK() { UpdateData(); m_pBuffer.Clear(); m_sHex.Remove( _T(' ') ); m_sHex.Remove( _T('\t') ); m_sHex.Remove( _T('\r') ); m_sHex.Remove( _T('\n') ); if ( size_t length = m_sHex.GetLength() ) { if ( ( length & 1 ) != 0 ) { AfxMessageBox( _T("String has wrong even length!") ); return; } m_pBuffer.EnsureBuffer( length / 2 ); for ( size_t i = 0; i < length; ++i ) { BYTE b = 0; TCHAR c = m_sHex.GetAt( i ); if ( c >= '0' && c <= '9' ) b = BYTE( ( c - '0' ) << 4 ); else if ( c >= 'A' && c <= 'F' ) b = BYTE( ( c - 'A' + 10 ) << 4 ); else if ( c >= 'a' && c <= 'f' ) b = BYTE( ( c - 'a' + 10 ) << 4 ); else { CString sMsg; sMsg.Format( _T("Found wrong symbol at position: %d"), i ); AfxMessageBox( sMsg ); return; } ++i; c = m_sHex.GetAt( i ); if ( c >= '0' && c <= '9' ) b |= BYTE( c - '0' ); else if ( c >= 'A' && c <= 'F' ) b |= BYTE( c - 'A' + 10 ); else if ( c >= 'a' && c <= 'f' ) b |= BYTE( c - 'a' + 10 ); else { CString sMsg; sMsg.Format( _T("Found wrong symbol at position: %d"), i ); AfxMessageBox( sMsg ); return; } m_pBuffer.Add( &b, 1 ); } } else { AfxMessageBox( _T("Empty string!") ); return; } CSkinDialog::OnOK(); }
/** * Handles the message sent for the creation of world objects in the world. * * This function is called whenever a world object should be created in the world for a client. * * @return cMessage - Returns a Create Object (0x0000F745) server message. */ cMessage cWorldObject::CreatePacket() { DWORD dwFlags; cMessage cmCreate; cmCreate << 0xF745L << m_dwGUID << BYTE( 0x11 ) << BYTE( 0 ) << BYTE( 0 ) << BYTE( 0 ); dwFlags = 0x00028001L; WORD wPortalMode = 0x0408; cmCreate << dwFlags; cmCreate << WORD( wPortalMode ); cmCreate << WORD( 0x8005 ); // wUnknown_1 // MASK 0x00020000 unknown cmCreate << 0x65L; // MASK 0x00008000 - Location if ( !m_fIsOwned ) cmCreate.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) ); // MASK 0x00000001 ModelNumber DWORD dwModel = 0x02000000L + m_dwModel; cmCreate << dwModel; // SeaGreens WORD wNuminteracts = 0x0; WORD wNumbubbles = 0x0; WORD wNumJumps = 0x0; WORD wNumOverrides = 0x0; WORD wUnkFlag8 = 0x0; WORD wUnkFlag10 = 0x0; cmCreate << m_wPositionSequence << m_wNumAnims //wNuminteracts << wNumbubbles << wNumJumps << m_wNumPortals << m_wNumAnims << wNumOverrides << wUnkFlag8 << m_wNumLogins << wUnkFlag10; switch(iObjectType) { case 0: { DWORD dwFlags2 = 0x00200018; cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon); DWORD dwObjectFlags1 = 0x80L; cmCreate << dwObjectFlags1; DWORD dwObjectFlags2 = 0x80L; cmCreate << dwObjectFlags2; // Masked against dwFlags2 //Mask 0x0008 - Value cmCreate << DWORD(0x00); // Mask 0x0010 dwUnknown_v2 cmCreate << DWORD(0x20); // Mask 0x00200000 - Burden cmCreate << WORD(0x0040); } break; case 1: { DWORD dwFlags2 = 0x00200018; cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon); DWORD dwObjectFlags1 = 0x80L; cmCreate << dwObjectFlags1; DWORD dwObjectFlags2 = 0x14L; cmCreate << dwObjectFlags2; // Masked against dwFlags2 //Mask 0x0008 - Value cmCreate << DWORD(0x00); // Mask 0x0010 dwUnknown_v2 cmCreate << DWORD(0x20); // Mask 0x00200000 - Burden cmCreate << WORD(0x0040); } break; case 2: { DWORD dwFlags2 = 0x00600038; cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon); DWORD dwObjectFlags1 = 0x00400000; cmCreate << dwObjectFlags1; DWORD dwObjectFlags2 = 0x14L; cmCreate << dwObjectFlags2; // Masked against dwFlags2 //Mask 0x0008 - Value cmCreate << DWORD(0x00); // Mask 0x0010 dwUnknown_v2 cmCreate << DWORD(0x20); // Mask 0x0020 Approach distance cmCreate << float(3.0); // Mask 0x00200000 - Burden cmCreate << WORD(0x0040); // Mask 0x00400000 - Spell cmCreate << WORD(0x049F); } break; default: { DWORD dwFlags2 = 0x00200018; cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon); DWORD dwObjectFlags1 = 0x80L; cmCreate << dwObjectFlags1; DWORD dwObjectFlags2 = 0x14L; cmCreate << dwObjectFlags2; // Masked against dwFlags2 //Mask 0x0008 - Value cmCreate << DWORD(0x00); // Mask 0x0010 dwUnknown_v2 cmCreate << DWORD(0x20); // Mask 0x00200000 - Burden cmCreate << WORD(0x0040); } break; } return cmCreate; }
void D3DObjectFont::PushForDraw(Glyph *glyph, int x, int y) { BeginCache(_image_id); // Uff, I'm not sure about multiple windows... #define LERP(a, b, t1, t2) (BYTE)(FLOAT(a) * (t1) + FLOAT(b) * (t2)) Color dc, sc; FLOAT a; sc.color = _color; const FLOAT color_alpha = sc.Alpha(); DWORD *data = _cache.data.Data(); BYTE *gdata = glyph->_data.Data(); const int glyph_height = glyph->_height; const int cache_height = _cache.height; const int glyph_width = glyph->_width; const int cache_width = _cache.width; for (int i = 0, yi = y; i < glyph_height && yi < cache_height; i++, yi++) { if (yi < 0) continue; DWORD *dst = data + ((yi) * cache_width + x); BYTE *src = gdata + (i * glyph_width); POINT *dirty_yi = &_cache.dirty[yi]; if (_cache.valid_rect.top > yi) _cache.valid_rect.top = yi; if (_cache.valid_rect.bottom < yi) _cache.valid_rect.bottom = yi; for (int j = 0, xj = x; j < glyph_width && xj < cache_width; j++, xj++, dst++, src++) { if (xj < 0) continue; BYTE glyph_pix = *src; if (glyph_pix == 0) continue; if (dirty_yi->x >= 0 && dirty_yi->y < 0) dirty_yi->x = 0, dirty_yi->y = cache_width - 1; else { if (dirty_yi->x < 0 || dirty_yi->x > xj) dirty_yi->x = xj; if (dirty_yi->y < 0 || dirty_yi->y < xj) dirty_yi->y = xj; } if (_cache.valid_rect.left > xj) _cache.valid_rect.left = xj; if (_cache.valid_rect.right < xj) _cache.valid_rect.right = xj; if (glyph_pix == 0xff && sc.a == 0xff) { *dst = sc.color; continue; } a = FLOAT(glyph_pix) * color_alpha / 255.f; if (*dst == 0) { *dst = (BYTE(255.f * a) << 24) | (0x00ffffff & sc.color); continue; } dc.color = *dst; dc.r = LERP(dc.r, sc.r, 1 - a, a); dc.g = LERP(dc.g, sc.g, 1 - a, a); dc.b = LERP(dc.b, sc.b, 1 - a, a); dc.a = max(dc.a, BYTE(255.f * a)); *dst = dc.color; } } }
BYTE* dataparser2(LPCSTR pStr,DWORD* pdwDataLength) { if (pStr[0]=='\0') return NULL; BYTE* pData=new BYTE[10]; BYTE* pDataPtr=pData; DWORD nAllocLen=10; // Removing spaces while (*pStr==' ') pStr++; while (*pStr!='\0') { if (_1stcontain2nd(pStr,"int")) { pStr+=3; int base=_getbase2(pStr,10); if (*pStr!='(') break; pStr++; _allocmore(pData,pDataPtr,nAllocLen,4); *((DWORD*)pDataPtr)=DWORD(_readnum(base,pStr)); while (*pStr!=')' && *pStr!='\0') pStr++; if (*pStr==')') pStr++; pDataPtr+=4; } else if (_1stcontain2nd(pStr,"dword")) { pStr+=5; int base=_getbase2(pStr,16); if (*pStr!='(') break; pStr++; _allocmore(pData,pDataPtr,nAllocLen,4); *((DWORD*)pDataPtr)=DWORD(_readnum(base,pStr)); while (*pStr!=')' && *pStr!='\0') pStr++; if (*pStr==')') pStr++; pDataPtr+=4; } else if (_1stcontain2nd(pStr,"word")) { pStr+=4; int base=_getbase2(pStr,16); if (*pStr!='(') break; pStr++; _allocmore(pData,pDataPtr,nAllocLen,2); *((WORD*)pDataPtr)=WORD(_readnum(base,pStr)); while (*pStr!=')' && *pStr!='\0') pStr++; if (*pStr==')') pStr++; pDataPtr+=2; } else if (_1stcontain2nd(pStr,"byte")) { pStr+=4; int base=_getbase2(pStr,16); if (*pStr!='(') break; pStr++; _allocmore(pData,pDataPtr,nAllocLen,1); *((BYTE*)pDataPtr)=BYTE(_readnum(base,pStr)); while (*pStr!=')' && *pStr!='\0') pStr++; if (*pStr==')') pStr++; pDataPtr+=1; } else if (_1stcontain2nd(pStr,"str")) { pStr+=3; if (*pStr!='(') break; pStr++; for (;*pStr!=')' && *pStr!='\0';pStr++) { _allocmore(pData,pDataPtr,nAllocLen,1); if (*pStr=='\\' && pStr[1]!='\0') { pStr++; switch (*pStr) { case '0': *(pDataPtr++)='\0'; break; case 'n': *(pDataPtr++)='\n'; break; case 'r': *(pDataPtr++)='\r'; break; case 't': *(pDataPtr++)='\t'; break; case 'b': *(pDataPtr++)='\b'; break; case ')': *(pDataPtr++)=')'; break; default: *(pDataPtr++)=BYTE(_readnum(16,pStr,2));; pStr--; break; } } else *(pDataPtr++)=*pStr; } if (*pStr==')') pStr++; } #ifdef WIN32 else if (_1stcontain2nd(pStr,"oem")) { pStr+=3; if (*pStr!='(') break; pStr++; int iStart=DWORD(pDataPtr-pData); for (;*pStr!=')' && *pStr!='\0';pStr++) { _allocmore(pData,pDataPtr,nAllocLen,1); if (*pStr=='\\' && pStr[1]!='\0') { pStr++; switch (*pStr) { case '0': *(pDataPtr++)='\0'; break; case 'n': *(pDataPtr++)='\n'; break; case 'r': *(pDataPtr++)='\r'; break; case 't': *(pDataPtr++)='\t'; break; case 'b': *(pDataPtr++)='\b'; break; case ')': *(pDataPtr++)=')'; break; default: *(pDataPtr++)=BYTE(_readnum(16,pStr,2));; pStr--; break; } } else *(pDataPtr++)=*pStr; } CharToOemBuff(LPSTR(pData+iStart),LPSTR(pData+iStart),DWORD(pDataPtr-pData)-iStart); if (*pStr==')') pStr++; } #endif #ifdef DEF_WCHAR else if (_1stcontain2nd(pStr,"wstr") || _1stcontain2nd(pStr,"uni")) { pStr+=3; while (*pStr!='(') pStr++; pStr++; for (;*pStr!=')' && *pStr!='\0';pStr++) { _allocmore(pData,pDataPtr,nAllocLen,2); if (*pStr=='\\' && pStr[1]!='\0') { pStr++; switch (*pStr) { case '0': *LPWORD(pDataPtr)=L'\0'; break; case 'n': *LPWORD(pDataPtr)=L'\n'; break; case 'r': *LPWORD(pDataPtr)=L'\r'; break; case 't': *LPWORD(pDataPtr)=L'\t'; break; case 'b': *LPWORD(pDataPtr)=L'\b'; break; case ')': *LPWORD(pDataPtr)=L')'; break; default: *LPWORD(pDataPtr)=WORD(_readnum(16,pStr,4));; pStr--; break; } pDataPtr+=2; } else { _MemCopyAtoW(pDataPtr,nAllocLen,pStr,1); pDataPtr+=2; } } if (*pStr==')') pStr++; } #endif else { _allocmore(pData,pDataPtr,nAllocLen,1); LPCSTR pStrOld=pStr; *pDataPtr=_readnum(16,pStr,2); if (pStr==pStrOld) { *pdwDataLength=DWORD(pDataPtr-pData); return pData; } pDataPtr++; } while (*pStr==' ') pStr++; } *pdwDataLength=DWORD(pDataPtr-pData); return pData; }
void store(uint16_t v) { store_variable(BYTE(pc++), v); }