Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Rejoin and Vote Map Clan War

I'm retired, I'm already
Banned
Joined
Oct 3, 2011
Messages
832
Reaction score
155
Hello, these codes you can adapt to your mode to make it work in the "Clan War" since this code has been extracted from the source of UGG, if you have any questions you can continue to complete the code next to the source that has been released Already 1 year ago by Steven.

Code Source: UniverseGamers

Coded By: Steven.

Rejoin:
PHP:
MMatchDBMgr.cpp

TCHAR g_szDB_INSERT_REJOIN_LOG[] = _T("{CALL InsertReportLog('%s', %d, %d, %d, %d, %d)}");

--

bool MMatchDBMgr::InsertRejoinLog(const char* szGameName, unsigned int nCID, unsigned int nBLUECLID, unsigned int nREDCLID, unsigned int nTeam, unsigned int LowID )
{
	_STATUS_DB_START;
	if (!CheckOpen()) return false;

	CString strSQL;

	try {
		strSQL.Format(g_szDB_INSERT_REJOIN_LOG, m_DBFilter.Filtering(szGameName).c_str(), nCID, nBLUECLID, nREDCLID, nTeam, LowID);
		m_DB.ExecuteSQL( strSQL );
	} 
	catch(CDBException* e) {
		ExceptionHandler(strSQL, e);
		return false;
	}

	_STATUS_DB_END(13);
	return true;
}

--

bool InsertRejoinLog(const char* szGameName, unsigned int nCID, unsigned int nBLUECLID, unsigned int nREDCLID, unsigned int nTeam, unsigned int LowID );

--

MMatchServer.h

struct ClanRejoin
{
	MMatchTeam Team;
	MUID StageUID;
	ClanRejoin(MMatchTeam team, MUID stageUID)
	{
		Team = team;
		StageUID = stageUID;
	}
};

--

struct CountryCode
{
	char CS[3];
	long IpTo;
	CountryCode(char cs[3], long i)
	{
		strcpy(CS, cs);
		IpTo = i;
	}
};
typedef map<unsigned long, ClanRejoin*> ClanReDef;
typedef std::map<long, CountryCode*> CCMap;
class MMatchServer : public MServer{

--

ClanReDef			ClanRejoiner;

--

bool StageJoin(const MUID& uidPlayer, const MUID& uidStage, bool rejoin=false, MMatchTeam Team =MMT_ALL);

--

Por: ChannelResponsePlayerList(uidPlayer, uidChannelTmp, 0);

	if (pChannel->GetChannelType() == MCHANNEL_TYPE_CLAN)
	{
		ClanReDef::iterator it = ClanRejoiner.find(pObj->GetCharInfo()->m_nCID);
		if(it != ClanRejoiner.end())
		{
			MMatchStage* pStage = FindStage(it->second->StageUID);
			if(pStage)
			{
				Announce(pObj, "To rejoin your game type /rejoin");
			}
		}
	}

--

bool MMatchServer::LadderJoin(const MUID& uidPlayer, const MUID& uidStage, MMatchTeam nTeam)
{
	MMatchObject* pObj = GetObject(uidPlayer);
	if (pObj == NULL) return false;

	if (pObj->GetStageUID() != MUID(0,0))
		StageLeave(pObj->GetUID());//, pObj->GetStageUID());

	MMatchStage* pStage = FindStage(uidStage);
	if (pStage == NULL /*|| pStage->GetState() == STAGE_STATE_RUN*/) return false;
	ClanRejoiner.insert(ClanReDef::value_type(pObj->GetCharInfo()->m_nCID, new ClanRejoin(nTeam, uidStage)));
	pObj->OnStageJoin();

	// Join
	pStage->AddObject(uidPlayer, pObj);
	pObj->SetStageUID(uidStage);
	pObj->SetStageState(MOSS_READY);
	pObj->SetLadderChallenging(false);
	pStage->PlayerTeam(uidPlayer, nTeam);
	pStage->PlayerState(uidPlayer, MOSS_READY);

	MCommand* pCmd = CreateCommand(MC_MATCH_LADDER_PREPARE, uidPlayer);
	pCmd->AddParameter(new MCmdParamUID(uidStage));
	pCmd->AddParameter(new MCmdParamInt(nTeam));
	Post(pCmd);
	pStage->SetCLID(pObj->GetCharInfo()->m_ClanInfo.m_nClanID, nTeam);
	return true;
}

--

MMatchServer_OnCommand

		case MC_MATCH_STAGE_REQUEST_REJOIN:
			{
				MMatchObject* pObj = (MMatchObject*)GetObject(pCommand->GetSenderUID());
				if (pObj)
				{
					ClanReDef::iterator it = ClanRejoiner.find(pObj->GetCharInfo()->m_nCID);
					if(it != ClanRejoiner.end())
					{
						if(!StageJoin(pObj->GetUID(), it->second->StageUID, true, it->second->Team))
						{
							NotifyMessage(pObj->GetUID(), MATCHNOTIFY_STAGE_NOT_EXIST);
						}
					}
				} 
			}
			break;

--

MMatchServer_Stage

bool MMatchServer::StageJoin(const MUID& uidPlayer, const MUID& uidStage, bool rejoin,MMatchTeam Team)
{
	MMatchObject* pObj = GetObject(uidPlayer);
	if (!IsEnabledObject(pObj)) return false;

	if (pObj->GetStageUID() != MUID(0,0))
		StageLeave(pObj->GetUID());//, pObj->GetStageUID());

	MMatchChannel* pChannel = FindChannel(pObj->GetChannelUID());
	if (pChannel == NULL) return false;
	if (pChannel->GetChannelType() == MCHANNEL_TYPE_DUELTOURNAMENT) return false;

	MMatchStage* pStage = FindStage(uidStage);
	if (pStage == NULL) return false;
	if(rejoin == true)
	{
		GetDBMgr()->InsertRejoinLog(pStage->GetName(), pObj->GetCharInfo()->m_nCID, pStage->GetBlueCLID(), pStage->GetRedCLID(), (int)Team, pStage->GetUID().Low);
	}
	int ret = ValidateStageJoin(uidPlayer, uidStage);
	if (ret != MOK) {
		RouteResponseToListener(pObj, MC_MATCH_RESPONSE_STAGE_JOIN, ret);
		return false;
	}
	pObj->OnStageJoin();

	// Cache Add
	MMatchObjectCacheBuilder CacheBuilder;
	CacheBuilder.AddObject(pObj);
	MCommand* pCmdCacheAdd = CacheBuilder.GetResultCmd(MATCHCACHEMODE_ADD, this);
	RouteToStage(pStage->GetUID(), pCmdCacheAdd);

	// Join
	pStage->AddObject(uidPlayer, pObj);
		// ÀÓ½ÃÄÚµå... À߸øµÈ Ŭ·£ID ¿Â´Ù¸é üũÇÏ¿© Àâ±âÀ§ÇÔ...20090224 by kammir
	if(pObj->GetCharInfo()->m_ClanInfo.GetClanID() >= 9000000)
		LOG(LOG_FILE, "[UpdateCharClanInfo()] %s's ClanID:%d.", pObj->GetAccountName(), pObj->GetCharInfo()->m_ClanInfo.GetClanID());

	pObj->SetStageUID(uidStage);
	pObj->SetStageState(MOSS_NONREADY);

	// Cast Join
	if(rejoin == true && pStage->GetStageType() != MST_LADDER && pStage->GetStageType() != MST_PLAYERWARS) rejoin = false;
	if(rejoin == false)
	{
	//pObj->SetTeam(pStage->GetRecommandedTeam());
	if(pStage->GetStageSetting()->GetGameType() != MMATCH_GAMETYPE_DEATHMATCH_TEAM_TRIPLE)	{	// 3 Team DM.
		pObj->SetTeam(pStage->GetRecommandedTeam());
	}	else {
		pObj->SetTeam(pStage->GetRecommandedTeamTriple());
	}
	MCommand* pNew = new MCommand(m_CommandManager.GetCommandDescByID(MC_MATCH_STAGE_JOIN), MUID(0,0), m_This);
	pNew->AddParameter(new MCommandParameterUID(uidPlayer));
	pNew->AddParameter(new MCommandParameterUID(pStage->GetUID()));
	pNew->AddParameter(new MCommandParameterUInt(pStage->GetIndex()+1));
	pNew->AddParameter(new MCommandParameterString((char*)pStage->GetName()));
	
	if (pStage->GetState() == STAGE_STATE_STANDBY)  RouteToStage(pStage->GetUID(), pNew);
	else											RouteToListener(pObj, pNew);

	} 
	else
	{
		MCommand* pCmd = CreateCommand(MC_MATCH_LADDER_PREPARE, uidPlayer);
		pCmd->AddParameter(new MCmdParamUID(uidStage));
		pCmd->AddParameter(new MCmdParamInt((int)pObj->GetTeam()));
		RouteToListener(pObj, pCmd);
	}
	// Cache Update
	CacheBuilder.Reset();
	for (MUIDRefCache::iterator i=pStage->GetObjBegin(); i!=pStage->GetObjEnd(); i++) {
		MUID uidObj = (MUID)(*i).first;
		MMatchObject* pScanObj = (MMatchObject*)GetObject(uidObj);
		if (pScanObj) {
			CacheBuilder.AddObject(pScanObj);
		} else {
			LOG(LOG_PROG, "MMatchServer::StageJoin - Invalid ObjectMUID(%u:%u) exist in Stage(%s)\n",
				uidObj.High, uidObj.Low, pStage->GetName());
			pStage->RemoveObject(uidObj);
			return false;
		}
	}
    MCommand* pCmdCacheUpdate = CacheBuilder.GetResultCmd(MATCHCACHEMODE_UPDATE, this);
	RouteToListener(pObj, pCmdCacheUpdate);

	if(rejoin == false)
	{
	// Cast Master(¹æÀå)
	MUID uidMaster = pStage->GetMasterUID();
	MCommand* pMasterCmd = CreateCommand(MC_MATCH_STAGE_MASTER, MUID(0,0));
	pMasterCmd->AddParameter(new MCommandParameterUID(uidStage));
	pMasterCmd->AddParameter(new MCommandParameterUID(uidMaster));
	RouteToListener(pObj, pMasterCmd);
	}

#ifdef _QUEST_ITEM
	if (MGetServerConfig()->GetServerMode() == MSM_TEST || MGetServerConfig()->GetServerMode() == MSM_CLANTEST)
	{
		const MSTAGE_SETTING_NODE* pNode = pStage->GetStageSetting()->GetStageSetting();
		if( 0 == pNode )
		{
			mlog( "MMatchServer::StageJoin - ½ºÅ×ÀÌÁö ¼ÂÆà ³ëµå ã±â ½ÇÆÐ.\n" );
			return false;
		}

		if (MGetGameTypeMgr()->IsQuestDerived(pNode->nGameType))
		{
			MMatchRuleBaseQuest* pRuleQuest = reinterpret_cast< MMatchRuleBaseQuest* >( pStage->GetRule() );
			if( 0 == pRuleQuest )
			{
				mlog( "MMatchServer::StageJoin - Æ÷ÀÎÅÍ Çüº¯È¯ ½ÇÆÐ.\n" );
				return false;
			}

			pRuleQuest->OnChangeCondition();
			//pRuleQuest->OnResponseQL_ToStage( pObj->GetStageUID() );
			// µ¿È¯¾¾²²¼­ óÀ½ ½ºÅ×ÀÌÁö Á¶Àνô ÀÌÀü¿¡ ¼³Á¤ÀÌ Äù½ºÆ®·Î µÇÀ־ 
			//  óÀ½ Á¶ÀÎÇÑ À¯Àú´Â Äù½ºÆ® ŸÀÔÀÎÁö ¾Ë¼ö°¡ ¾ø±â¿¡,
			//	Ŭ¶óÀ̾ðÆ®°¡ ½ºÅ×ÀÌÁö ŸÀÔÀÌ Äù½ºÆ®ÀÎÁö¸¦ ÀνÄÇÏ´Â ½ÃÁ¡¿¡¼­
			//  ÀÌ Á¤º¸¸¦ ¿äûÀ» ÇÏ´Â ¹æÇâÀ¸·Î ¼öÁ¤ÇÔ. - 05/04/14 by Ãß±³¼º.
			// pStage->GetRule()->OnResponseSacrificeSlotInfoToStage( uidPlayer );
		}
	}
#endif

	if( rejoin == false)
	{
	// Cast Character Setting
	StageTeam(uidPlayer, uidStage, pObj->GetTeam());
	StagePlayerState(uidPlayer, uidStage, pObj->GetStageState());
	} else {
		
		pObj->SetForcedEntry(true);
		StageTeam(uidPlayer, uidStage, Team);
		StagePlayerState(uidPlayer, uidStage, MOSS_READY);
		MCommand* pCmd = CreateCmdResponseStageSetting(uidStage);
		RouteToListener(pObj, pCmd);
		pObj->SetLaunchedGame(true);
		pCmd = CreateCommand(MC_MATCH_LADDER_LAUNCH, uidPlayer);
		pCmd->AddParameter(new MCmdParamUID(uidStage));
		pCmd->AddParameter(new MCmdParamStr( const_cast<char*>(pStage->GetMapName()) ));
		pCmd->AddParameter(new MCmdParamBool((bool)(pStage->GetStageType() == MST_PLAYERWARS)));
		RouteToListener(pObj, pCmd);
		StageEnterBattle(uidPlayer, uidStage);
	}
	// ¹æ¼Û °ü°èÀÚ¸é ¹æÀå±ÇÇÑÀ» ÀÚµ¿À¸·Î »©¾Ñ´Â´Ù. - ¿Â°ÔÀÓ³Ý ºñºñºò ¿äû
	//if (MMUG_EVENTMASTER == pObj->GetAccountInfo()->m_nUGrade) {
	//	OnEventChangeMaster(pObj->GetUID());
	//}
	return true;
}

--

void MMatchServer::StageFinishGame(const MUID& uidStage)
{
	MMatchStage* pStage = FindStage(uidStage);
	if (pStage == NULL) return;

	bool bIsRelayMapUnFinish = true;
	if(pStage->GetStageType() == MST_LADDER || pStage->GetStageType() == MST_PLAYERWARS)
	{
		ClanReDef::iterator it = ClanRejoiner.begin();
		while(it != ClanRejoiner.end())
		{
			if(it->second->StageUID == uidStage)
			{
				ClanRejoiner.erase(it++);
			}
			else
			++it;
		}
	}

--

MSharedCommandTable.cpp

	C(MC_MATCH_STAGE_REQUEST_REJOIN, "Stage.Request.Rejoin", "Stage Rejoin", MCDT_MACHINE2MACHINE | MCCT_NON_ENCRYPTED);
	C(MC_STAFF_STAGE_JOIN, "STAFF.STAGE.JOIN", "STAFF STAGE JOIN", MCDT_MACHINE2MACHINE | MCCT_NON_ENCRYPTED)
		P(MPT_UID, "uidPlayer")
		P(MPT_STR, "name")

--

MSharedCommandTable.h
#define MC_MATCH_STAGE_REQUEST_REJOIN			XXXXX
#define MC_STAFF_STAGE_JOIN						XXXXX


---------------------------Gunz-------------------------------

ZChat_Cmds.cpp

void ChatCmd_StageRejoin(const char* line, const int argc, char **const argv);
void ChatCmd_AdminStage( const char* line, const int argc, char **const argv );

_CC_AC("rejoin",					&ChatCmd_StageRejoin,		CCF_LOBBY, ARGVNoMin, ARGVNoMax, true, "/rejoin", "");
_CC_AC("admin_stage",					&ChatCmd_AdminStage,					CCF_ADMIN, ARGVNoMin, 1, true, "/admin_stage <stageid>", "");

void ChatCmd_StageRejoin(const char* line, const int argc, char **const argv) 
{
	ZGetGameClient()->IsRejoin = true;
	ZPostStageRequestRejoin();
}
void ChatCmd_AdminStage(const char* line, const int argc, char **const argv) 
{
	if (argc < 2) 
	{
		OutputCmdWrongArgument(argv[0]);
		return;
	}
	long l;
	if(l = atol(argv[1]))
	ZPostAdminStageJoin(MUID(0, l), "");
}
--

ZGameClient.cpp

ZGameClient::ZGameClient() : MMatchClient() , m_pUPnP(NULL)
{
	ToggleNat = false;
	ShowTeamChat = false;
	ShowLocalDamage = false;
	IsRejoin = false;

---

public:
	bool IsRejoin;
	// µà¾óÅä³Ê¸ÕÆ® ³» ÀüÀûÁ¤º¸ (·Î±×ÀÎÇÒ¶§¸¸ 1ȸ ¹ÞÀ½, ¾ð¾îº¯°æ½Ã ¿©±â¿¡ ±â¾ïµÈ °ªÀ¸·Î ui°»½Å)
	struct DTCHARINFO {	

---

ZGameClient_OnCommand.cpp

		case MC_MATCH_NOTIFY:
			{
				unsigned int nMsgID = 0;
				if (pCommand->GetParameter(&nMsgID, 0, MPT_UINT) == false) break;
				if(ZGetGameClient()->GetServerUID() != pCommand->GetSenderUID()) return false;
				if(nMsgID == MATCHNOTIFY_STAGE_NOT_EXIST) ZGetGameClient()->IsRejoin = false;
				OnMatchNotify(nMsgID);
			}
			break;
-----

ZPost.h

inline void ZPostStageRequestRejoin()
{
	ZPOSTCMD0(MC_MATCH_STAGE_REQUEST_REJOIN);
}

inline void ZPostAdminStageJoin(MUID uidStage, char* trg)
{
	ZPOSTCMD2(MC_STAFF_STAGE_JOIN, MCmdParamUID(uidStage), MCmdParamStr(trg));
}

-----

VoteMap:
PHP:
MLadderMgr.cpp
-----
void MLadderMgr::LaunchLadder(MLADDERTYPE nLadderType, int nGroupA, int nGroupB, int nGroupC)
{
#ifdef _DEBUG
	//char szLog[128];
	//sprintf(szLog, "Team(%d) vs Group(%d) LADDER LAUNCHED \n", nGroupA, nGroupB);
	//OutputDebugString(szLog);
#endif 

	MLadderGroupMap* pGroupMap = GetWaitGroupContainer(nLadderType);
	if (pGroupMap == NULL) return;

	MLadderGroup* pGroupA = pGroupMap->Find(nGroupA);
	MLadderGroup* pGroupB = pGroupMap->Find(nGroupB);
	MLadderGroup* pGroupC = NULL;
	if(nGroupC != -1)
	{
		pGroupC = pGroupMap->Find(nGroupC);
		if ((pGroupA != NULL) && (pGroupC != NULL) && (pGroupC->IsSameGroup(pGroupA))) return;
		if ((pGroupC != NULL) && (pGroupB != NULL) && (pGroupC->IsSameGroup(pGroupB))) return;
		pGroupMap->Remove(nGroupC);
		RemoveFromGroupList(pGroupC);
	}
	// ¸¸¾à °°Àº Ŭ·£À̰ųª °°Àº ±×·ìÀÌ¸é ·±Ä¡°¡ ¾ÈµÈ´Ù.
	if ((pGroupA != NULL) && (pGroupB != NULL) && (pGroupA->IsSameGroup(pGroupB))) return;

	pGroupMap->Remove(nGroupA);
	pGroupMap->Remove(nGroupB);

	RemoveFromGroupList(pGroupA);
	RemoveFromGroupList(pGroupB);

	if ((pGroupA == NULL) || (pGroupB == NULL)) {
#ifdef _DEBUG
		OutputDebugString("LADDER ºÒ¹ß \n");
#endif
		return;
	}
	LadderGameMapVoteInfo* m = new LadderGameMapVoteInfo();
	for(int i = 0; i < 3; i++)
	{
		m->Votes[i] = 0;
		m->Maps[i] = -1;
	}
	MBaseTeamGameStrategy* pTeamGameStrategy = MBaseTeamGameStrategy::GetInstance(MGetServerConfig()->GetServerMode());
	if (pTeamGameStrategy)
	{
		for(int i = 0; i < 3; i++)
		{
			int index = pTeamGameStrategy->GetPlayerWarsRandomMap((int)pGroupA->GetPlayerCount());
			while(index == m->Maps[0] || index == m->Maps[1] || index == m->Maps[2])
				index = pTeamGameStrategy->GetPlayerWarsRandomMap((int)pGroupA->GetPlayerCount());
			m->Maps[i] = index;
		}
	};
	int ID = counter++;
	m->RegisterTime = timeGetTime();
	MMatchServer* pServer = MMatchServer::GetInstance();
	MCommand* pCommand = pServer->CreateCommand(MC_MATCH_PLAYERWARS_RANDOM_MAPS,  MUID(0,0));
	pCommand->AddParameter(new MCmdParamInt(m->Maps[0]));
	pCommand->AddParameter(new MCmdParamInt(m->Maps[1]));
	pCommand->AddParameter(new MCmdParamInt(m->Maps[2]));
	for (list<MUID>::iterator i=pGroupA->GetPlayerListBegin(); i!= pGroupA->GetPlayerListEnd(); i++)
	{
		MUID uidPlayer = (*i);
		MMatchObject* pObj = (MMatchObject*)pServer->GetObject(uidPlayer);
		if (pObj) 
		{
			pObj->PlayerWarsIdentifier = ID;
			MCommand* pSendCmd = pCommand->Clone();
			pServer->RouteToListener(pObj, pSendCmd);
		}
	}	
	for (list<MUID>::iterator i=pGroupB->GetPlayerListBegin(); i!= pGroupB->GetPlayerListEnd(); i++)
	{
		MUID uidPlayer = (*i);
		MMatchObject* pObj = (MMatchObject*)pServer->GetObject(uidPlayer);
		if (pObj) 
		{
			pObj->PlayerWarsIdentifier = ID;
			MCommand* pSendCmd = pCommand->Clone();
			pServer->RouteToListener(pObj, pSendCmd);
		}
	}
	delete pCommand;
	m->pGroupA = pGroupA;
	m->pGroupB = pGroupB;
	WaitingMapSelectionGames.insert(map<unsigned long int, LadderGameMapVoteInfo*>::value_type(ID, m));
}

void MLadderMgr::UpdatePlayerVote(int VoteID, MMatchObject* pObj)
{
	if(pObj->PlayerWarsIdentifier != -1)
	{
		map<unsigned long int, LadderGameMapVoteInfo*>::iterator i = WaitingMapSelectionGames.find(pObj->PlayerWarsIdentifier);
		if(i!=WaitingMapSelectionGames.end())
		{
			LadderGameMapVoteInfo*  m = i->second;
			if(m)
			{
				if(pObj->LastVoteID != -1)
					m->Votes[pObj->LastVoteID]--;
				m->Votes[VoteID]++;
				pObj->LastVoteID = VoteID;
			}
		}
	}
}

void MLadderMgr::UpdateMapCountDown(unsigned long int NowTime)
{
	MMatchServer* pServer = MMatchServer::GetInstance();
	for(map<unsigned long int, LadderGameMapVoteInfo*>::iterator i = WaitingMapSelectionGames.begin(); i != WaitingMapSelectionGames.end();)
	{
		LadderGameMapVoteInfo* m = i->second;
		if(!m) 
		{
			i = WaitingMapSelectionGames.erase(i);
			continue;
		}
		if((NowTime - m->RegisterTime) >= 20000)
		{
			int winningmapindex = -1, winningindex = -1, votecount = 0;
			for(int a = 0; a < 3; a++)
			{
				if(m->Votes[a] == votecount)
				{
					votecount = m->Votes[a];
					winningmapindex = m->Maps[a];
					winningindex = a;
				}
				else if(m->Votes[a] >= votecount)
				{
					votecount = m->Votes[a];
					winningmapindex = m->Maps[a];
					winningindex = a;
				}
			}
			if(winningmapindex == -1)
			winningmapindex = m->Maps[RandomNumber(0, 2)];
			else
			{
				switch(winningindex)
				{
				case 0:
					if(m->Votes[winningindex] == m->Votes[1])
						winningmapindex = m->Maps[RandomNumber(0, 1)];
					else if(m->Votes[winningindex] == m->Votes[2])
						if(RandomNumber(0, 1) == 0)
						winningmapindex = m->Maps[winningindex];
						else
						winningmapindex = m->Maps[2];
					break;
				case 1:
					if(m->Votes[winningindex] == m->Votes[0])
						winningmapindex = m->Maps[RandomNumber(0, 1)];
					else if(m->Votes[winningindex] == m->Votes[2])
						if(RandomNumber(0, 1) == 0)
						winningmapindex = m->Maps[winningindex];
						else
						winningmapindex = m->Maps[2];
					break;
				case 2:					
					if(m->Votes[winningindex] == m->Votes[1])
						winningmapindex = m->Maps[RandomNumber(1, 2)];
					else if(m->Votes[winningindex] == m->Votes[0])
						if(RandomNumber(0, 1) == 1)
						winningmapindex = m->Maps[winningindex];
						else
						winningmapindex = m->Maps[0];
					break;
				}
			}
			i = WaitingMapSelectionGames.erase(i);
			pServer->LadderGameLaunch(m->pGroupA, m->pGroupB, NULL, winningmapindex);
			continue;
		} 
		else 
		{	
			MCommand* pCommand = pServer->CreateCommand(MC_MATCH_PLAYERWARS_VOTE_UPDATE,  MUID(0,0));
			pCommand->AddParameter(new MCmdParamInt(m->Votes[0]));
			pCommand->AddParameter(new MCmdParamInt(m->Votes[1]));
			pCommand->AddParameter(new MCmdParamInt(m->Votes[2]));
			for (list<MUID>::iterator i=m->pGroupA->GetPlayerListBegin(); i!= m->pGroupA->GetPlayerListEnd(); i++)
			{
				MUID uidPlayer = (*i);
				MMatchObject* pObj = (MMatchObject*)pServer->GetObject(uidPlayer);
				if (pObj) 
				{
					MCommand* pSendCmd = pCommand->Clone();
					pServer->RouteToListener(pObj, pSendCmd);
				}
			}	
			for (list<MUID>::iterator i=m->pGroupB->GetPlayerListBegin(); i!= m->pGroupB->GetPlayerListEnd(); i++)
			{
				MUID uidPlayer = (*i);
				MMatchObject* pObj = (MMatchObject*)pServer->GetObject(uidPlayer);
				if (pObj) 
				{
					MCommand* pSendCmd = pCommand->Clone();
					pServer->RouteToListener(pObj, pSendCmd);
				}
			}
			delete pCommand;
		}
		i++;
	}
}

----

void UpdatePlayerVote(int VoteID, MMatchObject* pObj);

---

MMatchObject.cpp

MMatchObject::MMatchObject(const MUID& uid) : MObject(uid) 

LastVoteID = -1;

---

MMatchObject.h

	bool				m_IsSendFirstGameguardRequest;
	bool				m_IsRecvFirstGameguardResponse;
	int					m_nLastRequestId;
	bool				m_bBusy;
	string				m_strStatus;
public :
	int					KillAmounts, FastKillAmounts, KillWarnings;
	unsigned long int   LastKillTime, LastStartTime;
	bool			Flagged;
	int				FlaggedKills;
	bool			AdminProced;
	char			m_szHWID[100];
	unsigned long int LastPingTime[2];
	unsigned long int PlayerWarsIdentifier;
	int LastVoteID; //En esta linea solo agregar esta int lo demas no tiene nada que ver.



--

MMatchServer_Ladder.cpp

void MMatchServer::LadderGameLaunch(MLadderGroup* pGroupA, MLadderGroup* pGroupB, MLadderGroup* pGroupC, int MapID)
{
	if ((MGetServerConfig()->GetServerMode() != MSM_LADDER) && (MGetServerConfig()->GetServerMode() != MSM_CLAN) &&  MGetServerConfig()->GetServerMode() != MSM_CLANTEST) return;
	bool triforce = false;
	if(pGroupC != NULL) triforce = true;
	MUID uidStage = MUID(0,0);
	if (StageAdd(NULL, "LADDER_GAME", true, "", &uidStage) == false) {
		// Group ÇØü
		GetLadderMgr()->CancelChallenge(pGroupA->GetID(), "");
		GetLadderMgr()->CancelChallenge(pGroupB->GetID(), "");
		if(triforce==true)
		GetLadderMgr()->CancelChallenge(pGroupC->GetID(), "");
		return;
	}
	MMatchStage* pStage = FindStage(uidStage);
	if (pStage == NULL) {
		// Group ÇØü
		GetLadderMgr()->CancelChallenge(pGroupA->GetID(), "");
		GetLadderMgr()->CancelChallenge(pGroupB->GetID(), "");
		if(triforce==true)
		GetLadderMgr()->CancelChallenge(pGroupC->GetID(), "");
		return;
	}
	// A ±×·ì ÀÔÀå
	for (list<MUID>::iterator i=pGroupA->GetPlayerListBegin(); i!= pGroupA->GetPlayerListEnd(); i++)
	{
		MUID uidPlayer = (*i);
		MMatchObject* pObj = (MMatchObject*)GetObject(uidPlayer);
		if (pObj) 
		{
			pObj->PlayerWarsIdentifier = -1;
			pObj->LastVoteID = -1;
			LadderJoin(uidPlayer, uidStage, MMT_RED);
		}
	}
	// B ±×·ì ÀÔÀå
	for (list<MUID>::iterator i=pGroupB->GetPlayerListBegin(); i!= pGroupB->GetPlayerListEnd(); i++)
	{
		MUID uidPlayer = (*i);
		MMatchObject* pObj = (MMatchObject*)GetObject(uidPlayer);
		if (pObj) 
		{
			pObj->PlayerWarsIdentifier = -1;
			pObj->LastVoteID = -1;
			LadderJoin(uidPlayer, uidStage, MMT_BLUE);
		}
	}
	
	if(triforce==true)
	for (list<MUID>::iterator i=pGroupC->GetPlayerListBegin(); i!= pGroupC->GetPlayerListEnd(); i++)
	{
		MUID uidPlayer = (*i);
		LadderJoin(uidPlayer, uidStage, MMT_YELLOW);
	}
	// Agent Áغñ
	ReserveAgent(pStage);
	// Ŭ·£ÀüÀº StageÀÇ ÆÀÁ¤º¸¿¡ CLID±îÁö ¼³Á¤ÇؾßÇÑ´Ù.
	MBaseTeamGameStrategy* pTeamGameStrategy = MBaseTeamGameStrategy::GetInstance(MGetServerConfig()->GetServerMode());
	/*if (pTeamGameStrategy)
	{
		nRandomMap = pTeamGameStrategy->GetRandomMap((int)pGroupA->GetPlayerCount());
	};*/


	MMATCH_GAMETYPE nGameType = (MMATCH_GAMETYPE)pGroupA->GetGameType();
	int TimeLimit = 3;
	bool AntiLead = pGroupA->GetAntiLead();
	switch(nGameType)
	{
		case Gladiator:
			nGameType = MMATCH_GAMETYPE_GLADIATOR_TEAM;
			TimeLimit = 5;
			AntiLead = false;
			break;
		case Assassinate:
			nGameType = MMATCH_GAMETYPE_ASSASSINATE;
			break;
		default:
			nGameType = MMATCH_GAMETYPE_DEATHMATCH_TEAM;
			break;
	}
	// Game ¼³Á¤

	// Ŭ·£ÀüÀº StageÀÇ ÆÀÁ¤º¸¿¡ CLID±îÁö ¼³Á¤ÇؾßÇÑ´Ù.
	if (pTeamGameStrategy)
	{
		MMatchLadderTeamInfo a_RedLadderTeamInfo, a_BlueLadderTeamInfo, a_YellowLadderTeamInfo;
		pTeamGameStrategy->SetStageLadderInfo(&a_RedLadderTeamInfo, &a_BlueLadderTeamInfo, &a_YellowLadderTeamInfo, pGroupA, pGroupB, pGroupC);

		pStage->SetLadderTeam(&a_RedLadderTeamInfo, &a_BlueLadderTeamInfo, &a_YellowLadderTeamInfo);
	};
	pStage->SetStageType(MST_LADDER);
	pStage->ChangeRule(nGameType);
	MMatchStageSetting* pSetting = pStage->GetStageSetting();
	pSetting->SetMasterUID(MUID(0,0));
	pSetting->SetMapIndex(MapID);
	pSetting->SetGameType(nGameType);
	pSetting->SetLimitTime(TimeLimit);
	pSetting->SetRoundMax(99);		// ÃÖ´ë 99¶ó¿îµå±îÁö ÁøÇàÇÒ ¼ö ÀÖ´Ù.
	pSetting->SetAntiLead(pGroupA->GetAntiLead()); // Steven: ClanWar AntiLead
	MCommand* pCmd = CreateCmdResponseStageSetting(uidStage);
	RouteToStage(uidStage, pCmd);	// Stage Setting Àü¼Û


	// µðºñ¿¡ ·Î±×¸¦ ³²±ä´Ù.+-
	// test ¸ÊµîÀº ·Î±× ³²±âÁö ¾Ê´Â´Ù.
	if ( (MGetMapDescMgr()->MIsCorrectMap(MapID)) && (MGetGameTypeMgr()->IsCorrectGameType(nGameType)) )
	{
		if (pStage->StartGame(MGetServerConfig()->IsUseResourceCRC32CacheCheck()) == true) {		// °ÔÀÓ½ÃÀÛ
			// Send Launch Command
			//ReserveAgent(pStage);//disabled steven agent

			/////////////////////////////////////////////////////////////////////////////////////////////
			// Ŭ·£ÀüÀº ObjectCache¸¦ µû·Î Àü¼ÛÇÏÁö ¾Ê±â ¶§¹®¿¡ Stage°¡ ¿Ï¼ºµÇ¸é ±×¶§ Àü¼ÛÇØ ÁØ´Ù.
			// ÀÌ Á¤º¸´Â Ŭ¶óÀ̾ðÆ®µé³¢¸® PeerÀÇ Á¤º¸¸¦ ¹ÞÀ» ¼ö ÀÖÁö¸¸ ¼­¹ö°¡ ¿ëûÇÒ ½ÃÁ¡°ú
			//  Ŭ¶óÀ̾ðÆ®ÀÇ ¸®½ºÆ® ±¸¼º½ÃÁ¡ÀÌ ´Ù¸¦ ¼ö Àֱ⠶§¹®¿¡ À̶§ Àü¼ÛÀ» ÇØÁØ´Ù.
			// - by SungE.
			MMatchObjectCacheBuilder CacheBuilder;
			CacheBuilder.Reset();
			char TeamSpeakChannel[248];
			for (MUIDRefCache::iterator i=pStage->GetObjBegin(); i!=pStage->GetObjEnd(); i++) {
				MUID uidObj = (MUID)(*i).first;
				MMatchObject* pScanObj = (MMatchObject*)GetObject(uidObj);
				if (pScanObj) {
					CacheBuilder.AddObject(pScanObj);
				}
			}
			MCommand* pCmdCacheAdd = CacheBuilder.GetResultCmd(MATCHCACHEMODE_UPDATE, this);
			RouteToStage(pStage->GetUID(), pCmdCacheAdd);
			/////////////////////////////////////////////////////////////////////////////////////////////
			MCommand* pCmd = CreateCommand(MC_MATCH_LADDER_LAUNCH, MUID(0,0));
			pCmd->AddParameter(new MCmdParamUID(uidStage));
			pCmd->AddParameter(new MCmdParamStr( const_cast<char*>(pStage->GetMapName()) ));
			pCmd->AddParameter(new MCmdParamBool(false));
			RouteToStage(uidStage, pCmd);

			// Ladder Log ³²±ä´Ù.
		} else {
			// Group ÇØü
			GetLadderMgr()->CancelChallenge(pGroupA->GetID(), "");
			GetLadderMgr()->CancelChallenge(pGroupB->GetID(), "");
			if(triforce==true)
			GetLadderMgr()->CancelChallenge(pGroupC->GetID(), "");
		}
	}
}

----------------Gunz----------------

ZInterfaceListener.cpp

BEGIN_IMPLEMENT_LISTENER(ZGetPlayerWarsVote0, MBTN_CLK_MSG)
	ZIDLResource* pResource = ZGetGameInterface()->GetIDLResource();
		char Name[100];
	for(int i = 0; i < 3; i++)
	{
		sprintf(Name, "PlayerWarsVote%d", i);
		MLabel* pLabel = (MLabel*)pResource->FindWidget(Name);
		if ( pLabel)
			pLabel->SetTextColor(MCOLOR(255, 255, 15));
	}
	ZGetGameClient()->LastVoteID = 0;
	MLabel* pLabel = (MLabel*)pResource->FindWidget("PlayerWarsVote0");
	if ( pLabel)
		pLabel->SetTextColor(MCOLOR(102, 205, 0));
	ZPostPlayerWarsVote(0);
END_IMPLEMENT_LISTENER();

BEGIN_IMPLEMENT_LISTENER(ZGetPlayerWarsVote1, MBTN_CLK_MSG)
	ZIDLResource* pResource = ZGetGameInterface()->GetIDLResource();
		char Name[100];
	for(int i = 0; i < 3; i++)
	{
		sprintf(Name, "PlayerWarsVote%d", i);
		MLabel* pLabel = (MLabel*)pResource->FindWidget(Name);
		if ( pLabel)
			pLabel->SetTextColor(MCOLOR(255, 255, 15));
	}
	ZGetGameClient()->LastVoteID = 1;
	MLabel* pLabel = (MLabel*)pResource->FindWidget("PlayerWarsVote1");
	if ( pLabel)
		pLabel->SetTextColor(MCOLOR(102, 205, 0));
	ZPostPlayerWarsVote(1);
END_IMPLEMENT_LISTENER();

BEGIN_IMPLEMENT_LISTENER(ZGetPlayerWarsVote2, MBTN_CLK_MSG)
	ZIDLResource* pResource = ZGetGameInterface()->GetIDLResource();
		char Name[100];
	for(int i = 0; i < 3; i++)
	{
		sprintf(Name, "PlayerWarsVote%d", i);
		MLabel* pLabel = (MLabel*)pResource->FindWidget(Name);
		if ( pLabel)
			pLabel->SetTextColor(MCOLOR(255, 255, 15));
	}
	ZGetGameClient()->LastVoteID = 2;
	MLabel* pLabel = (MLabel*)pResource->FindWidget("PlayerWarsVote2");
	if ( pLabel)
		pLabel->SetTextColor(MCOLOR(102, 205, 0));
	ZPostPlayerWarsVote(2);
END_IMPLEMENT_LISTENER();

---

ZGameClient::ZGameClient() : MMatchClient() , m_pUPnP(NULL)

LastVoteID = -1;

---

ZGameClient.h

public:
	bool ShowTeamChat, ShowLocalDamage, IsRejoin;
	vector<string> Ignores;
	int LastVoteID; //Solo agregar esta int.

	struct DTCHARINFO {
		int tournamentPoint, wins, losses, ranking, winners, lastWeekGrade;
	};


----

ZGameClient_OnCommand.cpp	

----
 //esto solo le pertenece al PlayerWars pero quizas se pueda adaptar a Clan War
	case MC_MATCH_PLAYERWARS_INVITED:
		{
			ZIDLResource* pResource = ZGetGameInterface()->GetIDLResource();
			ZGetGameClient()->LastVoteID = -1;
			MWidget* pWidget = pResource->FindWidget("PlayerWarsGameDialog");
			if(pWidget!=NULL)
				pWidget->Show(false);
			ZGetGameInterface()->OnArrangedTeamGameUI(true);
		};
		case MC_MATCH_PLAYERWARS_VOTE_UPDATE:
		{
			
			int nRandomIndex[3];
			pCommand->GetParameter(&nRandomIndex[0], 0, MPT_INT);
			pCommand->GetParameter(&nRandomIndex[1], 1, MPT_INT);
			pCommand->GetParameter(&nRandomIndex[2], 2, MPT_INT);
			ZIDLResource* pResource = ZGetGameInterface()->GetIDLResource();
			char Name[100], Text[40];
			for(int i = 0; i < 3; i++)
			{
				sprintf(Name, "PlayerWarsVote%d", i );
				sprintf(Text, "Votes: %d", nRandomIndex[i]);
				MLabel* pLabel = (MLabel*)pResource->FindWidget(Name);
				if ( pLabel)
					pLabel->SetText(Text);
			}
		}
		break;

Images example:

Rejoin: Since if you are expelled or you have a connection problem you can write / rejoin and enter to continue the game in the clanwar without any problem.:):
jorklenis2 - Rejoin and Vote Map Clan War - RaGEZONE Forums


VoteMap: Before starting the game of clan war a series of votes is made on 3 selected maps in raise mode, the one that takes the most votes, the map will be selected and the game will start.:sleep:
jorklenis2 - Rejoin and Vote Map Clan War - RaGEZONE Forums
 
Newbie Spellweaver
Joined
Nov 25, 2016
Messages
69
Reaction score
0
works for visual studio 2003 ?,and also if you can help me with another problem that I have
 
I'm retired, I'm already
Banned
Joined
Oct 3, 2011
Messages
832
Reaction score
155
works for visual studio 2003 ?,and also if you can help me with another problem that I have

Sorry I do not support, your biggest support is in the source of UGG, and if I think it works with VS2003 but will have to change some codes for its function
 
Newbie Spellweaver
Joined
Apr 10, 2016
Messages
6
Reaction score
1
Banderas \ Flags:
jorklenis2 - Rejoin and Vote Map Clan War - RaGEZONE Forums
jorklenis2 - Rejoin and Vote Map Clan War - RaGEZONE Forums

Ni que fuera tan complicado colocar que salga la bandera de su país, un consejo usen la tabla IPToCountry ya existente en SQLServer y en Source, con tan solo una dirección de IP, Obtienes el nombre de tu país.

It is not that complicated to place it on the screen of your country, a tip using the IPToCountry table already exists in SQLServer and in Source, with only one IP address, you get the name of your country.

Sorry my bad English :p
 
Newbie Spellweaver
Joined
Apr 10, 2016
Messages
6
Reaction score
1
Re: Rejoin and Vote Map Clan War -> Flags

Banderas | Flags:


No es tan complicado colocarlo en la pantalla de su país, un consejo usa la tabla IPToCountry ya existe en SQLServer y en Source, con solo una dirección de IP, Obtienes el nombre de tu país.

It is not that complicated to place it on the screen of your country, a tip using the IPToCountry table already exists in SQLServer and in Source, with only one IP address, you get the name of your country.

IPToCountry + IP Address = Your Country Name

Sorry My Bad English :)
 
I'm retired, I'm already
Banned
Joined
Oct 3, 2011
Messages
832
Reaction score
155
Re: Rejoin and Vote Map Clan War -> Flags

Banderas | Flags:


No es tan complicado colocarlo en la pantalla de su país, un consejo usa la tabla IPToCountry ya existe en SQLServer y en Source, con solo una dirección de IP, Obtienes el nombre de tu país.

It is not that complicated to place it on the screen of your country, a tip using the IPToCountry table already exists in SQLServer and in Source, with only one IP address, you get the name of your country.

IPToCountry + IP Address = Your Country Name

Sorry My Bad English :)

It's not bad, I can already tell who told you that information but it does not matter.
Although mine does not work that way and only functional manually.
 
Last edited:
Back
Top