Merge pull request #1253 from BenLubar/warnings-fix

Fix MSVC and GCC warnings in DFHack and core plugins
develop
Lethosor 2018-04-10 18:53:34 -04:00 committed by GitHub
commit c0787f065b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 565 additions and 567 deletions

@ -53,13 +53,18 @@ if(MSVC)
add_definitions( "/wd4819" ) add_definitions( "/wd4819" )
# Disable use of POSIX name warnings # Disable use of POSIX name warnings
add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS") add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS")
# supress C4503 - VC++ dislikes if a name is too long. If you get # supress C4503 - VC++ dislikes if a name is too long. If you get
# weird and mysterious linking errors, you can disable this, but you'll have to # weird and mysterious linking errors, you can disable this, but you'll have to
# deal with a LOT of compiler noise over it # deal with a LOT of compiler noise over it
# see https://msdn.microsoft.com/en-us/library/074af4b6.aspx # see https://msdn.microsoft.com/en-us/library/074af4b6.aspx
add_definitions( "/wd4503") add_definitions( "/wd4503")
# suppress C4267 - VC++ complains whenever we implicitly convert an integer to
# a smaller type, and most of the time this is just conversion from 64 to 32 bits
# for things like vector sizes, which are never that big anyway.
add_definitions( "/wd4267")
endif() endif()
# Automatically detect architecture based on Visual Studio generator # Automatically detect architecture based on Visual Studio generator

@ -1 +1 @@
Subproject commit 0f0ad78c4fd429caacd0694b5c868dbeacea16b6 Subproject commit f638c8ea7f9c50fe7f64159c9f173846856f87a6

@ -7,7 +7,7 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DLUA_USE_
ADD_DEFINITIONS(-DLUA_COMPAT_BITLIB) ADD_DEFINITIONS(-DLUA_COMPAT_BITLIB)
IF(WIN32) IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE ) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE /wd4334 )
ELSE() ELSE()
ADD_DEFINITIONS ( -DLUA_USE_POSIX -DLUA_USE_DLOPEN ) ADD_DEFINITIONS ( -DLUA_USE_POSIX -DLUA_USE_DLOPEN )
SET ( LIBS m dl ) SET ( LIBS m dl )

@ -135,7 +135,7 @@ void MD5Final(unsigned char digest[16], MD5Context *ctx)
MD5Transform(ctx->buf, (uint32_t *) ctx->in); MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4); byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16); memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
} }

@ -16,10 +16,6 @@
* Petr Mrázek * Petr Mrázek
*/ */
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define _CRT_SECURE_NO_WARNINGS
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//basic includes //basic includes
#include <algorithm> #include <algorithm>

@ -191,7 +191,7 @@ LIST(APPEND LIBPROTOBUF_FULL_SRCS ${LIBPROTOBUF_LITE_SRCS})
IF(CMAKE_COMPILER_IS_GNUCC) IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unused-local-typedefs -Wno-misleading-indentation")
ELSEIF(MSVC) ELSEIF(MSVC)
# Disable warnings for integer conversion to smaller type # Disable warnings for integer conversion to smaller type
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")

