Jump to content

Sanchez

Premium
  • Posts

    576
  • Joined

  • Days Won

    43
  • Feedback

    0%

Posts posted by Sanchez

  1. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hi everyone,

    Maybe just in my country, but it looks so many people started using this annoying PM flooder which cause a buffer overflow in the target client. It can be fixed easily on server-side, so let's do it:

    Add these functions as public to char.h:

        void ClearPMCounter(void)       { m_iPMCounter = 0;      } 
        void IncreasePMCounter(void)    { m_iPMCounter++;        }
        void SetLastPMPulse(void);
        int  GetPMCounter(void)   const { return m_iPMCounter;   }
        int  GetLastPMPulse(void) const { return m_iLastPMPulse; }
        

    Add these to char.h too, but as protected:

    int m_iLastPMPulse;
    int m_iPMCounter;
        

    Add this function to char.cpp:

    void CHARACTER::SetLastPMPulse(void)
    {
          m_iLastPMPulse = thecore_pulse() + 25;
    }

    Still in char.cpp search for the Initialize and add these to the function:

    m_iLastPMPulse = 0;
    m_iPMCounter = 0;

    Now navigate to the Whisper function in input_main.cpp and add this after the iExtraLen variable checking at the top:

    if (ch->GetLastPMPulse() < thecore_pulse())
         ch->ClearPMCounter();
         
    if (ch->GetPMCounter() > 3 && ch->GetLastPMPulse() > thecore_pulse())
    {
       ch->GetDesc()->SetPhase(PHASE_CLOSE);
       return -1;
    } 

    Search for this still in the Whisper function:

    if (pkChr == ch)
        return (iExtraLen);
        

    Add these after that:

    ch->IncreasePMCounter();
    ch->SetLastPMPulse();
        
    • Metin2 Dev 17
    • kekw 1
    • Good 9
    • Love 48
  2. There is a function, checkpointing which get executed every 30 seconds and check the value of a variable. If the value is more than 0, then everything okay, otherwise something stuck in the game which blocks a thread. I recommend you to delete all of your quests and try to run your server for a while. If you're not getting this error again, then one of your loop inside your quests are corrupt and trying to run for an infite time.

     

    Edit: It's a security alert, not a crash.

  3. I don't know what do you mean as "void" but do not do infinite while loops in the game, that blocks the thread. Use the built-in timer to achieve your goal:
     

    // Initialize the event
    static LPEVENT YourEvent = NULL;
     
    // Create the event information struct. You can pass values to the timer by adding them here.
    EVENTINFO(this_is_your_event_information)
    {
         // Just pass one value
         int value;
    };
     
    // Create the function of the event
    EVENTFUNC(this_is_your_event)
    {
        /* This is your event function, you can do anything here */
    
        // To reach your passed values, you have to do this
        this_is_your_event_information* info = dynamic_cast<this_is_your_event_information*>( event->info );
        // Get the value
        DoSomething(info->value);
     
        // The return value is the time of your re-execution
        return 5 * 25; // So this function will be called again in 5 seconds
    }
     
    /* To start your event */
     
    // Allocate the event informations
    this_is_your_event_information* info = AllocEventInfo<this_is_your_event_information>();
    // Set a value of your variable
    info->value = 3;
    // Start the event
    YourEvent = event_create(this_is_your_event, info, 5 * 25);
    
×
×
  • 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.