Skip to content

Commit 7a19dce

Browse files
committed
Fix mode types
1 parent 50dd52e commit 7a19dce

File tree

8 files changed

+376
-232
lines changed

8 files changed

+376
-232
lines changed

api/lib/src/event/process/client.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,7 @@ Future<ServerResponse?> processClientEvent(
362362
);
363363
case ModeChangeRequest():
364364
final location = event.location;
365-
final mode = location == null
366-
? null
367-
: assetManager.getPack(location.namespace)?.getMode(location.id);
365+
final mode = location == null ? null : assetManager.getModeItem(location);
368366
return UpdateServerResponse.builder(
369367
WorldInitialized.fromMode(mode, state),
370368
channel,

api/lib/src/event/server.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ final class WorldInitialized extends ServerWorldEvent
2828
});
2929

3030
factory WorldInitialized.fromMode(
31-
ItemLocation location,
32-
GameMode? mode,
31+
PackItem<GameMode>? mode,
3332
WorldState state,
3433
) => WorldInitialized(
3534
clearUserInterface: true,
36-
info: state.info.copyWith(teams: mode?.teams ?? {}, script: location),
37-
table: mode?.tables[state.tableName] ?? GameTable(),
35+
info: state.info.copyWith(
36+
teams: mode?.item.teams ?? {},
37+
script: mode?.location,
38+
),
39+
table: mode?.item.tables[state.tableName] ?? GameTable(),
3840
teamMembers: const {},
3941
);
4042
}

api/lib/src/models/config.mapper.dart

Lines changed: 162 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/lib/src/models/data.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ class SetonixData extends ArchiveData<SetonixData> {
321321
}
322322
}
323323

324+
PackItem<GameMode>? getModeItem(String id, [String namespace = '']) =>
325+
PackItem.wrap(
326+
pack: this,
327+
namespace: namespace,
328+
id: id,
329+
item: getMode(id),
330+
);
331+
324332
Map<String, GameMode> getModesData() => Map.fromEntries(
325333
getModes().map((e) {
326334
final mode = getMode(e);

0 commit comments

Comments
 (0)