Fix nasty bug when generating map of objects with extra properties

This commit is contained in:
Lucas S. Vieira 2024-12-22 23:18:55 -03:00
parent db173b5756
commit cf7931a34b
2 changed files with 29 additions and 17 deletions

View file

@ -164,18 +164,19 @@ def parse_object_group(
p.rotcw = int(float(obj.get("rotation", 0))) == 90
p.rotct = int(float(obj.get("rotation", 0))) == -90
props = obj.find("properties")
if props:
if p.otype == ObjectId.MONITOR.value:
if p.otype == ObjectId.MONITOR.value:
m = MonitorProperties()
if props:
prop = props.find("property")
m = MonitorProperties()
m.kind = MonitorKind.get(prop.get("value")).value
p.properties = m
elif p.otype == ObjectId.BUBBLE_PATCH.value:
p.properties = m
elif p.otype == ObjectId.BUBBLE_PATCH.value:
bp = BubblePatchProperties()
if props:
prop = props.find("property")
bp = BubblePatchProperties()
# Get first available value
bp.frequency = int(prop.get("value"))
p.properties = bp
p.properties = bp
# print(
# f"Object type {current_ts.object_types[p.otype + current_ts.firstgid].name if p.otype >= 0 else 'DUMMY'}"
# )

View file

@ -4,16 +4,21 @@ enum ObjectType: s8 {
RING_3V = 0xfe, // -2
RING_3H = 0xff, // -1
RING = 0,
MONITOR = 1,
SPIKES = 2,
CHECKPOINT = 3,
SPRING_YELLOW = 4,
SPRING_RED = 5,
SPRING_YELLOW_DIAGONAL = 6,
SPRING_RED_DIAGONAL = 7,
GOAL_SIGN = 8,
SWITCH = 9,
RING = 0x0,
MONITOR = 0x1,
SPIKES = 0x2,
CHECKPOINT = 0x3,
SPRING_YELLOW = 0x4,
SPRING_RED = 0x5,
SPRING_YELLOW_DIAGONAL = 0x6,
SPRING_RED_DIAGONAL = 0x7,
SWITCH = 0x8,
GOAL_SIGN = 0x9,
EXPLOSION = 0xa,
MONITOR_IMAGE = 0xb,
SHIELD = 0xc,
BUBBLE_PATCH = 0xd,
BUBBLE = 0xe
};
enum MonitorKind: u8 {
@ -38,6 +43,10 @@ struct MonitorProperties {
MonitorKind kind;
};
struct BubblePatchProperties {
u8 frequency;
};
struct ObjectPlacement {
u8 is_level_specific;
ObjectType type;
@ -48,6 +57,8 @@ struct ObjectPlacement {
// Properties, type-dependent
if(type == ObjectType::MONITOR) {
MonitorProperties properties;
} else if(type == ObjectType::BUBBLE_PATCH) {
BubblePatchProperties properties;
}
};