Skip to content

Seed a structure's sight bonus from its fixed-up coordinate #106

Description

@ZivDero

TechnoClass::Unlimbo assigns SightIncrease = Get_Sight_Bonus(coord) from the caller's coordinate (code/techno.cpp:1742 as of ecd2968). Structure placement passes a bare cell — building->Unlimbo(cell) on deploy in UnitClass (code/unit.cpp:1947) and tech->Unlimbo((Cell)cell) in HouseClass::Place_Object (code/house.cpp:2753) — and Coord(Cell const &, LEPTON z = 0) (code/coord.h:61) gives it Z = 0. By then ObjectClass::Unlimbo has already run Coord_Fixup, which sets PositionCoord.Z to the ground height (BuildingTypeClass::Coord_Fixup, code/builtype.cpp:1615), so a structure on raised ground ends placement with a bonus of 0 while its own coordinate says otherwise.

The only reader, TechnoClass::Look (code/techno.cpp:7940), recomputes the value from Get_Coord().Z before using it, so no reveal radius is wrong. The effects are that the structure's first look after placement is forced non-incremental (the recomputed bonus exceeds the stored 0), and that the stored value serialized into saves and the desync dump is wrong for every structure on raised ground.

Seeding from PositionCoordSightIncrease = Get_Sight_Bonus(PositionCoord); — or dropping the assignment, since Look() rewrites it, fixes both. Units are unaffected either way: their per-cell look rewrites the field.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions