Sign in to follow this  
HBPLD

Real Damage

Recommended Posts

is me again and still have problem with show real damage. Look this Client step

 

case DEF_OBJECTMAGIC:
case DEF_OBJECTDAMAGEMOVE:
case DEF_OBJECTDAMAGE:
            
    cDir = *cp;
    cp++;
        
              //here i change to receive with short
    sp  = (short *)cp;
    sV1 = *sp;
    cp += 2;

    sp  = (short *)cp;
    sV2 = *sp;
    cp += 2;
    //end
                
             break;

 

case DEF_OBJECTDYING:
    cDir = *cp;
    cp++;
              
              //here i change to receive with short
    sp  = (short *)cp;
    sV1 = *sp;
    cp += 2;

    sp  = (short *)cp;
    sV2 = *sp;
    cp += 2;
              //end

    sp  = (short *)cp;
    sX = *sp;
    cp += 2;

    sp  = (short *)cp;
    sY = *sp;
    cp += 2;
             break;

 

case DEF_OBJECTATTACK:
    cDir = *cp;
    cp++;
    
              //here i change to receive with short    
    sp  = (short *)cp;
    sV1 = *sp;
    cp += 2;
    
    sp  = (short *)cp;
    sV2 = *sp;
    cp += 2;
             //end

    sp = (short *)cp;
    sV3 = *sp;
    cp += 2;
              break;

 

 

and i change this

 

if (sV1 > 0)
    wsprintf(cTxt, "-%dPts!", sV1); //pts
else 
    strcpy(cTxt, "Critical!");

 

on this

 

wsprintf(cTxt, "-%dPts!", sV1); //pts

 

next HG step;

 

in function ::SendEventToNearClient_TypeA

 

i change it

 

    
             *cp_s = (unsigned char)sV1;
    cp_s++;

    *cp_s = (unsigned char)sV2;
    cp_s++;

on this

      

              sp = (short *)cp_s;
    *sp = (short)sV1;
    cp_s += 2;
        
    sp = (short *)cp_s;
    *sp = (short)sV2;
    cp_s += 2;

 

 

 

and change this

        *cp_sv = sV1 - sX;
        cp_sv++;

        *cp_sv = sV2 - sY;
        cp_sv++;

 

on this

 

sp = (short *)cp_s;
        *sp = (short)sV1-sX;
        cp_s += 2;
        
        sp = (short *)cp_s;
        *sp = (short)sV2-sY;
        cp_s += 2;

 

and second time under change that same

 

 

change this

    *cp_s = (unsigned char)sV1;
        cp_s++;
        *cp_s = (unsigned char)sV2;
        cp_s++;

on this

sp = (short *)cp_s;
        *sp = (short)sV1;
        cp_s += 2;
        
        sp = (short *)cp_s;
        *sp = (short)sV2;
        cp_s += 2;

 

 

change this

 

*cp_sv = sV1 - sX;
        cp_sv++;
        *cp_sv = sV2 - sY;
        cp_sv++;

 

on this

 

sp = (short *)cp_s;
        *sp = (short)sV1-sX;
        cp_s += 2;
        
        sp = (short *)cp_s;
        *sp = (short)sV2-sY;
        cp_s += 2;

 

and end my code and i have problem with this code because if i attack NPC and anything , client CRASH and dont show caption (-%d pts) strange error npc disappears , mobies

 

What wrong it this code? what i bad do? Please Help :/

 

Sory for my bad english.

Share this post


Link to post
Share on other sites

Remember that everytime you make a change on packets like changing var types etc. you're increasing the amount of bytes that will be sent to client / hgserver. So you also have to change the amount of bytes on SendMsg function.

 

I'll explain:

 

        *cp_sv = sV1 - sX;
        cp_sv++;

        *cp_sv = sV2 - sY;
        cp_sv++;

 

on this

 

sp = (short *)cp_s;
        *sp = (short)sV1-sX;
        cp_s += 2;
        
        sp = (short *)cp_s;
        *sp = (short)sV2-sY;
        cp_s += 2;

 

When you did that you change that cp++ to cp += 2 which means that you change the amount of bytes of the packet.

 

Then on hgserver there is a function called iSendMsg that's send that packet to client.

 

iSendMsg function its something like this:

iRet = m_pClientList[iClientH]->m_pXSock->iSendMsg(cData, iSize + 20);

 

Imagine that before your changes iSendMsg sent 20 bytes. After your changes you increase +1 bytes on each cp which give us +2 bytes, so you need to change that on iSendMsg.

 

iRet = m_pClientList[iClientH]->m_pXSock->iSendMsg(cData, iSize + 22);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this