[Release] Offline Shop MAX YANG

Indította TheSLESH, 2016-12-11, 13:10:42

2016-12-11, 13:10:42 Utolsó szerkesztés: 2016-12-11, 13:43:40 Szerző: TheSLESH
Sziasztok! Mai nap, sikerült összehoznom a max yangot, az offline boltba, mivel sokan keresitek ezért publikálom is nektek.
Elöszörr is, nyissuk meg a forrásunkat

INDITO RÉSZT NEMSOKÁRA PUBLIKÁLOM HOZZÁ!

common/tables.h

typedef struct SSOfflineShopItemTable

keress rá:
      long lPrice;
cseréld le erre:
   long long llPrice;
   
game/char.cpp

Cseréld le erre
void CHARACTER::OpenMyOfflineShop(const char * c_pszSign, TOfflineShopItemTable * pTable, BYTE bItemCount, BYTE bTime)
ezt
void CHARACTER::OpenMyOfflineShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount, BYTE bTime)




Cseréld le erre
if (GetGold() < static_cast<long long>(g_dwNeedMoney))
ezt
if (GetGold() < static_cast<int>(g_dwNeedMoney))



Cseréld le erre
if ((pTable + i)->price >= GOLD_MAX)
{
ChatPacket(CHAT_TYPE_INFO, "You can't build this offline shop because of the overflow yang!");
return;
}

ezt
if ((pTable + i)->price >= GOLD_MAX - 1)
{
ChatPacket(CHAT_TYPE_INFO, "You can't build this offline shop because of the overflow yang!");
return;
}





Cseréld le erre
int iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%u,%lld,%u", pkItem->GetID(), GetPlayerID(), (pTable + i)->display_pos, pkItem->GetCount(), (pTable + i)->price, pkItem->GetVnum());
ezt
int iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%u,%u,%u", pkItem->GetID(), GetPlayerID(), (pTable + i)->display_pos, pkItem->GetCount(), (pTable + i)->price, pkItem->GetVnum());




char.h


Cseréld le erre
void OpenMyOfflineShop(const char * c_pszSign, TOfflineShopItemTable * pTable, BYTE bItemCount, BYTE bTime);
ezt
void OpenMyOfflineShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount, BYTE bTime);



game/input_main.cpp


Cseréld le erre
COfflineShopManager::instance().AddItem(ch, pTable->bDisplayPos, pTable->bPos, pTable->llPrice);
ezt
COfflineShopManager::instance().AddItem(ch, pTable->bDisplayPos, pTable->bPos, pTable->lPrice);



Cseréld le erre
sys_log(0, "INPUT: %s OFFLINE_CHANGE_PRICE(%lld)", ch->GetName(), pTable->bDisplayPos);
COfflineShopManager::instance().ChangePrice(ch, pTable->bDisplayPos, pTable->llPrice);

ezt
sys_log(0, "INPUT: %s OFFLINE_CHANGE_PRICE (%d)", ch->GetName(), pTable->bDisplayPos);
COfflineShopManager::instance().ChangePrice(ch, pTable->bDisplayPos, pTable->lPrice);




Cseréld le erre
int iExtraLen = p->bCount * sizeof(TOfflineShopItemTable);
ezt
int iExtraLen = p->bCount * sizeof(TShopItemTable);



Cseréld le erre
ch->OpenMyOfflineShop(p->szSign, (TOfflineShopItemTable *)(c_pData + sizeof(TPacketCGMyOfflineShop)), p->bCount, p->bTime);
ezt
ch->OpenMyOfflineShop(p->szSign, (TShopItemTable *)(c_pData + sizeof(TPacketCGMyOfflineShop)), p->bCount, p->bTime);



game/offlineshop_manager.cpp

Cseréld le erre
void COfflineShopManager::AddItem(LPCHARACTER ch, BYTE bDisplayPos, BYTE bPos, long long llPrice)
ezt
void COfflineShopManager::AddItem(LPCHARACTER ch, BYTE bDisplayPos, BYTE bPos, int iPrice)



Cseréld le erre
if (llPrice >= GOLD_MAX)
{
ch->ChatPacket(CHAT_TYPE_INFO, "You can't add this item because of the overflow gold max!");
return;
}

ezt
if (iPrice >= GOLD_MAX - 1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "You can't add this item because of the overflow gold max!");
return;
}




