Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.8.0' into wip5.8.0webport
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 25, 2024
2 parents b2e8137 + 9f27460 commit 02c0ca7
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 59 deletions.
18 changes: 13 additions & 5 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,16 @@ wanted_fps (Wanted FPS) int 30

# Start optimizing far blocks, in blocks (16 nodes). good values 2 - 5 . 0 = disable
lodmesh () int 4
# Client-side landscape render

# Farmesh max distance, 0 for disable
farmesh () int 30000

# Farmesh quality (0 .. 4)
farmesh_quality () int 2

# Farmesh map data from server
farmesh_server () bool true

# Set to true to disable wield light (enabled by default, requires shaders)
disable_wieldlight () bool false

Expand All @@ -123,7 +130,7 @@ headless_optimize () bool false
# Disable death screen, respawn automaticaly
respawn_auto () bool false

#Save password for every server in favorites (in plaintext)
# Save password for every server in favorites (in plaintext)
password_save () bool true

# Show cmd console on Windows
Expand All @@ -137,12 +144,13 @@ chat_buffer_size () int 6
# Selection box border color (R,G,B)
selectionbox_color () string (0,0,0)

#Android only: use better keyboard. glitchy on <4.4 versions
# Android only: use better keyboard. glitchy on <4.4 versions
android_keyboard () enum 0 0,1,2

#Androud: use touchscreen gui
# Androud: use touchscreen gui
touchscreen () bool true


[*Server]
# Lan udp announce
serverlist_lan () bool true
Expand Down Expand Up @@ -190,7 +198,7 @@ default_privs_creative () string interact, shout, fly, fast
movement_fall_aerodynamics () int 110

# Constant volume liquids
liquid_real () bool false
liquid_real () bool true

# Minimal liquid step in ms
liquid_step () int 100
Expand Down
12 changes: 6 additions & 6 deletions src/client/fm_far_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include "irr_v3d.h"
#include "irrlichttypes.h"

block_step_t getLodStep(const MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &blockpos, const pos_t speedf)
block_step_t getLodStep(const MapDrawControl &draw_control,
const v3bpos_t &playerblockpos, const v3bpos_t &blockpos, const pos_t speedf)
{
if (draw_control.lodmesh) {
int range = radius_box(playerblockpos, blockpos);
Expand Down Expand Up @@ -66,8 +66,8 @@ block_step_t getLodStep(const MapDrawControl &draw_control, const v3bpos_t &play
return 0;
};

block_step_t getFarStepBad(const MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &blockpos)
block_step_t getFarStepBad(const MapDrawControl &draw_control,
const v3bpos_t &playerblockpos, const v3bpos_t &blockpos)
{
if (!draw_control.farmesh)
return 1;
Expand Down Expand Up @@ -120,8 +120,8 @@ using v3tpos_t = v3bpos_t;
using tpos_t = int32_t;
using v3tpos_t = v3s32;
#endif
bool inFarGrid(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos, block_step_t step,
const MapDrawControl &draw_control)
bool inFarGrid(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos,
block_step_t step, const MapDrawControl &draw_control)
{
const auto act = getFarActual(blockpos, playerblockpos, step, draw_control);
return act == blockpos;
Expand Down
35 changes: 25 additions & 10 deletions src/client/fm_far_calc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,33 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.

struct MapDrawControl;

block_step_t getLodStep(const MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &block_pos, const pos_t speedf);
#if USE_POS32
constexpr uint16_t tree_pow_default = FARMESH_STEP_MAX;
#else
constexpr uint16_t tree_pow_default = 12;
#endif

struct tree_params
{
const uint16_t tree_pow = tree_pow_default;
const uint16_t tree_size = 1 << tree_pow;
const uint16_t tree_align = tree_pow - 1;
const uint16_t tree_align_size = 1 << (tree_align);
const uint16_t external_pow = tree_pow - 2;
};

block_step_t getLodStep(const MapDrawControl &draw_control,
const v3bpos_t &playerblockpos, const v3bpos_t &block_pos, const pos_t speedf);
block_step_t getFarStepCellSize(const MapDrawControl &draw_control, const v3bpos_t &ppos,
const v3bpos_t &blockpos, uint8_t cell_size_pow);
block_step_t getFarStep(const MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &block_pos);
block_step_t getFarStepBad(const MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &block_pos);
bool inFarGrid(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos, block_step_t step,
const MapDrawControl &draw_control);
v3bpos_t getFarActual(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos, block_step_t step,
const MapDrawControl &draw_control);
block_step_t getFarStep(const MapDrawControl &draw_control,
const v3bpos_t &playerblockpos, const v3bpos_t &block_pos);
block_step_t getFarStepBad(const MapDrawControl &draw_control,
const v3bpos_t &playerblockpos, const v3bpos_t &block_pos);
bool inFarGrid(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos,
block_step_t step, const MapDrawControl &draw_control);
v3bpos_t getFarActual(const v3bpos_t &blockpos, const v3bpos_t &playerblockpos,
block_step_t step, const MapDrawControl &draw_control);
v3bpos_t playerBlockAlign(
const MapDrawControl &draw_control, const v3bpos_t &playerblockpos);
void runFarAll(const MapDrawControl &draw_control, const v3bpos_t &ppos,
Expand Down
13 changes: 7 additions & 6 deletions src/client/fm_far_container.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "fm_far_container.h"
#include <unordered_map>
#include "client.h"
#include "client/clientmap.h"
#include "client/fm_far_calc.h"
Expand Down Expand Up @@ -72,12 +71,14 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos)
return block;
};

if (!block && !m_client->m_simple_singleplayer_mode && !m_client->far_container.have_params) {
thread_local static std::unordered_set<v3bpos_t> miss_cache;
if (!miss_cache.contains(bpos)) {
block = loadBlock(bpos, step);
if (!block && !m_client->m_simple_singleplayer_mode &&
!m_client->far_container.have_params) {
thread_local static std::array<std::unordered_set<v3bpos_t>, FARMESH_STEP_MAX>
miss_cache;
if (!miss_cache[step].contains(bpos_aligned)) {
block = loadBlock(bpos_aligned, step);
if (!block) {
miss_cache.emplace(bpos);
miss_cache[step].emplace(bpos_aligned);
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/mapgen/mapgen_v7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,36 @@ int MapgenV7::generateTerrain()
return stone_surface_max_y;
}

// fm:
/*
void MapgenV7::generateExperimental() {
}
*/
bool MapgenV7::visible(const v3pos_t &p)
{
// return baseTerrainLevelAtPoint(p.X, p.Z) >= p.Y;

// from getSpawnLevelAtPoint

auto y = baseTerrainLevelAtPoint(p.X, p.Z);

// If mountains are disabled, terrain level is base terrain level.
// Avoids mid-air spawn where mountain terrain would have been.
if (!(spflags & MGV7_MOUNTAINS)) {
return y + 1 >= p.Y;
}

// todo: make faster
int iters = 256;
while (iters > 0) {
if (!getMountainTerrainAtPoint(p.X, y + 1, p.Z)) {
return y + 1 >= p.Y;
}
y++;
iters--;
}

return false;
}

// ==
18 changes: 7 additions & 11 deletions src/mapgen/mapgen_v7.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ class MapgenV7 : public MapgenBasic, public Mapgen_features {

virtual int generateTerrain();


//freeminer:
virtual bool visible(const v3pos_t &p)
{
// TODO: add more height features
return baseTerrainLevelAtPoint(p.X, p.Z) >= p.Y;
}


private:
s16 mount_zero_level;
s16 floatland_ymin;
Expand All @@ -141,9 +132,14 @@ class MapgenV7 : public MapgenBasic, public Mapgen_features {
Noise *noise_ridge;

//freeminer:
MapgenV7Params *sp;
MapgenV7Params *sp{};
//virtual void generateExperimental();
//=========
// freeminer:
public:
virtual bool visible(const v3pos_t &p);

private:
// ==

Noise *noise_floatland;
};
22 changes: 16 additions & 6 deletions util/master/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,34 @@ the serverlist webpage template.

First install node.js, eg:

# apt-get install nodejs
# apt install nodejs
# pacman -S nodejs
# emerge nodejs

Then install doT.js and its dependencies:

# apt install node-dot node-commander

Or with npm:

$ npm install dot commander mkdirp

Or manually:

$ cd ~/code
$ git clone https://github.com/olado/doT.git
$ cd doT
$ npm install

Or with npm:

$ npm install dot commander mkdirp

And finally compile the template:

$ cd ~/freeminer/util/master

$ /usr/share/nodejs/dot/bin/dot-packer -s . -d .

or

$ ~/code/doT/bin/dot-packer -s . -d .

or
Expand All @@ -38,12 +48,12 @@ Embedding to any page

<script>
var master = {
root: 'http://servers.freeminer.org/',
root: '//servers.freeminer.org/',
limit: 10,
clients_min: 1,
no_flags: 1,
no_ping: 1,
no_uptime: 1
};
</script>
<script src="http://servers.freeminer.org/list.js"></script>
<script src="//servers.freeminer.org/list.js"></script>
24 changes: 20 additions & 4 deletions util/master/list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var master;
if (!master) master = {};
if (typeof(master.root) == 'undefined') master.root = "http://servers.freeminer.org/";
if (typeof(master.root) == 'undefined') master.root = "//servers.freeminer.org/";
if (!master.play_root) master.play_root = '//play.freeminer.org/';
if (!master.output) master.output = '#server_list';
if (!master.list) master.list = "list";
if (!master.list_root) master.list_root = master.root;
Expand Down Expand Up @@ -29,6 +30,16 @@ function escapeHTML(str) {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

function addressEscaped(address, port) {
var isIPv6 = address.indexOf(":") != -1;
var addrStr = (isIPv6 ? '[' : '') +
escapeHTML(address) +
(isIPv6 ? ']' : '');
if (port)
addrStr += ':' + parseInt(port);
return addrStr;
}

function addressString(server) {
var isIPv6 = server.address.indexOf(":") != -1;
var addrStr = (isIPv6 ? '[' : '') +
Expand All @@ -42,7 +53,7 @@ function addressString(server) {
str += ' class="mts_tooltip" title="' + addrStr + '"'
}
if (server.port != 30000)
shortStr += ':' + server.port;
shortStr += ':' + parseInt(server.port);
return str + '>' + shortStr + '</span>';
}

Expand Down Expand Up @@ -86,9 +97,14 @@ function get() {
jQuery.getJSON(master.list_url, draw);
}

function maybeGet() {
if (!document.hidden)
get();
}

function loaded(){
if (!master.no_refresh) {
setInterval(get, 60 * 1000);
setInterval(maybeGet, 60 * 1000);
}
get();
}
Expand All @@ -100,6 +116,6 @@ toast(master.root + 'style.css', master.root + 'servers.js', function() {
if (typeof(jQuery) != 'undefined')
return loaded();
else
toast('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', loaded);
toast('//ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js', loaded);
});

7 changes: 4 additions & 3 deletions util/master/master.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ no strict qw(refs);
use warnings "NONFATAL" => "all";
no warnings qw(uninitialized);
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
no if $] >= 5.038, warnings => 'deprecated::smartmatch';
use utf8;
use Socket;
BEGIN {
Expand Down Expand Up @@ -106,7 +107,7 @@ our %config = (
#debug => 1,
list_full => $root_path . 'list_full',
list_pub => $root_path . 'list',
log => $root_path . 'log.log',
log => $root_path . '../log/master.log',
time_purge => 86400 * 1,
time_alive => 650,
source_check => 1,
Expand Down Expand Up @@ -309,7 +310,7 @@ sub request (;$) {
$param->{ping} = $duration if $pingret;
printlog " PING t=$config{ping_timeout}, $param->{address}:$param->{port} = ( $pingret, $duration, $ip )" if $config{debug};
}
return if !$param->{ping};
return if !$param->{ping} and !($param->{ip} ~~ $config{trusted});
}
my $list = read_json($config{list_full}) || {};
printlog "readed[$config{list_full}] list size=", scalar @{$list->{list}} if $config{debug};
Expand Down Expand Up @@ -337,7 +338,7 @@ sub request (;$) {

$list->{list} = [
sort { $b->{clients} <=> $a->{clients} || $a->{start} <=> $b->{start} }
grep { $_->{time} > time - $config{time_alive} and !$_->{off} and (!$config{ping} or !$config{pingable} or $_->{ping}) }
grep { $_->{time} > time - $config{time_alive} and !$_->{off} and (!$config{ping} or !$config{pingable} or $_->{ping} or ($param->{ip} ~~ $config{trusted})) }
@{$list_full}
];
$list->{total} = {clients => 0, servers => 0};
Expand Down
Loading

0 comments on commit 02c0ca7

Please sign in to comment.