Fix remaining warnings in supported plugins

develop
Ben Lubar 2018-04-06 14:17:34 -05:00
parent a7dfacd1c5
commit 1dd6625270
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24
25 changed files with 215 additions and 188 deletions

@ -73,20 +73,11 @@ MACRO(DFHACK_PLUGIN)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS}) CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS}) CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
SET(PLUGIN_PROTOCPP) SET(PLUGIN_PROTOS)
FOREACH(pbuf ${PLUGIN_PROTOBUFS}) FOREACH(pbuf ${PLUGIN_PROTOBUFS})
SET(PLUGIN_SOURCES ${PLUGIN_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.pb.cc) LIST(APPEND PLUGIN_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.proto)
SET(PLUGIN_SOURCES ${PLUGIN_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.proto)
SET(PLUGIN_PROTOCPP ${PLUGIN_PROTOCPP} ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.pb.cc)
ENDFOREACH() ENDFOREACH()
IF(UNIX)
SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTOCPP} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()
# Tell CMake the source won't be available until build time.
SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTOCPP} PROPERTIES GENERATED 1)
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES}) ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
IDE_FOLDER(${PLUGIN_NAME} "Plugins") IDE_FOLDER(${PLUGIN_NAME} "Plugins")
@ -95,24 +86,63 @@ MACRO(DFHACK_PLUGIN)
# Make sure the source is generated before the executable builds. # Make sure the source is generated before the executable builds.
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto) ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto)
LIST(LENGTH PLUGIN_PROTOBUFS NUM_PROTO) LIST(LENGTH PLUGIN_PROTOS NUM_PROTO)
IF(NUM_PROTO) IF(NUM_PROTO)
STRING(REPLACE ".proto" ".pb.cc" PLUGIN_PROTO_SRCS "${PLUGIN_PROTOS}")
STRING(REPLACE ".proto" ".pb.h" PLUGIN_PROTO_HDRS "${PLUGIN_PROTOS}")
STRING(REPLACE "/proto/" "/proto/tmp/" PLUGIN_PROTO_TMP_FILES "${PLUGIN_PROTO_SRCS};${PLUGIN_PROTO_HDRS}")
SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTO_SRCS} ${PLUGIN_PROTO_HDRS} PROPERTIES GENERATED TRUE)
# Force a re-gen if any *.pb.* files are missing
# (only runs when cmake is run, but better than nothing)
FOREACH(file IN LISTS PLUGIN_PROTO_SRCS PLUGIN_PROTO_HDRS)
IF(NOT EXISTS ${file})
# MESSAGE("Resetting generate_proto_${PLUGIN_NAME} because '${file}' is missing")
FILE(REMOVE ${PLUGIN_PROTO_TMP_FILES})
BREAK()
ENDIF()
ENDFOREACH()
ADD_CUSTOM_COMMAND(
OUTPUT ${PLUGIN_PROTO_TMP_FILES}
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
${PLUGIN_PROTOS}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl
${PLUGIN_PROTO_TMP_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/proto/
COMMENT "Generating plugin ${PLUGIN_NAME} protobufs"
DEPENDS protoc-bin ${PLUGIN_PROTOS}
)
IF(UNIX)
SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()
ADD_CUSTOM_TARGET(generate_proto_${PLUGIN_NAME} DEPENDS ${PLUGIN_PROTO_TMP_FILES})
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto_${PLUGIN_NAME})
# Merge headers into sources
SET_SOURCE_FILES_PROPERTIES( ${PLUGIN_PROTO_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
LIST(APPEND PLUGIN_SOURCES ${PLUGIN_PROTO_HDRS})
LIST(APPEND PLUGIN_SOURCES ${PLUGIN_PROTO_SRCS})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack protobuf-lite dfhack-version ${PLUGIN_LINK_LIBRARIES}) TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack protobuf-lite dfhack-version ${PLUGIN_LINK_LIBRARIES})
IF(UNIX) IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "-include Export.h") SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} -include Export.h")
ELSE() ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"") SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} /FI\"Export.h\"")
ENDIF() ENDIF()
ELSE() ELSE()
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack dfhack-version ${PLUGIN_LINK_LIBRARIES}) TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack dfhack-version ${PLUGIN_LINK_LIBRARIES})
ENDIF() ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS}")
IF(UNIX) IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS_GCC}") SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} ${PLUGIN_COMPILE_FLAGS_GCC}")
ELSE() ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS_MSVC}") SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} ${PLUGIN_COMPILE_FLAGS_MSVC}")
ENDIF() ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS}")
IF(APPLE) IF(APPLE)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dylib PREFIX "") SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dylib PREFIX "")

