Skip to content

Commit

Permalink
refactor: bump gdext to previous version of setting MSRV 1.78 (#486)
Browse files Browse the repository at this point in the history
* refactor: bump `gdext` to previous version of setting MSRV 1.78

* fix
  • Loading branch information
leanmendoza authored Nov 12, 2024
1 parent c0d6893 commit fb70332
Show file tree
Hide file tree
Showing 83 changed files with 636 additions and 684 deletions.
4 changes: 2 additions & 2 deletions .github/actions/import-assets/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
uses: actions/cache@v3
with:
path: godot/.godot
key: ${{ runner.os }}-godot-assets-cache-4.3-bump
key: ${{ runner.os }}-godot-assets-cache-4.3

# Step 2: Run the command that generates/uses the assets
- name: Import assets
Expand All @@ -21,4 +21,4 @@ runs:
uses: actions/cache@v3
with:
path: godot/.godot
key: ${{ runner.os }}-godot-assets-cache-4.3-bump
key: ${{ runner.os }}-godot-assets-cache-4.3
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
- **MacOS**: `brew install ffmpeg@6 pkg-config`
- **Windows**:
- download and unzip `https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z`
- set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately)
- set `FFMPEG_DIR` = `root folder where ffmpeg has been unzipped`
- add `ffmpeg\bin` to your `PATH`
- set `LIBCLANG_PATH` = `path to LLVM\x64\bin` (this is packaged with visual studio, or can be downloaded separately)
- the `.github/workflows/ci.yml` file can be useful to guide you

4. Run `cargo run -- install --platforms linux` in the repo root folder (change linux to your target platform).
Expand All @@ -34,7 +34,7 @@
Execute the following commands for building Godot:
```bash
# Run Docker
docker run -v {godot-explorer-repo-path}:/app/ -it kuruk/dcl-godot-android-builder:latest
docker run -v {godot-explorer-repo-path}:/app/ -it quay.io/decentraland/dcl-godot-android-builder:99091016236094cb776bd9cb1298602e56b8cdab

# Compile for Android
cd lib
Expand Down
6 changes: 6 additions & 0 deletions godot/src/decentraland_components/player_collider_filter.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://b4tld1cqcvql5"]

[ext_resource type="Script" path="res://src/decentraland_components/player_collider_filter.gd" id="1_pn4dy"]

[node name="PlayerColliderFilter" type="Node"]
script = ExtResource("1_pn4dy")
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
godot = { git = "https://github.com/dclexplorer/gdext", branch = "master", features=["experimental-threads", "serde"] }
godot = { git = "https://github.com/godot-rust/gdext", rev ="cb41673a0ab802145543a8f371abfcb1f0be10f9", features=["experimental-threads", "serde"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0.92", features = ["raw_value"] }
Expand Down
4 changes: 2 additions & 2 deletions lib/src/analytics/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ impl INode for Metrics {
timer.set_one_shot(false);
timer.set_autostart(true);

let callable = self.base.callable("timer_timeout");
let callable = self.base().callable("timer_timeout");
timer.connect("timeout".into(), callable);

self.base.add_child(timer.upcast());
self.base_mut().add_child(timer.upcast());
}

fn process(&mut self, delta: f64) {
Expand Down
33 changes: 16 additions & 17 deletions lib/src/auth/dcl_player_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct DclPlayerIdentity {
#[var]
is_guest: bool,

#[base]
base: Base<Node>,
}

Expand Down Expand Up @@ -89,7 +88,7 @@ impl DclPlayerIdentity {
"error {e} invalid data ephemeral_auth_chain {:?}",
ephemeral_auth_chain
);
self.base.call_deferred(
self.base_mut().call_deferred(
"_error_getting_wallet".into(),
&["Error parsing ephemeral_auth_chain".to_variant()],
);
Expand All @@ -114,7 +113,7 @@ impl DclPlayerIdentity {
self.ephemeral_auth_chain = Some(ephemeral_auth_chain);

let address = self.get_address();
self.base.call_deferred(
self.base_mut().call_deferred(
"emit_signal".into(),
&[
"wallet_connected".to_variant(),
Expand Down Expand Up @@ -144,7 +143,7 @@ impl DclPlayerIdentity {

let address = format!("{:#x}", self.get_address());

self.base.call_deferred(
self.base_mut().call_deferred(
"emit_signal".into(),
&[
"wallet_connected".to_variant(),
Expand Down Expand Up @@ -178,7 +177,7 @@ impl DclPlayerIdentity {

self.magic_auth = false;

let instance_id = self.base.instance_id();
let instance_id = self.base().instance_id();
let sender = DclGlobal::singleton()
.bind()
.get_dcl_tokio_rpc()
Expand Down Expand Up @@ -226,7 +225,7 @@ impl DclPlayerIdentity {

self.magic_auth = true;

let instance_id = self.base.instance_id();
let instance_id = self.base().instance_id();
let sender = DclGlobal::singleton()
.bind()
.get_dcl_tokio_rpc()
Expand Down Expand Up @@ -328,17 +327,17 @@ impl DclPlayerIdentity {
};

if let Some(CurrentWallet::Local { wallet: _, keys }) = &self.wallet {
dict.insert(
let _ = dict.insert(
"local_wallet",
PackedByteArray::from_iter(keys.iter().cloned()).to_variant(),
);
}

dict.insert("magic_auth", self.magic_auth.to_variant());
let _ = dict.insert("magic_auth", self.magic_auth.to_variant());

dict.insert("account_address", self.get_address_str().to_variant());
dict.insert("chain_id", chain_id.to_variant());
dict.insert(
let _ = dict.insert("account_address", self.get_address_str().to_variant());
let _ = dict.insert("chain_id", chain_id.to_variant());
let _ = dict.insert(
"ephemeral_auth_chain",
serde_json::to_string(&self.ephemeral_auth_chain.as_ref().unwrap())
.expect("serialize ephemeral auth chain")
Expand All @@ -361,7 +360,7 @@ impl DclPlayerIdentity {
let profile = DclUserProfile::from_gd(profile);
self.profile = Some(profile.clone());

self.base.call_deferred(
self.base_mut().call_deferred(
"emit_signal".into(),
&["profile_changed".to_variant(), profile.to_variant()],
);
Expand All @@ -371,7 +370,7 @@ impl DclPlayerIdentity {
pub fn set_profile(&mut self, profile: Gd<DclUserProfile>) {
self.profile = Some(profile.clone());

self.base.call_deferred(
self.base_mut().call_deferred(
"emit_signal".into(),
&["profile_changed".to_variant(), profile.to_variant()],
);
Expand All @@ -392,7 +391,7 @@ impl DclPlayerIdentity {
metadata: GString,
method: GString,
) -> Gd<Promise> {
let promise = Promise::alloc_gd();
let promise = Promise::new_alloc();
let promise_instance_id = promise.instance_id();

if let Some(handle) = TokioRuntime::static_clone_handle() {
Expand Down Expand Up @@ -439,7 +438,7 @@ impl DclPlayerIdentity {
new_profile: Gd<DclUserProfile>,
has_new_snapshots: bool,
) -> Gd<Promise> {
let promise = Promise::alloc_gd();
let promise = Promise::new_alloc();
let promise_instance_id = promise.instance_id();

let current_profile = if let Some(profile) = self.profile.clone() {
Expand Down Expand Up @@ -517,7 +516,7 @@ impl DclPlayerIdentity {
let new_profile = DclUserProfile::from_gd(profile);
self.profile = Some(new_profile.clone());

self.base.call_deferred(
self.base_mut().call_deferred(
"emit_signal".into(),
&["profile_changed".to_variant(), new_profile.to_variant()],
);
Expand Down Expand Up @@ -561,7 +560,7 @@ impl DclPlayerIdentity {
self.wallet = None;
self.ephemeral_auth_chain = None;
self.profile = None;
self.base
self.base_mut()
.call_deferred("emit_signal".into(), &["logout".to_variant()]);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/av/video_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl FfmpegContext for VideoContext {
self.video_info.width as i32,
self.video_info.height as i32,
false,
Format::FORMAT_RGBA8,
Format::RGBA8,
data_arr,
)
.unwrap();
Expand All @@ -187,7 +187,7 @@ impl FfmpegContext for VideoContext {
self.video_info.width as i32,
self.video_info.height as i32,
false,
Format::FORMAT_RGBA8,
Format::RGBA8,
data_arr,
);
self.texture.update(image);
Expand Down
13 changes: 6 additions & 7 deletions lib/src/avatars/avatar_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type AvatarAlias = u32;
#[derive(GodotClass)]
#[class(base=Node)]
pub struct AvatarScene {
#[base]
base: Base<Node>,

// map alias to the entity_id
Expand Down Expand Up @@ -60,7 +59,7 @@ impl INode for AvatarScene {
fn ready(&mut self) {
DclGlobal::singleton().bind_mut().scene_runner.connect(
"scene_spawned".into(),
self.base.callable("on_scene_spawned"),
self.base().callable("on_scene_spawned"),
);
}
}
Expand Down Expand Up @@ -133,7 +132,7 @@ impl AvatarScene {
.bind_mut()
.set_movement_type(AvatarMovementType::LerpTwoPoints as i32);

let instance_id = self.base.instance_id();
let instance_id = self.base().instance_id();
let avatar_entity_id = entity_id;
let avatar_changed_scene_callable =
Callable::from_fn("on_avatar_changed_scene", move |args: &[&Variant]| {
Expand Down Expand Up @@ -184,7 +183,7 @@ impl AvatarScene {
new_avatar.connect("change_scene_id".into(), avatar_changed_scene_callable);
new_avatar.connect("emote_triggered".into(), emote_triggered_callable);

self.base.add_child(new_avatar.clone().upcast());
self.base_mut().add_child(new_avatar.clone().upcast());
self.avatar_godot_scene.insert(entity_id, new_avatar);
}

Expand All @@ -201,7 +200,7 @@ impl AvatarScene {
}

#[func]
pub fn on_scene_spawned(&mut self) {
pub fn on_scene_spawned(&mut self, _scene_id: i32, _entity_id: GString) {
for (_, avatar) in self.avatar_godot_scene.iter_mut() {
avatar.bind_mut().on_parcel_scenes_changed();
}
Expand Down Expand Up @@ -323,7 +322,7 @@ impl AvatarScene {

let avatars = std::mem::take(&mut self.avatar_godot_scene);
for (_, mut avatar) in avatars {
self.base.remove_child(avatar.clone().upcast());
self.base_mut().remove_child(avatar.clone().upcast());
avatar.queue_free()
}
}
Expand All @@ -338,7 +337,7 @@ impl AvatarScene {
self.last_updated_profile.remove(&entity_id);

avatar.queue_free();
self.base.remove_child(avatar.upcast());
self.base_mut().remove_child(avatar.upcast());

// Push dirty state in all the scenes
let mut scene_runner = DclGlobal::singleton().bind().scene_runner.clone();
Expand Down
7 changes: 2 additions & 5 deletions lib/src/avatars/avatar_type.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use godot::{
bind::{godot_api, GodotClass},
prelude::*,
};
use godot::prelude::*;

use crate::comms::profile::{AvatarColor, AvatarEmote, AvatarSnapshots, AvatarWireFormat};

Expand All @@ -20,7 +17,7 @@ const DEFAULT_EMOTES: [&str; AVATAR_EMOTE_SLOTS_COUNT] = [
];

#[derive(GodotClass)]
#[class(base=RefCounted)]
#[class(init, base=RefCounted)]
pub struct DclAvatarWireFormat {
pub inner: AvatarWireFormat,
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/avatars/dcl_user_profile.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use godot::{
bind::{godot_api, GodotClass},
builtin::{meta::ToGodot, Dictionary, GString},
obj::Gd,
prelude::*,
};

use crate::comms::profile::UserProfile;
Expand Down
5 changes: 3 additions & 2 deletions lib/src/avatars/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ use crate::{
godot_classes::dcl_global::DclGlobal,
};
use godot::{
bind::{godot_api, GodotClass},
builtin::{GString, PackedStringArray},
obj::Gd,
prelude::*,
};
use std::sync::Arc;

#[derive(Default)]
pub struct ItemEntityDefinition {
pub id: String,
pub entity_definition_json: EntityDefinitionJson,
Expand Down Expand Up @@ -57,7 +58,7 @@ impl ItemEntityDefinition {
}

#[derive(GodotClass)]
#[class(base=RefCounted)]
#[class(init, base=RefCounted)]
pub struct DclItemEntityDefinition {
pub inner: Arc<ItemEntityDefinition>,
}
Expand Down
18 changes: 9 additions & 9 deletions lib/src/comms/adapter/archipelago.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ArchipelagoManager {
};

Self {
ws_peer: WebSocketPeer::new(),
ws_peer: WebSocketPeer::new_gd(),
ws_url: GString::from(ws_url),
state: ArchipelagoState::Connecting,
player_address: ephemeral_auth_chain.signer(),
Expand Down Expand Up @@ -124,7 +124,7 @@ impl ArchipelagoManager {

match self.state.clone() {
ArchipelagoState::Connecting => match ws_state {
godot::engine::web_socket_peer::State::STATE_CLOSED => {
godot::engine::web_socket_peer::State::CLOSED => {
if (Instant::now() - self.last_try_to_connect).as_secs() > 1 {
let ws_protocols = {
let mut v = PackedStringArray::new();
Expand All @@ -138,13 +138,13 @@ impl ArchipelagoManager {
self.last_try_to_connect = Instant::now();
}
}
godot::engine::web_socket_peer::State::STATE_OPEN => {
godot::engine::web_socket_peer::State::OPEN => {
self.state = ArchipelagoState::Connected;
}
_ => {}
},
ArchipelagoState::Connected => match ws_state {
godot::engine::web_socket_peer::State::STATE_OPEN => {
godot::engine::web_socket_peer::State::OPEN => {
let client_packet = ClientPacket {
message: Some(client_packet::Message::ChallengeRequest(
ChallengeRequestMessage {
Expand All @@ -160,7 +160,7 @@ impl ArchipelagoManager {
}
},
ArchipelagoState::IdentMessageSent => match ws_state {
godot::engine::web_socket_peer::State::STATE_OPEN => {
godot::engine::web_socket_peer::State::OPEN => {
while let Some((packet_length, message)) = get_next_packet(peer.clone()) {
match message {
server_packet::Message::ChallengeResponse(challenge_msg) => {
Expand Down Expand Up @@ -208,7 +208,7 @@ impl ArchipelagoManager {
}
},
ArchipelagoState::ChallengeMessageSent => match ws_state {
godot::engine::web_socket_peer::State::STATE_OPEN => {
godot::engine::web_socket_peer::State::OPEN => {
while let Some((packet_length, message)) = get_next_packet(peer.clone()) {
match message {
server_packet::Message::Welcome(_welcome) => {
Expand All @@ -228,7 +228,7 @@ impl ArchipelagoManager {
}
},
ArchipelagoState::WelcomeMessageReceived => match ws_state {
godot::engine::web_socket_peer::State::STATE_OPEN => {
godot::engine::web_socket_peer::State::OPEN => {
self._handle_messages();
if (Instant::now() - self.last_send_heartbeat) > HEARTBEAT_INTERVAL {
let client_packet = ClientPacket {
Expand Down Expand Up @@ -265,8 +265,8 @@ impl ArchipelagoManager {
let mut peer = self.ws_peer.clone();
peer.close();
match peer.get_ready_state() {
godot::engine::web_socket_peer::State::STATE_OPEN
| godot::engine::web_socket_peer::State::STATE_CONNECTING => {
godot::engine::web_socket_peer::State::OPEN
| godot::engine::web_socket_peer::State::CONNECTING => {
peer.close();
}
_ => {}
Expand Down
Loading

0 comments on commit fb70332

Please sign in to comment.