Jump to content

Phase Game Fix - does not handle this header (header: 81, last: 45, 81)


wezt

Recommended Posts

Hello,

I'd like to share a fix for "Phase Game does not handle this header (header: 81, last: 45, 81)".

Spoiler

This error usually happens when players on low-lvl characters teleporting between different maps (as far I noticed this also happens only on wireless connection).

At least these symptoms were on my server.

 

Let's start ;)

First of all I'd like to begin from adding some debug info in client, in order to be sure that this fix is necessary (check spoiler below).

Spoiler

Go in Client_source\UserInterface\PythonNetworkStreamPhaseGame.cpp

Find there "bool CPythonNetworkStream::RecvQuestInfoPacket()": and replace:


	if (0 != (c_rFlag & QUEST_SEND_TITLE))
	{
		if (!Recv(sizeof(szTitle), &szTitle))
			return false;

		szTitle[30]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_CLOCK_NAME))
	{
		if (!Recv(sizeof(szClockName), &szClockName))
			return false;

		szClockName[16]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_CLOCK_VALUE))
	{
		if (!Recv(sizeof(iClockValue), &iClockValue))
			return false;
	}
	if (0 != (c_rFlag & QUEST_SEND_COUNTER_NAME))
	{
		if (!Recv(sizeof(szCounterName), &szCounterName))
			return false;

		szCounterName[16]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_COUNTER_VALUE))
	{
		if (!Recv(sizeof(iCounterValue), &iCounterValue))
			return false;
	}
	if (0 != (c_rFlag & QUEST_SEND_ICON_FILE))
	{
		if (!Recv(sizeof(szIconFileName), &szIconFileName))
			return false;

		szIconFileName[24]='\0';
	}

With:


	if (0 != (c_rFlag & QUEST_SEND_TITLE))
	{
		if (!Recv(sizeof(szTitle), &szTitle))
		{
			TraceError("!Recv(sizeof(szTitle), &szTitle)");
			return false;
		}

		szTitle[30]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_CLOCK_NAME))
	{
		if (!Recv(sizeof(szClockName), &szClockName))
		{
			TraceError("!Recv(sizeof(szClockName), &szClockName)");
			return false;
		}

		szClockName[16]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_CLOCK_VALUE))
	{
		if (!Recv(sizeof(iClockValue), &iClockValue))
		{
			TraceError("!Recv(sizeof(iClockValue), &iClockValue)");
			return false;
		}
	}
	if (0 != (c_rFlag & QUEST_SEND_COUNTER_NAME))
	{
		if (!Recv(sizeof(szCounterName), &szCounterName))
		{
			TraceError("!Recv(sizeof(szCounterName), &szCounterName)");
			return false;
		}
		szCounterName[16]='\0';
	}
	if (0 != (c_rFlag & QUEST_SEND_COUNTER_VALUE))
	{
		if (!Recv(sizeof(iCounterValue), &iCounterValue))
		{
			TraceError("!Recv(sizeof(iCounterValue), &iCounterValue)");
			return false;
		}
	}
	if (0 != (c_rFlag & QUEST_SEND_ICON_FILE))
	{
		if (!Recv(sizeof(szIconFileName), &szIconFileName))
		{
			TraceError("!Recv(sizeof(szIconFileName), &szIconFileName)");
			return false;
		}

		szIconFileName[24]='\0';
	}

 

Compile your game client and try to catch an error with header.

Check out client syserr.txt. There should be more info (we've added it with previous changes). If you'll have there something like this:

Spoiler

0504 19:17:23903 :: !Recv(sizeof(szTitle), &szTitle)
0504 19:17:23903 :: Phase Game does not handle this header (header: 81, last: 45, 81)
0504 19:17:23903 :: Unknown packet header blabla

Means that this fix is for you ;)

At this point we'll start with fix (if you didn't have "!Recv(sizeof(BLA), &BLA)" in syserr.txt I don't sure that this fix is for you).


GAME SOURCE:

game/src/packet.h

Spoiler

Find:


struct packet_quest_info

Replace it with next one:


struct packet_quest_info
{
	BYTE	header;
	WORD	size;
	WORD	index;
	BYTE	flag;
	char	szTitle[30 + 1];
	BYTE	isBegin;
	char	szClockName[16 + 1];
	int		iClockValue;
	char	szCounterName[16 + 1];
	int		iCounterValue;
	char	szIconFileName[24 + 1];
};

game/src/questpc.cpp

Spoiler

Find:


void PC::SendQuestInfoPakcet()

