| 3434 | } |
| 3435 | |
| 3436 | void Osiris_SaveOMMS(CFILE *file) { |
| 3437 | // save out our current OMMS handle position |
| 3438 | cf_WriteShort(file, OMMS_Current_base_id); |
| 3439 | cf_WriteShort(file, OMMS_Current_id); |
| 3440 | |
| 3441 | // go through all the hash nodes write their information out |
| 3442 | tOMMSHashNode *currhash = OMMS_Hash_node_root; |
| 3443 | while (currhash) { |
| 3444 | // write out a 1, saying that we have a hash node here |
| 3445 | cf_WriteByte(file, 1); |
| 3446 | |
| 3447 | cf_WriteShort(file, currhash->base_id); |
| 3448 | |
| 3449 | // write out the info about this hash node |
| 3450 | int length; |
| 3451 | length = (currhash->script_name) ? strlen(currhash->script_name) : 0; |
| 3452 | cf_WriteByte(file, length); |
| 3453 | if (length) |
| 3454 | cf_WriteBytes((uint8_t *)currhash->script_name, length, file); |
| 3455 | |
| 3456 | // now go through all the nodes and write their data |
| 3457 | tOMMSNode *node; |
| 3458 | node = currhash->root; |
| 3459 | while (node) { |
| 3460 | // write out 1, for valid hash |
| 3461 | cf_WriteByte(file, 1); |
| 3462 | cf_WriteShort(file, node->id); |
| 3463 | |
| 3464 | // write out all the node data |
| 3465 | cf_WriteByte(file, node->free_called); |
| 3466 | cf_WriteShort(file, node->reference_count); |
| 3467 | cf_WriteInt(file, node->unique_id); |
| 3468 | cf_WriteInt(file, node->size_of_memory); |
| 3469 | if (node->size_of_memory) |
| 3470 | cf_WriteBytes((uint8_t *)node->memory_ptr, node->size_of_memory, file); |
| 3471 | |
| 3472 | node = node->next; |
| 3473 | } |
| 3474 | // write out terminating 0 |
| 3475 | cf_WriteByte(file, 0); |
| 3476 | |
| 3477 | // go to the next hash node |
| 3478 | currhash = currhash->next; |
| 3479 | } |
| 3480 | |
| 3481 | // write out terminating 0 |
| 3482 | cf_WriteByte(file, 0); |
| 3483 | } |
| 3484 | |
| 3485 | void Osiris_RestoreOMMS(CFILE *file) { |
| 3486 | ASSERT(OMMS_Hash_node_root == NULL); |
no test coverage detected