mirror of
https://github.com/XProger/OpenLara.git
synced 2025-04-22 03:51:58 +02:00
add saveDir path for savegame.dat file
This commit is contained in:
parent
effe449040
commit
d4f31f85c1
@ -618,7 +618,7 @@ namespace Core {
|
||||
|
||||
GAPI::init();
|
||||
|
||||
LOG("cache : %s\n", Stream::cacheDir);
|
||||
LOG("cache : %s\n", cacheDir);
|
||||
LOG("supports :\n");
|
||||
LOG(" variyngs count : %d\n", support.maxVectors);
|
||||
LOG(" binary shaders : %s\n", support.shaderBinary ? "true" : "false");
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include "ui.h"
|
||||
#include "savegame.h"
|
||||
|
||||
namespace Game {
|
||||
Level *level;
|
||||
Stream *nextLevel;
|
||||
#define MAX_CHEAT_SEQUENCE 8
|
||||
|
||||
#define MAX_CHEAT_SEQUENCE 8
|
||||
namespace Game {
|
||||
Level *level;
|
||||
Stream *nextLevel;
|
||||
ControlKey cheatSeq[MAX_CHEAT_SEQUENCE];
|
||||
|
||||
void cheatControl(ControlKey key) {
|
||||
|
@ -475,7 +475,7 @@ namespace GAPI {
|
||||
bool linkBinary(const char *name) {
|
||||
// non-async code!
|
||||
char path[255];
|
||||
strcpy(path, Stream::cacheDir);
|
||||
strcpy(path, cacheDir);
|
||||
strcat(path, name);
|
||||
|
||||
if (!Stream::exists(path))
|
||||
|
@ -629,15 +629,18 @@ struct Lara : Character {
|
||||
health = data.extra.lara.health;
|
||||
oxygen = data.extra.lara.oxygen;
|
||||
|
||||
if (level->isHome()) return;
|
||||
|
||||
layers[1].mask = layers[2].mask = layers[3].mask = 0;
|
||||
|
||||
wpnSet(TR::Entity::Type(data.extra.lara.itemWeapon));
|
||||
if (data.extra.lara.itemWeapon)
|
||||
wpnSet(TR::Entity::Type(data.extra.lara.itemWeapon));
|
||||
|
||||
wpnCurrent = TR::Entity::Type(data.extra.lara.itemWeapon);
|
||||
itemHolster = TR::Entity::Type(data.extra.lara.itemHolster);
|
||||
wpnState = Weapon::IS_HIDDEN;
|
||||
|
||||
if (data.extra.lara.itemHands == data.extra.lara.itemWeapon)
|
||||
if (data.extra.lara.itemHands && data.extra.lara.itemHands == data.extra.lara.itemWeapon)
|
||||
wpnDraw(true);
|
||||
|
||||
if (itemHolster != TR::Entity::NONE)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "game.h"
|
||||
|
||||
@ -43,10 +44,7 @@ void osToggleVR(bool enable) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring contentDir, jstring cacheDir) {
|
||||
JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstring jcacheDir) {
|
||||
env->GetJavaVM(&jvm);
|
||||
|
||||
timeval t;
|
||||
@ -55,15 +53,17 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring contentDir, jstri
|
||||
|
||||
const char* str;
|
||||
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
str = env->GetStringUTFChars(contentDir, NULL);
|
||||
strcat(Stream::contentDir, str);
|
||||
env->ReleaseStringUTFChars(contentDir, str);
|
||||
str = env->GetStringUTFChars(jcontentDir, NULL);
|
||||
strcat(contentDir, str);
|
||||
env->ReleaseStringUTFChars(jcontentDir, str);
|
||||
|
||||
str = env->GetStringUTFChars(cacheDir, NULL);
|
||||
strcat(Stream::cacheDir, str);
|
||||
env->ReleaseStringUTFChars(cacheDir, str);
|
||||
str = env->GetStringUTFChars(jcacheDir, NULL);
|
||||
strcat(cacheDir, str);
|
||||
env->ReleaseStringUTFChars(jcacheDir, str);
|
||||
|
||||
strcpy(saveDir, cacheDir);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&GAPI::defaultFBO);
|
||||
Game::init();
|
||||
|
@ -526,11 +526,7 @@ void inputUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
LOG("start\n");
|
||||
if (!eglInit()) {
|
||||
LOG("! can't initialize EGL context\n");
|
||||
return -1;
|
||||
@ -539,26 +535,33 @@ LOG("start\n");
|
||||
Core::width = fb.width;
|
||||
Core::height = fb.height;
|
||||
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
strcpy(Stream::contentDir, argv[0]);
|
||||
int i = strlen(Stream::contentDir);
|
||||
strcpy(contentDir, argv[0]);
|
||||
int i = strlen(contentDir);
|
||||
while (--i >= 0) {
|
||||
if (Stream::contentDir[i] == '/') {
|
||||
Stream::contentDir[i + 1] = 0;
|
||||
if (contentDir[i] == '/') {
|
||||
contentDir[i + 1] = 0;
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
strcpy(Stream::cacheDir, Stream::contentDir);
|
||||
strcat(Stream::cacheDir, "cache/");
|
||||
strcpy(cacheDir, contentDir);
|
||||
strcat(cacheDir, "cache/");
|
||||
|
||||
struct stat st = {0};
|
||||
if (stat(Stream::cacheDir, &st) == -1 && mkdir(Stream::cacheDir, 0777) == -1)
|
||||
Stream::cacheDir[0] = 0;
|
||||
if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1)
|
||||
cacheDir[0] = 0;
|
||||
|
||||
LOG("cache dir %s\n", Stream::cacheDir);
|
||||
const char *home;
|
||||
if (!(home = getenv("HOME")))
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
strcpy(saveDir, home);
|
||||
strcat(saveDir, "/.openlara/");
|
||||
|
||||
if (stat(saveDir, &st) == -1 && mkdir(saveDir, 0777) == -1)
|
||||
saveDir[0] = 0;
|
||||
|
||||
timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
bool osJoyReady(int index) {
|
||||
return false;
|
||||
}
|
||||
@ -112,11 +109,11 @@ void soundInit() {
|
||||
[EAGLContext setCurrentContext:self.context];
|
||||
|
||||
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
NSString *path = [[NSBundle mainBundle] resourcePath];
|
||||
strcat(Stream::contentDir, [path UTF8String]);
|
||||
strcat(Stream::contentDir, "/");
|
||||
strcat(contentDir, [path UTF8String]);
|
||||
strcat(contentDir, "/");
|
||||
|
||||
Game::init();
|
||||
|
||||
|
@ -353,21 +353,19 @@ void WndProc(const XEvent &e,Display*dpy,Window wnd) {
|
||||
}
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
const char *home;
|
||||
if (!(home = getenv("HOME")))
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
strcat(Stream::cacheDir, home);
|
||||
strcat(Stream::cacheDir, "/.OpenLara/");
|
||||
|
||||
struct stat st = {0};
|
||||
if (stat(Stream::cacheDir, &st) == -1 && mkdir(Stream::cacheDir, 0777) == -1)
|
||||
Stream::cacheDir[0] = 0;
|
||||
strcat(cacheDir, home);
|
||||
strcat(cacheDir, "/.openlara/");
|
||||
|
||||
struct stat st = {0};
|
||||
if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1)
|
||||
cacheDir[0] = 0;
|
||||
strcpy(saveDir, cacheDir);
|
||||
|
||||
static int XGLAttr[] = {
|
||||
GLX_RGBA,
|
||||
|
@ -153,18 +153,15 @@ int osGetTime() {
|
||||
return int(t / 1000);
|
||||
}
|
||||
|
||||
char Stream::contentDir[255];
|
||||
char Stream::cacheDir[255];
|
||||
|
||||
int main() {
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
// get path to game content
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
CFURLRef bundleURL = CFBundleCopyBundleURL(bundle);
|
||||
CFStringRef pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
|
||||
CFStringGetFileSystemRepresentation(pathStr, Stream::contentDir, 230);
|
||||
strcat(Stream::contentDir, "/Contents/Resources/");
|
||||
CFStringGetFileSystemRepresentation(pathStr, contentDir, 230);
|
||||
strcat(contentDir, "/Contents/Resources/");
|
||||
|
||||
// init window
|
||||
Rect rect = {0, 0, 720, 1280};
|
||||
|
@ -139,10 +139,9 @@ void sndInit() {
|
||||
pspAudioSetChannelCallback(0, sndFill, NULL);
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
int main() {
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
scePowerSetClockFrequency(333, 333, 166);
|
||||
setupCallbacks();
|
||||
|
||||
|
@ -467,9 +467,6 @@ void inputUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
EGLDisplay display;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@ -489,17 +486,18 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
const char *home;
|
||||
if (!(home = getenv("HOME")))
|
||||
home = getpwuid(getuid())->pw_dir;
|
||||
strcat(Stream::cacheDir, home);
|
||||
strcat(Stream::cacheDir, "/.OpenLara/");
|
||||
strcat(cacheDir, home);
|
||||
strcat(cacheDir, "/.openlara/");
|
||||
|
||||
struct stat st = {0};
|
||||
if (stat(Stream::cacheDir, &st) == -1 && mkdir(Stream::cacheDir, 0777) == -1)
|
||||
Stream::cacheDir[0] = 0;
|
||||
if (stat(cacheDir, &st) == -1 && mkdir(cacheDir, 0777) == -1)
|
||||
cacheDir[0] = 0;
|
||||
strcpy(saveDir, cacheDir);
|
||||
|
||||
timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
@ -312,12 +312,9 @@ EM_BOOL mouseCallback(int eventType, const EmscriptenMouseEvent *e, void *userDa
|
||||
return 1;
|
||||
}
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
int main() {
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
initGL();
|
||||
|
||||
emscripten_set_keydown_callback(0, 0, 1, keyCallback);
|
||||
|
@ -667,9 +667,6 @@ void vrCompose() {
|
||||
}
|
||||
#endif // #ifdef VR_SUPPORT
|
||||
|
||||
char Stream::cacheDir[255];
|
||||
char Stream::contentDir[255];
|
||||
|
||||
#ifdef _DEBUG
|
||||
int main(int argc, char** argv) {
|
||||
_CrtMemState _msBegin, _msEnd, _msDiff;
|
||||
@ -682,11 +679,12 @@ int main(int argc, char** argv) {
|
||||
//#else
|
||||
//int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
#endif
|
||||
Stream::contentDir[0] = Stream::cacheDir[0] = 0;
|
||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||
|
||||
strcat(Stream::cacheDir, getenv("APPDATA"));
|
||||
strcat(Stream::cacheDir, "\\OpenLara\\");
|
||||
CreateDirectory(Stream::cacheDir, NULL);
|
||||
strcat(cacheDir, getenv("APPDATA"));
|
||||
strcat(cacheDir, "\\OpenLara\\");
|
||||
strcpy(saveDir, cacheDir);
|
||||
CreateDirectory(cacheDir, NULL);
|
||||
|
||||
RECT r = { 0, 0, 1280, 720 };
|
||||
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false);
|
||||
|
@ -626,7 +626,7 @@ namespace Sound {
|
||||
|
||||
OGG(Stream *stream, int channels) : Decoder(stream, channels, 0), ogg(NULL) {
|
||||
char buf[255];
|
||||
strcpy(buf, Stream::contentDir);
|
||||
strcpy(buf, contentDir);
|
||||
strcat(buf, stream->name);
|
||||
|
||||
alloc.alloc_buffer_length_in_bytes = 256 * 1024;
|
||||
|
32
src/utils.h
32
src/utils.h
@ -1189,10 +1189,11 @@ extern void osWriteSlot (Stream *stream);
|
||||
extern void osDownload (Stream *stream);
|
||||
#endif
|
||||
|
||||
struct Stream {
|
||||
static char cacheDir[255];
|
||||
static char contentDir[255];
|
||||
char cacheDir[255];
|
||||
char saveDir[255];
|
||||
char contentDir[255];
|
||||
|
||||
struct Stream {
|
||||
typedef void (Callback)(Stream *stream, void *userData);
|
||||
Callback *callback;
|
||||
void *userData;
|
||||
@ -1284,7 +1285,7 @@ struct Stream {
|
||||
|
||||
static bool existsContent(const char *name) {
|
||||
char fileName[1024];
|
||||
strcpy(fileName, Stream::contentDir);
|
||||
strcpy(fileName, contentDir);
|
||||
strcat(fileName, name);
|
||||
return exists(fileName);
|
||||
}
|
||||
@ -1337,9 +1338,9 @@ struct Stream {
|
||||
|
||||
|
||||
#ifdef OS_FILEIO_CACHE
|
||||
void osCacheWrite(Stream *stream) {
|
||||
void osDataWrite(Stream *stream, const char *dir) {
|
||||
char path[255];
|
||||
strcpy(path, Stream::cacheDir);
|
||||
strcpy(path, dir);
|
||||
strcat(path, stream->name);
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (f) {
|
||||
@ -1354,9 +1355,9 @@ void osCacheWrite(Stream *stream) {
|
||||
delete stream;
|
||||
}
|
||||
|
||||
void osCacheRead(Stream *stream) {
|
||||
void osDataRead(Stream *stream, const char *dir) {
|
||||
char path[255];
|
||||
strcpy(path, Stream::cacheDir);
|
||||
strcpy(path, dir);
|
||||
strcat(path, stream->name);
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (f) {
|
||||
@ -1375,13 +1376,22 @@ void osCacheRead(Stream *stream) {
|
||||
delete stream;
|
||||
}
|
||||
|
||||
void osReadSlot(Stream *stream) {
|
||||
return osCacheRead(stream);
|
||||
void osCacheWrite(Stream *stream) {
|
||||
osDataWrite(stream, cacheDir);
|
||||
}
|
||||
|
||||
void osCacheRead(Stream *stream) {
|
||||
osDataRead(stream, cacheDir);
|
||||
}
|
||||
|
||||
void osWriteSlot(Stream *stream) {
|
||||
return osCacheWrite(stream);
|
||||
osDataWrite(stream, saveDir);
|
||||
}
|
||||
|
||||
void osReadSlot(Stream *stream) {
|
||||
osDataRead(stream, saveDir);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user