Jump to content
  • 0

Problem with lag


K_Doom

Question

Hi guys, I came here to ask a few questions.

Have you ever created a large map and had lag issues in a specific sector?
Well my computer is fine, I've never had any problems with any Doom maps so far, even the gigantic Sunder maps for example. But both in UDB creation and in the game I feel a small lag in the sector, why does this happen and how to solve it?

Share this post


Link to post

Recommended Posts

  • 0
11 hours ago, K_Doom said:

I found a things filter, this filter helps me to select all things of the same type. Very useful. Although there is still lag in that specific sector, at least now I don't use as many lights, making the map better for those who play.

 

Here's a solution in UDBScript:


 

`#version 4`;
`#name Remove duplicate things`;
`#description Removes things of the same type that share the exact same position, so that only one of them is left.`;

let things = {};
let totalremoved = 0;

// Group all things by their type
UDB.Map.getThings().forEach(t => {
    if(things[t.type] === undefined)
        things[t.type] = [];

    things[t.type].push(t);
});

// Go through all things by their type
for(let type in things)
{
    // Keep going while there are things left
    while(things[type].length > 0)
    {
        // Get the firstmost thing
        let thing = things[type].shift();

        // Get all things of the same type that share the position of the thing we just got
        let duplicates = things[type].filter(t => thing.position == t.position);

        // We only have to do the next steps if there are actually duplicates
        if(duplicates.length > 0)
        {
            // Delete all duplicates
            duplicates.forEach(t => t.delete());

            // Remove the duplicates from the list of things
            things[type] = things[type].filter(t => !duplicates.includes(t));

            // Tell the user what was done
            UDB.log(`Removed ${duplicates.length} duplicates for things type ${type} at (${thing.position})`);

            // Tally up the number of removed things
            totalremoved += duplicates.length;
        }
    }
}

// Show the summary
UDB.log('');
UDB.log(`Removed a total of ${totalremoved} things.`);

Note that the script is pretty naive, it only checks the thing types and positions, i.e. doesn't take any other properties (flags, actions, etc.) into account.

Share this post


Link to post
  • 0
6 hours ago, boris said:

 

Here's a solution in UDBScript:


 


`#version 4`;
`#name Remove duplicate things`;
`#description Removes things of the same type that share the exact same position, so that only one of them is left.`;

let things = {};
let totalremoved = 0;

// Group all things by their type
UDB.Map.getThings().forEach(t => {
    if(things[t.type] === undefined)
        things[t.type] = [];

    things[t.type].push(t);
});

// Go through all things by their type
for(let type in things)
{
    // Keep going while there are things left
    while(things[type].length > 0)
    {
        // Get the firstmost thing
        let thing = things[type].shift();

        // Get all things of the same type that share the position of the thing we just got
        let duplicates = things[type].filter(t => thing.position == t.position);

        // We only have to do the next steps if there are actually duplicates
        if(duplicates.length > 0)
        {
            // Delete all duplicates
            duplicates.forEach(t => t.delete());

            // Remove the duplicates from the list of things
            things[type] = things[type].filter(t => !duplicates.includes(t));

            // Tell the user what was done
            UDB.log(`Removed ${duplicates.length} duplicates for things type ${type} at (${thing.position})`);

            // Tally up the number of removed things
            totalremoved += duplicates.length;
        }
    }
}

// Show the summary
UDB.log('');
UDB.log(`Removed a total of ${totalremoved} things.`);

Note that the script is pretty naive, it only checks the thing types and positions, i.e. doesn't take any other properties (flags, actions, etc.) into account.

Thanks for that, it will help a lot.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...