From f473ffbe7ff5206b994c9f01c04008f800f4d71e Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 5 Sep 2019 19:06:31 +0200 Subject: [PATCH] mpqapi_add_file cleanup --- Source/mpqapi.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index dc58bfe35..ddf9bd850 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -266,17 +266,12 @@ _BLOCKENTRY *mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int block_i h3 = Hash(pszName, 2); if (mpqapi_get_hash_index(h1, h2, h3, 0) != -1) app_fatal("Hash collision between \"%s\" and existing file\n", pszName); - i = 2048; hIdx = h1 & 0x7FF; - while (1) { - i--; + i = 2048; + while (i--) { if (sgpHashTbl[hIdx].block == -1 || sgpHashTbl[hIdx].block == -2) break; hIdx = (hIdx + 1) & 0x7FF; - if (!i) { - i = -1; - break; - } } if (i < 0) app_fatal("Out of hash space");