mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-25 13:00:27 -04:00
Made ScanForQuads also work for monuments + input no longer requires salt offset.
This commit is contained in:
parent
774612a265
commit
11954031c6
23
finders.c
23
finders.c
@ -674,17 +674,19 @@ L_ERR:
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
int scanForQuadBits(const StructureConfig sconf, int radius, int64_t s48,
|
int scanForQuadBits(const StructureConfig sconf, int radius, int64_t s48,
|
||||||
int64_t lbit, int lbitn, int64_t invB, int x, int z, int w, int h,
|
int64_t lbit, int lbitn, int64_t invB, int64_t x, int64_t z,
|
||||||
Pos *qplist, int n)
|
int64_t w, int64_t h, Pos *qplist, int n)
|
||||||
{
|
{
|
||||||
const int m = (1LL << lbitn);
|
const int64_t m = (1LL << lbitn);
|
||||||
const int64_t A = 341873128712LL;
|
const int64_t A = 341873128712LL;
|
||||||
// for lbitn=20: invB = 132477LL;
|
// for lbitn=20: invB = 132477LL;
|
||||||
|
|
||||||
if (n < 1)
|
if (n < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
lbit &= m-1;
|
||||||
|
|
||||||
int i, j, cnt = 0;
|
int64_t i, j;
|
||||||
|
int cnt = 0;
|
||||||
for (i = x; i <= x+w; i++)
|
for (i = x; i <= x+w; i++)
|
||||||
{
|
{
|
||||||
int64_t sx = s48 + A * i;
|
int64_t sx = s48 + A * i;
|
||||||
@ -694,7 +696,10 @@ int scanForQuadBits(const StructureConfig sconf, int radius, int64_t s48,
|
|||||||
for (; j <= z+h; j += m)
|
for (; j <= z+h; j += m)
|
||||||
{
|
{
|
||||||
int64_t sp = moveStructure(s48, -i, -j);
|
int64_t sp = moveStructure(s48, -i, -j);
|
||||||
if (isQuadBase(sconf, sp - sconf.salt, radius))
|
if ((sp & (m-1)) != lbit)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (isQuadBase(sconf, sp, radius))
|
||||||
{
|
{
|
||||||
qplist[cnt].x = i;
|
qplist[cnt].x = i;
|
||||||
qplist[cnt].z = j;
|
qplist[cnt].z = j;
|
||||||
@ -714,7 +719,13 @@ int scanForQuads(
|
|||||||
int x, int z, int w, int h, Pos *qplist, int n)
|
int x, int z, int w, int h, Pos *qplist, int n)
|
||||||
{
|
{
|
||||||
int i, cnt = 0;
|
int i, cnt = 0;
|
||||||
const int64_t invB = mulInv(132897987541LL, (1LL << lowBitN));
|
int64_t invB;
|
||||||
|
if (lowBitN == 20)
|
||||||
|
invB = 132477LL;
|
||||||
|
else if (lowBitN == 48)
|
||||||
|
invB = 211541297333629LL;
|
||||||
|
else
|
||||||
|
invB = mulInv(132897987541LL, (1LL << lowBitN));
|
||||||
|
|
||||||
for (i = 0; i < lowBitCnt; i++)
|
for (i = 0; i < lowBitCnt; i++)
|
||||||
{
|
{
|
||||||
|
@ -118,10 +118,11 @@ int64_t invSeed48(int64_t nseed)
|
|||||||
static inline __attribute__((const))
|
static inline __attribute__((const))
|
||||||
int64_t mulInv(int64_t x, int64_t m)
|
int64_t mulInv(int64_t x, int64_t m)
|
||||||
{
|
{
|
||||||
int64_t t, q, a, b;
|
int64_t t, q, a, b, n;
|
||||||
if (m == 1)
|
if (m <= 1)
|
||||||
return 0; // no solution
|
return 0; // no solution
|
||||||
|
|
||||||
|
n = m;
|
||||||
a = 0; b = 1;
|
a = 0; b = 1;
|
||||||
|
|
||||||
while (x > 1)
|
while (x > 1)
|
||||||
@ -133,6 +134,8 @@ int64_t mulInv(int64_t x, int64_t m)
|
|||||||
t = a; a = b - q * a; b = t;
|
t = a; a = b - q * a; b = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b < 0)
|
||||||
|
b += n;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user