Skip to content
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

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

jt-traub
Copy link
Contributor

@jt-traub jt-traub commented Oct 4, 2023

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.

Copy link
Member

@artyomtrityak artyomtrityak left a 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

@artyomtrityak
Copy link
Member

I am not sure it is correct solution.
We should change code = Parse1Order(token); in void Game::ParseOrders so it will parse correctly @endturn orders

@@ -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();
Copy link
Member

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?

Copy link
Contributor Author

@jt-traub jt-traub Oct 4, 2023

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'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artyomtrityak artyomtrityak merged commit 2092f69 into Atlantis-PBEM:neworigins-v6 Oct 4, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants