![]() |
|
Mini SDK Parcer LogCash by Orion Games - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Release Zone (https://lckb.dev/forum/forumdisplay.php?fid=190) +---- Forum: General Releases (https://lckb.dev/forum/forumdisplay.php?fid=127) +----- Forum: General Tools Releases (https://lckb.dev/forum/forumdisplay.php?fid=214) +----- Thread: Mini SDK Parcer LogCash by Orion Games (/showthread.php?tid=4655) |
- Izirayd - 02-07-2016 Library for parsing log cash.exe by wizatek. - Have nice speed. - Have function sorts. /* ПарÑер логов Cash.exe By Orion Games © 2016 orionlc.ru Edit Serh (Izirayd). */ #include <fstream> #include <iostream> #define SIZE_STR 32 struct CashElement { int IDLogin; char Login[SIZE_STR]; int IDItem; int Price; }; #define ELEMENT_SIZE 1024 class ItemStats { public: ItemStats() { CountId = 0; // ЧиÑтим маÑÑив Ñлементов for (size_t i = 0; i < ELEMENT_SIZE; i++) { m_ListItemPoint[i].Point = 0; m_ListItemPoint[i].Id = 0; m_ListItemPoint[i].FullPrice = 0; m_ListItemPoint[i].Price = 0; } } // Сортировка по поинтами void SortElement(int* arr, int size) { int tmp, i, j, pos; for (i = 0; i < size; ++i) // i - номер текущего шага { pos = i; tmp = arr[i]; for (j = i + 1; j < size; ++j) // цикл выбора наименьшего Ñлемента { if (arr[j] < tmp) { pos = j; tmp = arr[j]; } } arr[pos] = arr[i]; arr[i] = tmp; // менÑем меÑтами наименьший Ñ a[i] } } void PrintNoSort() { std::cout << "\nPRINT NO SORT"; for (size_t i = 0; i < CountId; i++) std::cout << "\nID: " << m_ListItemPoint[i].Id << " COUNT_POINT: " << m_ListItemPoint[i].Point; } void PrintSort() { std::cout << "\nPRINT SORT USING POINT"; for (size_t i = 0; i < CountId; i++) std::cout << "\nID: " << m_TopItem[i].Id << " COUNT_POINT: " << m_TopItem[i].Point << " PRICE: " << m_TopItem[i].Price << " FULL_PRICE: " << m_TopItem[i].Price * m_TopItem[i].Point; } void PrintSortPrice() { std::cout << "\nPRINT SORT USING PRICE"; for (size_t i = 0; i < CountId; i++) std::cout << "\nID: " << m_TopItemPrice[i].Id << " COUNT_POINT: " << m_TopItemPrice[i].Point << " PRICE: " << m_TopItemPrice[i].Price << " FULL_PRICE: " << m_TopItemPrice[i].FullPrice; } void PrintSortFullPrice() { std::cout << "\nPRINT SORT USING FULL PRICE"; for (size_t i = 0; i < CountId; i++) std::cout << "\nID: " << m_TopItemFullPrice[i].Id << " COUNT_POINT: " << m_TopItemFullPrice[i].Point << " PRICE: " << m_TopItemFullPrice[i].Price << " FULL_PRICE: " << m_TopItemFullPrice[i].FullPrice; } void SortElement() { for (size_t i = 0; i < CountId; i++) m_TopItem[i] = m_ListItemPoint[i]; int i, j, pos; ListItemPoint ListTmp; for (i = 0; i < CountId; ++i) // i - номер текущего шага { pos = i; ListTmp = m_TopItem[i]; for (j = i + 1; j < CountId; ++j) // цикл выбора наименьшего Ñлемента { if (m_TopItem[j].Point < ListTmp.Point) { pos = j; ListTmp = m_TopItem[j]; } } m_TopItem[pos] = m_TopItem[i]; m_TopItem[i] = ListTmp; // менÑем меÑтами наименьший Ñ a[i] } } void SortPrice() { for (size_t i = 0; i < CountId; i++) { m_TopItemPrice[i] = m_ListItemPoint[i]; m_TopItemPrice[i].FullPrice = m_TopItemPrice[i].Point * m_TopItemPrice[i].Price; } int i, j, pos; ListItemPoint ListTmp; for (i = 0; i < CountId; ++i) // i - номер текущего шага { pos = i; ListTmp = m_TopItemPrice[i]; for (j = i + 1; j < CountId; ++j) // цикл выбора наименьшего Ñлемента { if (m_TopItemPrice[j].Price < ListTmp.Price) { pos = j; ListTmp = m_TopItemPrice[j]; } } m_TopItemPrice[pos] = m_TopItemPrice[i]; m_TopItemPrice[i] = ListTmp; // менÑем меÑтами наименьший Ñ a[i] } } void SortFullPrice() { for (size_t i = 0; i < CountId; i++) { m_TopItemFullPrice[i] = m_ListItemPoint[i]; m_TopItemFullPrice[i].FullPrice = m_TopItemFullPrice[i].Point * m_TopItemFullPrice[i].Price; } int i, j, pos; ListItemPoint ListTmp; for (i = 0; i < CountId; ++i) // i - номер текущего шага { pos = i; ListTmp = m_TopItemFullPrice[i]; for (j = i + 1; j < CountId; ++j) // цикл выбора наименьшего Ñлемента { if (m_TopItemFullPrice[j].FullPrice < ListTmp.FullPrice) { pos = j; ListTmp = m_TopItemFullPrice[j]; } } m_TopItemFullPrice[pos] = m_TopItemFullPrice[i]; m_TopItemFullPrice[i] = ListTmp; // менÑем меÑтами наименьший Ñ a[i] } } int ReturnCountPoint(int Id) { int Result = SearchIdElment(Id); if (Result < 0) return -1; return m_ListItemPoint[Result].Point; } void AddPoint(int Id, int Price) { int Result = SearchIdElment(Id); if (Result > -1) { m_ListItemPoint[Result].Point++; m_ListItemPoint[Result].Price = Price; } else NewItem(Id, Price); }; void AddPoint(int Id, int CountPoint, int Price) { int Result = SearchIdElment(Id); if (Result > -1) { m_ListItemPoint[Result].Point += CountPoint; m_ListItemPoint[Result].Price = Price; } else NewItem(Id, CountPoint, Price); }; void NewItem(int Id, int CountPoint, int Price) { m_ListItemPoint[CountId].Id = Id; m_ListItemPoint[CountId].Point += CountPoint; m_ListItemPoint[CountId].Price = Price; CountId++; } void NewItem(int Id, int Price) { m_ListItemPoint[CountId].Id = Id; m_ListItemPoint[CountId].Point++; m_ListItemPoint[CountId].Price = Price; CountId++; } int SearchIdElment(int IdElement) { for (size_t i = 0; i < CountId; i++) if (m_ListItemPoint[i].Id == IdElement) return i; return -1; } struct ListItemPoint{ int Id; int Point; int FullPrice; int Price; }; ListItemPoint m_ListItemPoint[ELEMENT_SIZE]; ListItemPoint m_TopItem[ELEMENT_SIZE]; ListItemPoint m_TopItemPrice[ELEMENT_SIZE]; ListItemPoint m_TopItemFullPrice[ELEMENT_SIZE]; int CountId; }; class Cash { public: Cash() { CountElement = 0; SumPrice = 0; } void OpenFile(const char *NameFile); void BuildStatistic(); int SumPrice; ItemStats m_ItemStats; private: void EditStrSizeSymbol(char *Buffer, int CountSymbol); int EditStrSymbol(char *Buffer, char *Result, char Symbol); void Step(char *Str); void Step(char *Str, int CountSteps); void Parcer(char *Str); CashElement m_CashElement[1024]; int CountElement; }; void Cash::BuildStatistic() { std::cout << "\nStart Add point"; for (int i = 0; i < this->CountElement; i++) { SumPrice += this->m_CashElement[i].Price; m_ItemStats.AddPoint(m_CashElement[i].IDItem, m_CashElement[i].Price); } std::cout << "\nStart Sort"; m_ItemStats.SortElement(); m_ItemStats.SortPrice(); m_ItemStats.SortFullPrice(); m_ItemStats.PrintSort(); m_ItemStats.PrintSortPrice(); m_ItemStats.PrintSortFullPrice(); } void Cash::Step(char *Str, int CountSteps) { for (int i = 0; i < CountSteps; i++) Step(Str); } void Cash::Step(char *Str) { char StrResult[512]; int A = this->EditStrSymbol(Str, StrResult, ':'); if (A < 1) A++; this->EditStrSizeSymbol(Str, A); } // Возвращает количеÑтво Ñимволов в Ñтроке int Cash::EditStrSymbol(char *Buffer, char *Result, char Symbol) { int Len = strlen(Buffer); int i = -1; int iR = 0; int iB = 0; for (i = 0; ((Buffer[i] != Symbol) && (i < Len)); i++) { if (Buffer[i] == ' ') continue; Result[iR] = Buffer[i]; iR++; } Result[iR] = '\0'; return iR; } void Cash::EditStrSizeSymbol(char *Buffer, int CountSymbol) { int Len = strlen(Buffer); for (int i = 0; i < Len - CountSymbol; i++) Buffer[i] = Buffer[i + CountSymbol]; Buffer[Len - CountSymbol] = '\0'; } #define BUYITEM "BUYITEM" void Cash: arcer(char *Str) {char StrResult[512]; Step(Str, 9); EditStrSymbol(Str, StrResult, '>'); if (strcmp(StrResult, BUYITEM) == 0) { Step(Str, 6); EditStrSymbol(Str, StrResult, ':'); m_CashElement[CountElement].IDLogin = atoi(StrResult); Step(Str, 4); EditStrSymbol(Str, m_CashElement[CountElement].Login, ':'); Step(Str, 8); EditStrSymbol(Str, StrResult, ':'); m_CashElement[CountElement].IDItem = atoi(StrResult); Step(Str, 8); EditStrSymbol(Str, StrResult, ':'); m_CashElement[CountElement].Price = atoi(StrResult); CountElement++; } } void Cash::OpenFile(const char *NameFile) { std::fstream Test; char _buf[2000]; Test.open(NameFile, std::ios::in); while (Test.getline(_buf, 512)) { Parcer(_buf); } Test.close(); } int main() { Cash m_Cash; m_Cash.OpenFile("Cash.log"); m_Cash.BuildStatistic(); while (1) { } return 0; } - Izirayd - 02-07-2016 - Izirayd - 02-07-2016 |