示例#1
0
void CGameSocket::RecvUserRegene(char* pBuf)
{
    int index = 0;
    short uid=-1, sHP=0;

    uid = GetShort( pBuf, index );
    sHP = GetShort( pBuf, index );

    // User List에서 User정보,, 삭제...
    CUser* pUser = m_pMain->GetUserPtr(uid);
    if(pUser == NULL)	return;

    pUser->m_bLive = USER_LIVE;
    pUser->m_sHP = sHP;

    char buff[256];
    sprintf_s(buff, sizeof(buff), "**** RecvUserRegene -- uid = (%s,%d), HP = %d", pUser->m_strUserID, pUser->m_iUserId, pUser->m_sHP);
    TimeTrace(buff);
    //TRACE("**** RecvUserRegene -- uid = (%s,%d), HP = %d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_sHP);
}
示例#2
0
void CUser::Dead(int tid, int nDamage)
{
	if(m_bLive == USER_DEAD) return;

	// 이 부분에서 update를 해야 함,,  게임서버에서,, 처리하도록,,,
	m_sHP = 0;
	m_bLive = USER_DEAD;

	InitNpcAttack();

	// region에서 삭제...
	MAP* pMap = GetMap();
	if(pMap == NULL)	{
		TRACE("#### CUser-Dead() Fail : [nid=%d, name=%s], pMap == NULL #####\n", m_iUserId, m_strUserID);
		return;
	}
	// map에 region에서 나의 정보 삭제..
	if(m_sRegionX < 0 || m_sRegionZ < 0 || m_sRegionX > pMap->GetXRegionMax() || m_sRegionZ > pMap->GetZRegionMax())	{
		TRACE("#### CUser-Dead() Fail : [nid=%d, name=%s], x1=%d, z1=%d #####\n", m_iUserId, m_strUserID, m_sRegionX, m_sRegionZ);
		return;
	}
	//pMap->m_ppRegion[m_sRegionX][m_sRegionZ].DeleteUser(m_iUserId);
	pMap->RegionUserRemove(m_sRegionX, m_sRegionZ, m_iUserId);
	//TRACE("*** User Dead()-> User(%s, %d)를 Region에 삭제,, region_x=%d, y=%d\n", m_strUserID, m_iUserId, m_sRegionX, m_sRegionZ);

	m_sRegionX = -1;		m_sRegionZ = -1;

	int send_index = 0;
	int sid = -1, targid = -1;
	BYTE type, result;
	char buff[256];
	memset( buff, 0x00, 256 );

	wsprintf(buff, "*** User Dead = %d, %s ***", m_iUserId, m_strUserID);
	TimeTrace(buff);
	//TRACE("*** User Dead = %d, %s ********\n", m_iUserId, m_strUserID);
	memset( buff, 0x00, 256 );

	float rx=0.0f, ry=0.0f, rz=0.0f;

	type = 0x02;
	result = ATTACK_TARGET_DEAD;
	sid = tid;
	targid = m_iUserId+USER_BAND;

	SetByte( buff, AG_ATTACK_RESULT, send_index );
	SetByte( buff, type, send_index );
	SetByte( buff, result, send_index );
	SetShort( buff, sid, send_index );
	SetShort( buff, targid, send_index );
	SetShort( buff, nDamage, send_index );
	SetDWORD( buff, m_sHP, send_index );
	//SetShort( buff, m_sMaxHP, send_index );

	//TRACE("Npc - SendAttackSuccess()-User Dead : [sid=%d, tid=%d, result=%d], damage=%d, hp = %d\n", sid, targid, result, nDamage, m_sHP);

	if(tid > 0)
		SendAll(buff, send_index);   // thread 에서 send

/*	SetByte(buff, AG_DEAD, send_index );
	SetShort(buff, m_iUserId, send_index );
	Setfloat(buff, m_curx, send_index);
	Setfloat(buff, m_curz, send_index);

	SendAll(buff, send_index);   // thread 에서 send	*/
}
示例#3
0
/*-----------------------------------------------------------------
attivita'	:
    scandisce i dati letti in tplString e li scrive su outputString.
*/
int Parser::ProcTplData(char* tplString, itxString* outputString)
{
  BaseCommand*  basecmd = NULL;
	itxString     commandRetStr;	  //stringa restituita dal comando eseguito (l'allocazione spetta al comando)
	itxString     transfArg;				//argomento di una funzione trasformato dalla chiamata ricorsiva
	itxString     argStr;						//argomento grezzo del comando
	char*         cmdStart;
	char*         paux;
	int	          dataIsChar = 1; 	//flag che indica se il dato da restituire � un semplice carattere
  int           i = 0;
	int		        cmdOrd = 0;
	int		        retStrLen = 0;

  if (tplString == NULL)
    return 0;
  transfArg.SetGranularity(1024);

  try
  {
	  while (*tplString != 0 && m_ForceExit == 0 && m_ForceReturn == 0)
	  { 
		  dataIsChar=1; // Di default non mi aspetto un comando: assumo che il dato 
		                // sia un carattere da copiare in uscita cos� come �

      if (m_CurTpl->m_RecursionZero == 0)
      {
        paux = tplString;
        tplString = strchr(paux, m_StartCommandTag);
        
        if (m_CurTpl->MustExec())
        {
          if(tplString == NULL)
          {
            *outputString += paux;
            return 0; //Reached the end of template
          }
          else
          {
            *tplString = '\0';
            *outputString += paux;
            *tplString = m_StartCommandTag;
          }
        }
      }

		  // se incontro il carattere di segnalazione comando
		  if (*tplString == m_StartCommandTag)
		  {
			  // verifico la sintassi del comando e metto i puntatori su tplString
			  // all'inizio del nome del comando e dell'argomento (termino le stringhe ponendo
			  // a zero i caratteri di inizio e fine argomento); tplString viene spostato a fine comando    
        if (VerifyCmdSynt(&tplString, &cmdOrd, &argStr, &cmdStart) == 1)
			  {
          if (cmdOrd < m_BaseCount)
          {
            if (m_CurTpl->CheckStartBlock(((BaseCommand*)m_Command[cmdOrd])->m_Type, cmdStart))
		          dataIsChar = 0; // si disattiva il flag che segnala la presenza di un singolo carattere
          }

				  // esecuzione comando
				  if (m_CurTpl->MustExec())
				  {
        	  // chiamata ricorsiva: l'argomento del comando viene interpretato e restituito su
					  // transfArg; il file pointer (secondo argomento) viene passato NULL per permettere
					  // il riconoscimento del livello interno di ricorsione
            transfArg = "";
            m_CurTpl->m_RecursionZero++;
					  ProcTplData(argStr.GetBuffer(), &transfArg);
            m_CurTpl->m_RecursionZero--;

            try //Esecuzione
            {
              TimeTrace("PRIMA DEL COMANDO");              
					    DebugTrace2(DEFAULT, "Executing: %s(%s)\n", m_Command[cmdOrd]->GetName(), transfArg.GetBuffer());
              commandRetStr = m_Command[cmdOrd]->Execute(transfArg.GetBuffer());
              TimeTrace("DOPO IL COMANDO");

              m_Command[cmdOrd]->Deallocate();
            }
            catch(char* msg)
            {
					    DebugTrace2(IN_ERROR, "Propagated message: '%s'\n", msg);
              throw;
            }
            catch(...)
            {
              itxSystem sys;
					    DebugTrace2((cmdOrd < m_BaseCount ? IN_ERROR : IN_WARNING),
                          "Parser::ProcTplData: Unhandled Exception during '%s - %d' COMMAND\n",
                          m_Command[cmdOrd]->GetName(), sys.BSGetLastError());
              throw;
            }

            // si disattiva il flag che segnala la presenza di un singolo carattere
					  dataIsChar = 0;
				  }

          if (cmdOrd < m_BaseCount)
          {
            if (m_CurTpl->CheckEndBlock(((BaseCommand*)m_Command[cmdOrd])->m_Type, &tplString))
		          dataIsChar = 0; // si disattiva il flag che segnala la presenza di un singolo carattere
          }
			  }
		  }

		  if (m_CurTpl->MustExec())
		  {
			  // se il carattere letto non � il principio di un comando va scritto in output cos� come �
			  if (dataIsChar) //&& *tplString != '\x0A')
					*outputString += (char) *tplString;
			  // il dato non � un singolo carattere ma una stringa
			  // risultato dell'elaborazione di un comando
			  else
			  {
				  // si copia la stringa di ritorno del comando sullo stream di uscita
					if (!commandRetStr.IsNull() && !commandRetStr.IsEmpty())
            *outputString += commandRetStr;
				  commandRetStr = "";					
			  }
		  }

		  tplString++;
	  } // while (*tplString != 0)
  }
  catch (...)
  {
		DebugTrace2(IN_ERROR, "Parser::ProcTplData: recursion level %d.\n", m_CurTpl->m_RecursionZero);
		DebugTrace2(IN_ERROR, "Parser::ProcTplData: transfArg = '%s'\n", transfArg.GetBuffer());
		DebugTrace2(IN_ERROR, "Parser::ProcTplData: commandRetStr = '%s'\n", commandRetStr.GetBuffer());
    m_ForceExit = 1;
    throw;
  }
   
	return 0;
}