twohoursonelife / OneLife

Two Hours One Life, building upon One Hour One Life. Join us on Discord to play.
https://twohoursonelife.com
Other
46 stars 39 forks source link

Make VOG allowed accounts case insensitive. Fixes #106 #244

Closed TanyaPegasus closed 1 month ago

TanyaPegasus commented 1 month ago

The commit ensures that accounts allowed to enter VOG mode are no longer case sensitive, by converting the player email, and the line from vogAllowAccounts.ini to lowercase before comparison. It uses the stringToLowerCase() function which can be found in minorGems stringUtils. https://github.com/twohoursonelife/minorGems/blob/fbd0365bcb2ab3b1daf6c9f278c91a905a0186a1/util/stringUtils.cpp#L59

Tested and working locally as expected.

I've determined the code structure by comparing to other parts of the code base where this function is used, for consistency.

risvh commented 1 month ago

This works, then I saw this function near where you linked. What do you think?

https://github.com/twohoursonelife/minorGems/blob/fbd0365bcb2ab3b1daf6c9f278c91a905a0186a1/util/stringUtils.cpp#L117

TanyaPegasus commented 1 month ago

I think I saw that function later, after I'd done my version. The biggest reason I didn't then change it was because it does have to do more than just calling stringToLowercase directly as I did. Because we're iterating over a list, I only called the function to convert nextPlayer email once at the beginning, and then removed it at the end. If we were to use the comparison function, one of the parameters would be the same each time, and it would need to re-convert it each time. That being said, it's not a very long list, and is unlikely to ever be significantly larger, so it probably wouldn't make a big difference in terms of resources used.

connorhsm commented 1 month ago

Would be much preferred to see this reimplemented with the function, please.