fix issues
This commit is contained in:
parent
92ba5b1a75
commit
747e37409f
3 changed files with 32 additions and 32 deletions
|
|
@ -180,11 +180,14 @@ impl MatchmakeExtension for User {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_progress_score(&self, gid: u32, progress: u8) -> Result<(), ErrorCode> {
|
async fn update_progress_score(&self, gid: u32, progress: u8) -> Result<(), ErrorCode> {
|
||||||
let session = self.matchmake_manager.get_session(gid).await?;
|
#[cfg(feature = "v3-5-0")]
|
||||||
|
{
|
||||||
|
let session = self.matchmake_manager.get_session(gid).await?;
|
||||||
|
|
||||||
let mut session = session.lock().await;
|
let mut session = session.lock().await;
|
||||||
|
|
||||||
session.session.progress_score = progress;
|
session.session.progress_score = progress;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use log::{info, warn};
|
|
||||||
use rnex_core::rmc::structures::{Result, RmcSerialize};
|
use rnex_core::rmc::structures::{Result, RmcSerialize};
|
||||||
use std::io::{Cursor, Read, Write};
|
use std::io::{Cursor, Read, Write};
|
||||||
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
|
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
|
||||||
|
|
@ -12,32 +11,21 @@ pub struct Any {
|
||||||
impl RmcSerialize for Any {
|
impl RmcSerialize for Any {
|
||||||
fn serialize(&self, writer: &mut impl Write) -> Result<()> {
|
fn serialize(&self, writer: &mut impl Write) -> Result<()> {
|
||||||
self.name.serialize(writer)?;
|
self.name.serialize(writer)?;
|
||||||
let u32_len = self.data.len() as u32 - 1;
|
|
||||||
|
let u32_len = self.data.len() as u32;
|
||||||
(u32_len + 4).serialize(writer)?;
|
(u32_len + 4).serialize(writer)?;
|
||||||
u32_len.serialize(writer)?;
|
self.data.serialize(writer)?;
|
||||||
writer.write_all(&self.data)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn deserialize(reader: &mut impl Read) -> Result<Self> {
|
fn deserialize(reader: &mut impl Read) -> Result<Self> {
|
||||||
let name = String::deserialize(reader)?;
|
let name = String::deserialize(reader)?;
|
||||||
|
|
||||||
let size = u32::deserialize(reader)? as usize + 1;
|
// also length ?
|
||||||
let mut buf = vec![0; size];
|
let _len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||||
reader.read_exact(&mut buf[..])?;
|
let data = Vec::deserialize(reader)?;
|
||||||
let mut cursor = Cursor::new(&buf);
|
|
||||||
let len2: u32 = cursor.read_struct(IS_BIG_ENDIAN)?;
|
|
||||||
|
|
||||||
if len2 as usize + 3 != size {
|
Ok(Any { name, data })
|
||||||
warn!("mismatched sizes on any: {} vs {}", size, len2 + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("any data: {}", hex::encode(&buf));
|
|
||||||
|
|
||||||
Ok(Any {
|
|
||||||
name,
|
|
||||||
data: (&buf[4..]).to_owned(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,8 +46,6 @@ impl Any {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::io::Cursor;
|
|
||||||
|
|
||||||
use crate::rmc::structures::{
|
use crate::rmc::structures::{
|
||||||
RmcSerialize,
|
RmcSerialize,
|
||||||
any::Any,
|
any::Any,
|
||||||
|
|
@ -68,6 +54,21 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
|
let any = Any {
|
||||||
|
name: "MatchmakeSession".into(),
|
||||||
|
data: [
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 98, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 20, 0, 68, 111, 111, 114, 115, 32, 70, 114, 105, 101, 110, 100, 32,
|
||||||
|
73, 110, 118, 105, 116, 101, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 1, 2, 3, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("{}", hex::encode(&any.data));
|
||||||
|
|
||||||
|
let _: MatchmakeSession = any.try_get().unwrap().unwrap();
|
||||||
let sess = MatchmakeSession {
|
let sess = MatchmakeSession {
|
||||||
gathering: Gathering {
|
gathering: Gathering {
|
||||||
self_gid: 0,
|
self_gid: 0,
|
||||||
|
|
@ -87,18 +88,15 @@ mod test {
|
||||||
matchmake_system_type: 2,
|
matchmake_system_type: 2,
|
||||||
application_buffer: [1, 2, 3].into(),
|
application_buffer: [1, 2, 3].into(),
|
||||||
participation_count: 0,
|
participation_count: 0,
|
||||||
|
#[cfg(feature = "v3-5-0")]
|
||||||
progress_score: 0,
|
progress_score: 0,
|
||||||
session_key: [].into(),
|
session_key: [].into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let any = Any::new(&sess).unwrap().to_data().unwrap();
|
let any = Any::new(&sess).unwrap();
|
||||||
|
|
||||||
let sess2: MatchmakeSession = Any::deserialize(&mut Cursor::new(any))
|
let sess2: MatchmakeSession = any.try_get().unwrap().unwrap();
|
||||||
.unwrap()
|
|
||||||
.try_get()
|
|
||||||
.unwrap()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(sess, sess2);
|
assert_eq!(sess, sess2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ cfg_if! {
|
||||||
pub matchmake_system_type: u32,
|
pub matchmake_system_type: u32,
|
||||||
pub application_buffer: Vec<u8>,
|
pub application_buffer: Vec<u8>,
|
||||||
pub participation_count: u32,
|
pub participation_count: u32,
|
||||||
pub progress_score: u8,
|
|
||||||
pub session_key: Vec<u8>,
|
pub session_key: Vec<u8>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue