Jump to content

Fix for Phase Select Empire


Recommended Posts

  • Active Member

Hello friends and enemies, ladies and gentlemans,

I was playing with my introEmpire.py and as always I got an obstacle in my way, the "select empire phase" was not working properly.

 

BEFORE(ymir):

- Client was receiving a random number(1,3) if you didn't had an empire selected.

- Packet that sends "simple information" to the client was called after changing the phase to "select phase".

 

AFTER:

- Client is receiving correctly the empire ID.

- Client is initializing the "select empire" phase if you have no characters on your account (if pid columns in table player.player_index are set on 0)

 

NOTE:

- Other bugs not tested yet but everything seems to be OK for now ...

- Need to do something about the remaining row in player.player_index table after deleting all the characters on the account.(too lazy, too sleepy now 6:33 AM ...)

 

Here is the FIX(minimalist tutorial):

root/introSelect.py (disabling the reselectempire phase)

Spoiler

Replace EMPIRE_MODE = 1 with EMPIRE_MODE = 0

 

game/src/input_db.cpp

Spoiler


void CInputDB::LoginSuccess(DWORD dwHandle, const char *data)
{
	sys_log(0, "LoginSuccess");

	TAccountTable * pTab = (TAccountTable *)data;

	itertype(g_sim) it = g_sim.find(pTab->id);
	if (g_sim.end() != it)
	{
		sys_log(0, "CInputDB::LoginSuccess - already exist sim [%s]", pTab->login);
		it->second->SendLoad();
		return;
	}

	LPDESC d = DESC_MANAGER::instance().FindByHandle(dwHandle);

	if (!d)
	{
		sys_log(0, "CInputDB::LoginSuccess - cannot find handle [%s]", pTab->login);

		TLogoutPacket pack;

		strlcpy(pack.login, pTab->login, sizeof(pack.login));
		db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));
		return;
	}

	if (strcmp(pTab->status, "OK")) // OK°ˇ ľĆ´Ď¸é
	{
		sys_log(0, "CInputDB::LoginSuccess - status[%s] is not OK [%s]", pTab->status, pTab->login);

		TLogoutPacket pack;

		strlcpy(pack.login, pTab->login, sizeof(pack.login));
		db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));

		LoginFailure(d, pTab->status);
		return;
	}

	//for (int i = 0; i != PLAYER_PER_ACCOUNT; ++i)
	//{
	//	TSimplePlayer& player = pTab->players[i];
	//	sys_log(0, "\tplayer(%s).job(%d)", player.szName, player.byJob); // scos 28 mai 2018
	//}

	bool bFound = GetServerLocation(*pTab, pTab->bEmpire);

	d->BindAccountTable(pTab);

#ifndef ENABLE_FIX_SELECT_EMPIRE_PHASE
	if (!bFound) // Äł¸ŻĹÍ°ˇ ľřŔ¸¸é ·Ł´ýÇŃ Á¦±ąŔ¸·Î ş¸ł˝´Ů.. -_-
	{
		TPacketGCEmpire pe;
		pe.bHeader = HEADER_GC_EMPIRE;
		pe.bEmpire = number(1, 3);
		d->Packet(&pe, sizeof(pe));
	}
	else
	{
#endif
		TPacketGCEmpire pe;
		pe.bHeader = HEADER_GC_EMPIRE;
#ifdef ENABLE_FIX_SELECT_EMPIRE_PHASE
		BYTE realEmpire = 0; // temporary fix
		for (int i = 0; i != PLAYER_PER_ACCOUNT; ++i)
		{
			TSimplePlayer& player = pTab->players[i];
			if (player.dwID)
			{
				realEmpire = d->GetEmpire();
				break;
			}
		}
		pe.bEmpire = realEmpire;
#else
		pe.bEmpire = d->GetEmpire();
#endif
		d->Packet(&pe, sizeof(pe));
#ifndef ENABLE_FIX_SELECT_EMPIRE_PHASE
	}
#endif

#ifdef ENABLE_FIX_SELECT_EMPIRE_PHASE
	d->SendLoginSuccessPacket(); // Trimite pachetul de logare si informatiile simple ale contului inainte de faza de select
	d->SetPhase(PHASE_SELECT);
#else
	d->SetPhase(PHASE_SELECT);
	d->SendLoginSuccessPacket();
#endif

#ifdef ENABLE_FIX_SELECT_EMPIRE_PHASE
	// [28 mai 2018] Exygo's note: Daca tot am dat de acest sys_log, macar sa-l facem cum trebuie ...
	char bufPids[48 + 1];
	int bufPidsSize = snprintf(bufPids, sizeof(bufPids), " ");
	for (int i = 0; i != PLAYER_PER_ACCOUNT; ++i)
	{
		TSimplePlayer& player = pTab->players[i];
		DWORD pid = player.dwID;
		bufPidsSize += snprintf(bufPids + bufPidsSize, sizeof(bufPids) - bufPidsSize, "%d, ", pid);
	}

	sys_log(0, "InputDB::login_success: username(%s), pids(%s)", pTab->login, bufPids);
#endif
}

 

 

  • Good 1
  • Love 5
Link to comment
Share on other sites

  • 5 years later...
void CInputDB::LoginSuccess(DWORD dwHandle, const char *data)
{
	sys_log(0, "LoginSuccess");

	TAccountTable * pTab = (TAccountTable *) data;

	LPDESC d = DESC_MANAGER::instance().FindByHandle(dwHandle);

	if (!d)
	{
		sys_log(0, "CInputDB::LoginSuccess - cannot find handle [%s]", pTab->login);

		TLogoutPacket pack;

		strlcpy(pack.login, pTab->login, sizeof(pack.login));
		db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));
		return;
	}

	if (strcmp(pTab->status, "OK")) // if not ok
	{
		sys_log(0, "CInputDB::LoginSuccess - status[%s] is not OK [%s]", pTab->status, pTab->login);

		TLogoutPacket pack;

		strlcpy(pack.login, pTab->login, sizeof(pack.login));
		db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));

		LoginFailure(d, pTab->status);
		return;
	}

	const bool bFound{ GetServerLocation(*pTab, pTab->bEmpire) };

	d->BindAccountTable(pTab);

	if (bFound)
	{
		TPacketGCEmpire pe;
		pe.bHeader = HEADER_GC_EMPIRE;
		pe.bEmpire = d->GetEmpire();
		d->Packet(&pe, sizeof(pe));
	}

	d->SendLoginSuccessPacket();
	d->SetPhase(PHASE_SELECT);

	sys_log(0, "InputDB::LoginSucces: account.login: %s", pTab->login);
}

 

With this if you don't have an assigned empire on your account, at login you will be prompted directly to empire select. (use it with empire reselect feature disabled, with it enabled you will trigger double empire selection on an account with all slots free)

Edited by [TiTAN]
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.