コード例 #1
0
ファイル: VisualFix.cpp プロジェクト: stevemqeen/zClient
void VisualFix::RecvKilledObject(PMSG_DIEPLAYER *lpRecv)
{
	printf("RecvKilledObject %d %d", MAKE_NUMBERW(lpRecv->NumberH, lpRecv->NumberL), this->aIndex);
	short tIndex = MAKE_NUMBERW(lpRecv->NumberH, lpRecv->NumberL);
	if (this->aIndex == tIndex)
	{
		this->Life = 0;
		this->SD = 0;
		this->PlayerKill = TRUE;
	}
}
コード例 #2
0
ファイル: ClientNetWork.cpp プロジェクト: MagistrAVSH/node3d
bool CClientNetWork::send(void* buf)
{
	static unsigned char s_XorBuf[MAX_EXSENDBUF_SIZE]	= {0};
	static unsigned char s_EncBuf[MAX_EXSENDBUF_SIZE]	= {0};
	// ----
	unsigned char* pMsg									= (unsigned char*)buf;
	// ---
	unsigned char uMsgType								= pMsg[0];
	// ----
	// # Get Size
	int len												= pMsg[1];
	// ----
	if ( uMsgType == 0xC2 || uMsgType == 0xC4 )
	{
		len = MAKE_NUMBERW(pMsg[1],pMsg[2]);
	}
	// ----
	// # Enc Xor Data
	// ----
	memcpy(s_XorBuf,buf,len);
	// ----
	pMsg = s_XorBuf;
	// ----
	EncXorData(pMsg,len,(uMsgType==0xC1||uMsgType==0xC3)?2:3);
	// ----
	// # Encrypt C3 C4
	// ---- 
	if((uMsgType == 0xC3) || (uMsgType == 0xC4))
	{
		s_uSerial++;
		// ----
		if(uMsgType == 0xC3)
		{
			pMsg[1]		= s_uSerial;
			// ----
			len			= g_SimpleModulusCS.Encrypt(& s_EncBuf[2], & pMsg[1], len-1) + 2;
			// ----
			s_EncBuf[0] = uMsgType;
			s_EncBuf[1] = len;
		}
		else
		{
			pMsg[2]		= s_uSerial;
			// ----
			len			= g_SimpleModulusCS.Encrypt(& s_EncBuf[3], & pMsg[2], len-2) + 3;
			// ----
			s_EncBuf[0] = uMsgType;
			s_EncBuf[1] = SET_NUMBERH(len);
			s_EncBuf[2] = SET_NUMBERL(len);
		}
		// ----
		pMsg = s_EncBuf;
	}
	// ----
	return CNetWork::DataSend(pMsg,len);
}
コード例 #3
0
ファイル: VisualFix.cpp プロジェクト: stevemqeen/zClient
void VisualFix::RecvDamage(PMSG_ATTACKRESULT *lpRecv)
{
	printf("RecvDamage1 %d %d %d\n", lpRecv->AttackHP, lpRecv->AttackSD, MAKE_NUMBERW(lpRecv->NumberH, lpRecv->NumberL));

	this->AttackHP = lpRecv->AttackHP;
	this->AttackSD = lpRecv->AttackSD;

	short tIndex = MAKE_NUMBERW(lpRecv->NumberH & 0x7F, lpRecv->NumberL);
	printf("RecvDamage2 %d %d %d\n", lpRecv->AttackHP, lpRecv->AttackSD, tIndex);
	if (this->aIndex == tIndex)
	{
		this->Life -= this->AttackHP;
		this->SD -= this->AttackSD;

		if (this->Life < 0)
		{
			this->Life = 0;
		}
	}
}
コード例 #4
0
ファイル: GenSystem.cpp プロジェクト: ElBedeawi/mu-server-ex
// ------------------------------------------------------------
void GenSystem::SendLogo(LPOBJ lpObj,unsigned char * aSend)
{
	WORD Size = (16*aSend[4])+6;
	BYTE Packet[10000];
	Packet[0] = 0xC2;
	Packet[1] = HIBYTE(Size);
	Packet[2] = LOBYTE(Size);
	Packet[3] = 0xF8;
	Packet[4] = 0x05;
	Packet[5] = aSend[4];

	int EffectCount = 0;
	for(int x=0;x<aSend[4];x++)
	{
		int Inc = 16*x;
		int Inc2 = (36*x)+EffectCount;
		BYTE PID1 = aSend[5+Inc2];
		BYTE PID2 = aSend[6+Inc2];
		WORD PlayerID = MAKE_NUMBERW(PID1,PID2);
		if(PlayerID >= OBJMAX)PlayerID -= OBJMIN;
		if(PlayerID < OBJMIN || PlayerID >= OBJMAX)
		{
			Packet[6+Inc] = 0x00;
			Packet[14+Inc] = 0x00;
		}
		else
		{
			LPOBJ lpOtherObj = &gObj[PlayerID];
			Packet[6+Inc] = lpOtherObj->GenFamily;
			Packet[14+Inc] = lpOtherObj->GenLevel;
		}
		Packet[7+Inc] = aSend[5+Inc2];
		Packet[8+Inc] = aSend[6+Inc2];
		Packet[9+Inc] = 0x00;
		Packet[10+Inc] = 0x00;
		Packet[11+Inc] = 0x00;
		Packet[12+Inc] = 0x00;
		Packet[13+Inc] = 0x00;
		Packet[15+Inc] = 0x00;
		Packet[16+Inc] = 0x00;
		Packet[17+Inc] = 0x00;
		Packet[18+Inc] = 0x00;
 		Packet[19+Inc] = 0x00;
		Packet[20+Inc] = 0x00;
		Packet[21+Inc] = 0x00;

		EffectCount += aSend[40+Inc2];
	}
	gSendProto.DataSend(lpObj->m_Index, Packet, Size);
	return;
}
コード例 #5
0
bool cProtoFunc::CGPartyRequestRecv(PMSG_PARTYREQUEST * lpMsg, int aIndex)
{	
	int number =  MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);

	OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);	 
	OBJECTSTRUCT *pObj = (OBJECTSTRUCT*)OBJECT_POINTER(number);
																			 
	if(gObj->Level > pObj->Level && gObj->Level - pObj->Level >= Config.PartyGapLvl)
	{	
		Chat.MessageLog(1, cLog.c_Red, cLog.t_Default, gObj, "[Party] You can't stay with %s in party! %s needs %d more lvl.", pObj->Name, pObj->Name, gObj->Level-Config.PartyGapLvl - pObj->Level);
		return true;
	}

	if(gObj->Level < pObj->Level && pObj->Level - gObj->Level >= Config.PartyGapLvl)
	{																													
		Chat.MessageLog(1, cLog.c_Red, cLog.t_Default, gObj, "[Party] You can't stay with %s in party! You need %d more lvl.", pObj->Name, pObj->Level - Config.PartyGapLvl - gObj->Level);
		return true;
	}	   
	return false;
}
コード例 #6
0
// ------------------------------------------------------------------------------------------------------------------------------------------------------
void CGPartyRequestResultRecv(PMSG_PARTYREQUESTRESULT * lpMsg, int aIndex)
{
	int number;
	BYTE result = false;
	char szTemp[256];
	int pnumber = -1;

	if( !PacketCheckTime(&gObj[aIndex]))
		return;

	number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);

	if( number < 0 || number > OBJMAX-1)
		return;

	if( !gObjIsConnected(&gObj[aIndex]))
		return;

	if( !gObjIsConnected(&gObj[number]))
	{
		GCResultSend(aIndex, 0x41, 0x04);
	}
	else
	{
		result = true;
	}

	if( gObj[number].MapNumber != gObj[aIndex].MapNumber )
	{
		result = false;
		GCResultSend(number, 0x41, 0x00);
	}

	if( gUser.ChaosCastleMapRange(gObj[aIndex].MapNumber) == true )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(4, 198)), aIndex, 1);
		result = false;
		::GCResultSend(number, 0x41, 0x00);
	}

	if( lpMsg->Result == 0 )
	{
		result = false;
		::GCResultSend(number, 0x41, 0x01);
	}

	if( gObj[number].m_IfState.use == 0 || gObj[number].m_IfState.type != 2)
	{
		result = false;
		::GCResultSend(number, 0x41, 0x00);
	}	
	
	if( gObj[aIndex].m_IfState.use == 0 || gObj[aIndex].m_IfState.type != 2)
	{
		result = false;
		::GCResultSend(number, 0x41, 0x00);
	}

	if( result == 1 )
	{
		if( gObj[number].PartyNumber < 0 )
		{
			gObj[number].PartyNumber = gParty.Create(number, gObj[number].DBNumber, gObj[number].Level);
		}

		if( gObj[number].PartyNumber >= 0  )
		{
			pnumber = gObj[number].PartyNumber;
			int iPartyPos = gParty.AddMember(gObj[number].PartyNumber, aIndex, gObj[aIndex].DBNumber, gObj[aIndex].Level);

			if( iPartyPos >= 0 )
			{
				gObj[aIndex].PartyNumber = gObj[number].PartyNumber;
				result = true;
				wsprintf(szTemp, lMsg.Get(MSGGET(4, 83)), gObj[aIndex].Name);
				::GCServerMsgStringSend(szTemp, number, 1);
				wsprintf(szTemp, lMsg.Get(MSGGET(4, 83)), gObj[number].Name);
				::GCServerMsgStringSend(szTemp, aIndex, 1);

				gParty.Paint(pnumber);
			}
			else if( iPartyPos == -1 )
			{
				GCResultSend(number, 0x41, 2);
				GCResultSend(aIndex, 0x41, 2);
			}
			else if( iPartyPos == -2 )
			{
				result = 2;
				wsprintf(szTemp, lMsg.Get(MSGGET(4, 84)), gObj[aIndex].Name);
				GCServerMsgStringSend(szTemp, aIndex, 1);
			}
		}
	}

	if( gObj[aIndex].m_IfState.use !=  0 && gObj[aIndex].m_IfState.type == 2)
	{
		gObj[aIndex].m_IfState.use = 0;
		gObj[aIndex].PartyTargetUser = -1;
	}

	if( gObj[number].m_IfState.use !=  0 && gObj[number].m_IfState.type == 2)
	{
		gObj[number].m_IfState.use = 0;
		gObj[number].PartyTargetUser = -1;
	}

	if( pnumber >= 0 )
	{
		CGPartyListAll(pnumber);
	}
}
コード例 #7
0
// ------------------------------------------------------------------------------------------------------------------------------------------------------
void CGPartyRequestRecv(PMSG_PARTYREQUEST * lpMsg, int aIndex)
{
	int number =  MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
	PMSG_PARTYREQUESTSEND pMsg;

	if ( number < 0 || number > OBJMAX-1)
		return;

	if (!PacketCheckTime(&gObj[aIndex]))
		return;

	if ( !gObjIsConnected(&gObj[number]))
	{
		::GCResultSend(aIndex, 0x41, 0x03);
		return;
	}

	if ( gObj[aIndex].CloseCount >= 0 || gObj[number].CloseCount >= 0 )
	{
		::GCResultSend(aIndex, 0x41, 0x00);
		return;
	}

	if ( gObj[number].GenFamily != gObj[aIndex].GenFamily )
	{
		::GCServerMsgStringSend("Can't make party with different gen member", aIndex, 1);
		return;
	}

	if ( gUser.ChaosCastleMapRange(gObj[aIndex].MapNumber) == true )
	{
		::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 198)), aIndex, 1);
		return;
	}

	if ( IT_MAP_RANGE(gObj[aIndex].MapNumber) )
	{
		::GCServerMsgStringSend("Can't make party in Illusion Temple", aIndex, 1);
		return;
	}

