Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Arena Score 1.2

Junior Spellweaver
Joined
Apr 9, 2011
Messages
111
Reaction score
6

Note :
"Anyone who isn't familiar/in knowledge with source should leave(Your finger) from here."

Source :

dpTrans.cpp:
Code:
#ifdef __ARENA_SCORE
    ON_MSG( PACKETTYPE_ARENA_UPDATE, OnSendArenaScore ); 
    ON_MSG( PACKETTYPE_ARENA_GET, OnGetArenaScore );
#endif
Code:
#ifdef __ARENA_SCORE
void CDPTrans::OnGetArenaScore( CAr & ar, DPID dpid, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
{
    LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus        = g_DbManager.AllocRequest();
    g_DbManager.MakeRequest( lpDbOverlappedPlus, lpBuf, uBufSize );
    lpDbOverlappedPlus->dpid    = dpid;
    lpDbOverlappedPlus->nQueryMode    = LOAD_ARENASCORE;
    PostQueuedCompletionStatus( g_DbManager.m_hIOCPPut, 1, NULL, &lpDbOverlappedPlus->Overlapped );
}

void CDPTrans::OnSendArenaScore( CAr & ar, DPID dpid, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
{
    LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus        = g_DbManager.AllocRequest();
    g_DbManager.MakeRequest( lpDbOverlappedPlus, lpBuf, uBufSize );
    lpDbOverlappedPlus->dpid    = dpid;
    lpDbOverlappedPlus->nQueryMode = SAVE_ARENASCORE;
    PostQueuedCompletionStatus( g_DbManager.m_hIOCPPut, 1, NULL, &lpDbOverlappedPlus->Overlapped );
}

void CDPTrans::SendArenaScore( u_long idPlayer, int nAkill, int nAdeath )
{

    BEFORESENDDUAL( ar, PACKETTYPE_ARENA_GET, DPID_UNKNOWN, DPID_UNKNOWN );
    ar << idPlayer << nAkill << nAdeath;

    SEND( ar, this, DPID_ALLPLAYERS );
}
#endif


dpTrans.h
Code:
#ifdef __ARENA_SCORE
void OnGetArenaScore( CAr & ar, DPID dpid, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize );
void OnSendArenaScore( CAr & ar, DPID dpid, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize );
void SendArenaScore( u_long idPlayer, int nAkill, int nAdeath );
#endif

DbManager.cpp

Code:
#ifdef __ARENA_SCORE
            case LOAD_ARENASCORE:
                LoadArenaScore( pQueryChar, lpDbOverlappedPlus );
                break;
            case SAVE_ARENASCORE:
                SaveArenaScore( pQueryChar, lpDbOverlappedPlus );
                break;
#endif
Code:
#ifdef __ARENA_SCORE
void CDbManager::LoadArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
    CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );
    
    u_long nidPlayer;
    int    nArenaKills; 
    int    nArenaDeaths;
    arRead >> nidPlayer;
    char szQuery[QUERY_SIZE] = {0,};
    sprintf( szQuery, "uspLoadArena @serverindex='%02d', @idPlayer='%07d' ",g_appInfo.dwSys, nidPlayer );    //can add arguments directly %s %d..
    //RUN QUERY

    


    //RUN QUERY
    if( FALSE == qry->Exec( szQuery ) )
    {
        WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );

    }



            while( qry->Fetch() )
            {    
                    nArenaKills    =    qry->GetInt("nArenaKills");
                    nArenaDeaths    =    qry->GetInt("nArenaDeaths");
            }

    
    CDPTrans::GetInstance()->SendArenaScore( nidPlayer, nArenaKills, nArenaDeaths );

    FreeRequest( lpDbOverlappedPlus );
}

void CDbManager::SaveArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus )
{
    CAr arRead( lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize );
    
    u_long idPlayer;
    int    nArenaKills;
    int    nArenaDeaths;
    BOOL bCreate;
    arRead >> idPlayer >> nArenaKills >> nArenaDeaths >> bCreate;

    char szQuery[250] = {0,};
if( !bCreate )
    sprintf( szQuery, "uspSaveArena @serverindex='%02d', @idPlayer='%07d', @nArenaKills='%d', @nArenaDeaths='%d'", g_appInfo.dwSys, idPlayer, nArenaKills, nArenaDeaths );
else
    sprintf( szQuery, "TRUNCATE TABLE dbo.ArenaScore");


        if( FALSE == qry->Exec( szQuery ) )
        {
            WriteLog( "%s, %d\t%s", __FILE__, __LINE__, szQuery );
            FreeRequest( lpDbOverlappedPlus );
            return;
        }
    

    FreeRequest( lpDbOverlappedPlus );
}
#endif


