Add a salt/stagnant flag removal command to the liquids tool.

develop
Petr Mrázek 2011-09-02 01:25:01 +02:00
parent e48f8af9a8
commit 8cdeb0b59c
4 changed files with 100 additions and 77 deletions

@ -1,80 +1,4 @@
#FIXME: inherit all macros and stuff from the dfhack SDK INCLUDE(Plugins.cmake)
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32 -std=c++0x")
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32")
ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include")
include_directories("${dfhack_SOURCE_DIR}/library/depends/xgetopt")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO(CAR)
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO(CDR)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF (${value} STREQUAL ${value2})
ENDFOREACH (value2)
ENDMACRO(LIST_CONTAINS)
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name)
LIST_CONTAINS(is_option ${arg} ${option_names})
IF (is_option)
SET(${prefix}_${arg} TRUE)
ELSE (is_option)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option)
ENDIF (is_arg_name)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
ENDMACRO(DFHACK_PLUGIN)
# Dfusion plugin # Dfusion plugin
IF(UNIX) IF(UNIX)

@ -0,0 +1,77 @@
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32 -std=c++0x")
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32")
ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include")
include_directories("${dfhack_SOURCE_DIR}/library/depends/xgetopt")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO()
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO()
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF()
ENDFOREACH()
ENDMACRO()
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH()
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH()
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE()
LIST_CONTAINS(is_option ${arg} ${option_names})
IF(is_option)
SET(${prefix}_${arg} TRUE)
ELSE()
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF()
ENDIF()
ENDFOREACH()
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO()
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
ENDMACRO(DFHACK_PLUGIN)

@ -206,6 +206,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
<< "of - make obsidian floors" << endl << "of - make obsidian floors" << endl
<< "rs - make a river source" << endl << "rs - make a river source" << endl
<< "f - flow bits only" << endl << "f - flow bits only" << endl
<< "wclean - remove salt and stagnant flags from tiles" << endl
<< "Set-Modes (only for magma/water):" << endl << "Set-Modes (only for magma/water):" << endl
<< "s+ - only add" << endl << "s+ - only add" << endl
<< "s. - set" << endl << "s. - set" << endl
@ -254,6 +255,10 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
{ {
mode = "riversource"; mode = "riversource";
} }
else if(command == "wclean")
{
mode = "wclean";
}
else if(command == "point" || command == "p") else if(command == "point" || command == "p")
{ {
delete brush; delete brush;
@ -423,6 +428,19 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
iter++; iter++;
} }
} }
else if(mode=="wclean")
{
coord_vec::iterator iter = all_tiles.begin();
while (iter != all_tiles.end())
{
DFHack::DFCoord current = *iter;
DFHack::t_designation des = mcache.designationAt(current);
des.bits.water_salt = false;
des.bits.water_stagnant = false;
mcache.setDesignationAt(current,des);
iter++;
}
}
else if(mode== "magma" || mode== "water" || mode == "flowbits") else if(mode== "magma" || mode== "water" || mode == "flowbits")
{ {
set <Block *> seen_blocks; set <Block *> seen_blocks;

@ -198,6 +198,10 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con << "rained?" << std::endl; con << "rained?" << std::endl;
if(des.smooth) if(des.smooth)
con << "smooth?" << std::endl; con << "smooth?" << std::endl;
if(des.water_salt)
con << "salty" << endl;
if(des.water_stagnant)
con << "stagnant" << endl;
#define PRINT_FLAG( X ) con.print("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) ) #define PRINT_FLAG( X ) con.print("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) )
PRINT_FLAG( hidden ); PRINT_FLAG( hidden );