Well, that would be why the ActiveBlocks data isn't correct . . .
[aesalon.git] / gui / src / storage / FreeEvent.cpp
blobdc8867b31a93b0a0a5824b26d398b61bd4c8e925
1 #include "FreeEvent.h"
3 void FreeEvent::apply_to(Snapshot *snapshot) {
4 qDebug("Asked to apply FreeEvent to snapshot #%li . . .", (long int)snapshot->get_snapshot_id());
5 BiTreeNode *node = snapshot->get_head_node();
6 if(!node) return;
8 quint8 max_depth = snapshot->get_max_tree_depth();
9 /* First, traverse the tree to find the right spot. Do not create any
10 nodes required to get there -- this is a removal, not an addition! */
11 for(quint8 depth = 0; depth < max_depth; depth ++) {
12 bool bit = MemoryAddress(address << depth) & 0x01;
13 if(!bit) {
14 if(node->get_left() != NULL) node = node->get_left();
15 else return;
17 else {
18 if(node->get_right() != NULL) node = node->get_right();
19 else return;
22 Block *block = node->get_block(address);
23 if(block) node->remove_block(block);