Skip to content

Commit

Permalink
Fixed fortress generation finding incorrect end pieces (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubitect committed Oct 11, 2023
1 parent 4c8b36e commit df68a25
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
12 changes: 6 additions & 6 deletions finders.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,21 +2380,21 @@ Piece *addFortressPiece(PieceEnv *env, int typ, int x, int y, int z, int depth,
}
// accept the piece and append it to the processing front
skipNextN(env->rng, fortress_info[typ].skip);
(*env->n)++;
env->ntyp[typ]++;
if (typ != FORTRESS_END)
env->typlast = typ;
//int queue = 0;
if (pending)
{
(*env->n)++;
env->ntyp[typ]++;
if (typ != FORTRESS_END)
env->typlast = typ;
Piece *q = env->list;
while (q->next) {
q = q->next; //queue++;
}
q->next = p;
}
//printf("[%3d] typ=%2d @(%4d %4d %4d) f=%d queue=%2d rng:%ld\n",
// (*env->n-1), typ, b0.x, b0.y, b0.z, facing, pending?queue:-1, *env->rng);
//printf("[%3d] typ=%2d @(%4d %4d %4d) f=%d p=%d queue=%2d rng:%ld\n",
// (*env->n-1), typ, b0.x, b0.y, b0.z, facing, pending, queue, *env->rng);
//fflush(stdout);
return p;
}
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ all: release

debug: CFLAGS += -DDEBUG -O0 -ggdb3
debug: libcubiomes
release: CFLAGS += -O3 -g3
release: CFLAGS += -O3
release: libcubiomes
native: CFLAGS += -O3 -march=native -ffast-math
native: libcubiomes
Expand Down
2 changes: 1 addition & 1 deletion noise.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void samplePerlinBeta17Terrain(const PerlinNoise *noise, double *v,
i3 &= 0xff;

double d2;
int i2, yi, yic, gfCopy;
int i2, yi, yic = 0, gfCopy = 0;
for (yi = 0; yi <= 7; yi++)
{
d2 = yi*noise->lacunarity*yLacAmp+noise->b;
Expand Down
14 changes: 12 additions & 2 deletions tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void findStructures(int structureType, int mc, int dim, uint64_t seed,
continue; // biomes are not viable
if (structureType == End_City)
{ // end cities have a dedicated terrain checker
if (!isViableEndCityTerrain(&g.en, &sn, pos.x, pos.z))
if (!isViableEndCityTerrain(&g, &sn, pos.x, pos.z))
continue;
}
else if (mc >= MC_1_18)
Expand All @@ -471,7 +471,17 @@ int main()
//testAreas(mc, 0, 256);
//testCanBiomesGenerate();
//testGeneration();
findBiomeParaBounds();
//findBiomeParaBounds();

long seed = -3390226979891259151L;
int cx = 336 >> 4; //cx = -112>>4;
int cz = 352 >> 4; //cz = -96>>4;

Piece list[1000];
int n = getFortressPieces(list, 1000, MC_1_16, seed, cx, cz);

printf("%d\n", n);

return 0;
}

Expand Down

0 comments on commit df68a25

Please sign in to comment.