From f8e3b4723162ca9194889b2e2c57003a1d724fea Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 15 Nov 2015 03:41:47 +0800 Subject: [PATCH] [makerom] misc --- makerom/romfs_gen.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/makerom/romfs_gen.c b/makerom/romfs_gen.c index 5bed220..74cdaa9 100644 --- a/makerom/romfs_gen.c +++ b/makerom/romfs_gen.c @@ -19,7 +19,7 @@ void PopulateRomfs(romfs_buildctx *ctx); void BuildRomfsHeader(romfs_buildctx *ctx); void BuildIvfcHeader(romfs_buildctx *ctx); void GenIvfcHashTree(romfs_buildctx *ctx); -u32 CalcPathHash(u32 parent, const romfs_char* path, u32 start, u32 length); +u32 CalcPathHash(u32 parent, const romfs_char* path); int PrepareBuildRomFsBinary(ncch_settings *ncchset, romfs_buildctx *ctx) @@ -279,13 +279,13 @@ void BuildRomfsHeader(romfs_buildctx *ctx) u32 GetFileHashTableIndex(romfs_buildctx *ctx, u32 parent, const romfs_char *path) { - u32 hash = CalcPathHash(parent, path, 0, romfs_strlen(path)); + u32 hash = CalcPathHash(parent, path); return hash % ctx->m_fileHashTable; } u32 GetDirHashTableIndex(romfs_buildctx *ctx, u32 parent, const romfs_char* path) { - u32 hash = CalcPathHash(parent, path, 0, romfs_strlen(path)); + u32 hash = CalcPathHash(parent, path); return hash % ctx->m_dirHashTable; } @@ -459,13 +459,14 @@ void GenIvfcHashTree(romfs_buildctx *ctx) return; } -u32 CalcPathHash(u32 parent, const romfs_char* path, u32 start, u32 length) +u32 CalcPathHash(u32 parent, const romfs_char* path) { + u32 len = romfs_strlen(path); u32 hash = parent ^ 123456789; - for( u32 index = 0; index < length; index++ ) + for( u32 i = 0; i < len; i++ ) { hash = (u32)((hash >> 5) | (hash << 27));//ror - hash ^= (u16)path[start + index]; + hash ^= (u16)path[i]; } return hash; }