|
57 | 57 | #include "df/descriptor_shape.h" |
58 | 58 | #include "df/dfhack_material_category.h" |
59 | 59 | #include "df/enabler.h" |
| 60 | +#include "df/engraving.h" |
60 | 61 | #include "df/graphic.h" |
61 | 62 | #include "df/historical_figure.h" |
62 | 63 |
|
@@ -182,20 +183,18 @@ const char* growth_locations[] = { |
182 | 183 | #include "df/art_image.h" |
183 | 184 | #include "df/art_image_chunk.h" |
184 | 185 | #include "df/art_image_ref.h" |
185 | | -command_result generate_image(color_ostream &out, vector <string> & parameters) |
| 186 | +command_result loadArtImageChunk(color_ostream &out, vector <string> & parameters) |
186 | 187 | { |
187 | | - df::art_image_ref imageRef; |
188 | | - imageRef.civ_id = -1; |
189 | | - imageRef.id = -1; |
190 | | - imageRef.site_id = -1; |
191 | | - imageRef.subid = -1; |
| 188 | + if (parameters.size() != 1) |
| 189 | + return CR_WRONG_USAGE; |
192 | 190 |
|
193 | | - GET_IMAGE getImage = reinterpret_cast<GET_IMAGE>(Core::getInstance().vinfo->getAddress("rfr_get_art_image")); |
194 | | - if (getImage) |
| 191 | + |
| 192 | + GET_ART_IMAGE_CHUNK GetArtImageChunk = reinterpret_cast<GET_ART_IMAGE_CHUNK>(Core::getInstance().vinfo->getAddress("rfr_get_art_image")); |
| 193 | + if (GetArtImageChunk) |
195 | 194 | { |
196 | | - int16_t subid = -1; |
197 | | - auto image = getImage(world, &imageRef, &subid); |
198 | | - out.print("Id: %d, subid: %d\n", image->id, image->subid); |
| 195 | + int index = atoi(parameters[0].c_str()); |
| 196 | + auto chunk = GetArtImageChunk(&(world->art_image_chunks), index); |
| 197 | + out.print("Loaded chunk id: &d", chunk->id); |
199 | 198 | } |
200 | 199 | return CR_OK; |
201 | 200 | } |
@@ -271,10 +270,10 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector <Plugin |
271 | 270 | )); |
272 | 271 | commands.push_back(PluginCommand("RemoteFortressReader_version", "List the loaded RemoteFortressReader version", RemoteFortressReader_version, false, "This is used for plugin version checking.")); |
273 | 272 | commands.push_back(PluginCommand( |
274 | | - "generate_image", |
275 | | - "make a blank art image using inbuilt DF functions.", |
276 | | - generate_image, false, |
277 | | - "used to test the function pointer being correct. If everything works, the subid should increment each time.")); |
| 273 | + "load_art_image_chunk", |
| 274 | + "Gets an art image chunk by index, loading from disk if necessary", |
| 275 | + loadArtImageChunk, false, |
| 276 | + "Usage: load_art_image_chunk N, where N is the id of the chunk to get.")); |
278 | 277 | enableUpdates = true; |
279 | 278 | return CR_OK; |
280 | 279 | } |
@@ -799,13 +798,29 @@ bool areItemsChanged(vector<int> * items) |
799 | 798 | return result; |
800 | 799 | } |
801 | 800 |
|
| 801 | +map<int, int> engravingHashes; |
| 802 | + |
| 803 | +bool isEngravingNew(int index) |
| 804 | +{ |
| 805 | + if (engravingHashes[index]) |
| 806 | + return false; |
| 807 | + engravingHashes[index] = true; |
| 808 | + return true; |
| 809 | +} |
| 810 | + |
| 811 | +void engravingIsNotNew(int index) |
| 812 | +{ |
| 813 | + engravingHashes[index] = false; |
| 814 | +} |
| 815 | + |
802 | 816 | static command_result ResetMapHashes(color_ostream &stream, const EmptyMessage *in) |
803 | 817 | { |
804 | 818 | hashes.clear(); |
805 | 819 | waterHashes.clear(); |
806 | 820 | buildingHashes.clear(); |
807 | 821 | spatterHashes.clear(); |
808 | 822 | itemHashes.clear(); |
| 823 | + engravingHashes.clear(); |
809 | 824 | return CR_OK; |
810 | 825 | } |
811 | 826 |
|
@@ -1485,6 +1500,54 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in |
1485 | 1500 | } |
1486 | 1501 | } |
1487 | 1502 | } |
| 1503 | + |
| 1504 | + for (int i = 0; i < world->engravings.size(); i++) |
| 1505 | + { |
| 1506 | + auto engraving = world->engravings[i]; |
| 1507 | + if (engraving->pos.x < (min_x * 16) || engraving->pos.x >(max_x * 16)) |
| 1508 | + continue; |
| 1509 | + if (engraving->pos.y < (min_y * 16) || engraving->pos.x >(max_y * 16)) |
| 1510 | + continue; |
| 1511 | + if (engraving->pos.z < (min_z * 16) || engraving->pos.x >(max_z * 16)) |
| 1512 | + continue; |
| 1513 | + if (!isEngravingNew(i)) |
| 1514 | + continue; |
| 1515 | + |
| 1516 | + df::art_image_chunk * chunk = NULL; |
| 1517 | + GET_ART_IMAGE_CHUNK GetArtImageChunk = reinterpret_cast<GET_ART_IMAGE_CHUNK>(Core::getInstance().vinfo->getAddress("rfr_get_art_image")); |
| 1518 | + if (GetArtImageChunk) |
| 1519 | + { |
| 1520 | + chunk = GetArtImageChunk(&(world->art_image_chunks), engraving->art_id); |
| 1521 | + } |
| 1522 | + else |
| 1523 | + { |
| 1524 | + for (int i = 0; i < world->art_image_chunks.size(); i++) |
| 1525 | + { |
| 1526 | + if (world->art_image_chunks[i]->id == engraving->art_id) |
| 1527 | + chunk = world->art_image_chunks[i]; |
| 1528 | + } |
| 1529 | + } |
| 1530 | + if (!chunk) |
| 1531 | + { |
| 1532 | + engravingIsNotNew(i); |
| 1533 | + continue; |
| 1534 | + } |
| 1535 | + auto netEngraving = out->add_engravings(); |
| 1536 | + ConvertDFCoord(engraving->pos, netEngraving->mutable_pos()); |
| 1537 | + netEngraving->set_quality(engraving->quality); |
| 1538 | + netEngraving->set_tile(engraving->tile); |
| 1539 | + CopyImage(chunk->images[engraving->art_subid], netEngraving->mutable_image()); |
| 1540 | + netEngraving->set_floor(engraving->flags.bits.floor); |
| 1541 | + netEngraving->set_west(engraving->flags.bits.west); |
| 1542 | + netEngraving->set_east(engraving->flags.bits.east); |
| 1543 | + netEngraving->set_north(engraving->flags.bits.north); |
| 1544 | + netEngraving->set_south(engraving->flags.bits.south); |
| 1545 | + netEngraving->set_hidden(engraving->flags.bits.hidden); |
| 1546 | + netEngraving->set_northwest(engraving->flags.bits.northwest); |
| 1547 | + netEngraving->set_northeast(engraving->flags.bits.northeast); |
| 1548 | + netEngraving->set_southwest(engraving->flags.bits.southwest); |
| 1549 | + netEngraving->set_southeast(engraving->flags.bits.southeast); |
| 1550 | + } |
1488 | 1551 | MC.trash(); |
1489 | 1552 | return CR_OK; |
1490 | 1553 | } |
|
0 commit comments