@ -151,7 +151,7 @@ namespace embark_assist {
fields i = first_fields; fields i = first_fields;
while (true) { while (true) {
for (int k = 0; k < state->ui[static_cast<int8_t>(i)]->list.size(); k++) { for (size_t k = 0; k < state->ui[static_cast<int8_t>(i)]->list.size(); k++) {
if (state->ui[static_cast<int8_t>(i)]->current_value == state->ui[static_cast<int8_t>(i)]->list[k].key) { if (state->ui[static_cast<int8_t>(i)]->current_value == state->ui[static_cast<int8_t>(i)]->list[k].key) {
fprintf(outfile, "[%s:%s]\n", state->finder_list[static_cast<int8_t>(i)].text.c_str(), state->ui[static_cast<int8_t>(i)]->list[k].text.c_str()); fprintf(outfile, "[%s:%s]\n", state->finder_list[static_cast<int8_t>(i)].text.c_str(), state->ui[static_cast<int8_t>(i)]->list[k].text.c_str());
break; break;
@ -203,7 +203,7 @@ namespace embark_assist {
found = false; found = false;
for (int l = 0; l < state->ui[static_cast<int8_t>(i)]->list.size(); l++) { for (size_t l = 0; l < state->ui[static_cast<int8_t>(i)]->list.size(); l++) {
for (int m = k + 1; m < count; m++) { for (int m = k + 1; m < count; m++) {
if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] != line[m]) { if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] != line[m]) {
if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] == '\0' && if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] == '\0' &&
@ -259,7 +259,7 @@ namespace embark_assist {
found = false; found = false;
for (int l = 0; l < state->ui[static_cast<int8_t>(i)]->list.size(); l++) { for (size_t l = 0; l < state->ui[static_cast<int8_t>(i)]->list.size(); l++) {
for (int m = k + 1; m < count; m++) { for (int m = k + 1; m < count; m++) {
if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] != line[m]) { if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] != line[m]) {
if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] == '\0' && if (state->ui[static_cast<int8_t>(i)]->list[l].text.c_str()[m - (k + 1)] == '\0' &&
@ -1334,7 +1334,7 @@ namespace embark_assist {
} }
// Implement scrolling lists if they don't fit on the screen. // Implement scrolling lists if they don't fit on the screen.
if (state->ui[state->finder_list_focus]->list.size() > screen_size.y - 3) { if (int32_t(state->ui[state->finder_list_focus]->list.size()) > screen_size.y - 3) {
offset = (screen_size.y - 3) / 2; offset = (screen_size.y - 3) / 2;
if (state->ui[state->finder_list_focus]->current_index < offset) { if (state->ui[state->finder_list_focus]->current_index < offset) {
offset = 0; offset = 0;
@ -1343,7 +1343,7 @@ namespace embark_assist {
offset = state->ui[state->finder_list_focus]->current_index - offset; offset = state->ui[state->finder_list_focus]->current_index - offset;
} }
if (state->ui[state->finder_list_focus]->list.size() - offset < screen_size.y - 3) { if (int32_t(state->ui[state->finder_list_focus]->list.size() - offset) < screen_size.y - 3) {
offset = static_cast<uint16_t>(state->ui[state->finder_list_focus]->list.size()) - (screen_size.y - 3); offset = static_cast<uint16_t>(state->ui[state->finder_list_focus]->list.size()) - (screen_size.y - 3);
} }
} }

@ -179,7 +179,7 @@ namespace embark_assist {
} }
} }
for (auto i = 0; i < state->embark_info.size(); i++) { for (size_t i = 0; i < state->embark_info.size(); i++) {
embark_assist::screen::paintString(state->embark_info[i].pen, 1, i + 19, state->embark_info[i].text, false); embark_assist::screen::paintString(state->embark_info[i].pen, 1, i + 19, state->embark_info[i].text, false);
} }

@ -13,7 +13,7 @@ bool embark_assist::screen::paintString(const DFHack::Screen::Pen &pen, int x, i
return false; // Won't paint outside of the screen or on the frame return false; // Won't paint outside of the screen or on the frame
} }
if (x + text.length() - 1 < screen_size.x - 2) { if (x + int32_t(text.length()) - 1 < screen_size.x - 2) {
DFHack::Screen::paintString(pen, x, y, text, map); DFHack::Screen::paintString(pen, x, y, text, map);
} }
else if (x < screen_size.x - 2) { else if (x < screen_size.x - 2) {

@ -295,6 +295,8 @@ public:
df::building* bld = get_building_from_job(j); df::building* bld = get_building_from_job(j);
switch (bld->getType()) switch (bld->getType())
{ {
case df::building_type::NONE:
return df::unit_labor::NONE;
case df::building_type::Hive: case df::building_type::Hive:
return df::unit_labor::BEEKEEPING; return df::unit_labor::BEEKEEPING;
case df::building_type::Workshop: case df::building_type::Workshop:
@ -399,6 +401,8 @@ public:
switch (bld->getType()) switch (bld->getType())
{ {
case df::building_type::NONE:
return df::unit_labor::NONE;
case df::building_type::Hive: case df::building_type::Hive:
return df::unit_labor::BEEKEEPING; return df::unit_labor::BEEKEEPING;
case df::building_type::Workshop: case df::building_type::Workshop:

@ -525,8 +525,8 @@ struct dwarf_info_t
df::unit_labor using_labor; df::unit_labor using_labor;
dwarf_info_t(df::unit* dw) : dwarf(dw), clear_all(false), dwarf_info_t(df::unit* dw) : dwarf(dw), state(OTHER),
state(OTHER), high_skill(0), has_children(false), armed(false), using_labor(df::unit_labor::NONE) clear_all(false), high_skill(0), has_children(false), armed(false), using_labor(df::unit_labor::NONE)
{ {
for (int e = TOOL_NONE; e < TOOLS_MAX; e++) for (int e = TOOL_NONE; e < TOOLS_MAX; e++)
has_tool[e] = false; has_tool[e] = false;
@ -614,7 +614,7 @@ static void init_state()
{ {
string key = p->key(); string key = p->key();
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str());
if (labor >= 0 && labor <= labor_infos.size()) if (labor >= 0 && size_t(labor) <= labor_infos.size())
{ {
labor_infos[labor].config = *p; labor_infos[labor].config = *p;
labor_infos[labor].active_dwarfs = 0; labor_infos[labor].active_dwarfs = 0;
@ -622,7 +622,7 @@ static void init_state()
} }
// Add default labors for those not in save // Add default labors for those not in save
for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) { for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
if (labor_infos[i].config.isValid()) if (labor_infos[i].config.isValid())
continue; continue;
@ -966,12 +966,12 @@ private:
int worker = -1; int worker = -1;
int bld = -1; int bld = -1;
for (int r = 0; r < j->general_refs.size(); ++r) for (auto ref : j->general_refs)
{ {
if (j->general_refs[r]->getType() == df::general_ref_type::UNIT_WORKER) if (ref->getType() == df::general_ref_type::UNIT_WORKER)
worker = ((df::general_ref_unit_workerst *)(j->general_refs[r]))->unit_id; worker = ((df::general_ref_unit_workerst *)ref)->unit_id;
if (j->general_refs[r]->getType() == df::general_ref_type::BUILDING_HOLDER) if (ref->getType() == df::general_ref_type::BUILDING_HOLDER)
bld = ((df::general_ref_building_holderst *)(j->general_refs[r]))->building_id; bld = ((df::general_ref_building_holderst *)ref)->building_id;
} }
if (bld != -1) if (bld != -1)
@ -985,7 +985,7 @@ private:
b->getType() != df::building_type::TradeDepot) b->getType() != df::building_type::TradeDepot)
{ {
int fjid = -1; int fjid = -1;
for (int jn = 0; jn < b->jobs.size(); jn++) for (size_t jn = 0; jn < b->jobs.size(); jn++)
{ {
if (b->jobs[jn]->flags.bits.suspend) if (b->jobs[jn]->flags.bits.suspend)
continue; continue;
@ -1062,7 +1062,7 @@ private:
plant_count = 0; plant_count = 0;
detail_count = 0; detail_count = 0;
for (int i = 0; i < world->map.map_blocks.size(); ++i) for (size_t i = 0; i < world->map.map_blocks.size(); ++i)
{ {
df::map_block* bl = world->map.map_blocks[i]; df::map_block* bl = world->map.map_blocks[i];
@ -1187,7 +1187,7 @@ private:
dwarf_info_t* dwarf = add_dwarf(cre); dwarf_info_t* dwarf = add_dwarf(cre);
df::historical_figure* hf = df::historical_figure::find(dwarf->dwarf->hist_figure_id); df::historical_figure* hf = df::historical_figure::find(dwarf->dwarf->hist_figure_id);
for (int i = 0; i < hf->entity_links.size(); i++) for (size_t i = 0; i < hf->entity_links.size(); i++)
{ {
df::histfig_entity_link* hfelink = hf->entity_links.at(i); df::histfig_entity_link* hfelink = hf->entity_links.at(i);
if (hfelink->getType() == df::histfig_entity_link_type::POSITION) if (hfelink->getType() == df::histfig_entity_link_type::POSITION)
@ -1213,7 +1213,7 @@ private:
// identify dwarfs who are needed for meetings and mark them for exclusion // identify dwarfs who are needed for meetings and mark them for exclusion
for (int i = 0; i < ui->activities.size(); ++i) for (size_t i = 0; i < ui->activities.size(); ++i)
{ {
df::activity_info *act = ui->activities[i]; df::activity_info *act = ui->activities[i];
if (!act) continue; if (!act) continue;
@ -1259,7 +1259,7 @@ private:
// check if dwarf has an axe, pick, or crossbow // check if dwarf has an axe, pick, or crossbow
for (int j = 0; j < dwarf->dwarf->inventory.size(); j++) for (size_t j = 0; j < dwarf->dwarf->inventory.size(); j++)
{ {
df::unit_inventory_item* ui = dwarf->dwarf->inventory[j]; df::unit_inventory_item* ui = dwarf->dwarf->inventory[j];
if (ui->mode == df::unit_inventory_item::Weapon && ui->item->isWeapon()) if (ui->mode == df::unit_inventory_item::Weapon && ui->item->isWeapon())
@ -1335,7 +1335,7 @@ private:
else else
{ {
df::job_type job = dwarf->dwarf->job.current_job->job_type; df::job_type job = dwarf->dwarf->job.current_job->job_type;
if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
state = dwarf_states[job]; state = dwarf_states[job];
else else
{ {
@ -2258,7 +2258,7 @@ command_result labormanager(color_ostream &out, std::vector <std::string> & para
return CR_FAILURE; return CR_FAILURE;
} }
for (int i = 0; i < labor_infos.size(); i++) for (size_t i = 0; i < labor_infos.size(); i++)
{ {
reset_labor((df::unit_labor) i); reset_labor((df::unit_labor) i);
} }

@ -15,15 +15,16 @@ SET(PROJECT_HDRS
) )
#proto files to include. #proto files to include.
SET(PROJECT_PROTO SET(PROJECT_PROTO
../../proto/RemoteFortressReader ${CMAKE_CURRENT_SOURCE_DIR}/../proto/RemoteFortressReader.pb.cc
../../proto/AdventureControl ${CMAKE_CURRENT_SOURCE_DIR}/../proto/AdventureControl.pb.cc
../../proto/ItemdefInstrument ${CMAKE_CURRENT_SOURCE_DIR}/../proto/ItemdefInstrument.pb.cc
) )
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_PROTO} PROPERTIES GENERATED TRUE)
# mash them together (headers are marked as headers and nothing will try to compile them) # mash them together (headers are marked as headers and nothing will try to compile them)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS};${PROJECT_PROTO})
#linux #linux
IF(UNIX) IF(UNIX)
@ -41,4 +42,4 @@ ELSE(UNIX)
) )
ENDIF(UNIX) ENDIF(UNIX)
# this makes sure all the stuff is put in proper places and linked to dfhack # this makes sure all the stuff is put in proper places and linked to dfhack
DFHACK_PLUGIN(RemoteFortressReader ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS} PROTOBUFS ${PROJECT_PROTO} ) DFHACK_PLUGIN(RemoteFortressReader ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS} COMPILE_FLAGS_MSVC "/FI\"Export.h\"" COMPILE_FLAGS_GCC "-include Export.h -Wno-misleading-indentation" )

@ -104,7 +104,7 @@ DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const D
if (st == furnace_type::Custom) if (st == furnace_type::Custom)
{ {
for (int i = 0; i < df::global::world->raws.buildings.furnaces.size(); i++) for (size_t i = 0; i < df::global::world->raws.buildings.furnaces.size(); i++)
{ {
auto cust = df::global::world->raws.buildings.furnaces[i]; auto cust = df::global::world->raws.buildings.furnaces[i];
@ -152,7 +152,7 @@ DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const D
if (st == workshop_type::Custom) if (st == workshop_type::Custom)
{ {
for (int i = 0; i < df::global::world->raws.buildings.workshops.size(); i++) for (size_t i = 0; i < df::global::world->raws.buildings.workshops.size(); i++)
{ {
auto cust = df::global::world->raws.buildings.workshops[i]; auto cust = df::global::world->raws.buildings.workshops[i];

@ -61,7 +61,7 @@ void CopyImage(const df::art_image * image, ArtImage * netImage)
auto id = netImage->mutable_id(); auto id = netImage->mutable_id();
id->set_mat_type(image->id); id->set_mat_type(image->id);
id->set_mat_index(image->subid); id->set_mat_index(image->subid);
for (int i = 0; i < image->elements.size(); i++) for (size_t i = 0; i < image->elements.size(); i++)
{ {
auto element = image->elements[i]; auto element = image->elements[i];
auto netElement = netImage->add_elements(); auto netElement = netImage->add_elements();
@ -121,7 +121,7 @@ void CopyImage(const df::art_image * image, ArtImage * netImage)
break; break;
} }
} }
for (int i = 0; i < image->properties.size(); i++) for (size_t i = 0; i < image->properties.size(); i++)
{ {
auto dfProperty = image->properties[i]; auto dfProperty = image->properties[i];
auto netProperty = netImage->add_properties(); auto netProperty = netImage->add_properties();
@ -236,7 +236,7 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
} }
else else
{ {
for (int i = 0; i < world->art_image_chunks.size(); i++) for (size_t i = 0; i < world->art_image_chunks.size(); i++)
{ {
if (world->art_image_chunks[i]->id == statue->image.id) if (world->art_image_chunks[i]->id == statue->image.id)
chunk = world->art_image_chunks[i]; chunk = world->art_image_chunks[i];
@ -433,7 +433,7 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
VIRTUAL_CAST_VAR(constructed_item, df::item_constructed, DfItem); VIRTUAL_CAST_VAR(constructed_item, df::item_constructed, DfItem);
if (constructed_item) if (constructed_item)
{ {
for (int i = 0; i < constructed_item->improvements.size(); i++) for (size_t i = 0; i < constructed_item->improvements.size(); i++)
{ {
auto improvement = constructed_item->improvements[i]; auto improvement = constructed_item->improvements[i];
@ -528,7 +528,7 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
case df::enums::item_type::GEM: case df::enums::item_type::GEM:
case df::enums::item_type::SMALLGEM: case df::enums::item_type::SMALLGEM:
{ {
for (int i = 0; i < world->raws.descriptors.shapes.size(); i++) for (size_t i = 0; i < world->raws.descriptors.shapes.size(); i++)
{ {
auto shape = world->raws.descriptors.shapes[i]; auto shape = world->raws.descriptors.shapes[i];
if (shape->gems_use.whole == 0) if (shape->gems_use.whole == 0)
@ -542,7 +542,7 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
} }
case df::enums::item_type::PLANT: case df::enums::item_type::PLANT:
{ {
for (int i = 0; i < world->raws.plants.all.size(); i++) for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{ {
auto plantRaw = world->raws.plants.all[i]; auto plantRaw = world->raws.plants.all[i];
mat_def = out->add_material_list(); mat_def = out->add_material_list();
@ -574,7 +574,10 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_type((int)it);
mat_def->mutable_mat_pair()->set_mat_index(1); mat_def->mutable_mat_pair()->set_mat_index(1);
mat_def->set_id("THREAD/WEB"); mat_def->set_id("THREAD/WEB");
break;
} }
default:
break;
} }
int subtypes = Items::getSubtypeCount(it); int subtypes = Items::getSubtypeCount(it);
if (subtypes >= 0) if (subtypes >= 0)
@ -606,7 +609,7 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
send_instrument->set_size(instrument->size); send_instrument->set_size(instrument->size);
send_instrument->set_value(instrument->value); send_instrument->set_value(instrument->value);
send_instrument->set_material_size(instrument->material_size); send_instrument->set_material_size(instrument->material_size);
for (int j = 0; j < instrument->pieces.size(); j++) for (size_t j = 0; j < instrument->pieces.size(); j++)
{ {
auto piece = send_instrument->add_pieces(); auto piece = send_instrument->add_pieces();
piece->set_type(instrument->pieces[j]->type); piece->set_type(instrument->pieces[j]->type);
@ -616,39 +619,39 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
} }
send_instrument->set_pitch_range_min(instrument->pitch_range_min); send_instrument->set_pitch_range_min(instrument->pitch_range_min);
send_instrument->set_pitch_range_max(instrument->pitch_range_max); send_instrument->set_pitch_range_max(instrument->pitch_range_max);
for (int j = 0; j < instrument->sound_production.size(); j++) for (size_t j = 0; j < instrument->sound_production.size(); j++)
{ {
send_instrument->add_sound_production((SoundProductionType)instrument->sound_production[j]); send_instrument->add_sound_production((SoundProductionType)instrument->sound_production[j]);
} }
for (int j = 0; j < instrument->sound_production_parm1.size(); j++) for (size_t j = 0; j < instrument->sound_production_parm1.size(); j++)
{ {
send_instrument->add_sound_production_parm1(*(instrument->sound_production_parm1[j])); send_instrument->add_sound_production_parm1(*(instrument->sound_production_parm1[j]));
} }
for (int j = 0; j < instrument->sound_production_parm2.size(); j++) for (size_t j = 0; j < instrument->sound_production_parm2.size(); j++)
{ {
send_instrument->add_sound_production_parm2(*(instrument->sound_production_parm2[j])); send_instrument->add_sound_production_parm2(*(instrument->sound_production_parm2[j]));
} }
for (int j = 0; j < instrument->pitch_choice.size(); j++) for (size_t j = 0; j < instrument->pitch_choice.size(); j++)
{ {
send_instrument->add_pitch_choice((PitchChoiceType)instrument->pitch_choice[j]); send_instrument->add_pitch_choice((PitchChoiceType)instrument->pitch_choice[j]);
} }
for (int j = 0; j < instrument->pitch_choice_parm1.size(); j++) for (size_t j = 0; j < instrument->pitch_choice_parm1.size(); j++)
{ {
send_instrument->add_pitch_choice_parm1(*(instrument->pitch_choice_parm1[j])); send_instrument->add_pitch_choice_parm1(*(instrument->pitch_choice_parm1[j]));
} }
for (int j = 0; j < instrument->pitch_choice_parm2.size(); j++) for (size_t j = 0; j < instrument->pitch_choice_parm2.size(); j++)
{ {
send_instrument->add_pitch_choice_parm2(*(instrument->pitch_choice_parm2[j])); send_instrument->add_pitch_choice_parm2(*(instrument->pitch_choice_parm2[j]));
} }
for (int j = 0; j < instrument->tuning.size(); j++) for (size_t j = 0; j < instrument->tuning.size(); j++)
{ {
send_instrument->add_tuning((TuningType)instrument->tuning[j]); send_instrument->add_tuning((TuningType)instrument->tuning[j]);
} }
for (int j = 0; j < instrument->tuning_parm.size(); j++) for (size_t j = 0; j < instrument->tuning_parm.size(); j++)
{ {
send_instrument->add_tuning_parm(*(instrument->tuning_parm[j])); send_instrument->add_tuning_parm(*(instrument->tuning_parm[j]));
} }
for (int j = 0; j < instrument->registers.size(); j++) for (size_t j = 0; j < instrument->registers.size(); j++)
{ {
auto reg = send_instrument->add_registers(); auto reg = send_instrument->add_registers();
reg->set_pitch_range_min(instrument->registers[j]->pitch_range_min); reg->set_pitch_range_min(instrument->registers[j]->pitch_range_min);

@ -1 +0,0 @@
placeholder to fix protobufs in plugins/remotefortressreader/CMakeLists.txt

@ -216,13 +216,13 @@ command_result dump_bp_mods(color_ostream &out, vector <string> & parameters)
output << "Race Index;Race;Caste;Bodypart Token;Bodypart Name;Tissue Layer;Modifier Type;Range\n"; output << "Race Index;Race;Caste;Bodypart Token;Bodypart Name;Tissue Layer;Modifier Type;Range\n";
for (int creatureIndex = 0; creatureIndex < world->raws.creatures.all.size(); creatureIndex++) for (size_t creatureIndex = 0; creatureIndex < world->raws.creatures.all.size(); creatureIndex++)
{ {
auto creatureRaw = world->raws.creatures.all[creatureIndex]; auto creatureRaw = world->raws.creatures.all[creatureIndex];
for (int casteIndex = 0; casteIndex < creatureRaw->caste.size(); casteIndex++) for (size_t casteIndex = 0; casteIndex < creatureRaw->caste.size(); casteIndex++)
{ {
df::caste_raw *casteRaw = creatureRaw->caste[casteIndex]; df::caste_raw *casteRaw = creatureRaw->caste[casteIndex];
for (int partIndex = 0; partIndex < casteRaw->bp_appearance.part_idx.size(); partIndex++) for (size_t partIndex = 0; partIndex < casteRaw->bp_appearance.part_idx.size(); partIndex++)
{ {
output << creatureIndex << ";"; output << creatureIndex << ";";
output << creatureRaw->creature_id << ";"; output << creatureRaw->creature_id << ";";
@ -665,7 +665,7 @@ RemoteFortressReader::TiletypeVariant TranslateVariant(df::tiletype_variant vari
static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in) static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in)
{ {
clock_t start = clock(); clock_t start = clock();
for (int i = 0; i < world->map.map_blocks.size(); i++) for (size_t i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block * block = world->map.map_blocks[i]; df::map_block * block = world->map.map_blocks[i];
fletcher16((uint8_t*)(block->tiletype), 16 * 16 * sizeof(df::enums::tiletype::tiletype)); fletcher16((uint8_t*)(block->tiletype), 16 * 16 * sizeof(df::enums::tiletype::tiletype));
@ -765,13 +765,13 @@ bool IsspatterChanged(DFCoord pos)
uint16_t hash = 0; uint16_t hash = 0;
for (int i = 0; i < materials.size(); i++) for (size_t i = 0; i < materials.size(); i++)
{ {
auto mat = materials[i]; auto mat = materials[i];
hash ^= fletcher16((uint8_t*)mat, sizeof(df::block_square_event_material_spatterst)); hash ^= fletcher16((uint8_t*)mat, sizeof(df::block_square_event_material_spatterst));
} }
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
for (int i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
auto item = items[i]; auto item = items[i];
hash ^= fletcher16((uint8_t*)item, sizeof(df::block_square_event_item_spatterst)); hash ^= fletcher16((uint8_t*)item, sizeof(df::block_square_event_item_spatterst));
@ -806,7 +806,7 @@ bool isItemChanged(int i)
bool areItemsChanged(vector<int> * items) bool areItemsChanged(vector<int> * items)
{ {
bool result = false; bool result = false;
for (int i = 0; i < items->size(); i++) for (size_t i = 0; i < items->size(); i++)
{ {
if (isItemChanged(items->at(i))) if (isItemChanged(items->at(i)))
result = true; result = true;
@ -862,7 +862,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
df::world_raws *raws = &world->raws; df::world_raws *raws = &world->raws;
df::world_history *history = &world->history; df::world_history *history = &world->history;
MaterialInfo mat; MaterialInfo mat;
for (int i = 0; i < raws->inorganics.size(); i++) for (size_t i = 0; i < raws->inorganics.size(); i++)
{ {
mat.decode(0, i); mat.decode(0, i);
MaterialDefinition *mat_def = out->add_material_list(); MaterialDefinition *mat_def = out->add_material_list();
@ -870,7 +870,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i); mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken()); mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature; mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)] < raws->descriptors.colors.size()) if (size_t(raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)]) < raws->descriptors.colors.size())
{ {
ConvertDFColorDescriptor(raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)], mat_def->mutable_state_color()); ConvertDFColorDescriptor(raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)], mat_def->mutable_state_color());
} }
@ -888,16 +888,16 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(j); mat_def->mutable_mat_pair()->set_mat_index(j);
mat_def->set_id(mat.getToken()); mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature; mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])] < raws->descriptors.colors.size()) if (size_t(raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])]) < raws->descriptors.colors.size())
{ {
ConvertDFColorDescriptor(raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])], mat_def->mutable_state_color()); ConvertDFColorDescriptor(raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])], mat_def->mutable_state_color());
} }
} }
} }
for (int i = 0; i < raws->creatures.all.size(); i++) for (size_t i = 0; i < raws->creatures.all.size(); i++)
{ {
df::creature_raw * creature = raws->creatures.all[i]; df::creature_raw * creature = raws->creatures.all[i];
for (int j = 0; j < creature->material.size(); j++) for (size_t j = 0; j < creature->material.size(); j++)
{ {
mat.decode(j + MaterialInfo::CREATURE_BASE, i); mat.decode(j + MaterialInfo::CREATURE_BASE, i);
MaterialDefinition *mat_def = out->add_material_list(); MaterialDefinition *mat_def = out->add_material_list();
@ -905,13 +905,13 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i); mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken()); mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature; 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()) if (size_t(creature->material[j]->state_color[GetState(creature->material[j])]) < raws->descriptors.colors.size())
{ {
ConvertDFColorDescriptor(creature->material[j]->state_color[GetState(creature->material[j])], mat_def->mutable_state_color()); ConvertDFColorDescriptor(creature->material[j]->state_color[GetState(creature->material[j])], mat_def->mutable_state_color());
} }
} }
} }
//for (int i = 0; i < history->figures.size(); i++) //for (size_t i = 0; i < history->figures.size(); i++)
//{ //{
// df::historical_figure * figure = history->figures[i]; // df::historical_figure * figure = history->figures[i];
// if (figure->race < 0) // if (figure->race < 0)
@ -936,10 +936,10 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
// } // }
// } // }
//} //}
for (int 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];
for (int j = 0; j < plant->material.size(); j++) for (size_t j = 0; j < plant->material.size(); j++)
{ {
mat.decode(j + 419, i); mat.decode(j + 419, i);
MaterialDefinition *mat_def = out->add_material_list(); MaterialDefinition *mat_def = out->add_material_list();
@ -947,7 +947,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i); mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken()); mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature; mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (plant->material[j]->state_color[GetState(plant->material[j])] < raws->descriptors.colors.size()) if (size_t(plant->material[j]->state_color[GetState(plant->material[j])]) < raws->descriptors.colors.size())
{ {
ConvertDFColorDescriptor(plant->material[j]->state_color[GetState(plant->material[j])], mat_def->mutable_state_color()); ConvertDFColorDescriptor(plant->material[j]->state_color[GetState(plant->material[j])], mat_def->mutable_state_color());
} }
@ -970,7 +970,7 @@ static command_result GetGrowthList(color_ostream &stream, const EmptyMessage *i
return CR_OK;//'. return CR_OK;//'.
for (int i = 0; i < raws->plants.all.size(); i++) for (size_t i = 0; i < raws->plants.all.size(); i++)
{ {
df::plant_raw * pp = raws->plants.all[i]; df::plant_raw * pp = raws->plants.all[i];
if (!pp) if (!pp)
@ -981,7 +981,7 @@ static command_result GetGrowthList(color_ostream &stream, const EmptyMessage *i
basePlant->mutable_mat_pair()->set_mat_type(-1); basePlant->mutable_mat_pair()->set_mat_type(-1);
basePlant->mutable_mat_pair()->set_mat_index(i); basePlant->mutable_mat_pair()->set_mat_index(i);
#if DF_VERSION_INT > 40001 #if DF_VERSION_INT > 40001
for (int g = 0; g < pp->growths.size(); g++) for (size_t g = 0; g < pp->growths.size(); g++)
{ {
df::plant_growth* growth = pp->growths[g]; df::plant_growth* growth = pp->growths[g];
if (!growth) if (!growth)
@ -1023,7 +1023,7 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
df::map_block_column * column = df::global::world->map.column_index[(DfBlock->map_pos.x / 48) * 3][(DfBlock->map_pos.y / 48) * 3]; df::map_block_column * column = df::global::world->map.column_index[(DfBlock->map_pos.x / 48) * 3][(DfBlock->map_pos.y / 48) * 3];
for (int i = 0; i < column->plants.size(); i++) for (size_t i = 0; i < column->plants.size(); i++)
{ {
df::plant* plant = column->plants[i]; df::plant* plant = column->plants[i];
if (plant->tree_info == NULL) if (plant->tree_info == NULL)
@ -1179,7 +1179,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
} }
} }
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
for (int i = 0; i < world->jobs.postings.size(); i++) for (size_t i = 0; i < world->jobs.postings.size(); i++)
{ {
auto job = world->jobs.postings[i]->job; auto job = world->jobs.postings[i]->job;
if (job == nullptr) if (job == nullptr)
@ -1260,7 +1260,7 @@ void CopyProjectiles(RemoteFortressReader::MapBlock * NetBlock)
NetItem->set_velocity_z(diff.z / max_dist); NetItem->set_velocity_z(diff.z / max_dist);
} }
} }
for (int i = 0; i < world->vehicles.active.size(); i++) for (size_t i = 0; i < world->vehicles.active.size(); i++)
{ {
bool isProj = false; bool isProj = false;
auto vehicle = world->vehicles.active[i]; auto vehicle = world->vehicles.active[i];
@ -1296,7 +1296,7 @@ void CopyProjectiles(RemoteFortressReader::MapBlock * NetBlock)
void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC) void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC)
{ {
for (int i = 0; i < df::global::world->buildings.all.size(); i++) for (size_t i = 0; i < df::global::world->buildings.all.size(); i++)
{ {
df::building * bld = df::global::world->buildings.all[i]; df::building * bld = df::global::world->buildings.all[i];
if (bld->x1 >= max.x || bld->y1 >= max.y || bld->x2 < min.x || bld->y2 < min.y) if (bld->x1 >= max.x || bld->y1 >= max.y || bld->x2 < min.x || bld->y2 < min.y)
@ -1327,7 +1327,7 @@ void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * Ne
df::building_actual* actualBuilding = virtual_cast<df::building_actual>(bld); df::building_actual* actualBuilding = virtual_cast<df::building_actual>(bld);
if (actualBuilding) if (actualBuilding)
{ {
for (int i = 0; i < actualBuilding->contained_items.size(); i++) for (size_t i = 0; i < actualBuilding->contained_items.size(); i++)
{ {
auto buildingItem = out_bld->add_items(); auto buildingItem = out_bld->add_items();
buildingItem->set_mode(actualBuilding->contained_items[i]->use_mode); buildingItem->set_mode(actualBuilding->contained_items[i]->use_mode);
@ -1356,7 +1356,7 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
for (int xx = 0; xx < 16; xx++) for (int xx = 0; xx < 16; xx++)
{ {
auto send_pile = NetBlock->add_spatterpile(); auto send_pile = NetBlock->add_spatterpile();
for (int i = 0; i < materials.size(); i++) for (size_t i = 0; i < materials.size(); i++)
{ {
auto mat = materials[i]; auto mat = materials[i];
if (mat->amount[xx][yy] == 0) if (mat->amount[xx][yy] == 0)
@ -1367,7 +1367,7 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
send_spat->set_amount(mat->amount[xx][yy]); send_spat->set_amount(mat->amount[xx][yy]);
} }
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
for (int i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
auto item = items[i]; auto item = items[i];
if (item->amount[xx][yy] == 0) if (item->amount[xx][yy] == 0)
@ -1380,7 +1380,7 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
send_item->set_mat_index(item->item_subtype); send_item->set_mat_index(item->item_subtype);
} }
int grassPercent = 0; int grassPercent = 0;
for (int i = 0; i < grasses.size(); i++) for (size_t i = 0; i < grasses.size(); i++)
{ {
auto grass = grasses[i]; auto grass = grasses[i];
if (grass->amount[xx][yy] > grassPercent) if (grass->amount[xx][yy] > grassPercent)
@ -1396,7 +1396,7 @@ void CopyItems(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
NetBlock->set_map_x(DfBlock->map_pos.x); NetBlock->set_map_x(DfBlock->map_pos.x);
NetBlock->set_map_y(DfBlock->map_pos.y); NetBlock->set_map_y(DfBlock->map_pos.y);
NetBlock->set_map_z(DfBlock->map_pos.z); NetBlock->set_map_z(DfBlock->map_pos.z);
for (int i = 0; i < DfBlock->items.size(); i++) for (size_t i = 0; i < DfBlock->items.size(); i++)
{ {
int id = DfBlock->items[i]; int id = DfBlock->items[i];
@ -1441,7 +1441,7 @@ void CopyFlows(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
NetBlock->set_map_x(DfBlock->map_pos.x); NetBlock->set_map_x(DfBlock->map_pos.x);
NetBlock->set_map_y(DfBlock->map_pos.y); NetBlock->set_map_y(DfBlock->map_pos.y);
NetBlock->set_map_z(DfBlock->map_pos.z); NetBlock->set_map_z(DfBlock->map_pos.z);
for (int i = 0; i < DfBlock->flows.size(); i++) for (size_t i = 0; i < DfBlock->flows.size(); i++)
{ {
CopyFlow(DfBlock->flows[i], NetBlock->add_flows(), i); CopyFlow(DfBlock->flows[i], NetBlock->add_flows(), i);
} }
@ -1568,7 +1568,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
} }
} }
for (int i = 0; i < world->engravings.size(); i++) for (size_t i = 0; i < world->engravings.size(); i++)
{ {
auto engraving = world->engravings[i]; auto engraving = world->engravings[i];
if (engraving->pos.x < (min_x * 16) || engraving->pos.x >(max_x * 16)) if (engraving->pos.x < (min_x * 16) || engraving->pos.x >(max_x * 16))
@ -1588,7 +1588,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
} }
else else
{ {
for (int i = 0; i < world->art_image_chunks.size(); i++) for (size_t i = 0; i < world->art_image_chunks.size(); i++)
{ {
if (world->art_image_chunks[i]->id == engraving->art_id) if (world->art_image_chunks[i]->id == engraving->art_id)
chunk = world->art_image_chunks[i]; chunk = world->art_image_chunks[i];
@ -1615,7 +1615,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
netEngraving->set_southwest(engraving->flags.bits.southwest); netEngraving->set_southwest(engraving->flags.bits.southwest);
netEngraving->set_southeast(engraving->flags.bits.southeast); netEngraving->set_southeast(engraving->flags.bits.southeast);
} }
for (int i = 0; i < world->ocean_waves.size(); i++) for (size_t i = 0; i < world->ocean_waves.size(); i++)
{ {
auto wave = world->ocean_waves[i]; auto wave = world->ocean_waves[i];
auto netWave = out->add_ocean_waves(); auto netWave = out->add_ocean_waves();
@ -1665,7 +1665,7 @@ static command_result GetPlantList(color_ostream &stream, const BlockRequest *in
if (xx < 0 || yy < 0 || xx >= world->map.x_count_block || yy >= world->map.y_count_block) if (xx < 0 || yy < 0 || xx >= world->map.x_count_block || yy >= world->map.y_count_block)
continue; continue;
df::map_block_column * column = world->map.column_index[xx][yy]; df::map_block_column * column = world->map.column_index[xx][yy];
for (int i = 0; i < column->plants.size(); i++) for (size_t i = 0; i < column->plants.size(); i++)
{ {
df::plant * plant = column->plants[i]; df::plant * plant = column->plants[i];
if (!plant->tree_info) if (!plant->tree_info)
@ -1705,7 +1705,7 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in,
static command_result GetUnitListInside(color_ostream &stream, const BlockRequest *in, UnitList *out) static command_result GetUnitListInside(color_ostream &stream, const BlockRequest *in, UnitList *out)
{ {
auto world = df::global::world; auto world = df::global::world;
for (int i = 0; i < world->units.all.size(); i++) for (size_t i = 0; i < world->units.all.size(); i++)
{ {
df::unit * unit = world->units.all[i]; df::unit * unit = world->units.all[i];
auto send_unit = out->add_creature_list(); auto send_unit = out->add_creature_list();
@ -1742,11 +1742,11 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
} }
auto appearance = send_unit->mutable_appearance(); auto appearance = send_unit->mutable_appearance();
for (int j = 0; j < unit->appearance.body_modifiers.size(); j++) for (size_t j = 0; j < unit->appearance.body_modifiers.size(); j++)
appearance->add_body_modifiers(unit->appearance.body_modifiers[j]); appearance->add_body_modifiers(unit->appearance.body_modifiers[j]);
for (int j = 0; j < unit->appearance.bp_modifiers.size(); j++) for (size_t j = 0; j < unit->appearance.bp_modifiers.size(); j++)
appearance->add_bp_modifiers(unit->appearance.bp_modifiers[j]); appearance->add_bp_modifiers(unit->appearance.bp_modifiers[j]);
for (int j = 0; j < unit->appearance.colors.size(); j++) for (size_t j = 0; j < unit->appearance.colors.size(); j++)
appearance->add_colors(unit->appearance.colors[j]); appearance->add_colors(unit->appearance.colors[j]);
appearance->set_size_modifier(unit->appearance.size_modifier); appearance->set_size_modifier(unit->appearance.size_modifier);
@ -1756,7 +1756,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
if (Units::getNoblePositions(&pvec, unit)) if (Units::getNoblePositions(&pvec, unit))
{ {
for (int j = 0; j < pvec.size(); j++) for (size_t j = 0; j < pvec.size(); j++)
{ {
auto noble_positon = pvec[j]; auto noble_positon = pvec[j];
send_unit->add_noble_positions(noble_positon.position->code); send_unit->add_noble_positions(noble_positon.position->code);
@ -1768,7 +1768,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
auto creatureRaw = world->raws.creatures.all[unit->race]; auto creatureRaw = world->raws.creatures.all[unit->race];
auto casteRaw = creatureRaw->caste[unit->caste]; auto casteRaw = creatureRaw->caste[unit->caste];
for (int j = 0; j < unit->appearance.tissue_style_type.size(); j++) for (size_t j = 0; j < unit->appearance.tissue_style_type.size(); j++)
{ {
auto type = unit->appearance.tissue_style_type[j]; auto type = unit->appearance.tissue_style_type[j];
if (type < 0) if (type < 0)
@ -1801,7 +1801,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
} }
} }
for (int j = 0; j < unit->inventory.size(); j++) for (size_t j = 0; j < unit->inventory.size(); j++)
{ {
auto inventory_item = unit->inventory[j]; auto inventory_item = unit->inventory[j];
auto sent_item = send_unit->add_inventory(); auto sent_item = send_unit->add_inventory();
@ -1911,7 +1911,7 @@ DFCoord GetMapCenter()
} }
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
else else
for (int i = 0; i < df::global::world->armies.all.size(); i++) for (size_t i = 0; i < df::global::world->armies.all.size(); i++)
{ {
df::army * thisArmy = df::global::world->armies.all[i]; df::army * thisArmy = df::global::world->armies.all[i];
if (thisArmy->flags.is_set(df::enums::army_flags::player)) if (thisArmy->flags.is_set(df::enums::army_flags::player))
@ -2055,7 +2055,7 @@ static void SetRegionTile(RegionTile * out, df::region_map_entry * e1)
out->set_water_elevation(99); out->set_water_elevation(99);
int topLayer = 0; int topLayer = 0;
for (int i = 0; i < geoBiome->layers.size(); i++) for (size_t i = 0; i < geoBiome->layers.size(); i++)
{ {
auto layer = geoBiome->layers[i]; auto layer = geoBiome->layers[i];
if (layer->top_height == 0) if (layer->top_height == 0)
@ -2075,7 +2075,7 @@ static void SetRegionTile(RegionTile * out, df::region_map_entry * e1)
surfaceMat->set_mat_index(topLayer); surfaceMat->set_mat_index(topLayer);
surfaceMat->set_mat_type(0); surfaceMat->set_mat_type(0);
for (int i = 0; i < region->population.size(); i++) for (size_t i = 0; i < region->population.size(); i++)
{ {
auto pop = region->population[i]; auto pop = region->population[i];
if (pop->type == world_population_type::Grass) if (pop->type == world_population_type::Grass)
@ -2285,7 +2285,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
df::world_region_details * east = NULL; df::world_region_details * east = NULL;
df::world_region_details * southEast = NULL; df::world_region_details * southEast = NULL;
for (int i = 0; i < worldData->region_details.size(); i++) for (size_t i = 0; i < worldData->region_details.size(); i++)
{ {
auto region = worldData->region_details[i]; auto region = worldData->region_details[i];
if (region->pos.x == pos_x + 1 && region->pos.y == pos_y + 1) if (region->pos.x == pos_x + 1 && region->pos.y == pos_y + 1)
@ -2372,7 +2372,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
df::world_region_details * east = NULL; df::world_region_details * east = NULL;
df::world_region_details * southEast = NULL; df::world_region_details * southEast = NULL;
for (int i = 0; i < worldData->region_details.size(); i++) for (size_t i = 0; i < worldData->region_details.size(); i++)
{ {
auto region = worldData->region_details[i]; auto region = worldData->region_details[i];
if (region->pos.x == pos_x + 1 && region->pos.y == pos_y + 1) if (region->pos.x == pos_x + 1 && region->pos.y == pos_y + 1)
@ -2481,7 +2481,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
auto regionMap = worldData->region_map[pos_x][pos_y]; auto regionMap = worldData->region_map[pos_x][pos_y];
for (int i = 0; i < worldData->sites.size(); i++) for (size_t i = 0; i < worldData->sites.size(); i++)
{ {
df::world_site* site = worldData->sites[i]; df::world_site* site = worldData->sites[i];
if (!site) if (!site)
@ -2509,7 +2509,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
if (region_x < 0 || region_y < 0 || region_x >= 16 || region_y >= 16) if (region_x < 0 || region_y < 0 || region_x >= 16 || region_y >= 16)
continue; continue;
for (int j = 0; j < realization->building_map[site_x][site_y].buildings.size(); j++) for (size_t j = 0; j < realization->building_map[site_x][site_y].buildings.size(); j++)
{ {
auto in_building = realization->building_map[site_x][site_y].buildings[j]; auto in_building = realization->building_map[site_x][site_y].buildings[j];
auto out_building = outputTiles[region_x][region_y]->add_buildings(); auto out_building = outputTiles[region_x][region_y]->add_buildings();
@ -2564,7 +2564,7 @@ static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *i
return CR_FAILURE; return CR_FAILURE;
} }
df::world_data * data = df::global::world->world_data; df::world_data * data = df::global::world->world_data;
for (int i = 0; i < data->region_details.size(); i++) for (size_t i = 0; i < data->region_details.size(); i++)
{ {
df::world_region_details * region = data->region_details[i]; df::world_region_details * region = data->region_details[i];
if (!region) if (!region)
@ -2582,7 +2582,7 @@ static command_result GetRegionMapsNew(color_ostream &stream, const EmptyMessage
return CR_FAILURE; return CR_FAILURE;
} }
df::world_data * data = df::global::world->world_data; df::world_data * data = df::global::world->world_data;
for (int i = 0; i < data->region_details.size(); i++) for (size_t i = 0; i < data->region_details.size(); i++)
{ {
df::world_region_details * region = data->region_details[i]; df::world_region_details * region = data->region_details[i];
if (!region) if (!region)
@ -2640,7 +2640,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_creature->set_adultsize(orig_creature->adultsize); send_creature->set_adultsize(orig_creature->adultsize);
for (int j = 0; j < orig_creature->caste.size(); j++) for (size_t j = 0; j < orig_creature->caste.size(); j++)
{ {
auto orig_caste = orig_creature->caste[j]; auto orig_caste = orig_creature->caste[j];
if (!orig_caste) if (!orig_caste)
@ -2662,7 +2662,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_caste->add_child_name(orig_caste->child_name[1]); send_caste->add_child_name(orig_caste->child_name[1]);
send_caste->set_gender(orig_caste->gender); send_caste->set_gender(orig_caste->gender);
for (int partIndex = 0; partIndex < orig_caste->body_info.body_parts.size(); partIndex++) for (size_t partIndex = 0; partIndex < orig_caste->body_info.body_parts.size(); partIndex++)
{ {
auto orig_part = orig_caste->body_info.body_parts[partIndex]; auto orig_part = orig_caste->body_info.body_parts[partIndex];
if (!orig_part) if (!orig_part)
@ -2678,7 +2678,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_part->add_flags(orig_part->flags.is_set((body_part_raw_flags::body_part_raw_flags)partFlagIndex)); send_part->add_flags(orig_part->flags.is_set((body_part_raw_flags::body_part_raw_flags)partFlagIndex));
} }
for (int layerIndex = 0; layerIndex < orig_part->layers.size(); layerIndex++) for (size_t layerIndex = 0; layerIndex < orig_part->layers.size(); layerIndex++)
{ {
auto orig_layer = orig_part->layers[layerIndex]; auto orig_layer = orig_part->layers[layerIndex];
if (!orig_layer) if (!orig_layer)
@ -2688,7 +2688,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_layer->set_layer_name(orig_layer->layer_name); send_layer->set_layer_name(orig_layer->layer_name);
send_layer->set_tissue_id(orig_layer->tissue_id); send_layer->set_tissue_id(orig_layer->tissue_id);
send_layer->set_layer_depth(orig_layer->layer_depth); send_layer->set_layer_depth(orig_layer->layer_depth);
for (int layerModIndex = 0; layerModIndex < orig_layer->bp_modifiers.size(); layerModIndex++) for (size_t layerModIndex = 0; layerModIndex < orig_layer->bp_modifiers.size(); layerModIndex++)
{ {
send_layer->add_bp_modifiers(orig_layer->bp_modifiers[layerModIndex]); send_layer->add_bp_modifiers(orig_layer->bp_modifiers[layerModIndex]);
} }
@ -2699,7 +2699,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_caste->set_total_relsize(orig_caste->body_info.total_relsize); send_caste->set_total_relsize(orig_caste->body_info.total_relsize);
for (int k = 0; k < orig_caste->bp_appearance.modifiers.size(); k++) for (size_t k = 0; k < orig_caste->bp_appearance.modifiers.size(); k++)
{ {
auto send_mod = send_caste->add_modifiers(); auto send_mod = send_caste->add_modifiers();
auto orig_mod = orig_caste->bp_appearance.modifiers[k]; auto orig_mod = orig_caste->bp_appearance.modifiers[k];
@ -2719,13 +2719,13 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
} }
} }
for (int k = 0; k < orig_caste->bp_appearance.modifier_idx.size(); k++) for (size_t k = 0; k < orig_caste->bp_appearance.modifier_idx.size(); k++)
{ {
send_caste->add_modifier_idx(orig_caste->bp_appearance.modifier_idx[k]); send_caste->add_modifier_idx(orig_caste->bp_appearance.modifier_idx[k]);
send_caste->add_part_idx(orig_caste->bp_appearance.part_idx[k]); send_caste->add_part_idx(orig_caste->bp_appearance.part_idx[k]);
send_caste->add_layer_idx(orig_caste->bp_appearance.layer_idx[k]); send_caste->add_layer_idx(orig_caste->bp_appearance.layer_idx[k]);
} }
for (int k = 0; k < orig_caste->body_appearance_modifiers.size(); k++) for (size_t k = 0; k < orig_caste->body_appearance_modifiers.size(); k++)
{ {
auto send_mod = send_caste->add_body_appearance_modifiers(); auto send_mod = send_caste->add_body_appearance_modifiers();
auto orig_mod = orig_caste->body_appearance_modifiers[k]; auto orig_mod = orig_caste->body_appearance_modifiers[k];
@ -2745,17 +2745,17 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_mod->set_mod_max(orig_mod->ranges[6]); send_mod->set_mod_max(orig_mod->ranges[6]);
} }
} }
for (int k = 0; k < orig_caste->color_modifiers.size(); k++) for (size_t k = 0; k < orig_caste->color_modifiers.size(); k++)
{ {
auto send_mod = send_caste->add_color_modifiers(); auto send_mod = send_caste->add_color_modifiers();
auto orig_mod = orig_caste->color_modifiers[k]; auto orig_mod = orig_caste->color_modifiers[k];
for (int l = 0; l < orig_mod->pattern_index.size(); l++) for (size_t l = 0; l < orig_mod->pattern_index.size(); l++)
{ {
auto orig_pattern = world->raws.descriptors.patterns[orig_mod->pattern_index[l]]; auto orig_pattern = world->raws.descriptors.patterns[orig_mod->pattern_index[l]];
auto send_pattern = send_mod->add_patterns(); auto send_pattern = send_mod->add_patterns();
for (int m = 0; m < orig_pattern->colors.size(); m++) for (size_t m = 0; m < orig_pattern->colors.size(); m++)
{ {
auto send_color = send_pattern->add_colors(); auto send_color = send_pattern->add_colors();
auto orig_color = world->raws.descriptors.colors[orig_pattern->colors[m]]; auto orig_color = world->raws.descriptors.colors[orig_pattern->colors[m]];
@ -2768,7 +2768,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_pattern->set_pattern((PatternType)orig_pattern->pattern); send_pattern->set_pattern((PatternType)orig_pattern->pattern);
} }
for (int l = 0; l < orig_mod->body_part_id.size(); l++) for (size_t l = 0; l < orig_mod->body_part_id.size(); l++)
{ {
send_mod->add_body_part_id(orig_mod->body_part_id[l]); send_mod->add_body_part_id(orig_mod->body_part_id[l]);
send_mod->add_tissue_layer_id(orig_mod->tissue_layer_id[l]); send_mod->add_tissue_layer_id(orig_mod->tissue_layer_id[l]);
@ -2782,7 +2782,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
send_caste->set_adult_size(orig_caste->misc.adult_size); send_caste->set_adult_size(orig_caste->misc.adult_size);
} }
for (int j = 0; j < orig_creature->tissue.size(); j++) for (size_t j = 0; j < orig_creature->tissue.size(); j++)
{ {
auto orig_tissue = orig_creature->tissue[j]; auto orig_tissue = orig_creature->tissue[j];
auto send_tissue = send_creature->add_tissues(); auto send_tissue = send_creature->add_tissues();
@ -2811,14 +2811,7 @@ static command_result GetPartialPlantRaws(color_ostream &stream, const ListReque
df::world * world = df::global::world; df::world * world = df::global::world;
int list_start = 0; for (size_t i = 0; i < world->raws.plants.all.size(); i++)
if (in != nullptr)
{
list_start = in->list_start();
}
for (int i = 0; i < world->raws.plants.all.size(); i++)
{ {
df::plant_raw* plant_local = world->raws.plants.all[i]; df::plant_raw* plant_local = world->raws.plants.all[i];
PlantRaw* plant_remote = out->add_plant_raws(); PlantRaw* plant_remote = out->add_plant_raws();
@ -2831,14 +2824,14 @@ static command_result GetPartialPlantRaws(color_ostream &stream, const ListReque
else else
plant_remote->set_tile(plant_local->tiles.tree_tile); plant_remote->set_tile(plant_local->tiles.tree_tile);
#if DF_VERSION_INT > 34011 #if DF_VERSION_INT > 34011
for (int j = 0; j < plant_local->growths.size(); j++) for (size_t j = 0; j < plant_local->growths.size(); j++)
{ {
df::plant_growth* growth_local = plant_local->growths[j]; df::plant_growth* growth_local = plant_local->growths[j];
TreeGrowth * growth_remote = plant_remote->add_growths(); TreeGrowth * growth_remote = plant_remote->add_growths();
growth_remote->set_index(j); growth_remote->set_index(j);
growth_remote->set_id(growth_local->id); growth_remote->set_id(growth_local->id);
growth_remote->set_name(growth_local->name); growth_remote->set_name(growth_local->name);
for (int k = 0; k < growth_local->prints.size(); k++) for (size_t k = 0; k < growth_local->prints.size(); k++)
{ {
df::plant_growth_print* print_local = growth_local->prints[k]; df::plant_growth_print* print_local = growth_local->prints[k];
GrowthPrint* print_remote = growth_remote->add_prints(); GrowthPrint* print_remote = growth_remote->add_prints();
@ -3018,7 +3011,7 @@ static command_result GetReports(color_ostream & stream, const EmptyMessage * in
break; break;
} }
} }
for (int i = lastSentIndex + 1; i < world->status.reports.size(); i++) for (size_t i = lastSentIndex + 1; i < world->status.reports.size(); i++)
{ {
auto local_rep = world->status.reports[i]; auto local_rep = world->status.reports[i];
if (!local_rep) if (!local_rep)
@ -3046,7 +3039,7 @@ static command_result GetLanguage(color_ostream & stream, const EmptyMessage * i
if (!world) if (!world)
return CR_FAILURE; return CR_FAILURE;
for (int i = 0; i < world->raws.descriptors.shapes.size(); i++) for (size_t i = 0; i < world->raws.descriptors.shapes.size(); i++)
{ {
auto shape = world->raws.descriptors.shapes[i]; auto shape = world->raws.descriptors.shapes[i];
auto netShape = out->add_shapes(); auto netShape = out->add_shapes();

@ -104,7 +104,7 @@ rect2d getMapViewport()
} }
return mkrect_wh(1,1,view_rb,view_height+1); return mkrect_wh(1,1,view_rb,view_height+1);
} }
lightingEngineViewscreen::lightingEngineViewscreen(renderer_light* target):lightingEngine(target),doDebug(false),threading(this) lightingEngineViewscreen::lightingEngineViewscreen(renderer_light* target):lightingEngine(target),threading(this),doDebug(false)
{ {
reinit(); reinit();
defaultSettings(); defaultSettings();
@ -391,7 +391,7 @@ rgbf getStandartColor(int colorId)
int getPlantNumber(const std::string& id) int getPlantNumber(const std::string& id)
{ {
std::vector<df::plant_raw*>& vec=df::plant_raw::get_vector(); std::vector<df::plant_raw*>& vec=df::plant_raw::get_vector();
for(int i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
if(vec[i]->id==id) if(vec[i]->id==id)
return i; return i;
@ -605,7 +605,7 @@ rgbf lightingEngineViewscreen::getSkyColor(float v)
float pos=v*(dayColors.size()-1); float pos=v*(dayColors.size()-1);
int pre=floor(pos); int pre=floor(pos);
pos-=pre; pos-=pre;
if(pre==dayColors.size()-1) if(pre==int(dayColors.size())-1)
return dayColors[pre]; return dayColors[pre];
return dayColors[pre]*(1-pos)+dayColors[pre+1]*pos; return dayColors[pre]*(1-pos)+dayColors[pre+1]*pos;
} }
@ -719,7 +719,7 @@ void lightingEngineViewscreen::doOcupancyAndLights()
if(!block) if(!block)
continue; continue;
//flows //flows
for(int i=0;i<block->flows.size();i++) for(size_t i=0;i<block->flows.size();i++)
{ {
df::flow_info* f=block->flows[i]; df::flow_info* f=block->flows[i];
if(f && f->density>0 && (f->type==df::flow_type::Dragonfire || f->type==df::flow_type::Fire)) if(f && f->density>0 && (f->type==df::flow_type::Dragonfire || f->type==df::flow_type::Fire))
@ -749,7 +749,7 @@ void lightingEngineViewscreen::doOcupancyAndLights()
} }
//blood and other goo //blood and other goo
for(int i=0;i<block->block_events.size();i++) for(size_t i=0;i<block->block_events.size();i++)
{ {
df::block_square_event* ev=block->block_events[i]; df::block_square_event* ev=block->block_events[i];
df::block_square_event_type ev_type=ev->getType(); df::block_square_event_type ev_type=ev->getType();
@ -789,7 +789,7 @@ void lightingEngineViewscreen::doOcupancyAndLights()
//citizen only emit light, if defined //citizen only emit light, if defined
//or other creatures //or other creatures
if(matCitizen.isEmiting || creatureDefs.size()>0) if(matCitizen.isEmiting || creatureDefs.size()>0)
for (int i=0;i<df::global::world->units.active.size();++i) for (size_t i=0;i<df::global::world->units.active.size();++i)
{ {
df::unit *u = df::global::world->units.active[i]; df::unit *u = df::global::world->units.active[i];
coord2d pos=worldToViewportCoord(coord2d(u->pos.x,u->pos.y),vp,window2d); coord2d pos=worldToViewportCoord(coord2d(u->pos.x,u->pos.y),vp,window2d);
@ -1247,7 +1247,7 @@ void lightingEngineViewscreen::loadSettings()
/* /*
* Threading stuff * Threading stuff
*/ */
lightThread::lightThread( lightThreadDispatch& dispatch ):dispatch(dispatch),isDone(false),myThread(0) lightThread::lightThread( lightThreadDispatch& dispatch ):dispatch(dispatch),myThread(0),isDone(false)
{ {
} }
@ -1309,7 +1309,7 @@ void lightThread::work()
void lightThread::combine() void lightThread::combine()
{ {
for(int i=0;i<canvas.size();i++) for(size_t i=0;i<canvas.size();i++)
{ {
rgbf& c=dispatch.lightMap[i]; rgbf& c=dispatch.lightMap[i];
c=blend(c,canvas[i]); c=blend(c,canvas[i]);
@ -1425,21 +1425,22 @@ void lightThreadDispatch::signalDoneOcclusion()
occlusionDone.notify_all(); occlusionDone.notify_all();
} }
lightThreadDispatch::lightThreadDispatch( lightingEngineViewscreen* p ):parent(p),lights(parent->lights),occlusion(parent->ocupancy),num_diffusion(parent->num_diffuse), lightThreadDispatch::lightThreadDispatch( lightingEngineViewscreen* p ):parent(p),lights(parent->lights),
lightMap(parent->lightMap),writeCount(0),occlusionReady(false) occlusionReady(false),occlusion(parent->ocupancy),num_diffusion(parent->num_diffuse),
lightMap(parent->lightMap),writeCount(0)
{ {
} }
void lightThreadDispatch::shutdown() void lightThreadDispatch::shutdown()
{ {
for(int i=0;i<threadPool.size();i++) for(size_t i=0;i<threadPool.size();i++)
{ {
threadPool[i]->isDone=true; threadPool[i]->isDone=true;
} }
occlusionDone.notify_all();//if stuck signal that you are done with stuff. occlusionDone.notify_all();//if stuck signal that you are done with stuff.
for(int i=0;i<threadPool.size();i++) for(size_t i=0;i<threadPool.size();i++)
{ {
threadPool[i]->myThread->join(); threadPool[i]->myThread->join();
} }
@ -1473,7 +1474,7 @@ void lightThreadDispatch::start(int count)
void lightThreadDispatch::waitForWrites() void lightThreadDispatch::waitForWrites()
{ {
tthread::lock_guard<tthread::mutex> guard(writeLock); tthread::lock_guard<tthread::mutex> guard(writeLock);
while(threadPool.size()>writeCount)//missed it somehow already. while(threadPool.size()>size_t(writeCount))//missed it somehow already.
{ {
writesDone.wait(writeLock); //if not, wait a bit writesDone.wait(writeLock); //if not, wait a bit
} }

@ -181,11 +181,11 @@ struct matLightDef
bool flicker; bool flicker;
rgbf emitColor; rgbf emitColor;
int radius; int radius;
matLightDef():isTransparent(false),isEmiting(false),transparency(0,0,0),emitColor(0,0,0),radius(0){} matLightDef():isTransparent(false),transparency(0,0,0),isEmiting(false),emitColor(0,0,0),radius(0){}
matLightDef(rgbf transparency,rgbf emit,int rad):isTransparent(true),isEmiting(true), matLightDef(rgbf transparency,rgbf emit,int rad):isTransparent(true),transparency(transparency),
transparency(transparency),emitColor(emit),radius(rad){} isEmiting(true),emitColor(emit),radius(rad){}
matLightDef(rgbf emit,int rad):isTransparent(false),isEmiting(true),emitColor(emit),radius(rad),transparency(0,0,0){} matLightDef(rgbf emit,int rad):isTransparent(false),transparency(0,0,0),isEmiting(true),emitColor(emit),radius(rad){}
matLightDef(rgbf transparency):isTransparent(true),isEmiting(false),transparency(transparency){} matLightDef(rgbf transparency):isTransparent(true),transparency(transparency),isEmiting(false){}
lightSource makeSource(float size=1) const lightSource makeSource(float size=1) const
{ {
if(size>0.999 && size<1.001) if(size>0.999 && size<1.001)

@ -236,6 +236,7 @@ DFhackCExport command_result plugin_onstatechange ( color_ostream &out, state_ch
std::string cmd = "DFHack.onstatechange "; std::string cmd = "DFHack.onstatechange ";
switch (e) { switch (e) {
#define SCASE(s) case SC_ ## s : cmd += ":" # s ; break #define SCASE(s) case SC_ ## s : cmd += ":" # s ; break
case SC_UNKNOWN : return CR_OK;
SCASE(WORLD_LOADED); SCASE(WORLD_LOADED);
SCASE(WORLD_UNLOADED); SCASE(WORLD_UNLOADED);
SCASE(MAP_LOADED); SCASE(MAP_LOADED);

@ -14,7 +14,7 @@ SET(PROJECT_SRCS
) )
SET(PROJECT_PROTOS SET(PROJECT_PROTOS
stockpiles.proto stockpiles
) )
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)

@ -214,7 +214,7 @@ void StockpileSerializer::unserialize_list_organic_mat ( FuncReadImport get_valu
std::string token = get_value ( i ); std::string token = get_value ( i );
int16_t idx = OrganicMatLookup::food_idx_by_token ( debug(), cat, token ); int16_t idx = OrganicMatLookup::food_idx_by_token ( debug(), cat, token );
debug() << " organic_material " << idx << " is " << token << endl; debug() << " organic_material " << idx << " is " << token << endl;
if ( idx >= pile_list->size() ) if ( size_t(idx) >= pile_list->size() )
{ {
debug() << "error organic mat index too large! idx[" << idx << "] max_size[" << pile_list->size() << "]" << endl; debug() << "error organic mat index too large! idx[" << idx << "] max_size[" << pile_list->size() << "]" << endl;
continue; continue;
@ -247,7 +247,7 @@ void StockpileSerializer::unserialize_list_item_type ( FuncItemAllowed is_allowe
{ {
pile_list->clear(); pile_list->clear();
pile_list->resize ( 112, '\0' ); // TODO remove hardcoded list size value pile_list->resize ( 112, '\0' ); // TODO remove hardcoded list size value
for ( int i = 0; i < pile_list->size(); ++i ) for ( size_t i = 0; i < pile_list->size(); ++i )
{ {
pile_list->at ( i ) = is_allowed ( ( item_type::item_type ) i ) ? 0 : 1; pile_list->at ( i ) = is_allowed ( ( item_type::item_type ) i ) ? 0 : 1;
} }
@ -261,7 +261,7 @@ void StockpileSerializer::unserialize_list_item_type ( FuncItemAllowed is_allowe
const item_type type = ( item_type ) idx; const item_type type = ( item_type ) idx;
if ( !is_allowed ( type ) ) continue; if ( !is_allowed ( type ) ) continue;
debug() << " item_type " << idx << " is " << token << endl; debug() << " item_type " << idx << " is " << token << endl;
if ( idx >= pile_list->size() ) if ( size_t(idx) >= pile_list->size() )
{ {
debug() << "error item_type index too large! idx[" << idx << "] max_size[" << pile_list->size() << "]" << endl; debug() << "error item_type index too large! idx[" << idx << "] max_size[" << pile_list->size() << "]" << endl;
continue; continue;
@ -296,7 +296,7 @@ void StockpileSerializer::unserialize_list_material ( FuncMaterialAllowed is_all
std::set<int32_t> idx_set; std::set<int32_t> idx_set;
pile_list->clear(); pile_list->clear();
pile_list->resize ( world->raws.inorganics.size(), 0 ); pile_list->resize ( world->raws.inorganics.size(), 0 );
for ( int i = 0; i < pile_list->size(); ++i ) for ( size_t i = 0; i < pile_list->size(); ++i )
{ {
MaterialInfo mi ( 0, i ); MaterialInfo mi ( 0, i );
pile_list->at ( i ) = is_allowed ( mi ) ? 0 : 1; pile_list->at ( i ) = is_allowed ( mi ) ? 0 : 1;
@ -308,7 +308,7 @@ void StockpileSerializer::unserialize_list_material ( FuncMaterialAllowed is_all
mi.find ( token ); mi.find ( token );
if ( !is_allowed ( mi ) ) continue; if ( !is_allowed ( mi ) ) continue;
debug() << " material " << mi.index << " is " << token << endl; debug() << " material " << mi.index << " is " << token << endl;
if ( mi.index >= pile_list->size() ) if ( size_t(mi.index) >= pile_list->size() )
{ {
debug() << "error material index too large! idx[" << mi.index << "] max_size[" << pile_list->size() << "]" << endl; debug() << "error material index too large! idx[" << mi.index << "] max_size[" << pile_list->size() << "]" << endl;
continue; continue;
@ -435,7 +435,7 @@ void StockpileSerializer::unserialize_list_itemdef ( FuncReadImport read_value,
ItemTypeInfo ii; ItemTypeInfo ii;
if ( !ii.find ( token ) ) continue; if ( !ii.find ( token ) ) continue;
debug() << " itemdef " << ii.subtype << " is " << token << endl; debug() << " itemdef " << ii.subtype << " is " << token << endl;
if ( ii.subtype >= pile_list->size() ) if ( size_t(ii.subtype) >= pile_list->size() )
{ {
debug() << "error itemdef index too large! idx[" << ii.subtype << "] max_size[" << pile_list->size() << "]" << endl; debug() << "error itemdef index too large! idx[" << ii.subtype << "] max_size[" << pile_list->size() << "]" << endl;
continue; continue;
@ -528,7 +528,7 @@ void StockpileSerializer::read_animals()
std::string id = mBuffer.animals().enabled ( i ); std::string id = mBuffer.animals().enabled ( i );
int idx = find_creature ( id ); int idx = find_creature ( id );
debug() << id << " " << idx << endl; debug() << id << " " << idx << endl;
if ( idx < 0 || idx >= mPile->settings.animals.enabled.size() ) if ( idx < 0 || size_t(idx) >= mPile->settings.animals.enabled.size() )
{ {
debug() << "WARNING: animal index invalid: " << idx << endl; debug() << "WARNING: animal index invalid: " << idx << endl;
continue; continue;
@ -895,7 +895,7 @@ void StockpileSerializer::read_furniture()
const std::string type = furniture.type ( i ); const std::string type = furniture.type ( i );
df::enum_traits<furniture_type>::base_type idx = linear_index ( debug(), type_traits, type ); df::enum_traits<furniture_type>::base_type idx = linear_index ( debug(), type_traits, type );
debug() << " type " << idx << " is " << type << endl; debug() << " type " << idx << " is " << type << endl;
if ( idx < 0 || idx >= mPile->settings.furniture.type.size() ) if ( idx < 0 || size_t(idx) >= mPile->settings.furniture.type.size() )
{ {
debug() << "WARNING: furniture type index invalid " << type << ", idx=" << idx << endl; debug() << "WARNING: furniture type index invalid " << type << ", idx=" << idx << endl;
continue; continue;
@ -1048,7 +1048,7 @@ void StockpileSerializer::refuse_read_helper ( std::function<std::string ( const
const std::string creature_id = get_value ( i ); const std::string creature_id = get_value ( i );
const int idx = find_creature ( creature_id ); const int idx = find_creature ( creature_id );
const df::creature_raw* creature = find_creature ( idx ); const df::creature_raw* creature = find_creature ( idx );
if ( idx < 0 || !refuse_creature_is_allowed ( creature ) || idx >= pile_list->size() ) if ( idx < 0 || !refuse_creature_is_allowed ( creature ) || size_t(idx) >= pile_list->size() )
{ {
debug() << "WARNING invalid refuse creature " << creature_id << ", idx=" << idx << endl; debug() << "WARNING invalid refuse creature " << creature_id << ", idx=" << idx << endl;
continue; continue;
@ -1519,7 +1519,7 @@ void StockpileSerializer::read_gems()
const std::string token = gems.rough_other_mats ( i ); const std::string token = gems.rough_other_mats ( i );
MaterialInfo mi; MaterialInfo mi;
mi.find ( token ); mi.find ( token );
if ( !mi.isValid() || mi.type >= builtin_size ) if ( !mi.isValid() || size_t(mi.type) >= builtin_size )
{ {
debug() << "WARNING: invalid gem mat " << token << ". idx=" << mi.type << endl; debug() << "WARNING: invalid gem mat " << token << ". idx=" << mi.type << endl;
continue; continue;
@ -1536,7 +1536,7 @@ void StockpileSerializer::read_gems()
const std::string token = gems.cut_other_mats ( i ); const std::string token = gems.cut_other_mats ( i );
MaterialInfo mi; MaterialInfo mi;
mi.find ( token ); mi.find ( token );
if ( !mi.isValid() || mi.type >= builtin_size ) if ( !mi.isValid() || size_t(mi.type) >= builtin_size )
{ {
debug() << "WARNING: invalid gem mat " << token << ". idx=" << mi.type << endl; debug() << "WARNING: invalid gem mat " << token << ". idx=" << mi.type << endl;
continue; continue;

@ -21,7 +21,7 @@
/** /**
* Retrieve creature raw from index * Retrieve creature raw from index
*/ */
static df::creature_raw* find_creature ( int32_t idx ) static inline df::creature_raw* find_creature ( int32_t idx )
{ {
return df::global::world->raws.creatures.all[idx]; return df::global::world->raws.creatures.all[idx];
} }
@ -30,7 +30,7 @@ static df::creature_raw* find_creature ( int32_t idx )
* Retrieve creature index from id string * Retrieve creature index from id string
* @return -1 if not found * @return -1 if not found
*/ */
static int16_t find_creature ( const std::string &creature_id ) static inline int16_t find_creature ( const std::string &creature_id )
{ {
return linear_index ( df::global::world->raws.creatures.all, &df::creature_raw::creature_id, creature_id ); return linear_index ( df::global::world->raws.creatures.all, &df::creature_raw::creature_id, creature_id );
} }
@ -38,7 +38,7 @@ static int16_t find_creature ( const std::string &creature_id )
/** /**
* Retrieve plant raw from index * Retrieve plant raw from index
*/ */
static df::plant_raw* find_plant ( size_t idx ) static inline df::plant_raw* find_plant ( size_t idx )
{ {
return df::global::world->raws.plants.all[idx]; return df::global::world->raws.plants.all[idx];
} }
@ -47,7 +47,7 @@ static df::plant_raw* find_plant ( size_t idx )
* Retrieve plant index from id string * Retrieve plant index from id string
* @return -1 if not found * @return -1 if not found
*/ */
static size_t find_plant ( const std::string &plant_id ) static inline size_t find_plant ( const std::string &plant_id )
{ {
return linear_index ( df::global::world->raws.plants.all, &df::plant_raw::id, plant_id ); return linear_index ( df::global::world->raws.plants.all, &df::plant_raw::id, plant_id );
} }
@ -60,7 +60,7 @@ struct less_than_no_case: public std::binary_function< char,char,bool >
} }
}; };
static bool CompareNoCase(const std::string &a, const std::string &b) static inline bool CompareNoCase(const std::string &a, const std::string &b)
{ {
return std::lexicographical_compare( a.begin(),a.end(), b.begin(),b.end(), less_than_no_case() ); return std::lexicographical_compare( a.begin(),a.end(), b.begin(),b.end(), less_than_no_case() );
} }
@ -70,7 +70,7 @@ static bool CompareNoCase(const std::string &a, const std::string &b)
* Checks if the parameter has the dfstock extension. * Checks if the parameter has the dfstock extension.
* Doesn't check if the file exists or not. * Doesn't check if the file exists or not.
*/ */
static bool is_dfstockfile ( const std::string& filename ) static inline bool is_dfstockfile ( const std::string& filename )
{ {
return filename.rfind ( ".dfstock" ) != std::string::npos; return filename.rfind ( ".dfstock" ) != std::string::npos;
} }

@ -504,12 +504,6 @@ static std::vector<std::string> clean_dfstock_list ( const std::string &path )
return files; return files;
} }
static bool isEnabled( lua_State *L )
{
Lua::Push(L, is_enabled);
return 1;
}
static int stockpiles_list_settings ( lua_State *L ) static int stockpiles_list_settings ( lua_State *L )
{ {
auto path = luaL_checkstring ( L, 1 ); auto path = luaL_checkstring ( L, 1 );

@ -134,7 +134,7 @@ class tweak_onupdate_hookst {
public: public:
typedef void(*T_callback)(void); typedef void(*T_callback)(void);
tweak_onupdate_hookst(std::string name_, T_callback cb) tweak_onupdate_hookst(std::string name_, T_callback cb)
:name(name_), callback(cb), enabled(false) {} :enabled(false), name(name_), callback(cb) {}
bool enabled; bool enabled;
std::string name; std::string name;
T_callback callback; T_callback callback;

@ -56,7 +56,7 @@ struct block_labors_hook : df::viewscreen_dwarfmodest {
df::unit *unit = Gui::getAnyUnit(this); df::unit *unit = Gui::getAnyUnit(this);
for (int y = 5, i = (*ui_look_cursor/13)*13; for (int y = 5, i = (*ui_look_cursor/13)*13;
y <= 17 && i < unit_labors_sidemenu.size(); y <= 17 && size_t(i) < unit_labors_sidemenu.size();
++y, ++i) ++y, ++i)
{ {
df::unit_labor labor = unit_labors_sidemenu[i]; df::unit_labor labor = unit_labors_sidemenu[i];

@ -50,7 +50,7 @@ struct cage_butcher_hook : df::viewscreen_dwarfmodest {
auto dims = Gui::getDwarfmodeViewDims(); auto dims = Gui::getDwarfmodeViewDims();
for (int y = 4, i = (*ui_building_item_cursor/11)*11; for (int y = 4, i = (*ui_building_item_cursor/11)*11;
y <= 14 && i < units.size(); y <= 14 && size_t(i) < units.size();
++y, ++i) ++y, ++i)
{ {
df::unit *unit = vector_get(units, i); df::unit *unit = vector_get(units, i);

@ -3,7 +3,7 @@ struct craft_age_wear_hook : df::item_crafted {
DEFINE_VMETHOD_INTERPOSE(bool, ageItem, (int amount)) DEFINE_VMETHOD_INTERPOSE(bool, ageItem, (int amount))
{ {
int orig_age = age; uint32_t orig_age = age;
age += amount; age += amount;
if (age > 200000000) if (age > 200000000)
age = 200000000; age = 200000000;
@ -24,7 +24,7 @@ struct craft_age_wear_hook : df::item_crafted {
wear = 1; wear = 1;
else else
return false; return false;
wear = ((orig_age % wear) + (age - orig_age)) / wear; wear = ((orig_age % wear) + int32_t(age - orig_age)) / wear;
if (wear > 0) if (wear > 0)
return incWearTimer(wear); return incWearTimer(wear);
else else

@ -47,7 +47,7 @@ struct dwarfmode_pausing_fps_counter_hook : df::viewscreen_dwarfmodest {
if (prev_clock == 0) if (prev_clock == 0)
{ {
// init // init
for (int i = 0; i < history_length; i++) for (uint32_t i = 0; i < history_length; i++)
history[i] = 0.0; history[i] = 0.0;
} }
@ -91,7 +91,7 @@ struct dwarfmode_pausing_fps_counter_hook : df::viewscreen_dwarfmodest {
// average fps over a few seconds to stabilize the counter. // average fps over a few seconds to stabilize the counter.
double fps_sum = 0.0; double fps_sum = 0.0;
int fps_count = 0; int fps_count = 0;
for (int i = 0; i < history_length; i++) for (uint32_t i = 0; i < history_length; i++)
{ {
if (history[i] > 0.0) if (history[i] > 0.0)
{ {

@ -18,7 +18,7 @@ struct pet_gender_hook : df::viewscreen_topicmeeting_takerequestsst {
df::historical_entity* entity = df::historical_entity::find(meeting->civ_id); df::historical_entity* entity = df::historical_entity::find(meeting->civ_id);
vector<int32_t>& races = entity->resources.animals.pet_races; vector<int32_t>& races = entity->resources.animals.pet_races;
vector<int16_t>& castes = entity->resources.animals.pet_castes; vector<int16_t>& castes = entity->resources.animals.pet_castes;
for (int i = (good_idx / 17) * 17, y = 4; i < (good_idx / 17) * 17 + 17 && i < races.size(); i++, y++) { for (int i = (good_idx / 17) * 17, y = 4; i < (good_idx / 17) * 17 + 17 && size_t(i) < races.size(); i++, y++) {
int x = 30 + 1 + world->raws.creatures.all[races[i]]->caste[castes[i]]->caste_name[0].size(); int x = 30 + 1 + world->raws.creatures.all[races[i]]->caste[castes[i]]->caste_name[0].size();
bool male = (bool)world->raws.creatures.all[races[i]]->caste[castes[i]]->gender; bool male = (bool)world->raws.creatures.all[races[i]]->caste[castes[i]]->gender;
OutputString((i == good_idx) ? COLOR_WHITE : COLOR_GREY, OutputString((i == good_idx) ? COLOR_WHITE : COLOR_GREY,