rnd-20100107-2-src
authorHolger Schemel <info@artsoft.org>
Thu, 7 Jan 2010 16:09:59 +0000 (17:09 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:58:15 +0000 (10:58 +0200)
* added handling of gravity ports when converting Supaplex style R'n'D
  levels to native Supaplex levels for playing with Supaplex engine

ChangeLog
src/conftime.h
src/files.c

index fc0dd1c7f714fba66c2bac7f75e01c0cfcc90f0d..17c8df158fa44910511d888fe915fba09405632b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-01-07
+       * added handling of gravity ports when converting Supaplex style R'n'D
+         levels to native Supaplex levels for playing with Supaplex engine
+
 2010-01-06
        * fixed bug in Supaplex engine regarding initial screen scroll position
 
index 86fdfa2746cfa29f147b8332afa4be45669dd701..587a3c61c2bfd37e010fb6d901d1f7be45559d31 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2010-01-07 00:44"
+#define COMPILE_DATE_STRING "2010-01-07 17:02"
index cd288bce594a83cd27d8570348372e2e914d1faf..a969861edebc5eca093742203a1ef693fedf7e52 100644 (file)
@@ -4212,7 +4212,7 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
   LevelInfoType *header = &level_sp->header;
   int i, x, y;
 
-  level_sp->width = level->fieldx;
+  level_sp->width  = level->fieldx;
   level_sp->height = level->fieldy;
 
   for (x = 0; x < level->fieldx; x++)
@@ -4244,7 +4244,67 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level)
 
   header->InfotronsNeeded = level->gems_needed;
 
-  /* !!! ADD SPECIAL PORT DATABASE STUFF !!! */
+  header->SpecialPortCount = 0;
+
+  for (x = 0; x < level->fieldx; x++) for (y = 0; y < level->fieldy; y++)
+  {
+    boolean gravity_port_found = FALSE;
+    boolean gravity_port_valid = FALSE;
+    int gravity_port_flag;
+    int gravity_port_base_element;
+    int element = level->field[x][y];
+
+    if (element >= EL_SP_GRAVITY_ON_PORT_RIGHT &&
+       element <= EL_SP_GRAVITY_ON_PORT_UP)
+    {
+      gravity_port_found = TRUE;
+      gravity_port_valid = TRUE;
+      gravity_port_flag = 1;
+      gravity_port_base_element = EL_SP_GRAVITY_ON_PORT_RIGHT;
+    }
+    else if (element >= EL_SP_GRAVITY_OFF_PORT_RIGHT &&
+            element <= EL_SP_GRAVITY_OFF_PORT_UP)
+    {
+      gravity_port_found = TRUE;
+      gravity_port_valid = TRUE;
+      gravity_port_flag = 0;
+      gravity_port_base_element = EL_SP_GRAVITY_OFF_PORT_RIGHT;
+    }
+    else if (element >= EL_SP_GRAVITY_PORT_RIGHT &&
+            element <= EL_SP_GRAVITY_PORT_UP)
+    {
+      /* change R'n'D style gravity inverting special port to normal port
+        (there are no gravity inverting ports in native Supaplex engine) */
+
+      gravity_port_found = TRUE;
+      gravity_port_valid = FALSE;
+      gravity_port_base_element = EL_SP_GRAVITY_PORT_RIGHT;
+    }
+
+    if (gravity_port_found)
+    {
+      if (gravity_port_valid &&
+         header->SpecialPortCount < SP_MAX_SPECIAL_PORTS)
+      {
+       SpecialPortType *port = &header->SpecialPort[header->SpecialPortCount];
+
+       port->PortLocation = (y * level->fieldx + x) * 2;
+       port->Gravity = gravity_port_flag;
+
+       element += EL_SP_GRAVITY_PORT_RIGHT - gravity_port_base_element;
+
+       header->SpecialPortCount++;
+      }
+      else
+      {
+       /* change special gravity port to normal port */
+
+       element += EL_SP_PORT_RIGHT - gravity_port_base_element;
+      }
+
+      level_sp->playfield[x][y] = element - EL_SP_START;
+    }
+  }
 }
 
 void CopyNativeLevel_SP_to_RND(struct LevelInfo *level)