Skip to content

Commit

Permalink
updated to latest svn
Browse files Browse the repository at this point in the history
  • Loading branch information
s0t7x committed Oct 9, 2024
1 parent c74fb39 commit 377c0fd
Show file tree
Hide file tree
Showing 7 changed files with 511 additions and 338 deletions.
26 changes: 16 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ Shroudtopia
<b>Creative Mode Mod for Enshrouded Dedicated Servers</b>
</p>
<p align="center">
<img alt="Static Badge" src="https://img.shields.io/badge/Game%20Version%20(SVN)-555489-blue">
<img alt="Static Badge" src="https://img.shields.io/badge/Game%20Version%20(SVN)-558123-blue">
</p>

I'm excited to introduce **Shroudtopia**, a mod that brings creative mode functionalities to Enshrouded dedicated servers. Whether you're a builder looking for unlimited resources or an explorer seeking freedom from limitations, Shroudtopia enhances your gameplay experience.

## Features

- **Custom Experience Multiplier:** Adjust experience gain to your preference.
- **Fly Mode with Glider:** Enjoy full flight capabilities with the glider.
- **Fly:** Enjoy full flight capabilities with the glider. No more losing height!
- **Infinite Altars:** Bypass the general altar limit and make the world yours.
- ~~**Custom Experience Multiplier:** Adjust experience gain to your preference.~~ *(Obsolete since official gameSettings implementation)*
- **No Fall Damage:** Explore without the fear of taking fall damage.
- **No Stamina Loss:** Infinite stamina for uninterrupted gameplay.
- **No Durability Loss:** Gear and items never degrade or break.
- **Item Duplication:** Splitting stacks results in cloned items.
- **Free Crafting & Building:** Resources are required but crafting and building have no resource cost.
- ~~**No Durability Loss:** Gear and items never degrade or break.~~ *(Obsolete since official gameSettings implementation)*
- ~~**Item Duplication:** Splitting stacks results in cloned items.~~ *(Broken)*
- **Free Crafting:** Resources are required but crafting has no cost.
- **Infinite Item Use & No Building Cost:** Resources are required but using and building has no cost.

## Installation

Expand All @@ -36,17 +38,21 @@ If Shroudtopia is loaded you should see something like this in the server consol
[shroudtopia] Wait for server. Configured boot delay is 1000ms.
```

Upon first launch the file ```shroudtopia.json``` is created. By default all mods are deactivated and you have to manually alter the configuration to your likings.
The file can be changed while the server is running and will be reloaded on-the-fly.

## Customization

Each aspect of Shroudtopia is customizable via the `shroudtopia.json` config file. Adjust settings to tailor the mod to your preferred gameplay style:

```json
{
"clone_item_splits": true,
"exp_multiplier": 5,
"free_craft": true,
"active": true,
"boot_delay": 3000,
"bypass_altar_limit": true,
"glider_flight": true,
"no_durability_loss": true,
"infinite_item_use": true,
"no_craft_cost": true,
"no_fall_damage": true,
"no_stamina_loss": true
}
Expand Down
101 changes: 73 additions & 28 deletions shroudtopia/config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <fstream>
#include <filesystem>
#include "pch.h"

#define CONFIG_FILE "shroudtopia.json"
Expand All @@ -9,53 +10,71 @@ using json = nlohmann::json;
class Config
{
public:
Config() {
try {
lastModifiedTime = std::filesystem::last_write_time(CONFIG_FILE);
} catch (std::exception err) { }
}

bool active = true;
int boot_delay = 3000;
int exp_multiplier = 5;
bool glider_flight = true;
bool no_fall_damage = true;
bool no_stamina_loss = true;
bool no_durability_loss = true;
bool clone_item_splits = true;
bool free_craft = true;

bool glider_flight = false;
bool no_stamina_loss = false;
bool no_fall_damage = false;
bool no_craft_cost = false;
bool inf_item_use = false;
bool bypass_world_borders = false;
bool bypass_altar_limit = false;

bool read()
{
std::ifstream configFile(CONFIG_FILE);
if (configFile.is_open())
{
json jConfig;
configFile >> jConfig;
active = jConfig.value("active", true);
boot_delay = jConfig.value("boot_delay", 3000);
exp_multiplier = jConfig.value("exp_multiplier", 5);
glider_flight = jConfig.value("glider_flight", true);
no_fall_damage = jConfig.value("no_fall_damage", true);
no_stamina_loss = jConfig.value("no_stamina_loss", true);
no_durability_loss = jConfig.value("no_durability_loss", true);
clone_item_splits = jConfig.value("clone_item_splits", true);
free_craft = jConfig.value("free_craft", true);
return true;
try {
std::ifstream configFile(CONFIG_FILE);
if (configFile.is_open())
{
json jConfig;
configFile >> jConfig;

active = jConfig.value("active", false);
boot_delay = jConfig.value("boot_delay", 3000);
glider_flight = jConfig.value("glider_flight", false);
no_stamina_loss = jConfig.value("no_stamina_loss", false);
no_fall_damage = jConfig.value("no_fall_damage", false);
no_craft_cost = jConfig.value("no_craft_cost", false);
inf_item_use = jConfig.value("infinite_item_use", false);
bypass_world_borders = jConfig.value("bypass_world_borders", false);
bypass_altar_limit = jConfig.value("bypass_altar_limit", false);

lastModifiedTime = std::filesystem::last_write_time(CONFIG_FILE);
return true;
}
return false;
}
catch (std::exception err) {
return false;
}
return false;
}

std::string dump()
{
json jConfig;
jConfig["exp_multiplier"] = exp_multiplier;
jConfig["active"] = active;
jConfig["boot_delay"] = boot_delay;
jConfig["glider_flight"] = glider_flight;
jConfig["no_fall_damage"] = no_fall_damage;
jConfig["no_stamina_loss"] = no_stamina_loss;
jConfig["no_durability_loss"] = no_durability_loss;
jConfig["clone_item_splits"] = clone_item_splits;
jConfig["free_craft"] = free_craft;
jConfig["no_craft_cost"] = no_craft_cost;
jConfig["infinite_item_use"] = inf_item_use;
jConfig["bypass_world_borders"] = bypass_world_borders;
jConfig["bypass_altar_limit"] = bypass_altar_limit;

return jConfig.dump(4);
}

bool write()
{
std::ofstream configFile("shroudtopia.json");
std::ofstream configFile(CONFIG_FILE);
if (configFile.is_open())
{
// Write pretty-printed JSON to file
Expand All @@ -65,4 +84,30 @@ class Config
}
return false;
}


// Check if the configuration file has changed
bool hasFileChanged()
{
try {
auto currentModifiedTime = std::filesystem::last_write_time(CONFIG_FILE);
return currentModifiedTime != lastModifiedTime;
}
catch (std::exception err) {
return false;
}
}

// Reload configuration if the file has changed
bool reloadIfChanged()
{
if (hasFileChanged())
{
return read(); // Reload the config if changed
}
return false; // No changes detected
}

private:
std::filesystem::file_time_type lastModifiedTime; // To track last modified time
};
Loading

0 comments on commit 377c0fd

Please sign in to comment.