needing help

All Helbreath Server Source Discussion here.
Post Reply
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

im having some trouble with the decode function of NpcItem config... i was using the WLServer of hypno to send the config but the wl still incomplete and not useable! and im too noob to fix all bugs :( so i modified the function to read the config from GameConfigs and it doesnt work :(, i dont know why because i did it with the Teleport,World and Crafting Decoding and works perfect... just the NpcItem is giving me trouble :( once i get it fixed i'll release my files to public have a lots of shit fixed and at latest heldenian and apoc released by snoopy working on it 100% ^^

im having this:
(2006:10:12:17:24) - (!) Reading NpcItem.cfg...
(2006:10:12:17:24) - (!!!) CRITICAL ERROR! NPCITEM configuration file error - No exist Npc Name
when i get back the function to WLServer cfg sended Loading it works perfect then i modif i get this error... a help will be apreciated =x

the function:

Code: Select all

BOOL CGame::_bDecodeNpcItemConfigFileContents(char *pFn)
{
 FILE * pFile;
 HANDLE hFile;
 DWORD  dwFileSize;
 char * cp, * token, cReadModeA = 0, cReadModeB = 0;
 char seps[] = "= \t\n";
 class CStrTok * pStrTok;
 int  iNpcConfigListIndex = 0;
 int k = 0;
 class CNpcItem * pTempNpcItem = NULL;
 int   iIndex = 0;

	hFile = CreateFile(pFn, GENERIC_READ, NULL, NULL, OPEN_EXISTING, NULL, NULL);
	dwFileSize = GetFileSize(hFile, NULL);
	if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
	pFile = fopen(pFn, "rt");
	if (pFile == NULL) {
	PutLogList("(!) Cannot open NpcItem.cfg file.");
	return FALSE;
	}
        else {
	PutLogList("(!) Reading NpcItem.cfg...");
	cp = new char[dwFileSize+2];
	ZeroMemory(cp, dwFileSize+2);
	fread(cp, dwFileSize, 1, pFile);

	pStrTok = new class CStrTok(cp, seps);
	token = pStrTok->pGet();
	while( token != NULL ) {
  if (cReadModeA != 0) {
  	switch (cReadModeA) {
  	case 1:

    switch (cReadModeB) {

    case 1:
    	// NPC À̸§
    	if (strlen(token) > 20)	{
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Too long Npc name.");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}
    	for (iNpcConfigListIndex = 0; iNpcConfigListIndex < DEF_MAXNPCTYPES; iNpcConfigListIndex++)
      if (m_pNpcConfigList[iNpcConfigListIndex] != NULL) {
      	if(strcmp(m_pNpcConfigList[iNpcConfigListIndex]->m_cNpcName,token) == 0) {
        PutLogList(token);
        break;	
      	}
      }

    	if (iNpcConfigListIndex == DEF_MAXNPCTYPES ) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - No exist Npc Name");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}

    	cReadModeB = 2;
    	break;

    case 2:
    	if( strlen(token) > 2 ) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Type Error.");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}

    	m_pNpcConfigList[iNpcConfigListIndex]->m_iNpcitemType = atoi(token);

    	cReadModeB = 3;
    	break;

    case 3:
    	if (strlen(token) > 20)	{
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Too long Item name.");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}

    	if (pTempNpcItem == NULL)
      pTempNpcItem = new class CNpcItem();


    	if( memcmp(token,"[ENDITEM]",9) == 0 ){
      cReadModeA = 0;
      cReadModeB = 0;

      if ( pTempNpcItem  != NULL) {
      	delete pTempNpcItem; 
      	pTempNpcItem = NULL;
      }
      break;
    	}
    	
    	strcpy(pTempNpcItem->m_cName, token);

    	for(k = 0; k<DEF_MAXITEMTYPES; k++) {
         if (m_pItemConfigList[k] != NULL) {   
          if (strcmp(token, m_pItemConfigList[k]->m_cName) == 0 ) {
           pTempNpcItem->m_sItemID = m_pItemConfigList[k]->m_sIDnum;
           }
         }
         else {
         break;
        }
    	}


    	if ( k == DEF_MAXITEMTYPES ) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration error - Do Not exist in ITEM LIST");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}

    	cReadModeB = 4;
    	break;

    case 4:
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Wrong Data format.");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}
    	pTempNpcItem->m_sFirstProbability = atoi(token);

    	if (pTempNpcItem->m_sFirstProbability <= 0 ) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - First probability have wrong value");
      delete cp;
      delete pStrTok;
      return FALSE; 
    	}

    	if ( pTempNpcItem->m_sFirstProbability > 13) 
      pTempNpcItem->m_cFirstTargetValue = 13;
    	else if ( pTempNpcItem->m_sFirstProbability > 3) 
      pTempNpcItem->m_cFirstTargetValue = 3;
    	else 
      pTempNpcItem->m_cFirstTargetValue = 1;
      
    	cReadModeB = 5;
    	break;

    case 5:
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Wrong Data format.");
      delete cp;
      delete pStrTok;
      return FALSE;
    	}

    	pTempNpcItem->m_sSecondProbability = atoi(token);

    	if (pTempNpcItem->m_sSecondProbability <= 0 ) {
      PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file error - Second probability have wrong value");
      delete cp;
      delete pStrTok;
      return FALSE; 
    	}

    	if ( pTempNpcItem->m_sSecondProbability > 13) 
      pTempNpcItem->m_cSecondTargetValue = 13;
    	else if ( pTempNpcItem->m_sSecondProbability > 3) 
      pTempNpcItem->m_cSecondTargetValue = 3;
    	else 
      pTempNpcItem->m_cSecondTargetValue = 1;

    	cReadModeB = 3;
  	
    	m_pNpcConfigList[iNpcConfigListIndex]->m_vNpcItem.push_back(*pTempNpcItem);

    	if( m_pNpcConfigList[iNpcConfigListIndex]->m_iNpcitemMax < pTempNpcItem->m_sSecondProbability )
      m_pNpcConfigList[iNpcConfigListIndex]->m_iNpcitemMax = pTempNpcItem->m_sSecondProbability;

    	break;

    }

  	default: 
    break;

  	}
  }
  else {

  	if (memcmp(token, "NpcItem", 7) == 0) {
    cReadModeA = 1;
    cReadModeB = 1;
  	
  	}
  }
  token = pStrTok->pGet();
	}

	delete pStrTok;
	delete cp;

	if ((cReadModeA != 0) || (cReadModeB != 0)) {
  PutLogList("(!!!) CRITICAL ERROR! NPCITEM configuration file contents error!");
  return FALSE;
	}


	if (pFile != NULL) fclose(pFile);
  wsprintf(G_cTxt, "(!) NPCITEM-LIST(Total:%d) configuration - success!", iNpcConfigListIndex);
  PutLogList(G_cTxt);
  return TRUE;
        }

        m_bNpcItemConfig = TRUE;
}
thanks ;)
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
Crossfade
Loyal fan
Posts: 354
Joined: Sun Mar 20, 2005 5:55 pm

Post by Crossfade »

make sure your codes sending right defines and that you set up your cfg correctly. its probally a simple prob but i cant bother atm i need to go take care of some stuff.
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

Crossfade wrote: make sure your codes sending right defines and that you set up your cfg correctly. its probally a simple prob but i cant bother atm i need to go take care of some stuff.
im sure it is... because when i convert to be readed when wlserver sends the cfg it works :S the hg decode without problems... then convert to be readed from gameconfigs **THE SAME CFG** and get that error :(
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
Post Reply