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})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
SET(PLUGIN_PROTOCPP)
SET(PLUGIN_PROTOS)
FOREACH(pbuf ${PLUGIN_PROTOBUFS})
SET(PLUGIN_SOURCES ${PLUGIN_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.pb.cc)
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)
LIST(APPEND PLUGIN_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/${pbuf}.proto)
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})
IDE_FOLDER(${PLUGIN_NAME} "Plugins")
@ -95,24 +86,63 @@ MACRO(DFHACK_PLUGIN)
# Make sure the source is generated before the executable builds.
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto)
LIST(LENGTH PLUGIN_PROTOBUFS NUM_PROTO)
LIST(LENGTH PLUGIN_PROTOS 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})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "-include Export.h")
SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} -include Export.h")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"")
SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} /FI\"Export.h\"")
ENDIF()
ELSE()
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack dfhack-version ${PLUGIN_LINK_LIBRARIES})
ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS}")
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()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS_MSVC}")
SET(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} ${PLUGIN_COMPILE_FLAGS_MSVC}")
ENDIF()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS}")
IF(APPLE)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dylib PREFIX "")

@ -151,7 +151,7 @@ namespace embark_assist {
fields i = first_fields;
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) {
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;
@ -203,7 +203,7 @@ namespace embark_assist {
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++) {
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' &&
@ -259,7 +259,7 @@ namespace embark_assist {
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++) {
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' &&
@ -1334,7 +1334,7 @@ namespace embark_assist {
}
// 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;
if (state->ui[state->finder_list_focus]->current_index < offset) {
offset = 0;
@ -1343,7 +1343,7 @@ namespace embark_assist {
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);
}
}

@ -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);
}

@ -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
}
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);
}
else if (x < screen_size.x - 2) {

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

@ -525,8 +525,8 @@ struct dwarf_info_t
df::unit_labor using_labor;
dwarf_info_t(df::unit* dw) : dwarf(dw), clear_all(false),
state(OTHER), high_skill(0), has_children(false), armed(false), using_labor(df::unit_labor::NONE)
dwarf_info_t(df::unit* dw) : dwarf(dw), state(OTHER),
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++)
has_tool[e] = false;
@ -614,7 +614,7 @@ static void init_state()
{
string key = p->key();
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].active_dwarfs = 0;
@ -622,7 +622,7 @@ static void init_state()
}
// 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())
continue;
@ -966,12 +966,12 @@ private:
int worker = -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)
worker = ((df::general_ref_unit_workerst *)(j->general_refs[r]))->unit_id;
if (j->general_refs[r]->getType() == df::general_ref_type::BUILDING_HOLDER)
bld = ((df::general_ref_building_holderst *)(j->general_refs[r]))->building_id;
if (ref->getType() == df::general_ref_type::UNIT_WORKER)
worker = ((df::general_ref_unit_workerst *)ref)->unit_id;
if (ref->getType() == df::general_ref_type::BUILDING_HOLDER)
bld = ((df::general_ref_building_holderst *)ref)->building_id;
}
if (bld != -1)
@ -985,7 +985,7 @@ private:
b->getType() != df::building_type::TradeDepot)
{
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)
continue;
@ -1062,7 +1062,7 @@ private:
plant_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];
@ -1187,7 +1187,7 @@ private:
dwarf_info_t* dwarf = add_dwarf(cre);
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);
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
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];
if (!act) continue;
@ -1259,7 +1259,7 @@ private:
// 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];
if (ui->mode == df::unit_inventory_item::Weapon && ui->item->isWeapon())
@ -1335,7 +1335,7 @@ private:
else
{
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];
else
{
@ -2258,7 +2258,7 @@ command_result labormanager(color_ostream &out, std::vector <std::string> & para
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);
}

@ -15,15 +15,16 @@ SET(PROJECT_HDRS
)
#proto files to include.
SET(PROJECT_PROTO
../../proto/RemoteFortressReader
../../proto/AdventureControl
../../proto/ItemdefInstrument
${CMAKE_CURRENT_SOURCE_DIR}/../proto/RemoteFortressReader.pb.cc
${CMAKE_CURRENT_SOURCE_DIR}/../proto/AdventureControl.pb.cc
${CMAKE_CURRENT_SOURCE_DIR}/../proto/ItemdefInstrument.pb.cc
)
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)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS};${PROJECT_PROTO})
#linux
IF(UNIX)
@ -41,4 +42,4 @@ ELSE(UNIX)
)
ENDIF(UNIX)
# 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)
{
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];
@ -152,7 +152,7 @@ DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const D
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];

