Commit graph

220 commits

Author SHA1 Message Date
CosminPerRam
5b5c41b468 Add Barotrauma support. 2023-10-13 00:40:08 +03:00
Tom
3b9c784e70
Reduce game implementation repetition (#122)
* [Games] Add macro to replace valve game query implementations

This somewhat reduces repeated code (#120), and also adds auto-generated
doc comments to all valve game query functions.

* [Games] Add macro to replace gamespy game query implementations

This somewhat reduces repeated code (#120), and also adds auto-generated
doc comments to all gamespy game query functions.

* [Games] Add macro to replace quake game query implementations

This somewhat reduces repeated code (#120), and also adds auto-generated
doc comments to all quake game query functions.

* [Games] Move all valve game modules into a single file using macros

Vastly reduces the number of files. However does break the game
definition-per-file test, so that was removed.

* [Games] Move all quake game modules into a single file using macros

* [Games] Move all gamespy game modules into a single file using macros

* [Docs] Update CHANGELOG

* [Docs] Improve game query function generation macro documentation

* [Games] Add missed Halo: Combat Evolved to gamespy
2023-10-10 09:26:35 +03:00
CosminPerRam
c8a93357cf
Add Send and Sync on Error Source (#118)
* Add Send and Sync on Error Source and remove 'static

* Add back 'static

* Update the changelog
2023-10-09 19:11:34 +03:00
CosminPerRam
b584e11336 Remove serde derives Generic Player and Response 2023-10-08 22:26:25 +03:00
CosminPerRam
1e083c2df7 [Generic] Add missing derives to types 2023-10-08 19:45:24 +03:00
CosminPerRam
7164ab5f64 [Protocol] Add derives to RequestSettings and new_just_hostname function 2023-10-08 00:37:11 +03:00
CosminPerRam
311a5425a8
Remove minecraftping from game definitions as its useless (#117)
* Remove minecraftping from game definitions as its useless

* Update minecraftpocket name
2023-10-07 18:06:18 +03:00
CosminPerRam
5280ecb3c6
[Game] Apply new id naming (#114)
* Apply new id naming

* Fix failing CI on all features

* Update changelog

* Rename tf2 example to teamfortress2

* Fix typo in steamapp game names

* Rename minecraft legacy versions

* Apply CI node badge fix by Douile

* Add/Update badge

---------

Co-authored-by: GitHub Action <action@github.com>
2023-10-06 17:20:30 +03:00
Tom
efc1828b29
[Protocol] Make gamespy1 parsing less likely to fail (#107)
* [Protocol] Gamespy1 don't skip "playername" field (#88)

* [Protocol] Gamespy1 make more player fields optional (#88)

These fields seem to be missing from bf1942 queries so make them
optional.
2023-09-27 17:07:42 +03:00
Tom
c3281be419
[Protocol] Retry failed requests (#95)
* Add retry count to TimeoutSettings

This can be used to specify how many times to re-send requests that
fail. The default value is "1" so the if the first request fails, 1 more
attempt will be made.

* Add retries to valve queries

* [Protocol] &Optional<TimeoutSettings> add get_retries_or_default

Allow fetching the number of retries or the default retries value from a
borrowed optional TimeoutSettings.

* [Protocol] Add retries to minecraft protocol

* [Protocol] Add retries to quake

* [Protocol] Add retries to gamespy

* [Protocol] Update TimeoutSettings docs, and change default retries to 0

* Remove logging from retry_on_timeout

* [Protocol] TimeoutSettings make retries non-optional

* [Protocol] Move retry logic into lower level query functions

Retries are now implemented as wrappers on the single function that
would need to be retried on timeout.

In order to avoid cloning of TimeoutSettings, Socket::apply_timeouts()
was changed to accept a borrowed TimeoutSettings. And extra helpers were
added to the TimeoutSettings impl to reduce repetition.

* [Examples] Add retries to the generic example

* Also retry on PacketSend error

Sending packets could also timeout and until error_generic_member_access
is stable we have no way of determining the type of the underlying
`std::error::Error`.

* Add retry unit tests

* [Docs] Update changelog
2023-09-25 22:12:54 +03:00
Tom
52750fba76
[Games] Update game definitions to match node-gamedig names (#100)
* [Games] Update game definitions to match node-gamedig names

* Update game file names to match definitions

* [Games] rename minecraft definitions to better match node

* [Games] Add test that all game files match definition name

* Update SteamApp to match node names

* [Games] Update the forest to match node-GameDig#367

* Clippy fix in games test

* [Docs] Update GAMES.md with new names

* [DOCS] Update changelog
2023-09-23 00:20:01 +03:00
CosminPerRam
6179532065 [Crate] Changeup a doc comment 2023-09-10 23:27:06 +03:00
CosminPerRam
cb0486bded [Crate] Solve Cargo Doc redundant explicit link target 2023-09-10 23:14:13 +03:00
CosminPerRam
995ab23b51 [Crate] Separate error code into different files. 2023-09-10 23:12:18 +03:00
CosminPerRam
edbb0e6cf5 [Protocol] Valve: Rename compressed field to decompressed 2023-09-10 22:32:02 +03:00
CosminPerRam
b418319e01 [Protocol] GameSpy 3: Removed instance on unchecked .unwrap 2023-09-06 14:17:37 +03:00
CosminPerRam
527f8f6369 [Protocol] Valve: change up compressed packages structure to use Options 2023-09-06 13:46:52 +03:00
CosminPerRam
7cfecbfff9 [Game] Remove instances of using unwrap without handling the panics 2023-09-06 13:37:48 +03:00
Tom
6c1fdb1159
[Generic] Add struct for all extra request settings (#93)
* [Generic] Add struct for all extra request settings

Adds a new struct `ExtraRequestSettings` that contains all possible
extra settings for all protocols, and can be implicitly converted with
`.into()` into each protocol's extra settings type.

This is then used in a new query method
`query_with_timeout_and_extra_settings()` that passes the object on to
the selected protocol.

This also updates the generic example to set some of these generic
settings so that it can be used for certain queries like
"mc.hypixel.net".

* [Minecraft] Add `request_settings` parameter to auto query

This allows generic queries to pass through request settings when using
the `mc` game so that servers like `mc.hypixel.net` will still work when
using auto query.

* Fix generic examples tests (and enable example tests in pre-commit)
2023-09-05 01:13:12 +03:00
CosminPerRam
76a3ac2f78 [Game] Add Creativerse support. 2023-09-03 12:12:14 +03:00
CosminPerRam
a56ca45de6
[Protocol] Fix Minecraft Java query not being able to specify a hostname (#91)
* Make initial fix

* Fix imports

* Rename query_address to hostname and add this to the mc example

* Fix master_querant example not compiling

* Add extra safety on converting strings to Minecraft Varint strings

* Add docs to RequestSettings

* Fix formatting
2023-09-01 22:21:08 +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
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
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
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
23669531b6 [Crate] Fix clippy lints 2023-07-18 15:31:35 +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
fb9d15f0cc
[Crate] Bump rustfmt version to 1.6.0 (#69) 2023-07-10 18:32:17 +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