Compare commits

..

1 Commits

Author SHA1 Message Date
Simon Robertshaw
9c1ffdccc1 Very old Powder Toy source code tar ~2009 2021-03-22 21:56:29 +00:00
815 changed files with 8688 additions and 103565 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore

2
.github/.gitignore vendored
View File

@ -1,2 +0,0 @@
build_init.bat
jdk.ini

515
.github/build.sh vendored
View File

@ -1,515 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
if [[ -z ${BSH_BUILD_PLATFORM-} ]]; then >&2 echo "BSH_BUILD_PLATFORM not set"; exit 1; fi
if [[ -z ${BSH_HOST_ARCH-} ]]; then >&2 echo "BSH_HOST_ARCH not set"; exit 1; fi
if [[ -z ${BSH_HOST_PLATFORM-} ]]; then >&2 echo "BSH_HOST_PLATFORM not set"; exit 1; fi
if [[ -z ${BSH_HOST_LIBC-} ]]; then >&2 echo "BSH_HOST_LIBC not set"; exit 1; fi
if [[ -z ${BSH_STATIC_DYNAMIC-} ]]; then >&2 echo "BSH_STATIC_DYNAMIC not set"; exit 1; fi
if [[ -z ${BSH_DEBUG_RELEASE-} ]]; then >&2 echo "BSH_DEBUG_RELEASE not set"; exit 1; fi
if [[ -z ${RELEASE_NAME-} ]]; then >&2 echo "RELEASE_NAME not set"; exit 1; fi
if [[ -z ${RELEASE_TYPE-} ]]; then >&2 echo "RELEASE_TYPE not set"; exit 1; fi
if [[ -z ${MOD_ID-} ]]; then >&2 echo "MOD_ID not set"; exit 1; fi
if [[ -z ${SEPARATE_DEBUG-} ]]; then >&2 echo "SEPARATE_DEBUG not set"; exit 1; fi
if [[ -z ${PACKAGE_MODE-} ]]; then >&2 echo "PACKAGE_MODE not set"; exit 1; fi
if [[ -z ${ASSET_PATH-} ]]; then >&2 echo "ASSET_PATH not set"; exit 1; fi
if [[ -z ${DEBUG_ASSET_PATH-} ]]; then >&2 echo "DEBUG_ASSET_PATH not set"; exit 1; fi
if [[ -z ${APP_NAME-} ]]; then >&2 echo "APP_NAME not set"; exit 1; fi
if [[ -z ${APP_COMMENT-} ]]; then >&2 echo "APP_COMMENT not set"; exit 1; fi
if [[ -z ${APP_EXE-} ]]; then >&2 echo "APP_EXE not set"; exit 1; fi
if [[ -z ${APP_ID-} ]]; then >&2 echo "APP_ID not set"; exit 1; fi
if [[ -z ${APP_DATA-} ]]; then >&2 echo "APP_DATA not set"; exit 1; fi
if [[ -z ${APP_VENDOR-} ]]; then >&2 echo "APP_VENDOR not set"; exit 1; fi
case $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_STATIC_DYNAMIC in
x86_64-linux-gnu-static) ;;
x86_64-linux-gnu-dynamic) ;;
x86_64-windows-mingw-static) ;;
x86_64-windows-mingw-dynamic) ;;
x86_64-windows-msvc-static) ;;
x86_64-windows-msvc-dynamic) ;;
x86-windows-msvc-static) ;;
x86-windows-msvc-dynamic) ;;
x86_64-darwin-macos-static) ;;
x86_64-darwin-macos-dynamic) ;;
aarch64-darwin-macos-static) ;;
aarch64-darwin-macos-dynamic) ;;
x86-android-bionic-static) ;;
x86_64-android-bionic-static) ;;
arm-android-bionic-static) ;;
aarch64-android-bionic-static) ;;
wasm32-emscripten-emscripten-static) ;;
*) >&2 echo "configuration $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_STATIC_DYNAMIC is not supported" && exit 1;;
esac
if [[ $BSH_HOST_PLATFORM == android ]]; then
android_platform=android-31
if [[ -z "${JAVA_HOME_8_X64-}" ]]; then
>&2 echo "JAVA_HOME_8_X64 not set"
exit 1
fi
if [[ -z "${ANDROID_SDK_ROOT-}" ]]; then
>&2 echo "ANDROID_SDK_ROOT not set"
exit 1
fi
if [[ -z "${ANDROID_NDK_LATEST_HOME-}" ]]; then
>&2 echo "ANDROID_NDK_LATEST_HOME not set"
exit 1
fi
fi
if [[ -z ${BSH_NO_PACKAGES-} ]]; then
case $BSH_HOST_PLATFORM in
android)
(
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/tools/bin:$PATH
sdkmanager "platforms;$android_platform"
)
;;
windows)
if [[ $BSH_BUILD_PLATFORM-$BSH_HOST_LIBC == windows-mingw ]]; then
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-gcc
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-{cmake,7zip,jq} patch
else
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-{pkgconf,bzip2,luajit,jsoncpp,curl,SDL2,libpng,meson,fftw,jq}
fi
export PKG_CONFIG=$(which pkg-config.exe)
fi
;;
linux)
sudo apt update
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
sudo apt install libc6-dev libc6-dev-i386
else
sudo apt install libluajit-5.1-dev libcurl4-openssl-dev libfftw3-dev zlib1g-dev libsdl2-dev libbz2-dev libjsoncpp-dev
fi
;;
darwin)
brew install pkg-config binutils
if [[ $BSH_STATIC_DYNAMIC != static ]]; then
brew install luajit curl fftw zlib sdl2 bzip2 jsoncpp
fi
;;
emscripten)
git clone https://github.com/emscripten-core/emsdk.git --branch 3.1.30
cd emsdk
./emsdk install latest
./emsdk activate latest
. ./emsdk_env.sh
cd ..
;;
esac
fi
function inplace_sed() {
local subst=$1
local path=$2
if [[ $BSH_BUILD_PLATFORM == darwin ]]; then
sed -i "" -e $subst $path
else
sed -i $subst $path
fi
}
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == windows-msvc ]]; then
case $BSH_HOST_ARCH in
x86_64) vs_env_arch=x64;;
x86) vs_env_arch=x86;;
esac
VS_ENV_PARAMS=$vs_env_arch$'\t'-vcvars_ver=14.1
. ./.github/vs-env.sh
elif [[ $BSH_HOST_PLATFORM == darwin ]]; then
# may need export SDKROOT=$(xcrun --show-sdk-path --sdk macosx11.1)
CC=clang
CXX=clang++
if [[ $BSH_HOST_ARCH == aarch64 ]]; then
macos_min_ver=11.0
CC+=" -arch arm64"
CXX+=" -arch arm64"
else
macos_min_ver=10.13
CC+=" -arch x86_64"
CXX+=" -arch x86_64"
fi
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
export MACOSX_DEPLOYMENT_TARGET=$macos_min_ver
fi
export CC
export CXX
elif [[ $BSH_HOST_PLATFORM == android ]]; then
case $BSH_HOST_ARCH in
x86_64) android_toolchain_prefix=x86_64-linux-android ; android_system_version=21; android_arch_abi=x86_64 ;;
x86) android_toolchain_prefix=i686-linux-android ; android_system_version=21; android_arch_abi=x86 ;;
aarch64) android_toolchain_prefix=aarch64-linux-android ; android_system_version=21; android_arch_abi=arm64-v8a ;;
arm) android_toolchain_prefix=armv7a-linux-androideabi; android_system_version=21; android_arch_abi=armeabi-v7a;;
esac
android_toolchain_dir=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64
CC=$android_toolchain_dir/bin/$android_toolchain_prefix$android_system_version-clang
CXX=$android_toolchain_dir/bin/$android_toolchain_prefix$android_system_version-clang++
LD=$android_toolchain_dir/bin/$android_toolchain_prefix-ld
AR=$android_toolchain_dir/bin/llvm-ar
echo $AR
CC+=" -fPIC"
CXX+=" -fPIC"
LD+=" -fPIC"
export CC
export CXX
export LD
export AR
else
export CC=gcc
export CXX=g++
fi
if [[ -d build ]]; then
rm -r build
fi
c_args=
c_link_args=
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC != windows-msvc ]]; then
c_args+=\'-ffunction-sections\',
c_args+=\'-fdata-sections\',
if [[ $BSH_HOST_PLATFORM == darwin ]]; then
c_link_args+=\'-Wl,-dead_strip\',
else
c_link_args+=\'-Wl,--gc-sections\',
fi
fi
if [[ $BSH_HOST_PLATFORM-$BSH_STATIC_DYNAMIC == darwin-static ]]; then
c_args+=\'-mmacosx-version-min=$macos_min_ver\',
c_link_args+=\'-mmacosx-version-min=$macos_min_ver\',
fi
meson_configure=meson$'\t'setup
if [[ $BSH_DEBUG_RELEASE == release ]]; then
meson_configure+=$'\t'-Dbuildtype=debugoptimized
fi
if [[ $BSH_HOST_PLATFORM == darwin ]]; then
meson_configure+=$'\t'-Dmanifest_macos_min_ver=$macos_min_ver
else
meson_configure+=$'\t'-Dmanifest_date=$(date --iso-8601)
fi
meson_configure+=$'\t'-Dapp_name=$APP_NAME
meson_configure+=$'\t'-Dapp_comment=$APP_COMMENT
meson_configure+=$'\t'-Dapp_exe=$APP_EXE
meson_configure+=$'\t'-Dapp_id=$APP_ID
meson_configure+=$'\t'-Dapp_data=$APP_DATA
meson_configure+=$'\t'-Dapp_vendor=$APP_VENDOR
meson_configure+=$'\t'-Dstrip=false
meson_configure+=$'\t'-Db_staticpic=false
meson_configure+=$'\t'-Dmod_id=$MOD_ID
case $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_DEBUG_RELEASE in
x86_64-linux-gnu-debug) ;&
x86_64-windows-mingw-debug) ;&
x86_64-windows-msvc-debug) ;&
x86_64-darwin-macos-debug)
meson_configure+=$'\t'-Dbuild_render=true
meson_configure+=$'\t'-Dbuild_font=true
;;
esac
if [[ $PACKAGE_MODE == nohttp ]]; then
meson_configure+=$'\t'-Dhttp=false
fi
if [[ $PACKAGE_MODE == nolua ]]; then
meson_configure+=$'\t'-Dlua=none
fi
if [[ $PACKAGE_MODE == backendvs ]]; then
meson_configure+=$'\t'-Dbackend=vs
# meson 1.2.3 configures vs projects that bring their own manifest, which conflicts with ours
# TODO: remove this patch once https://github.com/mesonbuild/meson/pull/12472 makes it into a release that we can use
meson_configure+=$'\t'-Dwindows_utf8cp=false
fi
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
meson_configure+=$'\t'-Dstatic=prebuilt
if [[ $BSH_HOST_PLATFORM == windows ]]; then
if [[ $BSH_HOST_LIBC == msvc ]]; then
meson_configure+=$'\t'-Db_vscrt=static_from_buildtype
else
c_link_args+=\'-static\',
c_link_args+=\'-static-libgcc\',
c_link_args+=\'-static-libstdc++\',
fi
elif [[ $BSH_HOST_PLATFORM == linux ]]; then
c_link_args+=\'-static-libgcc\',
c_link_args+=\'-static-libstdc++\',
fi
else
if [[ "$BSH_HOST_PLATFORM-$BSH_HOST_LIBC $BSH_BUILD_PLATFORM" == "windows-mingw windows" ]]; then
meson_configure+=$'\t'-Dworkaround_elusive_bzip2=true
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_include_dir=/ucrt64/include
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_lib_dir=/ucrt64/lib
fi
if [[ $BSH_BUILD_PLATFORM == linux ]]; then
meson_configure+=$'\t'-Dworkaround_elusive_bzip2=true
fi
if [[ $BSH_BUILD_PLATFORM == darwin ]]; then
meson_configure+=$'\t'-Dworkaround_elusive_bzip2=true
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_lib_dir=/usr/local/opt/bzip2/lib
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_include_dir=/usr/local/opt/bzip2/include
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_static=true
fi
fi
if [[ $BSH_HOST_PLATFORM == linux ]] && [[ $BSH_HOST_ARCH != aarch64 ]]; then
# certain file managers can't run PIEs https://bugzilla.gnome.org/show_bug.cgi?id=737849
meson_configure+=$'\t'-Db_pie=false
c_link_args+=\'-no-pie\',
fi
stable_or_beta=no
if [[ $RELEASE_TYPE == beta ]]; then
meson_configure+=$'\t'-Dbeta=true
stable_or_beta=yes
fi
if [[ $RELEASE_TYPE == stable ]]; then
stable_or_beta=yes
fi
if [[ $stable_or_beta == yes ]]; then
xyz=$(echo $RELEASE_NAME | cut -d 'v' -f 2 | cut -d 'b' -f 1) # $RELEASE_NAME is vX.Y.Z or vX.Y.Zb
display_version_major=$(echo $xyz | cut -d '.' -f 1)
display_version_minor=$(echo $xyz | cut -d '.' -f 2)
build_num=$(echo $xyz | cut -d '.' -f 3)
if [[ $MOD_ID != 0 ]]; then
meson_configure+=$'\t'-Ddisplay_version_major=$display_version_major
meson_configure+=$'\t'-Ddisplay_version_minor=$display_version_minor
meson_configure+=$'\t'-Dbuild_num=$build_num
fi
fi
if [[ $RELEASE_TYPE == snapshot ]]; then
build_num=$(echo $RELEASE_NAME | cut -d '-' -f 2) # $RELEASE_NAME is snapshot-X
meson_configure+=$'\t'-Dsnapshot=true
if [[ $MOD_ID != 0 ]]; then
meson_configure+=$'\t'-Dbuild_num=$build_num
fi
fi
if [[ $RELEASE_TYPE == snapshot ]] && [[ $MOD_ID != 0 ]]; then
>&2 echo "mods and snapshots do not mix"
exit 1
fi
if [[ $RELEASE_TYPE == snapshot ]] || [[ $MOD_ID != 0 ]]; then
meson_configure+=$'\t'-Dupdate_server=starcatcher.us/TPT
if [[ $BSH_HOST_PLATFORM == emscripten ]]; then
meson_configure+=$'\t'-Dserver=tptserv.starcatcher.us
meson_configure+=$'\t'-Dstatic_server=tptserv.starcatcher.us/Static
fi
fi
if [[ $RELEASE_TYPE != dev ]]; then
meson_configure+=$'\t'-Dignore_updates=false
fi
if [[ "$BSH_HOST_PLATFORM-$BSH_HOST_LIBC" == "windows-mingw" ]]; then
meson_configure+=$'\t'--cross-file=.github/mingw-ghactions.ini
# there is some mingw bug that only ever manifests on ghactions which makes MakeIco.exe use tons of memory and fail
# TODO: remove this hack once we figure out how to fix that
meson_configure+=$'\t'-Dwindows_icons=false
fi
if [[ $BSH_DEBUG_RELEASE-$BSH_STATIC_DYNAMIC == release-static ]]; then
meson_configure+=$'\t'-Db_lto=true
fi
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_ARCH == darwin-aarch64 ]]; then
meson_configure+=$'\t'--cross-file=.github/macaa64-ghactions.ini
fi
if [[ $BSH_HOST_PLATFORM == emscripten ]]; then
meson_configure+=$'\t'--cross-file=.github/emscripten-ghactions.ini
fi
if [[ $RELEASE_TYPE == tptlibsdev ]] && ([[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == windows-msvc ]] || [[ $BSH_STATIC_DYNAMIC == static ]]); then
if [[ -z ${TPTLIBSREMOTE-} ]]; then
if [[ -z "${GITHUB_REPOSITORY_OWNER-}" ]]; then
>&2 echo "GITHUB_REPOSITORY_OWNER not set"
exit 1
fi
tptlibsremote=https://github.com/$GITHUB_REPOSITORY_OWNER/tpt-libs
else
tptlibsremote=$TPTLIBSREMOTE
fi
tptlibsbranch=$(echo $RELEASE_NAME | cut -d '-' -f 2-) # $RELEASE_NAME is tptlibsdev-BRANCH
if [[ -d build-tpt-libs ]] && [[ ${TPTLIBSRESET-} == yes ]]; then
rm -rf build-tpt-libs
fi
if [[ ! -d build-tpt-libs/tpt-libs ]]; then
mkdir -p build-tpt-libs
cd build-tpt-libs
git clone $tptlibsremote --branch $tptlibsbranch --depth 1
cd ..
fi
tpt_libs_vtag=v00000000000000
if [[ ! -f build-tpt-libs/tpt-libs/.ok ]]; then
cd build-tpt-libs/tpt-libs
BSH_VTAG=$tpt_libs_vtag ./.github/build.sh
touch .ok
cd ../../subprojects
for i in tpt-libs-prebuilt-*; do
if [[ -d $i ]]; then
rm -r $i
fi
done
7z x ../build-tpt-libs/tpt-libs/temp/libraries.zip
cd ..
fi
meson_configure+=$'\t'-Dtpt_libs_vtag=$tpt_libs_vtag
fi
if [[ $BSH_HOST_PLATFORM == android ]]; then
android_platform_jar=$ANDROID_SDK_ROOT/platforms/$android_platform/android.jar
if ! [[ -f $android_platform_jar ]]; then
>&2 echo "$android_platform_jar not found"
exit 1
fi
meson_configure+=$'\t'--cross-file=android/cross/$BSH_HOST_ARCH.ini
cat << ANDROID_INI > .github/android-ghactions.ini
[constants]
andriod_ndk_toolchain_bin = '$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin'
andriod_sdk_build_tools = '$ANDROID_SDK_ROOT/build-tools/32.0.0'
[properties]
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross
android_ndk_toolchain_prefix = android_ndk_toolchain_prefix
android_platform = '$android_platform'
android_platform_jar = '$android_platform_jar'
java_runtime_jar = '$JAVA_HOME_8_X64/jre/lib/rt.jar'
[binaries]
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross
c = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang')
cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++')
strip = andriod_ndk_toolchain_bin / 'llvm-strip'
javac = '$JAVA_HOME_8_X64/bin/javac'
jar = '$JAVA_HOME_8_X64/bin/jar'
d8 = andriod_sdk_build_tools / 'd8'
aapt = andriod_sdk_build_tools / 'aapt'
aapt2 = andriod_sdk_build_tools / 'aapt2'
zipalign = andriod_sdk_build_tools / 'zipalign'
apksigner = andriod_sdk_build_tools / 'apksigner'
ANDROID_INI
meson_configure+=$'\t'--cross-file=.github/android-ghactions.ini
fi
meson_configure+=$'\t'-Dc_args=[$c_args]
meson_configure+=$'\t'-Dcpp_args=[$c_args]
meson_configure+=$'\t'-Dc_link_args=[$c_link_args]
meson_configure+=$'\t'-Dcpp_link_args=[$c_link_args]
$meson_configure build
cd build
function verify_version_component() {
local key=$1
local expected=$2
local actual=$(jq -r '.[] | select(.name == "'$key'") | .value' < meson-info/intro-buildoptions.json)
if [[ $actual != $expected ]]; then
>&2 echo "meson option $key expected to be $expected, is instead $actual"
exit 1
fi
}
if [[ $stable_or_beta == yes ]] && [[ $MOD_ID == 0 ]]; then
verify_version_component display_version_major $display_version_major
verify_version_component display_version_minor $display_version_minor
verify_version_component build_num $build_num
verify_version_component upstream_version_major $display_version_major
verify_version_component upstream_version_minor $display_version_minor
verify_version_component upstream_build_num $build_num
fi
if [[ $RELEASE_TYPE == snapshot ]] && [[ $MOD_ID == 0 ]]; then
verify_version_component build_num $build_num
verify_version_component upstream_build_num $build_num
fi
strip=strip
objcopy=objcopy
strip_target=$ASSET_PATH
if [[ $BSH_HOST_PLATFORM == android ]]; then
strip=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-$strip
objcopy=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-$objcopy
strip_target=lib$APP_EXE.so
fi
if [[ $PACKAGE_MODE == appimage ]]; then
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
meson configure -Dcan_install=no -Dignore_updates=true -Dbuild_render=false -Dbuild_font=false
strip_target=$APP_EXE
fi
meson_compile=meson$'\t'compile
meson_compile+=$'\t'-v
if [[ $BSH_BUILD_PLATFORM == windows ]] && [[ $PACKAGE_MODE != backendvs ]]; then
set +e
meson_compile+=$'\t'--ninja-args='["-d","keeprsp"]'
$meson_compile
ninja_code=$?
set -e
cat $APP_EXE.exe.rsp
[[ $ninja_code == 0 ]];
echo # rsps don't usually have a newline at the end
if [[ "$BSH_HOST_PLATFORM-$BSH_STATIC_DYNAMIC $BSH_BUILD_PLATFORM" == "windows-dynamic windows" ]]; then
# on windows we provide the dynamic dependencies also; makes sense to check for their presence
# msys ldd works fine but only on windows build machines
if ldd $APP_EXE | grep "not found"; then
exit 1 # ldd | grep will have printed missing deps
fi
fi
else
$meson_compile
fi
if [[ $SEPARATE_DEBUG == yes ]] && [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC != windows-msvc ]]; then
$objcopy --only-keep-debug $strip_target $DEBUG_ASSET_PATH
$strip --strip-debug --strip-unneeded $strip_target
$objcopy --add-gnu-debuglink $DEBUG_ASSET_PATH $strip_target
chmod -x $DEBUG_ASSET_PATH
fi
if [[ $BSH_HOST_PLATFORM == android ]]; then
$JAVA_HOME_8_X64/bin/keytool -genkeypair -keystore keystore.jks -alias androidkey -validity 10000 -keyalg RSA -keysize 2048 -keypass bagelsbagels -storepass bagelsbagels -dname "CN=nobody"
meson configure -Dandroid_keystore=$(realpath keystore.jks)
ANDROID_KEYSTORE_PASS=bagelsbagels ninja android/$APP_EXE.apk
mv android/$APP_EXE.apk $APP_EXE.apk
fi
if [[ $PACKAGE_MODE == dmg ]]; then
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == darwin-macos
appdir=$APP_NAME.app
mkdir $appdir
mkdir $appdir/Contents
cp resources/Info.plist $appdir/Contents/Info.plist
mkdir $appdir/Contents/MacOS
cp $APP_EXE $appdir/Contents/MacOS/$APP_EXE
mkdir $appdir/Contents/Resources
mkdir icon_exe.iconset
cp ../resources/generated_icons/icon_exe_16.png icon_exe.iconset/icon_16x16.png
cp ../resources/generated_icons/icon_exe_32.png icon_exe.iconset/icon_32x32.png
cp ../resources/generated_icons/icon_exe.png icon_exe.iconset/icon_128x128.png
iconutil -c icns icon_exe.iconset
cp icon_exe.icns $appdir/Contents/Resources/icon_exe.icns
mkdir icon_cps.iconset
cp ../resources/generated_icons/icon_cps_16.png icon_cps.iconset/icon_16x16.png
cp ../resources/generated_icons/icon_cps_32.png icon_cps.iconset/icon_32x32.png
cp ../resources/generated_icons/icon_cps.png icon_cps.iconset/icon_128x128.png
iconutil -c icns icon_cps.iconset
cp icon_cps.icns $appdir/Contents/Resources/icon_cps.icns
mkdir dmgroot
mv $appdir dmgroot/$appdir
cp ../LICENSE dmgroot/LICENSE
cp ../README.md dmgroot/README.md
hdiutil create -format UDZO -volname $APP_NAME -fs HFS+ -srcfolder dmgroot -o $ASSET_PATH
elif [[ $PACKAGE_MODE == emscripten ]]; then
tar cvf $ASSET_PATH $APP_EXE.js $APP_EXE.worker.js $APP_EXE.wasm
elif [[ $PACKAGE_MODE == appimage ]]; then
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
case $BSH_HOST_ARCH in
aarch64) appimage_arch=aarch64;;
arm) appimage_arch=armhf ;;
x86) appimage_arch=i686 ;;
x86_64) appimage_arch=x86_64 ;;
esac
curl -fsSLo appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$appimage_arch.AppImage"
curl -fsSLo AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-$appimage_arch"
chmod +x appimagetool
chmod +x AppRun
appdir=bagels.AppDir # doesn't matter, won't be visible in the resulting appimage
mkdir -p $appdir/usr/bin
mkdir -p $appdir/usr/share/metainfo
mkdir -p $appdir/usr/share/applications
mkdir -p $appdir/usr/share/icons
cp $APP_EXE $appdir/usr/bin/$APP_EXE
mv AppRun $appdir/AppRun
cp ../resources/icon_exe.svg $appdir/$APP_VENDOR-$APP_EXE.svg
cp resources/powder.desktop $appdir/$APP_ID.desktop
cp resources/appdata.xml $appdir/usr/share/metainfo/$APP_ID.appdata.xml
cp $appdir/$APP_VENDOR-$APP_EXE.svg $appdir/usr/share/icons/$APP_VENDOR-$APP_EXE.svg
cp $appdir/$APP_ID.desktop $appdir/usr/share/applications/$APP_ID.desktop
./appimagetool $appdir $ASSET_PATH
fi

View File

@ -1,4 +0,0 @@
set -euo pipefail
IFS=$'\t\n'
gh release create --draft --verify-tag --title $RELEASE_NAME $GITHUB_REF_NAME

View File

@ -1,11 +0,0 @@
[binaries]
c = 'emcc'
cpp = 'em++'
strip = 'emstrip'
ar = 'emar'
[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'

View File

@ -1,11 +0,0 @@
[binaries]
c = [ 'clang', '-arch', 'arm64' ]
cpp = [ 'clang++', '-arch', 'arm64' ]
objcpp = [ 'clang++', '-arch', 'arm64' ]
strip = 'strip'
[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'armv8'
endian = 'little'

View File

@ -1,14 +0,0 @@
[constants]
prefix = 'x86_64-w64-mingw32'
[binaries]
c = prefix + '-gcc'
cpp = prefix + '-g++'
strip = prefix + '-strip'
windres = prefix + '-windres'
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

1
.github/mod_id.txt vendored
View File

@ -1 +0,0 @@
0

216
.github/prepare.py vendored
View File

@ -1,216 +0,0 @@
import datetime
import json
import os
import re
import subprocess
import sys
ref = os.getenv('GITHUB_REF')
event_name = os.getenv('GITHUB_EVENT_NAME')
publish_hostport = os.getenv('PUBLISH_HOSTPORT')
def set_output(key, value):
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
f.write(f"{key}={value}\n")
match_stable = re.fullmatch(r'refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)', ref)
match_beta = re.fullmatch(r'refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)b', ref)
match_snapshot = re.fullmatch(r'refs/tags/snapshot-([0-9]+)', ref)
match_tptlibsdev = re.fullmatch(r'refs/heads/tptlibsdev-(.*)', ref)
match_alljobs = re.fullmatch(r'refs/heads/(.*)-alljobs', ref)
do_release = False
do_priority = 10
if event_name == 'pull_request':
do_priority = 0
if match_stable:
release_type = 'stable'
release_name = 'v%s.%s.%s' % (match_stable.group(1), match_stable.group(2), match_stable.group(3))
do_release = True
do_priority = 0
elif match_beta:
release_type = 'beta'
release_name = 'v%s.%s.%sb' % (match_beta.group(1), match_beta.group(2), match_beta.group(3))
do_release = True
do_priority = 0
elif match_snapshot:
release_type = 'snapshot'
release_name = 'snapshot-%s' % match_snapshot.group(1)
do_release = True
do_priority = 0
elif match_tptlibsdev:
release_type = 'tptlibsdev'
release_name = 'tptlibsdev-%s' % match_tptlibsdev.group(1)
do_priority = 0
else:
release_type = 'dev'
release_name = 'dev'
if match_alljobs:
do_priority = 0
do_publish = publish_hostport and do_release
set_output('release_type', release_type)
set_output('release_name', release_name)
subprocess.run([ 'meson', 'setup', '-Dprepare=true', 'build-prepare' ], check = True)
build_options = {}
with open('build-prepare/meson-info/intro-buildoptions.json') as f:
for option in json.loads(f.read()):
build_options[option['name']] = option['value']
if int(build_options['mod_id']) == 0 and os.path.exists('.github/mod_id.txt'):
with open('.github/mod_id.txt') as f:
build_options['mod_id'] = f.read()
if int(build_options['mod_id']) == 0:
if release_type == 'stable':
pass
elif release_type == 'beta':
build_options['app_name' ] += ' Beta'
build_options['app_comment'] += ' - Beta'
build_options['app_exe' ] += 'beta'
build_options['app_id' ] += 'beta'
elif release_type == 'snapshot':
build_options['app_name' ] += ' Snapshot'
build_options['app_comment'] += ' - Snapshot'
build_options['app_exe' ] += 'snapshot'
build_options['app_id' ] += 'snapshot'
else:
build_options['app_name' ] += ' Dev'
build_options['app_comment'] += ' - Dev'
build_options['app_exe' ] += 'dev'
build_options['app_id' ] += 'dev'
set_output('mod_id' , build_options['mod_id' ])
set_output('app_name' , build_options['app_name' ])
set_output('app_comment', build_options['app_comment'])
set_output('app_exe' , build_options['app_exe' ])
set_output('app_id' , build_options['app_id' ])
set_output('app_data' , build_options['app_data' ])
set_output('app_vendor' , build_options['app_vendor' ])
app_exe = build_options['app_exe']
app_name = build_options['app_name']
app_name_slug = re.sub('[^A-Za-z0-9]', '_', app_name)
build_matrix = []
publish_matrix = []
# consider disabling line wrapping to edit this monstrosity
for arch, platform, libc, statdyn, bplatform, runson, suffix, publish, artifact, dbgsuffix, mode, starcatcher, dbgrel, priority in [
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'debug', 0 ), # priority = 0: static debug build
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-20.04', '', True, True, '.dbg', None, 'x86_64-lin-gcc-static', 'release', 10 ),
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-20.04', '', False, True, '.dbg', 'appimage', None, 'release', 0 ), # priority = 0: appimage release
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'debug', 10 ),
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, 'nohttp', None, 'debug', 10 ),
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, 'nolua', None, 'debug', 10 ),
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'release', 10 ),
# ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'debug', 10 ), # ubuntu-20.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain
# ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-20.04', '', False, True, '.dbg', None, None, 'release', 10 ), # ubuntu-20.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them; worse, it's a different toolchain
# ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'debug', 10 ), # ubuntu-20.04 doesn't have ucrt64-capable mingw >_>
# ( 'x86_64', 'windows', 'mingw', 'dynamic', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'release', 10 ), # ubuntu-20.04 doesn't have ucrt64-capable mingw >_>
( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 0 ), # priority = 0: static debug build
( 'x86_64', 'windows', 'mingw', 'static', 'windows', 'windows-2019', '.exe', False, True, '.dbg', None, None, 'release', 10 ),
( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 10 ),
( 'x86_64', 'windows', 'mingw', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'release', 10 ),
( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 0 ), # priority = 0: static debug build
( 'x86_64', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', True, True, '.pdb', None,'x86_64-win-msvc-static', 'release', 10 ),
( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 10 ),
# ( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, 'backendvs', None, 'debug', 0 ), # priority = 0: backend=vs build
( 'x86_64', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'release', 10 ),
( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 0 ), # priority = 0: static debug build
( 'x86', 'windows', 'msvc', 'static', 'windows', 'windows-2019', '.exe', True, True, '.pdb', None, 'i686-win-msvc-static', 'release', 10 ),
( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'debug', 10 ),
( 'x86', 'windows', 'msvc', 'dynamic', 'windows', 'windows-2019', '.exe', False, False, None, None, None, 'release', 10 ),
( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'debug', 0 ), # priority = 0: static debug build
( 'x86_64', 'darwin', 'macos', 'static', 'darwin', 'macos-12', '.dmg', True, True, None, 'dmg', 'x86_64-mac-gcc-static', 'release', 10 ), # I have no idea how to separate debug info on macos
( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'debug', 10 ),
( 'x86_64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'release', 10 ),
( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'debug', 0 ), # priority = 0: static debug build
( 'aarch64', 'darwin', 'macos', 'static', 'darwin', 'macos-12', '.dmg', True, True, None, 'dmg', 'arm64-mac-gcc-static', 'release', 10 ),
# ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'debug', 10 ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64
# ( 'aarch64', 'darwin', 'macos', 'dynamic', 'darwin', 'macos-12', '.dmg', False, False, None, 'dmg', None, 'release', 10 ), # macos-11.0 is x86_64 and I haven't yet figured out how to get homebrew to install aarch64 libs on x86_64
( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', False, False, None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build
( 'x86', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', True, True, '.dbg', None, 'i686-and-gcc-static', 'release', 10 ),
( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', False, False, None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build
( 'x86_64', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', True, True, '.dbg', None, 'x86_64-and-gcc-static', 'release', 10 ),
( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', False, False, None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build
( 'arm', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', True, True, '.dbg', None, 'arm-and-gcc-static', 'release', 10 ),
( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', False, False, None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build
( 'aarch64', 'android', 'bionic', 'static', 'linux', 'ubuntu-20.04', '.apk', True, True, '.dbg', None, 'arm64-and-gcc-static', 'release', 10 ),
( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-20.04', '.tar', False, False, None, None, None, 'debug', 0 ), # priority = 0: rarely used debug build
( 'wasm32', 'emscripten', 'emscripten', 'static', 'linux', 'ubuntu-20.04', '.tar', True, True, None, 'emscripten', 'wasm32-ems-static', 'release', 10 ), # I have no idea how to separate debug info on emscripten
]:
if priority < do_priority:
continue
job_name = f'build'
if starcatcher:
job_name += f'+target=starcatcher-{starcatcher}'
else:
job_name += f'+target={arch}-{platform}-{libc}-{statdyn}-{dbgrel}'
if mode:
job_name += f'+mode={mode}'
if bplatform != platform:
job_name += f'+bplatform={bplatform}'
if not mode:
mode = 'default'
separate_debug = True
if not dbgsuffix:
dbgsuffix = 'BOGUS'
separate_debug = False
if not starcatcher:
starcatcher = 'BOGUS'
if publish:
assert artifact
if dbgrel != 'release':
assert not publish
assert not artifact
asset_path = f'{app_exe}{suffix}'
asset_name = f'{app_exe}-{release_name}-{arch}-{platform}-{libc}{suffix}'
debug_asset_path = f'{app_exe}{dbgsuffix}'
debug_asset_name = f'{app_exe}-{release_name}-{arch}-{platform}-{libc}{dbgsuffix}'
if mode == 'appimage':
asset_path = f'{app_name_slug}-{arch}.AppImage'
asset_name = f'{app_name_slug}-{arch}.AppImage'
debug_asset_path = f'{app_name_slug}-{arch}.AppImage.dbg'
debug_asset_name = f'{app_name_slug}-{arch}.AppImage.dbg'
starcatcher_name = f'powder-{release_name}-{starcatcher}{suffix}'
msys2_bash = (bplatform == 'windows' and libc == 'mingw')
shell = 'bash'
if msys2_bash:
shell = 'msys2 {0}'
build_matrix.append({
'bsh_build_platform': bplatform, # part of the unique portion of the matrix
'bsh_host_arch': arch, # part of the unique portion of the matrix
'bsh_host_platform': platform, # part of the unique portion of the matrix
'bsh_host_libc': libc, # part of the unique portion of the matrix
'bsh_static_dynamic': statdyn, # part of the unique portion of the matrix
'bsh_debug_release': dbgrel, # part of the unique portion of the matrix
'runs_on': runson,
'force_msys2_bash': msys2_bash and 'yes' or 'no',
'package_suffix': suffix,
'package_mode': mode,
'publish': publish and 'yes' or 'no',
'artifact': artifact and 'yes' or 'no',
'separate_debug': separate_debug and 'yes' or 'no',
'asset_path': asset_path,
'asset_name': asset_name,
'debug_asset_path': debug_asset_path,
'debug_asset_name': debug_asset_name,
'job_name': job_name,
'shell': shell,
})
if publish:
publish_matrix.append({
'bsh_build_platform': bplatform, # part of the unique portion of the matrix
'bsh_host_arch': arch, # part of the unique portion of the matrix
'bsh_host_platform': platform, # part of the unique portion of the matrix
'bsh_host_libc': libc, # part of the unique portion of the matrix
'bsh_static_dynamic': statdyn, # part of the unique portion of the matrix
'asset_path': asset_path,
'asset_name': asset_name,
'starcatcher_name': starcatcher_name,
})
set_output('build_matrix', json.dumps({ 'include': build_matrix }))
set_output('publish_matrix', json.dumps({ 'include': publish_matrix }))
set_output('do_release', do_release and 'yes' or 'no')
set_output('do_publish', do_publish and 'yes' or 'no')

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
cat << NETRC > ~/.netrc
machine $(echo $PUBLISH_HOSTPORT | cut -d ':' -f 1)
login $PUBLISH_USERNAME
password $PUBLISH_PASSWORD
NETRC
chmod 660 ~/.netrc
mountpoint=ftpmnt
mkdir $mountpoint
curlftpfs "$PUBLISH_HOSTPORT" $mountpoint -o ssl,ciphers='ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_8_SHA256:TLS_AES_128_CCM_SHA256'
if [[ -z ${PUBLISH_ACCESSCHECK-} ]]; then
cp $PUBLISH_FILENAME $mountpoint/${PUBLISH_DIRECTORY:-.}/
fi
fusermount -u $mountpoint
rmdir $mountpoint

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
curl "https://starcatcher.us/TPT/perform-release.lua?mod=$MOD_ID&type=$RELEASE_TYPE&name=$RELEASE_NAME&commit=$GITHUB_SHA" > perform_release
if ! grep "Release complete" < perform_release > /dev/null; then
cat perform_release
exit 1
fi

View File

@ -1,12 +0,0 @@
set -euo pipefail
IFS=$'\t\n'
temp=.temp
mkdir $temp
cp $ASSET_PATH $temp/$ASSET_NAME
(
cd $temp
gh release upload $GITHUB_REF_NAME $ASSET_NAME
)
rm -r $temp
echo browser_download_url=https://github.com/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/$ASSET_NAME >> $GITHUB_OUTPUT

31
.github/vs-env.sh vendored
View File

@ -1,31 +0,0 @@
set -euo pipefail
IFS=$'\t\n'
IFS=$'\t\n\r'
for i in $("$(env | grep '^ProgramFiles(x86)=' | cut -d = -f 2-)/Microsoft Visual Studio/Installer/vswhere.exe" \
-sort \
-prerelease \
-requiresAny \
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
-requires Microsoft.VisualStudio.Workload.WDExpress \
-products \* \
-utf8 \
-property installationPath); do
if ! [ -z ${VS_ENV_FILTER-} ]; then
if ! echo $i | grep $VS_ENV_FILTER >/dev/null; then
continue
fi
fi
vs_install_dir=$i
break
done
IFS=$'\t\n'
for i in $(MSYS_NO_PATHCONV=1 cmd /c "$vs_install_dir\\VC\\Auxiliary\\Build\\vcvarsall.bat" $VS_ENV_PARAMS \& env \& exit /b); do
set +e
export "$i" 2>/dev/null
echo $i | grep ERROR
set -e
done
cl

View File

@ -1,182 +0,0 @@
name: build
on:
push:
branches:
- '*'
tags:
- 'v*.*'
- 'snapshot-*'
- 'tptlibsdev-*'
pull_request:
branches:
- '*'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
do_release: ${{ steps.prepare.outputs.do_release }}
build_matrix: ${{ steps.prepare.outputs.build_matrix }}
publish_matrix: ${{ steps.prepare.outputs.publish_matrix }}
release_type: ${{ steps.prepare.outputs.release_type }}
release_name: ${{ steps.prepare.outputs.release_name }}
mod_id: ${{ steps.prepare.outputs.mod_id }}
app_name: ${{ steps.prepare.outputs.app_name }}
app_comment: ${{ steps.prepare.outputs.app_comment }}
app_exe: ${{ steps.prepare.outputs.app_exe }}
app_id: ${{ steps.prepare.outputs.app_id }}
app_data: ${{ steps.prepare.outputs.app_data }}
app_vendor: ${{ steps.prepare.outputs.app_vendor }}
do_publish: ${{ steps.prepare.outputs.do_publish }}
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: python -m pip install meson==1.2.3 ninja # TODO: go back to using latest meson once https://github.com/mesonbuild/meson/pull/12544 is live
- id: prepare
run: python ./.github/prepare.py
env:
PUBLISH_HOSTPORT: ${{ secrets.STARCATCHER_PUBLISH_HOSTPORT }}
GITHUB_REF: ${{ github.ref }}
- if: steps.prepare.outputs.do_publish == 'yes'
run: sudo apt update && sudo apt install curlftpfs && bash -c './.github/starcatcher-publish.sh'
env:
PUBLISH_HOSTPORT: ${{ secrets.STARCATCHER_PUBLISH_HOSTPORT }}
PUBLISH_USERNAME: ${{ secrets.STARCATCHER_PUBLISH_USERNAME }}
PUBLISH_PASSWORD: ${{ secrets.STARCATCHER_PUBLISH_PASSWORD }}
PUBLISH_ACCESSCHECK: yes
- if: steps.prepare.outputs.do_release == 'yes'
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ steps.prepare.outputs.release_name }}
run: bash -c './.github/create-release.sh'
build:
runs-on: ${{ matrix.runs_on }}
name: ${{ matrix.job_name }}
needs: [prepare]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.build_matrix) }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- if: matrix.force_msys2_bash == 'yes'
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
path-type: strict
cache: true
# this list doesn't have to mirror the one in build.sh perfectly
# but the packages listed here get cached properly and take less time to install
install: >-
git
curl
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-pkgconf
mingw-w64-ucrt-x86_64-bzip2
mingw-w64-ucrt-x86_64-luajit
mingw-w64-ucrt-x86_64-jsoncpp
mingw-w64-ucrt-x86_64-curl
mingw-w64-ucrt-x86_64-SDL2
mingw-w64-ucrt-x86_64-libpng
mingw-w64-ucrt-x86_64-meson
mingw-w64-ucrt-x86_64-python
mingw-w64-ucrt-x86_64-python-pip
mingw-w64-ucrt-x86_64-fftw
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-7zip
mingw-w64-ucrt-x86_64-jq
patch
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- if: matrix.force_msys2_bash != 'yes'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- if: matrix.force_msys2_bash != 'yes'
run: python -m pip install meson==1.2.3 ninja # TODO: go back to using latest meson once https://github.com/mesonbuild/meson/pull/12544 is live
- if: matrix.bsh_build_platform == 'darwin'
run: brew install bash coreutils
- run: bash -c './.github/build.sh'
env:
BSH_HOST_ARCH: ${{ matrix.bsh_host_arch }}
BSH_HOST_PLATFORM: ${{ matrix.bsh_host_platform }}
BSH_HOST_LIBC: ${{ matrix.bsh_host_libc }}
BSH_STATIC_DYNAMIC: ${{ matrix.bsh_static_dynamic }}
BSH_BUILD_PLATFORM: ${{ matrix.bsh_build_platform }}
BSH_DEBUG_RELEASE: ${{ matrix.bsh_debug_release }}
RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
RELEASE_TYPE: ${{ needs.prepare.outputs.release_type }}
MOD_ID: ${{ needs.prepare.outputs.mod_id }}
APP_NAME: ${{ needs.prepare.outputs.app_name }}
APP_COMMENT: ${{ needs.prepare.outputs.app_comment }}
APP_EXE: ${{ needs.prepare.outputs.app_exe }}
APP_ID: ${{ needs.prepare.outputs.app_id }}
APP_DATA: ${{ needs.prepare.outputs.app_data }}
APP_VENDOR: ${{ needs.prepare.outputs.app_vendor }}
SEPARATE_DEBUG: ${{ matrix.separate_debug }}
PACKAGE_MODE: ${{ matrix.package_mode }}
ASSET_PATH: ${{ matrix.asset_path }}
DEBUG_ASSET_PATH: ${{ matrix.debug_asset_path }}
- if: needs.prepare.outputs.do_release == 'yes' && matrix.publish == 'yes' # TODO-NTL: ship licenses
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_PATH: build/${{ matrix.asset_path }}
ASSET_NAME: ${{ matrix.asset_name }}
run: bash -c './.github/upload-release-asset.sh'
- if: needs.prepare.outputs.do_release == 'yes' && matrix.publish == 'yes' && matrix.separate_debug == 'yes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_PATH: build/${{ matrix.debug_asset_path }}
ASSET_NAME: ${{ matrix.debug_asset_name }}
run: bash -c './.github/upload-release-asset.sh'
- uses: actions/upload-artifact@v4
if: matrix.artifact == 'yes'
with:
path: build/${{ matrix.asset_path }}
name: ${{ matrix.asset_name }}
- uses: actions/upload-artifact@v4
if: matrix.artifact == 'yes' && matrix.separate_debug == 'yes'
with:
path: build/${{ matrix.debug_asset_path }}
name: ${{ matrix.debug_asset_name }}
publish:
runs-on: ubuntu-latest
needs: [build, prepare]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.publish_matrix) }}
if: needs.prepare.outputs.do_publish == 'yes'
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.asset_name }}
- run: mv ${{ matrix.asset_path }} ${{ matrix.starcatcher_name }}
- run: sudo apt update && sudo apt install curlftpfs && bash -c './.github/starcatcher-publish.sh'
env:
PUBLISH_HOSTPORT: ${{ secrets.STARCATCHER_PUBLISH_HOSTPORT }}
PUBLISH_USERNAME: ${{ secrets.STARCATCHER_PUBLISH_USERNAME }}
PUBLISH_PASSWORD: ${{ secrets.STARCATCHER_PUBLISH_PASSWORD }}
PUBLISH_DIRECTORY: ${{ secrets.STARCATCHER_PUBLISH_DIRECTORY }}
PUBLISH_FILENAME: ${{ matrix.starcatcher_name }}
release:
runs-on: ubuntu-latest
needs: [build, publish, prepare]
if: needs.prepare.outputs.do_publish == 'yes'
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- run: ./.github/starcatcher-release.sh
env:
RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
RELEASE_TYPE: ${{ needs.prepare.outputs.release_type }}
MOD_ID: ${{ needs.prepare.outputs.mod_id }}
GITHUB_SHA: ${{ github.sha }}

94
.gitignore vendored
View File

@ -1,94 +0,0 @@
# Misc extensions, system files
*.zip
*.txt
*.gz
*.out
*.sh
*.py
*.png
*.ppm
*.swp
*~
.DS_Store
# Build files
build*/*
*.o
*.exe
*.dmg
*.dll
*.a
*.la
# Legacy SCons files
config.log
*.sconsign.dblite
*.sconf_temp
/site_scons/
/generated/
# User data
/stamps/
/Saves/
/scripts/
/recordings/
*.def
*.pref
*.lua
screenshot_*
# Visual studio
/Debug/
/Release/
/includes/
*.vcxproj*
*.user
*.filter
*.sln
*.suo
*.manifest
*.manifest.res
*manifest.rc
*res.res
*.idb
*.obj
*.tlog
*.lib
*.ipch
*.ilk
*.log
*.lastbuildstate
*.unsuccessfulbuild
*.pdb
*.db
# QtCreator / KDevelop
*.user
*.config
*.creator*
*.cflags
*.cxxflags
*.files
*.includes
*.kdev4
/.kdev4
# Other IDEs / misc
.vscode/
.vs/
*.sublime-*
*.project
*.cproject
*.settings
*.cbp
*.layout
*.gch
*.pyc
*.xcodeproj
*.plist
*.lproj
*.opensdf
*.sdf
/font/
compile_commands.json
ignore/

884
LICENSE
View File

@ -1,626 +1,285 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
13. Use with the GNU Affero General Public License.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
14. Revised Versions of this License.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
NO WARRANTY
15. Disclaimer of Warranty.
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -628,15 +287,15 @@ free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@ -645,30 +304,37 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

74
Makefile Normal file
View File

@ -0,0 +1,74 @@
SOURCES := powder.c http.c md5.c update.c
HEADERS := font.h http.h md5.h icon.h update.h fbi.h
CFLAGS := -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -fgnu89-inline
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
LFLAGS := -lSDL -lm -lbz2
MFLAGS_SSE3 := -march=k8 -DX86 -DX86_SSE3 -msse3
MFLAGS_SSE2 := -march=k8 -DX86 -DX86_SSE2
MFLAGS_SSE := -march=pentium3 -DX86 -DX86_SSE
LINUX_TARG := powder-64-sse2 powder-sse powder-sse2
WIN32_TARG := powder-sse.exe powder-sse2.exe
powder: $(SOURCES) $(HEADERS)
gcc -m64 -DINTERNAL -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
powder-sse3: $(SOURCES) $(HEADERS)
gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN32
strip $@
powder-sse2: $(SOURCES) $(HEADERS)
gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN32
strip $@
powder-sse: $(SOURCES) $(HEADERS)
gcc -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE) $(SOURCES) -DLIN32
strip $@
powder-64-sse3: $(SOURCES) $(HEADERS)
gcc -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
strip $@
powder-64-sse2: $(SOURCES) $(HEADERS)
gcc -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN64
strip $@
powder-res.o: powder-res.rc powder.ico
i586-mingw32msvc-windres powder-res.rc powder-res.o
powder-sse3.exe: $(SOURCES) $(HEADERS) powder-res.o
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
powder-sse2.exe: $(SOURCES) $(HEADERS) powder-res.o
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
powder-sse.exe: $(SOURCES) $(HEADERS) powder-res.o
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
strip $@
chmod 0644 $@
powder-src.tar.bz2: *.c *.h *.rc *.ico Makefile
mkdir powder-src
cp *.c *.h *.rc *.ico Makefile powder-src/
tar cfj powder-src.tar.bz2 powder-src
rm -rf powder-src
release: $(LINUX_TARG) $(WIN32_TARG) powder-src.tar.bz2
tar cfz powder-linux.tar.gz $(LINUX_TARG)
cp /usr/i586-mingw32msvc/bin/SDL.dll .
zip powder-win32.zip $(WIN32_TARG) SDL.dll
mkdir -p release
mv powder-linux.tar.gz release/
mv powder-win32.zip release/
mv powder-src.tar.bz2 release/
cp powder-sse.exe powder.exe
rm -f release/powder.zip
zip release/powder.zip powder.exe SDL.dll
cp powder-64-sse2 release/powder64
rm -f release/powder64.gz
gzip release/powder64
rm -f release/powder.gz
cp powder-sse release/powder
gzip release/powder
cd release; tar czf powder-bin.tar.gz powder.gz powder64.gz powder-linux.tar.gz powder-win32.zip powder.zip; cd ..
rm -f $(LINUX_TARG) $(WIN32_TARG) SDL.dll powder.exe

128
README.md
View File

@ -1,128 +0,0 @@
The Powder Toy - April 2024
==========================
Get the latest version [from the Powder Toy website](https://powdertoy.co.uk/Download.html).
To use online features such as saving, you need to [register an account](https://powdertoy.co.uk/Register.html).
You can also visit [the official TPT forum](https://powdertoy.co.uk/Discussions/Categories/Index.html).
Have you ever wanted to blow something up? Or maybe you always dreamt of operating an atomic power plant? Do you have a will to develop your own CPU? The Powder Toy lets you to do all of these, and even more!
The Powder Toy is a free physics sandbox game, which simulates air pressure and velocity, heat, gravity and a countless number of interactions between different substances! The game provides you with various building materials, liquids, gases and electronic components which can be used to construct complex machines, guns, bombs, realistic terrains and almost anything else. You can then mine them and watch cool explosions, add intricate wirings, play with little stickmen or operate your machine. You can browse and play thousands of different saves made by the community or upload your own we welcome your creations!
There is a Lua API you can automate your work or even make plugins for the game. The Powder Toy is free and the source code is distributed under the GNU General Public License, so you can modify the game yourself or help with development.
Build instructions
===========================================================================
See the _Powder Toy Development Help_ section [on the main page of the wiki](https://powdertoy.co.uk/Wiki/W/Main_Page.html).
Thanks
===========================================================================
* Stanislaw K Skowronek - Designed the original
* Simon Robertshaw
* Skresanov Savely
* cracker64
* Catelite
* Victoria Hoyle
* Nathan Cousins
* jacksonmj
* Felix Wallin
* Lieuwe Mosch
* Anthony Boot
* Me4502
* MaksProg
* jacob1
* mniip
* LBPHacker
Libraries and other assets used
===========================================================================
* [BSON](https://github.com/interactive-matter/bson-c)
* [bzip2](http://www.bzip.org/)
* [FFTW](http://fftw.org/)
* [JsonCpp](https://github.com/open-source-parsers/jsoncpp)
* [libcurl](https://curl.se/libcurl/)
* [libpng](http://www.libpng.org/pub/png/libpng.html)
* [Lua](https://www.lua.org/)
* [LuaJIT](https://luajit.org/)
* [Mallangche](https://github.com/JammPark/Mallangche)
* [mbedtls](https://www.trustedfirmware.org/projects/mbed-tls/)
* [SDL](https://libsdl.org/)
* [zlib](https://www.zlib.net/)
Instructions
===========================================================================
Click on the elements with the mouse and draw in the field, like in MS Paint. The rest of the game is learning what happens next.
Controls
===========================================================================
| Key | Action |
| ----------------------- | --------------------------------------------------------------- |
| TAB | Switch between circle/square/triangle brush |
| Space | Pause |
| Q / Esc | Quit |
| Z | Zoom |
| S | Save stamp (use with Ctrl when STK2 is out) |
| L | Load last saved stamp |
| K | Stamp library |
| 0-9 | Set view mode |
| P / F2 | Save screenshot as .png |
| E | Bring up element search |
| F | Pause and step to next frame |
| G | Increase grid size |
| Shift + G | Decrease grid size |
| H | Show/Hide HUD |
| Ctrl + H / F1 | Show intro text |
| D / F3 | Debug mode (use with Ctrl when STK2 is out) |
| I | Invert Pressure and Velocity map |
| W | Cycle gravity modes (use with Ctrl when STK2 is out) |
| Y | Cycle air modes |
| Ctrl + E | Cycle edge modes |
| B | Enter decoration editor menu |
| Ctrl + B | Toggle decorations on/off |
| N | Toggle Newtonian Gravity on/off |
| U | Toggle ambient heat on/off |
| Ctrl + I | Install powder toy, for loading saves/stamps by double clicking |
| Backtick | Toggle console |
| = | Reset pressure and velocity map |
| Ctrl + = | Reset Electricity |
| \[ | Decrease brush size |
| \] | Increase brush size |
| Alt + \[ | Decrease brush size by 1 |
| Alt + \] | Increase brush size by 1 |
| Ctrl + C/V/X | Copy/Paste/Cut |
| Ctrl + Z | Undo |
| Ctrl + Y | Redo |
| Ctrl + Cursor drag | Rectangle |
| Shift + Cursor drag | Line |
| Middle click | Sample element |
| Alt + Left click | Sample element |
| Mouse scroll | Change brush size |
| Ctrl + Mouse scroll | Change vertical brush size |
| Shift + Mouse scroll | Change horizontal brush size |
| Shift + R | Horizontal mirror for selected area when pasting stamps |
| Ctrl + Shift + R | Vertical mirror for selected area when pasting stamps |
| R | Rotate selected area counterclockwise when pasting stamps |
| F11 | Toggle fullscreen |
Command Line
---------------------------------------------------------------------------
| Command | Description | Example |
| --------------------- | ------------------------------------------------ | --------------------------------------------|
| `scale:SIZE` | Change window scale factor | `scale:2` |
| `kiosk` | Fullscreen mode | |
| `proxy:SERVER[:PORT]` | Proxy server to use | `proxy:wwwcache.lancs.ac.uk:8080` |
| `open FILE` | Opens the file as a stamp or game save | |
| `ddir DIRECTORY` | Directory used for saving stamps and preferences | |
| `ptsave:SAVEID` | Open online save, used by ptsave: URLs | `ptsave:2198` |
| `disable-network` | Disables internet connections | |
| `disable-bluescreen` | Disable bluescreen handler | |
| `redirect` | Redirects output to stdout.txt / stderr.txt | |
| `cafile:CAFILE` | Set certificate bundle path | `cafile:/etc/ssl/certs/ca-certificates.crt` |
| `capath:CAPATH` | Set certificate directory path | `capath:/etc/ssl/certs` |

View File

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="@APPID@"
android:versionCode="@BUILD_NUM@"
android:versionName="@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@.@BUILD_NUM@"
android:installLocation="auto"
>
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="30"
/>
<uses-feature
android:glEsVersion="0x00020000"
/>
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false"
/>
<uses-feature
android:name="android.hardware.bluetooth"
android:required="false"
/>
<uses-feature
android:name="android.hardware.gamepad"
android:required="false"
/>
<uses-feature
android:name="android.hardware.usb.host"
android:required="false"
/>
<uses-feature
android:name="android.hardware.type.pc"
android:required="false"
/>
@ANDROID_PERMISSIONS@
<application
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true"
@ANDROID_PROPERTIES@
>
<activity
android:name=".PowderActivity"
android:screenOrientation="landscape"
android:label="@string/app_name"
android:alwaysRetainTaskState="true"
android:launchMode="singleInstance"
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:preferMinimalPostProcessing="true"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter> -->
</activity>
</application>
</manifest>

View File

@ -1,42 +0,0 @@
package @APPID@;
import org.libsdl.app.SDLActivity;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.Enumeration;
import java.io.IOException;
import java.util.Base64;
public class PowderActivity extends SDLActivity
{
public static String getCertificateBundle()
{
String allPems = "";
try {
KeyStore ks = KeyStore.getInstance("AndroidCAStore");
if (ks != null) {
ks.load(null, null);
Enumeration<String> aliases = ks.aliases();
while (aliases.hasMoreElements()) {
String alias = (String)aliases.nextElement();
java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate)ks.getCertificate(alias);
allPems += "-----BEGIN CERTIFICATE-----\n" + Base64.getMimeEncoder().encodeToString(cert.getEncoded()) + "\n-----END CERTIFICATE-----\n";;
}
}
} catch (IOException e) {
e.printStackTrace();
return "";
} catch (KeyStoreException e) {
e.printStackTrace();
return "";
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
} catch (java.security.cert.CertificateException e) {
e.printStackTrace();
return "";
}
return allPems;
}
}

View File

@ -1,26 +0,0 @@
import os
import os.path
import subprocess
import sys
(
script,
zipalign,
build_dir,
unsigned_name,
unaligned_name,
) = sys.argv
unaligned_path = os.path.join(build_dir, unaligned_name)
unsigned_path = os.path.join(build_dir, unsigned_name)
if os.path.exists(unsigned_path):
os.remove(unsigned_path)
if subprocess.run([
zipalign,
'-f', '4',
unaligned_path,
unsigned_path,
]).returncode:
sys.exit(1)

View File

@ -1,104 +0,0 @@
import os
import os.path
import shutil
import subprocess
import sys
(
script,
d8,
aapt,
aapt2,
source_dir,
build_dir,
private_name,
unaligned_name,
sha_name,
android_jar,
sdl_jar,
powder_jar,
tpt_arch,
debug_release,
manifest_xml,
*resources,
) = sys.argv
if tpt_arch == 'x86':
android_arch = 'x86'
if tpt_arch == 'arm':
android_arch = 'armeabi-v7a'
if tpt_arch == 'aarch64':
android_arch = 'arm64-v8a'
if tpt_arch == 'x86_64':
android_arch = 'x86_64'
sha_packaged_name = 'libpowder.so'
manifest_path = os.path.join(build_dir, manifest_xml)
sha_path = os.path.join(build_dir, sha_name)
unaligned_path = os.path.join(build_dir, unaligned_name)
private_dir = os.path.join(build_dir, private_name)
arch_dir = os.path.join(private_dir, 'lib', android_arch)
sha_lib_path = os.path.join(arch_dir, sha_packaged_name)
flat_dir = os.path.join(private_dir, 'flat')
if os.path.exists(arch_dir):
shutil.rmtree(arch_dir)
os.makedirs(arch_dir)
if os.path.exists(sha_lib_path):
os.remove(sha_lib_path)
if os.path.exists(unaligned_path):
os.remove(unaligned_path)
if os.path.exists(flat_dir):
shutil.rmtree(flat_dir)
os.makedirs(flat_dir)
if subprocess.run([
aapt2,
'compile',
'-o', os.path.join(private_dir, 'flat'),
*resources,
], cwd = build_dir).returncode:
sys.exit(1)
aapt2_link_inputs = []
for root, dirs, files in os.walk(flat_dir):
for name in files:
if name.endswith(".flat"):
aapt2_link_inputs.append(os.path.join(root, name))
if subprocess.run([
aapt2,
'link',
'-o', unaligned_path,
'-I', android_jar,
'--manifest', manifest_path,
*aapt2_link_inputs,
]).returncode:
sys.exit(1)
shutil.copy(sha_path, sha_lib_path)
if subprocess.run([
aapt,
'add',
unaligned_path,
os.path.join('lib', android_arch, sha_packaged_name),
], cwd = private_dir).returncode:
sys.exit(1)
if subprocess.run([
d8,
os.path.join(build_dir, sdl_jar),
os.path.join(build_dir, powder_jar),
'--' + debug_release,
'--lib', android_jar,
'--min-api', '21',
], cwd = private_dir).returncode:
sys.exit(1)
if subprocess.run([
aapt,
'add',
unaligned_path,
'classes.dex',
], cwd = private_dir).returncode:
sys.exit(1)

View File

@ -1,8 +0,0 @@
[constants]
android_ndk_toolchain_prefix = 'aarch64-linux-android21-'
[host_machine]
system = 'android'
cpu_family = 'aarch64'
cpu = 'armv8'
endian = 'little'

View File

@ -1,8 +0,0 @@
[constants]
android_ndk_toolchain_prefix = 'armv7a-linux-androideabi21-'
[host_machine]
system = 'android'
cpu_family = 'arm'
cpu = 'armv7a'
endian = 'little'

View File

@ -1,8 +0,0 @@
[constants]
android_ndk_toolchain_prefix = 'i686-linux-android21-'
[host_machine]
system = 'android'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

View File

@ -1,8 +0,0 @@
[constants]
android_ndk_toolchain_prefix = 'x86_64-linux-android21-'
[host_machine]
system = 'android'
cpu_family = 'x86_64'
cpu = 'amd64'
endian = 'little'

View File

@ -1,272 +0,0 @@
#!/usr/bin/env bash
# mainly based on https://www.sh-zam.com/2019/05/debugging-krita-on-android.html
set -euo pipefail
IFS=$'\n\t'
function get_buildoption() {
jq -r '.[] | select(.name == "'$1'") | .value' < meson-info/intro-buildoptions.json
}
function get_cpp_compiler() {
jq -r '.[] | select(.name == "'$1'") | .target_sources.[] | select(.language == "cpp") | .compiler.[]' < meson-info/intro-targets.json
}
# customize
default_app_id=uk.co.powdertoy.tpt
default_app_exe=powder
default_lldb_server=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/lib/linux/aarch64/lldb-server
default_lldb_client=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/lldb.sh
in_build_site=no
if which jq >/dev/null && [[ -f meson-info/intro-buildoptions.json ]]; then
>&2 echo "[+] pwd is a build site, auto-detecting parameters"
in_build_site=yes
default_app_id=$(get_buildoption app_id)
default_app_exe=$(get_buildoption app_exe)
found_lldb=no
compiler_path=$(get_cpp_compiler $default_app_exe)
for line in $compiler_path; do
# iterate over the command array (might be for example [ "ccache", "aarch64-linux-android21-clang++" ])
if (echo $line | grep toolchains && basename $line | grep android | grep clang++) >/dev/null; then
arch=$(basename $line | cut -d '-' -f 1)
default_lldb_server=$(realpath $(dirname $line)/../lib/clang/*/lib/linux/$arch/lldb-server)
default_lldb_client=$(realpath $(dirname $line)/lldb.sh)
found_lldb=yes
fi
done
if [[ $found_lldb != yes ]]; then
>&2 echo "[-] cannot determine LLDB paths from compiler command array:"
for line in $compiler_path; do
>&2 echo "[-] - $line"
done
exit 1
fi
>&2 echo "[+] APP_ID: $default_app_id"
>&2 echo "[+] APP_EXE: $default_app_exe"
>&2 echo "[+] LLDB_SERVER: $default_lldb_server"
>&2 echo "[+] LLDB_CLIENT: $default_lldb_client"
else
>&2 echo "[+] pwd is not a build site, not auto-detecting parameters"
fi
app_id=${APP_ID:-$default_app_id}
app_exe=${APP_EXE:-$default_app_exe}
lldb_server=${LLDB_SERVER:-$default_lldb_server}
lldb_server_port=${LLDB_SERVER_PORT:-9998}
jdb_port=${JDB_PORT:-13456}
lldb_client=${LLDB_CLIENT:-$default_lldb_client}
meson=${MESON:-meson}
adb=${ADB:-adb}
jdb=${JDB:-jdb}
# don't customize unless necessary
app_activity=${APP_ACTIVITY:-PowderActivity}
lldb_server_staging=${LLDB_SERVER_STAGING:-/data/local/tmp/lldb-server}
lldb_server_remote=${LLDB_SERVER_REMOTE:-lldb-server}
pidof_retry_count=${PIDOF_RETRY_COUNT:-20}
pidof_retry_delay=${PIDOF_RETRY_DELAY:-0.1}
function check_which() {
if ! which $1 >/dev/null; then
>&2 echo "[-] can't run $1"
return 1
fi
}
function check_env() {
if ! [[ -f $lldb_server ]]; then
>&2 echo "[-] $lldb_server doesn't exist"
return 1
fi
check_which $lldb_client
check_which $adb
check_which $jdb
}
function check_adb() {
$adb shell whoami >/dev/null
}
function maybe_install_app() {
if [[ $in_build_site != yes ]]; then
return 0
fi
android_keystore=$(get_buildoption android_keystore)
android_keyalias=$(get_buildoption android_keyalias)
if [[ -z ${ANDROID_KEYSTORE_PASS-} ]]; then
>&2 echo "[-] ANDROID_KEYSTORE_PASS not set"
>&2 echo
>&2 cat << HELP
The current directory seems to be a build site, but ANDROID_KEYSTORE_PASS is not set, so android/$app_exe.apk cannot be invoked. If you don't have a keystore yet, create one with:
ANDROID_KEYSTORE_PASS=bagelsbagels keytool -genkey \\
-keystore $android_keystore \\
-alias $android_keyalias \\
-storepass:env ANDROID_KEYSTORE_PASS \\
-keypass:env ANDROID_KEYSTORE_PASS \\
-dname CN=bagels
Then try again with:
ANDROID_KEYSTORE_PASS=bagelsbagels $0
Naturally, replace bagelsbagels with an appropriate password.
HELP
exit 1
fi
>&2 echo "[+] meson compiling android/$app_exe.apk"
if ! $meson compile sign-apk; then
>&2 echo "[-] failed"
return 1
fi
>&2 echo "[+] adb installing android/$app_exe.apk"
if ! $adb install android/$app_exe.apk; then
>&2 echo "[-] failed"
return 1
fi
}
function check_debuggable() {
$adb shell run-as $app_id whoami >/dev/null
}
function find_lldb_server() {
$adb shell run-as $app_id pgrep $lldb_server_remote >/dev/null
}
function kill_lldb_server() {
if ! $adb shell run-as $app_id pkill $lldb_server_remote; then
>&2 echo "[-] failed"
return 1
fi
}
function adb_forward() {
>&2 echo "[+] adb forwarding tcp:$jdb_port jdwp:$pid"
if ! ($adb forward tcp:$jdb_port jdwp:$pid | grep $jdb_port >/dev/null); then
>&2 echo "[+] failed"
return 1
fi
}
function adb_unforward() {
$adb forward --remove tcp:$jdb_port
}
function undo_current_adb_forward() {
>&2 echo "[+] adb un-forwarding orphaned tcp:$jdb_port"
adb_unforward
}
function maybe_undo_previous_adb_forward() {
if $adb forward --list | grep tcp:$jdb_port; then
>&2 echo "[+] adb un-forwarding orphaned tcp:$jdb_port"
adb_unforward
fi
}
function maybe_kill_previous_lldb_server() {
if find_lldb_server; then
>&2 echo "[+] killing orphaned $lldb_server_remote"
kill_lldb_server
fi
}
function kill_current_lldb_server() {
>&2 echo "[+] killing $lldb_server_remote"
kill_lldb_server
}
function start_app() {
>&2 echo "[+] starting $app_id/.$app_activity"
set +e
$adb shell am start -D -n "$app_id/.$app_activity" >/dev/null
set -e
local i
local maybe_pid
local pidof_result
for ((i = 0; i <= $pidof_retry_count; i++)); do
set +e
maybe_pid=$($adb shell pidof $app_id)
pidof_result=$?
set -e
if [[ $pidof_result == 0 ]]; then
pid=$maybe_pid
break
fi
sleep $pidof_retry_delay
done
if [[ -z ${pid-} ]]; then
>&2 echo "[-] failed"
return 1
fi
echo $pid
}
function jdb_attach() {
>&2 echo "[+] attaching jdb in the background"
$jdb -attach localhost:$jdb_port >/dev/null 2>/dev/null &
disown $!
# at some point jdb exits because it doesn't have an stdin... fine by me
}
function maybe_deploy_lldb_server() {
if ! $adb shell [[ -f $lldb_server_staging ]]; then
>&2 echo "[+] $lldb_server_remote not present on host, deploying"
if ! ($adb push $lldb_server $lldb_server_staging && $adb shell chmod +x $lldb_server_staging); then
>&2 echo "[-] failed"
fi
fi
}
function start_lldb_server() {
if ! $adb shell run-as $app_id pgrep $lldb_server_remote >/dev/null; then
>&2 echo "[+] $lldb_server_remote not running on host, starting"
$adb shell run-as $app_id cp $lldb_server_staging /data/data/$app_id/$lldb_server_remote
$adb shell run-as $app_id ./$lldb_server_remote platform --server --listen "*:$lldb_server_port" >/dev/null 2>/dev/null &
disown $!
if ! $adb shell run-as $app_id pgrep $lldb_server_remote >/dev/null; then
>&2 echo "[-] failed"
return 1
fi
fi
}
function start_lldb() {
local pid=$1
>&2 echo "[+] starting $lldb_client"
local lldb_init=$(mktemp)
cat - << LLDB_INIT > $lldb_init
platform select remote-android
platform connect connect://localhost:$lldb_server_port
attach $pid
continue
LLDB_INIT
local lldb_status
set +e
$lldb_client --source $lldb_init
lldb_status=$?
set -e
>&2 echo "[+] $lldb_client exited with status $lldb_status"
rm $lldb_init
}
check_env
check_adb
maybe_install_app
check_debuggable
maybe_kill_previous_lldb_server
maybe_undo_previous_adb_forward
if [[ ${1-} == clean ]]; then
>&2 echo "[+] done"
exit 0
fi
maybe_deploy_lldb_server
start_lldb_server
pid=$(start_app)
adb_forward
jdb_attach
start_lldb $pid
kill_current_lldb_server
undo_current_adb_forward
>&2 echo "[+] done"

View File

@ -1,25 +0,0 @@
import os
import os.path
import subprocess
import sys
(
script,
adb,
build_dir,
phony,
apk_name,
) = sys.argv
apk_path = os.path.join(build_dir, apk_name)
phony_path = os.path.join(build_dir, phony)
if os.path.exists(phony_path):
os.remove(phony_path)
if subprocess.run([
adb,
'install',
apk_path,
]).returncode:
sys.exit(1)

View File

@ -1,105 +0,0 @@
android_manifest_xml = configure_file(
input: 'AndroidManifest.template.xml',
output: 'AndroidManifest.xml',
configuration: conf_data,
)
powder_jar_sources = configure_file(
input: 'PowderActivity.template.java',
output: 'PowderActivity.java',
configuration: conf_data,
)
subdir('res')
python3 = find_program('python3')
android_platform_jar = meson.get_external_property('android_platform_jar')
java_runtime_jar = meson.get_external_property('java_runtime_jar')
android_keystore = get_option('android_keystore')
sdl_jar = tpt_libs.get_variable('sdl_jar')
powder_jar = custom_target(
'powder-jar',
output: app_exe + '.jar',
command: [
python3,
files('powder-jar.py'),
find_program('javac'),
find_program('jar'),
meson.current_source_dir(),
meson.project_build_root(),
'@PRIVATE_DIR@',
'@OUTPUT@',
android_platform_jar,
java_runtime_jar,
sdl_jar,
is_debug ? 'debug' : 'release',
powder_jar_sources,
],
)
unaligned_apk = custom_target(
'build-apk',
output: app_exe + '.unaligned.apk',
input: powder_sha,
command: [
python3,
files('build-apk.py'),
find_program('d8'),
find_program('aapt'),
find_program('aapt2'),
meson.current_source_dir(),
meson.project_build_root(),
'@PRIVATE_DIR@',
'@OUTPUT@',
'@INPUT@',
android_platform_jar,
sdl_jar,
powder_jar,
host_arch,
is_debug ? 'debug' : 'release',
android_manifest_xml,
android_resources,
],
)
unsigned_apk = custom_target(
'align-apk',
output: app_exe + '.unsigned.apk',
input: unaligned_apk,
command: [
python3,
files('align-apk.py'),
find_program('zipalign'),
meson.project_build_root(),
'@OUTPUT@',
'@INPUT@',
],
)
signed_apk = custom_target(
'sign-apk',
output: app_exe + '.apk',
input: unsigned_apk,
command: [
python3,
files('sign-apk.py'),
find_program('apksigner'),
meson.project_build_root(),
'@OUTPUT@',
'@INPUT@',
android_keystore,
get_option('android_keyalias'),
],
)
adb = find_program('adb', required: false)
if adb.found()
install_apk = custom_target(
'install-apk',
input: signed_apk,
output: 'install-apk',
command: [ python3, files('install-apk.py'), adb, meson.project_build_root(), '@OUTPUT@', '@INPUT@' ],
)
custom_target(
'run-apk',
input: [ signed_apk, install_apk ],
build_always_stale: true,
output: 'run-apk',
command: [ python3, files('run-apk.py'), adb, meson.project_build_root(), '@OUTPUT@', '@INPUT0@', app_id ],
)
endif

View File

@ -1,54 +0,0 @@
import os
import os.path
import shutil
import subprocess
import sys
(
script,
javac,
jar,
source_dir,
build_dir,
private_name,
powder_jar_name,
android_jar,
java_runtime,
sdl_jar,
debug_release,
*javac_sources,
) = sys.argv
powder_jar_path = os.path.join(build_dir, powder_jar_name)
private_dir = os.path.join(build_dir, private_name)
class_dir = os.path.join(private_dir, 'class')
if os.path.exists(powder_jar_path):
os.remove(powder_jar_path)
if os.path.exists(class_dir):
shutil.rmtree(class_dir)
os.makedirs(class_dir)
if subprocess.run([
javac,
'-d', class_dir,
'-source', '1.8',
'-target', '1.8',
'-bootclasspath', java_runtime,
'-classpath', os.pathsep.join([ android_jar, sdl_jar ]),
*javac_sources,
], cwd = build_dir).returncode:
sys.exit(1)
jar_inputs = []
for root, dirs, files in os.walk(class_dir):
for name in files:
if name.endswith(".class"):
jar_inputs.append(os.path.relpath(os.path.join(root, name), start = class_dir))
if subprocess.run([
jar,
'cMf',
powder_jar_path,
*jar_inputs,
], cwd = class_dir).returncode:
sys.exit(1)

View File

@ -1,7 +0,0 @@
android_resources = files(
'values/colors.xml',
'values/styles.xml',
)
subdir('values')
subdir('mipmap-mdpi')

View File

@ -1 +0,0 @@
android_resources += fs.copyfile(rendered_icons['icon_exe'], 'ic_launcher.png')

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@ -1,5 +0,0 @@
android_resources += configure_file(
input: 'strings.template.xml',
output: 'strings.xml',
configuration: conf_data,
)

View File

@ -1,3 +0,0 @@
<resources>
<string name="app_name">@APPNAME@</string>
</resources>

View File

@ -1,4 +0,0 @@
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
</style>
</resources>

View File

@ -1,25 +0,0 @@
import os
import os.path
import subprocess
import sys
(
script,
adb,
build_dir,
phony,
apk_name,
app_id,
) = sys.argv
apk_path = os.path.join(build_dir, apk_name)
if subprocess.run([
adb,
'shell',
'am',
'start',
'--activity-clear-top',
'-n', app_id + '/.PowderActivity',
]).returncode:
sys.exit(1)

View File

@ -1,35 +0,0 @@
import os
import os.path
import subprocess
import sys
(
script,
apksigner,
build_dir,
apk_name,
unsigned_name,
android_keystore,
android_keyalias,
) = sys.argv
if 'ANDROID_KEYSTORE_PASS' not in os.environ:
print('ANDROID_KEYSTORE_PASS not set')
sys.exit(1)
unsigned_path = os.path.join(build_dir, unsigned_name)
apk_path = os.path.join(build_dir, apk_name)
if os.path.exists(apk_path):
os.remove(apk_path)
if subprocess.run([
apksigner,
'sign',
'--ks', android_keystore,
'--ks-key-alias', android_keyalias,
'--ks-pass', 'env:ANDROID_KEYSTORE_PASS',
'--out', apk_path,
unsigned_path,
]).returncode:
sys.exit(1)

View File

@ -1,3 +0,0 @@
# This file is used by the starcatcher.us update server to pull changelogs for mod releases
# Erase and replace the changelog for every release, do not just append changes to the end
# Lines starting with # and empty lines are ignored

View File

@ -1,25 +0,0 @@
[constants]
andriod_ndk_toolchain_bin = '/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin'
[properties]
# only needed if you want to run the custom target powder_apk (powder.apk)
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross
android_ndk_toolchain_prefix = android_ndk_toolchain_prefix
android_platform = 'android-30'
android_platform_jar = '/opt/android-sdk/platforms/' + android_platform + '/android.jar'
java_runtime_jar = '/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar'
[binaries]
c = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang')
# c = [ 'ccache', andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang') ]
cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++')
# cpp = [ 'ccache', andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++') ]
strip = andriod_ndk_toolchain_bin / 'llvm-strip'
# only needed if you want to run the custom target powder_apk (powder.apk)
javac = '/usr/lib/jvm/java-8-openjdk/bin/javac'
jar = '/usr/lib/jvm/java-8-openjdk/bin/jar'
d8 = '/opt/android-sdk/build-tools/32.0.0/d8'
aapt = '/opt/android-sdk/build-tools/32.0.0/aapt'
aapt2 = '/opt/android-sdk/build-tools/32.0.0/aapt2'
zipalign = '/opt/android-sdk/build-tools/32.0.0/zipalign'
apksigner = '/opt/android-sdk/build-tools/32.0.0/apksigner'

View File

@ -1,11 +0,0 @@
[binaries]
c = [ 'clang', '-arch', 'arm64' ]
cpp = [ 'clang++', '-arch', 'arm64' ]
objcpp = [ 'clang++', '-arch', 'arm64' ]
strip = 'strip'
[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'armv8'
endian = 'little'

View File

@ -1,14 +0,0 @@
[constants]
prefix = 'x86_64-w64-mingw32'
[binaries]
c = prefix + '-gcc'
cpp = prefix + '-g++'
strip = prefix + '-strip'
windres = prefix + '-windres'
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

223
fbi.h Normal file
View File

@ -0,0 +1,223 @@
#define FBI_W 268
#define FBI_H 201
#define FBI_CMP 3464
unsigned char fbi[FBI_CMP] = {
0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xE5, 0x00, 0x24, 0xC9, 0x00, 0x01,
0x88, 0x7F, 0xFF, 0xD2, 0x49, 0x24, 0xB2, 0x68, 0x24, 0xB2, 0x48, 0x14, 0x90, 0x49, 0x24, 0x9A,
0x48, 0x28, 0x92, 0x09, 0x24, 0x96, 0x41, 0x04, 0x92, 0x49, 0x26, 0x92, 0x49, 0x01, 0x82, 0x41,
0x24, 0x92, 0xC8, 0x60, 0x1D, 0x5E, 0xF2, 0x57, 0xD8, 0x02, 0xD1, 0xA9, 0x65, 0x8D, 0xB0, 0x00,
0x01, 0xAD, 0x1A, 0x24, 0x12, 0xA3, 0x4A, 0xD3, 0x6C, 0x1B, 0x60, 0x00, 0x69, 0x40, 0x24, 0x6B,
0x4B, 0xDE, 0x2F, 0x7A, 0x88, 0x8B, 0xD6, 0x1B, 0x29, 0x8D, 0x33, 0x85, 0xDC, 0x15, 0xAE, 0x08,
0xC9, 0x6C, 0xEB, 0xA3, 0xBB, 0xAB, 0x80, 0x50, 0x05, 0x04, 0x54, 0xCD, 0x92, 0x4C, 0x40, 0x1A,
0x68, 0x68, 0xF5, 0x00, 0xD0, 0xD0, 0x00, 0x0D, 0x00, 0x03, 0x40, 0x68, 0x04, 0x84, 0x44, 0x24,
0x48, 0xF5, 0x0F, 0x53, 0xF4, 0x89, 0xB5, 0x1A, 0x68, 0x19, 0x0C, 0x00, 0x41, 0x81, 0x31, 0x0C,
0x83, 0xD1, 0xA1, 0xC6, 0x4C, 0x9A, 0x31, 0x0D, 0x34, 0x30, 0x13, 0x43, 0x13, 0x46, 0x99, 0x31,
0x03, 0x23, 0x09, 0xA3, 0x4D, 0x30, 0x83, 0x26, 0x12, 0x7A, 0xA5, 0x28, 0x90, 0x0A, 0x7A, 0x8C,
0x00, 0x26, 0x4C, 0x86, 0x00, 0x00, 0x00, 0x09, 0x88, 0x32, 0x18, 0x21, 0x2A, 0x9A, 0x53, 0x6A,
0x9A, 0x32, 0x68, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x81, 0xA0, 0x34, 0x0A, 0x9A, 0x95,
0x4D, 0x12, 0x80, 0x1A, 0x34, 0x64, 0x00, 0x00, 0x68, 0x1A, 0x06, 0x4D, 0x00, 0x00, 0x00, 0x77,
0xBD, 0x8E, 0xD8, 0x28, 0x92, 0x6C, 0x8A, 0x26, 0xD6, 0x50, 0x0B, 0x64, 0x4D, 0xB2, 0x94, 0x1B,
0x9D, 0xB5, 0x73, 0x6C, 0x59, 0xB2, 0xA3, 0x13, 0x56, 0xA2, 0xAC, 0x6D, 0x45, 0xB5, 0x36, 0x6D,
0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 0x8C, 0xDD, 0xD5, 0x74,
0xB0, 0x14, 0x94, 0x29, 0x19, 0xB3, 0x48, 0x3B, 0xAE, 0xC4, 0x8A, 0x22, 0xA8, 0xDB, 0x3B, 0x18,
0x05, 0xD6, 0x22, 0x18, 0xD9, 0xA0, 0xC3, 0x44, 0x14, 0x04, 0x11, 0x8C, 0xA1, 0x9A, 0x28, 0xC8,
0x73, 0xAA, 0xB3, 0x3B, 0xBB, 0x10, 0xC6, 0x58, 0xD4, 0xC3, 0x7F, 0x9D, 0xB6, 0x97, 0x3C, 0x95,
0xB9, 0xA6, 0x12, 0x24, 0xA8, 0x94, 0xC0, 0xAE, 0x6E, 0xF8, 0x6D, 0x6D, 0x57, 0xF7, 0x17, 0x72,
0x45, 0x38, 0x50, 0x90, 0xE5, 0x00, 0x24, 0xC9,
};

194
font.h Normal file
View File

@ -0,0 +1,194 @@
#define FONT_H 10
char font_data[] = {
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xC7, 0x31, 0x0C, 0x02, 0x70, 0x04, 0x00, 0x00,
0x05, 0xCC, 0x74, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x80, 0x19, 0xCC, 0xE0, 0x3F, 0xCC, 0xF0, 0x2F, 0xCC, 0x90, 0x09, 0x00, 0x00, 0x00,
0x06, 0x30, 0xD0, 0x3F, 0x33, 0xE1, 0x07, 0xF4, 0x12, 0x33, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00,
0x07, 0x2D, 0xCE, 0xCC, 0xE1, 0x1D, 0xC0, 0x03, 0x74, 0x4B, 0x33, 0xB3, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7D, 0x30, 0x0C, 0x13, 0xD0, 0x32, 0xB3, 0x33, 0x1C, 0x7D, 0x07, 0x00, 0x00, 0x00, 0x00,
0x03, 0x4C, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x34, 0x1D, 0x07, 0x03, 0x07, 0x1D, 0x34, 0x00, 0x00, 0x00,
0x04, 0x07, 0x1D, 0x34, 0x30, 0x34, 0x1D, 0x07, 0x00, 0x00, 0x00,
0x06, 0x44, 0xD0, 0x1C, 0x64, 0xF0, 0x3F, 0x64, 0xD0, 0x1C, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x02, 0x30, 0xE0, 0x2F, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x03, 0x00,
0x05, 0x00, 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x40, 0x70, 0x00, 0x00, 0x00,
0x06, 0x80, 0x02, 0x0C, 0xA0, 0x00, 0x03, 0x28, 0xC0, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF8, 0xE0, 0x39, 0x07, 0x33, 0x32, 0x03, 0xB3, 0x38, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x30, 0xF0, 0x60, 0x03, 0x0C, 0x30, 0xC0, 0x40, 0x07, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x41, 0x03, 0x0A, 0x2C, 0x70, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0x71, 0x34, 0x01, 0x03, 0x1E, 0x00, 0x33, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xC0, 0x03, 0x37, 0x1C, 0x73, 0x34, 0xBF, 0x03, 0x30, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x33, 0x00, 0x57, 0xE0, 0x2F, 0x00, 0x13, 0x30, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD3, 0x00, 0x07, 0xF0, 0x1F, 0x03, 0x33, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x07, 0x34, 0x80, 0x03, 0x0E, 0x38, 0xD0, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x03, 0xD3, 0x1F, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x03, 0xC3, 0x3F, 0x40, 0x23, 0x30, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x70, 0x04, 0x40, 0x70, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x1C, 0x04, 0x00, 0x0C, 0x0D, 0x03, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xC0, 0xC3, 0x0B, 0x1B, 0xC0, 0x0B, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x0F, 0x90, 0x83, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFD, 0x71, 0x30, 0x81, 0x03, 0x0E, 0x34, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0xF8, 0x0F, 0x1D, 0x30, 0xE7, 0x37, 0x73, 0x1C, 0xE3, 0x2F, 0x07, 0x00, 0xFD, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x74, 0xD0, 0x1D, 0x47, 0x33, 0x30, 0xFF, 0x33, 0x30, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xBF, 0x30, 0x38, 0x43, 0xF3, 0x1F, 0x43, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD1, 0x34, 0x03, 0x31, 0x00, 0x03, 0x70, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7F, 0x30, 0x1D, 0x43, 0x33, 0x30, 0x03, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x32, 0x00, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x10, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x33, 0x10, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD1, 0x34, 0x03, 0x30, 0x3E, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x47, 0x33, 0x30, 0x03, 0xF3, 0x3F, 0x03, 0x33, 0x30, 0x47, 0x03, 0x00, 0x00, 0x00, 0x00,
0x04, 0x1D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x06, 0xD0, 0x01, 0x0C, 0xC0, 0x00, 0x0C, 0xC0, 0x10, 0x0D, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x47, 0xC3, 0x34, 0x70, 0x03, 0xBC, 0x00, 0xB3, 0xC0, 0xB0, 0x70, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x30, 0x10, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00,
0x08, 0x03, 0x30, 0x1F, 0x3D, 0x7B, 0x3B, 0xE3, 0x32, 0x83, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x07, 0xCD, 0x03, 0x73, 0xC3, 0x8C, 0x32, 0xC3, 0xCD, 0xC0, 0x33, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xF4, 0x41, 0xC7, 0x71, 0xD0, 0x0C, 0x30, 0x03, 0xCD, 0xD1, 0xD1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7F, 0x30, 0x1D, 0x43, 0x73, 0x34, 0xFF, 0x31, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xF4, 0x41, 0xD3, 0x71, 0xD0, 0x0C, 0x30, 0xC3, 0xCD, 0xD1, 0xD1, 0xDF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x31, 0x34, 0x03, 0xF3, 0x0F, 0xD7, 0x30, 0x34, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x31, 0x07, 0xD0, 0x0F, 0x90, 0x23, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x13, 0x13, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0xCC, 0x00, 0x33, 0xC0, 0x0C, 0x30, 0x03, 0xCD, 0xD2, 0xD1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x03, 0x33, 0x30, 0x03, 0xB3, 0x38, 0xCD, 0xC1, 0x0D, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x03, 0x30, 0x43, 0x30, 0xC7, 0x34, 0xCD, 0x1C, 0xED, 0x1E, 0x2C, 0x0E, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0x4C, 0xC3, 0x81, 0x3B, 0xD0, 0x03, 0xDC, 0x42, 0xC3, 0x31, 0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x03, 0xB3, 0x38, 0xDC, 0x40, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xFF, 0x0F, 0xD0, 0x02, 0x2C, 0xC0, 0x02, 0x2D, 0xC0, 0x06, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x2F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2F, 0x00, 0x00, 0x00,
0x05, 0x03, 0x28, 0xC0, 0x00, 0x0A, 0x30, 0x80, 0x02, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x3E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3E, 0x00, 0x00, 0x00,
0x04, 0x1D, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x47, 0x30, 0xFC, 0x0C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x07, 0x0C, 0xF0, 0xC7, 0x35, 0xC3, 0x0C, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC3, 0x25, 0x03, 0x4C, 0xD2, 0x03, 0x00, 0x00, 0x00, 0x00,
0x05, 0xD0, 0x00, 0x83, 0x8F, 0x33, 0xC3, 0x1C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0xBF, 0x0C, 0xD0, 0x0B, 0x00, 0x00, 0x00, 0x00,
0x04, 0x3D, 0x07, 0x03, 0x2F, 0x03, 0x03, 0x07, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xC0, 0xCB, 0x32, 0xC3, 0xF4, 0x03, 0x4C, 0x30, 0x7E, 0x00, 0x00,
0x05, 0x03, 0x0C, 0xF0, 0xC7, 0x39, 0xC3, 0x0C, 0x73, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x1C, 0x00, 0x0D, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x04, 0x00, 0x30, 0x00, 0x34, 0x30, 0x30, 0x30, 0x30, 0x1E, 0x00,
0x05, 0x03, 0x0C, 0x31, 0xCE, 0x0E, 0x1F, 0xCC, 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x47, 0x3D, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x9B, 0x71, 0x37, 0x33, 0x33, 0x32, 0x43, 0x03, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xC7, 0x31, 0xC3, 0x0C, 0x33, 0x0D, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x31, 0xC3, 0x4C, 0xD3, 0x07, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xC7, 0x31, 0xC3, 0x4C, 0xF3, 0xC7, 0x00, 0x03, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xDF, 0x31, 0xC3, 0x4C, 0xD3, 0x0F, 0x30, 0xC0, 0x00, 0x05,
0x03, 0x00, 0x30, 0x7F, 0xC7, 0x30, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xC0, 0xC7, 0x10, 0x3C, 0x04, 0xF3, 0x03, 0x00, 0x00, 0x00, 0x00,
0x04, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x1C, 0x74, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x70, 0xDC, 0x30, 0xC3, 0x4C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCC, 0x30, 0xD3, 0xDC, 0xC2, 0x02, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x47, 0x33, 0x32, 0x33, 0x73, 0x37, 0xCD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCD, 0x32, 0x7D, 0x8C, 0x73, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCC, 0x30, 0xC7, 0x74, 0x43, 0x07, 0x0C, 0x1F, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0x4F, 0x2C, 0x2C, 0x2C, 0xF1, 0x0F, 0x00, 0x00, 0x00, 0x00,
0x04, 0x38, 0x0C, 0x0C, 0x03, 0x0C, 0x0C, 0x38, 0x00, 0x00, 0x00,
0x02, 0x32, 0x33, 0x33, 0x13, 0x00,
0x04, 0x0B, 0x0C, 0x0C, 0x30, 0x0C, 0x0C, 0x0B, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x1D, 0x72, 0x37, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x00, 0x1F, 0x00, 0x7F, 0x00, 0xFF, 0x01, 0xFF, 0x07, 0xFF, 0x1F, 0xFF, 0x7F, 0xFF, 0x1B, 0xBF, 0x01, 0x1B, 0x00,
0x0C, 0x00, 0x40, 0xFF, 0x00, 0x00, 0xF8, 0xF0, 0x3F, 0xEE, 0x2C, 0x30, 0xCB, 0x0B, 0x30, 0x42, 0xC3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xF3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xFF, 0x3F, 0x00,
0x0C, 0xC2, 0x00, 0x00, 0xCB, 0x00, 0x00, 0xEE, 0xC0, 0xFF, 0xF8, 0xB0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09, 0xFE, 0xFF, 0xE3, 0xFF, 0x0F, 0xAA, 0x3E, 0x0A, 0xF8, 0x2E, 0xE0, 0xBF, 0x80, 0xFF, 0xAA, 0xFE, 0xFF, 0xE2, 0xFF, 0x02, 0x02, 0x00, 0x00,
0x09, 0x00, 0x80, 0x04, 0xD0, 0xE2, 0xFF, 0x02, 0x00, 0x00, 0xFF, 0x6F, 0x00, 0x40, 0xE6, 0xAF, 0x50, 0x00, 0x09, 0x00, 0x20, 0x00, 0x64, 0x00,
0x09, 0xE0, 0x3F, 0x70, 0x60, 0x63, 0xC0, 0xE4, 0x80, 0xC2, 0x03, 0x07, 0x0F, 0x1E, 0x6C, 0xFF, 0x27, 0xFF, 0x3F, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x09, 0x44, 0x44, 0x00, 0x12, 0x41, 0x88, 0x04, 0x21, 0x21, 0x84, 0x48, 0x20, 0x23, 0xC2, 0xCC, 0x08, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x1D, 0x00, 0x1D, 0x00, 0x78, 0x00, 0xB4, 0x07, 0xF0, 0x2F, 0xC0, 0xFB, 0x00, 0xBE, 0x02, 0xF4, 0x07, 0xFD, 0xFF, 0x01, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x00, 0x19, 0x00, 0xA8, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x00, 0x00, 0xF0, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 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 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x87, 0x30, 0x60, 0x60, 0x60, 0xC0, 0x3F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x87, 0x30, 0xB8, 0x00, 0x23, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x0E, 0x36, 0xC6, 0xFC, 0x03, 0x0C, 0x30, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xCB, 0x00, 0x7F, 0x40, 0x13, 0x8C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xCB, 0x10, 0x2F, 0x4C, 0x33, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0x0F, 0x30, 0x60, 0x60, 0xC0, 0x00, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0x7D, 0x4C, 0x33, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0xC6, 0xE0, 0x03, 0x8C, 0x1F, 0x00, 0x00, 0x00,
0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x03, 0xC0, 0xF0, 0x3C, 0xCF, 0xF3, 0x3C, 0x03, 0x00,
0x03, 0x00, 0xCC, 0xF3, 0x3C, 0xCF, 0xF3, 0x30, 0x00,
0x05, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00,
};
short font_ptrs[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x000E, 0x0017, 0x0025, 0x0035, 0x0045, 0x0058, 0x0068,
0x0071, 0x007C, 0x0087, 0x0097, 0x00A7, 0x00B2, 0x00C0, 0x00C9,
0x00D9, 0x00E9, 0x00F7, 0x0107, 0x0117, 0x0127, 0x0137, 0x0147,
0x0157, 0x0167, 0x0177, 0x0180, 0x018B, 0x019B, 0x01AB, 0x01BB,
0x01CB, 0x01E0, 0x01F0, 0x0200, 0x0210, 0x0220, 0x0230, 0x0240,
0x0250, 0x0260, 0x026B, 0x027B, 0x028E, 0x029E, 0x02B3, 0x02C6,
0x02D9, 0x02E9, 0x02FC, 0x030C, 0x031C, 0x032C, 0x033F, 0x034F,
0x0364, 0x0377, 0x0387, 0x039A, 0x03A5, 0x03B3, 0x03BE, 0x03C9,
0x03D9, 0x03E2, 0x03F0, 0x03FE, 0x040C, 0x041A, 0x0428, 0x0433,
0x0441, 0x044F, 0x045A, 0x0465, 0x0473, 0x047E, 0x048E, 0x049C,
0x04AA, 0x04B8, 0x04C6, 0x04CF, 0x04DD, 0x04E8, 0x04F6, 0x0504,
0x0514, 0x0522, 0x0530, 0x053E, 0x0549, 0x054F, 0x055A, 0x056A,
0x0575, 0x058A, 0x05A9, 0x05C8, 0x05E2, 0x0601, 0x061B, 0x0635,
0x064F, 0x0669, 0x0683, 0x069D, 0x06B7, 0x06D6, 0x06E6, 0x0700,
0x071A, 0x0734, 0x074E, 0x0763, 0x0780, 0x079D, 0x07BC, 0x07DB,
0x07F3, 0x080B, 0x0823, 0x083B, 0x0853, 0x086B, 0x0883, 0x089B,
0x08B3, 0x08CB, 0x08E3, 0x08FD, 0x091A, 0x0937, 0x094C, 0x0966,
0x0980, 0x099A, 0x09B4, 0x09CC, 0x09D7, 0x09E0, 0x09E9, 0x09F7,
0x0A05, 0x0A13, 0x0A21, 0x0A2F, 0x0A3D, 0x0A4B, 0x0A59, 0x0A67,
0x0A75, 0x0A83, 0x0A8E, 0x0A97, 0x0AA0, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE, 0x0AAE,
};

5
font/Makefile Normal file
View File

@ -0,0 +1,5 @@
editor: editor.c
gcc -oeditor -DSCALE=2 editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99
clean:
rm -f editor packer

284
font/editor.c Normal file
View File

@ -0,0 +1,284 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>
#define CELLW 12
#define CELLH 10
#define XRES 800
#define YRES 600
char xsize=CELLW, ysize=CELLH;
char base=7, top=2;
char font[256][CELLH][CELLW];
char width[256];
void blendpixel(unsigned *vid, int x, int y, int r, int g, int b, int a)
{
int t;
if(x<0 || y<0 || x>=XRES || y>=YRES)
return;
if(a!=255) {
t = vid[y*XRES+x];
r = (a*r + (255-a)*((t>>16)&255)) >> 8;
g = (a*g + (255-a)*((t>>8)&255)) >> 8;
b = (a*b + (255-a)*(t&255)) >> 8;
}
vid[y*XRES+x] = (r<<16)|(g<<8)|b;
}
int drawchar(unsigned *vid, int x, int y, int c, int r, int g, int b)
{
int i, j;
for(j=0; j<CELLH; j++)
for(i=0; i<width[c]; i++)
blendpixel(vid, x+i, y+j, r, g, b, (font[c][j][i]*255)/3);
return x + width[c];
}
int drawtext(unsigned *vid, int x, int y, char *s, int r, int g, int b)
{
for(;*s;s++)
x = drawchar(vid, x, y, *s, r, g, b);
return x;
}
void drawline(unsigned *vid, int x1, int y1, int x2, int y2, int r, int g, int b, int a)
{
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
float e, de;
if(cp) {
y = x1;
x1 = y1;
y1 = y;
y = x2;
x2 = y2;
y2 = y;
}
if(x1 > x2) {
y = x1;
x1 = x2;
x2 = y;
y = y1;
y1 = y2;
y2 = y;
}
dx = x2 - x1;
dy = abs(y2 - y1);
e = 0.0f;
de = dy/(float)dx;
y = y1;
sy = (y1<y2) ? 1 : -1;
for(x=x1; x<=x2; x++) {
if(cp)
blendpixel(vid, y, x, r, g, b, a);
else
blendpixel(vid, x, y, r, g, b, a);
e += de;
if(e >= 0.5f) {
y += sy;
e -= 1.0f;
}
}
}
void drawcell(unsigned *vid, int i, int j, int c, int m)
{
int x,y,x0=i*32+64,y0=j*32+64;
for(y=1;y<32;y++)
for(x=1;x<32;x++)
blendpixel(vid, x0+x, y0+y, 127*m, 127*m, 127*m, c);
for(x=0;x<32;x+=2) {
if(!j)
blendpixel(vid, x0+x, y0, 64*m, 64*m, 64*m, 255);
if(!i)
blendpixel(vid, x0, y0+x, 64*m, 64*m, 64*m, 255);
blendpixel(vid, x0+x, y0+32, 64*m, 64*m, 64*m, 255);
blendpixel(vid, x0+32, y0+x, 64*m, 64*m, 64*m, 255);
}
}
/***********************************************************
* SDL OUTPUT *
***********************************************************/
SDL_Surface *sdl_scrn;
int sdl_key;
void sdl_open(void)
{
if(SDL_Init(SDL_INIT_VIDEO)<0) {
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
sdl_scrn=SDL_SetVideoMode(XRES*SCALE,YRES*SCALE + 40*SCALE,32,SDL_SWSURFACE);
if(!sdl_scrn) {
fprintf(stderr, "Creating window: %s\n", SDL_GetError());
exit(1);
}
}
void sdl_blit(int x, int y, int w, int h, unsigned int *src, int pitch)
{
unsigned *dst,i,j,k;
if(SDL_MUSTLOCK(sdl_scrn))
if(SDL_LockSurface(sdl_scrn)<0)
return;
dst=(unsigned *)sdl_scrn->pixels+y*sdl_scrn->pitch/4+x;
for(j=0;j<h;j++) {
for(k=0;k<SCALE;k++) {
for(i=0;i<w*SCALE;i++)
dst[i]=src[i/SCALE];
dst+=sdl_scrn->pitch/4;
}
src+=pitch/4;
}
if(SDL_MUSTLOCK(sdl_scrn))
SDL_UnlockSurface(sdl_scrn);
SDL_UpdateRect(sdl_scrn,0,0,0,0);
}
int frame_idx=0;
void dump_frame(unsigned int *src, int w, int h, int pitch)
{
char frame_name[32];
unsigned j,i,c;
FILE *f;
sprintf(frame_name,"frame%04d.ppm",frame_idx);
f=fopen(frame_name,"w");
fprintf(f,"P6\n%d %d\n255\n",w,h);
for(j=0;j<h;j++) {
for(i=0;i<w;i++) {
c=((src[i]&0xFF0000)>>16)|(src[i]&0x00FF00)|((src[i]&0x0000FF)<<16);
fwrite(&c,3,1,f);
}
src+=pitch/4;
}
fclose(f);
frame_idx++;
}
int sdl_poll(void)
{
SDL_Event event;
sdl_key=0;
while(SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
sdl_key=event.key.keysym.sym;
break;
case SDL_QUIT:
return 1;
}
}
return 0;
}
/***********************************************************
* MAIN PROGRAM *
***********************************************************/
char *tag = "(c) 2008 Stanislaw Skowronek";
int main(int argc, char *argv[])
{
unsigned *vid_buf = calloc(XRES*YRES, sizeof(unsigned));
int x, y, b = 0, lb, c = 0xA0, i, j, dc = 0;
int mode = 0;
FILE *f;
f = fopen("font.bin", "r");
if(f) {
fread(&xsize, 1, 1, f);
fread(&ysize, 1, 1, f);
fread(&base, 1, 1, f);
fread(&top, 1, 1, f);
fread(width, 1, 256, f);
fread(font, CELLW*CELLH, 256, f);
fclose(f);
}
sdl_open();
while(!sdl_poll()) {
if(sdl_key=='q' || sdl_key==SDLK_ESCAPE)
break;
if(sdl_key==' ' || sdl_key=='=') {
c++;
printf("Current: %02X '%c'\n", c, c);
}
if(sdl_key=='\b' || sdl_key=='-') {
c--;
printf("Current: %02X '%c'\n", c, c);
}
lb = b;
b = SDL_GetMouseState(&x, &y);
if(b) {
x /= SCALE;
y /= SCALE;
}
i = x/32-2;
j = y/32-2;
if(!lb && b && (i<0 || i>=CELLW)) {
if(abs(j-base) < abs(j-top))
mode = 2; // BASE
else
mode = 3; // TOP
} else if(!lb && b && (j<0 || j>=CELLH))
mode = 4; // LEFT
else if(!lb && b) {
mode = 1; // DRAW
if(b==1)
dc = (font[c][j][i]+3)%4;
else
dc = (font[c][j][i]+1)%4;
}
if(b)
switch(mode) {
case 1:
if(i>=0 && j>=0 && i<CELLW && j<CELLH)
font[c][j][i] = dc;
break;
case 2:
base = j;
break;
case 3:
top = j;
break;
case 4:
width[c] = i;
break;
}
memset(vid_buf, 0, XRES*YRES*4);
for(j=0; j<CELLH; j++)
for(i=0; i<CELLW; i++)
drawcell(vid_buf, i, j, (font[c][j][i]*255)/3, i>=width[c]?1:2);
drawline(vid_buf, 32, 64+base*32, 128+32*CELLW, 64+base*32, 128, 255, 128, 255);
drawline(vid_buf, 32, 64+top*32, 128+32*CELLW, 64+top*32, 128, 128, 255, 255);
drawline(vid_buf, 64+width[c]*32, 32, 64+width[c]*32, 128+32*CELLH, 255, 128, 128, 255);
drawtext(vid_buf, 64, 192+32*CELLH, "A quick brown fox jumps over the lazy dog.", 255, 255, 255);
drawtext(vid_buf, 64, 192+33*CELLH, "A QUICK BROWN FOX JUMPS OVER THE LAZY DOG.", 255, 255, 255);
drawtext(vid_buf, 64, 192+34*CELLH, "0123456789 ~`!@#$%^&*()-=_+[]{}\\|;:'\",./<>?", 255, 255, 255);
drawchar(vid_buf, 32, 192+32*CELLH, c, 255, 255, 255);
sdl_blit(0, 0, XRES, YRES, vid_buf, XRES*4);
}
f = fopen("font.bin", "w");
fwrite(&xsize, 1, 1, f);
fwrite(&ysize, 1, 1, f);
fwrite(&base, 1, 1, f);
fwrite(&top, 1, 1, f);
fwrite(width, 1, 256, f);
fwrite(font, CELLW*CELLH, 256, f);
fclose(f);
return 0;
}

BIN
font/font.bin Normal file

Binary file not shown.

100
font/packer.c Normal file
View File

@ -0,0 +1,100 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define CELLW 12
#define CELLH 10
char xsize=CELLW, ysize=CELLH;
char base=7, top=2;
char font[256][CELLH][CELLW];
char width[256];
int bits_n = 0, bits_a = 0;
int flush_bits(void)
{
if(bits_n) {
bits_a >>= 8-bits_n;
printf("0x%02X, ", bits_a);
bits_a = 0;
bits_n = 0;
return 1;
}
return 0;
}
int stock_bits(int b, int nb)
{
bits_a >>= nb;
bits_a |= b << (8-nb);
bits_n += nb;
if(bits_n >= 8) {
printf("0x%02X, ", bits_a);
bits_a = 0;
bits_n = 0;
return 1;
}
return 0;
}
int save_char(int c)
{
int nb = 1;
int x, y;
if(!width[c])
return 0;
printf(" 0x%02X, ", width[c]);
for(y=0; y<CELLH; y++)
for(x=0; x<width[c]; x++)
nb += stock_bits(font[c][y][x]&3, 2);
nb += flush_bits();
printf("\n");
return nb;
}
char *tag = "(c) 2008 Stanislaw Skowronek";
int main(int argc, char *argv[])
{
FILE *f;
int c, p[256], n = 0;
memset(p, 0, 256*4);
f = fopen("font.bin", "r");
fread(&xsize, 1, 1, f);
fread(&ysize, 1, 1, f);
fread(&base, 1, 1, f);
fread(&top, 1, 1, f);
fread(width, 1, 256, f);
fread(font, CELLW*CELLH, 256, f);
fclose(f);
printf("#define FONT_H %d\n", ysize);
printf("char font_data[] = {\n");
for(c=0; c<256; c++) {
p[c] = n;
n += save_char(c);
}
printf("};\n");
printf("short font_ptrs[] = {\n");
for(c=0; c<256; c++) {
if(!(c%8))
printf(" ");
printf("0x%04X,", p[c]);
if((c%8)==7)
printf("\n");
else
printf(" ");
}
printf("};\n");
return 0;
}

View File

@ -1,290 +0,0 @@
#!/usr/bin/env python3
import bz2
import math
import re
import argparse
CP_MAX = 0x10FFFF
FONT_CPP = "resources/font.bz2"
FONT_HEIGHT = 12
class ReadBDFError(RuntimeError):
def __init__(self, line_number, message):
super().__init__(self, 'line %i: %s' % (line_number, message))
class FontTool:
def __init__(self, file):
self.file = file
with open(self.file, 'rb') as font_cpp:
font_cpp_data = bz2.decompress(font_cpp.read())
i = 0
self.code_points = [False for _ in range(CP_MAX + 2)]
while i < len(font_cpp_data):
cp = font_cpp_data[i] | (font_cpp_data[i + 1] << 8) | (font_cpp_data[i + 2] << 16)
width = font_cpp_data[i + 3]
n = i + 4 + 3 * width
self.code_points[cp] = font_cpp_data[(i + 3): n]
i = n
def commit(self):
l = []
for i, data in enumerate(self.code_points):
if data:
l.append(i & 0xFF)
l.append((i >> 8) & 0xFF)
l.append((i >> 16) & 0xFF)
l += data
with open(self.file, 'wb') as font_cpp:
font_cpp.write(bz2.compress(bytes(l)))
def pack(cp_matrix):
width = 0
for row in cp_matrix:
if width < len(row):
width = len(row)
cp_data = [width]
bits = 8
for row in cp_matrix:
padded = row + [0] * (width - len(row))
for cv in padded:
if bits == 8:
cp_data.append(0)
bits = 0
cp_data[-1] |= (cv & 3) << bits
bits += 2
return cp_data
def unpack(cp_data):
ptr = 1
bits = 0
buf = 0
cp_matrix = []
for y in range(FONT_HEIGHT):
cp_matrix.append([])
for x in range(cp_data[0]):
if bits == 0:
buf = cp_data[ptr]
ptr += 1
bits = 8
cp_matrix[-1].append(buf & 3)
buf >>= 2
bits -= 2
return cp_matrix
def dump(self, i, print):
lut = [' ', '░░', '▒▒', '▓▓']
if self.code_points[i]:
print('code point %i (%c)' % (i, i))
print('')
for l in [''.join([lut[ch] for ch in row]) for row in FontTool.unpack(self.code_points[i])]:
print(l)
print('')
else:
print('code point %i (%c) is not available' % (i, i))
class RawReader:
def __init__(self, path):
self.code_points = [False for _ in range(CP_MAX + 2)]
with open(path) as raw:
items = [int(v) for v in re.findall(r'[0-9]+', raw.read())]
ptr = 0
while ptr <= len(items) - 2:
cp = items[ptr]
width = items[ptr + 1]
ptr += 2
matrix = []
for i in range(ptr, ptr + width * FONT_HEIGHT, width):
matrix.append(items[i: (i + width)])
ptr += width * FONT_HEIGHT
self.code_points[cp] = FontTool.pack(matrix)
class BDFReader:
def __init__(self, path, xoffs, yoffs):
self.code_points = [False for _ in range(CP_MAX + 2)]
item_re = re.compile(r'[^ \n\r]+')
with open(path) as bdf:
global_dw = False
startchar = False
bitmap = False
char_dw = False
char_cp = False
char_bbx = False
skip = 0
for line_number, line in enumerate(bdf):
if skip:
skip -= 1
continue
items = re.findall(item_re, line)
if startchar and items[0] == 'ENDCHAR':
if len(bitmap) != char_bbx[1]:
raise ReadBDFError(line_number, "invalid bitmap data")
cp_matrix = []
for y in range(FONT_HEIGHT):
cp_matrix.append([])
for x in range(char_dw):
cv = 0
xx = x + xoffs
yy = FONT_HEIGHT - 1 - y + yoffs
if char_bbx[2] <= xx < char_bbx[0] + char_bbx[2] and char_bbx[3] <= yy < char_bbx[1] + \
char_bbx[3]:
cv = bitmap[char_bbx[1] - 1 - (yy - char_bbx[3])][xx - char_bbx[2]] * 3
cp_matrix[-1].append(cv)
self.code_points[char_cp] = FontTool.pack(cp_matrix)
startchar = False
bitmap = False
char_dw = False
char_cp = False
char_bbx = False
elif bitmap != False:
if len(items) != 1:
raise ReadBDFError(line_number, "missing bitmap data")
bits = []
for ch in items[0]:
cv = int(ch, 16)
bits += [cv & 8 and 1 or 0, cv & 4 and 1 or 0, cv & 2 and 1 or 0, cv & 1 and 1 or 0]
bitmap.append(bits[: char_bbx[0]])
elif items[0] == 'SIZE':
if len(items) != 4:
raise ReadBDFError(line_number, "invalid directive")
elif items[0] == 'FONTBOUNDINGBOX':
if len(items) != 5:
raise ReadBDFError(line_number, "invalid directive")
elif not startchar and items[0] == 'STARTCHAR':
startchar = True
char_dw = global_dw
elif items[0] == 'STARTPROPERTIES':
if len(items) != 2:
raise ReadBDFError(line_number, "invalid directive")
skip = int(items[1]) + 1
elif startchar and items[0] == 'BITMAP':
bitmap = []
elif startchar and items[0] == 'BBX':
if len(items) != 5:
raise ReadBDFError(line_number, "invalid directive")
char_bbx = [int(items[1]), int(items[2]), int(items[3]), int(items[4])]
elif startchar and items[0] == 'ENCODING':
if len(items) != 2:
raise ReadBDFError(line_number, "invalid directive")
char_cp = int(items[1])
elif items[0] == 'METRICSSET':
if len(items) != 2:
raise ReadBDFError(line_number, "invalid directive")
if int(items[1]) == 1:
raise ReadBDFError(line_number, "font does not support writing direction 0")
elif items[0] == 'DWIDTH':
if len(items) != 3:
raise ReadBDFError(line_number, "invalid directive")
if int(items[2]) != 0:
raise ReadBDFError(line_number, "vertical component of dwidth vector is non-zero")
char_dw = int(items[1])
if not startchar:
global_dw = char_dw
def pad_str(s, pad, n):
return s + pad * (n - len(s))
if __name__ == "__main__":
parser = argparse.ArgumentParser("fonttool.py", description="font tools for managing fonts, this script can be"
" imported as a module",
fromfile_prefix_chars="@")
command = parser.add_subparsers(dest="command", required=True)
addbdf = command.add_parser("addbdf", help="Adds BDF Formated Font")
addbdf.add_argument("first", metavar="FIRST", type=int)
addbdf.add_argument("last", metavar="LAST", type=int)
addbdf.add_argument("bdffile", metavar="BDFFILE", help="BDF is an archaic bitmap font format")
addbdf.add_argument("xoffs", metavar="XOFFS", nargs="?", default=0, type=int, help="Defaults to 0")
addbdf.add_argument("yoffs", metavar="YOFFS", nargs="?", default=0, type=int, help="Defaults to 0")
addraw = command.add_parser("addraw", help="Adds a Raw Formated Font")
addraw.add_argument("first", metavar="FIRST", type=int)
addraw.add_argument("last", metavar="LAST", type=int)
addraw.add_argument("rawfile", metavar="RAWFILE", help=""""Raw" files are simply ASCII-encoded white-space delimited \
lists
of decimal integer constants. These lists of integers encode
characters as any number of consecutive character description
structures laid out as follows:
* the code point corresponding to the character being described;
* the width in pixels of the character being described;
* width times %i brightness levels between 0 and 3, a row-major matrix.""")
remove = command.add_parser("remove", help="Remove a range of characters")
remove.add_argument("first", metavar="FIRST", type=int)
remove.add_argument("last", metavar="LAST", type=int, default=None, nargs="?", help="Defaults to FIRST")
copy = command.add_parser("copy", help="Copy a range of characters to another range")
copy.add_argument("dest", metavar="DSTFIRST", type=int)
copy.add_argument("first", metavar="SRCFIRST", type=int)
copy.add_argument("last", metavar="SRCLAST", type=int, default=None, nargs="?", help="Defaults to SRCFIRST")
inspect = command.add_parser("inspect", help="Inspect a range of characters")
inspect.add_argument("first", metavar="FIRST", type=int)
inspect.add_argument("last", metavar="LAST", type=int, default=None, nargs="?", help="Defaults to FIRST")
diff = command.add_parser("diff", help="Prints subranges that changed between the current and an external font file")
diff.add_argument("external", metavar="EXTERNAL", help="External font.bz2")
args = parser.parse_args()
if 'first' in args:
cp_first = args.first
if args.last is None:
cp_last = cp_first
else:
cp_last = args.last
if cp_first < 0 or cp_last > CP_MAX or cp_first > cp_last:
print('invalid range')
exit(1)
ft = FontTool(FONT_CPP)
if args.command == "addbdf":
xoffs = args.xoffs
yoffs = args.yoffs
bdfr = BDFReader(args.bdffile, xoffs, yoffs)
for i in range(cp_first, cp_last + 1):
if bdfr.code_points[i] and not ft.code_points[i]:
ft.code_points[i] = bdfr.code_points[i]
ft.commit()
elif args.command == 'addraw':
rr = RawReader(args.rawfile)
for i in range(cp_first, cp_last + 1):
if rr.code_points[i] and not ft.code_points[i]:
ft.code_points[i] = rr.code_points[i]
ft.commit()
elif args.command == 'remove':
for i in range(cp_first, cp_last + 1):
ft.code_points[i] = False
ft.commit()
elif args.command == 'copy':
for i in range(cp_first, cp_last + 1):
ft.code_points[i + (args.dest - cp_first)] = ft.code_points[i]
ft.commit()
elif args.command == 'inspect':
for i in range(cp_first, cp_last + 1):
ft.dump(i, print)
elif args.command == 'diff':
pad_to = 50
eft = FontTool(args.external)
for i in range(0, CP_MAX + 1):
if eft.code_points[i] != ft.code_points[i]:
cur = []
def add_cur(line):
global cur
cur.append(line)
ft.dump(i, add_cur)
ext = []
def add_ext(line):
global ext
ext.append(line)
eft.dump(i, add_ext)
print('#' * (2 * pad_to + 7))
for j in range(max(len(cur), len(ext))):
print('# ' + pad_str(j < len(cur) and cur[j] or '', ' ', pad_to) + ' # ' + pad_str(j < len(ext) and ext[j] or '', ' ', pad_to) + ' #')

856
http.c Normal file
View File

@ -0,0 +1,856 @@
/**
* Powder Toy - HTTP library
*
* Powder Toy is the legal property of Stanislaw Skowronek.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifndef MACOSX
#include <malloc.h>
#endif
#include <time.h>
#ifdef WIN32
#define _WIN32_WINNT 0x0501
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/socket.h>
#include <netdb.h>
#endif
#include "http.h"
#include "md5.h"
#ifdef WIN32
#define PERROR SOCKET_ERROR
#define PERRNO WSAGetLastError()
#define PEAGAIN WSAEWOULDBLOCK
#define PEINTR WSAEINTR
#define PEINPROGRESS WSAEINPROGRESS
#define PEALREADY WSAEALREADY
#define PCLOSE closesocket
#else
#define PERROR -1
#define PERRNO errno
#define PEAGAIN EAGAIN
#define PEINTR EINTR
#define PEINPROGRESS EINPROGRESS
#define PEALREADY EALREADY
#define PCLOSE close
#endif
static int http_up = 0;
static long http_timeout = 15;
static int http_use_proxy = 0;
static struct sockaddr_in http_proxy;
static char *mystrdup(char *s)
{
char *x;
if(s) {
x = malloc(strlen(s)+1);
strcpy(x, s);
return x;
}
return s;
}
static int splituri(char *uri, char **host, char **path)
{
char *p=uri,*q,*x,*y;
if(!strncmp(p, "http://", 7))
p += 7;
q = strchr(p, '/');
if(!q)
q = p + strlen(p);
x = malloc(q-p+1);
if(*q)
y = mystrdup(q);
else
y = mystrdup("/");
strncpy(x, p, q-p);
x[q-p] = 0;
if(q==p || x[q-p-1]==':') {
free(x);
free(y);
return 1;
}
*host = x;
*path = y;
return 0;
}
static char *getserv(char *host)
{
char *q, *x = mystrdup(host);
q = strchr(x, ':');
if(q)
*q = 0;
return x;
}
static char *getport(char *host)
{
char *p, *q;
q = strchr(host, ':');
if(q)
p = mystrdup(q+1);
else
p = mystrdup("80");
return p;
}
static int resolve(char *dns, char *srv, struct sockaddr_in *addr)
{
struct addrinfo hnt, *res = 0;
if(http_use_proxy) {
memcpy(addr, &http_proxy, sizeof(struct sockaddr_in));
return 0;
}
memset(&hnt, 0, sizeof(hnt));
hnt.ai_family = AF_INET;
hnt.ai_socktype = SOCK_STREAM;
if(getaddrinfo(dns, srv, &hnt, &res))
return 1;
if(res) {
if(res->ai_family != AF_INET) {
freeaddrinfo(res);
return 1;
}
memcpy(addr, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);
return 0;
}
return 1;
}
void http_init(char *proxy)
{
char *host, *port;
#ifdef WIN32
WSADATA wsadata;
if(!WSAStartup(MAKEWORD(2,2), &wsadata))
http_up = 1;
#else
signal(SIGPIPE, SIG_IGN);
http_up = 1;
#endif
if(proxy) {
host = getserv(proxy);
port = getport(proxy);
if(resolve(host, port, &http_proxy))
http_up = 0;
else
http_use_proxy = 1;
free(host);
free(port);
}
}
void http_done(void)
{
#ifdef WIN32
WSACleanup();
#endif
http_up = 0;
}
#define CHUNK 4096
#define HTS_STRT 0
#define HTS_RSLV 1
#define HTS_CONN 2
#define HTS_IDLE 3
#define HTS_XMIT 4
#define HTS_RECV 5
#define HTS_DONE 6
struct http_ctx {
int state;
long last;
int keep;
int ret;
char *host, *path;
char *thdr;
int thlen;
char *txd;
int txdl;
struct sockaddr_in addr;
char *tbuf;
int tlen, tptr;
char *hbuf;
int hlen, hptr;
char *rbuf;
int rlen, rptr;
int chunked, chunkhdr, rxtogo, contlen, cclose;
int fd;
char *fdhost;
};
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
{
struct http_ctx *cx = ctx;
if(!ctx) {
ctx = calloc(1, sizeof(struct http_ctx));
cx = ctx;
cx->fd = PERROR;
}
if(!cx->hbuf) {
cx->hbuf = malloc(256);
cx->hlen = 256;
}
if(!http_up) {
cx->ret = 604;
cx->state = HTS_DONE;
return ctx;
}
if(cx->state!=HTS_STRT && cx->state!=HTS_IDLE) {
fprintf(stderr, "HTTP: unclean request restart state.\n");
exit(1);
}
cx->keep = keep;
cx->ret = 600;
if(splituri(uri, &cx->host, &cx->path)) {
cx->ret = 601;
cx->state = HTS_DONE;
return ctx;
}
if(http_use_proxy) {
free(cx->path);
cx->path = mystrdup(uri);
}
if(cx->fdhost && strcmp(cx->host, cx->fdhost)) {
free(cx->fdhost);
cx->fdhost = NULL;
PCLOSE(cx->fd);
cx->fd = PERROR;
cx->state = HTS_STRT;
}
if(data) {
if(!dlen)
dlen = strlen(data);
cx->txd = malloc(dlen);
memcpy(cx->txd, data, dlen);
cx->txdl = dlen;
} else
cx->txdl = 0;
cx->contlen = 0;
cx->chunked = 0;
cx->chunkhdr = 0;
cx->rxtogo = 0;
cx->cclose = 0;
cx->tptr = 0;
cx->tlen = 0;
cx->last = time(NULL);
return ctx;
}
void http_async_add_header(void *ctx, char *name, char *data)
{
struct http_ctx *cx = ctx;
cx->thdr = realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 4);
cx->thlen += sprintf(cx->thdr+cx->thlen, "%s: %s\n", name, data);
}
static void process_header(struct http_ctx *cx, char *str)
{
char *p;
if(cx->chunkhdr) {
p = strchr(str, ';');
if(p)
*p = 0;
cx->rxtogo = strtoul(str, NULL, 16);
cx->chunkhdr = 0;
if(!cx->rxtogo)
cx->chunked = 0;
}
if(!str[0]) {
cx->rxtogo = cx->contlen;
cx->chunkhdr = cx->chunked;
if(!cx->contlen && !cx->chunked && cx->ret!=100)
cx->state = HTS_DONE;
return;
}
if(!strncmp(str, "HTTP/", 5)) {
p = strchr(str, ' ');
if(!p) {
cx->ret = 603;
cx->state = HTS_DONE;
return;
}
p++;
cx->ret = atoi(p);
return;
}
if(!strncmp(str, "Content-Length: ", 16)) {
cx->contlen = atoi(str+16);
return;
}
if(!strcmp(str, "Transfer-Encoding: chunked")) {
cx->chunked = 1;
return;
}
if(!strcmp(str, "Connection: close")) {
cx->cclose = 1;
return;
}
}
static void process_byte(struct http_ctx *cx, char ch)
{
if(cx->rxtogo) {
cx->rxtogo--;
if(!cx->rbuf) {
cx->rbuf = malloc(256);
cx->rlen = 256;
}
if(cx->rptr >= cx->rlen-1) {
cx->rlen *= 2;
cx->rbuf = realloc(cx->rbuf, cx->rlen);
}
cx->rbuf[cx->rptr++] = ch;
if(!cx->rxtogo && !cx->chunked)
cx->state = HTS_DONE;
} else {
if(ch == '\n') {
cx->hbuf[cx->hptr] = 0;
process_header(cx, cx->hbuf);
cx->hptr = 0;
} else if(ch != '\r') {
if(cx->hptr >= cx->hlen-1) {
cx->hlen *= 2;
cx->hbuf = realloc(cx->hbuf, cx->hlen);
}
cx->hbuf[cx->hptr++] = ch;
}
}
}
int http_async_req_status(void *ctx)
{
struct http_ctx *cx = ctx;
char *dns,*srv,buf[CHUNK];
int tmp, i;
long now = time(NULL);
#ifdef WIN32
unsigned long tmp2;
#endif
switch(cx->state) {
case HTS_STRT:
dns = getserv(cx->host);
srv = getport(cx->host);
if(resolve(dns, srv, &cx->addr)) {
free(dns);
free(srv);
cx->state = HTS_DONE;
cx->ret = 602;
return 1;
}
free(dns);
free(srv);
cx->state = HTS_RSLV;
return 0;
case HTS_RSLV:
cx->state = HTS_CONN;
cx->last = now;
return 0;
case HTS_CONN:
if(cx->fd == PERROR) {
cx->fd = socket(AF_INET, SOCK_STREAM, 0);
if(cx->fd == PERROR)
goto fail;
cx->fdhost = mystrdup(cx->host);
#ifdef WIN32
tmp2 = 1;
if(ioctlsocket(cx->fd, FIONBIO, &tmp2) == SOCKET_ERROR)
goto fail;
#else
tmp = fcntl(cx->fd, F_GETFL);
if(tmp < 0)
goto fail;
if(fcntl(cx->fd, F_SETFL, tmp|O_NONBLOCK) < 0)
goto fail;
#endif
}
if(!connect(cx->fd, (struct sockaddr *)&cx->addr, sizeof(cx->addr)))
cx->state = HTS_IDLE;
#ifdef WIN32
else if(PERRNO==WSAEISCONN)
cx->state = HTS_IDLE;
#endif
#ifdef MACOSX
else if(PERRNO==EISCONN)
cx->state = HTS_IDLE;
#endif
else if(PERRNO!=PEINPROGRESS && PERRNO!=PEALREADY
#ifdef WIN32
&& PERRNO!=PEAGAIN && PERRNO!=WSAEINVAL
#endif
)
goto fail;
if(now-cx->last>http_timeout)
goto timeout;
return 0;
case HTS_IDLE:
if(cx->txdl) {
// generate POST
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 96 + cx->txdl + cx->thlen);
cx->tptr = 0;
cx->tlen = 0;
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host);
if(!cx->keep)
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
if(cx->thdr) {
memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen);
cx->tlen += cx->thlen;
free(cx->thdr);
cx->thdr = NULL;
cx->thlen = 0;
}
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
cx->tlen += cx->txdl;
free(cx->txd);
cx->txd = NULL;
cx->txdl = 0;
} else {
// generate GET
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 64 + cx->thlen);
cx->tptr = 0;
cx->tlen = 0;
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host);
if(cx->thdr) {
memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen);
cx->tlen += cx->thlen;
free(cx->thdr);
cx->thdr = NULL;
cx->thlen = 0;
}
if(!cx->keep)
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
}
cx->state = HTS_XMIT;
cx->last = now;
return 0;
case HTS_XMIT:
tmp = send(cx->fd, cx->tbuf+cx->tptr, cx->tlen-cx->tptr, 0);
if(tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR)
goto fail;
if(tmp!=PERROR) {
cx->tptr += tmp;
if(cx->tptr == cx->tlen) {
cx->tptr = 0;
cx->tlen = 0;
free(cx->tbuf);
cx->state = HTS_RECV;
}
cx->last = now;
}
if(now-cx->last>http_timeout)
goto timeout;
return 0;
case HTS_RECV:
tmp = recv(cx->fd, buf, CHUNK, 0);
if(tmp==PERROR && PERRNO!=PEAGAIN && PERRNO!=PEINTR)
goto fail;
if(tmp!=PERROR) {
for(i=0;i<tmp;i++) {
process_byte(cx, buf[i]);
if(cx->state == HTS_DONE)
return 1;
}
cx->last = now;
}
if(now-cx->last>http_timeout)
goto timeout;
return 0;
case HTS_DONE:
return 1;
}
return 0;
fail:
cx->ret = 600;
cx->state = HTS_DONE;
return 1;
timeout:
cx->ret = 605;
cx->state = HTS_DONE;
return 1;
}
char *http_async_req_stop(void *ctx, int *ret, int *len)
{
struct http_ctx *cx = ctx;
char *rxd;
if(cx->state != HTS_DONE)
while(!http_async_req_status(ctx)) ;
if(cx->host) {
free(cx->host);
cx->host = NULL;
}
if(cx->path) {
free(cx->path);
cx->path = NULL;
}
if(cx->txd) {
free(cx->txd);
cx->txd = NULL;
cx->txdl = 0;
}
if(cx->hbuf) {
free(cx->hbuf);
cx->hbuf = NULL;
}
if(cx->thdr) {
free(cx->thdr);
cx->thdr = NULL;
cx->thlen = 0;
}
if(ret)
*ret = cx->ret;
if(len)
*len = cx->rptr;
if(cx->rbuf)
cx->rbuf[cx->rptr] = 0;
rxd = cx->rbuf;
cx->rbuf = NULL;
cx->rlen = 0;
cx->rptr = 0;
cx->contlen = 0;
if(!cx->keep)
http_async_req_close(ctx);
else if(cx->cclose) {
PCLOSE(cx->fd);
cx->fd = PERROR;
if(cx->fdhost) {
free(cx->fdhost);
cx->fdhost = NULL;
}
cx->state = HTS_STRT;
} else
cx->state = HTS_IDLE;
return rxd;
}
void http_async_get_length(void *ctx, int *total, int *done)
{
struct http_ctx *cx = ctx;
if(done)
*done = cx->rptr;
if(total)
*total = cx->contlen;
}
void http_async_req_close(void *ctx)
{
struct http_ctx *cx = ctx;
void *tmp;
if(cx->host) {
cx->keep = 1;
tmp = http_async_req_stop(ctx, NULL, NULL);
if(tmp)
free(tmp);
}
if(cx->fdhost)
free(cx->fdhost);
PCLOSE(cx->fd);
free(ctx);
}
char *http_simple_get(char *uri, int *ret, int *len)
{
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
if(!ctx) {
if(ret)
*ret = 600;
if(len)
*len = 0;
return NULL;
}
return http_async_req_stop(ctx, ret, len);
}
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len)
{
void *ctx = http_async_req_start(NULL, uri, data, dlen, 0);
if(!ctx) {
if(ret)
*ret = 600;
if(len)
*len = 0;
return NULL;
}
return http_async_req_stop(ctx, ret, len);
}
char *http_ret_text(int ret)
{
switch(ret) {
case 100: return "Continue";
case 101: return "Switching Protocols";
case 102: return "Processing";
case 200: return "OK";
case 201: return "Created";
case 202: return "Accepted";
case 203: return "Non-Authoritative Information";
case 204: return "No Content";
case 205: return "Reset Content";
case 206: return "Partial Content";
case 207: return "Multi-Status";
case 300: return "Multiple Choices";
case 301: return "Moved Permanently";
case 302: return "Found";
case 303: return "See Other";
case 304: return "Not Modified";
case 305: return "Use Proxy";
case 306: return "Switch Proxy";
case 307: return "Temporary Redirect";
case 400: return "Bad Request";
case 401: return "Unauthorized";
case 402: return "Payment Required";
case 403: return "Forbidden";
case 404: return "Not Found";
case 405: return "Method Not Allowed";
case 406: return "Not Acceptable";
case 407: return "Proxy Authentication Required";
case 408: return "Request Timeout";
case 409: return "Conflict";
case 410: return "Gone";
case 411: return "Length Required";
case 412: return "Precondition Failed";
case 413: return "Request Entity Too Large";
case 414: return "Request URI Too Long";
case 415: return "Unsupported Media Type";
case 416: return "Requested Range Not Satisfiable";
case 417: return "Expectation Failed";
case 422: return "Unprocessable Entity";
case 423: return "Locked";
case 424: return "Failed Dependency";
case 425: return "Unordered Collection";
case 426: return "Upgrade Required";
case 500: return "Internal Server Error";
case 501: return "Not Implemented";
case 502: return "Bad Gateway";
case 503: return "Service Unavailable";
case 504: return "Gateway Timeout";
case 505: return "HTTP Version Not Supported";
case 506: return "Variant Also Negotiates";
case 507: return "Insufficient Storage";
case 509: return "Bandwidth Limit Exceeded";
case 510: return "Not Extended";
case 600: return "Internal Client Error";
case 601: return "Unsupported Protocol";
case 602: return "Server Not Found";
case 603: return "Malformed Response";
case 604: return "Network Not Available";
case 605: return "Request Timed Out";
default: return "Unknown Status Code";
}
}
static char hex[] = "0123456789abcdef";
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, int *ret, int *len)
{
void *ctx;
char *data = NULL, *tmp, *p;
int dlen = 0, i, j, m;
unsigned char hash[16];
unsigned char boundary[32], ch;
int blen = 0;
unsigned int map[62];
struct md5_context md5;
int own_plen = 0;
if(names) {
if(!plens) {
own_plen = 1;
for(i=0;names[i];i++) ;
plens = calloc(i, sizeof(int));
for(i=0;names[i];i++)
plens[i] = strlen(parts[i]);
}
retry:
if(blen >= 31)
goto fail;
memset(map, 0, 62*sizeof(int));
for(i=0;names[i];i++) {
for(j=0;j<plens[i]-blen;j++)
if(!blen || !memcmp(parts[i]+j, boundary, blen)) {
ch = parts[i][j+blen];
if(ch>='0' && ch<='9')
map[ch-'0']++;
else if(ch>='A' && ch<='Z')
map[ch-'A'+10]++;
else if(ch>='a' && ch<='z')
map[ch-'a'+36]++;
}
}
m = ~0;
j = 61;
for(i=0;i<62;i++)
if(map[i]<m) {
m = map[i];
j = i;
}
if(j<10)
boundary[blen] = '0'+j;
else if(j<36)
boundary[blen] = 'A'+(j-10);
else
boundary[blen] = 'a'+(j-36);
blen++;
if(map[j])
goto retry;
boundary[blen] = 0;
for(i=0;names[i];i++)
dlen += blen+strlen(names[i])+plens[i]+128;
dlen += blen+8;
data = malloc(dlen);
dlen = 0;
for(i=0;names[i];i++) {
dlen += sprintf(data+dlen, "--%s\r\n", boundary);
dlen += sprintf(data+dlen, "Content-transfer-encoding: binary\r\n");
if(strchr(names[i], ':')) {
tmp = mystrdup(names[i]);
p = strchr(tmp, ':');
*p = 0;
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
free(tmp);
p = strchr(names[i], ':');
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", p+1);
} else
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
memcpy(data+dlen, parts[i], plens[i]);
dlen += plens[i];
dlen += sprintf(data+dlen, "\r\n");
}
dlen += sprintf(data+dlen, "--%s--\r\n", boundary);
}
ctx = http_async_req_start(NULL, uri, data, dlen, 0);
if(!ctx)
goto fail;
if(user) {
http_async_add_header(ctx, "X-Auth-User", user);
if(pass) {
md5_init(&md5);
md5_update(&md5, (unsigned char *)user, strlen(user));
md5_update(&md5, (unsigned char *)"-", 1);
m = 0;
if(names) {
for(i=0;names[i];i++) {
md5_update(&md5, (unsigned char *)parts[i], plens[i]);
md5_update(&md5, (unsigned char *)"-", 1);
p = strchr(names[i], ':');
if(p)
m += (p - names[i]) + 1;
else
m += strlen(names[i])+1;
}
tmp = malloc(m);
m = 0;
for(i=0;names[i];i++) {
p = strchr(names[i], ':');
if(m) {
tmp[m] = ' ';
m ++;
}
if(p) {
memcpy(tmp+m, names[i], p-names[i]);
m += p - names[i];
} else {
strcpy(tmp+m, names[i]);
m += strlen(names[i]);
}
}
tmp[m] = 0;
http_async_add_header(ctx, "X-Auth-Objects", tmp);
free(tmp);
}
md5_update(&md5, (unsigned char *)pass, strlen(pass));
md5_final(hash, &md5);
tmp = malloc(33);
for(i=0;i<16;i++) {
tmp[i*2] = hex[hash[i]>>4];
tmp[i*2+1] = hex[hash[i]&15];
}
tmp[32] = 0;
http_async_add_header(ctx, "X-Auth-Hash", tmp);
free(tmp);
}
}
if(data) {
tmp = malloc(32+strlen((char *)boundary));
sprintf(tmp, "multipart/form-data, boundary=%s", boundary);
http_async_add_header(ctx, "Content-type", tmp);
free(tmp);
free(data);
}
if(own_plen)
free(plens);
return http_async_req_stop(ctx, ret, len);
fail:
if(data)
free(data);
if(own_plen)
free(plens);
if(ret)
*ret = 600;
if(len)
*len = 0;
return NULL;
}

21
http.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef HTTP_H
#define HTTP_H
void http_init(char *proxy);
void http_done(void);
char *http_simple_get(char *uri, int *ret, int *len);
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len);
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep);
void http_async_add_header(void *ctx, char *name, char *data);
int http_async_req_status(void *ctx);
void http_async_get_length(void *ctx, int *total, int *done);
char *http_async_req_stop(void *ctx, int *ret, int *len);
void http_async_req_close(void *ctx);
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, int *ret, int *len);
char *http_ret_text(int ret);
#endif

309
icon.h Normal file
View File

@ -0,0 +1,309 @@
static unsigned char app_icon[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
0x01,0x00,0x0b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x16,0x02,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0x00,0x00,0x1b,0x02,0x00,0x0e,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x19,0x01,0x00,
0x62,0x09,0x02,0x4b,0x07,0x01,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x00,0x00,0x30,0x01,0x00,0x80,0x04,0x00,0x6c,
0x04,0x01,0x23,0x01,0x00,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x4d,
0x01,0x00,0xbc,0x08,0x01,0xdf,0x13,0x04,0x74,0x08,
0x01,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x00,0x15,0x00,0x00,0x78,0x04,0x00,0xf7,0x12,
0x02,0xfe,0x15,0x02,0xa2,0x06,0x00,0x28,0x00,0x00,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x24,0x00,
0x00,0xa7,0x08,0x01,0xff,0x28,0x07,0xff,0x26,0x06,
0xea,0x14,0x04,0x65,0x03,0x00,0x0e,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x00,0x00,0x32,0x00,0x00,0xc0,0x0e,0x01,
0xff,0x3e,0x0a,0xff,0x42,0x0a,0xff,0x2e,0x07,0x97,
0x09,0x01,0x1c,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,
0x3f,0x00,0x00,0xca,0x14,0x01,0xff,0x46,0x05,0xff,
0x57,0x07,0xfe,0x33,0x02,0x9f,0x06,0x00,0x28,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x09,0x00,0x00,0x46,0x01,0x00,0xd2,
0x1f,0x02,0xff,0x5e,0x08,0xff,0x75,0x0c,0xff,0x4e,
0x08,0xae,0x0f,0x00,0x32,0x00,0x00,0x04,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,
0x00,0x00,0x4a,0x02,0x00,0xd5,0x26,0x01,0xff,0x72,
0x0a,0xff,0x9e,0x12,0xff,0x7c,0x0d,0xc1,0x26,0x01,
0x39,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x4b,0x04,
0x00,0xd7,0x37,0x02,0xff,0x90,0x0a,0xff,0xc5,0x15,
0xff,0xad,0x14,0xca,0x3f,0x03,0x42,0x05,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0a,0x00,0x00,0x4b,0x08,0x00,0xd7,0x48,0x02,
0xff,0xb5,0x10,0xff,0xf4,0x20,0xff,0xd2,0x19,0xcd,
0x56,0x03,0x48,0x0c,0x00,0x0b,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
0x48,0x0c,0x00,0xd4,0x58,0x04,0xff,0xdc,0x1b,0xff,
0xff,0x2c,0xff,0xe7,0x1c,0xcb,0x69,0x03,0x4c,0x15,
0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x00,0x00,0x3f,0x0e,0x00,0xbc,
0x56,0x01,0xfe,0xd6,0x16,0xff,0xff,0x36,0xff,0xea,
0x20,0xc9,0x72,0x02,0x4d,0x1c,0x00,0x0e,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,
0x00,0x00,0x33,0x0d,0x00,0x96,0x51,0x02,0xfa,0xd5,
0x1f,0xff,0xff,0x4f,0xff,0xf1,0x32,0xca,0x7c,0x05,
0x50,0x21,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x28,0x0d,
0x00,0x84,0x50,0x04,0xf6,0xdd,0x32,0xff,0xff,0x75,
0xff,0xf7,0x51,0xd0,0x89,0x0f,0x53,0x28,0x00,0x11,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x02,0x00,0x00,0x22,0x0c,0x00,0x79,0x4e,0x07,
0xf3,0xd7,0x3c,0xff,0xff,0x87,0xff,0xfc,0x6d,0xd5,
0x9b,0x20,0x5a,0x32,0x02,0x14,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,
0x1d,0x0d,0x00,0x72,0x53,0x0d,0xf2,0xde,0x55,0xff,
0xff,0xb1,0xff,0xff,0x9e,0xe5,0xbc,0x41,0x72,0x48,
0x0b,0x1f,0x0b,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x18,0x0e,0x00,0x69,
0x56,0x14,0xef,0xe4,0x74,0xff,0xff,0xeb,0xff,0xff,
0xe8,0xfd,0xe9,0x83,0xad,0x74,0x25,0x37,0x19,0x02,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x11,0x0b,0x00,0x60,0x51,0x17,0xec,0xe5,
0x84,0xff,0xff,0xfa,0xff,0xff,0xfe,0xff,0xff,0xca,
0xe6,0xab,0x46,0x46,0x21,0x04,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x06,
0x00,0x4c,0x3c,0x0f,0xdc,0xca,0x63,0xff,0xff,0xd6,
0xff,0xff,0xdc,0xff,0xfb,0x9c,0xb7,0x79,0x2a,0x30,
0x18,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x04,0x02,0x00,0x2c,0x1c,0x03,
0x8e,0x66,0x22,0xfb,0xf3,0x7f,0xff,0xfb,0x86,0xfb,
0xf0,0x6c,0x5f,0x32,0x0a,0x13,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x0c,0x04,0x00,0x2f,0x19,0x02,0xec,
0xc4,0x44,0xfa,0xd4,0x4b,0xe9,0xb9,0x40,0x1a,0x09,
0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x02,0x00,0xbc,0x97,0x38,0xcb,0xa3,
0x3c,0xbe,0x99,0x3a,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xb2,0x94,0x3b,0xc0,0xa0,0x40,0xb8,0x99,0x3d,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb2,0x94,0x3c,
0xc0,0xa0,0x40,0xb8,0x9a,0x3e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x74,0x61,0x26,0x86,0x70,0x2c,0x79,
0x64,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

225
md5.c Normal file
View File

@ -0,0 +1,225 @@
// based on public-domain code from Colin Plumb (1993)
#include <string.h>
#include "md5.h"
static unsigned getu32(const unsigned char *addr)
{
return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0];
}
static void putu32(unsigned data, unsigned char *addr)
{
addr[0] = (unsigned char)data;
addr[1] = (unsigned char)(data >> 8);
addr[2] = (unsigned char)(data >> 16);
addr[3] = (unsigned char)(data >> 24);
}
void md5_init(struct md5_context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
void md5_update(struct md5_context *ctx, unsigned char const *buf, unsigned len)
{
unsigned t;
// update bit count
t = ctx->bits[0];
if((ctx->bits[0] = (t + ((unsigned)len << 3)) & 0xffffffff) < t)
ctx->bits[1]++; // carry
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f;
// use leading data to top up the buffer
if(t) {
unsigned char *p = ctx->in + t;
t = 64-t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
md5_transform(ctx->buf, ctx->in);
buf += t;
len -= t;
}
// following 64-byte chunks
while(len >= 64) {
memcpy(ctx->in, buf, 64);
md5_transform(ctx->buf, ctx->in);
buf += 64;
len -= 64;
}
// save rest of bytes for later
memcpy(ctx->in, buf, len);
}
void md5_final(unsigned char digest[16], struct md5_context *ctx)
{
unsigned count;
unsigned char *p;
// #bytes mod64
count = (ctx->bits[0] >> 3) & 0x3F;
// first char of padding = 0x80
p = ctx->in + count;
*p++ = 0x80;
// calculate # of bytes to pad
count = 64 - 1 - count;
// Pad out to 56 mod 64
if(count < 8) {
// we need to finish a whole block before padding
memset(p, 0, count);
md5_transform(ctx->buf, ctx->in);
memset(ctx->in, 0, 56);
} else {
// just pad to 56 bytes
memset(p, 0, count-8);
}
// append length & final transform
putu32(ctx->bits[0], ctx->in + 56);
putu32(ctx->bits[1], ctx->in + 60);
md5_transform(ctx->buf, ctx->in);
putu32(ctx->buf[0], digest);
putu32(ctx->buf[1], digest + 4);
putu32(ctx->buf[2], digest + 8);
putu32(ctx->buf[3], digest + 12);
memset(ctx, 0, sizeof(ctx));
}
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
void md5_transform(unsigned buf[4], const unsigned char inraw[64])
{
unsigned a, b, c, d;
unsigned in[16];
int i;
for (i = 0; i < 16; ++i)
in[i] = getu32 (inraw + 4 * i);
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
static char hex[] = "0123456789abcdef";
void md5_ascii(char *result, unsigned char const *buf, unsigned len)
{
struct md5_context md5;
unsigned char hash[16];
int i;
if(len==0)
len = strlen((char *)buf);
md5_init(&md5);
md5_update(&md5, buf, len);
md5_final(hash, &md5);
for(i=0;i<16;i++) {
result[i*2] = hex[hash[i]>>4];
result[i*2+1] = hex[hash[i]&15];
}
result[32] = 0;
}

17
md5.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef MD5_H
#define MD5_H
struct md5_context {
unsigned buf[4];
unsigned bits[2];
unsigned char in[64];
};
void md5_init(struct md5_context *context);
void md5_update(struct md5_context *context, unsigned char const *buf, unsigned len);
void md5_final(unsigned char digest[16], struct md5_context *context);
void md5_transform(unsigned buf[4], const unsigned char in[64]);
void md5_ascii(char *result, unsigned char const *buf, unsigned len);
#endif

View File

@ -1,484 +0,0 @@
project(
'the-powder-toy',
[ 'c', 'cpp' ],
version: 'the.cake.is.a.lie',
default_options: [
'c_std=c99',
'cpp_std=c++17',
'cpp_rtti=false',
'build.c_std=c99', # used by to_array
'build.cpp_std=c++17', # used by to_array
'build.cpp_rtti=false', # used by to_array
],
meson_version: '>=0.64.0',
)
if get_option('prepare')
# we're being run by prepare.py in a ghactions workflow only to determine the values of options; exit early
subdir_done()
endif
fs = import('fs')
to_array = generator(
executable('toarray', sources: 'resources/ToArray.cpp', native: true),
output: [ '@PLAINNAME@.cpp', '@PLAINNAME@.h' ],
arguments: [ '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', '@EXTRA_ARGS@' ]
)
render_icons_with_inkscape = get_option('render_icons_with_inkscape')
inkscape = find_program('inkscape', required: render_icons_with_inkscape)
c_compiler = meson.get_compiler('c')
is_x86 = host_machine.cpu_family() in [ 'x86', 'x86_64' ]
is_64bit = host_machine.cpu_family() in [ 'aarch64', 'x86_64' ]
is_msvc = c_compiler.get_id() in [ 'msvc' ]
host_arch = host_machine.cpu_family()
host_platform = host_machine.system()
# educated guesses follow, PRs welcome
if c_compiler.get_id() in [ 'msvc' ]
if host_platform != 'windows'
error('this seems fishy')
endif
host_libc = 'msvc'
elif c_compiler.get_id() in [ 'gcc' ] and host_platform == 'windows'
host_libc = 'mingw'
elif host_platform in [ 'darwin' ]
host_libc = 'macos'
elif host_platform in [ 'emscripten' ]
host_platform = 'emscripten'
host_libc = 'emscripten'
elif host_platform in [ 'android' ]
host_platform = 'android'
host_libc = 'bionic'
else
if host_platform != 'linux'
# TODO: maybe use 'default' in place of 'linux', or use something other than host_platform where details such as desktop integration are concerned
warning('host platform is not linux but we will pretend that it is')
host_platform = 'linux'
endif
host_libc = 'gnu'
endif
static_variant = get_option('static')
if static_variant != 'prebuilt' and host_platform == 'android'
warning('only prebuilt libs are supported for android')
static_variant = 'prebuilt'
endif
if static_variant == 'system' and host_platform == 'windows' and host_libc == 'msvc'
warning('no way to find system libs for msvc on windows')
static_variant = 'prebuilt'
endif
is_static = static_variant != 'none'
is_debug = get_option('optimization') in [ '0', 'g' ]
app_exe = get_option('app_exe')
tpt_libs_static = 'none'
if static_variant == 'prebuilt'
tpt_libs_static = 'static'
endif
if static_variant == 'none' and host_platform == 'windows' and host_libc == 'msvc'
tpt_libs_static = 'dynamic'
endif
tpt_libs_debug = is_debug ? 'debug' : 'release'
tpt_libs_variant = '@0@-@1@-@2@-@3@'.format(host_arch, host_platform, host_libc, tpt_libs_static)
tpt_libs_vtag = get_option('tpt_libs_vtag')
if tpt_libs_vtag == ''
tpt_libs_vtag = 'v20240112165024'
endif
if tpt_libs_static != 'none'
if tpt_libs_variant not in [
'x86_64-linux-gnu-static',
'x86_64-windows-mingw-static',
'x86_64-windows-msvc-static',
'x86_64-windows-msvc-dynamic',
'x86-windows-msvc-static',
'x86-windows-msvc-dynamic',
'x86_64-darwin-macos-static',
'aarch64-darwin-macos-static',
'x86-android-bionic-static',
'x86_64-android-bionic-static',
'arm-android-bionic-static',
'aarch64-android-bionic-static',
'wasm32-emscripten-emscripten-static',
]
error('no prebuilt @0@ libraries are currently provided'.format(tpt_libs_variant))
endif
tpt_libs = subproject('tpt-libs-prebuilt-@0@-@1@-@2@'.format(tpt_libs_variant, tpt_libs_debug, tpt_libs_vtag))
else
if get_option('workaround_elusive_bzip2')
bzip2_lib_name = get_option('workaround_elusive_bzip2_lib_name')
bzip2_include_name = get_option('workaround_elusive_bzip2_include_name')
bzip2_lib_dir = get_option('workaround_elusive_bzip2_lib_dir')
bzip2_include_dir = include_directories(get_option('workaround_elusive_bzip2_include_dir'))
bzip2_static = get_option('workaround_elusive_bzip2_static')
meson.override_dependency('bzip2', declare_dependency(
dependencies: c_compiler.find_library(
bzip2_lib_name,
has_headers: bzip2_include_name,
dirs: bzip2_lib_dir,
header_include_directories: bzip2_include_dir,
static: bzip2_static,
),
include_directories: bzip2_include_dir,
))
endif
endif
x86_sse_level_str = get_option('x86_sse')
if x86_sse_level_str == 'auto'
x86_sse_level = 20
if not is_x86 or not is_64bit or host_platform == 'darwin' or (is_64bit and is_msvc)
x86_sse_level = 0
endif
elif x86_sse_level_str == 'sse3'
x86_sse_level = 30
elif x86_sse_level_str == 'sse2'
x86_sse_level = 20
elif x86_sse_level_str == 'sse'
x86_sse_level = 10
elif x86_sse_level_str == 'none'
x86_sse_level = 0
endif
lua_variant = get_option('lua')
if lua_variant == 'auto'
if host_platform == 'emscripten'
lua_variant = 'lua5.2'
else
lua_variant = 'luajit'
endif
endif
if lua_variant == 'luajit' and host_platform == 'emscripten'
error('luajit does not work with emscripten')
endif
if lua_variant == 'none'
lua_dep = []
elif lua_variant == 'lua5.1' or lua_variant == 'lua5.2'
lua_dep = dependency(lua_variant + '-c++', static: is_static, required: false)
if not lua_dep.found()
if not get_option('workaround_noncpp_lua')
error('your system @0@ is not compatible with C++, configure with -Dworkaround_noncpp_lua=true to disable this error'.format(lua_variant))
endif
lua_dep = dependency(lua_variant, static: is_static)
endif
elif lua_variant == 'luajit'
lua_dep = dependency('luajit', static: is_static)
endif
enable_http = get_option('http')
if host_platform == 'android'
android_ndk_toolchain_prefix = meson.get_external_property('android_ndk_toolchain_prefix')
android_platform = meson.get_external_property('android_platform')
tpt_libs_android_toolchain_prefix = tpt_libs.get_variable('android_toolchain_prefix')
tpt_libs_android_system_version = tpt_libs.get_variable('android_system_version')
tpt_libs_android_platform = tpt_libs.get_variable('android_platform')
if '@0@@1@-'.format(tpt_libs_android_toolchain_prefix, tpt_libs_android_system_version) != android_ndk_toolchain_prefix
error('tpt-libs android toolchain mismatch')
endif
if tpt_libs_android_platform != android_platform
error('tpt-libs android platform mismatch')
endif
endif
curl_dep = []
if enable_http and host_platform != 'emscripten'
curl_dep = dependency('libcurl', static: is_static)
endif
project_link_args = []
project_c_args = []
project_cpp_args = []
fftw_dep = dependency('fftw3f', static: is_static)
threads_dep = dependency('threads')
if host_platform == 'emscripten'
zlib_dep = []
png_dep = []
sdl2_dep = []
bzip2_dep = []
project_link_args += [
'--no-heap-copy',
'-s', 'WASM=1',
'-s', 'ALLOW_MEMORY_GROWTH=1',
'-s', 'FORCE_FILESYSTEM=1',
'-s', 'EXIT_RUNTIME=0',
'-s', 'EXPORTED_RUNTIME_METHODS=ccall,cwrap',
'-s', 'FS_DEBUG',
'-s', 'MODULARIZE',
'-s', 'EXPORT_NAME=create_' + app_exe,
'-Wl,-u,_emscripten_run_callback_on_thread',
'-lidbfs.js',
]
emcc_args = [
'-s', 'USE_SDL=2',
'-s', 'USE_BZIP2=1',
'-s', 'USE_LIBPNG',
'-s', 'USE_ZLIB=1',
'-s', 'DISABLE_EXCEPTION_CATCHING=0',
]
if is_debug
project_link_args += [ '--source-map-base=./' ]
emcc_args += [ '-gsource-map' ]
endif
project_link_args += emcc_args
project_c_args += emcc_args
project_cpp_args += emcc_args
else
zlib_dep = dependency('zlib', static: is_static)
png_dep = dependency('libpng16', static: is_static)
sdl2_dep = dependency('sdl2', static: is_static)
bzip2_dep = dependency('bzip2', static: is_static)
endif
json_dep = dependency('jsoncpp', static: is_static)
if is_msvc
if x86_sse_level >= 30
warning('SSE3 configured to be enabled but unavailable in msvc')
x86_sse_level = 20
endif
if is_64bit and x86_sse_level > 0
warning('SSE explicitly configured but unavailable in msvc targeting 64-bit machines')
x86_sse_level = 0
endif
args_msvc = [
'/GS',
'/D_SCL_SECURE_NO_WARNINGS',
'/DUNICODE',
'/D_UNICODE',
]
if x86_sse_level >= 20
args_msvc += [ '/arch:SSE2' ]
elif x86_sse_level >= 10
args_msvc += [ '/arch:SSE' ]
endif
if not is_debug
args_msvc += [
'/Oy-',
'/fp:fast',
'/GL',
]
project_link_args += [
'/OPT:REF',
'/OPT:ICF',
'/LTCG',
]
endif
project_c_args += args_msvc
project_cpp_args += args_msvc
else
args_ccomp = []
if host_platform == 'darwin' and x86_sse_level > 0
message('SSE level explicitly configured but unavailable on macosx')
x86_sse_level = 0
endif
if x86_sse_level >= 30
args_ccomp += [ '-msse3' ]
elif x86_sse_level >= 20
args_ccomp += [ '-msse2' ]
elif x86_sse_level >= 10
args_ccomp += [ '-msse' ]
endif
if host_platform == 'windows'
args_ccomp += [
'-DUNICODE',
'-D_UNICODE',
]
endif
if not is_debug
args_ccomp += [
'-ftree-vectorize',
'-funsafe-math-optimizations',
'-ffast-math',
'-fomit-frame-pointer',
]
endif
if host_platform == 'android'
if not is_64bit
args_ccomp += [ '-U_FILE_OFFSET_BITS' ]
endif
# android doesn't ship libc++_shared.so, so we might as well link it statically;
# the alternative would be to grab libc++_shared.so from the NDK and ship it with
# the app alongside libpowder.so, and possibly add it to SDL's list of libraries to load
project_link_args += [ '-static-libstdc++' ]
endif
project_c_args += args_ccomp + [
'-Wno-implicit-fallthrough',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wno-unused-parameter',
]
project_cpp_args += args_ccomp + [
'-Wno-invalid-offsetof',
'-Wno-unused-result',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
]
endif
if host_platform == 'windows'
args_ccomp_win = [ '-D_WIN32_WINNT=0x0501', '-DNOMINMAX' ]
windows_mod = import('windows')
if is_static
args_ccomp_win += [ '-DCURL_STATICLIB' ]
if host_arch == 'x86_64'
args_ccomp_win += [ '-DZLIB_WINAPI' ]
endif
endif
if tpt_libs_static == 'dynamic'
foreach input_output_condition : tpt_libs.get_variable('config_dlls')
dll_input = input_output_condition[0]
dll_output = input_output_condition[1]
dll_condition = input_output_condition[2]
do_copy = false
if dll_condition == 'all'
do_copy = true
elif dll_condition == 'lua=' + lua_variant
do_copy = true
endif
if do_copy
fs.copyfile(dll_input, dll_output)
endif
endforeach
endif
project_c_args += args_ccomp_win
project_cpp_args += args_ccomp_win
endif
project_inc = include_directories([ 'src', 'resources' ])
if host_platform == 'windows'
ident_platform = is_64bit ? 'WIN64' : 'WIN32'
elif host_platform == 'linux'
ident_platform = is_64bit ? 'LIN64' : 'LIN32'
elif host_platform == 'darwin'
ident_platform = host_arch == 'aarch64' ? 'MACOSARM' : 'MACOSX'
else
ident_platform = 'UNKNOWN'
endif
project_deps = []
data_files = []
powder_deps = []
project_export_dynamic = false
subdir('src')
subdir('resources')
powder_files += data_files
render_files += data_files
font_files += data_files
if host_platform == 'emscripten'
project_link_args += [
'-o', app_exe + '.js', # so we get a .wasm, and a .js
]
endif
if get_option('export_lua_symbols')
if is_static and lua_variant != 'none' and not project_export_dynamic
if host_platform == 'windows'
error('Lua symbols are currently impossible to export correctly on Windows')
elif c_compiler.has_link_argument('-Wl,--export-dynamic-symbol')
project_link_args += [
'-Wl,--export-dynamic-symbol=lua_*',
'-Wl,--export-dynamic-symbol=luaL_*',
'-Wl,--export-dynamic-symbol=luaopen_*',
]
else
warning('your linker does not support -Wl,--export-dynamic-symbol so Meson will be instructed to export all symbols in order to enable loading Lua shared modules, which may blow up the size of the resulting binary')
project_export_dynamic = true
endif
endif
endif
if get_option('build_powder')
powder_deps += project_deps + [
threads_dep,
zlib_dep,
png_dep,
sdl2_dep,
lua_dep,
curl_dep,
fftw_dep,
bzip2_dep,
json_dep,
]
if host_platform == 'android'
powder_sha = shared_library(
app_exe,
sources: powder_files,
include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args,
link_args: project_link_args,
dependencies: powder_deps,
)
subdir('android')
else
executable(
app_exe,
sources: powder_files,
include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args,
win_subsystem: is_debug ? 'console' : 'windows',
link_args: project_link_args,
dependencies: powder_deps,
export_dynamic: project_export_dynamic,
install: true,
)
endif
endif
if get_option('build_render')
if host_platform == 'emscripten'
error('render does not target emscripten')
endif
render_deps = project_deps + [
threads_dep,
zlib_dep,
bzip2_dep,
json_dep,
png_dep,
]
render_link_args = project_link_args
if host_platform == 'linux' and is_static
render_link_args += [ '-static' ]
endif
executable(
'render',
sources: render_files,
include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args,
link_args: render_link_args,
dependencies: render_deps,
export_dynamic: project_export_dynamic,
)
endif
if get_option('build_font')
if host_platform == 'emscripten'
error('font does not target emscripten')
endif
font_deps = project_deps + [
threads_dep,
zlib_dep,
png_dep,
sdl2_dep,
bzip2_dep,
json_dep,
]
executable(
'font',
sources: font_files,
include_directories: project_inc,
c_args: project_c_args,
cpp_args: project_cpp_args,
link_args: project_link_args,
dependencies: font_deps,
export_dynamic: project_export_dynamic,
)
endif

View File

@ -1,313 +0,0 @@
option(
'static',
type: 'combo',
choices: [ 'none', 'system', 'prebuilt' ],
value: 'none',
description: 'Build statically using libraries present on the system (\'system\') or using prebuilt libraries official builds use (\'prebuilt\')'
)
option(
'beta',
type: 'boolean',
value: false,
description: 'Beta build'
)
option(
'ignore_updates',
type: 'boolean',
value: true,
description: 'Don\'t show notifications about available updates'
)
option(
'can_install',
type: 'combo',
choices: [ 'no', 'yes', 'yes_check', 'auto' ],
value: 'auto',
description: 'Disable (\'no\') or enable (\'yes\') setting up file and URL associations, or even offer to do it at startup (\'yes_check\')'
)
option(
'http',
type: 'boolean',
value: true,
description: 'Enable HTTP via libcurl'
)
option(
'snapshot',
type: 'boolean',
value: false,
description: 'Snapshot build'
)
option(
'display_version_major',
type: 'integer',
min: 0,
value: 98,
description: 'Major component of the display version, should more or less map to the MINOR version in semantic versioning'
)
option(
'display_version_minor',
type: 'integer',
min: 0,
value: 2,
description: 'Minor component of the display version, should more or less map to the PATCH version in semantic versioning'
)
option(
'build_num',
type: 'integer',
min: 0,
value: 365,
description: 'Build number, should be strictly monotonously increasing across public releases'
)
option(
'upstream_version_major',
type: 'integer',
min: 0,
value: 98,
description: 'Major component of the upstream display version, mod owners should not change this but merge upstream changes to it'
)
option(
'upstream_version_minor',
type: 'integer',
min: 0,
value: 2,
description: 'Minor component of the upstream display version, mod owners should not change this but merge upstream changes to it'
)
option(
'upstream_build_num',
type: 'integer',
min: 0,
value: 365,
description: 'Upstream build number, mod owners should not change this but merge upstream changes to it'
)
option(
'mod_id',
type: 'integer',
min: 0,
value: 0,
description: 'Mod ID, used on the https://starcatcher.us/TPT build server, the build server will compile for all platforms for you and send updates in-game, see jacob1 to get a mod ID'
)
option(
'lua',
type: 'combo',
choices: [ 'none', 'lua5.1', 'lua5.2', 'luajit', 'auto' ],
value: 'auto',
description: 'Lua library to use'
)
option(
'x86_sse',
type: 'combo',
choices: [ 'none', 'sse', 'sse2', 'sse3', 'auto' ],
value: 'auto',
description: 'Enable SSE (available only on x86)'
)
option(
'build_powder',
type: 'boolean',
value: true,
description: 'Build the game'
)
option(
'build_render',
type: 'boolean',
value: false,
description: 'Build the thumbnail renderer'
)
option(
'build_font',
type: 'boolean',
value: false,
description: 'Build the font editor'
)
option(
'server',
type: 'string',
value: 'powdertoy.co.uk',
description: 'Simulation server'
)
option(
'static_server',
type: 'string',
value: 'static.powdertoy.co.uk',
description: 'Static simulation server'
)
option(
'update_server',
type: 'string',
value: '',
description: 'Update server, only used by snapshots and mods, see \'snapshot\' and \'mod_id\''
)
option(
'workaround_noncpp_lua',
type: 'boolean',
value: false,
description: 'Allow linking against a non-C++ system Lua'
)
option(
'workaround_elusive_bzip2',
type: 'boolean',
value: true,
description: 'acquire bzip2 dependency with find_library'
)
option(
'workaround_elusive_bzip2_lib_name',
type: 'string',
value: 'bz2',
description: 'bzip2 library name, see \'workaround_elusive_bzip2\''
)
option(
'workaround_elusive_bzip2_lib_dir',
type: 'string',
value: '/usr/lib/x86_64-linux-gnu',
description: 'bzip2 library directory, see \'workaround_elusive_bzip2\''
)
option(
'workaround_elusive_bzip2_include_name',
type: 'string',
value: 'bzlib.h',
description: 'bzip2 header name, see \'workaround_elusive_bzip2\''
)
option(
'workaround_elusive_bzip2_include_dir',
type: 'string',
value: '/usr/include',
description: 'bzip2 header directory, see \'workaround_elusive_bzip2\''
)
option(
'workaround_elusive_bzip2_static',
type: 'boolean',
value: false,
description: 'bzip2 static setting, see \'workaround_elusive_bzip2\''
)
option(
'tpt_libs_vtag',
type: 'string',
value: '',
description: 'tpt-libs vtag override, only used for tpt-libs development'
)
option(
'android_keystore',
type: 'string',
value: '',
description: 'Path to Java keystore for signing an APK, only used for Android development'
)
option(
'android_keyalias',
type: 'string',
value: 'androidkey',
description: 'Signing key alias for signing an APK, only used for Android development'
)
option(
'app_name',
type: 'string',
value: 'The Powder Toy',
description: 'App name, used for desktop integration and the window title, change if you work on a mod'
)
option(
'app_comment',
type: 'string',
value: 'Physics sandbox game',
description: 'App comment, used for desktop integration, change if you work on a mod'
)
option(
'app_exe',
type: 'string',
value: 'powder',
description: 'App executable name, used for desktop integration, change if you work on a mod'
)
option(
'app_id',
type: 'string',
value: 'uk.co.powdertoy.tpt',
description: 'App ID, a D-Bus well-known name, used for desktop integration, change if you work on a mod'
)
option(
'app_data',
type: 'string',
value: 'The Powder Toy',
description: 'App data directory name, do not change even if you work on a mod, only if you know what you are doing'
)
option(
'app_vendor',
type: 'string',
value: 'powdertoy',
description: 'App vendor prefix, used for desktop integration, do not change even if you work on a mod, only if you know what you are doing'
)
option(
'enforce_https',
type: 'boolean',
value: true,
description: 'Enforce encrypted HTTP traffic, may be disabled for debugging'
)
option(
'secure_ciphers_only',
type: 'boolean',
value: false,
description: 'Use only secure ciphers for encrypted HTTP traffic, please review cipher list before enabling'
)
option(
'prepare',
type: 'boolean',
value: false,
description: 'Used by ghactions workflows, not useful otherwise'
)
option(
'render_icons_with_inkscape',
type: 'feature',
value: 'disabled',
description: 'Render icons with Inkscape (inkscape binary needs to be in PATH)'
)
option(
'resolve_vcs_tag',
type: 'combo',
choices: [ 'no', 'static_release_only', 'yes' ],
value: 'static_release_only',
description: 'Enable VCS tag resolution, introduces an always-stale custom target'
)
option(
'manifest_copyright',
type: 'string',
value: 'Copyright © 2008-2011 Stanislaw K Skowrenek, Copyright © 2011-2023 Simon Robertshaw, Copyright © 2016-2023 jacob1',
description: 'Copyright string, don\'t take too seriously, subject to change'
)
option(
'manifest_macos_min_ver',
type: 'string',
value: '',
description: 'MacOS minimum allowed platform version string, used by ghactions workflows, not useful otherwise'
)
option(
'manifest_date',
type: 'string',
value: '',
description: 'Build date string, used by ghactions workflows, not useful otherwise'
)
option(
'platform_clipboard',
type: 'boolean',
value: true,
description: 'Enable platform clipboard, allows copying simulation data between different windows'
)
option(
'use_bluescreen',
type: 'combo',
choices: [ 'no', 'yes', 'auto' ],
value: 'auto',
description: 'Show blue error screen upon unhandled signals and exceptions'
)
option(
'windows_icons',
type: 'boolean',
value: true,
description: 'Add icon resources to the executable on Windows'
)
option(
'windows_utf8cp',
type: 'boolean',
value: true,
description: 'Ask Windows nicely for UTF-8 as the codepage'
)
option(
'export_lua_symbols',
type: 'boolean',
value: false,
description: 'Export Lua symbols to enable loading of Lua shared modules'
)

2
powder-res.rc Normal file
View File

@ -0,0 +1,2 @@
#define IDI_ICON1 101
IDI_ICON1 ICON DISCARDABLE "powder.ico"

5907
powder.c Normal file

File diff suppressed because it is too large Load Diff

BIN
powder.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>ptsave</string>
</array>
<key>CFBundleURLName</key>
<string>Powder Toy Save URL</string>
</dict>
</array>
<key>CFBundleName</key>
<string>@APPNAME@</string>
<key>CFBundleIconFile</key>
<string>icon_exe.icns</string>
<key>NSHumanReadableCopyright</key>
<string>@MANIFEST_COPYRIGHT@</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>stm</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>icon_cps.icns</string>
<key>CFBundleTypeName</key>
<string>Powder Toy Save</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>cps</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>icon_cps.icns</string>
<key>CFBundleTypeName</key>
<string>Powder Toy Stamp</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>@APPEXE@</string>
<key>CFBundleIdentifier</key>
<string>@APPID@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@ (build @BUILD_NUM@)</string>
<key>LSMinimumSystemVersion</key>
<string>@MANIFEST_MACOS_MIN_VER@</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -1,137 +0,0 @@
#include <cstdint>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
static void writeU32LE(uint8_t *dest, uint32_t value)
{
dest[0] = uint8_t( value & 0xFF);
dest[1] = uint8_t((value >> 8) & 0xFF);
dest[2] = uint8_t((value >> 16) & 0xFF);
dest[3] = uint8_t((value >> 24) & 0xFF);
}
static uint32_t readU32BE(const uint8_t *src)
{
return uint32_t(src[3]) |
(uint32_t(src[2]) << 8) |
(uint32_t(src[1]) << 16) |
(uint32_t(src[0]) << 24);
}
int main(int argc, char *argv[])
{
if (argc < 3)
{
std::cerr << "usage: " << argv[0] << " OUTPUT INPUT..." << std::endl;
exit(1);
}
auto images = argc - 2;
if (images > 255)
{
std::cerr << "too many images specified" << std::endl;
exit(1);
}
std::string outputPath = argv[1];
std::ofstream output(outputPath, std::ios::binary);
auto outputFailure = [&outputPath](std::string action) {
std::cerr << "failed to " << action << " " << outputPath << ": " << strerror(errno) << std::endl;
exit(1);
};
if (!output)
{
outputFailure("open");
}
std::vector<char> header(6 + images * 16, 0);
auto writeHeader = [&header, &output, &outputFailure]() {
output.seekp(0, std::ios_base::beg);
output.write(&header[0], header.size());
if (!output)
{
outputFailure("write");
}
};
writeHeader(); // make space for header
auto *headerU8 = reinterpret_cast<uint8_t *>(&header[0]);
headerU8[2] = 1;
headerU8[4] = images;
for (auto image = 0; image < images; ++image)
{
std::string inputPath = argv[2 + image];
std::ifstream input(inputPath, std::ios::binary);
auto inputFailure = [&inputPath](std::string action) {
std::cerr << "failed to " << action << " " << inputPath << ": " << strerror(errno) << std::endl;
exit(1);
};
auto imageFailure = [&inputPath](std::string failure) {
std::cerr << "failed to process " << inputPath << ": " << failure << std::endl;
exit(1);
};
if (!input)
{
inputFailure("open");
}
std::vector<char> buf;
input.seekg(0, std::ios_base::end);
buf.resize(input.tellg());
input.seekg(0, std::ios_base::beg);
input.read(&buf[0], buf.size());
if (!input)
{
inputFailure("read");
}
auto *bufU8 = reinterpret_cast<uint8_t *>(&buf[0]);
if (buf.size() < 0x21 ||
readU32BE(&bufU8[0]) != UINT32_C(0x89504E47) ||
readU32BE(&bufU8[4]) != UINT32_C(0x0D0A1A0A) ||
bufU8[0x18] != 8 ||
bufU8[0x19] != 6)
{
imageFailure("not a 32bpp RGBA PNG");
}
auto writeOffset = output.tellp();
output.write(&buf[0], buf.size());
if (!output)
{
outputFailure("write");
}
auto width = readU32BE(&bufU8[0x10]);
auto height = readU32BE(&bufU8[0x14]);
if (width == 256)
{
width = 0;
}
if (width > 255)
{
imageFailure("width exceeds U8 limit");
}
if (height == 256)
{
height = 0;
}
if (height > 255)
{
imageFailure("height exceeds U8 limit");
}
auto *entryU8 = headerU8 + 6 + image * 16;
entryU8[0] = width;
entryU8[1] = height;
entryU8[4] = 1;
entryU8[6] = 32;
if (buf.size() > UINT32_MAX)
{
imageFailure("data size exceeds U32 limit");
}
writeU32LE(&entryU8[8], uint32_t(buf.size()));
if (writeOffset > UINT32_MAX)
{
std::cerr << "output data size exceeds U32 limit" << std::endl;
exit(1);
}
writeU32LE(&entryU8[12], uint32_t(writeOffset));
}
writeHeader(); // actually write it out
return 0;
}

View File

@ -1,52 +0,0 @@
#include <fstream>
int main(int argc, char *argv[])
{
if (argc != 5)
{
return 1;
}
auto *outputCppPath = argv[1];
auto *outputHPath = argv[2];
auto *inputAnyPath = argv[3];
auto *symbolName = argv[4];
std::ifstream inputAny(inputAnyPath, std::ios::binary);
std::ofstream outputCpp(outputCppPath);
if (!outputCpp)
{
return 2;
}
outputCpp << "#include \"" << outputHPath << "\"\nconst unsigned char " << symbolName << "[] = { ";
auto dataLen = 0U;
while (true)
{
char ch;
inputAny.read(&ch, 1);
if (inputAny.eof())
{
break;
}
if (!inputAny)
{
return 3;
}
outputCpp << (unsigned int)(unsigned char)(ch) << ", ";
dataLen += 1;
}
outputCpp << " }; const unsigned int " << symbolName << "_size = " << dataLen << ";\n";
if (!outputCpp)
{
return 4;
}
std::ofstream outputH(outputHPath);
if (!outputH)
{
return 5;
}
outputH << "#pragma once\nextern const unsigned char " << symbolName << "[]; extern const unsigned int " << symbolName << "_size;\n";
if (!outputH)
{
return 6;
}
return 0;
}

View File

@ -1,34 +0,0 @@
<?xml version="1.0"?>
<component type="desktop">
<id>@APPID@</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0</project_license>
<name>@APPNAME@</name>
<summary>@APPCOMMENT@</summary>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">moderate</content_attribute>
</content_rating>
<launchable type="desktop-id">@APPID@.desktop</launchable>
<description>
<p>
Have you ever wanted to blow something up? Or maybe you always dreamt of operating an atomic power plant? Do you have a will to develop your own CPU? The Powder Toy lets you to do all of these, and even more!
</p>
<p>
The Powder Toy is a free physics sandbox game, which simulates air pressure and velocity, heat, gravity and a countless number of interactions between different substances! The game provides you with various building materials, liquids, gases and electronic components which can be used to construct complex machines, guns, bombs, realistic terrains and almost anything else. You can then mine them and watch cool explosions, add intricate wirings, play with little stickmen or operate your machine. You can browse and play thousands of different saves made by the community or upload your own we welcome your creations!
</p>
<p>
There is a Lua API you can automate your work or even make plugins for the game. The Powder Toy is free and the source code is distributed under the GNU General Public License, so you can modify the game yourself or help with development.
</p>
</description>
<screenshots>
<screenshot>
<image>https://powdertoy.co.uk/Themes/Next/Design/Images/Screen2.png</image>
</screenshot>
</screenshots>
<url type="homepage">https://powdertoy.co.uk/</url>
<url type="bugtracker">https://github.com/The-Powder-Toy/The-Powder-Toy/issues</url>
<url type="help">https://powdertoy.co.uk/Wiki/W/Main_Page.html</url>
<releases>
<release date="@MANIFEST_DATE@" version="@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@.@BUILD_NUM@" />
</releases>
</component>

Binary file not shown.

View File

@ -1,9 +0,0 @@
We keep these icons here to make it possible to build TPT without Inkscape. If
you have Inkscape and want to change the game's icons, edit the SVGs in the
parent directory and configure your build sites with
`-Drender_icons_with_inkscape=true`.
The GitHub Actions workflows currently do not use Inkscape and use these icons
instead, so once you are satisfied with the state of the SVGs, replace these
icons with the ones in your build site in the same subdirectory and make a new
commit.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 255 KiB

View File

@ -1,533 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64"
height="64"
viewBox="0 0 16.933331 16.933331"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="icon_exe.svg"
inkscape:export-filename="icon.png"
inkscape:export-xdpi="192"
inkscape:export-ydpi="192"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#ffffff"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="16.970563"
inkscape:cx="57.422963"
inkscape:cy="24.188945"
inkscape:window-width="1280"
inkscape:window-height="1054"
inkscape:window-x="1297"
inkscape:window-y="26"
inkscape:window-maximized="0"
inkscape:current-layer="layer7" /><defs
id="defs2"><linearGradient
id="linearGradient10317"><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0"
id="stop10311" /><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0.58129495"
id="stop10313" /><stop
style="stop-color:#f5ffff;stop-opacity:0;"
offset="1"
id="stop10315" /></linearGradient><linearGradient
id="linearGradient7451"><stop
style="stop-color:#f5ffff;stop-opacity:0.98309183;"
offset="0"
id="stop7445" /><stop
style="stop-color:#f5ffff;stop-opacity:0.65823293;"
offset="0.44851306"
id="stop7447" /><stop
style="stop-color:#f5ffff;stop-opacity:0;"
offset="1"
id="stop7449" /></linearGradient><linearGradient
id="linearGradient7331"><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0"
id="stop7325" /><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0.37253886"
id="stop7327" /><stop
style="stop-color:#f5ffff;stop-opacity:0;"
offset="1"
id="stop7329" /></linearGradient><linearGradient
id="linearGradient6957"><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0"
id="stop6951" /><stop
style="stop-color:#f5ffff;stop-opacity:1;"
offset="0.61608356"
id="stop6953" /><stop
style="stop-color:#f5ffff;stop-opacity:0;"
offset="1"
id="stop6955" /></linearGradient><linearGradient
id="linearGradient6573"><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0"
id="stop6567" /><stop
style="stop-color:#f5ff08;stop-opacity:0.823915;"
offset="0.62599742"
id="stop6569" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop6571" /></linearGradient><linearGradient
id="linearGradient6175"><stop
style="stop-color:#f5ff08;stop-opacity:0.47854495;"
offset="0"
id="stop6169" /><stop
style="stop-color:#f5ff08;stop-opacity:0.29862821;"
offset="0.67936534"
id="stop6171" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop6173" /></linearGradient><linearGradient
id="linearGradient5893"><stop
style="stop-color:#f5ff08;stop-opacity:0.71252441;"
offset="0"
id="stop5887" /><stop
style="stop-color:#f5ff08;stop-opacity:0.5904839;"
offset="0.67936534"
id="stop5889" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop5891" /></linearGradient><linearGradient
id="linearGradient5757"><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0"
id="stop5751" /><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0.75665909"
id="stop5753" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop5755" /></linearGradient><linearGradient
id="linearGradient5685"><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0"
id="stop5679" /><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0.63781762"
id="stop5681" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop5683" /></linearGradient><linearGradient
id="linearGradient5619"><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0"
id="stop5613" /><stop
style="stop-color:#f5ff08;stop-opacity:1;"
offset="0.73820531"
id="stop5615" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop5617" /></linearGradient><linearGradient
id="linearGradient5441"><stop
style="stop-color:#f5ff08;stop-opacity:0.89862061;"
offset="0"
id="stop5435" /><stop
style="stop-color:#f5ff08;stop-opacity:0.72535044;"
offset="0.62599742"
id="stop5437" /><stop
style="stop-color:#f5ff08;stop-opacity:0;"
offset="1"
id="stop5439" /></linearGradient><linearGradient
id="linearGradient1452"><stop
style="stop-color:#f50008;stop-opacity:1;"
offset="0"
id="stop1446" /><stop
style="stop-color:#f50008;stop-opacity:1;"
offset="0.7918601"
id="stop1448" /><stop
style="stop-color:#f50008;stop-opacity:0;"
offset="1"
id="stop1450" /></linearGradient><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1452"
id="radialGradient522"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.78484331,0,0,0.78747227,696.44887,-323.11915)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1452"
id="radialGradient524"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.8981104,0,0,0.76442481,749.97364,-321.90886)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6573"
id="radialGradient526"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.63729372,0,0,0.41448086,723.17431,-328.11791)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5619"
id="radialGradient528"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.44694866,0,0,0.65155251,787.10411,-304.51482)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5619"
id="radialGradient530"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.44694866,0,0,0.40774632,806.63991,-285.18279)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5685"
id="radialGradient532"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.31040892,0,0,0.40774632,771.18902,-267.79397)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5757"
id="radialGradient534"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.61485849,0,0,0.48365086,699.42828,-280.26845)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5893"
id="radialGradient536"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.18217879,0,0,0.57948295,785.06567,-317.57229)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6175"
id="radialGradient538"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.17110206,0,0,0.57948295,813.03511,-347.11197)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6175"
id="radialGradient540"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.65699536,0,0,0.23041338,805.19531,-234.77302)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6175"
id="radialGradient542"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.65699536,0,0,0.23041338,673.99742,-230.76895)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5441"
id="radialGradient544"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.44694866,0,0,0.46338383,720.63883,-314.42592)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6957"
id="radialGradient546"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.81417897,0,0,0.30393809,713.08122,-253.70655)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient10317"
id="radialGradient548"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.37560777,0,0,0.52796713,798.71131,-289.99247)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient7331"
id="radialGradient550"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.51429536,0,0,0.55006434,705.69388,-287.70068)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /><radialGradient
inkscape:collect="always"
xlink:href="#linearGradient7451"
id="radialGradient552"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.51429536,0,0,0.55006434,726.67823,-322.63777)"
cx="85.568382"
cy="110.37487"
fx="85.568382"
fy="110.37487"
r="80.962494" /></defs><g
inkscape:groupmode="layer"
id="layer7"
inkscape:label="icon"><rect
style="opacity:1;fill:#cccccc;stroke-width:0.0500064;stroke-linecap:square;stroke-dasharray:none"
id="rect9549"
width="16.933332"
height="13.229165"
x="0"
y="1.8520831" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,13.493748 v 0.529167 h 0.529166 v -0.529167 z"
id="path2369" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,12.699998 v 0.529167 h 0.529166 v -0.529167 z"
id="path2367" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,11.906248 v 0.529167 h 0.529166 v -0.529167 z"
id="path2365" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,11.112498 v 0.529167 h 0.529166 v -0.529167 z"
id="path2363" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,10.318749 v 0.529166 h 0.529166 v -0.529166 z"
id="path2361" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,9.5249987 v 0.5291663 h 0.529166 V 9.5249987 Z"
id="path2359" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,8.7312488 v 0.5291666 h 0.529166 V 8.7312488 Z"
id="path2357" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,6.0854158 v 2.3812497 h 0.529166 V 6.0854158 Z"
id="path2355" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,5.2916659 v 0.5291666 h 0.529166 V 5.2916659 Z"
id="path2353" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,4.497916 v 0.5291666 h 0.529166 V 4.497916 Z"
id="path2351" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,3.7041662 v 0.5291665 h 0.529166 V 3.7041662 Z"
id="path2349" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 16.139581,2.9104163 v 0.5291666 h 0.529166 V 2.9104163 Z"
id="rect14444" /><rect
style="opacity:1;fill:#666666;stroke-width:0.0500064;stroke-linecap:square;stroke-dasharray:none"
id="rect15056"
width="1.0583332"
height="0.52916658"
x="15.610415"
y="2.1166663" /><rect
style="opacity:1;fill:#666666;stroke-width:0.0500064;stroke-linecap:square;stroke-dasharray:none"
id="rect15468"
width="1.0583332"
height="0.52916658"
x="14.287498"
y="2.1166663" /><rect
style="opacity:1;fill:#666666;stroke-width:0.0500064;stroke-linecap:square;stroke-dasharray:none"
id="rect15470"
width="1.0583332"
height="0.52916658"
x="12.964582"
y="2.1166663" /><rect
style="opacity:1;fill:#999999;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
id="rect15882"
width="3.9687495"
height="0.52916658"
x="0.26458329"
y="2.1166663" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-16.139581 h 0.529167 v -0.529167 h -0.529167 z"
transform="rotate(90)"
id="path2231" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-15.345831 h 0.529167 v -0.529167 h -0.529167 z"
transform="rotate(90)"
id="path2229" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-14.552081 h 0.529167 v -0.529167 h -0.529167 z"
transform="rotate(90)"
id="path2227" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-11.641665 h 0.529167 v -2.645833 h -0.529167 z"
transform="rotate(90)"
id="path2225" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-5.8208325 h 0.529167 v -5.5562495 h -0.529167 z"
transform="rotate(90)"
id="path2223" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-4.7624993 h 0.529167 v -0.7937499 h -0.529167 z"
transform="rotate(90)"
id="path2221" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-1.8520831 h 0.529167 V -4.497916 h -0.529167 z"
transform="rotate(90)"
id="path2219" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-1.0583332 h 0.529167 v -0.5291666 h -0.529167 z"
transform="rotate(90)"
id="path2217" /><path
style="opacity:1;fill:#000000;stroke-width:0.0500063;stroke-linecap:square;stroke-dasharray:none"
d="m 14.287498,-0.2645833 h 0.529167 v -0.52916659 h -0.529167 z"
transform="rotate(90)"
id="rect16090" /></g><g
id="g1799"
transform="matrix(0.9833263,0,0,0.93331382,-31.070772,-23.035828)"
style="stroke-width:1.04385"><rect
style="fill:#000000;fill-opacity:1;stroke-width:0.445374;stroke-linecap:square"
id="rect486"
width="135.46664"
height="101.59999"
x="753.36902"
y="-330.61847"
inkscape:label="rect-bg"
transform="matrix(0.1171875,0,0,0.1171875,-56.418761,66.544469)"
mask="none" /><path
id="rect488"
mask="none"
style="fill:url(#radialGradient522);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-red"
d="m 725.48004,-288.15082 v 101.59998 h 101.67054 v -101.59998 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect490"
mask="none"
style="fill:url(#radialGradient524);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-red"
d="m 754.10795,-288.15082 v 101.59998 h 106.83874 v -101.59998 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect492"
mask="none"
style="fill:url(#radialGradient526);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 726.11063,-288.15082 v 39.33912 h 103.1919 v -39.33912 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect494"
mask="none"
style="fill:url(#radialGradient528);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 789.16083,-285.35065 v 98.79981 h 71.78586 v -98.79981 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect496"
mask="none"
style="fill:url(#radialGradient530);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 808.70031,-273.18864 v 66.02235 h 52.24638 v -66.02235 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect498"
mask="none"
style="fill:url(#radialGradient532);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 772.61997,-255.80111 v 66.02236 h 50.262 v -66.02236 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect500"
mask="none"
style="fill:url(#radialGradient534);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 725.48004,-266.04489 v 78.31666 h 76.3411 v -78.31666 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect502"
mask="none"
style="fill:url(#radialGradient536);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 785.90646,-288.15082 v 81.45637 h 29.49662 v -81.45637 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect504"
mask="none"
style="fill:url(#radialGradient538);fill-opacity:1;stroke-width:0.44543;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 813.8244,-288.15082 v 51.91565 h 27.70629 v -51.91565 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect506"
mask="none"
style="fill:url(#radialGradient540);fill-opacity:1;stroke-width:0.445429;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 808.21965,-227.99781 v 37.31065 h 52.72704 v -37.31065 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect508"
mask="none"
style="fill:url(#radialGradient542);fill-opacity:1;stroke-width:0.445429;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 725.48004,-223.99378 v 37.31065 h 57.9261 v -37.31065 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect510"
mask="none"
style="fill:url(#radialGradient544);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-yellow"
d="m 725.48004,-288.15082 v 62.38874 h 69.58982 v -62.38874 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect512"
mask="none"
style="fill:url(#radialGradient546);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-white"
d="m 725.48004,-244.76798 v 49.2169 h 123.18557 v -49.2169 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect514"
mask="none"
style="fill:url(#radialGradient548);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-white"
d="m 800.4409,-274.46305 v 85.49128 h 60.50579 v -85.49128 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect516"
mask="none"
style="fill:url(#radialGradient550);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-white"
d="m 725.48004,-271.52176 v 84.97092 h 65.85919 v -84.97092 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /><path
id="rect518"
mask="none"
style="fill:url(#radialGradient552);fill-opacity:1;stroke-width:0.445431;stroke-linecap:square;stroke-dasharray:none"
inkscape:label="rect-white"
d="m 729.04751,-288.15082 v 70.7628 h 83.27759 v -70.7628 z"
transform="matrix(0.1171875,0,0,0.1171875,-53.150408,61.568041)" /></g></svg>

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,120 +0,0 @@
rendered_icons_optionally_from_svg = {
'icon_exe' : { 'png': 'icon_exe.png' , 'svg': 'icon_exe.svg', 'width': '256', 'height': '256' },
'icon_exe_48': { 'png': 'icon_exe_48.png', 'svg': 'icon_exe.svg', 'width': '48', 'height': '48' },
'icon_exe_32': { 'png': 'icon_exe_32.png', 'svg': 'icon_exe.svg', 'width': '32', 'height': '32' },
'icon_exe_16': { 'png': 'icon_exe_16.png', 'svg': 'icon_exe.svg', 'width': '16', 'height': '16' },
'icon_cps' : { 'png': 'icon_cps.png' , 'svg': 'icon_cps.svg', 'width': '256', 'height': '256' },
'icon_cps_48': { 'png': 'icon_cps_48.png', 'svg': 'icon_cps.svg', 'width': '48', 'height': '48' },
'icon_cps_32': { 'png': 'icon_cps_32.png', 'svg': 'icon_cps.svg', 'width': '32', 'height': '32' },
'icon_cps_16': { 'png': 'icon_cps_16.png', 'svg': 'icon_cps.svg', 'width': '16', 'height': '16' },
}
rendered_icons = {}
if render_icons_with_inkscape.allowed()
foreach key, info : rendered_icons_optionally_from_svg
rendered_icons += { key: custom_target(
key + '-from-svg',
output: info['png'],
command: [
inkscape,
'--export-area-page',
'--export-type', 'png',
'--export-filename', '@OUTPUT@',
'--export-width', info['width'],
'--export-height', info['height'],
files(info['svg']),
],
) }
endforeach
else
foreach key, info : rendered_icons_optionally_from_svg
rendered_icons += { key: files('generated_icons/' + info['png']) }
endforeach
endif
if host_platform == 'windows'
windows_icons = get_option('windows_icons')
windows_utf8cp = get_option('windows_utf8cp')
rc_conf_depends = []
rc_conf_depend_files = [
'resource.h',
]
icon_exe_ico_path = ''
icon_cps_ico_path = ''
winutf8_xml_path = ''
if windows_icons
make_ico = executable('makeico', sources: 'MakeIco.cpp', native: true)
generated_win_icos = {}
win_icos = {
'icon_exe': [ 'icon_exe', 'icon_exe_48', 'icon_exe_32', 'icon_exe_16' ],
'icon_cps': [ 'icon_cps', 'icon_cps_48', 'icon_cps_32', 'icon_cps_16' ],
}
foreach key, icons : win_icos
command = [
make_ico,
'@OUTPUT@',
]
foreach ikey : icons
command += [ rendered_icons[ikey] ]
endforeach
generated_win_icos += { key: custom_target(
key + '-ico',
output: key + '.ico',
command: command,
) }
endforeach
rc_conf_depends += [
generated_win_icos['icon_exe'],
generated_win_icos['icon_cps'],
]
icon_exe_ico_path = join_paths(meson.current_build_dir(), 'icon_exe.ico')
icon_cps_ico_path = join_paths(meson.current_build_dir(), 'icon_cps.ico')
endif
if windows_utf8cp
rc_conf_depend_files += [
'winutf8.xml',
]
winutf8_xml_path = join_paths(meson.current_source_dir(), 'winutf8.xml')
endif
rc_conf_data = configuration_data()
rc_conf_data.merge_from(conf_data)
rc_conf_data.set('HAVE_ICONS', windows_icons ? 1 : 0)
rc_conf_data.set('HAVE_UTF8CP', windows_utf8cp ? 1 : 0)
rc_conf_data.set('RESOUCE_H', join_paths(meson.current_source_dir(), 'resource.h'))
rc_conf_data.set('WINUTF8_XML', winutf8_xml_path)
rc_conf_data.set('ICON_EXE_ICO', icon_exe_ico_path)
rc_conf_data.set('ICON_CPS_ICO', icon_cps_ico_path)
powder_files += windows_mod.compile_resources(
configure_file(
input: 'powder-res.template.rc',
output: 'powder-res.rc',
configuration: rc_conf_data,
),
depends: rc_conf_depends,
depend_files: rc_conf_depend_files,
)
elif host_platform == 'darwin'
configure_file(
input: 'Info.template.plist',
output: 'Info.plist',
configuration: conf_data,
)
elif host_platform == 'linux'
data_files += to_array.process(rendered_icons['icon_exe'], extra_args: 'icon_exe_png')
data_files += to_array.process(rendered_icons['icon_cps'], extra_args: 'icon_cps_png')
data_files += to_array.process('save.xml', extra_args: 'save_xml')
data_files += to_array.process(configure_file(
input: 'powder.template.desktop',
output: 'powder.desktop',
configuration: conf_data,
), extra_args: 'powder_desktop')
configure_file(
input: 'appdata.template.xml',
output: 'appdata.xml',
configuration: conf_data,
)
endif
data_files += to_array.process('save_local.png', extra_args: 'save_local_png')
data_files += to_array.process('save_online.png', extra_args: 'save_online_png')
data_files += to_array.process('font.bz2', extra_args: 'compressed_font_data')

View File

@ -1,40 +0,0 @@
#pragma code_page(65001) // UTF-8
#include "@RESOUCE_H@"
#include <winuser.h>
#include <winver.h>
#include <ntdef.h>
#define HAVE_ICONS @HAVE_ICONS@
#define HAVE_UTF8CP @HAVE_UTF8CP@
#if HAVE_ICONS
IDI_ICON ICON DISCARDABLE "@ICON_EXE_ICO@"
IDI_DOC_ICON ICON DISCARDABLE "@ICON_CPS_ICO@"
#endif
#if HAVE_UTF8CP
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "@WINUTF8_XML@"
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION @DISPLAY_VERSION_MAJOR@,@DISPLAY_VERSION_MINOR@,0,@BUILD_NUM@
PRODUCTVERSION @DISPLAY_VERSION_MAJOR@,@DISPLAY_VERSION_MINOR@,0,@BUILD_NUM@
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "CompanyName", "https://powdertoy.co.uk/\0"
VALUE "FileDescription", "@APPNAME@\0"
VALUE "FileVersion", "@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@.0.@BUILD_NUM@\0"
VALUE "OriginalFilename", "@APPEXE@.exe\0"
VALUE "LegalCopyright", "@MANIFEST_COPYRIGHT@\0"
VALUE "ProductName", "@APPCOMMENT@\0"
VALUE "ProductVersion", "@DISPLAY_VERSION_MAJOR@.@DISPLAY_VERSION_MINOR@.0.@BUILD_NUM@\0"
VALUE "InternalName", "@APPID@\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 65001
}
}

View File

@ -1,56 +0,0 @@
.TH POWDER 6 "2019-09-25" "" "Games manual"
.
.SH NAME
powder \- a physics sandbox game
.
.SH SYNOPSIS
.SY powder
[\fIOPTIONS...\fR]
.YS
.
.SH DESCRIPTION
The Powder Toy is a free physics sandbox game, which simulates
air pressure and velocity, heat, gravity and a number of other interactions
between different substances.
The game provides the player with various building materials, liquids,
gases and electronic components which can be used to construct
complex machines, guns, bombs, realistic terrains and almost anything else.
The player can then mine them and watch cool explosions, add intricate wirings,
play with little stickmen or operate their machine.
The game also features a Lua API, which allows to automate work or even
make plugins for the program.
.
.SH OPTIONS
\fBNOTE:\fR Program options should be written exactly as specified on this
man page \- there are \fBno leading dashes\fR in front of their names.
.TP
\fBddir\fR \fIDIRECTORY\fR
Load and save preferences, savegames etc. in \fIDIRECTORY\fR.
The directory must already exist (if missing, it will not be created).
.TP
.B disable-network
Disable network access.
.TP
.B kiosk
Run in fullscreen mode.
.TP
\fBopen\fR \fIFILE\fR
Open the specified savegame on program start.
.TP
\fBproxy\fR:\fISERVER\fR[:\fIPORT\fR]
Use the specified proxy server.
.TP
\fBptsave\fR:\fISAVEID\fR
Open an on-line save with the given ID.
.TP
.B redirect
Do not print anything to standard output nor the standard error stream;
redirect all messages to \fIstdout.log\fR and \fIstderr.log\fR files.
.
.SH SEE ALSO
.TP
.B https://powdertoy.co.uk/
Official website. To use on-line features, such as saving and sharing their
creations, players need to register an account.

View File

@ -1,8 +0,0 @@
[Desktop Entry]
Name=@APPNAME@
Type=Application
Comment=@APPCOMMENT@
MimeType=application/vnd.powdertoy.save;x-scheme-handler/ptsave;
Categories=Game;Simulation;
Exec=@APPEXE@ %u
Icon=@APPVENDOR@-@APPEXE@

View File

@ -1,3 +0,0 @@
#define IDI_ICON 101
#define IDI_DOC_ICON 102

View File

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/vnd.powdertoy.save">
<comment>Powder Toy save</comment>
<glob pattern="*.cps"/>
<glob pattern="*.stm"/>
</mime-type>
</mime-info>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -1,8 +0,0 @@
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="." version="6.0.0.0"/>
<application>
<windowsSettings>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>
</assembly>

View File

@ -1,35 +0,0 @@
#pragma once
#include "gui/interface/Window.h"
class Activity
{
public:
virtual void Exit() {}
virtual void Show() {}
virtual void Hide() {}
virtual ~Activity() {}
};
class WindowActivity: public ui::Window, public Activity
{
public:
WindowActivity(ui::Point position, ui::Point size) :
ui::Window(position, size)
{
Show();
}
void Exit() override
{
Hide();
SelfDestruct();
}
void Show() override
{
MakeActiveWindow();
}
void Hide() override
{
CloseActiveWindow();
}
virtual ~WindowActivity() {}
};

View File

@ -1,70 +0,0 @@
#pragma once
#include "VcsTag.h"
#include "common/Version.h"
constexpr bool SET_WINDOW_ICON = @SET_WINDOW_ICON@;
constexpr bool DEBUG = @DEBUG@;
constexpr bool X86 = @X86@;
constexpr bool BETA = @BETA@;
constexpr bool SNAPSHOT = @SNAPSHOT@;
constexpr bool MOD = @MOD@;
constexpr bool NOHTTP = @NOHTTP@;
constexpr bool LUACONSOLE = @LUACONSOLE@;
constexpr bool ALLOW_FAKE_NEWER_VERSION = @ALLOW_FAKE_NEWER_VERSION@;
constexpr bool USE_UPDATESERVER = @USE_UPDATESERVER@;
constexpr bool CAN_INSTALL = @CAN_INSTALL@;
constexpr bool USE_BLUESCREEN = @USE_BLUESCREEN@;
constexpr bool INSTALL_CHECK = @INSTALL_CHECK@;
constexpr bool IGNORE_UPDATES = @IGNORE_UPDATES@;
constexpr bool ENFORCE_HTTPS = @ENFORCE_HTTPS@;
constexpr bool SECURE_CIPHERS_ONLY = @SECURE_CIPHERS_ONLY@;
constexpr bool PLATFORM_CLIPBOARD = @PLATFORM_CLIPBOARD@;
constexpr bool USE_SYSTEM_CERT_PROVIDER = @USE_SYSTEM_CERT_PROVIDER@;
constexpr bool FFTW_PLAN_MEASURE = @FFTW_PLAN_MEASURE@;
constexpr bool ALLOW_QUIT = @ALLOW_QUIT@;
constexpr bool DEFAULT_TOUCH_UI = @DEFAULT_TOUCH_UI@;
constexpr bool ALLOW_DATA_FOLDER = @ALLOW_DATA_FOLDER@;
constexpr char PATH_SEP_CHAR = '@PATH_SEP_CHAR@';
enum ForceWindowFrameOps
{
forceWindowFrameOpsNone, // usual behaviour
forceWindowFrameOpsEmbedded, // e.g. into a webpage; this sweeps a few emscripten limitations under the rug
forceWindowFrameOpsHandheld, // e.g. the system doesn't support windowed mode; includes odd setups like chromebooks
};
constexpr ForceWindowFrameOps FORCE_WINDOW_FRAME_OPS = @FORCE_WINDOW_FRAME_OPS@;
constexpr char SERVER[] = "@SERVER@";
constexpr char STATICSERVER[] = "@STATICSERVER@";
constexpr char UPDATESERVER[] = "@UPDATESERVER@";
constexpr char IDENT_PLATFORM[] = "@IDENT_PLATFORM@";
constexpr char IDENT[] = "@IDENT@";
constexpr char APPNAME[] = "@APPNAME@";
constexpr char APPCOMMENT[] = "@APPCOMMENT@";
constexpr char APPEXE[] = "@APPEXE@";
constexpr char APPID[] = "@APPID@";
constexpr char APPDATA[] = "@APPDATA@";
constexpr char APPVENDOR[] = "@APPVENDOR@";
constexpr int MOD_ID = @MOD_ID@;
struct DisplayVersionWithBuild
{
Version<2> displayVersion;
size_t build;
};
constexpr DisplayVersionWithBuild APP_VERSION = { { @DISPLAY_VERSION_MAJOR@, @DISPLAY_VERSION_MINOR@ }, @BUILD_NUM@ };
constexpr DisplayVersionWithBuild UPSTREAM_VERSION = { { @UPSTREAM_VERSION_MAJOR@, @UPSTREAM_VERSION_MINOR@ }, @UPSTREAM_BUILD_NUM@ };
constexpr auto DISPLAY_VERSION = APP_VERSION.displayVersion;
constexpr char IDENT_RELTYPE = SNAPSHOT ? 'S' : (BETA ? 'B' : 'R');
constexpr char SCHEME[] = "https://";
constexpr char STATICSCHEME[] = "https://";
constexpr char LOCAL_SAVE_DIR[] = "Saves";
constexpr char STAMPS_DIR[] = "stamps";
constexpr char BRUSH_DIR[] = "Brushes";
constexpr int httpMaxConcurrentStreams = 50;
constexpr int httpConnectTimeoutS = 15;

View File

@ -1,9 +0,0 @@
#pragma once
class Controller
{
private:
virtual void Exit();
virtual void Show();
virtual void Hide();
virtual ~Controller() = default;
};

View File

@ -1,394 +0,0 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <optional>
#include <stdexcept>
#include <png.h>
#include "Format.h"
#include "graphics/Graphics.h"
ByteString format::UnixtimeToDate(time_t unixtime, ByteString dateFormat, bool local)
{
struct tm * timeData;
char buffer[128];
if (local)
{
timeData = localtime(&unixtime);
}
else
{
timeData = gmtime(&unixtime);
}
strftime(buffer, 128, dateFormat.c_str(), timeData);
return ByteString(buffer);
}
ByteString format::UnixtimeToDateMini(time_t unixtime)
{
time_t currentTime = time(NULL);
struct tm currentTimeData = *gmtime(&currentTime);
struct tm timeData = *gmtime(&unixtime);
if(currentTimeData.tm_year != timeData.tm_year)
{
return UnixtimeToDate(unixtime, "%d %b %Y");
}
else if(currentTimeData.tm_mon != timeData.tm_mon || currentTimeData.tm_mday != timeData.tm_mday)
{
return UnixtimeToDate(unixtime, "%d %B");
}
else
{
return UnixtimeToDate(unixtime, "%H:%M:%S");
}
}
String format::CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric)
{
for (size_t i = 0; i < dirtyString.size(); i++)
{
switch(dirtyString[i])
{
case '\b':
if (color)
{
dirtyString.erase(i, 2);
i--;
}
else
i++;
break;
case '\x0E':
if (color)
{
dirtyString.erase(i, 1);
i--;
}
break;
case '\x0F':
if (color)
{
dirtyString.erase(i, 4);
i--;
}
else
i += 3;
break;
case '\r':
case '\n':
if (newlines)
dirtyString[i] = ' ';
break;
default:
if (numeric && (dirtyString[i] < '0' || dirtyString[i] > '9'))
{
dirtyString.erase(i, 1);
i--;
}
// if less than ascii 20 or greater than ascii 126, delete
else if (ascii && (dirtyString[i] < ' ' || dirtyString[i] > '~'))
{
dirtyString.erase(i, 1);
i--;
}
break;
}
}
return dirtyString;
}
std::vector<char> format::PixelsToPPM(PlaneAdapter<std::vector<pixel>> const &input)
{
std::vector<char> data;
char buffer[256];
sprintf(buffer, "P6\n%d %d\n255\n", input.Size().X, input.Size().Y);
data.insert(data.end(), buffer, buffer + strlen(buffer));
data.reserve(data.size() + input.Size().X * input.Size().Y * 3);
for (int i = 0; i < input.Size().X * input.Size().Y; i++)
{
auto colour = RGB<uint8_t>::Unpack(input.data()[i]);
data.push_back(colour.Red);
data.push_back(colour.Green);
data.push_back(colour.Blue);
}
return data;
}
static std::unique_ptr<PlaneAdapter<std::vector<uint32_t>>> readPNG(
std::vector<char> const &data,
// If omitted,
// RGB data is returned with A=0xFF
// RGBA data is returned as itself
// If specified
// RGB data is returned with A=0x00
// RGBA data is blended against the background and returned with A=0x00
std::optional<RGB<uint8_t>> background
)
{
png_infop info = nullptr;
auto deleter = [&info](png_struct *png) {
png_destroy_read_struct(&png, &info, NULL);
};
auto png = std::unique_ptr<png_struct, decltype(deleter)>(
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
[](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG error: %s\n", msg);
},
[](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG warning: %s\n", msg);
}
), deleter
);
if (!png)
return nullptr;
// libpng might longjmp() here in case of error
// Every time we create an object with a non-trivial destructor we must call setjmp again
if (setjmp(png_jmpbuf(png.get())))
return nullptr;
info = png_create_info_struct(png.get());
if (!info)
return nullptr;
auto it = data.begin();
auto const end = data.end();
auto readFn = [&it, end](png_structp png, png_bytep data, size_t length) {
if (size_t(end - it) < length)
png_error(png, "Tried to read beyond the buffer");
std::copy_n(it, length, data);
it += length;
};
// See above
if (setjmp(png_jmpbuf(png.get())))
return nullptr;
png_set_read_fn(png.get(), static_cast<void *>(&readFn), [](png_structp png, png_bytep data, size_t length) {
(*static_cast<decltype(readFn) *>(png_get_io_ptr(png)))(png, data, length);
});
png_set_user_limits(png.get(), RES.X, RES.Y); // Refuse to parse larger images
png_read_info(png.get(), info);
auto output = std::make_unique<PlaneAdapter<std::vector<uint32_t>>>(
Vec2<int>(png_get_image_width(png.get(), info), png_get_image_height(png.get(), info))
);
std::vector<png_bytep> rowPointers(output->Size().Y);
for (int y = 0; y < output->Size().Y; y++)
rowPointers[y] = reinterpret_cast<png_bytep>(&*output->RowIterator(Vec2(0, y)));
// See above
if (setjmp(png_jmpbuf(png.get())))
return nullptr;
png_set_filler(png.get(), background ? 0x00 : 0xFF, PNG_FILLER_AFTER);
png_set_bgr(png.get());
auto bitDepth = png_get_bit_depth(png.get(), info);
auto colorType = png_get_color_type(png.get(), info);
if (colorType == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png.get());
if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8)
png_set_expand_gray_1_2_4_to_8(png.get());
if (bitDepth == 16)
png_set_scale_16(png.get());
if (png_get_valid(png.get(), info, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png.get());
if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png.get());
if (background)
{
png_color_16 colour;
colour.red = background->Red;
colour.green = background->Green;
colour.blue = background->Blue;
png_set_background(png.get(), &colour, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
}
png_read_image(png.get(), rowPointers.data());
return output;
}
std::unique_ptr<PlaneAdapter<std::vector<pixel_rgba>>> format::PixelsFromPNG(std::vector<char> const &data)
{
return readPNG(data, std::nullopt);
}
std::unique_ptr<PlaneAdapter<std::vector<pixel>>> format::PixelsFromPNG(std::vector<char> const &data, RGB<uint8_t> background)
{
return readPNG(data, background);
}
std::unique_ptr<std::vector<char>> format::PixelsToPNG(PlaneAdapter<std::vector<pixel>> const &input)
{
png_infop info = nullptr;
auto deleter = [&info](png_struct *png) {
png_destroy_write_struct(&png, &info);
};
auto png = std::unique_ptr<png_struct, decltype(deleter)>(
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
[](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG error: %s\n", msg);
},
[](png_structp png, png_const_charp msg) {
fprintf(stderr, "PNG warning: %s\n", msg);
}
), deleter
);
if (!png)
return nullptr;
// libpng might longjmp() here in case of error
// Every time we create an object with a non-trivial destructor we must call setjmp again
if (setjmp(png_jmpbuf(png.get())))
return nullptr;
info = png_create_info_struct(png.get());
if (!info)
return nullptr;
std::vector<char> output;
auto writeFn = [&output](png_structp png, png_bytep data, size_t length) {
output.insert(output.end(), data, data + length);
};
std::vector<png_const_bytep> rowPointers(input.Size().Y);
for (int y = 0; y < input.Size().Y; y++)
rowPointers[y] = reinterpret_cast<png_const_bytep>(&*input.RowIterator(Vec2(0, y)));
// See above
if (setjmp(png_jmpbuf(png.get())))
return nullptr;
png_set_write_fn(png.get(), static_cast<void *>(&writeFn), [](png_structp png, png_bytep data, size_t length) {
(*static_cast<decltype(writeFn) *>(png_get_io_ptr(png)))(png, data, length);
}, NULL);
png_set_IHDR(png.get(), info, input.Size().X, input.Size().Y, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(png.get(), info);
png_set_filler(png.get(), 0x00, PNG_FILLER_AFTER);
png_set_bgr(png.get());
png_write_image(png.get(), const_cast<png_bytepp>(rowPointers.data()));
png_write_end(png.get(), NULL);
return std::make_unique<std::vector<char>>(std::move(output));
}
const static char hex[] = "0123456789ABCDEF";
ByteString format::URLEncode(ByteString source)
{
ByteString result;
for (auto it = source.begin(); it < source.end(); ++it)
{
if (!((*it >= 'a' && *it <= 'z') ||
(*it >= 'A' && *it <= 'Z') ||
(*it >= '0' && *it <= '9')))
{
auto byte = uint8_t(*it);
result.append(1, '%');
result.append(1, hex[(byte >> 4) & 0xF]);
result.append(1, hex[ byte & 0xF]);
}
else
{
result.append(1, *it);
}
}
return result;
}
ByteString format::URLDecode(ByteString source)
{
ByteString result;
for (auto it = source.begin(); it < source.end(); ++it)
{
if (*it == '%' && it < source.end() + 2)
{
auto byte = uint8_t(0);
for (auto i = 0; i < 2; ++i)
{
it += 1;
auto *off = strchr(hex, tolower(*it));
if (!off)
{
return {};
}
byte = (byte << 4) | (off - hex);
}
result.append(1, byte);
}
else if (*it == '+')
{
result.append(1, ' ');
}
else
{
result.append(1, *it);
}
}
return result;
}
void format::RenderTemperature(StringBuilder &sb, float temp, int scale)
{
switch (scale)
{
case 1:
sb << (temp - 273.15f) << "C";
break;
case 2:
sb << (temp - 273.15f) * 1.8f + 32.0f << "F";
break;
default:
sb << temp << "K";
break;
}
}
float format::StringToTemperature(String str, int defaultScale)
{
auto scale = defaultScale;
if (str.size())
{
if (str.EndsWith("K"))
{
scale = 0;
str = str.SubstrFromEnd(1);
}
else if (str.EndsWith("C"))
{
scale = 1;
str = str.SubstrFromEnd(1);
}
else if (str.EndsWith("F"))
{
scale = 2;
str = str.SubstrFromEnd(1);
}
}
if (!str.size())
{
throw std::out_of_range("empty string");
}
auto out = str.ToNumber<float>();
switch (scale)
{
case 1:
out = out + 273.15;
break;
case 2:
out = (out - 32.0f) / 1.8f + 273.15f;
break;
}
return out;
}

View File

@ -1,23 +0,0 @@
#pragma once
#include <memory>
#include <vector>
#include "common/String.h"
#include "common/Plane.h"
#include "graphics/Pixel.h"
class VideoBuffer;
namespace format
{
ByteString URLEncode(ByteString value);
ByteString URLDecode(ByteString value);
ByteString UnixtimeToDate(time_t unixtime, ByteString dateFomat = ByteString("%d %b %Y"), bool local = true);
ByteString UnixtimeToDateMini(time_t unixtime);
String CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric = false);
std::vector<char> PixelsToPPM(PlaneAdapter<std::vector<pixel>> const &);
std::unique_ptr<std::vector<char>> PixelsToPNG(PlaneAdapter<std::vector<pixel>> const &);
std::unique_ptr<PlaneAdapter<std::vector<pixel_rgba>>> PixelsFromPNG(std::vector<char> const &);
std::unique_ptr<PlaneAdapter<std::vector<pixel>>> PixelsFromPNG(std::vector<char> const &, RGB<uint8_t> background);
void RenderTemperature(StringBuilder &sb, float temp, int scale);
float StringToTemperature(String str, int defaultScale);
}

View File

@ -1,14 +0,0 @@
#pragma once
#include <variant>
struct FpsLimitVsync
{
};
struct FpsLimitNone
{
};
struct FpsLimitExplicit
{
float value;
};
using FpsLimit = std::variant<FpsLimitVsync, FpsLimitNone, FpsLimitExplicit>;

View File

@ -1,92 +0,0 @@
#include "Misc.h"
#include "common/String.h"
#include <cstring>
#include <sys/types.h>
#include <cmath>
#include <algorithm>
void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b)//convert 0-255(0-360 for H) HSV values to 0-255 RGB
{
float hh, ss, vv, c, x;
int m;
hh = h/60.0f;//normalize values
ss = s/255.0f;
vv = v/255.0f;
c = vv * ss;
x = c * ( 1 - fabs(fmod(hh,2.0f) -1) );
if(hh<1){
*r = (int)(c*255.0);
*g = (int)(x*255.0);
*b = 0;
}
else if(hh<2){
*r = (int)(x*255.0);
*g = (int)(c*255.0);
*b = 0;
}
else if(hh<3){
*r = 0;
*g = (int)(c*255.0);
*b = (int)(x*255.0);
}
else if(hh<4){
*r = 0;
*g = (int)(x*255.0);
*b = (int)(c*255.0);
}
else if(hh<5){
*r = (int)(x*255.0);
*g = 0;
*b = (int)(c*255.0);
}
else if(hh<6){
*r = (int)(c*255.0);
*g = 0;
*b = (int)(x*255.0);
}
m = (int)((vv-c)*255.0);
*r += m;
*g += m;
*b += m;
}
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v)//convert 0-255 RGB values to 0-255(0-360 for H) HSV
{
float rr, gg, bb, a,x,c,d;
rr = r/255.0f;//normalize values
gg = g/255.0f;
bb = b/255.0f;
a = std::min(rr,gg);
a = std::min(a,bb);
x = std::max(rr,gg);
x = std::max(x,bb);
if (a==x)//greyscale
{
*h = 0;
*s = 0;
*v = (int)(a*255.0);
}
else
{
c = (rr==a) ? gg-bb : ((bb==a) ? rr-gg : bb-rr);
d = (rr==a) ? 3.f : ((bb==a) ? 1.f : 5.f);
*h = (int)(60.0*(d - c/(x - a)));
*s = (int)(255.0*((x - a)/x));
*v = (int)(255.0*x);
}
}
void membwand(void * destv, void * srcv, size_t destsize, size_t srcsize)
{
size_t i;
unsigned char * dest = (unsigned char*)destv;
unsigned char * src = (unsigned char*)srcv;
for(i = 0; i < destsize; i++){
dest[i] = dest[i] & src[i%srcsize];
}
}
bool byteStringEqualsString(const ByteString &str, const char *data, size_t size)
{
return str.size() == size && !memcmp(str.data(), data, size);
}

View File

@ -1,92 +0,0 @@
#pragma once
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
template<class Signed>
inline std::pair<Signed, Signed> floorDiv(Signed a, Signed b)
{
auto quo = a / b;
auto rem = a % b;
if (a < Signed(0) && rem)
{
quo -= Signed(1);
rem += b;
}
return { quo, rem };
}
template<class Signed>
inline std::pair<Signed, Signed> ceilDiv(Signed a, Signed b)
{
return floorDiv(a + b - Signed(1), b);
}
//Linear interpolation
template <typename T> inline T LinearInterpolate(T val1, T val2, T lowerCoord, T upperCoord, T coord)
{
if(lowerCoord == upperCoord) return val1;
return (((val2 - val1) / (upperCoord - lowerCoord)) * (coord - lowerCoord)) + val1;
}
//Signum function
inline int isign(int i)
{
if (i<0)
return -1;
if (i>0)
return 1;
return 0;
}
inline int isign(float i)
{
if (i<0)
return -1;
if (i>0)
return 1;
return 0;
}
inline int iabs(int i)
{
return i * isign(i);
}
inline unsigned clamp_flt(float f, float min, float max)
{
if (f<min)
return 0;
if (f>max)
return 255;
return (int)(255.0f*(f-min)/(max-min));
}
inline float restrict_flt(float f, float min, float max)
{
// Fix crash in certain cases when f is nan
if (!std::isfinite(f))
return min;
if (f < min)
return min;
if (f > max)
return max;
return f;
}
void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b);
void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v);
void membwand(void * dest, void * src, size_t destsize, size_t srcsize);
class ByteString;
bool byteStringEqualsString(const ByteString &str, const char *data, size_t size);
template<size_t N>
// TODO: use std::literals::string_literals::operator""s if we get rid of ByteString
bool byteStringEqualsLiteral(const ByteString &str, const char (&lit)[N])
{
return byteStringEqualsString(str, lit, N - 1U);
}

View File

@ -1,572 +0,0 @@
#include "PowderToySDL.h"
#include "Format.h"
#include "X86KillDenormals.h"
#include "prefs/GlobalPrefs.h"
#include "client/Client.h"
#include "client/GameSave.h"
#include "client/SaveFile.h"
#include "client/SaveInfo.h"
#include "client/http/requestmanager/RequestManager.h"
#include "client/http/GetSaveRequest.h"
#include "client/http/GetSaveDataRequest.h"
#include "common/platform/Platform.h"
#include "graphics/Graphics.h"
#include "simulation/SaveRenderer.h"
#include "simulation/SimulationData.h"
#include "common/tpt-rand.h"
#include "gui/game/Favorite.h"
#include "gui/Style.h"
#include "gui/game/GameController.h"
#include "gui/game/GameView.h"
#include "gui/game/IntroText.h"
#include "gui/dialogues/ConfirmPrompt.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/interface/Engine.h"
#include "gui/interface/TextWrapper.h"
#include "Config.h"
#include "SimulationConfig.h"
#include <optional>
#include <climits>
#include <iostream>
#include <csignal>
#include <SDL.h>
#include <exception>
#include <cstdlib>
void LoadWindowPosition()
{
if (Client::Ref().IsFirstRun())
{
return;
}
auto &prefs = GlobalPrefs::Ref();
int savedWindowX = prefs.Get("WindowX", INT_MAX);
int savedWindowY = prefs.Get("WindowY", INT_MAX);
int borderTop, borderLeft;
SDL_GetWindowBordersSize(sdl_window, &borderTop, &borderLeft, nullptr, nullptr);
// Sometimes (Windows), the border size may not be reported for 200+ frames
// So just have a default of 5 to ensure the window doesn't get stuck where it can't be moved
if (borderTop == 0)
borderTop = 5;
int numDisplays = SDL_GetNumVideoDisplays();
SDL_Rect displayBounds;
bool ok = false;
for (int i = 0; i < numDisplays; i++)
{
SDL_GetDisplayBounds(i, &displayBounds);
if (savedWindowX + borderTop > displayBounds.x && savedWindowY + borderLeft > displayBounds.y &&
savedWindowX + borderTop < displayBounds.x + displayBounds.w &&
savedWindowY + borderLeft < displayBounds.y + displayBounds.h)
{
ok = true;
break;
}
}
if (ok)
SDL_SetWindowPosition(sdl_window, savedWindowX + borderLeft, savedWindowY + borderTop);
}
void SaveWindowPosition()
{
int x, y;
SDL_GetWindowPosition(sdl_window, &x, &y);
int borderTop, borderLeft;
SDL_GetWindowBordersSize(sdl_window, &borderTop, &borderLeft, nullptr, nullptr);
auto &prefs = GlobalPrefs::Ref();
prefs.Set("WindowX", x - borderLeft);
prefs.Set("WindowY", y - borderTop);
}
void LargeScreenDialog()
{
StringBuilder message;
auto scale = ui::Engine::Ref().windowFrameOps.scale;
message << "Switching to " << scale << "x size mode since your screen was determined to be large enough: ";
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW * scale << "x" << WINDOWH * scale << " required";
message << "\nTo undo this, hit Cancel. You can change this in settings at any time.";
new ConfirmPrompt("Large screen detected", message.Build(), { nullptr, []() {
GlobalPrefs::Ref().Set("Scale", 1);
ui::Engine::Ref().windowFrameOps.scale = 1;
} });
}
void TickClient()
{
Client::Ref().Tick();
}
static void BlueScreen(String detailMessage, std::optional<std::vector<String>> stackTrace)
{
auto &engine = ui::Engine::Ref();
engine.g->BlendFilledRect(engine.g->Size().OriginRect(), 0x1172A9_rgb .WithAlpha(0xD2));
auto crashPrevLogPath = ByteString("crash.prev.log");
auto crashLogPath = ByteString("crash.log");
Platform::RenameFile(crashLogPath, crashPrevLogPath, true);
StringBuilder crashInfo;
crashInfo << "ERROR - Details: " << detailMessage << "\n";
crashInfo << "An unrecoverable fault has occurred, please report it by visiting the website below\n\n " << SCHEME << SERVER << "\n\n";
crashInfo << "An attempt will be made to save all of this information to " << crashLogPath.FromUtf8() << " in your data folder.\n";
crashInfo << "Please attach this file to your report.\n\n";
crashInfo << "Version: " << VersionInfo().FromUtf8() << "\n";
crashInfo << "Tag: " << VCS_TAG << "\n";
crashInfo << "Date: " << format::UnixtimeToDate(time(NULL), "%Y-%m-%dT%H:%M:%SZ", false).FromUtf8() << "\n";
if (stackTrace)
{
crashInfo << "Stack trace:\n";
for (auto &item : *stackTrace)
{
crashInfo << " - " << item << "\n";
}
}
else
{
crashInfo << "Stack trace not available\n";
}
String errorText = crashInfo.Build();
constexpr auto width = 440;
ui::TextWrapper tw;
tw.Update(errorText, true, width);
engine.g->BlendText(ui::Point((engine.g->Size().X - width) / 2, 80), tw.WrappedText(), 0xFFFFFF_rgb .WithAlpha(0xFF));
auto crashLogData = errorText.ToUtf8();
std::cerr << crashLogData << std::endl;
Platform::WriteFile(std::vector<char>(crashLogData.begin(), crashLogData.end()), crashLogPath);
//Death loop
SDL_Event event;
auto running = true;
while (running)
{
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
running = false;
}
}
blit(engine.g->Data());
}
// Don't use Platform::Exit, we're practically zombies at this point anyway.
#if defined(__MINGW32__) || defined(__APPLE__) || defined(__EMSCRIPTEN__)
// Come on...
exit(-1);
#else
quick_exit(-1);
#endif
}
static struct
{
int sig;
const char *message;
} signalMessages[] = {
{ SIGSEGV, "Memory read/write error" },
{ SIGFPE, "Floating point exception" },
{ SIGILL, "Program execution exception" },
{ SIGABRT, "Unexpected program abort" },
{ 0, nullptr },
};
static void SigHandler(int signal)
{
const char *message = "Unknown signal";
for (auto *msg = signalMessages; msg->message; ++msg)
{
if (msg->sig == signal)
{
message = msg->message;
break;
}
}
BlueScreen(ByteString(message).FromUtf8(), Platform::StackTrace());
}
static void TerminateHandler()
{
ByteString err = "std::terminate called without a current exception";
auto eptr = std::current_exception();
try
{
if (eptr)
{
std::rethrow_exception(eptr);
}
}
catch (const std::exception &e)
{
err = "unhandled exception: " + ByteString(e.what());
}
catch (...)
{
err = "unhandled exception not derived from std::exception, cannot determine reason";
}
BlueScreen(err.FromUtf8(), Platform::StackTrace());
}
constexpr int SCALE_MAXIMUM = 10;
constexpr int SCALE_MARGIN = 30;
int GuessBestScale()
{
const int widthNoMargin = desktopWidth - SCALE_MARGIN;
const int widthGuess = widthNoMargin / WINDOWW;
const int heightNoMargin = desktopHeight - SCALE_MARGIN;
const int heightGuess = heightNoMargin / WINDOWH;
int guess = std::min(widthGuess, heightGuess);
if(guess < 1 || guess > SCALE_MAXIMUM)
guess = 1;
return guess;
}
struct ExplicitSingletons
{
// These need to be listed in the order they are populated in main.
std::unique_ptr<GlobalPrefs> globalPrefs;
http::RequestManagerPtr requestManager;
std::unique_ptr<Client> client;
std::unique_ptr<SaveRenderer> saveRenderer;
std::unique_ptr<Favorite> favorite;
std::unique_ptr<ui::Engine> engine;
std::unique_ptr<SimulationData> simulationData;
std::unique_ptr<GameController> gameController;
};
static std::unique_ptr<ExplicitSingletons> explicitSingletons;
int main(int argc, char *argv[])
{
Platform::SetupCrt();
return Platform::InvokeMain(argc, argv);
}
int Main(int argc, char *argv[])
{
Platform::Atexit([]() {
SaveWindowPosition();
// Unregister dodgy error handlers so they don't try to show the blue screen when the window is closed
for (auto *msg = signalMessages; msg->message; ++msg)
{
signal(msg->sig, SIG_DFL);
}
SDLClose();
explicitSingletons.reset();
});
explicitSingletons = std::make_unique<ExplicitSingletons>();
// https://bugzilla.libsdl.org/show_bug.cgi?id=3796
if (SDL_Init(0) < 0)
{
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
return 1;
}
Platform::originalCwd = Platform::GetCwd();
using Argument = std::optional<ByteString>;
std::map<ByteString, Argument> arguments;
for (auto i = 1; i < argc; ++i)
{
auto str = ByteString(argv[i]);
if (str.BeginsWith("file://"))
{
arguments.insert({ "open", format::URLDecode(str.substr(7 /* length of the "file://" prefix */)) });
}
else if (str.BeginsWith("ptsave:"))
{
arguments.insert({ "ptsave", str });
}
else if (auto split = str.SplitBy(':'))
{
arguments.insert({ split.Before(), split.After() });
}
else if (auto split = str.SplitBy('='))
{
arguments.insert({ split.Before(), split.After() });
}
else if (str == "open" || str == "ptsave" || str == "ddir")
{
if (i + 1 < argc)
{
arguments.insert({ str, argv[i + 1] });
i += 1;
}
else
{
std::cerr << "no value provided for command line parameter " << str << std::endl;
}
}
else
{
arguments.insert({ str, "" }); // so .has_value() is true
}
}
auto ddirArg = arguments["ddir"];
if (ddirArg.has_value())
{
if (Platform::ChangeDir(ddirArg.value()))
Platform::sharedCwd = Platform::GetCwd();
else
perror("failed to chdir to requested ddir");
}
else
{
auto ddir = Platform::DefaultDdir();
if (!Platform::FileExists("powder.pref"))
{
if (ddir.size())
{
if (!Platform::ChangeDir(ddir))
{
perror("failed to chdir to default ddir");
ddir = {};
}
}
}
if (ddir.size())
{
Platform::sharedCwd = ddir;
}
}
// We're now in the correct directory, time to get prefs.
explicitSingletons->globalPrefs = std::make_unique<GlobalPrefs>();
auto &prefs = GlobalPrefs::Ref();
WindowFrameOps windowFrameOps{
prefs.Get("Scale", 1),
prefs.Get("Resizable", false),
prefs.Get("Fullscreen", false),
prefs.Get("AltFullscreen", false),
prefs.Get("ForceIntegerScaling", true),
prefs.Get("BlurryScaling", false),
};
auto graveExitsConsole = prefs.Get("GraveExitsConsole", true);
momentumScroll = prefs.Get("MomentumScroll", true);
showAvatars = prefs.Get("ShowAvatars", true);
auto true_string = [](ByteString str) {
str = str.ToLower();
return str == "true" ||
str == "t" ||
str == "on" ||
str == "yes" ||
str == "y" ||
str == "1" ||
str == ""; // standalone "redirect" or "disable-bluescreen" or similar arguments
};
auto true_arg = [&true_string](Argument arg) {
return arg.has_value() && true_string(arg.value());
};
auto kioskArg = arguments["kiosk"];
if (kioskArg.has_value())
{
windowFrameOps.fullscreen = true_string(kioskArg.value());
prefs.Set("Fullscreen", windowFrameOps.fullscreen);
}
if (true_arg(arguments["redirect"]))
{
FILE *new_stdout = freopen("stdout.log", "w", stdout);
FILE *new_stderr = freopen("stderr.log", "w", stderr);
if (!new_stdout || !new_stderr)
{
Platform::Exit(42);
}
}
auto scaleArg = arguments["scale"];
if (scaleArg.has_value())
{
try
{
windowFrameOps.scale = scaleArg.value().ToNumber<int>();
prefs.Set("Scale", windowFrameOps.scale);
}
catch (const std::runtime_error &e)
{
std::cerr << "failed to set scale: " << e.what() << std::endl;
}
}
auto clientConfig = [&prefs](Argument arg, ByteString name, ByteString defaultValue) {
ByteString value;
if (arg.has_value())
{
value = arg.value();
if (value == "")
{
value = defaultValue;
}
prefs.Set(name, value);
}
else
{
value = prefs.Get(name, defaultValue);
}
return value;
};
ByteString proxyString = clientConfig(arguments["proxy"], "Proxy", "");
ByteString cafileString = clientConfig(arguments["cafile"], "CAFile", "");
ByteString capathString = clientConfig(arguments["capath"], "CAPath", "");
bool disableNetwork = true_arg(arguments["disable-network"]);
explicitSingletons->requestManager = http::RequestManager::Create(proxyString, cafileString, capathString, disableNetwork);
explicitSingletons->client = std::make_unique<Client>();
Client::Ref().Initialize();
explicitSingletons->saveRenderer = std::make_unique<SaveRenderer>();
explicitSingletons->favorite = std::make_unique<Favorite>();
explicitSingletons->engine = std::make_unique<ui::Engine>();
// TODO: maybe bind the maximum allowed scale to screen size somehow
if(windowFrameOps.scale < 1 || windowFrameOps.scale > SCALE_MAXIMUM)
windowFrameOps.scale = 1;
auto &engine = ui::Engine::Ref();
engine.g = new Graphics();
engine.GraveExitsConsole = graveExitsConsole;
engine.MomentumScroll = momentumScroll;
engine.ShowAvatars = showAvatars;
engine.Begin();
engine.SetFastQuit(prefs.Get("FastQuit", true));
engine.TouchUI = prefs.Get("TouchUI", DEFAULT_TOUCH_UI);
engine.windowFrameOps = windowFrameOps;
SDLOpen();
if (Client::Ref().IsFirstRun() && FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsNone)
{
auto guessed = GuessBestScale();
if (engine.windowFrameOps.scale != guessed)
{
engine.windowFrameOps.scale = guessed;
prefs.Set("Scale", windowFrameOps.scale);
showLargeScreenDialog = true;
}
}
bool enableBluescreen = USE_BLUESCREEN && !true_arg(arguments["disable-bluescreen"]);
if (enableBluescreen)
{
//Get ready to catch any dodgy errors
for (auto *msg = signalMessages; msg->message; ++msg)
{
signal(msg->sig, SigHandler);
}
std::set_terminate(TerminateHandler);
}
if constexpr (X86)
{
X86KillDenormals();
}
explicitSingletons->simulationData = std::make_unique<SimulationData>();
explicitSingletons->gameController = std::make_unique<GameController>();
auto *gameController = explicitSingletons->gameController.get();
engine.ShowWindow(gameController->GetView());
auto openArg = arguments["open"];
if (openArg.has_value())
{
if constexpr (DEBUG)
{
std::cout << "Loading " << openArg.value() << std::endl;
}
if (Platform::FileExists(openArg.value()))
{
try
{
std::vector<char> gameSaveData;
if (!Platform::ReadFile(gameSaveData, openArg.value()))
{
new ErrorMessage("Error", "Could not read file");
}
else
{
auto newFile = std::make_unique<SaveFile>(openArg.value());
auto newSave = std::make_unique<GameSave>(std::move(gameSaveData));
newFile->SetGameSave(std::move(newSave));
gameController->LoadSaveFile(std::move(newFile));
}
}
catch (std::exception & e)
{
new ErrorMessage("Error", "Could not open save file:\n" + ByteString(e.what()).FromUtf8()) ;
}
}
else
{
new ErrorMessage("Error", "Could not open file");
}
}
auto ptsaveArg = arguments["ptsave"];
if (ptsaveArg.has_value())
{
engine.g->Clear();
engine.g->DrawRect(RectSized(engine.g->Size() / 2 - Vec2(100, 25), Vec2(200, 50)), 0xB4B4B4_rgb);
String loadingText = "Loading save...";
engine.g->BlendText(engine.g->Size() / 2 - Vec2((Graphics::TextSize(loadingText).X - 1) / 2, 5), loadingText, style::Colour::InformationTitle);
blit(engine.g->Data());
try
{
ByteString saveIdPart;
if (ByteString::Split split = ptsaveArg.value().SplitBy(':'))
{
if (split.Before() != "ptsave")
throw std::runtime_error("Not a ptsave link");
saveIdPart = split.After().SplitBy('#').Before();
}
else
throw std::runtime_error("Invalid save link");
if (!saveIdPart.size())
throw std::runtime_error("No Save ID");
if constexpr (DEBUG)
{
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
}
ByteString saveHistoryPart = "0";
if (auto split = saveIdPart.SplitBy('@'))
{
saveHistoryPart = split.After();
saveIdPart = split.Before();
}
int saveId = saveIdPart.ToNumber<int>();
int saveHistory = saveHistoryPart.ToNumber<int>();
gameController->OpenSavePreview(saveId, saveHistory, savePreviewUrl);
}
catch (std::exception & e)
{
new ErrorMessage("Error", ByteString(e.what()).FromUtf8());
Platform::MarkPresentable();
}
}
else
{
Platform::MarkPresentable();
}
MainLoop();
Platform::Exit(0);
return 0;
}

View File

@ -1,88 +0,0 @@
#include "PowderToySDL.h"
#include "graphics/Graphics.h"
#include "common/platform/Platform.h"
#include "common/tpt-rand.h"
#include "gui/font/FontEditor.h"
#include "gui/interface/Engine.h"
#include "Config.h"
#include "SimulationConfig.h"
#include <iostream>
#include <memory>
void LoadWindowPosition()
{
}
void SaveWindowPosition()
{
}
void LargeScreenDialog()
{
}
void TickClient()
{
}
struct ExplicitSingletons
{
// These need to be listed in the order they are populated in main.
std::unique_ptr<ui::Engine> engine;
};
static std::unique_ptr<ExplicitSingletons> explicitSingletons;
int main(int argc, char * argv[])
{
Platform::SetupCrt();
Platform::Atexit([]() {
SDLClose();
explicitSingletons.reset();
});
explicitSingletons = std::make_unique<ExplicitSingletons>();
WindowFrameOps windowFrameOps;
if (argc >= 3)
{
std::istringstream ss(argv[2]);
int buf;
if (ss >> buf)
{
windowFrameOps.scale = buf;
}
}
// TODO: maybe bind the maximum allowed scale to screen size somehow
if (windowFrameOps.scale < 1 || windowFrameOps.scale > 10)
{
windowFrameOps.scale = 1;
}
explicitSingletons->engine = std::make_unique<ui::Engine>();
auto &engine = ui::Engine::Ref();
engine.g = new Graphics();
engine.windowFrameOps = windowFrameOps;
SDLOpen();
engine.Begin();
engine.SetFastQuit(true);
if (argc >= 2)
{
engine.ShowWindow(new FontEditor(argv[1]));
}
else
{
std::cerr << "path to font.bz2 not supplied" << std::endl;
Platform::Exit(1);
}
while (engine.Running())
{
EngineProcess();
}
Platform::Exit(0);
return 0;
}

View File

@ -1,78 +0,0 @@
#include "graphics/Graphics.h"
#include "graphics/Renderer.h"
#include "common/String.h"
#include "common/tpt-rand.h"
#include "Format.h"
#include "gui/interface/Engine.h"
#include "client/GameSave.h"
#include "simulation/Simulation.h"
#include "simulation/SimulationData.h"
#include "common/platform/Platform.h"
#include <ctime>
#include <iostream>
#include <fstream>
#include <vector>
int main(int argc, char *argv[])
{
if (!argv[1] || !argv[2]) {
std::cout << "Usage: " << argv[0] << " <inputFilename> <outputPrefix>" << std::endl;
return 1;
}
auto inputFilename = ByteString(argv[1]);
auto outputFilename = ByteString(argv[2]) + ".png";
auto simulationData = std::make_unique<SimulationData>();
std::vector<char> fileData;
if (!Platform::ReadFile(fileData, inputFilename))
{
return 1;
}
std::unique_ptr<GameSave> gameSave;
try
{
gameSave = std::make_unique<GameSave>(fileData, false);
}
catch (ParseException &e)
{
//Render the save again later or something? I don't know
if (ByteString(e.what()).FromUtf8() == "Save from newer version")
throw e;
}
Simulation * sim = new Simulation();
Renderer * ren = new Renderer(sim);
if (gameSave)
{
sim->Load(gameSave.get(), true, { 0, 0 });
//Render save
ren->decorations_enable = true;
ren->blackDecorations = true;
int frame = 15;
while(frame)
{
frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen();
}
}
else
{
ren->clearScreen();
int w = Graphics::TextSize("Save file invalid").X + 15, x = (XRES-w)/2, y = (YRES-24)/2;
ren->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w, 24 }), 0xC0C0C0_rgb);
ren->BlendText({ x+8, y+8 }, "Save file invalid", 0xC0C0F0_rgb .WithAlpha(255));
}
ren->RenderBegin();
ren->RenderEnd();
if (auto data = ren->DumpFrame().ToPNG())
Platform::WriteFile(*data, outputFilename);
}

