Uncollapse _db_select
This commit is contained in:
parent
79f5e00f6e
commit
1f6339b3b3
61
src/art.cc
61
src/art.cc
|
@ -146,15 +146,31 @@ int artInit()
|
||||||
gArtLanguageInitialized = true;
|
gArtLanguageInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool critterDbSelected = false;
|
||||||
for (int objectType = 0; objectType < OBJ_TYPE_COUNT; objectType++) {
|
for (int objectType = 0; objectType < OBJ_TYPE_COUNT; objectType++) {
|
||||||
gArtListDescriptions[objectType].flags = 0;
|
gArtListDescriptions[objectType].flags = 0;
|
||||||
sprintf(path, "%s%s%s\\%s.lst", _cd_path_base, "art\\", gArtListDescriptions[objectType].name, gArtListDescriptions[objectType].name);
|
sprintf(path, "%s%s%s\\%s.lst", _cd_path_base, "art\\", gArtListDescriptions[objectType].name, gArtListDescriptions[objectType].name);
|
||||||
|
|
||||||
|
int oldDb;
|
||||||
|
if (objectType == OBJ_TYPE_CRITTER) {
|
||||||
|
oldDb = _db_current();
|
||||||
|
critterDbSelected = true;
|
||||||
|
_db_select(_critter_db_handle);
|
||||||
|
}
|
||||||
|
|
||||||
if (artReadList(path, &(gArtListDescriptions[objectType].fileNames), &(gArtListDescriptions[objectType].fileNamesLength)) != 0) {
|
if (artReadList(path, &(gArtListDescriptions[objectType].fileNames), &(gArtListDescriptions[objectType].fileNamesLength)) != 0) {
|
||||||
debugPrint("art_read_lst failed in art_init\n");
|
debugPrint("art_read_lst failed in art_init\n");
|
||||||
|
if (critterDbSelected) {
|
||||||
|
_db_select(oldDb);
|
||||||
|
}
|
||||||
cacheFree(&gArtCache);
|
cacheFree(&gArtCache);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objectType == OBJ_TYPE_CRITTER) {
|
||||||
|
critterDbSelected = false;
|
||||||
|
_db_select(oldDb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_anon_alias = (int*)internal_malloc(sizeof(*_anon_alias) * gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength);
|
_anon_alias = (int*)internal_malloc(sizeof(*_anon_alias) * gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength);
|
||||||
|
@ -848,8 +864,8 @@ bool artExists(int fid)
|
||||||
int oldDb = -1;
|
int oldDb = -1;
|
||||||
|
|
||||||
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
||||||
oldDb = _db_current(1);
|
oldDb = _db_current();
|
||||||
_db_current(_critter_db_handle);
|
_db_select(_critter_db_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* filePath = artBuildFilePath(fid);
|
char* filePath = artBuildFilePath(fid);
|
||||||
|
@ -861,27 +877,38 @@ bool artExists(int fid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldDb != -1) {
|
if (oldDb != -1) {
|
||||||
_db_current(oldDb);
|
_db_select(oldDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Exactly the same implementation as `artExists`.
|
||||||
|
//
|
||||||
// 0x419930
|
// 0x419930
|
||||||
bool _art_fid_valid(int fid)
|
bool _art_fid_valid(int fid)
|
||||||
{
|
{
|
||||||
// NOTE: Original Code involves calling some unknown function. Check in debugger in mapper.
|
bool result = false;
|
||||||
|
int oldDb = -1;
|
||||||
|
|
||||||
|
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
||||||
|
oldDb = _db_current();
|
||||||
|
_db_select(_critter_db_handle);
|
||||||
|
}
|
||||||
|
|
||||||
char* filePath = artBuildFilePath(fid);
|
char* filePath = artBuildFilePath(fid);
|
||||||
if (filePath == NULL) {
|
if (filePath != NULL) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fileSize;
|
int fileSize;
|
||||||
if (dbGetFileSize(filePath, &fileSize) == -1) {
|
if (dbGetFileSize(filePath, &fileSize) != -1) {
|
||||||
return false;
|
result = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
if (oldDb != -1) {
|
||||||
|
_db_select(oldDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x419998
|
// 0x419998
|
||||||
|
@ -931,8 +958,8 @@ static int artCacheGetFileSizeImpl(int fid, int* sizePtr)
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
||||||
oldDb = _db_current(1);
|
oldDb = _db_current();
|
||||||
_db_current(_critter_db_handle);
|
_db_select(_critter_db_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* artFilePath = artBuildFilePath(fid);
|
char* artFilePath = artBuildFilePath(fid);
|
||||||
|
@ -967,7 +994,7 @@ static int artCacheGetFileSizeImpl(int fid, int* sizePtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldDb != -1) {
|
if (oldDb != -1) {
|
||||||
_db_current(oldDb);
|
_db_select(oldDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -980,8 +1007,8 @@ static int artCacheReadDataImpl(int fid, int* sizePtr, unsigned char* data)
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
if (FID_TYPE(fid) == OBJ_TYPE_CRITTER) {
|
||||||
oldDb = _db_current(1);
|
oldDb = _db_current();
|
||||||
_db_current(_critter_db_handle);
|
_db_select(_critter_db_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* artFileName = artBuildFilePath(fid);
|
char* artFileName = artBuildFilePath(fid);
|
||||||
|
@ -1015,7 +1042,7 @@ static int artCacheReadDataImpl(int fid, int* sizePtr, unsigned char* data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldDb != -1) {
|
if (oldDb != -1) {
|
||||||
_db_current(oldDb);
|
_db_select(oldDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
16
src/db.cc
16
src/db.cc
|
@ -61,20 +61,22 @@ int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: This function simply returns 0, but it definitely accept one parameter
|
|
||||||
// via eax, as seen at every call site. This value is ignored. It's impossible
|
|
||||||
// to guess it's name.
|
|
||||||
//
|
|
||||||
// 0x4C5D54
|
// 0x4C5D54
|
||||||
int _db_current(int a1)
|
int _db_select(int dbHandle)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Uncollapsed 0x4C5D54.
|
||||||
|
int _db_current()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C5D58
|
// 0x4C5D58
|
||||||
bool _db_total()
|
int _db_total()
|
||||||
{
|
{
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C5D60
|
// 0x4C5D60
|
||||||
|
|
5
src/db.h
5
src/db.h
|
@ -11,8 +11,9 @@ typedef void FileReadProgressHandler();
|
||||||
typedef char* StrdupProc(const char* string);
|
typedef char* StrdupProc(const char* string);
|
||||||
|
|
||||||
int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4);
|
int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4);
|
||||||
int _db_current(int a1);
|
int _db_select(int dbHandle);
|
||||||
bool _db_total();
|
int _db_current();
|
||||||
|
int _db_total();
|
||||||
void dbExit();
|
void dbExit();
|
||||||
int dbGetFileSize(const char* filePath, int* sizePtr);
|
int dbGetFileSize(const char* filePath, int* sizePtr);
|
||||||
int dbGetFileContents(const char* filePath, void* ptr);
|
int dbGetFileContents(const char* filePath, void* ptr);
|
||||||
|
|
|
@ -1251,6 +1251,7 @@ static int gameDbInit()
|
||||||
|
|
||||||
_critter_db_handle = dbOpen(main_file_name, 0, patch_file_name, 1);
|
_critter_db_handle = dbOpen(main_file_name, 0, patch_file_name, 1);
|
||||||
if (_critter_db_handle == -1) {
|
if (_critter_db_handle == -1) {
|
||||||
|
_db_select(_master_db_handle);
|
||||||
showMesageBox("Could not find the critter datafile. Please make sure the FALLOUT CD is in the drive and that you are running FALLOUT from the directory you installed it to.");
|
showMesageBox("Could not find the critter datafile. Please make sure the FALLOUT CD is in the drive and that you are running FALLOUT from the directory you installed it to.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1263,6 +1264,8 @@ static int gameDbInit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_db_select(_master_db_handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitP
|
||||||
gOrderedWindowIds[index] = -1;
|
gOrderedWindowIds[index] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_db_total()) {
|
if (_db_total() == 0) {
|
||||||
if (dbOpen(NULL, 0, _path_patches, 1) == -1) {
|
if (dbOpen(NULL, 0, _path_patches, 1) == -1) {
|
||||||
return WINDOW_MANAGER_ERR_INITIALIZING_DEFAULT_DATABASE;
|
return WINDOW_MANAGER_ERR_INITIALIZING_DEFAULT_DATABASE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue