<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://olddev.minetest.org/index.php?action=history&amp;feed=atom&amp;title=Engine%2FStructure</id>
	<title>Engine/Structure - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://olddev.minetest.org/index.php?action=history&amp;feed=atom&amp;title=Engine%2FStructure"/>
	<link rel="alternate" type="text/html" href="https://olddev.minetest.org/index.php?title=Engine/Structure&amp;action=history"/>
	<updated>2026-04-15T07:24:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.7</generator>
	<entry>
		<id>https://olddev.minetest.org/index.php?title=Engine/Structure&amp;diff=29&amp;oldid=prev</id>
		<title>&gt;Rubenwardy: /* General architecture */</title>
		<link rel="alternate" type="text/html" href="https://olddev.minetest.org/index.php?title=Engine/Structure&amp;diff=29&amp;oldid=prev"/>
		<updated>2020-06-20T14:49:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;General architecture&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[File:minetest-0.3-dfd-visio.png|500px|thumb|right|0.3 data flow diagram - still mostly accurate.]]&lt;br /&gt;
== General architecture ==&lt;br /&gt;
&lt;br /&gt;
Minetest consists of 3 main &amp;quot;components&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
* Server - runs server-side logic, updating things for connected players.&lt;br /&gt;
* Client - graphics, controls, and logic for a single player.&lt;br /&gt;
* Mainmenu - The main menu, before joining a game.&lt;br /&gt;
&lt;br /&gt;
Each of these &amp;quot;components&amp;quot; consists of some C++ code and a Lua API for scripting.&lt;br /&gt;
&lt;br /&gt;
When playing a game, there must always be a server. A singleplayer game will consist of a client and a server running in the same process but on different threads.&lt;br /&gt;
A multiple remote game will consist of a client running locally, and a server running remotely.&lt;br /&gt;
&lt;br /&gt;
=== Environment ===&lt;br /&gt;
&lt;br /&gt;
Both the server and the client have an Environment. An environment contains the map, any nodes, players, [[Engine/Objects|objects]], and various other things.&lt;br /&gt;
The environment is &amp;quot;stepped&amp;quot; by an interval called a dtime, updating the world and running Lua callbacks.&lt;br /&gt;
&lt;br /&gt;
The map is a container of MapBlocks. A MapBlock contains 16x16x16 nodes, any  [[Engine/Objects|static objects]], and meta data.&lt;br /&gt;
&lt;br /&gt;
=== Server ===&lt;br /&gt;
&lt;br /&gt;
The Server class is the main class for the server. It hosts the update loop, and owns the lifecycle of all other server components.&lt;br /&gt;
Whilst there will always need to be a main class to host the update loop, this class may be considered a god class as it contains a lot of other responsibility.&lt;br /&gt;
&lt;br /&gt;
In singleplayer or local server mode, the server class is started on a thread&lt;br /&gt;
&lt;br /&gt;
=== Client / MainMenu ===&lt;br /&gt;
&lt;br /&gt;
The ClientLauncher is used to initialise the window, contains the main menu loop, and is used to determine how the client should be launched.&lt;br /&gt;
&lt;br /&gt;
The Game class is the main class for the client. It hosts the clear-draw-display-update loop, and owns the lifecycle of all other client components.&lt;br /&gt;
&lt;br /&gt;
== Threads ==&lt;br /&gt;
&lt;br /&gt;
=== Stand-alone server ===&lt;br /&gt;
* main&lt;br /&gt;
:* Doesn't do much&lt;br /&gt;
* ServerThread (Server)&lt;br /&gt;
:* Runs the server&lt;br /&gt;
* EmergeThread (Server)&lt;br /&gt;
:* Fetches and generates world&lt;br /&gt;
&lt;br /&gt;
=== Client-only ===&lt;br /&gt;
* main&lt;br /&gt;
:* Runs almost everything in main game loop&lt;br /&gt;
* MeshUpdateThread (Client)&lt;br /&gt;
:* Does mesh updates in the background&lt;br /&gt;
&lt;br /&gt;
=== Singleplayer ===&lt;br /&gt;
* main&lt;br /&gt;
:* Runs almost everything except server in main game loop&lt;br /&gt;
* MeshUpdateThread (Client)&lt;br /&gt;
:* Does mesh updates in the background&lt;br /&gt;
* ServerThread (Server)&lt;br /&gt;
:* Runs the server&lt;br /&gt;
* EmergeThread (Server)&lt;br /&gt;
:* Fetches and generates world&lt;br /&gt;
&lt;br /&gt;
== Classes ==&lt;br /&gt;
&lt;br /&gt;
=== IGameDef ===&lt;br /&gt;
An interface for fetching pointers to the managers of things. It is passed to almost everything.&lt;br /&gt;
&lt;br /&gt;
It is implemented by Client and Server. Neither implements all interfaces.&lt;br /&gt;
&lt;br /&gt;
Generally these can be accessed by referring to IGameDef:&lt;br /&gt;
* TextureSource&lt;br /&gt;
* ItemDefManager&lt;br /&gt;
* NodeDefManager&lt;br /&gt;
* SoundManager&lt;br /&gt;
* MtEventManager&lt;br /&gt;
&lt;br /&gt;
This is the main difference between 0.3 and 0.4. In 0.3 this does not exist, because all content is defined in static tables in source code.&lt;br /&gt;
&lt;br /&gt;
gamedef.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== TextureSource ===&lt;br /&gt;
Fetches, generates and caches textures.&lt;br /&gt;
&lt;br /&gt;
tile.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== ItemDefManager ===&lt;br /&gt;
Stores the definitions of items, by item name. Content is set up at server startup, and transferred from server to client at beginning of connection.&lt;br /&gt;
&lt;br /&gt;
itemdef.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== NodeDefManager ===&lt;br /&gt;
Stores the definitions of nodes and the mapping between node ids and names. Content is set up at server startup, and transferred from server to client at beginning of connection.&lt;br /&gt;
&lt;br /&gt;
nodedef.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== SoundManager ===&lt;br /&gt;
Stores and plays sounds on the client.&lt;br /&gt;
&lt;br /&gt;
sound.{h,cpp}; sound_openal.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== MtEventManager ===&lt;br /&gt;
A minimal event manager currently only used for triggering sounds on the client.&lt;br /&gt;
&lt;br /&gt;
event.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== Client ===&lt;br /&gt;
Contains a lot of stuff. Most considerable members are listed here.&lt;br /&gt;
* TextureSource&lt;br /&gt;
* ItemDefManager&lt;br /&gt;
* NodeDefManager&lt;br /&gt;
* SoundManager&lt;br /&gt;
* MtEventManager&lt;br /&gt;
* MeshUpdateThread&lt;br /&gt;
* ClientEnvironment&lt;br /&gt;
:* ClientMap&lt;br /&gt;
:* Players&lt;br /&gt;
:* ClientActiveObjects (CAOs)&lt;br /&gt;
* Connection&lt;br /&gt;
&lt;br /&gt;
Implements IGameDef.&lt;br /&gt;
&lt;br /&gt;
client.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== Server ===&lt;br /&gt;
Contains a lot of stuff. Most considerable members are listed here.&lt;br /&gt;
* ServerEnvironment &lt;br /&gt;
:* ServerMap&lt;br /&gt;
:* Players&lt;br /&gt;
:* ServerActiveObjects (SAOs)&lt;br /&gt;
* Connection&lt;br /&gt;
* BanManager&lt;br /&gt;
* Lua State&lt;br /&gt;
* ItemDefManager&lt;br /&gt;
* NodeDefManager&lt;br /&gt;
* CraftDefManager&lt;br /&gt;
* ServerThread&lt;br /&gt;
* EmergeThread&lt;br /&gt;
&lt;br /&gt;
Implements IGameDef.&lt;br /&gt;
&lt;br /&gt;
server.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== [[Script Engine]] ===&lt;br /&gt;
script/*&lt;br /&gt;
&lt;br /&gt;
The script engine contains &amp;quot;core to script&amp;quot;- as well as &amp;quot;script to core&amp;quot;-interface implementation.&lt;br /&gt;
&lt;br /&gt;
=== Connection ===&lt;br /&gt;
Connection (client-&amp;gt;server or server-&amp;gt;clients)&lt;br /&gt;
&lt;br /&gt;
=== ClientEnvironment (Environment) ===&lt;br /&gt;
Contains most of the actual game environment (players, objects, map...)&lt;br /&gt;
&lt;br /&gt;
* ClientMap&lt;br /&gt;
* Players&lt;br /&gt;
* ClientActiveObjects (CAOs)&lt;br /&gt;
&lt;br /&gt;
environment.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== ServerEnvironment (Environment) ===&lt;br /&gt;
Contains the actual game environment (players, objects, map, time of day, ...)&lt;br /&gt;
&lt;br /&gt;
* ServerMap&lt;br /&gt;
* Players&lt;br /&gt;
* ServerActiveObjects (SAOs)&lt;br /&gt;
&lt;br /&gt;
environment.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== ClientMap (Map) ===&lt;br /&gt;
&lt;br /&gt;
map.{h,cpp}, clientmap.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
=== ServerMap (Map) ===&lt;br /&gt;
&lt;br /&gt;
map.{h,cpp}&lt;br /&gt;
&lt;br /&gt;
[[Category:Core Engine]]&lt;/div&gt;</summary>
		<author><name>&gt;Rubenwardy</name></author>
	</entry>
</feed>