View File

@ -1,446 +0,0 @@
#include "PowderToySDL.h"
#include "SimulationConfig.h"
#include "WindowIcon.h"
#include "Config.h"
#include "gui/interface/Engine.h"
#include "graphics/Graphics.h"
#include "common/platform/Platform.h"
#include "common/clipboard/Clipboard.h"
#include <iostream>
int desktopWidth = 1280;
int desktopHeight = 1024;
SDL_Window *sdl_window = NULL;
SDL_Renderer *sdl_renderer = NULL;
SDL_Texture *sdl_texture = NULL;
bool vsyncHint = false;
WindowFrameOps currentFrameOps;
bool momentumScroll = true;
bool showAvatars = true;
uint64_t lastTick = 0;
uint64_t lastFpsUpdate = 0;
bool showLargeScreenDialog = false;
int mousex = 0;
int mousey = 0;
int mouseButton = 0;
bool mouseDown = false;
bool calculatedInitialMouse = false;
bool hasMouseMoved = false;
double correctedFrameTimeAvg = 0;
uint64_t drawingTimer = 0;
uint64_t frameStart = 0;
uint64_t oldFrameStart = 0;
void StartTextInput()
{
SDL_StartTextInput();
}
void StopTextInput()
{
SDL_StopTextInput();
}
void SetTextInputRect(int x, int y, int w, int h)
{
// Why does SDL_SetTextInputRect not take logical coordinates???
SDL_Rect rect;
#if SDL_VERSION_ATLEAST(2, 0, 18)
int wx, wy, wwx, why;
SDL_RenderLogicalToWindow(sdl_renderer, float(x), float(y), &wx, &wy);
SDL_RenderLogicalToWindow(sdl_renderer, float(x + w), float(y + h), &wwx, &why);
rect.x = wx;
rect.y = wy;
rect.w = wwx - wx;
rect.h = why - wy;
#else
// TODO: use SDL_RenderLogicalToWindow when ubuntu deigns to update to sdl 2.0.18
auto scale = ui::Engine::Ref().windowFrameOps.scale;
rect.x = x * scale;
rect.y = y * scale;
rect.w = w * scale;
rect.h = h * scale;
#endif
SDL_SetTextInputRect(&rect);
}
void ClipboardPush(ByteString text)
{
SDL_SetClipboardText(text.c_str());
}
ByteString ClipboardPull()
{
return ByteString(SDL_GetClipboardText());
}
int GetModifiers()
{
return SDL_GetModState();
}
unsigned int GetTicks()
{
return SDL_GetTicks();
}
static void CalculateMousePosition(int *x, int *y)
{
int globalMx, globalMy;
SDL_GetGlobalMouseState(&globalMx, &globalMy);
int windowX, windowY;
SDL_GetWindowPosition(sdl_window, &windowX, &windowY);
if (x)
*x = (globalMx - windowX) / currentFrameOps.scale;
if (y)
*y = (globalMy - windowY) / currentFrameOps.scale;
}
void blit(pixel *vid)
{
SDL_UpdateTexture(sdl_texture, NULL, vid, WINDOWW * sizeof (Uint32));
// need to clear the renderer if there are black edges (fullscreen, or resizable window)
if (currentFrameOps.fullscreen || currentFrameOps.resizable)
SDL_RenderClear(sdl_renderer);
SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
SDL_RenderPresent(sdl_renderer);
}
void SDLOpen()
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, "Initializing SDL (video subsystem): %s\n", SDL_GetError());
Platform::Exit(-1);
}
Clipboard::Init();
SDLSetScreen();
int displayIndex = SDL_GetWindowDisplayIndex(sdl_window);
if (displayIndex >= 0)
{
SDL_Rect rect;
if (!SDL_GetDisplayUsableBounds(displayIndex, &rect))
{
desktopWidth = rect.w;
desktopHeight = rect.h;
}
}
StopTextInput();
}
void SDLClose()
{
if (SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_OPENGL)
{
// * nvidia-460 egl registers callbacks with x11 that end up being called
// after egl is unloaded unless we grab it here and release it after
// sdl closes the display. this is an nvidia driver weirdness but
// technically an sdl bug. glfw has this fixed:
// https://github.com/glfw/glfw/commit/9e6c0c747be838d1f3dc38c2924a47a42416c081
SDL_GL_LoadLibrary(NULL);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_GL_UnloadLibrary();
}
SDL_Quit();
}
void SDLSetScreen()
{
auto newFrameOps = ui::Engine::Ref().windowFrameOps;
auto newVsyncHint = std::holds_alternative<FpsLimitVsync>(ui::Engine::Ref().GetFpsLimit());
if (FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsEmbedded)
{
newFrameOps.resizable = false;
newFrameOps.fullscreen = false;
newFrameOps.changeResolution = false;
newFrameOps.forceIntegerScaling = false;
}
if (FORCE_WINDOW_FRAME_OPS == forceWindowFrameOpsHandheld)
{
newFrameOps.resizable = false;
newFrameOps.fullscreen = true;
newFrameOps.changeResolution = false;
newFrameOps.forceIntegerScaling = false;
}
auto currentFrameOpsNorm = currentFrameOps.Normalize();
auto newFrameOpsNorm = newFrameOps.Normalize();
auto recreate = !sdl_window ||
// Recreate the window when toggling fullscreen, due to occasional issues
newFrameOpsNorm.fullscreen != currentFrameOpsNorm.fullscreen ||
// Also recreate it when enabling resizable windows, to fix bugs on windows,
// see https://github.com/jacob1/The-Powder-Toy/issues/24
newFrameOpsNorm.resizable != currentFrameOpsNorm.resizable ||
newFrameOpsNorm.changeResolution != currentFrameOpsNorm.changeResolution ||
newFrameOpsNorm.blurryScaling != currentFrameOpsNorm.blurryScaling ||
newVsyncHint != vsyncHint;
if (!(recreate ||
newFrameOpsNorm.scale != currentFrameOpsNorm.scale ||
newFrameOpsNorm.forceIntegerScaling != currentFrameOpsNorm.forceIntegerScaling))
{
return;
}
auto size = WINDOW * newFrameOpsNorm.scale;
if (sdl_window && newFrameOpsNorm.resizable)
{
SDL_GetWindowSize(sdl_window, &size.X, &size.Y);
}
if (recreate)
{
if (sdl_texture)
{
SDL_DestroyTexture(sdl_texture);
sdl_texture = NULL;
}
if (sdl_renderer)
{
SDL_DestroyRenderer(sdl_renderer);
sdl_renderer = NULL;
}
if (sdl_window)
{
SaveWindowPosition();
SDL_DestroyWindow(sdl_window);
sdl_window = NULL;
}
unsigned int flags = 0;
unsigned int rendererFlags = 0;
if (newFrameOpsNorm.fullscreen)
{
flags = newFrameOpsNorm.changeResolution ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP;
}
if (newFrameOpsNorm.resizable)
{
flags |= SDL_WINDOW_RESIZABLE;
}
if (vsyncHint)
{
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
}
sdl_window = SDL_CreateWindow(APPNAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, size.X, size.Y, flags);
if (!sdl_window)
{
fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError());
Platform::Exit(-1);
}
if constexpr (SET_WINDOW_ICON)
{
WindowIcon(sdl_window);
}
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, newFrameOpsNorm.blurryScaling ? "linear" : "nearest");
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, rendererFlags);
if (!sdl_renderer)
{
fprintf(stderr, "SDL_CreateRenderer failed; available renderers:\n");
int num = SDL_GetNumRenderDrivers();
for (int i = 0; i < num; ++i)
{
SDL_RendererInfo info;
SDL_GetRenderDriverInfo(i, &info);
fprintf(stderr, " - %s\n", info.name);
}
Platform::Exit(-1);
}
SDL_RenderSetLogicalSize(sdl_renderer, WINDOWW, WINDOWH);
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, WINDOWW, WINDOWH);
if (!sdl_texture)
{
fprintf(stderr, "SDL_CreateTexture failed: %s\n", SDL_GetError());
Platform::Exit(-1);
}
SDL_RaiseWindow(sdl_window);
Clipboard::RecreateWindow();
}
SDL_RenderSetIntegerScale(sdl_renderer, newFrameOpsNorm.forceIntegerScaling ? SDL_TRUE : SDL_FALSE);
if (!(newFrameOpsNorm.resizable && SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_MAXIMIZED))
{
SDL_SetWindowSize(sdl_window, size.X, size.Y);
LoadWindowPosition();
}
UpdateFpsLimit();
if (newFrameOpsNorm.fullscreen)
{
SDL_RaiseWindow(sdl_window);
}
currentFrameOps = newFrameOps;
vsyncHint = newVsyncHint;
}
static void EventProcess(const SDL_Event &event)
{
auto &engine = ui::Engine::Ref();
switch (event.type)
{
case SDL_QUIT:
if (ALLOW_QUIT && (engine.GetFastQuit() || engine.CloseWindow()))
{
engine.Exit();
}
break;
case SDL_KEYDOWN:
if (SDL_GetModState() & KMOD_GUI)
{
break;
}
if (ALLOW_QUIT && !event.key.repeat && event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL))
engine.ConfirmExit();
else
engine.onKeyPress(event.key.keysym.sym, event.key.keysym.scancode, event.key.repeat, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
break;
case SDL_KEYUP:
if (SDL_GetModState() & KMOD_GUI)
{
break;
}
engine.onKeyRelease(event.key.keysym.sym, event.key.keysym.scancode, event.key.repeat, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
break;
case SDL_TEXTINPUT:
if (SDL_GetModState() & KMOD_GUI)
{
break;
}
engine.onTextInput(ByteString(event.text.text).FromUtf8());
break;
case SDL_TEXTEDITING:
if (SDL_GetModState() & KMOD_GUI)
{
break;
}
engine.onTextEditing(ByteString(event.edit.text).FromUtf8(), event.edit.start);
break;
case SDL_MOUSEWHEEL:
{
// int x = event.wheel.x;
int y = event.wheel.y;
if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED)
{
// x *= -1;
y *= -1;
}
engine.onMouseWheel(mousex, mousey, y); // TODO: pass x?
break;
}
case SDL_MOUSEMOTION:
mousex = event.motion.x;
mousey = event.motion.y;
engine.onMouseMove(mousex, mousey);
hasMouseMoved = true;
break;
case SDL_DROPFILE:
engine.onFileDrop(event.drop.file);
SDL_free(event.drop.file);
break;
case SDL_MOUSEBUTTONDOWN:
// if mouse hasn't moved yet, sdl will send 0,0. We don't want that
if (hasMouseMoved)
{
mousex = event.button.x;
mousey = event.button.y;
}
mouseButton = event.button.button;
engine.onMouseDown(mousex, mousey, mouseButton);
mouseDown = true;
if constexpr (!DEBUG)
{
SDL_CaptureMouse(SDL_TRUE);
}
break;
case SDL_MOUSEBUTTONUP:
// if mouse hasn't moved yet, sdl will send 0,0. We don't want that
if (hasMouseMoved)
{
mousex = event.button.x;
mousey = event.button.y;
}
mouseButton = event.button.button;
engine.onMouseUp(mousex, mousey, mouseButton);
mouseDown = false;
if constexpr (!DEBUG)
{
SDL_CaptureMouse(SDL_FALSE);
}
break;
case SDL_WINDOWEVENT:
{
switch (event.window.event)
{
case SDL_WINDOWEVENT_SHOWN:
if (!calculatedInitialMouse)
{
//initial mouse coords, sdl won't tell us this if mouse hasn't moved
CalculateMousePosition(&mousex, &mousey);
engine.initialMouse(mousex, mousey);
engine.onMouseMove(mousex, mousey);
calculatedInitialMouse = true;
}
break;
}
break;
}
}
}
void EngineProcess()
{
auto &engine = ui::Engine::Ref();
auto correctedFrameTime = frameStart - oldFrameStart;
drawingTimer += correctedFrameTime;
correctedFrameTimeAvg = correctedFrameTimeAvg + (correctedFrameTime - correctedFrameTimeAvg) * 0.05;
if (correctedFrameTime && frameStart - lastFpsUpdate > UINT64_C(200'000'000))
{
engine.SetFps(1e9f / correctedFrameTimeAvg);
lastFpsUpdate = frameStart;
}
if (frameStart - lastTick > UINT64_C(100'000'000))
{
lastTick = frameStart;
TickClient();
}
if (showLargeScreenDialog)
{
showLargeScreenDialog = false;
LargeScreenDialog();
}
SDL_Event event;
while (SDL_PollEvent(&event))
{
EventProcess(event);
}
engine.Tick();
auto fpsLimit = ui::Engine::Ref().GetFpsLimit();
int drawcap = ui::Engine::Ref().GetDrawingFrequencyLimit();
if (!drawcap || drawingTimer > 1e9f / drawcap)
{
engine.Draw();
drawingTimer = 0;
SDLSetScreen();
blit(engine.g->Data());
}
auto now = uint64_t(SDL_GetTicks()) * UINT64_C(1'000'000);
oldFrameStart = frameStart;
frameStart = now;
if (auto *fpsLimitExplicit = std::get_if<FpsLimitExplicit>(&fpsLimit))
{
auto timeBlockDuration = uint64_t(UINT64_C(1'000'000'000) / fpsLimitExplicit->value);
auto oldFrameStartTimeBlock = oldFrameStart / timeBlockDuration;
auto frameStartTimeBlock = oldFrameStartTimeBlock + 1U;
frameStart = std::max(frameStart, frameStartTimeBlock * timeBlockDuration);
SDL_Delay((frameStart - now) / UINT64_C(1'000'000));
}
}

View File

@ -1,45 +0,0 @@
#pragma once
#include "common/String.h"
#include "graphics/Pixel.h"
#include "gui/WindowFrameOps.h"
#include "FpsLimit.h"
#include <cstdint>
#include <SDL.h>
#include <variant>
extern int desktopWidth;
extern int desktopHeight;
extern SDL_Window *sdl_window;
extern SDL_Renderer *sdl_renderer;
extern SDL_Texture *sdl_texture;
extern bool momentumScroll;
extern bool showAvatars;
extern uint64_t lastTick;
extern uint64_t lastFpsUpdate;
extern bool showLargeScreenDialog;
extern int mousex;
extern int mousey;
extern int mouseButton;
extern bool mouseDown;
extern bool calculatedInitialMouse;
extern bool hasMouseMoved;
void MainLoop();
void EngineProcess();
void StartTextInput();
void StopTextInput();
void SetTextInputRect(int x, int y, int w, int h);
void ClipboardPush(ByteString text);
ByteString ClipboardPull();
int GetModifiers();
unsigned int GetTicks();
void blit(pixel *vid);
void SDLOpen();
void SDLClose();
void SDLSetScreen();
void SetFpsLimit(FpsLimit newFpsLimit);
void LoadWindowPosition();
void SaveWindowPosition();
void LargeScreenDialog();
void TickClient();
void UpdateFpsLimit();

View File

@ -1,18 +0,0 @@
#include "PowderToySDL.h"
#include "gui/interface/Engine.h"
void MainLoop()
{
while (ui::Engine::Ref().Running())
{
EngineProcess();
}
}
void SetFpsLimit(FpsLimit newFpsLimit)
{
}
void UpdateFpsLimit()
{
}

View File

@ -1,52 +0,0 @@
#include "PowderToySDL.h"
#include "gui/interface/Engine.h"
#include <emscripten.h>
#include <iostream>
namespace Platform
{
void MaybeTriggerSyncFs();
}
static void MainLoopBody()
{
EngineProcess();
Platform::MaybeTriggerSyncFs();
}
void SetFpsLimit(FpsLimit newFpsLimit)
{
static bool mainLoopSet = false;
if (!mainLoopSet)
{
emscripten_set_main_loop(MainLoopBody, 0, 0);
mainLoopSet = true;
}
if (auto *fpsLimitVsync = std::get_if<FpsLimitVsync>(&newFpsLimit))
{
emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
std::cerr << "implicit fps limit via vsync" << std::endl;
}
else
{
auto delay = 0;
if (auto *fpsLimitExplicit = std::get_if<FpsLimitExplicit>(&newFpsLimit))
{
delay = int(1000.f / fpsLimitExplicit->value);
}
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
std::cerr << "explicit fps limit: " << delay << "ms delays" << std::endl;
}
}
void UpdateFpsLimit()
{
SetFpsLimit(ui::Engine::Ref().GetFpsLimit());
}
// Is actually only called once at startup, the real main loop body is MainLoopBody.
void MainLoop()
{
UpdateFpsLimit();
MainLoopBody();
}

Some files were not shown because too many files have changed in this diff Show More