📄 cell.cpp
字号:
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
// pSendUser->GetMapItemInfo(arItem, ptMap, uid, ITEM_PICK_UP);
// TRACE("ChangeItemCell --> ID : %s, x : %d, y : %d\n", pSendUser->m_strUserID, ptMap.x, ptMap.y);
}
}
}
}
arUid.RemoveAll();
}
////////////////////////////////////////////////////////////////////////
// 坷肺瘤 凛绰 悼累父 老绢抄促.
//
void CELL::ChangeMoneyCell(DWORD dwDN, CPoint pt, CPoint ptMap, int uid)
{
CCellUidArray arUid;
USER* pSendUser = NULL;
// USER* pUser = NULL;
int nSize = 0;
int i, nX, nY;
int cx, cy;
int nUid = 0;
for(nX = -1; nX <= 1; nX++) // 9伎 荤捞俊 乐绰 蜡历俊霸 沥焊傈价
{
for(nY = -1; nY <= 1; nY++)
{
cx = pt.x + nX;
cy = pt.y + nY;
if(cx < 0 || cx >= m_sizeCell.cx) continue;
if(cy < 0 || cy >= m_sizeCell.cy) continue;
m_pCell[cx][cy].Get(arUid);
nSize = arUid.GetSize();
for(i = 0; i < nSize; i++)
{
nUid = arUid.GetAt(i);
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
pSendUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
pSendUser->GetMapMoneyInfo(dwDN, ptMap, uid);
}
}
}
}
arUid.RemoveAll();
}
////////////////////////////////////////////////////////////////////////
// Cell俊 甘俊辑狼 酒捞袍 谅钎甫 殿废窍绊 葛电 蜡历俊霸 舅赴促.
//
void CELL::AddItemCell(int uid, CPoint itemPt, int isReg)//(蜡历, 甘谅钎, 殿废倾啊:01:捣02:酒捞袍)
{ //(蜡历, 甘谅钎, 殿废秒家:11:捣12:酒捞袍)
DWORD dwDN = 0;
int nSize = 0, iSize = 0;
CPoint pt;
CCellUidArray arUid;
ItemInfoArray arMapItem;
arMapItem.RemoveAll();
USER* pSendUser = NULL;
USER* pUser = NULL;
CNpc* pNpc = NULL;
int i, nX, nY;
int cx, cy;
int nUid = 0;
if(uid >= USER_BAND && uid < NPC_BAND)
{
pUser = m_pCom->GetUserUid(uid - USER_BAND);
if(pUser == NULL || pUser->m_state != STATE_GAMESTARTED || pUser->m_curz != m_Zone) goto go_result;
pt.x = pUser->m_ptCell.x;
pt.y = pUser->m_ptCell.y;
if(isReg < 10) m_pCell[pt.x][pt.y].AddItem(itemPt); // 伎惑俊 殿废
if(!GetMapItemList(arMapItem, dwDN, itemPt, pUser->m_ZoneIndex)) goto go_result; // 秦寸 甘俊辑 酒捞袍 府胶飘甫 掘绢柯促.
for(nX = -1; nX <= 1; nX++) // 9伎 荤捞俊 乐绰 蜡历俊霸 沥焊傈价
{
for(nY = -1; nY <= 1; nY++)
{
cx = pt.x + nX;
cy = pt.y + nY;
if(cx < 0 || cx >= m_sizeCell.cx) continue;
if(cy < 0 || cy >= m_sizeCell.cy) continue;
m_pCell[cx][cy].Get(arUid);
nSize = arUid.GetSize();
for(i = 0; i < nSize; i++)
{
nUid = arUid.GetAt(i);
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
pSendUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
// if(isReg%2 == 0) pSendUser->GetMapItemInfo(arMapItem, itemPt, -1, ITEM_INFO_ADD);
// else pSendUser->GetMapMoneyInfo(dwDN, itemPt);
}
}
}
}
}
else if(uid >= NPC_BAND)
{
pNpc = GetNpc(uid - NPC_BAND);
if(pNpc == NULL) return;
pt.x = pNpc->m_ptCell.x;
pt.y = pNpc->m_ptCell.y;
if(isReg < 10) m_pCell[pt.x][pt.y].AddItem(itemPt); // 伎惑俊 殿废
if(!GetMapItemList(arMapItem, dwDN, itemPt, pNpc->m_ZoneIndex)) goto go_result; // 秦寸 甘俊辑 酒捞袍 府胶飘甫 掘绢柯促.
for(nX = -1; nX <= 1; nX++)
{
for(nY = -1; nY <= 1; nY++)
{
cx = pt.x + nX;
cy = pt.y + nY;
if(cx < 0 || cx >= m_sizeCell.cx) continue;
if(cy < 0 || cy >= m_sizeCell.cy) continue;
m_pCell[cx][cy].Get(arUid);
nSize = arUid.GetSize();
for(i = 0; i < nSize; i++)
{
nUid = arUid.GetAt(i);
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
pSendUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
// if(isReg%2 == 0) pSendUser->GetMapItemInfo(arMapItem, itemPt, -1, ITEM_INFO_ADD);
// else pSendUser->GetMapMoneyInfo(dwDN, itemPt);
// if(arMapItem.GetSize() > 0) pSendUser->GetMapItemInfo(arMapItem, itemPt, ITEM_INFO_ADD);
// if(dwDN > 0) pSendUser->GetMapMoneyInfo(dwDN, itemPt);
// TRACE("Add Item Cell\n");
}
}
}
}
}
go_result:
arUid.RemoveAll();
arMapItem.RemoveAll();
}
////////////////////////////////////////////////////////////////////////
// 甘俊辑 酒捞袍 府胶飘甫 啊廉柯促.(林狼 : 捞傈 窜拌俊辑 怖 Lock捞 吧妨 乐绢具窃)
//
BOOL CELL::GetMapItemList(ItemInfoArray &arMapItem, DWORD &dwDN, CPoint pt, int zoneIndex)
{
int j = 0;
int iSize = 0;
iSize = g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_Item.GetSize();
dwDN = g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_FieldDN;
// 秦寸 甘俊 酒公巴档 绝促.
if(iSize <= 0 && dwDN <= 0) return FALSE;
// 盖 困俊绰 捣父 乐促...
if(iSize > 0) arMapItem.Add(g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_Item[iSize - 1]);
return TRUE;
}
////////////////////////////////////////////////////////////////////////
// 甘俊辑 酒捞袍 府胶飘甫 啊廉柯促.(AddCell, DeleteCell傈侩栏肺辑 秦寸 甘 醚 沥焊甫 爱绰促.)
//
BOOL CELL::GetViewMapItemList(ItemInfoArray &arMapItem, DWORD &dwDN, CPoint pt, int zoneIndex)
{
int j = 0;
int iSize = 0;
long lUsed = 0;
lUsed = g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_FieldUse;
if(InterlockedCompareExchange((PVOID*)&lUsed, (PVOID)1, (PVOID)0) == (PVOID*)0)
{
iSize = g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_Item.GetSize();
dwDN = g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_FieldDN;
if(iSize <= 0 && dwDN <= 0) return FALSE;
for(j=0; j < iSize; j++)
{
arMapItem.Add(g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_Item[j]);
}
::InterlockedExchange(&g_zone[zoneIndex]->m_pMap[pt.x][pt.y].m_FieldUse, 0);
return TRUE;
}
else return FALSE;
}
CNpc* CELL::GetNpc(int nid)
{
CNpc* pNpc = NULL;
// int nSize = g_arNpcThread.GetSize();
int nSize = g_arNpc.GetSize();
// if(nid < 0 || nid >= nSize) return NULL;
/* pNpc = g_arNpcThread[nid]->m_pNpc;
*/
for( int i = 0; i < g_arNpc.GetSize(); i++)
{
pNpc = g_arNpc[i];
if( !pNpc ) continue;
if( pNpc->m_sNid == nid )
{
return pNpc;
}
}
return NULL;
}
////////////////////////////////////////////////////////////////////////
// 醚扁拌凯俊狼茄 鸥款器呕甫 困秦 伎俊 User甫 眠啊茄促.(菩哦樊阑 临捞扁困秦)
//
void CELL::AddCellFromTownPotal(CPoint pt, int nUid)
{
CCellItemArray arCellItem;
CCellUidArray arUid;
m_pCell[pt.x][pt.y].Add(nUid);
ItemInfoArray arMapItem;
arMapItem.RemoveAll();
USER* pUser = NULL;
USER* pSendUser = NULL;
CNpc* pNpc = NULL;
int nSize = 0, iSize = 0;
int i, nX, nY;
int cx, cy;
DWORD dwDN = 0;
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
CPoint ptCell;
pUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pUser == NULL || pUser->m_curz != m_Zone) return;
for(nX = -1; nX <= 1; nX++)
{
for(nY = -1; nY <= 1; nY++)
{
cx = pt.x + nX;
cy = pt.y + nY;
if(cx < 0 || cx >= m_sizeCell.cx) continue;
if(cy < 0 || cy >= m_sizeCell.cy) continue;
m_pCell[cx][cy].Get(arUid);
nSize = arUid.GetSize();
m_pCell[cx][cy].GetItem(arCellItem); // 甘惑俊辑狼 酒捞袍 困摹甫...
iSize = arCellItem.GetSize(); // 茄 伎俊辑狼 酒捞袍 困摹 荐
for(i = 0; i < iSize; i++) // 葛电 酒捞袍 困摹沥焊甫 焊辰促.
{
dwDN = 0;
ptCell = arCellItem[i];
if(!GetViewMapItemList(arMapItem, dwDN, ptCell, pUser->m_ZoneIndex)) continue;
if(dwDN > 0) pUser->GetMapMoneyInfo(dwDN, ptCell);
// if(arMapItem.GetSize() > 0) pUser->GetMapItemInfo(arMapItem, ptCell, -1, ITEM_INFO_MODIFY);
arMapItem.RemoveAll();
}
for(i = 0; i < nSize; i++)
{
nUid = arUid.GetAt(i);
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
pSendUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
pSendUser->SendUserTownPotal(pUser, INFO_TOWNPOTAL);// Other <- Me(郴啊 鸥款器呕吝捞促)
pUser->SendUserInfo(pSendUser, INFO_MODIFY); // Other -> Me(老馆 伎苞 鞍捞)
}
if(nUid >= NPC_BAND)
{
pNpc = pUser->GetNpc(nUid - NPC_BAND);
if(!pNpc) continue;
pUser->SendNpcInfo(pNpc, INFO_MODIFY);
}
}
}
}
}
}
////////////////////////////////////////////////////////////////////////
// 醚扁拌凯俊狼茄 鸥款器呕甫 困秦 伎俊 User甫 昏力茄促.
//
void CELL::DeleteCellFromTownPotal(CPoint pt, int nUid)
{
// Add User ID to Cell and Copy Cell Array
CCellItemArray arCellItem;
ItemInfoArray arMapItem;
arMapItem.RemoveAll();
CCellUidArray arUid;
m_pCell[pt.x][pt.y].Delete(nUid);
USER* pUser = NULL;
USER* pSendUser = NULL;
CNpc* pNpc = NULL;
int nSize = 0, iSize = 0;
int i, nX, nY;
int cx, cy;
BOOL bZoneChanging = FALSE;
DWORD dwDN = 0;
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
CPoint ptCell;
pUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pUser == NULL || pUser->m_state != STATE_GAMESTARTED || pUser->m_curz != m_Zone) return;
if(pUser->m_NowZoneChanging) bZoneChanging = TRUE;
for(nX = -1; nX <= 1; nX++)
{
for(nY = -1; nY <= 1; nY++)
{
cx = pt.x + nX;
cy = pt.y + nY;
if(cx < 0 || cx >= m_sizeCell.cx) continue;
if(cy < 0 || cy >= m_sizeCell.cy) continue;
m_pCell[cx][cy].Get(arUid);
nSize = arUid.GetSize();
m_pCell[cx][cy].GetItem(arCellItem); // 甘惑俊辑狼 酒捞袍 困摹甫...
iSize = arCellItem.GetSize(); // 茄 伎俊辑狼 酒捞袍 困摹 荐
if(!bZoneChanging)
{
for(i = 0; i < iSize; i++) // 葛电 酒捞袍 困摹沥焊甫 焊辰促.
{
dwDN = 0;
ptCell = arCellItem[i];
if(!GetViewMapItemList(arMapItem, dwDN, ptCell, pUser->m_ZoneIndex)) continue;
if(dwDN > 0) pUser->GetMapMoneyInfo(dwDN, ptCell);
// if(arMapItem.GetSize() > 0) pUser->GetMapItemInfo(arMapItem, ptCell, -1, ITEM_INFO_DEL);
arMapItem.RemoveAll();
}
}
for(i = 0; i < nSize; i++)
{
nUid = arUid.GetAt(i);
if(nUid >= USER_BAND && nUid < NPC_BAND)
{
pSendUser = m_pCom->GetUserUid(nUid - USER_BAND);
if(pSendUser == NULL || pSendUser->m_state != STATE_GAMESTARTED || pSendUser->m_curz != m_Zone) continue;
pSendUser->SendUserTownPotal(pUser, INFO_TOWNPOTAL_DELETE); // Other <- Me
if(!bZoneChanging) pUser->SendUserInfo(pSendUser, INFO_DELETE); // Other -> Me
}
if(nUid >= NPC_BAND)
{
pNpc = pUser->GetNpc(nUid - NPC_BAND);
if(!pNpc) continue;
if(!bZoneChanging) pUser->SendNpcInfo(pNpc, INFO_DELETE); // 粮眉牢瘤啊 绝阑锭父 焊辰促.
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -