From 0fdce91d4842cab07ba9c2430e33b8740b6a2864 Mon Sep 17 00:00:00 2001 From: "Stephen G. Tuggy" Date: Sun, 12 Jan 2025 16:13:17 -0800 Subject: [PATCH 1/6] Peer feedback: implementing Benjamen Meyer's suggestions --- engine/CMakeLists.txt | 7 ----- engine/setup/CMakeLists.txt | 7 ----- engine/src/cmd/script/script_variables.cpp | 35 ++++++++++++---------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 9cd66fe607..785680b281 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -34,15 +34,8 @@ MESSAGE("PROCESSING DIRECTORY: ${CMAKE_CURRENT_SOURCE_DIR}") CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR) -IF (POLICY CMP0087) - cmake_policy(SET CMP0087 NEW) -ENDIF () SET(X_VCPKG_APPLOCAL_DEPS_INSTALL ON) -IF (POLICY CMP0167) - CMAKE_POLICY (SET CMP0167 OLD) -ENDIF (POLICY CMP0167) - # One version header generator to rule them all CONFIGURE_FILE(src/version.h.in ${Vega_Strike_BINARY_DIR}/src/version.h) CONFIGURE_FILE(src/version.h.in ${Vega_Strike_BINARY_DIR}/setup/src/include/version.h) diff --git a/engine/setup/CMakeLists.txt b/engine/setup/CMakeLists.txt index fbcb998f1f..0b80ab7d01 100644 --- a/engine/setup/CMakeLists.txt +++ b/engine/setup/CMakeLists.txt @@ -24,15 +24,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR) -IF (POLICY CMP0087) - cmake_policy(SET CMP0087 NEW) -ENDIF () SET(X_VCPKG_APPLOCAL_DEPS_INSTALL ON) -IF (POLICY CMP0167) - CMAKE_POLICY (SET CMP0167 OLD) -ENDIF (POLICY CMP0167) - IF (CMAKE_SYSTEM_NAME STREQUAL BEOS OR CMAKE_SYSTEM_NAME STREQUAL Windows) MESSAGE ("SKIPPING vegasettings - not supported on this platform at this time") ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux) diff --git a/engine/src/cmd/script/script_variables.cpp b/engine/src/cmd/script/script_variables.cpp index 4670b78566..918613f363 100644 --- a/engine/src/cmd/script/script_variables.cpp +++ b/engine/src/cmd/script/script_variables.cpp @@ -1,9 +1,8 @@ /* * script_variables.cpp * - * Copyright (C) 2001-2002 Daniel Horn - * Copyright (C) Alexander Rawass - * Copyright (C) 2021-2022 Stephen G. Tuggy + * Copyright (C) 2001-2025 Daniel Horn, Alexander Rawass, Stephen G. Tuggy, + * and other Vega Strike contributors * * https://github.com/vegastrike/Vega-Strike-Engine-Source * @@ -11,7 +10,7 @@ * * Vega Strike is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Vega Strike is distributed in the hope that it will be useful, @@ -439,35 +438,42 @@ void Mission::doSetVar(missionNode *node, int mode) { node->script.name = node->attr_value("name"); if (node->script.name.empty()) { fatalError(node, mode, "you have to give a variable name"); + VS_LOG_FLUSH_EXIT(fatal, "you have to give a variable name", -1); } } debug(3, node, mode, "trying to set variable " + node->script.name); if (node->subnodes.size() != 1) { fatalError(node, mode, "setvar takes exactly one argument"); - assert(0); + VS_LOG_FLUSH_EXIT(fatal, "setvar takes exactly one argument", -1); } missionNode *expr = (missionNode *) node->subnodes[0]; if (mode == SCRIPT_PARSE) { varInst *vi = searchScopestack(node->script.name); - if (vi == NULL) { + if (vi == nullptr) { missionNode *global_var = runtime.global_variables[node->script.name]; - if (global_var == NULL) { + if (global_var == nullptr) { fatalError(node, mode, "no variable " + node->script.name + " found on the scopestack (setvar)"); - assert(0); + VS_LOG_FLUSH_EXIT(fatal, (boost::format("no variable %1% found on the scopestack (setvar)") % node->script.name), -1); } vi = global_var->script.varinst; } - if (vi->type != VAR_BOOL && vi->type != VAR_FLOAT && vi->type != VAR_INT && vi->type != VAR_OBJECT) { - fatalError(node, mode, "unsupported type in setvar"); - assert(0); + switch (vi->type) { + case VAR_FLOAT: // fall-through + case VAR_INT: // fall-through + case VAR_BOOL: // fall-through + case VAR_OBJECT:// fall-through + break; + default: + fatalError(node, mode, "unsupported type in setvar"); + VS_LOG_FLUSH_EXIT(fatal, "unsupported type in setvar", -1); } } if (mode == SCRIPT_RUN) { varInst *var_inst = doVariable(node, mode); //lookup variable instance - if (var_inst == NULL) { + if (var_inst == nullptr) { fatalError(node, mode, "variable lookup failed for " + node->script.name); printRuntime(); - assert(0); + VS_LOG_FLUSH_EXIT(fatal, (boost::format("variable lookup failed for %1%") % node->script.name), -1); } if (var_inst->type == VAR_BOOL) { bool res = checkBoolExpr(expr, mode); @@ -488,7 +494,7 @@ void Mission::doSetVar(missionNode *node, int mode) { deleteVarInst(ovi); } else { fatalError(node, mode, "unsupported datatype"); - assert(0); + VS_LOG_FLUSH_EXIT(fatal, "unsupported datatype", -1); } } } @@ -636,4 +642,3 @@ void Mission::saveVarInst(varInst *vi, std::ostream &aa_out) { } } } - From 25ce9f26ce9d8139653b391da39ee50879952ce1 Mon Sep 17 00:00:00 2001 From: "Stephen G. Tuggy" Date: Sun, 12 Jan 2025 19:02:52 -0800 Subject: [PATCH 2/6] 5x CMakeLists.txt: Omit CMAKE_MINIMUM_REQUIRED clause, since it is specified at the root level of the project --- doc/CMakeLists.txt | 3 --- doc/man/CMakeLists.txt | 2 -- engine/CMakeLists.txt | 2 -- engine/objconv/CMakeLists.txt | 2 -- engine/setup/CMakeLists.txt | 2 -- 5 files changed, 11 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3e7b54bcbe..956e569d66 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -23,8 +23,6 @@ # -CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR) - INCLUDE(GNUInstallDirs) MESSAGE("Always using preferred method now to install doc files") INSTALL(FILES AUTHORS TYPE DOC RENAME AUTHORS.SF) @@ -32,4 +30,3 @@ INSTALL(FILES "${PROJECT_SOURCE_DIR}/AUTHORS" TYPE DOC RENAME AUTHORS.GITHUB) INSTALL(FILES ChangeLog TYPE DOC) ADD_SUBDIRECTORY(man) - diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index e694498c63..27442d22cd 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -23,8 +23,6 @@ # -CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR) - IF (UNIX) MESSAGE("Always using preferred method now to install man pages") INSTALL(FILES vegastrike-engine.1 TYPE MAN) diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 785680b281..05a7997866 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -32,8 +32,6 @@ MESSAGE("PROCESSING DIRECTORY: ${CMAKE_CURRENT_SOURCE_DIR}") -CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR) - SET(X_VCPKG_APPLOCAL_DEPS_INSTALL ON) # One version header generator to rule them all diff --git a/engine/objconv/CMakeLists.txt b/engine/objconv/CMakeLists.txt index 2deb9bc89e..1f6228a6a2 100644 --- a/engine/objconv/CMakeLists.txt +++ b/engine/objconv/CMakeLists.txt @@ -23,8 +23,6 @@ # -CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR) - #SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "") INCLUDE_DIRECTORIES("..") SET(TRISORT_SOURCES trisort.cpp) diff --git a/engine/setup/CMakeLists.txt b/engine/setup/CMakeLists.txt index 0b80ab7d01..1d0d361248 100644 --- a/engine/setup/CMakeLists.txt +++ b/engine/setup/CMakeLists.txt @@ -22,8 +22,6 @@ # along with Vega Strike. If not, see . # -CMAKE_MINIMUM_REQUIRED(VERSION 3.21 FATAL_ERROR) - SET(X_VCPKG_APPLOCAL_DEPS_INSTALL ON) IF (CMAKE_SYSTEM_NAME STREQUAL BEOS OR CMAKE_SYSTEM_NAME STREQUAL Windows) From 937d5d49b0d46673c53d0514a1d3ecb9fa3649fe Mon Sep 17 00:00:00 2001 From: "Stephen G. Tuggy" Date: Sun, 12 Jan 2025 19:13:12 -0800 Subject: [PATCH 3/6] Change all occurrences I could find of snprintf to pass the number of chars as the length of the buffer minus 1 --- engine/setup/src/include/display.h | 9 +-------- engine/src/galaxy_gen.cpp | 3 +-- engine/src/gldrv/gl_program.cpp | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/engine/setup/src/include/display.h b/engine/setup/src/include/display.h index 712c657661..dd62de8f5e 100644 --- a/engine/setup/src/include/display.h +++ b/engine/setup/src/include/display.h @@ -1,10 +1,3 @@ -/* -#==================================== -# @file : display.h -# @brief : setup configuration -#==================================== -*/ - /* * Copyright (C) 2001-2025 Daniel Horn, David Ranger, pyramid3d, * Stephen G. Tuggy, Benjamen R. Meyer, and other Vega Strike contributors. @@ -39,7 +32,7 @@ void ShowMain(); #define GET_TITLE char title[1000]="Vega Strike Settings"; \ if (strlen(CONFIG.program_name)+strlen(VERSION)<800) { \ - snprintf(title, 1000, "Settings - %s - Version %s", \ + snprintf(title, 999, "Settings - %s - Version %s", \ CONFIG.program_name, VEGASTRIKE_VERSION_STR); \ } diff --git a/engine/src/galaxy_gen.cpp b/engine/src/galaxy_gen.cpp index ae7c757511..899b42a4ec 100644 --- a/engine/src/galaxy_gen.cpp +++ b/engine/src/galaxy_gen.cpp @@ -1327,7 +1327,7 @@ void readplanetentity(vector &starinfos, string planetlist, unsigned i if (starinfos[u % numstars].planets.back().num == 0) { num[0] = 0; } else { - snprintf(num, sizeof(num), "%d", starinfos[u % numstars].planets.back().num); + snprintf(num, sizeof(num) - 1, "%d", starinfos[u % numstars].planets.back().num); } numpos = 0; @@ -1517,4 +1517,3 @@ int main( int argc, char **argv ) return 0; } #endif - diff --git a/engine/src/gldrv/gl_program.cpp b/engine/src/gldrv/gl_program.cpp index 7b5027350c..b89dfdb397 100644 --- a/engine/src/gldrv/gl_program.cpp +++ b/engine/src/gldrv/gl_program.cpp @@ -156,7 +156,7 @@ static VSFileSystem::VSError getProgramSource(const std::string &path, } else { // Append a blank line to avoid issues and restore line numbers lines.push_back("\n"); - snprintf(buf, buflen, "#line %zu\n", lineno); + snprintf(buf, buflen - 1, "#line %zu\n", lineno); lines.push_back(buf); } } else { From dc243bebc779e5674896932a10930c16b0f308ae Mon Sep 17 00:00:00 2001 From: "Stephen G. Tuggy" Date: Sun, 12 Jan 2025 20:13:51 -0800 Subject: [PATCH 4/6] display_gtk.cpp: Use boost::format to put together the application title with the version for the title bar --- engine/setup/src/include/display_gtk.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/engine/setup/src/include/display_gtk.cpp b/engine/setup/src/include/display_gtk.cpp index ef516615f8..e39b15ceac 100644 --- a/engine/setup/src/include/display_gtk.cpp +++ b/engine/setup/src/include/display_gtk.cpp @@ -1,5 +1,7 @@ /* - * Copyright (C) 2001-2022 Daniel Horn, David Ranger, + * display_gtk.cpp + * + * Copyright (C) 2001-2025 Daniel Horn, David Ranger, * pyramid3d, Stephen G. Tuggy, and other Vega Strike contributors. * * https://github.com/vegastrike/Vega-Strike-Engine-Source @@ -36,6 +38,8 @@ void ClickButton(GtkWidget *w, struct catagory *CUR); #include +#include + //#define USE_RADIO @@ -47,11 +51,13 @@ void exit_0(GtkWidget *w, void *arg) { void InitGraphics(int *argc, char ***argv) { gtk_init(argc, argv); - GET_TITLE; // sets title; uses sprintf, not snprintf -- //[MSVC-Warn] + GET_TITLE; GET_STATIC_TEXT; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 600, 400); - gtk_window_set_title(GTK_WINDOW(window), title); + gtk_window_set_title( + GTK_WINDOW(window), + (boost::format("Settings - %1% - Version %2%") % CONFIG.program_name % VEGASTRIKE_VERSION_STR).str().c_str()); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(exit_0), NULL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(exit_0), NULL); From 8ad2354b7c2a18b8dbbed7dc2b1a519a0fc8428b Mon Sep 17 00:00:00 2001 From: Benjamen Meyer Date: Mon, 13 Jan 2025 00:58:07 -0500 Subject: [PATCH 5/6] Enhancement: Minimize Download Size Document how others can minimize downloads, specifically for maintainers of systems like Gentoo, Arch, etc. Closes #83 --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index ce0e0dc04d..1ae0cc8af3 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,21 @@ If you encounter any issues while playing, please create an issue with the Vega # Compiling Vegastrike +## Saving some space while downloading + +The Vega Strike Engine Source repository contains a lot of history not all of which is relevant to current developers if they want to quickly download and build something. +By default, the full clone will download over 800 MB of data. There are several options to minimize this: + +1. Download a compressed copy of the source from the release +2. Download a master.zip from GitHub +3. Do a shallow clone using the following: + +```bash +$ git clone git@github.com:vegastrike/Vega-Strike-Engine-Source.git --shallow-since=2023-09-27 +``` + +This will produce a significantly smaller download - in the order of 22-30 MB; well over a 10x reduction. + ## Compiling On Linux 1. Install the development dependencies: From 4c99f0e44b679c86b814e3827cca28d5767d2ab1 Mon Sep 17 00:00:00 2001 From: Stephen G Tuggy Date: Tue, 14 Jan 2025 06:49:40 -0800 Subject: [PATCH 6/6] Apply @royfalk 's changes to vdu.cpp from #973 --- engine/src/gfx/vdu.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/engine/src/gfx/vdu.cpp b/engine/src/gfx/vdu.cpp index 6e15f3e5cd..1d41415917 100644 --- a/engine/src/gfx/vdu.cpp +++ b/engine/src/gfx/vdu.cpp @@ -1185,21 +1185,18 @@ void VDU::DrawDamage(Unit *parent) { float x, y, w, h; //float th; //char st[1024]; - GFXColor4f(1, parent->GetHull() / (*maxhull), parent->GetHull() / (*maxhull), 1); + double health_percent = parent->layers[0].facets[0].Percent(); + GFXColor4f(1, health_percent, health_percent, 1); GFXEnable(TEXTURE0); float armor[8]; parent->ArmorData(armor); const bool draw_damage_sprite = configuration()->graphics_config.hud.draw_damage_sprite; - DrawHUDSprite(this, draw_damage_sprite ? parent->getHudImage() : NULL, .6, x, y, w, h, - (armor[0] + armor[2] + armor[4] + armor[6]) - / (float) (StartArmor[0] + StartArmor[2] + StartArmor[4] + StartArmor[6]), - (armor[0] + armor[1] + armor[4] + armor[5]) - / (float) (StartArmor[0] + StartArmor[1] + StartArmor[4] + StartArmor[5]), - (armor[2] + armor[3] + armor[6] + armor[7]) - / (float) (StartArmor[2] + StartArmor[3] + StartArmor[6] + StartArmor[7]), - (armor[1] + armor[3] + armor[5] - + armor[7]) / (float) (StartArmor[1] + StartArmor[3] + StartArmor[5] + StartArmor[7]), - parent->GetHull() / (*maxhull), true, false); + DrawHUDSprite(this, draw_damage_sprite ? parent->getHudImage() : nullptr, .6, x, y, w, h, + parent->layers[1].facets[0].Percent(), + parent->layers[1].facets[3].Percent(), + parent->layers[1].facets[2].Percent(), + parent->layers[1].facets[1].Percent(), + health_percent, true, false); GFXDisable(TEXTURE0); //Unit *thr = parent->Threat(); parent->Threat();