HurricanGame / Hurrican

Freeware jump and shoot game created by Poke53280, based on the Turrican game series by Manfred Trenz
61 stars 22 forks source link

Console command macro #55

Closed Mia75owo closed 11 months ago

Mia75owo commented 11 months ago

Moved console commands with an argument to a macro, which is controlled by the ENABLE_CONSOLE_COMMANDS flag and moved code get the argument from the console buffer to its own function.

drfiemost commented 11 months ago

It looks good, but I don't see the need for CONSOLE_COMMAND_ARG as all the strings are null-terminated. Not sure why the original code used strncpy. Also, while at it, the CONSOLE_COMMAND macro should ideally be turned into a static inline function.

Mia75owo commented 11 months ago

It uses strncpy because commands like maxfps take an argument. maxfps 30 would not be matched with strcmp. The difference between CONSOLE_COMMAND and CONSOLE_COMMAND_ARG is that the first one matches the whole buffer and the second one only matches the first x chars of the buffer to allow arguments.

I also moved the macros to a function but i didn't want to make it static because it uses Buffer of the class and i wanted to keep the functions within ConsoleClass