From eb9ee8cf954977514bace1e74528008500fe7862 Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Fri, 10 Mar 2023 19:51:06 -0500 Subject: [PATCH 1/6] Make the ship's log bigger This should probably be a constant or more smart, but it bothered me now and this would fix the bother --- src/spaceObjects/playerSpaceship.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spaceObjects/playerSpaceship.cpp b/src/spaceObjects/playerSpaceship.cpp index ee21a59ab8..b5662ead7a 100644 --- a/src/spaceObjects/playerSpaceship.cpp +++ b/src/spaceObjects/playerSpaceship.cpp @@ -1117,9 +1117,9 @@ void PlayerSpaceship::setRepairCrewCount(int amount) void PlayerSpaceship::addToShipLog(string message, glm::u8vec4 color) { - // Cap the ship's log size to 100 entries. If it exceeds that limit, + // Cap the ship's log size to 10000 entries. If it exceeds that limit, // start erasing entries from the beginning. - if (ships_log.size() > 100) + if (ships_log.size() > 10000) ships_log.erase(ships_log.begin()); // Timestamp a log entry, color it, and add it to the end of the log. From 29bae6a030c78e3462d8425d0b7d60f8ade88277 Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Sat, 7 Oct 2023 16:02:24 -0400 Subject: [PATCH 2/6] Update src/spaceObjects/playerSpaceship.cpp Co-authored-by: Garrett Guillotte --- src/spaceObjects/playerSpaceship.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spaceObjects/playerSpaceship.cpp b/src/spaceObjects/playerSpaceship.cpp index b5662ead7a..0a8b3752a5 100644 --- a/src/spaceObjects/playerSpaceship.cpp +++ b/src/spaceObjects/playerSpaceship.cpp @@ -1117,7 +1117,7 @@ void PlayerSpaceship::setRepairCrewCount(int amount) void PlayerSpaceship::addToShipLog(string message, glm::u8vec4 color) { - // Cap the ship's log size to 10000 entries. If it exceeds that limit, + // Cap the ship's log size to 400 entries. If it exceeds that limit, // start erasing entries from the beginning. if (ships_log.size() > 10000) ships_log.erase(ships_log.begin()); From b607f1c668824fd982065d5410b9c23f80eb1a87 Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Sat, 7 Oct 2023 16:02:50 -0400 Subject: [PATCH 3/6] Update src/spaceObjects/playerSpaceship.cpp Co-authored-by: Garrett Guillotte --- src/spaceObjects/playerSpaceship.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spaceObjects/playerSpaceship.cpp b/src/spaceObjects/playerSpaceship.cpp index 0a8b3752a5..8e072db081 100644 --- a/src/spaceObjects/playerSpaceship.cpp +++ b/src/spaceObjects/playerSpaceship.cpp @@ -1119,7 +1119,7 @@ void PlayerSpaceship::addToShipLog(string message, glm::u8vec4 color) { // Cap the ship's log size to 400 entries. If it exceeds that limit, // start erasing entries from the beginning. - if (ships_log.size() > 10000) + if (ships_log.size() > 400) ships_log.erase(ships_log.begin()); // Timestamp a log entry, color it, and add it to the end of the log. From a6d4b61451a6c554d383c0839780cceaf5cd1dd4 Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Mon, 9 Oct 2023 17:54:32 -0400 Subject: [PATCH 4/6] Fix off-by-one in log size check This is before insertion, so >400 is 401 lines. I noticed this when I set it to 10 for a different experiment and saw 11 lines. --- src/spaceObjects/playerSpaceship.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spaceObjects/playerSpaceship.cpp b/src/spaceObjects/playerSpaceship.cpp index 8e072db081..47f2350910 100644 --- a/src/spaceObjects/playerSpaceship.cpp +++ b/src/spaceObjects/playerSpaceship.cpp @@ -1119,7 +1119,7 @@ void PlayerSpaceship::addToShipLog(string message, glm::u8vec4 color) { // Cap the ship's log size to 400 entries. If it exceeds that limit, // start erasing entries from the beginning. - if (ships_log.size() > 400) + if (ships_log.size() >= 400) ships_log.erase(ships_log.begin()); // Timestamp a log entry, color it, and add it to the end of the log. From 1e13f81e7b21198c06ffd6f2e6cc6b24c7f2bc8a Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Fri, 13 Oct 2023 23:24:43 -0400 Subject: [PATCH 5/6] Change ship's log to a sequenced vector * sp::SeqVector provides efficient network sync * sequence #s must start at 1 for replication --- src/spaceObjects/playerSpaceship.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spaceObjects/playerSpaceship.h b/src/spaceObjects/playerSpaceship.h index f691272a09..136e56f1cb 100644 --- a/src/spaceObjects/playerSpaceship.h +++ b/src/spaceObjects/playerSpaceship.h @@ -5,6 +5,7 @@ #include "scanProbe.h" #include "commsScriptInterface.h" #include "playerInfo.h" +#include "seqvector.h" #include class ScanProbe; @@ -111,9 +112,10 @@ class PlayerSpaceship : public SpaceShip std::vector comms_reply_message; CommsScriptInterface comms_script_interface; // Server only // Ship's log container - std::vector ships_log; + sp::SeqVector ships_log; float energy_shield_use_per_second = default_energy_shield_use_per_second; float energy_warp_per_second = default_energy_warp_per_second; + unsigned int last_log_seq = 1; public: std::vector custom_functions; From c1d77184776152034c97d2c855b5adf1ac868ea7 Mon Sep 17 00:00:00 2001 From: Chris Sibbitt Date: Sat, 14 Oct 2023 00:23:10 -0400 Subject: [PATCH 6/6] Raise ship's log size to 10,000 --- src/spaceObjects/playerSpaceship.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spaceObjects/playerSpaceship.cpp b/src/spaceObjects/playerSpaceship.cpp index 47f2350910..62e604404f 100644 --- a/src/spaceObjects/playerSpaceship.cpp +++ b/src/spaceObjects/playerSpaceship.cpp @@ -1117,9 +1117,9 @@ void PlayerSpaceship::setRepairCrewCount(int amount) void PlayerSpaceship::addToShipLog(string message, glm::u8vec4 color) { - // Cap the ship's log size to 400 entries. If it exceeds that limit, + // Cap the ship's log size to 10000 entries. If it exceeds that limit, // start erasing entries from the beginning. - if (ships_log.size() >= 400) + if (ships_log.size() >= 10000) ships_log.erase(ships_log.begin()); // Timestamp a log entry, color it, and add it to the end of the log.