|
1 | 1 | use assembly_core::buffer::CastError; |
2 | 2 | use assembly_data::{fdb::common::Latin1Str, xml::localization::LocaleNode}; |
3 | 3 | use paradox_typed_db::{ |
4 | | - typed_rows::{BehaviorTemplateRow, MissionTaskRow, MissionsRow, TypedRow}, |
| 4 | + typed_rows::{BehaviorTemplateRow, MissionTaskRow, MissionsRow, ObjectsRef, TypedRow}, |
5 | 5 | typed_tables::{BehaviorParameterTable, BehaviorTemplateTable, MissionTasksTable}, |
6 | 6 | TypedDatabase, |
7 | 7 | }; |
@@ -464,18 +464,27 @@ fn rev_mission_types_full_api(_db: &TypedDatabase, rev: Rev) -> Result<Json, Cas |
464 | 464 | Ok(warp::reply::json(&rev.inner.mission_types)) |
465 | 465 | } |
466 | 466 |
|
| 467 | +#[derive(Serialize)] |
| 468 | +struct ObjectIDs<'a, T> { |
| 469 | + object_ids: &'a [T], |
| 470 | +} |
| 471 | + |
467 | 472 | fn rev_object_type_api( |
468 | | - _db: &TypedDatabase, |
| 473 | + db: &TypedDatabase, |
469 | 474 | rev: Rev, |
470 | 475 | ty: PercentDecoded, |
471 | 476 | ) -> Result<Option<Json>, CastError> { |
472 | 477 | let key: &String = ty.borrow(); |
473 | 478 | tracing::info!("{}", key); |
474 | | - Ok(rev |
475 | | - .inner |
476 | | - .object_types |
477 | | - .get(key) |
478 | | - .map(|objects| warp::reply::json(&objects))) |
| 479 | + Ok(rev.inner.object_types.get(key).map(|objects| { |
| 480 | + let rep = Api { |
| 481 | + data: ObjectIDs { |
| 482 | + object_ids: objects.as_ref(), |
| 483 | + }, |
| 484 | + embedded: TypedTableIterAdapter::<ObjectsRef, _, _>::new(&db.objects, objects), |
| 485 | + }; |
| 486 | + warp::reply::json(&rep) |
| 487 | + })) |
479 | 488 | } |
480 | 489 |
|
481 | 490 | fn rev_object_types_api(_db: &TypedDatabase, rev: Rev) -> Result<Json, CastError> { |
|
0 commit comments