- Joined
- Jan 9, 2009
- Messages
- 614
- Reaction score
- 152
So, I got tired of people refusing packets from other players (which allowed them to grab a CTF Flag without being attacked), and fixed it. Since it's a pretty nasty exploit, I thought i'd share the fix (Note: Not telling where you put this, people that have any business opening th esource should know where it goes and what to replace).
Fix:
Fix:
if( !CheckBitSet(pItem->GetSpawnTypeFlags(), WORLD_ITEM_STAND_ALINE) )
{
//If PlayerCount < 4 let them grab the flag even if they cheat, it doesn't matter.
if ((int)ZGetCharacterManager()->size() >= 4 && ZGetGame()->GetMatch()->GetMatchType() == MMATCH_GAMETYPE_CTF)
{
int nFoulCount = 0;
int nPlayerCount = 0;
for (auto itor = ZGetGameClient()->GetPeers()->begin(); itor != ZGetGameClient()->GetPeers()->end(); ++itor)
{
ZCharacter* pCharacter = ZGetCharacterManager()->Find((*itor).first);
//Valid connection to teamm8's is unnecessary for this fix
if (pCharacter->GetTeamID() == ZGetGame()->m_pMyCharacter->GetTeamID())
continue;
//ignore a connection to yourself
if (pCharacter->GetUID() == ZGetGame()->m_pMyCharacter->GetUID())
continue;
//Increment based on enemies team size
nPlayerCount+=1;
//if you fail to connect to a player of the opposite team,increment foulcount
if (pCharacter->m_dwStatusBitPackingValue.Ref().m_bLostConEffect)
{
++nFoulCount;
}
}
//this is assuming both teams have equal players, critique it how you like
if (nFoulCount >= nPlayerCount)
{
//add a check to prevent spam if you want, i think it's rather useful to spam the message
ZChatOutput("Error: Unable to obtain flag, please check your connection and rejoin.");
return;
}
//all is well, allow the player to capture the flag
ZPostRequestObtainWorldItem(ZGetGameClient()->GetPlayerUID(), pItem->GetID());
}
else
ZPostRequestObtainWorldItem(ZGetGameClient()->GetPlayerUID(), pItem->GetID());
}
else
{
ZPostLocalEventOptainSpecialWorldItem(int(pItem->GetItemID()));
}