diff --git a/.env.example b/.env.example index 22fff590..bbda7da6 100644 --- a/.env.example +++ b/.env.example @@ -5,11 +5,12 @@ BUILD_THREADS=1 # Updates NET_VERSION in CMakeVariables.txt BUILD_VERSION=171022 # make sure this is a long random string +# grab a "SHA 256-bit Key" from here: https://keygen.io/ ACCOUNT_MANAGER_SECRET= # Should be the externally facing IP of your server host EXTERNAL_IP=localhost # Database values -MARIADB_USER=SECRET_VALUE_CHANGE_ME +MARIADB_USER=darkflame MARIADB_PASSWORD=SECRET_VALUE_CHANGE_ME MARIADB_ROOT_PASSWORD=SECRET_VALUE_CHANGE_ME -MARIADB_DATABASE=SECRET_VALUE_CHANGE_ME \ No newline at end of file +MARIADB_DATABASE=darkflame \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 00000000..3d0c5cc8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,51 @@ +name: Bug Report +description: Report incorrect behavior in DarkflameServer +title: "BUG: " +labels: ["bug", "triage"] + +body: + - type: checkboxes + id: checks + attributes: + options: + - label: > + I have checked that this issue has not already been reported. + required: true + - label: > + I have validated that this issue is not a syntax error of either MySQL or SQLite. + required: true + - label: > + I have pulled the latest version of the main branch of DarkflameServer and have confirmed that the issue exists there. + required: true + - type: textarea + id: problem + attributes: + label: Issue Description + description: > + Please provide a description of the issue. If this is an in-game bug, please also include pictures that showcase the issue. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction steps + description: > + Please provide a concise list of steps needed to reproduce this issue. + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: Expected Behavior + description: > + Please describe what you expected to happen instead of the issue. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: > + Please include the environment you're running DarkflameServer on (for example: Windows, macOS, Ubuntu, WSL, etc). + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_improvement.yaml b/.github/ISSUE_TEMPLATE/documentation_improvement.yaml new file mode 100644 index 00000000..12d4cb4a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_improvement.yaml @@ -0,0 +1,42 @@ +name: Documentation Improvement +description: Report wrong or missing documentation +title: "DOC: " +labels: ["docs", "triage"] + +body: + - type: checkboxes + attributes: + options: + - label: > + I have checked that this issue has not already been reported. + required: true + - label: > + I have validated that the documentation is wrong or missing on the latest version of the main branch of DarkflameServer + required: true + - type: textarea + id: location + attributes: + label: Location of the documentation + description: > + Please provide the location of the documentation, e.g. "Entity.cpp" or the + URL of the documentation, e.g. + "https://github.com/DarkflameUniverse/DarkflameServer/blob/main/README.md" + placeholder: https://github.com/DarkflameUniverse/DarkflameServer/blob/main/README.md + validations: + required: true + - type: textarea + id: problem + attributes: + label: Documentation problem + description: > + Please provide a description of what documentation you believe needs to be fixed/improved + validations: + required: true + - type: textarea + id: suggested-fix + attributes: + label: Suggested fix for documentation + description: > + Please explain the suggested fix and **why** it's better than the existing documentation + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 00000000..2f0b839a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,40 @@ +name: Feature Request +description: Suggest an idea for DarkflameServer +title: "ENH: " +labels: ["enhancement", "triage"] + +body: + - type: textarea + id: problem + attributes: + label: Is your feature request related to a problem? + description: > + Please provide a description of what the problem is, e.g. "I wish I could use DarkflameServer to do [...]" + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe the solution you'd like + description: > + Please provide a description of the feature request, e.g. "`SlashCommandHandler.cpp` should get a new command `/unlimited-coins` that [...]", try to write a docstring for the desired feature + validations: + required: true + - type: textarea + id: implications + attributes: + label: Repository breaking implications + description: > + Please provide a description of how this feature will affect the DarkflameServer repository + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: > + Please provide a description of any alternative solutions or features you've considered + - type: textarea + id: example + attributes: + label: Additional context + description: > + Please add any other context, code examples, or references to existing implementations about the feature request here diff --git a/.github/ISSUE_TEMPLATE/installation_issue.yaml b/.github/ISSUE_TEMPLATE/installation_issue.yaml new file mode 100644 index 00000000..f5cfb566 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/installation_issue.yaml @@ -0,0 +1,53 @@ +name: Installation Issue +description: Report issues installing the DarkflameServer on your system +title: "BUILD: " +labels: ["build", "triage"] + +body: + - type: checkboxes + id: checks + attributes: + options: + - label: > + I have read the [installation guide](https://github.com/DarkflameUniverse/DarkflameServer/blob/main/README.md). + required: true + - type: dropdown + id: platform + attributes: + label: Platform + description: > + Please provide on which platform you've tried to install DarkflameServer + options: + - Windows + - WSL1 + - WSL2 + - macOS + - Ubuntu + - Other + validations: + required: true + - type: dropdown + id: architecture + attributes: + label: Architecture + description: > + Please provide on which architecture you've tried to install DarkflameServer + options: + - x86 + - ARM + validations: + required: true + - type: textarea + id: logs + attributes: + label: Error Logs + description: > + If possible, please copy and paste the error logs when attempting to install DarkflameServer. + value: > +
+ + + Replace this line with the error logs. + + +
diff --git a/.github/ISSUE_TEMPLATE/performance_issue.yaml b/.github/ISSUE_TEMPLATE/performance_issue.yaml new file mode 100644 index 00000000..f9fe4945 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/performance_issue.yaml @@ -0,0 +1,33 @@ +name: Performance Issue +description: Report slow performance or memory issues when running DarkflameServer +title: "PERF: " +labels: ["performance", "triage"] + +body: + - type: checkboxes + id: checks + attributes: + options: + - label: > + I have checked that this issue has not already been reported. + required: true + - label: > + I have pulled the latest version of the main branch of DarkflameServer and have confirmed that the issue exists there. + required: true + - type: textarea + id: example + attributes: + label: Reproducible Example + description: > + Please provide a minimal, example that quantifies slow runtime or memory issues. + Ideally include screenshots of CPU usage or memory usage. And if possible point + to the code that you may suspect to cause the issue. + validations: + required: true + - type: textarea + id: prior-performance + attributes: + label: Prior Performance + description: > + If applicable, please provide the prior version of DarkflameServer and output + of the same reproducible example where the performance issue did not exist. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0030f49..64fcbc9f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,12 +36,89 @@ In general, we follow the "fork-and-pull" Git workflow - Open a PR in our repository. PRs should include (when applicable): +- A descriptive title that covers the **entire** content of the pull request - Description - Motivation and Context - Type of Changes - How Has This Been Tested? - Screenshots +## Commits + +Commits to this project should be concise, descriptive and to the point. Writing proper commits helps define a clear project history and makes it easier to browse the source and pinpoint issues. Although this might seem trivial, a pull request with improperly formatted commits will not be accepted. An overview of good commit practices can be found in [this](https://cbea.ms/git-commit/) article. In a nutshell, a good commit has: + +#### one conceptual change with a subject line that reflects it + +The subject line of the commit is what you specify when doing `git commit -m ""`. When making commit, make sure that you create it for one conceptual change. E.g. do not use a commit to dump all the changes you have locally, but split your changes into commits that conceptually make sense and use the subject line to refelct that. Some examples: + +**Bad:** +Commit message: `Document MovementAIComponent and add Avant Gardens Mech Scripts and fix Entity.cpp bug causing infinite loops` +Changed files: +- MovementAIComponent.cpp +- AgMechScript.cpp +- Entity.cpp + +**Good:** + +Commit message: `Document MovementAIComponent` +Changed files: +- MovementAIComponent.cpp + +Commit message: `Add Avant Gardens Mech Scripts` +Changed files: +- AgMechScript.cpp + +Commit message: `Fix Entity.cpp bug causing infinite loops` +Changed files: +- Entity.cpp + +Not only does this logically make more sense, it'll make it easier to revert a conceptual change once something wrong with it. If you commit using the bad example but your bugfix turned out to introduce an even worse bug, all your changes have to be reverted, even though your other changes might not be broken. Splitting your commits into conceptually unique commits makes it easier to find and revert issues. + +#### an imperative subject line + +In the subject line it's also important to have an imperative writing style that covers the contents of your commit so that it easily reflects what it'll do when applied. We pick an imperative writing style so that all commits have equal tonality. An easy check for this is placing `When applied, this commit will ...` in front of your commit message and checking if that makes sense. Some examples: + +**Bad:** +``` +Nice commit :) -> "When applied, this commit will nice commit :)" +``` + +**Bad:** +``` +fixed bug -> "When applied, this commit will fixed bug" +``` + +**Good:** +``` +Fix Entity.cpp bug causing infinite loop -> "When applied, this commit will fix Entity.cpp bug causing infinite loop" +``` + +**Good:** +``` +Add Avant Gardens mech scripts -> "When applied, this commit will add Avant Gardens mech scripts" +``` + +#### a subject line and a body + +A good commit has a subject line that summarizes the change and a body that further describes the context required to understand the change. In this body you don't have to explain *what* the change was, as the code should reflect that, but *why* a change was made. Some examples: + +**Bad:** +``` +Add Avant Gardens mech scripts + +Added the Avant Gardens mech scripts by creaing a new file called +AgMechScripts.cpp and then adding the proper event handlers to that +to send events to the client regarding changes of the mech. +``` + +**Good:** +``` +Add Avant Gardens mech scripts + +Added the Avant Gardens mech scripts as they were previously not +added, which produced InvalidScript errors. +``` + ## Development Resources Check out a compiled list of development resources and tools [here](https://lu-dev.net/). diff --git a/Docker.md b/Docker.md index f1e58ebd..4968d48a 100644 --- a/Docker.md +++ b/Docker.md @@ -11,15 +11,11 @@ 1. Copy `.env.example` and save it as `.env` inside the root directory of this repository 2. Edit the `.env` file and add your path to your LEGO® Universe Client after `CLIENT_PATH=` 3. Update other values in the `.env` file as need (be sure to update passwords!) -4. Run `docker-compose up --build setup` -5. Run `docker-compose up -d database` -6. Run `docker-compose up --build -d account-manager brickbuildfix` -7. Run `docker-compose build darkflame` -8. Run `docker-compose exec darkflame /app/MasterServer -a` and setup your admin account -9. Run `docker-compose up -d darkflame` -10. Now you can see the output of the server with `docker compose logs -f --tail 100` or `docker-compose logs -f --tail 100`. This can help you understand issues and there you can also see when the server finishes it's startup. Exit this with Ctrl+C. -11. You're ready to connect your client! -12. You can stop the server with `docker-compose stop` and start it again with `docker-compose up -d`. +4. Run `docker compose up -d --build` +5. Run `docker compose exec darkflame /app/MasterServer -a` and setup your admin account +6. Now you can see the output of the server with `docker compose logs -f --tail 100` or `docker compose logs -f --tail 100`. This can help you understand issues and there you can also see when the server finishes it's startup. Exit this with Ctrl+C. +7. You're ready to connect your client! +8. You can stop the server with `docker-compose stop` and start it again with `docker-compose up -d`. ## Disable brickbuildfix diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 060c53d6..057a6568 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -460,7 +460,7 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet) std::string promotedPlayer = PacketUtils::ReadString(0x14, packet, true); - Game::logger->Log("ChatPacketHandler", "(%llu) promiting (%s) to team leader\n", playerID, promotedPlayer.c_str()); + Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader\n", playerID, promotedPlayer.c_str()); auto* promoted = playerContainer.GetPlayerData(promotedPlayer); diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index ffd40ed7..50ea26b1 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -296,7 +296,7 @@ void InventoryComponent::RemoveItem(const LOT lot, const uint32_t count, eInvent { if (count == 0) { - Game::logger->Log("InventoryComponent", "Attempted to remove 0 of item (%i) to the inventory!\n", lot); + Game::logger->Log("InventoryComponent", "Attempted to remove 0 of item (%i) from the inventory!\n", lot); return; } diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index a882f314..e7fd02c8 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -718,7 +718,7 @@ void RacingControlComponent::Update(float deltaTime) { m_Started = true; - Game::logger->Log("RacingControlComponent", "Starting rase\n"); + Game::logger->Log("RacingControlComponent", "Starting race\n"); EntityManager::Instance()->SerializeEntity(m_Parent); @@ -871,7 +871,7 @@ void RacingControlComponent::Update(float deltaTime) { } Game::logger->Log("RacingControlComponent", - "Rached point (%i)/(%i)\n", player.respawnIndex, + "Reached point (%i)/(%i)\n", player.respawnIndex, path->pathWaypoints.size()); break; diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index 75d4c586..b77be4b2 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -237,7 +237,7 @@ void Inventory::AddManagedItem(Item* item) if (slots.find(slot) != slots.end()) { - Game::logger->Log("Inventory", "Attempting to add an item with and already present slot (%i)!\n", slot); + Game::logger->Log("Inventory", "Attempting to add an item with an already present slot (%i)!\n", slot); return; } diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 1c73fd22..8f89d8c8 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -159,9 +159,9 @@ int main(int argc, char** argv) { auto master_server_ip = config.GetValue("master_ip"); - if (master_server_ip == "") { - master_server_ip = Game::server->GetIP(); - } + if (master_server_ip == "") { + master_server_ip = Game::server->GetIP(); + } //If we found a server, update it's IP and port to the current one. if (result->next()) { diff --git a/dScripts/AgDarklingMech.cpp b/dScripts/AgDarklingMech.cpp deleted file mode 100644 index 335eabe4..00000000 --- a/dScripts/AgDarklingMech.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "AgDarklingMech.h" -#include "DestroyableComponent.h" - -void AgDarklingMech::OnStartup(Entity *self) { - auto* destroyableComponent = self->GetComponent(); - if (destroyableComponent != nullptr) { - destroyableComponent->SetFaction(4); - } -} diff --git a/dScripts/AgDarklingMech.h b/dScripts/AgDarklingMech.h deleted file mode 100644 index 2d92f2f6..00000000 --- a/dScripts/AgDarklingMech.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include "BaseEnemyMech.h" - -class AgDarklingMech : public BaseEnemyMech { - void OnStartup(Entity* self) override; -}; diff --git a/dScripts/AmDarklingMech.cpp b/dScripts/AmDarklingMech.cpp index dd95883b..59eb6b45 100644 --- a/dScripts/AmDarklingMech.cpp +++ b/dScripts/AmDarklingMech.cpp @@ -3,9 +3,6 @@ void AmDarklingMech::OnStartup(Entity* self) { - auto* destroyableComponent = self->GetComponent(); - - destroyableComponent->SetFaction(4); - + BaseEnemyMech::OnStartup(self); qbTurretLOT = 13171; } diff --git a/dScripts/BaseEnemyMech.cpp b/dScripts/BaseEnemyMech.cpp index 37678857..eb95095a 100644 --- a/dScripts/BaseEnemyMech.cpp +++ b/dScripts/BaseEnemyMech.cpp @@ -7,6 +7,14 @@ #include "EntityManager.h" #include "dpWorld.h" #include "GeneralUtils.h" +#include "DestroyableComponent.h" + +void BaseEnemyMech::OnStartup(Entity* self) { + auto* destroyableComponent = self->GetComponent(); + if (destroyableComponent != nullptr) { + destroyableComponent->SetFaction(4); + } +} void BaseEnemyMech::OnDie(Entity* self, Entity* killer) { ControllablePhysicsComponent* controlPhys = static_cast(self->GetComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS)); diff --git a/dScripts/BaseEnemyMech.h b/dScripts/BaseEnemyMech.h index f9f0b025..a8955061 100644 --- a/dScripts/BaseEnemyMech.h +++ b/dScripts/BaseEnemyMech.h @@ -4,6 +4,7 @@ class BaseEnemyMech : public CppScripts::Script { public: + void OnStartup(Entity* self) override; void OnDie(Entity* self, Entity* killer) override; protected: LOT qbTurretLOT = 6254; diff --git a/dScripts/BossSpiderQueenEnemyServer.cpp b/dScripts/BossSpiderQueenEnemyServer.cpp index 0b44f4ac..9896fd45 100644 --- a/dScripts/BossSpiderQueenEnemyServer.cpp +++ b/dScripts/BossSpiderQueenEnemyServer.cpp @@ -243,7 +243,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) { // Prep the selected spider egg //randomEgg:FireEvent{s}erID=self, args="prepEgg"} eggEntity->OnFireEventServerSide(self, "prepEgg"); - Game::logger->Log("SpiderQueen", "Preppign egg %llu\n", eggEntity->GetObjectID()); + Game::logger->Log("SpiderQueen", "Prepping egg %llu\n", eggEntity->GetObjectID()); // Add the prepped egg to our hatchList hatchList.push_back(eggEntity->GetObjectID()); diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 99702805..ed59c5ba 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -51,7 +51,6 @@ #include "NpcCowboyServer.h" #include "ZoneAgMedProperty.h" #include "AgStromlingProperty.h" -#include "AgDarklingMech.h" #include "AgDarkSpiderling.h" #include "PropertyFXDamage.h" #include "AgPropguards.h" @@ -377,7 +376,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\ai\\AG\\L_AG_STROMBIE_PROPERTY.lua") script = new AgStromlingProperty(); else if (scriptName == "scripts\\ai\\AG\\L_AG_DARKLING_MECH.lua") - script = new AgDarklingMech(); + script = new BaseEnemyMech(); else if (scriptName == "scripts\\ai\\AG\\L_AG_DARK_SPIDERLING.lua") script = new AgDarkSpiderling(); else if (scriptName == "scripts\\ai\\PROPERTY\\L_PROP_GUARDS.lua") diff --git a/dScripts/ImgBrickConsoleQB.cpp b/dScripts/ImgBrickConsoleQB.cpp index afa320c2..b24cb9bf 100644 --- a/dScripts/ImgBrickConsoleQB.cpp +++ b/dScripts/ImgBrickConsoleQB.cpp @@ -275,7 +275,7 @@ void ImgBrickConsoleQB::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { - Game::logger->Log("ImgBrickConsoleQB", "Reseting...\n"); + Game::logger->Log("ImgBrickConsoleQB", "Resetting...\n"); auto* rebuildComponent = self->GetComponent(); diff --git a/dScripts/VeMech.cpp b/dScripts/VeMech.cpp index e26b34b0..87f2e88f 100644 --- a/dScripts/VeMech.cpp +++ b/dScripts/VeMech.cpp @@ -1,5 +1,6 @@ #include "VeMech.h" void VeMech::OnStartup(Entity *self) { + BaseEnemyMech::OnStartup(self); qbTurretLOT = 8432; } diff --git a/docker-compose.yml b/docker-compose.yml index 7446748e..c49b2e7d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,10 +30,9 @@ services: - database:/var/lib/mysql networks: - darkflame - # (optional) ports only exposed so that DB management tools can connect - # Remove the # of the next two lines to expose your database + # You can expose these so that DB management tools can connect (WARNING: INSECURE) # ports: - # - 3306:3306 + # - 3306:3306 darkflame: container_name: DarkflameServer diff --git a/docker/setup.sh b/docker/setup.sh index 14d0951f..85776e6f 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -58,7 +58,7 @@ update_ini_values if [[ ! -d "/client" ]]; then echo "Client not found." - echo "Did you forgot to mount the client into the \"/client\" directory?" + echo "Did you forget to mount the client into the \"/client\" directory?" exit 1 fi @@ -69,8 +69,8 @@ if [[ ! -f "/client/extracted" ]]; then touch /client/extracted else - echo "Client already extracted. Skip this step" - echo "If you want to force re-extract, just delete the file called \"extracted\" in the client directory" + echo "Client already extracted. Skip this step..." + echo "If you want to force a re-extract, just delete the file called \"extracted\" in the client directory" fi if [[ ! -f "/client/migrated" ]]; then @@ -80,6 +80,6 @@ if [[ ! -f "/client/migrated" ]]; then touch /client/migrated else - echo "Client db already migrated. Skip this step" - echo "If you want to force re-migrate, just delete the file called \"migrated\" in the client directory" + echo "Client db already migrated. Skip this step..." + echo "If you want to force a re-migrate, just delete the file called \"migrated\" in the client directory" fi diff --git a/docker/start_server.sh b/docker/start_server.sh index 825d5014..cf22093c 100755 --- a/docker/start_server.sh +++ b/docker/start_server.sh @@ -37,12 +37,13 @@ else echo "Server already initialized" fi -while [ ! -f "/client/migrated" ]; do - echo "Client setup not finished. Waiting for setup container to complete" - sleep 1 +# check to make sure the setup has completed +while [ ! -f "/client/extracted" ] || [ ! -f "/client/migrated" ]; do + echo "Client setup not finished. Waiting for setup container to complete..." + sleep 5 done # start the server -echo "Start MasterServer" +echo "Starting MasterServer" ./MasterServer tail -f /dev/null \ No newline at end of file