Cseréld le erre
int iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%u,%lld,%u", pkItem->GetID(), ch->GetPlayerID(), bDisplayPos, pkItem->GetCount(), llPrice, pkItem->GetVnum());
ezt
int iUpdateLen = snprintf(szValues, sizeof(szValues), "%u,%u,%d,%u,%d,%u", pkItem->GetID(), ch->GetPlayerID(), bDisplayPos, pkItem->GetCount(), iPrice, pkItem->GetVnum());



Cseréld le erre
void COfflineShopManager::ChangePrice(LPCHARACTER ch, BYTE bPos, long long llPrice)
ezt
void COfflineShopManager::ChangePrice(LPCHARACTER ch, BYTE bPos, DWORD dwPrice)



Cseréld le erre
if (llPrice >= GOLD_MAX)
{
ch->ChatPacket(CHAT_TYPE_INFO, "You can't change price of the item because of the overflow gold max!");
return;
}

ezt
if (dwPrice >= GOLD_MAX - 1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "You can't change price of the item because of the overflow gold max!");
return;
}




Cseréld le erre
pkOfflineShop->BroadcastUpdatePrice(bPos, llPrice);
ezt
pkOfflineShop->BroadcastUpdatePrice(bPos, dwPrice);


Cseréld le erre
DBManager::instance().DirectQuery("UPDATE %soffline_shop_item SET price = %lld WHERE owner_id = %u and pos = %d", get_table_postfix(), llPrice, ch->GetPlayerID(), bPos);
ezt
DBManager::instance().DirectQuery("UPDATE %soffline_shop_item SET price = %u WHERE owner_id = %u and pos = %d", get_table_postfix(), dwPrice, ch->GetPlayerID(), bPos);



Cseréld le erre
bool isOverFlow = static_cast<long long>(ch->GetGold()) + llRequiredMoney > GOLD_MAX - 1 ? true : false;
ezt
bool isOverFlow = ch->GetGold() + llRequiredMoney > GOLD_MAX - 1 ? true : false;


offlineshop_manager.h

Cseréld le erre
void AddItem(LPCHARACTER ch, BYTE bDisplayPos, BYTE bPos, long long llPrice);
ezt
void AddItem(LPCHARACTER ch, BYTE bDisplayPos, BYTE bPos, int iPrice);


Cseréld le erre
void ChangePrice(LPCHARACTER ch, BYTE bPos, long long llPrice);
ezt
void ChangePrice(LPCHARACTER ch, BYTE bPos, DWORD dwPrice);


offline_shop.h

Cseréld le erre
void BroadcastUpdatePrice(BYTE bPos, long long llPrice);
ezt
void BroadcastUpdatePrice(BYTE bPos, DWORD dwPrice);
   


packet.h

Cseréld le erre
struct packet_offline_shop_item items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
ezt
struct packet_shop_item items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];


game/offline_shop.cpp

Cseréld le erre
long long llPrice = 0;
ezt
DWORD dwPrice = 0;


Cseréld le erre
str_to_number(llPrice, row[3]);
ezt
str_to_number(dwPrice, row[3]);


Cseréld le erre
if (ch->GetGold() < static_cast<long long>(llPrice))
{
sys_log(1, "OfflineShop::Buy : Not enough money : %s has %u, price %lld", ch->GetName(), ch->GetGold(), llPrice);
return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
}

ezt
if (ch->GetGold() < static_cast<int>(dwPrice))
{
sys_log(1, "OfflineShop::Buy : Not enough money : %s has %u, price %u", ch->GetName(), ch->GetGold(), dwPrice);
return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
}



Cseréld le erre
sys_log(0, "OFFLINE_SHOP: BUY: name %s %s(x %u):%u price %lld", ch->GetName(), pItem->GetName(), pItem->GetCount(), pItem->GetID(), llPrice);
ezt
sys_log(0, "OFFLINE_SHOP: BUY: name %s %s(x %u):%u price %u", ch->GetName(), pItem->GetName(), pItem->GetCount(), pItem->GetID(), dwPrice);


Cseréld le erre
bool bIsOverFlow = tch->GetGold() + llPrice > GOLD_MAX - 1 ? true : false;
ezt
bool bIsOverFlow = tch->GetGold() + dwPrice > GOLD_MAX - 1 ? true : false;


Cseréld le erre
DBManager::instance().Query("UPDATE player.player SET money = money + %lld WHERE id = %u", llPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
ezt
DBManager::instance().Query("UPDATE player.player SET money = money + %u WHERE id = %u", dwPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());


Cseréld le erre
tch->PointChange(POINT_GOLD, llPrice, false);
ezt
tch->PointChange(POINT_GOLD, dwPrice, false);


Cseréld le erre
DBManager::instance().Query("UPDATE player.player SET money = money + %lld WHERE id = %u", llPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
ezt
    DBManager::instance().Query("UPDATE player.player SET money = money + %u WHERE id = %u", dwPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());


Cseréld le erre
DBManager::instance().Query("UPDATE player.player SET money = money + %lld WHERE id = %u", llPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
ezt
DBManager::instance().Query("UPDATE player.player SET money = money + %u WHERE id = %u", dwPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());


Cseréld le erre   
bool bIsOverFlow = pkCCI->pkDesc->GetCharacter()->GetGold() + llPrice > GOLD_MAX - 1 ? true : false;
if (bIsOverFlow)
DBManager::instance().Query("UPDATE player.player SET money = money + %lld WHERE id = %u", llPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
else
pkCCI->pkDesc->GetCharacter()->PointChange(POINT_GOLD, llPrice, false);

ezt
bool bIsOverFlow = pkCCI->pkDesc->GetCharacter()->GetGold() + dwPrice > GOLD_MAX - 1 ? true : false;
if (bIsOverFlow)
DBManager::instance().Query("UPDATE player.player SET money = money + %u WHERE id = %u", dwPrice, ch->GetOfflineShopOwner()->GetOfflineShopRealOwner());
else
pkCCI->pkDesc->GetCharacter()->PointChange(POINT_GOLD, dwPrice, false);



Cseréld le erre
ch->PointChange(POINT_GOLD, -llPrice, false);
ezt
ch->PointChange(POINT_GOLD, -dwPrice, false);


Cseréld le erre
TPacketGCOfflineShopUpdateItem pack2;
ezt
TPacketGCShopUpdateItem pack2;


Üzenet összefésülés: 2016-12-11, 13:42:06

Az ember csak fiatalon találhat ki igazán új dolgokat. Utána már túl tapasztalt, túl híres (...) és túl ostoba.

Mivel átlépte a 20 ezer karaktert ezért külön topicba rakom, egy mod majd tegye össze a kettőt légyszives!

*******************************************************************
INDÍTÓ RÉSZ


userinterface/packet.h

Cseréld le erre
struct packet_offline_shop_item items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
ezt
struct packet_shop_item items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];


userinterface/PythonNetworkStream.h

Cseréld le erre
bool SendChangePriceOfflineShopItem(BYTE bPos, long long llPrice);
bool SendAddOfflineShopItem(BYTE bDisplayPos, BYTE bPos, long long llPrice);

ezt
bool SendChangePriceOfflineShopItem(BYTE bPos, int iPrice);
bool SendAddOfflineShopItem(BYTE bDisplayPos, BYTE bPos, long lPrice);

      

Cseréld le erre
bool SendBuildOfflineShopPacket(const char * c_szName, const std::vector<TOfflineShopItemTable> & c_rSellingItemStock, BYTE bTime);
ezt
bool SendBuildOfflineShopPacket(const char * c_szName, const std::vector<TShopItemTable> & c_rSellingItemStock, BYTE bTime);


userinterface/PythonNetworkStreamModule.cpp

Cseréld le erre
long long llPrice;
ezt
int iPrice;



Cseréld le erre
if (!PyTuple_GetLongLong(poArgs, 1, &llPrice))
return Py_BuildException();

ezt
if (!PyTuple_GetInteger(poArgs, 1, &iPrice))
return Py_BuildException();



Cseréld le erre
rkNetStream.SendChangePriceOfflineShopItem(bPos, llPrice);
ezt
rkNetStream.SendChangePriceOfflineShopItem(bPos, iPrice);


Cseréld le erre
long long llPrice;
ezt   
int iPrice;


Cseréld le erre
if (!PyTuple_GetLongLong(poArgs, 2, &llPrice))
return Py_BuildException();

ezt
if (!PyTuple_GetInteger(poArgs, 2, &iPrice))
return Py_BuildException();



Cseréld le erre
rkNetStream.SendAddOfflineShopItem(bDisplayPos, bPos, llPrice);
ezt   
rkNetStream.SendAddOfflineShopItem(bDisplayPos, bPos, iPrice);


userinterface/PythonNetworkStreamPhaseGame.cpp

Cseréld le erre
bool CPythonNetworkStream::SendBuildOfflineShopPacket(const char * c_szName, const std::vector<TOfflineShopItemTable> & c_rSellingItemStock, BYTE bTime)
ezt
bool CPythonNetworkStream::SendBuildOfflineShopPacket(const char * c_szName, const std::vector<TShopItemTable> & c_rSellingItemStock, BYTE bTime)



Cseréld le erre
TPacketCGMyOfflineShop packet;
packet.bHeader = HEADER_CG_MY_OFFLINE_SHOP;
strncpy(packet.szSign, c_szName, SHOP_SIGN_MAX_LEN);
packet.bCount = c_rSellingItemStock.size();
packet.bTime = bTime;
if (!Send(sizeof(packet), &packet))
return false;

for (std::vector<TOfflineShopItemTable>::const_iterator itor = c_rSellingItemStock.begin(); itor < c_rSellingItemStock.end(); ++itor)
{
const TOfflineShopItemTable & c_rItem = *itor;
if (!Send(sizeof(c_rItem), &c_rItem))
return false;
}

ezt
TPacketCGMyOfflineShop packet;
packet.bHeader = HEADER_CG_MY_OFFLINE_SHOP;
strncpy(packet.szSign, c_szName, SHOP_SIGN_MAX_LEN);
packet.bCount = c_rSellingItemStock.size();
packet.bTime = bTime;
if (!Send(sizeof(packet), &packet))
return false;

for (std::vector<TShopItemTable>::const_iterator itor = c_rSellingItemStock.begin(); itor < c_rSellingItemStock.end(); ++itor)
{
const TShopItemTable & c_rItem = *itor;
if (!Send(sizeof(c_rItem), &c_rItem))
return false;
}



Cseréld le erre
std::vector<int> vecBuffer;
ezt
std::vector<char> vecBuffer;


Cseréld le erre
TPacketGCOfflineShopStart * pShopStartPacket = (TPacketGCOfflineShopStart *)&vecBuffer[1];
ezt
TPacketGCOfflineShopStart * pShopStartPacket = (TPacketGCOfflineShopStart *)&vecBuffer[4];


Cseréld le erre
TPacketGCOfflineShopStart * pShopStartPacket = (TPacketGCOfflineShopStart *)&vecBuffer[1];
ezt
TPacketGCOfflineShopStart * pShopStartPacket = (TPacketGCOfflineShopStart *)&vecBuffer[4];


userinterface/PythonNetworkStreamPhaseGameItem.cpp

Cseréld le erre
bool CPythonNetworkStream::SendAddOfflineShopItem(BYTE bDisplayPos, BYTE bPos, long long llPrice)
ezt
bool CPythonNetworkStream::SendAddOfflineShopItem(BYTE bDisplayPos, BYTE bPos, long lPrice)


Cseréld le erre
pTable.lPrice = llPrice;
ezt
pTable.lPrice = lPrice;


Cseréld le erre
bool CPythonNetworkStream::SendChangePriceOfflineShopItem(BYTE bPos, long long llPrice)[/code]
ezt
bool CPythonNetworkStream::SendChangePriceOfflineShopItem(BYTE bPos, int iPrice)


Cseréld le erre
pTable.lPrice = llPrice;

ezt
pTable.lPrice = iPrice;


userinterface/PythonShop.cpp

Cseréld le erre
void CPythonShop::SetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData & c_rShopItemData)
ezt
void CPythonShop::SetOfflineShopItemData(DWORD dwIndex, const TShopItemData & c_rShopItemData)


Cseréld le erre
void CPythonShop::SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData & c_rShopItemData)
ezt
void CPythonShop::SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TShopItemData & c_rShopItemData)


