-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.1.0 - in-game loading! And apologies to people who tried compiling,…
… but couldn't find a Makefile...forgot it on the last cleanup
- Loading branch information
penguin673
committed
May 30, 2008
1 parent
1992d76
commit 6c85d80
Showing
6 changed files
with
404 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
CXXFLAGS = -I./ -I../include -DTIXML_USE_STL -g3 -Wall | ||
TINYXML_USE_STL := YES | ||
|
||
CPPFILES := $(wildcard *.cpp) $(wildcard tinyxml/*.cpp) | ||
|
||
LINFILES := $(wildcard lin/*.cpp) | ||
OFILES := $(CPPFILES:.cpp=.o) $(LINFILES:.cpp=.o) | ||
|
||
WINFILES := $(wildcard win/*.cpp) | ||
OBJFILES := $(CPPFILES:.cpp=.OBJ) $(WINFILES:.cpp=.OBJ) | ||
|
||
PKGPREFIX := ../l-echo-0.1.0_r30- | ||
|
||
all: $(OFILES) | ||
gcc tinyxml/*.o *.o lin/*.o -DTIXML_USE_STL -lGL -lGLU /usr/lib/libglut.so.3.8.0 -lpthread -g3 -Wall -o l-echo | ||
|
||
%.OBJ: %.cpp | ||
i586-mingw32msvc-g++ $(CXXFLAGS) -c -o $@ $< | ||
|
||
w32: $(OBJFILES) | ||
i586-mingw32msvc-g++ *.OBJ win/*.OBJ tinyxml/*.OBJ glut32.lib -lGL -lGLU -g3 -Wall -o l-echo.exe | ||
|
||
clean: | ||
rm *.o *.OBJ l-echo.exe l-echo lin/*.o win/*.OBJ *~ || echo | ||
|
||
clean-all: clean | ||
rm tinyxml/*.o tinyxml/*.OBJ || echo | ||
|
||
run: all | ||
./l-echo perspective_movement.xml | ||
|
||
dbg: all | ||
gdb ./l-echo | ||
|
||
package: all w32 | ||
zip -r $(PKGPREFIX)lin32.zip l-echo *.xml L_ECHO_README | ||
zip -r $(PKGPREFIX)w32.zip l-echo.exe *.xml L_ECHO_README | ||
|
||
count: | ||
wc -l *.cpp *.h lin/*.cpp win/*.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// echo_ingame_loader.cpp | ||
|
||
/* | ||
This file is part of L-Echo. | ||
L-Echo is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
L-Echo is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with L-Echo. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <cstdlib> | ||
#include <cstring> | ||
#include <iostream> | ||
//POSIX | ||
#include <dirent.h> | ||
#include <fcntl.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
|
||
#include <echo_stage.h> | ||
#include <echo_loader.h> | ||
#include <echo_ingame_loader.h> | ||
|
||
char* echo_merge(const char* arg1, const char* arg2) | ||
{ | ||
char* ret = new char[strlen(arg1) + strlen(arg2) + 2]; | ||
strcat(strcat(strcpy(ret, arg1), "/"), arg2); | ||
return(ret); | ||
} | ||
|
||
int is_dir(const char* dir, const char* fname) | ||
{ | ||
if(!strcmp(fname, "..")) | ||
return(1); | ||
char* merged = echo_merge(dir, fname); | ||
int ret = is_dir(merged); | ||
delete merged; | ||
return(ret); | ||
} | ||
|
||
int is_dir(const char* fname) | ||
{ | ||
int fd = open(fname, O_RDONLY); | ||
struct stat *file_stat = new(struct stat); | ||
int exists = !fstat(fd, file_stat); | ||
close(fd); | ||
if(exists) | ||
{ | ||
int ret = S_ISDIR(file_stat->st_mode); | ||
delete file_stat; | ||
return(ret); | ||
} | ||
delete file_stat; | ||
return(0); | ||
} | ||
|
||
static char* cmp_dir; | ||
|
||
static int cmp(const void* arg1v, const void* arg2v) | ||
{ | ||
const char* arg1 = *((char**)arg1v); | ||
const char* arg2 = *((char**)arg2v); | ||
//std::cout << "cmp: " << arg1v << ", " << arg2v<< std::endl; | ||
int arg1isdir = is_dir(cmp_dir, arg1), arg2isdir = is_dir(cmp_dir, arg2); | ||
if(arg1isdir && !arg2isdir) | ||
return(-1); | ||
if(!arg1isdir && arg2isdir) | ||
return(1); | ||
return(strcmp(arg1, arg2)); | ||
} | ||
|
||
echo_files* get_files(const char* dirname) | ||
{ | ||
int fd = open(dirname, O_RDONLY); | ||
struct stat dir_stat; | ||
int exists = !fstat(fd, &dir_stat); | ||
close(fd); | ||
if(exists) | ||
{ | ||
DIR* dir = opendir(dirname); | ||
echo_files* ret = new(echo_files); | ||
ret->num_files = 0; | ||
ret->current_dir = const_cast<char*>(dirname); | ||
dirent* each_ent; | ||
while(each_ent = readdir(dir)) | ||
{ | ||
//std::cout << "each_ent->d_name: " << each_ent->d_name << std::endl; | ||
if(strcmp(each_ent->d_name, ".") && strcmp(each_ent->d_name, "..")) | ||
ret->num_files++; | ||
} | ||
//std::cout << "each_ent: " << each_ent << std::endl; | ||
ret->num_files++; | ||
ret->file_names = new char*[ret->num_files]; | ||
ret->file_names[0] = ".."; | ||
|
||
int each = 1; | ||
|
||
rewinddir(dir); | ||
while(each_ent = readdir(dir)) | ||
{ | ||
/* | ||
fname = new char[strlen(dirname) + strlen(each_ent->d_name) + 1]; | ||
ret->file_names[each] = strcat(strcpy(fname, dirname) | ||
, strcmp(".", each_ent->d_name) ? each_ent->d_name : ".."); | ||
// */ | ||
if(strcmp(each_ent->d_name, ".") && strcmp(each_ent->d_name, "..")) | ||
{ | ||
ret->file_names[each] = new char[strlen(each_ent->d_name) + 1]; | ||
strcpy(ret->file_names[each], each_ent->d_name); | ||
each++; | ||
} | ||
} | ||
//std::cout << "num_files + each: " << ret->num_files << ", " << each << std::endl; | ||
closedir(dir); | ||
|
||
cmp_dir = ret->current_dir; | ||
//std::cout << "cmp_dir: " << cmp_dir << std::endl; | ||
qsort(ret->file_names, ret->num_files, sizeof(char*), cmp); | ||
return(ret); | ||
} | ||
return(NULL); | ||
} | ||
|
||
void dump_files(echo_files* files) | ||
{ | ||
int each = 0; | ||
std::cout << "files->num_files: " << files->num_files << std::endl; | ||
while(each < files->num_files) | ||
{ | ||
std::cout << "files: " << files->file_names[each] << std::endl; | ||
each++; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// echo_ingame_loader.h | ||
|
||
/* | ||
This file is part of L-Echo. | ||
L-Echo is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
L-Echo is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with L-Echo. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <echo_stage.h> | ||
#include <echo_loader.h> | ||
|
||
#ifndef __ECHO_INTERNAL_FILES__ | ||
#define __ECHO_INTERNAL_FILES__ | ||
typedef struct | ||
{ | ||
char* current_dir; | ||
char** file_names; | ||
int num_files; | ||
} echo_files; | ||
#endif | ||
|
||
char* echo_merge(const char* arg1, const char* arg2); | ||
echo_files* get_files(const char* dirname); | ||
void dump_files(echo_files* files); | ||
int is_dir(const char* dir, const char* fname); | ||
int is_dir(const char* fname); | ||
|
||
|
Oops, something went wrong.