MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Map_ChangeSpiceAmount

Function Map_ChangeSpiceAmount

src/map.c:771–803  ·  view source on GitHub ↗

* Change amount of spice at \a packed position. * @param packed Position in the world to modify. * @param dir Direction of change, > 0 means add spice, < 0 means remove spice. */

Source from the content-addressed store, hash-verified

769 * @param dir Direction of change, > 0 means add spice, < 0 means remove spice.
770 */
771void Map_ChangeSpiceAmount(uint16 packed, int16 dir)
772{
773 uint16 type;
774 uint16 spriteID;
775
776 if (dir == 0) return;
777
778 type = Map_GetLandscapeType(packed);
779
780 if (type == LST_THICK_SPICE && dir > 0) return;
781 if (type != LST_SPICE && type != LST_THICK_SPICE && dir < 0) return;
782 if (type != LST_NORMAL_SAND && type != LST_ENTIRELY_DUNE && type != LST_SPICE && dir > 0) return;
783
784 if (dir > 0) {
785 type = (type == LST_SPICE) ? LST_THICK_SPICE : LST_SPICE;
786 } else {
787 type = (type == LST_THICK_SPICE) ? LST_SPICE : LST_NORMAL_SAND;
788 }
789
790 spriteID = 0;
791 if (type == LST_SPICE) spriteID = 49;
792 if (type == LST_THICK_SPICE) spriteID = 65;
793
794 spriteID = g_iconMap[g_iconMap[ICM_ICONGROUP_LANDSCAPE] + spriteID] & 0x1FF;
795 g_mapTileID[packed] = 0x8000 | spriteID;
796 g_map[packed].groundTileID = spriteID;
797
798 Map_FixupSpiceEdges(packed);
799 Map_FixupSpiceEdges(packed + 1);
800 Map_FixupSpiceEdges(packed - 1);
801 Map_FixupSpiceEdges(packed - 64);
802 Map_FixupSpiceEdges(packed + 64);
803}
804
805/**
806 * Sets the viewport position.

Callers 3

Map_FillCircleWithSpiceFunction · 0.85
Script_Unit_HarvestFunction · 0.85

Calls 2

Map_GetLandscapeTypeFunction · 0.85
Map_FixupSpiceEdgesFunction · 0.85

Tested by

no test coverage detected