DbManager.h

Code:
#ifdef __ARENA_SCORE
    ,LOAD_ARENASCORE
    ,SAVE_ARENASCORE
#endif
Code:
#ifdef __ARENA_SCORE
void    LoadArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus );
void    SaveArenaScore( CQuery *qry, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus );
#endif

Client :

DpClient.cpp

Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreClient.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
            case SNAPSHOTTYPE_ARENA_UPDATE: OnArenaUpdate( ar ); break;
#endif

Code:
#ifdef __ARENA_SCORE
void CDPClient::OnArenaUpdate( CAr & ar )
{
    int nCount;
    
    ar >> nCount;
    
    g_ArenaScore.m_vecUserInfo.clear();

    for( int i=0; i<nCount; i++)
    {
        ARENA_INFO tmpInfo;
        ar.ReadString( tmpInfo.szName );
        ar >> tmpInfo.nKills;        
        ar >> tmpInfo.nDeaths;
        ar >> tmpInfo.nPoints;
        ar >> tmpInfo.nKills2;
        ar >> tmpInfo.nDeaths2;
        ar >> tmpInfo.nLevel;

        g_ArenaScore.m_vecUserInfo.push_back( tmpInfo );
    }
    

}

#endif

DPClient.h

Code:
#ifdef __ARENA_SCORE
    void    OnArenaUpdate( CAr & ar );
#endif

Neuz.cpp

Code:
#ifdef __ARENA_SCORE
    m_pHeroIconArena = NULL;
#endif

Code:
#ifdef __ARENA_SCORE
    m_pHeroIconArena = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ICON, "icon_ArenaMvp.png"), 0xffff00ff );
#endif

Neuz.h

Code:
#ifdef __ARENA_SCORE
    CTexture*                m_pHeroIconArena;
#endif

FuncTextCmd.cpp

Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif
#endif    // __WORLDSERVER

Code:
BOOL TextCmd_ArenaAllout( CScanner& scanner )  
{ 
#ifdef __WORLDSERVER
#ifdef __ARENA_SCORE
            g_ArenaScore.m_nRemainTime = ::timeGetTime();
            g_ArenaScore.KickOut();
#endif
#endif
            return TRUE;
}

Code:
#ifdef __ARENA_SCORE
    ON_TEXTCMDFUNC( TextCmd_ArenaAllout,           "AlloutArena",              "aoa",             "½Ã°£",           "½Ã",      TCM_SERVER, AUTH_GAMEMASTER      , "½Ã°£ º¸±â [/½Ã°£]" )
#endif

WndWorld.cpp


Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreClient.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
    g_ArenaScore.WorldDrawer(p2DRender);
#endif
Code:
#ifdef __ARENA_SCORE
        if( nChar == VK_TAB )
            g_ArenaScore.m_bDraw = !g_ArenaScore.m_bDraw;
#endif


Mover.cpp


Code:
#ifdef __ARENA_SCORE
#include "..\WORLDSERVER\ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __WORLDSERVER
#ifdef __ARENA_SCORE
            if( GetWorld()->IsArena() && IsPlayer() )
                g_ArenaScore.ArenaOnKillHook((CUser*)pAttacker,(CUser*)this);
#endif    // __ARENA_SCORE
#endif


MoverRender.cpp


Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreClient.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
            //Arena Score
        if( GetWorld()->IsArena() && !strcmp( m_szName , g_ArenaScore.m_vecUserInfo[0].szName) )
        {
                    pTexture = g_Neuz.m_pHeroIconArena;
                    if( pTexture )
                    {
                        long oldpointx=point.x;
                        long oldpointy=point.y;
                        point.y -= pTexture->m_size.cy + 5;
                        point.y = point.y+1;
                        //point.x = point.x + 15;
                        if(pGuild==NULL)
                        {
                            point.x -= cs1.cx + 27;    
                        }
                        else
                        {
                            if( cs1.cx > cs2.cx )
                            {
                                if(this->GetGuild()->m_dwLogo!=NULL)
                                {
                                    point.x -= cs1.cx + 52;    
                                }
                                else
                                {
                                    point.x -= cs1.cx + 27;    
                                }
                            }
                            else
                            {
                                if(this->GetGuild()->m_dwLogo!=NULL)
                                {
                                    point.x -= cs2.cx + 52;    
                                }
                                else
                                {
                                    point.x -= cs2.cx + 27;    
                                }
                            }
                        }

                            pTexture->Render( &g_Neuz.m_2DRender, point );

                        point.x=oldpointx;
                        point.y=oldpointy;
                    }
            }
#endif

Worldserver:

DPDatabaseClient.cpp


Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
    ON_MSG( PACKETTYPE_ARENA_GET, OnGetArenaScore );
#endif