Cseréld le erre
BOOL CPythonShop::GetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData ** c_ppItemData)
ezt
BOOL CPythonShop::GetOfflineShopItemData(DWORD dwIndex, const TShopItemData ** c_ppItemData)


Cseréld le erre
BOOL CPythonShop::GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData ** c_ppItemData)
ezt
BOOL CPythonShop::GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TShopItemData ** c_ppItemData)


Cseréld le erre
void CPythonShop::AddOfflineShopItemStock(TItemPos ItemPos, BYTE dwDisplayPos, long long llPrice)
ezt
void CPythonShop::AddOfflineShopItemStock(TItemPos ItemPos, BYTE dwDisplayPos, DWORD dwPrice)


Cseréld le erre
TOfflineShopItemTable SellingItem;
ezt
TShopItemTable SellingItem;


Cseréld le erre
SellingItem.price = llPrice;
ezt
SellingItem.price = dwPrice;


Cseréld le erre
long long CPythonShop::GetOfflineShopItemPrice(TItemPos ItemPos)
ezt
int CPythonShop::GetOfflineShopItemPrice(TItemPos ItemPos)


Cseréld le erre
TOfflineShopItemTable & rShopItemTable = itor->second;
ezt
TShopItemTable & rShopItemTable = itor->second;


Cseréld le erre
std::vector<TOfflineShopItemTable> ItemStock;
ItemStock.reserve(m_OfflineShopItemStock.size());

TOfflineShopItemStock::iterator itor = m_OfflineShopItemStock.begin();
for (; itor != m_OfflineShopItemStock.end(); ++itor)
{
ItemStock.push_back(itor->second);
}

std::sort(ItemStock.begin(), ItemStock.end(), OfflineShopItemStockSortFunc());

CPythonNetworkStream::Instance().SendBuildOfflineShopPacket(c_szName, ItemStock, bTime);

ezt
std::vector<TShopItemTable> ItemStock;
ItemStock.reserve(m_OfflineShopItemStock.size());

TOfflineShopItemStock::iterator itor = m_OfflineShopItemStock.begin();
for (; itor != m_OfflineShopItemStock.end(); ++itor)
{
ItemStock.push_back(itor->second);
}

std::sort(ItemStock.begin(), ItemStock.end(), ItemStockSortFunc());

CPythonNetworkStream::Instance().SendBuildOfflineShopPacket(c_szName, ItemStock, bTime);



Cseréld le erre
const TOfflineShopItemData * c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return PyLong_FromLongLong(c_pItemData->price);

ezt
const TShopItemData * c_pItemData;
if (CPythonShop::Instance().GetOfflineShopItemData(iIndex, &c_pItemData))
return Py_BuildValue("i", c_pItemData->price);



Cseréld le erre
long long llPrice;
if (!PyTuple_GetLongLong(poArgs, 3, &llPrice))
return Py_BuildException();

CPythonShop::Instance().AddOfflineShopItemStock(TItemPos(bItemWindowType, wItemSlotIndex), iDisplaySlotIndex, llPrice);

ezt
int iPrice;
if (!PyTuple_GetInteger(poArgs, 3, &iPrice))
return Py_BuildException();

CPythonShop::Instance().AddOfflineShopItemStock(TItemPos(bItemWindowType, wItemSlotIndex), iDisplaySlotIndex, iPrice);



Cseréld le erre
return PyLong_FromLongLong(CPythonShop::Instance().GetOfflineShopItemPrice(TItemPos(bItemWindowType, wItemSlotIndex)));
ezt
int iValue = CPythonShop::Instance().GetOfflineShopItemPrice(TItemPos(bItemWindowType, wItemSlotIndex));
return Py_BuildValue("i", iValue);




userinterface/PythonShop.h

Cseréld le erre
void SetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData & c_rShopItemData);
BOOL GetOfflineShopItemData(DWORD dwIndex, const TOfflineShopItemData ** c_ppItemData);

void SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData & c_rShopItemData);
BOOL GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TOfflineShopItemData ** c_ppItemData);

ezt
void SetOfflineShopItemData(DWORD dwIndex, const TShopItemData & c_rShopItemData);
BOOL GetOfflineShopItemData(DWORD dwIndex, const TShopItemData ** c_ppItemData);

void SetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TShopItemData & c_rShopItemData);
BOOL GetOfflineShopItemData(BYTE tabIdx, DWORD dwSlotPos, const TShopItemData ** c_ppItemData);



Cseréld le erre
void AddOfflineShopItemStock(TItemPos ItemPos, BYTE byDisplayPos, long long llPrice);
ezt
void AddOfflineShopItemStock(TItemPos ItemPos, BYTE byDisplayPos, DWORD dwPrice);

Cseréld le erre
long long GetOfflineShopItemPrice(TItemPos ItemPos);
ezt
int GetOfflineShopItemPrice(TItemPos ItemPos);


Cseréld le erre
TOfflineShopItemData items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];
ezt
TShopItemData items[OFFLINE_SHOP_HOST_ITEM_MAX_NUM];


Cseréld le erre
typedef std::map<TItemPos, TOfflineShopItemTable> TOfflineShopItemStock;
ezt
typedef std::map<TItemPos, TShopItemTable> TOfflineShopItemStock;

Az ember csak fiatalon találhat ki igazán új dolgokat. Utána már túl tapasztalt, túl híres (...) és túl ostoba.