-
Notifications
You must be signed in to change notification settings - Fork 2
0.8.0 -> 0.9.0 Patch Example #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 0.8.7
Are you sure you want to change the base?
Conversation
* Fixes Not Compiling on Windows * cleanup * fixing silent (?) crash * Remove <filesystem>
Needed for #95 [skip ci]
closes #122 [skip ci]
Related to #43 Code courtesy of ChatGPT and lightly modified by me.
ChatGPT failed. Trying phind now.
[skip ci]
[skip ci]
The amd64 image gets overwritten after the arm64 image is pushed. I think this will work? Maybe docker/build-push-action#733 ?
Right now when it's enabled, NP crashes before it gets to the main menu. I think we should disable it until the game can actually be played.
* if CIRRUS and darwin, then change the test a little * CI: Add skip rules to Cirrus CI closes #132
We shouldn't link to GitHub when the file is in the current directory structure. The links will still be rendered properly on GH. Helps with editor integration.
[skip ci]
In other words: fixes explosions always being at 100% volume
…orking Fixing volume controls not affecting ambient sounds, explosions, etc.
Fixes Bots Crashing - Always use physfs
const std::vector<UnitBase *> &uc = | ||
UnitInterface::getPlayerUnits(PlayerInterface::getLocalPlayerIndex()); | ||
|
||
for (Uint8 id_list_index = 0; id_list_index < uc.size(); ++id_list_index) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
id_list_index
call to size
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable id_list_index
is of a type that is at least as wide as the type returned by uc.size()
. The best way to achieve this is to change the type of id_list_index
from Uint8
to size_t
, which matches the type of uc.size()
.
- Change the type of
id_list_index
fromUint8
tosize_t
. - This change should be made in the file
src/NetPanzer/Bot/Bot.cpp
on line 132.
-
Copy modified line R132
@@ -131,3 +131,3 @@ | ||
|
||
for (Uint8 id_list_index = 0; id_list_index < uc.size(); ++id_list_index) { | ||
for (size_t id_list_index = 0; id_list_index < uc.size(); ++id_list_index) { | ||
unit_ptr = uc[id_list_index]; |
if (uc.size() > 0) { | ||
UnitBase *unitsl = uc[rand() % uc.size()]; | ||
|
||
for (Uint8 i = 0; i < uc.size(); ++i) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
call to size
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
is of a type that can safely be compared with the return value of uc.size()
. The best way to do this is to change the type of i
from Uint8
to size_t
, which is the type returned by the size()
function of the vector. This ensures that the comparison is made between two values of the same type, preventing any potential overflow or unexpected behavior.
-
Copy modified line R116
@@ -115,3 +115,3 @@ | ||
|
||
for (Uint8 i = 0; i < uc.size(); ++i) { | ||
for (size_t i = 0; i < uc.size(); ++i) { | ||
UnitBase *unit = uc[i]; |
UnitInterface::getPlayerUnits(playerIndex); | ||
unsigned char threat_count = 0; | ||
|
||
for (Uint8 i = 0; i < uc.size(); ++i) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
call to size
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
used in the loop condition has a type that is at least as wide as the type returned by the size()
method of the vector. The best way to achieve this is to change the type of i
from Uint8
to std::vector<UnitBase *>::size_type
, which is the type returned by the size()
method of the vector. This ensures that the comparison is made between values of the same type, preventing any potential overflow or unexpected behavior.
-
Copy modified line R316
@@ -315,3 +315,3 @@ | ||
|
||
for (Uint8 i = 0; i < uc.size(); ++i) { | ||
for (std::vector<UnitBase *>::size_type i = 0; i < uc.size(); ++i) { | ||
UnitBase *enemyUnit; |
UnitInterface::getPlayerUnits(playerIndex); | ||
unsigned char moving_count = 0; | ||
|
||
for (Uint8 i = 0; i < uct.size(); ++i) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
call to size
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
used in the loop condition has a type that is at least as wide as the type returned by the size()
method of the vector. The best way to achieve this is to change the type of i
from Uint8
to std::vector<UnitBase *>::size_type
, which is the type returned by the size()
method.
This change ensures that the comparison in the loop condition is between two values of the same type, preventing any potential overflow or unexpected behavior.
-
Copy modified line R316 -
Copy modified line R382
@@ -315,3 +315,3 @@ | ||
|
||
for (Uint8 i = 0; i < uc.size(); ++i) { | ||
for (std::vector<UnitBase *>::size_type i = 0; i < uc.size(); ++i) { | ||
UnitBase *enemyUnit; | ||
@@ -381,3 +381,3 @@ | ||
|
||
for (Uint8 i = 0; i < uct.size(); ++i) { | ||
for (std::vector<UnitBase *>::size_type i = 0; i < uct.size(); ++i) { | ||
if (uct[i]->unit_state.moving == true) { |
dbHeader->tile_count = file.readULE16(); | ||
file.read(&dbHeader->palette, sizeof(dbHeader->palette), 1); | ||
void TileSet::computeTileConsts(void) { | ||
tile_size = tile_set_info.x_pix * tile_set_info.y_pix; |
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the multiplication is performed using the larger type (unsigned long
) to avoid overflow. This can be achieved by casting one of the operands to unsigned long
before performing the multiplication. This way, the multiplication will be done in the larger type, and the result will be correctly assigned to tile_size
.
-
Copy modified line R53
@@ -52,3 +52,3 @@ | ||
void TileSet::computeTileConsts(void) { | ||
tile_size = tile_set_info.x_pix * tile_set_info.y_pix; | ||
tile_size = static_cast<unsigned long>(tile_set_info.x_pix) * tile_set_info.y_pix; | ||
} |
|
||
size_t map_size = map_info.width * map_info.height; | ||
size_t map_size = map_info.width * map_info.height; |
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the multiplication is performed using the larger type (size_t
) to avoid overflow. This can be achieved by casting one or both operands to size_t
before performing the multiplication. This way, the multiplication will be done using the larger type, and the result will be correctly stored in the size_t
variable.
-
Copy modified line R54
@@ -53,3 +53,3 @@ | ||
|
||
size_t map_size = map_info.width * map_info.height; | ||
size_t map_size = static_cast<size_t>(map_info.width) * static_cast<size_t>(map_info.height); | ||
|
} | ||
|
||
void ObjectiveInterface::disownPlayerObjectives(PlayerID player_id) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
num_objectives
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
is of a type that is at least as wide as the type of num_objectives
. Since num_objectives
is of type int
, we should change the type of i
to int
as well. This will prevent any potential overflow issues and ensure that the comparison behaves as expected.
-
Copy modified line R424 -
Copy modified line R449
@@ -423,3 +423,3 @@ | ||
void ObjectiveInterface::disownPlayerObjectives(PlayerID player_id) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { | ||
for (int i = 0; i < num_objectives; ++i) { | ||
if (objective_list[i]->occupying_player && | ||
@@ -448,3 +448,3 @@ | ||
Objective* ObjectiveInterface::getObjectiveAtWorldXY(const iXY& loc) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { | ||
for (int i = 0; i < num_objectives; ++i) { | ||
if (objective_list[i]->selection_box.contains(loc)) { |
} | ||
|
||
Objective* ObjectiveInterface::getObjectiveAtWorldXY(const iXY& loc) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
num_objectives
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the type of the loop variable i
is at least as wide as the type of num_objectives
. The best way to achieve this is to change the type of i
from Uint16
to int
, which matches the type of num_objectives
. This change will prevent any potential overflow issues and ensure that the comparison behaves as expected.
-
Copy modified line R424 -
Copy modified line R449
@@ -423,3 +423,3 @@ | ||
void ObjectiveInterface::disownPlayerObjectives(PlayerID player_id) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { | ||
for (int i = 0; i < num_objectives; ++i) { | ||
if (objective_list[i]->occupying_player && | ||
@@ -448,3 +448,3 @@ | ||
Objective* ObjectiveInterface::getObjectiveAtWorldXY(const iXY& loc) { | ||
for (Uint16 i = 0; i < num_objectives; ++i) { | ||
for (int i = 0; i < num_objectives; ++i) { | ||
if (objective_list[i]->selection_box.contains(loc)) { |
// Create the correct number of unit information slots. | ||
unitParticleInfo.resize(UnitProfileInterface::getNumUnitTypes()); | ||
|
||
for (unsigned short i = 0; i < UnitProfileInterface::getNumUnitTypes(); i++) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
call to getNumUnitTypes
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
is of a type that is at least as wide as the return type of UnitProfileInterface::getNumUnitTypes()
. The best way to fix this without changing existing functionality is to change the type of i
from unsigned short
to unsigned int
.
-
Copy modified line R1012
@@ -1011,3 +1011,3 @@ | ||
|
||
for (unsigned short i = 0; i < UnitProfileInterface::getNumUnitTypes(); i++) { | ||
for (unsigned int i = 0; i < UnitProfileInterface::getNumUnitTypes(); i++) { | ||
unsigned short vector_index = i * GameManager::ststylesnum; |
|
||
if (NetworkState::status == _network_state_server) // server only | ||
{ | ||
for (unsigned char i = 0; i < GameConfig::getUnitStylesNum(); i++) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
i
call to getUnitStylesNum
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, we need to ensure that the variable i
is of a type that is at least as wide as the type returned by GameConfig::getUnitStylesNum()
. Since GameConfig::getUnitStylesNum()
returns an unsigned short
, we should change the type of i
to unsigned short
to match.
-
Copy modified line R98 -
Copy modified line R109
@@ -97,3 +97,3 @@ | ||
{ | ||
for (unsigned char i = 0; i < GameConfig::getUnitStylesNum(); i++) { | ||
for (unsigned short i = 0; i < GameConfig::getUnitStylesNum(); i++) { | ||
NPString sstyle = GameConfig::getUnitStyle(i); | ||
@@ -108,3 +108,3 @@ | ||
} else { | ||
for (unsigned char i = 0; i < GameManager::ststylesnum; i++) { | ||
for (unsigned short i = 0; i < GameManager::ststylesnum; i++) { | ||
NPString sstyle = GameManager::stlist[i]; |
No description provided.