c++ 6. kő foglalat korrektül

Indította Samurai, 2016-07-12, 09:28:47

2016-07-12, 09:28:47 Utolsó szerkesztés: 2016-07-17, 08:59:17 Szerző: Samurai
Mivel sokkalta túllépte volna a 20.000 karaktert egy txt-be megtaláljátok a dolgokat!

Sok sikert, és jelezzetek vissza a működésével kapcsolatban!


Csatolmány.

1-2 dolgot elfelejtettem átírni. tessék

cache.cpp

", %lu, %lu, %lu", p->alSockets[0], p->alSockets[1], p->alSockets[2], p->alSockets[3], p->alSockets[4], p->alSockets[5]);


csere erre:

", %lu, %lu, %lu, %lu, %lu, %lu", p->alSockets[0], p->alSockets[1], p->alSockets[2], p->alSockets[3], p->alSockets[4], p->alSockets[5]);


Client manager.cpp

ezt:

void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
{
TPlayerItem * p = (TPlayerItem *) c_pData;

// â°í¸é Äł˝¬ÇĎÁö ľĘ°í, Äł˝¬żˇ ŔÖ´ř °Íµµ »©ąö·Áľß ÇŃ´Ů.
// auctionŔş ŔĚ ·çĆ®¸¦ ŸÁö ľĘľĆľß ÇŃ´Ů. EnrollInAuctionŔ» ŸľßÇŃ´Ů.

if (p->window == SAFEBOX || p->window == MALL)
{
CItemCache * c = GetItemCache(p->id);

if (c)
{
TItemCacheSetPtrMap::iterator it = m_map_pkItemCacheSetPtr.find(c->Get()->owner);

if (it != m_map_pkItemCacheSetPtr.end())
{
if (g_test_server)
sys_log(0, "ITEM_CACHE: safebox owner %u id %u", c->Get()->owner, c->Get()->id);

it->second->erase(c);
}

m_map_itemCache.erase(p->id);

delete c;
}
char szQuery[512];

snprintf(szQuery, sizeof(szQuery),
"REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, "
"attrtype0, attrvalue0, "
"attrtype1, attrvalue1, "
"attrtype2, attrvalue2, "
"attrtype3, attrvalue3, "
"attrtype4, attrvalue4, "
"attrtype5, attrvalue5, "
"attrtype6, attrvalue6) "
"VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
GetTablePostfix(),
p->id,
p->owner,
p->window,
p->pos,
p->count,
p->vnum,
p->alSockets[0],
p->alSockets[1],
p->alSockets[2],
p->aAttr[0].bType, p->aAttr[0].sValue,
p->aAttr[1].bType, p->aAttr[1].sValue,
p->aAttr[2].bType, p->aAttr[2].sValue,
p->aAttr[3].bType, p->aAttr[3].sValue,
p->aAttr[4].bType, p->aAttr[4].sValue,
p->aAttr[5].bType, p->aAttr[5].sValue,
p->aAttr[6].bType, p->aAttr[6].sValue);

CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_SAVE, pkPeer->GetHandle(), NULL);
}
#ifdef __AUCTION__
else if (p->window == AUCTION)
{
sys_err("invalid window. how can you enter this route?");
return ;
}
#endif
else
{
if (g_test_server)
sys_log(0, "QUERY_ITEM_SAVE => PutItemCache() owner %d id %d vnum %d ", p->owner, p->id, p->vnum);

PutItemCache(p);
}
}


Erre:

void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
{
TPlayerItem * p = (TPlayerItem *) c_pData;

// â°í¸é Äł˝¬ÇĎÁö ľĘ°í, Äł˝¬żˇ ŔÖ´ř °Íµµ »©ąö·Áľß ÇŃ´Ů.
// auctionŔş ŔĚ ·çĆ®¸¦ ŸÁö ľĘľĆľß ÇŃ´Ů. EnrollInAuctionŔ» ŸľßÇŃ´Ů.

if (p->window == SAFEBOX || p->window == MALL)
{
CItemCache * c = GetItemCache(p->id);

if (c)
{
TItemCacheSetPtrMap::iterator it = m_map_pkItemCacheSetPtr.find(c->Get()->owner);

if (it != m_map_pkItemCacheSetPtr.end())
{
if (g_test_server)
sys_log(0, "ITEM_CACHE: safebox owner %u id %u", c->Get()->owner, c->Get()->id);

it->second->erase(c);
}

m_map_itemCache.erase(p->id);

delete c;
}
char szQuery[512];

snprintf(szQuery, sizeof(szQuery),
"REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, socket3, socket4, socket5, "
"attrtype0, attrvalue0, "
"attrtype1, attrvalue1, "
"attrtype2, attrvalue2, "
"attrtype3, attrvalue3, "
"attrtype4, attrvalue4, "
"attrtype5, attrvalue5, "
"attrtype6, attrvalue6) "
"VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
GetTablePostfix(),
p->id,
p->owner,
p->window,
p->pos,
p->count,
p->vnum,
p->alSockets[0],
p->alSockets[1],
p->alSockets[2],
p->alSockets[3],
p->alSockets[4],
p->alSockets[5],
p->aAttr[0].bType, p->aAttr[0].sValue,
p->aAttr[1].bType, p->aAttr[1].sValue,
p->aAttr[2].bType, p->aAttr[2].sValue,
p->aAttr[3].bType, p->aAttr[3].sValue,
p->aAttr[4].bType, p->aAttr[4].sValue,
p->aAttr[5].bType, p->aAttr[5].sValue,
p->aAttr[6].bType, p->aAttr[6].sValue);

CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_SAVE, pkPeer->GetHandle(), NULL);
}
#ifdef __AUCTION__
else if (p->window == AUCTION)
{
sys_err("invalid window. how can you enter this route?");
return ;
}
#endif
else
{
if (g_test_server)
sys_log(0, "QUERY_ITEM_SAVE => PutItemCache() owner %d id %d vnum %d ", p->owner, p->id, p->vnum);

PutItemCache(p);
}
}


Indító rész:


gamelib/itemdata.h

ezt:
ITEM_SOCKET_MAX_NUM = 3,

erre:
ITEM_SOCKET_MAX_NUM = 6,

Userinterface/pythonchatmodule.cpp

PyObject * chatGetLinkFromHyperlink(PyObject * poSelf, PyObject * poArgs)
{
char * szHyperlink;

if (!PyTuple_GetString(poArgs, 0, &szHyperlink))
return Py_BuildException();

std::string stHyperlink(szHyperlink);
std::vector<std::string> results;

split_string(stHyperlink, ":", results, false);

// item:vnum:flag:socket0:socket1:socket2
if (0 == results[0].compare("item"))
{
if (results.size() < 6)
return Py_BuildValue("s", "");

CItemData * pItemData = NULL;

if (CItemManager::Instance().GetItemDataPointer(htoi(results[1].c_str()), &pItemData))
{
char buf[1024] = { 0 };
char itemlink[256];
int len;
bool isAttr = false;

len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x:%x:%x:%x",
htoi(results[1].c_str()),
htoi(results[2].c_str()),
htoi(results[3].c_str()),
htoi(results[4].c_str()),
htoi(results[5].c_str()));

if (results.size() >= 8)
{
for (int i = 6; i < results.size(); i += 2)
{
len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d",
htoi(results[i].c_str()),
atoi(results[i+1].c_str()));
isAttr = true;
}
}

if (isAttr)
//"item:ąřČŁ:ÇĂ·ˇ±×:ĽŇÄĎ0:ĽŇÄĎ1:ĽŇÄĎ2"
snprintf(buf, sizeof(buf), "|cffffc700|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
else
snprintf(buf, sizeof(buf), "|cfff1e6c0|H%s|h[%s]|h|r", itemlink, pItemData->GetName());

return Py_BuildValue("s", buf);
}
}

return Py_BuildValue("s", "");
}


erre:

PyObject * chatGetLinkFromHyperlink(PyObject * poSelf, PyObject * poArgs)
{
char * szHyperlink;

if (!PyTuple_GetString(poArgs, 0, &szHyperlink))
return Py_BuildException();

std::string stHyperlink(szHyperlink);
std::vector<std::string> results;

split_string(stHyperlink, ":", results, false);

// item:vnum:flag:socket0:socket1:socket2:socket3:socket4:socket5
if (0 == results[0].compare("item"))
{
if (results.size() < 9)
return Py_BuildValue("s", "");

CItemData * pItemData = NULL;

if (CItemManager::Instance().GetItemDataPointer(htoi(results[1].c_str()), &pItemData))
{
char buf[1024] = { 0 };
char itemlink[256];
int len;
bool isAttr = false;

len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x:%x:%x:%x:%x:%x:%x",
htoi(results[1].c_str()),
htoi(results[2].c_str()),
htoi(results[3].c_str()),
htoi(results[4].c_str()),
htoi(results[5].c_str()),
htoi(results[6].c_str()),
htoi(results[7].c_str()),
htoi(results[8].c_str()));

if (results.size() >= 11)
{
for (int i = 9; i < results.size(); i += 2)
{
len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d",
htoi(results[i].c_str()),
atoi(results[i+1].c_str()));
isAttr = true;
}
}

if (isAttr)
//"item:1oEL:ÇA·!±×:1OÄI0:1OÄI1:1OÄI2"
snprintf(buf, sizeof(buf), "|cffffc700|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
else
snprintf(buf, sizeof(buf), "|cfff1e6c0|H%s|h[%s]|h|r", itemlink, pItemData->GetName());

return Py_BuildValue("s", buf);
}
}

return Py_BuildValue("s", "");
}


és végül az utolsó lépés:

userinterface/pythonplayermodule.cpp

ez:

PyObject * playerGetItemLink(PyObject * poSelf, PyObject * poArgs)
{
TItemPos Cell;

switch (PyTuple_Size(poArgs))
{
case 1:
if (!PyTuple_GetInteger(poArgs, 0, &Cell.cell))
return Py_BuildException();
break;
case 2:
if (!PyTuple_GetByte(poArgs, 0, &Cell.window_type))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &Cell.cell))
return Py_BuildException();
break;
default:
return Py_BuildException();
}
const TItemData * pPlayerItem = CPythonPlayer::Instance().GetItemData(Cell);
CItemData * pItemData = NULL;
char buf[1024];

if (pPlayerItem && CItemManager::Instance().GetItemDataPointer(pPlayerItem->vnum, &pItemData))
{
char itemlink[256];
int len;
bool isAttr = false;

len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x:%x:%x:%x",
pPlayerItem->vnum, pPlayerItem->flags,
pPlayerItem->alSockets[0], pPlayerItem->alSockets[1], pPlayerItem->alSockets[2]);

for (int i = 0; i < ITEM_ATTRIBUTE_SLOT_MAX_NUM; ++i)
if (pPlayerItem->aAttr[i].bType != 0)
{
len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d",
pPlayerItem->aAttr[i].bType, pPlayerItem->aAttr[i].sValue);
isAttr = true;
}


if( GetDefaultCodePage() == CP_ARABIC ) {
if (isAttr)
//"item:ąřČŁ:ÇĂ·ˇ±×:ĽŇÄĎ0:ĽŇÄĎ1:ĽŇÄĎ2"
snprintf(buf, sizeof(buf), " |h|r[%s]|cffffc700|H%s|h", pItemData->GetName(), itemlink);
else
snprintf(buf, sizeof(buf), " |h|r[%s]|cfff1e6c0|H%s|h", pItemData->GetName(), itemlink);
} else {
if (isAttr)
//"item:ąřČŁ:ÇĂ·ˇ±×:ĽŇÄĎ0:ĽŇÄĎ1:ĽŇÄĎ2"
snprintf(buf, sizeof(buf), "|cffffc700|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
else
snprintf(buf, sizeof(buf), "|cfff1e6c0|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
}
}
else
buf[0] = '\0';

return Py_BuildValue("s", buf);
}


Erre:

PyObject * playerGetItemLink(PyObject * poSelf, PyObject * poArgs)
{
TItemPos Cell;

switch (PyTuple_Size(poArgs))
{
case 1:   
if (!PyTuple_GetInteger(poArgs, 0, &Cell.cell))
return Py_BuildException();
break;
case 2:
if (!PyTuple_GetByte(poArgs, 0, &Cell.window_type))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &Cell.cell))
return Py_BuildException();
break;
default:
return Py_BuildException();
}
const TItemData * pPlayerItem = CPythonPlayer::Instance().GetItemData(Cell);
CItemData * pItemData = NULL;
char buf[1024];

if (pPlayerItem && CItemManager::Instance().GetItemDataPointer(pPlayerItem->vnum, &pItemData))
{
char itemlink[256];
int len;
bool isAttr = false;

len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x:%x:%x:%x:%x:%x:%x",
pPlayerItem->vnum, pPlayerItem->flags,
pPlayerItem->alSockets[0], pPlayerItem->alSockets[1], pPlayerItem->alSockets[2] , pPlayerItem->alSockets[3], pPlayerItem->alSockets[4], pPlayerItem->alSockets[5]);

for (int i = 0; i < ITEM_ATTRIBUTE_SLOT_MAX_NUM; ++i)
if (pPlayerItem->aAttr[i].bType != 0)
{
len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d",
pPlayerItem->aAttr[i].bType, pPlayerItem->aAttr[i].sValue);
isAttr = true;
}

if( GetDefaultCodePage() == CP_ARABIC ) {
if (isAttr)
//"item:1oEL:ÇA·!±×:1OÄI0:1OÄI1:1OÄI2"
snprintf(buf, sizeof(buf), " |h|r[%s]|cffffc700|H%s|h", pItemData->GetName(), itemlink);
else
snprintf(buf, sizeof(buf), " |h|r[%s]|cfff1e6c0|H%s|h", pItemData->GetName(), itemlink);
} else {
if (isAttr)
//"item:1oEL:ÇA·!±×:1OÄI0:1OÄI1:1OÄI2"
snprintf(buf, sizeof(buf), "|cffffc700|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
else
snprintf(buf, sizeof(buf), "|cfff1e6c0|H%s|h[%s]|h|r", itemlink, pItemData->GetName());
}
}
else
buf[0] = '\0';

return Py_BuildValue("s", buf);
}
ElsÅ' az elsÅ'k között, Az emberek istent játszanak engedély nélkül.