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

Fix unknown Monster Family crashing the server (see #5442) #5444

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tonitch
Copy link
Contributor

@tonitch tonitch commented Sep 27, 2022

Should solve #5442
I'm sorry for the other pr, I just messed it up so I make a new one...

Fixes #5442

Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

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

Thank You!

Just one minor comment.

src/Mobs/Monster.cpp Show resolved Hide resolved
@12xx12 12xx12 changed the title Fix #5442 Fix unknown Monster Family crashing the server (see #5442) Oct 18, 2022
Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

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

This won't crash. Good to merge

@tigerw
Copy link
Member

tigerw commented Nov 2, 2022

Will this work if you pass -2? i.e. I think the problem is Lua calling C++ with arbitrary integer values but C++ not expecting them since it works based off the fixed set of enumeration values. I would suggest writing a manual binding similar to this and adding a manual error check like so:

if (!cChunkDef::IsValidHeight(Position))
{
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
}
to cleanly report to the plugin that it did something wrong.

Something like if pluginmonstertype < mtInvalidType || pluginmonstertype > zombievillager { error } else { call cMonster::FamilyFromType(pluginmonstertype) }

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.

API: Passing -1 to function cMonster:FamilyFromType crashes the server
3 participants