-
Notifications
You must be signed in to change notification settings - Fork 37
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
Allow @endturn on input orders #136
Allow @endturn on input orders #136
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.
Thank you for contribution
I am not sure it is correct solution. |
@@ -2042,6 +2042,8 @@ AString *Game::ProcessTurnOrder(Unit *unit, Aorders *f, OrdersCheck *pCheck, | |||
order = new AString("#end"); | |||
} | |||
AString saveorder = *order; | |||
// In order to allow @endturn to work the same as endturn we need to check for and eat the possible @ | |||
int getatsign = order->getat(); |
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.
Does it also eats turn @
?
It changes it for every order, is it intended to be?
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.
It doesn't change it for every order. The order that gets copied into the turn save, is a copy (saveorder). (the copy constructor operator=() for AString performs a copy of the input, which is why this is safe) This modifies the local order, but that isn't used except for checking for the end conditions for the turrn/endturn pair. Those were in fact broken if any of those ending conditions were preceeded by an @ leading to the buggy behavior. The code as it is now will just eat the @ before parsing the order and testing it. I don't think parsing the @ in Parse1Order will work given that the outer loop for this (the main parse loop) also relies on pulling off the @ and parsing the order, so you would need to return multiple values from Parse1Order which today just returns the int value of the current order it sees under it's cursor.
I tested this locally to make sure it didn't break anything by locally running turns with and without the @ in front of both the external and internal commands and they generated identical output now in all cases which is what we want.
In the order template output, it will be converted from @turn/@endturn to the @turn/endturn (without the @) which is also right. This is basically following the principle of 'be liberal in the input you accept, and be strict in the output you generate'.
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 https://github.com/Atlantis-PBEM/Atlantis/blob/neworigins-v6/astring.cpp#L102-L119 specifically lines 107 and 117
This allows the following structure
@turn
@endturn
to not end up screwing up and thinking you failed to end your orders. The checker and ALH already thought this was
fine. This just brings the game-processing in-line.