summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/util.cpp
authorsudonix <sudonix>2004-02-26 02:25:15 (UTC)
committer sudonix <sudonix>2004-02-26 02:25:15 (UTC)
commitb339031e14a607ff18e404e0395b1c2782b92fdc (patch) (side-by-side diff)
treeecd65299976322166ee5dfb2c30f045dd542c1e1 /noncore/games/sfcave-sdl/util.cpp
parentcb72ff620022306e493421006b024b971449f864 (diff)
downloadopie-b339031e14a607ff18e404e0395b1c2782b92fdc.zip
opie-b339031e14a607ff18e404e0395b1c2782b92fdc.tar.gz
opie-b339031e14a607ff18e404e0395b1c2782b92fdc.tar.bz2
SDL includes corrected, CRs in some files removed, just for consistency :)
Diffstat (limited to 'noncore/games/sfcave-sdl/util.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/util.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/noncore/games/sfcave-sdl/util.cpp b/noncore/games/sfcave-sdl/util.cpp
index f73e256..743f16e 100644
--- a/noncore/games/sfcave-sdl/util.cpp
+++ b/noncore/games/sfcave-sdl/util.cpp
@@ -1,75 +1,75 @@
-#include "SDL.h"
-
-#include <dirent.h>
-
-#include <vector>
-using namespace std;
-
-#include "util.h"
-#include "random.h"
-
-Uint32 getpixel(SDL_Surface *surface, int x, int y)
-{
- int bpp = surface->format->BytesPerPixel;
- /* Here p is the address to the pixel we want to retrieve */
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
-
- switch(bpp) {
- case 1:
- return *p;
-
- case 2:
- return *(Uint16 *)p;
-
- case 3:
- if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
- return p[0] << 16 | p[1] << 8 | p[2];
- else
- return p[0] | p[1] << 8 | p[2] << 16;
-
- case 4:
- return *(Uint32 *)p;
-
- default:
- return 0; /* shouldn't happen, but avoids warnings */
- }
-}
-
-string chooseRandomFile( string path, string fileType )
-{
- vector<string> files;
- DIR *d = opendir( path.c_str() );
- if ( !d )
- return "";
-
- struct dirent *item = readdir( d );
- while ( item )
- {
- string file = string( path ) + item->d_name;
-
- // Rip extension from file
- int pos = file.find( ".", 1 ) + 1;
- string tmp = file.substr( pos );
- if ( tmp.size() > 0 && fileType.find( tmp ) != -1 )
- {
- files.push_back( file );
- }
- item = readdir( d );
- }
-
- closedir( d );
- return files[nextInt( files.size() )];
-}
-
-
-string getHomeDir()
-{
- string home;
-#ifdef QWS
- home = getenv( "HOME" );
-#else
- home = ".";
-#endif
-
- return home;
-}
+#include <SDL/SDL.h>
+
+#include <dirent.h>
+
+#include <vector>
+using namespace std;
+
+#include "util.h"
+#include "random.h"
+
+Uint32 getpixel(SDL_Surface *surface, int x, int y)
+{
+ int bpp = surface->format->BytesPerPixel;
+ /* Here p is the address to the pixel we want to retrieve */
+ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+
+ switch(bpp) {
+ case 1:
+ return *p;
+
+ case 2:
+ return *(Uint16 *)p;
+
+ case 3:
+ if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
+ return p[0] << 16 | p[1] << 8 | p[2];
+ else
+ return p[0] | p[1] << 8 | p[2] << 16;
+
+ case 4:
+ return *(Uint32 *)p;
+
+ default:
+ return 0; /* shouldn't happen, but avoids warnings */
+ }
+}
+
+string chooseRandomFile( string path, string fileType )
+{
+ vector<string> files;
+ DIR *d = opendir( path.c_str() );
+ if ( !d )
+ return "";
+
+ struct dirent *item = readdir( d );
+ while ( item )
+ {
+ string file = string( path ) + item->d_name;
+
+ // Rip extension from file
+ int pos = file.find( ".", 1 ) + 1;
+ string tmp = file.substr( pos );
+ if ( tmp.size() > 0 && fileType.find( tmp ) != -1 )
+ {
+ files.push_back( file );
+ }
+ item = readdir( d );
+ }
+
+ closedir( d );
+ return files[nextInt( files.size() )];
+}
+
+
+string getHomeDir()
+{
+ string home;
+#ifdef QWS
+ home = getenv( "HOME" );
+#else
+ home = ".";
+#endif
+
+ return home;
+}