Replace whole function with next one:


	void PC::SendQuestInfoPakcet()
	{
		assert(m_iSendToClient);
		assert(m_RunningQuestState);

		packet_quest_info qi;

		qi.header = HEADER_GC_QUEST_INFO;
		qi.size = sizeof(struct packet_quest_info);
		qi.index = m_RunningQuestState->iIndex;
		qi.flag = m_iSendToClient;

		if (m_iSendToClient & QUEST_SEND_TITLE)
		{
			m_RunningQuestState->_title.reserve(30+1);
			strlcpy(qi.szTitle, m_RunningQuestState->_title.c_str(), sizeof(qi.szTitle));
			qi.szTitle[30] = '\0';
		}
		else
			qi.szTitle[30 + 1] = '\0';

		if (m_iSendToClient & QUEST_SEND_ISBEGIN)
		{
			qi.isBegin = m_RunningQuestState->bStart?1:0;
		}
		else
			qi.isBegin = 0;

		if (m_iSendToClient & QUEST_SEND_CLOCK_NAME)
		{
			m_RunningQuestState->_clock_name.reserve(16+1);
			strlcpy(qi.szClockName, m_RunningQuestState->_clock_name.c_str(), sizeof(qi.szClockName));
			qi.szClockName[16] = '\0';
		}
		else
			qi.szClockName[16] = '\0';

		if (m_iSendToClient & QUEST_SEND_CLOCK_VALUE)
		{
			qi.iClockValue = m_RunningQuestState->_clock_value;
		}
		else
			qi.iClockValue = 0;

		if (m_iSendToClient & QUEST_SEND_COUNTER_NAME)
		{
			m_RunningQuestState->_counter_name.reserve(16+1);
			strlcpy(qi.szCounterName, m_RunningQuestState->_counter_name.c_str(), sizeof(qi.szCounterName));
			qi.szCounterName[16] = '\0';
		}
		else
			qi.szCounterName[16] = '\0';

		if (m_iSendToClient & QUEST_SEND_COUNTER_VALUE)
		{
			qi.iCounterValue = m_RunningQuestState->_counter_value;
		}
		else
			qi.iCounterValue = 0;

		if (m_iSendToClient & QUEST_SEND_ICON_FILE)
		{
			m_RunningQuestState->_icon_file.reserve(24+1);
			strlcpy(qi.szIconFileName, m_RunningQuestState->_icon_file.c_str(), sizeof(qi.szIconFileName));
			qi.szIconFileName[24] = '\0';
		}
		else
			qi.szIconFileName[24] = '\0';

		CQuestManager::instance().GetCurrentCharacterPtr()->GetDesc()->Packet(&qi, sizeof(qi));

		m_iSendToClient = 0;
	}

 

 

CLIENT SOURCE:

UserInterface\Packet.h

Spoiler

Find:


typedef struct packet_quest_info

Replace with:


typedef struct packet_quest_info
{
	BYTE	header;
	WORD	size;
	WORD	index;
	BYTE	flag;
	char	szTitle[30 + 1];
	BYTE	isBegin;
	char	szClockName[16 + 1];
	int		iClockValue;
	char	szCounterName[16 + 1];
	int		iCounterValue;
	char	szIconFileName[24 + 1];
} TPacketGCQuestInfo;

UserInterface\PythonNetworkStreamPhaseGame.cpp

Spoiler

Find:


bool CPythonNetworkStream::RecvQuestInfoPacket()

Replace whole function with next one:

  1. bool CPythonNetworkStream::RecvQuestInfoPacket()
  2. {
  3.     TPacketGCQuestInfo QuestInfo;
  4.  
  5.     if (!Peek(sizeof(TPacketGCQuestInfo), &QuestInfo))
  6.     {
  7.         Tracen("Recv Quest Info Packet Error #1");
  8.         TraceError("Recv Quest Info Packet Error #1");
  9.         return false;
  10.     }
  11.  
  12.     if (!Peek(QuestInfo.size))
  13.     {
  14.         Tracen("Recv Quest Info Packet Error #2");
  15.         TraceError("Recv Quest Info Packet Error #2");
  16.         return false;
  17.     }
  18.  
  19.     Recv(sizeof(TPacketGCQuestInfo));
  20.  
  21.     const BYTE & c_rFlag = QuestInfo.flag;
  22.  
  23.     enum
  24.     {
  25.         QUEST_PACKET_TYPE_NONE,
  26.         QUEST_PACKET_TYPE_BEGIN,
  27.         QUEST_PACKET_TYPE_UPDATE,
  28.         QUEST_PACKET_TYPE_END,
  29.     };
  30.  
  31.     BYTE byQuestPacketType = QUEST_PACKET_TYPE_NONE;
  32.  
  33.     if (0 != (c_rFlag & QUEST_SEND_IS_BEGIN))
  34.     {
  35.         BYTE isBegin = QuestInfo.isBegin;
  36.  
  37.         if (isBegin)
  38.             byQuestPacketType = QUEST_PACKET_TYPE_BEGIN;
  39.         else
  40.             byQuestPacketType = QUEST_PACKET_TYPE_END;
  41.     }
  42.     else
  43.     {
  44.         byQuestPacketType = QUEST_PACKET_TYPE_UPDATE;
  45.     }
  46.  
  47.     // Recv Data Start
  48.     char szTitle[30 + 1] = "";
  49.     char szClockName[16 + 1] = "";
  50.     int iClockValue = 0;
  51.     char szCounterName[16 + 1] = "";
  52.     int iCounterValue = 0;
  53.     char szIconFileName[24 + 1] = "";
  54.  
  55.     if (0 != (c_rFlag & QUEST_SEND_TITLE))
  56.     {
  57.         strncpy(szTitle, QuestInfo.szTitle, sizeof(szTitle));
  58.  
  59.         szTitle[30]='\0';
  60.     }
  61.  
  62.     if (0 != (c_rFlag & QUEST_SEND_CLOCK_NAME))
  63.     {
  64.         strncpy(szClockName, QuestInfo.szClockName, sizeof(szClockName));
  65.  
  66.         szClockName[16]='\0';
  67.     }
  68.  
  69.     if (0 != (c_rFlag & QUEST_SEND_CLOCK_VALUE))
  70.     {
  71.         iClockValue = QuestInfo.iClockValue;
  72.     }
  73.  
  74.     if (0 != (c_rFlag & QUEST_SEND_COUNTER_NAME))
  75.     {
  76.         strncpy(szCounterName, QuestInfo.szCounterName, sizeof(szCounterName));
  77.  
  78.         szCounterName[16]='\0';
  79.     }
  80.  
  81.     if (0 != (c_rFlag & QUEST_SEND_COUNTER_VALUE))
  82.     {
  83.         iCounterValue = QuestInfo.iCounterValue;
  84.     }
  85.  
  86.     if (0 != (c_rFlag & QUEST_SEND_ICON_FILE))
  87.     {
  88.         strncpy(szIconFileName, QuestInfo.szIconFileName, sizeof(szIconFileName));
  89.  
  90.         szIconFileName[24]='\0';
  91.     }
  92.     // Recv Data End
  93.  
  94.     CPythonQuest& rkQuest=CPythonQuest::Instance();
  95.  
  96.     // Process Start
  97.     if (QUEST_PACKET_TYPE_END == byQuestPacketType)
  98.     {
  99.         rkQuest.DeleteQuestInstance(QuestInfo.index);
  100.     }
  101.     else if (QUEST_PACKET_TYPE_UPDATE == byQuestPacketType)
  102.     {
  103.         if (!rkQuest.IsQuest(QuestInfo.index))
  104.         {
  105.             rkQuest.MakeQuest(QuestInfo.index);
  106.         }
  107.  
  108.         if (strlen(szTitle) > 0)
  109.             rkQuest.SetQuestTitle(QuestInfo.index, szTitle);
  110.         if (strlen(szClockName) > 0)
  111.             rkQuest.SetQuestClockName(QuestInfo.index, szClockName);
  112.         if (strlen(szCounterName) > 0)
  113.             rkQuest.SetQuestCounterName(QuestInfo.index, szCounterName);
  114.         if (strlen(szIconFileName) > 0)
  115.             rkQuest.SetQuestIconFileName(QuestInfo.index, szIconFileName);
  116.  
  117.         if (c_rFlag & QUEST_SEND_CLOCK_VALUE)
  118.             rkQuest.SetQuestClockValue(QuestInfo.index, iClockValue);
  119.         if (c_rFlag & QUEST_SEND_COUNTER_VALUE)
  120.             rkQuest.SetQuestCounterValue(QuestInfo.index, iCounterValue);
  121.     }
  122.     else if (QUEST_PACKET_TYPE_BEGIN == byQuestPacketType)
  123.     {
  124.         CPythonQuest::SQuestInstance QuestInstance;
  125.         QuestInstance.dwIndex = QuestInfo.index;
  126.         QuestInstance.strTitle = szTitle;
  127.         QuestInstance.strClockName = szClockName;
  128.         QuestInstance.iClockValue = iClockValue;
  129.         QuestInstance.strCounterName = szCounterName;
  130.         QuestInstance.iCounterValue = iCounterValue;
  131.         QuestInstance.strIconFileName = szIconFileName;
  132.         CPythonQuest::Instance().RegisterQuestInstance(QuestInstance);
  133.     }
  134.     // Process Start End
  135.     PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RefreshQuest", Py_BuildValue("()"));
  136.     return true;
  137. }

 

That's it. As you can see we've just deleted TEMP_BUFFER from server function and put all data in packet body.

 

Spoiler

P.S.:

1. I'm very hope that you'll make backup for your source before apply this fix.

2. I cannot promise that this will fix the problem for you (but I'm 100% sure that problem was solved on my server with current fix ;) ).

3. If you'll repost this solution somewhere, please keep credits in your repost.

And last thing. Would be nice to hear if this solution solved header 81 problem on your servers.

 

Let me know if you'll have problems with compiling (I could forget to add something in this TUT).

And sorry if my English isn't good enough for you :)

 

Regards.

  • Metin2 Dev 3
  • Love 11
Link to comment
Share on other sites

please help 

 

game compile:
questpc.cpp: In member function 'void quest::PC::SendQuestInfoPakcet()':
questpc.cpp:335: error: expected primary-expression before ';' token
questpc.cpp:338: error: expected primary-expression before ';' token
questpc.cpp:354: error: expected primary-expression before ';' token
questpc.cpp:370: error: expected primary-expression before ';' token
questpc.cpp:383: error: expected primary-expression before ';' token
gmake: *** [OBJDIR/questpc.o] Error 1
 

 

 

Link to comment
Share on other sites

  • 11 months later...

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.