Membru Ucenic
Membru Ucenic
Mesaje: 46
Membru din: 10 Mai 2026, 14:20
  • Reacții: 79
  • Mesaje utile: 0
  • Status: Pierd vremea ^.^
  • Regat: Shinsoo
  • Medalii

    [FIX] MartySama Server Performance Optimizations - Mesaj 1 - Imagine 1

    entity_view.cpp




    ## entity_view.cpp

    This code block filters the rules for adding game entities (players, monsters, NPCs, ground items) to each other's view lists (`ViewInsert`) to optimize server performance. It reduces CPU and network packet load by preventing monsters and entities from tracking each other unnecessarily.

    * **Player Characters (`chMe->IsPC()`):** Adds all entities within their field of view (monsters, NPCs, items, other players) to their view list without restrictions. There is no reduction in visuals on the player's screen.
    * **Monsters and NPCs (`chMe->IsNPC()`):** Monsters are prevented from adding each other to their view lists. A monster or NPC takes a target into its view only under the following 4 conditions:
    * **Players:** If the target is a player (`IsPC()`) (to attack or follow).
    * **Healer Mobs:** If the monster has healer logic (`AIFLAG_HEALER`) and the target is in its own party (to cast healing spells).
    * **Ship Defense (Hydra):** If the target is the Hydra mast (`20434`) (to attack the mast).
    * **City Guards:** If the NPC is a guard (`IsGuardNPC()`), it sees surrounding monsters (to strike mobs entering the city).
    * **Non-Character Entities (`!m_me->IsType(ENTITY_CHARACTER)`):** Ground items or map objects only register surrounding players (`IsPC()`) into their view lists. Monsters are entirely excluded from the ground item matrix.
    * **When the Macro is Disabled (`#else`):** The classic Metin2 logic operates; all entities within range add each other to their view lists without exception.

    In classic Metin2, when 100 monsters in a room process each other, it creates $100 \times 100 = 10,000$ view matrix checks. Thanks to this filtering, monsters ignore each other, and the complexity drops solely to the number of players in that room.








    #define ENABLE_REDUCED_ENTITY_VIEW


    Code:
               
    
                #ifdef ENABLE_REDUCED_ENTITY_VIEW
    
                if (m_me->IsType(ENTITY_CHARACTER))
    
                {
    
                    const auto chMe = (LPCHARACTER) m_me;
    
    
    
                    // players view every entity
    
                    if (chMe->IsPC())
    
                        m_me->ViewInsert(ent);
    
    
    
                    // npcs view only a restricted amount of entities
    
                    else if (chMe->IsNPC() && ent->IsType(ENTITY_CHARACTER))
    
                    {
    
                        constexpr auto DefenseWaveMast = 20434;
    
                        const auto chEnt = (LPCHARACTER) ent;
    
    
    
                        // mobs view every player
    
                        if (chEnt->IsPC())
    
                            m_me->ViewInsert(ent);
    
    
    
                        // aiflag healers view their party
    
                        else if (IS_SET(chMe->GetAIFlag(), AIFLAG_HEALER) && chMe->GetParty() && chMe->GetParty() == chEnt->GetParty())
    
                            m_me->ViewInsert(ent);
    
    
    
                        // hydra mast is seen by other mobs
    
                        else if (chEnt->GetRaceNum() == DefenseWaveMast)
    
                            m_me->ViewInsert(ent);
    
    
    
                        // city guardians see all mobs
    
                        else if (chMe->IsGuardNPC())
    
                            m_me->ViewInsert(ent);
    
                    }
    
                }
    
                else if (ent->IsType(ENTITY_CHARACTER))
    
                {
    
                    const auto chEnt = (LPCHARACTER) ent;
    
    
    
                    // other entities see every player
    
                    if (chEnt->IsPC())
    
                        m_me->ViewInsert(ent);
    
                }
    
                #else
    
                m_me->ViewInsert(ent);
    
                #endif

    Nou Cum descarc de pe TeraBox?

    Afișează detalii Ascunde detalii
    • Este asemănător cu Mega.nz
    • Instalați-vă clientul lor de Download de aici
    • Faceți-vă un cont (vă puteți loga cu Facebook / Google / etc)
    • Nou Dacă nu vreți să descărcați clientul de Download, folosiți acest site
    • Gata! Acum puteți descărca resursele rapid & simplu.

    De ce folosim TeraBox?

    • Este gratuit
    • Primești 1TB de spațiu gratuit la orice cont creat!
    • Este ușor de folosit și varianta premium este foarte ieftină
    • Fișierele nu sunt șterse niciodată
    TeraBox logo

    Creează-ți un cont sau autentifică-te pentru a participa la discuție

    Trebuie să fii membru pentru a răspunde

    Creează-ți un cont

    Membrii pot crea subiecte noi și pot descărca resurse Metin2 Gratuit!


    Te poți înregistra sau conecta rapid utilizând contul tău de Discord, Github sau Google.

    Înregistrare

    Autentifică-te

    Înapoi la “FIX-uri”

    Informații

    Utilizatori ce navighează pe acest forum: Achilles, ElProfesor, Google [Bot], yungwrist și 4 vizitatori

    Discord ID copiat: