Commit graph

281 commits

Author SHA1 Message Date
CosminPerRam
f11587f2eb Separate errors into groups 2023-08-26 02:58:19 +03:00
CosminPerRam
3db40649f5 Make error a folder and separate code 2023-08-26 02:23:28 +03:00
CosminPerRam
211cd5fd5f [Crate] Update LICENSE.md to specify GameDig organization 2023-08-23 21:24:25 +03:00
CosminPerRam
51c7e2383e [Crate] Update LICENSE.md to specify GameDig developers 2023-08-23 21:12:54 +03:00
CosminPerRam
a8fc67412c [Protocol] Fix an instance of unwrapping in The Ship 2023-08-17 23:08:59 +03:00
CosminPerRam
7e028ce97d [Protocol] Remove Minecraft unused function to convert a string to bytes 2023-08-17 22:50:23 +03:00
CosminPerRam
f50c50f0f1 [Protocol] Apply many nursery clippy lints 2023-08-17 22:37:17 +03:00
CosminPerRam
c4097fae78 [Crate] Update CHANGELOG with check_app_id addition and player score being fixed. 2023-08-15 22:05:59 +03:00
CosminPerRam
b35e52f795
[Protocol] Add app id checking to valve protocol in gather settings (#87) 2023-08-15 22:00:20 +03:00
CosminPerRam
071fc367df [Protocol] Add buffer comment to refactor at some point remaining_bytes 2023-08-15 21:36:40 +03:00
CosminPerRam
9d8fb1ba94
[Protocol] Standardize fields (#84)
* [Protocol] Standardize The Ship fields

* [Protocol] Standardize FFOW fields

* [Protocol] Rename Valve's protocol field to protocol_version

* [Protocol] Rename Minecraft's version_protocol field to protocol_version

* [Protocol] Rename Valve's version field to game_version

* [Protocol] Rename Minecraft java version_name to game_version

* [Crate] Reformat RESPONSES.md

* [Protocol] Renamed Minecraft Java players_sample to players

* [Protocol] Rename Quake (1,2,3) version field to game_version

* [Protocol] Rename quake (1 and 2) game_type field to game_mode

* [Protocol] Rename Valve, FFOW, TS game field to game_mode

* [Generics] Rename game field/function to game_mode

* [Protocol] Change players_minimum, _maximum and _bots from those who werent u8 or u32 to u32

* [Protocol] Change instances of player score field type from u32 to i32

* [Crate] Nicer gramar in CHANGELOG

* [Protocol] Apply clippy fixes
2023-08-15 20:44:18 +03:00
CosminPerRam
65c56dc196 [Service] Fix valve master server ip gatherer being broken (again) 2023-08-08 18:43:33 +03:00
CosminPerRam
c10555a9d7 [Service] Fix valve master server ip gatherer being broken 2023-08-08 18:42:43 +03:00
CosminPerRam
b509a6dcc4 [Crate] Convert pub(crate) to pub in buffer as its not exported externally 2023-08-06 21:55:39 +03:00
CosminPerRam
5aa2ce99ec [Crate] Apply strict clippy on buffer 2023-08-06 21:54:19 +03:00
CosminPerRam
4ff50ea711 [Crate] Apply strict clippy suggestions and fix doc line. 2023-08-06 21:50:17 +03:00
CosminPerRam
47547a77bd [Crate] Remove unnecessary path prefix in error code 2023-08-06 21:32:44 +03:00
CosminPerRam
c43cc0438a [Crate] Update CHANGELOG.md 2023-08-06 21:29:40 +03:00
Tom
5e7e010d24
[Crate] Add rich error type (#80)
* Add rich error type with source and backtrace

Adds a rich error type that will take a backtrace and allow capturing
the source of the error. The best way to use this is with the included
helpers that will automatically capture the backtrace and convert the
source error:

```
GDRichError::packet_bad_from_into("Reason packet was bad")
```

* [Crate] Bump MSRV to 1.65.0

This is required for backtraces in rich errors.

* Remove leftover debug logging

* [Errors] Replace variant overloads with single .rich method on kind enum

This overhaul replaces the exhaustive impls of each variant as multiple
methods on the rich error type with a singular .rich() method on the
kind enum. This consumes the variant and converts it to a rich error
with a source (.into() can be used if a source is not needed).

I also took the liberty of replacing all usages with the this new method
as I saw fit (adding various error messages) and converting a few
PacketBad errors to TypeParse errors when they are the result of parse
failing.

* Fix problem with rustdoc

* Remove BadGame's owned string

* Rename GDError to GDErrorKind

* Rename GDRichError to GDError

* Remove error impl from GDErrorKind

* Fix tests not passing

* Use error context everywhere map_err is used

* Improve GDError display formatter

* Add tests for new error type
2023-08-05 12:36:48 +03:00
CosminPerRam
f7b5463073
[Crate] Add issue templates (#81) 2023-08-03 21:36:03 +03:00
Tom
fb447edbc2
[Docs] Add rustdoc checks to CI and tests to pre-commit (#83) 2023-08-02 17:44:42 +03:00
Tom
a4df444c86
[Docs] Improve generic example (#79)
- Allow entering DNS names that can be resolved
- Output a list of games if there is no game provided
2023-07-23 21:37:44 +03:00
CosminPerRam
ada60f2376 [Protocol] Fixed quake 2 bug that version wouldn't always be present 2023-07-22 16:17:52 +03:00
CosminPerRam
a81a6ef968 [Protocol] GS 1 rename Player's frags field to score to be more inline with the other protocols 2023-07-20 19:27:06 +03:00
CosminPerRam
bec0f518b4 [Crate] Bump version to 0.3.0 2023-07-18 15:58:49 +03:00
CosminPerRam
84118d2590 [Crate] Generalize dependencies 2023-07-18 15:52:47 +03:00
CosminPerRam
23669531b6 [Crate] Fix clippy lints 2023-07-18 15:31:35 +03:00
CosminPerRam
ea1360441c [Crate] Update CHANGELOG to add missing added changes. 2023-07-18 15:25:03 +03:00
Cain
66cc39eb26
[Crate] Refactor: Buffer (#62)
* merge: local -> fresh pr

* fix: utf16 bugs + clean up

* docs: buffer

* [feat/buffer] Replaced errors, partial valve protocol ported

* fix: change buffer name + add endian switch

* chore: update module

* refactor: valve_master

* refactor: mc bedrock

* refactor: mc java

* refactor: mc types

* refactor: mc legacy 1.8

* refactor: mc legacy 1.4

* refactor: valve

* refactor: valve types

* refactor: quake

* refactor: mc legacy 1.6

* refactor: gamespy 1

* fix: make switch endian move cursor

* fix: reset cursor on switch

* chore: add switch endian tests

* chore: remove todo comment

* chore: clean up buffer generic types

* refactor: prop len when switching in mc bedrock

* fix: tests and current pos fn

* refactor: ffow

* refactor: jc2mp

* refactor: gs 3

* refactor: gs 2

* fix: mc bedrock prop on move + move data

* fix: mc java lifetime error

* fix: mc legacy 1.6 using pub not pub crate

* fix: quake client lifetime

* fix: quake 2 clippy warning

* fix: valve lifetime issue

* fix: buffer test

* chore: format to keep ci happy

* fix: buffer move_cursor

* fix: quake client

* feat: GameSpy 1 small optimization

* fix: incomplete gamespy 3 fix

* fix: gamespy 3 fix

* fix: minecraft java

* fix: minecraft bedrock

* feat: update the CHANGELOG to mention the buffer rewrite and thank @cainthebest for it

* fix: minecraft legacy 1.6

---------

Co-authored-by: CosminPerRam <cosmin.p@live.com>
2023-07-18 11:46:53 +03:00
Tom
a8342296d6
[CI] Improve checks (#71)
* [CI] Improve checks

- Adds .actrc so CI actions can be tested locally
- Adds testing for variants of features so changes that break feature
  sets like disabling games can be caught
- Adds more of the CI tests to pre-commit

* [CI] Add more feature sets to test

* [CI] Check github actions before comitting

Requires act: https://github.com/nektos/act

* [CI] Add caching between builds

* [CI] Add caching everywhere

* [CI] Add more feature tests

* [CI] Add YAML schemas

* [CI] Disable audit when running locally

This is needed because the audit action requires a GITHUB_TOKEN which we
don't have when running locally.

* [CI] Move clippy to own job and use action that annotates PRs

Using actions-rs/clippy-check means that PRs will problems will
automatically have the relevant lines annotated

* [CI] Don't unnecessarily cache targets for fmt
2023-07-12 23:40:10 +03:00
Tom
fb9d15f0cc
[Crate] Bump rustfmt version to 1.6.0 (#69) 2023-07-10 18:32:17 +03:00
CosminPerRam
bf8c087b94
[CI] Using recommended CI Cargo audit Github action and update serde (#70)
* [CI] Using recommended CI Github action

* [Crate] Update serde dependencies
2023-07-10 17:09:22 +03:00
Tom
e207e8dc95
[Games] Add timeout settings for proprietary games (#67)
Adding query functions with timeout settings to proprietary games allows
the generic query with timeout function to pass the timeout settings
through.

This does change how the pre-existing FFOW query_with_timeout function
worked: it accepted a non-optional timeout settings, this was changed to
optional to be consistent with other query_with_timeout functions and to
move deciding what to do if the user doesn't provide timeout settings to
a more central location.

Closes #64
2023-07-10 16:17:49 +03:00
Tom
f3a792e325
[Crate] Swap no_games, no_services for games, services (#61) 2023-06-27 02:12:57 +03:00
CosminPerRam
0f9a10f2fb [Games] Add Warsow support. 2023-06-27 01:15:04 +03:00
CosminPerRam
58f7ff8aab [Protocol] Fix common quake 2 player score conversion 2023-06-27 01:08:42 +03:00
CosminPerRam
f7e93fd7cd [Protocol] Renamed quake 2's player's frags field to score to be more inline with the other protocols 2023-06-27 01:06:16 +03:00
CosminPerRam
84ebeb8065 [Protocol] Add optional address field to quake 2 player 2023-06-27 00:58:38 +03:00
Tom
8316dac2cc
[Games] Add method to query with timeout options (#60) 2023-06-27 00:50:06 +03:00
CosminPerRam
dd80d6309f [Protocol] Replace some usage of remaining_length with the more appropiate is_remaining_empty 2023-06-27 00:23:19 +03:00
CosminPerRam
8fe521749a [Protocol] Remove bufferer::remaining_data_vec function and replace its usage 2023-06-27 00:18:56 +03:00
CosminPerRam
d61085b1ab [Protocol] Remove bufferer::data_length function and replace its usage 2023-06-27 00:17:33 +03:00
CosminPerRam
c55254aaf6
[Protocol] Add PROPRIETARY to protocol enumeration (#59)
* [Protocol] Add CUSTOM to protocol enumeration

* [Protocol] Rename CUSTOM to PROPRIETARY

* [Protocol] Rename struct to ProprietaryProtocol and do the same thing to generic response

* [Protocol] Revert proprietary change on generic response
2023-06-26 23:52:40 +03:00
Tom
b368877031
[Protocol] Implement generic response with dyn (#56)
* Implement generic response as enum

* First draft of implementing into_common()

* Make common response type generic

* Use macros and generics to reduce repetition

* [Games] Add dynamically dispatched CommonResponse trait

This adds two traits: "CommonResponse", and "CommonPlayer", when the
generic game query function returns a response it returns a pointer to
its original response type that implements "CommonResponse".

Both common traits require that "as_original()" be implemented, this
returns an enum containing a pointer to the original type.

Both traits have a concrete method "as_json()" that returns a struct
containing data fetched from all of its methods as. This struct
implements serde and can hence be serialized as required.

The traits require a few other methods be implemented, those being the
fields that are common across all types. All other methods have a
default None implementation so that each response type only needs to
implement methods for fields that it has.

* [Game] Implement common traits for JCMP2 response

* [Fmt] Run cargo fmt

* Fix doctest failing

* Run cargo fmt
2023-06-25 16:31:23 +03:00
Tom
bf14ecb4a4
[Crate] Add documentation for where versions need to be updated (#58)
VERSIONS.md tells you what the current versions for things like MSRV is
and which files you need to update if you change it.

Also fixes the incorrect:
- MSRV in README.md
- nightly version in .pre-commit-config.yaml
2023-06-25 16:02:25 +03:00
CosminPerRam
9c93e40650
[CI] Pin specific rustfmt version (#57)
* [CI] Specify specific rustfmt version

* [CI] Specify platform in CI for rustfmt

* [CI] Fix cargo fmt running missing nightly version
2023-06-25 15:42:29 +03:00
Tom
89fbd81331
[Crate] Add clippy and rustfmt pre-commit hooks (#50)
These hooks can be installed using [pre-commit], with:
"pre-commit install". Once installed they will prevent you from
committing if the staged code has clippy warnings or hasn't been
formatted. You can skip the pre-commit checks by adding the "-n" flag to
your git commit command.

The hooks also require rustup as the nightly versions of rustfmt and
clippy are used.

[pre-commit]: https://pre-commit.com/
2023-06-25 14:41:20 +03:00
CosminPerRam
31162b6d6e [Crate] Modify GAMES.md to make it more cohesive. 2023-06-19 23:05:41 +03:00
CosminPerRam
c3e2d948e8
[Game] Add JC2MP support. (#54)
* [Game] Add JC2MP support.

* [Game] Add game to changelog and games

* [Games] Add generic support to JC2MP.

* [Game] Add players_maximum and players_online
2023-06-19 22:10:49 +03:00
CosminPerRam
cb9384e474 [Crate] Updated CHANGELOG.md to include generic query 2023-06-19 19:59:06 +03:00