#if (FOREIGN_GAMESERVER==1)
	if ( szAuthKey[4] != AUTHKEY4 )
		DestroyGIocp();
#endif

	//LogAddL("Party result : %d %d %d %d", gObj[aIndex].CloseCount, gObj[number].CloseCount, gObj[aIndex].Connected, gObj[number].Connected);
	//LogAddL("%s %s", gObj[aIndex].Name, gObj[number].Name);

	if ( gObj[aIndex].m_IfState.use > 0 )
	{
		::GCResultSend(aIndex, 0x41, 0x00);
		return;
	}
		
	if ( gObj[number].m_IfState.use > 0 )
	{
		::GCResultSend(aIndex, 0x41, 0x00);
		return;
	}

	if ( (gObj[number].m_Option &1) != TRUE )
	{
		::GCResultSend(aIndex, 0x41, 0x01);
		return;
	}

	if ( gObj[aIndex].PartyNumber >= 0 )
	{
		int iUserIndex;
		int iDbNumber;
		gParty.GetIndexUser(gObj[aIndex].PartyNumber, 0, iUserIndex, iDbNumber);
		
		if ( iUserIndex < 0 || ( iUserIndex != aIndex && gObj[aIndex].DBNumber != iDbNumber )  )
		{
			::GCResultSend(aIndex, 0x41, 0x00);
			return;

		}
	}

	if ( gObj[aIndex].PartyTargetUser >= 0 )
		return;

	if ( gObj[number].PartyNumber >= 0 )
	{
		::GCResultSend(aIndex, 0x41, 0x04);
		return;
	}

	if ( gObj[number].PartyTargetUser >= 0 )
	{
		::GCResultSend(aIndex, 0x41, 0x00);
		return;
	}

	int maxlevel = 0;
	int minlevel = 0;

	/*if ( gObj[number].PartyNumber >= 0 )
	{
		if ( gParty.GetLevel( gObj[number].PartyNumber, maxlevel, minlevel) == TRUE )
		{
			int limmaxlevel;
			int limmaxlevel2;

			if ( maxlevel > gObj[number].Level )
				limmaxlevel = maxlevel;
			else
				limmaxlevel = gObj[number].Level;

			if ( maxlevel < gObj[number].Level )
				limmaxlevel2 = maxlevel;
			else
				limmaxlevel2 = gObj[number].Level;

			if ( (limmaxlevel - limmaxlevel2) > MAX_PARTY_LEVEL_DIFFERENCE )
			{
				::GCResultSend(aIndex, 0x41, 0x05);
				// Restricted level for the party is %d
				// DEATHWAY FIX HERE
				LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
				return;
			}

			int limminlevel;
			int limminlevel2;

			if ( maxlevel > gObj[number].Level )
				limminlevel = minlevel;
			else
				limminlevel = gObj[number].Level;

			if ( maxlevel < gObj[number].Level )
				limminlevel2 = minlevel;
			else
				limminlevel2 = gObj[number].Level;

			if ( (limminlevel - limminlevel2) > MAX_PARTY_LEVEL_DIFFERENCE )
			{
				::GCResultSend(aIndex, 0x41, 0x05);
				// Restricted level for the party is %d
				// DEATHWAY FIX HERE
				LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
				return;
			}
		}
	}
	else
	{
		short sMaxMinLevel[2];

		if ( gObj[aIndex].Level > gObj[number].Level )
			sMaxMinLevel[1] = gObj[aIndex].Level;
		else
			sMaxMinLevel[1] = gObj[number].Level;
		
		if ( gObj[aIndex].Level < gObj[number].Level )
			sMaxMinLevel[0] = gObj[aIndex].Level;
		else
			sMaxMinLevel[0] = gObj[number].Level;
		
		if ( (sMaxMinLevel[1]- sMaxMinLevel[0]) >MAX_PARTY_LEVEL_DIFFERENCE)
		{
			::GCResultSend(aIndex, 0x41, 0x05);
			// Restricted level for the party is %d
			// DEATHWAY FIX HERE
			LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
			return;
		}
	}*/

	gObj[aIndex].m_IfState.use = TRUE;
	gObj[aIndex].m_IfState.type = 2;
	gObj[aIndex].m_IfState.state = 0;
	gObj[number].m_IfState.use = TRUE;
	gObj[number].m_IfState.type = 2;
	gObj[number].m_IfState.state = 0;
	gObj[aIndex].TargetNumber = number;
	gObj[number].TargetNumber = aIndex;
	gObj[aIndex].m_InterfaceTime = GetTickCount();
	gObj[number].m_InterfaceTime = GetTickCount();
	gObj[aIndex].PartyTargetUser = number;
	
	C1HeadSet((LPBYTE)&pMsg, 0x40, sizeof(pMsg));
	pMsg.NumberH = SET_NUMBERH(aIndex);
	pMsg.NumberL = SET_NUMBERL(aIndex);

	gSendProto.DataSend(number, (LPBYTE)&pMsg, pMsg.h.size);
}
コード例 #8
0
void cDuelSystem::RecvDuelAnswer(LPOBJ lpObj, PMSG_DUEL_ANSWER_START* lpMsg)
{
    int iDuelIndex = -1;

    int aIndex = lpObj->m_Index;

    int iDuelRoom = AddTab[aIndex].DUEL_Room;

    PMSG_DUEL_START pMsgSend;

    pMsgSend.h.c		= 0xC1;
    pMsgSend.h.headcode = 0xAA;
    pMsgSend.h.subcode  = 0x01;
    pMsgSend.bDuelStart = 0;
    pMsgSend.h.size		= sizeof(pMsgSend);

    LPOBJ gObjg    = (LPOBJ)OBJECT_POINTER(aIndex);

    if(iDuelRoom < 0 || iDuelRoom > MAX_DUEL_ROOMS - 1)
    {
        return;
    }

    if(gObjg->CloseType != -1)
    {
        return;
    }

    iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL); // aIndex Packet C1 XX AA

    OBJECTSTRUCT *gObjs = (OBJECTSTRUCT*)OBJECT_POINTER(iDuelIndex);

    if(iDuelIndex <= 7999 || lpObj->m_Index <= 7999)
    {
        return;
    }

    if(OBJECT_MAXRANGE(iDuelIndex))
    {
        if(!Utilits.gObjIsConnected(iDuelIndex))
        {
            return;
        }

        if(gObjs->Type == OBJECT_MONSTER)
        {
            return;
        }

        if(gObjs->CloseCount >= 0)
        {
            return;
        }

        if(lpMsg->bDuelOK)
        {
            if
            (
                (gObjs->MapNumber >= 11 && gObjs->MapNumber <= 17) || gObjs->MapNumber == 52  ||
                (gObjs->MapNumber >= 18 && gObjs->MapNumber <= 23) || gObjs->MapNumber == 53 ||
                gObjs->MapNumber == 9 || gObjs->MapNumber == 32 ||
                (gObjs->MapNumber >= 45 && gObjs->MapNumber <= 50)
            )
            {
                GCServerMsgStringSend("Duels are not allowed in event maps.", lpObj->m_Index, 1);

                this->RoomReset(iDuelRoom, true, true);

                memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));

                DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

                return;
            }
        }

        if(OBJECT_MAXRANGE(lpObj->m_iDuelUser))
        {
            GCServerMsgStringSend("You are already in a Duel.", lpObj->m_Index, 1);
            GCServerMsgStringSend("In order to issue a Duel, cancel the previous request.", lpObj->m_Index, 1);

            this->RoomReset(iDuelRoom, true, true);

            memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));

            DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

            return;
        }

        if(OBJECT_MAXRANGE(lpObj->m_iDuelUserReserved))
        {
            GCServerMsgStringSend("You are already issuing a Duel challenge.", lpObj->m_Index, 1);

            this->RoomReset(iDuelRoom, true, true);

            memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));

            DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

            return;
        }
        if(gObjs->m_iDuelUserReserved == lpObj->m_Index)
        {
            char szDuelName[MAX_ACCOUNT_LEN + 1]  = {0};
            char szDuelName2[MAX_ACCOUNT_LEN + 1] = {0};

            memcpy(szDuelName, gObjs->Name, MAX_ACCOUNT_LEN);

            szDuelName[MAX_ACCOUNT_LEN] = 0;

            memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);

            szDuelName2[MAX_ACCOUNT_LEN] = 0;

            if(!strcmp(szDuelName, szDuelName2))
            {
                if(lpMsg->bDuelOK == false)
                {
                    this->RoomReset(iDuelRoom, true, true);

                    pMsgSend.bDuelStart = 0x0F;

                    memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));

                    DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
                }

                else if (lpMsg->bDuelOK == true)
                {
                    if(gObjMoveGate(lpObj->m_Index, g_DuelGates[iDuelRoom].Gate01) == false)
                    {
                        this->RoomReset(iDuelRoom, true, true);

                        return;
                    }

                    if(gObjMoveGate(iDuelIndex, g_DuelGates[iDuelRoom].Gate02) == false)
                    {
                        this->RoomReset(iDuelRoom, true, true);

                        return;
                    }

                    gObjs->m_iDuelUserReserved	= -1;
                    gObjs->m_btDuelScore		= 0;
                    gObjs->m_iDuelUser			= lpObj->m_Index;
                    gObjs->m_iDuelTickCount		= GetTickCount();

                    this->g_DuelRooms[iDuelRoom].dwStartTime	= GetTickCount();
                    this->g_DuelRooms[iDuelRoom].dwTicketCount  = GetTickCount() + (MAX_DUEL_TIME * 60000);

                    lpObj->m_iDuelUserRequested = -1;
                    lpObj->m_iDuelUserReserved  = -1;
                    lpObj->m_btDuelScore		= 0;
                    lpObj->m_iDuelUser			= iDuelIndex;
                    lpObj->m_iDuelTickCount		= GetTickCount();

                    this->g_DuelRooms[iDuelRoom].RoomFree		= FALSE;
                    this->g_DuelRooms[iDuelRoom].DuelWaiting	= FALSE;
                    this->g_DuelRooms[iDuelRoom].szWinner		= FALSE;

                    pMsgSend.bDuelStart		= 0;
                    pMsgSend.NumberH		= SET_NUMBERH(iDuelIndex);
                    pMsgSend.NumberL		= SET_NUMBERL(iDuelIndex);

                    memcpy(pMsgSend.szName, szDuelName, sizeof(pMsgSend.szName));

                    DataSend(lpObj->m_Index, (LPBYTE)&pMsgSend, pMsgSend.h.size);

                    pMsgSend.NumberH		= SET_NUMBERH(lpObj->m_Index);
                    pMsgSend.NumberL		= SET_NUMBERL(lpObj->m_Index);

                    memcpy(pMsgSend.szName, lpObj->Name, sizeof(pMsgSend.szName));

                    DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

                    this->UpdateDuelScore(iDuelRoom);

                    Chat.MessageAllLog(0, 0, c_Cyan, t_Duel, lpObj, "Duelo %s VS %s na sala %d!", lpObj->Name, gObjs->Name, iDuelRoom + 1);

                    Log.ConsoleOutPut(1, c_Blue,t_Duel,"[Duel System] Duel Started [%s][%s] VS [%s][%s] on Room[%d]",lpObj->AccountID, lpObj->Name, gObjs->AccountID, gObjs->Name, iDuelRoom + 1);
                }
            }
            else
            {
                this->RoomReset(iDuelRoom);
                DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

                return;
            }
        }
        else
        {
            this->RoomReset(iDuelRoom);
            DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);

            return;
        }
    }
}
コード例 #9
0
void cDuelSystem::RecvDuelRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_START* lpMsg)
{
    int iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);

    OBJECTSTRUCT *gObjs = (OBJECTSTRUCT*)OBJECT_POINTER(iDuelIndex);

    if(!OBJECT_MAXRANGE(iDuelIndex))
    {
        Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] [%s][%s] Try duel with NO_PLAYER object!", lpObj->AccountID, lpObj->Name);

        return;
    }

    if(iDuelIndex == lpObj->m_Index)
    {
        return;
    }

    if(iDuelIndex <= 7999 || lpObj->m_Index <= 7999)
    {
        return;
    }

    char Buff[256];

    if(lpObj->CloseType != -1)
    {
        return;
    }

    if(GetPrivateProfileInt("GameServerInfo", "NonPK", 0 , GS_CONFIG_FILE) == 1)
    {
        GCServerMsgStringSend("Dueling is not allowed in NON-PK servers.", lpObj->m_Index, 1);
        return;
    }

    if(GetPrivateProfileInt("GameServerInfo","PkLimitFree", 1, GS_CONFIG_FILE) == 0)
    {
        if(lpObj->m_PK_Level >= 6)
        {
            GCServerMsgStringSend("An outlaw can't issue a Duel challenge.", lpObj->m_Index, 1);
            return;
        }

        if(gObjs->m_PK_Level >= 6)
        {
            GCServerMsgStringSend("You cannot Duel with an Outlaw.", lpObj->m_Index, 1);
            return;
        }
    }

    if(OBJECT_MAXRANGE(lpObj->m_iDuelUser))
    {
        GCServerMsgStringSend("You are already in a Duel.", lpObj->m_Index, 1);
        GCServerMsgStringSend("In order to issue a Duel, cancel the previous request.", lpObj->m_Index, 1);
        return;
    }

    if(gObjs->MapNumber == 9 || gObjs->MapNumber == 32)
    {
        GCServerMsgStringSend("A duel is not allowed in Devil Square.", lpObj->m_Index, 1);
        return;
    }

    if((gObjs->MapNumber >= 11 && gObjs->MapNumber <= 17) || gObjs->MapNumber == 52)
    {
        GCServerMsgStringSend("You cannot Duel inside Blood Castle.", lpObj->m_Index, 1);
        return;
    }

    if((gObjs->MapNumber >= 18 && gObjs->MapNumber <= 23) || gObjs->MapNumber == 53)
    {
        GCServerMsgStringSend("Duels are not allowed within Chaos Castle.", lpObj->m_Index, 1);
        return;
    }

    if((gObjs->MapNumber >= 45 && gObjs->MapNumber <= 50))
    {
        GCServerMsgStringSend("Duels are not allowed in Illusion Temple", lpObj->m_Index, 1);
        return;
    }

    if(lpObj->Level < 30 || gObjs->Level < 30)
    {
        PMSG_DUEL_START pMsgSend;

        pMsgSend.h.c		= 0xC1;
        pMsgSend.h.headcode = 0xAA;
        pMsgSend.h.subcode  = 0x01;
        pMsgSend.bDuelStart = 0x0C;
        pMsgSend.h.size		= sizeof(pMsgSend);

        DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);

        return;
    }

    if(lpObj->Money < 30000 || gObjs->Money < 30000)
    {
        PMSG_DUEL_START pMsgSend;

        pMsgSend.h.c		= 0xC1;
        pMsgSend.h.headcode = 0xAA;
        pMsgSend.h.subcode  = 0x01;
        pMsgSend.bDuelStart = 0x1e;
        pMsgSend.h.size		= sizeof(pMsgSend);

        DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);

        return;
    }

    int iDuelRoom = this->GetFreeRoomIndex();

    if(iDuelRoom == -1)
    {
        PMSG_DUEL_START pMsgSend;

        pMsgSend.h.c		= 0xC1;
        pMsgSend.h.headcode = 0xAA;
        pMsgSend.h.subcode  = 0x01;
        pMsgSend.bDuelStart = 0x10;
        pMsgSend.h.size		= sizeof(pMsgSend);

        DataSend(lpObj->m_Index, (BYTE*)&pMsgSend, pMsgSend.h.size);

        return;
    }

    if((GetTickCount() - gObjs->m_PacketCheckTime) < 300)
    {
        return;
    }

    lpObj->m_PacketCheckTime = GetTickCount();

    char szDuelName[MAX_ACCOUNT_LEN + 1]  = {0};
    char szDuelName2[MAX_ACCOUNT_LEN + 1] = {0};

    memcpy(szDuelName, gObjs->Name, MAX_ACCOUNT_LEN);

    szDuelName[MAX_ACCOUNT_LEN]  = 0;

    memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);

    szDuelName2[MAX_ACCOUNT_LEN] = 0;

    if(strcmp(szDuelName, szDuelName2) != 0)
    {
        return;
    }

    if(this->IsDuelEnable(iDuelIndex) == FALSE)
    {
        GCServerMsgStringSend("Your challenge to Duel has been refused.", lpObj->m_Index, 1);
        return;
    }

    if(lpObj->lpGuild && lpObj->lpGuild->WarState == 1)
    {
        GCServerMsgStringSend("You cannot challenge someone to a duel while in a guild war.", lpObj->m_Index, 1);
        return;
    }

    if(gObjs->lpGuild && gObjs->lpGuild->WarState == 1)
    {
        GCServerMsgStringSend("Your opponent cannot duel while in a guild war.", lpObj->m_Index, 1);
        return;
    }

    if(Utilits.gObjIsConnected(iDuelIndex) == FALSE)
    {
        return;
    }

    if(gObjs->Type == OBJECT_MONSTER)
    {
        return;
    }

    if(gObjs->CloseCount >= 0)
    {
        return;
    }

    for(int n = 0; n < 5; n++)
    {
        if(lpObj->SelfDefense[n] >= 0 || gObjs->SelfDefense[n] >= 0)
        {
            GCServerMsgStringSend("Self-defense is active. You cannot Duel.", lpObj->m_Index, 1);

            return;
        }
    }

    if(lpObj->m_IfState.use > 0)
    {
        GCServerMsgStringSend("You cannot Duel while trading.", lpObj->m_Index, 1);

        return;
    }

    if(gObjs->m_IfState.use > 0)
    {
        wsprintf(Buff, "%s is trading an item.", gObjs->Name);

        GCServerMsgStringSend(Buff, lpObj->m_Index, 1);

        return;
    }

    if(OBJECT_MAXRANGE(gObjs->m_iDuelUserRequested))
    {
        wsprintf(Buff,"%s has already accepted a challenge to Duel.", gObjs->Name);

        GCServerMsgStringSend(Buff, lpObj->m_Index, 1);

        return;
    }

    if(OBJECT_MAXRANGE(gObjs->m_iDuelUserReserved))
    {
        wsprintf(Buff, "%s issues a Duel challenge.", gObjs->Name);

        GCServerMsgStringSend(Buff, lpObj->m_Index, 1);

        return;
    }

    if(OBJECT_MAXRANGE(gObjs->m_iDuelUser))
    {
        wsprintf(Buff, "%s is in a Duel.", gObjs->Name);

        GCServerMsgStringSend(Buff, lpObj->m_Index, 1);

        return;
    }

    lpObj->m_iDuelUser						 = -1;
    lpObj->m_iDuelUserReserved				 = iDuelIndex;
    gObjs->m_iDuelUserRequested				 = lpObj->m_Index;
    int aIndex								 = lpObj->m_Index;

    AddTab[aIndex].DUEL_Room	 = iDuelRoom;
    int uIndex								 = gObjs->m_Index;
    AddTab[uIndex].DUEL_Room	 = iDuelRoom;

    this->g_DuelRooms[iDuelRoom].szlpObjOne  = lpObj;
    this->g_DuelRooms[iDuelRoom].szlpObjTy   = gObjs;
    this->g_DuelRooms[iDuelRoom].DuelWaiting = TRUE;

    PMSG_DUEL_QUESTION_START pMsg;

    pMsg.h.c			= 0xC1;
    pMsg.h.headcode		= 0xAA;
    pMsg.h.subcode		= 0x02;
    pMsg.h.size			= sizeof(pMsg);
    pMsg.NumberH		= SET_NUMBERH(lpObj->m_Index);
    pMsg.NumberL		= SET_NUMBERL(lpObj->m_Index);

    memcpy(pMsg.szName, lpObj->Name, sizeof(pMsg.szName));

    DataSend(iDuelIndex, (LPBYTE)&pMsg, pMsg.h.size);

    wsprintf(Buff, "Challenged %s to a Duel.", gObjs->Name);

    GCServerMsgStringSend(Buff, lpObj->m_Index, 1);

    if(Config.Logging)
    {
        Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System][%s][%s] Requested to Start Duel to [%s][%s] on Room [%d]",lpObj->AccountID, lpObj->Name, gObjs->AccountID, gObjs->Name, iDuelRoom + 1);
    }
}
コード例 #10
0
ファイル: VisualFix.cpp プロジェクト: stevemqeen/zClient
void VisualFix::RecvIndex(PMSG_JOINRESULT *lpRecv)
{
	printf("RecvIndex: %d\n", MAKE_NUMBERW(lpRecv->NumberH, lpRecv->NumberL));
	this->aIndex = MAKE_NUMBERW(lpRecv->NumberH, lpRecv->NumberL);
	this->PlayerKill = FALSE;
}
コード例 #11
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::BuyItemPersonalShop(PMSG_REQ_BUYITEM_FROM_PSHOP * lpMsg, int aSourceIndex)
{
	LPOBJ SrcObj = &gObj[aSourceIndex];
	// ------
	if( gDoPShopOpen == FALSE ) return;
	// ------
	if( gObjIsConnected( MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Offline (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)];
	// ------
	if( lpObj->Type != OBJ_USER )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller isn't an Object User (%d).", SrcObj->AccountID,
			SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( lpObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Closing (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0,2);
		return;
	}
	// ------
	if( SrcObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Buyer is Closing (%d).", SrcObj->AccountID, SrcObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( lpObj->m_bPShopOpen == false )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Open Shop.", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 3);
		return;
	}
	// ------
	char szName[MAX_ACCOUNT_LEN+1] = {0};
	// ------
	memcpy(szName, lpMsg->btName, sizeof(lpMsg->btName));
	szName[MAX_ACCOUNT_LEN] = 0;
	// ------
	int iITEM_LOG_TYPE;
	int iITEM_LOG_LEVEL;
	int iITEM_LOG_DUR;
	int iITEM_LOG_SERIAL;
	// ------
	if( strcmp(szName, lpObj->Name) )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Name Mismatch [%s]-[%s]", SrcObj->AccountID, SrcObj->Name,
			szName, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6);
		return;
	}
	// ------
	if( (lpObj->Penalty &4) == 4 || (lpObj->Penalty &8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9);
		return;
	}
	// ------
	if( (SrcObj->Penalty &4) == 4 || (SrcObj->Penalty &8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9);
		return;
	}
	// ------
	EnterCriticalSection(&lpObj->m_critPShopTrade);
	// ------
	if( lpObj->m_bPShopTransaction == true )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Already In Trade.", SrcObj->AccountID, SrcObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,4);
		// ------
		LeaveCriticalSection(&lpObj->m_critPShopTrade);
	}
	else
	{
		lpObj->m_bPShopTransaction = true;
		// ------
		LeaveCriticalSection(&lpObj->m_critPShopTrade);
		// ------
		if( gObjInventorySearchSerialNumber(&gObj[aSourceIndex], lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
		{
			GCReFillSend(aSourceIndex, SrcObj->Life, -3, 1, SrcObj->iShield);
			// ------
			CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", SrcObj->AccountID, SrcObj->Name, __FILE__, __LINE__);
			return;
		}
		// ------
		if( gObjInventorySearchSerialNumber(lpObj, lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
		{
			GCReFillSend(lpObj->m_Index, lpObj->Life, -3, 1, lpObj->iShield);
			// ------
			CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", lpObj->AccountID, lpObj->Name, __FILE__, __LINE__);
			return;
		}
		// ------
		if(gObjFixInventoryPointer(aSourceIndex) == false )
		{
			CLog.LogAddC(TColor.Red(), PShopModule, "[Fix Inv.Ptr] False Location - [%s](%d)", __FILE__, __LINE__);
		}
		// ------
		if( SrcObj->pTransaction == 1 )
		{
			CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Item Buy Request Failed: Requester Transaction == 1, IF_STAT_TYPE : %d", SrcObj->AccountID,
				SrcObj->Name, SrcObj->m_IfState.type);
			return;
		}
		// ------
		iITEM_LOG_TYPE		= 0;
		iITEM_LOG_LEVEL		= 0;
		iITEM_LOG_DUR		= 0;
		iITEM_LOG_SERIAL	= 0;
		// ------
		__try
		{
			if( PSHOP_RANGE(lpMsg->btItemPos) == FALSE )
			{
				SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 5);
				return;
			}
			// ------
			if( lpObj->m_bMapSvrMoveQuit == true )
			{
				SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
				return;
			}
			// ------
			if( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == TRUE )
			{
				if( lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue <= 0 )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Choose Item Price.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6);
					return;
				}
				// ------
				if( SrcObj->Money < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Lack of Zen.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 7);
					return;
				}
				// ------
				DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
				// ------
				if( gObjCheckMaxZen(lpObj->m_Index, dwCost) == FALSE )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Exceeding Zen of the Host", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8);
					return;
				}
				// ------
				BYTE btNewItemPos	= 0;
				btNewItemPos		= gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
				// ------
				if( btNewItemPos == 0xFF )
				{
					CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] No Room to Buy Item.", SrcObj->AccountID,
						SrcObj->Name, lpObj->AccountID, lpObj->Name);
					// ------
					SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8);
					return;
				}
				// ------
				iITEM_LOG_TYPE		= lpObj->Inventory1[lpMsg->btItemPos].m_Type;
				iITEM_LOG_LEVEL		= lpObj->Inventory1[lpMsg->btItemPos].m_Level;
				iITEM_LOG_DUR		= lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
				iITEM_LOG_SERIAL	= lpObj->Inventory1[lpMsg->btItemPos].m_Number;
				// ------
				gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
				// ------
				lpObj->Inventory1[lpMsg->btItemPos].Clear();
				GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
				// ------
				SrcObj->Money	-= dwCost;
				lpObj->Money	+= dwCost;
				// ------
				GCMoneySend(aSourceIndex, SrcObj->Money);
				GCMoneySend(lpObj->m_Index, lpObj->Money);
				// ------
				SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
				// ------
				SendPShopSoldItemResult(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
				// ------
				CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s][%s] Shop Item Buy Request Succeed: [%s][%s][%s] Price = (%d), Type:(%d)[%s] Level:(%d) Dur:(%d) Serial:(%d).",
					SrcObj->AccountID, SrcObj->Name, SrcObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
					ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
				// ------
				if( PShop_CheckInventoryEmpty(lpObj->m_Index) == true )
				{
					CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s] Sold All Items - Auto Closing Shop.", lpObj->AccountID, lpObj->Name);
					// ------
					SendMsg.MessageOut(lpObj->m_Index, 0x01, "[PersonalShop] All items in Your Shop have been sold!");
					// ------
					lpObj->m_bPShopOpen = false;
					// ------
					memset(lpObj->m_szPShopText, 0, sizeof(lpObj->m_szPShopText));
					// ------
					SendPShopCloseResult(lpObj->m_Index, 1);
				}
				else
				{
					lpObj->m_bPShopItemChange = true;
				}
			}
		}
		// ------
		__finally
		{
			lpObj->m_bPShopTransaction = false;
		}
	}
}
コード例 #12
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::BuyListPersonalShop(PMSG_REQ_BUYLIST_FROM_PSHOP * lpMsg, int aSourceIndex)
{
	LPOBJ pObj = &gObj[aSourceIndex];
	// ------
	if( gDoPShopOpen == FALSE ) return;
	// ------
	if( gObjIsConnected(MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE)
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Request Failed: Seller is Offline (%d).", pObj->AccountID, pObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPlShopBuyListResult(aSourceIndex, -1, 2, 0);
		return;
	}
	// ------
	LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)];
	// ------
	if( lpObj->Type != OBJ_USER )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Request Failed: Seller isn't an Object User (%d).", pObj->AccountID, pObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPlShopBuyListResult(aSourceIndex, -1, 2, 0);
		return;
	}
	// ------
	if( lpObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Closing (%d).", pObj->AccountID, pObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( pObj->CloseCount >= 0 )	
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Buyer is Closing (%d)", pObj->AccountID, pObj->Name,
			MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
		// ------
		SendPShopBuyItemResult(aSourceIndex, -1, 0, 2);
		return;
	}
	// ------
	if( lpObj->m_Index == aSourceIndex )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Requested to (Him/Her)Self.", pObj->AccountID, pObj->Name);
		// ------
		SendPlShopBuyListResult(aSourceIndex, -1, 2, 0);
		return;
	}
	// ------
	if( lpObj->m_bPShopOpen == false )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Request Failed: [%s][%s] Didn't Open Shop", pObj->AccountID, pObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPlShopBuyListResult(aSourceIndex, -1, 3, 0);
		return;
	}
	// ------
	if( (lpObj->Penalty &4) == 4 || (lpObj->Penalty&8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Request Failed: [%s][%s] is in Item Block", pObj->AccountID, pObj->Name,
			lpObj->AccountID, lpObj->Name);
		// ------
		SendPlShopBuyListResult(aSourceIndex, -1, 4, 0);
		return;
	}
	// ------
	if( !gObjFixInventoryPointer(aSourceIndex))
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[Fix Inv.Ptr] False Location - [%s](%d)", __FILE__, __LINE__);
	}
	// ------
	if( pObj->pTransaction == 1 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop List Request Failed: Requester Transaction == 1, IF_STAT_TYPE : %d", pObj->AccountID,
			pObj->Name, pObj->m_IfState.type);
		return;
	}
	// ------
	CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] is Receiving Shop List From [%s][%s]", pObj->AccountID, pObj->Name, lpObj->AccountID, lpObj->Name);
	// ------
	pObj->m_bPShopWantDeal		= true;
	pObj->m_iPShopDealerIndex	= lpObj->m_Index;
	// ------
	memcpy(pObj->m_szPShopDealerName, lpObj->Name, MAX_ACCOUNT_LEN);
	// ------
	SendPlShopBuyListResult(aSourceIndex, lpObj->m_Index, 1, false);
}
コード例 #13
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SetPersonalShopItemPrice(PMSG_REQ_PSHOP_SETITEMPRICE * lpMsg, int aIndex)
{
	LPOBJ lpObj = &gObj[aIndex];
	// ------
	if( gDoPShopOpen == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Trying to Open Personal Shop.", lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopSetItemPriceResult(aIndex, 0, lpMsg->btItemPos);
		return;
	}
	// ------
	if( !gObjIsConnected(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Offline Player.", lpObj->AccountID, lpObj->Name);
		return;
	}
	// ------
	if( lpObj->Type != OBJ_USER )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s] isn't an Object User.", lpObj->m_Index);
		return;
	}
	// ------
	if( lpObj->Level <= 5 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Level: (%d)", lpObj->AccountID, lpObj->Name, lpObj->Level);
		// ------
		SendPShopSetItemPriceResult(aIndex, 5, lpMsg->btItemPos);
		return;
	}
	// ------
	if( INVENTORY_RANGE(lpMsg->btItemPos) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Position Out of Range: (%d)",lpObj->AccountID, lpObj->Name, lpMsg->btItemPos);
		// ------
		SendPShopSetItemPriceResult(aIndex, 2, lpMsg->btItemPos);
		return;
	}
	// ------
	if( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Doesn't Exist: (%d)",lpObj->AccountID, lpObj->Name, lpMsg->btItemPos);
		// ------
		SendPShopSetItemPriceResult(aIndex, 3, lpMsg->btItemPos);
		return;
	}
	// ------
	CItem * sitem = &lpObj->Inventory1[lpMsg->btItemPos];
	// ------
	int iItemPrice = MAKE_NUMBERDW(MAKE_NUMBERW(lpMsg->sItemPrice4, lpMsg->sItemPrice3), MAKE_NUMBERW(lpMsg->sItemPrice2, lpMsg->sItemPrice1));
	// ------
	if( gObjInventorySearchSerialNumber(lpObj, sitem->GetNumber()) == FALSE )
	{
		GCReFillSend(aIndex, lpObj->Life, 0xFD, TRUE, lpObj->iShield);
		// ------
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)",lpObj->AccountID, lpObj->Name, __FILE__, __LINE__);
		return;
	}
	// ------
	if( iItemPrice <= 0 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Price <= (0): (%d)",lpObj->AccountID, lpObj->Name, sitem->m_iPShopValue);
		// ------
		SendPShopSetItemPriceResult(aIndex, 4, lpMsg->btItemPos);
		return;
	}
	// ------
	if( (lpObj->Penalty&4) == 4 || (lpObj->Penalty&8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Price Change(%d), Item Block",lpObj->AccountID, lpObj->Name, sitem->m_iPShopValue);
		// ------
		SendPShopSetItemPriceResult(aIndex, 6, lpMsg->btItemPos);
		return;
	}
	// ------
	sitem->m_iPShopValue = iItemPrice;
	// ------
	ItemAttribute[sitem->m_Type].Name[31] = 0;
	// ------
	CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s]: Changing Item Price:(%d) - Type:(%d) [%s] - Level:(%d) - Serial:(%d) - Dur:(%d)",lpObj->AccountID,
		lpObj->Name, sitem->m_iPShopValue, sitem->m_Type, ItemAttribute[sitem->m_Type].Name, sitem->m_Level, sitem->m_Number, sitem->m_Durability);
	// ------
	SendPShopSetItemPriceResult(aIndex, 1, lpMsg->btItemPos);
}
コード例 #14
0
ファイル: ClientNetWork.cpp プロジェクト: MagistrAVSH/node3d
int CClientNetWork::ProtocolCore(const unsigned char* buf, int len)
{
	int size		= 0;
	// ----
	BYTE headcode	= 0x00;
	// ----
	if((buf[0] == 0xC1) || (buf[0] == 0xC3))		
	{
		// # Type packet handling C1 Type
		// ----
		size		= buf[1];
		headcode	= buf[2];
	}
	else if((buf[0] == 0xC2) || (buf[0] == 0xC4)) 
	{
		// # Type packet handling C2 Type
		// ----
		size		= MAKE_NUMBERW(buf[1],buf[2]);
		headcode =	 buf[3];
	}
	// ----
	if(size > 0)
	{
		if((buf[0] == 0xC1) || (buf[0] == 0xC2))
		{
			if((size > 0) && (size <= len))
			{
				this->wsProtocolCore(headcode, buf, size);
			}
		}
		else if((buf[0] == 0xC3 || buf[0] == 0xC4))
		{
			static unsigned char s_DecBuf[MAX_EXSENDBUF_SIZE]	= {0};
			// ----
			int nMsgSize										= 0;
			// ----
			if(buf[0] == 0xC3)
			{
				nMsgSize	= g_SimpleModulusSC.Decrypt(& s_DecBuf[1], & buf[2], size - 2) + 1;
				// ----
				s_DecBuf[0] = 0xC3;
				s_DecBuf[1] = nMsgSize;
				// ----
				headcode	= s_DecBuf[2];
			}
			else
			{
				nMsgSize	= g_SimpleModulusSC.Decrypt(& s_DecBuf[2], & buf[3], size - 3) + 2;
				// ----
				s_DecBuf[0] = 0xC4;
				s_DecBuf[1] = SET_NUMBERH(nMsgSize);
				s_DecBuf[2] = SET_NUMBERL(nMsgSize);
				// ----
				headcode	= s_DecBuf[3];
			}
			// ----
			if((size > 0) && (size <= len))
			{
				this->wsProtocolCore(headcode, s_DecBuf, nMsgSize);
			}
		}
	}
	// ----
	return size;
}