aboutsummaryrefslogtreecommitdiff
path: root/textures/base/pack/fast_btn.png
blob: 08cb189ea0e6e31756e6ef7f111e17b71593a307 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 40 00 00 00 40 08 06 00 00 00 aa 69 71 .PNG........IHDR...@...@......iq
0020 de 00 00 03 32 49 44 41 54 78 da ed 98 51 88 95 55 10 80 bf d9 ee 6e 6a 4b 45 14 d5 16 95 56 85 ....2IDATx...Q..U.....njKE....V.
0040 04 11 bd 98 0a 16 04 18 28 05 91 40 4f 11 da 4b 10 25 15 90 18 50 40 48 f4 b4 0a 55 18 51 4f 26 ........(..@O..K.%...P@H...U.QO&
0060 d0 4b 89 44 49 11 09 11 59 09 24 0b 06 1b b0 91 22 c4 d6 b6 59 6b ee d7 cb 59 f8 f9 f9 f7 ef de .K.DI...Y.$....."...Yk...Y......
0080 7f 6f 75 ef de f3 c1 be cc 3f 33 7b e6 cc 9c b9 67 0e 64 32 99 4c 26 93 c9 64 32 99 4c 26 93 c9 .ou......?3{....g.d2.L&..d2.L&..
00a0 f4 30 ea a3 ea 57 ea 69 f5 53 75 d3 52 7d c6 bf b8 d8 21 60 3d b0 b2 81 f9 99 88 38 5e f2 f7 1c .0...W.i.Su.R}....!`=......8^...
00c0 f0 52 49 6f 1e d8 1c 11 1f f7 62 b6 36 da 9c 73 ea aa 82 af 51 f5 cf 45 74 4f f4 64 05 00 a8 d7 .RIo......b.6..s....Q..EtO.d....
00e0 01 ad 06 a6 b3 11 71 ba e0 67 1d f0 45 8d fe aa 88 38 bb 9c cf fe b5 35 d5 32 ad 36 4e 64 ab 87 ......q..g..E....8.....5.2.6Nd..
0100 82 bc 13 d8 00 5c 0d fc 0e 4c 02 9f 45 c4 54 44 4c a9 1f 02 9b 2b 4c c7 23 c2 e4 e3 42 60 3b 30 .....\...L..E.TDL....+L.#...B`;0
0120 02 bc 19 11 33 fd 90 dd ad ea 44 4d 86 bf 54 b7 a8 63 ea 91 82 7c 5e 7d 23 05 8d da 52 0f 15 be ....3.....DM..T..c...|^}#...R...
0140 7f d4 eb 81 8f a8 fb 3b 68 8c 9f ab eb d5 0d ea 36 75 6d c9 d7 db 25 fd ef bb da 04 d5 5d c0 1d .......;h.......6um...%......]..
0160 0d 62 3d 0f bc 1c 11 df 14 7c 0d 03 ef 2f 52 d2 b5 cb 00 0e 01 07 81 63 c0 5f c0 bd c0 93 c0 ad .b=......|.../R........c._......
0180 25 bd 87 23 e2 dd 6e f6 80 d1 86 c9 be 00 58 51 92 ed ad 08 fe 13 60 1c 98 00 ae 00 f6 a4 9e 50 %..#..n.......XQ......`........P
01a0 4e d8 d6 f4 57 c7 ee 76 82 ff bf 4a 7f 75 3a bf 45 9e 2a e9 8c a9 b3 0d ee 0f 73 ea 33 bd 7e f6 N...W..v...J.u:.E.*.......s.3.~.
01c0 2f 4d 57 d9 05 9e af d0 79 b5 41 f0 87 d5 db 7b ea 22 54 b3 09 37 00 0f 01 13 11 f1 41 e9 db 4d /MW.....y.A....{."T..7......A..M
01e0 c0 09 60 b8 c2 74 3a d9 dd 08 5c 93 64 27 81 a3 11 31 b9 5c 2e 3d 07 6b b2 bc 73 b9 4f 7b eb 2a ..`..t:...\.d'...1.\.=.k..s.O{.*
0200 fa c3 02 27 d5 91 6e ff cf d6 12 17 7c 71 ea f2 9d f2 5b 44 9c ab 90 bf 58 73 2c 77 47 c4 5c 2f ...'..n.....|q....[D....Xs,wG.\/
0220 65 eb 91 25 4c 7b 13 15 fe 36 d5 e8 1f 4b e3 35 bd 54 01 ef 01 3f 36 b4 3d 55 0a 7e 05 b0 af 46 e..%L{...6...K.5.T...?6.=U.~...F
0240 ff d9 88 98 5f ae e7 3e d4 b7 6a b2 ff 9d da ea e7 00 87 52 79 df 5c f1 ed 72 f5 40 1b 47 e6 5b ...._..>..j........Ry.\..r.@.G.[
0260 f5 ae 7e dd 80 c3 85 40 8e a8 3b d5 c7 d5 7d ea 2f 1d f4 8d f3 ea 2b 69 8e e8 9b e0 d7 74 d8 1c ..~....@..;...}./.....+i.....t..
0280 67 d5 7b d4 07 d5 a3 35 53 e1 58 bf 6c c0 88 3a d9 66 f0 93 e9 e9 ab 68 ff 40 fa fd af fa 55 58 g.{....5S.X.l..:.f.....h.@....UX
02a0 d9 2f 9b 70 a5 ba 57 3d bb 48 e0 53 ea 2e 75 74 11 fb 8b d4 d7 2a ec f6 74 63 7d d1 66 10 f7 03 ./.p..W=.H.S..ut.....*..tc}.f...
02c0 5b 3a f4 3d 03 bc b0 f0 2c a5 5e 02 6c 04 6e 03 86 80 33 c0 d7 c0 f1 88 10 e0 1f d6 b0 0d 38 90 [:.=....,.^.l.n...3...........8.
02e0 6c 01 fe 00 d6 46 c4 0f ff c5 06 3c 0d dc d7 a1 ef 39 60 47 44 fc d4 c5 6a 1a 07 9e 28 88 f6 47 l....F.....<.....9`GD...j...(..G
0300 c4 63 0c 0a 69 94 fe b9 34 ff 5f bf 14 9f 43 fd b4 01 11 31 0d bc 5e 10 0d a7 e7 30 06 a9 0a ae .c..i...4._...C....1..^....0....
0320 2a 35 d4 19 f5 b2 81 a8 80 54 05 a7 80 77 0a a2 51 e0 ee 41 ab 82 35 ea af 85 cb d3 6a 06 0d f5 *5.......T...w..Q..A..5.....j...
0340 16 75 7b 7a 5e cb 64 32 99 4c 26 93 c9 64 32 99 4c 26 93 69 9b bf 01 5c 03 d9 e1 c4 d2 1a 67 00 .u{z^.d2.L&..d2.L&.i...\......g.
0360 00 00 00 49 45 4e 44 ae 42 60 82 ...IEND.B`.
202' href='#n202'>202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
/*
Minetest
Copyright (C) 2010-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 SERVER_HEADER
#define SERVER_HEADER

#include "connection.h"
#include "irr_v3d.h"
#include "map.h"
#include "hud.h"
#include "gamedef.h"
#include "serialization.h" // For SER_FMT_VER_INVALID
#include "mods.h"
#include "inventorymanager.h"
#include "subgame.h"
#include "util/numeric.h"
#include "util/thread.h"
#include "environment.h"
#include "clientiface.h"
#include <string>
#include <list>
#include <map>
#include <vector>

#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"

class IWritableItemDefManager;
class IWritableNodeDefManager;
class IWritableCraftDefManager;
class BanManager;
class EventManager;
class Inventory;
class Player;
class PlayerSAO;
class IRollbackManager;
struct RollbackAction;
class EmergeManager;
class GameScripting;
class ServerEnvironment;
struct SimpleSoundSpec;
class ServerThread;

enum ClientDeletionReason {
	CDR_LEAVE,
	CDR_TIMEOUT,
	CDR_DENY
};

/*
	Some random functions
*/
v3f findSpawnPos(ServerMap &map);

class MapEditEventIgnorer
{
public:
	MapEditEventIgnorer(bool *flag):
		m_flag(flag)
	{
		if(*m_flag == false)
			*m_flag = true;
		else
			m_flag = NULL;
	}

	~MapEditEventIgnorer()
	{
		if(m_flag)
		{
			assert(*m_flag);
			*m_flag = false;
		}
	}

private:
	bool *m_flag;
};

class MapEditEventAreaIgnorer
{
public:
	MapEditEventAreaIgnorer(VoxelArea *ignorevariable, const VoxelArea &a):
		m_ignorevariable(ignorevariable)
	{
		if(m_ignorevariable->getVolume() == 0)
			*m_ignorevariable = a;
		else
			m_ignorevariable = NULL;
	}

	~MapEditEventAreaIgnorer()
	{
		if(m_ignorevariable)
		{
			assert(m_ignorevariable->getVolume() != 0);
			*m_ignorevariable = VoxelArea();
		}
	}

private:
	VoxelArea *m_ignorevariable;
};

struct MediaInfo
{
	std::string path;
	std::string sha1_digest;

	MediaInfo(const std::string &path_="",
	          const std::string &sha1_digest_=""):
		path(path_),
		sha1_digest(sha1_digest_)
	{
	}
};

struct ServerSoundParams
{
	float gain;
	std::string to_player;
	enum Type{
		SSP_LOCAL=0,
		SSP_POSITIONAL=1,
		SSP_OBJECT=2
	} type;
	v3f pos;
	u16 object;
	float max_hear_distance;
	bool loop;

	ServerSoundParams():
		gain(1.0),
		to_player(""),
		type(SSP_LOCAL),
		pos(0,0,0),
		object(0),
		max_hear_distance(32*BS),
		loop(false)
	{}

	v3f getPos(ServerEnvironment *env, bool *pos_exists) const;
};

struct ServerPlayingSound
{
	ServerSoundParams params;
	std::set<u16> clients; // peer ids
};

class Server : public con::PeerHandler, public MapEventReceiver,
		public InventoryManager, public IGameDef
{
public:
	/*
		NOTE: Every public method should be thread-safe
	*/

	Server(
		const std::string &path_world,
		const SubgameSpec &gamespec,
		bool simple_singleplayer_mode,
		bool ipv6
	);
	~Server();
	void start(Address bind_addr);
	void stop();
	// This is mainly a way to pass the time to the server.
	// Actual processing is done in an another thread.
	void step(float dtime);
	// This is run by ServerThread and does the actual processing
	void AsyncRunStep(bool initial_step=false);
	void Receive();
	PlayerSAO* StageTwoClientInit(u16 peer_id);
	void ProcessData(u8 *data, u32 datasize, u16 peer_id);

	// Environment must be locked when called
	void setTimeOfDay(u32 time);

	/*
		Shall be called with the environment locked.
		This is accessed by the map, which is inside the environment,
		so it shouldn't be a problem.
	*/
	void onMapEditEvent(MapEditEvent *event);

	/*
		Shall be called with the environment and the connection locked.
	*/
	Inventory* getInventory(const InventoryLocation &loc);
	void setInventoryModified(const InventoryLocation &loc);

	// Connection must be locked when called
	std::wstring getStatusString();

	// read shutdown state
	inline bool getShutdownRequested()
			{ return m_shutdown_requested; }

	// request server to shutdown
	inline void requestShutdown(void)
			{ m_shutdown_requested = true; }

	// Returns -1 if failed, sound handle on success
	// Envlock
	s32 playSound(const SimpleSoundSpec &spec, const ServerSoundParams &params);
	void stopSound(s32 handle);

	// Envlock
	std::set<std::string> getPlayerEffectivePrivs(const std::string &name);
	bool checkPriv(const std::string &name, const std::string &priv);
	void reportPrivsModified(const std::string &name=""); // ""=all
	void reportInventoryFormspecModified(const std::string &name);

	void setIpBanned(const std::string &ip, const std::string &name);
	void unsetIpBanned(const std::string &ip_or_name);
	std::string getBanDescription(const std::string &ip_or_name);

	void notifyPlayer(const char *name, const std::wstring &msg);
	void notifyPlayers(const std::wstring &msg);
	void spawnParticle(const char *playername,
		v3f pos, v3f velocity, v3f acceleration,
		float expirationtime, float size,
		bool collisiondetection, bool vertical, std::string texture);

	void spawnParticleAll(v3f pos, v3f velocity, v3f acceleration,
		float expirationtime, float size,
		bool collisiondetection, bool vertical, std::string texture);

	u32 addParticleSpawner(const char *playername,
		u16 amount, float spawntime,
		v3f minpos, v3f maxpos,
		v3f minvel, v3f maxvel,
		v3f minacc, v3f maxacc,
		float minexptime, float maxexptime,
		float minsize, float maxsize,
		bool collisiondetection, bool vertical, std::string texture);

	u32 addParticleSpawnerAll(u16 amount, float spawntime,
		v3f minpos, v3f maxpos,
		v3f minvel, v3f maxvel,
		v3f minacc, v3f maxacc,
		float minexptime, float maxexptime,
		float minsize, float maxsize,
		bool collisiondetection, bool vertical, std::string texture);

	void deleteParticleSpawner(const char *playername, u32 id);
	void deleteParticleSpawnerAll(u32 id);

	// Creates or resets inventory
	Inventory* createDetachedInventory(const std::string &name);

	// Envlock and conlock should be locked when using scriptapi
	GameScripting *getScriptIface(){ return m_script; }

	//TODO: determine what (if anything) should be locked to access EmergeManager
	EmergeManager *getEmergeManager(){ return m_emerge; }

	// actions: time-reversed list
	// Return value: success/failure
	bool rollbackRevertActions(const std::list<RollbackAction> &actions,
			std::list<std::string> *log);

	// IGameDef interface
	// Under envlock
	virtual IItemDefManager* getItemDefManager();
	virtual INodeDefManager* getNodeDefManager();
	virtual ICraftDefManager* getCraftDefManager();
	virtual ITextureSource* getTextureSource();
	virtual IShaderSource* getShaderSource();
	virtual u16 allocateUnknownNodeId(const std::string &name);
	virtual ISoundManager* getSoundManager();
	virtual MtEventManager* getEventManager();
	virtual scene::ISceneManager* getSceneManager();
	virtual IRollbackManager *getRollbackManager() { return m_rollback; }


	IWritableItemDefManager* getWritableItemDefManager();
	IWritableNodeDefManager* getWritableNodeDefManager();
	IWritableCraftDefManager* getWritableCraftDefManager();

	const ModSpec* getModSpec(const std::string &modname);
	void getModNames(std::list<std::string> &modlist);
	std::string getBuiltinLuaPath();
	inline std::string getWorldPath()
			{ return m_path_world; }

	inline bool isSingleplayer()
			{ return m_simple_singleplayer_mode; }

	inline void setAsyncFatalError(const std::string &error)
			{ m_async_fatal_error.set(error); }

	bool showFormspec(const char *name, const std::string &formspec, const std::string &formname);
	Map & getMap() { return m_env->getMap(); }
	ServerEnvironment & getEnv() { return *m_env; }
	
	u32 hudAdd(Player *player, HudElement *element);
	bool hudRemove(Player *player, u32 id);
	bool hudChange(Player *player, u32 id, HudElementStat stat, void *value);
	bool hudSetFlags(Player *player, u32 flags, u32 mask);
	bool hudSetHotbarItemcount(Player *player, s32 hotbar_itemcount);
	void hudSetHotbarImage(Player *player, std::string name);
	void hudSetHotbarSelectedImage(Player *player, std::string name);

	inline Address getPeerAddress(u16 peer_id)
			{ return m_con.GetPeerAddress(peer_id); }
			
	bool setLocalPlayerAnimations(Player *player, v2s32 animation_frames[4], f32 frame_speed);
	bool setPlayerEyeOffset(Player *player, v3f first, v3f third);

	bool setSky(Player *player, const video::SColor &bgcolor,
			const std::string &type, const std::vector<std::string> &params);
	
	bool overrideDayNightRatio(Player *player, bool do_override,
			float brightness);

	/* con::PeerHandler implementation. */
	void peerAdded(con::Peer *peer);
	void deletingPeer(con::Peer *peer, bool timeout);

	void DenyAccess(u16 peer_id, const std::wstring &reason);
	bool getClientConInfo(u16 peer_id, con::rtt_stat_type type,float* retval);
	bool getClientInfo(u16 peer_id,ClientState* state, u32* uptime,
			u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch,
			std::string* vers_string);

	// Bind address
	Address m_bind_addr;

private:

	friend class EmergeThread;
	friend class RemoteClient;

	void SendMovement(u16 peer_id);
	void SendHP(u16 peer_id, u8 hp);
	void SendBreath(u16 peer_id, u16 breath);
	void SendAccessDenied(u16 peer_id,const std::wstring &reason);
	void SendDeathscreen(u16 peer_id,bool set_camera_point_target, v3f camera_point_target);
	void SendItemDef(u16 peer_id,IItemDefManager *itemdef, u16 protocol_version);
	void SendNodeDef(u16 peer_id,INodeDefManager *nodedef, u16 protocol_version);

	/* mark blocks not sent for all clients */
	void SetBlocksNotSent(std::map<v3s16, MapBlock *>& block);

	// Envlock and conlock should be locked when calling these
	void SendInventory(u16 peer_id);
	void SendChatMessage(u16 peer_id, const std::wstring &message);
	void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
	void SendPlayerHP(u16 peer_id);
	void SendPlayerBreath(u16 peer_id);
	void SendMovePlayer(u16 peer_id);
	void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
	void SendEyeOffset(u16 peer_id, v3f first, v3f third);
	void SendPlayerPrivileges(u16 peer_id);
	void SendPlayerInventoryFormspec(u16 peer_id);
	void SendShowFormspecMessage(u16 peer_id, const std::string &formspec, const std::string &formname);
	void SendHUDAdd(u16 peer_id, u32 id, HudElement *form);
	void SendHUDRemove(u16 peer_id, u32 id);
	void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);
	void SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask);
	void SendHUDSetParam(u16 peer_id, u16 param, const std::string &value);
	void SendSetSky(u16 peer_id, const video::SColor &bgcolor,
			const std::string &type, const std::vector<std::string> &params);
	void SendOverrideDayNightRatio(u16 peer_id, bool do_override, float ratio);
	
	/*
		Send a node removal/addition event to all clients except ignore_id.
		Additionally, if far_players!=NULL, players further away than
		far_d_nodes are ignored and their peer_ids are added to far_players
	*/
	// Envlock and conlock should be locked when calling these
	void sendRemoveNode(v3s16 p, u16 ignore_id=0,
			std::list<u16> *far_players=NULL, float far_d_nodes=100);
	void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
			std::list<u16> *far_players=NULL, float far_d_nodes=100,
			bool remove_metadata=true);
	void setBlockNotSent(v3s16 p);

	// Environment and Connection must be locked when called
	void SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto_version);

	// Sends blocks to clients (locks env and con on its own)
	void SendBlocks(float dtime);

	void fillMediaCache();
	void sendMediaAnnouncement(u16 peer_id);
	void sendRequestedMedia(u16 peer_id,
			const std::list<std::string> &tosend);

	void sendDetachedInventory(const std::string &name, u16 peer_id);
	void sendDetachedInventories(u16 peer_id);

	// Adds a ParticleSpawner on peer with peer_id (PEER_ID_INEXISTENT == all)
	void SendAddParticleSpawner(u16 peer_id, u16 amount, float spawntime,
		v3f minpos, v3f maxpos,
		v3f minvel, v3f maxvel,
		v3f minacc, v3f maxacc,
		float minexptime, float maxexptime,
		float minsize, float maxsize,
		bool collisiondetection, bool vertical, std::string texture, u32 id);

	void SendDeleteParticleSpawner(u16 peer_id, u32 id);

	// Spawns particle on peer with peer_id (PEER_ID_INEXISTENT == all)
	void SendSpawnParticle(u16 peer_id,
		v3f pos, v3f velocity, v3f acceleration,
		float expirationtime, float size,
		bool collisiondetection, bool vertical, std::string texture);

	/*
		Something random
	*/

	void DiePlayer(u16 peer_id);
	void RespawnPlayer(u16 peer_id);
	void DeleteClient(u16 peer_id, ClientDeletionReason reason);
	void UpdateCrafting(u16 peer_id);