[Help] create new packet

04/03/2012 20:08 420twisted1#1
I need a detailed explanation on creating new packets I need to create one for CDPSrvr::LoadIPCut so that I can call it from dpsrvr.cpp( worldserver ) to use in a command this would help me learn and would be much appreciated.

I attempted and failed
I put

Code:
#define PACKETTYPE_RELOAD_BANS (DWORD)0x88100250
in MsgHdr.h
I also put

Code:
ON_MSG( PACKETTYPE_RELOAD_BANS, LoadIPCut );
Code:
void CDPSrvr::LoadIPCut()
{
}

in DpSrvr.cpp(world)

and
Code:
void    LoadIPCut();
in DpSrvr.h

and
Code:
ON_MSG( PACKETTYPE_RELOAD_BANS, LoadIPCut );
in DpSrvr.cpp(Account)

but received this error

Code:
error C2440: '=' : cannot convert from 'BOOL (__thiscall CDPSrvr::* )(void)' to 'void (__thiscall CDPSrvr::* )(CAr &,DPID,DPID,LPBYTE,u_long)'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
04/03/2012 20:25 aldimaster#2
You have to add the specific parameters to your function:
PHP Code:
void    LoadIPCut(CAr arDPID dpidCacheDPID dpidUserLPBYTE lpBufu_long uBufSize);

void CDPSrvr::LoadIPCut(CAr arDPID dpidCacheDPID dpidUserLPBYTE lpBufu_long uBufSize)
{

It depends on how you send your packet to the server, but this should work.

Greetz
04/03/2012 20:52 420twisted1#3
Quote:
Originally Posted by aldimaster View Post
You have to add the specific parameters to your function:
PHP Code:
void    LoadIPCut(CAr arDPID dpidCacheDPID dpidUserLPBYTE lpBufu_long uBufSize);

void CDPSrvr::LoadIPCut(CAr arDPID dpidCacheDPID dpidUserLPBYTE lpBufu_long uBufSize)
{

It depends on how you send your packet to the server, but this should work.

Greetz
FuncTextCmd.cpp(388) : error C2660: 'CDPSrvr::LoadIPCut' : function does not take 0 arguments

Code:
BOOL TextCmd_PERM_BAN( CScanner & scanner )
{
#ifdef __WORLDSERVER
	CUser* pUser = (CUser*)scanner.dwValue;
	
	scanner.GetToken();
	u_long idTarget	= CPlayerDataCenter::GetInstance()->GetPlayerId( scanner.token );
	CUser* pTarget	= g_UserMng.GetUserByPlayerID( idTarget );	

	if( !IsValidObj( pTarget ) )
	{
		pUser->AddText( "Invalid target name." );		
		return TRUE;
	}
	
	CString strPath;
	CString TNickName;
	CString UNickName;
	CString strTargetIp;
	char szBannish[MAX_PATH];
	UNickName = pUser->GetName();
	TNickName = pTarget->GetName();
	CString strIp = pTarget->m_playAccount.lpAddr;
	CString strAccnt = pTarget->m_playAccount.lpszAccount;

	
	if( pUser->IsAuthHigher( AUTH_GAMEMASTER ) ) 
	{
	    sprintf( szBannish, "%s , you have been Banned by [Staff member]--> %s", TNickName, UNickName );
	    pTarget->AddText( szBannish );
		strTargetIp.Format( "%s - %s // Accnt %s  UserNname %s was banned by Staff member %s ", strIp,  strIp, strAccnt, TNickName, UNickName );
		strPath.Format( "..\\Program\\IPCut.ini" );
		DSystemLog( strTargetIp, strPath, 0 );
		g_DPCoreClient.SendKillPlayer( pTarget->m_idPlayer, idTarget );
                g_DPSrvr.LoadIPCut();// <----FuncTextCmd.cpp(388)
		pUser->AddText("User has been Banned");
	}
#endif // __WORLDSERVER
	return TRUE;
}
I need this command to call

Code:
BOOL CDPSrvr::LoadIPCut( LPCSTR lpszFileName )
{
	CMclAutoLock	Lock( m_csIPCut );

	InitIPCut();

	char strABClass[MAX_PATH];

	CScanner s;
	if( s.Load( lpszFileName ) )
	{
		s.GetToken();
		while( s.tok != FINISHED )
		{
			ZeroMemory( strABClass, sizeof( strABClass ) );
			
			GetABCClasstoString( s.Token, strABClass, m_nIPCut[m_nSizeofIPCut][0] );
			s.GetToken();
			s.GetToken();
			GetABCClasstoString( s.Token, strABClass, m_nIPCut[m_nSizeofIPCut][1] );

			int nFindLast = -1;
			STRING2INT::iterator iFind = m_sIPCut.find( strABClass );
			if( iFind != m_sIPCut.end() )
			{	
				int nFind = iFind->second;
				int nBufFind = m_nIPCut[nFind][2];
				nFindLast = nFind;
				while( nBufFind != -1 )
				{
					nFindLast = nBufFind;
					nBufFind = m_nIPCut[nBufFind][2];
				}
			}
			m_sIPCut.insert( map<string, int>::value_type( strABClass, m_nSizeofIPCut ) );
			++m_nSizeofIPCut;

			if( nFindLast != -1 )
			{
				m_nIPCut[nFindLast][2] = m_nSizeofIPCut - 1;
			}
			s.GetToken();
		}
		return TRUE;
	}
	
	return FALSE;
}
in Dpsrvr.cpp(account server)

so that when a user is banned the Ipcut.ini is reloaded preventing the user from logging in again

I also tried
Code:
g_DPSrvr.LoadIPCut( "Ipcut.ini" );
but got
FuncTextCmd.cpp(388) : error C2660: 'CDPSrvr::LoadIPCut' : function does not take 1 arguments
04/03/2012 21:09 aldimaster#4
You are trying to call the function LoadIPCut in Neuz, but this is wrong.
You have to write a function which sends the packet PACKETTYPE_RELOAD_BANS to the server:

PHP Code:
dpclient.h
void    SendLoadIpCut
OBJID objid );

dpclient.cpp
void    CDPClient
::SendLoadIpCutOBJID objid );
{
    
BEFORESENDSOLEarPACKETTYPE_RELOAD_BANSDPID_UNKNOWN );
    
ar << g_pPlayer->m_idPlayer << objid;
    
SENDarthisDPID_SERVERPLAYER );

Now you can call SendLoadIpCut instead of LoadIpCut in FuncTextCmd.


Greetz
04/03/2012 21:28 420twisted1#5
Quote:
Originally Posted by aldimaster View Post
You are trying to call the function LoadIPCut in Neuz, but this is wrong.
You have to write a function which sends the packet PACKETTYPE_RELOAD_BANS to the server:

PHP Code:
dpclient.h
void    SendLoadIpCut
OBJID objid );

dpclient.cpp
void    CDPClient
::SendLoadIpCutOBJID objid );
{
    
BEFORESENDSOLEarPACKETTYPE_RELOAD_BANSDPID_UNKNOWN );
    
ar << g_pPlayer->m_idPlayer << objid;
    
SENDarthisDPID_SERVERPLAYER );

Now you can call SendLoadIpCut instead of LoadIpCut in FuncTextCmd.


Greetz
so i dont need?
Code:
void CDPSrvr::LoadIPCut(CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize)
{
}
Code:
\SRC\Program\_Interface\FuncTextCmd.cpp(388) : error C2065: 'g_DPlay' : undeclared identifier
\SRC\Program\_Interface\FuncTextCmd.cpp(388) : error C2228: left of '.SendLoadIpCut' must have class/struct/union type
04/04/2012 12:51 Unleashed!#6
You need the function in DPSrvr.cpp wich you want to call, also you need the ON_MSG(...) in the top of DPSrvr.cpp, wich tells the server, what function has to be called with wich packet. Then you need a function in DPClient.cpp to send the packet. I learned how to send packets, when i looked at another sourcerelease, where packets are used, i think this could help you :P
04/04/2012 14:09 Flyff_Service#7
Meine Fresse, er will durch ein GM Befehl die IPCut im AccountServer neuladen lassen.

@420twisted1:
You are trying to call a function from WorldServer which is only implemented in AccountServer.
Choose one of these, to solve your problem
  1. Because only DatabaseServer is connected to AccountServer, you must send the packet from Worldserver => DatabaseServer => AccountServer.
  2. You must reactivate the connection between WorldServer and AccountServer, which is already implemented, so it shouldnt be too difficult.