M4: Fix creating INvPal

This commit is contained in:
Paul Gilbert 2023-06-23 20:57:31 -07:00 committed by Eugene Sandulenko
parent e1181801ba
commit b2b418480c
3 changed files with 12 additions and 17 deletions

View File

@ -91,8 +91,7 @@ char *db_rmlst_get_asset_room_path(char *asset_name, char *result, int32 *sceneC
char *search_result = catalog_search(asset_name);
//apr10
if (search_result != NULL) {
if (search_result != nullptr) {
db_get_catalog_entry(search_result, &tag, &room, name, path, &c_size);
*sceneCode = room;
}
@ -119,7 +118,7 @@ static int32 count_catalog_items() {
int32 my_catalog_size = 0;
while (pCatIter) {
pCatIter = db_get_catalog_entry(pCatIter, NULL, NULL, NULL, NULL, NULL);
pCatIter = db_get_catalog_entry(pCatIter, nullptr, nullptr, nullptr, nullptr, nullptr);
if (pCatIter)
++my_catalog_size;
}
@ -157,7 +156,7 @@ static void sort_catalog() {
_G(catalog)._catalog[index] = pCatalogIter;
short room_number;
char *nextItem = db_get_catalog_entry(pCatalogIter, &tag, &room_number, name, path, NULL);
char *nextItem = db_get_catalog_entry(pCatalogIter, &tag, &room_number, name, path, nullptr);
switch (tag) {
case _T_ROOM:
@ -196,7 +195,7 @@ static char *catalog_search(char *name) {
char **result = (char **)bsearch((void *)myString, (void *)_G(catalog)._catalog, _G(catalog)._size, sizeof(char *), compare_catalog_entries_for_search);
if (!result)
return NULL;
return nullptr;
return *result;
}
@ -219,7 +218,7 @@ static char *db_get_catalog_entry(char *c, short *tag, short *room, char *name,
short size = convert_intel16(*(short *)&c[0]);
if (!size)
return NULL;
return nullptr;
if (c_size)
*c_size = size;
@ -230,7 +229,7 @@ static char *db_get_catalog_entry(char *c, short *tag, short *room, char *name,
if (tag)
*tag = theTag;
x += sizeof(short); //tag
x += sizeof(short); // tag
if ((theTag == _T_ROOM) && room) {
*room = convert_intel16(*(short *)&c[x]);
@ -248,13 +247,6 @@ static char *db_get_catalog_entry(char *c, short *tag, short *room, char *name,
if (name)
snprintf(name, MAX_FILENAME_SIZE, "%s", s);
//feb5
//skip over trailing '\0' or NULL string.
//for( i=0; i<2; i++ ) {
// if( c[x] )
// break;
// x++;
//}
for (;; ) {
if (c[x])
break;

View File

@ -28,6 +28,9 @@ namespace M4 {
Common::Stream *f_io_open(const Common::String &filename, const Common::String &mode) {
if (mode.hasPrefix("r")) {
if (filename.empty())
return nullptr;
Common::File *f = new Common::File();
if (f->open(filename))
return f;

View File

@ -90,9 +90,9 @@ uint32 SysFile::get_pos() {
void SysFile::open_read_low_level() {
Common::File temp_fp;
uint32 hash_table_size;
char hag_name[33];
byte hagfile;
uint32 hash_table_size;
char hag_name[33];
byte hagfile;
Hag_Name_Record *temp_ptr;
char *temp_name;
Common::String last_string;