diff --git a/examples/veinlook.cpp b/examples/veinlook.cpp index e01558087..2609fdbce 100644 --- a/examples/veinlook.cpp +++ b/examples/veinlook.cpp @@ -100,8 +100,15 @@ int puttile(int x, int y, int tiletype, int color) znak = '='; break; case RAMP: - znak = '^'; - break; + attron(COLOR_PAIR(color)); + mvwaddwstr(stdscr, y, x, L"\u25B2"); + attroff(COLOR_PAIR(color)); + return 0; + case RAMP_TOP: + attron(COLOR_PAIR(color)); + mvwaddwstr(stdscr, y, x, L"\u25BC"); + attroff(COLOR_PAIR(color)); + return 0; case FLOOR: znak = '.'; break; diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp index fe03ff978..d0860b03c 100644 --- a/library/DFHackAPI.cpp +++ b/library/DFHackAPI.cpp @@ -352,7 +352,7 @@ bool API::ReadBlock40d(uint32_t x, uint32_t y, uint32_t z, mapblock40d * buffer) g_pProcess->read (addr + d->biome_stuffs, sizeof (buffer->biome_indices), (uint8_t *) buffer->biome_indices); buffer->origin = addr; uint32_t addr_of_struct = g_pProcess->readDWord(addr); - buffer->dirty_dword = g_pProcess->readDWord(addr_of_struct); + buffer->blockflags.whole = g_pProcess->readDWord(addr_of_struct); return true; } return false; @@ -399,8 +399,30 @@ bool API::WriteDirtyBit(uint32_t x, uint32_t y, uint32_t z, bool dirtybit) return false; } +/// read/write the block flags +bool API::ReadBlockFlags(uint32_t x, uint32_t y, uint32_t z, t_blockflags &blockflags) +{ + uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z]; + if(addr) + { + uint32_t addr_of_struct = g_pProcess->readDWord(addr); + blockflags.whole = g_pProcess->readDWord(addr_of_struct); + return true; + } + return false; +} +bool API::WriteBlockFlags(uint32_t x, uint32_t y, uint32_t z, t_blockflags blockflags) +{ + uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z]; + if (addr) + { + uint32_t addr_of_struct = g_pProcess->readDWord(addr); + g_pProcess->writeDWord (addr_of_struct, blockflags.whole); + return true; + } + return false; +} -// 256 * sizeof(uint32_t) bool API::ReadDesignations (uint32_t x, uint32_t y, uint32_t z, designations40d *buffer) { uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z]; diff --git a/library/DFHackAPI.h b/library/DFHackAPI.h index b828e1695..c99b8c287 100644 --- a/library/DFHackAPI.h +++ b/library/DFHackAPI.h @@ -161,6 +161,10 @@ namespace DFHack bool ReadDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool &dirtybit); bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit); + /// read/write the block flags + bool ReadBlockFlags(uint32_t blockx, uint32_t blocky, uint32_t blockz, t_blockflags &blockflags); + bool WriteBlockFlags(uint32_t blockx, uint32_t blocky, uint32_t blockz, t_blockflags blockflags); + /// read region offsets of a block - used for determining layer stone matgloss bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, biome_indices40d *buffer); diff --git a/library/DFTileTypes.h b/library/DFTileTypes.h index 0601c1502..4ec224241 100644 --- a/library/DFTileTypes.h +++ b/library/DFTileTypes.h @@ -42,6 +42,7 @@ namespace DFHack STAIR_UPDOWN, RAMP, + RAMP_TOP, FLOOR, TREE_DEAD, @@ -95,7 +96,7 @@ namespace DFHack { // 0 {"void",EMPTY, AIR, VAR_1}, - {"ramp top",EMPTY, AIR, VAR_1}, + {"ramp top",RAMP_TOP, AIR, VAR_1}, {"pool",FLOOR, SOIL, VAR_1}, {0, EMPTY, AIR, VAR_1}, {0, EMPTY, AIR, VAR_1}, diff --git a/library/DFTypes.h b/library/DFTypes.h index 3f38d6e29..33d534ba5 100644 --- a/library/DFTypes.h +++ b/library/DFTypes.h @@ -828,6 +828,24 @@ union t_occupancy naked_occupancy_grouped unibits; }; +// map block flags +struct naked_blockflags +{ + unsigned int designated : 1;// designated for jobs (digging and stuff like that) + unsigned int unk_1 : 1; // possibly related to the designated flag + // two flags required for liquid flow. no idea why + unsigned int liquid_1 : 1; + unsigned int liquid_2 : 1; + unsigned int unk_2: 28; // rest of the flags is completely unknown + // there's a possibility that this flags field is shorter than 32 bits +}; + +union t_blockflags +{ + uint32_t whole; + naked_blockflags bits; +}; + typedef int16_t tiletypes40d [16][16]; typedef DFHack::t_designation designations40d [16][16]; typedef DFHack::t_occupancy occupancies40d [16][16]; @@ -841,7 +859,7 @@ typedef struct // really a '7', but I use 8 to make it neater :) biome_indices40d biome_indices; uint32_t origin; // the address where it came from - uint32_t dirty_dword; // bit 1 set means that the block is to be included in job checks + t_blockflags blockflags; } mapblock40d; struct t_viewscreen diff --git a/shmserver/mod-maps.cpp b/shmserver/mod-maps.cpp index 424c157ed..53e11f900 100644 --- a/shmserver/mod-maps.cpp +++ b/shmserver/mod-maps.cpp @@ -64,7 +64,7 @@ inline void ReadBlockByAddress (void * data) memcpy(&(SHMDATA(mapblock40d)->designation), ((char *) block) + offsets.designation_offset, sizeof(SHMDATA(mapblock40d)->designation)); memcpy(&(SHMDATA(mapblock40d)->occupancy), ((char *) block) + offsets.occupancy_offset, sizeof(SHMDATA(mapblock40d)->occupancy)); memcpy(&(SHMDATA(mapblock40d)->biome_indices), ((char *) block) + offsets.biome_stuffs, sizeof(SHMDATA(mapblock40d)->biome_indices)); - SHMDATA(mapblock40d)->dirty_dword = *block->ptr_to_dirty; + SHMDATA(mapblock40d)->blockflags.whole = *block->ptr_to_dirty; SHMDATA(mapblock40d)->origin = (uint32_t)block; SHMHDR->error = false; diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index eaedbad08..fd64b44dd 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -30,11 +30,20 @@ int main (void) cout << "cursor coords: " << x << "/" << y << "/" << z << endl; if(DF.isValidBlock(x/16,y/16,z)) { - DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - + // place the magma + DF.ReadDesignations((x/16),(y/16),z, &designations); designations[x%16][y%16].bits.flow_size = 7; designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; DF.WriteDesignations(x/16,y/16,z, &designations); + + // make the magma flow :) + DFHack::t_blockflags bflags; + DF.ReadBlockFlags((x/16),(y/16),z,bflags); + // 0x00000001 = job-designated + // 0x0000000C = run flows? - both bit 3 and 4 required for making magma placed on a glacier flow + bflags.bits.liquid_1 = true; + bflags.bits.liquid_2 = true; + DF.WriteBlockFlags((x/16),(y/16),z,bflags); cout << "Success" << endl; } else