fixed using custom laser color defined in DF style laser for MM engine
authorHolger Schemel <holger.schemel@virtion.de>
Tue, 17 Jan 2023 23:09:55 +0000 (00:09 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Tue, 17 Jan 2023 23:09:55 +0000 (00:09 +0100)
src/files.c
src/game_mm/export.h
src/game_mm/mm_files.c
src/game_mm/mm_game.c

index 926ce926d71ff247a157b8ad9a47c381cc28e490..fb0c740cb3f117a4622b29faefc851ba485697cb 100644 (file)
@@ -4161,9 +4161,13 @@ static void CopyNativeLevel_RND_to_MM(struct LevelInfo *level)
   level_mm->kettles_needed = level->gems_needed;
   level_mm->auto_count_kettles = level->auto_count_gems;
 
-  level_mm->laser_red = level->mm_laser_red;
-  level_mm->laser_green = level->mm_laser_green;
-  level_mm->laser_blue = level->mm_laser_blue;
+  level_mm->mm_laser_red   = level->mm_laser_red;
+  level_mm->mm_laser_green = level->mm_laser_green;
+  level_mm->mm_laser_blue  = level->mm_laser_blue;
+
+  level_mm->df_laser_red   = level->df_laser_red;
+  level_mm->df_laser_green = level->df_laser_green;
+  level_mm->df_laser_blue  = level->df_laser_blue;
 
   strcpy(level_mm->name, level->name);
   strcpy(level_mm->author, level->author);
@@ -4205,9 +4209,13 @@ static void CopyNativeLevel_MM_to_RND(struct LevelInfo *level)
   level->gems_needed = level_mm->kettles_needed;
   level->auto_count_gems = level_mm->auto_count_kettles;
 
-  level->mm_laser_red = level_mm->laser_red;
-  level->mm_laser_green = level_mm->laser_green;
-  level->mm_laser_blue = level_mm->laser_blue;
+  level->mm_laser_red   = level_mm->mm_laser_red;
+  level->mm_laser_green = level_mm->mm_laser_green;
+  level->mm_laser_blue  = level_mm->mm_laser_blue;
+
+  level->df_laser_red   = level_mm->df_laser_red;
+  level->df_laser_green = level_mm->df_laser_green;
+  level->df_laser_blue  = level_mm->df_laser_blue;
 
   strcpy(level->name, level_mm->name);
 
index e9d84fda44a870cfea5940571bdbf5e6595275c8..b628a8d04c3b16ae3cee8b7479bd175abacaf173 100644 (file)
@@ -141,6 +141,7 @@ struct GameInfo_MM
   int lights_still_needed;
   int num_keys;
   int ball_choice_pos;         // current content element choice position
+  boolean laser_red, laser_green, laser_blue;
 
   boolean level_solved;
   boolean game_over;
@@ -164,7 +165,8 @@ struct LevelInfo_MM
   int time;
   int kettles_needed;
   boolean auto_count_kettles;
-  boolean laser_red, laser_green, laser_blue;
+  boolean mm_laser_red, mm_laser_green, mm_laser_blue;
+  boolean df_laser_red, df_laser_green, df_laser_blue;
   char name[MM_MAX_LEVEL_NAME_LEN + 1];
   char author[MM_MAX_LEVEL_AUTHOR_LEN + 1];
   int score[MM_LEVEL_SCORE_ELEMENTS];
index d334b8a0b3fb8932bb289172f9012c55c76be3b4..4a85360925f4b409d969d114a3fca4718a6195ce 100644 (file)
@@ -112,9 +112,12 @@ void setLevelInfoToDefaults_MM(void)
   native_mm_level.time_bomb = 75;
   native_mm_level.time_ball = 75;
   native_mm_level.time_block = 75;
-  native_mm_level.laser_red = FALSE;
-  native_mm_level.laser_green = FALSE;
-  native_mm_level.laser_blue = TRUE;
+  native_mm_level.mm_laser_red = FALSE;
+  native_mm_level.mm_laser_green = FALSE;
+  native_mm_level.mm_laser_blue = TRUE;
+  native_mm_level.df_laser_red = TRUE;
+  native_mm_level.df_laser_green = TRUE;
+  native_mm_level.df_laser_blue = FALSE;
 
   for (i = 0; i < MAX_LEVEL_NAME_LEN; i++)
     native_mm_level.name[i] = '\0';
@@ -209,9 +212,9 @@ static int LoadLevel_MM_HEAD(File *file, int chunk_size,
     level->time_fuse = 25;
 
   laser_color                  = getFile8Bit(file);
-  level->laser_red             = (laser_color >> 2) & 0x01;
-  level->laser_green           = (laser_color >> 1) & 0x01;
-  level->laser_blue            = (laser_color >> 0) & 0x01;
+  level->mm_laser_red          = (laser_color >> 2) & 0x01;
+  level->mm_laser_green                = (laser_color >> 1) & 0x01;
+  level->mm_laser_blue         = (laser_color >> 0) & 0x01;
 
   level->encoding_16bit_field  = (getFile8Bit(file) == 1 ? TRUE : FALSE);
 
@@ -401,9 +404,9 @@ static void SaveLevel_MM_HEAD(FILE *file, struct LevelInfo_MM *level)
   fputc(level->amoeba_speed, file);
   fputc(level->time_fuse, file);
 
-  laser_color = ((level->laser_red   << 2) |
-                (level->laser_green << 1) |
-                (level->laser_blue  << 0));
+  laser_color = ((level->mm_laser_red   << 2) |
+                (level->mm_laser_green << 1) |
+                (level->mm_laser_blue  << 0));
   fputc(laser_color, file);
 
   fputc((level->encoding_16bit_field ? 1 : 0), file);
index 571c9094240bd8b4a0019a50fcbc1ade8dc746c9..45c65634a9985556c75420f04edc463ead080198 100644 (file)
@@ -433,9 +433,9 @@ static void SetLaserColor(int brightness)
 
   pen_ray =
     GetPixelFromRGB(window,
-                   (native_mm_level.laser_red   ? color_max  : color_up),
-                   (native_mm_level.laser_green ? color_down : color_min),
-                   (native_mm_level.laser_blue  ? color_down : color_min));
+                   (game_mm.laser_red   ? color_max  : color_up),
+                   (game_mm.laser_green ? color_down : color_min),
+                   (game_mm.laser_blue  ? color_down : color_min));
 }
 
 static void InitMovDir_MM(int x, int y)
@@ -538,6 +538,19 @@ static void InitField(int x, int y)
        laser.start_edge.x = x;
        laser.start_edge.y = y;
        laser.start_angle = get_element_angle(element);
+
+        if (IS_MCDUFFIN(element))
+        {
+          game_mm.laser_red   = native_mm_level.mm_laser_red;
+          game_mm.laser_green = native_mm_level.mm_laser_green;
+          game_mm.laser_blue  = native_mm_level.mm_laser_blue;
+        }
+        else
+        {
+          game_mm.laser_red   = native_mm_level.df_laser_red;
+          game_mm.laser_green = native_mm_level.df_laser_green;
+          game_mm.laser_blue  = native_mm_level.df_laser_blue;
+        }
       }
 
       break;
@@ -627,6 +640,10 @@ void InitGameEngine_MM(void)
   game_mm.num_keys = 0;
   game_mm.ball_choice_pos = 0;
 
+  game_mm.laser_red = FALSE;
+  game_mm.laser_green = FALSE;
+  game_mm.laser_blue = TRUE;
+
   game_mm.level_solved = FALSE;
   game_mm.game_over = FALSE;
   game_mm.game_over_cause = 0;