📄 com.cpp
字号:
}
else if(dwInter != 0 && dwCurrTick - dwInter > 10000) // 10檬饶 磊悼栏肺 炮 抛胶飘
{
g_QuestEventZone.RemoveUserInEventZone(i);
g_QuestEventZone.m_SingleEventZone[i].m_lUsed = 0;
g_QuestEventZone.m_SingleEventZone[i].m_dwInterTick = 0;
}
}
}
for(j = 0; j < g_arGuildHouseWar.GetSize(); j++)
{
if(!g_arGuildHouseWar[j]) continue;
if(g_arGuildHouseWar[j]->m_CurrentGuild.lUsed == 1)
{
DWORD dwTempTick = g_arGuildHouseWar[j]->m_CurrentGuild.dwTimer;
DWORD dwInterTick = g_arGuildHouseWar[j]->m_CurrentGuild.dwIntervalTick;
if(dwTempTick != 0 && dwCurrTick - dwTempTick > 60000 * 10) // 10盒 抛胶飘
{
g_arGuildHouseWar[j]->CheckGuildHouseRank(); // Agent俊 历厘茄促.
g_arGuildHouseWar[j]->SetNpcListToWarEnd();
//g_arGuildHouseWar[j]->SetUserListToWarEnd(user_array);
g_arGuildHouseWar[j]->SetUserListToWarEnd();
g_arGuildHouseWar[j]->InitGuild();
g_arGuildHouseWar[j]->m_CurrentGuild.dwIntervalTick = 0;
InterlockedExchange(&g_arGuildHouseWar[j]->m_CurrentGuild.lUsed, 0);
}
else if(dwInterTick != 0 && dwCurrTick - dwInterTick > 10000) // 10檬饶 磊悼栏肺 炮 抛胶飘
{
g_arGuildHouseWar[j]->m_CurrentGuild.dwIntervalTick = 0;
// g_arGuildHouseWar[j]->CheckGuildHouseRank(); // Agent俊 历厘茄促.
// 荤侩吝牢 钎矫甫 钱绢霖促.
// g_arGuildHouseWar[j]->SetNpcListToWarEnd();
//g_arGuildHouseWar[j]->SetUserListToWarEnd(user_array); // 悸泼甫 钱绢霖促.
g_arGuildHouseWar[j]->SetUserListToWarEnd(); // 悸泼甫 钱绢霖促.
g_arGuildHouseWar[j]->InitGuild(); // 单捞磐甫 朝赴促.
::InterlockedExchange(&g_arGuildHouseWar[j]->m_CurrentGuild.lUsed, 0);
}
}
if(CurrTime.GetDay() == GUILD_HOUSE_DAY) // 辨靛窍快胶 盒剧 朝楼
{
if(CurrTime.GetHour() == 0) // 辨靛窍快胶 盒剧 矫埃
{
if(CurrTime.GetMinute() == 20 && !nState)
{
nState = 1;
for(i = 0; i < MAX_GUILD_HOUSE_NUM - 1; i++) // 瘤陛 辨.窍啊 6俺挥捞扼 捞吧 DB俊 历厘窍妨搁 茄波锅俊秦具窍唱?
{
if(!g_arGuildHouse[i]) continue;
if(InterlockedCompareExchange((PVOID*)&g_arGuildHouse[i]->lUsed, (PVOID)1, (PVOID)0) == (PVOID*)0)
{
g_arGuildHouse[i]->iSid = i + 1;
g_arGuildHouse[i]->iGuild = g_arGuildHouseWar[j]->m_TopList[i].lGuild;
g_arGuildHouse[i]->UpdateGuildHouse();
::InterlockedExchange(&g_arGuildHouse[i]->lUsed, 0);
}
}
g_arGuildHouseWar[j]->ResetGuildHouseRank();
RemoveUserInGuildHouse();
}
}
}
}
}
void COM::SendGuildWarBegin(CStore *pStore)
{
UpdateStoreMem2DB(pStore);
int i, j, k, type;
USER *pUser = NULL;
BOOL bSend = FALSE;
CBufferEx TempBuf;
CDWordArray arGuildList;
arGuildList.RemoveAll();
if(pStore->m_iGuildSid <= 0) return; // 辨靛傈阑困秦 曼咯吝牢 傈眉 府胶飘甫 父电促.
arGuildList.Add(pStore->m_iGuildSid); // 郴辨靛 刚历...
for(j =0; j < GUILD_ATTACK_MAX_NUM; j++) // 惑措祈 辨靛...
{
if(pStore->m_arAttackGuild[j] > 0)
{
arGuildList.Add(pStore->m_arAttackGuild[j]);
}
}
CString strMsg;
CGuild *pGuild = NULL;
for(i = 0; i < arGuildList.GetSize(); i++) // 惑痢 傈里傈 鞘靛傈捞 乐栏搁 檬扁拳 秦霖促.
{
j = arGuildList[i];
if(j <= 0 || j >= g_arGuildData.GetSize()) continue;
pGuild = g_arGuildData[j];
if(!pGuild) continue;
pUser = GetUser(pGuild->m_strMasterName);
if(!pUser) continue;
if(pUser->m_tGuildWar == GUILD_WARRING && pUser->m_dwFieldWar > 0)
{
strMsg = _ID(IDS_USER_DRAW);
pUser->SendGuildWarFieldEnd((LPTSTR)(LPCTSTR)strMsg);// 亲汗
}
}
short nCount = arGuildList.GetSize();
if(nCount <= 1)
{
strMsg = _T("");
strMsg.Format( IDS_USER_END_NO_APPLY_GUILD, pStore->m_strGuildName);
Announce((LPTSTR)(LPCTSTR)strMsg, SYSTEM_NORMAL);
pStore->m_dwStartTick = 0;
return;
}
TempBuf.Add(GUILD_WAR);
TempBuf.Add((BYTE)0x01); // 辨靛傈 矫累...
TempBuf.Add((BYTE)GUILD_STORE_WARRING); // 惑痢傈...
TempBuf.Add((short)pStore->m_sStoreID); // 秦寸 瘤开 牢郸胶
/* TempBuf.Add(nCount); // 醚 辨靛荐
for(i = 0; i < nCount; i++)
{
TempBuf.Add(arGuildList[i]);
}
*/
for(i = 0; i < MAX_USER; i++)
{
type = 0;
pUser = GetUserUid(i);
if(pUser == NULL || pUser->m_state != STATE_GAMESTARTED) continue;
if(pUser->m_dwGuild <= 0) continue;
type = ((g_zone[pUser->m_ZoneIndex]->m_pMap[pUser->m_curx][pUser->m_cury].m_dwType & 0xFF00 ) >> 8);
// if(g_arMapTable[type]->m_sStoreID != pStore->m_sStoreID) continue;
if(type >= 0 && type < 8)
{ //辨靛傈捞 老绢唱绰 惑痢瘤开捞搁
if(g_arMapTable[type]->m_sStoreID == pStore->m_sStoreID)// && g_arMapTable[type]->m_sStoreZone)
{
if(pStore->m_iGuildSid != pUser->m_dwGuild && pUser->m_tIsOP != TRUE ) pUser->TownPotal(); // 规绢辨靛盔捞 酒聪搁 葛滴 付阑肺
}
}
if(pStore->m_iGuildSid <= 0)
{
TempBuf.Add((BYTE)0x00); // 老馆蜡历
pUser->Send(TempBuf, TempBuf.GetLength());
continue;
}
if(pStore->m_iGuildSid == pUser->m_dwGuild)
{
pUser->BeginGuildWar(); // 辨靛 傈阑 矫累茄促.
TempBuf.Add((BYTE)0x01); // 秦寸 辨靛 蜡历
TempBuf.Add(nCount); // 醚 辨靛荐
for(j = 0; j < nCount; j++)
{
TempBuf.Add(arGuildList[j]);
}
pUser->Send(TempBuf, TempBuf.GetLength());
}
else
{
for(j =0; j < GUILD_ATTACK_MAX_NUM; j++)
{
if(pStore->m_arAttackGuild[j] <= 0) continue;
if(pStore->m_arAttackGuild[j] == pUser->m_dwGuild)
{
pUser->BeginGuildWar(); // 辨靛 傈阑 矫累茄促.
TempBuf.Add((BYTE)0x01); // 秦寸 辨靛 蜡历
TempBuf.Add(nCount); // 醚 辨靛荐
for(k = 0; k < nCount; k++)
{
TempBuf.Add(arGuildList[k]);
}
bSend = TRUE;
pUser->Send(TempBuf, TempBuf.GetLength());
break;
}
}
if(!bSend)
{
TempBuf.Add((BYTE)0x00); // 老馆蜡历
pUser->Send(TempBuf, TempBuf.GetLength());
}
}
}
for(j = 0; j < pStore->m_arNpcList.GetSize(); j++) // 秦寸 NPC俊霸档 舅府绊
{
type = pStore->m_arNpcList[j];
if( type < 0 || type >= g_arNpc.GetSize() ) continue;
g_arNpc[type]->m_tGuildWar = GUILD_WARRING;
if(g_arNpc[type]->m_tNpcType == NPCTYPE_GUILD_GUARD) g_arNpc[type]->m_tNpcAttType = 1;
}
}
void COM::SendGuildWarEnd(CStore *pStore)
{
int i, j, type;
int index = 0;
USER *pUser = NULL;
if(pStore->UpdateGuildStore() == FALSE) return;
pStore->InitStoreInfo(pStore->m_iGuildSid);
pStore->SetGuildStoreTex();
CBufferEx TempBuf;
TempBuf.Add(GUILD_WAR);
TempBuf.Add((BYTE)0x02); // 辨靛傈 辆丰...
TempBuf.Add(GUILD_STORE_WARRING);
TempBuf.Add((short)pStore->m_sStoreID);
for(i = 0; i < MAX_USER; i++)
{
pUser = GetUserUid(i);
if(pUser == NULL || pUser->m_state != STATE_GAMESTARTED) continue;
if(pUser->m_dwGuild <= 0) continue;
pUser->m_tGuildWar = GUILD_WAR_AFFTER;
pUser->m_FieldWarGMUid = 0;
pUser->m_dwFieldWar = 0;
pUser->Send(TempBuf, TempBuf.GetLength());
type = pUser->CheckInvalidMapType();
if(type >= 0 && type < 17)
{
index = g_arMapTable[type]->m_sStoreID;
if(index < FORTRESS_BAND)
{
CStore *pStore = NULL;
index = g_arMapTable[type]->m_sStoreIndex;
pStore = pUser->GetStore(index);
if(pStore)
{
pUser->SendSystemMsg( IDS_USER_END_FIELD_STORE_WAR, SYSTEM_NORMAL, TO_ME);
}
}
}
}
for(j = 0; j < pStore->m_arNpcList.GetSize(); j++) // 秦寸 NPC俊霸档 舅府绊
{
type = pStore->m_arNpcList[j];
if( type < 0 || type >= g_arNpc.GetSize() ) continue;
g_arNpc[type]->m_tGuildWar = GUILD_WAR_AFFTER;
g_arNpc[type]->m_tNpcAttType = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// 辨靛傈捞 矫累登扁傈俊 辨靛芒绊狼 郴侩阑 DB肺 诀单捞飘 茄促.
//
void COM::UpdateStoreMem2DB(CStore *pStore)
{
SQLHSTMT hstmt = NULL;
SQLRETURN retcode = 0;
BOOL bQuerySuccess = TRUE;
TCHAR szSQL[8000];
TCHAR strAttackList[_GUILDLIST_DB];
int i;
CSharedMemory* pShared = NULL;
CMemStore* pMDStore = NULL;
if(pStore == NULL) return;
if(pStore->m_sStoreID >= g_arStoreSharedMemory.GetSize()) return;
pShared = g_arStoreSharedMemory[pStore->m_sStoreID];
if(pShared == NULL) return;
if(pShared->m_hMapping == NULL) return;
pMDStore = (CMemStore*) pShared->m_lpData;
if(pMDStore == NULL) return;
if(pMDStore->m_sStoreID == -1) return;
if(pMDStore->m_iGuildSid <= 0) return;
::ZeroMemory(szSQL, sizeof(szSQL));
::ZeroMemory(strAttackList, sizeof(strAttackList));
pStore->GuildListToStr(strAttackList);
SDWORD sLen = sizeof(strAttackList);
_sntprintf(szSQL, sizeof(szSQL), TEXT("{call UPDATE_GUILD_STORE(%d, %d, %d, %d, %d, ?)}"),
pMDStore->m_sStoreID, pMDStore->m_iGuildSid, pMDStore->m_sTaxRate, pMDStore->m_dwStoreDN,
pMDStore->m_tWarType);
int db_index = 0;
CDatabase* pDB = g_DBNew[AUTOMATA_THREAD].GetDB( db_index );
if( !pDB ) return;
retcode = SQLAllocHandle( (SQLSMALLINT)SQL_HANDLE_STMT, pDB->m_hdbc, &hstmt );
if (retcode == SQL_SUCCESS)
{
i = 1;
SQLBindParameter(hstmt, i++, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, sizeof(strAttackList), 0, (TCHAR*)strAttackList, 0, &sLen);
retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS);
if (retcode ==SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
}
else if (retcode==SQL_ERROR)
{
DisplayErrorMsg( hstmt );
bQuerySuccess = FALSE;
}
}
else
{
// if (hstmt!=NULL) SQLFreeHandle( (SQLSMALLINT)SQL_HANDLE_STMT, hstmt);
// g_DBNew[AUTOMATA_THREAD].ReleaseDB(db_index);
return;
}
if (hstmt!=NULL) SQLFreeHandle( (SQLSMALLINT)SQL_HANDLE_STMT, hstmt);
g_DBNew[AUTOMATA_THREAD].ReleaseDB(db_index);
pMDStore->m_dwStoreDN = 0;
}
void COM::CheckGuildWarSchedule(CStore *pStore)
{
if(pStore == NULL) return;
int nSize = g_arStoreSharedMemory.GetSize();
CSharedMemory* pShared = NULL;
CMemStore* pData = NULL;
if(pStore->m_sStoreID >= nSize) return;
pShared = g_arStoreSharedMemory[pStore->m_sStoreID];
if(pShared == NULL) return;
if(pShared->m_hMapping == NULL) return;
pData = (CMemStore*) pShared->m_lpData;
if(pData == NULL) return;
pStore->m_tWarType = GUILD_WAR_DECISION;
pData->m_tWarType = GUILD_WAR_DECISION;
}
void COM::Announce(TCHAR *pBuf, BYTE sysType)
{
CBufferEx TempBuf;
TempBuf.Add(SYSTEM_MSG);
TempBuf.Add(sysType);
TempBuf.Add(pBuf, _tcslen(pBuf));
USER* pUser = NULL;
for(int i = 0; i < MAX_USER; i++)
{
pUser = GetUserUid(i);
if(pUser == NULL || pUser->m_state != STATE_GAMESTARTED) continue;
pUser->Send(TempBuf, TempBuf.GetLength());
}
}
void COM::AnnounceZone(TCHAR *pBuf, BYTE sysType, int iZone)
{
CBufferEx TempBuf;
TempBuf.Add(SYSTEM_MSG);
TempBuf.Add(sysType);
TempBuf.Add(pBuf, _tcslen(pBuf));
USER* pUser = NULL;
for(int i = 0; i < MAX_USER; i++)
{
pUser = GetUserUid(i);
if( pUser == NULL || pUser->m_state != STATE_GAMESTARTED ) continue;
if( pUser->m_curz != iZone ) continue;
pUser->Send(TempBuf, TempBuf.GetLength());
}
}
USER* COM::GetUser(TCHAR* id)
{
if(!strlen(id)) return NULL;
CString szSource = id;
USER *pUser = NULL;
for( int i = 0; i < MAX_USER; i++)
{
pUser = GetUserUid(i);
if(pUser == NULL) continue;
if( pUser->m_state == STATE_DISCONNECTED || pUser->m_state == STATE_LOGOUT ) continue;
if(!szSource.CompareNoCase(pUser->m_strUserID ) ) return pUser;
}
return NULL;
}
USER* COM::GetUserUid(int uid)
{
USER *pUser = NULL;
if (uid >= 0 && uid < MAXPOSSIBLE_USER )
{
pUser = g_pUserList->GetUserUid(uid);
/* if ( pUser )
{
if ( pUser->m_SockFlag != 1 )
{
g_pMainDlg->UserFree( uid );
return NULL;
}
}
*/ return pUser;
}
return NULL;
}
void COM::UpdateUserCount()
{
int nCount = 0;
USER *pUser = NULL;
nCount = 0;
for (int i = 0; i < MAX_USER; i++ )
{
pUser = GetUserUid(i);
if( pUser && pUser->m_state == STATE_GAMESTARTED ) nCount++;
}
if(nCount >= 500) nCount = (int)((double)nCount * 1.1 + 0.5);
SQLHSTMT hstmt;
SQLRETURN retcode;
TCHAR szSQL[1024];
memset(szSQL, 0x00, 1024);
_sntprintf(szSQL, sizeof(szSQL), TEXT("{call UpdateGameUserCount ( \'%s\', %d )}"), m_strIP, nCount );
hstmt = NULL;
int db_index = -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -