Преглед на файлове

Update parsing of new object_event macro

Marcus Huderle преди 6 години
родител
ревизия
a89dc22245
променени са 1 файла, в които са добавени 9 реда и са изтрити 35 реда
  1. 9
    35
      project.cpp

+ 9
- 35
project.cpp Целия файл

@@ -1292,29 +1292,22 @@ void Project::saveMapEvents(Map *map) {
1292 1292
             Event *object_event = map->events["object"].value(i);
1293 1293
             int radius_x = object_event->getInt("radius_x");
1294 1294
             int radius_y = object_event->getInt("radius_y");
1295
-            QString radius = QString("%1").arg((radius_x & 0xf) + ((radius_y & 0xf) << 4));
1296 1295
             uint16_t x = object_event->getInt("x");
1297 1296
             uint16_t y = object_event->getInt("y");
1298 1297
 
1299 1298
             text += QString("\tobject_event %1").arg(i + 1);
1300 1299
             text += QString(", %1").arg(object_event->get("sprite"));
1301 1300
             text += QString(", %1").arg(object_event->get("replacement"));
1302
-            text += QString(", %1").arg(x & 0xff);
1303
-            text += QString(", %1").arg((x >> 8) & 0xff);
1304
-            text += QString(", %1").arg(y & 0xff);
1305
-            text += QString(", %1").arg((y >> 8) & 0xff);
1301
+            text += QString(", %1").arg(x);
1302
+            text += QString(", %1").arg(y);
1306 1303
             text += QString(", %1").arg(object_event->get("elevation"));
1307 1304
             text += QString(", %1").arg(object_event->get("behavior"));
1308
-            text += QString(", %1").arg(radius);
1309
-            text += QString(", 0");
1305
+            text += QString(", %1").arg(radius_x);
1306
+            text += QString(", %1").arg(radius_y);
1310 1307
             text += QString(", %1").arg(object_event->get("property"));
1311
-            text += QString(", 0");
1312 1308
             text += QString(", %1").arg(object_event->get("sight_radius"));
1313
-            text += QString(", 0");
1314 1309
             text += QString(", %1").arg(object_event->get("script_label"));
1315 1310
             text += QString(", %1").arg(object_event->get("event_flag"));
1316
-            text += QString(", 0");
1317
-            text += QString(", 0");
1318 1311
             text += "\n";
1319 1312
         }
1320 1313
         text += "\n";
@@ -1422,34 +1415,15 @@ void Project::readMapEvents(Map *map) {
1422 1415
         if (command.value(0) == "object_event") {
1423 1416
             Event *object = new Event;
1424 1417
             object->put("map_name", map->name);
1425
-            // This macro is not fixed as of writing, but it should take fewer args.
1426
-            bool old_macro = false;
1427
-            if (command.length() >= 20) {
1428
-                command.removeAt(19);
1429
-                command.removeAt(18);
1430
-                command.removeAt(15);
1431
-                command.removeAt(13);
1432
-                command.removeAt(11);
1433
-                command.removeAt(1); // id. not 0, but is just the index in the list of objects
1434
-                old_macro = true;
1435
-            }
1436
-            int i = 1;
1418
+            int i = 2;
1437 1419
             object->put("sprite", command.value(i++));
1438 1420
             object->put("replacement", command.value(i++));
1439
-            int16_t x = command.value(i++).toInt(nullptr, 0) | (command.value(i++).toInt(nullptr, 0) << 8);
1440
-            int16_t y = command.value(i++).toInt(nullptr, 0) | (command.value(i++).toInt(nullptr, 0) << 8);
1441
-            object->put("x", x);
1442
-            object->put("y", y);
1421
+            object->put("x", command.value(i++).toInt(nullptr, 0));
1422
+            object->put("y", command.value(i++).toInt(nullptr, 0));
1443 1423
             object->put("elevation", command.value(i++));
1444 1424
             object->put("behavior", command.value(i++));
1445
-            if (old_macro) {
1446
-                int radius = command.value(i++).toInt(nullptr, 0);
1447
-                object->put("radius_x", radius & 0xf);
1448
-                object->put("radius_y", (radius >> 4) & 0xf);
1449
-            } else {
1450
-                object->put("radius_x", command.value(i++));
1451
-                object->put("radius_y", command.value(i++));
1452
-            }
1425
+            object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1426
+            object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1453 1427
             object->put("property", command.value(i++));
1454 1428
             object->put("sight_radius", command.value(i++));
1455 1429
             object->put("script_label", command.value(i++));