Add shareware support and spawn correctly for difficulty levels
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -2,11 +2,16 @@ import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:wolf_dart/classes/matrix.dart';
|
||||
import 'package:wolf_dart/features/entities/map_objects.dart';
|
||||
import 'package:wolf_dart/features/map/wolf_level.dart';
|
||||
|
||||
abstract class WolfMapParser {
|
||||
/// Parses MAPHEAD and GAMEMAPS to extract the raw level data.
|
||||
static List<WolfLevel> parseMaps(ByteData mapHead, ByteData gameMaps) {
|
||||
static List<WolfLevel> parseMaps(
|
||||
ByteData mapHead,
|
||||
ByteData gameMaps, {
|
||||
bool isShareware = false,
|
||||
}) {
|
||||
List<WolfLevel> levels = [];
|
||||
|
||||
// 1. READ MAPHEAD
|
||||
@@ -66,6 +71,21 @@ abstract class WolfMapParser {
|
||||
Uint16List carmackExpandedObjects = _expandCarmack(compressedObjectData);
|
||||
List<int> flatObjectGrid = _expandRlew(carmackExpandedObjects, rlewTag);
|
||||
|
||||
for (int i = 0; i < flatObjectGrid.length; i++) {
|
||||
int id = flatObjectGrid[i];
|
||||
|
||||
// Handle the 'secret' pushwalls (Logic check)
|
||||
if (id == MapObject.pushwallTrigger) {
|
||||
// In Wolf3D, ID 98 means the wall at this same index in Plane 0 is pushable.
|
||||
// You might want to mark this in your engine state.
|
||||
}
|
||||
|
||||
// Filter out invalid IDs for Shareware to prevent crashes
|
||||
if (isShareware && !MapObject.isSharewareCompatible(id)) {
|
||||
flatObjectGrid[i] = 0; // Turn unknown objects into empty space
|
||||
}
|
||||
}
|
||||
|
||||
Matrix<int> wallGrid = [];
|
||||
Matrix<int> objectGrid = []; // NEW
|
||||
|
||||
|
||||
Reference in New Issue
Block a user