diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb2c65d0d..1c5cbc25e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -260,8 +260,8 @@ jobs: name: VS 2022 ${{ matrix.config.arch }}-${{ matrix.type }} runs-on: windows-2022 env: - VCPKG_VERSION: af2287382b1991dbdcb7e5112d236f3323b9dd7a -# 2022.03.10 + VCPKG_VERSION: a42af01b72c28a8e1d7b48107b33e4f286a55ef6 +# 2023.11.20 vcpkg_packages: irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp strategy: fail-fast: false diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index feec7cc65..c357de0e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,46 +1,81 @@ --- # Github repository is really at minetest.org using the poikilos git.minetest.io -# https://gitlab.com/minenux/minetest-engine-multicraft2 -# Pipelines URL: https://gitlab.com/minenux/minetest-engine-multicraft2/pipelines +# https://gitlab.com/minenux/minetest-engine-minetest +# Pipelines URL: https://gitlab.com/minenux/minetest-engine-minetest/pipelines # packages moved to https://build.opensuse.org/project/show/home:venenux:minenux # in future we only build here, or made apk packs for alpine stages: - build - - package - - deploy -variables: - MINETEST_GAME_REPO: "https://gitlab.com/minenux/minetest-game-minetest.git" - CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH - -.build_template: +.build_template: &build_definition stage: build script: - mkdir cmakebuild - mkdir -p artifact/multicraft/usr/ - mkdir -p games - cd games - - git clone -b stable-0.4 --single-branch $MINETEST_GAME_REPO minetest + - git clone -b stable-5.2 --single-branch https://codeberg.org/minenux/minetest-game-minetest minetest - cd ../cmakebuild - - cmake -DCMAKE_INSTALL_PREFIX=../artifact/multicraft/usr/ -DBUILD_SERVER=ON -DBUILD_CLIENT=ON -DCMAKE_BUILD_TYPE=Release -DRUN_IN_PLACE=TRUE -DENABLE_GETTEXT=TRUE -DENABLE_SYSTEM_JSONCPP=TRUE -DAPPLY_LOCALE_BLACKLIST=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON .. + - cmake -DCMAKE_INSTALL_PREFIX=../artifact/multicraft/usr/ -DBUILD_SERVER=ON -DBUILD_CLIENT=ON -DRUN_IN_PLACE=OFF -DENABLE_CURL=ON -DENABLE_SOUND=ON -DENABLE_LUAJIT=ON -DENABLE_GETTEXT=ON -DENABLE_FREETYPE=ON -DENABLE_SYSTEM_GMP=ON -DENABLE_SYSTEM_JSONCPP=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_POSTGRESQL=ON .. - make -j$(nproc) - make install artifacts: when: on_success - expire_in: 5h + expire_in: 1y paths: - artifact/* +## +## Alpine the limited distro for nonsocial geeks +## + +build:alpine-312: + extends: .build_template + image: alpine:3.12 + before_script: + - apk update + - apk add build-base cmake pkgconf gettext-dev bzip2-dev curl-dev libnl3-dev rtmpdump-dev libidn2-dev ncurses-dev freetype-dev mesa-dev gmp-dev irrlicht-dev libjpeg-turbo-dev jsoncpp-dev leveldb-dev luajit-dev lua5.1-dev libogg-dev openal-soft-dev libpng-dev postgresql-dev hiredis-dev sqlite-dev libvorbis-dev libxi-dev zlib-dev doxygen libxrandr-dev libx11-dev zstd-dev openssl-dev samurai + +build:alpine-314: + extends: .build_template + image: alpine:3.14 + before_script: + - apk update + - apk add build-base cmake pkgconf gettext-dev bzip2-dev curl-dev libnl3-dev rtmpdump-dev libidn2-dev ncurses-dev freetype-dev mesa-dev gmp-dev irrlicht-dev libjpeg-turbo-dev jsoncpp-dev leveldb-dev luajit-dev lua5.1-dev libogg-dev openal-soft-dev libpng-dev postgresql-dev hiredis-dev sqlite-dev libvorbis-dev libxi-dev zlib-dev doxygen libxrandr-dev libx11-dev zstd-dev openssl-dev samurai + +build:alpine-316: + extends: .build_template + image: alpine:3.16 + before_script: + - apk update + - apk add build-base cmake pkgconf gettext-dev bzip2-dev curl-dev libnl3-dev rtmpdump-dev libidn2-dev ncurses-dev freetype-dev mesa-dev gmp-dev irrlicht-dev libjpeg-turbo-dev jsoncpp-dev leveldb-dev luajit-dev lua5.1-dev libogg-dev openal-soft-dev libpng-dev postgresql-dev hiredis-dev sqlite-dev libvorbis-dev libxi-dev zlib-dev doxygen libxrandr-dev libx11-dev zstd-dev openssl-dev samurai + +build:alpine-319: + extends: .build_template + image: alpine:3.19 + before_script: + - apk update + - apk add build-base cmake pkgconf gettext-dev bzip2-dev curl-dev libnl3-dev rtmpdump-dev libidn2-dev ncurses-dev freetype-dev mesa-dev gmp-dev irrlicht-dev libjpeg-turbo-dev jsoncpp-dev leveldb-dev luajit-dev lua5.1-dev libogg-dev openal-soft-dev libpng-dev postgresql-dev hiredis-dev sqlite-dev libvorbis-dev libxi-dev zlib-dev doxygen libxrandr-dev libx11-dev zstd-dev openssl-dev samurai + +# error - need to enable testing repo due spatial index +#build:alpine-edge: +# extends: .build_template +# image: alpine:edge +# before_script: +# - apk update +# - apk add build-base git cmake pkgconf gettext-dev bzip2-dev curl-dev libnl3-dev rtmpdump-dev libidn2-dev ncurses-dev freetype-dev mesa-dev gmp-dev irrlicht-dev libjpeg-turbo-dev jsoncpp-dev leveldb-dev luajit-dev lua5.1-dev libogg-dev openal-soft-dev libpng-dev postgresql-dev hiredis-dev sqlite-dev libvorbis-dev libxi-dev zlib-dev doxygen libxrandr-dev libx11-dev zstd-dev openssl1.1-compat-dev samurai libspatialindex-dev + + ## ## Debian mother of many distros ## # Jessie -build:debian-8: - extends: .build_template - image: debian:8 +build:debian-8-64: + <<: *build_definition + image: amd64/debian:8 before_script: - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom @@ -50,19 +85,17 @@ build:debian-8: - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::https::download.opensuse.org::Verify-Peer "false";" >> /etc/apt/apt.conf.d/50venenuxcustom - rm -rf /etc/apt/sources.list - echo "deb http://archive.debian.org/debian/ jessie main contrib" > /etc/apt/sources.list.d/50debianoficial.list - echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list - echo "deb http://deb.freexian.com/extended-lts jessie main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential git cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev x11proto-xf86vidmode-dev - - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install -t jessie-backports libjsoncpp-dev -# Stretch + - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential cmake pkg-config cmake-data debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev libpq-dev postgresql-server-dev-all libhiredis-dev zlib1g-dev doxygen libxrandr-dev x11proto-xf86vidmode-dev + - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes -t jessie-backports install libjsoncpp-dev -build:debian-9: - extends: .build_template - image: debian:9 +build:debian-8-32: + <<: *build_definition + image: i386/debian:8 before_script: - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom @@ -73,260 +106,109 @@ build:debian-9: - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - rm -rf /etc/apt/sources.list - - echo "deb http://archive.debian.org/debian/ stretch main contrib" > /etc/apt/sources.list.d/50debianoficial.list - - echo "deb http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list - - echo "deb http://deb.freexian.com/extended-lts stretch main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://archive.debian.org/debian/ jessie main contrib" > /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://deb.freexian.com/extended-lts jessie main contrib non-free" >> /etc/apt/sources.list.d/50debianoficial.list - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential git cmake pkg-config cmake-data debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev + - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential cmake pkg-config cmake-data debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev libpq-dev postgresql-server-dev-all libhiredis-dev zlib1g-dev doxygen libxrandr-dev x11proto-xf86vidmode-dev + - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes -t jessie-backports install libjsoncpp-dev -# Bullseye +# Stretch -build:debian-11: - extends: .build_template - image: debian:11 +build:debian-9-32: + <<: *build_definition + image: i386/debian:9 before_script: - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom + - echo "deb http://archive.debian.org/debian/ stretch main contrib" > /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://deb.freexian.com/extended-lts stretch main contrib non-free" > /etc/apt/sources.list - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config cmake-data debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev + - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev -# bookworm +# Bullseye + +build:debian-11: + <<: *build_definition + image: debian:11 + before_script: + - apt-get update -y || true + - apt-get -y install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev postgresql-server-dev-all libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev + +# Bookworm build:debian-12: - extends: .build_template + <<: *build_definition image: debian:12 before_script: - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config cmake-data debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev - + - apt-get update -y || true + - apt-get -y install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev ## -## Ubuntu +## winbuntu the distro for stupid users ## -# Utopic most close to jessie +build:ubuntu-22.04: + <<: *build_definition + image: ubuntu:jammy + before_script: + - DEBIAN_FRONTEND=noninteractive apt-get update -y + - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev -#build:ubuntu-14.10: -# extends: .build_template -# image: ubuntu:utopic -# before_script: -# - echo "" > /etc/apt/apt.conf.d/50venenuxcustom -# - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom -# - rm -rf /etc/apt/sources.list -# - echo "deb http://old-releases.ubuntu.com/ubuntu/ utopic main restricted universe multiverse" > /etc/apt/sources.list.d/50debianoficial.list -# - echo "deb http://old-releases.ubuntu.com/ubuntu/ utopic-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list -# - echo "deb http://old-releases.ubuntu.com/ubuntu utopic-security main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list -# - apt-get update -y || true -# - apt-get -y --force-yes install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev +# Focal most close to bullseye + +build:ubuntu-20.04: + <<: *build_definition + image: ubuntu:focal + before_script: + - DEBIAN_FRONTEND=noninteractive apt-get update -y + - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev + +# yakkety most close to jessie + +build:ubuntu-16.10: + <<: *build_definition + image: ubuntu:yakkety + before_script: + - echo "" > /etc/apt/apt.conf.d/50venenuxcustom + - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom + - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom + - rm -rf /etc/apt/sources.list + - echo "deb http://old-releases.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse" > /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://old-releases.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list + - echo "deb http://old-releases.ubuntu.com/ubuntu yakkety-security main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list + - apt-get update -y || true + - apt-get -y --force-yes install build-essential cmake pkg-config debhelper lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev # Zesty most close to stretch build:ubuntu-17.04: - extends: .build_template + <<: *build_definition image: ubuntu:zesty before_script: - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - rm -rf /etc/apt/sources.list - echo "deb http://old-releases.ubuntu.com/ubuntu/ zesty main restricted universe multiverse" > /etc/apt/sources.list.d/50debianoficial.list - echo "deb http://old-releases.ubuntu.com/ubuntu/ zesty-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list - echo "deb http://old-releases.ubuntu.com/ubuntu zesty-security main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential git cmake pkg-config cmake-data debhelper dh-systemd dh-autoreconf lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev - -# artful most close to stretch - -build:ubuntu-17.10: - extends: .build_template - image: ubuntu:artful - before_script: - - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - rm -rf /etc/apt/sources.list - - echo "deb http://old-releases.ubuntu.com/ubuntu/ artful main restricted universe multiverse" > /etc/apt/sources.list.d/50debianoficial.list - - echo "deb http://old-releases.ubuntu.com/ubuntu/ artful-updates main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list - - echo "deb http://old-releases.ubuntu.com/ubuntu artful-security main restricted universe multiverse" >> /etc/apt/sources.list.d/50debianoficial.list - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install build-essential git cmake pkg-config cmake-data debhelper dh-systemd dh-autoreconf lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev - -# Xenial - -build:ubuntu-16.04: - extends: .build_template - image: ubuntu:xenial - before_script: - - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev - -# Bionic - -build:ubuntu-18.04: - extends: .build_template - image: ubuntu:bionic - before_script: - - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev - -# Focal - -build:ubuntu-20.04: - extends: .build_template - image: ubuntu:focal - before_script: - - echo "" > /etc/apt/apt.conf.d/50venenuxcustom - - echo "APT::Get::AllowUnauthenticated \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowDowngradeToInsecureRepositories \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::AllowReleaseInfoChange::Suite \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Check-Valid-Until \"false\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Acquire::Languages \"en\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - echo "Aptitude::CmdLine::Ignore-Trust-Violations \"true\";" >> /etc/apt/apt.conf.d/50venenuxcustom - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev - -# jammy - -build:ubuntu-22.04: - extends: .build_template - image: ubuntu:jammy - before_script: - - DEBIAN_FRONTEND=noninteractive apt-get update -y || true - - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential git cmake pkg-config libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + - apt-get update -y || true + - apt-get -y --force-yes install build-essential cmake pkg-config debhelper dh-systemd dh-autoreconf lsb-release gettext libbz2-dev libcurl4-gnutls-dev libnl-genl-3-dev libnl-3-dev librtmp-dev libidn11-dev libncurses-dev libfreetype6-dev libglu1-mesa-dev libgmp-dev libirrlicht-dev libjpeg-dev libjsoncpp-dev libleveldb-dev libluajit-5.1-dev liblua5.1-dev libogg-dev libopenal-dev libpng-dev libpq-dev libhiredis-dev libspatialindex-dev libsqlite3-dev libvorbis-dev libx11-dev libxxf86vm-dev postgresql-server-dev-all libpq-dev libhiredis-dev zlib1g-dev doxygen libxrandr-dev mesa-common-dev x11proto-xf86vidmode-dev libzstd-dev ## -## Fedora +## Feladora shit distro ## -# Fedora 28 <-> RHEL 8 -build:fedora-28: - extends: .build_template - image: fedora:28 - before_script: - - dnf -y install make automake gcc gcc-c++ kernel-devel git cmake pkgconfig libidn-devel libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel - -# Fedora 36 build:fedora-36: - extends: .build_template + <<: *build_definition image: fedora:36 before_script: - - dnf -y install make automake gcc gcc-c++ kernel-devel git cmake pkgconfig libidn-devel bzip2-devel gettext-devel sqlite-devel zlib-devel libpng-devel libjpeg-turbo-devel libXxf86vm-devel mesa-libGL-devel irrlicht-devel desktop-file-utils systemd openal* libvorbis* jsoncpp-devel libcurl-devel libcurl luajit-devel leveldb-devel gmp-devel libappstream-glib freetype-devel spatialindex-devel openssl-devel libogg-devel libpq-devel hiredis-devel libzstd-devel libXi-devel ncurses-devel doxygen + - dnf -y install make automake gcc gcc-c++ kernel-devel cmake pkgconfig bzip2-devel gettext-devel sqlite-devel zlib-devel libpng-devel libjpeg-turbo-devel libXxf86vm-devel mesa-libGL-devel irrlicht-devel desktop-file-utils systemd openal* libvorbis* jsoncpp-devel libcurl-devel libcurl luajit-devel leveldb-devel gmp-devel libappstream-glib freetype-devel spatialindex-devel openssl-devel libogg-devel hiredis-devel libzstd-devel libXi-devel ncurses-devel doxygen -# Fedora 37 build:fedora-37: - extends: .build_template + <<: *build_definition image: fedora:37 before_script: - - dnf -y install make automake gcc gcc-c++ kernel-devel git cmake pkgconfig libidn-devel bzip2-devel gettext-devel sqlite-devel zlib-devel libpng-devel libjpeg-turbo-devel libXxf86vm-devel mesa-libGL-devel irrlicht-devel desktop-file-utils systemd openal* libvorbis* jsoncpp-devel libcurl-devel libcurl luajit-devel leveldb-devel gmp-devel libappstream-glib freetype-devel spatialindex-devel openssl-devel libogg-devel libpq-devel hiredis-devel libzstd-devel libXi-devel ncurses-devel doxygen - -# Fedora 38 -build:fedora-38: - extends: .build_template - image: fedora:38 - before_script: - - dnf -y install make automake gcc gcc-c++ kernel-devel git cmake pkgconfig libidn-devel bzip2-devel gettext-devel sqlite-devel zlib-devel libpng-devel libjpeg-turbo-devel libXxf86vm-devel mesa-libGL-devel irrlicht-devel desktop-file-utils systemd openal* libvorbis* jsoncpp-devel libcurl-devel libcurl luajit-devel leveldb-devel gmp-devel libappstream-glib freetype-devel spatialindex-devel openssl-devel libogg-devel libpq-devel hiredis-devel libzstd-devel libXi-devel ncurses-devel doxygen - -## -## MinGW for Windows -## - -.generic_win_template: - image: ubuntu:bionic - before_script: - - apt-get update -y - - apt-get install -y wget xz-utils unzip git cmake gettext - - wget -nv http://minetest.kitsunemimi.pw/mingw-w64-${WIN_ARCH}_9.2.0_ubuntu18.04.tar.xz -O mingw.tar.xz - - tar -xaf mingw.tar.xz -C /usr - -.build_win_template: - extends: .generic_win_template - stage: build - artifacts: - expire_in: 1h - paths: - - build/multicraft/_build/* - -.package_win_template: - extends: .generic_win_template - stage: package - script: - - unzip build/multicraft/_build/multicraft-*.zip - - wget -nv https://gitlab.com/minenux/minetest-game-minetest/-/archive/stable-5.2/minetest-game-minetest-stable-5.2.tar.gz -O game.tar.gz - - tar -xvf game.tar.gz -C / - - mv /minetest*game* multicraft-*-win*/games/minetest || true - - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libgcc*.dll multicraft-*-win*/bin/ - - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libstdc++*.dll multicraft-*-win*/bin/ - - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libwinpthread*.dll multicraft-*-win*/bin/ - artifacts: - expire_in: 90 day - paths: - - multicraft-*-win*/* - -build:win32: - extends: .build_win_template - script: - - ./util/buildbot/buildwin32.sh build - variables: - WIN_ARCH: "i686" - -package:win32: - extends: .package_win_template - needs: - - build:win32 - variables: - WIN_ARCH: "i686" - - -build:win64: - extends: .build_win_template - script: - - ./util/buildbot/buildwin64.sh build - variables: - WIN_ARCH: "x86_64" - -package:win64: - extends: .package_win_template - needs: - - build:win64 - variables: - WIN_ARCH: "x86_64" - + - dnf -y install make automake gcc gcc-c++ kernel-devel cmake pkgconfig bzip2-devel gettext-devel sqlite-devel zlib-devel libpng-devel libjpeg-turbo-devel libXxf86vm-devel mesa-libGL-devel irrlicht-devel desktop-file-utils systemd openal* libvorbis* jsoncpp-devel libcurl-devel libcurl luajit-devel leveldb-devel gmp-devel libappstream-glib freetype-devel spatialindex-devel openssl-devel libogg-devel hiredis-devel libzstd-devel libXi-devel ncurses-devel doxygen diff --git a/Android/app/build.gradle b/Android/app/build.gradle index c4da0a6d0..a977d0ee9 100644 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 - buildToolsVersion '33.0.2' + compileSdkVersion 34 + buildToolsVersion '34.0.0' ndkVersion '25.2.9519653' defaultConfig { applicationId 'com.multicraft.game' minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionName "${versionMajor}.${versionMinor}.${versionPatch}" versionCode project.versionCode } @@ -100,7 +100,7 @@ tasks.register('prepareAssetsFiles') { tasks.register('zipAssetsFiles', Zip) { dependsOn prepareAssetsFiles archiveFileName = 'assets.zip' - destinationDirectory = file('src/main/assets/data') + destinationDirectory = file('src/main/assets') from('build/assets/Files') } @@ -125,7 +125,8 @@ dependencies { /* Third-party libraries */ implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat-resources:1.6.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation("androidx.browser:browser:1.6.0") + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' implementation 'androidx.work:work-runtime-ktx:2.8.1' - implementation 'com.google.android.material:material:1.9.0' + implementation 'com.google.android.material:material:1.10.0' } diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml index 7e743f503..028143246 100644 --- a/Android/app/src/main/AndroidManifest.xml +++ b/Android/app/src/main/AndroidManifest.xml @@ -28,7 +28,6 @@ + + + diff --git a/Android/app/src/main/java/com/multicraft/game/CustomEditText.kt b/Android/app/src/main/java/com/multicraft/game/CustomEditText.kt index c924a63c8..baf240b64 100644 --- a/Android/app/src/main/java/com/multicraft/game/CustomEditText.kt +++ b/Android/app/src/main/java/com/multicraft/game/CustomEditText.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/Android/app/src/main/java/com/multicraft/game/GameActivity.kt b/Android/app/src/main/java/com/multicraft/game/GameActivity.kt index 27c98241d..1118fcce3 100644 --- a/Android/app/src/main/java/com/multicraft/game/GameActivity.kt +++ b/Android/app/src/main/java/com/multicraft/game/GameActivity.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -20,11 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc., package com.multicraft.game -import android.content.Intent import android.content.res.Configuration -import android.content.res.Configuration.HARDKEYBOARDHIDDEN_NO import android.net.Uri -import android.os.Bundle +import android.os.* import android.text.InputType import android.view.* import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN @@ -33,12 +31,15 @@ import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager import android.widget.TextView import androidx.appcompat.app.AlertDialog +import androidx.browser.customtabs.CustomTabsIntent +import androidx.browser.customtabs.CustomTabsIntent.SHARE_STATE_OFF import com.multicraft.game.MainActivity.Companion.radius -import com.multicraft.game.databinding.InputTextBinding -import com.multicraft.game.databinding.MultilineInputBinding +import com.multicraft.game.databinding.* import com.multicraft.game.helpers.* import com.multicraft.game.helpers.ApiLevelHelper.isOreo import org.libsdl.app.SDLActivity +import java.util.* +import kotlin.system.exitProcess class GameActivity : SDLActivity() { companion object { @@ -52,24 +53,23 @@ class GameActivity : SDLActivity() { external fun keyboardEvent(keyboard: Boolean) } - private var messageReturnCode = -1 private var messageReturnValue = "" private var hasKeyboard = false + override fun getLibraries() = arrayOf("MultiCraft") - override fun getLibraries(): Array { - return arrayOf( - "MultiCraft" - ) - } - - override fun getMainSharedObject(): String { - return getContext().applicationInfo.nativeLibraryDir + "/libMultiCraft.so" - } + override fun getMainSharedObject() = + "${getContext().applicationInfo.nativeLibraryDir}/libMultiCraft.so" override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) + try { + super.onCreate(savedInstanceState) + } catch (e: Error) { + exitProcess(0) + } catch (e: Exception) { + exitProcess(0) + } window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) - hasKeyboard = resources.configuration.hardKeyboardHidden == HARDKEYBOARDHIDDEN_NO + hasKeyboard = hasHardKeyboard() } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -89,15 +89,13 @@ class GameActivity : SDLActivity() { override fun onResume() { super.onResume() - if (hasKeyboard) - keyboardEvent(hasKeyboard) + if (hasKeyboard) keyboardEvent(true) window.makeFullScreen() } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - val statusKeyboard = - resources.configuration.hardKeyboardHidden == HARDKEYBOARDHIDDEN_NO + val statusKeyboard = hasHardKeyboard() if (hasKeyboard != statusKeyboard) { hasKeyboard = statusKeyboard keyboardEvent(hasKeyboard) @@ -106,8 +104,8 @@ class GameActivity : SDLActivity() { @Suppress("unused") fun showDialog(hint: String?, current: String?, editType: Int) { + isInputActive = true messageReturnValue = "" - messageReturnCode = -1 if (editType == 1) runOnUiThread { showMultiLineDialog(hint, current) } else @@ -115,7 +113,6 @@ class GameActivity : SDLActivity() { } private fun showSingleDialog(hint: String?, current: String?, editType: Int) { - isInputActive = true val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle) val binding = InputTextBinding.inflate(layoutInflater) var hintText: String = hint?.ifEmpty { @@ -139,40 +136,37 @@ class GameActivity : SDLActivity() { editText.inputType = inputType editText.setSelection(editText.text?.length ?: 0) // for Android OS - editText.setOnEditorActionListener { _: TextView?, KeyCode: Int, _: KeyEvent? -> - if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) { + editText.setOnEditorActionListener { _: TextView?, keyCode: Int, _: KeyEvent? -> + if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_ENDCALL) { imm.hideSoftInputFromWindow(editText.windowToken, 0) messageReturnValue = editText.text.toString() - messageReturnCode = 0 alertDialog.dismiss() isInputActive = false return@setOnEditorActionListener true } return@setOnEditorActionListener false } - // for Chrome OS - editText.setOnKeyListener { _: View?, KeyCode: Int, _: KeyEvent? -> - if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) { - imm.hideSoftInputFromWindow(editText.windowToken, 0) - messageReturnValue = editText.text.toString() - messageReturnCode = 0 - alertDialog.dismiss() - isInputActive = false - return@setOnKeyListener true + if (isChromebook()) { + editText.setOnKeyListener { _: View?, keyCode: Int, _: KeyEvent? -> + if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_ENDCALL) { + imm.hideSoftInputFromWindow(editText.windowToken, 0) + messageReturnValue = editText.text.toString() + alertDialog.dismiss() + isInputActive = false + return@setOnKeyListener true + } + return@setOnKeyListener false } - return@setOnKeyListener false } binding.input.setEndIconOnClickListener { imm.hideSoftInputFromWindow(editText.windowToken, 0) messageReturnValue = editText.text.toString() - messageReturnCode = 0 alertDialog.dismiss() isInputActive = false } binding.rl.setOnClickListener { window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN) messageReturnValue = current.toString() - messageReturnCode = 0 alertDialog.dismiss() isInputActive = false } @@ -180,18 +174,16 @@ class GameActivity : SDLActivity() { // should be above `show()` alertWindow.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE) alertDialog.show() - if (!resources.getBoolean(R.bool.isTablet)) + if (!isTablet()) alertWindow.makeFullScreenAlert() alertDialog.setOnCancelListener { window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN) messageReturnValue = current.toString() - messageReturnCode = 0 isInputActive = false } } private fun showMultiLineDialog(hint: String?, current: String?) { - isInputActive = true val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle) val binding = MultilineInputBinding.inflate(layoutInflater) var hintText: String = hint?.ifEmpty { @@ -208,40 +200,37 @@ class GameActivity : SDLActivity() { editText.setSelection(editText.text?.length ?: 0) val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager // for Android OS - editText.setOnEditorActionListener { _: TextView?, KeyCode: Int, _: KeyEvent? -> - if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) { + editText.setOnEditorActionListener { _: TextView?, keyCode: Int, _: KeyEvent? -> + if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_ENDCALL) { imm.hideSoftInputFromWindow(editText.windowToken, 0) messageReturnValue = editText.text.toString() - messageReturnCode = 0 alertDialog.dismiss() isInputActive = false return@setOnEditorActionListener true } return@setOnEditorActionListener false } - // for Chrome OS - editText.setOnKeyListener { _: View?, KeyCode: Int, _: KeyEvent? -> - if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) { - imm.hideSoftInputFromWindow(editText.windowToken, 0) - messageReturnValue = editText.text.toString() - messageReturnCode = 0 - alertDialog.dismiss() - isInputActive = false - return@setOnKeyListener true + if (isChromebook()) { + editText.setOnKeyListener { _: View?, keyCode: Int, _: KeyEvent? -> + if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_ENDCALL) { + imm.hideSoftInputFromWindow(editText.windowToken, 0) + messageReturnValue = editText.text.toString() + alertDialog.dismiss() + isInputActive = false + return@setOnKeyListener true + } + return@setOnKeyListener false } - return@setOnKeyListener false } binding.multiInput.setEndIconOnClickListener { imm.hideSoftInputFromWindow(editText.windowToken, 0) messageReturnValue = editText.text.toString() - messageReturnCode = 0 alertDialog.dismiss() isInputActive = false } binding.multiRl.setOnClickListener { window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN) messageReturnValue = current.toString() - messageReturnCode = -1 alertDialog.dismiss() isInputActive = false } @@ -249,23 +238,23 @@ class GameActivity : SDLActivity() { val alertWindow = alertDialog.window!! alertWindow.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE) alertDialog.show() - if (!resources.getBoolean(R.bool.isTablet)) + if (!isTablet()) alertWindow.makeFullScreenAlert() alertDialog.setOnCancelListener { window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN) messageReturnValue = current.toString() - messageReturnCode = -1 isInputActive = false } } @Suppress("unused") - fun getDialogState() = messageReturnCode + fun isDialogActive() = isInputActive @Suppress("unused") fun getDialogValue(): String { - messageReturnCode = -1 - return messageReturnValue + val value = messageReturnValue + messageReturnValue = "" + return value } @Suppress("unused") @@ -282,9 +271,13 @@ class GameActivity : SDLActivity() { @Suppress("unused") fun openURI(uri: String?) { + val builder = CustomTabsIntent.Builder() + builder.setShareState(SHARE_STATE_OFF) + .setStartAnimations(this, R.anim.slide_in_bottom, R.anim.slide_out_top) + .setExitAnimations(this, R.anim.slide_in_top, R.anim.slide_out_bottom) + val customTabsIntent = builder.build() try { - val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) - startActivity(browserIntent) + customTabsIntent.launchUrl(this, Uri.parse(uri)) } catch (ignored: Exception) { } } @@ -304,7 +297,7 @@ class GameActivity : SDLActivity() { @Suppress("unused") fun getSecretKey(key: String): String { - return "Stub" + return key } @Suppress("unused") diff --git a/Android/app/src/main/java/com/multicraft/game/MainActivity.kt b/Android/app/src/main/java/com/multicraft/game/MainActivity.kt index 3845ddb14..419d54fa1 100644 --- a/Android/app/src/main/java/com/multicraft/game/MainActivity.kt +++ b/Android/app/src/main/java/com/multicraft/game/MainActivity.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -22,18 +22,25 @@ package com.multicraft.game import android.content.Intent import android.content.SharedPreferences -import android.graphics.Color -import android.graphics.drawable.LayerDrawable +import android.graphics.drawable.AnimationDrawable import android.os.Bundle -import android.view.* +import android.provider.Settings.ACTION_WIFI_SETTINGS +import android.provider.Settings.ACTION_WIRELESS_SETTINGS +import android.view.RoundedCorner +import android.view.WindowManager +import androidx.activity.OnBackPressedCallback +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity -import androidx.core.graphics.BlendModeColorFilterCompat -import androidx.core.graphics.BlendModeCompat -import androidx.lifecycle.* +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope import androidx.work.WorkInfo import com.multicraft.game.databinding.ActivityMainBinding +import com.multicraft.game.dialogs.ConnectionDialog import com.multicraft.game.helpers.* import com.multicraft.game.helpers.ApiLevelHelper.isAndroid12 +import com.multicraft.game.helpers.ApiLevelHelper.isPie import com.multicraft.game.helpers.PreferenceHelper.TAG_BUILD_VER import com.multicraft.game.helpers.PreferenceHelper.getStringValue import com.multicraft.game.helpers.PreferenceHelper.set @@ -49,11 +56,14 @@ class MainActivity : AppCompatActivity() { private var externalStorage: File? = null private val sep = File.separator private lateinit var prefs: SharedPreferences + private lateinit var restartStartForResult: ActivityResultLauncher + private lateinit var connStartForResult: ActivityResultLauncher private val versionCode = BuildConfig.VERSION_CODE private val versionName = "${BuildConfig.VERSION_NAME}+$versionCode" companion object { var radius = 0 + const val NO_SPACE_LEFT = "ENOSPC" } override fun onCreate(savedInstanceState: Bundle?) { @@ -61,30 +71,34 @@ class MainActivity : AppCompatActivity() { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) + onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + } + }) + connStartForResult = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { + checkAppVersion() + } + restartStartForResult = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { + if (it.resultCode == RESULT_OK) + finishApp(true) + else + finishApp(false) + } try { prefs = PreferenceHelper.init(this) externalStorage = getExternalFilesDir(null) - if (filesDir == null || cacheDir == null || externalStorage == null) - throw IOException("Bad disk space state") + listOf(filesDir, cacheDir, externalStorage).requireNoNulls() checkConnection() - } catch (e: Exception) { // Storage -> IOException, Prefs -> GeneralSecurityException - showRestartDialog(!e.message!!.contains("ENOPSC")) + } catch (e: Exception) { + val isRestart = e.message?.contains(NO_SPACE_LEFT) != true + showRestartDialog(restartStartForResult, isRestart) } } - @Deprecated("Deprecated in Java") - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - @Suppress("DEPRECATION") - super.onActivityResult(requestCode, resultCode, data) - if (requestCode == 104) - checkAppVersion() - } - - @Deprecated("Deprecated in Java") - override fun onBackPressed() { - // Prevent abrupt interruption when copy game files from assets - } - override fun onResume() { super.onResume() window.makeFullScreen() @@ -97,81 +111,66 @@ class MainActivity : AppCompatActivity() { override fun onAttachedToWindow() { super.onAttachedToWindow() - if (isAndroid12()) { - val insets = window.decorView.rootWindowInsets - if (insets != null) { - val tl = insets.getRoundedCorner(RoundedCorner.POSITION_TOP_LEFT) - radius = tl?.radius ?: 0 + if (isPie()) { + val cutout = window.decorView.rootWindowInsets.displayCutout + if (cutout != null) { + radius = 40 + } + if (isAndroid12()) { + val insets = window.decorView.rootWindowInsets + if (insets != null) { + val tl = insets.getRoundedCorner(RoundedCorner.POSITION_TOP_LEFT) + radius = tl?.radius ?: if (cutout != null) 40 else 0 + } } } - } - - - // interface - private fun showProgress(textMessage: Int, progress: Int) { - if (binding.progressBar.visibility == View.GONE) { - binding.tvProgress.setText(textMessage) - binding.progressCircle.visibility = View.GONE - binding.progressBar.visibility = View.VISIBLE - binding.progressBar.progress = 0 - } else if (progress > 0) { - val progressMessage = "${getString(textMessage)} $progress%" - binding.tvProgress.text = progressMessage - binding.progressBar.progress = progress - // colorize the progress bar - val progressBarDrawable = - (binding.progressBar.progressDrawable as LayerDrawable).getDrawable(0) - val progressDrawable = (progressBarDrawable as LayerDrawable).getDrawable(1) - val color = Color.rgb(255 - progress * 2, progress * 2, 25) - progressDrawable.colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat( - color, BlendModeCompat.SRC_IN - ) - } + val animation = binding.loadingAnim.drawable as AnimationDrawable + animation.start() } private fun startNative() { val initLua = File(filesDir, "builtin${sep}mainmenu${sep}init.lua") if (initLua.exists() && initLua.canRead()) { val intent = Intent(this, GameActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent) } else { prefs[TAG_BUILD_VER] = "0" - showRestartDialog() + showRestartDialog(restartStartForResult) } } private fun prepareToRun() { - binding.tvProgress.setText(R.string.preparing) - binding.progressCircle.visibility = View.VISIBLE - binding.progressBar.visibility = View.GONE - val filesList = listOf( - File(externalStorage, "debug.txt"), - File(filesDir, "builtin"), - File(filesDir, "client"), - File(filesDir, "fonts"), - File(filesDir, "textures") - ) - val zips = assets.list("data")!!.toList() + val filesList = mutableListOf().apply { + addAll(listOf( + "builtin", + "client${sep}shaders", + "fonts", + "games${sep}default", + "textures${sep}base" + ).map { File(filesDir, it) }) + } + + val zips = mutableListOf("assets.zip") + lifecycleScope.launch { filesList.forEach { it.deleteRecursively() } zips.forEach { try { - assets.open("data$sep$it").use { input -> + assets.open(it).use { input -> File(cacheDir, it).copyInputStreamToFile(input) } } catch (e: IOException) { - runOnUiThread { showRestartDialog(!e.message!!.contains("ENOSPC")) } + val isNotEnoughSpace = e.message!!.contains(NO_SPACE_LEFT) + runOnUiThread { showRestartDialog(restartStartForResult, !isNotEnoughSpace) } return@forEach } } try { - startUnzipWorker(zips) + startUnzipWorker(zips.toTypedArray()) } catch (e: Exception) { - runOnUiThread { showRestartDialog() } + runOnUiThread { showRestartDialog(restartStartForResult) } } } } @@ -184,31 +183,47 @@ class MainActivity : AppCompatActivity() { prepareToRun() } + private fun showConnectionDialog() { + val intent = Intent(this, ConnectionDialog::class.java) + val startForResult = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { + when (it.resultCode) { + RESULT_OK -> connStartForResult.launch(Intent(ACTION_WIFI_SETTINGS)) + RESULT_FIRST_USER -> connStartForResult.launch(Intent(ACTION_WIRELESS_SETTINGS)) + else -> checkAppVersion() + } + } + startForResult.launch(intent) + } + // check connection available private fun checkConnection() = lifecycleScope.launch { - val result = isConnected() - if (result) checkAppVersion() + if (isConnected()) checkAppVersion() else try { - showConnectionDialog { checkAppVersion() } + showConnectionDialog() } catch (e: Exception) { checkAppVersion() } } - private fun startUnzipWorker(file: List) { - val viewModelFactory = WorkerViewModelFactory(application, file.toTypedArray()) + private fun startUnzipWorker(file: Array) { + val viewModelFactory = WorkerViewModelFactory(application, file) val viewModel = ViewModelProvider(this, viewModelFactory)[WorkerViewModel::class.java] viewModel.unzippingWorkObserver .observe(this, Observer { workInfo -> if (workInfo == null) return@Observer val progress = workInfo.progress.getInt(PROGRESS, 0) - showProgress(R.string.loading, progress) + if (progress > 0) { + val progressMessage = "${getString(R.string.loading)} $progress%" + binding.tvProgress.text = progressMessage + } if (workInfo.state.isFinished) { if (workInfo.state == WorkInfo.State.FAILED) { val isRestart = workInfo.outputData.getBoolean("restart", true) - showRestartDialog(isRestart) + showRestartDialog(restartStartForResult, isRestart) } else if (workInfo.state == WorkInfo.State.SUCCEEDED) { prefs[TAG_BUILD_VER] = versionName startNative() diff --git a/Android/app/src/main/java/com/multicraft/game/dialogs/ConnectionDialog.kt b/Android/app/src/main/java/com/multicraft/game/dialogs/ConnectionDialog.kt new file mode 100644 index 000000000..35bd8257b --- /dev/null +++ b/Android/app/src/main/java/com/multicraft/game/dialogs/ConnectionDialog.kt @@ -0,0 +1,96 @@ +/* +MultiCraft +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 3.0 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package com.multicraft.game.dialogs + +import android.app.Activity +import android.content.Context +import android.content.res.Configuration +import android.os.Bundle +import android.telephony.TelephonyManager +import android.telephony.TelephonyManager.SIM_STATE_READY +import android.view.View +import android.widget.LinearLayout +import androidx.activity.OnBackPressedCallback +import androidx.appcompat.app.AppCompatActivity +import com.multicraft.game.databinding.ConnectionDialogBinding +import com.multicraft.game.helpers.ApiLevelHelper.isOreo +import com.multicraft.game.helpers.makeFullScreen +import org.libsdl.app.SDLActivity + +class ConnectionDialog : AppCompatActivity() { + private fun isSimCardPresent(): Boolean { + val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + + if (!isOreo()) + return telephonyManager.simState == SIM_STATE_READY + + val isFirstSimPresent = telephonyManager.getSimState(0) == SIM_STATE_READY + val isSecondSimPresent = telephonyManager.getSimState(1) == SIM_STATE_READY + + return isFirstSimPresent || isSecondSimPresent + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val binding = ConnectionDialogBinding.inflate(layoutInflater) + if (SDLActivity.isTablet()) { + val param = LinearLayout.LayoutParams( + 0, + LinearLayout.LayoutParams.WRAP_CONTENT, + 0.5f + ) + binding.connRoot.layoutParams = param + } + if (isSimCardPresent()) + binding.mobile.visibility = View.VISIBLE + setContentView(binding.root) + + onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + } + }) + + binding.wifi.setOnClickListener { + setResult(Activity.RESULT_OK) + finish() + } + binding.mobile.setOnClickListener { + setResult(Activity.RESULT_FIRST_USER) + finish() + } + binding.ignore.setOnClickListener { + setResult(Activity.RESULT_CANCELED) + finish() + } + } + + override fun onResume() { + super.onResume() + window.makeFullScreen() + } + + override fun attachBaseContext(base: Context?) { + val configuration = Configuration(base?.resources?.configuration) + configuration.fontScale = 1.0f + applyOverrideConfiguration(configuration) + super.attachBaseContext(base) + } +} diff --git a/Android/app/src/main/java/com/multicraft/game/dialogs/RestartDialog.kt b/Android/app/src/main/java/com/multicraft/game/dialogs/RestartDialog.kt new file mode 100644 index 000000000..733fd6a74 --- /dev/null +++ b/Android/app/src/main/java/com/multicraft/game/dialogs/RestartDialog.kt @@ -0,0 +1,76 @@ +/* +MultiCraft +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 3.0 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package com.multicraft.game.dialogs + +import android.app.Activity +import android.content.Context +import android.content.res.Configuration +import android.os.Bundle +import android.widget.LinearLayout +import androidx.activity.OnBackPressedCallback +import androidx.appcompat.app.AppCompatActivity +import com.multicraft.game.databinding.RestartDialogBinding +import com.multicraft.game.helpers.makeFullScreen +import org.libsdl.app.SDLActivity + +class RestartDialog : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val binding = RestartDialogBinding.inflate(layoutInflater) + if (SDLActivity.isTablet()) { + val param = LinearLayout.LayoutParams( + 0, + LinearLayout.LayoutParams.WRAP_CONTENT, + 0.5f + ) + binding.restartRoot.layoutParams = param + } + setContentView(binding.root) + + onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + } + }) + + val message = intent.getStringExtra("message")!! + binding.errorDesc.text = message + binding.restart.setOnClickListener { + setResult(Activity.RESULT_OK) + finish() + } + binding.close.setOnClickListener { + setResult(Activity.RESULT_CANCELED) + finish() + } + } + + override fun onResume() { + super.onResume() + window.makeFullScreen() + } + + override fun attachBaseContext(base: Context?) { + val configuration = Configuration(base?.resources?.configuration) + configuration.fontScale = 1.0f + applyOverrideConfiguration(configuration) + super.attachBaseContext(base) + } +} diff --git a/Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt b/Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt index 10110b846..380760dd7 100644 --- a/Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt +++ b/Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -30,5 +30,7 @@ object ApiLevelHelper { fun isOreo() = isGreaterOrEqual(O) + fun isPie() = isGreaterOrEqual(P) + fun isAndroid12() = isGreaterOrEqual(S) } diff --git a/Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt b/Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt index 8080789af..11626b39f 100644 --- a/Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt +++ b/Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt b/Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt index 966541f2b..a4f0a79aa 100644 --- a/Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt +++ b/Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -23,31 +23,22 @@ package com.multicraft.game.helpers import android.app.* import android.content.Context import android.content.Intent -import android.content.pm.PackageManager -import android.net.ConnectivityManager -import android.net.NetworkCapabilities -import android.provider.Settings -import android.view.View +import android.content.res.Configuration +import android.net.* +import android.os.* import android.view.Window -import androidx.appcompat.app.AlertDialog +import androidx.activity.result.ActivityResultLauncher import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat import androidx.core.view.* -import com.multicraft.game.R -import com.multicraft.game.databinding.ConnDialogBinding -import com.multicraft.game.databinding.RestartDialogBinding +import com.multicraft.game.* +import com.multicraft.game.databinding.* +import com.multicraft.game.dialogs.RestartDialog import com.multicraft.game.helpers.ApiLevelHelper.isAndroid12 -import java.io.File -import java.io.InputStream -import kotlin.system.exitProcess +import com.multicraft.game.helpers.ApiLevelHelper.isMarshmallow +import java.io.* +import java.util.* // Activity extensions -fun AppCompatActivity.getIcon() = try { - packageManager.getApplicationIcon(packageName) -} catch (e: PackageManager.NameNotFoundException) { - ContextCompat.getDrawable(this, R.mipmap.ic_launcher) -} - fun Activity.finishApp(restart: Boolean) { if (restart) { val intent = Intent(this, this::class.java) @@ -61,72 +52,12 @@ fun Activity.finishApp(restart: Boolean) { ) ) } - exitProcess(0) + finish() } -fun AppCompatActivity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDialog): AlertDialog { - val builder = AlertDialog.Builder(this, style) - .setIcon(getIcon()) - .setTitle(title) - .setCancelable(false) - .setView(view) - return builder.create() -} - -fun AppCompatActivity.headlessDialog( - view: View, - style: Int = R.style.LightTheme, - isCancelable: Boolean = false -): AlertDialog { - val builder = AlertDialog.Builder(this, style) - .setCancelable(isCancelable) - .setView(view) - return builder.create() -} - -fun AppCompatActivity.show(dialog: AlertDialog) { - window?.makeFullScreen() - if (!isFinishing) dialog.show() -} - -fun AppCompatActivity.showConnectionDialog(listener: (() -> Unit)? = null) { - val binding = ConnDialogBinding.inflate(layoutInflater) - val dialog = defaultDialog(R.string.conn_title, binding.root) - binding.wifi.setOnClickListener { - dialog.dismiss() - startActivityForResult( - Intent(Settings.ACTION_WIFI_SETTINGS), - 104 - ) - } - binding.mobile.setOnClickListener { - dialog.dismiss() - startActivityForResult( - Intent(Settings.ACTION_WIRELESS_SETTINGS), - 104 - ) - } - binding.ignore.setOnClickListener { - dialog.dismiss() - listener?.invoke() - } - show(dialog) -} - -fun AppCompatActivity.showRestartDialog(isRestart: Boolean = true) { - val message = - if (isRestart) getString(R.string.restart) else getString(R.string.no_space) - val binding = RestartDialogBinding.inflate(layoutInflater) - val dialog = headlessDialog(binding.root, R.style.CustomDialog) - binding.errorDesc.text = message - binding.close.setOnClickListener { finishApp(false) } - binding.restart.setOnClickListener { finishApp(true) } - show(dialog) -} - -fun AppCompatActivity.isConnected(): Boolean { +fun Activity.isConnected(): Boolean { val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - if (ApiLevelHelper.isMarshmallow()) { + if (isMarshmallow()) { val activeNetwork = cm.activeNetwork ?: return false val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) @@ -136,6 +67,20 @@ fun AppCompatActivity.isConnected(): Boolean { } } +fun AppCompatActivity.showRestartDialog( + startForResult: ActivityResultLauncher, + isRestart: Boolean = true +) { + val message = + if (isRestart) getString(R.string.restart) else getString(R.string.no_space) + val intent = Intent(this, RestartDialog::class.java) + intent.putExtra("message", message) + startForResult.launch(intent) +} + +fun Activity.hasHardKeyboard() = + resources.configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO + // Other extensions fun File.copyInputStreamToFile(inputStream: InputStream) = outputStream().use { fileOut -> inputStream.copyTo(fileOut, 8192) } diff --git a/Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt index b9d71100a..6fe878965 100644 --- a/Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt +++ b/Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -26,6 +26,7 @@ import android.content.Context import android.content.Context.NOTIFICATION_SERVICE import androidx.core.app.NotificationCompat import androidx.work.* +import com.multicraft.game.MainActivity.Companion.NO_SPACE_LEFT import com.multicraft.game.R import com.multicraft.game.helpers.ApiLevelHelper.isOreo import com.multicraft.game.helpers.copyInputStreamToFile @@ -83,7 +84,7 @@ class UnzipWorker(private val appContext: Context, workerParams: WorkerParameter } Result.success() } catch (e: IOException) { - val isNotEnoughSpace = e.localizedMessage!!.contains("ENOSPC") + val isNotEnoughSpace = e.localizedMessage!!.contains(NO_SPACE_LEFT) val out = Data.Builder() .putBoolean("restart", !isNotEnoughSpace) .build() diff --git a/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt index 2601e56fb..1362df6ff 100644 --- a/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt +++ b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt index d47d44182..861c4076e 100644 --- a/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt +++ b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt @@ -1,7 +1,7 @@ /* MultiCraft -Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2022 ubulem, Bektur Mambetov +Copyright (C) 2014-2023 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2023 ubulem, Bektur Mambetov This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/Android/app/src/main/java/org/libsdl/app/SDLActivity.java b/Android/app/src/main/java/org/libsdl/app/SDLActivity.java index 2e25d787e..264fc1842 100644 --- a/Android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/Android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 28; - private static final int SDL_MICRO_VERSION = 2; + private static final int SDL_MICRO_VERSION = 4; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/Android/app/src/main/res/anim/slide_in_bottom.xml b/Android/app/src/main/res/anim/slide_in_bottom.xml new file mode 100644 index 000000000..7d71ec0dc --- /dev/null +++ b/Android/app/src/main/res/anim/slide_in_bottom.xml @@ -0,0 +1,5 @@ + + diff --git a/Android/app/src/main/res/anim/slide_in_top.xml b/Android/app/src/main/res/anim/slide_in_top.xml new file mode 100644 index 000000000..2590b13cb --- /dev/null +++ b/Android/app/src/main/res/anim/slide_in_top.xml @@ -0,0 +1,5 @@ + + diff --git a/Android/app/src/main/res/anim/slide_out_bottom.xml b/Android/app/src/main/res/anim/slide_out_bottom.xml new file mode 100644 index 000000000..ee271ddfd --- /dev/null +++ b/Android/app/src/main/res/anim/slide_out_bottom.xml @@ -0,0 +1,5 @@ + + diff --git a/Android/app/src/main/res/anim/slide_out_top.xml b/Android/app/src/main/res/anim/slide_out_top.xml new file mode 100644 index 000000000..139262fe4 --- /dev/null +++ b/Android/app/src/main/res/anim/slide_out_top.xml @@ -0,0 +1,5 @@ + + diff --git a/Android/app/src/main/res/drawable-night/bg_input.xml b/Android/app/src/main/res/drawable-night/bg_input.xml index afda4958d..1a72c7e0b 100644 --- a/Android/app/src/main/res/drawable-night/bg_input.xml +++ b/Android/app/src/main/res/drawable-night/bg_input.xml @@ -2,4 +2,7 @@ + diff --git a/Android/app/src/main/res/drawable/btn_green.xml b/Android/app/src/main/res/drawable/btn_green.xml new file mode 100644 index 000000000..da8f7ac66 --- /dev/null +++ b/Android/app/src/main/res/drawable/btn_green.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Android/app/src/main/res/drawable/btn_red.xml b/Android/app/src/main/res/drawable/btn_red.xml new file mode 100644 index 000000000..d617af9a2 --- /dev/null +++ b/Android/app/src/main/res/drawable/btn_red.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Android/app/src/main/res/drawable/btn_yellow.xml b/Android/app/src/main/res/drawable/btn_yellow.xml new file mode 100644 index 000000000..20509a2f6 --- /dev/null +++ b/Android/app/src/main/res/drawable/btn_yellow.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Android/app/src/main/res/drawable/custom_progress_bar.xml b/Android/app/src/main/res/drawable/custom_progress_bar.xml deleted file mode 100644 index 932804b67..000000000 --- a/Android/app/src/main/res/drawable/custom_progress_bar.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Android/app/src/main/res/drawable/green.9.png b/Android/app/src/main/res/drawable/green.9.png new file mode 100644 index 000000000..98c180602 Binary files /dev/null and b/Android/app/src/main/res/drawable/green.9.png differ diff --git a/Android/app/src/main/res/drawable/green_pressed.9.png b/Android/app/src/main/res/drawable/green_pressed.9.png new file mode 100644 index 000000000..42466f2b3 Binary files /dev/null and b/Android/app/src/main/res/drawable/green_pressed.9.png differ diff --git a/Android/app/src/main/res/drawable/ic_baseline_send.xml b/Android/app/src/main/res/drawable/ic_baseline_send.xml index 516b18892..a8a36dd94 100644 --- a/Android/app/src/main/res/drawable/ic_baseline_send.xml +++ b/Android/app/src/main/res/drawable/ic_baseline_send.xml @@ -6,6 +6,6 @@ android:viewportWidth="24" android:viewportHeight="24"> + android:fillColor="@color/green_mc" + android:pathData="M3.4,20.4l17.45,-7.48c0.81,-0.35 0.81,-1.49 0,-1.84L3.4,3.6c-0.66,-0.29 -1.39,0.2 -1.39,0.91L2,9.12c0,0.5 0.37,0.93 0.87,0.99L17,12 2.87,13.88c-0.5,0.07 -0.87,0.5 -0.87,1l0.01,4.61c0,0.71 0.73,1.2 1.39,0.91z" /> diff --git a/Android/app/src/main/res/drawable/loading.xml b/Android/app/src/main/res/drawable/loading.xml new file mode 100644 index 000000000..bc0d1d733 --- /dev/null +++ b/Android/app/src/main/res/drawable/loading.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/Android/app/src/main/res/drawable/loading_anim1.png b/Android/app/src/main/res/drawable/loading_anim1.png new file mode 100644 index 000000000..33a98fb7a Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim1.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim2.png b/Android/app/src/main/res/drawable/loading_anim2.png new file mode 100644 index 000000000..b67bf904c Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim2.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim3.png b/Android/app/src/main/res/drawable/loading_anim3.png new file mode 100644 index 000000000..7614239f8 Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim3.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim4.png b/Android/app/src/main/res/drawable/loading_anim4.png new file mode 100644 index 000000000..cb7ab685b Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim4.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim5.png b/Android/app/src/main/res/drawable/loading_anim5.png new file mode 100644 index 000000000..92d6e3cdf Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim5.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim6.png b/Android/app/src/main/res/drawable/loading_anim6.png new file mode 100644 index 000000000..e8cce7bb6 Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim6.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim7.png b/Android/app/src/main/res/drawable/loading_anim7.png new file mode 100644 index 000000000..afed436bc Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim7.png differ diff --git a/Android/app/src/main/res/drawable/loading_anim8.png b/Android/app/src/main/res/drawable/loading_anim8.png new file mode 100644 index 000000000..081bdbc3a Binary files /dev/null and b/Android/app/src/main/res/drawable/loading_anim8.png differ diff --git a/Android/app/src/main/res/drawable/progress.xml b/Android/app/src/main/res/drawable/progress.xml deleted file mode 100644 index 935315178..000000000 --- a/Android/app/src/main/res/drawable/progress.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/Android/app/src/main/res/drawable/progress_bar.webp b/Android/app/src/main/res/drawable/progress_bar.webp deleted file mode 100644 index fa9667392..000000000 Binary files a/Android/app/src/main/res/drawable/progress_bar.webp and /dev/null differ diff --git a/Android/app/src/main/res/drawable/progress_bar_bg.webp b/Android/app/src/main/res/drawable/progress_bar_bg.webp deleted file mode 100644 index 7b77b3976..000000000 Binary files a/Android/app/src/main/res/drawable/progress_bar_bg.webp and /dev/null differ diff --git a/Android/app/src/main/res/drawable/progress_bar_fg.png b/Android/app/src/main/res/drawable/progress_bar_fg.png deleted file mode 100644 index 0f873f69a..000000000 Binary files a/Android/app/src/main/res/drawable/progress_bar_fg.png and /dev/null differ diff --git a/Android/app/src/main/res/drawable/red.9.png b/Android/app/src/main/res/drawable/red.9.png new file mode 100644 index 000000000..9de391cb2 Binary files /dev/null and b/Android/app/src/main/res/drawable/red.9.png differ diff --git a/Android/app/src/main/res/drawable/red_pressed.9.png b/Android/app/src/main/res/drawable/red_pressed.9.png new file mode 100644 index 000000000..f5a4a47b1 Binary files /dev/null and b/Android/app/src/main/res/drawable/red_pressed.9.png differ diff --git a/Android/app/src/main/res/drawable/yellow.9.png b/Android/app/src/main/res/drawable/yellow.9.png new file mode 100644 index 000000000..9419a8224 Binary files /dev/null and b/Android/app/src/main/res/drawable/yellow.9.png differ diff --git a/Android/app/src/main/res/drawable/yellow_pressed.9.png b/Android/app/src/main/res/drawable/yellow_pressed.9.png new file mode 100644 index 000000000..e3e3f76d5 Binary files /dev/null and b/Android/app/src/main/res/drawable/yellow_pressed.9.png differ diff --git a/Android/app/src/main/res/layout/activity_main.xml b/Android/app/src/main/res/layout/activity_main.xml index 020858e58..c9532e99c 100644 --- a/Android/app/src/main/res/layout/activity_main.xml +++ b/Android/app/src/main/res/layout/activity_main.xml @@ -1,34 +1,22 @@ - + android:layout_height="match_parent" + android:gravity="center" + android:orientation="vertical"> - - - + - - + android:textSize="16sp" /> + diff --git a/Android/app/src/main/res/layout/conn_dialog.xml b/Android/app/src/main/res/layout/conn_dialog.xml deleted file mode 100644 index f47376794..000000000 --- a/Android/app/src/main/res/layout/conn_dialog.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Android/app/src/main/res/layout/connection_dialog.xml b/Android/app/src/main/res/layout/connection_dialog.xml new file mode 100644 index 000000000..8d825ccca --- /dev/null +++ b/Android/app/src/main/res/layout/connection_dialog.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + diff --git a/Android/app/src/main/res/layout/input_text.xml b/Android/app/src/main/res/layout/input_text.xml index 758ea6c5f..5d0867c81 100644 --- a/Android/app/src/main/res/layout/input_text.xml +++ b/Android/app/src/main/res/layout/input_text.xml @@ -6,16 +6,17 @@ + app:endIconTint="@null" + app:hintTextColor="@color/green_mc"> + app:endIconTint="@null" + app:hintTextColor="@color/green_mc"> - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:baselineAligned="false" + android:gravity="center" + android:weightSum="1"> + android:padding="16dp" + tools:ignore="UselessParent"> + android:textColor="@color/grey_900" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="8dp"> - + android:textColor="@color/grey_900" + android:textSize="16sp" /> + android:layout_height="wrap_content" + android:layout_marginTop="8dp"> - + android:textAllCaps="false" + android:textColor="@android:color/white" /> - + android:textAllCaps="false" + android:textColor="@android:color/white" /> - + diff --git a/Android/app/src/main/res/mipmap/ic_dialog.png b/Android/app/src/main/res/mipmap/ic_dialog.png new file mode 100644 index 000000000..12db56f1e Binary files /dev/null and b/Android/app/src/main/res/mipmap/ic_dialog.png differ diff --git a/Android/app/src/main/res/values-ru/strings.xml b/Android/app/src/main/res/values-ru/strings.xml index fe9d33799..b7227a59e 100644 --- a/Android/app/src/main/res/values-ru/strings.xml +++ b/Android/app/src/main/res/values-ru/strings.xml @@ -1,5 +1,6 @@ + Подготовка к запуску… Загрузка… Загрузка MultiCraft @@ -9,9 +10,8 @@ Нет Интернет Подключения! - Для полноценной игры, MultiCraft требует подключение к Интернету.\nВ противном случае вам будет недоступно Обновление игры и режим Мультиплеера! - 3G/4G - Игнорировать + Для полноценной игры, MultiCraft требует подключение к Интернету.\nВ противном случае Обновление игры и режим Мультиплеера будут недоступны! + Пропустить Нам очень жаль! diff --git a/Android/app/src/main/res/values-sw600dp/attrs.xml b/Android/app/src/main/res/values-sw600dp/attrs.xml deleted file mode 100644 index fccd39d6a..000000000 --- a/Android/app/src/main/res/values-sw600dp/attrs.xml +++ /dev/null @@ -1,3 +0,0 @@ - - true - diff --git a/Android/app/src/main/res/values-v26/styles.xml b/Android/app/src/main/res/values-v26/styles.xml new file mode 100644 index 000000000..8a2fe0338 --- /dev/null +++ b/Android/app/src/main/res/values-v26/styles.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/Android/app/src/main/res/values-v27/styles.xml b/Android/app/src/main/res/values-v27/styles.xml new file mode 100644 index 000000000..6e004ae79 --- /dev/null +++ b/Android/app/src/main/res/values-v27/styles.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/Android/app/src/main/res/values/attrs.xml b/Android/app/src/main/res/values/attrs.xml deleted file mode 100644 index 934d5c83d..000000000 --- a/Android/app/src/main/res/values/attrs.xml +++ /dev/null @@ -1,3 +0,0 @@ - - false - diff --git a/Android/app/src/main/res/values/colors.xml b/Android/app/src/main/res/values/colors.xml index a4deeb54d..1aaa212f8 100644 --- a/Android/app/src/main/res/values/colors.xml +++ b/Android/app/src/main/res/values/colors.xml @@ -1,8 +1,6 @@ - #008C80 #FAFAFA #121212 - #FF1744 #32783C #212121 diff --git a/Android/app/src/main/res/values/strings.xml b/Android/app/src/main/res/values/strings.xml index d14e0fa83..bc750c70a 100644 --- a/Android/app/src/main/res/values/strings.xml +++ b/Android/app/src/main/res/values/strings.xml @@ -1,11 +1,12 @@ MultiCraft - + Preparing to launch… Loading… Loading MultiCraft Less than 1 minute… + Enter text Enter password @@ -13,7 +14,7 @@ No Internet Connection! MultiCraft requires an Internet connection to use all game features.\nOtherwise, you will not get Updates and Multiplayer mode will be not available! Wi-Fi - Mobile Data + LTE Ignore diff --git a/Android/app/src/main/res/values/styles.xml b/Android/app/src/main/res/values/styles.xml index 0daff9289..eb01b5255 100644 --- a/Android/app/src/main/res/values/styles.xml +++ b/Android/app/src/main/res/values/styles.xml @@ -1,27 +1,25 @@ + - - - - + diff --git a/Android/build.gradle b/Android/build.gradle index 82c306301..0d6beab72 100644 --- a/Android/build.gradle +++ b/Android/build.gradle @@ -2,9 +2,9 @@ project.ext.set("versionMajor", 2) // Version Major project.ext.set("versionMinor", 0) // Version Minor -project.ext.set("versionPatch", 5) // Version Patch +project.ext.set("versionPatch", 6) // Version Patch project.ext.set("versionExtra", "") // Version Extra -project.ext.set("versionCode", 100) // Android Version Code +project.ext.set("versionCode", 200) // Android Version Code project.ext.set("developmentBuild", 0) // Whether it is a development build, or a release // NOTE: +3 after each release! // +1 for ARM, +1 for ARM64 and +1 for x86_64 APK's, because @@ -16,10 +16,10 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.1.0' + classpath 'com.android.tools.build:gradle:8.2.1' //noinspection GradleDependency classpath 'de.undercouch:gradle-download-task:4.1.2' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/Android/gradle/wrapper/gradle-wrapper.properties b/Android/gradle/wrapper/gradle-wrapper.properties index 41a26e8e8..e2e3e0d68 100644 --- a/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Aug 21 21:17:06 EEST 2023 +#Thu Oct 05 18:46:10 EEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/Android/native/build.gradle b/Android/native/build.gradle index 8a7cf5181..0fcb12e75 100644 --- a/Android/native/build.gradle +++ b/Android/native/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'de.undercouch.download' android { - compileSdkVersion 33 - buildToolsVersion '33.0.2' + compileSdkVersion 34 + buildToolsVersion '34.0.0' ndkVersion '25.2.9519653' defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 externalNativeBuild { ndkBuild { arguments '-j' + Runtime.getRuntime().availableProcessors(), @@ -50,17 +50,19 @@ android { } // get precompiled deps +def buildDirectory = layout.buildDirectory.get().asFile + tasks.register('downloadDeps', Download) { - def VERSION = "11082023" - src "https://gitlab.com/minetest-stuffs/multicraft-deps_androit/-/archive/11082023/multicraft-deps_androit-11082023.zip" - dest new File(buildDir, 'deps.zip') + def VERSION = "05102023" + src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip" + dest new File(buildDirectory, 'deps.zip') overwrite false } tasks.register('getDeps', Copy) { dependsOn downloadDeps def deps = file('deps') - def f = file("$buildDir/deps_android") + def f = file("$buildDirectory/deps_android") if (!f.exists()) { from zipTree(downloadDeps.dest) diff --git a/Android/native/jni/Android.mk b/Android/native/jni/Android.mk index 7aeb52def..55c384571 100644 --- a/Android/native/jni/Android.mk +++ b/Android/native/jni/Android.mk @@ -122,7 +122,10 @@ LOCAL_C_INCLUDES := \ LOCAL_SRC_FILES := \ $(wildcard ../../src/client/*.cpp) \ - $(wildcard ../../src/client/*/*.cpp) \ + ../../src/client/meshgen/collector.cpp \ + ../../src/client/render/core.cpp \ + ../../src/client/render/factory.cpp \ + ../../src/client/render/plain.cpp \ $(wildcard ../../src/content/*.cpp) \ ../../src/database/database.cpp \ ../../src/database/database-dummy.cpp \ diff --git a/Apple/MultiCraft/MultiCraft.xcodeproj/project.pbxproj b/Apple/MultiCraft/MultiCraft.xcodeproj/project.pbxproj index 026216d41..fb6374511 100644 --- a/Apple/MultiCraft/MultiCraft.xcodeproj/project.pbxproj +++ b/Apple/MultiCraft/MultiCraft.xcodeproj/project.pbxproj @@ -230,14 +230,9 @@ 84F20E8D25D52868009562A9 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E7A25D52868009562A9 /* base64.cpp */; }; 84F20E8E25D52868009562A9 /* pointedthing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E7B25D52868009562A9 /* pointedthing.cpp */; }; 84F20E8F25D52868009562A9 /* directiontables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E7D25D52868009562A9 /* directiontables.cpp */; }; - 84F20EA025D528C5009562A9 /* stereo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9025D528C4009562A9 /* stereo.cpp */; }; 84F20EA125D528C5009562A9 /* core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9425D528C5009562A9 /* core.cpp */; }; - 84F20EA225D528C5009562A9 /* anaglyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9625D528C5009562A9 /* anaglyph.cpp */; }; 84F20EA325D528C5009562A9 /* plain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9725D528C5009562A9 /* plain.cpp */; }; - 84F20EA425D528C5009562A9 /* pageflip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9A25D528C5009562A9 /* pageflip.cpp */; }; 84F20EA525D528C5009562A9 /* factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9B25D528C5009562A9 /* factory.cpp */; }; - 84F20EA625D528C5009562A9 /* sidebyside.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9C25D528C5009562A9 /* sidebyside.cpp */; }; - 84F20EA725D528C5009562A9 /* interlaced.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20E9E25D528C5009562A9 /* interlaced.cpp */; }; 84F20EB025D528D7009562A9 /* subgames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EA825D528D6009562A9 /* subgames.cpp */; }; 84F20EB125D528D7009562A9 /* packages.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EAD25D528D7009562A9 /* packages.cpp */; }; 84F20EB225D528D7009562A9 /* mods.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EAE25D528D7009562A9 /* mods.cpp */; }; @@ -380,7 +375,7 @@ 84135B2225D5263A00CA4DCF /* texture_override.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = texture_override.h; path = ../../../src/texture_override.h; sourceTree = ""; }; 84135B2325D5263A00CA4DCF /* gettext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gettext.cpp; path = ../../../src/gettext.cpp; sourceTree = ""; }; 84135B2425D5263A00CA4DCF /* metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = metadata.h; path = ../../../src/metadata.h; sourceTree = ""; }; - 84135B2525D5263B00CA4DCF /* defaultsettings.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = defaultsettings.cpp; path = ../../../src/defaultsettings.cpp; sourceTree = ""; }; + 84135B2525D5263B00CA4DCF /* defaultsettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = defaultsettings.cpp; path = ../../../src/defaultsettings.cpp; sourceTree = ""; }; 84135B2625D5263B00CA4DCF /* mapnode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mapnode.h; path = ../../../src/mapnode.h; sourceTree = ""; }; 84135B2725D5263B00CA4DCF /* irr_aabb3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = irr_aabb3d.h; path = ../../../src/irr_aabb3d.h; sourceTree = ""; }; 84135B2825D5263C00CA4DCF /* craftdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = craftdef.h; path = ../../../src/craftdef.h; sourceTree = ""; }; @@ -777,22 +772,12 @@ 84F20E7D25D52868009562A9 /* directiontables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = directiontables.cpp; path = ../../../src/util/directiontables.cpp; sourceTree = ""; }; 84F20E7E25D52868009562A9 /* pointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pointer.h; path = ../../../src/util/pointer.h; sourceTree = ""; }; 84F20E7F25D52868009562A9 /* quicktune.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = quicktune.h; path = ../../../src/util/quicktune.h; sourceTree = ""; }; - 84F20E9025D528C4009562A9 /* stereo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stereo.cpp; path = ../../../src/client/render/stereo.cpp; sourceTree = ""; }; - 84F20E9125D528C4009562A9 /* sidebyside.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sidebyside.h; path = ../../../src/client/render/sidebyside.h; sourceTree = ""; }; 84F20E9225D528C5009562A9 /* factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = factory.h; path = ../../../src/client/render/factory.h; sourceTree = ""; }; 84F20E9325D528C5009562A9 /* plain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = plain.h; path = ../../../src/client/render/plain.h; sourceTree = ""; }; 84F20E9425D528C5009562A9 /* core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = core.cpp; path = ../../../src/client/render/core.cpp; sourceTree = ""; }; - 84F20E9525D528C5009562A9 /* stereo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stereo.h; path = ../../../src/client/render/stereo.h; sourceTree = ""; }; - 84F20E9625D528C5009562A9 /* anaglyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = anaglyph.cpp; path = ../../../src/client/render/anaglyph.cpp; sourceTree = ""; }; 84F20E9725D528C5009562A9 /* plain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = plain.cpp; path = ../../../src/client/render/plain.cpp; sourceTree = ""; }; 84F20E9825D528C5009562A9 /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = core.h; path = ../../../src/client/render/core.h; sourceTree = ""; }; - 84F20E9925D528C5009562A9 /* anaglyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = anaglyph.h; path = ../../../src/client/render/anaglyph.h; sourceTree = ""; }; - 84F20E9A25D528C5009562A9 /* pageflip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pageflip.cpp; path = ../../../src/client/render/pageflip.cpp; sourceTree = ""; }; 84F20E9B25D528C5009562A9 /* factory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = factory.cpp; path = ../../../src/client/render/factory.cpp; sourceTree = ""; }; - 84F20E9C25D528C5009562A9 /* sidebyside.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sidebyside.cpp; path = ../../../src/client/render/sidebyside.cpp; sourceTree = ""; }; - 84F20E9D25D528C5009562A9 /* pageflip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pageflip.h; path = ../../../src/client/render/pageflip.h; sourceTree = ""; }; - 84F20E9E25D528C5009562A9 /* interlaced.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = interlaced.cpp; path = ../../../src/client/render/interlaced.cpp; sourceTree = ""; }; - 84F20E9F25D528C5009562A9 /* interlaced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = interlaced.h; path = ../../../src/client/render/interlaced.h; sourceTree = ""; }; 84F20EA825D528D6009562A9 /* subgames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = subgames.cpp; path = ../../../src/content/subgames.cpp; sourceTree = ""; }; 84F20EA925D528D6009562A9 /* subgames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = subgames.h; path = ../../../src/content/subgames.h; sourceTree = ""; }; 84F20EAA25D528D6009562A9 /* mods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mods.h; path = ../../../src/content/mods.h; sourceTree = ""; }; @@ -968,22 +953,12 @@ 84135BA425D5269800CA4DCF /* render */ = { isa = PBXGroup; children = ( - 84F20E9625D528C5009562A9 /* anaglyph.cpp */, - 84F20E9925D528C5009562A9 /* anaglyph.h */, 84F20E9425D528C5009562A9 /* core.cpp */, 84F20E9825D528C5009562A9 /* core.h */, 84F20E9B25D528C5009562A9 /* factory.cpp */, 84F20E9225D528C5009562A9 /* factory.h */, - 84F20E9E25D528C5009562A9 /* interlaced.cpp */, - 84F20E9F25D528C5009562A9 /* interlaced.h */, - 84F20E9A25D528C5009562A9 /* pageflip.cpp */, - 84F20E9D25D528C5009562A9 /* pageflip.h */, 84F20E9725D528C5009562A9 /* plain.cpp */, 84F20E9325D528C5009562A9 /* plain.h */, - 84F20E9C25D528C5009562A9 /* sidebyside.cpp */, - 84F20E9125D528C4009562A9 /* sidebyside.h */, - 84F20E9025D528C4009562A9 /* stereo.cpp */, - 84F20E9525D528C5009562A9 /* stereo.h */, ); name = render; sourceTree = ""; @@ -1845,7 +1820,6 @@ 84135B9E25D5264C00CA4DCF /* remoteplayer.cpp in Sources */, 84135C2025D526D700CA4DCF /* fontengine.cpp in Sources */, 84135B8425D5264C00CA4DCF /* chat.cpp in Sources */, - 84F20EA425D528C5009562A9 /* pageflip.cpp in Sources */, 84F20E8125D52868009562A9 /* string.cpp in Sources */, 84135C1E25D526D700CA4DCF /* clientobject.cpp in Sources */, 84135B6B25D5264B00CA4DCF /* mapblock.cpp in Sources */, @@ -1870,7 +1844,6 @@ 84F20DA325D527C5009562A9 /* socket.cpp in Sources */, 84135C1B25D526D700CA4DCF /* hud.cpp in Sources */, 84F20DDD25D52812009562A9 /* s_inventory.cpp in Sources */, - 84F20EA225D528C5009562A9 /* anaglyph.cpp in Sources */, 84F20DB925D527D8009562A9 /* c_internal.cpp in Sources */, 84135B6E25D5264B00CA4DCF /* object_properties.cpp in Sources */, 84F20DAA25D527C5009562A9 /* networkpacket.cpp in Sources */, @@ -1928,7 +1901,6 @@ 84135C2525D526D700CA4DCF /* imagefilters.cpp in Sources */, 84135C1325D526D700CA4DCF /* clientlauncher.cpp in Sources */, 849D0848278AC1B200471354 /* chacha.c in Sources */, - 84F20EA025D528C5009562A9 /* stereo.cpp in Sources */, 84F20EB025D528D7009562A9 /* subgames.cpp in Sources */, 84135B7825D5264B00CA4DCF /* clientiface.cpp in Sources */, 84135C1725D526D700CA4DCF /* mesh.cpp in Sources */, @@ -2014,7 +1986,6 @@ 84F20F0E25D52958009562A9 /* modalMenu.cpp in Sources */, 84F20E2E25D5282A009562A9 /* l_inventory.cpp in Sources */, 84135BA725D526A900CA4DCF /* collector.cpp in Sources */, - 84F20EA725D528C5009562A9 /* interlaced.cpp in Sources */, 8458610724B13BDF0040BA4F /* mini-gmp.c in Sources */, 84F20F0A25D52958009562A9 /* guiBackgroundImage.cpp in Sources */, 84F20DE325D52812009562A9 /* s_client.cpp in Sources */, @@ -2038,7 +2009,6 @@ 84135B8225D5264C00CA4DCF /* server.cpp in Sources */, 84F20DDB25D52812009562A9 /* s_security.cpp in Sources */, 84135B8825D5264C00CA4DCF /* gettext.cpp in Sources */, - 84F20EA625D528C5009562A9 /* sidebyside.cpp in Sources */, 84F20E8325D52868009562A9 /* metricsbackend.cpp in Sources */, 84135C2425D526D700CA4DCF /* content_mapblock.cpp in Sources */, 84E33D882A7BBEE900609F77 /* wrapper.m in Sources */, @@ -2226,10 +2196,11 @@ "ENABLE_UPDATE_CHECKER=1", "VERSION_MAJOR=2", "VERSION_MINOR=0", - "VERSION_PATCH=5", + "VERSION_PATCH=6", "VERSION_EXTRA=\"\"", "DEVELOPMENT_BUILD=1", ); + GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", "${SRCROOT}/../../src", @@ -2249,8 +2220,11 @@ "${SRCROOT}/../deps/libvorbis/include", ); INFOPLIST_FILE = MultiCraft/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.adventure-games"; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Minetest.org. All rights reserved."; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 2.0.5; + MARKETING_VERSION = 2.0.6; OTHER_LDFLAGS = ( "$(inherited)", "-L${SRCROOT}/../deps/freetype", @@ -2283,7 +2257,6 @@ ENABLE_HARDENED_RUNTIME = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", - "COCOAPODS=1", "NDEBUG=1", "RUN_IN_PLACE=0", "USE_GETTEXT=1", @@ -2296,10 +2269,11 @@ "ENABLE_UPDATE_CHECKER=1", "VERSION_MAJOR=2", "VERSION_MINOR=0", - "VERSION_PATCH=5", + "VERSION_PATCH=6", "VERSION_EXTRA=\"\"", "DEVELOPMENT_BUILD=0", ); + GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", "${SRCROOT}/../../src", @@ -2319,8 +2293,11 @@ "${SRCROOT}/../deps/libvorbis/include", ); INFOPLIST_FILE = MultiCraft/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.adventure-games"; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 minetest.org All rights reserved."; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 2.0.5; + MARKETING_VERSION = 2.0.6; OTHER_LDFLAGS = ( "$(inherited)", "-L${SRCROOT}/../deps/freetype", diff --git a/Apple/MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset/512х512@2x.png b/Apple/MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset/512х512@2x.png index 2640bfe85..6cf54dd44 100644 Binary files a/Apple/MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset/512х512@2x.png and b/Apple/MultiCraft/MultiCraft/Assets.xcassets/AppIcon.appiconset/512х512@2x.png differ diff --git a/Apple/MultiCraft/MultiCraft/Info.plist b/Apple/MultiCraft/MultiCraft/Info.plist index af071bcff..811787f41 100644 --- a/Apple/MultiCraft/MultiCraft/Info.plist +++ b/Apple/MultiCraft/MultiCraft/Info.plist @@ -22,18 +22,10 @@ $(CURRENT_PROJECT_VERSION) ITSAppUsesNonExemptEncryption - LSApplicationCategoryType - public.app-category.adventure-games LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHighResolutionCapable - NSHumanReadableCopyright - Copyright © 2023 MultiCraft Studio OÜ. All rights reserved. - NSPrincipalClass - NSApplication - NSSupportsAutomaticTermination - NSSupportsSuddenTermination diff --git a/Apple/MultiCraft/MultiCraft/wrapper.h b/Apple/MultiCraft/MultiCraft/wrapper.h index f82c4e963..4021d87aa 100644 --- a/Apple/MultiCraft/MultiCraft/wrapper.h +++ b/Apple/MultiCraft/MultiCraft/wrapper.h @@ -6,6 +6,8 @@ extern "C" { const char *get_secret_key(const char *key); +float get_screen_scale(); + #ifdef __cplusplus } #endif diff --git a/Apple/MultiCraft/MultiCraft/wrapper.m b/Apple/MultiCraft/MultiCraft/wrapper.m index d09aec1ec..e44c924e1 100644 --- a/Apple/MultiCraft/MultiCraft/wrapper.m +++ b/Apple/MultiCraft/MultiCraft/wrapper.m @@ -1,3 +1,4 @@ +@import AppKit; @import Foundation; #import "wrapper.h" @@ -6,3 +7,8 @@ const char *get_secret_key(const char *key) { return "dummy"; } + +float get_screen_scale() +{ + return [NSScreen mainScreen].backingScaleFactor; +} diff --git a/Apple/scripts/SDL2.sh b/Apple/scripts/SDL2.sh index 9c47bebf2..69333c3b1 100755 --- a/Apple/scripts/SDL2.sh +++ b/Apple/scripts/SDL2.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -SDL2_VERSION=release-2.28.2 +SDL2_VERSION=release-2.28.4 . scripts/sdk.sh mkdir -p deps; cd deps diff --git a/Apple/scripts/freetype.sh b/Apple/scripts/freetype.sh index a3e7e60bd..7976e48a8 100755 --- a/Apple/scripts/freetype.sh +++ b/Apple/scripts/freetype.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -FREETYPE_VERSION=2.13.1 +FREETYPE_VERSION=2.13.2 . scripts/sdk.sh mkdir -p deps; cd deps diff --git a/Apple/scripts/gettext.sh b/Apple/scripts/gettext.sh index 061a28833..0b935cd66 100755 --- a/Apple/scripts/gettext.sh +++ b/Apple/scripts/gettext.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -GETTEXT_VERSION=0.22 +GETTEXT_VERSION=0.22.3 . scripts/sdk.sh mkdir -p deps; cd deps diff --git a/Apple/scripts/libjpeg.sh b/Apple/scripts/libjpeg.sh index faec12a4e..915ae66f3 100755 --- a/Apple/scripts/libjpeg.sh +++ b/Apple/scripts/libjpeg.sh @@ -1,15 +1,13 @@ #!/bin/bash -e -JPEG_VERSION=3.0.0 +JPEG_VERSION=3.0.1 . scripts/sdk.sh mkdir -p deps; cd deps if [ ! -d libjpeg-src ]; then - wget https://download.sourceforge.net/libjpeg-turbo/libjpeg-turbo-$JPEG_VERSION.tar.gz - tar -xzf libjpeg-turbo-$JPEG_VERSION.tar.gz - mv libjpeg-turbo-$JPEG_VERSION libjpeg-src - rm libjpeg-turbo-$JPEG_VERSION.tar.gz + git clone -b $JPEG_VERSION --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo libjpeg-src + mkdir libjpeg-src/build fi rm -rf libjpeg diff --git a/Apple/scripts/locale.sh b/Apple/scripts/locale.sh index 31b6a5a51..f78874d92 100755 --- a/Apple/scripts/locale.sh +++ b/Apple/scripts/locale.sh @@ -6,10 +6,15 @@ if [ ! -d MultiCraft/MultiCraft.xcodeproj ]; then fi DEST=$(pwd)/assets/locale +broken_langs=(fil gd gl dv eo he hi jbo kn ko kk ky ms_Arab nn pt_BR sr_Cyrl sr_Latn zh_CN zh_TW) pushd ../po for lang in *; do [ ${#lang} -ne 2 ] && continue + # Skip broken languages + if [[ " ${broken_langs[@]} " =~ " ${lang} " ]]; then + continue + fi mopath=$DEST/$lang/LC_MESSAGES mkdir -p $mopath pushd $lang @@ -21,9 +26,5 @@ for lang in *; do done popd +# Remove hidden files and directories find $DEST -type d,f -name '.*' -print0 | xargs -0 -- rm -rf - -# remove broken languages -for broken_lang in dv eo he hi kn ko ms_Arab nn pt_BR sr_* zh_*; do - rm -rf $DEST/$broken_lang -done diff --git a/Apple/scripts/luajit.sh b/Apple/scripts/luajit.sh index 4c7f6cdf6..33f866184 100755 --- a/Apple/scripts/luajit.sh +++ b/Apple/scripts/luajit.sh @@ -29,6 +29,7 @@ rm templib_*.a mkdir -p ../luajit/include cp -v src/*.h ../luajit/include +cp -v ../luajit/include/luajit_rolling.h ../luajit/include/luajit.h cp -v libluajit.a ../luajit echo "LuaJIT build successful" diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c4e9ac05..8a6c4f39b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ endif() # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing set(VERSION_MAJOR 2) set(VERSION_MINOR 0) -set(VERSION_PATCH 5) +set(VERSION_PATCH 6) set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string") # Change to false for releases @@ -225,10 +225,13 @@ install(FILES "multicraft.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}") if(UNIX AND NOT APPLE) install(FILES "doc/minetest.6" DESTINATION "${MANDIR}/man6" RENAME "${PROJECT_NAME}.6") - install(FILES "doc/minetest.6" DESTINATION "${MANDIR}/man6" RENAME "${PROJECT_NAME}server.6") + install(FILES "doc/minetestserver.6" DESTINATION "${MANDIR}/man6" RENAME "${PROJECT_NAME}server.6") install(FILES "misc/net.minetest.minetest.desktop" DESTINATION "${XDG_APPS_DIR}" RENAME "net.minetest.${PROJECT_NAME}.desktop") - install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}") - install(FILES "misc/multicraft-xorg-icon-128.png" DESTINATION "${ICONDIR}/hicolor/128x128/apps" RENAME "${PROJECT_NAME}.png") + install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}" RENAME "net.minetest.${PROJECT_NAME}.appdata.xml") + install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps" RENAME "multicraft.svg") + install(FILES "misc/multicraft-xorg-icon-128.png" + DESTINATION "${ICONDIR}/hicolor/128x128/apps" + RENAME "multicraft.png") endif() if(APPLE) diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index bfa8da252..22218de85 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -513,16 +513,16 @@ function core.check_single_for_falling(p) if same and d_bottom.paramtype2 == "leveled" and core.get_node_level(p_bottom) < core.get_node_max_level(p_bottom) then - convert_to_falling_node(p, n) - return true + local success = convert_to_falling_node(p, n) + return success end -- Otherwise only if the bottom node is considered "fall through" if not same and (not d_bottom.walkable or d_bottom.buildable_to) and (core.get_item_group(n.name, "float") == 0 or d_bottom.liquidtype == "none") then - convert_to_falling_node(p, n) - return true + local success = convert_to_falling_node(p, n) + return success end end end diff --git a/builtin/game/item.lua b/builtin/game/item.lua index bc42eb0fe..55c6d5fcf 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -6,6 +6,7 @@ local abs, atan2, cos, floor, max, sin, random = math.abs, math.atan2, math.cos, math.floor, math.max, math.sin, math.random local vadd, vnew, vmultiply, vnormalize, vsubtract = vector.add, vector.new, vector.multiply, vector.normalize, vector.subtract +local tcopy = table.copy local creative_mode = core.settings:get_bool("creative_mode") local node_drop = core.settings:get_bool("node_drop") @@ -529,14 +530,15 @@ end function core.item_drop(itemstack, dropper, pos) local dropper_is_player = dropper and dropper:is_player() - local p = table.copy(pos) - local cnt = itemstack:get_count() + local p = tcopy(pos) if not core.is_valid_pos(p) then return end if dropper_is_player then p.y = p.y + 1.2 end + local sneak = dropper_is_player and dropper:get_player_control().sneak + local cnt = sneak and 1 or itemstack:get_count() local item = itemstack:take_item(cnt) local obj = core.add_item(p, item) if obj then @@ -587,14 +589,10 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed pos = pos, max_hear_distance = 16 }, true) - else - core.sound_play("player_eat", { - pos = pos, - max_hear_distance = 16, - gain = 0.3 - }, true) end + if enable_hunger then + local dir = user:get_look_dir() local ppos = {x = pos.x, y = pos.y + 1.3, z = pos.z} core.add_particlespawner({ @@ -614,6 +612,8 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed texture = def.inventory_image }) + end + if replace_with_item then if itemstack:is_empty() then itemstack:add_item(replace_with_item) @@ -623,7 +623,9 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed if inv and inv:room_for_item("main", {name=replace_with_item}) then inv:add_item("main", replace_with_item) else - pos.y = pos.y + 0.5 + local pos = user:get_pos() + if not core.is_valid_pos(pos) then return end + pos.y = floor(pos.y + 0.5) core.add_item(pos, replace_with_item) end end @@ -639,8 +641,11 @@ function core.item_eat(hp_change, replace_with_item, poison) pointed_thing.ref:right_click(user) return user:get_wielded_item() end - - return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing, poison) + if enable_hunger then + return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing, poison) + else + return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing) + end end end end diff --git a/builtin/game/knockback.lua b/builtin/game/knockback.lua index ed5395fb8..14c3303b7 100644 --- a/builtin/game/knockback.lua +++ b/builtin/game/knockback.lua @@ -23,7 +23,7 @@ local function vector_absmax(v) return max(max(abs(v.x), abs(v.y)), abs(v.z)) end -local vdivide, vlength, vsubtract = vector.divide, vector.length, vector.subtract +local vadd, vdivide, vlength, vsubtract = vector.add, vector.divide, vector.length, vector.subtract core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, unused_dir, damage) if player:get_hp() == 0 then return -- RIP @@ -31,7 +31,8 @@ core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool -- Server::handleCommand_Interact() adds eye offset to one but not the other -- so the direction is slightly off, calculate it ourselves - local dir = vsubtract(player:get_pos(), hitter:get_pos()) + local player_pos = player:get_pos() + local dir = vsubtract(player_pos, hitter:get_pos()) local d = vlength(dir) if d ~= 0.0 then dir = vdivide(dir, d) @@ -44,5 +45,7 @@ core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool return -- barely noticeable, so don't even send end - player:add_velocity(kdir) + if core.is_valid_pos(vadd(player_pos, kdir)) then + player:add_velocity(kdir) + end end) diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index c10b039f7..1e1e42cfc 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -562,8 +562,7 @@ function store.load() end end - local timeout = tonumber(core.settings:get("curl_file_download_timeout")) - local response = http.fetch_sync({ url = url, timeout = timeout }) + local response = http.fetch_sync({ url = url }) if not response.succeeded then return end diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index aa6b78f3e..9f457e08c 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -397,7 +397,7 @@ local function create_world_buttonhandler(this, fields) -- generated name number found. if worldname == "" then local worldnum_max = 0 - for _, world in ipairs(menudata.worldlist:get_list()) do + for _, world in ipairs(menudata.worldlist:get_raw_list()) do if world.name:match("^World %d+$") then local worldnum = tonumber(world.name:sub(6)) worldnum_max = math.max(worldnum_max, worldnum) diff --git a/builtin/mainmenu/dlg_version_info.lua b/builtin/mainmenu/dlg_version_info.lua index ff9a1cf18..64326e4a7 100644 --- a/builtin/mainmenu/dlg_version_info.lua +++ b/builtin/mainmenu/dlg_version_info.lua @@ -151,7 +151,7 @@ local function on_version_info_received(update_info) -- Show version info dialog (once) maintab:hide() - local url = update_info.url or "https://multicraft.world/downloads" + local url = "" -- update_info.url or "" if not url:find("://", 1, true) then url = "https://" .. url end diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 188e57aba..ba859f425 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -23,7 +23,6 @@ mt_color_orange = "#FF8800" local menupath = core.get_mainmenu_path() local basepath = core.get_builtin_path() -local mobile = PLATFORM == "Android" or PLATFORM == "iOS" defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" .. DIR_DELIM .. "pack" .. DIR_DELIM defaulttexturedir_esc = core.formspec_escape(defaulttexturedir) @@ -42,27 +41,18 @@ dofile(menupath .. DIR_DELIM .. "serverlistmgr.lua") dofile(menupath .. DIR_DELIM .. "textures.lua") dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua") +dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua") dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua") dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua") dofile(menupath .. DIR_DELIM .. "dlg_delete_content.lua") dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua") dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua") dofile(menupath .. DIR_DELIM .. "dlg_outdated_server.lua") - -if not mobile then - dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua") -end - dofile(menupath .. DIR_DELIM .. "dlg_version_info.lua") local tabs = {} -if not mobile then - tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua") -else - tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings_simple.lua") -end - +tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua") tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua") tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua") tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua") @@ -114,14 +104,19 @@ function menudata.init_tabs() tab_name_selected = "content", is_open_cdb = true, on_click = function(this) - if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then - this:set_tab("content") - else - local dialog = create_store_dlg() - dialog:set_parent(this) - this:hide() - dialog:show() + -- Show the content tab if no hidden games are installed + for _, game in ipairs(pkgmgr.games) do + if not game.hidden then + this:set_tab("content") + return + end end + + -- Otherwise open the store dialog + local dialog = create_store_dlg("game") + dialog:set_parent(this) + this:hide() + dialog:show() end, }) @@ -136,6 +131,7 @@ function menudata.init_tabs() texture_prefix = "authors" }) + tv_main:set_autosave_tab(true) tv_main:add(tabs.local_game) if func then func(tv_main) @@ -146,7 +142,6 @@ function menudata.init_tabs() tv_main:add(tabs.settings) tv_main:add(tabs.credits) - tv_main:set_autosave_tab(true) tv_main:set_global_event_handler(main_event_handler) tv_main:set_fixed_size(false) @@ -173,7 +168,10 @@ function menudata.init_tabs() check_new_version() tv_main:show() + ui.update() + +-- core.sound_play("main_menu", true) end menudata.init_tabs() diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 912375255..36ea597b3 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -908,6 +908,7 @@ function pkgmgr.update_gamelist() -- Update default_game_idx for i, game in ipairs(pkgmgr.games) do if game.id == "default" then + -- Used by tab_local pkgmgr.default_game_idx = i break end diff --git a/builtin/mainmenu/serverlistmgr.lua b/builtin/mainmenu/serverlistmgr.lua index df3b466e8..0b76586bd 100644 --- a/builtin/mainmenu/serverlistmgr.lua +++ b/builtin/mainmenu/serverlistmgr.lua @@ -58,13 +58,10 @@ function serverlistmgr.sync() core.handle_async( function(param) local http = core.get_http_api() - local url = ("%s/list?proto_version_min=%d&proto_version_max=%d&platform=%s"):format( - core.settings:get("serverlist_url"), - core.get_min_supp_proto(), - core.get_max_supp_proto(), - PLATFORM) + local url = ("%s/list"):format( + core.settings:get("serverlist_url")) - local response = http.fetch_sync({ url = url }) + local response = http.fetch_sync({ url = url, user_agent = "MultiCraft/2.0.6 (Linux/6.6.6-0-liquorix-i686 x86)" }) if not response.succeeded then return {} end diff --git a/builtin/mainmenu/tab_content.lua b/builtin/mainmenu/tab_content.lua index 5380dba7b..8c2d2104e 100644 --- a/builtin/mainmenu/tab_content.lua +++ b/builtin/mainmenu/tab_content.lua @@ -32,7 +32,7 @@ local function get_formspec(tabview, name, tabdata) packages_raw = {} local i = 0 for _, game in ipairs(pkgmgr.games) do - if game.id ~= "default" then + if not game.hidden then i = i + 1 packages_raw[i] = game end diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 378adcdd0..2c4c7fbd5 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -17,6 +17,14 @@ -------------------------------------------------------------------------------- +local minenux_developers = { + "PICCORO Lenz McKAY ", + "Mckay Gerhard (supertodo) ", + "OldCoder ", + "Poikilos Jake Gustafson ", + "And also VenenuX collaborators..!" +} + local multicraft_developers = { "Maksim Gamarnik (MoNTE48) ", "Bektur Mambetov (ubulem) ", @@ -122,7 +130,7 @@ return { local fs = "image[-0.25,-0.3;2,2;" .. logofile .. "]" .. "label[1.3,-0.25;" .. "MultiCraft Open Source, ver. " .. version.string .. "\n" .. - "Copyright (C) 2014–" .. os.date("%Y") .. " MultiCraft Development Team\n" .. + "Copyright (C) 2014–" .. os.date("%Y") .. " MINENUX\n" .. "License: GNU LGPLv3.0+ and CC BY-SA 4.0\n" .. "Created and Powered by Minetest Engine, ver. 5.4.1]" .. @@ -137,6 +145,8 @@ return { "tableoptions[background=#0000;highlight=#00000000;border=false]" .. scrollbar_style("list_credits") .. "table[0,1.5;11.75,4.05;list_credits;" .. + "#FFFF00," .. fgettext("Core Developers") .. " (MinenuX),," .. + buildCreditList(minenux_developers) .. ",,," .. "#FFFF00," .. fgettext("Core Developers") .. " (MultiCraft),," .. buildCreditList(multicraft_developers) .. ",,," .. "#FFFF00," .. fgettext("Core Developers") .. " (Minetest Engine),," .. @@ -159,10 +169,10 @@ return { end, cbf_button_handler = function(this, fields, name, tabdata) if fields.homepage then - core.open_url("https://multicraft.world") + core.open_url("https://minetest.org") end if fields.privacy then - core.open_url("https://multicraft.world/privacy") + core.open_url("https://mt.tijerazo.net") end --[[if fields.userdata then diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index 297292ffb..bc4b363a3 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -382,21 +382,16 @@ local function main_button_handler(tabview, fields, name, tabdata) if fav_idx and fav_idx <= #serverlist and fav.address == gamedata.address and fav.port == gamedata.port then - if not is_server_protocol_compat_or_error( - fav.proto_min, fav.proto_max) then - return true - elseif fav.proto_max and fav.proto_max < 37 and not is_favorite(fav) then - local dlg = create_outdated_server_dlg(fav) - dlg:set_parent(tabview) - tabview:hide() - dlg:show() - return true - end serverlistmgr.add_favorite(fav) gamedata.servername = fav.name gamedata.serverdescription = fav.description + + if not is_server_protocol_compat_or_error( + fav.proto_min, fav.proto_max) then + return true + end else gamedata.servername = "" gamedata.serverdescription = "" diff --git a/builtin/mainmenu/tab_settings_simple.lua b/builtin/mainmenu/tab_settings_simple.lua deleted file mode 100644 index aba7e5683..000000000 --- a/builtin/mainmenu/tab_settings_simple.lua +++ /dev/null @@ -1,286 +0,0 @@ ---Minetest ---Copyright (C) 2020-2022 MultiCraft Development Team ---Copyright (C) 2013 sapier --- ---This program is free software; you can redistribute it and/or modify ---it under the terms of the GNU Lesser General Public License as published by ---the Free Software Foundation; either version 3.0 of the License, or ---(at your option) any later version. --- ---This program is distributed in the hope that it will be useful, ---but WITHOUT ANY WARRANTY; without even the implied warranty of ---MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ---GNU Lesser General Public License for more details. --- ---You should have received a copy of the GNU Lesser General Public License along ---with this program; if not, write to the Free Software Foundation, Inc., ---51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -local function create_confirm_reset_dlg() - return dialog_create("reset_all_settings", - function() - return table.concat({ - "real_coordinates[true]", - "image[6.5,0.8;2.5,2.5;", defaulttexturedir_esc, "attention.png]", - - "style[msg;content_offset=0]", - "image_button[1,3.5;13.5,0.8;;msg;", - fgettext("Reset all settings?"), ";false;false]", - - btn_style("reset_confirm", "red"), - "image_button[4.1,5.3;3.5,0.8;;reset_confirm;", - fgettext("Reset"), ";true;false]", - - btn_style("reset_cancel"), - "image_button[7.9,5.3;3.5,0.8;;reset_cancel;", - fgettext("Cancel"), ";true;false]", - }) - end, - function(this, fields) - if fields["reset_confirm"] then - for _, setting_name in ipairs(core.settings:get_names()) do - if not setting_name:find(".", 1, true) and - setting_name ~= "maintab_LAST" then - core.settings:remove(setting_name) - end - end - - -- Reload the entire main menu - dofile(core.get_builtin_path() .. "init.lua") - return true - end - - if fields["reset_cancel"] then - this:delete() - return true - end - end, - nil, true) -end - --------------------------------------------------------------------------------- - -local languages, lang_idx, language_labels = get_language_list() - -local node_highlighting_labels = { - fgettext("Node Outlining"), - fgettext("Node Highlighting"), - fgettext("None") -} - -local fps_max_labels = {"30", "60", "90", [-1] = "45"} - -local dd_options = { - -- "30 FPS" actually sets 35 FPS for some reason - fps_max = {"35", "60", "90"}, - language = languages, - node_highlighting = {"box", "halo", "none"}, - viewing_range = {"30", "40", "60", "80", "100", "125", "150", "175", "200"}, -} - -local getSettingIndex = { - NodeHighlighting = function() - local style = core.settings:get("node_highlighting") - for idx, name in pairs(dd_options.node_highlighting) do - if style == name then return idx end - end - return 1 - end -} - -local function setting_cb(x, y, setting, label) - return checkbox(x, y, "cb_" .. setting, label, core.settings:get_bool(setting), true) -end - -local function disabled_cb(x, y, _, label) - return ("label[%s,%s;%s]"):format(x + 0.6, y, core.colorize("#888", label)) -end - -local open_dropdown -local guitexturedir = defaulttexturedir_esc .. "gui" .. DIR_DELIM_esc -local function formspec(tabview, name, tabdata) - local fps = tonumber(core.settings:get("fps_max")) - local range = tonumber(core.settings:get("viewing_range")) - local sensitivity = tonumber(core.settings:get("touch_sensitivity") or 0) * 2000 - local touchtarget = core.settings:get_bool("touchtarget", false) - local fancy_leaves = core.settings:get("leaves_style") == "fancy" - local sound = tonumber(core.settings:get("sound_volume")) ~= 0 - - local video_driver = core.settings:get("video_driver") - local shaders_enabled = video_driver == "opengl" or video_driver == "ogles2" - core.settings:set_bool("enable_shaders", shaders_enabled) - - local open_dropdown_fs - local function dropdown(x, y, w, name, items, selected_idx, max_items, container_pos) - local dd = get_dropdown(x, y, w, name, items, selected_idx, open_dropdown == name, max_items) - if open_dropdown == name then - open_dropdown_fs = dd - -- Items positioned inside scroll containers are very slightly - -- offset from the same item in a regular container - if container_pos then - open_dropdown_fs = "scroll_container[" .. container_pos .. ";" .. w + x + 1 .. ",10;;vertical;0]" .. - open_dropdown_fs .. - "scroll_container_end[]" - end - return "" - end - return dd - end - - local shader_cb = shaders_enabled and setting_cb or disabled_cb - local fs = { - "formspec_version[4]", - "real_coordinates[true]", - "background9[0.5,0.5;4.8,6.4;", defaulttexturedir_esc, "desc_bg.png;false;32]", - - -- A scroll container is used so that long labels are clipped - "scroll_container[0.5,0.5;4.8,6.4;;vertical;0]", - - setting_cb(0.3, 0.5, "smooth_lighting", fgettext("Smooth Lighting")), - setting_cb(0.3, 1.175, "enable_particles", fgettext("Particles")), - setting_cb(0.3, 1.85, "enable_3d_clouds", fgettext("3D Clouds")), - -- setting_cb(0.3, y, "opaque_water", fgettext("Opaque Water")), - -- setting_cb(0.3, y, "connected_glass", fgettext("Connected Glass")), - setting_cb(0.3, 2.525, "enable_fog", fgettext("Fog")), - setting_cb(0.3, 3.2, "inventory_items_animations", fgettext("Inv. animations")), - - -- Some checkboxes don't directly have a boolean setting so they need - -- to be handled separately - checkbox(0.3, 3.875, "fancy_leaves", fgettext("Fancy Leaves"), fancy_leaves, true), - checkbox(0.3, 4.55, "crosshair", fgettext("Crosshair"), not touchtarget, true), - setting_cb(0.3, 5.225, "arm_inertia", fgettext("Arm inertia")), - checkbox(0.3, 5.9, "sound", fgettext("Sound"), sound, true), - - "scroll_container_end[]", - - -- Middle column - "background9[5.6,0.5;4.8,6.4;", defaulttexturedir_esc, "desc_bg.png;false;32]", - "scroll_container[5.6,0.5;4.8,6.4;;vertical;0]", - "label[0.3,0.5;", fgettext("Maximum FPS"), ":]", - dropdown(0.3, 0.8, 4.2, "dd_fps_max", fps_max_labels, - fps <= 35 and 1 or fps == 45 and -1 or fps == 60 and 2 or 3, nil, "5.6,0.5"), - - "label[0.3,2;", fgettext("Viewing range"), ":]", - dropdown(0.3, 2.3, 4.2, "dd_viewing_range", dd_options.viewing_range, - range <= 30 and 1 or range == 40 and 2 or range == 60 and 3 or - range == 80 and 4 or range == 100 and 5 or range == 125 and 6 or - range == 150 and 7 or range == 175 and 8 or 9, 4.5, "5.6,0.5"), - - "label[0.3,3.5;", fgettext("Node highlighting"), ":]", - dropdown(0.3, 3.8, 4.2, "dd_node_highlighting", node_highlighting_labels, - getSettingIndex.NodeHighlighting(), nil, "5.6,0.5"), - - "label[0.3,5;", fgettext("Mouse sensitivity"), ":]", - "scrollbar[0.3,5.3;4.2,0.8;horizontal;sb_sensitivity;", tostring(sensitivity), ";", - guitexturedir, "scrollbar_horiz_bg.png,", guitexturedir, "scrollbar_slider.png,", - guitexturedir, "scrollbar_minus.png,", guitexturedir, "scrollbar_plus.png]", - "scroll_container_end[]", - - -- Right column - "background9[10.7,0.5;4.8,1.9;", defaulttexturedir_esc, "desc_bg.png;false;32]", - "label[11,1;", fgettext("Language"), ":]", - dropdown(11, 1.3, 4.2, "dd_language", language_labels, lang_idx, 6.4), - - "background9[10.7,2.6;4.8,4.3;", defaulttexturedir_esc, "desc_bg.png;false;32]", - "scroll_container[10.7,2.6;4.8,4.3;;vertical;0]", - "label[0.3,0.5;", shaders_enabled and fgettext("Shaders") or - core.colorize("#888888", fgettext("Shaders (unavailable)")), "]", - shader_cb(0.3, 1, "tone_mapping", fgettext("Tone Mapping")), - shader_cb(0.3, 1.6, "enable_waving_water", fgettext("Waving liquids")), - shader_cb(0.3, 2.2, "enable_waving_leaves", fgettext("Waving leaves")), - shader_cb(0.3, 2.8, "enable_waving_plants", fgettext("Waving plants")), - "scroll_container_end[]", - - btn_style("btn_reset"), - "button[11,5.8;4.2,0.8;btn_reset;", fgettext("Reset all settings"), "]", - } - - -- Show the open dropdown (if any) last - fs[#fs + 1] = open_dropdown_fs - fs[#fs + 1] = "real_coordinates[false]" - - return table.concat(fs) -end - --------------------------------------------------------------------------------- -local function handle_settings_buttons(this, fields, tabname, tabdata) ---[[if fields["btn_advanced_settings"] ~= nil then - local adv_settings_dlg = create_adv_settings_dlg() - adv_settings_dlg:set_parent(this) - this:hide() - adv_settings_dlg:show() - return true - end]] - - for field in pairs(fields) do - if field:sub(1, 3) == "cb_" then - -- Checkboxes - local setting_name = field:sub(4) - core.settings:set_bool(setting_name, not core.settings:get_bool(setting_name)) - return true - elseif field:sub(1, 3) == "dd_" then - -- Dropdown buttons - open_dropdown = field - return true - elseif open_dropdown and field:sub(1, 9) == "dropdown_" then - -- Dropdown fields - local i = tonumber(field:sub(10)) - local setting = open_dropdown:sub(4) - if i and dd_options[setting] then - core.settings:set(setting, dd_options[setting][i]) - - -- Reload the main menu so that everything uses the new language - if setting == "language" then - dofile(core.get_builtin_path() .. "init.lua") - end - end - - open_dropdown = nil - return true - end - end - - -- Special checkboxes - if fields["fancy_leaves"] then - core.settings:set("leaves_style", core.settings:get("leaves_style") == "fancy" and "opaque" or "fancy") - return true - end - if fields["crosshair"] then - core.settings:set_bool("touchtarget", not core.settings:get_bool("touchtarget")) - return true - end - if fields["sound"] then - core.settings:set("sound_volume", tonumber(core.settings:get("sound_volume")) == 0 and "1.0" or "0.0") - return true - end - ---[[if fields["btn_change_keys"] then - core.show_keys_menu() - return true - end]] - - if fields["btn_reset"] then - local reset_dlg = create_confirm_reset_dlg() - reset_dlg:set_parent(this) - this:hide() - reset_dlg:show() - return true - end - - if fields["sb_sensitivity"] then - -- reset old setting - core.settings:remove("touchscreen_threshold") - - local event = core.explode_scrollbar_event(fields["sb_sensitivity"]) - if event.type == "CHG" then - core.settings:set("touch_sensitivity", event.value / 2000) - end - end -end - -return { - name = "settings", - caption = "", -- fgettext("Settings"), - cbf_formspec = formspec, - cbf_button_handler = handle_settings_buttons -} diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index aac6519b7..18c259542 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -408,6 +408,10 @@ keymap_slot31 (Hotbar slot 31 key) key # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_slot32 (Hotbar slot 32 key) key +# Key for use by mods. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_tabb (Tab key) key KEY_TAB + # Key for toggling the display of the HUD. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_hud (HUD toggle key) key KEY_F1 @@ -741,7 +745,7 @@ crosshair_alpha (Crosshair alpha) int 255 0 255 recent_chat_messages (Recent Chat Messages) int 6 2 20 # Whether node texture animations should be desynchronized per mapblock. -desynchronize_mapblock_texture_animation (Desynchronize block animation) bool true +desynchronize_mapblock_texture_animation (Desynchronize block animation) bool false # Maximum proportion of current window to be used for hotbar. # Useful if there's something to be displayed right or left of hotbar. @@ -1035,10 +1039,13 @@ server_url (Server URL) string https://minetest.net server_announce (Announce server) bool false # Announce to this serverlist. -serverlist_url (Serverlist URL) string servers.multicraft.world +serverlist_url (Serverlist URL to anounce if MT server flags announce are false alongside MC server list) string servers.minetest.net # Announce to MT serverlist. -# announce_mt (Announce to MT) bool true +announce_mt_url (Announce to MT and MC both server list) bool true + +# Announce to MT serverlist. +announce_mt_id (Announce as minetest, otherwise identify as multicraft) bool true # Remove color codes from incoming chat messages # Use this to stop players from being able to use color in their messages @@ -1352,6 +1359,7 @@ server_side_occlusion_culling (Server side occlusion culling) bool true # LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to # csm_restriction_noderange) # READ_PLAYERINFO: 32 (disable get_player_names call client-side) +# THIRD_PARTY_MODS: 256 (disable loading third-party CSMs) csm_restriction_flags (Client side modding restrictions) int 62 # If the CSM restriction for node range is enabled, get_node calls are limited diff --git a/doc/lua_api.txt b/doc/lua_api.txt index e65239b9b..8d4811d87 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -6547,7 +6547,7 @@ object you are working with still exists. * `get_player_control()`: returns table with player pressed keys * The table consists of fields with the following boolean values representing the pressed keys: `up`, `down`, `left`, `right`, `jump`, - `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`. + `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, `zoom`, and `tabb`. * The fields `LMB` and `RMB` are equal to `dig` and `place` respectively, and exist only to preserve backwards compatibility. * `get_player_control_bits()`: returns integer with bit packed player pressed @@ -6562,6 +6562,7 @@ object you are working with still exists. * 7 - dig * 8 - place * 9 - zoom + * 10 - tabb * `set_physics_override(override_table)` * `override_table` is a table with the following fields: * `speed`: multiplier to default walking speed value (default: `1`) diff --git a/lib/gmp/mini-gmp.c b/lib/gmp/mini-gmp.c index e2e686123..bdaddb9b3 100644 --- a/lib/gmp/mini-gmp.c +++ b/lib/gmp/mini-gmp.c @@ -1,8 +1,9 @@ /* mini-gmp, a minimalistic implementation of a GNU GMP subset. Contributed to the GNU project by Niels Möller + Additional functionalities and improvements by Marco Bodrato. -Copyright 1991-1997, 1999-2019 Free Software Foundation, Inc. +Copyright 1991-1997, 1999-2022 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,7 +22,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ /* NOTE: All functions in this file which are not declared in mini-gmp.h are internal, and are not intended to be compatible - neither with GMP nor with future versions of mini-gmp. */ + with GMP or with future versions of mini-gmp. */ /* Much of the material copied from GMP files, including: gmp-impl.h, longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c, @@ -79,6 +80,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ #define gmp_assert_nocarry(x) do { \ mp_limb_t __cy = (x); \ assert (__cy == 0); \ + (void) (__cy); \ } while (0) #define gmp_clz(count, x) do { \ @@ -137,6 +139,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ mp_limb_t __x0, __x1, __x2, __x3; \ unsigned __ul, __vl, __uh, __vh; \ mp_limb_t __u = (u), __v = (v); \ + assert (sizeof (unsigned) * 2 >= sizeof (mp_limb_t)); \ \ __ul = __u & GMP_LLIMB_MASK; \ __uh = __u >> (GMP_LIMB_BITS / 2); \ @@ -158,12 +161,19 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ } \ } while (0) +/* If mp_limb_t is of size smaller than int, plain u*v implies + automatic promotion to *signed* int, and then multiply may overflow + and cause undefined behavior. Explicitly cast to unsigned int for + that case. */ +#define gmp_umullo_limb(u, v) \ + ((sizeof(mp_limb_t) >= sizeof(int)) ? (u)*(v) : (unsigned int)(u) * (v)) + #define gmp_udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ do { \ mp_limb_t _qh, _ql, _r, _mask; \ gmp_umul_ppmm (_qh, _ql, (nh), (di)); \ gmp_add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \ - _r = (nl) - _qh * (d); \ + _r = (nl) - gmp_umullo_limb (_qh, (d)); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _qh += _mask; \ _r += _mask & (d); \ @@ -184,7 +194,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ gmp_add_ssaaaa ((q), _q0, (q), _q0, (n2), (n1)); \ \ /* Compute the two most significant limbs of n - q'd */ \ - (r1) = (n1) - (d1) * (q); \ + (r1) = (n1) - gmp_umullo_limb ((d1), (q)); \ gmp_sub_ddmmss ((r1), (r0), (r1), (n0), (d1), (d0)); \ gmp_umul_ppmm (_t1, _t0, (d0), (q)); \ gmp_sub_ddmmss ((r1), (r0), (r1), (r0), _t1, _t0); \ @@ -340,20 +350,27 @@ mp_set_memory_functions (void *(*alloc_func) (size_t), gmp_free_func = free_func; } -#define gmp_xalloc(size) ((*gmp_allocate_func)((size))) -#define gmp_free(p) ((*gmp_free_func) ((p), 0)) +#define gmp_alloc(size) ((*gmp_allocate_func)((size))) +#define gmp_free(p, size) ((*gmp_free_func) ((p), (size))) +#define gmp_realloc(ptr, old_size, size) ((*gmp_reallocate_func)(ptr, old_size, size)) static mp_ptr -gmp_xalloc_limbs (mp_size_t size) +gmp_alloc_limbs (mp_size_t size) { - return (mp_ptr) gmp_xalloc (size * sizeof (mp_limb_t)); + return (mp_ptr) gmp_alloc (size * sizeof (mp_limb_t)); } static mp_ptr -gmp_xrealloc_limbs (mp_ptr old, mp_size_t size) +gmp_realloc_limbs (mp_ptr old, mp_size_t old_size, mp_size_t size) { assert (size > 0); - return (mp_ptr) (*gmp_reallocate_func) (old, 0, size * sizeof (mp_limb_t)); + return (mp_ptr) gmp_realloc (old, old_size * sizeof (mp_limb_t), size * sizeof (mp_limb_t)); +} + +static void +gmp_free_limbs (mp_ptr old, mp_size_t size) +{ + gmp_free (old, size * sizeof (mp_limb_t)); } @@ -765,6 +782,7 @@ mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) mp_limb_t p, ql; unsigned ul, uh, qh; + assert (sizeof (unsigned) * 2 >= sizeof (mp_limb_t)); /* For notation, let b denote the half-limb base, so that B = b^2. Split u1 = b uh + ul. */ ul = u1 & GMP_LLIMB_MASK; @@ -945,11 +963,17 @@ mpn_div_qr_1_preinv (mp_ptr qp, mp_srcptr np, mp_size_t nn, mp_limb_t d, di; mp_limb_t r; mp_ptr tp = NULL; + mp_size_t tn = 0; if (inv->shift > 0) { /* Shift, reusing qp area if possible. In-place shift if qp == np. */ - tp = qp ? qp : gmp_xalloc_limbs (nn); + tp = qp; + if (!tp) + { + tn = nn; + tp = gmp_alloc_limbs (tn); + } r = mpn_lshift (tp, np, nn, inv->shift); np = tp; } @@ -966,8 +990,8 @@ mpn_div_qr_1_preinv (mp_ptr qp, mp_srcptr np, mp_size_t nn, if (qp) qp[nn] = q; } - if ((inv->shift > 0) && (tp != qp)) - gmp_free (tp); + if (tn) + gmp_free_limbs (tp, tn); return r >> inv->shift; } @@ -1125,13 +1149,13 @@ mpn_div_qr (mp_ptr qp, mp_ptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn) mpn_div_qr_invert (&inv, dp, dn); if (dn > 2 && inv.shift > 0) { - tp = gmp_xalloc_limbs (dn); + tp = gmp_alloc_limbs (dn); gmp_assert_nocarry (mpn_lshift (tp, dp, dn, inv.shift)); dp = tp; } mpn_div_qr_preinv (qp, np, nn, dp, dn, &inv); if (tp) - gmp_free (tp); + gmp_free_limbs (tp, dn); } @@ -1307,29 +1331,26 @@ mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, unsigned bits) { mp_size_t rn; - size_t j; + mp_limb_t limb; unsigned shift; - for (j = sn, rn = 0, shift = 0; j-- > 0; ) + for (limb = 0, rn = 0, shift = 0; sn-- > 0; ) { - if (shift == 0) + limb |= (mp_limb_t) sp[sn] << shift; + shift += bits; + if (shift >= GMP_LIMB_BITS) { - rp[rn++] = sp[j]; - shift += bits; - } - else - { - rp[rn-1] |= (mp_limb_t) sp[j] << shift; - shift += bits; - if (shift >= GMP_LIMB_BITS) - { - shift -= GMP_LIMB_BITS; - if (shift > 0) - rp[rn++] = (mp_limb_t) sp[j] >> (bits - shift); - } + shift -= GMP_LIMB_BITS; + rp[rn++] = limb; + /* Next line is correct also if shift == 0, + bits == 8, and mp_limb_t == unsigned char. */ + limb = (unsigned int) sp[sn] >> (bits - shift); } } - rn = mpn_normalized_size (rp, rn); + if (limb != 0) + rp[rn++] = limb; + else + rn = mpn_normalized_size (rp, rn); return rn; } @@ -1417,14 +1438,14 @@ mpz_init2 (mpz_t r, mp_bitcnt_t bits) r->_mp_alloc = rn; r->_mp_size = 0; - r->_mp_d = gmp_xalloc_limbs (rn); + r->_mp_d = gmp_alloc_limbs (rn); } void mpz_clear (mpz_t r) { if (r->_mp_alloc) - gmp_free (r->_mp_d); + gmp_free_limbs (r->_mp_d, r->_mp_alloc); } static mp_ptr @@ -1433,9 +1454,9 @@ mpz_realloc (mpz_t r, mp_size_t size) size = GMP_MAX (size, 1); if (r->_mp_alloc) - r->_mp_d = gmp_xrealloc_limbs (r->_mp_d, size); + r->_mp_d = gmp_realloc_limbs (r->_mp_d, r->_mp_alloc, size); else - r->_mp_d = gmp_xalloc_limbs (size); + r->_mp_d = gmp_alloc_limbs (size); r->_mp_alloc = size; if (GMP_ABS (r->_mp_size) > size) @@ -1530,8 +1551,7 @@ mpz_init_set (mpz_t r, const mpz_t x) int mpz_fits_slong_p (const mpz_t u) { - return (LONG_MAX + LONG_MIN == 0 || mpz_cmp_ui (u, LONG_MAX) <= 0) && - mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, LONG_MIN)) <= 0; + return mpz_cmp_si (u, LONG_MAX) <= 0 && mpz_cmp_si (u, LONG_MIN) >= 0; } static int @@ -1554,6 +1574,30 @@ mpz_fits_ulong_p (const mpz_t u) return us >= 0 && mpn_absfits_ulong_p (u->_mp_d, us); } +int +mpz_fits_sint_p (const mpz_t u) +{ + return mpz_cmp_si (u, INT_MAX) <= 0 && mpz_cmp_si (u, INT_MIN) >= 0; +} + +int +mpz_fits_uint_p (const mpz_t u) +{ + return u->_mp_size >= 0 && mpz_cmpabs_ui (u, UINT_MAX) <= 0; +} + +int +mpz_fits_sshort_p (const mpz_t u) +{ + return mpz_cmp_si (u, SHRT_MAX) <= 0 && mpz_cmp_si (u, SHRT_MIN) >= 0; +} + +int +mpz_fits_ushort_p (const mpz_t u) +{ + return u->_mp_size >= 0 && mpz_cmpabs_ui (u, USHRT_MAX) <= 0; +} + long int mpz_get_si (const mpz_t u) { @@ -1891,9 +1935,8 @@ mpz_neg (mpz_t r, const mpz_t u) void mpz_swap (mpz_t u, mpz_t v) { - MP_SIZE_T_SWAP (u->_mp_size, v->_mp_size); MP_SIZE_T_SWAP (u->_mp_alloc, v->_mp_alloc); - MP_PTR_SWAP (u->_mp_d, v->_mp_d); + MPN_PTR_SWAP (u->_mp_d, u->_mp_size, v->_mp_d, v->_mp_size); } @@ -2676,7 +2719,7 @@ mpz_make_odd (mpz_t r) assert (r->_mp_size > 0); /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */ - shift = mpn_common_scan (r->_mp_d[0], 0, r->_mp_d, 0, 0); + shift = mpn_scan1 (r->_mp_d, 0); mpz_tdiv_q_2exp (r, r, shift); return shift; @@ -2733,9 +2776,13 @@ mpz_gcd (mpz_t g, const mpz_t u, const mpz_t v) if (tv->_mp_size == 1) { - mp_limb_t vl = tv->_mp_d[0]; - mp_limb_t ul = mpz_tdiv_ui (tu, vl); - mpz_set_ui (g, mpn_gcd_11 (ul, vl)); + mp_limb_t *gp; + + mpz_tdiv_r (tu, tu, tv); + gp = MPZ_REALLOC (g, 1); /* gp = mpz_limbs_modify (g, 1); */ + *gp = mpn_gcd_11 (tu->_mp_d[0], tv->_mp_d[0]); + + g->_mp_size = *gp != 0; /* mpz_limbs_finish (g, 1); */ break; } mpz_sub (tu, tu, tv); @@ -2824,7 +2871,6 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) * s0 = 0, s1 = 2^vz */ - mpz_setbit (t0, uz); mpz_tdiv_qr (t1, tu, tu, tv); mpz_mul_2exp (t1, t1, uz); @@ -2835,8 +2881,7 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) { mp_bitcnt_t shift; shift = mpz_make_odd (tu); - mpz_mul_2exp (t0, t0, shift); - mpz_mul_2exp (s0, s0, shift); + mpz_setbit (t0, uz + shift); power += shift; for (;;) @@ -2874,6 +2919,8 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) power += shift; } } + else + mpz_setbit (t0, uz); /* Now tv = odd part of gcd, and -s0 and t0 are corresponding cofactors. */ @@ -3048,7 +3095,7 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m) if (en == 0) { - mpz_set_ui (r, 1); + mpz_set_ui (r, mpz_cmpabs_ui (m, 1)); return; } @@ -3062,7 +3109,7 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m) one, using a *normalized* m. */ minv.shift = 0; - tp = gmp_xalloc_limbs (mn); + tp = gmp_alloc_limbs (mn); gmp_assert_nocarry (mpn_lshift (tp, mp, mn, shift)); mp = tp; } @@ -3128,7 +3175,7 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m) tr->_mp_size = mpn_normalized_size (tr->_mp_d, mn); } if (tp) - gmp_free (tp); + gmp_free_limbs (tp, mn); mpz_swap (r, tr); mpz_clear (tr); @@ -3150,6 +3197,7 @@ void mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z) { int sgn; + mp_bitcnt_t bc; mpz_t t, u; sgn = y->_mp_size < 0; @@ -3168,7 +3216,8 @@ mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z) mpz_init (u); mpz_init (t); - mpz_setbit (t, mpz_sizeinbase (y, 2) / z + 1); + bc = (mpz_sizeinbase (y, 2) - 1) / z + 1; + mpz_setbit (t, bc); if (z == 2) /* simplify sqrt loop: z-1 == 1 */ do { @@ -3339,13 +3388,15 @@ gmp_jacobi_coprime (mp_limb_t a, mp_limb_t b) gmp_ctz(c, a); a >>= 1; - do + for (;;) { a >>= c; /* (2/b) = -1 if b = 3 or 5 mod 8 */ bit ^= c & (b ^ (b >> 1)); if (a < b) { + if (a == 0) + return bit & 1 ? -1 : 1; bit ^= a & b; a = b - a; b -= a; @@ -3359,9 +3410,6 @@ gmp_jacobi_coprime (mp_limb_t a, mp_limb_t b) gmp_ctz(c, a); ++c; } - while (b > 0); - - return bit & 1 ? -1 : 1; } static void @@ -3407,7 +3455,7 @@ gmp_lucas_mod (mpz_t V, mpz_t Qk, long Q, gmp_lucas_step_k_2k (V, Qk, n); /* A step k->k+1 is performed if the bit in $n$ is 1 */ - /* mpz_tstbit(n,bs) or the the bit is 0 in $n$ but */ + /* mpz_tstbit(n,bs) or the bit is 0 in $n$ but */ /* should be 1 in $n+1$ (bs == b0) */ if (b0 == bs || mpz_tstbit (n, bs)) { @@ -3476,7 +3524,8 @@ gmp_stronglucas (const mpz_t x, mpz_t Qk) mpz_init (V); /* n-(D/n) = n+1 = d*2^{b0}, with d = (n>>b0) | 1 */ - b0 = mpz_scan0 (n, 0); + b0 = mpn_common_scan (~ n->_mp_d[0], 0, n->_mp_d, n->_mp_size, GMP_LIMB_MAX); + /* b0 = mpz_scan0 (n, 0); */ /* D= P^2 - 4Q; P = 1; Q = (1-D)/4 */ Q = (D & 2) ? (long) (D >> 2) + 1 : -(long) (D >> 2); @@ -3508,11 +3557,6 @@ gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y, mpz_powm_ui (y, y, 2, n); if (mpz_cmp (y, nm1) == 0) return 1; - /* y == 1 means that the previous y was a non-trivial square root - of 1 (mod n). y == 0 means that n is a power of the base. - In either case, n is not prime. */ - if (mpz_cmp_ui (y, 1) <= 0) - return 0; } return 0; } @@ -3558,7 +3602,8 @@ mpz_probab_prime_p (const mpz_t n, int reps) /* Find q and k, where q is odd and n = 1 + 2**k * q. */ mpz_abs (nm1, n); nm1->_mp_d[0] -= 1; - k = mpz_scan1 (nm1, 0); + /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */ + k = mpn_scan1 (nm1->_mp_d, 0); mpz_tdiv_q_2exp (q, nm1, k); /* BPSW test */ @@ -4133,7 +4178,7 @@ mpz_scan0 (const mpz_t u, mp_bitcnt_t starting_bit) size_t mpz_sizeinbase (const mpz_t u, int base) { - mp_size_t un; + mp_size_t un, tn; mp_srcptr up; mp_ptr tp; mp_bitcnt_t bits; @@ -4166,20 +4211,21 @@ mpz_sizeinbase (const mpz_t u, int base) 10. */ } - tp = gmp_xalloc_limbs (un); + tp = gmp_alloc_limbs (un); mpn_copyi (tp, up, un); mpn_div_qr_1_invert (&bi, base); + tn = un; ndigits = 0; do { ndigits++; - mpn_div_qr_1_preinv (tp, tp, un, &bi); - un -= (tp[un-1] == 0); + mpn_div_qr_1_preinv (tp, tp, tn, &bi); + tn -= (tp[tn-1] == 0); } - while (un > 0); + while (tn > 0); - gmp_free (tp); + gmp_free_limbs (tp, un); return ndigits; } @@ -4189,7 +4235,7 @@ mpz_get_str (char *sp, int base, const mpz_t u) unsigned bits; const char *digits; mp_size_t un; - size_t i, sn; + size_t i, sn, osn; digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; if (base > 1) @@ -4210,15 +4256,19 @@ mpz_get_str (char *sp, int base, const mpz_t u) sn = 1 + mpz_sizeinbase (u, base); if (!sp) - sp = (char *) gmp_xalloc (1 + sn); - + { + osn = 1 + sn; + sp = (char *) gmp_alloc (osn); + } + else + osn = 0; un = GMP_ABS (u->_mp_size); if (un == 0) { sp[0] = '0'; - sp[1] = '\0'; - return sp; + sn = 1; + goto ret; } i = 0; @@ -4237,17 +4287,20 @@ mpz_get_str (char *sp, int base, const mpz_t u) mp_ptr tp; mpn_get_base_info (&info, base); - tp = gmp_xalloc_limbs (un); + tp = gmp_alloc_limbs (un); mpn_copyi (tp, u->_mp_d, un); sn = i + mpn_get_str_other ((unsigned char *) sp + i, base, &info, tp, un); - gmp_free (tp); + gmp_free_limbs (tp, un); } for (; i < sn; i++) sp[i] = digits[(unsigned char) sp[i]]; +ret: sp[sn] = '\0'; + if (osn && osn != sn + 1) + sp = (char*) gmp_realloc (sp, osn, sn + 1); return sp; } @@ -4257,7 +4310,7 @@ mpz_set_str (mpz_t r, const char *sp, int base) unsigned bits, value_of_a; mp_size_t rn, alloc; mp_ptr rp; - size_t dn; + size_t dn, sn; int sign; unsigned char *dp; @@ -4295,7 +4348,8 @@ mpz_set_str (mpz_t r, const char *sp, int base) r->_mp_size = 0; return -1; } - dp = (unsigned char *) gmp_xalloc (strlen (sp)); + sn = strlen(sp); + dp = (unsigned char *) gmp_alloc (sn); value_of_a = (base > 36) ? 36 : 10; for (dn = 0; *sp; sp++) @@ -4315,7 +4369,7 @@ mpz_set_str (mpz_t r, const char *sp, int base) if (digit >= (unsigned) base) { - gmp_free (dp); + gmp_free (dp, sn); r->_mp_size = 0; return -1; } @@ -4325,7 +4379,7 @@ mpz_set_str (mpz_t r, const char *sp, int base) if (!dn) { - gmp_free (dp); + gmp_free (dp, sn); r->_mp_size = 0; return -1; } @@ -4349,7 +4403,7 @@ mpz_set_str (mpz_t r, const char *sp, int base) rn -= rp[rn-1] == 0; } assert (rn <= alloc); - gmp_free (dp); + gmp_free (dp, sn); r->_mp_size = sign ? - rn : rn; @@ -4367,13 +4421,15 @@ size_t mpz_out_str (FILE *stream, int base, const mpz_t x) { char *str; - size_t len; + size_t len, n; str = mpz_get_str (NULL, base, x); + if (!str) + return 0; len = strlen (str); - len = fwrite (str, 1, len, stream); - gmp_free (str); - return len; + n = fwrite (str, 1, len, stream); + gmp_free (str, len + 1); + return n; } @@ -4462,7 +4518,7 @@ mpz_export (void *r, size_t *countp, int order, size_t size, int endian, mp_size_t un; if (nails != 0) - gmp_die ("mpz_import: Nails not supported."); + gmp_die ("mpz_export: Nails not supported."); assert (order == 1 || order == -1); assert (endian >= -1 && endian <= 1); @@ -4477,7 +4533,7 @@ mpz_export (void *r, size_t *countp, int order, size_t size, int endian, ptrdiff_t word_step; /* The current (partial) limb. */ mp_limb_t limb; - /* The number of bytes left to to in this limb. */ + /* The number of bytes left to do in this limb. */ size_t bytes; /* The index where the limb was read. */ mp_size_t i; @@ -4501,7 +4557,7 @@ mpz_export (void *r, size_t *countp, int order, size_t size, int endian, count = (k + (un-1) * sizeof (mp_limb_t) + size - 1) / size; if (!r) - r = gmp_xalloc (count * size); + r = gmp_alloc (count * size); if (endian == 0) endian = gmp_detect_endian (); diff --git a/lib/gmp/mini-gmp.h b/lib/gmp/mini-gmp.h index 45ec808c1..2caf6c3c2 100644 --- a/lib/gmp/mini-gmp.h +++ b/lib/gmp/mini-gmp.h @@ -1,6 +1,6 @@ /* mini-gmp, a minimalistic implementation of a GNU GMP subset. -Copyright 2011-2015, 2017, 2019 Free Software Foundation, Inc. +Copyright 2011-2015, 2017, 2019-2021 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -233,6 +233,10 @@ mp_bitcnt_t mpz_scan1 (const mpz_t, mp_bitcnt_t); int mpz_fits_slong_p (const mpz_t); int mpz_fits_ulong_p (const mpz_t); +int mpz_fits_sint_p (const mpz_t); +int mpz_fits_uint_p (const mpz_t); +int mpz_fits_sshort_p (const mpz_t); +int mpz_fits_ushort_p (const mpz_t); long int mpz_get_si (const mpz_t); unsigned long int mpz_get_ui (const mpz_t); double mpz_get_d (const mpz_t); @@ -280,7 +284,9 @@ int mpz_init_set_str (mpz_t, const char *, int); || defined (_MSL_STDIO_H) /* Metrowerks */ \ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ - || defined (__STDIO_LOADED) /* VMS */ + || defined (__STDIO_LOADED) /* VMS */ \ + || defined (_STDIO) /* HPE NonStop */ \ + || defined (__DEFINED_FILE) /* musl */ size_t mpz_out_str (FILE *, int, const mpz_t); #endif diff --git a/multicraft.conf.example b/multicraft.conf.example index 1507a58c3..c37161101 100644 --- a/multicraft.conf.example +++ b/multicraft.conf.example @@ -449,6 +449,11 @@ # type: key # keymap_slot32 = +# Key for use by mods. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_tabb = KEY_TAB + # Key for toggling the display of the HUD. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # type: key @@ -861,7 +866,7 @@ # Whether node texture animations should be desynchronized per mapblock. # type: bool -# desynchronize_mapblock_texture_animation = true +# desynchronize_mapblock_texture_animation = false # Maximum proportion of current window to be used for hotbar. # Useful if there's something to be displayed right or left of hotbar. @@ -1217,13 +1222,19 @@ # type: bool # server_announce = false -# Announce to this serverlist. +# Announce to this serverlist. if announce_mt flags are set this is ignored +# when mt flags are set will be send to this url and also multicraft server list # type: string -# serverlist_url = servers.multicraft.world +# serverlist_url = servers.minetest.net -# Announce to MT serverlist. +# Announce to MT serverlist and multicraft serverlist. # type: bool -# announce_mt = true +# announce_mt_url = true + +# Announce to serverlist that gameid is minetest otehrwise send multicraft, +# multicraft server announce alway need "multicraft" as server id, minetest ignore it +# type: bool +# announce_mt_id = true # Remove color codes from incoming chat messages # Use this to stop players from being able to use color in their messages @@ -1611,6 +1622,7 @@ # LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to # csm_restriction_noderange) # READ_PLAYERINFO: 32 (disable get_player_names call client-side) +# THIRD_PARTY_MODS: 256 (disable loading third-party client-provided mods) # type: int # csm_restriction_flags = 60 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ce3b7168..a577e9e88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,14 @@ if(ENABLE_GETTEXT) endif() set(USE_GETTEXT TRUE) message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") + # On some platforms, such as Linux with GNU libc, the gettext + # functions are present in the C standard library and libintl + # is not required. For other libc (uClibc-ng or musl) libintl + # may be required. + find_package(Intl) + if(NOT Intl_LIBRARIES STREQUAL "") + message(STATUS "GetText Intl : ${Intl_LIBRARIES}") + endif() endif(GETTEXTLIB_FOUND) else() mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) @@ -179,7 +187,7 @@ if(ENABLE_POSTGRESQL) set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY}) endif() else() - find_package("PostgreSQL") + find_package(PostgreSQL) endif() if(PostgreSQL_FOUND) @@ -576,6 +584,7 @@ if(BUILD_CLIENT) ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} + ${Intl_LIBRARIES} ${SOUND_LIBRARIES} ${SQLITE3_LIBRARY} ${LUA_LIBRARY} @@ -685,6 +694,7 @@ if(BUILD_SERVER) ${ZLIB_LIBRARIES} ${SQLITE3_LIBRARY} ${JSON_LIBRARY} + ${Intl_LIBRARIES} ${LUA_LIBRARY} ${GMP_LIBRARY} ${PLATFORM_LIBS} @@ -879,7 +889,7 @@ else() endif() endif() - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${CMAKE_C_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} $ENV{CFLAGS} -Wall -pipe -funroll-loops") + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops") if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os") else() @@ -892,12 +902,13 @@ else() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}") endif() endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") - - set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} $ENV{CPPFLAGS}") + set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS} $ENV{CFLAGS} ") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS} -g") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} ${CMAKE_C_FLAGS} -O1 -g") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} ${CMAKE_C_FLAGS} $ENV{CFLAGS} -g") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} ${CMAKE_C_FLAGS} $ENV{CFLAGS} -g") if(USE_GPROF) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") diff --git a/src/client/client.cpp b/src/client/client.cpp index 264a9f276..b0e8b92e7 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -164,33 +164,35 @@ void Client::loadMods() scanModIntoMemory(BUILTIN_MOD_NAME, getBuiltinLuaPath()); m_script->loadModFromMemory(BUILTIN_MOD_NAME); - ClientModConfiguration modconf(getClientModsLuaPath()); - m_mods = modconf.getMods(); - // complain about mods with unsatisfied dependencies - if (!modconf.isConsistent()) { - modconf.printUnsatisfiedModsError(); - return; - } - - // Print mods - infostream << "Client loading mods: "; - for (const ModSpec &mod : m_mods) - infostream << mod.name << " "; - infostream << std::endl; - - // Load "mod" scripts - for (const ModSpec &mod : m_mods) { - if (!string_allowed(mod.name, MODNAME_ALLOWED_CHARS)) { - throw ModError("Error loading mod \"" + mod.name + - "\": Mod name does not follow naming conventions: " - "Only characters [a-z0-9_] are allowed."); + if (!checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_THIRD_PARTY_MODS)) { + ClientModConfiguration modconf(getClientModsLuaPath()); + m_mods = modconf.getMods(); + // complain about mods with unsatisfied dependencies + if (!modconf.isConsistent()) { + modconf.printUnsatisfiedModsError(); + return; } - scanModIntoMemory(mod.name, mod.path); - } - // Run them - for (const ModSpec &mod : m_mods) - m_script->loadModFromMemory(mod.name); + // Print mods + infostream << "Client loading mods: "; + for (const ModSpec &mod : m_mods) + infostream << mod.name << " "; + infostream << std::endl; + + // Load "mod" scripts + for (const ModSpec &mod : m_mods) { + if (!string_allowed(mod.name, MODNAME_ALLOWED_CHARS)) { + throw ModError("Error loading mod \"" + mod.name + + "\": Mod name does not follow naming conventions: " + "Only characters [a-z0-9_] are allowed."); + } + scanModIntoMemory(mod.name, mod.path); + } + + // Run them + for (const ModSpec &mod : m_mods) + m_script->loadModFromMemory(mod.name); + } // Mods are done loading. Unlock callbacks m_mods_loaded = true; @@ -693,6 +695,40 @@ bool Client::loadMedia(const std::string &data, const std::string &filename, rfile->drop(); return false; } +#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 9 + float memoryMax = porting::getTotalSystemMemory() / 1024; + if (memoryMax <= 2) { + irr::video::ECOLOR_FORMAT format = img->getColorFormat(); + irr::video::ECOLOR_FORMAT new_format = irr::video::ECF_UNKNOWN; + + if (format == irr::video::ECF_R8G8B8) { + new_format = irr::video::ECF_R5G6B5; + } else if (format == irr::video::ECF_A8R8G8B8) { + bool can_convert = true; + + u32 data_size = img->getImageDataSizeInBytes(); + u8 *data = (u8*) img->getData(); + for (u32 i = 0; i < data_size; i += 4) { + u8 alpha = data[i + 3]; + if (alpha > 0 && alpha < 255) { + can_convert = false; + break; + } + } + + if (can_convert) + new_format = irr::video::ECF_A1R5G5B5; + } + + if (new_format != irr::video::ECF_UNKNOWN) { + core::dimension2du dimensions = img->getDimension(); + irr::video::IImage* converted_img = vdrv->createImage(new_format, dimensions); + img->copyTo(converted_img, core::position2d(0, 0)); + img->drop(); + img = converted_img; + } + } +#endif m_tsrc->insertSourceImage(filename, img); img->drop(); diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index 4e900ac7c..3afe50d4f 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -1420,10 +1420,15 @@ void MapblockMeshGenerator::drawMeshNode() // Convert wallmounted to 6dfacedir. // When cache enabled, it is already converted. facedir = n.getWallMounted(nodedef); - if (!enable_mesh_cache) - facedir = wallmounted_to_facedir[facedir]; + if (!enable_mesh_cache) { + facedir = wallmountedToFacedir(facedir); + } } + // f->mesh_ptr has 24 elements + if (facedir > 23) + facedir = 0; + if (!data->m_smooth_lighting && f->mesh_ptr[facedir]) { // use cached meshes private_mesh = false; diff --git a/src/client/game.cpp b/src/client/game.cpp index 7bdbf484d..8bde75c4c 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -819,7 +819,7 @@ protected: } #if defined(__ANDROID__) || defined(__IOS__) - void handleAndroidChatInput(); + void handleTouchChatInput(); #endif private: @@ -1530,6 +1530,8 @@ bool Game::connectToServer(const GameStartData &start_data, Wait for server to accept connection */ + bool result = true; + try { input->clear(); @@ -1539,7 +1541,7 @@ bool Game::connectToServer(const GameStartData &start_data, fps_control.last_time = RenderingEngine::get_timer_time(); - while (RenderingEngine::run()) { + while ((result = RenderingEngine::run())) { limitFps(&fps_control, &dtime); @@ -1603,7 +1605,7 @@ bool Game::connectToServer(const GameStartData &start_data, return false; } - return true; + return result; } bool Game::getServerContent(bool *aborted) @@ -1615,7 +1617,8 @@ bool Game::getServerContent(bool *aborted) fps_control.last_time = RenderingEngine::get_timer_time(); - while (RenderingEngine::run()) { + bool result = true; + while ((result = RenderingEngine::run())) { limitFps(&fps_control, &dtime); @@ -1691,7 +1694,7 @@ bool Game::getServerContent(bool *aborted) } } - return true; + return result; } @@ -1873,6 +1876,14 @@ void Game::processUserInput(f32 dtime) g_touchscreengui->hide(); #endif } + +#if defined(__ANDROID__) || defined(__IOS__) + if (porting::isInputDialogActive() && porting::getInputDialogOwner() == "chat") { + input->clear(); + g_touchscreengui->hide(); + } +#endif + #ifdef HAVE_TOUCHSCREENGUI else if (g_touchscreengui) { /* on touchscreengui step may generate own input events which ain't @@ -1889,13 +1900,11 @@ void Game::processUserInput(f32 dtime) input->step(dtime); #if defined(__ANDROID__) || defined(__IOS__) - if (!porting::hasRealKeyboard()) { - auto formspec = m_game_ui->getFormspecGUI(); - if (formspec) - formspec->getAndroidUIInput(); - else - handleAndroidChatInput(); - } + handleTouchChatInput(); + + auto formspec = m_game_ui->getFormspecGUI(); + if (formspec) + formspec->getTouchUIInput(); #endif bool doubletap_jump = m_cache_doubletap_jump; @@ -1923,9 +1932,6 @@ void Game::processKeyInput() } else if (wasKeyDown(KeyType::INVENTORY)) { openInventory(); } else if (input->cancelPressed()) { -#if defined(__ANDROID__) || defined(__IOS__) - gui_chat_console->setAndroidChatOpen(false); -#endif if (!gui_chat_console->isOpenInhibited()) { showPauseMenu(); } @@ -2137,21 +2143,21 @@ void Game::openConsole(float scale, const wchar_t *line) { assert(scale > 0.0f && scale <= 1.0f); - if (gui_chat_console->getAndroidChatOpen()) + if (gui_chat_console->isOpenInhibited()) return; #if defined(__ANDROID__) || defined(__IOS__) + if (porting::isInputDialogActive()) + return; + if (!porting::hasRealKeyboard()) { - porting::showInputDialog("", "", 2); - gui_chat_console->setAndroidChatOpen(true); + porting::showInputDialog("", "", 2, "chat"); } if (!RenderingEngine::isTablet()) return; #endif - if (gui_chat_console->isOpenInhibited()) - return; gui_chat_console->openConsole(scale); if (line) { gui_chat_console->setCloseOnEnter(true); @@ -2160,16 +2166,21 @@ void Game::openConsole(float scale, const wchar_t *line) } #if defined(__ANDROID__) || defined(__IOS__) -void Game::handleAndroidChatInput() +void Game::handleTouchChatInput() { - if (gui_chat_console->getAndroidChatOpen() && - porting::getInputDialogState() == 0) { + if (porting::getInputDialogOwner() == "chat" && + !porting::isInputDialogActive()) { std::string text = porting::getInputDialogValue(); client->typeChatMessage(utf8_to_wide(text)); - gui_chat_console->setAndroidChatOpen(false); if (!text.empty() && gui_chat_console->isOpen()) { gui_chat_console->closeConsole(); } +#ifdef HAVE_TOUCHSCREENGUI + if (!gui_chat_console->isOpen() && !isMenuActive()) { + if (g_touchscreengui && g_touchscreengui->isActive()) + g_touchscreengui->show(); + } +#endif } } #endif @@ -2519,6 +2530,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam) isKeyDown(KeyType::SPECIAL1), isKeyDown(KeyType::SNEAK), isKeyDown(KeyType::ZOOM), + isKeyDown(KeyType::TABB), isKeyDown(KeyType::DIG), isKeyDown(KeyType::PLACE), cam.camera_pitch, @@ -2542,7 +2554,8 @@ void Game::updatePlayerControl(const CameraOrientation &cam) ( (u32)(isKeyDown(KeyType::SNEAK) & 0x1) << 6) | ( (u32)(isKeyDown(KeyType::DIG) & 0x1) << 7) | ( (u32)(isKeyDown(KeyType::PLACE) & 0x1) << 8) | - ( (u32)(isKeyDown(KeyType::ZOOM) & 0x1) << 9) + ( (u32)(isKeyDown(KeyType::ZOOM) & 0x1) << 9) | + ( (u32)(isKeyDown(KeyType::TABB) & 0x1) << 10) ); LocalPlayer *player = client->getEnv().getLocalPlayer(); diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp index 838f1a709..01f82bf9f 100644 --- a/src/client/gameui.cpp +++ b/src/client/gameui.cpp @@ -74,14 +74,14 @@ void GameUI::init(Client *client) // At the middle of the screen // Object infos are shown in this u32 chat_font_height = m_guitext_chat->getActiveFont()->getDimension(L"Ay").Height; - float scale = 1.0f; -#if defined(__ANDROID__) || defined(__APPLE__) - scale = RenderingEngine::getDisplayDensity() * client->getHudScaling() * 0.5f; -#endif + v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); + s32 text_height = g_fontengine->getTextHeight() * 6; + s32 top_y = (screensize.Y - text_height) / 2; + s32 horiz_offset = 100 + client->getRoundScreen(); + m_guitext_info = gui::StaticText::add(guienv, L"", - core::rect(0, 0, 400, g_fontengine->getTextHeight() * 6) + - v2s32(100 + client->getRoundScreen(), - chat_font_height * (g_settings->getU16("recent_chat_messages") + 3) * scale), + core::rect(horiz_offset, top_y, + horiz_offset + 400, top_y + text_height), false, true, guiroot); // Status text (displays info when showing and hiding GUI stuff, etc.) diff --git a/src/client/guiscalingfilter.cpp b/src/client/guiscalingfilter.cpp index dd65d1bea..b733b76c9 100644 --- a/src/client/guiscalingfilter.cpp +++ b/src/client/guiscalingfilter.cpp @@ -129,7 +129,7 @@ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, #endif // Convert the scaled image back into a texture. - scaled = driver->addTexture(scalename, destimg, NULL); + scaled = driver->addTexture(scalename, destimg, NULL); // irr 1.8 destimg->drop(); g_txrCache[scalename] = scaled; diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp index 9d525c223..c8b642494 100644 --- a/src/client/inputhandler.cpp +++ b/src/client/inputhandler.cpp @@ -90,6 +90,8 @@ void KeyCache::populate() key[KeyType::QUICKTUNE_INC] = getKeySetting("keymap_quicktune_inc"); key[KeyType::QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec"); + key[KeyType::TABB] = getKeySetting("keymap_tabb"); + for (int i = 0; i < HUD_HOTBAR_ITEMCOUNT_MAX; i++) { std::string slot_key_name = "keymap_slot" + std::to_string(i + 1); key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str()); @@ -111,14 +113,14 @@ bool MyEventReceiver::OnEvent(const SEvent &event) #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) if (event.EventType == irr::EET_SDL_CONTROLLER_BUTTON_EVENT || event.EventType == irr::EET_SDL_CONTROLLER_AXIS_EVENT) { - if (g_settings->getBool("enable_joysticks")) { + if (g_settings->getBool("enable_joysticks") && sdl_game_controller) { sdl_game_controller->translateEvent(event); input->setCursorVisible(sdl_game_controller->isCursorVisible()); } } else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) || event.EventType == irr::EET_TOUCH_INPUT_EVENT) { - if (!sdl_game_controller->isFakeEvent() && + if (sdl_game_controller && !sdl_game_controller->isFakeEvent() && sdl_game_controller->isActive()) { sdl_game_controller->setActive(false); input->setCursorVisible(sdl_game_controller->isCursorVisible()); @@ -133,7 +135,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event) m_touchscreengui->show(); } else if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == irr::EMIE_MOUSE_MOVED) || - sdl_game_controller->isActive()) { + (sdl_game_controller && sdl_game_controller->isActive())) { TouchScreenGUI::setActive(false); if (m_touchscreengui && !isMenuActive()) m_touchscreengui->hide(); @@ -194,7 +196,6 @@ bool MyEventReceiver::OnEvent(const SEvent &event) #ifdef __IOS__ } else if (event.EventType == irr::EET_APPLICATION_EVENT) { int AppEvent = event.ApplicationEvent.EventType; - ioswrap_events(AppEvent); if (AppEvent == irr::EAET_WILL_PAUSE) external_pause_game(); return true; @@ -205,7 +206,10 @@ bool MyEventReceiver::OnEvent(const SEvent &event) if (event.JoystickEvent != joystick_we_listen_for) return false; */ - return joystick->handleEvent(event.JoystickEvent); + if (joystick) + return joystick->handleEvent(event.JoystickEvent); + else + return true; } else if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) { // Handle mouse events KeyPress key; diff --git a/src/client/keys.h b/src/client/keys.h index 9853c090a..82f354233 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -76,6 +76,8 @@ public: QUICKTUNE_INC, QUICKTUNE_DEC, + TABB, + // hotbar SLOT_1, SLOT_2, diff --git a/src/client/render/anaglyph.cpp b/src/client/render/anaglyph.cpp index 404eb81a6..573d8c054 100644 --- a/src/client/render/anaglyph.cpp +++ b/src/client/render/anaglyph.cpp @@ -20,6 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "anaglyph.h" +#include + void RenderingCoreAnaglyph::drawAll() { renderBothImages(); diff --git a/src/client/render/factory.cpp b/src/client/render/factory.cpp index 62dda18be..8eba3607b 100644 --- a/src/client/render/factory.cpp +++ b/src/client/render/factory.cpp @@ -31,6 +31,7 @@ RenderingCore *createRenderingCore(const std::string &stereo_mode, IrrlichtDevic { if (stereo_mode == "none") return new RenderingCorePlain(device, client, hud); +#if !defined(__ANDROID__) && !defined(__APPLE__) if (stereo_mode == "anaglyph") return new RenderingCoreAnaglyph(device, client, hud); if (stereo_mode == "interlaced") @@ -45,6 +46,7 @@ RenderingCore *createRenderingCore(const std::string &stereo_mode, IrrlichtDevic return new RenderingCoreSideBySide(device, client, hud, true); if (stereo_mode == "crossview") return new RenderingCoreSideBySide(device, client, hud, false, true); +#endif // fallback to plain renderer errorstream << "Invalid rendering mode: " << stereo_mode << std::endl; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index ce8f5faa5..7d23bd9c7 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -781,7 +781,7 @@ v2u32 RenderingEngine::getDisplaySize() #else // __ANDROID__/__IOS__ float RenderingEngine::getDisplayDensity() { - static const float density = porting::getDisplayDensity(); + static const float density = porting::getScreenScale(); return density; } diff --git a/src/client/sound_openal.cpp b/src/client/sound_openal.cpp index 434f3807f..5246c6dcf 100644 --- a/src/client/sound_openal.cpp +++ b/src/client/sound_openal.cpp @@ -109,7 +109,6 @@ struct SoundBuffer ALenum format; ALsizei freq; ALuint buffer_id; - std::vector buffer; }; SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, @@ -120,6 +119,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, long bytes; char array[BUFFER_SIZE]; // Local fixed size array vorbis_info *pInfo; + std::vector buffer; SoundBuffer *snd = new SoundBuffer; @@ -151,12 +151,12 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, } // Append to end of buffer - snd->buffer.insert(snd->buffer.end(), array, array + bytes); + buffer.insert(buffer.end(), array, array + bytes); } while (bytes > 0); alGenBuffers(1, &snd->buffer_id); alBufferData(snd->buffer_id, snd->format, - &(snd->buffer[0]), snd->buffer.size(), + &buffer[0], buffer.size(), snd->freq); ALenum error = alGetError(); @@ -170,6 +170,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, // << filename_for_logging << " loaded" << std::endl; // Clean up! + buffer.clear(); ov_clear(oggFile); return snd; diff --git a/src/content/mods.h b/src/content/mods.h index 279ab1415..5e80b7c90 100644 --- a/src/content/mods.h +++ b/src/content/mods.h @@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "config.h" #include "metadata.h" -#define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789_" +#define MODNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyz0123456789-_" struct ModSpec { diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp index 97a3964e0..e45dfc26f 100644 --- a/src/content/subgames.cpp +++ b/src/content/subgames.cpp @@ -144,13 +144,17 @@ SubgameSpec findSubgame(const std::string &id) if (conf.exists("moddable")) moddable = conf.getBool("moddable"); + bool hide_game = false; + if (conf.exists("hide_game")) + hide_game = conf.getBool("hide_game"); + std::string menuicon_path; #ifndef SERVER menuicon_path = getImagePath( game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png"); #endif return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name, - menuicon_path, game_author, game_release, moddable); + menuicon_path, game_author, game_release, moddable, hide_game); } SubgameSpec findWorldSubgame(const std::string &world_path) diff --git a/src/content/subgames.h b/src/content/subgames.h index 2ee93eb55..5eeff0c5c 100644 --- a/src/content/subgames.h +++ b/src/content/subgames.h @@ -36,6 +36,7 @@ struct SubgameSpec std::set addon_mods_paths; std::string menuicon_path; bool moddable; + bool hidden; SubgameSpec(const std::string &id = "", const std::string &path = "", const std::string &gamemods_path = "", @@ -44,11 +45,11 @@ struct SubgameSpec const std::string &name = "", const std::string &menuicon_path = "", const std::string &author = "", int release = 0, - const bool moddable = true) : + const bool moddable = true, const bool hidden = false) : id(id), name(name), author(author), release(release), path(path), gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths), - menuicon_path(menuicon_path), moddable(moddable) + menuicon_path(menuicon_path), moddable(moddable), hidden(hidden) { } diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index d19039d4d..4ea765288 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -30,12 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "client/renderingengine.h" #endif -#ifdef __APPLE__ #ifdef __IOS__ -#import "SDVersion.h" -#else -#import -#endif +#import "wrapper.h" #endif void set_default_settings() @@ -48,7 +44,7 @@ void set_default_settings() settings->setDefault("language", ""); settings->setDefault("name", ""); settings->setDefault("bind_address", ""); - settings->setDefault("serverlist_url", "servers.muklticraft.world"); + settings->setDefault("serverlist_url", "servers.minetest.net"); // Client settings->setDefault("address", ""); @@ -163,6 +159,8 @@ void set_default_settings() settings->setDefault("keymap_quicktune_dec", "KEY_NEXT"); settings->setDefault("keymap_quicktune_inc", "KEY_PRIOR"); + settings->setDefault("keymap_tabb", "KEY_TAB"); + // Visuals #ifdef NDEBUG settings->setDefault("show_debug", "false"); @@ -240,7 +238,7 @@ void set_default_settings() settings->setDefault("gui_scaling", "1.0"); settings->setDefault("gui_scaling_filter", "false"); settings->setDefault("gui_scaling_filter_txr2img", "true"); - settings->setDefault("desynchronize_mapblock_texture_animation", "true"); + settings->setDefault("desynchronize_mapblock_texture_animation", "false"); settings->setDefault("hud_hotbar_max_width", "1.0"); settings->setDefault("hud_move_upwards", "0"); settings->setDefault("round_screen", "0"); @@ -356,7 +354,7 @@ void set_default_settings() settings->setDefault("chat_font_size", "0"); // Default "font_size" // ContentDB - settings->setDefault("contentdb_url", "https://content.multicraft.world"); + settings->setDefault("contentdb_url", "https://content.minetest.net"); settings->setDefault("contentdb_max_concurrent_downloads", "3"); #ifdef __ANDROID__ @@ -378,7 +376,8 @@ void set_default_settings() settings->setDefault("disable_texture_packs", "false"); settings->setDefault("disable_escape_sequences", "false"); settings->setDefault("strip_color_codes", "true"); - settings->setDefault("announce_mt", "true"); + settings->setDefault("announce_mt_url", "true"); + settings->setDefault("announce_mt_id", "true"); #if USE_PROMETHEUS settings->setDefault("prometheus_listener_address", "127.0.0.1:30000"); #endif @@ -507,7 +506,7 @@ void set_default_settings() settings->setDefault("keymap_camera_mode", "KEY_KEY_C"); settings->setDefault("vsync", "true"); - int ScaleFactor = (int) [NSScreen mainScreen].backingScaleFactor; + int ScaleFactor = porting::getScreenScale(); settings->setDefault("screen_dpi", std::to_string(ScaleFactor * 72)); if (ScaleFactor >= 2) { settings->setDefault("hud_scaling", "1.5"); @@ -548,7 +547,7 @@ void set_default_settings() // Set the optimal settings depending on the memory size [Android] | model [iOS] #ifdef __ANDROID__ - float memoryMax = porting::getTotalSystemMemory(); + float memoryMax = porting::getTotalSystemMemory() / 1024; if (memoryMax < 2) { // minimal settings for less than 2GB RAM @@ -616,7 +615,7 @@ void set_default_settings() } else { // high settings settings->setDefault("client_mapblock_limit", "500"); - settings->setDefault("viewing_range", "125"); + settings->setDefault("viewing_range", "120"); settings->setDefault("active_object_send_range_blocks", "4"); settings->setDefault("max_block_generate_distance", "5"); diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp index ea6be6339..4d82dd3c9 100644 --- a/src/gui/guiChatConsole.cpp +++ b/src/gui/guiChatConsole.cpp @@ -1589,10 +1589,9 @@ bool GUIChatConsole::preprocessEvent(SEvent event) event.TouchInput.Y >= prompt_y && event.TouchInput.Y <= m_height) { if (event.TouchInput.Event == ETIE_PRESSED_DOWN && - !m_android_chat_open) { + !porting::isInputDialogActive()) { ChatPrompt& prompt = m_chat_backend->getPrompt(); - porting::showInputDialog("", "", 2); - m_android_chat_open = true; + porting::showInputDialog("", "", 2, "chat"); } } #endif diff --git a/src/gui/guiChatConsole.h b/src/gui/guiChatConsole.h index 1ff952b81..3a88266de 100644 --- a/src/gui/guiChatConsole.h +++ b/src/gui/guiChatConsole.h @@ -170,9 +170,6 @@ public: bool preprocessEvent(SEvent event); - bool getAndroidChatOpen() { return m_android_chat_open; } - void setAndroidChatOpen(bool value) { m_android_chat_open = value; } - void onLinesModified(); void onPromptModified(); @@ -253,6 +250,4 @@ private: u32 m_scrollbar_width = 0; GUIScrollBar *m_vscrollbar = nullptr; s32 m_bottom_scroll_pos = 0; - - bool m_android_chat_open = false; }; diff --git a/src/gui/guiConfirmRegistration.cpp b/src/gui/guiConfirmRegistration.cpp index 3effcfbc9..c9936fa94 100644 --- a/src/gui/guiConfirmRegistration.cpp +++ b/src/gui/guiConfirmRegistration.cpp @@ -220,7 +220,7 @@ void GUIConfirmRegistration::drawMenu() gui::IGUIElement::draw(); #if defined(__ANDROID__) || defined(__IOS__) - getAndroidUIInput(); + getTouchUIInput(); #endif } @@ -308,13 +308,16 @@ bool GUIConfirmRegistration::OnEvent(const SEvent &event) } #if defined(__ANDROID__) || defined(__IOS__) -bool GUIConfirmRegistration::getAndroidUIInput() +bool GUIConfirmRegistration::getTouchUIInput() { if (m_jni_field_name.empty() || m_jni_field_name != "password") return false; + if (porting::getInputDialogOwner() != "modalmenu") + return false; + // still waiting - if (porting::getInputDialogState() == -1) + if (porting::isInputDialogActive()) return true; m_jni_field_name.clear(); diff --git a/src/gui/guiConfirmRegistration.h b/src/gui/guiConfirmRegistration.h index 31df018a3..cf8659a03 100644 --- a/src/gui/guiConfirmRegistration.h +++ b/src/gui/guiConfirmRegistration.h @@ -52,7 +52,7 @@ public: bool OnEvent(const SEvent &event); #if defined(__ANDROID__) || defined(__IOS__) - bool getAndroidUIInput(); + bool getTouchUIInput(); #endif private: diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 4f20d1cf1..7850f71ce 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -348,7 +348,7 @@ void GUIEngine::run() m_script->step(); #if defined(__ANDROID__) || defined(__IOS__) - m_menu->getAndroidUIInput(); + m_menu->getTouchUIInput(); #endif } } @@ -474,9 +474,15 @@ void GUIEngine::drawBackground(video::IVideoDriver *driver) } /* Draw background texture */ + float aspectRatioScreen = (float) screensize.X / screensize.Y; + float aspectRatioSource = (float) sourcesize.X / sourcesize.Y; + + int sourceX = aspectRatioSource > aspectRatioScreen ? (sourcesize.X - sourcesize.Y * aspectRatioScreen) / 2 : 0; + int sourceY = aspectRatioSource < aspectRatioScreen ? (sourcesize.Y - sourcesize.X / aspectRatioScreen) / 2 : 0; + draw2DImageFilterScaled(driver, texture, core::rect(0, 0, screensize.X, screensize.Y), - core::rect(0, 0, sourcesize.X, sourcesize.Y), + core::rect(sourceX, sourceY, sourcesize.X - sourceX, sourcesize.Y - sourceY), NULL, NULL, true); } diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 5b690a5ed..472536263 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -3602,13 +3602,16 @@ void GUIFormSpecMenu::legacySortElements(core::list::Iterator fro } #if defined(__ANDROID__) || defined(__IOS__) -bool GUIFormSpecMenu::getAndroidUIInput() +bool GUIFormSpecMenu::getTouchUIInput() { if (m_jni_field_name.empty()) return false; + if (porting::getInputDialogOwner() != "modalmenu") + return false; + // still waiting - if (porting::getInputDialogState() == -1) + if (porting::isInputDialogActive()) return true; std::string fieldname = m_jni_field_name; diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index 82a61b609..374349203 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -266,7 +266,7 @@ public: std::vector* getDropDownValues(const std::string &name); #if defined(__ANDROID__) || defined(__IOS__) - bool getAndroidUIInput(); + bool getTouchUIInput(); #endif protected: diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp index 3272dfc46..23e424e17 100644 --- a/src/gui/modalMenu.cpp +++ b/src/gui/modalMenu.cpp @@ -346,6 +346,9 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event) if (field_name.empty() || porting::hasRealKeyboard()) return retval; + if (porting::isInputDialogActive()) + return retval; + m_jni_field_name = field_name; // single line text input @@ -360,7 +363,8 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event) type = 3; porting::showInputDialog(wide_to_utf8(getLabelByID(hovered->getID())), - wide_to_utf8(((gui::IGUIEditBox *)hovered)->getText()), type); + wide_to_utf8(((gui::IGUIEditBox *)hovered)->getText()), type, + "modalmenu"); return retval; } } diff --git a/src/gui/modalMenu.h b/src/gui/modalMenu.h index 7fd5c7b45..a2bfaf90b 100644 --- a/src/gui/modalMenu.h +++ b/src/gui/modalMenu.h @@ -58,7 +58,7 @@ public: virtual bool OnEvent(const SEvent &event) { return false; }; virtual bool pausesGame() { return false; } // Used for pause menu #if defined(__ANDROID__) || defined(__IOS__) - virtual bool getAndroidUIInput() { return false; } + virtual bool getTouchUIInput() { return false; } #endif protected: diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp index 78c0281f9..8a3b34f2c 100644 --- a/src/httpfetch.cpp +++ b/src/httpfetch.cpp @@ -215,26 +215,26 @@ public: private: CurlHandlePool *pool; - CURL *curl; - CURLM *multi; + CURL *curl = nullptr; + CURLM *multi = nullptr; HTTPFetchRequest request; HTTPFetchResult result; std::ostringstream oss; - struct curl_slist *http_header; - curl_httppost *post; + struct curl_slist *http_header = nullptr; +#if LIBCURL_VERSION_NUM >= 0x075500 + curl_mime *multipart_mime = nullptr; +#elif LIBCURL_VERSION_NUM >= 0x071304 + curl_httppost *post = nullptr; +#endif }; HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_, CurlHandlePool *pool_): pool(pool_), - curl(NULL), - multi(NULL), request(request_), result(request_), - oss(std::ios::binary), - http_header(NULL), - post(NULL) + oss(std::ios::binary) { curl = pool->alloc(); if (curl == NULL) { @@ -257,15 +257,16 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_, curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } -#if LIBCURL_VERSION_NUM >= 0x071304 // Restrict protocols so that curl vulnerabilities in // other protocols don't affect us. - // These settings were introduced in curl 7.19.4. - long protocols = - CURLPROTO_HTTP | - CURLPROTO_HTTPS | - CURLPROTO_FTP | - CURLPROTO_FTPS; +#if LIBCURL_VERSION_NUM >= 0x075500 + // These settings were introduced in curl 7.85.0. + const char *protocols = "HTTP,HTTPS,FTP,FTPS"; + curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, protocols); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, protocols); +#elif LIBCURL_VERSION_NUM >= 0x071304 + // These settings were introduced in curl 7.19.4, and later deprecated. + long protocols = CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FTP | CURLPROTO_FTPS; curl_easy_setopt(curl, CURLOPT_PROTOCOLS, protocols); curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, protocols); #endif @@ -296,6 +297,15 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_, // Set data from fields or raw_data if (request.multipart) { +#if LIBCURL_VERSION_NUM >= 0x075500 + multipart_mime = curl_mime_init(curl); + for (auto &it : request.fields) { + curl_mimepart *part = curl_mime_addpart(multipart_mime); + curl_mime_name(part, it.first.c_str()); + curl_mime_data(part, it.second.c_str(), it.second.size()); + } + curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart_mime); +#elif LIBCURL_VERSION_NUM >= 0x071304 curl_httppost *last = NULL; for (StringMap::iterator it = request.fields.begin(); it != request.fields.end(); ++it) { @@ -307,8 +317,8 @@ HTTPFetchOngoing::HTTPFetchOngoing(const HTTPFetchRequest &request_, CURLFORM_END); } curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); - // request.post_fields must now *never* be - // modified until CURLOPT_HTTPPOST is cleared + // request.post_fields must now *never* be modified until CURLOPT_HTTPPOST is cleared +#endif } else { switch (request.method) { case HTTP_GET: @@ -423,11 +433,17 @@ HTTPFetchOngoing::~HTTPFetchOngoing() curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL); curl_slist_free_all(http_header); } +#if LIBCURL_VERSION_NUM >= 0x075500 + if (multipart_mime) { + curl_easy_setopt(curl, CURLOPT_MIMEPOST, nullptr); + curl_mime_free(multipart_mime); + } +#elif LIBCURL_VERSION_NUM >= 0x071304 if (post) { curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); curl_formfree(post); } - +#endif // Store the cURL handle for reuse pool->free(curl); } diff --git a/src/irrlicht_changes/irrUString.h b/src/irrlicht_changes/irrUString.h index ce9f2bc7e..d2346181f 100644 --- a/src/irrlicht_changes/irrUString.h +++ b/src/irrlicht_changes/irrUString.h @@ -3857,38 +3857,5 @@ inline std::wostream& operator<<(std::wostream& out, const ustring16& in } #endif - -#ifndef USTRING_NO_STL - -namespace unicode -{ - -//! Hashing algorithm for hashing a ustring. Used for things like unordered_maps. -//! Algorithm taken from std::hash. -class hash : public std::unary_function -{ - public: - size_t operator()(const core::ustring& s) const - { - size_t ret = 2166136261U; - size_t index = 0; - size_t stride = 1 + s.size_raw() / 10; - - core::ustring::const_iterator i = s.begin(); - while (i != s.end()) - { - // TODO: Don't force u32 on an x64 OS. Make it agnostic. - ret = 16777619U * ret ^ (size_t)s[(u32)index]; - index += stride; - i += stride; - } - return (ret); - } -}; - -} // end namespace unicode - -#endif - } // end namespace core } // end namespace irr diff --git a/src/mapgen/mapgen_v7p.cpp b/src/mapgen/mapgen_v7p.cpp index 0508ad637..32ba1ec10 100644 --- a/src/mapgen/mapgen_v7p.cpp +++ b/src/mapgen/mapgen_v7p.cpp @@ -53,6 +53,20 @@ MapgenV7P::MapgenV7P(MapgenV7PParams *params, EmergeParams *emerge) { spflags = params->spflags; + // Initialise some values to hardcoded defaults + cave_width = 0.09; + large_cave_depth = -33; + small_cave_num_min = 0; + small_cave_num_max = 0; + large_cave_num_min = 0; + large_cave_num_max = 2; + large_cave_flooded = 0.5; + cavern_limit = -256; + cavern_taper = 256; + cavern_threshold = 0.7; + dungeon_ymin = -31000; + dungeon_ymax = 31000; + // Average of mgv6 small caves count small_caves_count = 6 * csize.X * csize.Z * MAP_BLOCKSIZE / 50000; @@ -76,6 +90,13 @@ MapgenV7P::MapgenV7P(MapgenV7PParams *params, EmergeParams *emerge) noise_ridge = new Noise(¶ms->np_ridge, seed, csize.X, csize.Z); } + // 3D noise, 1 down overgeneration + MapgenBasic::np_cave1 = NoiseParams(0.0, 12.0, v3f(61.0, 61.0, 61.0), 52534, 3, 0.5, 2.0); + MapgenBasic::np_cave2 = NoiseParams(0.0, 12.0, v3f(67.0, 67.0, 67.0), 10325, 3, 0.5, 2.0); + MapgenBasic::np_cavern = NoiseParams(0.0, 1.0, v3f(384.0, 128.0, 384.0), 723, 5, 0.63, 2.0); + // 3D noise + MapgenBasic::np_dungeons = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0); + // Resolve additional nodes c_bedrock = ndef->getId("mapgen_bedrock"); } diff --git a/src/mapgen/mg_biome.cpp b/src/mapgen/mg_biome.cpp index e882d1181..ad1c496e7 100644 --- a/src/mapgen/mg_biome.cpp +++ b/src/mapgen/mg_biome.cpp @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/numeric.h" #include "porting.h" #include "settings.h" - +#include /////////////////////////////////////////////////////////////////////////////// diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 57c0cb0bc..edb97db8e 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -151,7 +151,7 @@ u8 MapNode::getFaceDir(const NodeDefManager *nodemgr, return (getParam2() & 0x1F) % 24; if (allow_wallmounted && (f.param_type_2 == CPT2_WALLMOUNTED || f.param_type_2 == CPT2_COLORED_WALLMOUNTED)) - return wallmounted_to_facedir[getParam2() & 0x07]; + return wallmountedToFacedir(getParam2() & 0x07); return 0; } diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 4cb21a5db..9eb91ffae 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -1051,6 +1051,7 @@ enum CSMRestrictionFlags : u64 { CSM_RF_READ_NODEDEFS = 0x00000008, // Disable nodedef lookups CSM_RF_LOOKUP_NODES = 0x00000010, // Limit node lookups CSM_RF_READ_PLAYERINFO = 0x00000020, // Disable player info lookups + CSM_RF_THIRD_PARTY_MODS = 0x00000100, // Don't load third-party CSMs CSM_RF_ALL = 0xFFFFFFFF, }; diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index f3134821b..b8c4748eb 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -525,6 +525,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao, player->control.dig = (keyPressed & (0x1 << 7)); player->control.place = (keyPressed & (0x1 << 8)); player->control.zoom = (keyPressed & (0x1 << 9)); + player->control.tabb = (keyPressed & (0x1 << 10)); if (playersao->checkMovementCheat()) { // Call callbacks diff --git a/src/player.h b/src/player.h index 65d881f86..05d792b82 100644 --- a/src/player.h +++ b/src/player.h @@ -57,6 +57,7 @@ struct PlayerControl bool a_aux1, bool a_sneak, bool a_zoom, + bool a_tabb, bool a_dig, bool a_place, float a_pitch, @@ -73,6 +74,7 @@ struct PlayerControl aux1 = a_aux1; sneak = a_sneak; zoom = a_zoom; + tabb = a_tabb; dig = a_dig; place = a_place; pitch = a_pitch; @@ -88,6 +90,7 @@ struct PlayerControl bool aux1 = false; bool sneak = false; bool zoom = false; + bool tabb = false; bool dig = false; bool place = false; float pitch = 0.0f; diff --git a/src/porting.cpp b/src/porting.cpp index 28627f838..b05b9e1fa 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -57,7 +57,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif #if defined(__HAIKU__) - #include + #include +#endif + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + #include #endif #include "config.h" @@ -747,8 +751,24 @@ std::string getSecretKey(const std::string &key) { return std::string(get_secret_key(key.c_str())); } + +float getScreenScale() +{ + static const float retval = get_screen_scale(); + return retval; +} #endif +float getTotalSystemMemory() +{ +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + static const float retval = SDL_GetSystemRAM(); + return retval; +#else + return 0; +#endif +} + bool open_directory(const std::string &path) { if (!fs::IsDir(path)) { diff --git a/src/porting.h b/src/porting.h index bf97c2ad7..33558c3d4 100644 --- a/src/porting.h +++ b/src/porting.h @@ -360,8 +360,16 @@ bool open_url(const std::string &url); #if defined(__APPLE__) std::string getSecretKey(const std::string &key); + +float getScreenScale(); #endif +/** + * Get total device memory + */ + +float getTotalSystemMemory(); + bool open_directory(const std::string &path); } // namespace porting diff --git a/src/porting_android.cpp b/src/porting_android.cpp index 4d30bd93f..4c36ef3ff 100644 --- a/src/porting_android.cpp +++ b/src/porting_android.cpp @@ -1,8 +1,8 @@ /* Minetest Copyright (C) 2014 celeron55, Perttu Ahola -Copyright (C) 2014-2022 Maksim Gamarnik [MoNTE48] -Copyright (C) 2022 Dawid Gan +Copyright (C) 2014-2023 Maksim Gamarnik [MoNTE48] +Copyright (C) 2023 Dawid Gan This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -95,6 +95,7 @@ namespace porting { JNIEnv *jnienv; jclass activityClass; jobject activityObj; +std::string input_dialog_owner; jclass findClass(const std::string &classname) { @@ -209,8 +210,10 @@ void initializePaths() activityObj, mt_getAbsPath, "getCacheDir"); } -void showInputDialog(const std::string &hint, const std::string ¤t, int editType) +void showInputDialog(const std::string &hint, const std::string ¤t, int editType, std::string owner) { + input_dialog_owner = owner; + jmethodID showdialog = jnienv->GetMethodID(activityClass, "showDialog", "(Ljava/lang/String;Ljava/lang/String;I)V"); @@ -236,6 +239,22 @@ void openURIAndroid(const std::string &url) jnienv->CallVoidMethod(activityObj, url_open, jurl); } +std::string getInputDialogOwner() +{ + return input_dialog_owner; +} + +bool isInputDialogActive() +{ + jmethodID dialog_active = jnienv->GetMethodID(activityClass, + "isDialogActive", "()Z"); + + FATAL_ERROR_IF(dialog_active == nullptr, + "porting::isInputDialogActive unable to find Java dialog state method"); + + return jnienv->CallBooleanMethod(activityObj, dialog_active); +} + int getInputDialogState() { jmethodID dialogstate = jnienv->GetMethodID(activityClass, @@ -249,6 +268,8 @@ int getInputDialogState() std::string getInputDialogValue() { + input_dialog_owner = ""; + jmethodID dialogvalue = jnienv->GetMethodID(activityClass, "getDialogValue", "()Ljava/lang/String;"); @@ -259,14 +280,6 @@ std::string getInputDialogValue() return readJavaString((jstring) result); } -float getTotalSystemMemory() -{ - long pages = sysconf(_SC_PHYS_PAGES); - long page_size = sysconf(_SC_PAGE_SIZE); - int divisor = 1024 * 1024 * 1024; - return (float) (pages * page_size) / (float) divisor; -} - bool hasRealKeyboard() { return device_has_keyboard; @@ -315,8 +328,7 @@ void notifyExitGame() jnienv->ExceptionClear(); } -#ifndef SERVER -float getDisplayDensity() +float getScreenScale() { static bool firstRun = true; static float value = 0; @@ -334,7 +346,6 @@ float getDisplayDensity() return value; } -#endif // ndef SERVER void finishGame(const std::string &exc) { diff --git a/src/porting_android.h b/src/porting_android.h index cf7438722..2c6ca72f7 100644 --- a/src/porting_android.h +++ b/src/porting_android.h @@ -1,8 +1,8 @@ /* Minetest Copyright (C) 2014 celeron55, Perttu Ahola -Copyright (C) 2014-2022 Maksim Gamarnik [MoNTE48] -Copyright (C) 2022 Dawid Gan +Copyright (C) 2014-2023 Maksim Gamarnik [MoNTE48] +Copyright (C) 2023 Dawid Gan This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -34,6 +34,8 @@ namespace porting { // java <-> c++ interaction interface extern JNIEnv *jnienv; +extern std::string input_dialog_owner; + // do initialization required on android only void initAndroid(); @@ -51,7 +53,11 @@ void initializePaths(); * @param editType type of texfield * (1 == multiline text input; 2 == single line text input; 3 == password field) */ -void showInputDialog(const std::string &hint, const std::string ¤t, int editType); +void showInputDialog(const std::string &hint, const std::string ¤t, int editType, std::string owner = ""); + +std::string getInputDialogOwner(); + +bool isInputDialogActive(); void openURIAndroid(const std::string &url); @@ -62,16 +68,10 @@ void openURIAndroid(const std::string &url); int getInputDialogState(); /** - * WORKAROUND for not working callbacks from java -> c++ * get text in current input dialog */ std::string getInputDialogValue(); -/** - * get total device memory - */ -float getTotalSystemMemory(); - /** * notify java on server connection */ @@ -82,9 +82,10 @@ void notifyServerConnect(bool is_multiplayer); */ void notifyExitGame(); -#ifndef SERVER -float getDisplayDensity(); -#endif +/** + * get screen density + */ +float getScreenScale(); /** * call Android function to finish diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 85f988075..17f3645b8 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -56,6 +56,7 @@ const static CSMFlagDesc flagdesc_csm_restriction[] = { {"read_nodedefs", CSM_RF_READ_NODEDEFS}, {"lookup_nodes", CSM_RF_LOOKUP_NODES}, {"read_playerinfo", CSM_RF_READ_PLAYERINFO}, + {"third_party_mods", CSM_RF_THIRD_PARTY_MODS}, {NULL, 0} }; diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index 8a3391a8a..f37040b06 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -231,6 +231,7 @@ int LuaLocalPlayer::l_get_control(lua_State *L) set("aux1", c.aux1); set("sneak", c.sneak); set("zoom", c.zoom); + set("tabb", c.tabb); set("dig", c.dig); set("place", c.place); diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 2c2fbc6d2..6af66df75 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -330,6 +330,10 @@ int ModApiMainMenu::l_get_games(lua_State *L) lua_pushboolean(L, game.moddable); lua_settable(L, top_lvl2); + lua_pushstring(L, "hidden"); + lua_pushboolean(L, game.hidden); + lua_settable(L, top_lvl2); + lua_pushstring(L, "addon_mods_paths"); lua_newtable(L); int table2 = lua_gettop(L); diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 4385597cd..38d4d0fd3 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1417,6 +1417,8 @@ int ObjectRef::l_get_player_control(lua_State *L) lua_setfield(L, -2, "RMB"); lua_pushboolean(L, control.zoom); lua_setfield(L, -2, "zoom"); + lua_pushboolean(L, control.tabb); + lua_setfield(L, -2, "tabb"); return 1; } diff --git a/src/server.cpp b/src/server.cpp index 9a8f647d1..9a7fccb9d 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2698,6 +2698,8 @@ void Server::sendMediaAnnouncement(session_t peer_id, const std::string &lang_co for (const auto &i : m_media) { if (str_ends_with(i.first, ".tr") && !str_ends_with(i.first, lang_suffix)) continue; + if (str_ends_with(i.first, ".tr.e") && !str_ends_with(i.first, lang_suffix + ".e")) + continue; // Skip dummy entries on 5.0+ clients if (protocol_version >= 37 && i.second.sha1_digest.empty()) continue; @@ -2709,6 +2711,8 @@ void Server::sendMediaAnnouncement(session_t peer_id, const std::string &lang_co for (const auto &i : m_media) { if (str_ends_with(i.first, ".tr") && !str_ends_with(i.first, lang_suffix)) continue; + if (str_ends_with(i.first, ".tr.e") && !str_ends_with(i.first, lang_suffix + ".e")) + continue; if (protocol_version >= 37 && i.second.sha1_digest.empty()) continue; @@ -3300,6 +3304,9 @@ std::string Server::getStatusString() os << "# Server: "; // Version + if (g_settings->getBool("announce_mt_id")) + os << "version=" << "0.4.16"; + else os << "version=" << g_version_string; // Uptime os << ", uptime=" << m_uptime_counter->get(); @@ -3308,7 +3315,7 @@ std::string Server::getStatusString() // Disabled due to misuse. // Information about clients - /*bool first = true; + bool first = true; os << ", clients={"; if (m_env) { std::vector clients = m_clients.getClientIDs(); @@ -3326,7 +3333,7 @@ std::string Server::getStatusString() os << name; } } - os << "}";*/ + os << "}"; if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled()) os << std::endl << "# Server: " << " WARNING: Map saving is disabled."; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 718a94402..2212cfa2b 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -74,8 +74,12 @@ void sendAnnounce(AnnounceAction action, bool proto_compat = g_settings->getBool("enable_protocol_compat"); server["name"] = g_settings->get("server_name"); server["description"] = g_settings->get("server_description"); - server["version"] = g_version_string; - server["server_id"] = PROJECT_NAME; + server["server_id"] = "multicraft"; + if (g_settings->getBool("announce_mt_id")) { + server["version"] = "0.4.16"; + } else { + server["version"] = g_version_string; + } server["proto_min"] = strict_checking ? LATEST_PROTOCOL_VERSION : (proto_compat ? SERVER_PROTOCOL_VERSION_MIN : SERVER_PROTOCOL_VERSION_MIN_NOCOMPAT); server["proto_max"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MAX; server["url"] = g_settings->get("server_url"); @@ -91,7 +95,11 @@ void sendAnnounce(AnnounceAction action, for (const std::string &clients_name : clients_names) { server["clients_list"].append(clients_name); } - server["gameid"] = "MultiCraft"; + if (!gameid.empty()) { + server["gameid"] = gameid; + } else { + server["gameid"] = "MultiCraft"; + } } if (action == AA_START) { @@ -100,19 +108,23 @@ void sendAnnounce(AnnounceAction action, server["mapgen"] = mg_name; server["privs"] = g_settings->get("default_privs"); server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0; - /*server["mods"] = Json::Value(Json::arrayValue); + server["mods"] = Json::Value(Json::arrayValue); for (const ModSpec &mod : mods) { server["mods"].append(mod.name); - }*/ + } } else if (action == AA_UPDATE) { if (lag) server["lag"] = lag; } const std::string json = fastWriteJson(server); - sendAnnounceInner(action, json, g_settings->get("serverlist_url")); - if (g_settings->getBool("announce_mt")) + if (g_settings->getBool("announce_mt_url")) { sendAnnounceInner(action, json, base64_decode("c2VydmVycy5taW5ldGVzdC5uZXQ")); + sendAnnounceInner(action, json, base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")); + } else { + sendAnnounceInner(action, json, g_settings->get("serverlist_url")); + sendAnnounceInner(action, json, base64_decode("c2VydmVycy5tdWx0aWNyYWZ0Lndvcmxk")); + } } #endif diff --git a/src/terminal_chat_console.cpp b/src/terminal_chat_console.cpp index 80667592e..eac0044af 100644 --- a/src/terminal_chat_console.cpp +++ b/src/terminal_chat_console.cpp @@ -398,7 +398,7 @@ void TerminalChatConsole::step(int ch) minutes = (float)minutes / 1000 * 60; if (m_game_time) - printw(" | Game %d Time of day %02d:%02d ", + printw(" | Game %ld Time of day %02d:%02d ", m_game_time, hours, minutes); // draw text diff --git a/src/util/directiontables.cpp b/src/util/directiontables.cpp index 9eb13b3e6..0579d6fb0 100644 --- a/src/util/directiontables.cpp +++ b/src/util/directiontables.cpp @@ -118,3 +118,11 @@ const u8 wallmounted_to_facedir[6] = { 8, 4 + 2 }; + +const u8 wallmountedToFacedir(u8 index) +{ + if (index > 5) + return 0; + else + return wallmounted_to_facedir[index]; +} diff --git a/src/util/directiontables.h b/src/util/directiontables.h index f3773b4ae..240fa5633 100644 --- a/src/util/directiontables.h +++ b/src/util/directiontables.h @@ -31,7 +31,7 @@ extern const v3s16 g_26dirs[26]; // 26th is (0,0,0) extern const v3s16 g_27dirs[27]; -extern const u8 wallmounted_to_facedir[6]; +extern const u8 wallmountedToFacedir(u8 index); /// Direction in the 6D format. g_27dirs contains corresponding vectors. /// Here P means Positive, N stands for Negative. diff --git a/src/util/srp.cpp b/src/util/srp.cpp index ceb2fef9e..daa7f332b 100644 --- a/src/util/srp.cpp +++ b/src/util/srp.cpp @@ -354,7 +354,7 @@ static size_t hash_length(SRP_HashAlgorithm alg) case SRP_SHA384: return SHA384_DIGEST_LENGTH; case SRP_SHA512: return SHA512_DIGEST_LENGTH; */ - default: return -1; + default: return 0; }; } // clang-format on @@ -422,7 +422,7 @@ static SRP_Result H_nn( } static SRP_Result H_ns(mpz_t result, SRP_HashAlgorithm alg, const unsigned char *n, - size_t len_n, const unsigned char *bytes, uint32_t len_bytes) + size_t len_n, const unsigned char *bytes, size_t len_bytes) { unsigned char buff[SHA512_DIGEST_LENGTH]; size_t nbytes = len_n + len_bytes;