Update of /cvsroot/regcom/regcom/src
In directory usw-pr-cvs1:/tmp/cvs-serv29350
Modified Files:
Surface.cpp
Log Message:
(Load) Modified to search alternative data paths.
Index: Surface.cpp
===================================================================
RCS file: /cvsroot/regcom/regcom/src/Surface.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Surface.cpp 2001/07/06 23:01:48 1.4
--- Surface.cpp 2001/08/12 22:59:49 1.5
***************
*** 28,35 ****
#include "Surface.h"
- #ifndef GAME_DATADIR
- #define GAME_DATADIR "data"
- #endif
-
#define IMAGE_SUB "images"
--- 28,31 ----
***************
*** 79,87 ****
//----------------------------------------------------------------------
! int Surface::Load(const char* name)
{
! if (m_surface) SDL_FreeSurface(m_surface);
!
! long size = strlen(GAME_DATADIR) + strlen(PATH_SEP) +
strlen(IMAGE_SUB) + strlen(PATH_SEP) + strlen(name) + 1;
--- 75,81 ----
//----------------------------------------------------------------------
! int Surface::Load(const char* path, const char* name)
{
! long size = strlen(path) + strlen(PATH_SEP) +
strlen(IMAGE_SUB) + strlen(PATH_SEP) + strlen(name) + 1;
***************
*** 89,104 ****
sprintf(buffer,"%s%s%s%s%s",
! GAME_DATADIR,PATH_SEP,IMAGE_SUB,PATH_SEP,name);
m_surface = SDL_LoadBMP(buffer);
if (m_surface == NULL) {
! fprintf(stderr, "SDL_LoadBMP: %s\n",SDL_GetError());
exit(-1);
}
! delete [] buffer;
!
! return 0;
}
--- 83,128 ----
sprintf(buffer,"%s%s%s%s%s",
! path,PATH_SEP,IMAGE_SUB,PATH_SEP,name);
m_surface = SDL_LoadBMP(buffer);
+ delete [] buffer;
+
+ if (m_surface == NULL) return -1;
+
+ return 0;
+ }
+
+ //----------------------------------------------------------------------
+ // FUNCTION: Surface::Load
+ //----------------------------------------------------------------------
+
+ int Surface::Load(const char* name)
+ {
+ if (m_surface) SDL_FreeSurface(m_surface);
+
+ #ifdef GAME_DATADIR
+
+ if (Load(GAME_DATADIR,name) == 0) return 0;
+
+ #else
+
+ if (Load("data",name) == 0) return 0;
+
+ #ifndef macintosh
+
+ if (Load("../data",name) == 0) return 0;
+ if (Load("../../data",name) == 0) return 0;
+
+ #endif
+
+ #endif
+
if (m_surface == NULL) {
! fprintf(stderr, "Surface_Load: could not load '%s'\n",name);
exit(-1);
}
! return -1;
}
|