1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-17 03:49:28 +00:00

Replace spaces with tabs (future self: i'm sorry)

In most places, that is. Left some files unchanges because they are a mess.
This commit is contained in:
fgenesis 2017-01-12 22:51:46 +01:00
commit 8af953cb63
42 changed files with 691 additions and 706 deletions

View file

@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef BBGE_BUILD_VFS
# include "ttvfs.h"
# ifndef VFS_IGNORE_CASE
# error Must define VFS_IGNORE_CASE, see VFSDefines.h
# error Must define VFS_IGNORE_CASE, see VFSDefines.h
# endif
ttvfs::Root vfs; // extern
#endif
@ -67,13 +67,13 @@ Vector getDirVector(Direction dir)
case DIR_RIGHT:
return Vector(1, 0);
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
}
return Vector(0,0);
}
@ -94,13 +94,13 @@ Direction getOppositeDir(Direction dir)
case DIR_RIGHT:
return DIR_LEFT;
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
}
return DIR_NONE;
@ -122,13 +122,13 @@ Direction getNextDirClockwise(Direction dir)
case DIR_RIGHT:
return DIR_DOWN;
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
case DIR_UPLEFT:
case DIR_UPRIGHT:
case DIR_DOWNLEFT:
case DIR_DOWNRIGHT:
case DIR_MAX:
case DIR_NONE:
break;
}
return DIR_NONE;
}
@ -173,12 +173,12 @@ std::string removeSpaces(const std::string &input)
unsigned hash(const std::string &string)
{
unsigned hash = 5381;
unsigned hash = 5381;
for (int i = 0; i < string.size(); i++)
hash = ((hash << 5) + hash) + (unsigned char)string[i];
for (int i = 0; i < string.size(); i++)
hash = ((hash << 5) + hash) + (unsigned char)string[i];
return hash;
return hash;
}
@ -298,8 +298,8 @@ void stringToLowerUserData(std::string &s)
const std::string userdata = core->getUserDataFolder();
const size_t len = userdata.length();
const bool match = (s.length() > len) &&
((s[len] == '/') || (s[len] == '\\')) &&
!strncmp(userdata.c_str(), s.c_str(), len);
((s[len] == '/') || (s[len] == '\\')) &&
!strncmp(userdata.c_str(), s.c_str(), len);
if (!match)
stringToLower(s);
else
@ -319,18 +319,18 @@ int nocasecmp(const std::string &s1, const std::string &s2)
//stop when either string's end has been reached
while ( *it1 && *it2 )
{
if(charToUpper(*it1) != charToUpper(*it2)) //letters differ?
// return -1 to indicate smaller than, 1 otherwise
return (charToUpper(*it1) < charToUpper(*it2)) ? -1 : 1;
//proceed to the next character in each string
++it1;
++it2;
if(charToUpper(*it1) != charToUpper(*it2)) //letters differ?
// return -1 to indicate smaller than, 1 otherwise
return (charToUpper(*it1) < charToUpper(*it2)) ? -1 : 1;
//proceed to the next character in each string
++it1;
++it2;
}
size_t size1=s1.size(), size2=s2.size();// cache lengths
//return -1,0 or 1 according to strings' lengths
if (size1==size2)
return 0;
return (size1<size2) ? -1 : 1;
if (size1==size2)
return 0;
return (size1<size2) ? -1 : 1;
}
#endif // #if !HAVE_STRCASECMP
@ -553,22 +553,22 @@ std::string stripEndlineForUnix(const std::string &in)
struct vfscallback_s
{
std::string *path;
const char *ext;
intptr_t param;
void (*callback)(const std::string &filename, intptr_t param);
std::string *path;
const char *ext;
intptr_t param;
void (*callback)(const std::string &filename, intptr_t param);
};
void forEachFile_vfscallback(VFILE *vf, void *user)
{
vfscallback_s *d = (vfscallback_s*)user;
if(d->ext)
{
const char *e = strrchr(vf->name(), '.');
if(e && nocasecmp(d->ext, e))
return;
}
d->callback(*(d->path) + vf->name(), d->param);
vfscallback_s *d = (vfscallback_s*)user;
if(d->ext)
{
const char *e = strrchr(vf->name(), '.');
if(e && nocasecmp(d->ext, e))
return;
}
d->callback(*(d->path) + vf->name(), d->param);
}
#endif
@ -604,45 +604,45 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
dir = opendir(path.c_str());
if (dir)
{
dirent *file=0;
dirent *file=0;
while ( (file=readdir(dir)) != NULL )
{
if (strlen(file->d_name) > 4)
{
debugLog(file->d_name);
char *extension=strrchr(file->d_name,'.');
if (extension)
{
debugLog(extension);
if (extension!=NULL)
{
if (strcasecmp(extension,type.c_str())==0)
{
callback(path + std::string(file->d_name), param);
}
}
}
}
if (strlen(file->d_name) > 4)
{
debugLog(file->d_name);
char *extension=strrchr(file->d_name,'.');
if (extension)
{
debugLog(extension);
if (extension!=NULL)
{
if (strcasecmp(extension,type.c_str())==0)
{
callback(path + std::string(file->d_name), param);
}
}
}
}
}
closedir(dir);
}
else
{
debugLog("FAILED TO OPEN DIR");
debugLog("FAILED TO OPEN DIR");
}
#endif
#ifdef BBGE_BUILD_WINDOWS
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
int end = path.size()-1;
if (path[end] != '/')
path[end] += '/';
// Get the proper directory path
// Get the proper directory path
// \\ %s\\*
@ -658,21 +658,21 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
stringToUpper(type);
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
debugLog("No files of type " + type + " found in path " + path);
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
std::string filename = FileData.cFileName;
if (filename.size()>4)
@ -688,15 +688,15 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
}
if (!FindNextFile(hList, &FileData))
{
if (!FindNextFile(hList, &FileData))
{
fFinished = TRUE;
}
}
}
}
}
}
FindClose(hList);
FindClose(hList);
#endif
}
@ -705,29 +705,29 @@ std::vector<std::string> getFileList(std::string path, std::string type, int par
std::vector<std::string> list;
#ifdef BBGE_BUILD_WINDOWS
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
BOOL fFinished;
HANDLE hList;
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
// Get the proper directory path
sprintf(szDir, "%s\\*", path.c_str());
// Get the proper directory path
sprintf(szDir, "%s\\*", path.c_str());
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
printf("No files found\n\n");
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
// Get the first file
hList = FindFirstFile(szDir, &FileData);
if (hList == INVALID_HANDLE_VALUE)
{
printf("No files found\n\n");
}
else
{
// Traverse through the directory structure
fFinished = FALSE;
while (!fFinished)
{
// Check the object is a directory or not
//printf("%*s%s\n", indent, "", FileData.cFileName);
std::string filename = FileData.cFileName;
if (filename.size()>4 && filename.substr(filename.size()-4, filename.size())==type)
{
@ -736,15 +736,15 @@ std::vector<std::string> getFileList(std::string path, std::string type, int par
}
if (!FindNextFile(hList, &FileData))
{
if (!FindNextFile(hList, &FileData))
{
fFinished = TRUE;
}
}
}
}
}
}
FindClose(hList);
FindClose(hList);
#endif
return list;
@ -757,7 +757,7 @@ void cocoaMessageBox(const std::string &title, const std::string &msg);
void messageBox(const std::string& title, const std::string &msg)
{
#ifdef BBGE_BUILD_WINDOWS
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
#elif SDL_VERSION_ATLEAST(2,0,0)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, title.c_str(),
msg.c_str(), NULL);
@ -803,24 +803,24 @@ Vector getNearestPointOnLine(Vector a, Vector b, Vector c)
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius, Vector *closestP)
{
Vector dir = lineEnd - lineStart;
Vector diff = point - lineStart;
Vector closest;
if (!dir.isZero()) {
Vector dir = lineEnd - lineStart;
Vector diff = point - lineStart;
Vector closest;
if (!dir.isZero()) {
float t = diff.dot2D(dir) / dir.dot2D(dir);
if (t < 0.0f)
t = 0.0f;
t = 0.0f;
if (t > 1.0f)
t = 1.0f;
t = 1.0f;
closest = lineStart + t * dir;
} else {
} else {
closest = lineStart;
}
Vector d = point - closest;
float distsqr = d.dot2D(d);
}
Vector d = point - closest;
float distsqr = d.dot2D(d);
if (closestP)
(*closestP) = closest;
return distsqr <= radius*radius;
return distsqr <= radius*radius;
}
@ -899,56 +899,56 @@ int packFile(const std::string &sourcef, const std::string &destf, int level)
if (!source || !dest)
return 0;
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = in;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
strm.next_in = in;
/* run deflate() on input until output buffer not full, finish
compression if all of source has been read in */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */
/* run deflate() on input until output buffer not full, finish
compression if all of source has been read in */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = deflate(&strm, flush); /* no bad return value */
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */
/* done when last data in file processed */
} while (flush != Z_FINISH);
assert(ret == Z_STREAM_END); /* stream will be complete */
/* done when last data in file processed */
} while (flush != Z_FINISH);
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
/* clean up and return */
(void)deflateEnd(&strm);
fclose(source);
fclose(dest);
return Z_OK;
return Z_OK;
}
/* Decompress from file source to file dest until stream ends or EOF.
@ -965,64 +965,64 @@ int unpackFile(const std::string &sourcef, const std::string &destf)
if (!source || !dest)
return 0;
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
int ret;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
if (ferror(source)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
if (strm.avail_in == 0)
break;
strm.next_in = in;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = CHUNK;
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
have = CHUNK - strm.avail_out;
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
(void)inflateEnd(&strm);
return Z_ERRNO;
}
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
(void)inflateEnd(&strm);
/* clean up and return */
(void)inflateEnd(&strm);
fclose(source);
fclose(dest);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
#endif