Skip to main content

Module character_tree

Module character_tree 

Source
Expand description

The characters’ spatial tree: a loose quadtree of the CharacterComponents, which the tornado’s victims and the hunters’ prey are searched in.

  • Built: a world of 2048 units centred on the map (offset 1024, 1024), 8 levels, node base[level] + Morton(x, y) with the bases 0, 1, 5, 0x15, … 0x1555 (0x5555 nodes). Each node keeps a circular list of its slots (the head) and the count of slots in it and below (carried up parent = (i − 1) >> 2).
  • Insert (when a character starts or is loaded): the last freed slot, else a new one; then placed.
  • Remove (when a character ends): unlinked, the slot freed.
  • Place (at every character update): the level from the character’s square (its position ± the description’s radius), the cell its centre falls in at that level; a slot that changes node goes to the end of the new node’s list.
  • Search: a stack from the root; a node with nothing in or below it, or whose loose box (its square doubled, z from −1 to 1) misses the query’s box (the point ± the radius on every axis), is dropped; otherwise its slots are visited from the head and it is replaced by its four children (pushed 1 to 4, so the fourth comes off first). The z bounds mean nothing is found while the point stands more than the radius + 1 from height 0.

Original: built by FUN_140018cc0; insert FUN_14010ee90 (start) and FUN_14010ef80 (load); remove FUN_14010ee50; place FUN_14010e990; and FUN_140097e60, FUN_140097730, FUN_140097d50, FUN_140018e00, FUN_140018f70, FUN_140019070, FUN_140019710, FUN_140019650, FUN_1400197e0, FUN_140019290.

Structs§

CharacterTree
The characters’ spatial tree. See the module documentation.

Enums§

Who
What a slot holds: the owner of the CharacterComponent.