Code:
#ifdef __ARENA_SCORE // SendArenaUpdate
    if( pUser->m_nArenaKills || pUser->m_nArenaDeaths ) // Override fix.
        g_dpDBClient.SendArenaScore( pUser->m_idPlayer, pUser->m_nArenaKills, pUser->m_nArenaDeaths );
#endif

Code:
#ifdef __ARENA_SCORE


void CDPDatabaseClient::OnGetArenaScore(  CAr & ar, DPID, DPID )
{
    u_long idPlayer;
    int nKills,nDeaths;

    ar >> idPlayer >> nKills >> nDeaths;

    CUser* pUser    = g_UserMng.GetUserByPlayerID( idPlayer );

    if(IsValidObj(pUser))
    {    
        pUser->m_nArenaKills = nKills;
        pUser->m_nArenaDeaths = nDeaths;
        //g_UserMng.AddArenaUpdateSingleUser( pUser ); // Send User joined to other Clients.
    }


}


void CDPDatabaseClient::SendArenaScore( u_long idPlayer, int nAkill , int nAdeath, BOOL bCreate )
{

    BEFORESENDDUAL( ar, PACKETTYPE_ARENA_UPDATE, DPID_UNKNOWN, DPID_UNKNOWN );
    ar << idPlayer << nAkill << nAdeath << bCreate;
    SEND( ar, this, DPID_SERVERPLAYER );
}

void CDPDatabaseClient::GetArenaScore( u_long idPlayer )
{

    BEFORESENDDUAL( ar, PACKETTYPE_ARENA_GET, DPID_UNKNOWN, DPID_UNKNOWN );
    ar << idPlayer;
    SEND( ar, this, DPID_SERVERPLAYER );
}
#endif


DPServer.cpp


Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif

ThreadMng.cpp


Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
                g_ArenaScore.Process();
#endif


User.cpp

Code:
#ifdef __ARENA_SCORE
#include "ArenaScoreWorld.h"
extern CArenaScore g_ArenaScore;
#endif

Code:
#ifdef __ARENA_SCORE
    m_nArenaKills = 0;
    m_nArenaKills2 = 0;
    m_nArenaPoints = 0;
    m_nArenaDeaths = 0;
    m_nArenaDeaths2 = 0;
    m_nArenaIndex = NULL_ID;
#endif

Code:
#ifdef __ARENA_SCORE
    if( GetWorld()->IsArena() ) // This hook fixes the Score and ID of the player no matter where they are
        if( !g_ArenaScore.IsArenaUser( this ) )
        {
                g_ArenaScore.ArenaOnJoin( this );                // or how they got into thr Arena.

        }
    if( !GetWorld()->IsArena() )
            if( g_ArenaScore.IsArenaUser( this ) )
            {
                    g_ArenaScore.ArenaOnExit( this );
            }
#endif

Code:
#ifdef __ARENA_SCORE


void CUserMng::AddArenaUpdate()
{

    CAr arBlock;

    arBlock << NULL_ID << SNAPSHOTTYPE_ARENA_UPDATE;
    arBlock << g_ArenaScore.m_vecUserInfo.size();

    for( DWORD i = 0; i < g_ArenaScore.m_vecUserInfo.size(); i++ )
    {    
        arBlock.WriteString( g_ArenaScore.m_vecUserInfo[i].szName );
        arBlock << g_ArenaScore.m_vecUserInfo[i].nKills;
        arBlock << g_ArenaScore.m_vecUserInfo[i].nDeaths;
        arBlock << g_ArenaScore.m_vecUserInfo[i].nPoints;
        arBlock << g_ArenaScore.m_vecUserInfo[i].nKills2;
        arBlock << g_ArenaScore.m_vecUserInfo[i].nDeaths2;
        arBlock << g_ArenaScore.m_vecUserInfo[i].nLevel;
    }

    GETBLOCK( arBlock, lpBlock, uBlockSize );

    for( DWORD i = 0; i < g_ArenaScore.m_vecUserInfo.size(); i++ )
    {
        CUser* pUserReceive = prj.GetUser(g_ArenaScore.m_vecUserInfo[i].dwID);
        if( !pUserReceive )
            continue;

        pUserReceive->AddBlock( lpBlock, uBlockSize );
    }


}


void CUserMng::GetArenaUsers()
{    

    if( ::timeGetTime() > g_ArenaScore.m_nRejoinTime + 2000 )
    {
        map<DWORD, CUser*>::iterator it;
        for( it = m_users.begin(); it != m_users.end(); ++it )
        {
            CUser* pUser = it->second;

            if( !pUser->IsValid() )
                continue;

            if( pUser->GetWorld()->IsArena() )
                g_ArenaScore.NewUser( pUser );
       }

    }

}

#endif

Code:
#ifdef __ARENA_SCORE
    if( g_ArenaScore.IsArenaUser( pUser ) )
        {
            g_ArenaScore.ArenaOnExit( pUser );
            DestroyPlayer( pUser );
            return;
        }
    #endif

DatabaseClient.h



Code:
#ifdef __ARENA_SCORE
    // Arena
    void    SendArenaScore( u_long idPlayer, int nAkill , int nAdeath, BOOL bCreate = FALSE );
    void    GetArenaScore( u_long idPlayer );
    void    OnGetArenaScore(  CAr & ar, DPID, DPID );

#endif



User.h



Code:
#ifdef __ARENA_SCORE
public:
    //Arena Score
    int        m_nArenaKills;
    int        m_nArenaKills2;
    int        m_nArenaPoints;
    int        m_nArenaDeaths;
    int        m_nArenaDeaths2;
    int        m_nArenaIndex;

#endif

Code:
#ifdef __ARENA_SCORE
    void            AddArenaUpdate();
    void            GetArenaUsers();
#endif

msghdr.h

Code:
#define PACKETTYPE_ARENA_UPDATE (DWORD)0x00DD0001
#define PACKETTYPE_ARENA_GET (DWORD)0x00DD0002


Credits :

99.9% Pumaaa ( Recode )
0.01% lol32/caja ( Arena ~ Original Code )


 
Last edited:
Flyff Developer
Loyal Member
Joined
Apr 6, 2009
Messages
1,873
Reaction score
384
Some of the coding for DPClient.cpp didn't copy over completely.
 
Junior Spellweaver
Joined
Apr 9, 2011
Messages
111
Reaction score
6
sorry.. rechecked and now its complete :)
 
Flyff Developer
Loyal Member
Joined
Apr 6, 2009
Messages
1,873
Reaction score
384
Thanks. Mind telling me what site you found this on? I've never seen it before.
 
[R8]ℓσℓ32
Loyal Member
Joined
Oct 6, 2008
Messages
1,396
Reaction score
198
100% working, but as far as I know only 3 people get it working properly without crashes, since the guide it's not very "spoonfeed". Use your brain a bit.


Thanks. Mind telling me what site you found this on? I've never seen it before.

Got released on mmorpg-core a long time ago.
 
Junior Spellweaver
Joined
Apr 9, 2011
Messages
111
Reaction score
6
^agreed with this person Use your brain a bit.
 
i <3 C++
Joined
Jun 4, 2005
Messages
383
Reaction score
100
goodluck ^_^

btw you need to do the msghdr.h

#define PACKETTYPE_ARENA_UPDATE (DWORD)0x00DD0001
#define PACKETTYPE_ARENA_GET (DWORD)0x00DD0002


#define SNAPSHOTTYPE_ARENA_UPDATE (WORD)0x8861
#define SNAPSHOTTYPE_ARENA_UPDATE_SINGLE (WORD)0x8862

^_^
 
Last edited:
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
Hey, i have been trying to add this from mmorpg-core for a few weeks, i can't seem to find why my client connects to the game, but after selecting a character it goes to a white screen then the client crashes, i am sure i have defined everything correctly, and added everything in the right place, i have tried this in debug mode the same thing happens, can someone point me in the right direction please? or give me a list of defines and extras needed for me to check off.

Thanks
Nick
 
Experienced Elementalist
Joined
Sep 8, 2009
Messages
296
Reaction score
78
^In the process of adding it I never experienced anything like that.
 
Experienced Elementalist
Joined
Sep 8, 2009
Messages
296
Reaction score
78
For me it d/c's when I enter arena

D/C Or Crash? Mine crashed my client under certain circumstances, such as if someone entered the arena or i logged in while in the arena, I fixed it by moving some of the coding in the source.
 
Experienced Elementalist
Joined
Sep 8, 2009
Messages
296
Reaction score
78
I unfortunately cannot remember exactly what I edited, I know I played around with it for about 5 hours and finally got it to function properly, the only thing I'm working on now is making it save the kills/deaths into the ArenaScore table that I had to create same with the procedures to make it save.
 
Joined
Oct 6, 2008
Messages
471
Reaction score
73
I unfortunately cannot remember exactly what I edited, I know I played around with it for about 5 hours and finally got it to function properly, the only thing I'm working on now is making it save the kills/deaths into the ArenaScore table that I had to create same with the procedures to make it save.

Dang.. How do you forget something that took you so long to correct? oh well thanks any way.
 
Skilled Illusionist
Joined
Nov 29, 2009
Messages
368
Reaction score
15
Well, i have been trying to get this to work for a week or so and no luck, so i don't know where i am going wrong :(
 
Back
Top