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

Removed unnecessary state changes to RNG after last next() call #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ void generator::ChunkGenerator::ignoreLeafPattern(random_math::JavaRand& random)

bool generator::ChunkGenerator::leafPatternNot0And4(random_math::JavaRand& random)
{
bool _0 = random.nextIntPow2Unchecked(2) != 0;
if (random.nextIntPow2Unchecked(2) != 0) {
return false;
}

random.advance(advance_3);

bool _4 = random.nextIntPow2Unchecked(2) != 0;
random.advance(advance_11);

if (random.nextIntPow2Unchecked(2)) {
random.advance(advance_11);
return true;
}

return !_0 && _4;
return false;
}

int32_t generator::ChunkGenerator::checkTrees(random_math::JavaRand& random, int32_t maxTreeCount, int waterfallX)
Expand Down
1 change: 1 addition & 0 deletions generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace generator
static bool isValidTreeSpot(int treeX, int treeZ, bool firstTreeFound, bool secondTreeFound, int waterfallX);
static void generateLeafPattern(random_math::JavaRand& random, bool *out);
static void ignoreLeafPattern(random_math::JavaRand& random);
/* When false is returned, the RNG will be in an invalid state */
static bool leafPatternNot0And4(random_math::JavaRand& random);
static int32_t checkTrees(random_math::JavaRand& random, int32_t maxTreeCount, int waterfallX);
public:
Expand Down