X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserver.cpp;h=75b47e498f50af5ead900118257f10e9236b1172;hb=c5e583e059bc31c0dc57496b23f5c97db1f5a3e3;hp=051ca85fbdff0ab0d85bff72fe873213c0b4d179;hpb=d4d49ee8f4d425e7a4136d65f519728869680951;p=dragonfireclient.git diff --git a/src/server.cpp b/src/server.cpp index 051ca85fb..75b47e498 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mineral.h" #include "config.h" #include "servercommand.h" +#include "filesys.h" #define BLOCK_EMERGE_FLAG_FROMDISK (1<<0) @@ -798,7 +799,7 @@ void RemoteClient::SendObjectData( */ if(stepped_blocks.find(p) == NULL) { - block->stepObjects(dtime, true, server->getDayNightRatio()); + block->stepObjects(dtime, true, server->m_env.getDayNightRatio()); stepped_blocks.insert(p, true); block->setChangedFlag(); } @@ -968,7 +969,6 @@ Server::Server( m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this), m_thread(this), m_emergethread(this), - m_time_of_day(9000), m_time_counter(0), m_time_of_day_send_timer(0), m_uptime(0), @@ -987,10 +987,19 @@ Server::Server( m_con_mutex.Init(); m_step_dtime_mutex.Init(); m_step_dtime = 0.0; - + + // Register us to receive map edit events m_env.getMap().addEventReceiver(this); + // If file exists, load environment metadata + if(fs::PathExists(m_mapsavedir+"/env_meta.txt")) + { + dstream<<"Server: Loading environment metadata"<getName()) + privs = PRIV_ALL; + // Parse commands std::wstring commandprefix = L"/#"; if(message.substr(0, commandprefix.size()) == commandprefix) @@ -2895,12 +2922,6 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) message = message.substr(commandprefix.size()); - // Local player gets all privileges regardless of - // what's set on their account. - u64 privs = player->privs; - if(g_settings.get("name") == player->getName()) - privs = PRIV_ALL; - ServerCommandContext *ctx = new ServerCommandContext( str_split(message, L' '), this, @@ -2916,13 +2937,19 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } else { - line += L"<"; - /*if(is_operator) - line += L"@";*/ - line += name; - line += L"> "; - line += message; - send_to_others = true; + if(privs & PRIV_SHOUT) + { + line += L"<"; + line += name; + line += L"> "; + line += message; + send_to_others = true; + } + else + { + line += L"Server: You are not allowed to shout"; + send_to_sender = true; + } } if(line != L"") @@ -2983,6 +3010,31 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) SendPlayerHP(player); } + else if(command == TOSERVER_PASSWORD) + { + /* + [0] u16 TOSERVER_PASSWORD + [2] u8[28] old password + [30] u8[28] new password + */ + + if(datasize != 2+PASSWORD_SIZE*2) + return; + char password[PASSWORD_SIZE]; + for(u32 i=0; igetPassword(),password)) + { + // Wrong old password supplied!! + SendChatMessage(peer_id, L"Invalid old password supplied. Password NOT changed."); + return; + } + for(u32 i=0; iupdatePassword(password); + SendChatMessage(peer_id, L"Password change successful"); + } else { derr_server<<"WARNING: Server::ProcessData(): Ignoring " @@ -3618,6 +3670,23 @@ void Server::UpdateCrafting(u16 peer_id) } } + // Fence + if(!found) + { + ItemSpec specs[9]; + specs[4] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[5] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[6] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[7] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[8] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[9] = ItemSpec(ITEM_CRAFT, "Stick"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_FENCE, 2)); + found = true; + } + } + // Sign if(!found) { @@ -3994,6 +4063,7 @@ void setCreativeInventory(Player *player) CONTENT_TREE, CONTENT_LEAVES, CONTENT_GLASS, + CONTENT_FENCE, CONTENT_MESE, CONTENT_WATERSOURCE, CONTENT_CLOUD, @@ -4139,6 +4209,9 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id player->updateName(name); player->updatePassword(password); + if(g_settings.exists("default_privs")) + player->privs = g_settings.getU64("default_privs"); + /* Set player position */