Skip to content

Commit

Permalink
Dont use fm stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Jul 27, 2024
1 parent 4cbf6f5 commit 3ac1527
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 507 deletions.
4 changes: 3 additions & 1 deletion src/network/lan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include "server/serverlist.h"
#include "debug.h"
#include "json/json.h"
#include <mutex>
#include <shared_mutex>
#include "porting.h"
#include "threading/thread.h"
#include "threading/concurrent_map.h"
#include "network/address.h"

//copypaste from ../socket.cpp
Expand Down Expand Up @@ -303,6 +304,7 @@ void *lan_adv::run()
if (p["port"].isInt()) {
p["address"] = addr_str;
auto key = addr_str + ":" + p["port"].asString();
std::unique_lock lock(mutex);
if (p["cmd"].asString() == "shutdown") {
//infostream << "server shutdown " << key << "\n";
collected.erase(key);
Expand Down
7 changes: 5 additions & 2 deletions src/network/lan.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#include "json/json.h"
#include <map>
#include <shared_mutex>
#include <string>
#include <atomic>
#include "threading/thread.h"
#include "threading/concurrent_map.h"


class lan_adv : public Thread
Expand All @@ -37,7 +38,9 @@ class lan_adv : public Thread

void serve(unsigned short port);

concurrent_map<std::string, Json::Value> collected;
std::map<std::string, Json::Value> collected;
std::shared_mutex mutex;

std::atomic_bool fresh;
std::atomic_int clients_num;

Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/l_mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ int ModApiMainMenu::l_get_lan_servers(lua_State *L)
int top = lua_gettop(L);
unsigned int index = 1;

std::shared_lock lock(ServerList::lan_adv_client.mutex);
for (const auto &server : ServerList::lan_adv_client.collected) {
lua_pushnumber(L, index);

Expand Down
209 changes: 0 additions & 209 deletions src/threading/concurrent_map.h

This file was deleted.

131 changes: 0 additions & 131 deletions src/threading/lock.cpp

This file was deleted.

Loading

0 comments on commit 3ac1527

Please sign in to comment.