| 449 | } |
| 450 | |
| 451 | _BLOCKENTRY *mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int block_index) |
| 452 | { |
| 453 | DWORD h1, h2, h3; |
| 454 | int i, hIdx; |
| 455 | |
| 456 | h1 = Hash(pszName, 0); |
| 457 | h2 = Hash(pszName, 1); |
| 458 | h3 = Hash(pszName, 2); |
| 459 | if (mpqapi_get_hash_index(h1, h2, h3, 0) != -1) |
| 460 | app_fatal("Hash collision between \"%s\" and existing file\n", pszName); |
| 461 | hIdx = h1 & 0x7FF; |
| 462 | i = 2048; |
| 463 | while (i--) { |
| 464 | if (cur_archive.sgpHashTbl[hIdx].block == -1 || cur_archive.sgpHashTbl[hIdx].block == -2) |
| 465 | break; |
| 466 | hIdx = (hIdx + 1) & 0x7FF; |
| 467 | } |
| 468 | if (i < 0) |
| 469 | app_fatal("Out of hash space"); |
| 470 | if (!pBlk) |
| 471 | pBlk = mpqapi_new_block(&block_index); |
| 472 | |
| 473 | cur_archive.sgpHashTbl[hIdx].hashcheck[0] = h2; |
| 474 | cur_archive.sgpHashTbl[hIdx].hashcheck[1] = h3; |
| 475 | cur_archive.sgpHashTbl[hIdx].lcid = 0; |
| 476 | cur_archive.sgpHashTbl[hIdx].block = block_index; |
| 477 | |
| 478 | return pBlk; |
| 479 | } |
| 480 | |
| 481 | BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD dwLen, _BLOCKENTRY *pBlk) |
| 482 | { |
no test coverage detected