Comprehensive Guide to Editing, Updating, and Rebuilding SWGEmu Core3

Prerequisites


1. Editing and Committing Local Changes

Step 1: Navigate to Your Repository

Open your terminal and navigate to your Core3 repository:

cd ~/Core3/MMOCoreORB

Step 2: Ensure You're on the Correct Branch

Make sure you're on the unstable branch (or the branch you intend to work on):

git checkout unstable

Step 3: Check the Current Status

Before making changes, it's good practice to check the current status of your repository:

git status

This command will show you:

Step 4: Edit the Files

Make your desired changes to the files using your preferred text editor or IDE. For example, to edit config.lua:

nano ~/Core3/MMOCoreORB/bin/conf/config.lua

(You can replace nano with vim, gedit, or any editor you prefer.)

Step 5: Stage Your Changes

After editing, you need to stage the changes to prepare them for committing:

git add path/to/your/file1 path/to/your/file2

Example:

git add bin/conf/config.lua
git add .

This stages all modified and new files in the repository.

Step 6: Commit Your Changes

Commit the staged changes with a descriptive message:

git commit -m "Describe the changes you made"

Example:

git commit -m "Update server configuration settings for improved performance"

2. Pulling Latest Changes and Handling Merge Conflicts

Step 7: Pull the Latest Changes from Remote

Now, fetch and merge the latest changes from the remote unstable branch:

git pull

What Happens Here:

Note: If you encounter an error like:
fatal: detected dubious ownership in repository at '/home/swgemu/Core3'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/swgemu/Core3

Resolve it by running:

git config --global --add safe.directory /home/swgemu/Core3

Then, try pulling again:

git pull

Step 8: Resolve Merge Conflicts (If Any)

Sometimes, Git may encounter conflicts between your local changes and the remote updates. Here's how to handle them:

  1. Identify Conflicts:

    After running git pull, Git will notify you if there are merge conflicts. You can also check the status:

    git status

    Conflicted files will be marked as Unmerged.

  2. Open Conflicted Files:

    Open each conflicted file in your editor. Git marks conflicts using the following syntax:

    <<<<< HEAD
    Your local changes
    =======
    Remote changes
    >>>>> [commit hash]
  3. Resolve Conflicts:
  4. Stage Resolved Files:

    After resolving conflicts, stage the files:

    git add path/to/conflicted/file
  5. Complete the Merge:

    Once all conflicts are resolved and staged, commit the merge:

    git commit -m "Resolve merge conflicts between local changes and remote updates"

3. Rebuilding SWGEmu Core3 with Updated Code

Step 9: Delete the Old Build Directory

Since the CMakeLists.txt file is located in ~/Core3/MMOCoreORB, you need to manage the build directory within that folder.

Remove the existing build directory to ensure a clean build:

rm -rf ~/Core3/MMOCoreORB/build
Warning: Be cautious with the rm -rf command to avoid deleting unintended files. Double-check the path before executing.

Step 10: Create a New Build Directory

Create a new build directory inside MMOCoreORB and navigate into it:

mkdir ~/Core3/MMOCoreORB/build
cd ~/Core3/MMOCoreORB/build

Step 11: Configure the Build System with CMake

From the new build directory, run CMake to configure the build system with the required build type:

cmake -DCMAKE_BUILD_TYPE=Release ..

Explanation:

Step 12: Build the Project

Compile the project using the make command:

make -j$(nproc)

Explanation:


4. Additional Considerations

Backup and Restore Configuration Files

If you have customized any configuration files, it's wise to back them up before rebuilding:

Backup:

cp ~/Core3/MMOCoreORB/bin/conf/config.lua ~/Core3/MMOCoreORB/bin/conf/config.lua.bak

Restore After Build (If Necessary):

If the build process overwrites your configuration files, you can restore them:

cp ~/Core3/MMOCoreORB/bin/conf/config.lua.bak ~/Core3/MMOCoreORB/bin/conf/config.lua

Database Migrations (If Applicable)

If the update includes changes to the database schema:

mysqldump -u [username] -p[password] swgemu > swgemu-backup.sql

5. Best Practices

a. Regularly Commit Your Changes

Frequent commits help in tracking changes and make it easier to manage merges.

b. Pull Often

Regularly pulling updates reduces the likelihood of complex merge conflicts.

c. Use Descriptive Commit Messages

Clear commit messages make it easier to understand the history of changes.

d. Consider Using Feature Branches

For substantial changes, consider creating a new branch. This isolates your work and makes collaboration smoother.

Creating a New Branch:

git checkout -b my-feature-branch

Switching Back to unstable:

git checkout unstable

Merging Your Feature Branch into unstable:

  1. Switch to unstable:
    git checkout unstable
  2. Pull the Latest Changes:
    git pull
  3. Merge Your Feature Branch:
    git merge my-feature-branch

e. Backup Important Files

Before making significant changes, back up configuration files or other critical files.


6. Additional Tips