Skip to content
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

Steam networking testing #1

Merged
merged 63 commits into from
Jan 6, 2025
Merged

Steam networking testing #1

merged 63 commits into from
Jan 6, 2025

Conversation

BurntRanch
Copy link
Owner

No description provided.

@BurntRanch BurntRanch merged commit 25ebe17 into main Jan 6, 2025
1 check passed
@BurntRanch BurntRanch deleted the steam_networking_testing branch January 6, 2025 10:57
}
if (msgCount > 0) {
for (int i = 0; i < msgCount; i++) {
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));

Check failure

Code scanning / CodeQL

Suspicious add with sizeof High

Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is
ISteamNetworkingMessage *
.

Copilot Autofix AI 10 days ago

To fix the problem, we need to remove the manual scaling by sizeof(ISteamNetworkingMessage) in the pointer arithmetic expression. Instead of adding i * sizeof(ISteamNetworkingMessage) to incomingMessages, we should simply add i to it. This will correctly compute the offset based on the size of ISteamNetworkingMessage.

  • Change the line where incomingMessage is calculated by removing the multiplication by sizeof(ISteamNetworkingMessage).
  • The file to edit is src/engine.cpp.
  • No additional methods, imports, or definitions are needed to implement this change.
Suggested changeset 1
src/engine.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/engine.cpp b/src/engine.cpp
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -3113,3 +3113,3 @@
             for (int i = 0; i < msgCount; i++) {
-                ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));
+                ISteamNetworkingMessage *incomingMessage = incomingMessages + i;
 
EOF
@@ -3113,3 +3113,3 @@
for (int i = 0; i < msgCount; i++) {
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));
ISteamNetworkingMessage *incomingMessage = incomingMessages + i;

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
}
if (msgCount > 0) {
for (int i = 0; i < msgCount; i++) {
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));

Check failure

Code scanning / CodeQL

Suspicious add with sizeof High

Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is
ISteamNetworkingMessage *
.

Copilot Autofix AI 10 days ago

To fix the problem, we need to remove the manual scaling by sizeof(ISteamNetworkingMessage) in the pointer arithmetic. Instead of using incomingMessages + (i * sizeof(ISteamNetworkingMessage)), we should simply use incomingMessages + i. This will correctly compute the address of the i-th element in the array of ISteamNetworkingMessage pointers.

Suggested changeset 1
src/engine.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/engine.cpp b/src/engine.cpp
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -3233,3 +3233,3 @@
             for (int i = 0; i < msgCount; i++) {
-                ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));
+                ISteamNetworkingMessage *incomingMessage = incomingMessages + i;
 
EOF
@@ -3233,3 +3233,3 @@
for (int i = 0; i < msgCount; i++) {
ISteamNetworkingMessage *incomingMessage = incomingMessages + (i * sizeof(ISteamNetworkingMessage));
ISteamNetworkingMessage *incomingMessage = incomingMessages + i;

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants