mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
working time-of-day sending from server to client
This commit is contained in:
parent
ab7477c4c3
commit
5a36956f75
18
Makefile
18
Makefile
@ -2,18 +2,18 @@
|
|||||||
# It's usually sufficient to change just the target name and source file list
|
# It's usually sufficient to change just the target name and source file list
|
||||||
# and be sure that CXX is set to a valid compiler
|
# and be sure that CXX is set to a valid compiler
|
||||||
TARGET = test
|
TARGET = test
|
||||||
SOURCE_FILES = guiPauseMenu.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp
|
SOURCE_FILES = guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp
|
||||||
SOURCES = $(addprefix src/, $(SOURCE_FILES))
|
SOURCES = $(addprefix src/, $(SOURCE_FILES))
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build/
|
||||||
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))
|
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))
|
||||||
#OBJECTS = $(SOURCES:.cpp=.o)
|
#OBJECTS = $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
FAST_TARGET = fasttest
|
FAST_TARGET = fasttest
|
||||||
|
|
||||||
SERVER_TARGET = server
|
SERVER_TARGET = server
|
||||||
SERVER_SOURCE_FILES = mapnode.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp servermain.cpp test.cpp
|
SERVER_SOURCE_FILES = defaultsettings.cpp mapnode.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp servermain.cpp test.cpp
|
||||||
SERVER_SOURCES = $(addprefix src/, $(SERVER_SOURCE_FILES))
|
SERVER_SOURCES = $(addprefix src/, $(SERVER_SOURCE_FILES))
|
||||||
SERVER_BUILD_DIR = serverbuild
|
SERVER_BUILD_DIR = serverbuild/
|
||||||
SERVER_OBJECTS = $(addprefix $(SERVER_BUILD_DIR)/, $(SERVER_SOURCE_FILES:.cpp=.o))
|
SERVER_OBJECTS = $(addprefix $(SERVER_BUILD_DIR)/, $(SERVER_SOURCE_FILES:.cpp=.o))
|
||||||
#SERVER_OBJECTS = $(SERVER_SOURCES:.cpp=.o)
|
#SERVER_OBJECTS = $(SERVER_SOURCES:.cpp=.o)
|
||||||
|
|
||||||
@ -57,13 +57,13 @@ SERVER_DESTPATH = bin/$(SERVER_TARGET)$(SUF)
|
|||||||
|
|
||||||
# Build commands
|
# Build commands
|
||||||
|
|
||||||
all_linux all_win32: make_build_dir $(DESTPATH)
|
all_linux all_win32: $(BUILD_DIR) $(DESTPATH)
|
||||||
fast_linux: make_build_dir $(FAST_DESTPATH)
|
fast_linux: $(BUILD_DIR) $(FAST_DESTPATH)
|
||||||
server_linux: make_server_build_dir $(SERVER_DESTPATH)
|
server_linux: $(SERVER_BUILD_DIR) $(SERVER_DESTPATH)
|
||||||
|
|
||||||
make_build_dir:
|
$(BUILD_DIR):
|
||||||
mkdir -p $(BUILD_DIR)
|
mkdir -p $(BUILD_DIR)
|
||||||
make_server_build_dir:
|
$(SERVER_BUILD_DIR):
|
||||||
mkdir -p $(SERVER_BUILD_DIR)
|
mkdir -p $(SERVER_BUILD_DIR)
|
||||||
|
|
||||||
$(DESTPATH): $(OBJECTS)
|
$(DESTPATH): $(OBJECTS)
|
||||||
|
@ -60,3 +60,10 @@
|
|||||||
# Note that this gets applied at map generation time
|
# Note that this gets applied at map generation time
|
||||||
#endless_water = true
|
#endless_water = true
|
||||||
|
|
||||||
|
# 20 min/day
|
||||||
|
#time_speed = 72
|
||||||
|
# 1 min/day
|
||||||
|
#time_speed = 1440
|
||||||
|
|
||||||
|
#time_send_interval = 5
|
||||||
|
|
||||||
|
@ -91,10 +91,7 @@ Client::Client(
|
|||||||
m_server_ser_ver(SER_FMT_VER_INVALID),
|
m_server_ser_ver(SER_FMT_VER_INVALID),
|
||||||
m_step_dtime(0.0),
|
m_step_dtime(0.0),
|
||||||
m_inventory_updated(false),
|
m_inventory_updated(false),
|
||||||
m_time(0),
|
m_time_of_day(0)
|
||||||
m_time_counter(0.0)
|
|
||||||
//m_daynight_i(0)
|
|
||||||
//m_daynight_ratio(1000)
|
|
||||||
{
|
{
|
||||||
m_packetcounter_timer = 0.0;
|
m_packetcounter_timer = 0.0;
|
||||||
m_delete_unused_sectors_timer = 0.0;
|
m_delete_unused_sectors_timer = 0.0;
|
||||||
@ -165,48 +162,29 @@ void Client::step(float dtime)
|
|||||||
Day/night
|
Day/night
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
m_time_counter += dtime;
|
s32 d = 8;
|
||||||
int seconds = (int)m_time_counter;
|
s32 t = (((m_time_of_day.get() + 24000/d/2)%24000)/(24000/d));
|
||||||
m_time_counter -= (float)seconds;
|
s32 dn = 0;
|
||||||
m_time += seconds;
|
if(t == d/4 || t == (d-d/4))
|
||||||
if(seconds > 0)
|
dn = 1;
|
||||||
{
|
else if(t < d/4 || t > (d-d/4))
|
||||||
//dstream<<"m_time="<<m_time<<std::endl;
|
dn = 2;
|
||||||
/*JMutexAutoLock envlock(m_env_mutex);
|
else
|
||||||
u32 dr = 500+500*sin((float)((m_time/10)%7)/7.*2.*PI);
|
dn = 0;
|
||||||
if(dr != m_env.getDayNightRatio())
|
|
||||||
{
|
|
||||||
dstream<<"dr="<<dr<<std::endl;
|
|
||||||
m_env.setDayNightRatio(dr);
|
|
||||||
m_env.expireMeshes();
|
|
||||||
}*/
|
|
||||||
#if 1
|
|
||||||
s32 d = 4;
|
|
||||||
s32 t = (m_time/10)%d;
|
|
||||||
s32 dn = 0;
|
|
||||||
if(t == d/2-1 || t == d-1)
|
|
||||||
dn = 1;
|
|
||||||
else if(t < d/2-1)
|
|
||||||
dn = 0;
|
|
||||||
else
|
|
||||||
dn = 2;
|
|
||||||
|
|
||||||
u32 dr = 1000;
|
u32 dr = 1000;
|
||||||
if(dn == 0)
|
if(dn == 0)
|
||||||
dr = 1000;
|
dr = 1000;
|
||||||
if(dn == 1)
|
if(dn == 1)
|
||||||
dr = 600;
|
dr = 600;
|
||||||
if(dn == 2)
|
if(dn == 2)
|
||||||
dr = 300;
|
dr = 300;
|
||||||
#else
|
|
||||||
u32 dr = 1000;
|
if(dr != m_env.getDayNightRatio())
|
||||||
#endif
|
{
|
||||||
if(dr != m_env.getDayNightRatio())
|
//dstream<<"dr="<<dr<<std::endl;
|
||||||
{
|
m_env.setDayNightRatio(dr);
|
||||||
dstream<<"dr="<<dr<<std::endl;
|
m_env.expireMeshes(true);
|
||||||
m_env.setDayNightRatio(dr);
|
|
||||||
m_env.expireMeshes(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,6 +1012,16 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
|||||||
|
|
||||||
} //envlock
|
} //envlock
|
||||||
}
|
}
|
||||||
|
else if(command == TOCLIENT_TIME_OF_DAY)
|
||||||
|
{
|
||||||
|
if(datasize < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
u16 time = readU16(&data[2]);
|
||||||
|
time = time % 24000;
|
||||||
|
m_time_of_day.set(time);
|
||||||
|
//dstream<<"Client: time="<<time<<std::endl;
|
||||||
|
}
|
||||||
// Default to queueing it (for slow commands)
|
// Default to queueing it (for slow commands)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -290,9 +290,8 @@ private:
|
|||||||
|
|
||||||
PacketCounter m_packetcounter;
|
PacketCounter m_packetcounter;
|
||||||
|
|
||||||
// Access these only in main thread.
|
// Received from the server. 0-23999
|
||||||
u32 m_time;
|
MutexedVariable<u32> m_time_of_day;
|
||||||
float m_time_counter;
|
|
||||||
|
|
||||||
// 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
|
// 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
|
||||||
//s32 m_daynight_i;
|
//s32 m_daynight_i;
|
||||||
|
@ -20,6 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef CLIENTSERVER_HEADER
|
#ifndef CLIENTSERVER_HEADER
|
||||||
#define CLIENTSERVER_HEADER
|
#define CLIENTSERVER_HEADER
|
||||||
|
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
#define PROTOCOL_ID 0x4f457403
|
#define PROTOCOL_ID 0x4f457403
|
||||||
|
|
||||||
enum ToClientCommand
|
enum ToClientCommand
|
||||||
@ -90,6 +92,12 @@ enum ToClientCommand
|
|||||||
v3s16 blockpos
|
v3s16 blockpos
|
||||||
block objects
|
block objects
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
TOCLIENT_TIME_OF_DAY = 0x29,
|
||||||
|
/*
|
||||||
|
u16 command
|
||||||
|
u16 time (0-23999)
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ToServerCommand
|
enum ToServerCommand
|
||||||
@ -185,8 +193,13 @@ enum ToServerCommand
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for TOSERVER_GETBLOCK
|
inline SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time)
|
||||||
#define TOSERVER_GETBLOCK_FLAG_OPTIONAL (1<<0)
|
{
|
||||||
|
SharedBuffer<u8> data(2+2);
|
||||||
|
writeU16(&data[0], TOCLIENT_TIME_OF_DAY);
|
||||||
|
writeU16(&data[2], time);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
60
src/defaultsettings.cpp
Normal file
60
src/defaultsettings.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Minetest-c55
|
||||||
|
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
|
extern Settings g_settings;
|
||||||
|
|
||||||
|
void set_default_settings()
|
||||||
|
{
|
||||||
|
// Client stuff
|
||||||
|
g_settings.setDefault("wanted_fps", "30");
|
||||||
|
g_settings.setDefault("fps_max", "60");
|
||||||
|
g_settings.setDefault("viewing_range_nodes_max", "300");
|
||||||
|
g_settings.setDefault("viewing_range_nodes_min", "35");
|
||||||
|
g_settings.setDefault("screenW", "");
|
||||||
|
g_settings.setDefault("screenH", "");
|
||||||
|
g_settings.setDefault("host_game", "");
|
||||||
|
g_settings.setDefault("port", "");
|
||||||
|
g_settings.setDefault("address", "");
|
||||||
|
g_settings.setDefault("name", "");
|
||||||
|
g_settings.setDefault("random_input", "false");
|
||||||
|
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
|
||||||
|
g_settings.setDefault("enable_fog", "true");
|
||||||
|
|
||||||
|
// Server stuff
|
||||||
|
g_settings.setDefault("creative_mode", "false");
|
||||||
|
g_settings.setDefault("heightmap_blocksize", "32");
|
||||||
|
g_settings.setDefault("height_randmax", "constant 50.0");
|
||||||
|
g_settings.setDefault("height_randfactor", "constant 0.6");
|
||||||
|
g_settings.setDefault("height_base", "linear 0 0 0");
|
||||||
|
g_settings.setDefault("plants_amount", "1.0");
|
||||||
|
g_settings.setDefault("ravines_amount", "1.0");
|
||||||
|
g_settings.setDefault("objectdata_interval", "0.2");
|
||||||
|
g_settings.setDefault("active_object_range", "2");
|
||||||
|
g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");
|
||||||
|
g_settings.setDefault("max_simultaneous_block_sends_server_total", "4");
|
||||||
|
g_settings.setDefault("disable_water_climb", "true");
|
||||||
|
g_settings.setDefault("endless_water", "true");
|
||||||
|
g_settings.setDefault("max_block_send_distance", "5");
|
||||||
|
g_settings.setDefault("max_block_generate_distance", "4");
|
||||||
|
g_settings.setDefault("time_send_interval", "20");
|
||||||
|
g_settings.setDefault("time_speed", "144");
|
||||||
|
}
|
||||||
|
|
44
src/main.cpp
44
src/main.cpp
@ -172,10 +172,6 @@ TODO: Check what goes wrong with caching map to disk (Kray)
|
|||||||
|
|
||||||
TODO: Remove LazyMeshUpdater. It is not used as supposed.
|
TODO: Remove LazyMeshUpdater. It is not used as supposed.
|
||||||
|
|
||||||
TODO: Node cracking animation when digging
|
|
||||||
- TODO: A way to generate new textures by combining textures
|
|
||||||
- TODO: Mesh update to fetch cracked faces from the former
|
|
||||||
|
|
||||||
TODO: Add server unused sector deletion settings to settings
|
TODO: Add server unused sector deletion settings to settings
|
||||||
|
|
||||||
TODO: TOSERVER_LEAVE
|
TODO: TOSERVER_LEAVE
|
||||||
@ -183,6 +179,10 @@ TODO: TOSERVER_LEAVE
|
|||||||
Doing now:
|
Doing now:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
TODO: Node cracking animation when digging
|
||||||
|
- TODO: A way to generate new textures by combining textures
|
||||||
|
- TODO: Mesh update to fetch cracked faces from the former
|
||||||
|
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -298,41 +298,7 @@ bool g_viewing_range_all = false;
|
|||||||
|
|
||||||
Settings g_settings;
|
Settings g_settings;
|
||||||
|
|
||||||
// Sets default settings
|
extern void set_default_settings();
|
||||||
void set_default_settings()
|
|
||||||
{
|
|
||||||
// Client stuff
|
|
||||||
g_settings.setDefault("wanted_fps", "30");
|
|
||||||
g_settings.setDefault("fps_max", "60");
|
|
||||||
g_settings.setDefault("viewing_range_nodes_max", "300");
|
|
||||||
g_settings.setDefault("viewing_range_nodes_min", "35");
|
|
||||||
g_settings.setDefault("screenW", "");
|
|
||||||
g_settings.setDefault("screenH", "");
|
|
||||||
g_settings.setDefault("host_game", "");
|
|
||||||
g_settings.setDefault("port", "");
|
|
||||||
g_settings.setDefault("address", "");
|
|
||||||
g_settings.setDefault("name", "");
|
|
||||||
g_settings.setDefault("random_input", "false");
|
|
||||||
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
|
|
||||||
g_settings.setDefault("enable_fog", "true");
|
|
||||||
|
|
||||||
// Server stuff
|
|
||||||
g_settings.setDefault("creative_mode", "false");
|
|
||||||
g_settings.setDefault("heightmap_blocksize", "32");
|
|
||||||
g_settings.setDefault("height_randmax", "constant 50.0");
|
|
||||||
g_settings.setDefault("height_randfactor", "constant 0.6");
|
|
||||||
g_settings.setDefault("height_base", "linear 0 0 0");
|
|
||||||
g_settings.setDefault("plants_amount", "1.0");
|
|
||||||
g_settings.setDefault("ravines_amount", "1.0");
|
|
||||||
g_settings.setDefault("objectdata_interval", "0.2");
|
|
||||||
g_settings.setDefault("active_object_range", "2");
|
|
||||||
g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");
|
|
||||||
g_settings.setDefault("max_simultaneous_block_sends_server_total", "4");
|
|
||||||
g_settings.setDefault("disable_water_climb", "true");
|
|
||||||
g_settings.setDefault("endless_water", "true");
|
|
||||||
g_settings.setDefault("max_block_send_distance", "5");
|
|
||||||
g_settings.setDefault("max_block_generate_distance", "4");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Random stuff
|
Random stuff
|
||||||
|
@ -31,6 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "voxel.h"
|
#include "voxel.h"
|
||||||
|
|
||||||
|
#define BLOCK_EMERGE_FLAG_FROMDISK (1<<0)
|
||||||
|
|
||||||
void * ServerThread::Thread()
|
void * ServerThread::Thread()
|
||||||
{
|
{
|
||||||
ThreadStarted();
|
ThreadStarted();
|
||||||
@ -121,7 +123,7 @@ void * EmergeThread::Thread()
|
|||||||
|
|
||||||
// Check flags
|
// Check flags
|
||||||
u8 flags = i.getNode()->getValue();
|
u8 flags = i.getNode()->getValue();
|
||||||
if((flags & TOSERVER_GETBLOCK_FLAG_OPTIONAL) == false)
|
if((flags & BLOCK_EMERGE_FLAG_FROMDISK) == false)
|
||||||
optional = false;
|
optional = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -541,7 +543,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||||||
|
|
||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
if(generate == false)
|
if(generate == false)
|
||||||
flags |= TOSERVER_GETBLOCK_FLAG_OPTIONAL;
|
flags |= BLOCK_EMERGE_FLAG_FROMDISK;
|
||||||
|
|
||||||
server->m_emerge_queue.addBlock(peer_id, p, flags);
|
server->m_emerge_queue.addBlock(peer_id, p, flags);
|
||||||
server->m_emergethread.trigger();
|
server->m_emergethread.trigger();
|
||||||
@ -757,7 +759,7 @@ void RemoteClient::SendObjectData(
|
|||||||
m_num_blocks_in_emerge_queue.m_value++;*/
|
m_num_blocks_in_emerge_queue.m_value++;*/
|
||||||
|
|
||||||
// Add to queue as an anonymous fetch from disk
|
// Add to queue as an anonymous fetch from disk
|
||||||
u8 flags = TOSERVER_GETBLOCK_FLAG_OPTIONAL;
|
u8 flags = BLOCK_EMERGE_FLAG_FROMDISK;
|
||||||
server->m_emerge_queue.addBlock(0, p, flags);
|
server->m_emerge_queue.addBlock(0, p, flags);
|
||||||
server->m_emergethread.trigger();
|
server->m_emergethread.trigger();
|
||||||
}
|
}
|
||||||
@ -926,7 +928,10 @@ Server::Server(
|
|||||||
m_env(new ServerMap(mapsavedir, hm_params, map_params), dout_server),
|
m_env(new ServerMap(mapsavedir, hm_params, map_params), dout_server),
|
||||||
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
||||||
m_thread(this),
|
m_thread(this),
|
||||||
m_emergethread(this)
|
m_emergethread(this),
|
||||||
|
m_time_of_day(12000),
|
||||||
|
m_time_counter(0),
|
||||||
|
m_time_of_day_send_timer(0)
|
||||||
{
|
{
|
||||||
m_flowwater_timer = 0.0;
|
m_flowwater_timer = 0.0;
|
||||||
m_print_info_timer = 0.0;
|
m_print_info_timer = 0.0;
|
||||||
@ -1026,6 +1031,45 @@ void Server::AsyncRunStep()
|
|||||||
m_step_dtime -= dtime;
|
m_step_dtime -= dtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Update m_time_of_day
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
m_time_counter += dtime;
|
||||||
|
f32 speed = g_settings.getFloat("time_speed") * 24000./(24.*3600);
|
||||||
|
u32 units = (u32)(m_time_counter*speed);
|
||||||
|
m_time_counter -= (f32)units / speed;
|
||||||
|
m_time_of_day.set((m_time_of_day.get() + units) % 24000);
|
||||||
|
|
||||||
|
//dstream<<"Server: m_time_of_day = "<<m_time_of_day.get()<<std::endl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Send to clients at constant intervals
|
||||||
|
*/
|
||||||
|
|
||||||
|
m_time_of_day_send_timer -= dtime;
|
||||||
|
if(m_time_of_day_send_timer < 0.0)
|
||||||
|
{
|
||||||
|
m_time_of_day_send_timer = g_settings.getFloat("time_send_interval");
|
||||||
|
|
||||||
|
//JMutexAutoLock envlock(m_env_mutex);
|
||||||
|
JMutexAutoLock conlock(m_con_mutex);
|
||||||
|
|
||||||
|
for(core::map<u16, RemoteClient*>::Iterator
|
||||||
|
i = m_clients.getIterator();
|
||||||
|
i.atEnd() == false; i++)
|
||||||
|
{
|
||||||
|
RemoteClient *client = i.getNode()->getValue();
|
||||||
|
//Player *player = m_env.getPlayer(client->peer_id);
|
||||||
|
|
||||||
|
SharedBuffer<u8> data = makePacket_TOCLIENT_TIME_OF_DAY(
|
||||||
|
m_time_of_day.get());
|
||||||
|
// Send as reliable
|
||||||
|
m_con.Send(client->peer_id, 0, data, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//dstream<<"Server steps "<<dtime<<std::endl;
|
//dstream<<"Server steps "<<dtime<<std::endl;
|
||||||
|
|
||||||
//dstream<<"Server::AsyncRunStep(): dtime="<<dtime<<std::endl;
|
//dstream<<"Server::AsyncRunStep(): dtime="<<dtime<<std::endl;
|
||||||
@ -1435,6 +1479,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
// Send inventory to player
|
// Send inventory to player
|
||||||
SendInventory(peer->id);
|
SendInventory(peer->id);
|
||||||
|
|
||||||
|
// Send time of day
|
||||||
|
{
|
||||||
|
SharedBuffer<u8> data = makePacket_TOCLIENT_TIME_OF_DAY(
|
||||||
|
m_time_of_day.get());
|
||||||
|
m_con.Send(peer->id, 0, data, true);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
src/server.h
22
src/server.h
@ -265,9 +265,11 @@ public:
|
|||||||
void GetNextBlocks(Server *server, float dtime,
|
void GetNextBlocks(Server *server, float dtime,
|
||||||
core::array<PrioritySortedBlockTransfer> &dest);
|
core::array<PrioritySortedBlockTransfer> &dest);
|
||||||
|
|
||||||
// Connection and environment should be locked when this is called
|
/*
|
||||||
// steps() objects of blocks not found in active_blocks, then
|
Connection and environment should be locked when this is called.
|
||||||
// adds those blocks to active_blocks
|
steps() objects of blocks not found in active_blocks, then
|
||||||
|
adds those blocks to active_blocks
|
||||||
|
*/
|
||||||
void SendObjectData(
|
void SendObjectData(
|
||||||
Server *server,
|
Server *server,
|
||||||
float dtime,
|
float dtime,
|
||||||
@ -281,14 +283,6 @@ public:
|
|||||||
void SetBlockNotSent(v3s16 p);
|
void SetBlockNotSent(v3s16 p);
|
||||||
void SetBlocksNotSent(core::map<v3s16, MapBlock*> &blocks);
|
void SetBlocksNotSent(core::map<v3s16, MapBlock*> &blocks);
|
||||||
|
|
||||||
//void BlockEmerged();
|
|
||||||
|
|
||||||
/*bool IsSendingBlock(v3s16 p)
|
|
||||||
{
|
|
||||||
JMutexAutoLock lock(m_blocks_sending_mutex);
|
|
||||||
return (m_blocks_sending.find(p) != NULL);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
s32 SendingCount()
|
s32 SendingCount()
|
||||||
{
|
{
|
||||||
JMutexAutoLock lock(m_blocks_sending_mutex);
|
JMutexAutoLock lock(m_blocks_sending_mutex);
|
||||||
@ -458,6 +452,12 @@ private:
|
|||||||
// Nodes that are destinations of flowing liquid at the moment
|
// Nodes that are destinations of flowing liquid at the moment
|
||||||
core::map<v3s16, u8> m_flow_active_nodes;
|
core::map<v3s16, u8> m_flow_active_nodes;
|
||||||
|
|
||||||
|
// 0-23999
|
||||||
|
MutexedVariable<u32> m_time_of_day;
|
||||||
|
// Used to buffer dtime for adding to m_time_of_day
|
||||||
|
float m_time_counter;
|
||||||
|
float m_time_of_day_send_timer;
|
||||||
|
|
||||||
friend class EmergeThread;
|
friend class EmergeThread;
|
||||||
friend class RemoteClient;
|
friend class RemoteClient;
|
||||||
};
|
};
|
||||||
|
@ -86,41 +86,7 @@ IrrlichtDevice *g_device = NULL;
|
|||||||
|
|
||||||
Settings g_settings;
|
Settings g_settings;
|
||||||
|
|
||||||
// Sets default settings
|
extern void set_default_settings();
|
||||||
void set_default_settings()
|
|
||||||
{
|
|
||||||
// Client stuff
|
|
||||||
g_settings.setDefault("wanted_fps", "30");
|
|
||||||
g_settings.setDefault("fps_max", "60");
|
|
||||||
g_settings.setDefault("viewing_range_nodes_max", "300");
|
|
||||||
g_settings.setDefault("viewing_range_nodes_min", "35");
|
|
||||||
g_settings.setDefault("screenW", "");
|
|
||||||
g_settings.setDefault("screenH", "");
|
|
||||||
g_settings.setDefault("host_game", "");
|
|
||||||
g_settings.setDefault("port", "");
|
|
||||||
g_settings.setDefault("address", "");
|
|
||||||
g_settings.setDefault("name", "");
|
|
||||||
g_settings.setDefault("random_input", "false");
|
|
||||||
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
|
|
||||||
g_settings.setDefault("enable_fog", "true");
|
|
||||||
|
|
||||||
// Server stuff
|
|
||||||
g_settings.setDefault("creative_mode", "false");
|
|
||||||
g_settings.setDefault("heightmap_blocksize", "32");
|
|
||||||
g_settings.setDefault("height_randmax", "constant 50.0");
|
|
||||||
g_settings.setDefault("height_randfactor", "constant 0.6");
|
|
||||||
g_settings.setDefault("height_base", "linear 0 0 0");
|
|
||||||
g_settings.setDefault("plants_amount", "1.0");
|
|
||||||
g_settings.setDefault("ravines_amount", "1.0");
|
|
||||||
g_settings.setDefault("objectdata_interval", "0.2");
|
|
||||||
g_settings.setDefault("active_object_range", "2");
|
|
||||||
g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");
|
|
||||||
g_settings.setDefault("max_simultaneous_block_sends_server_total", "4");
|
|
||||||
g_settings.setDefault("disable_water_climb", "true");
|
|
||||||
g_settings.setDefault("endless_water", "true");
|
|
||||||
g_settings.setDefault("max_block_send_distance", "5");
|
|
||||||
g_settings.setDefault("max_block_generate_distance", "4");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Debug streams
|
Debug streams
|
||||||
|
Loading…
Reference in New Issue
Block a user