@ -61,7 +61,7 @@ void CopyImage(const df::art_image * image, ArtImage * netImage)
auto id = netImage->mutable_id();
id->set_mat_type(image->id);
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 netElement = netImage->add_elements();
@ -121,7 +121,7 @@ void CopyImage(const df::art_image * image, ArtImage * netImage)
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 netProperty = netImage->add_properties();
@ -236,7 +236,7 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
}
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)
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);
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];
@ -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::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];
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:
{
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];
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_index(1);
mat_def->set_id("THREAD/WEB");
break;
}
default:
break;
}
int subtypes = Items::getSubtypeCount(it);
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_value(instrument->value);
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();
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_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]);
}
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]));
}
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]));
}
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]);
}
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]));
}
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]));
}
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]);
}
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]));
}
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();
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";
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];
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];
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 << creatureRaw->creature_id << ";";
@ -665,7 +665,7 @@ RemoteFortressReader::TiletypeVariant TranslateVariant(df::tiletype_variant vari
static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in)
{
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];
fletcher16((uint8_t*)(block->tiletype), 16 * 16 * sizeof(df::enums::tiletype::tiletype));
@ -765,13 +765,13 @@ bool IsspatterChanged(DFCoord pos)
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];
hash ^= fletcher16((uint8_t*)mat, sizeof(df::block_square_event_material_spatterst));
}
#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];
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 result = false;
for (int i = 0; i < items->size(); i++)
for (size_t i = 0; i < items->size(); i++)
{
if (isItemChanged(items->at(i)))
result = true;
@ -862,7 +862,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
df::world_raws *raws = &world->raws;
df::world_history *history = &world->history;
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);
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->set_id(mat.getToken());
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());
}
@ -888,16 +888,16 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(j);
mat_def->set_id(mat.getToken());
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());
}
}
}
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];
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);
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->set_id(mat.getToken());
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());
}
}
}
//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];
// 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];
for (int j = 0; j < plant->material.size(); j++)
for (size_t j = 0; j < plant->material.size(); j++)
{
mat.decode(j + 419, i);
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->set_id(mat.getToken());
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());
}
@ -970,7 +970,7 @@ static command_result GetGrowthList(color_ostream &stream, const EmptyMessage *i
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];
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_index(i);
#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];
if (!growth)
@ -1023,7 +1023,7 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
#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];
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];
if (plant->tree_info == NULL)
@ -1179,7 +1179,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
}
}
#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;
if (job == nullptr)
@ -1260,7 +1260,7 @@ void CopyProjectiles(RemoteFortressReader::MapBlock * NetBlock)
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;
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)
{
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];
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);
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();
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++)
{
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];
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]);
}
#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];
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);
}
int grassPercent = 0;
for (int i = 0; i < grasses.size(); i++)
for (size_t i = 0; i < grasses.size(); i++)
{
auto grass = grasses[i];
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_y(DfBlock->map_pos.y);
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];
@ -1441,7 +1441,7 @@ void CopyFlows(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
NetBlock->set_map_x(DfBlock->map_pos.x);
NetBlock->set_map_y(DfBlock->map_pos.y);
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);
}
@ -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];
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
{
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)
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_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 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)
continue;
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];
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)
{
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];
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();
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]);
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]);
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->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))
{
for (int j = 0; j < pvec.size(); j++)
for (size_t j = 0; j < pvec.size(); j++)
{
auto noble_positon = pvec[j];
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 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];
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 sent_item = send_unit->add_inventory();
@ -1911,7 +1911,7 @@ DFCoord GetMapCenter()
}
#if DF_VERSION_INT > 34011
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];
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);
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];
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_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];
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 * 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];
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 * 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];
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];
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];
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)
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 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;
}
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];
if (!region)
@ -2582,7 +2582,7 @@ static command_result GetRegionMapsNew(color_ostream &stream, const EmptyMessage
return CR_FAILURE;
}
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];
if (!region)
@ -2640,7 +2640,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
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];
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->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];
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));
}
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];
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_tissue_id(orig_layer->tissue_id);
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]);
}
@ -2699,7 +2699,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
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 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_part_idx(orig_caste->bp_appearance.part_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 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]);
}
}
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 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 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 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);
}
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_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);
}
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 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;
int list_start = 0;
if (in != nullptr)
{
list_start = in->list_start();
}
for (int i = 0; i < world->raws.plants.all.size(); i++)
for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{
df::plant_raw* plant_local = world->raws.plants.all[i];
PlantRaw* plant_remote = out->add_plant_raws();
@ -2831,14 +2824,14 @@ static command_result GetPartialPlantRaws(color_ostream &stream, const ListReque
else
plant_remote->set_tile(plant_local->tiles.tree_tile);
#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];
TreeGrowth * growth_remote = plant_remote->add_growths();
growth_remote->set_index(j);
growth_remote->set_id(growth_local->id);
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];
GrowthPrint* print_remote = growth_remote->add_prints();
@ -3018,7 +3011,7 @@ static command_result GetReports(color_ostream & stream, const EmptyMessage * in
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];
if (!local_rep)
@ -3046,7 +3039,7 @@ static command_result GetLanguage(color_ostream & stream, const EmptyMessage * i
if (!world)
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 netShape = out->add_shapes();

@ -104,7 +104,7 @@ rect2d getMapViewport()
}
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();
defaultSettings();
@ -391,7 +391,7 @@ rgbf getStandartColor(int colorId)
int getPlantNumber(const std::string& id)
{
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)
return i;
@ -605,7 +605,7 @@ rgbf lightingEngineViewscreen::getSkyColor(float v)
float pos=v*(dayColors.size()-1);
int pre=floor(pos);
pos-=pre;
if(pre==dayColors.size()-1)
if(pre==int(dayColors.size())-1)
return dayColors[pre];
return dayColors[pre]*(1-pos)+dayColors[pre+1]*pos;
}
@ -719,7 +719,7 @@ void lightingEngineViewscreen::doOcupancyAndLights()
if(!block)
continue;
//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];
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
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_type ev_type=ev->getType();
@ -789,7 +789,7 @@ void lightingEngineViewscreen::doOcupancyAndLights()
//citizen only emit light, if defined
//or other creatures
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];
coord2d pos=worldToViewportCoord(coord2d(u->pos.x,u->pos.y),vp,window2d);
@ -1247,7 +1247,7 @@ void lightingEngineViewscreen::loadSettings()
/*
* 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()
{
for(int i=0;i<canvas.size();i++)
for(size_t i=0;i<canvas.size();i++)
{
rgbf& c=dispatch.lightMap[i];
c=blend(c,canvas[i]);
@ -1425,21 +1425,22 @@ void lightThreadDispatch::signalDoneOcclusion()
occlusionDone.notify_all();
}
lightThreadDispatch::lightThreadDispatch( lightingEngineViewscreen* p ):parent(p),lights(parent->lights),occlusion(parent->ocupancy),num_diffusion(parent->num_diffuse),
lightMap(parent->lightMap),writeCount(0),occlusionReady(false)
lightThreadDispatch::lightThreadDispatch( lightingEngineViewscreen* p ):parent(p),lights(parent->lights),
occlusionReady(false),occlusion(parent->ocupancy),num_diffusion(parent->num_diffuse),
lightMap(parent->lightMap),writeCount(0)
{
}
void lightThreadDispatch::shutdown()
{
for(int i=0;i<threadPool.size();i++)
for(size_t i=0;i<threadPool.size();i++)
{
threadPool[i]->isDone=true;
}
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();
}
@ -1473,7 +1474,7 @@ void lightThreadDispatch::start(int count)
void lightThreadDispatch::waitForWrites()
{
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
}

@ -181,11 +181,11 @@ struct matLightDef
bool flicker;
rgbf emitColor;
int radius;
matLightDef():isTransparent(false),isEmiting(false),transparency(0,0,0),emitColor(0,0,0),radius(0){}
matLightDef(rgbf transparency,rgbf emit,int rad):isTransparent(true),isEmiting(true),
transparency(transparency),emitColor(emit),radius(rad){}
matLightDef(rgbf emit,int rad):isTransparent(false),isEmiting(true),emitColor(emit),radius(rad),transparency(0,0,0){}
matLightDef(rgbf transparency):isTransparent(true),isEmiting(false),transparency(transparency){}
matLightDef():isTransparent(false),transparency(0,0,0),isEmiting(false),emitColor(0,0,0),radius(0){}
matLightDef(rgbf transparency,rgbf emit,int rad):isTransparent(true),transparency(transparency),
isEmiting(true),emitColor(emit),radius(rad){}
matLightDef(rgbf emit,int rad):isTransparent(false),transparency(0,0,0),isEmiting(true),emitColor(emit),radius(rad){}
matLightDef(rgbf transparency):isTransparent(true),transparency(transparency),isEmiting(false){}
lightSource makeSource(float size=1) const
{
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 ";
switch (e) {
#define SCASE(s) case SC_ ## s : cmd += ":" # s ; break
case SC_UNKNOWN : return CR_OK;
SCASE(WORLD_LOADED);
SCASE(WORLD_UNLOADED);
SCASE(MAP_LOADED);

@ -14,7 +14,7 @@ SET(PROJECT_SRCS
)
SET(PROJECT_PROTOS
stockpiles.proto
stockpiles
)
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 );
int16_t idx = OrganicMatLookup::food_idx_by_token ( debug(), cat, token );
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;
continue;
@ -247,7 +247,7 @@ void StockpileSerializer::unserialize_list_item_type ( FuncItemAllowed is_allowe
{
pile_list->clear();
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;
}
@ -261,7 +261,7 @@ void StockpileSerializer::unserialize_list_item_type ( FuncItemAllowed is_allowe
const item_type type = ( item_type ) idx;
if ( !is_allowed ( type ) ) continue;
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;
continue;
@ -296,7 +296,7 @@ void StockpileSerializer::unserialize_list_material ( FuncMaterialAllowed is_all
std::set<int32_t> idx_set;
pile_list->clear();
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 );
pile_list->at ( i ) = is_allowed ( mi ) ? 0 : 1;
@ -308,7 +308,7 @@ void StockpileSerializer::unserialize_list_material ( FuncMaterialAllowed is_all
mi.find ( token );
if ( !is_allowed ( mi ) ) continue;
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;
continue;
@ -435,7 +435,7 @@ void StockpileSerializer::unserialize_list_itemdef ( FuncReadImport read_value,
ItemTypeInfo ii;
if ( !ii.find ( token ) ) continue;
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;
continue;
@ -528,7 +528,7 @@ void StockpileSerializer::read_animals()
std::string id = mBuffer.animals().enabled ( i );
int idx = find_creature ( id );
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;
continue;
@ -895,7 +895,7 @@ void StockpileSerializer::read_furniture()
const std::string type = furniture.type ( i );
df::enum_traits<furniture_type>::base_type idx = linear_index ( debug(), type_traits, type );
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;
continue;
@ -1048,7 +1048,7 @@ void StockpileSerializer::refuse_read_helper ( std::function<std::string ( const
const std::string creature_id = get_value ( i );
const int idx = find_creature ( creature_id );
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;
continue;
@ -1519,7 +1519,7 @@ void StockpileSerializer::read_gems()
const std::string token = gems.rough_other_mats ( i );
MaterialInfo mi;
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;
continue;
@ -1536,7 +1536,7 @@ void StockpileSerializer::read_gems()
const std::string token = gems.cut_other_mats ( i );
MaterialInfo mi;
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;
continue;

@ -21,7 +21,7 @@
/**
* 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];
}
@ -30,7 +30,7 @@ static df::creature_raw* find_creature ( int32_t idx )
* Retrieve creature index from id string
* @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 );
}
@ -38,7 +38,7 @@ static int16_t find_creature ( const std::string &creature_id )
/**
* 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];
}
@ -47,7 +47,7 @@ static df::plant_raw* find_plant ( size_t idx )
* Retrieve plant index from id string
* @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 );
}
@ -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() );
}
@ -70,7 +70,7 @@ static bool CompareNoCase(const std::string &a, const std::string &b)
* Checks if the parameter has the dfstock extension.
* 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;
}

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

@ -133,8 +133,8 @@ using namespace DFHack::Gui;
class tweak_onupdate_hookst {
public:
typedef void(*T_callback)(void);
tweak_onupdate_hookst(std::string name_, T_callback cb)
:name(name_), callback(cb), enabled(false) {}
tweak_onupdate_hookst(std::string name_, T_callback cb)
:enabled(false), name(name_), callback(cb) {}
bool enabled;
std::string name;
T_callback callback;

@ -56,7 +56,7 @@ struct block_labors_hook : df::viewscreen_dwarfmodest {
df::unit *unit = Gui::getAnyUnit(this);
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)
{
df::unit_labor labor = unit_labors_sidemenu[i];

@ -50,7 +50,7 @@ struct cage_butcher_hook : df::viewscreen_dwarfmodest {
auto dims = Gui::getDwarfmodeViewDims();
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)
{
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))
{
int orig_age = age;
uint32_t orig_age = age;
age += amount;
if (age > 200000000)
age = 200000000;
@ -24,7 +24,7 @@ struct craft_age_wear_hook : df::item_crafted {
wear = 1;
else
return false;
wear = ((orig_age % wear) + (age - orig_age)) / wear;
wear = ((orig_age % wear) + int32_t(age - orig_age)) / wear;
if (wear > 0)
return incWearTimer(wear);
else

@ -47,7 +47,7 @@ struct dwarfmode_pausing_fps_counter_hook : df::viewscreen_dwarfmodest {
if (prev_clock == 0)
{
// init
for (int i = 0; i < history_length; i++)
for (uint32_t i = 0; i < history_length; i++)
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.
double fps_sum = 0.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)
{

@ -18,7 +18,7 @@ struct pet_gender_hook : df::viewscreen_topicmeeting_takerequestsst {
df::historical_entity* entity = df::historical_entity::find(meeting->civ_id);
vector<int32_t>& races = entity->resources.animals.pet_races;
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();
bool male = (bool)world->raws.creatures.all[races[i]]->caste[castes[i]]->gender;
OutputString((i == good_idx) ? COLOR_WHITE : COLOR_GREY,