- add: Not hardcoded object tag for the user when switching to the in game map
This commit was merged in pull request #11.
This commit is contained in:
@@ -7,8 +7,6 @@ use crate::enums::ItemType;
|
|||||||
use crate::packet::{send_packet, Packet, PacketPayload};
|
use crate::packet::{send_packet, Packet, PacketPayload};
|
||||||
use crate::packet_type::PacketType;
|
use crate::packet_type::PacketType;
|
||||||
use crate::packets::*;
|
use crate::packets::*;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::env;
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
@@ -16,6 +14,17 @@ use tokio::sync::Mutex;
|
|||||||
use tonic::{Code, Status};
|
use tonic::{Code, Status};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, warn};
|
||||||
use utils::null_string::NullTerminatedString;
|
use utils::null_string::NullTerminatedString;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
|
||||||
|
|
||||||
|
fn string_to_u32(s: &str) -> u32 {
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
s.hash(&mut hasher);
|
||||||
|
// Convert the 64-bit hash to a 32-bit number.
|
||||||
|
// Note: This cast might lead to collisions if there are a lot of objects,
|
||||||
|
hasher.finish() as u32
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn convert_slot_to_equip_slot(slot: i32) -> srv_char_list_reply::EquippedPosition {
|
pub(crate) fn convert_slot_to_equip_slot(slot: i32) -> srv_char_list_reply::EquippedPosition {
|
||||||
match enums::EquippedPosition::from_i32(slot) {
|
match enums::EquippedPosition::from_i32(slot) {
|
||||||
@@ -368,10 +377,9 @@ pub(crate) async fn handle_select_char_req(
|
|||||||
pat_cooldown_time: stats.pat_cooldown_time as u32,
|
pat_cooldown_time: stats.pat_cooldown_time as u32,
|
||||||
skills: skill_list,
|
skills: skill_list,
|
||||||
hotbar: hotbar_list,
|
hotbar: hotbar_list,
|
||||||
tag: 100,
|
tag: string_to_u32(&user_id),
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
debug!("{:?}", data);
|
|
||||||
let response_packet = Packet::new(PacketType::PakwcSelectCharReply, &data)?;
|
let response_packet = Packet::new(PacketType::PakwcSelectCharReply, &data)?;
|
||||||
send_packet(stream, &response_packet).await?;
|
send_packet(stream, &response_packet).await?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user