Updates to enhance GitHub Actions continuous integration:
* ci: add macOS app bundle packaging using cargo-bundle, closes#352
based on https://github.com/EndlessSkyCommunity/ESLauncher2/blob/master/Cargo.toml
* ci: add web target, building using wasm-pack (for #446)
* ci: refactor and cleanup targets, split out instead of using matrix
* main: save config in consistent OS-specific dirs::config_dir()
Instead of storing and loading in the current working directory, change
to a consistent dedicated configuration directory. This is necessary for
.app launching since cwd is set to /. To preserve compatibility with
existing installations, if conf.cfg exists in cwd then it will be used instead,
but otherwise we will use the operating system specific config dirs:
// Lin: Some(/home/alice/.config)
// Win: Some(C:\Users\Alice\AppData\Roaming)
// Mac: Some(/Users/Alice/Library/Application Support)
* macos: add icons based on screenshotted logo
* macos: add Cmd-Q to quit
* Add getrandom with js feature for JavaScript web compatibility
* Update to rand 0.8.0, closes#440
* Update to rand_pcg 0.3.0, closes#434
* Update rsa_public_encrypt_pkcs1 to 0.3.0, updates rand 0.8.0
Replace std::time with the `instant` crate, which bridges to std::time on
native but on wasm calls performance.now() instead of panicking.
A step towards 🕸️ Web support #446
* logo: replace SystemTime/UNIX_EPOCH with Instant
Steven used multisampled textures from the beginning, but this caused
incompatibilities: https://github.com/Thinkofname/steven/issues/74.
Subsequently fixed by increasing the number of samples, but increasing
it beyond the limit caused more incompatibilities, so it was clamped to
the maximum samples reported as supported by the system.
Fast-forward to now, as part of adding WebGL support (#446), the use of
multisampled textures via the glTexImage2DMultisample() call is
unsupported on this platform. Replace the following:
* glTexImage2DMultisample -> glTexImage2D
* TEXTURE_2D_MULTISAMPLE -> TEXTURE_2D
* sampler2DMS -> sampler2D
This disables the custom multisampling anti-aliasing algorithm (MSAA)
implemented in the chunk fragment shader, increasing compatibility:
* Update to glow release, remove image_2d_sample()
MSAA may be added back at a later date using multisampled renderbuffers
instead, see #442.
A small step for #446🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes#171 could not find Context in platform_impl.
winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.
Substantial refactoring to allow reusing the code between web/native:
* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads
* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper
* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2
* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL
* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook, mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web
* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446🕸️ Web support
Replaces the use of gl_generator with the glow wrapper:
* Add glow dependency, based on glow 0.6.1
* Pin version of glow fork for https://github.com/iceiix/glow/pull/1 until #442 renderbuffer
* Remove gl module, steven_gl
Porting details:
* Initialize glow in src/gl/mod.rs
* Call gl methods on glow context
* glow uses camelcase
* Import glow::HasContext trait, finds draw_elements etc.
* Fix mismatched types, glow uses Option and &str instead of raw pointers
* Fix uniform_location, glow already returns Some(u32)
* uniform_location: convert i32 to u32 for Uniform
* Fix attribute_location
* Fix shader creation Result u32 type
* Fix passing GLvoid and 2d/3d
* Fix missing Options type mismatches
* Offsets are i32 in glow, not GLvoid
* Fix clear_buffer using _f32_slice
* Delete methods are singular not plural
* glBufferData -> buffer_data_u8_slice
* buffer_sub_data_u8_slice
* Update more glow method wrapper names found by reviewing glow native platform
* Remove unused multi_draw_elements, can be replaced by draw_elements in a loop and it has no WebGL equivalent
* glow implements glMapBufferRange
* Remove unused read_buffer
* glow's deletes automatically pass 1 and take no reference
* shader_source() accepts &str directly; removes last of std::ptr
* Pass uniform Option<u32>
* Fix bool passing normalized parameter
* Fix draw_buffers parameter
* Stop unnecessarily returning context from gl::init
* Getting shader info is unsafe
* Unwrapping static mut is unsafe
* Use unsafe raw pointers for global mutable context
* Fix initializing GL objects wrappers from glow wrappers
* Unbinding framebuffers uses None
* Uppercase global to fix warning
* Shaders return Some instead of None
* Unbox the context to a raw pointer
* Use tex_image_2d_multisample added in glow fork
* Implement uniform_location, fixing unwrap None failed
* Add tex_sub_image_3d, using PixelUnpackData::Slice
* set_matrix4: transmute the Matrix4 since it is repr(C)
* get_pixels -> get_tex_image -> glGetTexImage, with PixelPackData::Slice
* Wrap sub_image_2d (glTexSubImage2D) and fix warnings
* Implement set_float_multi_raw and set_matrix4_multi, using from_raw_parts
* Update for ModifiersChanged event
* Consistently use logical position and size
CursorMoved gives us a PhysicalPosition, which needs to be converted
to LogicalPosition to properly track the mouse movement. Change the
width/height passed to be a LogicalSize instead of a PhysicalPosition,
matching the LogicalPosition.
Closes#425 build(deps): bump wasm-bindgen from 0.2.68 to 0.2.69
Closes#426 build(deps): bump structopt from 0.3.20 to 0.3.21
Closes#427 build(deps): bump serde_json from 1.0.59 to 1.0.60
Closes#428 build(deps): bump serde from 1.0.117 to 1.0.118
Closes#433 build(deps): bump reqwest from 0.10.9 to 0.10.10
Bump cfg-if to 1.0.0 (closes#412)
Bump serde to 1.0.117 (closes#416)
Bump serde_json to 1.0.59 (closes#413)
Bump structopt to 0.3.20 (closes#414)
Bump flate2 to 1.0.19 (closes#420)
Bump reqwest to 0.10.9 (closes#423)
Closes#372 bump log from 0.4.8 to 0.4.11
Closes#387 bump reqwest from 0.10.6 to 0.10.8
Closes#391 bump wasm-bindgen from 0.2.64 to 0.2.68
Closes#403 bump serde_json from 1.0.56 to 1.0.58
Closes#405 bump flate2 from 1.0.16 to 1.0.18
Closes#409 bump structopt from 0.3.15 to 0.3.19
Bump flate2 to 1.0.16, closes#350
Bump serde_json to 1.0.56, closes#349
Bump wasm-bindgen to 0.2.64, closes#348
gl: Bump libc to 0.2.71
protocol: Bump hex to 0.4.2
protocol: Bump aes to 0.4.0
protocol: Bump cfb8 to 0.4.0
protocol: Bump num-traits to 0.2.12
Thanks to @mwkroening (#317) and @martijnberger (#323) for helping fix this update.
* Update to glutin 0.22.0 and winit 0.20.0 release, removing alpha pinning
* scale_factor() replaces hidpi_factor()
* Listen for ScaleFactorChanged, separate from Resized event
* Fix getting physical size of window
* Fix logical mouse event coordinates
Update to structopt 0.3.15, closes#330
Update to base64 0.12.2, closes#329
Update to zip 0.5.6, closes#328
Update to serde_json 1.0.55, closes#327
Update to reqwest 0.10.6, closes#321
Update to flate2 1.0.14, closes#303
Update to byteorder 1.3.4, closes#285
The git dependency was only for wasm32-unknown-emscripten support:
https://github.com/aweinstock314/rust-clipboard/pull/62
but #92 changes to using wasm32-unknown-unknown instead, a better
supported path (though still incomplete in this project, see #171)
Closes#276 Bump serde_json from 1.0.44 to 1.0.45
Closes#274 Bump structopt from 0.3.7 to 0.3.8
Closes#273 Bump image from 0.22.3 to 0.22.4
Closes#272 Bump rand from 0.7.2 to 0.7.3
Closes#270 Bump num-traits from 0.2.10 to 0.2.11
Closes#269 Bump reqwest from 0.10.0 to 0.10.1
Completes the move of the protocol implementation into a new
crate, named steven_protocol, in the protocol/ subdirectory.
* Add Cargo.toml for steven_protocol
* Add steven_protocol entrypoint in protocol/src/lib.rs
* Use steven_protocol in main
* Remove protocol in main, replaced by steven_protocol
* Remove unused dependencies moved into steven_protocol
Improves fix for #184, whereas #255 reduced optimizations,
we now address the underlying compiler limitation and split out
the one massive lazy_static! initialization function, into
one function per block in the block_registration_functions module.
Previous build time, with opt-level=1:
% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 21.24s
cargo build --release 31.80s user 0.71s system 152% cpu 21.276 total
With this change, opt-level=3 and the function splitting fix:
% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 30.80s
cargo build --release 40.26s user 0.86s system 133% cpu 30.850 total
Full optimizations are expectedly slightly slower, but this is still
much much _much_ faster than before this refactoring, where this crate
would take up to an unbelievable 5 hours (and tens of GB of RAM). Long
story short, we're now back to full optimizations and stable Rust.
Thanks to dtolnay on the Rust programming language forum for suggesting
this technique, https://users.rust-lang.org/t/5-hours-to-compile-macro-what-can-i-do/36508/2
Update from glutin 0.21.x fork to glutin 0.22.0-alpha5 and corresponding
compatible version of winit. This removes our custom temporary wasm_stub
branches, back to mainline glutin and winit, and is a step towards WebAssembly
compatibility, most importantly merging the game loop and event loops as
required by winit _which now supports wasm_. Not yet functional on the web
because other web dependencies have to be added, see #171 and #34, but native
functionality is preserved.
* Update for 0.22 glutin API changes:
* Move game logic into event loop, run() replacing poll_events()
* Specify fullscreen Borderless mode
* Pass generic parameter of Event through handle_window_event
* hidpi_factor() replaces get_hidpi_factor()
* with_inner_size() replaces with_dimensions()
* No longer need to unwrap() LogicalSize
* set_cursor_grab/visible() replaces grab/hide_cursor()
* Fix modifiers deprecated warnings by destructuring only event fields we use, ignoring the rest with '..'
* Remove unnecessary mutability from events_loop
* Listen for ModifiersChanged event, fixing deprecated modifiers field
* Change to stdweb for web backend, replacing web-sys
* Pin to glutin =0.22.0-alpha5 and winit =0.20.0-alpha6
* Closes#237 Bump base64 from 0.10.1 to 0.11.0
* Closes#241 Bump flate2 from 1.0.12 to 1.0.13
* Closes#245 Bump num-traits from 0.2.8 to 0.2.10
* Closes#248 Bump serde_json from 1.0.41 to 1.0.44
* Closes#249 Bump serde from 1.0.102 to 1.0.104
* Closes#251 Bump web-sys from 0.3.30 to 0.3.33
* Closes#254 Bump structopt from 0.3.3 to 0.3.7
* Bump cfg-if from 0.1.9 to 0.1.10
* `cargo update` all modules
Reduce to "basic optimizations" for the steven_blocks module, so it
doesn't take hours of time and gigabytes of memory to compile. The main
program and other code still builds with full optimizations in release
mode, to accomplish this, the profile-overrides feature is required so
we also switch to nightly Rust (to be switched to 1.41+ in #258).
* Update to rustc 1.42.0-nightly (760ce94c6 2020-01-04)
* Update builds.sr.ht to use +nightly
* Override opt-level=1 for steven_blocks using profile-overrides
Closes#196 Bump web-sys from 0.3.24 to 0.3.25
Closes#200 Bump reqwest from 0.9.18 to 0.9.19
Closes#202 Bump log from 0.4.6 to 0.4.8
Closes#203 Bump serde from 1.0.94 to 1.0.98
Closes#187 Bump web-sys from 0.3.22 to 0.3.24
Closes#188 Bump flate2 from 1.0.7 to 1.0.9
Closes#189 Bump structopt from 0.2.16 to 0.2.18
Closes#190 Bump serde from 1.0.92 to 1.0.94
Closes#192 Bump serde_json from 1.0.39 to 1.0.40
`cargo update` updates smallvec (and others) used by collision:
Closes#193 [Security] Bump smallvec from 0.6.9 to 0.6.10
Logging from the `log` facade goes to the colorized in-game GUI console (opened with the backtick key), as well as standard output using `println!` on the native build. To make this work on the wasm build, web-sys is used to access the `console` object, to call `console.log`, `console.warn`, and so on corresponding to the log levels. Extends #92, fails later (see also #115) but now outputs the starting up message:
[main.rs:206][INFO] Starting steven
* Add println! logging to console.log on wasm
* Initialize logger before config (called 'console variables' for some reason) to avoid having to disable it to reach the first logging statement
* Add web-sys crate for browser console access, wasm32-only
* Refactor logger to call println_level on both web/native
* Add multiple log levels, console.warn etc., matching console_log crate
https://github.com/iamcodemaker/console_log#details
Updating the glutin dependency to a 0.21.0-based branch, based on the migration guide at:
https://gentz.rocks/posts/glutin-v0-21-0-migration-guide/
* Remove glutin::ContextTrait
* Create window with ContextBuilder instead of WindowedContext::new
* Add .window() accessor on WindowContext, since it now dereferences to Context
In order to not break wasm32-unknown-unknown compilation, a minor fork is used of glutin v0.21.0 and a corresponding version of winit: https://github.com/iceiix/glutin/pull/1https://github.com/iceiix/winit/pull/2
- with stubs to compile (but not run, see issue #115)
Movement packets were handled incorrectly, because although the fields are specified as integers they are actually fixed-point values, which need to be converted to floating-point before use. These fields were converted with `as f64`, but they actually need to be scaled. To fix this add several new types, FixedPoint5 for 5-bit fractional fixed-point and FixedPoint12 for 12-bit. Both are parameterized by an integer type: FixedPoint5<i32> and FixedPoint5<i8> for 1.7.10/1.8.9, FixedPoint12<i16> for 1.9+. This moves the calculation into the packet field parsing, so it no longer has to be calculated in src/server/mod.rs since the scaling is taken care of as part of the field type. This fixes the long-standing invisible or actually misplaced players bug on 1.7.10 and 1.8.9, closes#139.
* Add new FixedPoint5<T> type for 1.7/8, https://wiki.vg/Data_types#Fixed-point_numbers
* Add FixedPoint12<i16> for 1.9+, moving type conversion into packet type
https://wiki.vg/index.php?title=Protocol#Entity_Relative_Move
* Add num-traits 0.2.6 dependency for NumCast to use instead of From
* Use FixedPoint5<i32> in spawn object, experience orb, global entity, mob, player, teleport
* Use FixedPoint5<i8> and FixedPoint12<i16> in entity move, look and move
* Update packet handling bouncer functions, using f64::from for each conversion
* Add structopt dependency
* Add command-line --server argument to connect to server on startup
* Don't show login/server screen (which pings servers) when connecting to a server from command-line
Closes#116 Bump cfg-if from 0.1.6 to 0.1.7
Closes#120 Bump cfb8 from 0.3.1 to 0.3.2
Closes#122 Bump flate2 from 1.0.6 to 1.0.7
Closes#124 Bump serde from 1.0.89 to 1.0.90
Closes#127 Bump zip from 0.5.0 to 0.5.2
Note this only is the first step in web support, although the project compiles, it doesn't run!
Merging now to avoid branch divergence, until dependencies can be updated for wasm support.
* Add instructions to build for wasm32-unknown-unknown with wasm-pack in www/
* Update to rust-clipboard fork to compile with emscripten
https://github.com/aweinstock314/rust-clipboard/pull/62
* Exclude reqwest dependency in wasm32
* Exclude compiling clipboard pasting on wasm32
* Exclude reqwest-using code from wasm32
* Install wasm target with rustup in Travis CI
* Update to collision 0.19.0
Fixes wasm incompatibility in deprecated rustc-serialize crate: https://github.com/rustgd/collision-rs/issues/106
error[E0046]: not all trait items implemented, missing: `encode`
--> github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1358:1
* Increase travis_wait time even further, try 120 minutes
* Set RUST_BACKTRACE=1 in main
* Remove unused unneeded bzip2 features in zip crate
To fix wasm32-unknown-unknown target compile error:
error[E0432]: unresolved imports `libc::c_int`, `libc::c_uint`, `libc::c_void`, `libc::c_char`
--> src/github.com-1ecc6299db9ec823/bzip2-sys-0.1.7/lib.rs:5:12
|
5 | use libc::{c_int, c_uint, c_void, c_char};
| ^^^^^ ^^^^^^ ^^^^^^ ^^^^^^ no `c_char` in the root
| | | |
| | | no `c_void` in the root
| | no `c_uint` in the root
| no `c_int` in the root
* flate2 use Rust backend
* Add console_error_panic_hook module for wasm backtraces
* Build using wasm-pack, wasm-bindgen, run with wasm-app
* Update to miniz_oxide 0.2.1, remove patch for https://github.com/Frommi/miniz_oxide/issues/42
* Update to official clipboard crate since https://github.com/aweinstock314/rust-clipboard/pull/62 was merged, but git revision pending release
* Update to branch of glutin attempting to build for wasm
https://github.com/iceiix/glutin/pull/1
* Update winit dependency of glutin to git master
https://github.com/iceiix/winit/pull/2
* Update to glutin branch with working (compiles, doesn't run) wasm_stub
* Add app name in title on web page
* Add wasm to Travis-CI test matrix
* Update glutin to fix Windows EGL compilation on AppVeyor
97797352b5
Closes#100 Bump serde from 1.0.84 to 1.0.85
Closes#101 Bump serde_json from 1.0.36 to 1.0.37
Closes#102 Bump reqwest from 0.9.8 to 0.9.9
Closes#103 Bump base64 from 0.10.0 to 0.10.1