@ -244,6 +244,10 @@ ADD_CUSTOM_COMMAND(
DEPENDS protoc-bin ${PROJECT_PROTOS} DEPENDS protoc-bin ${PROJECT_PROTOS}
) )
IF(UNIX)
SET_SOURCE_FILES_PROPERTIES(${PROJECT_PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()
ADD_CUSTOM_TARGET(generate_proto_core DEPENDS ${PROJECT_PROTO_TMP_FILES}) ADD_CUSTOM_TARGET(generate_proto_core DEPENDS ${PROJECT_PROTO_TMP_FILES})
# Merge headers into sources # Merge headers into sources

@ -532,7 +532,7 @@ namespace DFHack
} }
if (seq[1] == 'D') if (seq[1] == 'D')
{ {
left_arrow: /* left arrow */
if (raw_cursor > 0) if (raw_cursor > 0)
{ {
raw_cursor--; raw_cursor--;
@ -541,7 +541,6 @@ namespace DFHack
} }
else if ( seq[1] == 'C') else if ( seq[1] == 'C')
{ {
right_arrow:
/* right arrow */ /* right arrow */
if (size_t(raw_cursor) != raw_buffer.size()) if (size_t(raw_cursor) != raw_buffer.size())
{ {
@ -636,7 +635,7 @@ namespace DFHack
prompt_refresh(); prompt_refresh();
break; break;
case 11: // Ctrl+k, delete from current to end of line. case 11: // Ctrl+k, delete from current to end of line.
if (raw_cursor < raw_buffer.size()) if (size_t(raw_cursor) < raw_buffer.size())
yank_buffer = raw_buffer.substr(raw_cursor); yank_buffer = raw_buffer.substr(raw_cursor);
raw_buffer.erase(raw_cursor); raw_buffer.erase(raw_cursor);
prompt_refresh(); prompt_refresh();
@ -652,7 +651,7 @@ namespace DFHack
case 20: // Ctrl+t, transpose current and previous characters case 20: // Ctrl+t, transpose current and previous characters
if (raw_buffer.size() >= 2 && raw_cursor > 0) if (raw_buffer.size() >= 2 && raw_cursor > 0)
{ {
if (raw_cursor == raw_buffer.size()) if (size_t(raw_cursor) == raw_buffer.size())
raw_cursor--; raw_cursor--;
std::swap(raw_buffer[raw_cursor - 1], raw_buffer[raw_cursor]); std::swap(raw_buffer[raw_cursor - 1], raw_buffer[raw_cursor]);
raw_cursor++; raw_cursor++;

@ -1504,8 +1504,18 @@ static const luaL_Reg dfhack_gui_funcs[] = {
/***** Job module *****/ /***** Job module *****/
static bool jobEqual(df::job *job1, df::job *job2) { return *job1 == *job2; } static bool jobEqual(const df::job *job1, const df::job *job2)
static bool jobItemEqual(df::job_item *job1, df::job_item *job2) { return *job1 == *job2; } {
CHECK_NULL_POINTER(job1);
CHECK_NULL_POINTER(job2);
return *job1 == *job2;
}
static bool jobItemEqual(const df::job_item *job1, const df::job_item *job2)
{
CHECK_NULL_POINTER(job1);
CHECK_NULL_POINTER(job2);
return *job1 == *job2;
}
static const LuaWrapper::FunctionReg dfhack_job_module[] = { static const LuaWrapper::FunctionReg dfhack_job_module[] = {
WRAPM(Job,cloneJobStruct), WRAPM(Job,cloneJobStruct),

@ -176,22 +176,6 @@ int Process::adjustOffset(int offset, bool /*to_file*/)
return offset; return offset;
} }
static int getdir (string dir, vector<string> &files)
{
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL)
{
cout << "Error(" << errno << ") opening " << dir << endl;
return errno;
}
while ((dirp = readdir(dp)) != NULL) {
files.push_back(string(dirp->d_name));
}
closedir(dp);
return 0;
}
uint32_t Process::getTickCount() uint32_t Process::getTickCount()
{ {
struct timeval tp; struct timeval tp;

@ -423,12 +423,15 @@ namespace df
using DFHack::BitArray; using DFHack::BitArray;
using DFHack::DfArray; using DFHack::DfArray;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
template<class T> template<class T>
void *allocator_fn(void *out, const void *in) { void *allocator_fn(void *out, const void *in) {
if (out) { *(T*)out = *(const T*)in; return out; } if (out) { *(T*)out = *(const T*)in; return out; }
else if (in) { delete (T*)in; return (T*)in; } else if (in) { delete (T*)in; return (T*)in; }
else return new T(); else return new T();
} }
#pragma GCC diagnostic pop
template<class T> template<class T>
void *allocator_nodel_fn(void *out, const void *in) { void *allocator_nodel_fn(void *out, const void *in) {

@ -395,10 +395,10 @@ static void manageJobInitiatedEvent(color_ostream& out) {
} }
//helper function for manageJobCompletedEvent //helper function for manageJobCompletedEvent
static int32_t getWorkerID(df::job* job) { //static int32_t getWorkerID(df::job* job) {
auto ref = findRef(job->general_refs, general_ref_type::UNIT_WORKER); // auto ref = findRef(job->general_refs, general_ref_type::UNIT_WORKER);
return ref ? ref->getID() : -1; // return ref ? ref->getID() : -1;
} //}
/* /*
TODO: consider checking item creation / experience gain just in case TODO: consider checking item creation / experience gain just in case
@ -1150,7 +1150,7 @@ static void manageInteractionEvent(color_ostream& out) {
df::report* lastAttackEvent = NULL; df::report* lastAttackEvent = NULL;
df::unit* lastAttacker = NULL; df::unit* lastAttacker = NULL;
df::unit* lastDefender = NULL; //df::unit* lastDefender = NULL;
unordered_map<int32_t,unordered_set<int32_t> > history; unordered_map<int32_t,unordered_set<int32_t> > history;
for ( ; a < reports.size(); a++ ) { for ( ; a < reports.size(); a++ ) {
df::report* report = reports[a]; df::report* report = reports[a];
@ -1164,7 +1164,7 @@ static void manageInteractionEvent(color_ostream& out) {
if ( attack ) { if ( attack ) {
lastAttackEvent = report; lastAttackEvent = report;
lastAttacker = NULL; lastAttacker = NULL;
lastDefender = NULL; //lastDefender = NULL;
} }
vector<df::unit*> relevantUnits = gatherRelevantUnits(out, lastAttackEvent, report); vector<df::unit*> relevantUnits = gatherRelevantUnits(out, lastAttackEvent, report);
InteractionData data = getAttacker(out, lastAttackEvent, lastAttacker, attack ? NULL : report, relevantUnits); InteractionData data = getAttacker(out, lastAttackEvent, lastAttacker, attack ? NULL : report, relevantUnits);
@ -1201,7 +1201,7 @@ static void manageInteractionEvent(color_ostream& out) {
} }
//out.print("%s,%d\n",__FILE__,__LINE__); //out.print("%s,%d\n",__FILE__,__LINE__);
lastAttacker = df::unit::find(data.attacker); lastAttacker = df::unit::find(data.attacker);
lastDefender = df::unit::find(data.defender); //lastDefender = df::unit::find(data.defender);
//fire event //fire event
for ( auto b = copy.begin(); b != copy.end(); b++ ) { for ( auto b = copy.begin(); b != copy.end(); b++ ) {
EventHandler handle = (*b).second; EventHandler handle = (*b).second;

@ -917,11 +917,13 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top)
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_petst, top)) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_petst, top))
{ {
df::viewscreen_petst::T_animal animal_default;
animal_default.unit = NULL;
switch (screen->mode) switch (screen->mode)
{ {
case df::viewscreen_petst::List: case df::viewscreen_petst::List:
if (!vector_get(screen->is_vermin, screen->cursor)) if (!vector_get(screen->is_vermin, screen->cursor))
return vector_get(screen->animal, screen->cursor).unit; return vector_get(screen->animal, screen->cursor, animal_default).unit;
return NULL; return NULL;
case df::viewscreen_petst::SelectTrainer: case df::viewscreen_petst::SelectTrainer:

@ -129,9 +129,6 @@ void DFHack::Job::deleteJobStruct(df::job *job, bool keptEverything)
bool DFHack::operator== (const df::job_item &a, const df::job_item &b) bool DFHack::operator== (const df::job_item &a, const df::job_item &b)
{ {
CHECK_NULL_POINTER(&a);
CHECK_NULL_POINTER(&b);
if (!(CMP(item_type) && CMP(item_subtype) && if (!(CMP(item_type) && CMP(item_subtype) &&
CMP(mat_type) && CMP(mat_index) && CMP(mat_type) && CMP(mat_index) &&
CMP(flags1.whole) && CMP(quantity) && CMP(vector_id) && CMP(flags1.whole) && CMP(quantity) && CMP(vector_id) &&
@ -152,9 +149,6 @@ bool DFHack::operator== (const df::job_item &a, const df::job_item &b)
bool DFHack::operator== (const df::job &a, const df::job &b) bool DFHack::operator== (const df::job &a, const df::job &b)
{ {
CHECK_NULL_POINTER(&a);
CHECK_NULL_POINTER(&b);
if (!(CMP(job_type) && CMP(job_subtype) && if (!(CMP(job_type) && CMP(job_subtype) &&
CMP(mat_type) && CMP(mat_index) && CMP(mat_type) && CMP(mat_index) &&
CMP(item_subtype) && CMP(item_category.whole) && CMP(item_subtype) && CMP(item_category.whole) &&
@ -514,7 +508,7 @@ bool DFHack::Job::removePostings(df::job *job, bool remove_all)
bool removed = false; bool removed = false;
if (!remove_all) if (!remove_all)
{ {
if (job->posting_index >= 0 && job->posting_index < world->jobs.postings.size()) if (job->posting_index >= 0 && size_t(job->posting_index) < world->jobs.postings.size())
{ {
world->jobs.postings[job->posting_index]->flags.bits.dead = true; world->jobs.postings[job->posting_index]->flags.bits.dead = true;
removed = true; removed = true;

@ -929,6 +929,7 @@ t_matpair MapExtras::BlockInfo::getBaseMaterial(df::tiletype tt, df::coord2d pos
case CONSTRUCTION: // just a fallback case CONSTRUCTION: // just a fallback
case MAGMA: case MAGMA:
case HFS: case HFS:
case UNDERWORLD_GATE:
// use generic 'rock' // use generic 'rock'
break; break;

@ -511,8 +511,8 @@ void PenArray::draw(unsigned int x, unsigned int y, unsigned int width, unsigned
{ {
for (unsigned int gridy = y; gridy < y + height; gridy++) for (unsigned int gridy = y; gridy < y + height; gridy++)
{ {
if (gridx >= gps->dimx || if (gridx >= unsigned(gps->dimx) ||
gridy >= gps->dimy || gridy >= unsigned(gps->dimy) ||
gridx - x + bufx >= dimx || gridx - x + bufx >= dimx ||
gridy - y + bufy >= dimy) gridy - y + bufy >= dimy)
continue; continue;

@ -1 +1 @@
Subproject commit 3c0bf63674d5430deadaf7befaec42f0ec1e8bc5 Subproject commit f3a49dbf40e4ff0d47f9631adc350196252df854

@ -130,7 +130,7 @@ public:
while (mc.testCoord(start)) while (mc.testCoord(start))
{ {
df::tiletype tt = mc.tiletypeAt(start); df::tiletype tt = mc.tiletypeAt(start);
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt)) if(DFHack::LowPassable(tt) || (juststarted && DFHack::HighPassable(tt)))
{ {
v.push_back(start); v.push_back(start);
juststarted = false; juststarted = false;

@ -73,42 +73,79 @@ 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()
# Tell CMake the source won't be available until build time. LIST(LENGTH PLUGIN_PROTOS NUM_PROTO)
SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTOCPP} PROPERTIES GENERATED 1) 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=${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}
)
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES}) IF(UNIX)
IDE_FOLDER(${PLUGIN_NAME} "Plugins") SET_SOURCE_FILES_PROPERTIES(${PLUGIN_PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()
ADD_DEPENDENCIES(${PLUGIN_NAME} dfhack-version) ADD_CUSTOM_TARGET(generate_proto_${PLUGIN_NAME} DEPENDS ${PLUGIN_PROTO_TMP_FILES})
# Make sure the source is generated before the executable builds. # Merge headers into sources
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto) 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})
LIST(LENGTH PLUGIN_PROTOBUFS NUM_PROTO)
IF(NUM_PROTO)
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()
ENDIF()
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
IDE_FOLDER(${PLUGIN_NAME} "Plugins")
IF(NUM_PROTO)
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto_${PLUGIN_NAME})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack protobuf-lite dfhack-version ${PLUGIN_LINK_LIBRARIES})
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}") ADD_DEPENDENCIES(${PLUGIN_NAME} dfhack-version)
# Make sure the source is generated before the executable builds.
ADD_DEPENDENCIES(${PLUGIN_NAME} generate_proto)
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 "")

@ -267,10 +267,8 @@ static bool skip_plant(const df::plant * plant, bool *restricted)
if (skip.food_trees || skip.cook_trees) if (skip.food_trees || skip.cook_trees)
{ {
df::material * mat; for (df::material * mat : plant_raw->material)
for (int idx = 0; idx < plant_raw->material.size(); idx++)
{ {
mat = plant_raw->material[idx];
if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW)) if (skip.food_trees && mat->flags.is_set(material_flags::EDIBLE_RAW))
{ {
if (restricted) if (restricted)

@ -624,7 +624,7 @@ static void init_state()
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str());
// Ensure that the labor is defined in the existing list // Ensure that the labor is defined in the existing list
if (labor >= 0 && labor <= labor_infos.size()) if (labor >= 0 && size_t(labor) < labor_infos.size())
{ {
// Link the labor treatment with the associated persistent data item // Link the labor treatment with the associated persistent data item
labor_infos[labor].set_config(*p); labor_infos[labor].set_config(*p);
@ -635,7 +635,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++) {
// Determine if the labor is already present. If so, exit the for loop // Determine if the labor is already present. If so, exit the for loop
if (labor_infos[i].config.isValid()) if (labor_infos[i].config.isValid())
@ -806,7 +806,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
// Scan the world and look for any citizens in the player's civilization. // Scan the world and look for any citizens in the player's civilization.
// Add these to the list of dwarves. // Add these to the list of dwarves.
// xxx Does it need to be ++i? // xxx Does it need to be ++i?
for (int i = 0; i < world->units.active.size(); ++i) for (size_t i = 0; i < world->units.active.size(); ++i)
{ {
df::unit* cre = world->units.active[i]; df::unit* cre = world->units.active[i];
if (Units::isCitizen(cre)) if (Units::isCitizen(cre))
@ -895,7 +895,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else else
{ {
int job = dwarfs[dwarf]->job.current_job->job_type; int job = dwarfs[dwarf]->job.current_job->job_type;
if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
dwarf_info[dwarf].state = dwarf_states[job]; dwarf_info[dwarf].state = dwarf_states[job];
else else
{ {
@ -960,7 +960,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
continue; continue;
// For every dwarf... // For every dwarf...
for(int dwarf = 0; dwarf < dwarfs.size(); dwarf++) for(size_t dwarf = 0; dwarf < dwarfs.size(); dwarf++)
{ {
if (!Units::isValidLabor(dwarfs[dwarf], labor)) if (!Units::isValidLabor(dwarfs[dwarf], labor))
continue; continue;
@ -1138,7 +1138,7 @@ command_result autohauler (color_ostream &out, std::vector <std::string> & param
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);
} }

@ -606,7 +606,7 @@ static void init_state()
{ {
string key = p->key(); string key = p->key();
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/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].is_exclusive = default_labor_infos[labor].is_exclusive; labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive;
@ -615,7 +615,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;
@ -960,7 +960,7 @@ static void assign_labor(unit_labor::unit_labor labor,
* Military and children/nobles will not have labors assigned. * Military and children/nobles will not have labors assigned.
* Dwarfs with the "health management" responsibility are always assigned DIAGNOSIS. * Dwarfs with the "health management" responsibility are always assigned DIAGNOSIS.
*/ */
for (int i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++) for (size_t i = 0; i < candidates.size() && labor_infos[labor].active_dwarfs < max_dwarfs; i++)
{ {
int dwarf = candidates[i]; int dwarf = candidates[i];
@ -1048,7 +1048,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
bool has_fishery = false; bool has_fishery = false;
bool trader_requested = false; bool trader_requested = false;
for (int i = 0; i < world->buildings.all.size(); ++i) for (size_t i = 0; i < world->buildings.all.size(); ++i)
{ {
df::building *build = world->buildings.all[i]; df::building *build = world->buildings.all[i];
auto type = build->getType(); auto type = build->getType();
@ -1074,7 +1074,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
} }
} }
for (int i = 0; i < world->units.active.size(); ++i) for (size_t i = 0; i < world->units.active.size(); ++i)
{ {
df::unit* cre = world->units.active[i]; df::unit* cre = world->units.active[i];
if (Units::isCitizen(cre)) if (Units::isCitizen(cre))
@ -1105,7 +1105,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
df::historical_figure* hf = df::historical_figure::find(dwarfs[dwarf]->hist_figure_id); df::historical_figure* hf = df::historical_figure::find(dwarfs[dwarf]->hist_figure_id);
if(hf!=NULL) //can be NULL. E.g. script created citizens if(hf!=NULL) //can be NULL. E.g. script created citizens
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)
@ -1140,7 +1140,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
// 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;
@ -1230,7 +1230,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
else else
{ {
int job = dwarfs[dwarf]->job.current_job->job_type; int job = dwarfs[dwarf]->job.current_job->job_type;
if (job >= 0 && job < ARRAY_COUNT(dwarf_states)) if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
dwarf_info[dwarf].state = dwarf_states[job]; dwarf_info[dwarf].state = dwarf_states[job];
else else
{ {
@ -1341,7 +1341,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
for (int i = 0; i < num_haulers; i++) for (int i = 0; i < num_haulers; i++)
{ {
assert(i < hauler_ids.size()); assert(size_t(i) < hauler_ids.size());
int dwarf = hauler_ids[i]; int dwarf = hauler_ids[i];
@ -1357,7 +1357,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
out.print("Dwarf %i \"%s\" assigned %s: hauler\n", dwarf, dwarfs[dwarf]->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, labor).c_str()); out.print("Dwarf %i \"%s\" assigned %s: hauler\n", dwarf, dwarfs[dwarf]->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, labor).c_str());
} }
for (int i = num_haulers; i < hauler_ids.size(); i++) for (size_t i = num_haulers; i < hauler_ids.size(); i++)
{ {
assert(i < hauler_ids.size()); assert(i < hauler_ids.size());
@ -1517,7 +1517,7 @@ command_result autolabor (color_ostream &out, std::vector <std::string> & parame
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);
} }

@ -69,12 +69,6 @@ struct MaterialDescriptor
} }
}; };
static command_result automaterial_cmd(color_ostream &out, vector <string> & parameters)
{
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{ {
return CR_OK; return CR_OK;
@ -1124,6 +1118,7 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
break; break;
case SELECT_SECOND: case SELECT_SECOND:
{
OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin); OutputString(COLOR_GREEN, x, y, "Choose second corner", true, left_margin);
int32_t curr_x, curr_y, curr_z; int32_t curr_x, curr_y, curr_z;
@ -1137,6 +1132,11 @@ struct jobutils_hook : public df::viewscreen_dwarfmodest
int cx = box_first.x; int cx = box_first.x;
int cy = box_first.y; int cy = box_first.y;
OutputString(COLOR_BROWN, cx, cy, "X", false, 0, 0, true /* map */); OutputString(COLOR_BROWN, cx, cy, "X", false, 0, 0, true /* map */);
break;
}
default:
break;
} }
OutputString(COLOR_BROWN, x, ++y, "Ignore Building Restrictions", true, left_margin); OutputString(COLOR_BROWN, x, ++y, "Ignore Building Restrictions", true, left_margin);

@ -106,9 +106,9 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
{ {
if (! b) if (! b)
return " "; return " ";
bool at_nw_corner = x == b->x1 && y == b->y1; bool at_nw_corner = int32_t(x) == b->x1 && int32_t(y) == b->y1;
bool at_se_corner = x == b->x2 && y == b->y2; bool at_se_corner = int32_t(x) == b->x2 && int32_t(y) == b->y2;
bool at_center = x == b->centerx && y == b->centery; bool at_center = int32_t(x) == b->centerx && int32_t(y) == b->centery;
pair<uint32_t, uint32_t> size = get_building_size(b); pair<uint32_t, uint32_t> size = get_building_size(b);
stringstream out;// = stringstream(); stringstream out;// = stringstream();
switch(b->getType()) switch(b->getType())
@ -227,7 +227,10 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
return "wy"; return "wy";
case workshop_type::Dyers: case workshop_type::Dyers:
return "wd"; return "wd";
case workshop_type::Kennels:
return "k";
case workshop_type::Custom: case workshop_type::Custom:
case workshop_type::Tool:
//can't do anything with custom workshop //can't do anything with custom workshop
return "`"; return "`";
} }
@ -261,6 +264,8 @@ string get_tile_build(uint32_t x, uint32_t y, df::building* b)
case building_type::Construction: case building_type::Construction:
switch (((df::building_constructionst*) b)->type) switch (((df::building_constructionst*) b)->type)
{ {
case construction_type::NONE:
return "`";
case construction_type::Fortification: case construction_type::Fortification:
return "CF"; return "CF";
case construction_type::Wall: case construction_type::Wall:
@ -482,7 +487,7 @@ string get_tile_place(uint32_t x, uint32_t y, df::building* b)
{ {
if (! b || b->getType() != building_type::Stockpile) if (! b || b->getType() != building_type::Stockpile)
return " "; return " ";
if (b->x1 != x || b->y1 != y) if (b->x1 != int32_t(x) || b->y1 != int32_t(y))
return "`"; return "`";
pair<uint32_t, uint32_t> size = get_building_size(b); pair<uint32_t, uint32_t> size = get_building_size(b);
df::building_stockpilest* sp = (df::building_stockpilest*) b; df::building_stockpilest* sp = (df::building_stockpilest*) b;

@ -287,7 +287,7 @@ struct work_hook : df::building_workshopst{
} }
int w=db->x2-db->x1+1; int w=db->x2-db->x1+1;
std::vector<graphic_tile> &cur_frame=def->frames[frame]; std::vector<graphic_tile> &cur_frame=def->frames[frame];
for(int i=0;i<cur_frame.size();i++) for(size_t i=0;i<cur_frame.size();i++)
{ {
if(cur_frame[i].tile>=0) if(cur_frame[i].tile>=0)
{ {

@ -17,7 +17,7 @@ void enable_quickfort_fn(pair<const df::building_type, bool>& pair) { pair.secon
* Material Choice Screen * Material Choice Screen
*/ */
static std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); } std::string material_to_string_fn(DFHack::MaterialInfo m) { return m.toString(); }
bool ItemFilter::matchesMask(DFHack::MaterialInfo &mat) bool ItemFilter::matchesMask(DFHack::MaterialInfo &mat)
{ {
@ -131,7 +131,7 @@ void ItemFilter::clear()
materials.clear(); materials.clear();
} }
static DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; } DFHack::MaterialInfo &material_info_identity_fn(DFHack::MaterialInfo &m) { return m; }
ViewscreenChooseMaterial::ViewscreenChooseMaterial(ItemFilter *filter) ViewscreenChooseMaterial::ViewscreenChooseMaterial(ItemFilter *filter)
{ {
@ -386,7 +386,7 @@ void RoomMonitor::reset(color_ostream &out)
} }
static void delete_item_fn(df::job_item *x) { delete x; } void delete_item_fn(df::job_item *x) { delete x; }
// START Planning // START Planning
@ -654,3 +654,12 @@ void Planner::cycleDefaultQuality(df::building_type type)
if (*quality == item_quality::Artifact) if (*quality == item_quality::Artifact)
(*quality) = item_quality::Ordinary; (*quality) = item_quality::Ordinary;
} }
map<df::building_type, bool> planmode_enabled, saved_planmodes;
bool show_debugging = false;
bool show_help = false;
Planner planner;
RoomMonitor roomMonitor;

@ -65,7 +65,7 @@ struct MaterialDescriptor
#define MAX_MATERIAL 21 #define MAX_MATERIAL 21
#define SIDEBAR_WIDTH 30 #define SIDEBAR_WIDTH 30
static bool canReserveRoom(df::building *building) static inline bool canReserveRoom(df::building *building)
{ {
if (!building) if (!building)
return false; return false;
@ -76,7 +76,7 @@ static bool canReserveRoom(df::building *building)
return building->is_room; return building->is_room;
} }
static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit) static inline std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
{ {
std::vector<Units::NoblePosition> np; std::vector<Units::NoblePosition> np;
Units::getNoblePositions(&np, unit); Units::getNoblePositions(&np, unit);
@ -92,19 +92,19 @@ static std::vector<Units::NoblePosition> getUniqueNoblePositions(df::unit *unit)
return np; return np;
} }
static void delete_item_fn(df::job_item *x); void delete_item_fn(df::job_item *x);
static MaterialInfo &material_info_identity_fn(MaterialInfo &m); MaterialInfo &material_info_identity_fn(MaterialInfo &m);
static map<df::building_type, bool> planmode_enabled, saved_planmodes; extern map<df::building_type, bool> planmode_enabled, saved_planmodes;
void enable_quickfort_fn(pair<const df::building_type, bool>& pair); void enable_quickfort_fn(pair<const df::building_type, bool>& pair);
void debug(const std::string &msg); void debug(const std::string &msg);
static std::string material_to_string_fn(MaterialInfo m); std::string material_to_string_fn(MaterialInfo m);
static bool show_debugging = false; extern bool show_debugging;
static bool show_help = false; extern bool show_help;
struct ItemFilter struct ItemFilter
{ {
@ -387,7 +387,7 @@ class Planner
public: public:
bool in_dummmy_screen; bool in_dummmy_screen;
Planner() : quickfort_mode(false), in_dummmy_screen(false) { } Planner() : in_dummmy_screen(false), quickfort_mode(false) { }
bool isPlanableBuilding(const df::building_type type) const bool isPlanableBuilding(const df::building_type type) const
{ {
@ -491,8 +491,8 @@ private:
} }
}; };
static Planner planner; extern Planner planner;
static RoomMonitor roomMonitor; extern RoomMonitor roomMonitor;
#endif #endif

@ -194,7 +194,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
df::interface_key last_token = get_string_key(input); df::interface_key last_token = get_string_key(input);
if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A058) if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A058)
{ {
int selection = last_token - interface_key::STRING_A048; size_t selection = last_token - interface_key::STRING_A048;
if (np.size() < selection) if (np.size() < selection)
return false; return false;
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code); roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code);
@ -317,7 +317,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
int y = 24; int y = 24;
OutputString(COLOR_BROWN, x, y, "DFHack", true, left_margin); OutputString(COLOR_BROWN, x, y, "DFHack", true, left_margin);
OutputString(COLOR_WHITE, x, y, "Auto-allocate to:", true, left_margin); OutputString(COLOR_WHITE, x, y, "Auto-allocate to:", true, left_margin);
for (int i = 0; i < np.size() && i < 9; i++) for (size_t i = 0; i < np.size() && i < 9; i++)
{ {
bool enabled = (roomMonitor.getReservedNobleCode(world->selected_building->id) bool enabled = (roomMonitor.getReservedNobleCode(world->selected_building->id)
== np[i].position->code); == np[i].position->code);

@ -227,7 +227,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
{ {
if(verbose) if(verbose)
out << "---Biome: " << i; out << "---Biome: " << i;
if(!all_biomes && i!=biome) if(!all_biomes && uint32_t(i)!=biome)
{ {
if(verbose) if(verbose)
out << "-skipping" << endl; out << "-skipping" << endl;
@ -257,7 +257,7 @@ command_result changelayer (color_ostream &out, std::vector <std::string> & para
out << "geoindex: " << geoindex << endl; out << "geoindex: " << geoindex << endl;
bool skip = false; bool skip = false;
for(int g=0; g<v_geoprocessed.size(); g++) for(int g=0; size_t(g)<v_geoprocessed.size(); g++)
{ {
if(v_geoprocessed.at(g)==geoindex) if(v_geoprocessed.at(g)==geoindex)
{ {

@ -56,7 +56,7 @@ public:
df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); } df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); }
std::string getFocusString() { return "commandprompt"; } std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):is_response(false), submitted(false) viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false)
{ {
show_fps=gps->display_frames; show_fps=gps->display_frames;
gps->display_frames=0; gps->display_frames=0;
@ -172,7 +172,7 @@ void viewscreen_commandpromptst::render()
if(cursor_pos < (dim.x - 10)) if(cursor_pos < (dim.x - 10))
{ {
Screen::paintString(Screen::Pen(' ', 7, 0), 10,0 , entry); Screen::paintString(Screen::Pen(' ', 7, 0), 10,0 , entry);
if (entry.size() > dim.x - 10) if (int16_t(entry.size()) > dim.x - 10)
Screen::paintTile(Screen::Pen('\032', 7, 0), dim.x - 1, 0); Screen::paintTile(Screen::Pen('\032', 7, 0), dim.x - 1, 0);
if (cursor != " ") if (cursor != " ")
Screen::paintString(Screen::Pen(' ', 10, 0), 10 + cursor_pos, 0, cursor); Screen::paintString(Screen::Pen(' ', 10, 0), 10 + cursor_pos, 0, cursor);
@ -243,7 +243,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
entry.erase(cursor_pos - 1, 1); entry.erase(cursor_pos - 1, 1);
cursor_pos--; cursor_pos--;
} }
if(cursor_pos > entry.size()) if(size_t(cursor_pos) > entry.size())
cursor_pos = entry.size(); cursor_pos = entry.size();
continue; continue;
} }
@ -260,7 +260,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
if(events->count(interface_key::CURSOR_RIGHT)) if(events->count(interface_key::CURSOR_RIGHT))
{ {
cursor_pos++; cursor_pos++;
if (cursor_pos > entry.size()) if (size_t(cursor_pos) > entry.size())
cursor_pos = entry.size(); cursor_pos = entry.size();
} }
else if(events->count(interface_key::CURSOR_LEFT)) else if(events->count(interface_key::CURSOR_LEFT))
@ -294,10 +294,10 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
} }
else if(events->count(interface_key::CURSOR_DOWN)) else if(events->count(interface_key::CURSOR_DOWN))
{ {
if (history_idx < command_history.size() - 1) if (size_t(history_idx) < command_history.size() - 1)
{ {
history_idx++; history_idx++;
if (history_idx >= command_history.size()) if (size_t(history_idx) >= command_history.size())
history_idx = command_history.size() - 1; history_idx = command_history.size() - 1;
entry = get_entry(); entry = get_entry();
cursor_pos = entry.size(); cursor_pos = entry.size();

@ -92,7 +92,7 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it
return false; return false;
// if we asked to make shoes and we got twice as many as we asked, then we're okay // if we asked to make shoes and we got twice as many as we asked, then we're okay
// otherwise, make a second set because shoes are normally made in pairs // otherwise, make a second set because shoes are normally made in pairs
if (is_shoes && out_items.size() == prod->count * 2) if (is_shoes && out_items.size() == size_t(prod->count * 2))
is_shoes = false; is_shoes = false;
MapExtras::MapCache mc; MapExtras::MapCache mc;

@ -812,14 +812,14 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
int x = 0,mx = 16; int x = 0,mx = 16;
if(bx == 0) if(bx == 0)
x = 1; x = 1;
if(bx == x_max - 1) if(int(bx) == x_max - 1)
mx = 15; mx = 15;
for(; x < mx; x++) for(; x < mx; x++)
{ {
int y = 0,my = 16; int y = 0,my = 16;
if(by == 0) if(by == 0)
y = 1; y = 1;
if(by == y_max - 1) if(int(by) == y_max - 1)
my = 15; my = 15;
for(; y < my; y++) for(; y < my; y++)
{ {
@ -838,8 +838,8 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
if(dm[y][x]) if(dm[y][x])
{ {
if(what == EXPLO_ALL if(what == EXPLO_ALL
|| des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED || (des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED)
|| des.bits.hidden && what == EXPLO_HIDDEN) || (des.bits.hidden && what == EXPLO_HIDDEN))
{ {
des.bits.dig = tile_dig_designation::Default; des.bits.dig = tile_dig_designation::Default;
} }
@ -948,7 +948,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
int which; int which;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = (4*x + y) % 5; which = (4*x + y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5[which], stamp_pattern(x,y_max - 1 - y, z_level, diag5[which],
@ -961,7 +961,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
int which; int which;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = (4*x + 1000-y) % 5; which = (4*x + 1000-y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which], stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which],
@ -975,7 +975,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
{ {
which = x % 3; which = x % 3;
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
stamp_pattern(x, y, z_level, ladder[which], stamp_pattern(x, y, z_level, ladder[which],
how, what, x_max, y_max); how, what, x_max, y_max);
@ -985,7 +985,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
else if(how == EXPLO_LADDERR) else if(how == EXPLO_LADDERR)
{ {
int which; int which;
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
which = y % 3; which = y % 3;
for(uint32_t x = 0; x < x_max; x++) for(uint32_t x = 0; x < x_max; x++)
@ -1023,7 +1023,7 @@ command_result digexp (color_ostream &out, vector <string> & parameters)
} }
else for(uint32_t x = 0; x < x_max; x++) else for(uint32_t x = 0; x < x_max; x++)
{ {
for(int32_t y = 0 ; y < y_max; y++) for(uint32_t y = 0 ; y < y_max; y++)
{ {
stamp_pattern(x, y, z_level, all_tiles, stamp_pattern(x, y, z_level, all_tiles,
how, what, x_max, y_max); how, what, x_max, y_max);
@ -1075,7 +1075,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1) if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
{ {
con.printerr("I won't dig the borders. That would be cheating!\n"); con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE; return CR_FAILURE;
@ -1136,10 +1136,10 @@ command_result digv (color_ostream &out, vector <string> & parameters)
{ {
MCache->setTagAt(current, 1); MCache->setTagAt(current, 1);
if(current.x < tx_max - 2) if(current.x < int32_t(tx_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
@ -1153,7 +1153,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
if(current.x > 1) if(current.x > 1)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
@ -1178,7 +1178,7 @@ command_result digv (color_ostream &out, vector <string> & parameters)
des.bits.dig = tile_dig_designation::DownStair; des.bits.dig = tile_dig_designation::DownStair;
} }
if(current.z < z_max - 1 && above && vmat_plus == vmat2) if(current.z < int32_t(z_max) - 1 && above && vmat_plus == vmat2)
{ {
flood.push(current+ 1); flood.push(current+ 1);
@ -1262,7 +1262,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1) if(xy.x == 0 || xy.x == int32_t(tx_max) - 1 || xy.y == 0 || xy.y == int32_t(ty_max) - 1)
{ {
con.printerr("I won't dig the borders. That would be cheating!\n"); con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE; return CR_FAILURE;
@ -1320,10 +1320,10 @@ command_result digl (color_ostream &out, vector <string> & parameters)
if(MCache->testCoord(current)) if(MCache->testCoord(current))
{ {
MCache->setTagAt(current, 1); MCache->setTagAt(current, 1);
if(current.x < tx_max - 2) if(current.x < int32_t(tx_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x + 1, current.y + 1, current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
@ -1337,7 +1337,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
if(current.x > 1) if(current.x > 1)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y, current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y, current.z));
if(current.y < ty_max - 2) if(current.y < int32_t(ty_max) - 2)
{ {
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x - 1, current.y + 1, current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z)); flood.push(DFHack::DFCoord(current.x, current.y + 1, current.z));
@ -1389,7 +1389,7 @@ command_result digl (color_ostream &out, vector <string> & parameters)
des.bits.dig = tile_dig_designation::DownStair; des.bits.dig = tile_dig_designation::DownStair;
} }
if(current.z < z_max - 1 && above && vmat_plus == -1 && bmat_plus == basemat) if(current.z < int32_t(z_max) - 1 && above && vmat_plus == -1 && bmat_plus == basemat)
{ {
flood.push(current+ 1); flood.push(current+ 1);
@ -1438,7 +1438,7 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
uint32_t targetDigType; int32_t targetDigType;
if ( parameters.size() == 1 ) if ( parameters.size() == 1 )
{ {
string parameter = parameters[0]; string parameter = parameters[0];
@ -1526,7 +1526,6 @@ command_result digtype (color_ostream &out, vector <string> & parameters)
continue; continue;
//designate it for digging //designate it for digging
df::tile_designation des = mCache->designationAt(current);
if ( !mCache->testCoord(current) ) if ( !mCache->testCoord(current) )
{ {
out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z); out.printerr("testCoord failed at (%d,%d,%d)\n", x, y, z);

@ -137,7 +137,7 @@ void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt,
uint32_t xMax,yMax,zMax; uint32_t xMax,yMax,zMax;
Maps::getSize(xMax,yMax,zMax); Maps::getSize(xMax,yMax,zMax);
if ( pt.x == 0 || pt.y == 0 || pt.x+1 == xMax*16 || pt.y+1 == yMax*16 ) if ( pt.x == 0 || pt.y == 0 || pt.x+1 == int32_t(xMax)*16 || pt.y+1 == int32_t(yMax)*16 )
return; return;
if ( jobLocations.find(pt) != jobLocations.end() ) { if ( jobLocations.find(pt) != jobLocations.end() ) {
return; return;

@ -68,8 +68,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
} }
//out.print("first important edge: (%d,%d,%d) -> (%d,%d,%d)\n", pt1.x,pt1.y,pt1.z, pt2.x,pt2.y,pt2.z); //out.print("first important edge: (%d,%d,%d) -> (%d,%d,%d)\n", pt1.x,pt1.y,pt1.z, pt2.x,pt2.y,pt2.z);
int32_t jobId = -1;
df::map_block* block1 = Maps::getTileBlock(pt1); df::map_block* block1 = Maps::getTileBlock(pt1);
df::map_block* block2 = Maps::getTileBlock(pt2); df::map_block* block2 = Maps::getTileBlock(pt2);
bool passable1 = block1->walkable[pt1.x&0xF][pt1.y&0xF]; bool passable1 = block1->walkable[pt1.x&0xF][pt1.y&0xF];
@ -111,7 +109,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
building->jobs.clear(); building->jobs.clear();
building->jobs.push_back(job); building->jobs.push_back(job);
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
job->completion_timer = abilities.jobDelay[CostDimension::DestroyBuilding]; job->completion_timer = abilities.jobDelay[CostDimension::DestroyBuilding];
} else { } else {
df::tiletype* type1 = Maps::getTileType(pt1); df::tiletype* type1 = Maps::getTileType(pt1);
@ -136,7 +133,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->job.hunt_target = NULL; firstInvader->job.hunt_target = NULL;
firstInvader->job.destroy_target = NULL; firstInvader->job.destroy_target = NULL;
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
df::construction* constr = df::construction::find(pt2); df::construction* constr = df::construction::find(pt2);
bool smooth = constr != NULL && constr->item_type != df::enums::item_type::BOULDER; bool smooth = constr != NULL && constr->item_type != df::enums::item_type::BOULDER;
if ( smooth ) if ( smooth )
@ -204,7 +200,6 @@ int32_t assignJob(color_ostream& out, Edge firstImportantEdge, unordered_map<df:
firstInvader->path.path.y.clear(); firstInvader->path.path.y.clear();
firstInvader->path.path.z.clear(); firstInvader->path.path.z.clear();
Job::linkIntoWorld(job); Job::linkIntoWorld(job);
jobId = job->id;
job->completion_timer = abilities.jobDelay[CostDimension::Dig]; job->completion_timer = abilities.jobDelay[CostDimension::Dig];
//TODO: test if he already has a pick //TODO: test if he already has a pick

@ -246,7 +246,7 @@ cost_t getEdgeCost(color_ostream& out, df::coord pt1, df::coord pt2, DigAbilitie
bool forbidden = false; bool forbidden = false;
if ( building1 && building1->getType() == df::building_type::Hatch ) { if ( building1 && building1->getType() == df::building_type::Hatch ) {
df::building_hatchst* hatch = (df::building_hatchst*)building1; df::building_hatchst* hatch = (df::building_hatchst*)building1;
if ( hatch->door_flags.bits.forbidden || hatch->door_flags.bits.closed && hatch->door_flags.bits.operated_by_mechanisms ) if ( hatch->door_flags.bits.forbidden || ( hatch->door_flags.bits.closed && hatch->door_flags.bits.operated_by_mechanisms ) )
forbidden = true; forbidden = true;
} }

@ -370,7 +370,7 @@ void AnimalHospital::processPatients(color_ostream &out) {
// Where the magic happens // Where the magic happens
for (vector<Patient*>::iterator patient = this->accepted_patients.begin(); patient != this->accepted_patients.end(); patient++) { for (vector<Patient*>::iterator patient = this->accepted_patients.begin(); patient != this->accepted_patients.end(); patient++) {
int id = (*patient)->getID(); int id = (*patient)->getID();
df::unit * real_unit; df::unit * real_unit = nullptr;
// Appears the health bits can get freed/realloced too -_-;, Find the unit from the main // Appears the health bits can get freed/realloced too -_-;, Find the unit from the main
// index and check it there. // index and check it there.
auto units = world->units.all; auto units = world->units.all;
@ -383,7 +383,7 @@ void AnimalHospital::processPatients(color_ostream &out) {
} }
// Check to make sure the unit hasn't expired before assigning a job, or if they've been healed // Check to make sure the unit hasn't expired before assigning a job, or if they've been healed
if (real_unit->flags1.bits.dead || !real_unit->health->flags.bits.needs_healthcare) { if (!real_unit || real_unit->flags1.bits.dead || !real_unit->health->flags.bits.needs_healthcare) {
// discharge the patient from the hospital // discharge the patient from the hospital
this->dischargePatient(*patient, out); this->dischargePatient(*patient, out);
return; return;
@ -459,7 +459,7 @@ bool compareAnimalHospitalZones(df::building * hospital1, df::building * hospita
hospital1->x2 == hospital2->x2 && hospital1->x2 == hospital2->x2 &&
hospital1->y1 == hospital2->y1 && hospital1->y1 == hospital2->y1 &&
hospital1->y2 == hospital2->y2 && hospital1->y2 == hospital2->y2 &&
hospital1->z == hospital1->z) { hospital1->z == hospital2->z) {
return true; return true;
} }
@ -733,16 +733,12 @@ processUnits:
// The master list handles all patients which are accepted // The master list handles all patients which are accepted
// Check if this is a unit we're already aware of // Check if this is a unit we're already aware of
bool patient_accepted = false; for (auto animal_hospital : animal_hospital_zones) {
for (vector<AnimalHospital*>::iterator animal_hospital = animal_hospital_zones.begin(); animal_hospital != animal_hospital_zones.end();) { if (animal_hospital->acceptPatient(unit->id, out)) {
if ((*animal_hospital)->acceptPatient(unit->id, out)) { out.print("Accepted patient %d at hospital %d\n", unit->id, animal_hospital->getID());
out.print("Accepted patient %d at hospital %d\n", unit->id, (*animal_hospital)->getID());
patient_accepted = true;
tracked_units.push_back(unit->id); tracked_units.push_back(unit->id);
break; break;
} }
} }
} }
} }

@ -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;
@ -185,9 +185,7 @@ namespace embark_assist {
bool found; bool found;
while (true) { while (true) {
if (!fgets(line, count, infile) || line[0] != '[') {
fgets(line, count, infile);
if (line[0] != '[') {
out.printerr("Failed to find token start '[' at line %i\n", static_cast<int8_t>(i)); out.printerr("Failed to find token start '[' at line %i\n", static_cast<int8_t>(i));
fclose(infile); fclose(infile);
return; return;
@ -205,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' &&
@ -251,14 +249,17 @@ namespace embark_assist {
i = first_fields; i = first_fields;
while (true) { while (true) {
fgets(line, count, infile); if (!fgets(line, count, infile))
{
break;
}
for (int k = 1; k < count; k++) { for (int k = 1; k < count; k++) {
if (line[k] == ':') { if (line[k] == ':') {
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' &&
@ -1333,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;
@ -1342,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);
} }
} }

@ -89,7 +89,6 @@ namespace embark_assist{
void ViewscreenHelpUi::render() { void ViewscreenHelpUi::render() {
color_ostream_proxy out(Core::getInstance().getConsole()); color_ostream_proxy out(Core::getInstance().getConsole());
auto screen_size = DFHack::Screen::getWindowSize();
Screen::Pen pen(' ', COLOR_WHITE); Screen::Pen pen(' ', COLOR_WHITE);
Screen::Pen site_pen = Screen::Pen(' ', COLOR_YELLOW, COLOR_BLACK, false); Screen::Pen site_pen = Screen::Pen(' ', COLOR_YELLOW, COLOR_BLACK, false);
Screen::Pen pen_lr(' ', COLOR_LIGHTRED); Screen::Pen pen_lr(' ', COLOR_LIGHTRED);

@ -41,7 +41,7 @@ namespace embark_assist {
uint16_t aquifer_count = 0; uint16_t aquifer_count = 0;
bool river_found = false; bool river_found = false;
bool waterfall_found = false; bool waterfall_found = false;
uint16_t river_elevation; uint16_t river_elevation = 0xffff;
uint16_t elevation = mlt->at(start_x).at(start_y).elevation; uint16_t elevation = mlt->at(start_x).at(start_y).elevation;
bool clay_found = false; bool clay_found = false;
bool sand_found = false; bool sand_found = false;
@ -394,7 +394,6 @@ namespace embark_assist {
df::world_data *world_data = world->world_data; df::world_data *world_data = world->world_data;
embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y); embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y);
const uint16_t embark_size = finder->x_dim * finder->y_dim; const uint16_t embark_size = finder->x_dim * finder->y_dim;
uint16_t count;
bool found; bool found;
if (tile->surveyed) { if (tile->surveyed) {
@ -750,7 +749,6 @@ namespace embark_assist {
finder->mineral_1 != -1 || finder->mineral_1 != -1 ||
finder->mineral_2 != -1 || finder->mineral_2 != -1 ||
finder->mineral_3 != -1) { finder->mineral_3 != -1) {
count = 0;
bool metal_1 = finder->metal_1 == -1; bool metal_1 = finder->metal_1 == -1;
bool metal_2 = finder->metal_2 == -1; bool metal_2 = finder->metal_2 == -1;
bool metal_3 = finder->metal_3 == -1; bool metal_3 = finder->metal_3 == -1;
@ -1104,7 +1102,6 @@ namespace embark_assist {
finder->mineral_1 != -1 || finder->mineral_1 != -1 ||
finder->mineral_2 != -1 || finder->mineral_2 != -1 ||
finder->mineral_3 != -1) { finder->mineral_3 != -1) {
count = 0;
bool metal_1 = finder->metal_1 == -1; bool metal_1 = finder->metal_1 == -1;
bool metal_2 = finder->metal_2 == -1; bool metal_2 = finder->metal_2 == -1;
bool metal_3 = finder->metal_3 == -1; bool metal_3 = finder->metal_3 == -1;
@ -1285,7 +1282,7 @@ uint16_t embark_assist::matcher::find(embark_assist::defs::match_iterators *iter
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
uint16_t x_end; uint16_t x_end;
uint16_t y_end; uint16_t y_end;
bool turn; bool turn = false;
uint16_t count; uint16_t count;
uint16_t preliminary_matches; uint16_t preliminary_matches;

@ -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) {

@ -1002,7 +1002,7 @@ void embark_assist::survey::survey_embark(embark_assist::defs::mid_level_tiles *
// color_ostream_proxy out(Core::getInstance().getConsole()); // color_ostream_proxy out(Core::getInstance().getConsole());
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
int16_t elevation; int16_t elevation = 0;
uint16_t x = screen->location.region_pos.x; uint16_t x = screen->location.region_pos.x;
uint16_t y = screen->location.region_pos.y; uint16_t y = screen->location.region_pos.y;
bool river_found = false; bool river_found = false;

@ -268,6 +268,8 @@ public:
case df::interface_key::CURSOR_DOWNRIGHT_FAST: case df::interface_key::CURSOR_DOWNRIGHT_FAST:
is_motion = true; is_motion = true;
break; break;
default:
break;
} }
if (is_motion && !moved_position) if (is_motion && !moved_position)
{ {
@ -284,7 +286,7 @@ protected:
// Used for event handling // Used for event handling
int prev_x; int prev_x;
int prev_y; int prev_y;
bool prev_lbut; int8_t prev_lbut;
// Used for controls // Used for controls
bool base_max_x; bool base_max_x;
bool base_max_y; bool base_max_y;
@ -304,7 +306,7 @@ protected:
return in_local_move || in_local_edge_resize_x || in_local_edge_resize_y || return in_local_move || in_local_edge_resize_x || in_local_edge_resize_y ||
in_local_corner_resize; in_local_corner_resize;
} }
void lbut_press(start_sitest* screen, bool pressed, int x, int y) void lbut_press(start_sitest* screen, int8_t pressed, int x, int y)
{ {
GET_EMBARK_POS(screen, x1, x2, y1, y2, width, height); GET_EMBARK_POS(screen, x1, x2, y1, y2, width, height);
in_local_move = in_local_edge_resize_x = in_local_edge_resize_y = in_local_move = in_local_edge_resize_x = in_local_edge_resize_y =
@ -460,7 +462,7 @@ public:
:EmbarkTool(), :EmbarkTool(),
prev_x(0), prev_x(0),
prev_y(0), prev_y(0),
prev_lbut(false), prev_lbut(0),
base_max_x(false), base_max_x(false),
base_max_y(false), base_max_y(false),
in_local_move(false), in_local_move(false),
@ -681,7 +683,7 @@ struct choose_start_site_hook : df::viewscreen_choose_start_sitest
if (parts.size()) if (parts.size())
{ {
std::string label = join_strings(", ", parts); std::string label = join_strings(", ", parts);
if (label.size() > dim.x - x - 1) if (int16_t(label.size()) > dim.x - x - 1)
{ {
label.resize(dim.x - x - 1 - 3); label.resize(dim.x - x - 1 - 3);
label.append("..."); label.append("...");

@ -78,17 +78,6 @@ struct ReactionInfo {
static std::map<std::string, ReactionInfo> reactions; static std::map<std::string, ReactionInfo> reactions;
static std::map<df::reaction_product*, ProductInfo*> products; static std::map<df::reaction_product*, ProductInfo*> products;
static ReactionInfo *find_reaction(const std::string &name)
{
auto it = reactions.find(name);
return (it != reactions.end()) ? &it->second : NULL;
}
static bool is_lua_hook(const std::string &name)
{
return name.size() > 9 && memcmp(name.data(), "LUA_HOOK_", 9) == 0;
}
/* /*
* Hooks * Hooks
*/ */
@ -158,12 +147,12 @@ void ev_mng_jobCompleted(color_ostream& out, void* job)
} }
void ev_mng_unitDeath(color_ostream& out, void* ptr) void ev_mng_unitDeath(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onUnitDeath(out,myId); onUnitDeath(out,myId);
} }
void ev_mng_itemCreate(color_ostream& out, void* ptr) void ev_mng_itemCreate(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onItemCreated(out,myId); onItemCreated(out,myId);
} }
void ev_mng_construction(color_ostream& out, void* ptr) void ev_mng_construction(color_ostream& out, void* ptr)
@ -178,12 +167,12 @@ void ev_mng_syndrome(color_ostream& out, void* ptr)
} }
void ev_mng_invasion(color_ostream& out, void* ptr) void ev_mng_invasion(color_ostream& out, void* ptr)
{ {
int32_t myId=*(int32_t*)&ptr; int32_t myId=(int32_t)(intptr_t)ptr;
onInvasion(out,myId); onInvasion(out,myId);
} }
static void ev_mng_building(color_ostream& out, void* ptr) static void ev_mng_building(color_ostream& out, void* ptr)
{ {
int32_t id = *((int32_t*)ptr); int32_t id=(int32_t)(intptr_t)ptr;
onBuildingCreatedDestroyed(out, id); onBuildingCreatedDestroyed(out, id);
} }
static void ev_mng_inventory(color_ostream& out, void* ptr) static void ev_mng_inventory(color_ostream& out, void* ptr)
@ -204,7 +193,7 @@ static void ev_mng_inventory(color_ostream& out, void* ptr)
onInventoryChange(out,unitId,itemId,item_old,item_new); onInventoryChange(out,unitId,itemId,item_old,item_new);
} }
static void ev_mng_report(color_ostream& out, void* ptr) { static void ev_mng_report(color_ostream& out, void* ptr) {
onReport(out,*(int32_t*)&ptr); onReport(out,(int32_t)(intptr_t)ptr);
} }
static void ev_mng_unitAttack(color_ostream& out, void* ptr) { static void ev_mng_unitAttack(color_ostream& out, void* ptr) {
EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr; EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr;

@ -120,6 +120,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
df::unit_action *action = unit->actions[i]; df::unit_action *action = unit->actions[i];
switch (action->type) switch (action->type)
{ {
case unit_action_type::None:
break;
case unit_action_type::Move: case unit_action_type::Move:
action->data.move.timer = 1; action->data.move.timer = 1;
break; break;
@ -171,6 +173,13 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
case unit_action_type::SuckBlood: case unit_action_type::SuckBlood:
action->data.suckblood.timer = 1; action->data.suckblood.timer = 1;
break; break;
case unit_action_type::Jump:
case unit_action_type::ReleaseTerrain:
case unit_action_type::Parry:
case unit_action_type::Block:
case unit_action_type::HoldItem:
case unit_action_type::ReleaseItem:
break;
} }
} }
} }

@ -215,7 +215,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x - 1, xy.y, xy.z)); flood.push(DFCoord(xy.x - 1, xy.y, xy.z));
} }
if (xy.x < tx_max - 1) if (xy.x < int32_t(tx_max) - 1)
{ {
flood.push(DFCoord(xy.x + 1, xy.y, xy.z)); flood.push(DFCoord(xy.x + 1, xy.y, xy.z));
} }
@ -223,7 +223,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x, xy.y - 1, xy.z)); flood.push(DFCoord(xy.x, xy.y - 1, xy.z));
} }
if (xy.y < ty_max - 1) if (xy.y < int32_t(ty_max) - 1)
{ {
flood.push(DFCoord(xy.x, xy.y + 1, xy.z)); flood.push(DFCoord(xy.x, xy.y + 1, xy.z));
} }
@ -234,7 +234,7 @@ command_result filltraffic(color_ostream &out, std::vector<std::string> & params
{ {
flood.push(DFCoord(xy.x, xy.y, xy.z - 1)); flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
} }
if (xy.z < z_max && HighPassable(tt)) if (xy.z < int32_t(z_max) && HighPassable(tt))
{ {
flood.push(DFCoord(xy.x, xy.y, xy.z + 1)); flood.push(DFCoord(xy.x, xy.y, xy.z + 1));
} }
@ -337,11 +337,11 @@ command_result setAllMatching(color_ostream &out, checkTile checkProc,
out.print("Setting traffic...\n"); out.print("Setting traffic...\n");
//Loop through every single tile //Loop through every single tile
for(uint32_t x = minCoord.x; x <= maxCoord.x; x++) for(int32_t x = minCoord.x; x <= maxCoord.x; x++)
{ {
for(uint32_t y = minCoord.y; y <= maxCoord.y; y++) for(int32_t y = minCoord.y; y <= maxCoord.y; y++)
{ {
for(uint32_t z = minCoord.z; z <= maxCoord.z; z++) for(int32_t z = minCoord.z; z <= maxCoord.z; z++)
{ {
DFCoord tile = DFCoord(x, y, z); DFCoord tile = DFCoord(x, y, z);
checkProc(tile, MCache); checkProc(tile, MCache);

@ -21,26 +21,13 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(cursor); REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
static int run_interval = 1200; // daily static unsigned run_interval = 1200; // daily
inline float getClock() inline float getClock()
{ {
return (float)clock() / (float)CLOCKS_PER_SEC; return (float)clock() / (float)CLOCKS_PER_SEC;
} }
static std::string get_unit_description(df::unit *unit)
{
if (!unit)
return "";
std::string desc;
auto name = Units::getVisibleName(unit);
if (name->has_name)
desc = Translation::TranslateName(name, false);
desc += (desc.size() ? ", " : "") + Units::getProfessionName(unit); // Check animal type too
return desc;
}
struct uo_buf { struct uo_buf {
uint32_t dim_x, dim_y, dim_z; uint32_t dim_x, dim_y, dim_z;
size_t size; size_t size;

@ -116,8 +116,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
y_max *= 16; y_max *= 16;
//Calculate a new screen position centered on the selected unit //Calculate a new screen position centered on the selected unit
x = unitPos.x + w/2 >= x_max ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0); x = unitPos.x + w/2 >= int32_t(x_max) ? x_max-w : (unitPos.x >= w/2 ? unitPos.x - w/2 : 0);
y = unitPos.y + h/2 >= y_max ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0); y = unitPos.y + h/2 >= int32_t(y_max) ? y_max-h : (unitPos.y >= h/2 ? unitPos.y - h/2 : 0);
z = unitPos.z; z = unitPos.z;
//Set the new screen position! //Set the new screen position!

@ -274,7 +274,7 @@ static bool moveToInventory(MapExtras::MapCache &mc, df::item *item, df::unit *u
// Step 2: Try to find a bodypart which is eligible to receive equipment AND which is appropriate for the specified item // Step 2: Try to find a bodypart which is eligible to receive equipment AND which is appropriate for the specified item
df::body_part_raw * confirmedBodyPart = NULL; df::body_part_raw * confirmedBodyPart = NULL;
int bpIndex; size_t bpIndex;
for(bpIndex = 0; bpIndex < unit->body.body_plan->body_parts.size(); bpIndex++) for(bpIndex = 0; bpIndex < unit->body.body_plan->body_parts.size(); bpIndex++)
{ {
df::body_part_raw * currPart = unit->body.body_plan->body_parts[bpIndex]; df::body_part_raw * currPart = unit->body.body_plan->body_parts[bpIndex];
@ -358,10 +358,9 @@ static bool moveToInventory(MapExtras::MapCache &mc, df::item *item, df::unit *u
{ {
confirmedBodyPart = currPart; // Assume that the bodypart is valid; we'll invalidate it if we detect too many collisions while looping confirmedBodyPart = currPart; // Assume that the bodypart is valid; we'll invalidate it if we detect too many collisions while looping
int collisions = 0; int collisions = 0;
for (int inventoryID=0; inventoryID < unit->inventory.size(); inventoryID++) for (df::unit_inventory_item * currInvItem : unit->inventory)
{ {
df::unit_inventory_item * currInvItem = unit->inventory[inventoryID]; if (currInvItem->body_part_id == int32_t(bpIndex))
if (currInvItem->body_part_id == bpIndex)
{ {
// Collision detected; have we reached the limit? // Collision detected; have we reached the limit?
if (++collisions >= multiEquipLimit) if (++collisions >= multiEquipLimit)
@ -415,6 +414,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
// The "here" option is hardcoded to true, because the plugin currently doesn't support // The "here" option is hardcoded to true, because the plugin currently doesn't support
// equip-at-a-distance (e.g. grab items within 10 squares of the targeted unit) // equip-at-a-distance (e.g. grab items within 10 squares of the targeted unit)
bool here = true; bool here = true;
(void)here;
// For balance (anti-cheating) reasons, the plugin applies a limit on the number of // For balance (anti-cheating) reasons, the plugin applies a limit on the number of
// item that can be equipped on any bodypart. This limit defaults to 1 but can be // item that can be equipped on any bodypart. This limit defaults to 1 but can be
// overridden with cmdline switches. // overridden with cmdline switches.
@ -512,7 +512,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
pos_cursor = DFCoord(cx,cy,cz); pos_cursor = DFCoord(cx,cy,cz);
// Iterate over all units, process the first one whose pos == pos_cursor // Iterate over all units, process the first one whose pos == pos_cursor
df::unit * targetUnit; df::unit * targetUnit = nullptr;
size_t numUnits = world->units.all.size(); size_t numUnits = world->units.all.size();
for(size_t i=0; i< numUnits; i++) for(size_t i=0; i< numUnits; i++)
{ {
@ -522,11 +522,13 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
if (pos_unit == pos_cursor) if (pos_unit == pos_cursor)
break; break;
if (i + 1 == numUnits) targetUnit = nullptr;
{ }
out.printerr("No unit found at cursor!\n");
return CR_FAILURE; if (!targetUnit)
} {
out.printerr("No unit found at cursor!\n");
return CR_FAILURE;
} }
// Assert: unit found. // Assert: unit found.
@ -534,7 +536,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
// If a specific bodypart was included in the command arguments, then search for it now // If a specific bodypart was included in the command arguments, then search for it now
df::body_part_raw * targetBodyPart = NULL; df::body_part_raw * targetBodyPart = NULL;
if (targetBodyPartCode.size() > 0) { if (targetBodyPartCode.size() > 0) {
for (int bpIndex = 0; bpIndex < targetUnit->body.body_plan->body_parts.size(); bpIndex ++) for (size_t bpIndex = 0; bpIndex < targetUnit->body.body_plan->body_parts.size(); bpIndex ++)
{ {
// Tentatively assume that the part is a match // Tentatively assume that the part is a match
targetBodyPart = targetUnit->body.body_plan->body_parts.at(bpIndex); targetBodyPart = targetUnit->body.body_plan->body_parts.at(bpIndex);

@ -165,7 +165,7 @@ command_result fortplan(color_ostream &out, vector<string> & params) {
con.print("Loading file '%s'...\n",filename.c_str()); con.print("Loading file '%s'...\n",filename.c_str());
try { try {
layout = tokenizeFile(filename); layout = tokenizeFile(filename);
} catch (int e) { } catch (int) {
con.print("Could not open the file.\n"); con.print("Could not open the file.\n");
return CR_FAILURE; return CR_FAILURE;
} }

@ -115,7 +115,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
int creatureCount = 0; int creatureCount = 0;
for (int i = 0; i < world->raws.creatures.all.size(); i++) for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
{ {
auto creatureRaw = world->raws.creatures.all[i]; auto creatureRaw = world->raws.creatures.all[i];
if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED)) if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED))
@ -150,7 +150,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
auto descriptor = descriptors[foundIndex]; auto descriptor = descriptors[foundIndex];
for (int j = 0; j < descriptor.size(); j++) for (size_t j = 0; j < descriptor.size(); j++)
{ {
if (descriptor[j] == ' ') if (descriptor[j] == ' ')
descriptor[j] = '_'; descriptor[j] = '_';
@ -194,7 +194,7 @@ command_result list_creatures(color_ostream &out, std::vector <std::string> & pa
} }
CoreSuspender suspend; CoreSuspender suspend;
for (int i = 0; i < world->raws.creatures.all.size(); i++) for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
{ {
auto creatureRaw = world->raws.creatures.all[i]; auto creatureRaw = world->raws.creatures.all[i];
if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED)) if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED))
@ -223,7 +223,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
int tileHeight = 24; int tileHeight = 24;
std::string fileName = "graphics_procedural_creatures"; std::string fileName = "graphics_procedural_creatures";
std::string pageName = "PROCEDURAL_FRIENDLY"; std::string pageName = "PROCEDURAL_FRIENDLY";
int repeats = 128; size_t repeats = 128;
std::ofstream outputFile(fileName + ".txt", std::ios::out | std::ios::trunc); std::ofstream outputFile(fileName + ".txt", std::ios::out | std::ios::trunc);
@ -244,7 +244,7 @@ command_result save_generated_raw(color_ostream &out, std::vector <std::string>
{ {
auto descriptor = descriptors[descIndex]; auto descriptor = descriptors[descIndex];
for (int j = 0; j < descriptor.size(); j++) for (size_t j = 0; j < descriptor.size(); j++)
{ {
if (descriptor[j] == ' ') if (descriptor[j] == ' ')
descriptor[j] = '_'; descriptor[j] = '_';

@ -17,13 +17,6 @@ static map<string, string> current_bindings;
static vector<string> sorted_keys; static vector<string> sorted_keys;
static bool show_usage = false; static bool show_usage = false;
static void send_key(const df::interface_key &key)
{
set< df::interface_key > keys;
keys.insert(key);
Gui::getCurViewscreen(true)->feed(&keys);
}
static bool can_invoke(string cmdline, df::viewscreen *screen) static bool can_invoke(string cmdline, df::viewscreen *screen)
{ {
vector<string> cmd_parts; vector<string> cmd_parts;
@ -116,7 +109,7 @@ static bool close_hotkeys_screen()
} }
static void invoke_command(const int index) static void invoke_command(const size_t index)
{ {
if (sorted_keys.size() <= index) if (sorted_keys.size() <= index)
return; return;
@ -147,12 +140,12 @@ public:
{ {
hotkeys_column.clear(); hotkeys_column.clear();
int max_key_length = 0; size_t max_key_length = 0;
for_each_(sorted_keys, [&] (const string &sym) for_each_(sorted_keys, [&] (const string &sym)
{ if (sym.length() > max_key_length) { max_key_length = sym.length(); } }); { if (sym.length() > max_key_length) { max_key_length = sym.length(); } });
int padding = max_key_length + 2; int padding = max_key_length + 2;
for (int i = 0; i < sorted_keys.size(); i++) for (size_t i = 0; i < sorted_keys.size(); i++)
{ {
string text = pad_string(sorted_keys[i], padding, false); string text = pad_string(sorted_keys[i], padding, false);
text += current_bindings[sorted_keys[i]]; text += current_bindings[sorted_keys[i]];
@ -230,7 +223,7 @@ public:
Plugin *plugin = Core::getInstance().getPluginManager()->getPluginByCommand(first); Plugin *plugin = Core::getInstance().getPluginManager()->getPluginByCommand(first);
if (plugin) if (plugin)
{ {
for (auto i = 0; i < plugin->size(); i++) for (size_t i = 0; i < plugin->size(); i++)
{ {
auto pc = plugin->operator[](i); auto pc = plugin->operator[](i);
if (pc.name == first) if (pc.name == first)
@ -278,7 +271,7 @@ private:
{ {
vector<string> result; vector<string> result;
string excess; string excess;
if (str.length() > width) if (int(str.length()) > width)
{ {
auto cut_space = str.rfind(' ', width-1); auto cut_space = str.rfind(' ', width-1);
int excess_start; int excess_start;

@ -225,7 +225,7 @@ bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCac
tile->set_current_year(*cur_year); tile->set_current_year(*cur_year);
tile->set_current_season(*cur_season); tile->set_current_season(*cur_season);
int num_valid_layers = 0; int num_valid_layers = 0;
for(int z = 0; z < MP->maxZ(); z++) for(uint32_t z = 0; z < MP->maxZ(); z++)
{ {
EmbarkTileLayer * tile_layer = tile->add_tile_layer(); EmbarkTileLayer * tile_layer = tile->add_tile_layer();
num_valid_layers += gather_embark_tile_layer(EmbX, EmbY, z, tile_layer, MP); num_valid_layers += gather_embark_tile_layer(EmbX, EmbY, z, tile_layer, MP);
@ -351,11 +351,11 @@ static command_result GetRawNames(color_ostream &stream, const MapRequest *in, R
} }
} }
out->set_available(true); out->set_available(true);
for(int i = 0; i < world->raws.inorganics.size(); i++){ for(size_t i = 0; i < world->raws.inorganics.size(); i++){
out->add_inorganic(world->raws.inorganics[i]->id); out->add_inorganic(world->raws.inorganics[i]->id);
} }
for(int i = 0; i < world->raws.plants.all.size(); i++){ for(size_t i = 0; i < world->raws.plants.all.size(); i++){
out->add_organic(world->raws.plants.all[i]->id); out->add_organic(world->raws.plants.all[i]->id);
} }
return CR_OK; return CR_OK;

@ -210,8 +210,8 @@ static df::unit_labor construction_build_labor(df::building_actual* b)
df::item* i = 0; df::item* i = 0;
for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++) for (auto p = b->contained_items.begin(); p != b->contained_items.end(); p++)
if (b->construction_stage > 0 && (*p)->use_mode == 2 || if ((b->construction_stage > 0 && (*p)->use_mode == 2) ||
b->construction_stage == 0 && (*p)->use_mode == 0) (b->construction_stage == 0 && (*p)->use_mode == 0))
i = (*p)->item; i = (*p)->item;
MaterialInfo matinfo; MaterialInfo matinfo;
@ -229,6 +229,7 @@ static df::unit_labor construction_build_labor(df::building_actual* b)
class jlfunc class jlfunc
{ {
public: public:
virtual ~jlfunc() {}
virtual df::unit_labor get_labor(df::job* j) = 0; virtual df::unit_labor get_labor(df::job* j) = 0;
}; };
@ -294,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:
@ -398,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];
@ -1147,7 +1147,7 @@ private:
tool_count[TOOL_AXE]++; tool_count[TOOL_AXE]++;
else if (weaponsk == df::job_skill::MINING) else if (weaponsk == df::job_skill::MINING)
tool_count[TOOL_PICK]++; tool_count[TOOL_PICK]++;
else if (weaponsk2 = df::job_skill::CROSSBOW) else if (weaponsk2 == df::job_skill::CROSSBOW)
tool_count[TOOL_CROSSBOW]++; tool_count[TOOL_CROSSBOW]++;
} }
@ -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
{ {
@ -1493,10 +1493,12 @@ private:
if (labor != df::unit_labor::NONE) if (labor != df::unit_labor::NONE)
{ {
if (d->dwarf->status.labors[labor]) if (d->dwarf->status.labors[labor])
{
if (labor == df::unit_labor::OPERATE_PUMP) if (labor == df::unit_labor::OPERATE_PUMP)
score += 50000; score += 50000;
else else
score += 25000; score += 25000;
}
if (default_labor_infos[labor].tool != TOOL_NONE && if (default_labor_infos[labor].tool != TOOL_NONE &&
d->has_tool[default_labor_infos[labor].tool]) d->has_tool[default_labor_infos[labor].tool])
score += 10000000; score += 10000000;
@ -2088,7 +2090,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
DFhackCExport command_result plugin_onupdate(color_ostream &out) DFhackCExport command_result plugin_onupdate(color_ostream &out)
{ {
static int step_count = 0; // static int step_count = 0;
// check run conditions // check run conditions
if (!initialized || !world || !world->map.block_index || !enable_labormanager) if (!initialized || !world || !world->map.block_index || !enable_labormanager)
{ {
@ -2102,7 +2104,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out)
if (*df::global::process_jobs) if (*df::global::process_jobs)
return CR_OK; return CR_OK;
step_count = 0; // step_count = 0;
debug_stream = &out; debug_stream = &out;
AutoLaborManager alm(out); AutoLaborManager alm(out);
@ -2256,14 +2258,14 @@ 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);
} }
out << "All labors reset." << endl; out << "All labors reset." << endl;
return CR_OK; return CR_OK;
} }
else if (parameters.size() == 1 && parameters[0] == "list" || parameters[0] == "status") else if (parameters.size() == 1 && (parameters[0] == "list" || parameters[0] == "status"))
{ {
if (!enable_labormanager) if (!enable_labormanager)
{ {

@ -16,7 +16,7 @@ public:
UIColor color; UIColor color;
ListEntry(const string text, const T elem, const string keywords = "", const UIColor color = COLOR_UNSELECTED) : ListEntry(const string text, const T elem, const string keywords = "", const UIColor color = COLOR_UNSELECTED) :
elem(elem), text(text), selected(false), keywords(keywords), color(color) elem(elem), text(text), keywords(keywords), selected(false), color(color)
{ {
} }
}; };
@ -73,14 +73,14 @@ public:
void add(const ListEntry<T> &entry) void add(const ListEntry<T> &entry)
{ {
list.push_back(entry); list.push_back(entry);
if (entry.text.length() > max_item_width) if (entry.text.length() > size_t(max_item_width))
max_item_width = entry.text.length(); max_item_width = entry.text.length();
} }
void add(const string &text, const T &elem) void add(const string &text, const T &elem)
{ {
list.push_back(ListEntry<T>(text, elem)); list.push_back(ListEntry<T>(text, elem));
if (text.length() > max_item_width) if (text.length() > size_t(max_item_width))
max_item_width = text.length(); max_item_width = text.length();
} }
@ -110,7 +110,7 @@ public:
paint_text(COLOR_TITLE, left_margin, y, title); paint_text(COLOR_TITLE, left_margin, y, title);
int last_index_able_to_display = display_start_offset + display_max_rows; int last_index_able_to_display = display_start_offset + display_max_rows;
for (int i = display_start_offset; i < display_list.size() && i < last_index_able_to_display; i++) for (int i = display_start_offset; size_t(i) < display_list.size() && i < last_index_able_to_display; i++)
{ {
++y; ++y;
UIColor fg_color = (is_selected_column && display_list[i]->selected) ? COLOR_SELECTED : display_list[i]->color; UIColor fg_color = (is_selected_column && display_list[i]->selected) ? COLOR_SELECTED : display_list[i]->color;
@ -336,8 +336,7 @@ public:
void selectItem(const T elem) void selectItem(const T elem)
{ {
int i = 0; for (size_t i = 0; i < display_list.size(); i++)
for (; i < display_list.size(); i++)
{ {
if (display_list[i]->elem == elem) if (display_list[i]->elem == elem)
{ {
@ -447,7 +446,7 @@ public:
gps->mouse_x >= left_margin && gps->mouse_x < left_margin + max_item_width) gps->mouse_x >= left_margin && gps->mouse_x < left_margin + max_item_width)
{ {
int new_index = display_start_offset + gps->mouse_y - 3; int new_index = display_start_offset + gps->mouse_y - 3;
if (new_index < display_list.size()) if (size_t(new_index) < display_list.size())
{ {
setHighlight(new_index); setHighlight(new_index);
feed_mouse_set_highlight = true; feed_mouse_set_highlight = true;
@ -472,7 +471,7 @@ public:
void setTitle(const string t) void setTitle(const string t)
{ {
title = t; title = t;
if (title.length() > max_item_width) if (title.length() > size_t(max_item_width))
max_item_width = title.length(); max_item_width = title.length();
} }

@ -223,7 +223,7 @@ static void lua_client_send(int server_id,int client_id,std::string data)
throw std::runtime_error("Client does with this id not exist"); throw std::runtime_error("Client does with this id not exist");
} }
CActiveSocket *sock=(*target)[client_id]; CActiveSocket *sock=(*target)[client_id];
if(sock->Send((const uint8_t*)data.c_str(),data.size())!=data.size()) if(size_t(sock->Send((const uint8_t*)data.c_str(),data.size()))!=data.size())
{ {
throw std::runtime_error(sock->DescribeError()); throw std::runtime_error(sock->DescribeError());
} }

@ -596,7 +596,7 @@ namespace unit_ops {
} }
string get_short_profname(UnitInfo *u) string get_short_profname(UnitInfo *u)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (columns[i].profession == u->unit->profession) if (columns[i].profession == u->unit->profession)
return string(columns[i].label); return string(columns[i].label);
@ -657,7 +657,7 @@ struct ProfessionTemplate
continue; continue;
} }
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (line == ENUM_KEY_STR(unit_labor, columns[i].labor)) if (line == ENUM_KEY_STR(unit_labor, columns[i].labor))
{ {
@ -678,7 +678,7 @@ struct ProfessionTemplate
if (mask) if (mask)
outfile << "MASK" << std::endl; outfile << "MASK" << std::endl;
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (hasLabor(columns[i].labor)) if (hasLabor(columns[i].labor))
{ {
@ -696,7 +696,7 @@ struct ProfessionTemplate
if (!mask && name.size() > 0) if (!mask && name.size() > 0)
unit_ops::set_profname(u, name); unit_ops::set_profname(u, name);
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
df::unit_labor labor = columns[i].labor; df::unit_labor labor = columns[i].labor;
bool status = hasLabor(labor); bool status = hasLabor(labor);
@ -709,7 +709,7 @@ struct ProfessionTemplate
void fromUnit(UnitInfo* u) void fromUnit(UnitInfo* u)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (u->unit->status.labors[columns[i].labor]) if (u->unit->status.labors[columns[i].labor])
labors.push_back(columns[i].labor); labors.push_back(columns[i].labor);
@ -899,7 +899,7 @@ public:
} }
OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size()));
OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: "); OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: ");
int max_x = gps->dimx - 2; size_t max_x = gps->dimx - 2;
size_t i = 0; size_t i = 0;
for ( ; i < units.size(); i++) for ( ; i < units.size(); i++)
{ {
@ -1046,7 +1046,7 @@ public:
menu_options.display(true); menu_options.display(true);
OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size())); OutputString(COLOR_LIGHTGREEN, x, y, itos(units.size()));
OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: "); OutputString(COLOR_GREY, x, y, string(" ") + (units.size() > 1 ? "dwarves" : "dwarf") + " selected: ");
int max_x = gps->dimx - 2; size_t max_x = gps->dimx - 2;
size_t i = 0; size_t i = 0;
for ( ; i < units.size(); i++) for ( ; i < units.size(); i++)
{ {
@ -1138,7 +1138,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
df::unit *unit = src[i]; df::unit *unit = src[i];
if (!unit) if (!unit)
{ {
if (cursor_pos > i) if (cursor_pos > int(i))
cursor_pos--; cursor_pos--;
continue; continue;
} }
@ -1192,7 +1192,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector<df::unit*> &src, int cur
if (first_row > sel_row) if (first_row > sel_row)
first_row = sel_row - num_rows + 1; first_row = sel_row - num_rows + 1;
// don't scroll beyond the end // don't scroll beyond the end
if (first_row > units.size() - num_rows) if (first_row > int(units.size()) - num_rows)
first_row = units.size() - num_rows; first_row = units.size() - num_rows;
last_selection = -1; last_selection = -1;
@ -1207,7 +1207,7 @@ void viewscreen_unitlaborsst::calcIDs()
if (!initialized) if (!initialized)
{ {
initialized = true; initialized = true;
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
group_map.insert(std::pair<df::profession, int>(columns[i].profession, columns[i].group)); group_map.insert(std::pair<df::profession, int>(columns[i].profession, columns[i].group));
} }
memset(list_prof_ids, 0, sizeof(list_prof_ids)); memset(list_prof_ids, 0, sizeof(list_prof_ids));
@ -1267,7 +1267,7 @@ void viewscreen_unitlaborsst::calcSize()
auto dim = Screen::getWindowSize(); auto dim = Screen::getWindowSize();
num_rows = dim.y - 11; num_rows = dim.y - 11;
if (num_rows > units.size()) if (num_rows > int(units.size()))
num_rows = units.size(); num_rows = units.size();
int num_columns = dim.x - DISP_COLUMN_MAX - 1; int num_columns = dim.x - DISP_COLUMN_MAX - 1;
@ -1289,7 +1289,7 @@ void viewscreen_unitlaborsst::calcSize()
// get max_name/max_prof from strings length // get max_name/max_prof from strings length
for (size_t i = 0; i < units.size(); i++) for (size_t i = 0; i < units.size(); i++)
{ {
if (col_maxwidth[DISP_COLUMN_NAME] < units[i]->name.size()) if (size_t(col_maxwidth[DISP_COLUMN_NAME]) < units[i]->name.size())
col_maxwidth[DISP_COLUMN_NAME] = units[i]->name.size(); col_maxwidth[DISP_COLUMN_NAME] = units[i]->name.size();
size_t detail_cmp; size_t detail_cmp;
@ -1300,7 +1300,7 @@ void viewscreen_unitlaborsst::calcSize()
} else { } else {
detail_cmp = units[i]->profession.size(); detail_cmp = units[i]->profession.size();
} }
if (col_maxwidth[DISP_COLUMN_DETAIL] < detail_cmp) if (size_t(col_maxwidth[DISP_COLUMN_DETAIL]) < detail_cmp)
col_maxwidth[DISP_COLUMN_DETAIL] = detail_cmp; col_maxwidth[DISP_COLUMN_DETAIL] = detail_cmp;
} }
@ -1383,7 +1383,7 @@ void viewscreen_unitlaborsst::calcSize()
return; return;
// if the window grows vertically, scroll upward to eliminate blank rows from the bottom // if the window grows vertically, scroll upward to eliminate blank rows from the bottom
if (first_row > units.size() - num_rows) if (first_row > int(units.size()) - num_rows)
first_row = units.size() - num_rows; first_row = units.size() - num_rows;
// if it shrinks vertically, scroll downward to keep the cursor visible // if it shrinks vertically, scroll downward to keep the cursor visible
@ -1391,7 +1391,7 @@ void viewscreen_unitlaborsst::calcSize()
first_row = sel_row - num_rows + 1; first_row = sel_row - num_rows + 1;
// if the window grows horizontally, scroll to the left to eliminate blank columns from the right // if the window grows horizontally, scroll to the left to eliminate blank columns from the right
if (first_column > NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS]) if (first_column > int(NUM_COLUMNS) - col_widths[DISP_COLUMN_LABORS])
first_column = NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS]; first_column = NUM_COLUMNS - col_widths[DISP_COLUMN_LABORS];
// if it shrinks horizontally, scroll to the right to keep the cursor visible // if it shrinks horizontally, scroll to the right to keep the cursor visible
@ -1437,7 +1437,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
sel_row = 0; sel_row = 0;
} }
if ((sel_row < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX)) if ((size_t(sel_row) < units.size()-1) && events->count(interface_key::CURSOR_DOWN_Z_AUX))
{ {
sel_row = units.size()-1; sel_row = units.size()-1;
} }
@ -1450,9 +1450,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
sel_row = 0; sel_row = 0;
} }
if (sel_row > units.size() - 1) if (size_t(sel_row) > units.size() - 1)
{ {
if (old_sel_row == units.size()-1 && events->count(interface_key::CURSOR_DOWN)) if (size_t(old_sel_row) == units.size()-1 && events->count(interface_key::CURSOR_DOWN))
sel_row = 0; sel_row = 0;
else else
sel_row = units.size() - 1; sel_row = units.size() - 1;
@ -1487,7 +1487,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
// go to beginning of next group // go to beginning of next group
int cur = columns[sel_column].group; int cur = columns[sel_column].group;
int next = sel_column+1; size_t next = sel_column+1;
while ((next < NUM_COLUMNS) && (columns[next].group == cur)) while ((next < NUM_COLUMNS) && (columns[next].group == cur))
next++; next++;
if ((next < NUM_COLUMNS) && (columns[next].group != cur)) if ((next < NUM_COLUMNS) && (columns[next].group != cur))
@ -1499,14 +1499,14 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
if (sel_column < 0) if (sel_column < 0)
sel_column = 0; sel_column = 0;
if (sel_column > NUM_COLUMNS - 1) if (size_t(sel_column) > NUM_COLUMNS - 1)
sel_column = NUM_COLUMNS - 1; sel_column = NUM_COLUMNS - 1;
if (events->count(interface_key::CURSOR_DOWN_Z) || events->count(interface_key::CURSOR_UP_Z)) if (events->count(interface_key::CURSOR_DOWN_Z) || events->count(interface_key::CURSOR_UP_Z))
{ {
// when moving by group, ensure the whole group is shown onscreen // when moving by group, ensure the whole group is shown onscreen
int endgroup_column = sel_column; int endgroup_column = sel_column;
while ((endgroup_column < NUM_COLUMNS-1) && columns[endgroup_column+1].group == columns[sel_column].group) while ((size_t(endgroup_column) < NUM_COLUMNS-1) && columns[endgroup_column+1].group == columns[sel_column].group)
endgroup_column++; endgroup_column++;
if (first_column < endgroup_column - col_widths[DISP_COLUMN_LABORS] + 1) if (first_column < endgroup_column - col_widths[DISP_COLUMN_LABORS] + 1)
@ -1674,7 +1674,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (newstatus) if (newstatus)
{ {
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if ((columns[i].labor != unit_labor::NONE) && columns[i].special) if ((columns[i].labor != unit_labor::NONE) && columns[i].special)
unit->status.labors[columns[i].labor] = false; unit->status.labors[columns[i].labor] = false;
@ -1688,7 +1688,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
const SkillColumn &col = columns[input_column]; const SkillColumn &col = columns[input_column];
bool newstatus = !unit->status.labors[col.labor]; bool newstatus = !unit->status.labors[col.labor];
for (int i = 0; i < NUM_COLUMNS; i++) for (size_t i = 0; i < NUM_COLUMNS; i++)
{ {
if (columns[i].group != col.group) if (columns[i].group != col.group)
continue; continue;
@ -1698,7 +1698,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (newstatus) if (newstatus)
{ {
for (int j = 0; j < NUM_COLUMNS; j++) for (size_t j = 0; j < NUM_COLUMNS; j++)
{ {
if ((columns[j].labor != unit_labor::NONE) && columns[j].special) if ((columns[j].labor != unit_labor::NONE) && columns[j].special)
unit->status.labors[columns[j].labor] = false; unit->status.labors[columns[j].labor] = false;
@ -1767,6 +1767,8 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
altsort = ALTSORT_NAME; altsort = ALTSORT_NAME;
break; break;
case ALTSORT_MAX:
break;
} }
} }
if (events->count(interface_key::OPTION20)) if (events->count(interface_key::OPTION20))
@ -1847,7 +1849,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
{ {
if (events->count(interface_key::UNITJOB_VIEW_UNIT) || events->count(interface_key::UNITJOB_ZOOM_CRE)) if (events->count(interface_key::UNITJOB_VIEW_UNIT) || events->count(interface_key::UNITJOB_ZOOM_CRE))
{ {
for (int i = 0; i < unitlist->units[unitlist->page].size(); i++) for (size_t i = 0; i < unitlist->units[unitlist->page].size(); i++)
{ {
if (unitlist->units[unitlist->page][i] == units[input_row]->unit) if (unitlist->units[unitlist->page][i] == units[input_row]->unit)
{ {
@ -1893,7 +1895,7 @@ void viewscreen_unitlaborsst::render()
for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++) for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++)
{ {
int col_offset = col + first_column; int col_offset = col + first_column;
if (col_offset >= NUM_COLUMNS) if (size_t(col_offset) >= NUM_COLUMNS)
break; break;
int8_t fg = columns[col_offset].color; int8_t fg = columns[col_offset].color;
@ -1922,7 +1924,7 @@ void viewscreen_unitlaborsst::render()
for (int row = 0; row < num_rows; row++) for (int row = 0; row < num_rows; row++)
{ {
int row_offset = row + first_row; int row_offset = row + first_row;
if (row_offset >= units.size()) if (size_t(row_offset) >= units.size())
break; break;
UnitInfo *cur = units[row_offset]; UnitInfo *cur = units[row_offset];
@ -1998,7 +2000,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill); skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[col_offset].skill);
if ((skill != NULL) && (skill->rating || skill->experience)) if ((skill != NULL) && (skill->rating || skill->experience))
{ {
int level = skill->rating; size_t level = skill->rating;
if (level > NUM_SKILL_LEVELS - 1) if (level > NUM_SKILL_LEVELS - 1)
level = NUM_SKILL_LEVELS - 1; level = NUM_SKILL_LEVELS - 1;
c = skill_levels[level].abbrev; c = skill_levels[level].abbrev;
@ -2060,7 +2062,7 @@ void viewscreen_unitlaborsst::render()
skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill); skill = binsearch_in_vector<df::unit_skill,df::job_skill>(unit->status.current_soul->skills, &df::unit_skill::id, columns[sel_column].skill);
if (skill) if (skill)
{ {
int level = skill->rating; size_t level = skill->rating;
if (level > NUM_SKILL_LEVELS - 1) if (level > NUM_SKILL_LEVELS - 1)
level = NUM_SKILL_LEVELS - 1; level = NUM_SKILL_LEVELS - 1;
str = stl_sprintf("%s %s", skill_levels[level].name, ENUM_ATTR_STR(job_skill, caption_noun, columns[sel_column].skill)); str = stl_sprintf("%s %s", skill_levels[level].name, ENUM_ATTR_STR(job_skill, caption_noun, columns[sel_column].skill));

@ -46,7 +46,7 @@ static bool live_view = true;
static bool skip_tracking_once = false; static bool skip_tracking_once = false;
static bool mouse_moved = false; static bool mouse_moved = false;
static int scroll_delay = 100; static uint32_t scroll_delay = 100;
static df::coord get_mouse_pos(int32_t &mx, int32_t &my) static df::coord get_mouse_pos(int32_t &mx, int32_t &my)
{ {
@ -231,9 +231,10 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
case Burrows: case Burrows:
return ui->burrows.in_define_mode; return ui->burrows.in_define_mode;
};
return false; default:
return false;
}
} }
bool isInTrackableMode() bool isInTrackableMode()

@ -401,9 +401,9 @@ command_result df_bprobe (color_ostream &out, vector <string> & parameters)
Buildings::t_building building; Buildings::t_building building;
if (!Buildings::Read(i, building)) if (!Buildings::Read(i, building))
continue; continue;
if (!(building.x1 <= cursor->x && cursor->x <= building.x2 && if (int32_t(building.x1) > cursor->x || cursor->x > int32_t(building.x2) ||
building.y1 <= cursor->y && cursor->y <= building.y2 && int32_t(building.y1) > cursor->y || cursor->y > int32_t(building.y2) ||
building.z == cursor->z)) int32_t(building.z) != cursor->z)
continue; continue;
string name; string name;
building.origin->getName(&name); building.origin->getName(&name);

@ -152,7 +152,7 @@ void printMats(color_ostream &con, MatMap &mat, std::vector<T*> &materials, bool
for (MatSorter::const_iterator it = sorting_vector.begin(); for (MatSorter::const_iterator it = sorting_vector.begin();
it != sorting_vector.end(); ++it) it != sorting_vector.end(); ++it)
{ {
if(it->first >= materials.size()) if(size_t(it->first) >= materials.size())
{ {
con << "Bad index: " << it->first << " out of " con << "Bad index: " << it->first << " out of "
<< materials.size() << endl; << materials.size() << endl;
@ -747,7 +747,7 @@ command_result prospector (color_ostream &con, vector <string> & parameters)
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++) for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
{ {
const df::plant & plant = *(*it); const df::plant & plant = *(*it);
if (plant.pos.z != z) if (uint32_t(plant.pos.z) != z)
continue; continue;
df::coord2d loc(plant.pos.x, plant.pos.y); df::coord2d loc(plant.pos.x, plant.pos.y);
loc = loc % 16; loc = loc % 16;

@ -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 protobuf-lite ${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));
@ -737,7 +737,6 @@ bool IsBuildingChanged(DFCoord pos)
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
DFCoord localPos = DFCoord(pos.x * 16 + x, pos.y * 16 + y, pos.z);
auto bld = block->occupancy[x][y].bits.building; auto bld = block->occupancy[x][y].bits.building;
if (buildingHashes[pos] != bld) if (buildingHashes[pos] != bld)
{ {
@ -766,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));
@ -807,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;
@ -863,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();
@ -871,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());
} }
@ -889,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();
@ -906,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)
@ -937,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();
@ -948,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());
} }
@ -971,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)
@ -982,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)
@ -1024,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)
@ -1180,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)
@ -1261,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];
@ -1297,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)
@ -1328,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);
@ -1357,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)
@ -1368,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)
@ -1381,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)
@ -1397,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];
@ -1442,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);
} }
@ -1517,7 +1516,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
bool spatterChanged = IsspatterChanged(pos); bool spatterChanged = IsspatterChanged(pos);
bool itemsChanged = block->items.size() > 0; bool itemsChanged = block->items.size() > 0;
bool flows = block->flows.size() > 0; bool flows = block->flows.size() > 0;
RemoteFortressReader::MapBlock *net_block; RemoteFortressReader::MapBlock *net_block = nullptr;
if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows) if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows)
net_block = out->add_map_blocks(); net_block = out->add_map_blocks();
if (tileChanged) if (tileChanged)
@ -1569,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))
@ -1589,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];
@ -1616,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();
@ -1666,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)
@ -1706,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();
@ -1743,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);
@ -1757,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);
@ -1769,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)
@ -1802,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();
@ -1912,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))
@ -2056,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)
@ -2076,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)
@ -2286,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)
@ -2373,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)
@ -2482,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)
@ -2510,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();
@ -2565,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)
@ -2583,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)
@ -2641,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)
@ -2663,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)
@ -2679,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)
@ -2689,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]);
} }
@ -2700,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];
@ -2720,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];
@ -2746,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]];
@ -2769,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]);
@ -2783,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();
@ -2812,17 +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++)
int list_end = world->raws.plants.all.size();
if (in != nullptr)
{
list_start = in->list_start();
if (in->list_end() < list_end)
list_end = in->list_end();
}
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();
@ -2835,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();
@ -3022,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)
@ -3050,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();
@ -335,7 +335,6 @@ void lightingEngineViewscreen::fixAdvMode(int mode)
int window_x=*df::global::window_x; int window_x=*df::global::window_x;
int window_y=*df::global::window_y; int window_y=*df::global::window_y;
int window_z=*df::global::window_z; int window_z=*df::global::window_z;
coord2d vpSize=rect_size(vp);
//mode 0-> make dark non-visible parts //mode 0-> make dark non-visible parts
if(mode==0) if(mode==0)
{ {
@ -392,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;
@ -606,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;
} }
@ -720,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))
@ -750,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();
@ -790,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);
@ -939,14 +938,14 @@ matLightDef lua_parseMatDef(lua_State* L)
matLightDef ret; matLightDef ret;
lua_getfield(L,-1,"tr"); lua_getfield(L,-1,"tr");
if(ret.isTransparent=!lua_isnil(L,-1)) if((ret.isTransparent=!lua_isnil(L,-1)))
{ {
ret.transparency=lua_parseLightCell(L); ret.transparency=lua_parseLightCell(L);
} }
lua_pop(L,1); lua_pop(L,1);
lua_getfield(L,-1,"em"); lua_getfield(L,-1,"em");
if(ret.isEmiting=!lua_isnil(L,-1)) if((ret.isEmiting=!lua_isnil(L,-1)))
{ {
ret.emitColor=lua_parseLightCell(L); ret.emitColor=lua_parseLightCell(L);
lua_pop(L,1); lua_pop(L,1);
@ -1248,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)
{ {
} }
@ -1310,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]);
@ -1426,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();
} }
@ -1474,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)

@ -418,6 +418,8 @@ command_result revflood(color_ostream &out, vector<string> & params)
case tiletype_shape::STAIR_DOWN: case tiletype_shape::STAIR_DOWN:
tt = ctt; tt = ctt;
break; break;
default:
break;
} }
bool below = 0; bool below = 0;
@ -433,6 +435,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
unhide = 0; unhide = 0;
break; break;
// air/free space // air/free space
case tiletype_shape::NONE:
case tiletype_shape::EMPTY: case tiletype_shape::EMPTY:
case tiletype_shape::RAMP_TOP: case tiletype_shape::RAMP_TOP:
case tiletype_shape::STAIR_UPDOWN: case tiletype_shape::STAIR_UPDOWN:

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

@ -957,14 +957,14 @@ class animal_trainer_search : public animal_trainer_search_base
public: public:
void render() const void render() const
{ {
Screen::paintTile(Screen::Pen(186, 8, 0), 14, 2); Screen::paintTile(Screen::Pen('\xBA', 8, 0), 14, 2);
Screen::paintTile(Screen::Pen(186, 8, 0), gps->dimx - 14, 2); Screen::paintTile(Screen::Pen('\xBA', 8, 0), gps->dimx - 14, 2);
Screen::paintTile(Screen::Pen(201, 8, 0), 14, 1); Screen::paintTile(Screen::Pen('\xC9', 8, 0), 14, 1);
Screen::paintTile(Screen::Pen(187, 8, 0), gps->dimx - 14, 1); Screen::paintTile(Screen::Pen('\xBB', 8, 0), gps->dimx - 14, 1);
for (int x = 15; x <= gps->dimx - 15; ++x) for (int x = 15; x <= gps->dimx - 15; ++x)
{ {
Screen::paintTile(Screen::Pen(205, 8, 0), x, 1); Screen::paintTile(Screen::Pen('\xCD', 8, 0), x, 1);
Screen::paintTile(Screen::Pen(0, 0, 0), x, 2); Screen::paintTile(Screen::Pen('\x00', 0, 0), x, 2);
} }
print_search_option(16, 2); print_search_option(16, 2);
} }
@ -1459,12 +1459,12 @@ public:
// About to make an assignment, so restore original list (it will be changed by the game) // About to make an assignment, so restore original list (it will be changed by the game)
int32_t *cursor = get_viewscreen_cursor(); int32_t *cursor = get_viewscreen_cursor();
auto list = get_primary_list(); auto list = get_primary_list();
if (*cursor >= list->size()) if (size_t(*cursor) >= list->size())
return false; return false;
df::unit *selected_unit = list->at(*cursor); df::unit *selected_unit = list->at(*cursor);
clear_search(); clear_search();
for (*cursor = 0; *cursor < list->size(); (*cursor)++) for (*cursor = 0; size_t(*cursor) < list->size(); (*cursor)++)
{ {
if (list->at(*cursor) == selected_unit) if (list->at(*cursor) == selected_unit)
break; break;

@ -98,6 +98,8 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
case mood_type::Possessed: case mood_type::Possessed:
out.print("possessed"); out.print("possessed");
break; break;
default:
break;
} }
out.print(" with intent to "); out.print(" with intent to ");
switch (job->job_type) switch (job->job_type)
@ -275,7 +277,7 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
int count_got = 0; int count_got = 0;
for (size_t j = 0; j < job->items.size(); j++) for (size_t j = 0; j < job->items.size(); j++)
{ {
if(job->items[j]->job_item_idx == i) if(job->items[j]->job_item_idx == int32_t(i))
{ {
if (item->item_type == item_type::BAR || item->item_type == item_type::CLOTH) if (item->item_type == item_type::BAR || item->item_type == item_type::CLOTH)
count_got += job->items[j]->item->getTotalDimension(); count_got += job->items[j]->item->getTotalDimension();

@ -14,31 +14,10 @@ SET(PROJECT_SRCS
) )
SET(PROJECT_PROTOS SET(PROJECT_PROTOS
${CMAKE_CURRENT_SOURCE_DIR}/proto/stockpiles.proto stockpiles
) )
#Create new lists of what sources and headers protoc will output after we invoke it
STRING(REPLACE ".proto" ".pb.cc;" PROJECT_PROTO_SRCS ${PROJECT_PROTOS})
STRING(REPLACE ".proto" ".pb.h;" PROJECT_PROTO_HDRS ${PROJECT_PROTOS})
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_PROTO_HDRS} PROPERTIES GENERATED TRUE)
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_PROTO_SRCS} PROPERTIES GENERATED TRUE)
LIST(APPEND PROJECT_HDRS ${PROJECT_PROTO_HDRS})
LIST(APPEND PROJECT_SRCS ${PROJECT_PROTO_SRCS})
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
#Generate sources from our proto files and store them in the source tree DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} PROTOBUFS ${PROJECT_PROTOS} LINK_LIBRARIES protobuf-lite lua)
ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
DEPENDS protoc-bin ${PROJECT_PROTOS}
)
IF(WIN32)
DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES protobuf-lite lua)
ELSE()
DFHACK_PLUGIN(stockpiles ${PROJECT_SRCS} ${PROJECT_HDRS} LINK_LIBRARIES protobuf-lite lua)
ENDIF()

@ -71,8 +71,8 @@ void OrganicMatLookup::food_build_map ( std::ostream &out )
df::world_raws &raws = world->raws; df::world_raws &raws = world->raws;
df::special_mat_table table = raws.mat_table; df::special_mat_table table = raws.mat_table;
using df::enums::organic_mat_category::organic_mat_category; using df::enums::organic_mat_category::organic_mat_category;
df::enum_traits<organic_mat_category> traits; using traits = df::enum_traits<organic_mat_category>;
for ( int32_t mat_category = traits.first_item_value; mat_category <= traits.last_item_value; ++mat_category ) for ( int32_t mat_category = traits::first_item_value; mat_category <= traits::last_item_value; ++mat_category )
{ {
for ( size_t i = 0; i < table.organic_indexes[mat_category].size(); ++i ) for ( size_t i = 0; i < table.organic_indexes[mat_category].size(); ++i )
{ {

@ -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;
@ -227,14 +227,14 @@ void StockpileSerializer::unserialize_list_organic_mat ( FuncReadImport get_valu
void StockpileSerializer::serialize_list_item_type ( FuncItemAllowed is_allowed, FuncWriteExport add_value, const std::vector<char> &list ) void StockpileSerializer::serialize_list_item_type ( FuncItemAllowed is_allowed, FuncWriteExport add_value, const std::vector<char> &list )
{ {
using df::enums::item_type::item_type; using df::enums::item_type::item_type;
df::enum_traits<item_type> type_traits; using type_traits = df::enum_traits<item_type>;
debug() << "item_type size = " << list.size() << " size limit = " << type_traits.last_item_value << " typecasted: " << ( size_t ) type_traits.last_item_value << endl; debug() << "item_type size = " << list.size() << " size limit = " << type_traits::last_item_value << " typecasted: " << ( size_t ) type_traits::last_item_value << endl;
for ( size_t i = 0; i <= ( size_t ) type_traits.last_item_value; ++i ) for ( size_t i = 0; i <= ( size_t ) type_traits::last_item_value; ++i )
{ {
if ( list.at ( i ) ) if ( list.at ( i ) )
{ {
const item_type type = ( item_type ) ( ( df::enum_traits<item_type>::base_type ) i ); const item_type type = ( item_type ) ( ( df::enum_traits<item_type>::base_type ) i );
std::string r_type ( type_traits.key_table[i+1] ); std::string r_type ( type_traits::key_table[i+1] );
if ( !is_allowed ( type ) ) continue; if ( !is_allowed ( type ) ) continue;
add_value ( r_type ); add_value ( r_type );
debug() << "item_type key_table[" << i+1 << "] type[" << ( int16_t ) type << "] is " << r_type <<endl; debug() << "item_type key_table[" << i+1 << "] type[" << ( int16_t ) type << "] is " << r_type <<endl;
@ -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;
@ -321,12 +321,12 @@ void StockpileSerializer::unserialize_list_material ( FuncMaterialAllowed is_all
void StockpileSerializer::serialize_list_quality ( FuncWriteExport add_value, const bool ( &quality_list ) [7] ) void StockpileSerializer::serialize_list_quality ( FuncWriteExport add_value, const bool ( &quality_list ) [7] )
{ {
using df::enums::item_quality::item_quality; using df::enums::item_quality::item_quality;
df::enum_traits<item_quality> quality_traits; using quality_traits = df::enum_traits<item_quality>;
for ( size_t i = 0; i < 7; ++i ) for ( size_t i = 0; i < 7; ++i )
{ {
if ( quality_list[i] ) if ( quality_list[i] )
{ {
const std::string f_type ( quality_traits.key_table[i] ); const std::string f_type ( quality_traits::key_table[i] );
add_value ( f_type ); add_value ( f_type );
debug() << " quality: " << i << " is " << f_type <<endl; debug() << " quality: " << i << " is " << f_type <<endl;
} }
@ -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;
@ -756,12 +756,12 @@ void StockpileSerializer::write_food()
food->set_prepared_meals ( mPile->settings.food.prepared_meals ); food->set_prepared_meals ( mPile->settings.food.prepared_meals );
using df::enums::organic_mat_category::organic_mat_category; using df::enums::organic_mat_category::organic_mat_category;
df::enum_traits<organic_mat_category> traits; using traits = df::enum_traits<organic_mat_category>;
for ( int32_t mat_category = traits.first_item_value; mat_category <traits.last_item_value; ++mat_category ) for ( int32_t mat_category = traits::first_item_value; mat_category <traits::last_item_value; ++mat_category )
{ {
food_pair p = food_map ( ( organic_mat_category ) mat_category ); food_pair p = food_map ( ( organic_mat_category ) mat_category );
if ( !p.valid ) continue; if ( !p.valid ) continue;
debug() << " food: " << traits.key_table[mat_category] << endl; debug() << " food: " << traits::key_table[mat_category] << endl;
serialize_list_organic_mat ( p.set_value, p.stockpile_values, ( organic_mat_category ) mat_category ); serialize_list_organic_mat ( p.set_value, p.stockpile_values, ( organic_mat_category ) mat_category );
} }
} }
@ -770,7 +770,7 @@ void StockpileSerializer::write_food()
void StockpileSerializer::read_food() void StockpileSerializer::read_food()
{ {
using df::enums::organic_mat_category::organic_mat_category; using df::enums::organic_mat_category::organic_mat_category;
df::enum_traits<organic_mat_category> traits; using traits = df::enum_traits<organic_mat_category>;
if ( mBuffer.has_food() ) if ( mBuffer.has_food() )
{ {
mPile->settings.flags.bits.food = 1; mPile->settings.flags.bits.food = 1;
@ -784,7 +784,7 @@ void StockpileSerializer::read_food()
debug() << " prepared_meals: " << mPile->settings.food.prepared_meals << endl; debug() << " prepared_meals: " << mPile->settings.food.prepared_meals << endl;
for ( int32_t mat_category = traits.first_item_value; mat_category <traits.last_item_value; ++mat_category ) for ( int32_t mat_category = traits::first_item_value; mat_category <traits::last_item_value; ++mat_category )
{ {
food_pair p = food_map ( ( organic_mat_category ) mat_category ); food_pair p = food_map ( ( organic_mat_category ) mat_category );
if ( !p.valid ) continue; if ( !p.valid ) continue;
@ -793,7 +793,7 @@ void StockpileSerializer::read_food()
} }
else else
{ {
for ( int32_t mat_category = traits.first_item_value; mat_category <traits.last_item_value; ++mat_category ) for ( int32_t mat_category = traits::first_item_value; mat_category <traits::last_item_value; ++mat_category )
{ {
food_pair p = food_map ( ( organic_mat_category ) mat_category ); food_pair p = food_map ( ( organic_mat_category ) mat_category );
if ( !p.valid ) continue; if ( !p.valid ) continue;
@ -830,12 +830,12 @@ void StockpileSerializer::write_furniture()
// FURNITURE type // FURNITURE type
using df::enums::furniture_type::furniture_type; using df::enums::furniture_type::furniture_type;
df::enum_traits<furniture_type> type_traits; using type_traits = df::enum_traits<furniture_type>;
for ( size_t i = 0; i < mPile->settings.furniture.type.size(); ++i ) for ( size_t i = 0; i < mPile->settings.furniture.type.size(); ++i )
{ {
if ( mPile->settings.furniture.type.at ( i ) ) if ( mPile->settings.furniture.type.at ( i ) )
{ {
std::string f_type ( type_traits.key_table[i] ); std::string f_type ( type_traits::key_table[i] );
furniture->add_type ( f_type ); furniture->add_type ( f_type );
debug() << "furniture_type " << i << " is " << f_type <<endl; debug() << "furniture_type " << i << " is " << f_type <<endl;
} }
@ -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 );

@ -42,17 +42,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
#define MAX_NAME 30 #define MAX_NAME 30
#define SIDEBAR_WIDTH 30 #define SIDEBAR_WIDTH 30
static bool show_debugging = false;
static void debug(const string &msg)
{
if (!show_debugging)
return;
color_ostream_proxy out(Core::getInstance().getConsole());
out << "DEBUG (stocks): " << msg << endl;
}
/* /*
* Utility * Utility

@ -1 +1 @@
Subproject commit 0430344c7bd8621b1af45bf27a8b6335dd89013e Subproject commit 9bc7acc114e25c7399f4b85c95d544fe7e7c3d8e

@ -106,6 +106,8 @@ df::job_skill getMoodSkill (df::unit *unit)
if (skill->rating == level) if (skill->rating == level)
skills.push_back(skill->id); skills.push_back(skill->id);
break; break;
default:
break;
} }
} }
if (!skills.size() && civ) if (!skills.size() && civ)
@ -175,7 +177,7 @@ void generateName(df::language_name &output, int language, int mode, const df::l
int32_t word; df::enum_field<df::part_of_speech,int16_t> part; int32_t word; df::enum_field<df::part_of_speech,int16_t> part;
output.first_name.clear(); output.first_name.clear();
selectWord(table1, word, part, 2); selectWord(table1, word, part, 2);
if (word >= 0 && word < world->raws.language.words.size()) if (word >= 0 && size_t(word) < world->raws.language.words.size())
output.first_name = *world->raws.language.translations[language]->words[word]; output.first_name = *world->raws.language.translations[language]->words[word];
} }
if (mode != 10) if (mode != 10)
@ -616,6 +618,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
for (int j = 0; j < 15; j++) for (int j = 0; j < 15; j++)
tickets.push_back(i); tickets.push_back(i);
break; break;
default:
break;
} }
} }
if (!tickets.size()) if (!tickets.size())
@ -765,6 +769,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::MECHANICS: case job_skill::MECHANICS:
job->job_type = job_type::StrangeMoodMechanics; job->job_type = job_type::StrangeMoodMechanics;
break; break;
default:
break;
} }
} }
// Check which types of glass are available - we'll need this information later // Check which types of glass are available - we'll need this information later
@ -1111,6 +1117,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
} }
item->quantity = base_item_count; item->quantity = base_item_count;
break; break;
default:
break;
} }
} }
@ -1157,8 +1165,10 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::GLASSMAKER: case job_skill::GLASSMAKER:
avoid_glass = 1; avoid_glass = 1;
break; break;
default:
break;
} }
for (size_t i = 0; i < extra_items; i++) for (int i = 0; i < extra_items; i++)
{ {
if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2))) if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2)))
{ {

@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
void help( color_ostream & out, std::vector<std::string> &commands, int start, int end) void help( color_ostream & out, std::vector<std::string> &commands, int start, int end)
{ {
std::string option = commands.size() > start ? commands[start] : ""; std::string option = commands.size() > size_t(start) ? commands[start] : "";
if (option.empty()) if (option.empty())
{ {
out << "Commands:" << std::endl out << "Commands:" << std::endl
@ -812,7 +812,7 @@ command_result executePaintJob(color_ostream &out)
*/ */
// Remove direction from directionless tiles // Remove direction from directionless tiles
DFHack::TileDirection direction = tileDirection(source); DFHack::TileDirection direction = tileDirection(source);
if (!(material == tiletype_material::RIVER || shape == tiletype_shape::BROOK_BED || special == tiletype_special::TRACK || shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))) if (!(material == tiletype_material::RIVER || shape == tiletype_shape::BROOK_BED || special == tiletype_special::TRACK || (shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))))
{ {
direction.whole = 0; direction.whole = 0;
} }
@ -894,7 +894,7 @@ command_result executePaintJob(color_ostream &out)
command_result processCommand(color_ostream &out, std::vector<std::string> &commands, int start, int end, bool & endLoop, bool hasConsole = false) command_result processCommand(color_ostream &out, std::vector<std::string> &commands, int start, int end, bool & endLoop, bool hasConsole = false)
{ {
if (commands.size() == start) if (commands.size() == size_t(start))
{ {
return executePaintJob(out); return executePaintJob(out);
} }

@ -133,8 +133,8 @@ using namespace DFHack::Gui;
class tweak_onupdate_hookst { 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

@ -45,7 +45,6 @@ struct max_wheelbarrow_hook : df::viewscreen_dwarfmodest {
bool handled = false; bool handled = false;
if (stockpile) if (stockpile)
{ {
auto dims = Gui::getDwarfmodeViewDims();
handled = true; handled = true;
if (!in_wheelbarrow_entry && if (!in_wheelbarrow_entry &&
input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW)) input->count(df::interface_key::BUILDJOB_STOCKPILE_WHEELBARROW))

@ -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,

@ -86,7 +86,7 @@ static void transform_(vector<T> &src, vector<V> &dst, Fn func)
typedef int8_t UIColor; typedef int8_t UIColor;
static void OutputString(UIColor color, int &x, int &y, const std::string &text, static inline void OutputString(UIColor color, int &x, int &y, const std::string &text,
bool newline = false, int left_margin = 0, const UIColor bg_color = 0, bool map = false) bool newline = false, int left_margin = 0, const UIColor bg_color = 0, bool map = false)
{ {
Screen::paintString(Screen::Pen(' ', color, bg_color), x, y, text, map); Screen::paintString(Screen::Pen(' ', color, bg_color), x, y, text, map);
@ -99,7 +99,7 @@ static void OutputString(UIColor color, int &x, int &y, const std::string &text,
x += text.length(); x += text.length();
} }
static void OutputHotkeyString(int &x, int &y, const char *text, const char *hotkey, bool newline = false, static inline void OutputHotkeyString(int &x, int &y, const char *text, const char *hotkey, bool newline = false,
int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map); OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map);
@ -108,14 +108,14 @@ static void OutputHotkeyString(int &x, int &y, const char *text, const char *hot
OutputString(text_color, x, y, display, newline, left_margin, 0, map); OutputString(text_color, x, y, display, newline, left_margin, 0, map);
} }
static void OutputHotkeyString(int &x, int &y, const char *text, df::interface_key hotkey, static inline void OutputHotkeyString(int &x, int &y, const char *text, df::interface_key hotkey,
bool newline = false, int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool newline = false, int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN,
bool map = false) bool map = false)
{ {
OutputHotkeyString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), newline, left_margin, text_color, hotkey_color, map); OutputHotkeyString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), newline, left_margin, text_color, hotkey_color, map);
} }
static void OutputLabelString(int &x, int &y, const char *text, const char *hotkey, const string &label, bool newline = false, static inline void OutputLabelString(int &x, int &y, const char *text, const char *hotkey, const string &label, bool newline = false,
int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map); OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map);
@ -126,14 +126,14 @@ static void OutputLabelString(int &x, int &y, const char *text, const char *hotk
OutputString(hotkey_color, x, y, label, newline, left_margin, 0, map); OutputString(hotkey_color, x, y, label, newline, left_margin, 0, map);
} }
static void OutputLabelString(int &x, int &y, const char *text, df::interface_key hotkey, const string &label, bool newline = false, static inline void OutputLabelString(int &x, int &y, const char *text, df::interface_key hotkey, const string &label, bool newline = false,
int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t text_color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputLabelString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), label, newline, OutputLabelString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), label, newline,
left_margin, text_color, hotkey_color, map); left_margin, text_color, hotkey_color, map);
} }
static void OutputFilterString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = false, static inline void OutputFilterString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = false,
int left_margin = 0, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map); OutputString(hotkey_color, x, y, hotkey, false, 0, 0, map);
@ -141,7 +141,7 @@ static void OutputFilterString(int &x, int &y, const char *text, const char *hot
OutputString((state) ? COLOR_WHITE : COLOR_GREY, x, y, text, newline, left_margin, 0, map); OutputString((state) ? COLOR_WHITE : COLOR_GREY, x, y, text, newline, left_margin, 0, map);
} }
static void OutputToggleString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = true, static inline void OutputToggleString(int &x, int &y, const char *text, const char *hotkey, bool state, bool newline = true,
int left_margin = 0, int8_t color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputHotkeyString(x, y, text, hotkey, false, 0, color, hotkey_color, map); OutputHotkeyString(x, y, text, hotkey, false, 0, color, hotkey_color, map);
@ -152,7 +152,7 @@ static void OutputToggleString(int &x, int &y, const char *text, const char *hot
OutputString(COLOR_GREY, x, y, "Off", newline, left_margin, 0, map); OutputString(COLOR_GREY, x, y, "Off", newline, left_margin, 0, map);
} }
static void OutputToggleString(int &x, int &y, const char *text, df::interface_key hotkey, bool state, bool newline = true, static inline void OutputToggleString(int &x, int &y, const char *text, df::interface_key hotkey, bool state, bool newline = true,
int left_margin = 0, int8_t color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false) int left_margin = 0, int8_t color = COLOR_WHITE, int8_t hotkey_color = COLOR_LIGHTGREEN, bool map = false)
{ {
OutputToggleString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), state, newline, left_margin, color, hotkey_color, map); OutputToggleString(x, y, text, DFHack::Screen::getKeyDisplay(hotkey).c_str(), state, newline, left_margin, color, hotkey_color, map);
@ -163,7 +163,7 @@ inline string int_to_string(const int n)
return static_cast<ostringstream*>( &(ostringstream() << n) )->str(); return static_cast<ostringstream*>( &(ostringstream() << n) )->str();
} }
static void set_to_limit(int &value, const int maximum, const int min = 0) static inline void set_to_limit(int &value, const int maximum, const int min = 0)
{ {
if (value < min) if (value < min)
value = min; value = min;
@ -193,9 +193,9 @@ inline void paint_text(const UIColor color, const int &x, const int &y, const st
Screen::paintString(Screen::Pen(' ', color, background), x, y, text); Screen::paintString(Screen::Pen(' ', color, background), x, y, text);
} }
static string pad_string(string text, const int size, const bool front = true, const bool trim = false) static inline string pad_string(string text, const int size, const bool front = true, const bool trim = false)
{ {
if (text.length() > size) if (text.length() > size_t(size))
{ {
if (trim && size > 10) if (trim && size > 10)
{ {
@ -218,7 +218,7 @@ static string pad_string(string text, const int size, const bool front = true, c
} }
} }
static df::interface_key get_string_key(const std::set<df::interface_key> *input) static inline df::interface_key get_string_key(const std::set<df::interface_key> *input)
{ {
for (auto it = input->begin(); it != input->end(); ++it) for (auto it = input->begin(); it != input->end(); ++it)
{ {
@ -228,7 +228,7 @@ static df::interface_key get_string_key(const std::set<df::interface_key> *input
return df::interface_key::NONE; return df::interface_key::NONE;
} }
static char get_string_input(const std::set<df::interface_key> *input) static inline char get_string_input(const std::set<df::interface_key> *input)
{ {
return DFHack::Screen::keyToChar(get_string_key(input)); return DFHack::Screen::keyToChar(get_string_key(input));
} }
@ -237,7 +237,7 @@ static char get_string_input(const std::set<df::interface_key> *input)
* Utility Functions * Utility Functions
*/ */
static df::building_stockpilest *get_selected_stockpile() static inline df::building_stockpilest *get_selected_stockpile()
{ {
if (!Gui::dwarfmode_hotkey(Core::getTopViewscreen()) || if (!Gui::dwarfmode_hotkey(Core::getTopViewscreen()) ||
df::global::ui->main.mode != ui_sidebar_mode::QueryBuilding) df::global::ui->main.mode != ui_sidebar_mode::QueryBuilding)
@ -248,7 +248,7 @@ static df::building_stockpilest *get_selected_stockpile()
return virtual_cast<df::building_stockpilest>(df::global::world->selected_building); return virtual_cast<df::building_stockpilest>(df::global::world->selected_building);
} }
static bool can_trade() static inline bool can_trade()
{ {
if (df::global::ui->caravans.size() == 0) if (df::global::ui->caravans.size() == 0)
return false; return false;
@ -266,19 +266,19 @@ static bool can_trade()
return false; return false;
} }
static bool is_metal_item(df::item *item) static inline bool is_metal_item(df::item *item)
{ {
MaterialInfo mat(item); MaterialInfo mat(item);
return (mat.getCraftClass() == craft_material_class::Metal); return (mat.getCraftClass() == craft_material_class::Metal);
} }
static bool is_set_to_melt(df::item* item) static inline bool is_set_to_melt(df::item* item)
{ {
return item->flags.bits.melt; return item->flags.bits.melt;
} }
// Copied from Kelly Martin's code // Copied from Kelly Martin's code
static bool can_melt(df::item* item) static inline bool can_melt(df::item* item)
{ {
df::item_flags bad_flags; df::item_flags bad_flags;
@ -318,6 +318,8 @@ static bool can_melt(df::item* item)
} }
} }
break; break;
default:
break;
} }
} }
@ -334,12 +336,13 @@ static bool can_melt(df::item* item)
class StockpileInfo { class StockpileInfo {
public: public:
StockpileInfo() : id(0), sp(nullptr) StockpileInfo() : id(0), sp(nullptr), x1(-30000), x2(-30000), y1(-30000), y2(-30000), z(-30000)
{ {
} }
StockpileInfo(df::building_stockpilest *sp_) : sp(sp_) StockpileInfo(df::building_stockpilest *sp_) : StockpileInfo()
{ {
sp = sp_;
readBuilding(); readBuilding();
} }

@ -438,7 +438,7 @@ static int fix_job_postings (color_ostream *out, bool dry_run)
for (size_t i = 0; i < world->jobs.postings.size(); ++i) for (size_t i = 0; i < world->jobs.postings.size(); ++i)
{ {
df::job_handler::T_postings *posting = world->jobs.postings[i]; df::job_handler::T_postings *posting = world->jobs.postings[i];
if (posting->job == job && i != job->posting_index && !posting->flags.bits.dead) if (posting->job == job && i != size_t(job->posting_index) && !posting->flags.bits.dead)
{ {
++count; ++count;
if (out) if (out)

@ -1874,7 +1874,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
if (p == "race") { if (p == "race") {
race_filter_set = true; race_filter_set = true;
} }
} catch (const exception& err) { } catch (const exception&) {
return CR_FAILURE; return CR_FAILURE;
} }
} }
@ -2073,7 +2073,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
if(target_count > 0) if(target_count > 0)
{ {
vector <df::unit*> units_for_cagezone; vector <df::unit*> units_for_cagezone;
size_t count = 0; int count = 0;
for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it) for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it)
{ {
df::unit *unit = *unit_it; df::unit *unit = *unit_it;