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

Spawn multiple entities #36

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

Conversation

John-Ingram
Copy link

Added code to spawn.h to allow for spawning multiple entities at once.

Copy link
Owner

@aaronkirkham aaronkirkham left a comment

Choose a reason for hiding this comment

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

Hey, looks good to me, just a few comments/ideas about std::stoi.

What happens right now if the user enters random / invalid data?
e.g. spawn car * aaaaaaaaa ///// / ********

I'm guessing stoi will throw due to invalid conversion and cause the game to crash due to an unhandled exception, which is why I suggested atoi instead.

Let me know what you think.

size_t spacer_position = arguments.find("/", 0);
std::string truncated_args = arguments.substr(0, multiplier_position - 1);

int multiplier = std::stoi(arguments.substr(multiplier_position + 1, 4));
Copy link
Owner

Choose a reason for hiding this comment

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

Just thinking if atoi would be better here (and line 42). std::stoi will throw an exception if the conversion fails, atoi will simply return 0, which I think would be OK here instead of doing exception handling.

int spacer = 5;

if (spacer_position != std::string::npos) {
spacer = std::stoi(arguments.substr(spacer_position + 1, std::string::npos));
Copy link
Owner

Choose a reason for hiding this comment

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

See notes above

@DiNod333
Copy link

I can not build the project myself, there are no additional source files to build, such as in the folder meow-hook. If anyone has succeeded, tell me how.

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.

None yet

3 participants