Fix: WinXP HG crash

All Helbreath Server Source Discussion here.
Post Reply
Daxation
Regular
Posts: 56
Joined: Mon Apr 26, 2004 1:45 am

Post by Daxation »

aiigh i know i added this to the end of another post, but i thought i would put it in a new topic so more people can find it.


with windows xp if you are using a hgserver made from 2.14 source(fake 2.17 on hbss also applies :P) then you may have seen it shut down and give you 1 of those annoying windows xp errors. i narrowed this down to being /createitem related. so if you replace /createitem with the following source it should work perfectly..

Code: Select all

void CGame::AdminOrder_CreateItem(int iClientH, char *pData, DWORD dwMsgSize)
{
 char   seps[] = "= \t\n";
 char   * cp, * token, cBuff[256], cItemName[256], cData[256], cTemp[256];
 SYSTEMTIME SysTime;
 class  CStrTok * pStrTok;
 class  CItem * pItem;
 short  * sp;
 int    iRet, iEraseReq;
 DWORD * dwp;
 WORD  * wp;
 
	if (m_pClientList[iClientH] == NULL) return;
	if ((dwMsgSize)	<= 0) return;

	if (m_pClientList[iClientH]->m_iAdminUserLevel < 3) {
  // Admin user levelÀÌ ³·¾Æ¼­ ÀÌ ±â´ÉÀ» »ç¿ëÇÒ ¼ö ¾ø´Ù.
  if (m_pClientList[iClientH]->m_iAdminUserLevel !=  0)	
  	SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
  return;
	}
	// ¾ÆÀÌÅÛ »ý¼º È®ÀÎ Äڵ尡 ÀԷµÇÁö ¾Ê¾Ò´Ù¸é ¸¸µé ¼ö ¾ø´Ù.
	if (m_pClientList[iClientH]->m_bIsAdminCreateItemEnabled == FALSE) return;


	ZeroMemory(cBuff, sizeof(cBuff));
	memcpy(cBuff, pData, dwMsgSize);

	pStrTok = new class CStrTok(cBuff, seps);
	token = pStrTok->pGet();
	
	token = pStrTok->pGet();
	if (token != NULL) {
  ZeroMemory(cItemName, sizeof(cItemName));
  strcpy(cItemName, token);
	}

	// ¾ÆÀÌÅÛÀ» ¸¸µé°í 
	pItem = new class CItem;
	// ±âº» Ư¼ºÀ¸·Î ¾ÆÀÌÅÛ »ý¼º 
	if (_bInitItemAttr(pItem, cItemName) == FALSE) {
  delete pItem;
  return;	
	}

	// ¾ÆÀÌÅÛ¿¡ °íÀ¯ ÄÚµå ÀԷ ȤÀº ³¯Â¥ÀÔ·Â 
	switch (pItem->m_sIDnum) {
	case 511: // ÀÔÀå±Ç·ù´Ù. ³¯Â¥ÀÔ·Â
	case 513:
	case 515:
	case 517:
	case 530:
	case 531:
	case 532:
	case 533:
	case 534:
  GetLocalTime(&SysTime);
  pItem->m_sTouchEffectType   = DEF_ITET_DATE;
  // v1.4311-3 º¯°æ ¿î¿µÀÚ°¡ ¹ß±ÞÇÑ ÀÔÀå±ÇÀº ±×³¯Àº Ç×»ó ÀÔÀå °¡´É ..
  pItem->m_sTouchEffectValue1 = (short)SysTime.wMonth;
  pItem->m_sTouchEffectValue2 = (short)SysTime.wDay;
  pItem->m_sTouchEffectValue3 = 24;
  break;

	default:
  GetLocalTime(&SysTime);
  pItem->m_sTouchEffectType   = DEF_ITET_ID;
  pItem->m_sTouchEffectValue1 = iDice(1,100000);
  pItem->m_sTouchEffectValue2 = iDice(1,100000);
  // ¸¶Áö¸· ¼ýÀÚ´Â ¾ÆÀÌÅÛ »ý¼º ¿ù, ÀÏ	
  ZeroMemory(cTemp, sizeof(cTemp));
  wsprintf(cTemp, "%d%2d",  (short)SysTime.wMonth, (short)SysTime.wDay);
  pItem->m_sTouchEffectValue3 = atoi(cTemp);
  break;
	}
	
	ZeroMemory(cData, sizeof(cData));
	if (_bAddClientItemList(iClientH, pItem, &iEraseReq) == TRUE) {
  // ¾ÆÀÌÅÛÀ» ȹµæÇß´Ù.
  dwp  = (DWORD *)(cData + DEF_INDEX4_MSGID);
  *dwp = MSGID_NOTIFY;
  wp   = (WORD *)(cData + DEF_INDEX2_MSGTYPE);
  *wp  = DEF_NOTIFY_ITEMOBTAINED;
  
  cp = (char *)(cData + DEF_INDEX2_MSGTYPE + 2);
  
  // 1°³ ȹµæÇß´Ù. Amount°¡ ¾Æ´Ï´Ù!
  *cp = 1;
  cp++;
  
  memcpy(cp, pItem->m_cName, 20);
  cp += 20;
  
  dwp  = (DWORD *)cp;
  *dwp = pItem->m_dwCount;	// ¼ö·®À» ÀÔ·Â 
  cp += 4;
  
  *cp = pItem->m_cItemType;
  cp++;
  
  *cp = pItem->m_cEquipPos;
  cp++;
  
  *cp = (char)0; // ¾òÀº ¾ÆÀÌÅÛÀ̹ǷΠÀåÂøµÇÁö ¾Ê¾Ò´Ù.
  cp++;
  
  sp  = (short *)cp;
  *sp = pItem->m_sLevelLimit;
  cp += 2;
  
  *cp = pItem->m_cGenderLimit;
  cp++;
  
  wp = (WORD *)cp;
  *wp = pItem->m_wCurLifeSpan;
  cp += 2;
  
  wp = (WORD *)cp;
  *wp = pItem->m_wWeight;
  cp += 2;
  
  sp  = (short *)cp;
  *sp = pItem->m_sSprite;
  cp += 2;
  
  sp  = (short *)cp;
  *sp = pItem->m_sSpriteFrame;
  cp += 2;
  
  *cp = pItem->m_cItemColor;
  cp++;

  *cp = (char)pItem->m_sItemSpecEffectValue2; // v1.41 
  cp++;
  
  dwp = (DWORD *)cp;
  *dwp = pItem->m_dwAttribute;
  cp += 4;
    
  if (iEraseReq == 1) {
  	delete pItem;
  }
  
  // ¾ÆÀÌÅÛ Á¤º¸ Àü¼Û 
  iRet = m_pClientList[iClientH]->m_pXSock->iSendMsg(cData, 53);
  
  // v1.41 Èñ±Í ¾ÆÀÌÅÛÀ̶ó¸é ·Î±×¸¦ ³²±ä´Ù. 
  _bItemLog(DEF_ITEMLOG_GET, iClientH, NULL, pItem);
  return;
	}
	else {
  // ¾ÆÀÌÅÛÀ» ¼ÒÁöÇÒ ¼ö ¾ø´Â »óȲÀÌ´Ù.  
  delete pItem;
  return;
	}
}
NOTE: this wont stop every single crash ur hg has ever had.. crashes are always going to be around in hbx files(but you guys did a great job tho)

this only stops the windows error crash
Chotudo
noob
Posts: 20
Joined: Sun Oct 10, 2004 5:44 pm

Post by Chotudo »

i use 3.51 source!! try it
drunk
Loyal fan
Posts: 265
Joined: Wed Mar 17, 2004 1:43 pm

Post by drunk »

Lets see your 3.51 source.
DMZ2
noob
Posts: 21
Joined: Sun Jan 16, 2005 10:06 am

Post by DMZ2 »

ty Daxation
Post Reply