-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Don't utf8-check New_Game #470
Conversation
Don't utf8-check New_Game
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.
Looks pretty good. Just have one question.
engine/src/cmd/basecomputer.cpp
Outdated
@@ -5979,7 +5979,7 @@ bool BaseComputer::actionConfirmedLoadGame() | |||
if (desc) { | |||
std::string tmp = desc->text(); | |||
if (tmp.length() > 0) { | |||
if (!isUtf8SaveGame(tmp)) { | |||
if ((tmp != "New_Game") && (!isUtf8SaveGame(tmp))) { |
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.
I wonder if this check should be made case insensitive? Using, for example, boost::iequals
.
Other than that, looks good.
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.
New_Game is hard-coded, all other case variants are intentionally allowed as legit save names, and only this exact one is barred from manual save, so that the engine knows it's dealing with a new game.
You can see it for instance in the method above this one, actionSaveGame
, which I just copied to actionConfirmedLoadGame
for coherence: (string( "New_Game" ) != tmp)
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.
@P-D-E is there a string constant that can be used for that? If not, we should add an issue to introduce one.
I'd just hate to see that string modified slightly and have things break.
Also, we probably should prohibit all case variants of that string (if we don't right now, that should be another issue).
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.
Yes, there are quite a few independent instances of the string "New_Game":
engine/datascripts/setup.base.xml
engine/datascripts/021.nsi
engine/src/cmd/basecomputer.cpp
engine/src/options.cpp
engine/launcher/saveinterface.cpp
data/cgi-accountserver/db.py
data/bases/computer_lib.py
data/bases/main_menu.py
data/modules/GUI.py
and they are more than the usages of a convenient UniverseUtil::getNewGameSaveName
function in engine/src/universe_util_generic.cpp
also made available to Python via the VS
module, e.g.
engine/src/cmd/basecomputer.cpp
6010: desc->setText( UniverseUtil::getNewGameSaveName() );
data/bases/main_menu.py
16: VS.loadGame(VS.getNewGameSaveName())
We might try replacing all the explicit New_Game mentions with calls to the function, especially where the needed includes are already there. I'd leave that to 0.9.x, though.
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.
@P-D-E I'm good with a separate PR for that too; can you please open an issue with your findings? Thanks!
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.
We might try replacing all the explicit New_Game mentions with calls to the function, especially where the needed includes are already there.
That sounds like a good approach to me.
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.
@BenjamenMeyer @ermo Thank you both, here's the issue.
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.
Cool. Looks good to me then.
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.
Aside from my comments related to @stephengtuggy's review, I'm good for this too.
Thank you for submitting a pull request and becoming a contributor to the Vega Strike Core Engine.
Please answer the following:
Code Changes:
Issues:
Purpose: