Merge pull request #2567 from RosaryMala/develop

Remote Fortress Reader updates
develop
Myk 2023-01-07 16:30:31 -08:00 committed by GitHub
commit f9cc43728f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 85 deletions

@ -1 +1 @@
Subproject commit d026f34ed1f7ab79aebb1c5bc8a36ee9b30bd13d Subproject commit d7de31978634d6bd165069e5fcaffc64a0d4a91c

@ -148,7 +148,7 @@ dfhack_plugin(pathable pathable.cpp LINK_LIBRARIES lua)
#dfhack_plugin(prospector prospector.cpp LINK_LIBRARIES lua) #dfhack_plugin(prospector prospector.cpp LINK_LIBRARIES lua)
#dfhack_plugin(power-meter power-meter.cpp LINK_LIBRARIES lua) #dfhack_plugin(power-meter power-meter.cpp LINK_LIBRARIES lua)
#dfhack_plugin(regrass regrass.cpp) #dfhack_plugin(regrass regrass.cpp)
#add_subdirectory(remotefortressreader) add_subdirectory(remotefortressreader)
#dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename) #dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename)
#add_subdirectory(rendermax) #add_subdirectory(rendermax)
dfhack_plugin(reveal reveal.cpp LINK_LIBRARIES lua) dfhack_plugin(reveal reveal.cpp LINK_LIBRARIES lua)

@ -39,6 +39,7 @@ void SetCoord(df::coord in, RemoteFortressReader::Coord *out)
command_result MoveCommand(DFHack::color_ostream &stream, const MoveCommandParams *in) command_result MoveCommand(DFHack::color_ostream &stream, const MoveCommandParams *in)
{ {
/* Removed for v50 which has no adventure mode.
auto viewScreen = getCurViewscreen(); auto viewScreen = getCurViewscreen();
if (!in->has_direction()) if (!in->has_direction())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -186,12 +187,13 @@ command_result MoveCommand(DFHack::color_ostream &stream, const MoveCommandParam
} }
break; break;
} }
return CR_OK; */ return CR_OK;
} }
command_result JumpCommand(DFHack::color_ostream &stream, const MoveCommandParams *in) command_result JumpCommand(DFHack::color_ostream &stream, const MoveCommandParams *in)
{ {
if (!in->has_direction()) /* Removed for v50 which has no adventure mode.
if (!in->has_direction())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
if (!df::global::adventure->menu == ui_advmode_menu::Default) if (!df::global::adventure->menu == ui_advmode_menu::Default)
return CR_OK; return CR_OK;
@ -228,12 +230,14 @@ command_result JumpCommand(DFHack::color_ostream &stream, const MoveCommandParam
} }
} }
keyQueue.push(interface_key::SELECT); keyQueue.push(interface_key::SELECT);
*/
return CR_OK; return CR_OK;
} }
command_result MenuQuery(DFHack::color_ostream &stream, const EmptyMessage *in, MenuContents *out) command_result MenuQuery(DFHack::color_ostream &stream, const EmptyMessage *in, MenuContents *out)
{ {
auto advUi = df::global::adventure; /* Removed for v50 which has no adventure mode.
auto advUi = df::global::adventure;
if (advUi == NULL) if (advUi == NULL)
return CR_FAILURE; return CR_FAILURE;
@ -272,12 +276,13 @@ command_result MenuQuery(DFHack::color_ostream &stream, const EmptyMessage *in,
default: default:
break; break;
} }
*/
return CR_OK; return CR_OK;
} }
command_result MovementSelectCommand(DFHack::color_ostream &stream, const dfproto::IntMessage *in) command_result MovementSelectCommand(DFHack::color_ostream &stream, const dfproto::IntMessage *in)
{ {
/* Removed for v50 which has no adventure mode.
if (!(df::global::adventure->menu == ui_advmode_menu::MoveCarefully)) if (!(df::global::adventure->menu == ui_advmode_menu::MoveCarefully))
return CR_OK; return CR_OK;
int choice = in->value(); int choice = in->value();
@ -288,12 +293,14 @@ command_result MovementSelectCommand(DFHack::color_ostream &stream, const dfprot
keyQueue.push(interface_key::SECONDSCROLL_PAGEDOWN); keyQueue.push(interface_key::SECONDSCROLL_PAGEDOWN);
} }
keyQueue.push((interface_key::interface_key)(interface_key::OPTION1 + select)); keyQueue.push((interface_key::interface_key)(interface_key::OPTION1 + select));
*/
return CR_OK; return CR_OK;
} }
command_result MiscMoveCommand(DFHack::color_ostream &stream, const MiscMoveParams *in) command_result MiscMoveCommand(DFHack::color_ostream &stream, const MiscMoveParams *in)
{ {
if (!df::global::adventure->menu == ui_advmode_menu::Default) /* Removed for v50 which has no adventure mode.
if (!df::global::adventure->menu == ui_advmode_menu::Default)
return CR_OK; return CR_OK;
auto type = in->type(); auto type = in->type();
@ -312,6 +319,6 @@ command_result MiscMoveCommand(DFHack::color_ostream &stream, const MiscMovePara
default: default:
break; break;
} }
*/
return CR_OK; return CR_OK;
} }

@ -316,7 +316,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
material->set_mat_index(local_build->mat_index); material->set_mat_index(local_build->mat_index);
remote_build->set_building_flags(local_build->flags.whole); remote_build->set_building_flags(local_build->flags.whole);
remote_build->set_is_room(local_build->is_room);
if (local_build->room.width > 0 && local_build->room.height > 0 && local_build->room.extents != nullptr) if (local_build->room.width > 0 && local_build->room.height > 0 && local_build->room.extents != nullptr)
{ {
auto room = remote_build->mutable_room(); auto room = remote_build->mutable_room();
@ -607,25 +606,27 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
} }
case df::enums::building_type::ArcheryTarget: case df::enums::building_type::ArcheryTarget:
{ {
//FIXME: Need to decode archery targets again.
auto actual = strict_virtual_cast<df::building_archerytargetst>(local_build); auto actual = strict_virtual_cast<df::building_archerytargetst>(local_build);
if (actual) if (actual)
{ {
auto facing = actual->archery_direction; for (size_t i = 0; i < actual->relations.size(); i++)
switch (facing)
{ {
case df::building_archerytargetst::TopToBottom: if (actual->relations[i]->getType() != df::enums::building_type::Civzone)
remote_build->set_direction(NORTH); continue;
break; auto zone = strict_virtual_cast<df::building_civzonest>(actual->relations[i]);
case df::building_archerytargetst::BottomToTop: if (!zone)
remote_build->set_direction(SOUTH); continue;
break; if (zone->type != df::civzone_type::ArcheryRange)
case df::building_archerytargetst::LeftToRight: continue;
remote_build->set_direction(WEST); if(zone->dir_x < 0)
break; remote_build->set_direction(EAST);
case df::building_archerytargetst::RightToLeft: else if(zone->dir_x > 0)
remote_build->set_direction(EAST); remote_build->set_direction(WEST);
break; else if (zone->dir_y < 0)
default: remote_build->set_direction(SOUTH);
else if (zone->dir_y > 0)
remote_build->set_direction(NORTH);
break; break;
} }
} }
@ -849,7 +850,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
auto actual = strict_virtual_cast<df::building_windmillst>(local_build); auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
if (actual) if (actual)
{ {
#if DF_VERSION_INT > 34011
if (actual->orient_x < 0) if (actual->orient_x < 0)
remote_build->set_direction(WEST); remote_build->set_direction(WEST);
else if (actual->orient_x > 0) else if (actual->orient_x > 0)
@ -859,7 +859,6 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
else if (actual->orient_y > 0) else if (actual->orient_y > 0)
remote_build->set_direction(SOUTH); remote_build->set_direction(SOUTH);
else else
#endif
remote_build->set_direction(WEST); remote_build->set_direction(WEST);
if (actual->machine.machine_id >= 0) if (actual->machine.machine_id >= 0)
{ {

@ -233,6 +233,7 @@ command_result SetPauseState(color_ostream &stream, const SingleBool *in)
void CopyBuildMenu(DwarfControl::SidebarState * out) void CopyBuildMenu(DwarfControl::SidebarState * out)
{ {
/* Removed in v50 because the new menu is completely changed and we may not even want to do it the same way anymore.
auto menus = df::global::game; auto menus = df::global::game;
auto build_selector = df::global::ui_build_selector; auto build_selector = df::global::ui_build_selector;
if (build_selector->building_type == -1) if (build_selector->building_type == -1)
@ -299,10 +300,12 @@ void CopyBuildMenu(DwarfControl::SidebarState * out)
send_selector->add_tiles(build_selector->tiles[x][y]); send_selector->add_tiles(build_selector->tiles[x][y]);
} }
} }
*/
} }
command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMessage *in, DwarfControl::SidebarState *out) command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMessage *in, DwarfControl::SidebarState *out)
{ {
/* Removed in v50 because the new menu is completely changed and we may not even want to do it the same way anymore.
auto plotinfo = df::global::plotinfo; auto plotinfo = df::global::plotinfo;
out->set_mode((proto::enums::ui_sidebar_mode::ui_sidebar_mode)plotinfo->main.mode); out->set_mode((proto::enums::ui_sidebar_mode::ui_sidebar_mode)plotinfo->main.mode);
auto mode = plotinfo->main.mode; auto mode = plotinfo->main.mode;
@ -422,11 +425,13 @@ command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMe
default: default:
break; break;
} }
*/
return CR_OK; return CR_OK;
} }
command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarCommand *in) command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarCommand *in)
{ {
/* Removed in v50 because the new menu is completely changed and we may not even want to do it the same way anymore.
auto plotinfo = df::global::plotinfo; auto plotinfo = df::global::plotinfo;
if (in->has_mode()) if (in->has_mode())
{ {
@ -489,5 +494,6 @@ command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::Si
break; break;
} }
} }
*/
return CR_OK; return CR_OK;
} }

@ -271,7 +271,8 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
case df::enums::item_type::GLOVES: case df::enums::item_type::GLOVES:
break; break;
case df::enums::item_type::BOX: case df::enums::item_type::BOX:
type->set_mat_index(DfItem->isBag()); //FIXME: Figure out how things change with this. Possibly make sure the item types are mutable.
//type->set_mat_index(DfItem->isBag());
break; break;
case df::enums::item_type::BIN: case df::enums::item_type::BIN:
break; break;

@ -319,14 +319,14 @@ uint16_t fletcher16(uint8_t const *data, size_t bytes)
void ConvertDfColor(int16_t index, RemoteFortressReader::ColorDefinition * out) void ConvertDfColor(int16_t index, RemoteFortressReader::ColorDefinition * out)
{ {
if (!df::global::enabler) if (!df::global::gps)
return; return;
auto enabler = df::global::enabler; auto gps = df::global::gps;
out->set_red((int)(enabler->ccolor[index][0] * 255)); out->set_red(gps->uccolor[index][0]);
out->set_green((int)(enabler->ccolor[index][1] * 255)); out->set_green(gps->uccolor[index][1]);
out->set_blue((int)(enabler->ccolor[index][2] * 255)); out->set_blue(gps->uccolor[index][2]);
} }
void ConvertDfColor(int16_t in[3], RemoteFortressReader::ColorDefinition * out) void ConvertDfColor(int16_t in[3], RemoteFortressReader::ColorDefinition * out)
@ -859,31 +859,6 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
} }
} }
} }
//for (size_t i = 0; i < history->figures.size(); i++)
//{
// df::historical_figure * figure = history->figures[i];
// if (figure->race < 0)
// continue;
// df::creature_raw * creature = raws->creatures.all[figure->race];
// for (int j = 0; j < creature->material.size(); j++)
// {
// mat.decode(j + MaterialInfo::FIGURE_BASE, i);
// MaterialDefinition *mat_def = out->add_material_list();
// mat_def->mutable_mat_pair()->set_mat_type(j + MaterialInfo::FIGURE_BASE);
// mat_def->mutable_mat_pair()->set_mat_index(i);
// stringstream id;
// id << "HF" << i << mat.getToken();
// mat_def->set_id(id.str());
// mat_def->set_name(mat.toString()); //find the name at cave temperature;
// if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->descriptors.colors.size())
// {
// df::descriptor_color *color = raws->descriptors.colors[creature->material[j]->state_color[GetState(creature->material[j])]];
// mat_def->mutable_state_color()->set_red(color->red * 255);
// mat_def->mutable_state_color()->set_green(color->green * 255);
// mat_def->mutable_state_color()->set_blue(color->blue * 255);
// }
// }
//}
for (size_t i = 0; i < raws->plants.all.size(); i++) for (size_t i = 0; i < raws->plants.all.size(); i++)
{ {
df::plant_raw * plant = raws->plants.all[i]; df::plant_raw * plant = raws->plants.all[i];
@ -1854,18 +1829,19 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
Gui::getViewCoords(x, y, z); Gui::getViewCoords(x, y, z);
Gui::getCursorCoords(cx, cy, cz); Gui::getCursorCoords(cx, cy, cz);
#if DF_VERSION_INT > 34011 //FIXME: Get get this info from the new embark screen.
auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); //#if DF_VERSION_INT > 34011
if (embark) // auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
{ // if (embark)
df::embark_location location = embark->location; // {
df::world_data * data = df::global::world->world_data; // df::embark_location location = embark->location;
if (data && data->region_map) // df::world_data * data = df::global::world->world_data;
{ // if (data && data->region_map)
z = data->region_map[location.region_pos.x][location.region_pos.y].elevation; // {
} // z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
} // }
#endif // }
//#endif
auto dims = Gui::getDwarfmodeViewDims(); auto dims = Gui::getDwarfmodeViewDims();
@ -1915,22 +1891,23 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in,
DFCoord GetMapCenter() DFCoord GetMapCenter()
{ {
DFCoord output; DFCoord output;
#if DF_VERSION_INT > 34011 //FIXME: Does this even still exist?
auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); //#if DF_VERSION_INT > 34011
if (embark) // auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
{ // if (embark)
df::embark_location location = embark->location; // {
output.x = (location.region_pos.x * 16) + 8; // df::embark_location location = embark->location;
output.y = (location.region_pos.y * 16) + 8; // output.x = (location.region_pos.x * 16) + 8;
output.z = 100; // output.y = (location.region_pos.y * 16) + 8;
df::world_data * data = df::global::world->world_data; // output.z = 100;
if (data && data->region_map) // df::world_data * data = df::global::world->world_data;
{ // if (data && data->region_map)
output.z = data->region_map[location.region_pos.x][location.region_pos.y].elevation; // {
} // output.z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
} // }
else // }
#endif // else
//#endif
if (Maps::IsValid()) if (Maps::IsValid())
{ {
int x, y, z; int x, y, z;