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(power-meter power-meter.cpp LINK_LIBRARIES lua)
#dfhack_plugin(regrass regrass.cpp)
#add_subdirectory(remotefortressreader)
add_subdirectory(remotefortressreader)
#dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename)
#add_subdirectory(rendermax)
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)
{
/* Removed for v50 which has no adventure mode.
auto viewScreen = getCurViewscreen();
if (!in->has_direction())
return CR_WRONG_USAGE;
@ -186,12 +187,13 @@ command_result MoveCommand(DFHack::color_ostream &stream, const MoveCommandParam
}
break;
}
return CR_OK;
*/ return CR_OK;
}
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;
if (!df::global::adventure->menu == ui_advmode_menu::Default)
return CR_OK;
@ -228,12 +230,14 @@ command_result JumpCommand(DFHack::color_ostream &stream, const MoveCommandParam
}
}
keyQueue.push(interface_key::SELECT);
*/
return CR_OK;
}
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)
return CR_FAILURE;
@ -272,12 +276,13 @@ command_result MenuQuery(DFHack::color_ostream &stream, const EmptyMessage *in,
default:
break;
}
*/
return CR_OK;
}
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))
return CR_OK;
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::interface_key)(interface_key::OPTION1 + select));
*/
return CR_OK;
}
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;
auto type = in->type();
@ -312,6 +319,6 @@ command_result MiscMoveCommand(DFHack::color_ostream &stream, const MiscMovePara
default:
break;
}
*/
return CR_OK;
}

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

@ -233,6 +233,7 @@ command_result SetPauseState(color_ostream &stream, const SingleBool *in)
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 build_selector = df::global::ui_build_selector;
if (build_selector->building_type == -1)
@ -299,10 +300,12 @@ void CopyBuildMenu(DwarfControl::SidebarState * out)
send_selector->add_tiles(build_selector->tiles[x][y]);
}
}
*/
}
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;
out->set_mode((proto::enums::ui_sidebar_mode::ui_sidebar_mode)plotinfo->main.mode);
auto mode = plotinfo->main.mode;
@ -422,11 +425,13 @@ command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMe
default:
break;
}
*/
return CR_OK;
}
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;
if (in->has_mode())
{
@ -489,5 +494,6 @@ command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::Si
break;
}
}
*/
return CR_OK;
}

@ -271,7 +271,8 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
case df::enums::item_type::GLOVES:
break;
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;
case df::enums::item_type::BIN:
break;

@ -319,14 +319,14 @@ uint16_t fletcher16(uint8_t const *data, size_t bytes)
void ConvertDfColor(int16_t index, RemoteFortressReader::ColorDefinition * out)
{
if (!df::global::enabler)
if (!df::global::gps)
return;
auto enabler = df::global::enabler;
auto gps = df::global::gps;
out->set_red((int)(enabler->ccolor[index][0] * 255));
out->set_green((int)(enabler->ccolor[index][1] * 255));
out->set_blue((int)(enabler->ccolor[index][2] * 255));
out->set_red(gps->uccolor[index][0]);
out->set_green(gps->uccolor[index][1]);
out->set_blue(gps->uccolor[index][2]);
}
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++)
{
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::getCursorCoords(cx, cy, cz);
#if DF_VERSION_INT > 34011
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;
if (data && data->region_map)
{
z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
}
}
#endif
//FIXME: Get get this info from the new embark screen.
//#if DF_VERSION_INT > 34011
// 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;
// if (data && data->region_map)
// {
// z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
// }
// }
//#endif
auto dims = Gui::getDwarfmodeViewDims();
@ -1915,22 +1891,23 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in,
DFCoord GetMapCenter()
{
DFCoord output;
#if DF_VERSION_INT > 34011
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;
output.y = (location.region_pos.y * 16) + 8;
output.z = 100;
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;
}
}
else
#endif
//FIXME: Does this even still exist?
//#if DF_VERSION_INT > 34011
// 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;
// output.y = (location.region_pos.y * 16) + 8;
// output.z = 100;
// 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;
// }
// }
// else
//#endif
if (Maps::IsValid())
{
int x, y, z;