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

External arguments validation #1

Open
bogu9821 opened this issue Apr 2, 2024 · 2 comments
Open

External arguments validation #1

bogu9821 opened this issue Apr 2, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@bogu9821
Copy link
Owner

bogu9821 commented Apr 2, 2024

Adding arguments validation rules might be useful and can remove a lot of ifs in the externals code. e.g. we can eliminate checks if pointer is nullptr.
It must also allow you to make custom rules because sometimes you want to have nullpointers or some any different unvalid states.

@bogu9821 bogu9821 added the enhancement New feature or request label Apr 2, 2024
@bogu9821 bogu9821 self-assigned this Apr 2, 2024
@bogu9821
Copy link
Owner Author

bogu9821 commented Apr 2, 2024

Example: automatic nullpointer checks

Transform code like this

void Npc_DoTakeItem(oCNpc* t_npc, oCItem* t_item)
{
	if (!t_npc || !t_item)
	{
		return;
	}

	t_npc->DoTakeVob(t_item);
}

Into

void Npc_DoTakeItem(oCNpc* t_npc, oCItem* t_item)
{
	t_npc->DoTakeVob(t_item);
}

@bogu9821
Copy link
Owner Author

bogu9821 commented Apr 2, 2024

I also need to add checks of the instance types, because daedalus does not distinguish them.
e.g. item instance can be passed to npc argument and this can lead to a crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant