mirror of
https://codeberg.org/demostf/inspector.git
synced 2026-06-03 10:04:09 +02:00
fix prop search
This commit is contained in:
parent
a046b1323c
commit
d360ffec68
8 changed files with 19 additions and 19 deletions
|
|
@ -124,7 +124,7 @@ impl Parser {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(identifier, table, prop)| {
|
.map(|(identifier, table, prop)| {
|
||||||
JsValue::from_serde(&PropName {
|
JsValue::from_serde(&PropName {
|
||||||
identifier: *identifier,
|
identifier: identifier.to_string(),
|
||||||
table: table.to_string(),
|
table: table.to_string(),
|
||||||
prop: prop.to_string(),
|
prop: prop.to_string(),
|
||||||
})
|
})
|
||||||
|
|
@ -147,7 +147,7 @@ impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn search(&self, filter: JsValue) -> Vec<usize> {
|
pub fn search(&self, filter: JsValue) -> Vec<usize> {
|
||||||
let filter: SearchFilter = filter.into_serde().unwrap();
|
let filter: SearchFilter = filter.into_serde().expect("failed to parse search filter");
|
||||||
self.packets
|
self.packets
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
|
@ -158,7 +158,7 @@ impl Parser {
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct PropName {
|
pub struct PropName {
|
||||||
pub identifier: u64,
|
pub identifier: String,
|
||||||
pub table: String,
|
pub table: String,
|
||||||
pub prop: String,
|
pub prop: String,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,18 @@ use tf_demo_parser::demo::message::{
|
||||||
StringCmdMessage,
|
StringCmdMessage,
|
||||||
};
|
};
|
||||||
use tf_demo_parser::demo::packet::consolecmd::ConsoleCmdPacket;
|
use tf_demo_parser::demo::packet::consolecmd::ConsoleCmdPacket;
|
||||||
|
use tf_demo_parser::demo::packet::datatable::ClassId;
|
||||||
use tf_demo_parser::demo::packet::message::MessagePacket;
|
use tf_demo_parser::demo::packet::message::MessagePacket;
|
||||||
use tf_demo_parser::demo::packet::stringtable::{StringTableEntry, StringTablePacket};
|
use tf_demo_parser::demo::packet::stringtable::{StringTableEntry, StringTablePacket};
|
||||||
use tf_demo_parser::demo::packet::Packet;
|
use tf_demo_parser::demo::packet::Packet;
|
||||||
|
use tf_demo_parser::demo::sendprop::SendPropIdentifier;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct SearchFilter {
|
pub struct SearchFilter {
|
||||||
pub entity: u32,
|
pub entity: u32,
|
||||||
pub search: String,
|
pub search: String,
|
||||||
#[serde(default)]
|
pub prop_ids: Vec<SendPropIdentifier>,
|
||||||
pub prop_ids: Vec<u64>,
|
pub class_ids: Vec<ClassId>,
|
||||||
#[serde(default)]
|
|
||||||
pub class_ids: Vec<u32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SearchFilter {
|
impl SearchFilter {
|
||||||
|
|
@ -97,7 +97,7 @@ fn message_matches(message: &Message, filter: &SearchFilter) -> bool {
|
||||||
Message::SetView(SetViewMessage { index }) => (*index as u32) == filter.entity,
|
Message::SetView(SetViewMessage { index }) => (*index as u32) == filter.entity,
|
||||||
Message::UserMessage(_) => false,
|
Message::UserMessage(_) => false,
|
||||||
Message::EntityMessage(EntityMessage { class_id, .. }) => {
|
Message::EntityMessage(EntityMessage { class_id, .. }) => {
|
||||||
filter.class_ids.contains(&(*class_id as u32))
|
filter.class_ids.contains(&((*class_id).into()))
|
||||||
}
|
}
|
||||||
Message::GameEvent(GameEventMessage { event, .. }) => {
|
Message::GameEvent(GameEventMessage { event, .. }) => {
|
||||||
has_search && event.event_type().as_str().contains(&filter.search)
|
has_search && event.event_type().as_str().contains(&filter.search)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ interface AppState {
|
||||||
header: Header | null,
|
header: Header | null,
|
||||||
progress: number,
|
progress: number,
|
||||||
packets: PacketMeta[],
|
packets: PacketMeta[],
|
||||||
prop_names: Map<number, { table: string, prop: string }>,
|
prop_names: Map<string, { table: string, prop: string }>,
|
||||||
class_names: Map<number, string>,
|
class_names: Map<number, string>,
|
||||||
active: Packet | null,
|
active: Packet | null,
|
||||||
activeIndex: number | null,
|
activeIndex: number | null,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {filterEntity, filterMessage, isSearchEmpty, SearchFilter} from "../searc
|
||||||
|
|
||||||
export interface MessageInfoProps {
|
export interface MessageInfoProps {
|
||||||
msg: Message,
|
msg: Message,
|
||||||
prop_names: Map<number, { table: String, prop: String }>,
|
prop_names: Map<string, { table: String, prop: String }>,
|
||||||
class_names: Map<number, String>,
|
class_names: Map<number, String>,
|
||||||
search: SearchFilter
|
search: SearchFilter
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ function formatPropValue(value: SendPropValue): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatEntity(entity: PacketEntity, prop_names: Map<number, { table: String, prop: String }>, class_names: Map<number, String>,): string {
|
function formatEntity(entity: PacketEntity, prop_names: Map<string, { table: String, prop: String }>, class_names: Map<number, String>,): string {
|
||||||
let class_name = class_names.get(entity.server_class);
|
let class_name = class_names.get(entity.server_class);
|
||||||
// let baseline = entity.baseline_props.map(prop => {
|
// let baseline = entity.baseline_props.map(prop => {
|
||||||
// let names = prop_names.get(prop.identifier);
|
// let names = prop_names.get(prop.identifier);
|
||||||
|
|
|
||||||
2
www/src/parser.d.ts
vendored
2
www/src/parser.d.ts
vendored
|
|
@ -3212,7 +3212,7 @@ export type GameEventValue =
|
||||||
Boolean: boolean;
|
Boolean: boolean;
|
||||||
};
|
};
|
||||||
export type GameEventTypeId = number;
|
export type GameEventTypeId = number;
|
||||||
export type SendPropIdentifier = number;
|
export type SendPropIdentifier = string;
|
||||||
export type SendPropValue = Vector | VectorXY | number | number | string | SendPropValue[];
|
export type SendPropValue = Vector | VectorXY | number | number | string | SendPropValue[];
|
||||||
export type EntityId = number;
|
export type EntityId = number;
|
||||||
export type ClassId = number;
|
export type ClassId = number;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ export type RequestMessageData = {type: "data", data: ArrayBuffer}
|
||||||
|
|
||||||
export type ResponseMessageData = { type: "progress", progress: number }
|
export type ResponseMessageData = { type: "progress", progress: number }
|
||||||
| { type: "packet", packet: Packet }
|
| { type: "packet", packet: Packet }
|
||||||
| { type: "done", packets: PacketMeta[], header: Header, prop_names: { identifier: number, table: string, prop: string }[], class_names: { identifier: number, name: string }[] }
|
| { type: "done", packets: PacketMeta[], header: Header, prop_names: { identifier: string, table: string, prop: string }[], class_names: { identifier: number, name: string }[] }
|
||||||
| { type: "packet_names", packet: {} }
|
| { type: "packet_names", packet: {} }
|
||||||
| { type: "search_result", matches: number[] };
|
| { type: "search_result", matches: number[] };
|
||||||
|
|
@ -6,13 +6,13 @@ import {Message, Packet, SendProp, StringTable} from "./parser";
|
||||||
export interface SearchFilter {
|
export interface SearchFilter {
|
||||||
entity: number,
|
entity: number,
|
||||||
search: string,
|
search: string,
|
||||||
prop_ids: number[],
|
prop_ids: string[],
|
||||||
class_ids: number[],
|
class_ids: number[],
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchBarProps {
|
export interface SearchBarProps {
|
||||||
onSearch: (search: SearchFilter) => void,
|
onSearch: (search: SearchFilter) => void,
|
||||||
prop_names: Map<number, { table: string, prop: string }>,
|
prop_names: Map<string, { table: string, prop: string }>,
|
||||||
class_names: Map<number, string>,
|
class_names: Map<number, string>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ export function filterPacket(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterPropNames(prop_names: Map<number, { table: string, prop: string }>, filter: string): number[] {
|
function filterPropNames(prop_names: Map<string, { table: string, prop: string }>, filter: string): string[] {
|
||||||
if (filter.length === 0) {
|
if (filter.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +166,7 @@ export function filterEntity(class_id: number, props: SendProp[], search: Search
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return search.class_ids.includes(class_id) || props.some(prop => search.prop_ids.includes(prop.identifier))
|
return search.class_ids.includes(class_id) || props.some(prop => search.prop_ids.includes(`${prop.identifier}`))
|
||||||
|| props.some(prop => prop.value == search.search);
|
|| props.some(prop => prop.value == search.search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {PacketMeta, PacketType} from "./index"
|
||||||
|
|
||||||
interface TableProps {
|
interface TableProps {
|
||||||
packets: PacketMeta[],
|
packets: PacketMeta[],
|
||||||
prop_names: Map<number, { table: string, prop: string }>,
|
prop_names: Map<string, { table: string, prop: string }>,
|
||||||
class_names: Map<number, string>,
|
class_names: Map<number, string>,
|
||||||
onClick: (i: number) => void,
|
onClick: (i: number) => void,
|
||||||
activeIndex: number | null,
|
activeIndex: number | null,
|
||||||
|
|
@ -79,7 +79,7 @@ export function PacketRow({packet}: RowProps) {
|
||||||
|
|
||||||
interface DetailProps {
|
interface DetailProps {
|
||||||
packet: Packet,
|
packet: Packet,
|
||||||
prop_names: Map<number, { table: string, prop: string }>,
|
prop_names: Map<string, { table: string, prop: string }>,
|
||||||
class_names: Map<number, string>,
|
class_names: Map<number, string>,
|
||||||
search: SearchFilter,
|
search: SearchFilter,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue