-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See notes above
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. |
Added code to spawn.h to allow for spawning multiple entities at once.