Skip to content

Commit

Permalink
fix crash, format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
leanmendoza committed Sep 26, 2024
1 parent 697b546 commit 0f4b670
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.2
toolchain: 1.78
override: true
components: clippy, rustfmt

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.76
toolchain: 1.78
override: true
components: llvm-tools-preview

Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.76
toolchain: 1.78
override: true

- name: Set up cargo cache
Expand Down
5 changes: 3 additions & 2 deletions godot/src/decentraland_components/avatar/avatar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func _ready():
label_3d_name.billboard = billboard_mode

emote_controller = AvatarEmoteController.new(self, animation_player, animation_tree)
# TODO
# TODO: uncomment this line before finishing bump to 4.3, FIX
# body_shape_skeleton_3d.bone_pose_changed.connect(self._attach_point_bone_pose_changed)

avatar_modifier_area_detector.set_avatar_modifier_area.connect(
Expand Down Expand Up @@ -248,7 +248,8 @@ func try_to_set_body_shape(body_shape_hash):
var new_child = child.duplicate()
new_child.name = "bodyshape_" + child.name.to_lower()

new_child.add_child(body_shape.get_node("ResourceLocker").duplicate())
var resource_locker = body_shape.get_node("ResourceLocker")
new_child.add_child(resource_locker.duplicate())
body_shape_skeleton_3d.add_child(new_child)

_add_attach_points()
Expand Down
6 changes: 1 addition & 5 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,4 @@ enable_inspector = ["use_deno", "dep:fastwebsockets", "dep:hyper1"]
[build-dependencies]
webrtc-sys-build = { git = "https://github.com/livekit/rust-sdks", optional = true, rev="8b276f9d4b98437a139e1cbe41cfda1332ce1120" }
prost-build = "0.11.8"
chrono = "0.4.31"

[patch."https://github.com/godot-rust/godot4-prebuilt".godot4-prebuilt]
git = "https://github.com//godot-rust/godot4-prebuilt"
rev = "bc1e77856d181c14c59d2a5cb6a7e138ea5a2b39"
chrono = "0.4.31"
10 changes: 5 additions & 5 deletions lib/src/auth/dcl_player_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,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 Down
4 changes: 2 additions & 2 deletions lib/src/avatars/avatar_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ impl DclAvatarWireFormat {

for (i, emote) in DEFAULT_EMOTES.iter().enumerate() {
if let Some(emote) = used_emotes.iter().find(|e| e.slot == i as u32) {
emotes.set(i, GString::from(emote.urn.as_str()));
emotes[i] = GString::from(emote.urn.as_str());
} else {
emotes.set(i, GString::from(*emote));
emotes[i] = GString::from(*emote);
}
}
emotes
Expand Down
2 changes: 1 addition & 1 deletion lib/src/comms/communication_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl CommunicationManager {
}

#[func]
fn _on_profile_changed(&mut self) {
fn _on_profile_changed(&mut self, _: Variant) {
self.base_mut()
.call_deferred("_on_update_profile".into(), &[]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/godot_classes/dcl_avatar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl DclAvatar {
self.lerp_state.factor = 0.0;
self.lerp_state.initial_velocity_y = y_velocity;

let initial_position = self.lerp_state.initial_position.clone();
let initial_position = self.lerp_state.initial_position;

// TODO: check euler order
self.base_mut()
Expand Down
26 changes: 9 additions & 17 deletions lib/src/godot_classes/resource_locker.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
use godot::{engine::node::InternalMode, prelude::*};

#[derive(GodotClass)]
#[class(base=Node)]
#[class(init, base=Node)]
pub struct ResourceLocker {
#[export]
reference: Gd<Resource>,

base: Base<Node>,
}

#[godot_api]
impl INode for ResourceLocker {
fn init(mut base: Base<Node>) -> Self {
let reference = Resource::new_gd();

// TODO: set meta
// base.set_name("ResourceLocker".to_godot());
// base.set_meta(
// StringName::from("instance_id"),
// reference.instance_id().to_variant(),
// );
Self { base, reference }
}
}

#[godot_api]
impl ResourceLocker {
#[func]
Expand All @@ -33,7 +18,14 @@ impl ResourceLocker {
return;
}

let resource_locker = ResourceLocker::new_alloc();
let mut resource_locker = Gd::from_init_fn(|base| {
let reference = Resource::new_gd();
ResourceLocker { reference, base }
});

let instance_id = resource_locker.bind().reference.instance_id().to_variant();
resource_locker.set_name("ResourceLocker".to_godot());
resource_locker.set_meta(StringName::from("instance_id"), instance_id);

node.add_child_ex(resource_locker.upcast())
.internal(InternalMode::FRONT)
Expand Down
1 change: 0 additions & 1 deletion lib/src/http_request/request_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ impl RequestResponse {
Variant::nil()
}
}
_ => Variant::nil(),
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/components/ui/ui_background.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use godot::{
obj::{NewAlloc, UserClass},
prelude::Gd,
};
use godot::{obj::NewAlloc, prelude::Gd};

use crate::{
dcl::{
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/components/ui/ui_dropdown.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use godot::{
obj::{NewAlloc, UserClass},
prelude::Gd,
};
use godot::{obj::NewAlloc, prelude::Gd};

use crate::{
dcl::{
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/components/ui/ui_input.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use godot::{
obj::{NewAlloc, UserClass},
prelude::Gd,
};
use godot::{obj::NewAlloc, prelude::Gd};

use crate::{
dcl::{
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/components/ui/ui_text.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use godot::{
obj::{NewAlloc, UserClass},
prelude::Gd,
};
use godot::{obj::NewAlloc, prelude::Gd};

use crate::{
dcl::{
Expand Down
6 changes: 3 additions & 3 deletions lib/src/scene_runner/godot_dcl_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
},
realm::scene_definition::SceneEntityDefinition,
};
use godot::{engine::Script, prelude::*};
use godot::prelude::*;
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -185,11 +185,11 @@ impl GodotDclScene {

let godot_entity_node = self.entities.get_mut(entity).unwrap();
if godot_entity_node.base_3d.is_none() {
let mut new_node_3d = DclNodeEntity3d::new_alloc(*entity);
let new_node_3d = DclNodeEntity3d::new_alloc(*entity);
self.root_node_3d.add_child(new_node_3d.clone().upcast());

if entity == &SceneEntityId::PLAYER || entity == &SceneEntityId::CAMERA {
// TODO
// TODO FIXME loading script and instantiate to cast to Node

// let mut player_collider_filter = godot::engine::load::<Script>(
// "res://src/decentraland_components/player_collider_filter.gd",
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/rpc_calls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
mod handle_restricted_actions;
mod portables;

use godot::{
builtin::meta::ToGodot,
obj::{NewGd, UserClass},
};
use godot::{builtin::meta::ToGodot, obj::NewGd};

use crate::{
content::content_mapping::DclContentMappingAndUrl,
Expand Down
5 changes: 1 addition & 4 deletions lib/src/scene_runner/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use std::{
time::Instant,
};

use godot::{
obj::{NewAlloc, UserClass},
prelude::Gd,
};
use godot::{obj::NewAlloc, prelude::Gd};

use crate::{
content::content_mapping::{ContentMappingAndUrl, ContentMappingAndUrlRef},
Expand Down
10 changes: 4 additions & 6 deletions src/copy_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ pub fn copy_library(debug_mode: bool, link_libs: bool) -> Result<(), anyhow::Err
copy_if_modified(source_file, destination_file, link_libs)?;

if debug_mode && os == "windows" {
let source_file = adjust_canonicalization(
fs::canonicalize(source_folder)?.join("dclgodot.pdb".to_string()),
);
let destination_file = adjust_canonicalization(
fs::canonicalize(lib_folder.as_str())?.join("dclgodot.pdb".to_string()),
);
let source_file =
adjust_canonicalization(fs::canonicalize(source_folder)?.join("dclgodot.pdb"));
let destination_file =
adjust_canonicalization(fs::canonicalize(lib_folder.as_str())?.join("dclgodot.pdb"));
copy_if_modified(source_file, destination_file, link_libs)?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn main() -> Result<(), anyhow::Error> {
("run", sm) => {
let mut build_args: Vec<&str> = sm
.values_of("build-args")
.map(|v| v.map(|it| it.into()).collect())
.map(|v| v.collect())
.unwrap_or_default();

if sm.is_present("resource-tracking") {
Expand Down
6 changes: 1 addition & 5 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ pub fn run(
extras: Vec<String>,
with_build_envs: Option<HashMap<String, String>>,
) -> Result<(), anyhow::Error> {
let with_build_envs = match with_build_envs {
Some(vars) => vars,
None => HashMap::new(),
};

let with_build_envs = with_build_envs.unwrap_or_default();
let program = adjust_canonicalization(
std::fs::canonicalize(format!(
"{}godot/{}",
Expand Down

0 comments on commit 0f4b670

Please sign in to comment.