From 56a6b9b9e284cfeaf8931464b4e3590904da9c1b Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 10:19:23 -0500 Subject: [PATCH 01/10] Rework the build system to clone repos as required and build and move build products into the correct directories at the correct time. Fix issues with missing water and burnin textures. --- .gitignore | 3 +- CMakeLists.txt | 58 ++++++++++++++++++++++++++++++---- MC2Repos | 2 ++ README.md | 32 ++++++++++++++++++- cmake/{sdl2 => }/Copyright.txt | 0 cmake/{sdl2 => }/README.md | 0 code/mechcmd2.cpp | 6 +++- data_tools/CMakeLists.txt | 28 ++++++++++++++++ data_tools/makefst.cpp | 21 +++++------- mclib/terrtxm2.h | 2 +- res/CMakeLists.txt | 11 ++++++- text_tool/CMakeLists.txt | 13 ++++++-- text_tool/main.cpp | 28 +++++++++------- 13 files changed, 167 insertions(+), 37 deletions(-) create mode 100644 MC2Repos rename cmake/{sdl2 => }/Copyright.txt (100%) rename cmake/{sdl2 => }/README.md (100%) diff --git a/.gitignore b/.gitignore index 2497801bf..ee91d7899 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ Tools *.a viewer mc2 -text_tool +text_tool/text_tool .ycm_extra_conf.py .ycm_extra_conf.pyc *.ico @@ -48,6 +48,7 @@ tmp/ dump/ test_code/ test_sound/ +cmake/sdl2 # Source repository should not track built resources *.fst diff --git a/CMakeLists.txt b/CMakeLists.txt index 981ce7518..0c5024731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,11 @@ -cmake_minimum_required (VERSION 3.10) +cmake_minimum_required (VERSION 3.14) # select GLVND versus legacy OpenGL libraries cmake_policy(SET CMP0072 NEW) # cmake --help-policy CMP0072 project(mc2) include(CMakeToolsHelpers OPTIONAL) +# Load the URLs for the SDL2 cmake modules and the MC2 data repo +include(MC2Repos REQUIRED) # Set a default build type for single-configuration # CMake generators if no build type is set. @@ -51,6 +53,37 @@ endif() add_definitions(-DUSE_ASSEMBLER_CODE=0) add_definitions(-DLINUX_BUILD) +find_package(Git REQUIRED) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2") + message(STATUS "Found cmake SDL package dir") +else() + # The SDL2 cmake package directory is missing, so clone it from a repo + message(STATUS "Cloning from ${SDL2_CMAKE_MODULE_REPO}") + execute_process(COMMAND ${GIT_EXECUTABLE} clone ${SDL2_CMAKE_MODULE_REPO} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_CLONE_RESULT ) + if(NOT GIT_CLONE_RESULT EQUAL "0") + message(FATAL_ERROR "git clone of repo failed with ${GIT_CLONE_RESULT}, please clone manually") + endif() +endif() + +# Check for MC2 data dir next to the MC2 dir. If not there, clone it from a repo +get_filename_component(MC2_DATA_PATH "../mc2srcdata" ABSOLUTE) +if(EXISTS "${MC2_DATA_PATH}") + message(STATUS "Found MC2 data dir") +else() + # The MechCommander 2 data directory is missing so clone from a repo + message(STATUS "Cloning from ${MC2_DATA_REPO}") + execute_process(COMMAND ${GIT_EXECUTABLE} clone ${MC2_DATA_REPO} ${MC2_DATA_PATH} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. + RESULT_VARIABLE GIT_CLONE_RESULT ) + if(NOT GIT_CLONE_RESULT EQUAL "0") + message(FATAL_ERROR "git clone of MC2 data repo failed with ${GIT_CLONE_RESULT}, please clone manually") + endif() +endif() + + find_package(SDL2 REQUIRED) find_package(SDL2_mixer REQUIRED) #required by text_tool @@ -74,6 +107,16 @@ get_filename_component(COM_PATH2 "./GameOS/gameos" ABSOLUTE) set(COMMON_INCLUDE_DIRS ${COM_PATH1} ${COM_PATH2}) +include_directories(${COMMON_INCLUDE_DIRS} "./mclib" "./gui" "./code" "./netlib") + +# Build the MC2 resource shared object and after the build completes, copy to the build dir +add_subdirectory("./res" "./out/res") + +# Build the data and text tools for converting the MC2 data and after the build completes, copy to the data dir +add_subdirectory("./data_tools" "./out/data_tools") +add_subdirectory("./text_tool" "./out/text_tool") + + add_subdirectory("./mclib/" "./out/mclib") add_subdirectory("./mclib/mlr" "./out/mclib/mlr") add_subdirectory("./mclib/gosfx" "./out/mclib/gosfx") @@ -176,7 +219,6 @@ set(SOURCES ) -include_directories(${COMMON_INCLUDE_DIRS} "./mclib" "./gui" "./code" "./netlib") if(NOT WIN32) set(ADDITIONAL_LIBS dl) @@ -188,9 +230,13 @@ endif() add_executable(mc2 ${SOURCES} ${MAIN_SRC}) -target_link_libraries(mc2 mclib gosfx mlr stuff gui gameos gameos_main windows ZLIB::ZLIB SDL2::Main GLEW::GLEW SDL2::Mixer ${ADDITIONAL_LIBS} OpenGL::GL) +target_link_libraries(mc2 mc2res mclib gosfx mlr stuff gui gameos gameos_main windows ZLIB::ZLIB SDL2::Main GLEW::GLEW SDL2::Mixer ${ADDITIONAL_LIBS} OpenGL::GL) -add_subdirectory("./res" "./out/res") -add_subdirectory("./data_tools" "./out/data_tools") -add_subdirectory("./text_tool" "./out/text_tool") add_subdirectory("./Viewer" "./out/Viewer") + +add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/shaders + ${CMAKE_CURRENT_BINARY_DIR}/shaders ) + diff --git a/MC2Repos b/MC2Repos new file mode 100644 index 000000000..80c68fcf1 --- /dev/null +++ b/MC2Repos @@ -0,0 +1,2 @@ +set(SDL2_CMAKE_MODULE_REPO "https://gitlab.com/aminosbh/sdl2-cmake-modules.git") +set(MC2_DATA_REPO "https://github.com/igough/mc2srcdata.git") diff --git a/README.md b/README.md index 33cf1f41f..ff16a9bcb 100644 --- a/README.md +++ b/README.md @@ -150,5 +150,35 @@ Once everything in place, you can launch build scripts as described in correspon Building on Linux ================= -You, probably already know hot to do it. If not, please, see windows building section, the process is quite similar. +The build process has been reworked to reduce the number of steps and chance of failure. It handles building and moving data and resources into the correct locations at the right time and cloning repositories as required. The game is build in the ```mc2/build64``` directory. + +You only need to clone the mc2 directory and the build process will clone the data directory and SDL2 cmake modules for you the first time you run the build process. The mc2 and mc2srcdata projects will be cloned side by side and the build process relies on this. The top level directory structure will look like : + +``` +some-empty-directory +| ++---mc2 +\---mc2srcdata +``` + +From an empty directory issue the following commands. + +``` +git clone https://github.com/alariq/mc2.git +cd mc2 +``` + +Edit MC2Repos to make sure the git repositories are set to which git repository you want to clone them from. Whoever user's mc2 project that you cloned, set the value for the ```MC2_DATA_REPO``` to be that same user. eg. If you cloned **alariq**'s mc2 from ```https://github.com/alariq/mc2```, then set MC2_DATA_REPO to ```https://github.com/alariq/mc2srcdata```. + +``` +mkdir build64 +cd build64 +cmake -DCMAKE_LIBRARY_ARCHITECTURE=x64 .. +make all + +cd ../../mc2srcdata/buildscripts +make all BUILD_PLATFORM=linux +./copy_assets.sh + +``` diff --git a/cmake/sdl2/Copyright.txt b/cmake/Copyright.txt similarity index 100% rename from cmake/sdl2/Copyright.txt rename to cmake/Copyright.txt diff --git a/cmake/sdl2/README.md b/cmake/README.md similarity index 100% rename from cmake/sdl2/README.md rename to cmake/README.md diff --git a/code/mechcmd2.cpp b/code/mechcmd2.cpp index 21097a2ea..11ecc9b62 100644 --- a/code/mechcmd2.cpp +++ b/code/mechcmd2.cpp @@ -2655,7 +2655,11 @@ void __stdcall GetGameOSEnvironment(const char* CommandLine ) Environment.allowMultipleApps = false; Environment.dontClearRegistry = true; - Environment.checkCDForFiles = true; + // New code was added to handle JPG versions of the burning files. Unfortunately, these JPG files are NOT included in the textures directory. + // if checkCDForFiles is set to true, then an attempt to load the burning textures from JPGs will continually retry and + // ask to insert the CD. If set to false, when the .JPG is not found, the load will fail and fallback to loading the .TGA + // versions which are included in textures.fst + Environment.checkCDForFiles = false; if (useSound) { diff --git a/data_tools/CMakeLists.txt b/data_tools/CMakeLists.txt index ec4d76024..8e423d966 100644 --- a/data_tools/CMakeLists.txt +++ b/data_tools/CMakeLists.txt @@ -1,3 +1,6 @@ +cmake_minimum_required (VERSION 3.14) +project(data_tools) + set(MAKEFST_SOURCES "makefst.cpp") set(PAK_SOURCES "pak.cpp" "common.hpp") set(ASECONV_SOURCES "aseconv.cpp" "common.hpp") @@ -17,3 +20,28 @@ target_link_libraries(aseconv mclib gosfx mlr stuff gameos windows ZLIB::ZLIB SD add_executable(makersp ${MAKERSP_SOURCES}) target_link_libraries(makersp mclib stuff gameos windows ZLIB::ZLIB SDL2::Main ${ADDITIONAL_LIBS}) +add_custom_command( + TARGET makefst POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/makefst + ${MC2_DATA_PATH}/build_scripts/) + +add_custom_command( + TARGET pak POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/pak + ${MC2_DATA_PATH}/build_scripts/) + +add_custom_command( + TARGET aseconv POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/aseconv + ${MC2_DATA_PATH}/build_scripts/) + +add_custom_command( + TARGET makersp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/makersp + ${MC2_DATA_PATH}/build_scripts/) + + diff --git a/data_tools/makefst.cpp b/data_tools/makefst.cpp index 7f2b20814..814947d39 100644 --- a/data_tools/makefst.cpp +++ b/data_tools/makefst.cpp @@ -29,7 +29,7 @@ int unpack(const char* fst_file, const char* out_path) long result = ff->open(fst_file); if (0 != result) { if(result == FASTFILE_VERSION) { - SPEW(("DBG", "Wrong fast file version\n")); + fprintf(stderr, "Wrong fast file version\n"); } PAUSE(("Error opening fast file\n")); delete ff; @@ -68,7 +68,7 @@ int unpack(const char* fst_file, const char* out_path) long fHandle = ff->openFast(hash, fname); if(fHandle==-1) { - SPEW(("DUMP", "Failed to find file: %s in fast file\n", fname)); + fprintf( stderr, "DUMP: Failed to find file: %s in fast file\n", fname); continue; } @@ -97,7 +97,7 @@ int unpack(const char* fst_file, const char* out_path) { DWORD err = GetLastError(); if (err == ERROR_ALREADY_EXISTS) { - SPEW(("DBG", "Failed to create directory %s, error code: %d - directory already exists\n", tmp, err)); + fprintf( stderr, "DBG: Failed to create directory %s, error code: %d - directory already exists\n", tmp, err); } else { PAUSE(("Failed to create directory %s, error code: %d\n", tmp, err)); } @@ -136,7 +136,7 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha FastFile out_ff; if(NO_ERR != out_ff.create(fst_file, b_compress)) { - SPEW(("pack: ", "Failed to create fast file %s\n", fst_file)); + fprintf( stderr, "pack: Failed to create fast file %s\n", fst_file); return -1; } @@ -145,13 +145,11 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha std::queue dirs2process; std::queue files2pack; - size_t num_files2pack = 0; const char* prefix = in_path; if(!rsp_file) { - char* findString = new char[1]; strcpy(findString, ""); dirs2process.push(findString); @@ -161,7 +159,7 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha char* cur_dir = dirs2process.front(); dirs2process.pop(); - SPEW(("Processing dir: ", "%s\n", cur_dir)); + fprintf( stdout, "Processing dir: %s\n", cur_dir); char* cur_search_path = new char[strlen(prefix) + strlen(PATH_SEPARATOR) + strlen(cur_dir) + strlen(PATH_SEPARATOR) + strlen("*") + 1]; if(strlen(cur_dir) > 0) { @@ -187,8 +185,7 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha } files2pack.push(filename); - SPEW(("\t", "%s\n", filename)); - num_files2pack++; + printf( "\t%s\n", filename); } else { if(strcmp(findResult.cFileName, ".") && strcmp(findResult.cFileName, "..")) { char* findString = new char[strlen(cur_dir) + strlen(findResult.cFileName) + strlen(PATH_SEPARATOR) + 1]; @@ -239,14 +236,12 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha strcpy(fname, line); files2pack.push(fname); - - num_files2pack++; } fclose(fh); delete[] line; } - SPEW(("DBG: ", "Numfiles to pack: %d\n", num_files2pack)); + printf( "DBG: Numfiles to pack: %lu\n", files2pack.size() ); size_t filebuf_size = CHUNK_SIZE; uint8_t* filebuf = new uint8_t[filebuf_size]; @@ -295,7 +290,7 @@ int pack(const char* in_path, const char* fst_file, const char* mount, const cha if(mount) { if (strstr(filename, "pmwbubba.fit")) { - int asdfa = 0; + // int asdfa = 0; } S_snprintf(filename_buf, filenamebuf_size, "%s" PATH_SEPARATOR "%s", mount, filename); diff --git a/mclib/terrtxm2.h b/mclib/terrtxm2.h index 8ffcf48ec..ec316d315 100644 --- a/mclib/terrtxm2.h +++ b/mclib/terrtxm2.h @@ -30,7 +30,7 @@ #define NO_ERR 0 #endif -#define MAX_WATER_DETAIL_TEXTURES 256 +#define MAX_WATER_DETAIL_TEXTURES 16 #define TOTAL_COLORMAP_TYPES 5 //--------------------------------------------------------------------------- diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt index 7fdb3b4cd..fea807947 100644 --- a/res/CMakeLists.txt +++ b/res/CMakeLists.txt @@ -1,3 +1,6 @@ +cmake_minimum_required (VERSION 3.14) +project(mc2res) + set(RES_SOURCES libmain.cpp libmainc.cpp) if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") @@ -10,4 +13,10 @@ else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") include_directories("." "../test_scripts/res_conv") -add_library(mc2res_${res_suffix} SHARED ${RES_SOURCES}) +add_library(${PROJECT_NAME} SHARED ${RES_SOURCES}) + +add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/libmc2res.so + ${CMAKE_CURRENT_BINARY_DIR}/../..) diff --git a/text_tool/CMakeLists.txt b/text_tool/CMakeLists.txt index 8fc95651f..ff576d909 100644 --- a/text_tool/CMakeLists.txt +++ b/text_tool/CMakeLists.txt @@ -1,8 +1,17 @@ +cmake_minimum_required (VERSION 3.14) +project(text_tool) + add_definitions(-DUSE_ASSEMBLER_CODE=0) add_definitions(-DLINUX_BUILD) set(TEXT_TOOL_SOURCES "main.cpp") -add_executable(text_tool ${TEXT_TOOL_SOURCES}) -target_link_libraries(text_tool gameos windows SDL2::Main SDL2::TTF GLEW::GLEW ${ADDITIONAL_LIBS} OpenGL::GL) +add_executable(${PROJECT_NAME} ${TEXT_TOOL_SOURCES}) +target_link_libraries(${PROJECT_NAME} gameos windows SDL2::Main SDL2::TTF GLEW::GLEW ${ADDITIONAL_LIBS} OpenGL::GL) + +add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/text_tool + ${MC2_DATA_PATH}/build_scripts/) diff --git a/text_tool/main.cpp b/text_tool/main.cpp index 85ef57048..a34669310 100644 --- a/text_tool/main.cpp +++ b/text_tool/main.cpp @@ -1,3 +1,5 @@ +#define _ARMOR + #include "gameos.hpp" #include "gos_render.h" #include "gos_font.h" @@ -13,6 +15,8 @@ #include "utils/shader_builder.h" #include "utils/gl_utils.h" +#include + static const uint32_t NUM_GLYPHS = 255 - 32; static const uint32_t START_GLYPH = 32; @@ -69,10 +73,11 @@ int main(int argc, char** argv) const char* size = argv[2]; const char* outFile = argv[3]; + int fontSize = atoi(size); if(fontSize<=0 || fontSize>=100) { printf("Invalid font size: %d\n", fontSize); - return 1; + return 2; } //int size_width = 2; // 2 chars enough to store 0 to 99 @@ -91,25 +96,26 @@ int main(int argc, char** argv) graphics::RenderWindowHandle win = graphics::create_window("text_tool", 512, 512); if(!win) - return 1; + return 3; + graphics::RenderContextHandle ctx = graphics::init_render_context(win); if(!ctx) - return 1; + return 4; GLenum err = glewInit(); if (GLEW_OK != err) { SPEW(("GLEW", "Error: %s\n", glewGetErrorString(err))); - return 1; + return 5; } SPEW(("GRAPHICS", "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION))); - if (!GLEW_ARB_vertex_program || !GLEW_ARB_vertex_program) - { - SPEW(("GRAPHICS", "No shader program support\n")); - return 1; - } + // if ( !GLEW_ARB_vertex_program ) + // { + // SPEW(("GRAPHICS", "No shader program support\n")); + // return 6; + // } graphics::make_current_context(ctx); @@ -117,7 +123,7 @@ int main(int argc, char** argv) if(TTF_Init() == -1) { printf("TTF_Init: %s\n", TTF_GetError()); - exit(1); + exit(7); } int outlinePixelSize = 0; @@ -125,7 +131,7 @@ int main(int argc, char** argv) TTF_Font* font = TTF_OpenFont(fontFile, fontSize); if(!font) { printf("TTF_OpenFont: %s\n", TTF_GetError()); - exit(1); + exit(8); } TTF_SetFontStyle(font, TTF_STYLE_NORMAL); From 002f61baedbc7f64908f866aaa8af3606fbca553 Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 10:55:20 -0500 Subject: [PATCH 02/10] Fix type in top level README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff16a9bcb..d549dc89c 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,15 @@ cd build64 cmake -DCMAKE_LIBRARY_ARCHITECTURE=x64 .. make all -cd ../../mc2srcdata/buildscripts +cd ../../mc2srcdata/build_scripts make all BUILD_PLATFORM=linux ./copy_assets.sh ``` +Running on Linux +---------------- +``` +cd ../../mc2/build64 +./mc2 +``` \ No newline at end of file From 487d74bf5036f9dbada5c69b3e434b2397951af8 Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 13:01:44 -0500 Subject: [PATCH 03/10] Workaround to prevent 2 mechs or vehicles being drawan with an offset --- shaders/gos_tex_vertex_lighted.vert | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shaders/gos_tex_vertex_lighted.vert b/shaders/gos_tex_vertex_lighted.vert index 8310417ab..71a05fc6a 100644 --- a/shaders/gos_tex_vertex_lighted.vert +++ b/shaders/gos_tex_vertex_lighted.vert @@ -42,7 +42,9 @@ void main(void) vec4 p = wvp_ * vec4(pos.xyz, 1); float rhw = 1 / p.w; - p.x = (p.x * rhw) * vp.z + vp.x + 100.0; + // The + 100 causes a duplicate model to be rendered to the right of the actual object + //p.x = (p.x * rhw) * vp.z + vp.x + 100.0; + p.x = (p.x * rhw) * vp.z + vp.x; p.y = (p.y * rhw) * vp.w + vp.y; p.z = p.z * rhw; p.w = abs(rhw); From 3e178d30a291cfd4b4e87c0fbe69a89823bf71ac Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 13:25:33 -0500 Subject: [PATCH 04/10] Fix invalid strings in mech info window. This was due to the array of name indexes having a type of char (signed 8 bit), so when the index was higher than 127, and added to a base string index value, it ended up *subtracting* from the base string index leading to bad string indices. Changed the array type to byte (uint8_t, unsigned char) --- code/infowindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/infowindow.cpp b/code/infowindow.cpp index f6f6691c9..28316e344 100644 --- a/code/infowindow.cpp +++ b/code/infowindow.cpp @@ -283,7 +283,7 @@ void InfoWindow::init( FitIniFile& file ) char SkillText[32]; for (int i = 0; i < 7; i++ ) { - sprintf( SkillText, "Skill%ld", i ); + sprintf( SkillText, "Skill%d", i ); skillInfos[i].init( file, SkillText ,ControlGui::hiResOffsetX, ControlGui::hiResOffsetY); } @@ -623,8 +623,8 @@ void InfoWindow::drawScrollingStuff() char disabledCount[60][2]; long ammo[60]; - char ranges[60]; - char names[60];// sebi: changed long to char + byte ranges[60]; + byte names[60];// igough: changed char to unsigned 8 bit since the value can be over 127, which causes a negative index memset( disabledCount, 0, sizeof( char ) * 60 * 2); // sebi: ORIG BUG FIX memory owerwrite fix fow win64 build: sizeof(long) < sizeof(char*)! @@ -643,7 +643,7 @@ void InfoWindow::drawScrollingStuff() for (long curWeapon = pUnit->numOther; curWeapon < (pUnit->numOther + pUnit->numWeapons); curWeapon++) { - char nName = pUnit->inventory[curWeapon].masterID; + byte nName = pUnit->inventory[curWeapon].masterID; bool bFound = 0; for ( int j = 0; j < i; j++ ) { @@ -995,7 +995,7 @@ void InfoWindow::drawSkillBar( int skill, float yVal, float height ) } char buffer[32]; - sprintf( buffer, "%ld", skill ); + sprintf( buffer, "%d", skill ); componentFont.render( buffer, SKILLRIGHT+2, yVal, SCROLLLEFT - SKILLRIGHT - 2, SKILLHEIGHT, 0xff005392, 0, 0 ); } From d60f3979925aa9a703a65bee3eeb3ec58b1516f2 Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 14:04:27 -0500 Subject: [PATCH 05/10] Fix another signed/unsigned problem that caused the ecm/probe/sensors/jump jets section of a mech's info display to display crap. This is because if a mech does not have one of those things installed, the value corresponding to that thing is supposed to be 255. The code grabbed the value as a signed char which made its value -1, then compared the -1 to 255 to see if the item was installed. If not installed, it is supposed to not print the line corresponding to the item. But since the compare always failed, it would always try and print something, which was always wrong --- code/infowindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/infowindow.cpp b/code/infowindow.cpp index 28316e344..5ba31ef78 100644 --- a/code/infowindow.cpp +++ b/code/infowindow.cpp @@ -760,7 +760,7 @@ void InfoWindow::drawScrollingStuff() //memset( names, 0, sizeof( char* ) * 60 ); MemSet(names, 0); - char count[4]; + byte count[4]; count[0] = pUnit->ecm; count[1] = pUnit->probe; count[2] = pUnit->jumpJets; From 7f2d9c7cf2f48aa0e8549ea3d9fed9d5bdb1ce05 Mon Sep 17 00:00:00 2001 From: igough Date: Sun, 28 Jan 2024 21:17:03 -0500 Subject: [PATCH 06/10] Fix error where vertexData was used where hardwareVertexData should have been used. --- mclib/txmmgr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mclib/txmmgr.h b/mclib/txmmgr.h index cc46d251d..ccaeca455 100644 --- a/mclib/txmmgr.h +++ b/mclib/txmmgr.h @@ -517,7 +517,7 @@ class MC_TextureManager masterTextureNodes[nodeId].hardwareVertexData2->flags = flags; masterTextureNodes[nodeId].hardwareVertexData2->textureIndex = nodeId; } - else if (masterTextureNodes[nodeId].vertexData && + else if (masterTextureNodes[nodeId].hardwareVertexData && (masterTextureNodes[nodeId].hardwareVertexData->flags != flags) && masterTextureNodes[nodeId].hardwareVertexData2 && (masterTextureNodes[nodeId].hardwareVertexData2->flags != flags) && From dd49a4e71d49047b95455476cfb35fd28a924f71 Mon Sep 17 00:00:00 2001 From: igough Date: Tue, 30 Jan 2024 08:32:35 -0500 Subject: [PATCH 07/10] Fix sparkling textures on mechs due to the mech being rendered twice. --- mclib/tgl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mclib/tgl.cpp b/mclib/tgl.cpp index 6825d8f34..56767aa43 100644 --- a/mclib/tgl.cpp +++ b/mclib/tgl.cpp @@ -2457,6 +2457,11 @@ long TG_Shape::MultiTransformShape (Stuff::Matrix4D *shapeToClip, Stuff::Point3D } } +#ifdef ALSO_RENDER_USING_TEX_SHADER + // This piece of code renders mechs and vehicles using the gos_tex_vertex_lighted.vert shader. This is in addition to the same objectes being + // rendered by addTriangle above. This results in a sparkling effect as the 2 renders fight each other as the mechs rotate. This behaviour is + // quite evident with 5 mechs. + // FIXME: this (listOfTypeTriangles[0]) is not correct if model has more than 1 texture! if (!isSpotlight && !isWindow && !theShape->listOfTextures[theShape->listOfTypeTriangles[0].localTextureHandle].textureAlpha && (alphaValue == 0xff)) { @@ -2492,6 +2497,7 @@ long TG_Shape::MultiTransformShape (Stuff::Matrix4D *shapeToClip, Stuff::Point3D mcTextureManager->addRenderShape(theShape->listOfTextures[theShape->listOfTypeTriangles[0].localTextureHandle].mcTextureNodeIndex, MC2_DRAWSOLID | addFlags); } } +#endif gosASSERT(oneOff || oneOn); From af8dfd7890e3ce5faa6f8f0a5ec8442ebe93f045 Mon Sep 17 00:00:00 2001 From: igough Date: Mon, 19 Feb 2024 08:00:34 -0500 Subject: [PATCH 08/10] Add specific dependencies for Debian based distros --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index d549dc89c..bd3f27d65 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,15 @@ Once everything in place, you can launch build scripts as described in correspon Building on Linux ================= +Dependencies +------------ +Apt based distros: +``` +sudo apt install libsdl2-dev, libsdl2-mixer-dev, libsdl2-ttf-dev, libsdl2-mixer-dev, zlib1g-dev, libglerw-dev +``` + +Build steps +----------- The build process has been reworked to reduce the number of steps and chance of failure. It handles building and moving data and resources into the correct locations at the right time and cloning repositories as required. The game is build in the ```mc2/build64``` directory. You only need to clone the mc2 directory and the build process will clone the data directory and SDL2 cmake modules for you the first time you run the build process. The mc2 and mc2srcdata projects will be cloned side by side and the build process relies on this. The top level directory structure will look like : From 8fd12ede89a435edcb45066f3043c06fa70b5439 Mon Sep 17 00:00:00 2001 From: igough Date: Mon, 19 Feb 2024 08:01:50 -0500 Subject: [PATCH 09/10] Fix typo in dependencies --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd3f27d65..8a178fe14 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Dependencies ------------ Apt based distros: ``` -sudo apt install libsdl2-dev, libsdl2-mixer-dev, libsdl2-ttf-dev, libsdl2-mixer-dev, zlib1g-dev, libglerw-dev +sudo apt install libsdl2-dev, libsdl2-mixer-dev, libsdl2-ttf-dev, libsdl2-mixer-dev, zlib1g-dev, libglew-dev ``` Build steps From 9063b3ee978b074689b8fed9ee226b674216e9ea Mon Sep 17 00:00:00 2001 From: igough Date: Fri, 23 Feb 2024 14:20:12 -0500 Subject: [PATCH 10/10] Fix segmentation fault --- mclib/txmmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mclib/txmmgr.cpp b/mclib/txmmgr.cpp index 03baa87be..79b381ab8 100644 --- a/mclib/txmmgr.cpp +++ b/mclib/txmmgr.cpp @@ -571,7 +571,7 @@ void MC_TextureManager::addRenderShape(DWORD nodeId, TG_RenderShape* render_shap masterTextureNodes[nodeId].hardwareVertexData2->currentShape = shapes; } - else if (masterTextureNodes[nodeId].vertexData3 && + else if (masterTextureNodes[nodeId].hardwareVertexData3 && masterTextureNodes[nodeId].vertexData3->flags == flags) { TG_RenderShape * shapes = masterTextureNodes[nodeId].hardwareVertexData3->currentShape;