| 3483 | } |
| 3484 | |
| 3485 | void Osiris_RestoreOMMS(CFILE *file) { |
| 3486 | ASSERT(OMMS_Hash_node_root == NULL); |
| 3487 | |
| 3488 | OMMS_Current_base_id = (uint16_t)cf_ReadShort(file); |
| 3489 | OMMS_Current_id = (uint16_t)cf_ReadShort(file); |
| 3490 | |
| 3491 | tOMMSHashNode *currhash; |
| 3492 | tOMMSNode *node; |
| 3493 | |
| 3494 | currhash = NULL; |
| 3495 | |
| 3496 | // we have to rebuild the nodes |
| 3497 | while (cf_ReadByte(file)) { |
| 3498 | if (!currhash) { |
| 3499 | currhash = OMMS_Hash_node_root = (tOMMSHashNode *)mem_malloc(sizeof(tOMMSHashNode)); |
| 3500 | } else { |
| 3501 | currhash->next = (tOMMSHashNode *)mem_malloc(sizeof(tOMMSHashNode)); |
| 3502 | currhash = currhash->next; |
| 3503 | } |
| 3504 | |
| 3505 | if (!currhash) |
| 3506 | Error("Out of memory"); |
| 3507 | |
| 3508 | currhash->next = NULL; |
| 3509 | currhash->root = NULL; |
| 3510 | currhash->script_name = NULL; |
| 3511 | |
| 3512 | currhash->base_id = (uint16_t)cf_ReadShort(file); |
| 3513 | |
| 3514 | // read length of string |
| 3515 | int length = cf_ReadByte(file); |
| 3516 | if (length) { |
| 3517 | currhash->script_name = (char *)mem_malloc(length + 1); |
| 3518 | if (!currhash->script_name) |
| 3519 | Error("Out of Memory"); |
| 3520 | else |
| 3521 | cf_ReadBytes((uint8_t *)currhash->script_name, length, file); |
| 3522 | } |
| 3523 | |
| 3524 | node = NULL; |
| 3525 | |
| 3526 | // now go through all the nodes and right their data |
| 3527 | while (cf_ReadByte(file)) { |
| 3528 | if (!node) { |
| 3529 | node = currhash->root = (tOMMSNode *)mem_malloc(sizeof(tOMMSNode)); |
| 3530 | } else { |
| 3531 | node->next = (tOMMSNode *)mem_malloc(sizeof(tOMMSNode)); |
| 3532 | node = node->next; |
| 3533 | } |
| 3534 | |
| 3535 | if (!node) |
| 3536 | Error("Out of memory"); |
| 3537 | |
| 3538 | node->memory_ptr = NULL; |
| 3539 | node->next = NULL; |
| 3540 | |
| 3541 | node->id = (uint16_t)cf_ReadShort(file); |
| 3542 |
no test coverage detected