mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-24 04:03:39 -04:00
Changed long -> int64_t
This commit is contained in:
parent
71e1c12f49
commit
32860bdcf4
@ -13,15 +13,15 @@
|
||||
|
||||
struct compactinfo_t
|
||||
{
|
||||
long seedStart, seedEnd;
|
||||
int64_t seedStart, seedEnd;
|
||||
};
|
||||
|
||||
void *searchCompactBiomesThread(void *data)
|
||||
{
|
||||
struct compactinfo_t info = *(struct compactinfo_t *)data;
|
||||
|
||||
long *seeds = (long *) malloc(sizeof(*seeds)*SEED_BUF_LEN);
|
||||
long i, s, scnt;
|
||||
int64_t *seeds = (int64_t *) malloc(sizeof(*seeds)*SEED_BUF_LEN);
|
||||
int64_t i, s, scnt;
|
||||
|
||||
LayerStack g = setupGenerator();
|
||||
int *cache = allocCache(&g.layers[L_BIOME_256], 8, 8);
|
||||
@ -61,7 +61,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
initBiomes();
|
||||
|
||||
long seedStart, seedEnd;
|
||||
int64_t seedStart, seedEnd;
|
||||
uint threads, t;
|
||||
|
||||
if(argc <= 1 || sscanf(argv[1], "%ld", &seedStart) != 1) seedStart = 0;
|
||||
@ -75,7 +75,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for(t = 0; t < threads; t++)
|
||||
{
|
||||
long seedCnt = (seedEnd - seedStart) / threads;
|
||||
int64_t seedCnt = (seedEnd - seedStart) / threads;
|
||||
info[t].seedStart = seedStart + seedCnt * t;
|
||||
info[t].seedEnd = seedStart + seedCnt * (t+1) + 1;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
int mcversion = 0;
|
||||
const char *seedFileName;
|
||||
long featureSeed;
|
||||
int64_t featureSeed;
|
||||
|
||||
if(argc > 2)
|
||||
{
|
||||
@ -74,9 +74,9 @@ int main(int argc, char *argv[])
|
||||
search4QuadBases(seedFileName, threads, featureSeed, quality);
|
||||
}
|
||||
|
||||
long i, j, qhcnt;
|
||||
long base, seed;
|
||||
long *qhcandidates = loadSavedSeeds(seedFileName, &qhcnt);
|
||||
int64_t i, j, qhcnt;
|
||||
int64_t base, seed;
|
||||
int64_t *qhcandidates = loadSavedSeeds(seedFileName, &qhcnt);
|
||||
|
||||
LayerStack g = setupGenerator();
|
||||
|
||||
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
||||
if(j >= 5) continue;
|
||||
|
||||
|
||||
long hits = 0, swpc;
|
||||
int64_t hits = 0, swpc;
|
||||
|
||||
for(j = 0; j < 0x10000; j++)
|
||||
{
|
||||
|
158
finders.c
158
finders.c
@ -66,8 +66,8 @@ Biome biomes[256];
|
||||
|
||||
typedef struct quad_threadinfo_t
|
||||
{
|
||||
long start, end;
|
||||
long structureSeed;
|
||||
int64_t start, end;
|
||||
int64_t structureSeed;
|
||||
int threadID;
|
||||
int quality;
|
||||
const char *fnam;
|
||||
@ -75,12 +75,12 @@ typedef struct quad_threadinfo_t
|
||||
|
||||
|
||||
|
||||
const long lowerBaseBitsQ1[] = // for quad-structure with quality 1
|
||||
const int64_t lowerBaseBitsQ1[] = // for quad-structure with quality 1
|
||||
{
|
||||
0x3f18,0x520a,0x751a,0x9a0a
|
||||
};
|
||||
|
||||
const long lowerBaseBitsQ2[] = // for quad-structure with quality 2
|
||||
const int64_t lowerBaseBitsQ2[] = // for quad-structure with quality 2
|
||||
{
|
||||
0x0770,0x0775,0x07ad,0x07b2,0x0c3a,0x0c58,0x0cba,0x0cd8,0x0e38,
|
||||
0x0e5a,0x0ed8,0x0eda,0x111c,0x1c96,0x2048,0x20e8,0x2248,0x224a,
|
||||
@ -103,16 +103,16 @@ const long lowerBaseBitsQ2[] = // for quad-structure with quality 2
|
||||
|
||||
|
||||
|
||||
int isQuadFeatureBase(const long structureSeed, const long seed,
|
||||
const long lower, const long upper)
|
||||
int isQuadFeatureBase(const int64_t structureSeed, const int64_t seed,
|
||||
const int64_t lower, const int64_t upper)
|
||||
{
|
||||
// seed offsets for the regions (0,0) to (1,1)
|
||||
const long reg00base = structureSeed;
|
||||
const long reg01base = 341873128712 + structureSeed;
|
||||
const long reg10base = 132897987541 + structureSeed;
|
||||
const long reg11base = 341873128712 + 132897987541 + structureSeed;
|
||||
const int64_t reg00base = structureSeed;
|
||||
const int64_t reg01base = 341873128712 + structureSeed;
|
||||
const int64_t reg10base = 132897987541 + structureSeed;
|
||||
const int64_t reg11base = 341873128712 + 132897987541 + structureSeed;
|
||||
|
||||
long s;
|
||||
int64_t s;
|
||||
|
||||
s = (reg00base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
|
||||
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
|
||||
@ -142,16 +142,16 @@ int isQuadFeatureBase(const long structureSeed, const long seed,
|
||||
}
|
||||
|
||||
|
||||
int isTriFeatureBase(const long structureSeed, const long seed,
|
||||
const long lower, const long upper)
|
||||
int isTriFeatureBase(const int64_t structureSeed, const int64_t seed,
|
||||
const int64_t lower, const int64_t upper)
|
||||
{
|
||||
// seed offsets for the regions (0,0) to (1,1)
|
||||
const long reg00base = structureSeed;
|
||||
const long reg01base = 341873128712 + structureSeed;
|
||||
const long reg10base = 132897987541 + structureSeed;
|
||||
const long reg11base = 341873128712 + 132897987541 + structureSeed;
|
||||
const int64_t reg00base = structureSeed;
|
||||
const int64_t reg01base = 341873128712 + structureSeed;
|
||||
const int64_t reg10base = 132897987541 + structureSeed;
|
||||
const int64_t reg11base = 341873128712 + 132897987541 + structureSeed;
|
||||
|
||||
long s;
|
||||
int64_t s;
|
||||
int missing = 0;
|
||||
|
||||
s = (reg00base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
|
||||
@ -191,21 +191,21 @@ int isTriFeatureBase(const long structureSeed, const long seed,
|
||||
return 1;
|
||||
}
|
||||
|
||||
long moveStructure(const long baseSeed, const int regionX, const int regionZ)
|
||||
int64_t moveStructure(const int64_t baseSeed, const int regionX, const int regionZ)
|
||||
{
|
||||
return (baseSeed - regionX*341873128712 - regionZ*132897987541) & 0xffffffffffff;
|
||||
}
|
||||
|
||||
|
||||
int isQuadMonumentBase(const long seed, const int qual)
|
||||
int isQuadMonumentBase(const int64_t seed, const int qual)
|
||||
{
|
||||
// seed offsets for the regions (0,0) to (1,1)
|
||||
const long reg00base = MONUMENT_SEED;
|
||||
const long reg01base = 341873128712 + MONUMENT_SEED;
|
||||
const long reg10base = 132897987541 + MONUMENT_SEED;
|
||||
const long reg11base = 341873128712 + 132897987541 + MONUMENT_SEED;
|
||||
const int64_t reg00base = MONUMENT_SEED;
|
||||
const int64_t reg01base = 341873128712 + MONUMENT_SEED;
|
||||
const int64_t reg10base = 132897987541 + MONUMENT_SEED;
|
||||
const int64_t reg11base = 341873128712 + 132897987541 + MONUMENT_SEED;
|
||||
|
||||
long s, p;
|
||||
int64_t s, p;
|
||||
|
||||
/*
|
||||
seed = regionX*341873128712 + regionZ*132897987541 + seed + 10387313;
|
||||
@ -282,15 +282,15 @@ int isQuadMonumentBase(const long seed, const int qual)
|
||||
}
|
||||
|
||||
|
||||
int isTriMonumentBase(const long seed, const int qual)
|
||||
int isTriMonumentBase(const int64_t seed, const int qual)
|
||||
{
|
||||
// seed offsets for the regions (0,0) to (1,1)
|
||||
const long reg00base = MONUMENT_SEED;
|
||||
const long reg01base = 341873128712 + MONUMENT_SEED;
|
||||
const long reg10base = 132897987541 + MONUMENT_SEED;
|
||||
const long reg11base = 341873128712 + 132897987541 + MONUMENT_SEED;
|
||||
const int64_t reg00base = MONUMENT_SEED;
|
||||
const int64_t reg01base = 341873128712 + MONUMENT_SEED;
|
||||
const int64_t reg10base = 132897987541 + MONUMENT_SEED;
|
||||
const int64_t reg11base = 341873128712 + 132897987541 + MONUMENT_SEED;
|
||||
|
||||
long s, p;
|
||||
int64_t s, p;
|
||||
int incomplete = 0;
|
||||
|
||||
/*
|
||||
@ -454,12 +454,12 @@ int countBlocksInSpawnRange(Pos p[4], const int ax, const int ay, const int az)
|
||||
|
||||
|
||||
|
||||
long *loadSavedSeeds(const char *fnam, long *scnt)
|
||||
int64_t *loadSavedSeeds(const char *fnam, int64_t *scnt)
|
||||
{
|
||||
FILE *fp = fopen(fnam, "r");
|
||||
|
||||
long seed;
|
||||
long *baseSeeds;
|
||||
int64_t seed;
|
||||
int64_t *baseSeeds;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
@ -475,11 +475,11 @@ long *loadSavedSeeds(const char *fnam, long *scnt)
|
||||
else while(!feof(fp) && fgetc(fp) != '\n');
|
||||
}
|
||||
|
||||
baseSeeds = (long*) calloc(*scnt, sizeof(*baseSeeds));
|
||||
baseSeeds = (int64_t*) calloc(*scnt, sizeof(*baseSeeds));
|
||||
|
||||
rewind(fp);
|
||||
|
||||
for(long i = 0; i < *scnt && !feof(fp);)
|
||||
for(int64_t i = 0; i < *scnt && !feof(fp);)
|
||||
{
|
||||
if(fscanf(fp, "%ld", &baseSeeds[i]) == 1) i++;
|
||||
else while(!feof(fp) && fgetc(fp) != '\n');
|
||||
@ -495,20 +495,20 @@ static void *search4QuadBasesThread(void *data)
|
||||
{
|
||||
quad_threadinfo_t info = *(quad_threadinfo_t*)data;
|
||||
|
||||
const long lower = info.quality;
|
||||
const long upper = 23-info.quality;
|
||||
const long start = info.start;
|
||||
const long end = info.end;
|
||||
const long structureSeed = info.structureSeed;
|
||||
const int64_t lower = info.quality;
|
||||
const int64_t upper = 23-info.quality;
|
||||
const int64_t start = info.start;
|
||||
const int64_t end = info.end;
|
||||
const int64_t structureSeed = info.structureSeed;
|
||||
|
||||
long seed;
|
||||
int64_t seed;
|
||||
|
||||
long *lowerBits;
|
||||
int64_t *lowerBits;
|
||||
int lowerBitsCnt;
|
||||
int lowerBitsIdx = 0;
|
||||
int i;
|
||||
|
||||
lowerBits = (long *) malloc(0x10000 * sizeof(long));
|
||||
lowerBits = (int64_t *) malloc(0x10000 * sizeof(int64_t));
|
||||
|
||||
if(info.quality == 1)
|
||||
{
|
||||
@ -603,11 +603,11 @@ static void *search4QuadBasesThread(void *data)
|
||||
|
||||
|
||||
void search4QuadBases(const char *fnam, const int threads,
|
||||
const long structureSeed, const int quality)
|
||||
const int64_t structureSeed, const int quality)
|
||||
{
|
||||
pthread_t threadID[threads];
|
||||
quad_threadinfo_t info[threads];
|
||||
long t;
|
||||
int64_t t;
|
||||
|
||||
for(t = 0; t < threads; t++)
|
||||
{
|
||||
@ -699,8 +699,8 @@ int getBiomeAtPos(const LayerStack g, const Pos pos)
|
||||
* generation attempt will occur in the specified region.
|
||||
* This function applies for scattered-feature structureSeeds and villages.
|
||||
*/
|
||||
Pos getStructurePos(const long structureSeed, long seed, const long regionX,
|
||||
const long regionZ)
|
||||
Pos getStructurePos(const int64_t structureSeed, int64_t seed,
|
||||
const int64_t regionX, const int64_t regionZ)
|
||||
{
|
||||
Pos pos;
|
||||
|
||||
@ -726,7 +726,7 @@ Pos getStructurePos(const long structureSeed, long seed, const long regionX,
|
||||
* the structure generation attempt will occur.
|
||||
* This function applies for scattered-feature structureSeeds and villages.
|
||||
*/
|
||||
Pos getStructureChunkInRegion(const long structureSeed, long seed,
|
||||
Pos getStructureChunkInRegion(const int64_t structureSeed, int64_t seed,
|
||||
const int regionX, const int regionZ)
|
||||
{
|
||||
/*
|
||||
@ -760,7 +760,7 @@ Pos getStructureChunkInRegion(const long structureSeed, long seed,
|
||||
* Fast implementation for finding the block position at which the ocean
|
||||
* monument generation attempt will occur in the specified region.
|
||||
*/
|
||||
Pos getOceanMonumentPos(long seed, const long regionX, const long regionZ)
|
||||
Pos getOceanMonumentPos(int64_t seed, const int64_t regionX, const int64_t regionZ)
|
||||
{
|
||||
Pos pos;
|
||||
|
||||
@ -793,7 +793,7 @@ Pos getOceanMonumentPos(long seed, const long regionX, const long regionZ)
|
||||
*
|
||||
* area80X, area80Z: area coordinates in units 1280 blocks (= 80 chunks)
|
||||
*/
|
||||
Pos getMansionPos(long seed, const long area80X, const long area80Z)
|
||||
Pos getMansionPos(int64_t seed, const int64_t area80X, const int64_t area80Z)
|
||||
{
|
||||
Pos pos;
|
||||
|
||||
@ -841,7 +841,7 @@ Pos findBiomePosition(
|
||||
const int centerZ,
|
||||
const int range,
|
||||
const int *isValid,
|
||||
long *seed,
|
||||
int64_t *seed,
|
||||
int *passes
|
||||
)
|
||||
{
|
||||
@ -905,7 +905,7 @@ Pos findBiomePosition(
|
||||
* locations : output block positions for the 3 strongholds
|
||||
* worldSeed : world seed used for the generator
|
||||
*/
|
||||
void findStrongholds_pre19(LayerStack *g, int *cache, Pos *locations, long worldSeed)
|
||||
void findStrongholds_pre19(LayerStack *g, int *cache, Pos *locations, int64_t worldSeed)
|
||||
{
|
||||
static int validStrongholdBiomes[256];
|
||||
const int SHNUM = 3;
|
||||
@ -957,12 +957,12 @@ static int canCoordinateBeSpawn(LayerStack *g, int *cache, Pos pos)
|
||||
* cache : biome buffer, set to NULL for temporary allocation
|
||||
* worldSeed : world seed used for the generator
|
||||
*/
|
||||
Pos getSpawn(LayerStack *g, int *cache, long worldSeed)
|
||||
Pos getSpawn(LayerStack *g, int *cache, int64_t worldSeed)
|
||||
{
|
||||
static int isSpawnBiome[0x100];
|
||||
Pos spawn;
|
||||
int found;
|
||||
uint i;
|
||||
unsigned int i;
|
||||
|
||||
if(!isSpawnBiome[biomesToSpawnIn[0]])
|
||||
{
|
||||
@ -1050,7 +1050,8 @@ int areBiomesViable(
|
||||
|
||||
|
||||
|
||||
int isViableFeaturePos(const LayerStack g, int *cache, const long blockX, const long blockZ)
|
||||
int isViableFeaturePos(const LayerStack g, int *cache,
|
||||
const int64_t blockX, const int64_t blockZ)
|
||||
{
|
||||
static int map[0x100];
|
||||
genArea(&g.layers[L_VORONOI_ZOOM_1], map, blockX, blockZ, 1, 1);
|
||||
@ -1064,13 +1065,14 @@ int isViableFeaturePos(const LayerStack g, int *cache, const long blockX, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int isViableVillagePos(const LayerStack g, int *cache, const long blockX, const long blockZ)
|
||||
int isViableVillagePos(const LayerStack g, int *cache,
|
||||
const int64_t blockX, const int64_t blockZ)
|
||||
{
|
||||
static int isVillageBiome[0x100];
|
||||
|
||||
if(!isVillageBiome[villageBiomeList[0]])
|
||||
{
|
||||
uint i;
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(villageBiomeList) / sizeof(int); i++)
|
||||
{
|
||||
isVillageBiome[ villageBiomeList[i] ] = 1;
|
||||
@ -1080,14 +1082,15 @@ int isViableVillagePos(const LayerStack g, int *cache, const long blockX, const
|
||||
return areBiomesViable(g, cache, blockX, blockZ, 0, isVillageBiome);
|
||||
}
|
||||
|
||||
int isViableOceanMonumentPos(const LayerStack g, int *cache, const long blockX, const long blockZ)
|
||||
int isViableOceanMonumentPos(const LayerStack g, int *cache,
|
||||
const int64_t blockX, const int64_t blockZ)
|
||||
{
|
||||
static int isWaterBiome[0x100];
|
||||
static int isDeepOcean[0x100];
|
||||
|
||||
if(!isWaterBiome[oceanMonumentBiomeList[0]])
|
||||
{
|
||||
uint i;
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(oceanMonumentBiomeList) / sizeof(int); i++)
|
||||
{
|
||||
isWaterBiome[ oceanMonumentBiomeList[i] ] = 1;
|
||||
@ -1100,13 +1103,14 @@ int isViableOceanMonumentPos(const LayerStack g, int *cache, const long blockX,
|
||||
areBiomesViable(g, cache, blockX, blockZ, 29, isWaterBiome);
|
||||
}
|
||||
|
||||
int isViableMansionPos(const LayerStack g, int *cache, const long blockX, const long blockZ)
|
||||
int isViableMansionPos(const LayerStack g, int *cache,
|
||||
const int64_t blockX, const int64_t blockZ)
|
||||
{
|
||||
static int isMansionBiome[0x100];
|
||||
|
||||
if(!isMansionBiome[mansionBiomeList[0]])
|
||||
{
|
||||
uint i;
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(mansionBiomeList) / sizeof(int); i++)
|
||||
{
|
||||
isMansionBiome[ mansionBiomeList[i] ] = 1;
|
||||
@ -1188,12 +1192,12 @@ int getBiomeRadius(
|
||||
*
|
||||
* Returns the number of found candidates.
|
||||
*/
|
||||
long filterAllTempCats(
|
||||
int64_t filterAllTempCats(
|
||||
LayerStack *g,
|
||||
int *cache,
|
||||
const long *seedsIn,
|
||||
long *seedsOut,
|
||||
const long seedCnt,
|
||||
const int64_t *seedsIn,
|
||||
int64_t *seedsOut,
|
||||
const int64_t seedCnt,
|
||||
const int centX,
|
||||
const int centZ)
|
||||
{
|
||||
@ -1230,7 +1234,7 @@ long filterAllTempCats(
|
||||
Layer layerSpecial;
|
||||
setupLayer(1024, &layerSpecial, NULL, 3, NULL);
|
||||
|
||||
long sidx, hits, seed;
|
||||
int64_t sidx, hits, seed;
|
||||
int types[9];
|
||||
int specialCnt;
|
||||
int i, j;
|
||||
@ -1253,7 +1257,7 @@ long filterAllTempCats(
|
||||
{
|
||||
for(j = 0; j < sZ; j++)
|
||||
{
|
||||
setChunkSeed(&layerSpecial, (long)(i+pX), (long)(j+pZ));
|
||||
setChunkSeed(&layerSpecial, (int64_t)(i+pX), (int64_t)(j+pZ));
|
||||
if(mcNextInt(&layerSpecial, 13) == 0)
|
||||
specialCnt++;
|
||||
}
|
||||
@ -1266,7 +1270,7 @@ long filterAllTempCats(
|
||||
|
||||
/*** Cold/Warm Check ***/
|
||||
|
||||
// Continue by checking if enough cold and warm categories are present.#
|
||||
// Continue by checking if enough cold and warm categories are present.
|
||||
setWorldSeed(lFilterSnow, seed);
|
||||
genArea(lFilterSnow, map, pX,pZ, sX,sZ);
|
||||
|
||||
@ -1345,23 +1349,23 @@ const int majorBiomes[] = {
|
||||
*
|
||||
* Returns the number of seeds found.
|
||||
*/
|
||||
long filterAllMajorBiomes(
|
||||
int64_t filterAllMajorBiomes(
|
||||
LayerStack *g,
|
||||
int *cache,
|
||||
const long *seedsIn,
|
||||
long *seedsOut,
|
||||
const long seedCnt,
|
||||
const int64_t *seedsIn,
|
||||
int64_t *seedsOut,
|
||||
const int64_t seedCnt,
|
||||
const int pX,
|
||||
const int pZ,
|
||||
const uint sX,
|
||||
const uint sZ)
|
||||
const unsigned int sX,
|
||||
const unsigned int sZ)
|
||||
{
|
||||
Layer *lFilterMushroom = &g->layers[L_ADD_MUSHROOM_ISLAND_256];
|
||||
Layer *lFilterBiomes = &g->layers[L_BIOME_256];
|
||||
|
||||
int *map;
|
||||
long sidx, seed, hits;
|
||||
uint i, id, hasAll;
|
||||
int64_t sidx, seed, hits;
|
||||
unsigned int i, id, hasAll;
|
||||
|
||||
int types[BIOME_NUM];
|
||||
|
||||
|
96
finders.h
96
finders.h
@ -100,17 +100,17 @@ extern Biome biomes[256];
|
||||
|
||||
|
||||
// helper functions
|
||||
int isQuadFeatureBase(const long structureSeed, const long seed,
|
||||
const long lower, const long upper);
|
||||
int isTriFeatureBase(const long structureSeed, const long seed,
|
||||
const long lower, const long upper);
|
||||
int isQuadFeatureBase(const int64_t structureSeed, const int64_t seed,
|
||||
const int64_t lower, const int64_t upper);
|
||||
int isTriFeatureBase(const int64_t structureSeed, const int64_t seed,
|
||||
const int64_t lower, const int64_t upper);
|
||||
|
||||
/* moveStructure
|
||||
* -------------
|
||||
* Transposes a base seed such that structures are moved by the specified region
|
||||
* vector, (regX, regZ).
|
||||
*/
|
||||
long moveStructure(const long baseSeed, const int regX, const int regZ);
|
||||
int64_t moveStructure(const int64_t baseSeed, const int regX, const int regZ);
|
||||
|
||||
/* loadSavedSeeds
|
||||
* --------------
|
||||
@ -122,14 +122,14 @@ long moveStructure(const long baseSeed, const int regX, const int regZ);
|
||||
*
|
||||
* Return a pointer to dynamically allocated seed list.
|
||||
*/
|
||||
long *loadSavedSeeds(const char *fnam, long *scnt);
|
||||
int64_t *loadSavedSeeds(const char *fnam, int64_t *scnt);
|
||||
|
||||
/* search4QuadBases
|
||||
* ----------------
|
||||
* Starts a multi-threaded search for structure base seeds of the specified
|
||||
* quality (chunk tolerance). The result is saved in a file of path 'fnam'.
|
||||
*/
|
||||
void search4QuadBases(const char *fnam, int threads, const long structureSeed,
|
||||
void search4QuadBases(const char *fnam, int threads, const int64_t structureSeed,
|
||||
int quality);
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ int getBiomeAtPos(const LayerStack g, const Pos pos);
|
||||
* the structure generation attempt will occur.
|
||||
* This function applies for scattered-feature structureSeeds and villages.
|
||||
*/
|
||||
Pos getStructureChunkInRegion(const long structureSeed, long seed,
|
||||
Pos getStructureChunkInRegion(const int64_t structureSeed, int64_t seed,
|
||||
const int regionX, const int regionZ);
|
||||
|
||||
|
||||
@ -162,8 +162,8 @@ Pos getStructureChunkInRegion(const long structureSeed, long seed,
|
||||
* generation attempt will occur in the specified region.
|
||||
* This function applies for scattered-feature structureSeeds and villages.
|
||||
*/
|
||||
Pos getStructurePos(const long structureSeed, long seed, const long regionX,
|
||||
const long regionZ);
|
||||
Pos getStructurePos(const int64_t structureSeed, int64_t seed, const int64_t regionX,
|
||||
const int64_t regionZ);
|
||||
|
||||
|
||||
/* getOceanMonumentPos
|
||||
@ -171,7 +171,7 @@ Pos getStructurePos(const long structureSeed, long seed, const long regionX,
|
||||
* Fast implementation for finding the block position at which the ocean
|
||||
* monument generation attempt will occur in the specified region.
|
||||
*/
|
||||
Pos getOceanMonumentPos(long seed, const long regionX, const long regionZ);
|
||||
Pos getOceanMonumentPos(int64_t seed, const int64_t regionX, const int64_t regionZ);
|
||||
|
||||
/* getMansionPos
|
||||
* -------------
|
||||
@ -180,7 +180,7 @@ Pos getOceanMonumentPos(long seed, const long regionX, const long regionZ);
|
||||
*
|
||||
* area80X, area80Z: area coordinates in units 1280 blocks (= 80 chunks)
|
||||
*/
|
||||
Pos getMansionPos(long seed, const long area80X, const long area80Z);
|
||||
Pos getMansionPos(int64_t seed, const int64_t area80X, const int64_t area80Z);
|
||||
|
||||
|
||||
/* findBiomePosition
|
||||
@ -205,7 +205,7 @@ Pos findBiomePosition(
|
||||
const int centerZ,
|
||||
const int range,
|
||||
const int *isValid,
|
||||
long *seed,
|
||||
int64_t *seed,
|
||||
int *passes
|
||||
);
|
||||
|
||||
@ -220,7 +220,7 @@ Pos findBiomePosition(
|
||||
* locations : output block positions for the 3 strongholds
|
||||
* worldSeed : world seed used for the generator
|
||||
*/
|
||||
void findStrongholds_pre19(LayerStack *g, int *cache, Pos *locations, long worldSeed);
|
||||
void findStrongholds_pre19(LayerStack *g, int *cache, Pos *locations, int64_t worldSeed);
|
||||
|
||||
/* getSpawn
|
||||
* --------
|
||||
@ -232,7 +232,7 @@ void findStrongholds_pre19(LayerStack *g, int *cache, Pos *locations, long world
|
||||
* cache : biome buffer, set to NULL for temporary allocation
|
||||
* worldSeed : world seed used for the generator
|
||||
*/
|
||||
Pos getSpawn(LayerStack *g, int *cache, long worldSeed);
|
||||
Pos getSpawn(LayerStack *g, int *cache, int64_t worldSeed);
|
||||
|
||||
|
||||
|
||||
@ -275,10 +275,10 @@ int areBiomesViable(
|
||||
* The return value is non-zero if the position is valid, and in the case of
|
||||
* isViableWitchHutPos() the return value is an enum of the temple type.
|
||||
*/
|
||||
int isViableWitchHutPos(const LayerStack g, int *cache, const long blockX, const long blockZ);
|
||||
int isViableVillagePos(const LayerStack g, int *cache, const long blockX, const long blockZ);
|
||||
int isViableOceanMonumentPos(const LayerStack g, int *cache, const long blockX, const long blockZ);
|
||||
int isViableMansionPos(const LayerStack g, int *cache, const long blockX, const long blockZ);
|
||||
int isViableWitchHutPos(const LayerStack g, int *cache, const int64_t blockX, const int64_t blockZ);
|
||||
int isViableVillagePos(const LayerStack g, int *cache, const int64_t blockX, const int64_t blockZ);
|
||||
int isViableOceanMonumentPos(const LayerStack g, int *cache, const int64_t blockX, const int64_t blockZ);
|
||||
int isViableMansionPos(const LayerStack g, int *cache, const int64_t blockX, const int64_t blockZ);
|
||||
|
||||
|
||||
|
||||
@ -323,12 +323,12 @@ int getBiomeRadius(
|
||||
*
|
||||
* Returns the number of found candidates.
|
||||
*/
|
||||
long filterAllTempCats(
|
||||
int64_t filterAllTempCats(
|
||||
LayerStack *g,
|
||||
int *cache,
|
||||
const long *seedsIn,
|
||||
long *seedsOut,
|
||||
const long seedCnt,
|
||||
const int64_t *seedsIn,
|
||||
int64_t *seedsOut,
|
||||
const int64_t seedCnt,
|
||||
const int centX,
|
||||
const int centZ);
|
||||
|
||||
@ -349,12 +349,12 @@ long filterAllTempCats(
|
||||
*
|
||||
* Returns the number of seeds found.
|
||||
*/
|
||||
long filterAllMajorBiomes(
|
||||
int64_t filterAllMajorBiomes(
|
||||
LayerStack *g,
|
||||
int *cache,
|
||||
const long *seedsIn,
|
||||
long *seedsOut,
|
||||
const long seedCnt,
|
||||
const int64_t *seedsIn,
|
||||
int64_t *seedsOut,
|
||||
const int64_t seedCnt,
|
||||
const int pX,
|
||||
const int pZ,
|
||||
const uint sX,
|
||||
@ -364,18 +364,18 @@ long filterAllMajorBiomes(
|
||||
/********************** C copy of the Java Random methods **********************
|
||||
*/
|
||||
|
||||
static inline void setSeed(long *seed)
|
||||
static inline void setSeed(int64_t *seed)
|
||||
{
|
||||
*seed = (*seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
|
||||
}
|
||||
|
||||
static inline int next(long *seed, const int bits)
|
||||
static inline int next(int64_t *seed, const int bits)
|
||||
{
|
||||
*seed = (*seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
|
||||
return (int) (*seed >> (48 - bits));
|
||||
}
|
||||
|
||||
static inline int nextInt(long *seed, const int n)
|
||||
static inline int nextInt(int64_t *seed, const int n)
|
||||
{
|
||||
int bits, val;
|
||||
do {
|
||||
@ -386,26 +386,26 @@ static inline int nextInt(long *seed, const int n)
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline long nextLong(long *seed)
|
||||
static inline int64_t nextint64_t(int64_t *seed)
|
||||
{
|
||||
return ((long) next(seed, 32) << 32) + next(seed, 32);
|
||||
return ((int64_t) next(seed, 32) << 32) + next(seed, 32);
|
||||
}
|
||||
|
||||
static inline float nextFloat(long *seed)
|
||||
static inline float nextFloat(int64_t *seed)
|
||||
{
|
||||
return next(seed, 24) / (float) (1 << 24);
|
||||
}
|
||||
|
||||
static inline double nextDouble(long *seed)
|
||||
static inline double nextDouble(int64_t *seed)
|
||||
{
|
||||
return (((long) next(seed, 26) << 27) + next(seed, 27)) / (double) (1L << 53);
|
||||
return (((int64_t) next(seed, 26) << 27) + next(seed, 27)) / (double) (1L << 53);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Custom, faster alternative for the first and second call to nextInt(24)
|
||||
|
||||
static inline int firstInt24(long seed)
|
||||
static inline int firstInt24(int64_t seed)
|
||||
{
|
||||
seed ^= 0x5deece66d;
|
||||
seed = (seed * 0x5deece66d) & 0xffffffffffff;
|
||||
@ -413,7 +413,7 @@ static inline int firstInt24(long seed)
|
||||
return seed % 24;
|
||||
}
|
||||
|
||||
static inline int secondInt24(long seed)
|
||||
static inline int secondInt24(int64_t seed)
|
||||
{
|
||||
seed ^= 0x5deece66d;
|
||||
seed = (seed * 0x5deece66d + 0xB) & 0xffffffffffff;
|
||||
@ -428,25 +428,25 @@ static inline int secondInt24(long seed)
|
||||
* Returns the previous 48-bit seed which will generate 'nseed'.
|
||||
* The upper 16 bits are ignored, both here and in the generator.
|
||||
*/
|
||||
static inline long invSeed48(long nseed)
|
||||
static inline int64_t invSeed48(int64_t nseed)
|
||||
{
|
||||
const long x = 0x5deece66d;
|
||||
const long xinv = 0xdfe05bcb1365L;
|
||||
const long y = 0xbL;
|
||||
const long m48 = 0xffffffffffffL;
|
||||
const int64_t x = 0x5deece66d;
|
||||
const int64_t xinv = 0xdfe05bcb1365L;
|
||||
const int64_t y = 0xbL;
|
||||
const int64_t m48 = 0xffffffffffffL;
|
||||
|
||||
long a = nseed >> 32;
|
||||
long b = nseed & 0xffffffffL;
|
||||
int64_t a = nseed >> 32;
|
||||
int64_t b = nseed & 0xffffffffL;
|
||||
if(b & 0x80000000L) a++;
|
||||
|
||||
long q = ((b << 16) - y - (a << 16)*x) & m48;
|
||||
for(long k = 0; k <= 5; k++)
|
||||
int64_t q = ((b << 16) - y - (a << 16)*x) & m48;
|
||||
for(int64_t k = 0; k <= 5; k++)
|
||||
{
|
||||
long d = (x - (q + (k << 48))) % x;
|
||||
int64_t d = (x - (q + (k << 48))) % x;
|
||||
d = (d + x) % x; // force the modulo and keep it positive
|
||||
if(d < 65536)
|
||||
{
|
||||
long c = ((q + d) * xinv) & m48;
|
||||
int64_t c = ((q + d) * xinv) & m48;
|
||||
if(c < 65536)
|
||||
{
|
||||
return ((((a << 16) + c) - y) * xinv) & m48;
|
||||
|
@ -246,7 +246,7 @@ void freeGenerator(LayerStack g)
|
||||
free(g.layers);
|
||||
}
|
||||
|
||||
void applySeed(LayerStack *g, long seed)
|
||||
void applySeed(LayerStack *g, int64_t seed)
|
||||
{
|
||||
// the seed has to be applied recursively
|
||||
setWorldSeed(&g->layers[g->layerNum-1], seed);
|
||||
|
@ -107,7 +107,7 @@ void setupMultiLayer(int scale, Layer *l, Layer *p1, Layer *p2, int s, void (*ge
|
||||
int calcRequiredBuf(Layer *layer, int areaX, int areaZ);
|
||||
|
||||
// Sets the world seed for the generator
|
||||
void applySeed(LayerStack *g, long seed);
|
||||
void applySeed(LayerStack *g, int64_t seed);
|
||||
|
||||
/*
|
||||
* genArea
|
||||
|
46
layers.c
46
layers.c
@ -107,7 +107,7 @@ void initBiomes()
|
||||
}
|
||||
|
||||
|
||||
void setWorldSeed(Layer *layer, long seed)
|
||||
void setWorldSeed(Layer *layer, int64_t seed)
|
||||
{
|
||||
if(layer->p2 != NULL && layer->getMap != mapHills)
|
||||
setWorldSeed(layer->p2, seed);
|
||||
@ -134,16 +134,16 @@ void mapIsland(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWid
|
||||
{
|
||||
register int x, z;
|
||||
|
||||
const long ws = l->worldSeed;
|
||||
const long ss = ws * (ws * 6364136223846793005L + 1442695040888963407L);
|
||||
const int64_t ws = l->worldSeed;
|
||||
const int64_t ss = ws * (ws * 6364136223846793005L + 1442695040888963407L);
|
||||
|
||||
for(z = 0; z < areaHeight; z++)
|
||||
{
|
||||
for(x = 0; x < areaWidth; x++)
|
||||
{
|
||||
const long chunkX = (long)(x + areaX);
|
||||
const long chunkZ = (long)(z + areaZ);
|
||||
register long cs = ss;
|
||||
const int64_t chunkX = (int64_t)(x + areaX);
|
||||
const int64_t chunkZ = (int64_t)(z + areaZ);
|
||||
register int64_t cs = ss;
|
||||
cs += chunkX;
|
||||
cs *= cs * 6364136223846793005L + 1442695040888963407L;
|
||||
cs += chunkZ;
|
||||
@ -383,8 +383,8 @@ void mapAddIsland(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
|
||||
l->p->getMap(l->p, out, pX, pZ, pWidth, pHeight);
|
||||
|
||||
const long ws = l->worldSeed;
|
||||
const long ss = ws * (ws * 6364136223846793005L + 1442695040888963407L);
|
||||
const int64_t ws = l->worldSeed;
|
||||
const int64_t ss = ws * (ws * 6364136223846793005L + 1442695040888963407L);
|
||||
|
||||
for(z = 0; z < areaHeight; z++)
|
||||
{
|
||||
@ -398,7 +398,7 @@ void mapAddIsland(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
|
||||
if(v11 == 0 && (v00 != 0 || v20 != 0 || v02 != 0 || v22 != 0))
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
int v = 1;
|
||||
int inc = 1;
|
||||
@ -417,13 +417,13 @@ void mapAddIsland(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
}
|
||||
else if(v11 > 0 && (v00 == 0 || v20 == 0 || v02 == 0 || v22 == 0))
|
||||
{
|
||||
//setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
//setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
//if(mcNextInt(l, 5) == 0)...
|
||||
|
||||
const long chunkX = (long)(x + areaX);
|
||||
const long chunkZ = (long)(z + areaZ);
|
||||
const int64_t chunkX = (int64_t)(x + areaX);
|
||||
const int64_t chunkZ = (int64_t)(z + areaZ);
|
||||
|
||||
register long cs = ss;
|
||||
register int64_t cs = ss;
|
||||
cs += chunkX;
|
||||
cs *= cs * 6364136223846793005L + 1442695040888963407L;
|
||||
cs += chunkZ;
|
||||
@ -470,7 +470,7 @@ void mapRemoveTooMuchOcean(Layer *l, int * __restrict out, int areaX, int areaZ,
|
||||
|
||||
if(v11 == 0)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
if(mcNextInt(l, 2) == 0)
|
||||
{
|
||||
@ -504,7 +504,7 @@ void mapAddSnow(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWi
|
||||
}
|
||||
else
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
int r = mcNextInt(l, 6);
|
||||
int v;
|
||||
|
||||
@ -603,7 +603,7 @@ void mapSpecial(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWi
|
||||
int v = out[x + z*areaWidth];
|
||||
if(v == 0) continue;
|
||||
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
if(mcNextInt(l, 13) == 0)
|
||||
{
|
||||
@ -635,7 +635,7 @@ void mapAddMushroomIsland(Layer *l, int * __restrict out, int areaX, int areaZ,
|
||||
// surrounded by ocean?
|
||||
if(v11 == 0 && !out[x+0 + (z+0)*pWidth] && !out[x+2 + (z+0)*pWidth] && !out[x+0 + (z+2)*pWidth] && !out[x+2 + (z+2)*pWidth])
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
if(mcNextInt(l, 100) == 0) {
|
||||
out[x + z*areaWidth] = mushroomIsland;
|
||||
continue;
|
||||
@ -721,7 +721,7 @@ void mapBiome(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
|
||||
continue;
|
||||
}
|
||||
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
switch(id){
|
||||
case Warm:
|
||||
@ -758,7 +758,7 @@ void mapRiverInit(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
{
|
||||
if(out[x + z*areaWidth] > 0)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
out[x + z*areaWidth] = mcNextInt(l, 299999)+2;
|
||||
}
|
||||
else
|
||||
@ -887,7 +887,7 @@ void mapHills(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt
|
||||
{
|
||||
for(x = 0; x < areaWidth; x++)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
int a11 = buf[x+1 + (z+1)*pWidth]; // biome branch
|
||||
int b11 = out[x+1 + (z+1)*pWidth]; // river branch
|
||||
int idx = x + z*areaWidth;
|
||||
@ -1039,7 +1039,7 @@ void mapSmooth(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWid
|
||||
|
||||
if(v01 == v21 && v10 == v12)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
if(mcNextInt(l, 2) == 0)
|
||||
v11 = v01;
|
||||
@ -1072,7 +1072,7 @@ void mapRareBiome(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
{
|
||||
for(x = 0; x < areaWidth; x++)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
int v11 = out[x+1 + (z+1)*pWidth];
|
||||
|
||||
if(mcNextInt(l, 57) == 0 && v11 == plains)
|
||||
@ -1258,7 +1258,7 @@ void mapOceanTemp(Layer *l, int * __restrict out, int areaX, int areaZ, int area
|
||||
{
|
||||
for(x = 0; x < areaWidth; x++)
|
||||
{
|
||||
setChunkSeed(l, (long)(x + areaX), (long)(z + areaZ));
|
||||
setChunkSeed(l, (int64_t)(x + areaX), (int64_t)(z + areaZ));
|
||||
|
||||
int v11;
|
||||
|
||||
|
15
layers.h
15
layers.h
@ -2,6 +2,7 @@
|
||||
#define LAYER_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined USE_SIMD && __AVX2__
|
||||
#include <emmintrin.h>
|
||||
@ -50,10 +51,10 @@ STRUCT(Biome) {
|
||||
};
|
||||
|
||||
STRUCT(Layer) {
|
||||
long baseSeed; // Generator seed (depends only on hierarchy of generator)
|
||||
long worldSeed; // based on the seed of the world
|
||||
int64_t baseSeed; // Generator seed (depends only on hierarchy of generator)
|
||||
int64_t worldSeed; // based on the seed of the world
|
||||
|
||||
long chunkSeed; // randomiser seed
|
||||
int64_t chunkSeed; // randomiser seed
|
||||
|
||||
int scale; // map scale of this layer (map entry = scale x scale blocks)
|
||||
|
||||
@ -69,7 +70,7 @@ extern Biome biomes[256];
|
||||
void initBiomes();
|
||||
|
||||
|
||||
void setWorldSeed(Layer *layer, long seed);
|
||||
void setWorldSeed(Layer *layer, int64_t seed);
|
||||
|
||||
|
||||
|
||||
@ -145,7 +146,7 @@ static inline int isBiomeSnowy(int id)
|
||||
|
||||
static inline int mcNextInt(Layer *layer, int mod)
|
||||
{
|
||||
int ret = (int)((layer->chunkSeed >> 24) % (long)mod);
|
||||
int ret = (int)((layer->chunkSeed >> 24) % (int64_t)mod);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -157,7 +158,7 @@ static inline int mcNextInt(Layer *layer, int mod)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void setChunkSeed(Layer *layer, long chunkX, long chunkZ)
|
||||
static inline void setChunkSeed(Layer *layer, int64_t chunkX, int64_t chunkZ)
|
||||
{
|
||||
layer->chunkSeed = layer->worldSeed;
|
||||
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
@ -170,7 +171,7 @@ static inline void setChunkSeed(Layer *layer, long chunkX, long chunkZ)
|
||||
layer->chunkSeed += chunkZ;
|
||||
}
|
||||
|
||||
static inline void setBaseSeed(Layer *layer, long seed)
|
||||
static inline void setBaseSeed(Layer *layer, int64_t seed)
|
||||
{
|
||||
layer->baseSeed = seed;
|
||||
layer->baseSeed *= layer->baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
|
Loading…
x
Reference in New Issue
Block a user