aboutsummaryrefslogtreecommitdiff
path: root/src/Support.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Support.cpp')
-rw-r--r--src/Support.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/Support.cpp b/src/Support.cpp
index 7c77fc5..083de12 100644
--- a/src/Support.cpp
+++ b/src/Support.cpp
@@ -32,9 +32,9 @@ void GetMouse(Point *p)
{
int x;
int y;
-
+
SDL_GetMouseState(&x, &y);
-
+
p->h = x;
p->v = y;
}
@@ -43,9 +43,9 @@ void GetMouseRel(Point *p)
{
int x;
int y;
-
+
SDL_GetRelativeMouseState(&x, &y);
-
+
p->h = x;
p->v = y;
}
@@ -89,13 +89,13 @@ static int find_filename(char *filename)
char *next;
DIR *dir;
struct dirent *dirent;
-
+
if (access(filename, R_OK) == 0) {
return 1;
}
-
+
ptr = filename;
-
+
while (*ptr) {
if (ptr == filename || *ptr == '/') {
if (*ptr == '/') {
@@ -103,53 +103,53 @@ static int find_filename(char *filename)
} else {
cur = ptr;
}
-
+
if (*cur == 0) {
/* hit the end */
break;
}
-
+
next = strchr(cur, '/');
-
+
if (ptr != filename) {
*ptr = 0;
}
-
+
if (next) {
*next = 0;
}
-
+
if (ptr == filename && *ptr == '/') {
dir = opendir("/");
} else {
dir = opendir(filename);
}
-
+
if (dir == NULL) {
if (ptr != filename) {
*ptr = '/';
}
-
+
if (next) {
*next = 0;
}
-
+
return 0;
}
-
+
while ((dirent = readdir(dir)) != NULL) {
if (strcasecmp(cur, dirent->d_name) == 0) {
strcpy(cur, dirent->d_name);
break;
}
}
-
+
closedir(dir);
-
+
if (ptr != filename) {
*ptr = '/';
}
-
+
if (next) {
*next = '/';
ptr = next;
@@ -160,11 +160,11 @@ static int find_filename(char *filename)
ptr++;
}
}
-
+
if (access(filename, R_OK) == 0) {
return 1;
}
-
+
return 0;
}
@@ -180,28 +180,28 @@ static void fix_filename(const char *original, char *fixed)
}
fixed[MAX_PATH-1] = 0;
-
+
strncpy(fixed, start, MAX_PATH);
-
+
/* check to see if strncpy overwrote the terminator */
if (fixed[MAX_PATH-1] != 0) {
fixed[MAX_PATH-1] = 0;
-
- fprintf(stderr, "ERROR: file truncation error: %s -> %s\n",
+
+ fprintf(stderr, "ERROR: file truncation error: %s -> %s\n",
original, fixed);
}
-
+
len = strlen(fixed);
for (i = 0; i < len; i++) {
if (fixed[i] == ':') {
fixed[i] = '/';
}
}
-
- /*
+
+ /*
here we would try to see if the file is available (game dir),
else try another dir
-
+
really, this function also needs a flag to indicate whether
it should only go to local (write) or both (read)
*/
@@ -218,18 +218,18 @@ Convenient Filename Hacks
FILE *cfh_fopen(const char *filename, const char *mode)
{
char filename1[MAX_PATH];
-
+
fix_filename(filename, filename1);
-
- return fopen(filename1, mode);
+
+ return fopen(filename1, mode);
}
int Files::OpenFile(Str255 Name)
{
char filename1[MAX_PATH];
-
+
fix_filename((char *)Name, filename1);
-
+
sFile = open(filename1, O_RDONLY | O_BINARY);
return sFile;
}
@@ -239,11 +239,11 @@ void Files::EndLoad()
if (sFile != -1) {
FSClose( sFile );
}
-
+
sFile = -1;
}
-#ifdef NOOGG
+#ifdef NOOGG
/*
Our own special magic version that fixes the filename.
*/
@@ -252,11 +252,11 @@ void alutLoadWAVFile_CFH(char *filename, ALenum *format, void **wave,
{
char filename1[MAX_PATH];
ALsizei format1, size1, bits1, freq1;
-
+
fix_filename(filename, filename1);
-
+
alutLoadWAV(filename1, wave, &format1, &size1, &bits1, &freq1);
-
+
*format = format1;
*size = size1;
*freq = freq1;
@@ -304,9 +304,9 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
fprintf(stderr, "ERROR: unable to open %s\n", filename1);
exit(EXIT_FAILURE);
}
-
+
/* open it up */
- err = ov_open(fp, &vf, NULL, 0);
+ err = ov_open(fp, &vf, NULL, 0);
if (err < 0) {
fprintf(stderr, "ERROR: vorbis error %d opening %s\n", -err, filename1);
exit(EXIT_FAILURE);
@@ -318,16 +318,16 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
fprintf(stderr, "ERROR: vorbis error opening %s (ov_info failed)\n", filename1);
exit(EXIT_FAILURE);
}
-
+
/* calculate the byte size */
size1 = vi->channels * 2 * ov_pcm_total(&vf, -1);
/* hack around some possible ogg vorbis weirdness */
asize = ((size1 + 2047) / 2048 + 1) * 2048;
-
- /* allocate our buffer */
+
+ /* allocate our buffer */
wave1 = malloc(asize);
-
+
if (wave1 == NULL) {
fprintf(stderr, "ERROR: could not allocate %d bytes while loading %s\n", size1, filename1);
exit(EXIT_FAILURE);
@@ -336,17 +336,17 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
/* read it in */
eof = 0;
buf = (char *)wave1;
-
+
while(!eof) {
- long ret = ov_read(&vf, buf, 1024, endian, 2, 1,
+ long ret = ov_read(&vf, buf, 1024, endian, 2, 1,
&current_section);
-
+
if (ret == 0) {
/* end of file */
eof = 1;
} else if (ret < 0) {
/* some sort of error */
-
+
/* TODO: is this ok to ignore? */
} else {
buf += ret;
@@ -362,13 +362,13 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave,
fprintf(stderr, "ERROR: ogg %s has %d channels\n", filename1, vi->channels);
exit(EXIT_FAILURE);
}
-
+
freq1 = vi->rate;
/* we are done with the ogg, so free it */
ov_clear(&vf);
-
- /* finall, give the values to the caller */
+
+ /* finall, give the values to the caller */
*format = format1;
*size = size1;
*freq = freq1;