Skip to content

Remove entity lump manipulation from OnLevelInit#1534

Merged
asherkin merged 2 commits intomasterfrom
bug-1470
Jul 17, 2021
Merged

Remove entity lump manipulation from OnLevelInit#1534
asherkin merged 2 commits intomasterfrom
bug-1470

Conversation

@asherkin
Copy link
Member

Newer Source engine versions now use a dynamically allocated buffer for
the map entity lump, and some maps have over 16MB of entity data - far
larger than our 2MB limit.

There is no sane way we can currently handle this, so just remove the
functionality from the forward until a more comprehensive API can be
designed.

The change in behaviour to the OnLevelInit forward params isn't obvious
when compiling a plugin, deprecate it to make it a lot more obvious that
something has changed.

Some plugins rely just on the timing of OnLevelInit rather than doing
anything with the entity lump, for these plugins offer a new OnMapInit
forward that is implemented in core rather than sdkhooks. If / when we
offer a new entity lump manipulation API in the future this'll be the
forward where it can be used to make changes.

Fixes #1470

asherkin added 2 commits July 17, 2021 18:05
Newer Source engine versions now use a dynamically allocated buffer for
the map entity lump, and some maps have over 16MB of entity data - far
larger than our 2MB limit.

There is no sane way we can currently handle this, so just remove the
functionality from the forward until a more comprehensive API can be
designed.

Fixes #1470
The change in behaviour to the OnLevelInit forward params isn't obvious
when compiling a plugin, deprecate it to make it a lot more obvious that
something has changed.

Some plugins rely just on the timing of OnLevelInit rather than doing
anything with the entity lump, for these plugins offer a new OnMapInit
forward that is implemented in core rather than sdkhooks. If / when we
offer a new entity lump manipulation API in the future this'll be the
forward where it can be used to make changes.
@asherkin asherkin requested a review from dvander July 17, 2021 17:22
Copy link
Member

@Headline Headline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely the right direction regarding this.

Would the future new API be an extension of this new forward or would be be through a different avenue? Any fcompat we can do now to anticipate that coming new API?

Copy link
Member

@dvander dvander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem the right way to go, unfortunately.

@asherkin
Copy link
Member Author

Would the future new API be an extension of this new forward or would be be through a different avenue? Any fcompat we can do now to anticipate that coming new API?

I'm imagining some new natives where the read-only ones can be used inside and after this forward, and the write ones can be used only inside this forward - no changes to the actual forward itself.

@lazyuselessman
Copy link

Hi.
What do you guys think about creation another function OnLevelInit2 with next set of parameters

public Action OnLevelInit2(const char[] mapName, ArrayList mapEntities)

each element of mapEntities will have type char, so you can set up such ArrayList on higher level and pass it like this. And Plugin_Changed will left same.
Also it will be nice if each individual element wasn't splitted in the middle, i mean it should be that last element of individual will be } and the first one {.

So idea is something like pack big data in ArrayList and on return if data was changed unpack it back.

@dvander
Copy link
Member

dvander commented Dec 13, 2021

Are entities still passed in a key/value map? I feel like a specialized set of natives for interacting with the entity lump would be ideal. Such a big list/string is unworkable in Pawn.

@lazyuselessman
Copy link

Are entities still passed in a key/value map? I feel like a specialized set of natives for interacting with the entity lump would be ideal. Such a big list/string is unworkable in Pawn.

If it will be splitted as describe then yes it won't damage key/value map. It will be just few key/value map / strings, whatever u called it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OnLevelInit mapEntities / g_szMapEntities buffer too small and crashes for with some maps

4 participants