mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-24 17:21:43 +00:00
add seed to the parameters of generations
This commit is contained in:
parent
e5a5973575
commit
140cf4bb5a
5 changed files with 13 additions and 6 deletions
3
app.js
3
app.js
|
|
@ -14,7 +14,8 @@ var options = {
|
||||||
commands: commands,
|
commands: commands,
|
||||||
logging:settings.logging,
|
logging:settings.logging,
|
||||||
kickTimeout:10*60*1000,
|
kickTimeout:10*60*1000,
|
||||||
generation:settings.generation
|
generation:settings.generation,
|
||||||
|
seed:settings.seed
|
||||||
};
|
};
|
||||||
|
|
||||||
mcServer.createMCServer(options);
|
mcServer.createMCServer(options);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ function inject(serv,settings)
|
||||||
serv.log(banner.username + " banned " + bannedUsername + (reason ? " (" + reason + ")" : ""));
|
serv.log(banner.username + " banned " + bannedUsername + (reason ? " (" + reason + ")" : ""));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
serv.on("seed",function(seed){
|
||||||
|
serv.log("seed: "+seed);
|
||||||
|
});
|
||||||
|
|
||||||
var logFile=path.join("logs",timeStarted + ".log");
|
var logFile=path.join("logs",timeStarted + ".log");
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,7 @@ var generations={
|
||||||
module.exports = inject;
|
module.exports = inject;
|
||||||
|
|
||||||
function inject(serv,options) {
|
function inject(serv,options) {
|
||||||
serv.world = new World(generations[options["generation"].name](options["generation"].options));
|
var seed=options.seed || Math.random()*Math.pow(2, 32);
|
||||||
|
serv.emit("seed",seed);
|
||||||
|
serv.world = new World(generations[options["generation"].name](seed,options["generation"].options));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ function DiamondSquare(size, roughness, seed) {
|
||||||
// public fields
|
// public fields
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.roughness = roughness;
|
this.roughness = roughness;
|
||||||
this.seed = (seed ? seed : Math.random());
|
this.seed = seed;
|
||||||
var opCount = 0;
|
var opCount = 0;
|
||||||
|
|
||||||
// private field
|
// private field
|
||||||
|
|
@ -93,11 +93,11 @@ function DiamondSquare(size, roughness, seed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generation(options) {
|
function generation(seed, options) {
|
||||||
var worldHeight=options.worldHeight || 80;
|
var worldHeight=options.worldHeight || 80;
|
||||||
// Selected empirically
|
// Selected empirically
|
||||||
var size = 10000000;
|
var size = 10000000;
|
||||||
var space = new DiamondSquare(size, size / 1000, Math.random() * 10000);
|
var space = new DiamondSquare(size, size / 1000, seed);
|
||||||
|
|
||||||
function generateSimpleChunk(chunkX, chunkZ) {
|
function generateSimpleChunk(chunkX, chunkZ) {
|
||||||
var chunk = new Chunk();
|
var chunk = new Chunk();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var Chunk = require('prismarine-chunk')(require("../version"));
|
var Chunk = require('prismarine-chunk')(require("../version"));
|
||||||
var Vec3 = require('vec3');
|
var Vec3 = require('vec3');
|
||||||
|
|
||||||
function generation(options) {
|
function generation(seed,options) {
|
||||||
function generateSimpleChunk(chunkX, chunkZ) {
|
function generateSimpleChunk(chunkX, chunkZ) {
|
||||||
var chunk = new Chunk();
|
var chunk = new Chunk();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue