- cleaned up the way badguys are handled
authorIngo Ruhnke <grumbel@gmx.de>
Thu, 25 Mar 2004 12:15:47 +0000 (12:15 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Thu, 25 Mar 2004 12:15:47 +0000 (12:15 +0000)
SVN-Revision: 360

src/gameloop.cpp
src/level.cpp

index 099643a..bb8d76b 100644 (file)
@@ -100,28 +100,12 @@ void start_timers(void)
 
 void activate_bad_guys(void)
 {
-  // Activate badguys the new style
   for (std::vector<BadGuyData>::iterator i = current_level.badguy_data.begin();
        i != current_level.badguy_data.end();
        ++i)
     {
       add_bad_guy(i->x, i->y, i->kind);
     }
-
-  // FIXME: should be removed;
-  // Activate bad guys the old style
-  for (int y = 0; y < 15; y++)
-    {
-      for (int x = 0; x < current_level.width; x++)
-        {
-          if (current_level.ia_tiles[y][x] >= 1000 && current_level.ia_tiles[y][x] <= 1010)
-            {
-              add_bad_guy(x * 32, y * 32,  
-                          static_cast<BadGuyKind>(current_level.ia_tiles[y][x] - 1000));
-              current_level.ia_tiles[y][x] = 0;
-            }
-        }
-    }
 }
 
 void activate_particle_systems(void)
index bc515db..9fb802c 100644 (file)
@@ -322,9 +322,6 @@ int level_load(st_level* plevel, const char* filename)
         {
           std::map<char, int> transtable;
           transtable['.'] = 0;
-          transtable['0'] = 1000;
-          transtable['1'] = 1001;
-          transtable['2'] = 1002;
           transtable['x'] = 104;
           transtable['X'] = 77;
           transtable['y'] = 78;
@@ -363,13 +360,29 @@ int level_load(st_level* plevel, const char* filename)
           transtable['\\'] = 81;
           transtable['&'] = 75;
 
+          int x = 0;
+          int y = 0;
           for(std::vector<int>::iterator i = ia_tm.begin(); i != ia_tm.end(); ++i)
             {
-              std::map<char, int>::iterator j = transtable.find(*i);
-              if (j != transtable.end())
-                *i = j->second;
+              if (*i == '0' || *i == '1' || *i == '2')
+                {
+                  plevel->badguy_data.push_back(BadGuyData(static_cast<BadGuyKind>(*i-'0'),
+                                                           x*32, y*32));
+                  *i = 0;
+                }
               else
-                printf("Error: conversion will fail, unsupported char: '%c' (%d)\n", *i, *i);
+                {
+                  std::map<char, int>::iterator j = transtable.find(*i);
+                  if (j != transtable.end())
+                    *i = j->second;
+                  else
+                    printf("Error: conversion will fail, unsupported char: '%c' (%d)\n", *i, *i);
+                }
+              ++x;
+              if (x >= plevel->width) {
+                x = 0;
+                ++y;
+              }
             }
         }
     }