Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] A method to catch entity lump parse failures #2198

Open
ghost opened this issue Jul 29, 2024 · 6 comments
Open

[Feature Request] A method to catch entity lump parse failures #2198

ghost opened this issue Jul 29, 2024 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 29, 2024

logicore.SetEntityLumpWritable(true);
g_pOnMapInit->PushString(pMapName);
g_pOnMapInit->Execute();
logicore.SetEntityLumpWritable(false);
if (!success)
{
logger->LogError("Map entity lump parsing for %s failed with error code %d on position %d", pMapName, parseError, position);
RETURN_META_VALUE(MRES_IGNORED, true);
}

Plugins like the SourcePawn plugin for Stripper will not be able to make changes if entity lump parsing fails. If there is a method to catch fails developers can find another work around such as reloading the map.

@asherkin
Copy link
Member

What parsing failures have you run into that would have been recoverable?

@ghost
Copy link
Author

ghost commented Jul 29, 2024

Without SM, some maps sometimes crash on map start with MapEntity_ParseAllEntities: found ? when expecting {.

With SM, instead of crash on map start receive log Map entity lump parsing for failed with error code 1 on position -1 and reloading map fixes it.

Entity lump does write the changes but does not appear in the map.

@nosoop
Copy link
Contributor

nosoop commented Jul 31, 2024

The entity lump is packed into the map file, so the general assumption is that a failure in parsing would only come from a malformed map file (which would not be a sometimes-issue that is fixed on a reload).

In your case, you could probably check that EntityLump.Length() == 0 during either OnMapInit() or OnMapStart(). Failures to parse mid-file would return a partly filled entity lump, but neither of those behaviors are strictly specified.

Error code 0 does suggest that parsing returned Status_OK, so I'm not sure how you're hitting this case. If you could list your environment and reproduction steps, that would probably help.

@ghost
Copy link
Author

ghost commented Aug 1, 2024

Sorry, meant error code 1. But I will try EntityLump.Length() == 0 as I guess what on position -1 does mean.

@nosoop
Copy link
Contributor

nosoop commented Aug 1, 2024

Position -1 would be end-of-file, so either the whole string was consumed (unlikely if you're hitting the parse failure) or the string was empty. Empty string would mean EntityLump.Length() == 0 should work in your case.

@ghost
Copy link
Author

ghost commented Aug 2, 2024

Unfortunately didn't work for my case. The map is tr_walkway. Stripper extension can make changes without issue. I am thinking maybe adding the success bool to OnMapInit.

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

No branches or pull requests

2 participants