mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
mod_vfs stuff from TurkeyMcMac's PR
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
This commit is contained in:
parent
d8435dcf8d
commit
e4a3b631cf
10 changed files with 119 additions and 67 deletions
|
@ -6,15 +6,19 @@
|
|||
#include "sscsm_requests.h"
|
||||
#include "sscsm_events.h"
|
||||
#include "sscsm_stupid_channel.h"
|
||||
#include "client/mod_vfs.h"
|
||||
|
||||
|
||||
SSCSMEnvironment::SSCSMEnvironment(std::shared_ptr<StupidChannel> channel) :
|
||||
Thread("SSCSMEnvironment-thread"),
|
||||
m_channel(std::move(channel)),
|
||||
m_script(std::make_unique<SSCSMScripting>(this))
|
||||
m_script(std::make_unique<SSCSMScripting>(this)),
|
||||
m_vfs(std::make_unique<ModVFS>())
|
||||
{
|
||||
}
|
||||
|
||||
SSCSMEnvironment::~SSCSMEnvironment() = default;
|
||||
|
||||
void *SSCSMEnvironment::run()
|
||||
{
|
||||
while (true) {
|
||||
|
@ -44,14 +48,14 @@ SerializedSSCSMAnswer SSCSMEnvironment::exchange(SerializedSSCSMRequest req)
|
|||
void SSCSMEnvironment::updateVFSFiles(std::vector<std::pair<std::string, std::string>> &&files)
|
||||
{
|
||||
for (auto &&p : files) {
|
||||
m_vfs.emplace(std::move(p.first), std::move(p.second));
|
||||
m_vfs->m_vfs.emplace(std::move(p.first), std::move(p.second));
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string_view> SSCSMEnvironment::readVFSFile(const std::string &path)
|
||||
{
|
||||
auto it = m_vfs.find(path);
|
||||
if (it == m_vfs.end())
|
||||
auto it = m_vfs->m_vfs.find(path);
|
||||
if (it == m_vfs->m_vfs.end())
|
||||
return std::nullopt;
|
||||
else
|
||||
return it->second;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue