Jump to content

Evor

Inactive Member
  • Posts

    84
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    0%

Posts posted by Evor

  1. Hello,

    stuck with proper UV maps caluclation.... (yeah, rectangle too complicated figure)

    So, all in all i've got something like this: 6be4f50e11a230f67080651162c7d653.png

    with that:

    
    	float fWidth = m_width;
    	float fHeight = m_height;
    
    	float texReverseWidth = 1.0f / (fWidth); // TextureWidth
    	float texReverseHeight = 1.0f / (fHeight); // TextureHeight
    	float su = m_renderRect.left * texReverseWidth;
    	float sv = m_renderRect.top * texReverseHeight;
    	float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left));
    	float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top));
    
    	SAFE_RELEASE(m_lpd3dOriginalRenderTarget);
    	SAFE_RELEASE(m_lpd3dOldDepthBufferSurface);
    
    	TPDTVertex pVertices[4];
    
    	pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f);
    	pVertices[0].texCoord = TTextureCoordinate(su, sv);
    	pVertices[0].diffuse = 0xffffffff;
    
    	pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f);
    	pVertices[1].texCoord = TTextureCoordinate(eu, sv);
    	pVertices[1].diffuse = 0xffffffff;
    
    	pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f);
    	pVertices[2].texCoord = TTextureCoordinate(su, ev);
    	pVertices[2].diffuse = 0xffffffff;
    
    	pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f,
    		m_renderRect.top + fHeight - 0.5f, 0.0f);
    	pVertices[3].texCoord = TTextureCoordinate(eu, ev);
    	pVertices[3].diffuse = 0xffffffff;
    
    	if (CGraphicBase::SetPDTStream(pVertices, 4))
    	{
    		CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT);
    
    		STATEMANAGER.SetTexture(0, GetRenderTargetTexture());
    		STATEMANAGER.SetTexture(1, NULL);
    		STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
    		STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
    	}

     

    On the other hand, i've got this: b338ac253bcb5efea64ba3209e380fbd.png

    with that:

    
    	float fWidth = m_width;
    	float fHeight = m_height;
    
    	float texReverseWidth = 1.0f / (desc.Width); // ScreenWidth
    	float texReverseHeight = 1.0f / (desc.Height); // ScreenHeight
    	float su = m_renderRect.left * texReverseWidth;
    	float sv = m_renderRect.top * texReverseHeight;
    	float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left));
    	float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top));
    
    	SAFE_RELEASE(m_lpd3dOriginalRenderTarget);
    	SAFE_RELEASE(m_lpd3dOldDepthBufferSurface);
    
    	TPDTVertex pVertices[4];
    
    	pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f);
    	pVertices[0].texCoord = TTextureCoordinate(su, sv);
    	pVertices[0].diffuse = 0xffffffff;
    
    	pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f);
    	pVertices[1].texCoord = TTextureCoordinate(eu, sv);
    	pVertices[1].diffuse = 0xffffffff;
    
    	pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f);
    	pVertices[2].texCoord = TTextureCoordinate(su, ev);
    	pVertices[2].diffuse = 0xffffffff;
    
    	pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f,
    		m_renderRect.top + fHeight - 0.5f, 0.0f);
    	pVertices[3].texCoord = TTextureCoordinate(eu, ev);
    	pVertices[3].diffuse = 0xffffffff;
    
    	if (CGraphicBase::SetPDTStream(pVertices, 4))
    	{
    		CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT);
    
    		STATEMANAGER.SetTexture(0, GetRenderTargetTexture());
    		STATEMANAGER.SetTexture(1, NULL);
    		STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE);
    		STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
    	}

    I'm missing something, but this direct api makes me crazy.

    All help gladly appreciated.

    Regards!

  2. Hello folks.

     

    Today i will show you have to solve some more or less serious bugs.

     

    P2P BASHPANEL:


    First of all, well mentioned bashpanel.

    The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP.

    First of all, let's talk about what P2P connections are.
    P2P is a way for all cores to communicate with each other.
    The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge).
    The fix is really simple and already implemented, but was unnecessarliy commented out.

    Let's find: (in main.cpp)
     

    if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    

    As we see, p2p is deafult for the PublicIP, but above that, we can see:

    // if internal ip exists, p2p socket uses internal ip, if not use public ip
    	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    

    and that's the way how it should look. 
    To apply it, simply make it look like this:

    // if internal ip exists, p2p socket uses internal ip, if not use public ip
    if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    //if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    

    instead of:

    // if internal ip exists, p2p socket uses internal ip, if not use public ip
    	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)
    

    First bug fixed.

     

    Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports.

    DB Account BUG:

    Let's move on.

    When DB port is Publicly available, user, which knows the account id, can simply use it.

    To fix it, let's make a "brute" fix, another way (using older revisions) is to write:

    BIND_IP: 127.0.0.1
    

    in ur config file, but let's fix it more quietly. 

    Simply move to ClientManager.cpp in DB, and change it like so:
    from:

    if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
    		strlcpy(szBindIP, "0", sizeof(szBindIP));
    

    to:

    if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
    		strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP));
    

    That's it. Fixed.

     

    Kind regards.

    • Good 2
    • Love 10
  3.  

     

     

    You didn't have to give the actual link to this kick hack.. now i have to make lib for 34k coz kids are playing around^

     

    Having the information public is the fastest way to get people to take action against it and the fix is in the thread. If you're able to create libs then it should be no problem for you

     

    Also having the hack we could test if the c++ fix works :D

     

     

     

    give me the hack for test in my server? Thank you

     

    http://wklej.to/BZqOB

    password: metin2dev

     

    only for testing purposes only and i don't know this works because i didn't use it

     

    While reading source, i think that, it is an older version of kick hack, because of using WHISPER instead of MESSENGER (friend adding.).

    Regards..

    • Metin2 Dev 1
    • Lmao 1
  4. Hello.

    Recently, my server is doing really strange things.

    The main problem is that after several minutes players got randomly disconnected.

    I mean, they are logged in the first channel, in the first map of empire and randomly they got disconnected.

    I'm unable to debug game core (more than 1000 players).

     

    My syslog showed only that:

    http://pastebin.com/Sj3ekt7w

    I removed sequence checking:
     

                    if (m_pPacketInfo->IsSequence(bHeader))
    		{
    			BYTE bSeq = lpDesc->GetSequence();
    			BYTE bSeqReceived = *(BYTE *) (c_pData + iPacketLen - sizeof(BYTE));
    
    			if (bSeq != bSeqReceived)
    			{
                                LPCHARACTER	ch = lpDesc->GetCharacter();
                                if(!ch) {
                                    lpDesc->SetPhase(PHASE_CLOSE);
                                   return true;
                               }
                            }          
    				
    			lpDesc->push_seq(bHeader, bSeq);
    			lpDesc->SetNextSequence();
    		}
    

    and i bump buffer size from 8192 to 9216.

     

    I got really confused...

    Kind regards,

    Evor.

  5. Hello folks.

    I don't know if it was "a feature" or not, but it was really annoying and it caused some bugs.

     

    So, let's begin.

     

    Firstly, we should go to the char.cpp (and we will stay here)

    Now, let's find the ApplyPoint function and then certain cases..

    case APPLY_MAX_HP:
    		case APPLY_MAX_HP_PCT:
    			{
    				int i = GetMaxHP(); if(i == 0) break;
    				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
    				float fRatio = (float)GetMaxHP() / (float)i;
    				PointChange(POINT_HP, GetHP() * fRatio - GetHP());
    			}
    			break;
    
    		case APPLY_MAX_SP:
    		case APPLY_MAX_SP_PCT:
    			{
    				int i = GetMaxSP(); if(i == 0) break;
    				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
    				float fRatio = (float)GetMaxSP() / (float)i;
    				PointChange(POINT_SP, GetSP() * fRatio - GetSP());
    			}
    			break;
    

    This part of code is written by Nova, which is used in novaline, but i know that some of you use it in other branches.

    It is causing the main problem, we should change it to look like this:

    case APPLY_MAX_HP:
    		case APPLY_MAX_HP_PCT:
    			{
    				int i = GetMaxHP(); if(i == 0) break;
    				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
    			}
    			break;
    
    		case APPLY_MAX_SP:
    		case APPLY_MAX_SP_PCT:
    			{
    				int i = GetMaxSP(); if(i == 0) break;
    				PointChange(aApplyInfo[bApplyType].bPointType, iVal);
    			}
    			break;
    

    Done, now we should conern next problem, it will cause a disproportion between max_hp and current hp.
    Moving on, we should find PointChange function (still in char.cpp).

    Then, find case POINT_MAX_HP and POINT_MAX_SP, and change it like that:

    case POINT_MAX_HP:
    			{
                                
    				SetPoint(type, GetPoint(type) + amount);
                                    int i = GetMaxHP();
    				int hp = GetRealPoint(POINT_MAX_HP);
    				int add_hp = MIN(3500, hp * GetPoint(POINT_MAX_HP_PCT) / 100);
    				add_hp += GetPoint(POINT_MAX_HP);
    				add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
    				SetMaxHP(hp + add_hp);
                                    float fRatio = (float)GetMaxHP() / (float)i;
                                    PointChange(POINT_HP, GetHP() * fRatio - GetHP());
    				val = GetMaxHP();
    			}
    			break;
    
    		case POINT_MAX_SP:
    			{
    				SetPoint(type, GetPoint(type) + amount);
                                    int i = GetMaxSP();
    				int sp = GetRealPoint(POINT_MAX_SP);
    				int add_sp = MIN(800, sp * GetPoint(POINT_MAX_SP_PCT) / 100);
    				add_sp += GetPoint(POINT_MAX_SP);
    				add_sp += GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
    				SetMaxSP(sp + add_sp);
                                    float fRatio = (float)GetMaxSP() / (float)i;
                                    PointChange(POINT_SP, GetSP() * fRatio - GetSP());
    				val = GetMaxSP();
    			}
    			break;
    

    Short description:

    I'm using  Nova method to calculate HP/SP ratio gain. It should prevent people from using it as a infinite source of hp (using affect.add(max_hp.. affect.add(hp... we would create another bug.)

    Kind regards,

    Evor.

    @DISCLAIMER

    This method was tested by me and my team. We find it fixing the whole problem, but whenever you find another bug, please report it.

    Ratio calculation courtesy of Nova.

    • Metin2 Dev 1
    • Love 10
  6. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hello guys!

     

    It is common that, whenever u want to use an old mob_proto, u need to rewrite mob_color column for every mob (serverside mob_proto dosen't include mob_color). I write this really simple python code to convert old mob_proto columns to a sql version of it. (Simply, insert that .sql file).

     

    To do:
    - Place your old mob_proto_dump.xml in a folder with converter.py

    - Remove first and last line of mob_proto_dump.xml

    - Make sure that u have python installed. (no matter which version)

    - Run it and save time :)

     

    Spoiler
    
    ## oldMobProto to sqlMobProto Converter
    ## Created by Evor.
    ## For personal use 
    oldProto = open("mob_proto_dump.xml", "r+")
    newProto = open("mob_proto_color.sql", "w+")
    newProto.write("/* Converter by Evor */n")
    for line in oldProto:
    	vnum = line.split("vnum=")[1].split(" name=")[0].replace(""", "")
    	mobColor = line.split("mob_color=")[1].split(" />")[0].replace(""", "")
    	if not int(mobColor) == 0:
    		newProto.write("UPDATE mob_proto SET mob_color='%s' WHERE vnum='%s' ;n" % ## there is a space between end of mysql syntax and semicolom, becouse without it navicat has some troubles in inserting that.
    		(mobColor, vnum))
    oldProto.close()
    newProto.close()
    	

     

    Kind regards.

     

    @Update.
    Smaller code.

    • Metin2 Dev 9
    • Good 3
    • Love 5
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.