Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12381
Modified Files:
level.cpp level.h screen.h
Log Message:
- replaced a few pure pointers with std::vector<>
Index: level.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- level.cpp 13 Apr 2004 11:34:52 -0000 1.34
+++ level.cpp 16 Apr 2004 14:26:19 -0000 1.35
@@ -211,23 +211,21 @@
for(int i = 0; i < 15; ++i)
{
- ia_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ ia_tiles[i].resize(width+1, 0);
ia_tiles[i][width] = (unsigned int) '\0';
+
for(int y = 0; y < width; ++y)
ia_tiles[i][y] = 0;
- ia_tiles[i][width] = (unsigned int) '\0';
- bg_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ bg_tiles[i].resize(width+1, 0);
bg_tiles[i][width] = (unsigned int) '\0';
for(int y = 0; y < width; ++y)
bg_tiles[i][y] = 0;
- bg_tiles[i][width] = (unsigned int) '\0';
- fg_tiles[i] = (unsigned int*) malloc((width+1)*sizeof(unsigned int));
+ fg_tiles[i].resize(width+1, 0);
fg_tiles[i][width] = (unsigned int) '\0';
for(int y = 0; y < width; ++y)
fg_tiles[i][y] = 0;
- fg_tiles[i][width] = (unsigned int) '\0';
}
}
@@ -391,9 +389,9 @@
for(int i = 0; i < 15; ++i)
{
- ia_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
- bg_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
- fg_tiles[i] = (unsigned int*) calloc((width +1) , sizeof(unsigned int) );
+ ia_tiles[i].resize(width + 1, 0);
+ bg_tiles[i].resize(width + 1, 0);
+ fg_tiles[i].resize(width + 1, 0);
}
int i = 0;
@@ -533,11 +531,11 @@
Level::cleanup()
{
for(int i=0; i < 15; ++i)
- free(bg_tiles[i]);
- for(int i=0; i < 15; ++i)
- free(ia_tiles[i]);
- for(int i=0; i < 15; ++i)
- free(fg_tiles[i]);
+ {
+ bg_tiles[i].clear();
+ ia_tiles[i].clear();
+ fg_tiles[i].clear();
+ }
name.clear();
author.clear();
Index: screen.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/screen.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- screen.h 13 Apr 2004 11:34:54 -0000 1.16
+++ screen.h 16 Apr 2004 14:26:19 -0000 1.17
@@ -26,7 +26,15 @@
struct Color
{
-int red, green, blue;
+ Color()
+ : red(0), green(0), blue(0)
+ {}
+
+ Color(int red_, int green_, int blue_)
+ : red(red_), green(green_), blue(blue_)
+ {}
+
+ int red, green, blue;
};
void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a);
Index: level.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/level.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- level.h 13 Apr 2004 11:34:54 -0000 1.29
+++ level.h 16 Apr 2004 14:26:19 -0000 1.30
@@ -61,9 +61,9 @@
std::string song_title;
std::string bkgd_image;
std::string particle_system;
- unsigned int* bg_tiles[15]; /* Tiles in the background */
- unsigned int* ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
- unsigned int* fg_tiles[15]; /* Tiles in the foreground */
+ std::vector<unsigned int> bg_tiles[15]; /* Tiles in the background */
+ std::vector<unsigned int> ia_tiles[15]; /* Tiles which can interact in the game (solids for example)*/
+ std::vector<unsigned int> fg_tiles[15]; /* Tiles in the foreground */
int time_left;
Color bkgd_top;
Color bkgd_bottom;
|