Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,43 @@
*.dll
*.def
*.exe
/lib/slang*
/mapslang/pkg/*
*.so
*.a
*.pc
*.log
lib/slang*
mapslang/pkg/*
mapslang/mapslang
mapslang/map
map
.vs/
.git
/.cproject
/.project
/.settings/
/tmp/
/build/
tmp/
build/
Makefile
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
install_manifest.txt
libadikted/CMakeFiles/
libadikted/CMakeCache.txt
libadikted/Makefile*
libadikted/cmake_install.cmake
libadikted/install_manifest.txt
mapslang/CMakeFiles/
mapslang/CMakeCache.txt
mapslang/cmake_install.cmake
mapslang/Makefile*
mapslang/install_manifest.txt
mapslang/map
putemple
puttrain
putgems
viewmap*
./putemple
./puttrain
./putgems
./viewmap*
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required( VERSION 3.1 )

project( ADiKtED LANGUAGES C )
set(PROJECT_DESCRIPTION "Dungeon Keeper 1 map editor")

include(GNUInstallDirs)
include(FindPkgConfig)

if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
endif()

set( CMAKE_C_STANDARD 99 )
set( CMAKE_C_STANDARD_REQUIRED ON )

set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-switch" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Wno-conversion -Wno-traditional-conversion -Wno-sign-compare" )

# Add Math::Math
include(cmake/FindMath.cmake)

# Add examples
include(cmake/examples.cmake)
option( ADIKTED_BUILD_EXAMPLES "Build ADiKtEd examples" ON )
if( ADIKTED_BUILD_EXAMPLES )
set(
ADIKTED_EXAMPLES
putgems
puttrain
viewmap
putemple
)

foreach( EXAMPLE ${ADIKTED_EXAMPLES} )
add_example( ${EXAMPLE} )
endforeach()
endif()

add_subdirectory(libadikted)
add_subdirectory(mapslang)

install( TARGETS ${ADIKTED_EXAMPLES} RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binaries)
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Adikted Dungeon Keeper Map Editor

Note - there is now a manual available for ADiKtEd.
It even includes a basic tutorial to quickly learn the program.
A version of it is included within this distribution,
called `dk_adikted_manual.htm`. You may wish to print this out.
## Build

### Unix-like systems

#### CMake

Run
`cmake --install-prefix=/usr . && make install`
and copy the examples to the keeperfx directory

### Windows

#### make

Run `cd libadikted/ && make -f Makefile.win && cd mapslang && make -f Makefile.win`

Here's the Win32 version executable. Just put all the
files in the same directory, edit map.ini as appropriate (you should
change paths to your DK files; you can also change other parameters
if you want), and run it.

## Usage

Run `map [mapfile] [-m <logfile>] [-v] [-r] [-n] [-s [mapfile]] [-q]`

When ADiKtEd saves a map, it will ask you what you wish to call it
(unless you're not using quick save). I suggest you don't save
directly over the Dungeon Keeper original levels, but keep it
in the current directory until you're finished.
Then, at end, save it on `map00001` to access it easily in the game.

You'll need a level script for your newly created level. You may be
able to get by with the script which comes with the original level 1
- ie just copy it and paste into TXT file of your new map - but
if not, study the level scripts reference from `dk_scripting_ref.htm`.
You can also try looking at the original DK and DD levels for examples.

Press F1 for help.

## TODO before final
Fixations in room things parameters (height,other)
Fixations in room corner graphics

## Author
Jon Skeet, skeet@pobox.com

Dev-C++ IDE version,
rewritten most of the code:
Tomasz Lis
76 changes: 76 additions & 0 deletions cmake/FindMath.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
include (CheckLibraryExists)
set(Math_FOUND FALSE)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${Math_FIND_QUIETLY})

if(CMAKE_C_COMPILER_LOADED)
include (CheckIncludeFile)
include (CheckCSourceCompiles)
elseif(CMAKE_CXX_COMPILER_LOADED)
include (CheckIncludeFileCXX)
include (CheckCXXSourceCompiles)
else()
message(FATAL_ERROR "FindMath only works if either C or CXX language is enabled")
endif()

set(MATH_C_CXX_TEST_SOURCE [====[
#include <math.h>

int main()
{
const double x = 7.3;
ceil(x);
acos(x);
sin(x);
sqrt(x);

return 0;
}
]====])


if(CMAKE_C_COMPILER_LOADED)
CHECK_INCLUDE_FILE("math.h" CMAKE_HAVE_MATH_H)
else()
CHECK_INCLUDE_FILE_CXX("math.h" CMAKE_HAVE_MATH_H)
endif()

if(CMAKE_HAVE_MATH_H)
set(CMAKE_HAVE_MATH_LIBRARY)

set(CMAKE_REQUIRED_LIBRARIES -lm)
if(CMAKE_C_COMPILER_LOADED)
CHECK_C_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM)
elseif(CMAKE_CXX_COMPILER_LOADED)
CHECK_CXX_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM)
endif()

if(CMAKE_HAVE_LIBC_LIBM)
set(CMAKE_MATH_LIBS_INIT ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_HAVE_MATH_LIBRARY 1)
set(Math_FOUND TRUE)
else()
set(Math_FOUND FALSE)
endif()

unset(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Math DEFAULT_MSG Math_FOUND)

if(MATH_FOUND AND NOT TARGET Math::Math)
add_library(Math::Math INTERFACE IMPORTED)

if(CMAKE_MATH_LIBS_INIT)
set_property(TARGET Math::Math PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_MATH_LIBS_INIT}")
endif()
elseif(NOT MATH_FOUND)
file(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if compiler accepts -lm failed with the following output:\n${_cmake_find_math_output}\n\n")
message(SEND_ERROR "Required Math library not found!")
endif()
endif()

unset(_cmake_find_math_output)
28 changes: 28 additions & 0 deletions cmake/examples.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function( add_example ARG_NAME )
list( APPEND ARG_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}" )
set( SOURCES "" )
set( RESOURCES "" )
foreach( DIR ${ARG_DIRECTORIES} )
file( GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.h )
list( APPEND SOURCES ${GLOB_SOURCES} )
file( GLOB GLOB_RESOURCES ${DIR}/*.rc )
list( APPEND RESOURCES ${GLOB_RESOURCES} )
endforeach()
add_executable( ${ARG_NAME} ${SOURCES} )
target_link_libraries( ${ARG_NAME} PUBLIC adikted )
find_package( SDL REQUIRED )
target_link_libraries( ${ARG_NAME} PUBLIC ${SDL_LIBRARY} )
target_compile_definitions( ${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL )
target_link_libraries( ${ARG_NAME} PUBLIC X11 Math::Math )
target_include_directories(${ARG_NAME} PUBLIC Math::Math
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lib${TARGET_NAME}>
${SDL_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.)

# Directory name
set_target_properties( ${ARG_NAME} PROPERTIES FOLDER
"${CMAKE_CURRENT_SOURCE_DIR}/examples" )
add_test(${ARG_NAME} ${ARG_NAME})
endfunction()

File renamed without changes.
10 changes: 5 additions & 5 deletions example4/putemple.c → examples/putemple/putemple.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************/
/** @file putemple.c
* ADiKtEd library example 4.
* ADiKtEd library putemple example.
* @par Purpose:
* Demonstrates fast drawing routines and putting slabs with mouse.
* Also, shows how to draw ADiKtEd messages using DK font.
Expand All @@ -23,7 +23,7 @@
#include <string.h>
#include <SDL/SDL.h>

#include "../libadikted/adikted.h"
#include "libadikted/adikted.h"

#define ONE_LOOP_DELAY 20
/**
Expand Down Expand Up @@ -404,7 +404,7 @@ static void process_events()
// contains error message.
// Release the error message.
message_release();
message_info("example4 finished with map load error");
message_info("putemple finished with map load error");
reload_data=0;
level_redraw=0;
clip_view=0;
Expand All @@ -425,7 +425,7 @@ static void process_events()
{
// Release the error message.
message_release();
message_info("example4 finished with data files load error");
message_info("putemple finished with data files load error");
level_redraw=0;
clip_view=0;
done = 1;
Expand Down Expand Up @@ -493,7 +493,7 @@ int main (int argc, char *argv[])
free_messages();
return 2;
}
SDL_WM_SetCaption ("ADiKtEd Libray example 4", NULL);
SDL_WM_SetCaption ("ADiKtEd Libray putemple example", NULL);

message_log("Preparing data structures");
// create object for storing map
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions example1/putgems.c → examples/putgems/putgems.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************/
/** @file putgems.c
* ADiKtEd library example 1.
* ADiKtEd library putgems example.
* @par Purpose:
* This example puts gems on center of gold vein in map 1.
* Demonstrates how to load/save map, and how to change slabs.
Expand All @@ -19,7 +19,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "../libadikted/adikted.h"
#include "libadikted/adikted.h"

int main(int argc, char *argv[])
{
Expand All @@ -34,7 +34,7 @@ int main(int argc, char *argv[])
// but still they have to be initialized)
init_messages();

printf("\nexample1: how to put gems on map\n\n");
printf("\nputgems: how to put gems on map\n\n");

// Setting file name of the map to load
format_lvl_fname(lvl,"Levels/MAP00001");
Expand All @@ -46,7 +46,7 @@ int main(int argc, char *argv[])
if (result!=ERR_NONE)
{
printf("cannot load map\n");
printf("example1 finished with error\n");
printf("putgems finished with error\n");
system("pause");

// The following two commands should be used to free memory
Expand All @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
if (result!=ERR_NONE)
{
printf("cannot save map\n");
printf("example1 finished with error\n");
printf("putgems finished with error\n");
system("pause");

// The following two commands should be used to free memory
Expand All @@ -85,7 +85,7 @@ int main(int argc, char *argv[])
return 1;
}
printf("map \"%s\" saved\n", get_lvl_savfname(lvl));
printf("example1 finished successfully\n");
printf("putgems finished successfully\n");
system("pause");

// The following two commands should be used to free memory
Expand Down
File renamed without changes.
File renamed without changes.
Loading