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

Function Map_FixupSpiceEdges

src/map.c:725–764  ·  view source on GitHub ↗

* Fixes edges of spice / thick spice to show sand / normal spice for better looks. * @param packed Position to check and possible fix edges of. */

Source from the content-addressed store, hash-verified

723 * @param packed Position to check and possible fix edges of.
724 */
725static void Map_FixupSpiceEdges(uint16 packed)
726{
727 uint16 type;
728 uint16 spriteID;
729
730 packed &= 0xFFF;
731 type = Map_GetLandscapeType(packed);
732 spriteID = 0;
733
734 if (type == LST_SPICE || type == LST_THICK_SPICE) {
735 uint8 i;
736
737 for (i = 0; i < 4; i++) {
738 const uint16 curPacked = packed + g_table_mapDiff[i];
739 uint16 curType;
740
741 if (Tile_IsOutOfMap(curPacked)) {
742 if (type == LST_SPICE || type == LST_THICK_SPICE) spriteID |= (1 << i);
743 continue;
744 }
745
746 curType = Map_GetLandscapeType(curPacked);
747
748 if (type == LST_SPICE) {
749 if (curType == LST_SPICE || curType == LST_THICK_SPICE) spriteID |= (1 << i);
750 continue;
751 }
752
753 if (curType == LST_THICK_SPICE) spriteID |= (1 << i);
754 }
755
756 spriteID += (type == LST_SPICE) ? 49 : 65;
757
758 spriteID = g_iconMap[g_iconMap[ICM_ICONGROUP_LANDSCAPE] + spriteID] & 0x1FF;
759 g_mapTileID[packed] = 0x8000 | spriteID;
760 g_map[packed].groundTileID = spriteID;
761 }
762
763 Map_Update(packed, 0, false);
764}
765
766/**
767 * Change amount of spice at \a packed position.

Callers 1

Map_ChangeSpiceAmountFunction · 0.85

Calls 2

Map_GetLandscapeTypeFunction · 0.85
Map_UpdateFunction · 0.85

Tested by

no test coverage detected