Commit Graph

150 Commits

Author SHA1 Message Date
iceiix 6ad43b3ccb
Merge pull request #731 from nathanruiz/digging
Add the ability to break blocks
2022-10-30 16:10:45 -07:00
Nathan Ruiz ddd9eb26e4 Fix formatting issues 2022-10-24 09:21:33 +00:00
Nathan Ruiz 700a31013f Add digging to ECS 2022-09-27 07:07:22 +00:00
iceiix fe8d8ece9c
Fix set_cursor_grab on Linux. Closes #714 (#717)
The glutin/winit update in #700 changed set_cursor_grab from a bool to
an enum, but always used CursorGrabMode::Locked, which is only available
on macOS. Conditionally compile to use CursorGrabMode::Confined otherwise.
Fixes #714 and fixes #713 

* set_cursor_grab failed with NotSupported(NotSupportedError) on Linux
Patch from https://github.com/iceiix/stevenarella/issues/714

* cargo fmt

Co-authored-by: inferno <inferrna@gmail.com>
2022-08-28 09:30:56 -07:00
iceiix ba3cf43f93
Update dependencies: glutin 0.29, winit 0.27, and more (#700)
* Update to glutin 0.29.0, winit 0.27.0. Closes #695
Change true/false to CursorGrabMode::Locked/None for set_cursor_grab
https://github.com/rust-windowing/winit/releases/tag/v0.27.0
> Breaking: Window::set_cursor_grab now accepts CursorGrabMode to control grabbing behavior.

* Update web-sys to 0.3.59. Closes #699

* Update flate2 to 1.0.24. Closes #698

* Update zip to 0.6.2. Closes #697

* Update to log 0.4.17. Closes #696
2022-07-30 15:54:49 -07:00
ice_iix c3edf715ef Fix clippy needless_borrow and unused_mut 2021-12-24 09:25:15 -08:00
ice_iix 47df12b5ee main: allow clippy::needless_borrow since it isn't needless for web 2021-08-01 06:25:57 -07:00
ice_iix 3d1bea85fe Fix clippy::needless_borrow 2021-08-01 06:19:48 -07:00
ice_iix 728367c59b Fix clippy::collapsible_match, collapse it 2021-06-18 19:32:26 -07:00
iceiix 63c9d81687
Update to glow 0.9.0. Closes #532 (#545) 2021-05-25 08:13:07 -07:00
ice_iix 995cf981c5 main: remove console chat activation, updates #479 2021-02-18 17:40:45 -08:00
iceiix 3e3bcdc5da
protocol, console, server: receive chat messages (#479)
Implements support for receiving chat messages from the server, the
first step towards #63 chat support. Long way to go, but is a start.

* server: handle ServerMessage_* packets, on_servermessage

* format: get the with arguments of translations
* format: hardcode chat types
* format: support bare strings, used in chat.type.text
* format: use extra text if present, fixes missing username on 1.16.5

* console/main/server: activate on receiving chat messages
2021-01-24 17:41:16 -08:00
iceiix 6b961622aa
forge: add FML2 protocol support (1.13.2-1.16.5+), fixes #400 (#494)
Allows connecting to newer Forge servers, 1.13.2 to 1.16.5 at least, which use
the FML2 handshake protocol:

https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29

Tested with a modded 1.16.5 server

Extends #88 #134 Forge FML (v1, for 1.7.10 - 1.12.2)

* protocol: update Cargo.lock
* protocol: send FML2 on fmlNetworkVersion: 2
* protocol: factor out read_raw_packet_from()
* protocol: move plugin message writing from Server to Conn; add write_fml2_handshake_plugin_message
* protocol: CommandNode: add forge:modid, forge:enum
* forge: add fml2 handshake packets
* server: handle fml:loginwrapper fml::handshake packets
2021-01-23 13:47:30 -08:00
iceiix 3daa9c0b83
console: configurable log levels, file logging (#359) (#488)
* console: write to log file (configdir/client.log)

* console: change to log only Info and more important to terminal (but all to file)

* console: configurable log levels
2021-01-20 15:22:28 -08:00
iceiix c7bdb60d85
CI enhancements: .app bundling, build .wasm (#486)
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
2021-01-18 19:05:29 -08:00
iceiix 0c65cc1e0d
ui: keyboard input fixes (#432, #476) (#477)
* Fix Cmd-V typing v, suppress key_type on ctrl/logo, closes #432
Only send key_type() when modifiers are not pressed.

* Fix backspace repeat and inserting ⌂, closes #476
Handle backspace in key_type instead of key_press, so we get
auto-repeat for free, and can suppress typing the character.
2021-01-16 14:11:17 -08:00
iceiix 8208e3b595
wasm: enable events loop (#459)
On the web, we have a separate render_loop (for window.requestAnimationFrame)
and events_loop (for winit/window events), so `game` and `ui_container` are shared
using an `Rc<RefCell>`, and `winit_window` as well for wasm only (on native,
`glutin_window` which provides access to the winit window is used instead).

With these changes, events (hover, click, etc.) and rendering now work in the web.
Another step towards 🕸️ Web support (#446)

* wasm: enable events loop

* Use Rc<RefCell>'s for winit_window

* Use Rc<RefCell> for game and ui_container

* main: disable set_cursor_grab() call on wasm to get further until Pointer Lock is available
2021-01-04 10:14:55 -08:00
iceiix 22f6c83d59
WebGL fixes after disabling threaded chunk builder (#451)
At this point, the UI renders in the browser through WebGL, with no GL errors.
Progress towards #446 🕸️ Web support

* main: enable render loop on wasm, disable events_loop on wasm for now
Allow for testing rendering on WebGL

* chunk_builder: disable on wasm due to no threads on wasm
Chunks will not be correctly rendered, but other parts of the program now can be tested instead of crashing in std::thread

* chunk_frag: glBindFragDataLocation is only on native, WebGL 2 uses in-shader specification layout(location=), which works on native in OpenGL 4.1 but we're on OpenGL 3.2 - see https://www.khronos.org/opengl/wiki/Fragment_Shader#Output_buffers

* std_or_web: always fail File::open() to avoid servers.json empty string JSON parse failing

* www: update installation instructions

* render: fix apparent TEXTURE_MAX_LEVEL -> TEXTURE_MAG_FILTER typo

* render: correct type for internalFormat DEPTH_COMPONENT24
Valid combinations of format, type, and internalFormat are listed at https://www.khronos.org/registry/OpenGL/specs/es/3.0/es_spec_3.0.pdf#page=124&zoom=100,168,206. We had UNSIGNED_BYTE for DEPTH_COMPONENT24, but only UNSIGNED_INT is a valid type for this internal format.

Fixes texImage: Mismatched internalFormat and format/type: 0x81a6 and 0x1902/0x1401
and fixes the subsequent GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error.

* render: gl::MULTISAMPLE (0x809d) is not available on WebGL
Fixes WebGL warning: enabled: cap: Invalid enum value <enum 0x809d> 0.bootstrap.js line 11 > eval:851:21

* gl: replace set_float_multi_raw with a safer set_float_multi
Removes use of passing raw pointers in set_float_multi_raw parameters
Instead, casts raw pointers to flatten, similar to set_matrix_multi
Fixes uniform setter: (uniform colorMul[0]) values length (1) must be a positive integer multiple of size of <enum 0x8b52>.

* render: model: send BYTE to id attrib, fixes type mismatch
Fixes drawElementsInstanced: Vertex attrib 0 requires data of type INT, but is being supplied with type UINT
2020-12-31 14:35:30 -08:00
iceiix 503a98d7a8
Use instant over std::time, for wasm compat (#449)
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
2020-12-27 15:06:03 -08:00
iceiix 0471eb3a82 Use web-sys for web backend (#444)
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
2020-12-26 13:43:21 -08:00
iceiix 9bc10c1100
Update to glutin 0.26.0 + winit 0.24.0 (#334)
* 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.
2020-12-20 08:18:39 -08:00
ice_iix 37f55e2c57 Add --network-parse-packet option 2020-12-19 15:32:19 -08:00
ice_iix 2e2c82eae4 Use if let pattern match to fix unnecessary_wrap 2020-07-02 17:14:49 -07:00
ice_iix c27425750d Change set_float_multi_raw to unsafe because it dereferences a raw pointer argument (not_unsafe_ptr_arg_deref); fix typo 2020-07-02 16:51:50 -07:00
ice_iix 0f9dcd2515 Use unwrap_or_else to fix two or_fun_call and suppress one 2020-06-30 19:09:15 -07:00
ice_iix bffb33297f Allow float_cmp since we use it to check if floating point values changed from the last value assigned, not compare two different floating point values; downgrade not_unsafe_ptr_arg_deref to warning 2020-06-30 19:01:17 -07:00
ice_iix e8c066cd26 Clippy: allow too_many_arguments, many_single_char_names 2020-06-29 18:17:16 -07:00
ice_iix 132b40c19e Fix collapsible_if in main game loop 2020-06-29 18:06:51 -07:00
ice_iix c3038f82ce Remove redundant imports (single_component_path_imports) 2020-06-29 18:01:02 -07:00
iceiix 518b6a07f8
Reformat all source with cargo fmt (#335) 2020-06-21 12:17:24 -07:00
Mèir Noordermeer b26500e1b2
Fix crash when window gets minimized (#332). Fixes #275
* Make sure aspect ratio is always valid

* Do not render while window has an invalid size (e.g. window is minimized)
2020-06-21 12:24:41 +02:00
Martin Kröning 54763da22d Get scale_factor from window instead of monitor
Fixes #316
2020-06-20 14:27:00 -07:00
iceiix a6bff21de8
Update to glutin 0.22.0 and winit 0.20.0 release (#268)
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
2020-06-20 13:55:45 -07:00
Kezi 3e96d2e03b
Add --username option to set offline username (#290) 2020-06-20 10:41:08 -07:00
Mèir Noordermeer 50befb5a0f
Do not redraw until main events are cleared (#315). Fixes #282
Fixes unresponsiveness to input
2020-06-20 10:26:47 -07:00
ice_iix bda0009a6f Add Cargo.toml for new steven_protocol crate. Closes #167 (#278)
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
2020-02-02 07:47:11 -08:00
ice_iix 643de31073 protocol: atomics replace unsafe for version/debug. Closes #261 2020-01-08 18:57:57 -08:00
iceiix a020ed6f2c
Update to glutin 0.22.0-alpha5, remove wasm_stub (#260)
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
2020-01-05 17:56:32 -08:00
ice_iix 9066b19031 Allow Cmd modifier as alternative to Ctrl, closes #206 2019-08-11 16:15:36 -07:00
ice_iix 1125c3883d Conditionalize wasm_bindgen to fix compile error on wasm32-wasi
From investigation for #115, now three targets:

- wasm32-unknown-unknown: build with `wasm-pack build`, uses
the #[wasm_bindgen] directive on main()

- wasm32-wasi: build with `cargo +nightly build --target wasm32-wasi`,
requires normal main()

- native targets: same as wasm32-wasi
2019-05-22 18:12:10 -07:00
iceiix fd7add3f17
wasm: log output to browser JavaScript console (#163)
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
2019-05-22 16:12:43 -07:00
ice_iix fd028d41b0 Replace println! with log crate facade macros info!, debug!, etc. 2019-05-22 16:01:14 -07:00
iceiix 8071db668c
Update to glutin 0.21.0. Closes #157 (#160)
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/1 https://github.com/iceiix/winit/pull/2
 - with stubs to compile (but not run, see issue #115)
2019-05-19 17:58:08 -07:00
ice_iix 9ceddc5057 Fix toggling fullscreen with F11 initially. Closes #156 2019-05-19 11:43:36 -07:00
ice_iix 1274a75f81 Enhance -p/--protocol-version to accept game version string
Now you can pass `-p 1.7.10` as an alternative to `-p 5`, etc
2019-05-13 16:35:39 -07:00
ice_iix 938905068b Add command-line option to change default protocol version
Previously, we would send the latest supported protocol version in the
server ping packet. This normally works fine since the server will
respond with the protocol version it supports, which we'll use. However,
some server software such as BungeeCord supports _multiple_ protocols,
and the server will match what the client sent in the ping (if it
supports it). Since BungeeCord is a proxy, it forwards to backend
servers which can be of various versions, which won't necessarily be the
latest.

This change adds a command-line option to change the "default" protocol
version, -p or --default-protocol-version, which is used in the ping
packet instead. Current default is 477 (1.14), but if you pass for
example -p 404 (1.13.2), then BungeeCord will respond accordingly:

packet = Some(StatusResponse(StatusResponse { status: "{\"version\":{\"name\":\"BungeeCord 1.8.x-1.14.x\",\"protocol\":404},\"players\":{\"max\":1,\"online\":0},\"description\":{\"extra\":[{\"color\":\"dark_blue\",\"text\":\"Another Bungee server\"}],\"text\":\"\"},\"modinfo\":{\"type\":\"FML\",\"modList\":[]}}" }))

[main.rs:95][INFO] Detected server protocol version 404

and this protocol will be used. Effectively, this option lets you
masquerade as any supported client version.

See https://github.com/iceiix/stevenarella/issues/125#issuecomment-489484701
2019-05-06 16:00:01 -07:00
iceiix 327efcf043 Add Forge handshake support. Closes #88 (#134)
Adds support for connecting to 1.7.10 modded servers using the FML|HS protocol:
https://wiki.vg/Minecraft_Forge_Handshake

* Handle client-bound plugin message packets

* Parse FML|HS plugin channel messages

* Add ModList serialization using Mod serializable, LenPrefixed<VarInt, Mod>

* Save forge_mods from server ping and send in FML|HS ModList packet

* Show Forge mod count in server ping listing

* Send acknowledgements, completing the handshake

* Add VarShort to custom payload len prefix replaces i16, fixes OOM on large modded servers

* Add custom CoFHLib's SendUUID packet -26

See explanation at https://github.com/SpigotMC/BungeeCord/issues/1437
This packet is defined by CoFHLib in https://github.com/CoFH/CoFHLib/blob/1.7.10/src/main/java/cofh/lib/util/helpers/SecurityHelper.java#L40
Fixes thread '' panicked at 'bad packet id 0xffffffe6 in Clientbound Play' with FTB:IE
2019-05-05 18:39:58 -07:00
ice_iix 30b91f4707 Remove unused Game instance variable protocol_version 2019-05-05 17:33:10 -07:00
ice_iix 4520f6bdae Add flag to log network packets for debugging, --network-debug
Pass -n or --network-debug to print out the packets from the server as
they are received, as well as write to last-packet for later analysis.
Useful when debugging network protocol issues. Builds on #90 #114.
2019-05-05 14:32:48 -07:00
iceiix 047ba79947
Add command-line arguments parsing, --server (#90) (#114)
* 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
2019-05-04 18:36:22 -07:00
ice_iix 6322cf8b21 Re-ping server on connect to detect protocol version
Previously, the server protocol was detected in the server listing GUI,
and saved for each server in a server_versions.json file. connect_to()
would read this file to get the version to use, an ugly hack/workaround
for threading/intercommunication challenges, and a questionable attempt
at avoiding another round-trip exchange.

Now, the server is re-pinged in connect_to() to get the protocol version
to use. This is a blocking ping so it may somewhat slow down server
connecting, but avoids the race conditions with the server list, and
undesirable intertwining the GUI with the server connection logic.

This hack was present since the original multiprotocol support (#18),
but it was blocking other enhancements, about time to remove it.
2019-05-04 17:21:58 -07:00
ice_iix 0d5c1478a5 Update for glutin wasm_stub branch tracking Rust 2018 changes
c0b36056bd
https://github.com/iceiix/glutin/pull/1
2019-03-03 11:50:52 -08:00
iceiix 2f2f35848a
Add support for compiling WebAssembly wasm32-unknown-unknown target (#92)
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
2019-03-03 08:32:36 -08:00
ice_iix 86b1c940ee Update to glutin unreleased post-0.19.0 git revision, current master 2019-03-02 15:17:45 -08:00
ice_iix c80372a1f1 Rename project to Stevenarella (#83)
This fork has significantly diverged from the original, it is time
to make it official, as a new distinct project. Forked from
https://github.com/thinkofname/steven into https://github.com/iceiix/steven,
now moved to https://github.com/iceiix/stevenarella and renamed accordingly.

* Update readme

* Update logo

* Update binary name

* Update window title

* Update splash text
2019-01-11 20:41:19 -08:00
iceiix 98cc88df5c
Workaround resource manager RwLock deadlock (#78). Closes https://github.com/iceiix/steven/issues/75
game.resource_manager, an Arc<RwLock<resources::Manager>>, sometimes hangs on write(), apparently a deadlock. Switch to using try_write() and continue the main game loop iteration if it fails, using the previous resource version and allow main loop tick if can't obtain a write lock. No warning is logged since this error is recoverable and seemingly intermittent. May not be the best fix, but unblocking iterative development.
2019-01-06 19:56:34 -08:00
iceiix d03f102bb8
Multiprotocol support: 1.12.2 and 1.11.2 (#54)
Adds support for connecting to both 1.12.2 and 1.11.2 (protocols 340 and 316) servers

https://github.com/iceiix/steven/issues/18 Enhance protocol support
Closes https://github.com/iceiix/steven/pull/48 1.11.2 protocol support (316)

* Restore create_ids!() macro in packet identifiers

* Add translate_packet_id() function to map external 1.12.2 packet ids to internal sequential ids

* Implement translate_internal_packet_id() from a new protocol_packet_ids! macro

* Move packet IDs to separate file, v1_12_2.rs

* Change supported protocols constant to an array

* Add v1_11_2 protocol packet IDs (from https://github.com/iceiix/steven/pull/48)

* Add keep alive packet variants: _i64 (>=1.12.2) and _VarInt (<=1.11.2)

* Abstract protocol versions, can now connect to both 1.12.2 and 1.11.2

* Send protocol version in handshake packet

* Restore 1.11 (315) protocol support as in original (https://github.com/thinkofname/steven) Steven
2018-12-03 14:22:47 -08:00
iceiix d80eca3940
Get the protocol version to send from the ping packet (#20)
The first step of https://github.com/iceiix/steven/issues/18 Enhance protocol support,
instead of hardcoding a fixed version, the client now matches whatever the server sent.

* Get the protocol version to send from the ping packet

* Save/load server protocol versions to disk, server_versions.json

* Fallback to default SUPPORTED_PROTOCOL if no ping response
2018-11-30 16:41:27 -08:00
iceiix c099a68168
Use glutin to replace sdl2 (#35)
* Add glutin dependency

* Create a glutin window

* Use the glutin window, basics work

* Store DPI factor on game object, update on Resized

* Use physical size for rendering only. Fixes UI scaled too small

Fixes https://github.com/iceiix/steven/pull/35#issuecomment-442683373
See also https://github.com/iceiix/steven/issues/22

* Begin adding mouse input events

* Listen for DeviceEvents

* Call hover_at on mouse motion

* Listen for CursorMoved window event, hovering works

Glutin has separate WindowEvent::CursorMoved and
DeviceEvent::MouseMotion events, for absolute cursor and relative mouse
motion, respectively, instead of SDL's Event::MouseMotion for both.

* Use tuple pattern matching instead of nested if for MouseInput

* Implement left clicking

* Use grab_cursor() to capture the cursor

* Hide the cursor when grabbing

* Implement MouseWheel event

* Listen for keyboard input, escape key release

* Keyboard input: console toggling, glutin calls backquote 'grave'

* Implement fullscreen in glutin, updates https://github.com/iceiix/steven/pull/31

* Update settings for glutin VirtualKeyCode

* Keyboard controls (note: must clear conf.cfg to use correct bindings)

* Move DeviceEvent match arm up higher for clarity

* Remove SDL

* Pass physical dimensions to renderer tick so blit_framebuffer can use full size but the ui is still sized logically.

* Listen for DeviceEvent::Text

* Implement text input using ReceivedCharacter window event, works

https://github.com/iceiix/steven/pull/35#issuecomment-443247267

* Request specific version of OpenGL, version 3.2

* Request OpenGL 3.2 but fallback to OpenGL ES 2.0 if available (not tested)

* Set core profile and depth 24-bits, stencil 0-bits

* Allow changing vsync, but require restarting (until https://github.com/tomaka/glutin/issues/693)

* Clarify specific Rust version requirement

* Import glutin::* in handle_window_event() to avoid overly repetitive code

* Linux in VM fix: manually calculate delta in MouseMotion

For the third issue on https://github.com/iceiix/steven/pull/35#issuecomment-443084458
https://github.com/tomaka/glutin/issues/1084 MouseMotion event returns absolute instead of relative values, when running Linux in a VM

* Heuristic to detect absolute/relative MouseMotion from delta:(xrel, yrel); use a higher scaling factor

* Add clipboard pasting with clipboard crate instead of sdl2

https://github.com/iceiix/steven/pull/35#issuecomment-443307295
2018-11-30 11:35:35 -08:00
iceiix 47d18781b6
Add toggling full screen mode with F11 hotkey (#31)
* Detect when F11 is pressed

* Change mutability of window in handle_window_event()

* Toggle fullscreen between Desktop and Off
2018-11-20 19:42:36 -08:00
ice_iix 1854275282 Fix HDPI scale/offset: Revert "Use drawable_size instead of size for rendering"
Closes https://github.com/iceiix/steven/issues/22 Wrong GUI offsets on AMD Radeon R9 M295X

This reverts commit 715b0cb1ee.
2018-11-19 07:51:55 -08:00
ice_iix 77cd4ecf35 Use field init shorthand, instead of x:x, just x,
https://rust-lang-nursery.github.io/edition-guide/rust-2018/data-types/field-init-shorthand.html

find src -name '*.rs' -exec perl -pe 's/\b(\w+): \1,/$1,/g' -i {} \;
2018-11-04 13:43:30 -08:00
ice_iix 103a58f92a Remove unnecessary #[macro_use] on console 2018-11-04 12:53:03 -08:00
ice_iix 411e4f69a6 Remove unnecessary 'extern crate's in Rust 2018 edition, import macros
https://rust-lang-nursery.github.io/edition-guide/print.html#no-more-extern-crate
https://rust-lang-nursery.github.io/edition-guide/rust-2018/macros/macro-changes.html
https://github.com/iceiix/steven/pull/13#issuecomment-435702507
2018-11-04 12:39:23 -08:00
ice_iix a40cd43a2e Update to use crate:: for current crate, for Rust 2018 edition
From `cargo fix --edition`, see https://rust-lang-nursery.github.io/edition-guide/print.html#the-crate-keyword-refers-to-the-current-crate
2018-11-04 12:06:00 -08:00
iceiix 1589a29685
Remove use of OpenSSL for RSA PKCS1 encryption (#12). Closes #2
* Add handwritten RSA PKCS1 encryption using num-bigint and simple_asn1

* Add more logging to compare OpenSSL with/without side-by-side

* Log message and ciphertext in hex

* Print N and e as hexadecimal integers

* Fix bad encryption caused by zeros in PKCS1 padding

PS field in https://tools.ietf.org/html/rfc8017#section-7.2.1
Must be nonzero

* Use rand fill instead of rand_bytes

* Remove OpenSSL!

* Update CI scripts and docs to not install OpenSSL

* Remove copying OpenSSL DLLs (libeay and ssleay) in AppVeyor script

* Change rsa_public_encrypt_pkcs1 to return a Result<Vec<u8>, String>

* Add error checking, returning Err<String> on failure; RFC comments

* Add the required message representative range checking

* Use expect() instead of unwrap() on from_der

* Map the ASN.1 error to a String to return it from rsa_public_encrypt_pkcs1() instead of panicking

* Move RSA to a new crate, rsa_public_encrypt_pkcs1

https://github.com/iceiix/rsa_public_encrypt_pkcs1

* Update to rsa_public_encrypt_pkcs1 with simple_asn 0.1.0

https://github.com/iceiix/rsa_public_encrypt_pkcs1/issues/1

* Update to published version of rsa_public_encrypt_pkcs1, 0.1.0

* Remove unnecessarily added blank line

* Remove libssl-dev from .travis.yml
2018-11-04 09:40:51 -08:00
iceiix 90aaeaf16a
Support beta Rust release. Closes #8 (#11)
* Remove seemingly unneeded const on MetadataKey<T> new

* Change biome temperature/moisture to integer, x100 to remove floating-point so can use within stable 'const fn'

* Remove unstable const_fn feature, now using stable const fn: see https://www.reddit.com/r/rust/comments/9msqfn/const_fn_soon_on_stable_rust/

* Test on Rust beta (awaiting 1.31 release for stable)

* Update readme for beta Rust support
2018-11-02 16:57:23 -07:00
iceiix 6d88ce23ec Switch to RustCrypto for Cfb8 symmetric crypto, instead of OpenSSL (#10) (#2)
* Encrypt with both RustCrypto cfb8 and OpenSSL

* Switch to RustCrypto for decrypting

* Show encryption for both RustCrypto and OpenSSL, for comparison...

* Correct off-by-one error in encryption, cfb8 doesn't need extra byte

* Remove OpenSSL for symmetric crypto

* Update Cargo.lock
2018-11-01 20:46:21 -07:00
ice_iix c36d0706ac Remove obsolete comment 2018-10-29 17:10:08 -07:00
ice_iix 56a1cb2b76 Fix logging with set_boxed_logger, add std feature to dep
https://github.com/rust-lang-nursery/log/issues/303
2018-10-28 19:45:57 -07:00
iceiix b17f296ab4
Replace hyper with reqwest (#7)
An old version of hyper was used before (0.8.0), in the process of updating to hyper 0.12.11, found this higher-level replacement/wrapper, reqwest 0.9.4 which is simpler to use than the latest hyper and serves the purpose of a simple HTTP client well

* Begin updating to hyper 0.12.11

https://github.com/iceiix/steven/issues/4#issuecomment-425759778

* Use type variables for hyper::Client

* Fix setting header syntax, Content-Type: application/json, 17->13

* Parse strings into URLs with url.parse::<hyper::Uri>().unwrap()

b20971cb4e/examples/client.rs (L25)

* Use hyper::Request::post() then client.request() since client.post() removed

* wait() on the ResponseFuture to get the Result

* try! to unwrap the Result

* status() is now a method

* Concatenate body chunks unwrap into bytes, then parse JSON from byte slice, instead of from_reader which didn't compile

* Replace send() with wait() on ResponseFuture

* Parse HeaderValue to u64

* Slices implement std::io::Read trait

* Read into_bytes() instead of read_to_end()

* Disable boxed logger for now to workaround 'expected function, found macro'

* Remove unnecessary mutability, warnings

* Hack to parse twice to avoid double move

* Use hyper-rustls pure Rust implementation for TLS for HTTPS in hyper

* Start converting to reqwest: add Protocol::Error and reqwest::Error conversion

* Use reqwest, replacing hyper, in protocol

* Convert resources to use reqwest instead of hyper

* Convert skin download to reqwest, instead of hyper

* Remove hyper

* Revert unnecessary variable name change req/body to reduce diff

* Revert unnecessary whitespace change to reduce diff, align indentation on .

* Fix authenticating to server, wrong method and join URL

* Update Cargo.lock
2018-10-27 17:03:34 -07:00
iceiix de6cd2044e
Update to serde_json 1.0 (#6)
* Replace find() with get()

* Update for renamed as_string->as_str and as_boolean->as_bool

https://github.com/serde-rs/json/releases/tag/v0.8.0
Value::as_string() has been renamed to as_str() and Value::as_boolean() has been renamed to as_bool() to improve consistency
https://github.com/serde-rs/json/issues/126

* No serde_json::Value::I64/U64/F64 anymore, only Number

* Update from lookup() to pointer(), using JSON pointer syntax

https://github.com/iceiix/steven/pull/6#issuecomment-432472123

* Remove unused and removed ObjectBuilder import

* Use into_iter().collect() to convert BTreeMap to serde_json::Map

* Change parse_rules to accept serde_json::Map instead of BTreeMap

* Remove unused serde_json macro_use

* Update Cargo.lock
2018-10-23 18:47:21 -07:00
ice_iix c688836a16 Use hex module for hex decoding, removing deprecated rustc-serialize for https://github.com/iceiix/steven/issues/4 2018-09-30 18:14:36 -07:00
ice_iix e988c64376 Use base64 crate for base64 instead of deprecated rustc-serialize, for https://github.com/iceiix/steven/issues/4 2018-09-30 17:58:40 -07:00
ice_iix 43f6565fa5 Update to log 0.4.5
https://github.com/iceiix/steven/issues/4
2018-09-30 16:36:00 -07:00
ice_iix 6eaf1688f4 Remove time crate in favor of std::time, removing last usage in main
Combined with these changes, which also convert to std::time:
47aeb83da2 logo text
2f861f815a light updates
9677f8ae9c server ping
2018-09-29 23:11:47 -07:00
ice_iix 163556fbf1 Use sha1 module for hashing instead of openssl, part of https://github.com/iceiix/steven/issues/2 2018-09-29 22:23:48 -07:00
iceiix b399b74adb Update to rust-sdl2 0.31.0 2018-09-29 13:56:52 -07:00
iceiix 743aaac4cd Enable SDL hint to workaround SDL_SetRelativeMouseMode broken on Linux
Fixes https://github.com/Thinkofname/steven/issues/73
See https://bugzilla.libsdl.org/show_bug.cgi?id=2150
2018-09-29 13:39:20 -07:00
Matthew Collins 2e99712cc8 Update rust-sdl to fix a bug (Fixes #69) 2017-05-14 10:04:34 +01:00
satoshinm 2f950a749c Fix use of deprecated Rc:would_unwrap 2017-05-14 09:58:34 +01:00
llogiq 5e0c041a71 Fixed another batch of clippy warnings
Those are mostly readability-related. Also did a cargo update.
2016-09-15 15:15:52 +01:00
Kyle Wood 8d95965d40 Enable paste in textboxes 2016-04-26 00:50:16 +01:00
Thinkofname f23c16bff2 Update client url and add an in-game progress bar for the download (Fixes #22) 2016-04-24 23:22:10 +01:00
Thinkofname a7caa50b6f Rewrite the UI system (Closes #12) 2016-04-24 12:29:25 +01:00
Thinkofname 9c816c7ea1 Implement interaction with blocks 2016-04-21 20:25:58 +01:00
Thinkofname edf6f34a0b Separate the console and console vars. Removes the need to lock on the console to read vars 2016-04-21 11:40:50 +01:00
TheUnnamedDude f349d516f2 Implement frame limit and configurable vsync (Fixes #29) 2016-04-10 22:05:05 +01:00
TheUnnamedDude 4c590f8184 Add a options/pause menu (Closes #4) 2016-04-09 09:56:55 +01:00
Thinkofname 6cfef5af2d Fix clicking causing the camera to flick 2016-04-08 11:44:23 +01:00
Thinkofname d8b90b74bc Support being kicked from servers 2016-04-08 01:41:26 +01:00
Thinkofname a94b206241 Remove unused feature tag 2016-04-05 20:05:58 +01:00
Thinkofname f8e2d0333e Drop steven_openssl in favor of using the openssl crate (Closes #31) 2016-04-05 19:36:59 +01:00
Thinkofname be05214b70 Remove commented out clippy settings 2016-04-05 14:58:19 +01:00
Thinkofname 715b0cb1ee Use drawable_size instead of size for rendering 2016-04-05 12:43:57 +01:00
Thinkofname 98ecd348c6 Replace usages of x,y,z for block positions with Position 2016-04-03 20:53:40 +01:00
Thinkofname 92d773bd72 Move blocks into its own crate to speed up compile times 2016-04-03 18:26:52 +01:00
Thinkofname 357c695a3a Fix some lock ordering issues 2016-03-29 20:54:08 +01:00
Thinkofname e36a0f4579 Various bug fixes for entity handling. TODO: Smite this system from orbit, it sucks 2016-03-27 17:08:38 +01:00
Thinkofname 80f2121bf7 Initial entity work, moved self handling to an entity 2016-03-26 22:21:47 +00:00