Management Karbust 4884 Posted July 21, 2018 Management Share Posted July 21, 2018 Hello, Today I realized I had a bug on the transmutation system (change look). Instead the game discount 1kkk on the gold (price I set) it gives exactly 3.294.967.296 yang every time... The function that discounts the money: void CHARACTER::RefineClMaterials() { LPITEM * pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); if (!pkItemMaterial[0]) return; else if (!pkItemMaterial[1]) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] Please submit the item you want to transmute.")); return; } DWORD dwPrice = CL_TRANSMUTATION_PRICE; if (GetGold() < dwPrice) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You don't have enough Yang.")); return; } DWORD dwVnum = pkItemMaterial[1]->GetVnum(); PointChange(POINT_GOLD, -dwPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -dwPrice); ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "TRANSMUTED (SUCCESSFULLY)"); pkItemMaterial[0]->SetTransmutation(dwVnum, true); ClearClWindowMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketChangeLook sPacket; sPacket.header = HEADER_GC_CL; sPacket.subheader = CL_SUBHEADER_REFINE; sPacket.dwCost = 0; sPacket.bPos = 0; sPacket.tPos = tPos; GetDesc()->Packet(&sPacket, sizeof(TPacketChangeLook)); } The POINT_GOLD: case POINT_GOLD: { long long nTotalMoney = GetGold() + amount; if (nTotalMoney > yang_max) { sys_err("[OVERFLOW_GOLD] maximum %lld OriGold %lld AddedGold %lld id %u Name %s ", yang_max, GetGold(), amount, GetPlayerID(), GetName()); LogManager::instance().CharLog(this, GetGold() + amount, "OVERFLOW_GOLD", ""); nTotalMoney = GetGold(); amount = 0; SetGold(yang_max); return; } // û�ҳ⺸ȣ if (LC_IsNewCIBN() && amount > 0) { if (IsOverTime(OT_NONE)) { dev_log(LOG_DEB0, "<GOLD_LOG> %s = NONE", GetName()); } else if (IsOverTime(OT_3HOUR)) { amount = (amount / 2); dev_log(LOG_DEB0, "<GOLD_LOG> %s = 3HOUR", GetName()); } else if (IsOverTime(OT_5HOUR)) { amount = 0; dev_log(LOG_DEB0, "<GOLD_LOG> %s = 5HOUR", GetName()); } } SetGold(GetGold() + amount); val = GetGold(); } break; Can anyone help me out? Link to comment Share on other sites More sharing options...
ManiacRobert 429 Posted July 22, 2018 Share Posted July 22, 2018 DWORD dwPrice = CL_TRANSMUTATION_PRICE; to long long dwPrice = CL_TRANSMUTATION_PRICE; 1 Link to comment Share on other sites More sharing options...
Management Karbust 4884 Posted July 22, 2018 Author Management Share Posted July 22, 2018 1 hour ago, ManiacRobert said: DWORD dwPrice = CL_TRANSMUTATION_PRICE; to long long dwPrice = CL_TRANSMUTATION_PRICE; DWORD's size is 4294967295 (around 4,29kkk) my price is just 1kkk, I believe it's correct, right? But I will try it anyway... Thanks for your answer Link to comment Share on other sites More sharing options...
Premium TAUMP 839 Posted July 22, 2018 Premium Share Posted July 22, 2018 4 hours ago, charparodar said: DWORD's size is 4294967295 (around 4,29kkk) my price is just 1kkk, I believe it's correct, right? But I will try it anyway... Thanks for your answer PointChange(POINT_GOLD, -dwPrice); to PointChange(POINT_GOLD, -static_cast<long long>(dwPrice)); 1 Link to comment Share on other sites More sharing options...
Management Karbust 4884 Posted July 22, 2018 Author Management Share Posted July 22, 2018 (edited) Thanks, it worked (I used @ManiacRobert's option) But I have another bugs that isn't solved... Even though I have CL_TRANSMUTATION_PRICE = 1000000000 (1kkk) ingame it only shows 10000000 (10kk) but it removes the 1kkk correctly... I already changed the packets and everything price related to long long but it keeps not showing the correct amount... locale_game.txt CHANGE_LOOK_COST Custo da transmutação: %s Yang uichangelook.py self.cost.SetText(localeInfo.CHANGE_LOOK_COST % (self.NumberToMoneyString(changelook.GetCost()))) PythonChangeLook.cpp PyObject * GetClCost(PyObject * poSelf, PyObject * poArgs) { return Py_BuildValue("L", CPythonChangeLook::Instance().GetCost()); } { "GetCost", GetClCost, METH_VARARGS }, PythonChangeLook.h class CPythonChangeLook : public CSingleton<CPythonChangeLook> { public: long long dwCost; public: long long GetCost() { return dwCost; } void SetCost(long long dwCostR) { dwCost = dwCostR; } PythonNetworkStreamPhaseGame.cpp TPacketChangeLook sPacket; CPythonChangeLook::Instance().SetCost(sPacket.dwCost); packet.h typedef struct SPacketChangeLook { BYTE header; BYTE subheader; long long dwCost; BYTE bPos; TItemPos tPos; } TPacketChangeLook; char.cpp TPacketChangeLook sPacket; sPacket.dwCost = bOpen == true ? CL_TRANSMUTATION_PRICE : 0; Does anyone know what is wrong? Thank you Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Premium TAUMP 839 Posted July 22, 2018 Premium Share Posted July 22, 2018 PyObject * GetClCost(PyObject * poSelf, PyObject * poArgs) { return PyLong_FromLongLong(CPythonChangeLook::Instance().GetCost()); } PythonUtils.cpp bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret) { if (pos >= PyTuple_Size(poArgs)) return false; PyObject * poItem = PyTuple_GetItem(poArgs, pos); if (!poItem) return false; *ret = PyLong_AsLongLong(poItem); return true; } .h bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret); 1 Link to comment Share on other sites More sharing options...
Management Karbust 4884 Posted July 22, 2018 Author Management Share Posted July 22, 2018 7 minutes ago, .T4Ump said: PyObject * GetClCost(PyObject * poSelf, PyObject * poArgs) { return PyLong_FromLongLong(CPythonChangeLook::Instance().GetCost()); } PythonUtils.cpp bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret) { if (pos >= PyTuple_Size(poArgs)) return false; PyObject * poItem = PyTuple_GetItem(poArgs, pos); if (!poItem) return false; *ret = PyLong_AsLongLong(poItem); return true; } .h bool PyTuple_GetLongLong(PyObject* poArgs, int pos, long long* ret); Nothing changed Keeps saying it's 10kk Link to comment Share on other sites More sharing options...
Management Karbust 4884 Posted July 22, 2018 Author Management Share Posted July 22, 2018 Working now locale_game.txt CHANGE_LOOK_COST Custo da transmutação: %s uichangelook.py def NumberToMoneyString(self, n) : if n <= 0 : return "0 %s" % (localeInfo.MONETARY_UNIT0) return "%s %s" % ('.'.join([ i-3<0 and str(n)[:i] or str(n)[i-3:i] for i in range(len(str(n))%3, len(str(n))+1, 3) if i ]), localeInfo.MONETARY_UNIT0) It was a problem with this function. The original function: def NumberToMoneyString(self, number): number = str(number) strNumber = "%s" % (','.join([number[::-1][k : k + 3][::-1] for k in xrange(len(number)+1, -1, -3)])) strNumber = strNumber[1:] return "%s" % (strNumber) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now