Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/index_out_of_bounds_2025-01-…
Browse files Browse the repository at this point in the history
…11' into fix/index_out_of_bounds_2025-01-11
  • Loading branch information
stephengtuggy committed Jan 15, 2025
2 parents df25d52 + 4c99f0e commit 6dcf929
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 65 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]: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:
Expand Down
3 changes: 0 additions & 3 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
#


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)
INSTALL(FILES "${PROJECT_SOURCE_DIR}/AUTHORS" TYPE DOC RENAME AUTHORS.GITHUB)
INSTALL(FILES ChangeLog TYPE DOC)

ADD_SUBDIRECTORY(man)

2 changes: 0 additions & 2 deletions doc/man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,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)
Expand Down
2 changes: 0 additions & 2 deletions engine/objconv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions engine/setup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@
# along with Vega Strike. If not, see <https://www.gnu.org/licenses/>.
#

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)
Expand Down
9 changes: 1 addition & 8 deletions engine/setup/src/include/display.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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); \
}

Expand Down
12 changes: 9 additions & 3 deletions engine/setup/src/include/display_gtk.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -36,6 +38,8 @@ void ClickButton(GtkWidget *w, struct catagory *CUR);

#include <string>

#include <boost/format.hpp>

//#define USE_RADIO


Expand All @@ -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);
Expand Down
35 changes: 20 additions & 15 deletions engine/src/cmd/script/script_variables.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/*
* 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
*
* This file is part of Vega Strike.
*
* 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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -636,4 +642,3 @@ void Mission::saveVarInst(varInst *vi, std::ostream &aa_out) {
}
}
}

3 changes: 1 addition & 2 deletions engine/src/galaxy_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ void readplanetentity(vector<StarInfo> &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;
Expand Down Expand Up @@ -1517,4 +1517,3 @@ int main( int argc, char **argv )
return 0;
}
#endif

19 changes: 8 additions & 11 deletions engine/src/gfx/vdu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion engine/src/gldrv/gl_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6dcf929

Please sign in to comment.