Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from dankmeme01/0.2.0-e
Browse files Browse the repository at this point in the history
0.2.0 ready for release !!!!
  • Loading branch information
dankmeme01 authored Sep 23, 2023
2 parents 052f091 + ff882ee commit 8b49f7e
Show file tree
Hide file tree
Showing 42 changed files with 503 additions and 621 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Globed

Globed is a multiplayer mod for Geometry Dash, powered by [Geode](https://geode-sdk.org/).
Globed is an open-source, highly customizable multiplayer mod for Geometry Dash, powered by [Geode](https://geode-sdk.org/).

## Architecture

Expand Down Expand Up @@ -47,7 +47,6 @@ Here is a list of known issues or something I cannot test:

* unable to compile with MSVC, only can compile with clang on Linux. This should be resolved when a Geode update removes winsock.h from includes.
* no idea if it compiles/works on Mac, but I tried to avoid platform-specific code.
* `DRPPAEngine` (extrapolation but not really) doesn't do dash rotations because I was too lazy and you should use interpolation insetad anyway.
* Level list most of the time doesn't show creators properly, shows a dash instead.

Planned features:
Expand All @@ -57,6 +56,8 @@ Planned features:

## Special thanks

Thanks to [ca7x3](https://twitter.com/ca7x3) for making the logo for the mod <3 (and for helping me test some things out)

Thank you [Geode](https://geode-sdk.org/) and everybody in [Geode discord server](https://discord.gg/9e43WMKzhp) who helped me whenever I had issues. This is my first ever mod for Geometry Dash, and I am generally not very experienced in C++, so I've had a lot of difficulty with it.

Also, thanks a lot to Cvolton for [BetterInfo](https://github.com/Cvolton/betterinfo-geode), some classes like `GlobedListView` and `GlobedLevelsListView` are borrowed from there.
10 changes: 4 additions & 6 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ Globed is an open-source, highly customizable multiplayer mod for Geometry Dash.

It is very much in beta, and you may expierence some issues, especially if you live far from the server location. For optimal experience, make sure to update the mod whenever available, so you get all the latest bugfixes.

For best possible experience, use a framerate that is a multiple of 30, be it 60, 120, 240 or 360. Otherwise you may experience some jitter.

## Usage

In the main menu you should see an extra button at the bottom. It will open the Globed Menu, where you can see available Game Servers and various information about them, such as player count, region, ping, and name. All you have to do is pick the server you want and press 'Join'. After that, simply hop into a level and you will see anyone who is also playing on the level.
In the main menu you should see an extra button at the bottom. It will open the Globed Menu, where you can see a list of servers that you can join.

## Central server configuration

The default URL is http://globed.dankmeme.dev

If you want to change the URL of the Central Server, open the Globed Menu and press the gear button in bottom left. Here you can enter any valid HTTP(s) URL, and after pressing 'apply', the game will auto disconnect you from a server if you are already connected, fetch available Game Servers, and update the list. In case the list seems outdated, press the refresh button in bottom left, it will make a request to the Central Server and update the server list.

## Status

The mod is in beta and I don't have a massive motivation anymore to work on it, but I will try to fix bugs, add some features and maintain servers. If you are a developer, feel free to fork the repository or use the code in any way you want.
If you want to change the URL of the Central Server, open the Globed Menu and press the gear button in bottom left. Here you can enter any valid HTTP(s) URL, and after pressing 'apply', the active server will switch to the one you entered.
30 changes: 30 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# v0.2.0

## Lag is no more (sort of)

This update brings an overhaul to interpolation, and your game should be much smoother provided a stable ping, even if it's a high one.

There have been a lot of changes, so if you find any issues, feel free to contact me. You can do it on discord @dank_meme01, or in github issues if you feel like it, for some reason.

Detailed list of changes:

Interpolation related:

* Completely overhauled interpolation, rewritten with the mathematical formula `lerp` instead of own formulas
* Added timestamps to `PlayerData` packets to try and make other players' movement more accurate
* Removed the PPA engines setting
* Tried to counteract packet loss by applying extrapolation if needed
* Made packet receiving more efficient (1 packet = 1 datagram instead of 2)
* Remove Y rotation since X and Y rotations are generally always equal to each other

Other changes:

* Added colorful names for people who helped me or supported me, can be disabled in settings
* Changed the mod logo (and menu icon) (thanks [@ca7x3](https://twitter.com/ca7x3) :D)
* Made the menu icon change color depending on whether you are connected to a server or not
* Made some error messages a bit nicer
* Introduced more bugs
* Bump the protocol version to 5

The last change means you have to update the mod in order to use any of the official servers.

# v0.1.3

* Improved interpolation for greater smoothness
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 10 additions & 19 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"geode": "1.3.0",
"version": "0.1.3",
"version": "0.2.0",
"id": "dankmeme.globed",
"name": "globed",
"name": "Globed",
"developer": "dankmeme",
"description": "Multiplayer for Geometry Dash",
"repository": "https://github.com/dankmeme01/globed",
"resources": {
"sprites": [
"resources/icon.png"
"resources/menuicon.png"
]
},
"settings": {
Expand Down Expand Up @@ -39,21 +39,6 @@
"arrows": true
}
},
"ppa-engine": {
"name": "PPA type",
"type": "int",
"min": 0,
"max": 2,
"default": 2,
"description": "Player Position Approximation engines:\n\n<cg>0. Off.</c> <cp>highest</c> accuracy and <cp>lowest</c> latency, but <cr>lowest</c> smoothness.\n<cg>1. DR.</c> <cy>average</c> accuracy, <cp>lowest</c> latency and <cy>average</c> smoothness.\n<cg>2. Interpolation (recommended).</c> <cg>high</c> accuracy, <cy>average latency</c>, and <cp>highest</c> smoothness.",
"control": {
"arrows": true,
"arrow-step": 1,
"slider": true,
"slider-step": 1,
"input": false
}
},
"player-opacity": {
"name": "Player opacity",
"type": "int",
Expand Down Expand Up @@ -142,11 +127,17 @@
"default": true,
"description": "Shows a <cg>checkpoint</c> icon above a player's head if they're in <cg>practice mode</c>."
},
"name-colors": {
"name": "Name colors",
"type": "bool",
"default": true,
"description": "People who helped me or supported me get a <cj>colorful name</c> :D"
},
"debug": {
"name": "Debug mode",
"type": "bool",
"default": false,
"description": "This option toggles <cj>debug mode</c>. Please do not complain about any weirdness if you use this. It makes you able to see your own player, and play custom levels. Any custom level played with this mode <cr>will set and save the level's ID to 1</c>. You won't see any changes until you restart the game."
"description": "This option toggles <cj>debug mode</c>. It is <cr>not recommended</c> to use unless you know the risks. Your game may crash, produce weird behavior, be laggy, or even <cr>corrupt some of your data</c>. You have been warned. Restart the game to see any changes."
}
}
}
Binary file added resources/menuicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion server/central/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use util::Logger;
mod util;
mod web;

pub const PROTOCOL_VERSION: &str = "4";
pub const PROTOCOL_VERSION: &str = "5";
static LOGGER: Logger = Logger;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion server/game/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "globed-game-server"
version = "0.2.3"
version = "0.3.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
26 changes: 20 additions & 6 deletions server/game/src/data/player_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum IconGameMode {
#[derive(Default)]
pub struct SpecificIconData {
pub pos: (f32, f32),
pub rot: (f32, f32),
pub rot: f32,
pub game_mode: IconGameMode,

pub is_hidden: bool,
Expand All @@ -31,6 +31,7 @@ pub struct SpecificIconData {

#[derive(Default)]
pub struct PlayerData {
pub timestamp: f32,
pub player1: SpecificIconData,
pub player2: SpecificIconData,

Expand All @@ -47,8 +48,7 @@ impl PlayerData {
fn encode_specific(buf: &mut ByteBuffer, player: &SpecificIconData) {
buf.write_f32(player.pos.0);
buf.write_f32(player.pos.1);
buf.write_f32(player.rot.0);
buf.write_f32(player.rot.1);
buf.write_f32(player.rot);

buf.write_u8(player.game_mode as u8);
buf.write_bit(player.is_hidden);
Expand All @@ -62,8 +62,7 @@ impl PlayerData {
fn decode_specific(buf: &mut ByteReader) -> Result<SpecificIconData> {
let x = buf.read_f32()?;
let y = buf.read_f32()?;
let rx = buf.read_f32()?;
let ry = buf.read_f32()?;
let rot = buf.read_f32()?;

let game_mode = IconGameMode::try_from(buf.read_u8()?).unwrap_or(IconGameMode::default());
let is_hidden = buf.read_bit()?;
Expand All @@ -75,7 +74,7 @@ impl PlayerData {

Ok(SpecificIconData {
pos: (x, y),
rot: (rx, ry),
rot,
game_mode,
is_hidden,
is_dashing,
Expand All @@ -86,19 +85,24 @@ impl PlayerData {
}

pub fn encode(&self, buf: &mut ByteBuffer) {
buf.write_f32(self.timestamp);

Self::encode_specific(buf, &self.player1);
Self::encode_specific(buf, &self.player2);

buf.write_bit(self.practice);
}

pub fn decode(buf: &mut ByteReader) -> Result<Self> {
let timestamp = buf.read_f32()?;

let player1 = Self::decode_specific(buf)?;
let player2 = Self::decode_specific(buf)?;

let practice = buf.read_bit()?;

Ok(PlayerData {
timestamp,
player1,
player2,
practice,
Expand Down Expand Up @@ -165,4 +169,14 @@ impl PlayerAccountData {
name,
})
}

pub fn is_valid(&self) -> bool {
if self.name.len() > 32 {
return false;
}

// TODO handle invalid color ids and icon ids

true
}
}
14 changes: 8 additions & 6 deletions server/game/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ impl State {
}

pub async fn send_buf_to(&'static self, addr: SocketAddr, buf: &[u8]) -> Result<usize> {
let len_buf = buf.len() as u32;

// let _ = self.send_lock.lock().await;
self.server_socket
.send_to(&len_buf.to_be_bytes()[..], addr)
.await?;
Ok(self.server_socket.send_to(buf, addr).await?)
}

Expand Down Expand Up @@ -291,6 +285,14 @@ impl State {
Ok(_) => {
// add icons
let data = PlayerAccountData::decode(&mut bytebuffer)?;
if !data.is_valid() {
buf.write_u8(PacketType::ServerDisconnect as u8);
buf.write_string("Invalid data was passed. Contact the developer if you think this is wrong.");
self.send_buf_to(peer, buf.as_bytes()).await?;
let mut clients = self.connected_clients.write().await;
clients.remove(&client_id);
return Ok(());
}
info!("{} ({}) signed in", data.name, client_id);
let mut clients = self.connected_clients.write().await;
clients
Expand Down
Loading

0 comments on commit 8b49f7e

Please sign in to comment.