lunes, 5 de mayo de 2025

Compilar UMoria-Color paso a paso bajo Win11 y Linux

Como compilar Umoria-Color (y Moria) desde Linux Fedora 42 y Windows 11

Moria salió en 1983 (hecho en Pascal). Luego en 1986 salió UMoria (porteado a C). El 2020 nació Umoria-color un proyecto para darle un poco de color al Umoria que es en blanco y negro
En este pequeño post voy a explicar los pasos para compilar Umoria-Color en Linux y en Windows 11 y por defecto sirve para Moria ya que Umoria-Color es un fork de Umoria.

Linux

Como no tengo Linux Fedora, voy a bajar la imagen ISO y montarla con WMware Workstation PRO sobre Windows 11

1. Bajar ISO de Fedora 42 (mayo 2025) https://fedoraproject.org/workstation/download

Esta pesa cerca de 2 GB.

2. Con WMware Workstation PRO y cargar la ISO. Configurarlo con 1 CORE y 6 GB de RAM, 20 GB de Disco, es suficiente.

Instalar el S.O. Seguir este video SOLO hasta el minuto 4.32 que es lo que nos sirve

https://www.youtube.com/watch?v=Pqq1mRYnFUc

3. Ya estando adentro de Fedora, abrir Firefox.

Bajar el código fuente, en este caso usaremos la última versión de umoria-color 5.8.3 

https://github.com/andrewtweber/umoria-color/releases/tag/v5.8.3

Bajar la versión de Linux: umoria-color-5.8.3.tar.gz

4. Ve al Terminal

En la ventana de Terminal escribe comando

    ll    --> ver archivos y carpetas sus detalles
  cd Descargas   --> debe ser case sensitive

Descomprimir el archivo comprimido: umoria-color-5.8.3.tar.gz

  tar -xzvf umoria-color-5.8.3.tar.gz

Se creará una carpeta con el código fuente adentro

Instalar gcc

    sudo dnf install gcc

Instalar el compilador de c++

    sudo dnf install gcc gcc-c++

Instalar cmake

    sudo dnf install cmake

Validarlo con

    cmake --version

Dirá 3.31.6

Instalar ncurses

    sudo dnf install ncurses ncurses-devel

Compilación

    mkdir build && cd build

  cmake ..

    make

Ejecución

    cd umoria

   ./umoria


Windows

1. Bajar MSYS2 https://www.msys2.org/

Cuando termine no ejecutar

2. Abrir en Windows "MSYS2 MINGW64", no abrir MYSYS2 or UCRT64.

Se abrirá una ventana tipo Linux

3. Escribir comandos

pacman -S mingw-w64-x86_64-gcc
pacman -S gcc
pacman -S gcc cmake
pacman -S gcc make
pacman -S ncurses
pacman -S mingw-w64-x86_64-ncurses

4. Copy the source code into the folder where the terminal runs. In my case,

C:\msys64\home\<user>\umoria-color-5.8.3

5. Go to the folder with

cd /home/<user>/umoria-color-5.8.3

6. Modificar el archivo "CMakeLists.txt"

#set(CURSES_LIBRARIES "/$ENV{MINGW}/lib/libncurses.a")
set(CURSES_LIBRARIES "/$ENV{MINGW}/lib/libncursesw.dll.a") --> dejar esta línea

Al final agregar

include_directories(${CURSES_INCLUDE_DIR})
include_directories("/$ENV{MINGW}/include/ncursesw")
target_link_libraries(umoria ${CURSES_LIBRARIES})

7. escribir los comandos estando parados en el fuente (no dentro de src)

mkdir build

cd build

MINGW=mingw64 cmake ..

make


Al finalizar tendrás

C:\msys64\home\Spider Build\umoria-color-X\build\umoria

y en esa carpeta un umoria.exe

9. Antes de ejecutar debes copiar estas DLL 

  • libiconv-2.dll
  • libintl-8.dll
  • libncursesw6.dll
  • libpanelw6.dll
  • libwinpthread-1.dll

Desde esta carpeta C:\msys64\mingw64\bin

hacia la carpeta del ejecutable: C:\msys64\home\Spider Build\umoria-color-X\build\umoria


10. Ejecutar el juego desde esa carpeta

Bug: Color Blanco y negro

Hay un problema que detecté al compilar Umoria-Color bajo Windows 11 y no soy el único que detectó el issue. Esta versión, al ejecutarse ya sea dentro del mismo "MSYS2 MINGW64", o fuera como ejecutable común, no se ve en colores, solo blanco y negro. Estuve 5 horas intentando diferentes métodos, apoyándome con IA incluso y no hubo caso. Si saben cómo solucionarlo me escriben por acá.

Este es mi CMakeLists.txt

cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
# Do not allow in-source builds
if (${CMAKE_SOURCE_DIR} STREQUAL "${PROJECT_SOURCE_DIR}/src")
    message(FATAL_ERROR "CMake generation is not allowed within the source directory!")
endif ()
project(umoria
    LANGUAGES CXX
)
#
# Set a default build type
#
set(default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
    set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else ()
    message(STATUS "Build type set to '${CMAKE_BUILD_TYPE}'")
endif ()
# Compiler settings
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
#
# Core set of warnings
#
set(cxx_warnings "-Wall")
set(cxx_warnings "${cxx_warnings} -Wextra")
set(cxx_warnings "${cxx_warnings} -Wpedantic")
set(cxx_warnings "${cxx_warnings} -Wshadow")
set(cxx_warnings "${cxx_warnings} -Werror")
set(cxx_warnings "${cxx_warnings} -pedantic-errors")
set(cxx_warnings "${cxx_warnings} -Weffc++ ")
# Additional warnings
set(cxx_warnings "${cxx_warnings} -Wcast-align")
set(cxx_warnings "${cxx_warnings} -Wdisabled-optimization")
set(cxx_warnings "${cxx_warnings} -Wfloat-equal")
set(cxx_warnings "${cxx_warnings} -Winline")
set(cxx_warnings "${cxx_warnings} -Winvalid-pch")
set(cxx_warnings "${cxx_warnings} -Wmissing-format-attribute")
set(cxx_warnings "${cxx_warnings} -Wmissing-include-dirs")
set(cxx_warnings "${cxx_warnings} -Wpacked")
set(cxx_warnings "${cxx_warnings} -Wredundant-decls")
set(cxx_warnings "${cxx_warnings} -Wswitch-default")
set(cxx_warnings "${cxx_warnings} -Wswitch-enum")
set(cxx_warnings "${cxx_warnings} -Wunreachable-code")
set(cxx_warnings "${cxx_warnings} -Wwrite-strings")
# Some very strict warnings, that will be nice to use, but require some hefty refactoring
# set(cxx_warnings "${cxx_warnings} -Wcast-qual")
# set(cxx_warnings "${cxx_warnings} -Wconversion")
# set(cxx_warnings "${cxx_warnings} -Wformat=2")
# set(cxx_warnings "${cxx_warnings} -Wpadded")
# set(cxx_warnings "${cxx_warnings} -Wstrict-overflow")
# set(cxx_warnings "${cxx_warnings} -fno-strict-aliasing")
# Temporary support for GCC 8.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    set(cxx_warnings "${cxx_warnings} -Wno-format-overflow")
endif()
#
# Set the flags and warnings for the debug/release builds
#
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -O0 ${cxx_warnings}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 ${cxx_warnings}")

#
# Source files and directories
#
set(source_dir src)
set(
        source_files
        ${source_dir}/character.h
        ${source_dir}/color.h
        ${source_dir}/config.h
        ${source_dir}/curses.h
        ${source_dir}/dice.h
        ${source_dir}/dungeon.h
        ${source_dir}/dungeon_tile.h
        ${source_dir}/game.h
        ${source_dir}/headers.h
        ${source_dir}/helpers.h
        ${source_dir}/identification.h
        ${source_dir}/inventory.h
        ${source_dir}/mage_spells.h
        ${source_dir}/monster.h
        ${source_dir}/player.h
        ${source_dir}/recall.h
        ${source_dir}/rng.h
        ${source_dir}/scores.h
        ${source_dir}/scrolls.h
        ${source_dir}/spells.h
        ${source_dir}/staves.h
        ${source_dir}/store.h
        ${source_dir}/treasure.h
        ${source_dir}/types.h
        ${source_dir}/ui.h
        ${source_dir}/version.h
        ${source_dir}/wizard.h
        ${source_dir}/config.cpp
        ${source_dir}/helpers.cpp
        ${source_dir}/rng.cpp
        ${source_dir}/main.cpp
        ${source_dir}/data_creatures.cpp
        ${source_dir}/data_player.cpp
        ${source_dir}/data_recall.cpp
        ${source_dir}/data_store_owners.cpp
        ${source_dir}/data_stores.cpp
        ${source_dir}/data_tables.cpp
        ${source_dir}/data_treasure.cpp
        ${source_dir}/character.cpp
        ${source_dir}/color.cpp
        ${source_dir}/dice.cpp
        ${source_dir}/dungeon.cpp
        ${source_dir}/dungeon_generate.cpp
        ${source_dir}/dungeon_los.cpp
        ${source_dir}/game.cpp
        ${source_dir}/game_death.cpp
        ${source_dir}/game_files.cpp
        ${source_dir}/game_objects.cpp
        ${source_dir}/game_run.cpp
        ${source_dir}/game_save.cpp
        ${source_dir}/identification.cpp
        ${source_dir}/inventory.cpp
        ${source_dir}/mage_spells.cpp
        ${source_dir}/monster.cpp
        ${source_dir}/monster_manager.cpp
        ${source_dir}/player.cpp
        ${source_dir}/player_bash.cpp
        ${source_dir}/player_eat.cpp
        ${source_dir}/player_magic.cpp
        ${source_dir}/player_move.cpp
        ${source_dir}/player_pray.cpp
        ${source_dir}/player_quaff.cpp
        ${source_dir}/player_run.cpp
        ${source_dir}/player_stats.cpp
        ${source_dir}/player_throw.cpp
        ${source_dir}/player_traps.cpp
        ${source_dir}/player_tunnel.cpp
        ${source_dir}/recall.cpp
        ${source_dir}/scores.cpp
        ${source_dir}/scrolls.cpp
        ${source_dir}/spells.cpp
        ${source_dir}/staves.cpp
        ${source_dir}/store.cpp
        ${source_dir}/store_inventory.cpp
        ${source_dir}/treasure.cpp
        ${source_dir}/ui.cpp
        ${source_dir}/ui_inventory.cpp
        ${source_dir}/ui_io.cpp
        ${source_dir}/wizard.cpp
)

#
# Set up the install paths and files
#
set(build_dir "umoria")
set(data_dir "${build_dir}/data")

set(EXECUTABLE_OUTPUT_PATH ${build_dir})
# Core game data files
set(
        data_files
        data/help.txt
        data/help_wizard.txt
        data/rl_help.txt
        data/rl_help_wizard.txt
        data/welcome.txt
        data/death_tomb.txt
        data/death_royal.txt
)
file(COPY ${data_files} DESTINATION "${data_dir}")
# Various support files (readme, etc.)
set(
        support_files
        data/scores.dat
        AUTHORS
        LICENSE
)
file(COPY ${support_files} DESTINATION "${build_dir}")

#
# Extract the Umoria version number from version.h
#
file(STRINGS "${source_dir}/version.h" VERSION_HEADER)
string(REGEX MATCH "CURRENT_VERSION_MAJOR = ([0-9]+);" ${VERSION_HEADER})
set(umoria_version_major ${CMAKE_MATCH_1})
string(REGEX MATCH "CURRENT_VERSION_MINOR = ([0-9]+);" ${VERSION_HEADER})
set(umoria_version_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "CURRENT_VERSION_PATCH = ([0-9]+);" ${VERSION_HEADER})
set(umoria_version_patch ${CMAKE_MATCH_1})
set(umoria_version "${umoria_version_major}.${umoria_version_minor}.${umoria_version_patch}")

#
# Update the data files with the current version number and date
#
# Fetch release date from CHANGELOG if it's there :-)
file(READ "CHANGELOG.md" changelog)
string(REGEX MATCH "## ${umoria_version} \\(([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9])\\)" results ${changelog})
list(LENGTH results match_count)
if (match_count EQUAL 0)
    string(TIMESTAMP current_date "%Y-%m-%d" UTC)
else ()
    set(current_date ${CMAKE_MATCH_1})
endif ()
set(
        data_files_to_update
        data/splash.txt
        data/versions.txt
)
foreach (data_file ${data_files_to_update})
    configure_file(${data_file}.in ${build_dir}/${data_file})
endforeach ()

# All of the game resource files
set(resources ${data_files} ${support_files})
# Also add resources to the target so they are visible in the IDE
add_executable(umoria ${source_files} ${resources})

#
# Get around the fact that Visual Studio doesn't have ssize_t
# defined but uses SSIZE_T instead.
#
if(MSVC)
    add_definitions(-Dssize_t=SSIZE_T)
endif(MSVC)
# This is horrible, but needed bacause `find_package()` doesn't use the
# include/lib inside the /mingw32 or /mingw64 directories, and with
# `ncurses-devel` installed, it won't compile.
if ((MSYS OR MINGW) AND "$ENV{MINGW}" STREQUAL "")
    message(FATAL_ERROR "You must set the MINGW environment variable ('mingw64' or 'mingw32'). Example: MINGW=mingw64 cmake .")
    message(FATAL_ERROR "This will be the directory used for locating the ncurses library files.")
elseif ((MSYS OR MINGW) AND NOT "$ENV{MINGW}" STREQUAL "")
    message(STATUS "NOTE: Configuring build for Windows release...")
    # Make the ncurses library static
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -static -lpthread")
    
  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -static -lpthread")
    set(CURSES_INCLUDE_DIR "/$ENV{MINGW}/include/")
  set(CURSES_LIBRARIES "/$ENV{MINGW}/lib/libncursesw.dll.a")

else ()
    message(STATUS "NOTE: Configuring build for macOS/Linux release...")
    set(CURSES_NEED_NCURSES TRUE)
    find_package(Curses REQUIRED)
endif ()
include_directories(${CURSES_INCLUDE_DIR})
include_directories("/$ENV{MINGW}/include/ncursesw")
target_link_libraries(umoria ${CURSES_LIBRARIES})