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

{CHECK_EVEN}/{IF_EVEN}/{IF_ODD} macros are broken #70

Closed
cooljeanius opened this issue Jun 6, 2022 · 4 comments
Closed

{CHECK_EVEN}/{IF_EVEN}/{IF_ODD} macros are broken #70

cooljeanius opened this issue Jun 6, 2022 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@cooljeanius
Copy link
Collaborator

cooljeanius commented Jun 6, 2022

So, I first noticed this when trying to use the macros in S04 (Battle of Barnon), but it's a more generic issue than that if you look at how the macros are actually implemented:

#-------------------------------------------------------------------------------
# {IF_EVEN <numeric-variable>}
# {IF_ODD <numeric-variable>}
#define CHECK_EVEN N
{SET temp_a {N}}
{SET temp_b {N}}
{INCREMENT temp_a}
{MULTIPLY temp_a .5}
{MULTIPLY temp_b .5}
{IF temp_a equals $temp_b}
{SET_TRUE global_var__is_even}
{ELSE}
{SET_FALSE global_var__is_even}
{END_IF}
{RELEASE temp_a}
{RELEASE temp_b}
#enddef
#define IF_EVEN N
{CHECK_EVEN {N}}
{IF_TRUE global_var__is_even}
# no good place to deallocate 'global_var__is_even'.
#enddef
#define IF_ODD N
{CHECK_EVEN {N}}
{IF_FALSE global_var__is_even}
# no good place to deallocate 'global_var__is_even'.
#enddef

I mean, seriously? Why did szopen do it like that? Why not just use a modulo?

@cooljeanius cooljeanius added the bug Something isn't working label Jun 6, 2022
@cooljeanius cooljeanius added the help wanted Extra attention is needed label Aug 16, 2022
@soliton-
Copy link

Well, modulo support was added at the end of 2006 and ANO was first published in mid 2005.

@Elvish-Hunter
Copy link
Contributor

A quick search shows that {IF_ODD} and {IF_EVEN} are used only in one scenario and {CHECK_EVEN} is just a dependency for these two macros.
If that's OK, I'll prepare a small pull request to update this ancient code.

@cooljeanius
Copy link
Collaborator Author

A quick search shows that {IF_ODD} and {IF_EVEN} are used only in one scenario and {CHECK_EVEN} is just a dependency for these two macros. If that's OK, I'll prepare a small pull request to update this ancient code.

It's definitely okay; please do!

cooljeanius added a commit that referenced this issue Mar 26, 2023
Update code for odd/even turn number check.
Fixes #70.
@cooljeanius
Copy link
Collaborator Author

I confirmed that #121 fixes this; thanks @Elvish-Hunter for the PR!

@cooljeanius cooljeanius added this to the 1.6.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants