aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_env.h
blob: 51cf15036e450b44e3676eacbccd89743fb3941a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Minetest
Copyright (C) 2013 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 Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser 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.
*/

#ifndef S_ENV_H_
#define S_ENV_H_

#include "cpp_api/s_base.h"
#include "irr_v3d.h"

class ServerEnvironment;
struct MapgenParams;

class ScriptApiEnv
		: virtual public ScriptApiBase
{
public:
	// On environment step
	void environment_Step(float dtime);
	// After generating a piece of map
	void environment_OnGenerated(v3s16 minp, v3s16 maxp,u32 blockseed);
	// After initializing mapgens
	void environment_OnMapgenInit(MapgenParams *mgparams);

	void initializeEnvironment(ServerEnvironment *env);
};

#endif /* S_ENV_H_ */
y allocates the space for the data in the heap. Fix the performance hit by converting all of these value passed parameters to const references. I believe that this is what the author of the relevant code actually intended to do as there is a couple of packet construction helper functions that already use a const reference to get the raw data. * Optimize packet sender thread class Most of the data sending methods of the packet sender thread class use a value passed parameter for the packet data to be sent. This causes the rather bulky data to be allocated on the heap and copied, slowing the packet sending down. Convert these parameters to const references to avoid the performance hit. * Optimize packet receiver thread class The packet receiver and processor thread class has many methods (mostly packet handlers) that receive the packed data by value. This causes a performance hit that is actually worse than the one caused by the packet sender methods because the packet is first handed to the processPacket method which looks at the packet type stored in the header and then delegates the actual handling to one of the handlers. Both, processPacket and all the handlers get the packet data by value, leading to at least two unnecessary copies of the data (with malloc and all the slow bells and whistles of bulky classes). As there already is a few methods that use a const reference parameter for the packet data, convert all this value passed packets to const references. * Revert RTT fixes (#8187)ANAND2019-02-15 | | | | | The reverted commit 968ce9af598024ec71e9ffb2d15c3997a13ad754 is suspected (through the use of bisection) of causing network slowdowns. Revert for now as we are close to release. * Remove legacy client handling code.Lars Hofhansl2018-07-14 | * RTT fixes (#7428)you2018-06-23 | | | | | | | | | | | | * Few code updates * Do not show average RTT before timing out * Fix unwanted integer division in RTTStatistics * Fix float format, prettier jitter calculation * Use +=, 0.1f -> 100.0f for stronger average updates * Add session_t typedef + remove unused functions (#6470)Loïc Blot2017-09-27 | | | | | | * Add session_t typedef + remove unused functions u16 peer_id is used everywhere, to be more consistent and permit some evolutions on this type in the future (i'm working on a PoC), uniformize u16 peer_id to SessionId peer_id * Use a Buffer instead of SharedBuffer in ConnectionCommandLoic Blot2017-09-05 | | | | This fixes #6373 * Re-apply previous commit with a typo fixLoïc Blot2017-09-04 | * Revert "Network: fix a concurrency problem, by re-adding a copy in ↵Loïc Blot2017-09-04 | | | | | | ConnectionCommand" This reverts commit 5b04f5e7d231437b534f4cad39da78624d97c584. * Network: fix a concurrency problem, by re-adding a copy in ConnectionCommandLoïc Blot2017-09-04 | * Network part requires SharedBuffers to be pass as valueLoic Blot2017-09-03 | | | | | | This can trigger unreproductible crashes due to concurrency problem on SharedBuffers This fixes #6354 * Network cleanup (#6310)Loïc Blot2017-08-25 | | | | | | | | | | | | | | * Move Connection threads to dedicated files + various cleanups * ConnectionReceiveThread::processPacket now uses function pointer table to route MT packet types * Various code style fixes * Code style with clang-format * Various SharedBuffer copy removal * SharedBuffer cannot be copied anymore using Buffer * Fix many SharedBuffer copy (thanks to delete operator) * Network cleanup (#6302)Loïc Blot2017-08-24 | | | | | | | | | | | | | | | | | | | | | | | * Cleanup network headers * Move peerhandler to a specific header to reduce compilation times * Move socket.cpp/h to network folder * More work * Network code cleanups * Move socket.{cpp,h} to network folder * Move Address object to network/address.{cpp,h} * Move network exceptions to network/networkexceptions.h * Client: use unique_ptr for Connection * Server/ClientIface: use shared_ptr for Connection * Format fixes * Remove socket.cpp socket.h from clang-format whitelist * Also fix NetworkPacket code style & make it under clang-format * Modernize source code: last part (#6285)Loïc Blot2017-08-20 | | | | | | | | | | | * Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes * Code modernization: subfolders (#6283)Loïc Blot2017-08-19 | | | | | | | | | | | | | * Code modernization: subfolders Modernize various code on subfolders client, network, script, threading, unittests, util * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Make connection.cpp readable in a pointed place + typo * C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17 | | | | * Migrate cpp headers to pragma once * Cleanup various headers to reduce compilation times (#6255)Loïc Blot2017-08-16 | | | | * Cleanup various headers to reduce compilation times * server.cpp: code modernizationLoic Blot2017-08-15 | | | | | | | * Use more for range based loops * Simplify some tests * Code style fixes * connection.h: better PeerChange constructor instead of creating uninitalized object and then affect variables * C++11 cleanup on constructors dir network (#6021)Vincent Glize2017-06-21 | | | | * C++11 cleanup on constructors dir network * Use C++11 mutexes only (remove compat code) (#5922)Loïc Blot2017-06-06 | | | | * Fix event LINT & remove default constructor/destructors * remove compat code & modernize autolock header *